I use a function to build a rotation matrix to have the player sceneNode oriented according to the center of the planet. But... have a problem I can't solve. Here a image to describe it:

The rotation matrix allways have the Z axis (the front of the node) facing the target. But in this case I need the downside of the node facing the target.
A rusty solution can be rotate in 3dmax the player model, and use his Y as Z, but is a ugly solution....
here the function:
Code: Select all
// the initial up direction of the node
vector3df up(0,1,0);
// the up direction during gameplay
vector3df curup(up);
void pointTarget(ISceneNode& node, ISceneNode& target)
{
vector3df targetdir=target.getPosition()-node.getPosition();
// build the rotation matrix
vector3df z(targetdir);
z.normalize();
vector3df x( curup.crossProduct(z));
x.normalize();
vector3df y( z.crossProduct(x));
y.normalize();
core::matrix4 transform;
transform(0,0) = x.X;
transform(0,1) = y.X;
transform(0,2) = z.X;
transform(0,3) = 0;
transform(1,0) = x.Y;
transform(1,1) = y.Y;
transform(1,2) = z.Y;
transform(1,3) = 0;
transform(2,0) = x.Z;
transform(2,1) = y.Z;
transform(2,2) = z.Z;
transform(2,3) = 0;
transform(3,0) = 0;
transform(3,1) = 0;
transform(3,2) = 0;
transform(3,3) = 1.0f;
vector3df rot=transform.getRotationDegrees();
transform.transformVect(up,curup);
curup.normalize();
node.setRotation(rot);
} Any help is very welcome. Thanks in advance.

