本文整理汇总了C++中CHECK_MSTATUS函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_MSTATUS函数的具体用法?C++ CHECK_MSTATUS怎么用?C++ CHECK_MSTATUS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CHECK_MSTATUS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CHECK_MSTATUS
MStatus TestDeformer::deform(MDataBlock& data,
MItGeometry& iter,
const MMatrix& localToWorldMatrix,
unsigned int mIndex)
{
MStatus status;
// get the current node state
short initialized_mapping = data.inputValue( initialized_data, &status).asShort();
CHECK_MSTATUS(status);
__debug("%s(), initialized_mapping=%d, mIndex=%d", __FUNCTION__, initialized_mapping, mIndex);
if( initialized_mapping == 1 )
{
initVertMapping(data, iter, localToWorldMatrix, mIndex);
// set initialized_data to 2 automatically. User don't have to set it manully.
MObject tObj = thisMObject();
MPlug setInitMode = MPlug( tObj, initialized_data );
setInitMode.setShort( 2 );
// and sync initialized_mapping from initialized_data
// so, the code section:
// if (initialized_mapping == 2)
// {
// ...
// }
// will be executed when this deform() function is called next time.
initialized_mapping = data.inputValue( initialized_data, &status ).asShort();
CHECK_MSTATUS(status);
}
if( initialized_mapping == 2 )
{
envelope = MPxDeformerNode::envelope;
MDataHandle envelopeHandle = data.inputValue( envelope, &status );
CHECK_MSTATUS( status );
MArrayDataHandle vertMapArrayData = data.inputArrayValue( vert_map, &status );
CHECK_MSTATUS( status );
MArrayDataHandle meshAttrHandle = data.inputArrayValue( driver_mesh, &status );
CHECK_MSTATUS( status );
/// 1. init tempOutputPts to zero points
MPointArray tempOutputPts;
iter.reset();
while( !iter.isDone(&status) )
{
CHECK_MSTATUS(tempOutputPts.append(MPoint(0, 0, 0)));
CHECK_MSTATUS(iter.next());
}
assert(tempOutputPts.length() == iter.count());
/// 2. set tempOutputPts to deform values which comes from each driver mesh
iter.reset();
int numMeshes = meshAttrHandle.elementCount();
__debug("%s(), numMeshes=%d", __FUNCTION__, numMeshes);
CHECK_MSTATUS(meshAttrHandle.jumpToElement(0));
// for each driver mesh
for( int count=0; count < numMeshes; ++count )
{
__debug("%s(), count=%d", __FUNCTION__, count);
// for one driver mesh: currentMesh
MDataHandle currentMesh = meshAttrHandle.inputValue(&status);
CHECK_MSTATUS( status );
MObject meshMobj = currentMesh.asMesh();
__debugMeshInfo(__FUNCTION__, meshMobj);
// accumulate deform values of currentMesh to tempOutputPts
_deform_on_one_mesh(data, iter, localToWorldMatrix, mIndex,
meshMobj,
envelopeHandle, vertMapArrayData, tempOutputPts );
if( !meshAttrHandle.next() )
{
break;
}
}// for each driver mesh
/// 3. add deform value to this geometry(driven mesh)
int i = 0;
iter.reset();
while( !iter.isDone(&status) )
{
MPoint p = iter.position(MSpace::kObject, &status);
CHECK_MSTATUS(status);
// add the deform value to this vertex
CHECK_MSTATUS(iter.setPosition( p + tempOutputPts[i]/numMeshes ));
CHECK_MSTATUS(iter.next());
++i;
//.........这里部分代码省略.........
示例2: CHECK_MSTATUS
// The initialize routine is called after the node has been created.
// It sets up the input and output attributes and adds them to the
// node. Finally the dependencies are arranged so that when the
// inputs change Maya knowns to call compute to recalculate the output
// value.
//
MStatus stringFormat::initialize()
{
MFnNumericAttribute numAttr;
MFnTypedAttribute typedAttr;
MFnStringData stringData;
MStatus stat;
MStatus stat2;
// Setup the input attributes
//
attrFormat = typedAttr.create("format", "f", MFnData::kString,
stringData.create(&stat2), &stat);
CHECK_MSTATUS( stat2 );
CHECK_MSTATUS( stat );
CHECK_MSTATUS( typedAttr.setStorable( true ) );
CHECK_MSTATUS( typedAttr.setKeyable( true ) );
attrValues = numAttr.create("values", "v", MFnNumericData::kDouble,
0, &stat);
CHECK_MSTATUS( stat );
CHECK_MSTATUS( numAttr.setArray( true ) );
CHECK_MSTATUS( numAttr.setReadable( false ) );
CHECK_MSTATUS( numAttr.setIndexMatters( true ) );
CHECK_MSTATUS( numAttr.setStorable( true ) );
CHECK_MSTATUS( numAttr.setKeyable( true ) );
attrOutput = typedAttr.create( "output", "o", MFnData::kString,
stringData.create(&stat2), &stat);
CHECK_MSTATUS( stat2 );
CHECK_MSTATUS( stat );
CHECK_MSTATUS( typedAttr.setWritable( false ) );
CHECK_MSTATUS( typedAttr.setStorable( false ) );
// Add the attributes to the node
//
CHECK_MSTATUS( addAttribute( attrFormat ) );
CHECK_MSTATUS( addAttribute( attrValues ) );
CHECK_MSTATUS( addAttribute( attrOutput ) );
// Set the attribute dependencies
//
CHECK_MSTATUS( attributeAffects( attrFormat, attrOutput ) );
CHECK_MSTATUS( attributeAffects( attrValues, attrOutput ) );
return MS::kSuccess;
}
示例3: meshFn
void LuxRenderer::defineTriangleMesh(mtlu_MayaObject *obj, bool noObjectDef = false)
{
MObject meshObject = obj->mobject;
MStatus stat = MStatus::kSuccess;
MFnMesh meshFn(meshObject, &stat);
CHECK_MSTATUS(stat);
MItMeshPolygon faceIt(meshObject, &stat);
CHECK_MSTATUS(stat);
MPointArray points;
meshFn.getPoints(points);
MFloatVectorArray normals;
meshFn.getNormals( normals, MSpace::kWorld );
MFloatArray uArray, vArray;
meshFn.getUVs(uArray, vArray);
logger.debug(MString("Translating mesh object ") + meshFn.name().asChar());
MString meshFullName = obj->fullNiceName;
MIntArray trianglesPerFace, triVertices;
meshFn.getTriangles(trianglesPerFace, triVertices);
int numTriangles = 0;
for( size_t i = 0; i < trianglesPerFace.length(); i++)
numTriangles += trianglesPerFace[i];
// lux render does not have a per vertex per face normal definition, here we can use one normal and uv per vertex only
// So I create the triangles with unique vertices, normals and uvs. Of course this way vertices etc. cannot be shared.
int numPTFloats = numTriangles * 3 * 3;
logger.debug(MString("Num Triangles: ") + numTriangles + " num tri floats " + numPTFloats);
float *floatPointArray = new float[numPTFloats];
float *floatNormalArray = new float[numPTFloats];
float *floatUvArray = new float[numTriangles * 3 * 2];
logger.debug(MString("Allocated ") + numPTFloats + " floats for point and normals");
MIntArray triangelVtxIdListA;
MFloatArray floatPointArrayA;
MPointArray triPoints;
MIntArray triVtxIds;
MIntArray faceVtxIds;
MIntArray faceNormalIds;
int *triangelVtxIdList = new int[numTriangles * 3];
for( uint sgId = 0; sgId < obj->shadingGroups.length(); sgId++)
{
MString slotName = MString("slot_") + sgId;
}
int triCount = 0;
int vtxCount = 0;
for(faceIt.reset(); !faceIt.isDone(); faceIt.next())
{
int faceId = faceIt.index();
int numTris;
faceIt.numTriangles(numTris);
faceIt.getVertices(faceVtxIds);
MIntArray faceUVIndices;
faceNormalIds.clear();
for( uint vtxId = 0; vtxId < faceVtxIds.length(); vtxId++)
{
faceNormalIds.append(faceIt.normalIndex(vtxId));
int uvIndex;
faceIt.getUVIndex(vtxId, uvIndex);
faceUVIndices.append(uvIndex);
}
int perFaceShadingGroup = 0;
if( obj->perFaceAssignments.length() > 0)
perFaceShadingGroup = obj->perFaceAssignments[faceId];
//logger.info(MString("Face ") + faceId + " will receive SG " + perFaceShadingGroup);
for( int triId = 0; triId < numTris; triId++)
{
int faceRelIds[3];
faceIt.getTriangle(triId, triPoints, triVtxIds);
for( uint triVtxId = 0; triVtxId < 3; triVtxId++)
{
for(uint faceVtxId = 0; faceVtxId < faceVtxIds.length(); faceVtxId++)
{
if( faceVtxIds[faceVtxId] == triVtxIds[triVtxId])
{
faceRelIds[triVtxId] = faceVtxId;
}
}
}
uint vtxId0 = faceVtxIds[faceRelIds[0]];
uint vtxId1 = faceVtxIds[faceRelIds[1]];
uint vtxId2 = faceVtxIds[faceRelIds[2]];
uint normalId0 = faceNormalIds[faceRelIds[0]];
//.........这里部分代码省略.........
示例4: MAKE_INPUT
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus Cell3D::initialize()
{
MFnMatrixAttribute mAttr;
MFnNumericAttribute nAttr;
// Input attributes
aColorGain = nAttr.createColor("colorGain", "cg");
MAKE_INPUT(nAttr);
CHECK_MSTATUS( nAttr.setDefault(1.0f,1.0f,1.0f) );
aColorOffset = nAttr.createColor("colorOffset", "co");
MAKE_INPUT(nAttr);
aPlaceMat = mAttr.create("placementMatrix", "pm",
MFnMatrixAttribute::kFloat);
MAKE_INPUT(mAttr);
// Implicit shading network attributes
aPointWorld = nAttr.createPoint("pointWorld", "pw");
MAKE_INPUT(nAttr);
CHECK_MSTATUS( nAttr.setHidden(true) );
// Create output attributes
aOutF0 = nAttr.create( "F0", "f0", MFnNumericData::kFloat);
MAKE_OUTPUT(nAttr);
aOutF1 = nAttr.create( "F1", "f1", MFnNumericData::kFloat);
MAKE_OUTPUT(nAttr);
aOutN0 = nAttr.create( "N0", "n0", MFnNumericData::kFloat);
MAKE_OUTPUT(nAttr);
aOutBorderDist = nAttr.create("borderDistance", "bd",
MFnNumericData::kFloat);
MAKE_OUTPUT(nAttr);
aOutColor = nAttr.createColor("outColor", "oc");
MAKE_OUTPUT(nAttr);
aOutAlpha = nAttr.create( "outAlpha", "oa", MFnNumericData::kFloat);
MAKE_OUTPUT(nAttr);
// Add attributes to the node database.
CHECK_MSTATUS( addAttribute(aColorGain) );
CHECK_MSTATUS( addAttribute(aColorOffset) );
CHECK_MSTATUS( addAttribute(aPointWorld) );
CHECK_MSTATUS( addAttribute(aPlaceMat) );
CHECK_MSTATUS( addAttribute(aOutAlpha) );
CHECK_MSTATUS( addAttribute(aOutColor) );
CHECK_MSTATUS( addAttribute(aOutF0) );
CHECK_MSTATUS( addAttribute(aOutF1) );
CHECK_MSTATUS( addAttribute(aOutN0) );
CHECK_MSTATUS( addAttribute(aOutBorderDist) );
// All input affect the output color and alpha
CHECK_MSTATUS( attributeAffects (aColorGain, aOutColor) );
CHECK_MSTATUS( attributeAffects (aColorOffset, aOutColor) );
CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutColor) );
CHECK_MSTATUS( attributeAffects (aPointWorld, aOutColor) );
CHECK_MSTATUS( attributeAffects (aColorGain, aOutAlpha) );
CHECK_MSTATUS( attributeAffects (aColorOffset, aOutAlpha) );
CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutAlpha) );
CHECK_MSTATUS( attributeAffects (aPointWorld, aOutAlpha) );
// Geometry attribute affect all other outputs.
CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutF0) );
CHECK_MSTATUS( attributeAffects (aPointWorld, aOutF0) );
CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutF1) );
CHECK_MSTATUS( attributeAffects (aPointWorld, aOutF1) );
CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutN0) );
CHECK_MSTATUS( attributeAffects (aPointWorld, aOutN0) );
CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutBorderDist) );
CHECK_MSTATUS( attributeAffects (aPointWorld, aOutBorderDist) );
return MS::kSuccess;
}
示例5: CHECK_MSTATUS
//
// Deform computation
//
MStatus jhMeshBlur::deform( MDataBlock& block,MItGeometry& iter,const MMatrix& m,unsigned int multiIndex)
{
MStatus returnStatus;
// Envelope
float envData = block.inputValue(envelope, &returnStatus).asFloat();
CHECK_MSTATUS(returnStatus);
if(envData == 0)
return MS::kFailure;
/*
VARIABLES
*/
//float factor = block.inputValue(aShapeFactor, &returnStatus).asFloat();
float fStrength = block.inputValue(aStrength, &returnStatus).asFloat();
CHECK_MSTATUS(returnStatus);
if (fStrength == 0)
return MS::kFailure;
float fThreshold = block.inputValue(aTreshhold, &returnStatus).asFloat();
CHECK_MSTATUS(returnStatus);
float fW = 0.0f; // weight
float fDistance;
fStrength *= envData;
double dKracht = block.inputValue(aInterpPower, &returnStatus).asDouble();
CHECK_MSTATUS(returnStatus);
double dDotProduct; // Dotproduct of the point
bool bTweakblur = block.inputValue(aTweakBlur, &returnStatus).asBool();
CHECK_MSTATUS(returnStatus);
bool bQuad = block.inputValue(aQuadInterp, &returnStatus).asBool();
CHECK_MSTATUS(returnStatus);
MTime inTime = block.inputValue(aTime).asTime();
int nTijd = (int)inTime.as(MTime::kFilm);
MFloatVectorArray currentNormals; // normals of mesh
MFnPointArrayData fnPoints; // help converting to MPointArrays
MFloatVector dirVector; // direction vector of the point
MFloatVector normal; // normal of the point
MPointArray savedPoints; // save all point before edited
MMatrix matInv = m.inverse(); // inversed matrix
MPoint ptA; // current point (iter mesh)
MPoint ptB; // previous point (iter mesh)
MPoint ptC; // mesh before previous point (iter mesh)
// get node, use node to get inputGeom, use inputGeom to get mesh data, use mesh data to get normal data
MFnDependencyNode nodeFn(this->thisMObject());
MPlug inGeomPlug(nodeFn.findPlug(this->inputGeom,true));
MObject inputObject(inGeomPlug.asMObject());
MFnMesh inMesh(inputObject);
inMesh.getVertexNormals(true, currentNormals);
// get the previous mesh data
MPlug oldMeshPlug = nodeFn.findPlug(MString("oldMesh"));
MPlug oldMeshPositionsAPlug = oldMeshPlug.elementByLogicalIndex((multiIndex*4) + 0);
MPlug oldMeshPositionsBPlug = oldMeshPlug.elementByLogicalIndex((multiIndex*4) + 1);
MPlug oldMeshPositionsCPlug = oldMeshPlug.elementByLogicalIndex((multiIndex*4) + 2); // cache for tweak mode
MPlug oldMeshPositionsDPlug = oldMeshPlug.elementByLogicalIndex((multiIndex*4) + 3); // cache for tweak mode
// convert to MPointArrays
MObject objOldMeshA;
MObject objOldMeshB;
MObject objOldMeshC; // cache
MObject objOldMeshD; // cache
oldMeshPositionsAPlug.getValue(objOldMeshA);
oldMeshPositionsBPlug.getValue(objOldMeshB);
oldMeshPositionsCPlug.getValue(objOldMeshC); // cache
oldMeshPositionsDPlug.getValue(objOldMeshD); // cache
fnPoints.setObject(objOldMeshA);
MPointArray oldMeshPositionsA = fnPoints.array();
fnPoints.setObject(objOldMeshB);
MPointArray oldMeshPositionsB = fnPoints.array();
fnPoints.setObject(objOldMeshC);
MPointArray oldMeshPositionsC = fnPoints.array(); // cache
fnPoints.setObject(objOldMeshD);
MPointArray oldMeshPositionsD = fnPoints.array(); // cache
// If mesh position variables are empty,fill them with default values
if(oldMeshPositionsA.length() == 0 || nTijd <= 1){
iter.allPositions(oldMeshPositionsA);
for(int i=0; i < oldMeshPositionsA.length(); i++)
//.........这里部分代码省略.........
示例6: CHECK_MSTATUS
// The initialize routine is called after the node has been created.
// It sets up the input and output attributes and adds them to the node.
// Finally the dependencies are arranged so that when the inputs
// change Maya knowns to call compute to recalculate the output values.
//
MStatus hwColorPerVertexShader::initialize()
{
MFnNumericAttribute nAttr;
MFnTypedAttribute tAttr;
MStatus status;
// Create input attributes.
// All attributes are cached internal
//
aColorGain = nAttr.createColor( "colorGain", "cg", &status);
CHECK_MSTATUS( status );
CHECK_MSTATUS( nAttr.setStorable(true));
CHECK_MSTATUS( nAttr.setKeyable(true));
CHECK_MSTATUS( nAttr.setDefault(1.f, 1.f, 1.f));
nAttr.setCached( true );
nAttr.setInternal( true );
aTranspGain = nAttr.create("transparencyGain", "tg",
MFnNumericData::kFloat, 1.f, &status);
CHECK_MSTATUS( status );
CHECK_MSTATUS( nAttr.setStorable(true));
CHECK_MSTATUS( nAttr.setKeyable(true));
CHECK_MSTATUS( nAttr.setDefault(1.f));
CHECK_MSTATUS( nAttr.setSoftMin(0.f));
CHECK_MSTATUS( nAttr.setSoftMax(2.f));
nAttr.setCached( true );
nAttr.setInternal( true );
aColorBias = nAttr.createColor( "colorBias", "cb", &status);
CHECK_MSTATUS( status );
CHECK_MSTATUS( nAttr.setStorable(true));
CHECK_MSTATUS( nAttr.setKeyable(true));
CHECK_MSTATUS( nAttr.setDefault(0.f, 0.f, 0.f));
nAttr.setCached( true );
nAttr.setInternal( true );
aTranspBias = nAttr.create( "transparencyBias", "tb",
MFnNumericData::kFloat, 0.f, &status);
CHECK_MSTATUS( status );
CHECK_MSTATUS( nAttr.setStorable(true));
CHECK_MSTATUS( nAttr.setKeyable(true));
CHECK_MSTATUS( nAttr.setDefault(0.f));
CHECK_MSTATUS( nAttr.setSoftMin(-1.f));
CHECK_MSTATUS( nAttr.setSoftMax(1.f));
nAttr.setCached( true );
nAttr.setInternal( true );
aNormalsPerVertex = nAttr.create("normalsPerVertex", "nv",
MFnNumericData::kInt, 0, &status);
CHECK_MSTATUS( status );
CHECK_MSTATUS( nAttr.setStorable(true));
CHECK_MSTATUS( nAttr.setKeyable(false));
CHECK_MSTATUS( nAttr.setDefault(0));
CHECK_MSTATUS( nAttr.setSoftMin(0));
CHECK_MSTATUS( nAttr.setSoftMax(3));
nAttr.setCached( true );
nAttr.setInternal( true );
aColorsPerVertex = nAttr.create("colorsPerVertex", "cv",
MFnNumericData::kInt, 0, &status);
CHECK_MSTATUS( status );
CHECK_MSTATUS( nAttr.setStorable(true));
CHECK_MSTATUS( nAttr.setKeyable(false));
CHECK_MSTATUS( nAttr.setDefault(0));
CHECK_MSTATUS( nAttr.setSoftMin(0));
CHECK_MSTATUS( nAttr.setSoftMax(5));
nAttr.setCached( true );
nAttr.setInternal( true );
aColorSetName = tAttr.create("colorSetName", "cs",
MFnData::kString, MObject::kNullObj, &status);
CHECK_MSTATUS( status );
CHECK_MSTATUS( tAttr.setStorable(true));
CHECK_MSTATUS( tAttr.setKeyable(false));
tAttr.setCached( true );
tAttr.setInternal( true );
aTexRotateX = nAttr.create( "texRotateX", "tx",
MFnNumericData::kFloat, 0.f, &status);
CHECK_MSTATUS( status );
CHECK_MSTATUS( nAttr.setStorable(true));
CHECK_MSTATUS( nAttr.setKeyable(true));
CHECK_MSTATUS( nAttr.setDefault(0.f));
nAttr.setCached( true );
nAttr.setInternal( true );
aTexRotateY = nAttr.create( "texRotateY", "ty",
MFnNumericData::kFloat, 0.f, &status);
CHECK_MSTATUS( status );
CHECK_MSTATUS( nAttr.setStorable(true));
CHECK_MSTATUS( nAttr.setKeyable(true));
CHECK_MSTATUS( nAttr.setDefault(0.f));
nAttr.setCached( true );
nAttr.setInternal( true );
//.........这里部分代码省略.........
示例7: CHECK_MSTATUS
MStatus retargetLocator::initialize()
{
MFnNumericAttribute nAttr;
MFnMatrixAttribute mAttr;
MFnEnumAttribute eAttr;
MFnUnitAttribute uAttr;
MFnCompoundAttribute cAttr;
MFnTypedAttribute tAttr;
aOutput = nAttr.create( "output", "output", MFnNumericData::kDouble );
nAttr.setStorable( false );
CHECK_MSTATUS( addAttribute( aOutput ) );
aDiscMatrix = mAttr.create( "discMatrix", "discMatrix" );
mAttr.setStorable( true );
CHECK_MSTATUS( addAttribute( aDiscMatrix ) );
CHECK_MSTATUS( attributeAffects( aDiscMatrix, aOutput ) );
aDiscAxis = eAttr.create( "discAxis", "discAxis", 0 );
eAttr.addField( "X", 0 );
eAttr.addField( "Y", 1 );
eAttr.addField( "Z", 2 );
eAttr.setStorable( true );
eAttr.setChannelBox( true );
eAttr.setReadable( true );
CHECK_MSTATUS( addAttribute( aDiscAxis ) );
CHECK_MSTATUS( attributeAffects( aDiscAxis, aOutput ) );
aDiscDivision = nAttr.create( "discDivision", "discDivision", MFnNumericData::kInt, 32 );
nAttr.setMin( 1 );
nAttr.setMax( 32 );
nAttr.setStorable( true );
nAttr.setChannelBox( true );
CHECK_MSTATUS( addAttribute( aDiscDivision ) );
CHECK_MSTATUS( attributeAffects( aDiscDivision, aOutput ) );
aDiscAngle = uAttr.create( "discAngle", "discAngle", MFnUnitAttribute::kAngle, 0.0 );
uAttr.setStorable( true );
uAttr.setChannelBox( true );
CHECK_MSTATUS( addAttribute( aDiscAngle ) );
CHECK_MSTATUS( attributeAffects( aDiscAngle, aOutput ) );
aDiscOffsetX = nAttr.create( "discOffsetX", "discOffsetX", MFnNumericData::kDouble, 0.0 );
aDiscOffsetY = nAttr.create( "discOffsetY", "discOffsetY", MFnNumericData::kDouble, 0.0 );
aDiscOffsetZ = nAttr.create( "discOffsetZ", "discOffsetZ", MFnNumericData::kDouble, 0.0 );
aDiscOffset = nAttr.create( "discOffset", "discOffset", aDiscOffsetX, aDiscOffsetY, aDiscOffsetZ );
uAttr.setStorable( true );
uAttr.setChannelBox( true );
CHECK_MSTATUS( addAttribute( aDiscOffset ) );
CHECK_MSTATUS( attributeAffects( aDiscOffset, aOutput ) );
aDiscSizeX = nAttr.create( "discSizeX", "discSizeX", MFnNumericData::kDouble, 1.0 );
aDiscSizeY = nAttr.create( "discSizeY", "discSizeY", MFnNumericData::kDouble, 1.0 );
aDiscSizeZ = nAttr.create( "discSizeZ", "discSizeZ", MFnNumericData::kDouble, 1.0 );
aDiscSize = nAttr.create( "discSize", "discSize", aDiscSizeX, aDiscSizeY, aDiscSizeZ );
uAttr.setStorable( true );
uAttr.setChannelBox( true );
CHECK_MSTATUS( addAttribute( aDiscSize ) );
CHECK_MSTATUS( attributeAffects( aDiscSize, aOutput ) );
aDiscActiveColor = nAttr.createColor( "discActiveColor", "discActiveColor" );
nAttr.setStorable( true );
nAttr.setUsedAsColor(true);
nAttr.setDefault(1.0f, 1.0f, 1.0f);
CHECK_MSTATUS( addAttribute( aDiscActiveColor ) );
CHECK_MSTATUS( attributeAffects( aDiscActiveColor, aOutput ) );
aDiscLeadColor = nAttr.createColor( "discLeadColor", "discLeadColor" );
nAttr.setStorable( true );
nAttr.setUsedAsColor(true);
nAttr.setDefault(.263f, 1.0f, .639f);
CHECK_MSTATUS( addAttribute( aDiscLeadColor ) );
CHECK_MSTATUS( attributeAffects( aDiscLeadColor, aOutput ) );
aDiscDefaultColor = nAttr.createColor( "discDefaultColor", "discDefaultColor" );
nAttr.setStorable( true );
nAttr.setUsedAsColor(true);
nAttr.setDefault(.0f, .016f, .376f);
CHECK_MSTATUS( addAttribute( aDiscDefaultColor ) );
CHECK_MSTATUS( attributeAffects( aDiscDefaultColor, aOutput ) );
aDiscFillAlpha = nAttr.create( "discFillAlpha", "discFillAlpha", MFnNumericData::kFloat, 0.1f );
nAttr.setStorable( true );
nAttr.setMin( 0.0f );
nAttr.setMax( 1.0f );
CHECK_MSTATUS( addAttribute( aDiscFillAlpha ) );
CHECK_MSTATUS( attributeAffects( aDiscFillAlpha, aOutput ) );
aDiscLineAlpha = nAttr.create( "discLineAlpha", "discLineAlpha", MFnNumericData::kFloat, 1.0f );
nAttr.setStorable( true );
nAttr.setMin( 0.0f );
nAttr.setMax( 1.0f );
CHECK_MSTATUS( addAttribute( aDiscLineAlpha ) );
CHECK_MSTATUS( attributeAffects( aDiscLineAlpha, aOutput ) );
//.........这里部分代码省略.........
示例8: tmpMesh
void MayaObject::getMeshData(MPointArray& points, MFloatVectorArray& normals, MFloatArray& uArray, MFloatArray& vArray, MIntArray& triPointIndices, MIntArray& triNormalIndices, MIntArray& triUvIndices, MIntArray& triMatIndices)
{
MStatus stat;
MObject meshObject = this->mobject;
MMeshSmoothOptions options;
MFnMesh tmpMesh(this->mobject, &stat);
MFnMeshData meshData;
MObject dataObject;
MObject smoothedObj;
// create smooth mesh if needed
if (tmpMesh.findPlug("displaySmoothMesh").asBool())
{
stat = tmpMesh.getSmoothMeshDisplayOptions(options);
if (stat)
{
if (!tmpMesh.findPlug("useSmoothPreviewForRender", false, &stat).asBool())
{
//Logging::debug(MString("useSmoothPreviewForRender turned off"));
int smoothLevel = tmpMesh.findPlug("renderSmoothLevel", false, &stat).asInt();
options.setDivisions(smoothLevel);
}
if (options.divisions() > 0)
{
dataObject = meshData.create();
smoothedObj = tmpMesh.generateSmoothMesh(dataObject, &options, &stat);
if (stat)
{
meshObject = smoothedObj;
}
}
}
}
MFnMesh meshFn(meshObject, &stat);
CHECK_MSTATUS(stat);
MItMeshPolygon faceIt(meshObject, &stat);
CHECK_MSTATUS(stat);
meshFn.getPoints(points);
meshFn.getNormals(normals, MSpace::kObject);
meshFn.getUVs(uArray, vArray);
uint numVertices = points.length();
uint numNormals = normals.length();
uint numUvs = uArray.length();
//Logging::debug(MString("numVertices ") + numVertices);
//Logging::debug(MString("numNormals ") + numNormals);
//Logging::debug(MString("numUvs ") + numUvs);
// some meshes may have no uv's
// to avoid problems I add a default uv coordinate
if (numUvs == 0)
{
Logging::warning(MString("Object has no uv's: ") + this->shortName);
uArray.append(0.0);
vArray.append(0.0);
}
for (uint nid = 0; nid < numNormals; nid++)
{
if (normals[nid].length() < 0.1f)
Logging::warning(MString("Malformed normal in ") + this->shortName);
}
MPointArray triPoints;
MIntArray triVtxIds;
MIntArray faceVtxIds;
MIntArray faceNormalIds;
for (faceIt.reset(); !faceIt.isDone(); faceIt.next())
{
int faceId = faceIt.index();
int numTris;
faceIt.numTriangles(numTris);
faceIt.getVertices(faceVtxIds);
int perFaceShadingGroup = 0;
if (this->perFaceAssignments.length() > 0)
perFaceShadingGroup = this->perFaceAssignments[faceId];
MIntArray faceUVIndices;
faceNormalIds.clear();
for (uint vtxId = 0; vtxId < faceVtxIds.length(); vtxId++)
{
faceNormalIds.append(faceIt.normalIndex(vtxId));
int uvIndex;
if (numUvs == 0)
{
faceUVIndices.append(0);
}
else{
faceIt.getUVIndex(vtxId, uvIndex);
//if (uvIndex > uArray.length())
// Logging::info(MString("-----------------> UV Problem!!! uvIndex ") + uvIndex + " > uvArray in object " + this->shortName);
faceUVIndices.append(uvIndex);
}
}
//.........这里部分代码省略.........
示例9: MAKE_INPUT
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus PhongNode::initialize()
{
MFnNumericAttribute nAttr;
MFnLightDataAttribute lAttr;
aTranslucenceCoeff = nAttr.create("translucenceCoeff", "tc",
MFnNumericData::kFloat);
MAKE_INPUT(nAttr);
aDiffuseReflectivity = nAttr.create("diffuseReflectivity", "drfl",
MFnNumericData::kFloat);
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setDefault(0.8f) );
aColor = nAttr.createColor( "color", "c" );
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.58824f, 0.644f) );
aIncandescence = nAttr.createColor( "incandescence", "ic" );
MAKE_INPUT(nAttr);
aOutColor = nAttr.createColor( "outColor", "oc" );
MAKE_OUTPUT(nAttr);
aPointCamera = nAttr.createPoint( "pointCamera", "pc" );
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) );
CHECK_MSTATUS ( nAttr.setHidden(true) );
aPower = nAttr.create( "power", "pow", MFnNumericData::kFloat);
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setMin(0.0f) );
CHECK_MSTATUS ( nAttr.setMax(200.0f) );
CHECK_MSTATUS ( nAttr.setDefault(10.0f) );
aSpecularity = nAttr.create( "specularity", "spc", MFnNumericData::kFloat);
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setMin(0.0f) );
CHECK_MSTATUS ( nAttr.setMax(1.0f) ) ;
CHECK_MSTATUS ( nAttr.setDefault(0.5f) );
aReflectGain = nAttr.create( "reflectionGain", "rg", MFnNumericData::kFloat);
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setMin(0.0f) );
CHECK_MSTATUS ( nAttr.setMax(1.0f) );
CHECK_MSTATUS ( nAttr.setDefault(0.5f) );
aNormalCamera = nAttr.createPoint( "normalCamera", "n" );
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) );
CHECK_MSTATUS ( nAttr.setHidden(true) );
aTriangleNormalCamera = nAttr.createPoint( "triangleNormalCamera", "tn" );
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f));
CHECK_MSTATUS ( nAttr.setHidden(true));
aLightDirection = nAttr.createPoint( "lightDirection", "ld" );
CHECK_MSTATUS ( nAttr.setStorable(false) );
CHECK_MSTATUS ( nAttr.setHidden(true) );
CHECK_MSTATUS ( nAttr.setReadable(true) );
CHECK_MSTATUS ( nAttr.setWritable(false) );
CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) );
aLightIntensity = nAttr.createColor( "lightIntensity", "li" );
CHECK_MSTATUS ( nAttr.setStorable(false) );
CHECK_MSTATUS ( nAttr.setHidden(true) );
CHECK_MSTATUS ( nAttr.setReadable(true) );
CHECK_MSTATUS ( nAttr.setWritable(false) );
CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) );
aLightAmbient = nAttr.create( "lightAmbient", "la",
MFnNumericData::kBoolean);
CHECK_MSTATUS ( nAttr.setStorable(false) );
CHECK_MSTATUS ( nAttr.setHidden(true) );
CHECK_MSTATUS ( nAttr.setReadable(true) );
CHECK_MSTATUS ( nAttr.setWritable(false) );
CHECK_MSTATUS ( nAttr.setHidden(true) );
aLightDiffuse = nAttr.create( "lightDiffuse", "ldf",
MFnNumericData::kBoolean);
CHECK_MSTATUS ( nAttr.setStorable(false) );
CHECK_MSTATUS ( nAttr.setHidden(true) );
CHECK_MSTATUS ( nAttr.setReadable(true) );
CHECK_MSTATUS ( nAttr.setWritable(false) );
aLightSpecular = nAttr.create( "lightSpecular", "ls",
MFnNumericData::kBoolean);
CHECK_MSTATUS ( nAttr.setStorable(false) );
CHECK_MSTATUS ( nAttr.setHidden(true) );
CHECK_MSTATUS ( nAttr.setReadable(true) );
CHECK_MSTATUS ( nAttr.setWritable(false) );
aLightShadowFraction = nAttr.create("lightShadowFraction", "lsf",
MFnNumericData::kFloat);
CHECK_MSTATUS ( nAttr.setStorable(false) );
CHECK_MSTATUS ( nAttr.setHidden(true) );
//.........这里部分代码省略.........
示例10: MAKE_INPUT
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus CheckerNode::initialize()
{
MFnNumericAttribute nAttr;
// Input attributes
aColor1 = nAttr.createColor("color1", "c1");
MAKE_INPUT(nAttr);
CHECK_MSTATUS(nAttr.setDefault(0., .58824, .644) ); // Light blue
aColor2 = nAttr.createColor("color2", "c2");
MAKE_INPUT(nAttr);
CHECK_MSTATUS(nAttr.setDefault(1., 1., 1.) ); // White
aBias = nAttr.create( "bias", "b", MFnNumericData::k2Float);
MAKE_INPUT(nAttr);
CHECK_MSTATUS(nAttr.setMin(0.0f, 0.0f) );
CHECK_MSTATUS(nAttr.setMax(1.0f, 1.0f) );
CHECK_MSTATUS(nAttr.setDefault(0.5f, 0.5f) );
// Implicit shading network attributes
MObject child1 = nAttr.create( "uCoord", "u", MFnNumericData::kFloat);
MObject child2 = nAttr.create( "vCoord", "v", MFnNumericData::kFloat);
aUVCoord = nAttr.create( "uvCoord","uv", child1, child2);
MAKE_INPUT(nAttr);
CHECK_MSTATUS(nAttr.setHidden(true) );
// Output attributes
aOutColor = nAttr.createColor("outColor", "oc");
MAKE_OUTPUT(nAttr);
aOutAlpha = nAttr.create( "outAlpha", "oa", MFnNumericData::kFloat);
MAKE_OUTPUT(nAttr);
// Add attributes to the node database.
CHECK_MSTATUS(addAttribute(aColor1));
CHECK_MSTATUS(addAttribute(aColor2));
CHECK_MSTATUS(addAttribute(aBias));
CHECK_MSTATUS(addAttribute(aUVCoord));
CHECK_MSTATUS(addAttribute(aOutColor));
CHECK_MSTATUS(addAttribute(aOutAlpha));
// All input affect the output color and alpha
CHECK_MSTATUS(attributeAffects (aColor1, aOutColor));
CHECK_MSTATUS(attributeAffects(aColor1, aOutAlpha));
CHECK_MSTATUS(attributeAffects (aColor2, aOutColor));
CHECK_MSTATUS(attributeAffects(aColor2, aOutAlpha));
CHECK_MSTATUS(attributeAffects(aBias, aOutColor));
CHECK_MSTATUS(attributeAffects(aBias, aOutAlpha));
CHECK_MSTATUS(attributeAffects (aUVCoord, aOutColor));
CHECK_MSTATUS(attributeAffects(aUVCoord, aOutAlpha));
return MS::kSuccess;
}
示例11: initializePlugin
MStatus initializePlugin(
MObject obj) {
MStatus status;
MFnPlugin plugin(obj, "Pixar", "1.0", "Any");
// we use lambdas to pass in MCreatorFunctions into the various Maya registration
// functions so that we can specify the static data that the registered
// shape/data/node should be using.
status = plugin.registerData(
_data.stageData.typeName,
_data.stageData.typeId,
[]() {
return UsdMayaStageData::creator(_data.stageData);
});
CHECK_MSTATUS(status);
status = plugin.registerShape(
_data.proxyShape.typeName,
_data.proxyShape.typeId,
[]() {
return UsdMayaProxyShape::creator(_data.proxyShape);
},
[]() {
return UsdMayaProxyShape::initialize(
&(_data.proxyShape));
},
UsdMayaProxyShapeUI::creator,
&UsdMayaProxyDrawOverride::sm_drawDbClassification);
CHECK_MSTATUS(status);
status = plugin.registerNode(
_data.referenceAssembly.typeName,
_data.referenceAssembly.typeId,
[]() {
return UsdMayaReferenceAssembly::creator(
_data.referenceAssembly);
},
[]() {
return UsdMayaReferenceAssembly::initialize(
&(_data.referenceAssembly));
},
MPxNode::kAssembly,
&UsdMayaReferenceAssembly::_classification);
CHECK_MSTATUS(status);
status =
MHWRender::MDrawRegistry::registerDrawOverrideCreator(
UsdMayaProxyDrawOverride::sm_drawDbClassification,
UsdMayaProxyDrawOverride::sm_drawRegistrantId,
UsdMayaProxyDrawOverride::Creator);
CHECK_MSTATUS(status);
status = MGlobal::sourceFile("usdMaya.mel");
CHECK_MSTATUS(status);
// Set the label for the assembly node type so that it appears correctly
// in the 'Create -> Scene Assembly' menu.
const MString assemblyTypeLabel("UsdReferenceAssembly");
MString setLabelCmd;
status = setLabelCmd.format("assembly -e -type ^1s -label ^2s",
_data.referenceAssembly.typeName,
assemblyTypeLabel);
CHECK_MSTATUS(status);
status = MGlobal::executeCommand(setLabelCmd);
CHECK_MSTATUS(status);
// Procs stored in usdMaya.mel
// Add assembly callbacks for accessing data without creating an MPxAssembly instance
status = MGlobal::executeCommand("assembly -e -repTypeLabelProc usdMaya_UsdMayaReferenceAssembly_repTypeLabel -type " + _data.referenceAssembly.typeName);
CHECK_MSTATUS(status);
status = MGlobal::executeCommand("assembly -e -listRepTypesProc usdMaya_UsdMayaReferenceAssembly_listRepTypes -type " + _data.referenceAssembly.typeName);
CHECK_MSTATUS(status);
// Attribute Editor Templates
// XXX: The try/except here is temporary until we change the Pixar-internal
// package name to match the external package name.
MString attribEditorCmd(
"try:\n"
" from pxr.UsdMaya import AEpxrUsdReferenceAssemblyTemplate\n"
"except ImportError:\n"
" from pixar.UsdMaya import AEpxrUsdReferenceAssemblyTemplate\n"
"AEpxrUsdReferenceAssemblyTemplate.addMelFunctionStubs()");
status = MGlobal::executePythonCommand(attribEditorCmd);
CHECK_MSTATUS(status);
status = plugin.registerCommand("usdExport",
usdExport::creator,
usdExport::createSyntax );
if (!status) {
status.perror("registerCommand usdExport");
}
status = plugin.registerCommand("usdImport",
[]() {
return usdImport::creator(_data.referenceAssembly.typeName.asChar(),
_data.proxyShape.typeName.asChar());
//.........这里部分代码省略.........
示例12: driver_meshVertIter
void TestDeformer::_deform_on_one_mesh(MDataBlock& data,
MItGeometry& iter,
const MMatrix& localToWorldMatrix,
unsigned int mIndex,
MObject &driver_mesh,
const MDataHandle &envelopeHandle, MArrayDataHandle &vertMapArrayData, MPointArray &tempOutputPts)
{
MStatus status;
float env = envelopeHandle.asFloat();
// use driver_meshVertIter to walk through the vertex of the current driver mesh
MItMeshVertex driver_meshVertIter( driver_mesh, &status );
CHECK_MSTATUS( status );
int i = 0;
iter.reset();
while( !iter.isDone(&status) )
{
CHECK_MSTATUS( status );
// get the weight
float weight = weightValue( data, mIndex, iter.index() ); //painted weight
float ww = weight * env;
if ( fabs(ww) > FLT_EPSILON )//if ( ww != 0 )
{
__debug("%s(), vertMapArrayData.elementCount()=%d, iter.index()=%d",
__FUNCTION__, vertMapArrayData.elementCount(), iter.index());
// get index_mapped to which the currrent vertex vI is mapped
CHECK_MSTATUS(vertMapArrayData.jumpToElement(iter.index()));
int index_mapped = vertMapArrayData.inputValue(&status).asInt();
CHECK_MSTATUS( status );
if( index_mapped >= 0 )
{
__debug("index_mapped=%d", index_mapped);
int prevInt;
CHECK_MSTATUS( driver_meshVertIter.setIndex(index_mapped, prevInt) );
// vertex wrold position on driver mesh
MPoint mappedPt = driver_meshVertIter.position( MSpace::kWorld, &status );
CHECK_MSTATUS( status );
// vertex wrold position on driven mesh
MPoint iterPt = iter.position(MSpace::kObject, &status) * localToWorldMatrix;
CHECK_MSTATUS( status );
// use ww to interpolate between mappedPt and iterPt
MPoint pt = iterPt + ((mappedPt - iterPt) * ww );
pt = pt * localToWorldMatrix.inverse();
/// put the deform points to tempOutputPts
tempOutputPts[i] += pt;
}
}//if
CHECK_MSTATUS(iter.next());
++i;
}//while
}
示例13: CHECK_MSTATUS
MStatus MayaToIndigoGlobals::initialize()
{
MayaRenderGlobalsNode::initialize();
MFnNumericAttribute nAttr;
MFnTypedAttribute tAttr;
MFnGenericAttribute gAttr;
MFnEnumAttribute eAttr;
MFnMessageAttribute mAttr;
MStatus stat = MStatus::kSuccess;
// ------------- automatically created attributes start ----------- //
white_point = eAttr.create("white_point", "white_point", 4, &stat);
stat = eAttr.addField( "User", 0 );
stat = eAttr.addField( "A", 1 );
stat = eAttr.addField( "B", 2 );
stat = eAttr.addField( "C", 3 );
stat = eAttr.addField( "D50", 4 );
stat = eAttr.addField( "D55", 5 );
stat = eAttr.addField( "D65", 6 );
stat = eAttr.addField( "D75", 7 );
stat = eAttr.addField( "E", 8 );
stat = eAttr.addField( "F1", 9 );
stat = eAttr.addField( "F2", 10 );
stat = eAttr.addField( "F3", 11 );
stat = eAttr.addField( "F4", 12 );
stat = eAttr.addField( "F5", 13 );
stat = eAttr.addField( "F6", 14 );
stat = eAttr.addField( "F7", 15 );
stat = eAttr.addField( "F8", 16 );
stat = eAttr.addField( "F9", 17 );
stat = eAttr.addField( "F10", 18 );
stat = eAttr.addField( "F11", 19 );
stat = eAttr.addField( "F12", 20 );
CHECK_MSTATUS(addAttribute( white_point ));
white_pointX = nAttr.create("white_pointX", "white_pointX", MFnNumericData::kFloat, 0.0);
CHECK_MSTATUS(addAttribute( white_pointX ));
white_pointY = nAttr.create("white_pointY", "white_pointY", MFnNumericData::kFloat, 0.0);
CHECK_MSTATUS(addAttribute( white_pointY ));
bih_tri_threshold = nAttr.create("bih_tri_threshold", "bih_tri_threshold", MFnNumericData::kInt, 1100000);
CHECK_MSTATUS(addAttribute( bih_tri_threshold ));
metropolis = nAttr.create("metropolis", "metropolis", MFnNumericData::kBoolean, true);
CHECK_MSTATUS(addAttribute( metropolis ));
large_mutation_prob = nAttr.create("large_mutation_prob", "large_mutation_prob", MFnNumericData::kFloat, 0.1);
CHECK_MSTATUS(addAttribute( large_mutation_prob ));
max_change = nAttr.create("max_change", "max_change", MFnNumericData::kFloat, .01);
CHECK_MSTATUS(addAttribute( max_change ));
max_num_consec_rejections = nAttr.create("max_num_consec_rejections", "max_num_consec_rejections", MFnNumericData::kInt, 1000);
CHECK_MSTATUS(addAttribute( max_num_consec_rejections ));
logging = nAttr.create("logging", "logging", MFnNumericData::kBoolean, true);
CHECK_MSTATUS(addAttribute( logging ));
path_tracing = eAttr.create("path_tracing", "path_tracing", 0, &stat);
stat = eAttr.addField( "bidirectional", 0 );
stat = eAttr.addField( "backwards", 1 );
CHECK_MSTATUS(addAttribute( path_tracing ));
tone_mapper = eAttr.create("tone_mapper", "tone_mapper", 1, &stat);
stat = eAttr.addField( "linear", 0 );
stat = eAttr.addField( "reinhard", 1 );
stat = eAttr.addField( "camera", 2 );
CHECK_MSTATUS(addAttribute( tone_mapper ));
tone_linearScale = nAttr.create("tone_linearScale", "tone_linearScale", MFnNumericData::kFloat, 1.0);
nAttr.setMin(0.0001);
nAttr.setMax(100);
CHECK_MSTATUS(addAttribute( tone_linearScale ));
tone_reinhardPreScale = nAttr.create("tone_reinhardPreScale", "tone_reinhardPreScale", MFnNumericData::kFloat, 1.0);
CHECK_MSTATUS(addAttribute( tone_reinhardPreScale ));
tone_reinhardPostScale = nAttr.create("tone_reinhardPostScale", "tone_reinhardPostScale", MFnNumericData::kFloat, 1.0);
CHECK_MSTATUS(addAttribute( tone_reinhardPostScale ));
tone_reinhardBurn = nAttr.create("tone_reinhardBurn", "tone_reinhardBurn", MFnNumericData::kFloat, 10.0);
CHECK_MSTATUS(addAttribute( tone_reinhardBurn ));
tone_cameraResponse_function_path = tAttr.create("tone_cameraResponse_function_path", "tone_cameraResponse_function_path", MFnNumericData::kString);
CHECK_MSTATUS(addAttribute( tone_cameraResponse_function_path ));
tone_cameraEv_adjust = nAttr.create("tone_cameraEv_adjust", "tone_cameraEv_adjust", MFnNumericData::kFloat, 0.0);
CHECK_MSTATUS(addAttribute( tone_cameraEv_adjust ));
tone_cameraFilm_iso = nAttr.create("tone_cameraFilm_iso", "tone_cameraFilm_iso", MFnNumericData::kFloat, 200.0);
CHECK_MSTATUS(addAttribute( tone_cameraFilm_iso ));
save_untonemapped_exr = nAttr.create("save_untonemapped_exr", "save_untonemapped_exr", MFnNumericData::kBoolean, false);
CHECK_MSTATUS(addAttribute( save_untonemapped_exr ));
save_tonemapped_exr = nAttr.create("save_tonemapped_exr", "save_tonemapped_exr", MFnNumericData::kBoolean, true);
//.........这里部分代码省略.........
示例14: resultColor
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus PhongNode::compute(
const MPlug& plug,
MDataBlock& block )
{
if ((plug != aOutColor) && (plug.parent() != aOutColor))
return MS::kUnknownParameter;
MFloatVector resultColor(0.0,0.0,0.0);
// get sample surface shading parameters
MFloatVector& surfaceNormal = block.inputValue( aNormalCamera ).asFloatVector();
MFloatVector& cameraPosition = block.inputValue( aPointCamera ).asFloatVector();
// use for raytracing api enhancement below
MFloatVector point = cameraPosition;
MFloatVector normal = surfaceNormal;
MFloatVector& surfaceColor = block.inputValue( aColor ).asFloatVector();
MFloatVector& incandescence = block.inputValue( aIncandescence ).asFloatVector();
float diffuseReflectivity = block.inputValue( aDiffuseReflectivity ).asFloat();
// float translucenceCoeff = block.inputValue( aTranslucenceCoeff ).asFloat();
// User-defined Reflection Color Gain
float reflectGain = block.inputValue( aReflectGain ).asFloat();
// Phong shading attributes
float power = block.inputValue( aPower ).asFloat();
float spec = block.inputValue( aSpecularity ).asFloat();
float specularR, specularG, specularB;
float diffuseR, diffuseG, diffuseB;
diffuseR = diffuseG = diffuseB = specularR = specularG = specularB = 0.0;
// get light list
MArrayDataHandle lightData = block.inputArrayValue( aLightData );
int numLights = lightData.elementCount();
// iterate through light list and get ambient/diffuse values
for( int count=1; count <= numLights; count++ )
{
MDataHandle currentLight = lightData.inputValue();
MFloatVector& lightIntensity = currentLight.child(aLightIntensity).asFloatVector();
// Find the blind data
void*& blindData = currentLight.child( aLightBlindData ).asAddr();
// find ambient component
if( currentLight.child(aLightAmbient).asBool() ) {
diffuseR += lightIntensity[0];
diffuseG += lightIntensity[1];
diffuseB += lightIntensity[2];
}
MFloatVector& lightDirection = currentLight.child(aLightDirection).asFloatVector();
if ( blindData == NULL )
{
// find diffuse and specular component
if( currentLight.child(aLightDiffuse).asBool() )
{
float cosln = lightDirection * surfaceNormal;;
if( cosln > 0.0f ) // calculate only if facing light
{
diffuseR += lightIntensity[0] * ( cosln * diffuseReflectivity );
diffuseG += lightIntensity[1] * ( cosln * diffuseReflectivity );
diffuseB += lightIntensity[2] * ( cosln * diffuseReflectivity );
}
CHECK_MSTATUS( cameraPosition.normalize() );
if( cosln > 0.0f ) // calculate only if facing light
{
float RV = ( ( (2*surfaceNormal) * cosln ) - lightDirection ) * cameraPosition;
if( RV > 0.0 ) RV = 0.0;
if( RV < 0.0 ) RV = -RV;
if ( power < 0 ) power = -power;
float s = spec * powf( RV, power );
specularR += lightIntensity[0] * s;
specularG += lightIntensity[1] * s;
specularB += lightIntensity[2] * s;
}
}
}
else
{
float cosln = MRenderUtil::diffuseReflectance( blindData, lightDirection, point, surfaceNormal, true );
if( cosln > 0.0f ) // calculate only if facing light
{
diffuseR += lightIntensity[0] * ( cosln * diffuseReflectivity );
diffuseG += lightIntensity[1] * ( cosln * diffuseReflectivity );
diffuseB += lightIntensity[2] * ( cosln * diffuseReflectivity );
}
CHECK_MSTATUS ( cameraPosition.normalize() );
//.........这里部分代码省略.........
示例15: CHECK_MSTATUS
MStatus progressWindowPlugin::doIt(const MArgList &args)
{
MStatus stat = MS::kSuccess;
MString title = "Doing Nothing";
MString sleeping = "Sleeping: ";
int amount = 0;
int maxProgress = 10;
// First reserve the progress window. If a progress window is already
// active (eg. through the mel "progressWindow" command), this command
// fails.
//
if (!MProgressWindow::reserve())
{
MGlobal::displayError("Progress window already in use.");
stat = MS::kFailure;
return stat;
}
//
// Set up and print progress window state
//
CHECK_MSTATUS(MProgressWindow::setProgressRange(amount, maxProgress));
CHECK_MSTATUS(MProgressWindow::setTitle(title));
CHECK_MSTATUS(MProgressWindow::setInterruptable(true));
CHECK_MSTATUS(MProgressWindow::setProgress(amount));
MString progressWindowState = MString("Progress Window Info:") +
MString("\nMin: ") + MProgressWindow::progressMin() +
MString("\nMax: ") + MProgressWindow::progressMax() +
MString("\nTitle: ") + MProgressWindow::title() +
MString("\nInterruptible: ") + MProgressWindow::isInterruptable();
MGlobal::displayInfo(progressWindowState);
CHECK_MSTATUS(MProgressWindow::startProgress());
// Count 10 seconds
//
for (int i = amount; i < maxProgress; i++)
{
if (i != 0 && MProgressWindow::isCancelled()) {
MGlobal::displayInfo("Progress interrupted!");
break;
}
MString statusStr = sleeping;
statusStr += i;
CHECK_MSTATUS(MProgressWindow::setProgressStatus(statusStr));
CHECK_MSTATUS(MProgressWindow::advanceProgress(1));
MGlobal::displayInfo(MString("Current progress: ") + MProgressWindow::progress());
MGlobal::executeCommand("pause -sec 1", false, false);
}
// End the progress, unreserving the progress window so it can be used
// elsewhere.
//
CHECK_MSTATUS(MProgressWindow::endProgress());
return stat;
}