[Plib-users] Problem with rotations
Brought to you by:
sjbaker
|
From: Ben W. <be...@ec...> - 2002-09-09 14:53:20
|
Hello Everybody
I ran into a little problem, and I am unable to resolve it. Basically I a=
m=20
just trying to rotate something around its axes. At different times. For =
x=20
and z this works perfectly but for y it does not.=20
The model start with its feet on the origin and rotates around the x axes=
, and=20
it does that but not completely. Once it flat (z =3D 0) then it jumps so =
that=20
the x axes is now going though the middle of it, and its feet are on the =
y=20
axes. It then completes half a rotation and jumps back and completes the=20
orignal rotation with is feet on the x axes.
function rotate (float h, float p, float r) {
sgMat4 moveMat;
sgMat4 newMat;
sgMat4 currentLocation;
sgCoord newCoord;
sgMakeRotMat4(moveMat,h,p,r);
sgMakeCoordMat4(currentLocation, & this->location);
sgMultMat4(newMat,moveMat, currentLocation);
sgSetCoord ( &newCoord, newMat ) ;
this->location.xyz[0] =3D newCoord.xyz[0];
this->location.xyz[1] =3D newCoord.xyz[1];
this->location.xyz[2] =3D newCoord.xyz[2];
this->location.hpr[0] =3D newCoord.hpr[0];
this->location.hpr[1] =3D newCoord.hpr[1];
this->location.hpr[2] =3D newCoord.hpr[2];
this->setTransform( & this->location );
}
|