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