math & physics
anddos at January 17th, 2010 23:08 — #1
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?
rouncer at January 18th, 2010 00:35 — #2
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.
anddos at January 18th, 2010 01:13 — #3
Thanks alot exactly what i wanted
anddos at February 1st, 2010 15:16 — #4
Can you do this to find the direction the camera is looking?
nerd_skywalker at February 1st, 2010 17:34 — #5
I am not even close to a 3D programmer yet, but i would say it could likely be adapted to (almost) anything.