[osg-users] ECEF Oriented Compass Implementation
Nickolai Medvedev
raizel.dev at yandex.ru
Wed Nov 16 03:14:34 PST 2016
Hi, all.
Source file and header in archive.
To use a class a compass:
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("arrow.osgb"); // any node looking to the north
if(node.valid())
{
node->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
}
osg::ref_ptr<osg::PositionAttitudeTransform> pos = new osg::PositionAttitudeTransform;
pos->addChild(node.get());
pos->setScale(osg::Vec3(0.6,0.6,0.6));
osg::ref_ptr<Compass> compass = new Compass;
compass->setViewport( 0.0, 0.0, 100.0, 100.0 );
compass->setProjectionMatrix( osg::Matrixd::identity() );
compass->setNeedle( pos.get() );
compass->setMainCamera( VIEWER->getCamera() );
compass->setRenderOrder( osg::Camera::POST_RENDER );
compass->setClearMask( GL_DEPTH_BUFFER_BIT );
compass->setAllowEventFocus( false );
compass->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
compass->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
compass->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
root->addChild( compass.get() );
Good luck!
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69393#69393
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Compass.7z
Type: application/octet-stream
Size: 796 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20161116/189ffdab/attachment-0003.obj>
More information about the osg-users
mailing list