Public Group

# DirectX Transformations

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

## Recommended Posts

Yes, I know what you're thinking- "another damned newbie who doesn't get matrices", and you'd be right. Its not so much the process of creating them etc, its the actual use on individual objects. I know how to use the device.Transform.World property (I use MDX, but from what I can tell, this is the same in both), but its how you can use that to move individual items. I mean, isn't this property always going to act on the same single device, and therefore transform everything in the world? Clearly there's something I'm missing out on here, so any help would be appreciated.

##### Share on other sites
Well, dude I was once in your shoes a long time ago. If you take a look here you’ll find some usefull information about matrices and Direct3D.

A matrix is like a vector. Except is an array of vectors. Commonly used in today’s 3D applications are 3x3, 3x4 or 4x4 matrices. The device (IDirect3DDevice) uses matrices for view projections and other things. When you change the matrix on the device (i.e. IDirect3DDevice9::SetTransform( )) you affect all geometry that uses those matrices. For example, if you change the world matrix the world will take changes specified by the matrix. That is, rotation, translation scaling. You can also use these matrices on other objects to take the same effect. But remover, that the matrices that specified the world, view and projection for a device also effect the given object’s matrices applied to it. In other words, they are multiplied so-to-speak.

So in you world, a common world matrix is called the identity matrix. All it’s values are 1, hence the name. Then you multiply something with this matrix you get the same result, no changes (i.e. identity). So not, take for example that you have a world matrix that rotates around the Y axis by 45*. Your object also has a similar object that rotates around the Y axis by 45*. When the object is actually rendered it will have been rotated 90*, getting the picture?

Please note that most Direct3D matrix functions use Radians and not Degrees. There is a function called D3DXToRadian() that takes the degree a converts it to the proper radian. This can be useful for beginners because degrees some times make more since and are easier to understand.

I hope this helps!

##### Share on other sites
You set the World property on the DirectX device to a different value before rendering each "object".

If you set the World property once & then rendered everything you are correct - everything would render the same. But by changing this property for each object you render they are all uniquely translated/scaled/rotated.

##### Share on other sites
transformation don't change the world. if used in the correct order , they decide
where every model is going to be drawn and that makes every movement independent
from the other.

##### Share on other sites
Ah, thats great guys. I suspected that was the way it worked, but my code was showing otherwise. As it turned out my camera class had device.Transform.World instead of device.Transform.View. That old chestnut. Rather annoyingly, it was causing the view to update exactly as I was hoping, and now that I've "fixed" it, theres a whole lot more work to do.

One more question: device.Transform.Translation claims to move the focus (for want of the correct term) by a the amount provided in the parameters, ie translate (10, 3, -4), so I would have expected to have to manually reset this to the origin after each move in preparation for the next, but a small test I set up showed that this always seems to move from the origin.

Don't get me wrong, this is a much better approach, but the commenting for the method seemed to indicate that this was an offset from the last held value- and there's another question: since World is a property of Transform (in MDX anyway), when is it reset to 0?

##### Share on other sites
you need to clear the matrix after you are done transforming. i use D3DXMatrixIdentity which resets the matrix back. look
for it's eqavilant in MDX, and use that after each transformation.

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 104
• 11
• ### Forum Statistics

• Total Topics
632977
• Total Posts
3009676
• ### Who's Online (See full list)

There are no registered users currently online

×