Re: Game Technologies: Graphics Rotating points in 3D
saliksyed
I'm not sure if this is helpful specifically to DirectX but I can give you a general overview on transforming points in 3d, and on rendering 3d points on to a 2d plane.
In 3d space you have the 3 standard basis vectors e1 e2 and e3, one is pointing in positive x dir (length 1) the other in y, the next in z.
So we have:
e1 = (1,0,0) e2 = (0,1,0) and e3= (0,0,1)
Now if you want to rotate a vector by n degrees on some axis.
simply rotate e1 , e2, and e3 by n degrees on that axis , the new values for e1, e2 and e3 will be the columns of your transform matrix.
For example if we rotate e1(the x Axis) 90 degrees about the z Axis in the negative x direction
the new vector will obviously be pointing towards the y Axis
so the transformed vector is : (0 1 0)
now rotate e2 and we get (-1, 0, 0)
rotating e3 about the z axis gives no change
so t(e3) = (0,0,1)
from this we make our transform matrix:
0 -1 0
1 0 0
0 0 1
that's all there is to it,
if you use angles other than 90 you might need to figure out the components of the vector using simple trig but other than that it's easy
Projecting points on to a plane is a bit tricky to explain
To find the Y coordinate:
You calculate the distance of the object (point) from you in the xy plane:
dist = sqrt((myX-objX)^2 + (myY-objY)^2)
you can then find the Y coordinate using this inequality:
(ObjZ-MyZ)/dist = (screenY) / focalLength
You choose an arbitrary focal Length (this will determine how skewed the image is!)
Finding X coordinate is done in much the same way:
(ObjY-MyY)/(ObjX-MyX) = otherFocalLength/(screenX)
MyX, Y, Z are your camera coordinates, you might have to play around with the camera position and focalLengths to get it to look perfect.
All you are really doing is using properties of similar triangles
I dunno if that helps you at all but it's good to know how things work, and transform matrices are certainly very important