void StandardLightVisualiser::addEnvLightVisualiser( GroupPtr &output, Color3f multiplier, const std::string &textureName ) { IECoreGL::GroupPtr sphereGroup = new IECoreGL::Group(); Imath::M44f trans; trans.scale( V3f( 1, 1, -1 ) ); trans.rotate( V3f( -0.5 * M_PI, -0.5 * M_PI, 0 ) ); sphereGroup->setTransform( trans ); IECoreGL::SpherePrimitivePtr sphere = new IECoreGL::SpherePrimitive(); sphereGroup->addChild( sphere ); IECore::CompoundObjectPtr parameters = new CompoundObject; parameters->members()["lightMultiplier"] = new Color3fData( multiplier ); parameters->members()["previewOpacity"] = new FloatData( 1 ); parameters->members()["mapSampler"] = new StringData( textureName ); parameters->members()["defaultColor"] = new Color3fData( Color3f( textureName == "" ? 1.0f : 0.0f ) ); sphereGroup->getState()->add( new IECoreGL::ShaderStateComponent( ShaderLoader::defaultShaderLoader(), TextureLoader::defaultTextureLoader(), IECoreGL::Shader::defaultVertexSource(), "", environmentLightDrawFragSource(), parameters ) ); sphereGroup->getState()->add( new IECoreGL::DoubleSidedStateComponent( false ) ); output->addChild( sphereGroup ); }
void StandardLightVisualiser::addBasicLightVisualiser( ConstStringDataPtr type, GroupPtr &output, Color3f multiplier, float coneAngle, float penumbraAngle, const std::string *penumbraType, float lensRadius ) { bool indicatorFaceCamera = false; if( !type || type->readable() == "point" ) { output->addChild( const_pointer_cast<IECoreGL::Renderable>( pointRays() ) ); indicatorFaceCamera = true; } else if( type->readable() == "spot" ) { float innerAngle = 0; float outerAngle = 0; if( !penumbraType || *penumbraType == "inset" ) { outerAngle = coneAngle; innerAngle = coneAngle - 2.0f * penumbraAngle; } else if( *penumbraType == "outset" ) { outerAngle = coneAngle + 2.0f * penumbraAngle; innerAngle = coneAngle ; } else if( *penumbraType == "absolute" ) { outerAngle = coneAngle; innerAngle = penumbraAngle; } output->addChild( const_pointer_cast<IECoreGL::Renderable>( spotlightCone( innerAngle, outerAngle, lensRadius ) ) ); output->addChild( const_pointer_cast<IECoreGL::Renderable>( ray() ) ); } else if( type->readable() == "distant" ) { for ( int i = 0; i < 3; i++ ) { IECoreGL::GroupPtr rayGroup = new IECoreGL::Group(); Imath::M44f trans; trans.rotate( V3f( 0, 0, 2.0 * M_PI / 3.0 * i ) ); trans.translate( V3f( 0, 0.4, 0.5 ) ); rayGroup->addChild( const_pointer_cast<IECoreGL::Renderable>( ray() ) ); rayGroup->setTransform( trans ); output->addChild( rayGroup ); } } output->addChild( const_pointer_cast<IECoreGL::Renderable>( colorIndicator( multiplier, indicatorFaceCamera ) ) ); }