MStatus TransformationMatrixParameterHandler<T>::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const { typename IECore::TypedParameter<IECore::TransformationMatrix<T> >::Ptr p = IECore::runTimeCast<IECore::TypedParameter<IECore::TransformationMatrix<T> > >( parameter ); if( !p ) { return MS::kFailure; } IECore::TransformationMatrix<T> tMatrix = p->getTypedValue(); if( tMatrix.rotate.order() != Imath::Euler<T>::XYZ ) { IECore::msg( IECore::Msg::Error, "TransformationMatrixParameterHandler::doSetValue", "The rotation order of the parameter '"+parameter->name()+"' is not XYZ, unable to set value." ); return MS::kFailure; } std::vector<Imath::Vec3<T> > v; v.resize(8); for( unsigned int i=0; i<8; i++ ) { if( !getVecValues( plug.child(i), v[i] ) ) return MS::kFailure; } tMatrix.translate = v[ TRANSLATE_INDEX ]; tMatrix.rotate = Imath::Euler<T>(v[ ROTATE_INDEX ]); tMatrix.scale = v[ SCALE_INDEX ]; tMatrix.shear = v[ SHEAR_INDEX ]; tMatrix.scalePivot = v[ SCALEPIVOT_INDEX ]; tMatrix.scalePivotTranslation = v[ SCALEPIVOTTRANS_INDEX ]; tMatrix.rotatePivot = v[ ROTATEPIVOT_INDEX ]; tMatrix.rotatePivotTranslation = v[ ROTATEPIVOTTRANS_INDEX ]; p->setTypedValue( tMatrix ); return MS::kSuccess; }
MStatus BoxParameterHandler<T>::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const { typename IECore::TypedParameter<Box<T> >::Ptr p = IECore::runTimeCast<IECore::TypedParameter<Box<T> > >( parameter ); if( !p ) { return MS::kFailure; } if( plug.numChildren() != 2 ) { return MS::kFailure; } MPlug minPlug = plug.child( 0 ); MPlug maxPlug = plug.child( 1 ); if( minPlug.numChildren()!=T::dimensions() || maxPlug.numChildren()!=T::dimensions() ) { return MS::kFailure; } Box<T> v; for( unsigned i=0; i<minPlug.numChildren(); i++ ) { MStatus s = minPlug.child( i ).getValue( v.min[i] ); if( !s ) { return s; } s = maxPlug.child( i ).getValue( v.max[i] ); if( !s ) { return s; } } p->setTypedValue( v ); return MS::kSuccess; }
MStatus ColorSplineParameterHandler<S>::doSetValue( const MPlug &plug, IECore::ParameterPtr parameter ) const { assert( parameter ); typename IECore::TypedParameter< S >::Ptr p = IECore::runTimeCast<IECore::TypedParameter< S > >( parameter ); if( !p ) { return MS::kFailure; } S spline; MStatus s; MRampAttribute fnRAttr( plug, &s ); assert( s ); if ( !fnRAttr.isColorRamp() ) { return MS::kFailure; } MIntArray indices; (const_cast<MPlug &>( plug )).getExistingArrayAttributeIndices( indices, &s ); for( unsigned i = 0; i < indices.length(); i++ ) { MPlug pointPlug = plug.elementByLogicalIndex( indices[i] ); MPlug colorPlug = pointPlug.child( 1 ); typename S::YType y( 1 ); y[0] = colorPlug.child( 0 ).asDouble(); y[1] = colorPlug.child( 1 ).asDouble(); y[2] = colorPlug.child( 2 ).asDouble(); spline.points.insert( typename S::PointContainer::value_type( pointPlug.child( 0 ).asDouble(), y ) ); } // maya seems to do an implicit doubling up of the end points to cause interpolation to the ends. // our spline has no such implicit behaviour so we explicitly double up. if( spline.points.size() ) { #ifndef NDEBUG size_t oldSplineSize = spline.points.size(); #endif assert( spline.points.begin()->first <= spline.points.rbegin()->first ); spline.points.insert( *spline.points.begin() ); spline.points.insert( *spline.points.rbegin() ); assert( spline.points.size() == oldSplineSize + 2 ); } p->setTypedValue( spline ); if( spline.points.size() ) { assert( spline.points.size() >= 2 ); assert( spline.points.size() == fnRAttr.getNumEntries() + 2 ); } return MS::kSuccess; }