Help with the roll angle

Posted By: Regrin

Help with the roll angle - 09/02/09 23:01

I have an animated model of a warrior and a static model of a helmet, and now I'm working on a function to recalculate the position and angles of the helmet every frame. I found only this code:

function addons(ENTITY* entity1, var v1, var v2, var v3)
{
VECTOR hand_pos;
VECTOR hand_pos2;
VECTOR hand_pos3;
VECTOR hand_pos4;
VECTOR vec1;
VECTOR vec2;
VECTOR temp;

vec_for_vertex(entity1.x, Player1,v1); //vertex to place origin at
vec_for_vertex(hand_pos, Player1, v2); //vert to orient pan and tilt
vec_for_vertex(hand_pos2, Player1, v1);
vec_for_vertex(hand_pos3, Player1, v3); //vert to orient roll
vec_for_vertex(hand_pos4, Player1, v2);

vec_sub(hand_pos, entity1.x); //sets our pan and tilt
vec_to_angle(entity1.pan, hand_pos);
entity1.roll = 0;

//all this does the roll, courtesy of Gnometech
vec_sub(hand_pos3, hand_pos4);
vec_set(vec1, nullvector);
vec1.y = 1;
vec_rotate(vec1, entity1.pan);
vec_set(vec2, nullvector);
vec2.z = 1;
vec_rotate(vec2, entity1.pan);
temp.x = vec_dot(vec1, hand_pos4);
temp.y = vec_dot(vec2, hand_pos3);
temp.z = 0;
vec_to_angle(entity1.roll, temp);
}


Angles pan and tilt are working fine so far, but roll isn't right calculated. This problem is getting me mad and I can't find another solution. Can somebody help me??

Thanks!
Posted By: bart_the_13th

Re: Help with the roll angle - 09/03/09 08:33

There's an attach code in wiki and in AUM resource.
You could always search there...
Posted By: Widi

Re: Help with the roll angle - 09/03/09 09:27

It should work. Do you give to the function 3 vertexes? They should positioned like a "L"
Posted By: Michael_McCrickard

Re: Help with the roll angle - 09/03/09 17:10

Yeah, the three vertices you pick on your parent model are important. They should form an "L" shape as Widi mentioned. If they are in a straight line (or close to it), then the roll part goes all crazy.
© 2024 lite-C Forums