math & physics
Ok so i have a triangle rendering thats in the world like
what i want todo is translate an object in the direction the face is facing , heres the code i already have
D3DXVECTOR3 Sub1 = TriVert1Out - TriVert2Out;
D3DXVECTOR3 Sub2 = TriVert1Out - TriVert3Out;
SetRect(&textbox, 0, 0, 640, 480);
sprintf(Buffer,"%s %f %f %f\n","The triangle's direction is",Cross.x,Cross.y,Cross.z);
D3DCOLOR_ARGB(255, 255, 0, 0));
so next i want to say use D3DXMatrixTranslation on a box and make the box fire outwards from the direction the face is facing, i am not sure how to make the box keep moving in that diagonal path thats the direction etc...
can anyone help?
Im not sure what your problem is, youve written it all right so far.
Just find the triangles normal, Which it looks like your code is doing, normalize it.
then go D3DXMatrixTranslation(&tra, centre_of_tri.x+normal_of_tri.x*time, centre_of_tri.y+normal_of_tri.y*time, centre_of_tri.z+normal_of_tri.z*time);
Increment time by say 0.01f every cycle and it should shoot out of the triangle normal from the centre of the triangle.
Thanks alot exactly what i wanted
Can you do this to find the direction the camera is looking?
I am not even close to a 3D programmer yet, but i would say it could likely be adapted to (almost) anything.