[osg-users] Implementation of movement, rotation of scale

Maxim Senin ok23senya at yahoo.com
Fri May 31 02:14:56 PDT 2019


Hi, i finded code, but in this function is failed why?


Code:

osg::Node* addDraggerToScene(osg::Node* scene, const std::string& name)
{
	scene->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);

	osg::MatrixTransform* selection = new osg::MatrixTransform;
	selection->addChild(scene);

	osgManipulator::Dragger* dragger = createDragger(name);


	osg::Group* root = new osg::Group;
	root->addChild(dragger);
	root->addChild(selection);

	float scale = scene->getBound().radius() * 1.6;
	dragger->setMatrix(osg::Matrix::scale(scale, scale, scale) *
		osg::Matrix::translate(scene->getBound().center()));

	osgManipulator::GridConstraint *con = new osgManipulator::GridConstraint(*selection, osg::Vec3(0, 0, 0), osg::Vec3(30, 30, 30));
	osg::ref_ptr<osgManipulator::TabBoxDragger> m_pManipulator = new osgManipulator::TabBoxDragger;
	m_pManipulator->addConstraint(con);

	dragger->addConstraint(con);
	dragger->addTransformUpdating(selection);

	// we want the dragger to handle it's own events automatically
	dragger->setHandleEvents(true);

	// if we don't set an activation key or mod mask then any mouse click on
	// the dragger will activate it, however if do define either of ActivationModKeyMask or
	// and ActivationKeyEvent then you'll have to press either than mod key or the specified key to
	// be able to activate the dragger when you mouse click on it.  Please note the follow allows
	// activation if either the ctrl key or the 'a' key is pressed and held down.
	dragger->setActivationModKeyMask(osgGA::GUIEventAdapter::MODKEY_CTRL);
	dragger->setActivationKeyEvent('a');

	return root;
}



after RETURN failde:(
... 

Thank you!

Cheers,
Maxim

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76159#76159







More information about the osg-users mailing list