Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Simple vehicle physics

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    3

    Simple vehicle physics

    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

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    3
    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?

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,180
    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.

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    3
    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

  5. #5
    Junior Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    173
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •