Original Post
I am trying to get 3D objects to move and interact with each other. They will collide and move in other directions when such a collusion occurs. How would I go about doing this?
class Vector3
{
public:
Vector3() { x = y = z = 0.0f; }
float x;
float y;
float z;
};
//Push an identity matrix to the stack
//(any glTranslate operation you do operates on the current matrix - you'll need a blank slate to work with. Look up 'world space' and 'object space' to see what we're doing here)
glPushMatrix();
//Apply the desired translation
glTranslatef(myVector.x, myVector.y, myVector.z);
//Render your object, as you're already doing
//Pop the matrix stack
glPopMatrix();
do u think this will be a very hard task for someone who has only really read up on basic stuff on openGL? (such as just chapters 1-3 on the redbook, and just nehe lessons 1-5)?[/quote]
The things you're asking about actually have very little to do with OpenGL specifically, so the Red Book won't help you much here. I think the NeHe tutorials include some examples of moving about and so forth, but I'm not sure if they cover the kinds of things you're asking about. (You could always skim through the tutorial descriptions and see though.)
The assignment you've been given sounds a little involved to me (especially if you don't already have a background in the required subjects), but what I'd recommend is to break it down and tackle one problem at a time.
For example, a good first step might be just to get the movement part working, without worrying about the terrain or the collision detection. Just getting the ball moving continually in a forward direction and turning left or right in response to user input will be a good step towards finishing the assignment. (deadstar laid out the basics of how to do this above.)
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more