• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Bretttido

Rolling Ball

6 posts in this topic

I''m trying to create a ball that can roll along the ground in any direction, and whose path can change. For it''s rotation to look correct, i need some knowledge of it''s current rotation and how to update it through each frame. Anyone have any ideas of how I might go about storing and updating this information? (I''m a bit weak on my linear algebra)
0

Share this post


Link to post
Share on other sites
Try this:


void rotate_ball(float x, float y, float z)
{
glPushMatrix();

glRotatef(x, y, z);

draw_ball(); //Or whatever your ball drawing code is

glPopMatrix():

}

Then call rotate_ball() and replace x, y and z with the rotation values.
0

Share this post


Link to post
Share on other sites
...except that those aren''t the parameters to glRotatef().

You''ll want to get a vector normal to your direction of travel to rotate the ball about - unless the ball can slip on the ground.

In the simplest case you can rotate the ball depending on how far it has moved since the last frame, about your vector normal to the direction it has travelled in.
0

Share this post


Link to post
Share on other sites
You also have to make sure that it seems like the rotation of the ball is synchronized with it's movement. After rotating 360º, the ball will be 2 * r * pi. Therefore, after x degrees of rotation, the ball should move: (r = radius)

x * 2 * r * pi
--------------
360

You could have the ball rotate at a certain number of degrees per second or per frame. If it were per frame, you could do something like this (assuming the ball was rolling down the x-axis):

      
void MoveBall(float degrees)
{
ball_angle += degrees;

/* check to see if ball_angle is over 360 degrees */

// move the ball

ball_pos += (degrees * 2 * ball_radius * PI) / 360;

glPushMatrix();
glTranslatef(ball_pos, 0.0f, 0.0f);
glRotatef(ball_angle, 0.0f, 0.0f, -1.0f);
DrawBall();
glPopMatrix();
}


The variable names should be pretty self explanatory.


Edited by - masonium on October 18, 2001 10:53:25 PM

Edited by - masonium on October 23, 2001 8:24:19 PM
0

Share this post


Link to post
Share on other sites
Naive, newbie comment:

Would it be simpler to leave the vertex''s where they are and just adjust the texture coords of the verts to match the rotation that should have occured?
0

Share this post


Link to post
Share on other sites
You don't really have to adjust the vertices manually if you're drawing a sphere through your own function or glutSolidSphere or something. glRotatef rotates the vertices for you.

Edited by - masonium on October 23, 2001 8:23:40 PM
0

Share this post


Link to post
Share on other sites
Peeper: calling glRotatef doesn''t actually rotate the vertices. It updates the modelview matrix. The original vertices stay the same. During rendering, all vertices get multiplied by the matrix anyway, so apart from the one call to glRotatef, rotation really is free.
0

Share this post


Link to post
Share on other sites