コード例 #1
0
// once normals are supported in the polyMesh schema, polyMesh will look 
// different than readSubD
void readPoly(double iFrame, MFnMesh & ioMesh, MObject & iParent,
    Alembic::AbcGeom::IPolyMesh & iNode, bool iInitialized)
{
    Alembic::AbcGeom::IPolyMeshSchema schema = iNode.getSchema();
    Alembic::AbcGeom::MeshTopologyVariance ttype = schema.getTopologyVariance();

    int64_t index, ceilIndex;
    double alpha = getWeightAndIndex(iFrame,
        schema.getTimeSampling(), schema.getNumSamples(), index, ceilIndex);

    MFloatPointArray pointArray;
    Alembic::Abc::V3fArraySamplePtr ceilPoints;

    // we can just read the points
    if (ttype != Alembic::AbcGeom::kHeterogenousTopology && iInitialized)
    {

        Alembic::Abc::V3fArraySamplePtr points = schema.getPositions().getValue(
            Alembic::Abc::ISampleSelector(index) );

        if (alpha != 0.0)
        {
            ceilPoints = schema.getPositions().getValue(
                Alembic::Abc::ISampleSelector(ceilIndex) );
        }

        fillPoints(pointArray, points, ceilPoints, alpha);
        ioMesh.setPoints(pointArray, MSpace::kObject);

        if (schema.getNormals().getNumSamples() > 1)
        {
            setPolyNormals(iFrame, ioMesh, schema.getNormals());
        }

        if (schema.getUVs().getNumSamples() > 1)
        {
            setUVs(iFrame, ioMesh, schema.getUVs());
        }

        return;
    }

    // we need to read the topology
    Alembic::AbcGeom::IPolyMeshSchema::Sample samp;
    schema.get(samp, Alembic::Abc::ISampleSelector(index));

    if (alpha != 0.0 && ttype != Alembic::AbcGeom::kHeterogenousTopology)
    {
        ceilPoints = schema.getPositions().getValue(
            Alembic::Abc::ISampleSelector(ceilIndex) );
    }

    fillPoints(pointArray, samp.getPositions(), ceilPoints, alpha);

    fillTopology(ioMesh, iParent, pointArray, samp.getIndices(),
        samp.getCounts());

    setPolyNormals(iFrame, ioMesh, schema.getNormals());
    setUVs(iFrame, ioMesh, schema.getUVs());
}
コード例 #2
0
MObject createPoly(double iFrame, Alembic::AbcGeom::IPolyMesh & iNode,
    MObject & iParent, std::vector<std::string> & oSampledPropNameList)
{
    Alembic::AbcGeom::IPolyMeshSchema schema = iNode.getSchema();
    MString name(iNode.getName().c_str());

    MStatus status = MS::kSuccess;

    MFnMesh fnMesh;
    MObject obj;

    // add other properties
    if (schema.getNumSamples() > 1)
    {
        MFloatPointArray emptyPt;
        MIntArray emptyInt;
        obj = fnMesh.create(0, 0, emptyPt, emptyInt, emptyInt, iParent);
        fnMesh.setName(name);
    }
    else
    {
        int64_t index, ceilIndex;
        double alpha = getWeightAndIndex(iFrame, schema.getTimeSampling(),
            schema.getNumSamples(), index, ceilIndex);

        Alembic::AbcGeom::IPolyMeshSchema::Sample samp;
        schema.get(samp, Alembic::Abc::ISampleSelector(index));

        MFloatPointArray ptArray;
        Alembic::Abc::V3fArraySamplePtr ceilPoints;
        if (index != ceilIndex)
        {
            Alembic::AbcGeom::IPolyMeshSchema::Sample ceilSamp;
            schema.get(ceilSamp, Alembic::Abc::ISampleSelector(ceilIndex));
            ceilPoints = ceilSamp.getPositions();
        }

        fillPoints(ptArray, samp.getPositions(), ceilPoints, alpha);
        fillTopology(fnMesh, iParent, ptArray, samp.getIndices(),
            samp.getCounts());
        fnMesh.setName(iNode.getName().c_str());
        setPolyNormals(iFrame, fnMesh, schema.getNormals());
        setUVs(iFrame, fnMesh, schema.getUVs());
        obj = fnMesh.object();
    }

    MString pathName = fnMesh.partialPathName();
    setInitialShadingGroup(pathName);

    if ( !schema.getNormals().valid() )
    {
        MFnNumericAttribute attr;
        MString attrName("noNormals");
        MObject attrObj = attr.create(attrName, attrName,
        MFnNumericData::kBoolean, true, &status);
        attr.setKeyable(true);
        attr.setHidden(false);
        MFnMesh fnMesh(obj);
        fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
    }

    return obj;
}