示例#1
0
bool
OpenSubdivShader::getInternalValueInContext(const MPlug &plug, MDataHandle &handle, MDGContext &) 
{
    if (plug == aLevel) {
        handle.setInt(_level);
    } else if (plug == aTessFactor) {
        handle.setInt(_tessFactor);
    } else if (plug == aScheme) {
        handle.setShort(_scheme);
    } else if (plug == aKernel) {
        handle.setShort(_kernel);
    } else if (plug == aInterpolateBoundary) {
        handle.setShort(_interpolateBoundary);
    } else if (plug == aAdaptive) {
        handle.setBool(_adaptive);
 
    } else if (plug == aDiffuseMapFile) {
        handle.setString( _diffuseMapFile );
    } else if (plug == aUVSet) {
        handle.setString( _uvSet );
    } else if (plug == aInterpolateUVBoundary) {
        handle.setShort(_interpolateUVBoundary);
 
    } else if (plug == aShaderSource) {
        handle.setString( _shaderSourceFilename );
    }

    return false;
}
示例#2
0
void TestDeformer::_initVertMapping_on_one_mesh( MObject &driver_mesh, MArrayDataBuilder &vertMapOutArrayBuilder, const MPointArray& allPts)
{
    MStatus status;

    // use vertIter to walk through the vertex of a driver mesh
    MItMeshVertex vertIter( driver_mesh, &status );
    CHECK_MSTATUS(status);
    CHECK_MSTATUS(vertIter.reset());

    // for each vertex of the driver mesh
    while( !vertIter.isDone(&status) )
    {
        CHECK_MSTATUS(status);

        // get vertex position
        MPoint driver_pt;
        driver_pt = vertIter.position( MSpace::kWorld, &status );
        CHECK_MSTATUS(status);

        //get the closest driven point
        int closest_pt_index = getClosestPt( driver_pt, allPts );//which one is the closest point(in allPts array) to driver_pt

        //add the closest driven point
        MDataHandle snapDataHnd = vertMapOutArrayBuilder.addElement( closest_pt_index, &status );
        CHECK_MSTATUS( status );
        snapDataHnd.setInt( vertIter.index() );
        snapDataHnd.setClean();

        CHECK_MSTATUS(vertIter.next());
    }
}
bool
OpenSubdivPtexShader::getInternalValueInContext(const MPlug &plug, MDataHandle &handle, MDGContext &)
{
    if (plug == aLevel) {
        handle.setInt(_level);
    } else if (plug == aTessFactor) {
        handle.setInt(_tessFactor);
    } else if (plug == aScheme) {
        handle.setShort(_scheme);
    } else if (plug == aKernel) {
        handle.setShort(_kernel);
    } else if (plug == aInterpolateBoundary) {
        handle.setShort(_interpolateBoundary);
    } else if (plug == aAdaptive) {
        handle.setBool(_adaptive);

    } else if (plug == aShaderSource) {
        handle.setString( _shaderSourceFilename );

    } else if (plug == aDiffuseEnvironmentMapFile) {
        handle.setString(_diffEnvMapFile);
    } else if (plug == aSpecularEnvironmentMapFile) {
        handle.setString(_specEnvMapFile);
    } else if (plug == aColorFile) {
        handle.setString(_colorFile);
    } else if (plug == aDisplacementFile) {
        handle.setString(_displacementFile);
    } else if (plug == aOcclusionFile) {
        handle.setString(_occlusionFile);
    } else if (plug == aEnableColor) {
        handle.setBool(_enableColor);
    } else if (plug == aEnableDisplacement) {
        handle.setBool(_enableDisplacement);
    } else if (plug == aEnableOcclusion) {
        handle.setBool(_enableOcclusion);
    } else if (plug == aEnableNormal) {
        handle.setBool(_enableNormal);
    }

    return false;
}
示例#4
0
void TestDeformer::initVertMapping(MDataBlock& data,
                          MItGeometry& iter,
                          const MMatrix& localToWorldMatrix,
                          unsigned int mIndex)
{
    MStatus status;


    MArrayDataHandle vertMapOutArrayData = data.outputArrayValue( vert_map, &status );
    CHECK_MSTATUS( status );

    // use vertMapOutArrayBuilder to modify vertMapOutArrayData
    iter.reset();
    int count = iter.count();
    MArrayDataBuilder vertMapOutArrayBuilder( vert_map, count, &status );
    CHECK_MSTATUS( status );


    MPointArray allPts;// world vertex position of the driven mesh
    allPts.clear();

    // walk through the driven mesh
    /// copy MItGeometry's vertex to vertMapOutArrayData
    int i = 0;
    while( !iter.isDone(&status) )
    {
        CHECK_MSTATUS( status );

        MDataHandle initIndexDataHnd = vertMapOutArrayBuilder.addElement( i, &status );
        CHECK_MSTATUS( status );

        int negIndex = -1;

        initIndexDataHnd.setInt( negIndex );
        initIndexDataHnd.setClean();

        // append a vertex position(world coordination) to allPts
        CHECK_MSTATUS(allPts.append( iter.position() * localToWorldMatrix ));
        i = i+1;
        iter.next();
    }
    CHECK_MSTATUS(vertMapOutArrayData.set( vertMapOutArrayBuilder ));




    /// Append more vertex from each driver mesh to vertMapOutArrayData
    MArrayDataHandle meshAttrHandle = data.inputArrayValue( driver_mesh, &status );
    CHECK_MSTATUS( status );

    int numMeshes = meshAttrHandle.elementCount();
    __debug("%s(), numMeshes=%d", __FUNCTION__, numMeshes);

    CHECK_MSTATUS(meshAttrHandle.jumpToElement(0));
    for( int meshIndex=0; meshIndex < numMeshes; ++meshIndex )
    {
        __debug("%s(), meshIndex=%d", __FUNCTION__, meshIndex);

        MDataHandle currentMesh = meshAttrHandle.inputValue(&status);
        CHECK_MSTATUS(status);

        MObject meshMobj = currentMesh.asMesh();
        __debug("%s(), meshMobj.apiTypeStr()=%s", __FUNCTION__, meshMobj.apiTypeStr());

        __debugMeshInfo(__FUNCTION__, meshMobj);
        {
            _initVertMapping_on_one_mesh(meshMobj, vertMapOutArrayBuilder, allPts);// Note: vertMapOutArrayBuilder is updated in this function!
            //CHECK_MSTATUS(vertMapOutArrayData.set( vertMapOutArrayBuilder ));
        }

        if( !meshAttrHandle.next() )
        {
            break;
        }
    }// for (mesh
    CHECK_MSTATUS(vertMapOutArrayData.set( vertMapOutArrayBuilder ));



}