Doing Reflection Transformation

Started by
3 comments, last by lucky6969b 13 years, 3 months ago
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...
Thanks
Jack
Advertisement
If I have understood you correctly, you just want to flip the object vertically...Try D3DXMatrixRotationX or D3DXMatrixRotationZ.
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
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

//combine
finalTransformationMatrix = rotationMatrix * translationMatrix;

device->SetTransform(D3DTS_WORLD, &finalTransformationMatrix);
DrawObject();

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

finalTransform = rotation * scale * translation;
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
Jack

This topic is closed to new replies.

Advertisement