|
|
|
@ -579,26 +579,25 @@ namespace MWScript
|
|
|
|
|
Interpreter::Type_Float rotation = osg::DegreesToRadians(runtime[0].mFloat*MWBase::Environment::get().getFrameDuration());
|
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
|
|
const float *objRot = ptr.getRefData().getPosition().rot;
|
|
|
|
|
if (!ptr.getRefData().getBaseNode())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
float ax = objRot[0];
|
|
|
|
|
float ay = objRot[1];
|
|
|
|
|
float az = objRot[2];
|
|
|
|
|
// We can rotate actors only around Z axis
|
|
|
|
|
if (ptr.getClass().isActor() && (axis == "x" || axis == "y"))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
osg::Quat rot;
|
|
|
|
|
if (axis == "x")
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
|
|
|
|
|
}
|
|
|
|
|
rot = osg::Quat(rotation, -osg::X_AXIS);
|
|
|
|
|
else if (axis == "y")
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay+rotation,az);
|
|
|
|
|
}
|
|
|
|
|
rot = osg::Quat(rotation, -osg::Y_AXIS);
|
|
|
|
|
else if (axis == "z")
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,az+rotation);
|
|
|
|
|
}
|
|
|
|
|
rot = osg::Quat(rotation, -osg::Z_AXIS);
|
|
|
|
|
else
|
|
|
|
|
throw std::runtime_error ("invalid rotation axis: " + axis);
|
|
|
|
|
|
|
|
|
|
osg::Quat attitude = ptr.getRefData().getBaseNode()->getAttitude();
|
|
|
|
|
MWBase::Environment::get().getWorld()->rotateWorldObject(ptr, attitude * rot);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|