Jump to content
  • Advertisement
Sign in to follow this  

Doing Reflection Transformation

This topic is 2896 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

After a quick skim on the internet, I can't seem to find enough info on how about going to get the reflection transformation of an object reflected in its own axis.
Does anyone have any info? Or Tips for me please
The story is I have an object placed in the scene, but its facing the wrong direction in the Y axis (up axis). 180 degrees
Yes, forget to say, direct3d API that is
I have checked D3DXMatrixReflect, but it is reflecting against a plane? Not sure how it works
I have also tried D3DXMatrixRotationY to no avail...

Share this post

Link to post
Share on other sites
If I have understood you correctly, you just want to flip the object vertically...Try D3DXMatrixRotationX or D3DXMatrixRotationZ.

Share this post

Link to post
Share on other sites
Yes, I want to flip it. But i have tried D3DXMatrixRotationX/Z, but it results the same. Do those functions flip the object in their own axis or around the origin?

D3DXMATRIX matr[4];
matr = m_TruckPos.mat;
D3DXMatrixRotationZ(&matr, 1.57f);
pos.x = matr._41;
pos.y = matr._43;
pos.z = matr._42;

Another Problem I am having is the Vector "pos" is cleared to 0,0,0 after the operation
Thanks Jack

Share this post

Link to post
Share on other sites
D3DXMatrixRotation builds a matrix that rotates around axis, so last row has nothing to with rotation and thats why you see 0's.
First you want to make sure that your "object" is centered at origin, do this in modeling editor.
Then apply rotation and after that apply translation:

D3DXMATRIX rotationMatrix;
D3DXMATRIX translationMatrix;
D3DXMATRIX finalTransformationMatrix;

//apply rotation
D3DXMatrixRotation...(&rotationMatrix) <-- here use rotation functions

//apply translation
D3DXMatrixTranslation...(&translationMatrix) <--here use translation functions

finalTransformationMatrix = rotationMatrix * translationMatrix;

device->SetTransform(D3DTS_WORLD, &finalTransformationMatrix);

Optionaly if you want to add scaling you must multiply matrices in this order:

finalTransform = rotation * scale * translation;

Share this post

Link to post
Share on other sites
Thanks belfegor! I'll give it a try!
I have another question. How do I convert an angle in radians (for rotation about its own axis) into a vector?
D3DXMatrixRotationZ works, but its rotation around the origin not around an arbitary axis...
Thanks a lot

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!