Jump to content
  • Advertisement

Archived

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

UStink2Me

Odjects/Entities and Transformations

This topic is 6837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yeah. In general, you center the object on the origin (so for example a pyramid would have vertices at <1,0,1>, <-1,0,1>, <1,0,-1, -1,0,-1>, <0,1,0>). These are said to be in "model coordinates". You then need some information to describe this object's position and orientation in "world coordinates". For an object that doesn't move with respect to the 3d world, you could save this information in a D3DMATRIX. For one that does move, you could save this information in two D3DVECTORS Pos and Orient. Pos is the position and Orient is the orientation (the x,y,z components of Orient would actually be the heading, pitch, and roll). There are probably a ton of other ways to save this information--I find this way easier to manipulate the moving objects. Anyway with the D3DVECTORS, for each frame you'd compute a D3DMATRIX M corresponding to them and, right before you render the object, do a SetTransform(D3DTRANSFORMSTATE_WORLD, &M);.
There are quite a few optimizations you can add to this, but this is the basic idea.
Hope this helps. There are quite a few good tutorials and docs on this stuff, off the top of my head do a search for Pipeline in the DirectX SDK docs. I'm assuming you're looking at Direct3D but the same concepts hold true for other 3d systems. Just in case you're not using Direct3D, a D3DMATRIX is a 4x4 matrix and a D3DVECTOR has 3 floats, x y and z.
-ns

Share this post


Link to post
Share on other sites
Advertisement
How do 3D engines deal with objects/ entities (i.e. monsters, crates, etc.)? Since objects/entities need to maintain their own origins (is this right?) for rotations and animations, does this mean that each objcet/entity will have to have its own transformation matrix associated with it? And if so, what type of data structure would you suggest using to store this information?
I hope I'm not way off base with this question. I am fairly new to all of this and am just trying to grasp some of the concepts.

Thanx

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!