コード例 #1
0
void ShapeVisitor_VisualizerCreator::visualizeSphere( Layout::Shape_AbstractSphere& abstractSphere )
{
	osg::Sphere* sphere = new osg::Sphere;
	sphere->setRadius( getScaledDistance( abstractSphere.getRadius() ) );
	sphere->setCenter( getScaledPosition( abstractSphere.getCenter() ) );

	osg::ShapeDrawable* sd = new osg::ShapeDrawable;
	sd->setShape( sphere );
	//volovar zmena
	osg::PolygonMode* polygonMode = new osg::PolygonMode;  //podla http://snipplr.com/view/30978/osg-wireframe-display/

	sd->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
	switch ( abstractSphere.getRenderType() ) { //prepinanie medzi vykreslovacimi modmi shapu
		case Layout::Shape_AbstractSphere::SOLID:

			sd->setColor( osg::Vec4( 0.f, 0.f, 1.0f, abstractSphere.getAlpha() ) );
			sd->getStateSet()->setAttributeAndModes( new osg::BlendFunc, osg::StateAttribute::ON );
			sd->getStateSet()->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
			break;
		case Layout::Shape_AbstractSphere::WIREFRAME:
			polygonMode->setMode( osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE );
			sd->setColor( osg::Vec4( 0.f, 0.f, 1.0f, abstractSphere.getAlpha() ) );
			sd->getStateSet()->setAttributeAndModes( polygonMode,
					osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON );
			sd->getStateSet()->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
			break;
		case Layout::Shape_AbstractSphere::CIRCLE:
			break;
		default:
			return;
	}
	//volovar koniec zmeny


	//transparency of sphere

	sd->getStateSet()->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
	sd->getStateSet()->setMode( GL_DEPTH_TEST,osg::StateAttribute::OFF );
	sd->getStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );

	sd->getStateSet()->setRenderBinDetails( 11, "RenderBin" );
	//

	osg::Geode* geode = new osg::Geode;
	geode->addDrawable( sd );

	createdVisualizer_ = geode;
}
コード例 #2
0
void ShapeVisitor_VisualizerCreator::visualizeSphere (Layout::Shape_AbstractSphere & abstractSphere) {
	osg::Sphere * sphere = new osg::Sphere;
	sphere->setRadius (getScaledDistance (abstractSphere.getRadius ()));
	sphere->setCenter (getScaledPosition (abstractSphere.getCenter ()));

	osg::ShapeDrawable * sd = new osg::ShapeDrawable;
	sd->setShape (sphere);
	sd->setColor (osg::Vec4 (0, 0, 1.0, 0.06));

	//transparency of sphere
	sd->getOrCreateStateSet()->setMode (GL_BLEND, osg::StateAttribute::ON);
	sd->getStateSet()->setRenderingHint (osg::StateSet::TRANSPARENT_BIN);
	sd->getStateSet()->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
	sd->getStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
	sd->getStateSet()->setAttributeAndModes(new osg::BlendFunc, osg::StateAttribute::ON);
	sd->getStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
	sd->getStateSet()->setRenderBinDetails( 11, "RenderBin");
	//

	osg::Geode * geode = new osg::Geode;
	geode->addDrawable (sd);

    createdVisualizer_ = geode;
}