PDA

View Full Version : Simple vehicle physics



Firefly
09-24-2012, 04:57 PM
Hi there everybody, long time, first time here with a simple query.
I recently started coding in OpenGL and have started a project which will eventually be a vertical shooter style game. My question is this:
How would I make a simple car move like a simple car in OpenGL?

I have the mesh drawn fine, I gave it a simple place holder texture, and I can move it left and right using SDL key commands. However, this does not produce a realistic effect. I get the feeling I would need to do something like find the normal of the car's position, and have that as the forward vector while using Left and Right to change the rotation of the tires, but I'm completely lost on how to do that.

Unfortunately I really don't have any code to show you, because I don't even know where to start with this.

I've tried looking up the problem elsewhere, but all I've managed to derive from my search is the fact that I need to draw the wheels separately, but how would I do that and keep them connected to the car mesh?
And more importantly, how do I make the car move realistically?

Thanks for any help any one can give me, it is greatly appreciated. If there's anything I can do to hasten the production of my simple physics, just let me know!
Thanks again

Firefly
09-25-2012, 06:23 AM
Anybody? I've started to think about it, and I'm thinking maybe I was wrong about the normals thing.
Seems like it would make more sense to implement a turning radius, but I really have no idea how to go about this. Anyone done anything similar to this before?

mhagain
09-25-2012, 08:20 AM
This kind of question is well outside the scope of what OpenGL is for. OpenGL is just a graphics library and is for rendering things; any kind of movement physics don't even come into it. You're probably better off asking on a more general game development site - but leave out the "move in OpenGL" part, because OpenGL has nothing to do with that.

Firefly
09-25-2012, 09:52 AM
Ah my bad, I've been asking about the physics on another site so that just came out naturally. What I meant was;

How would I draw and rotate the wheels separately from the car while keeping them all together when the car moves? Currently I'm just drawing a car mesh with the wheels attached, but that doesn't give the effect I'd hoped for.

Also, this may be a long shot, but would anyone happen to know how to turn the wheels on their own without moving the entire car?

Thanks again

Carmine
09-25-2012, 04:47 PM
This sounds like a homework assignment designed to make you familiar with Push and PopMatrix.

Read the documentation on glPushMatrix and glPopMatrix, and look at some examples.

It is very easy to make the wheels turn and steer independently of the car,
AND have them move with the car.

Have fun.