I am in the process of learning about 3D graphics programming and digging into the Ogre Rendering Engine/API. I am wanting to take a model of a football player and have him move down a football field. Most football players run 40 yds in a certain amount of time 4.3 seconds for example. Many of you know this already.
My question is this. Where do I need to start and what do I need to research to begin to represent this in a program? I know I would create a model and add it as a sceneNode to a sceneGraph and that I can add an animation to the sceneNode. But, how do I control the rate of speed and make it look like the model is running down field like a player IRL would?
I'm not necessarily looking for someone to give me a spoon fed answer. I'm looking for at minimum a place to start.
3D programming question
Moderator: Coders of Rage
-
- Chaos Rift Junior
- Posts: 200
- Joined: Mon Feb 22, 2010 12:32 am
- Current Project: Breakout clone, Unnamed 2D RPG
- Favorite Gaming Platforms: PC, XBOX360
- Programming Language of Choice: C#
- Location: San Antonio,Texas
- Contact:
-
- Respected Programmer
- Posts: 387
- Joined: Fri Dec 19, 2008 3:33 pm
- Location: Dallas
- Contact:
Re: 3D programming question
Can't say 100% with Ogre, but if there's a physics entity attached to the player you should be able to add a "constant impulse" in "KMS" units. KMS is the scientific standard "Kilograms, meters, seconds" unit of measure that most API's default to. A constant impulse is just one that acts on the player without decay. I'm presuming you can do dimensional analysis to do any conversion.
If there is no physics entity, you can emulate this in the rendering by simple translation. A translation is a linear movement in some direction defined by some vector. The vector length becomes the speed of the player as per your physics studies. Its likely that there is some facility that will allow you to set a transform for the object and apply it. "TranslateObject", "SetPose", "SetMatrix"....something like this. It's most likely attached to the sceneNode object. You may have to multiply inherit from some other model object class if it is not present there. Just dig into the docs for that.
If there is no physics entity, you can emulate this in the rendering by simple translation. A translation is a linear movement in some direction defined by some vector. The vector length becomes the speed of the player as per your physics studies. Its likely that there is some facility that will allow you to set a transform for the object and apply it. "TranslateObject", "SetPose", "SetMatrix"....something like this. It's most likely attached to the sceneNode object. You may have to multiply inherit from some other model object class if it is not present there. Just dig into the docs for that.
-
- Chaos Rift Junior
- Posts: 200
- Joined: Mon Feb 22, 2010 12:32 am
- Current Project: Breakout clone, Unnamed 2D RPG
- Favorite Gaming Platforms: PC, XBOX360
- Programming Language of Choice: C#
- Location: San Antonio,Texas
- Contact:
Re: 3D programming question
thanks for the response. It at least gives me something a starting place. Ogre doesn't have physics built in but there are ways that you can connect it to Bullet physics. I would just need to figure out if I can do this in the Physics side or if I would have to pass something from the physics to the Ogre code.
-
- Respected Programmer
- Posts: 387
- Joined: Fri Dec 19, 2008 3:33 pm
- Location: Dallas
- Contact:
Re: 3D programming question
You can do this in physics by adding some constant impulse to the player. This says "Some force is acting on the player thusly and does not decay" (like gravity, which is growth, not decay...and is quadratic). The phsyics simulation is updated via a "time step". You provide physics with the average running rate of change of time per frame and it will update the physics simulation accordingly. Based on all applied impulses to the "actors" in the "scene" it will generate a new representation of the scene. Before rendering, you query the player "pose" (reaction matrix) based on this simulation and apply it to the rendering. In this way the physics API is completely in charge of the rigid body transformation.