HELP! - I need help... with QuatF...
by Kevin Mitchell · in Torque 3D Professional · 09/01/2011 (6:59 pm) · 3 replies
So I'm like in the last phase of my please rewrite but i have an issue.
Apparently you can not rotate the root node of a animation applied to a character that has animations for its root node.
Which leaves the hard part to make swim animation where i can rotate the center node in a 360 axis.
But at the same time rotate the swim animation forward 90 degrees.
I built 2 QuatF on to translate the Z rotation and one to rotate the x axis 90 degrees.
I want to merge these to make one transform but when i try i get some kind of weird scale on my character.
Apparently you can not rotate the root node of a animation applied to a character that has animations for its root node.
Which leaves the hard part to make swim animation where i can rotate the center node in a 360 axis.
But at the same time rotate the swim animation forward 90 degrees.
I built 2 QuatF on to translate the Z rotation and one to rotate the x axis 90 degrees.
I want to merge these to make one transform but when i try i get some kind of weird scale on my character.
//CHANGE FOR NODE ROTATION
if(move->y||move->x){
Point3F Point1;
Point3F Point2;
Point1.x=10;
Point1.y=10;
Point1.z=0;
Point2.x=10-(move->y);
Point2.y=10+move->x;
Point2.z=0;
//(CalcTheta(Point1,Point2)*180)/M_PI_F; // angle in degrees
mDataBlock->DIR_ANGLE = CalcTheta(Point1,Point2);
Point3F _pos;
_pos.set(0,0,0);
Point3F _axis;
_axis.set(0,0,1);
Point3F _SWMaxis;
_axis.SWMset(0,1,0);
QuatF _rot;
QuatF _SWMrot;
F32 y2 = move->yaw/2;
if (y2 > M_PI_F)
y2 -= M_2PI_F;
mDataBlock->DIR_ANGLE-=y2;
if (mDataBlock->DIR_ANGLE <0)
mDataBlock->DIR_ANGLE += M_2PI_F;
_rot.set(_axis,mDataBlock->DIR_ANGLE);
_SWMrot.set(_SWMaxis, ((90*M_PI_F)/180) );
//Test 1
//_rot+=_SWMrot
// ---- FAIL compile error.
//Test 2
//_rot.set(
// _rot.x+_SWMrot.x,
// _rot.y+_SWMrot.y,
// _rot.z+_SWMrot.z,
// _rot.w+_SWMrot.w
// );
// ---- FAIL Scales character.
String _name;
_name="Bip01";
mDataBlock->mShape->setNodeTransform(_name, _pos,_rot);
Con::printf("Node _pos: %f",((CalcTheta(Point1,Point2)*180)/M_PI_F));
//Con::printf("Node _pos: %f %f %f ",move->x,move->y,move->z);
//Con::printf("Node _pos: %f %f %f : < %f ::: %f",_rot.x,_rot.y,_rot.z,_rot.w, mDataBlock->DIR_ANGLE);
}else{
Point3F _pos;
_pos.set(0,0,0);
Point3F _axis;
_axis.set(0,1,0);
QuatF _rot;
F32 y2 = move->yaw/2;
if (y2 > M_PI_F)
y2 -= M_2PI_F;
mDataBlock->DIR_ANGLE-=y2;
if (mDataBlock->DIR_ANGLE <0)
mDataBlock->DIR_ANGLE += M_2PI_F;
_rot.set(_axis,mDataBlock->DIR_ANGLE);
String _name;
_name="Bip01";
mDataBlock->mShape->setNodeTransform(_name, _pos,_rot);
}About the author
Riding Solo since 2005. Current Project: Fated World 2005-Present RPG Engine Tool Kit - Now available.
Torque Owner Kevin Mitchell
12 CatBlack Studios