//-***************************************************************************** Abc::OCompoundProperty OMaterialSchema::getShaderParameters( const std::string & iTarget, const std::string & iShaderType ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OMaterialSchema::getShaderParameters" ); Util::validateName( iTarget, "target" ); Util::validateName( iShaderType, "shaderType" ); std::string propertyName = Util::buildTargetName( iTarget, iShaderType, "params" ); Data::NodeMap::iterator i = m_data->nodes.find( propertyName ); if ( i != m_data->nodes.end() ) { return i->second.params; } Data::Node n; n.params = Abc::OCompoundProperty( this->getPtr(), propertyName ); m_data->nodes[propertyName] = n; return n.params; ALEMBIC_ABC_SAFE_CALL_END(); return Abc::OCompoundProperty(); }
//-***************************************************************************** MeshTopologyVariance ICurvesSchema::getTopologyVariance() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICurvesSchema::getTopologyVariance()" ); if ( m_positionsProperty.isConstant() && m_nVerticesProperty.isConstant() && m_basisAndTypeProperty.isConstant() ) { return kConstantTopology; } else if ( m_nVerticesProperty.isConstant() && m_basisAndTypeProperty.isConstant() ) { return kHomogenousTopology; } else { return kHeterogenousTopology; } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw return kHeterogenousTopology; }
//-***************************************************************************** MeshTopologyVariance ISubDSchema::getTopologyVariance() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISubDSchema::getTopologyVariance()" ); if ( m_faceIndicesProperty.isConstant() && m_faceCountsProperty.isConstant() ) { if ( m_positionsProperty.isConstant() ) { return kConstantTopology; } else { return kHomogenousTopology; } } else { return kHeterogenousTopology; } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw return kConstantTopology; }
//-***************************************************************************** Abc::OCompoundProperty OMaterialSchema::getNetworkNodeParameters( const std::string & iNodeName ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OMaterialSchema::getNetworkNodeParameters" ); std::string nodeDstName = "nodes/" + iNodeName; Abc::OCompoundProperty params; Data::NodeMap::iterator i = m_data->nodes.find( nodeDstName ); if ( i == m_data->nodes.end() ) { //make the empty node, this is legit for a child material //overriding something other than target or nodeType createNodeCompound(); Data::Node n; n.prop = Abc::OCompoundProperty( m_node.getPtr(), iNodeName ); m_data->nodes[nodeDstName] = n; } if ( i->second.params.valid() ) { return i->second.params; } i->second.params = Abc::OCompoundProperty( i->second.prop, "params" ); return i->second.params; ALEMBIC_ABC_SAFE_CALL_END(); return Abc::OCompoundProperty(); }
//-***************************************************************************** void OMaterialSchema::setNetworkNodeConnection( const std::string & iNodeName, const std::string & iInputName, const std::string & iConnectedNodeName, const std::string & iConnectedOutputName ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OMaterialSchema::setNetworkNodeConnection" ); std::string nodeDstName = "nodes/" + iNodeName; if ( m_data->nodes.find( nodeDstName ) == m_data->nodes.end() ) { //make the empty node, this is legit for a child material //overriding something other than target or nodeType createNodeCompound(); Data::Node n; n.prop = Abc::OCompoundProperty( m_node.getPtr(), iNodeName ); m_data->nodes[nodeDstName] = n; } std::string connectionValue = iConnectedNodeName; if ( !iConnectedOutputName.empty() ) { connectionValue += "." + iConnectedOutputName; } m_data->nodes[nodeDstName].connections[iInputName] = connectionValue; ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** void ISubDSchema::loadFaceSetNames() { // Caller must ensure they have locked m_faceSetsMutex. // (allows us to use non-recursive mutex) ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISubDSchema::loadFaceSetNames()" ); if (!m_faceSetsLoaded) { // iterate over childHeaders, and if header matches // FaceSet add to our vec IObject _thisObject = getObject(); size_t numChildren = _thisObject.getNumChildren(); for ( size_t childIndex = 0 ; childIndex < numChildren; childIndex++ ) { ObjectHeader const & header = _thisObject.getChildHeader (childIndex); if ( IFaceSet::matches( header ) ) { // start out with an empty (invalid IFaceSet) // accessor later on will create real IFaceSet object. m_faceSets [header.getName ()] = IFaceSet (); } } m_faceSetsLoaded = true; } ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** void OPolyMeshSchema::setTimeSampling( uint32_t iIndex ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OPolyMeshSchema::setTimeSampling( uint32_t )" ); m_positionsProperty.setTimeSampling( iIndex ); m_indicesProperty.setTimeSampling( iIndex ); m_countsProperty.setTimeSampling( iIndex ); m_selfBoundsProperty.setTimeSampling( iIndex ); if ( m_velocitiesProperty ) { m_velocitiesProperty.setTimeSampling( iIndex ); } if ( m_uvsParam ) { m_uvsParam.setTimeSampling( iIndex ); } if ( m_normalsParam ) { m_normalsParam.setTimeSampling( iIndex ); } ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** void IPointsSchema::init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IPointsSchema::init()" ); Abc::Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); AbcA::CompoundPropertyReaderPtr _this = this->getPtr(); // no matching so we pick up old assets written as V3f m_positionsProperty = Abc::IP3fArrayProperty( _this, "P", kNoMatching, args.getErrorHandlerPolicy() ); m_idsProperty = Abc::IUInt64ArrayProperty( _this, ".pointIds", iArg0, iArg1 ); if ( _this->getPropertyHeader( ".velocities" ) != NULL ) { m_velocitiesProperty = Abc::IV3fArrayProperty( _this, ".velocities", iArg0, iArg1 ); } if ( _this->getPropertyHeader( ".widths" ) != NULL ) { m_widthsParam = IFloatGeomParam( _this, ".widths", iArg0, iArg1 ); } ALEMBIC_ABC_SAFE_CALL_END_RESET(); }
//-***************************************************************************** void OMaterialSchema::addNetworkNode( const std::string & iNodeName, const std::string & iTarget, const std::string & iNodeType ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OMaterialSchema::addNetworkNode" ); Util::validateName( iNodeName, "nodeName" ); Util::validateName( iTarget, "target" ); std::string dstName = "nodes/" + iNodeName; ABCA_ASSERT( m_data->nodes.find( dstName ) == m_data->nodes.end(), "Node already added: " << iNodeName ); createNodeCompound(); Data::Node n; n.prop = Abc::OCompoundProperty( m_node.getPtr(), iNodeName ); m_data->nodes[dstName] = n; Abc::OStringProperty( n.prop, "target" ).set( iTarget ); Abc::OStringProperty( n.prop, "type" ).set( iNodeType ); ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** void ICurvesSchema::get( ICurvesSchema::Sample &oSample, const Abc::ISampleSelector &iSS ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICurvesSchema::get()" ); if ( ! valid() ) { return; } m_positionsProperty.get( oSample.m_positions, iSS ); m_nVerticesProperty.get( oSample.m_nVertices, iSS ); Alembic::Util::uint8_t basisAndType[4]; m_basisAndTypeProperty.get( basisAndType, iSS ); oSample.m_type = static_cast<CurveType>( basisAndType[0] ); oSample.m_wrap = static_cast<CurvePeriodicity>( basisAndType[1] ); oSample.m_basis = static_cast<BasisType>( basisAndType[2] ); // we ignore basisAndType[3] since it is the same as basisAndType[2] if ( m_selfBoundsProperty ) { m_selfBoundsProperty.get( oSample.m_selfBounds, iSS ); } if ( m_velocitiesProperty && m_velocitiesProperty.getNumSamples() > 0 ) { m_velocitiesProperty.get( oSample.m_velocities, iSS ); } ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** IFaceSet ISubDSchema::getFaceSet( const std::string &iFaceSetName ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISubDSchema::getFaceSet()" ); Alembic::Util::scoped_lock l(m_faceSetsMutex); if (!m_faceSetsLoaded) { loadFaceSetNames(); } ABCA_ASSERT( m_faceSets.find (iFaceSetName) != m_faceSets.end (), "The requested FaceSet name can't be found in SubD."); if (!m_faceSets [iFaceSetName]) { // We haven't yet loaded the faceSet, so create/load it m_faceSets [iFaceSetName] = IFaceSet ( getObject(), iFaceSetName ); } return m_faceSets [iFaceSetName]; ALEMBIC_ABC_SAFE_CALL_END(); IFaceSet empty; return empty; }
//-***************************************************************************** IFaceSet IPolyMeshSchema::getFaceSet ( const std::string &iFaceSetName ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IPolyMeshSchema::getFaceSet()" ); boost::mutex::scoped_lock l(m_faceSetsMutex); if (!m_faceSetsLoaded) { loadFaceSetNames(); } ABCA_ASSERT( m_faceSets.find (iFaceSetName) != m_faceSets.end (), "The requested FaceSet name can't be found in PolyMesh."); if (!m_faceSets [iFaceSetName]) { // We haven't yet loaded the faceSet, so create/load it m_faceSets [iFaceSetName] = IFaceSet ( this->getParent().getObject(), iFaceSetName ); } return m_faceSets [iFaceSetName]; ALEMBIC_ABC_SAFE_CALL_END(); IFaceSet emptyFaceSet; return emptyFaceSet; }
//-***************************************************************************** void OCompoundProperty::init( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::init()" ); ABCA_ASSERT( iParent, "invalid parent" ); Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); m_property = Alembic::Util::dynamic_pointer_cast< AbcA::CompoundPropertyWriter>( iParent->getProperty( iName ) ); if ( !m_property ) { m_property = iParent->createCompoundProperty( iName, args.getMetaData() ); } ALEMBIC_ABC_SAFE_CALL_END_RESET(); }
//-***************************************************************************** void IArrayProperty::init( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0, const Argument &iArg1 ) { Arguments args( iParentPolicy ); iArg0.setInto( args ); iArg1.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::init()" ); const AbcA::PropertyHeader *pheader = iParent->getPropertyHeader( iName ); ABCA_ASSERT( pheader != NULL, "Nonexistent array property: " << iName ); m_property = iParent->getArrayProperty( iName ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); }
Abc::OStringArrayProperty OCollectionsSchema::createCollection( const std::string &iName, const Abc::Argument &iArg0, const Abc::Argument &iArg1, const Abc::Argument &iArg2 ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCollectionsSchema::createCollection" ); Abc::OStringArrayProperty prop = getCollection( iName ); if ( prop.valid() ) return prop; prop = Abc::OStringArrayProperty( this->getPtr(), iName, iArg0, iArg1, iArg2 ); if ( prop.valid() ) { m_collections.push_back( prop ); return prop; } ALEMBIC_ABC_SAFE_CALL_END(); return Abc::OStringArrayProperty(); }
//-***************************************************************************** MeshTopologyVariance INuPatchSchema::getTopologyVariance() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "INuPatch::getTopologyVariance()" ); bool pointsConstant = m_positionsProperty.isConstant() && ( !m_positionWeightsProperty || m_positionWeightsProperty.isConstant() ); bool uvConstant = ( m_uOrderProperty.isConstant() && m_vOrderProperty.isConstant() && m_uKnotProperty.isConstant() && m_vKnotProperty.isConstant() ); // check for constant topology. // if the surface has trim curves, we must also check those of topology // variance. if ( pointsConstant && uvConstant ) { if ( this -> hasTrimCurve() ) { if ( this -> trimCurveTopologyIsConstant() ) { return kConstantTopology; } else if ( this -> trimCurveTopologyIsHomogenous() ) { return kHomogenousTopology; } else { return kHeterogenousTopology; } } return kConstantTopology; } // points are animated else if ( uvConstant ) { if ( this -> hasTrimCurve() ) { if ( this -> trimCurveTopologyIsHomogenous() ) { return kHomogenousTopology; } else { return kHeterogenousTopology; } } return kHomogenousTopology; } ALEMBIC_ABC_SAFE_CALL_END(); return kHeterogenousTopology; }
//-***************************************************************************** void IFaceSetSchema::get( IFaceSetSchema::Sample &oSample, const Abc::ISampleSelector &iSS ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IFaceSetSchema::get()" ); m_facesProperty.get( oSample.m_faces, iSS ); ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** void OLightSchema::setFromPrevious() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OLightSchema::setFromPrevious" ); if ( m_cameraSchema ) m_cameraSchema.setFromPrevious(); ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** void OCameraSchema::setTimeSampling( uint32_t iIndex ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCameraSchema::setTimeSampling( uint32_t )" ); m_coreProperties.setTimeSampling( iIndex ); ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** void ISubDSchema::get( ISubDSchema::Sample &oSample, const Abc::ISampleSelector &iSS ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISubDSchema::get()" ); m_positionsProperty.get( oSample.m_positions, iSS ); m_faceIndicesProperty.get( oSample.m_faceIndices, iSS ); m_faceCountsProperty.get( oSample.m_faceCounts, iSS ); m_faceVaryingInterpolateBoundaryProperty.get( oSample.m_faceVaryingInterpolateBoundary, iSS ); m_faceVaryingPropagateCornersProperty.get( oSample.m_faceVaryingPropagateCorners, iSS ); m_interpolateBoundaryProperty.get( oSample.m_interpolateBoundary, iSS ); m_selfBoundsProperty.get( oSample.m_selfBounds, iSS ); if ( m_creaseIndicesProperty ) { m_creaseIndicesProperty.get( oSample.m_creaseIndices, iSS ); } if ( m_creaseLengthsProperty ) { m_creaseLengthsProperty.get( oSample.m_creaseLengths, iSS ); } if ( m_creaseSharpnessesProperty ) { m_creaseSharpnessesProperty.get( oSample.m_creaseSharpnesses, iSS ); } if ( m_cornerIndicesProperty ) { m_cornerIndicesProperty.get( oSample.m_cornerIndices, iSS ); } if ( m_cornerSharpnessesProperty ) { m_cornerSharpnessesProperty.get( oSample.m_cornerSharpnesses, iSS ); } if ( m_holesProperty ) { m_holesProperty.get( oSample.m_holes, iSS ); } m_subdSchemeProperty.get( oSample.m_subdScheme, iSS ); if ( m_childBoundsProperty && m_childBoundsProperty.getNumSamples() > 0 ) { m_childBoundsProperty.get( oSample.m_childBounds, iSS ); } ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** void OFaceSetSchema::setTimeSampling( uint32_t iTimeSamplingID ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OFaceSetSchema::setTimeSampling( uint32_t iTimeSamplingID )" ); m_facesProperty.setTimeSampling( iTimeSamplingID ); m_selfBoundsProperty.setTimeSampling( iTimeSamplingID ); ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** void IScalarProperty::get( void *oSamp, const ISampleSelector &iSS ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::get()" ); AbcA::index_t index = iSS.getIndex( m_property->getTimeSampling(), m_property->getNumSamples() ); m_property->getSample( index, oSamp ); ALEMBIC_ABC_SAFE_CALL_END(); }
//-***************************************************************************** bool OPolyMeshSchema::hasFaceSet( const std::string &iFaceSetName ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OPolyMeshSchema::hasFaceSet ()" ); return (m_faceSets.find (iFaceSetName) != m_faceSets.end ()); ALEMBIC_ABC_SAFE_CALL_END(); return false; }
//-***************************************************************************** size_t OLightSchema::getNumSamples() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OLightSchema::getNumSamples" ); if ( m_childBoundsProperty ) return m_childBoundsProperty.getNumSamples(); ALEMBIC_ABC_SAFE_CALL_END(); return 0; }
//-***************************************************************************** const AbcA::PropertyHeader &OCompoundProperty::getPropertyHeader( size_t iIdx ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::getPropertyHeader()" ); return m_property->getPropertyHeader( iIdx ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return g_hd; }
//-***************************************************************************** AbcA::TimeSamplingPtr IArrayProperty::getTimeSampling() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getTimeSampling()" ); return m_property->getTimeSampling(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return AbcA::TimeSamplingPtr(); }
//-***************************************************************************** bool IArrayProperty::isScalarLike() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::isScalarLike()" ); return m_property->isScalarLike(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return false; }
//-***************************************************************************** size_t IArrayProperty::getNumSamples() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getNumSamples()" ); return m_property->getNumSamples(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return 0; }
//-***************************************************************************** size_t ICompoundProperty::getNumProperties() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICompoundProperty::getNumProperties()" ); return m_property->getNumProperties(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return 0; }
//-***************************************************************************** void OMaterialSchema::createNodeCompound() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OMaterialSchema::createNodeCompound" ); if ( ! m_node.valid() ) { m_node = Abc::OCompoundProperty( this->getPtr(), ".nodes" ); } ALEMBIC_ABC_SAFE_CALL_END(); }