Hi,
I am a newbie of the OpenSceneGraph. I am trying to create a sub class which
inherets from teh osgManipulator::Dragger and mimic the similar behaviour of
the osgManipulator::RotateCylinderDragger.
However, I always got crashes on the line computeNodePathToRoot(...) in the
handle(...) function. The error hints that I forgot registering my new class
somewhere. However, I checked source code of the RotateCylinderDragger and
didn't find any way to do it.
Below is my code snippet. It always crashes after it execute the
computeNodePathToRoot and return true in the end.
I am desparately waiting for some help on this issue now.
Any answers will be greatly appreciated.
bool ScaleRotateDragger::handle(const 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):
{
// 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->setLocalToWorld(localToWorld);
_startLocalToWorld = _projector->getLocalToWorld();
_startWorldToLocal = _projector->getWorldToLocal();
if (_projector->isPointInFront(pointer, _startLocalToWorld))
_projector->setFront(true);
else
_projector->setFront(false);
osg::Vec3d projectedPoint;
if (_projector->project(pointer, projectedPoint))
{
// Generate the motion command.
osg::ref_ptr<Rotate3DCommand> cmd = new Rotate3DCommand();
cmd->setStage(MotionCommand::START);
cmd->setLocalToWorldAndWorldToLocal(_startLocalToWorld,_startWorldToLocal);
// Dispatch command.
dispatch(*cmd);
// Set color to pick color.
setMaterialColor(_pickColor,*this);
_prevWorldProjPt = projectedPoint *
_projector->getLocalToWorld();
_prevRotation = osg::Quat();
_prevPtOnCylinder = _projector->isProjectionOnCylinder();
aa.requestRedraw();
}
return true;
}
// Pick move.
case (osgGA::GUIEventAdapter::DRAG):
thx
...
Thank you!
Cheers,
Zhou
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50741#50741
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org