Exemple #1
0
bool outputCoordinateSystem( const ScenePlug *scene, const ScenePlug::ScenePath &path, IECore::Renderer *renderer )
{
	IECore::ConstCoordinateSystemPtr constCoordinateSystem = runTimeCast<const IECore::CoordinateSystem>( scene->object( path ) );
	if( !constCoordinateSystem )
	{
		return false;
	}

	if( !visible( scene, path ) )
	{
		return false;
	}

	const M44f transform = scene->fullTransform( path );

	std::string coordinateSystemName;
	ScenePlug::pathToString( path, coordinateSystemName );

	CoordinateSystemPtr coordinateSystem = constCoordinateSystem->copy();
	coordinateSystem->setName( coordinateSystemName );

	{
		TransformBlock transformBlock( renderer );
		renderer->concatTransform( transform );
		coordinateSystem->render( renderer );
	}

	return true;
}
Exemple #2
0
IECore::ObjectPtr FromMayaLocatorConverter::doConversion( const MDagPath &dagPath, IECore::ConstCompoundObjectPtr operands ) const
{
	MStatus st;

	bool hasLocator = dagPath.hasFn( MFn::kLocator, &st );
	if (!st || !hasLocator)
	{
		throw Exception( "Could not find locator!" );
	}

	MObject locatorObj = dagPath.node();
	if ( !locatorObj.hasFn( MFn::kLocator ) )
	{
		throw Exception( "Not a locator!" );
	}
	
	MFnDagNode fnLocator( locatorObj );

	CoordinateSystemPtr result = new CoordinateSystem;
	result->setName( IECore::convert<std::string>( fnLocator.name() ) );

	/// obtain local position and scale from locator
	Imath::V3f position(0), scale(0);

	MPlug positionPlug = fnLocator.findPlug( "localPositionX", &st );
	if ( !st )
		throw Exception("Could not find 'localPositionX' plug!");
	positionPlug.getValue(position[0]);

	positionPlug = fnLocator.findPlug( "localPositionY", &st );
	if ( !st )
		throw Exception("Could not find 'localPositionY' plug!");
	positionPlug.getValue(position[1]);

	positionPlug = fnLocator.findPlug( "localPositionZ", &st );
	if ( !st )
		throw Exception("Could not find 'localPositionZ' plug!");
	positionPlug.getValue(position[2]);

	MPlug scalePlug = fnLocator.findPlug( "localScaleX", &st );
	if ( !st )
		throw Exception("Could not find 'localScaleX' plug!");
	scalePlug.getValue(scale[0]);

	scalePlug = fnLocator.findPlug( "localScaleY", &st );
	if ( !st )
		throw Exception("Could not find 'localScaleY' plug!");
	scalePlug.getValue(scale[1]);

	scalePlug = fnLocator.findPlug( "localScaleZ", &st );
	if ( !st )
		throw Exception("Could not find 'localScaleZ' plug!");
	scalePlug.getValue(scale[2]);

	Imath::M44f scaleM,translateM;
	scaleM.scale(scale);
	translateM.translate(position);
	result->setTransform( new MatrixTransform( scaleM * translateM ) );

	return result;
}