实验中,xquat是竖直的那个,yquat是与屏幕平行的那个,zquat是水平的那个。如果是vec2 = quatxquatyquatZ*vec1,则先转xquat,再转yquat,再转zquat,
问题来了,如果多个步骤,该怎么办?顺序的不同,会导致结果的不同
那就设定一个数组,
struct DataRange : public osg::Referenced
{
//四元数数组
std::vectorosg::Quat _quatVector = std::vectorosg::Quat();
//六个面的法线
std::vectorosg::Vec3d _normalVector = std::vectorosg::Vec3d();
//中心点初始坐标(可能没在原点上)
osg::Vec3d _center;
//当前旋转的dir,也就是哪个dragger在起作用
RotateCutDirection _dir = None;
};
在release时,把该四元数加入到数组中
bool MyRotateCylinderDragger::handle(
const osgManipulator::PointerInfo& pointer,
const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa)
{
// Check if the dragger node is in the nodepath.
if (!pointer.contains(this)) return false;
switch (ea.getEventType())
{
// Pick start.
case (osgGA::GUIEventAdapter::PUSH):
{
_bRelease = false;
_dataRange->_dir = _dir;
// Get the LocalToWorld matrix for this node and set it for the projector.
osg::NodePath nodePathToRoot;
computeNodePathToRoot(*this, nodePathToRoot);
osg::Matrix localToWorld = osg::computeLocalToWorld(nodePathToRoot);
_projector->setLocalToWor