Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

World positions

Started by jaytee81 Apr 3, 2007 at 3:47 PM 2 replies 950+ views
Original Post
jaytee81
jaytee81
I'm loading some cube models in via .x files and they are set up with a local coordinate position. When displaying the model in the world I apply a D3DTS_WORLD transform which is made up of a translation and rotation matrix. What I'd like to do is maintain the cube's local coords but also store the resulting position vector of applying the world transform. Any ideas how I might be able to get this vector after applying my world transform. Thanks
Palidine
Palidine
well.. you could just transform the vector (0,0,0) by the object's world transform and you'd get it's world coordinates. But don't you have that anyway? Otherwise how are you constructing the world transform for the object?

-me
jaytee81
jaytee81
Sorry I should have mentioned that the cubes are part of a tetris shape. so the way I have done it is to give each cube of the whole block a position vector relative to the others, so one block may be (-1, 0, 0) for example. Each cube is then displayed in the world based on the whole tetris block's position vector and rotation. So the D3DTS_WORLD transform for each cube is based on creating translation and rotation matrices from the Block's position and rotation vectors and multiplying them to create the world transform. So in essence each cube only contains a position vector that tells us where it is relative to the others in the block and this doesn't change, so what I wanted to do was also get the position it gets displyed in in the world. Hope that explains a little better. Thanks again.
jaafit
jaafit
Quote:
the D3DTS_WORLD transform for each cube is based on creating translation and rotation matrices from the Block's position and rotation vectors and multiplying them to create the world transform.

There must be another step in there where you account for the cube's relative-to-block position. Otherwise you'd display each cube in the same world location.

Like Palidine says, if you are able to display these cubes in the correct positions then you already have everything you need and it's just a matter of caching the values.

Quote:
each cube only contains a position vector

So make each cube also contain is world position vector after multiplying (0,0,0) by the world transform.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.