Beispiel #1
0
void Grid::hashObject( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() == 2 )
	{
		SceneNode::hashObject( path, context, parent, h );
		h.append( path.back() );
		dimensionsPlug()->hash( h );
		if( path.back() == g_gridLinesName )
		{
			spacingPlug()->hash( h );
			gridColorPlug()->hash( h );
		}
		else if( path.back() == g_centerLinesName )
		{
			centerColorPlug()->hash( h );
		}
		else if( path.back() == g_borderLinesName )
		{
			borderColorPlug()->hash( h );
		}
	}
	else
	{
		h = outPlug()->objectPlug()->defaultValue()->hash();
	}
}
Beispiel #2
0
void Grid::hashChildNames( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	SceneNode::hashChildNames( path, context, parent, h );
	h.append( (uint64_t)path.size() );

	if( path.size() == 0 )
	{
		namePlug()->hash( h );
	}
}
Beispiel #3
0
Imath::Box3f ObjectSource::computeBound( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	Imath::Box3f result;
	IECore::ConstObjectPtr object = sourcePlug()->getValue();

	if( const IECore::VisibleRenderable *renderable = IECore::runTimeCast<const IECore::VisibleRenderable>( object.get() ) )
	{
		result = renderable->bound();
	}
	else if( object->isInstanceOf( IECore::Camera::staticTypeId() ) )
	{
		result = Imath::Box3f( Imath::V3f( -0.5, -0.5, 0 ), Imath::V3f( 0.5, 0.5, 2.0 ) );
	}
	else if( object->isInstanceOf( IECore::CoordinateSystem::staticTypeId() ) )
	{
		result = Imath::Box3f( Imath::V3f( 0 ), Imath::V3f( 1 ) );
	}
	else
	{
		result = Imath::Box3f( Imath::V3f( -0.5 ), Imath::V3f( 0.5 ) );
	}

	if( path.size() == 0 )
	{
		result = Imath::transform( result, transformPlug()->matrix() );
	}
	return result;
}
Beispiel #4
0
Imath::M44f ObjectSource::computeTransform( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	if( path.size() == 1 )
	{
		return transformPlug()->matrix();
	}
	return Imath::M44f();
}
Beispiel #5
0
void ObjectSource::hashTransform( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	SceneNode::hashTransform( path, context, parent, h );
	if( path.size() == 1 )
	{
		transformPlug()->hash( h );
	}
}
Beispiel #6
0
void Light::hashBound( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	SceneNode::hashBound( path, context, parent, h );
	if( path.size() == 0 )
	{
		transformPlug()->hash( h );
	}
}
Beispiel #7
0
Imath::M44f Grid::computeTransform( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	if( path.size() == 1 )
	{
		return transformPlug()->matrix();
	}
	return outPlug()->transformPlug()->defaultValue();
}
Beispiel #8
0
Imath::Box3f Light::computeBound( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	Imath::Box3f result = Imath::Box3f( Imath::V3f( -.5 ), Imath::V3f( .5 ) );
	if( path.size() == 0 )
	{
		result = Imath::transform( result, transformPlug()->matrix() );
	}
	return result;
}
Beispiel #9
0
IECore::ConstObjectPtr ObjectSource::computeObject( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	if( path.size() != 1 )
	{
		return parent->objectPlug()->defaultValue();
	}

	return sourcePlug()->getValue();
}
Beispiel #10
0
void ObjectSource::hashChildNames( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() == 0 )
	{
		SceneNode::hashChildNames( path, context, parent, h );
		namePlug()->hash( h );
		return;
	}
	h = parent->childNamesPlug()->defaultValue()->Object::hash();
}
Beispiel #11
0
Imath::Box3f ObjectSource::computeBound( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	IECore::ConstObjectPtr object = sourcePlug()->getValue();
	Imath::Box3f result = bound( object.get() );

	if( path.size() == 0 )
	{
		result = Imath::transform( result, transformPlug()->matrix() );
	}
	return result;
}
Beispiel #12
0
void ObjectSource::hashObject( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() != 1 )
	{
		h = parent->objectPlug()->defaultValue()->hash();
		return;
	}

	SceneNode::hashObject( path, context, parent, h );
	sourcePlug()->hash( h );
}
Beispiel #13
0
IECore::ConstInternedStringVectorDataPtr Grid::computeChildNames( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	if( path.size() <= 1 )
	{
		InternedStringVectorDataPtr resultData = new InternedStringVectorData;
		std::vector<InternedString> &result = resultData->writable();
		if( path.size() == 0 )
		{
			result.push_back( namePlug()->getValue() );
		}
		else
		{
			result.push_back( g_gridLinesName );
			result.push_back( g_centerLinesName );
			result.push_back( g_borderLinesName );
		}
		return resultData;
	}

	return outPlug()->childNamesPlug()->defaultValue();
}
Beispiel #14
0
void Grid::hashBound( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() == 0 )
	{
		h = hashOfTransformedChildBounds( path, parent );
	}
	else
	{
		Source::hashBound( path, context, parent, h );
		dimensionsPlug()->hash( h );
	}
}
Beispiel #15
0
Imath::Box3f Grid::computeBound( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	if( path.size() == 0 )
	{
		return unionOfTransformedChildBounds( path, parent );
	}
	else
	{
		const V2f halfDimensions = dimensionsPlug()->getValue() / 2.0f;
		const V3f d( halfDimensions.x, halfDimensions.y, 0 );
		return Box3f( -d, d );
	}
}
Beispiel #16
0
IECore::ConstCompoundObjectPtr Grid::computeAttributes( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	if( path.size() == 1 )
	{
		CompoundObjectPtr result = new CompoundObject;

		result->members()["gl:curvesPrimitive:useGLLines"] = new BoolData( true );
		result->members()["gl:smoothing:lines"] = new BoolData( true );

		ShaderPtr shader = new Shader( "Constant", "gl:surface" );
		shader->parameters()["Cs"] = new Color3fData( Color3f( 1 ) );
		result->members()["gl:surface"] = shader;

		return result;
	}
	else if( path.size() == 2 )
	{
		float pixelWidth = 1.0f;
		if( path.back() == g_gridLinesName )
		{
			pixelWidth = gridPixelWidthPlug()->getValue();
		}
		else if( path.back() == g_centerLinesName )
		{
			pixelWidth = centerPixelWidthPlug()->getValue();
		}
		else if( path.back() == g_borderLinesName )
		{
			pixelWidth = borderPixelWidthPlug()->getValue();
		}

		CompoundObjectPtr result = new CompoundObject;
		result->members()["gl:curvesPrimitive:glLineWidth"] = new FloatData( pixelWidth );

		return result;
	}
	return outPlug()->attributesPlug()->defaultValue();
}
Beispiel #17
0
IECore::ConstInternedStringVectorDataPtr ObjectSource::computeChildNames( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	if( path.size() == 0 )
	{
		IECore::InternedStringVectorDataPtr result = new IECore::InternedStringVectorData();
		const std::string &name = namePlug()->getValue();
		if( name.size() )
		{
			result->writable().push_back( name );
		}
		else
		{
			result->writable().push_back( "unnamed" );
		}
		return result;
	}
	return parent->childNamesPlug()->defaultValue();
}
Beispiel #18
0
IECore::ConstObjectPtr Grid::computeObject( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	if( path.size() == 2 )
	{
		IntVectorDataPtr vertsPerCurveData = new IntVectorData;
		vector<int> &vertsPerCurve = vertsPerCurveData->writable();

		V3fVectorDataPtr pData = new V3fVectorData;
		pData->setInterpretation( GeometricData::Point );
		vector<V3f> &p = pData->writable();

		bool periodic = false;
		Color3f cs( 1 );

		const V2f halfDimensions = dimensionsPlug()->getValue() / 2.0f;
		if( path.back() == g_gridLinesName )
		{
			const float spacing = spacingPlug()->getValue();
			const V2i n = V2f( halfDimensions / spacing ) - V2f( 0.01 );
			for( int d = 0; d < 2; ++d )
			{
				const int d0 = d;
				const int d1 = d == 0 ? 1 : 0;
				for( int i = -n[d]; i <= n[d]; ++i )
				{
					if( i == 0 )
					{
						continue;
					}
					vertsPerCurve.push_back( 2 );
					V3f e( 0 );
					e[d0] = i * spacing;
					e[d1] = -halfDimensions[d1];
					p.push_back( e );
					e[d1] = halfDimensions[d1];
					p.push_back( e );
				}
			}
			cs = gridColorPlug()->getValue();
		}
		else if( path.back() == g_centerLinesName )
		{
			vertsPerCurve.push_back( 2 );
			p.push_back( V3f( halfDimensions.x, 0, 0 ) );
			p.push_back( V3f( -halfDimensions.x, 0, 0 ) );
			vertsPerCurve.push_back( 2 );
			p.push_back( V3f( 0, halfDimensions.y, 0 ) );
			p.push_back( V3f( 0, -halfDimensions.y, 0 ) );
			cs = centerColorPlug()->getValue();
		}
		else if( path.back() == g_borderLinesName )
		{
			vertsPerCurve.push_back( 4 );
			p.push_back( V3f( -halfDimensions.x, -halfDimensions.y, 0 ) );
			p.push_back( V3f( halfDimensions.x, -halfDimensions.y, 0 ) );
			p.push_back( V3f( halfDimensions.x, halfDimensions.y, 0 ) );
			p.push_back( V3f( -halfDimensions.x, halfDimensions.y, 0 ) );
			periodic = true;
			cs = borderColorPlug()->getValue();
		}

		CurvesPrimitivePtr result = new CurvesPrimitive( vertsPerCurveData, CubicBasisf::linear(), periodic, pData );
		result->variables["Cs"] = PrimitiveVariable( PrimitiveVariable::Constant, new Color3fData( cs ) );
		return result;
	}
	return outPlug()->objectPlug()->defaultValue();
}