Code: Select all
/*====================================================================
local rotation of the entity --- by nespa */
DLL_EXPORT void DLL_APIENTRY TurnEntity(ISceneNode* Entity,float X,float Y,float Z)
{
vector3df rp(X,Y,Z);
vector3df r = Entity->getRotation(); //get current rotation (euler)
matrix4 m;
matrix4 mp;
m.setRotationDegrees(r); //set matrix to current rotation
mp.setRotationDegrees(rp); //set second matrix to rotation to add
m *= mp; //multipy them
r = m.getRotationDegrees(); //get rotation vector from matrix (euler)
if(r.Y == 0.0f)
{
r.Y = 0.001f;
}
if(r.Y == 180.0f)
{
r.Y = 180.001f;
}
Entity->setRotation(r); //rotates node
}
It turns around the local axes.
Use the wrapvalue in a loop or make an animator.
Good luck !