My problem is, I want to rotate a node to face another node.
The problem is, it doesn't seem to work - the node just keeps facing forwards, and even if I press the "rotate node 10 degrees left" key, it stays facing forwards. Therefore, it's fair to assume the problem is in the functions I've written to calculate the change in angles needed. So here they are:
Code: Select all
void MyObject::AdjustHeading(vector3df vDestination)
{
vector3df start = NodePtr->getPosition();
vector3df diff = vector3df(vDestination.X-start.X, vDestination.Y-start.Y, vDestination.Z-start.Z);
vector3df diffAngles = AsAngles(diff);
NodePtr->setRotation(diffAngles);
Code: Select all
vector3df AsAngles(vector3df v3d)
{
float xRot,yRot,zRot;
float x = v3d.X;
float y = v3d.Y;
float z = v3d.Z;
xRot = atanf(y/x);
yRot = 0;
zRot = atanf(y/z);
vector3df retval(xRot,yRot,zRot);
return retval;
}
So, anyone see anything small and foolish, or am I barking up entirely the wrong tree with this?