本文整理汇总了C++中MItGeometry::count方法的典型用法代码示例。如果您正苦于以下问题:C++ MItGeometry::count方法的具体用法?C++ MItGeometry::count怎么用?C++ MItGeometry::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MItGeometry
的用法示例。
在下文中一共展示了MItGeometry::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deform
MStatus mapBlendShape::deform(MDataBlock& data,
MItGeometry& itGeo,
const MMatrix& localToWorldMatrix,
unsigned int geomIndex)
{
MStatus status;
// get the blendMesh
MDataHandle hBlendMesh = data.inputValue( aBlendMesh, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MObject oBlendMesh = hBlendMesh.asMesh();
if (oBlendMesh.isNull())
{
return MS::kSuccess;
}
MFnMesh fnMesh( oBlendMesh, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MPointArray blendPoints;
fnMesh.getPoints( blendPoints );
// get the dirty flags for the input and blendMap
bool inputGeomClean = data.isClean(inputGeom, &status);
bool blendMapClean = data.isClean(aBlendMap, &status);
if (!blendMapClean) {
lumValues.reserve(itGeo.count());
}
MDoubleArray uCoords, vCoords;
MVectorArray resultColors;
MDoubleArray resultAlphas;
uCoords.setLength(1);
vCoords.setLength(1);
bool hasTextureNode;
bool useBlendMap = data.inputValue(aUseBlendMap).asBool();
float blendMapMultiplier = data.inputValue(aBlendMapMultiplier).asFloat();
if (blendMapMultiplier<=0.0) {
useBlendMap = false;
}
if (useBlendMap) {
hasTextureNode = MDynamicsUtil::hasValidDynamics2dTexture(thisMObject(), aBlendMap);
}
float env = data.inputValue(envelope).asFloat();
MPoint point;
float2 uvPoint;
float w, lum;
for ( ; !itGeo.isDone(); itGeo.next() )
{
lum = 1.0;
if (useBlendMap) {
if (!blendMapClean) {
fnMesh.getUVAtPoint(blendPoints[itGeo.index()], uvPoint);
if (hasTextureNode) {
uCoords[0] = uvPoint[0];
vCoords[0] = uvPoint[1];
MDynamicsUtil::evalDynamics2dTexture(thisMObject(), aBlendMap, uCoords, vCoords, &resultColors, &resultAlphas);
lum = float(resultColors[0][0]);
}
lumValues[itGeo.index()] = lum;
} else {
lum = lumValues[itGeo.index()];
}
}
point = itGeo.position();
w = weightValue( data, geomIndex, itGeo.index() );
point += (blendPoints[itGeo.index()] - point) * env * w * lum * blendMapMultiplier;
itGeo.setPosition( point );
}
return MS::kSuccess;
}
示例2: deform
MStatus PushDeformer::deform(MDataBlock& dataBlock,
MItGeometry& itGeo,
const MMatrix& localToWorldMatrix,
unsigned int geomIndex)
{
MStatus status;
//get attribute handles
double bulgeAmount = dataBlock.inputValue(aAmount, &status).asDouble();
CHECK_MSTATUS_AND_RETURN_IT(status);
m_taskData.envelope = dataBlock.inputValue(envelope, &status).asFloat();
CHECK_MSTATUS_AND_RETURN_IT(status);
bool useStressV = dataBlock.inputValue(aUseStress, &status).asBool();
CHECK_MSTATUS_AND_RETURN_IT(status);
int multiThreadingType = dataBlock.inputValue(aMultiThreadingType, &status).asBool();
CHECK_MSTATUS_AND_RETURN_IT(status);
if (m_taskData.envelope <= 0.001)
{
return MS::kSuccess;
}
// if the use stress plug is turned on pull
MDoubleArray stressV;
if (useStressV == true)
{
//pull out the raw data as an Mobject
MObject stressMap = dataBlock.inputValue(aStressMap, &status).data();
CHECK_MSTATUS_AND_RETURN_IT(status);
MFnDoubleArrayData stressDataFn(stressMap);
m_taskData.stressV = stressDataFn.array();
}
//retrieve the handle to the output array attribute
MArrayDataHandle hInput = dataBlock.outputArrayValue(input, &status);
CHECK_MSTATUS_AND_RETURN_IT(status);
//get the input array index handle
status = hInput.jumpToElement(geomIndex);
//get the handle of geomIndex attribute
MDataHandle hInputElement = hInput.outputValue(&status);
CHECK_MSTATUS_AND_RETURN_IT(status);
//Get the MObject of the input geometry of geomindex
MObject oInputGeom = hInputElement.child(inputGeom).asMesh();
MFnMesh fnMesh(oInputGeom, &status);
CHECK_MSTATUS_AND_RETURN_IT(status);
fnMesh.getVertexNormals(false, m_taskData.normals, MSpace::kWorld);
itGeo.allPositions(m_taskData.points, MSpace::kWorld);
//MGlobal::displayInfo( "test" );
/*for (int i = 0; i < itGeo.count(); i++)
{
MGlobal::displayInfo( MFnAttribute(weightList).isArray );
}*/
m_taskData.bulgeAmount = bulgeAmount;
if(multiThreadingType == 1)
{
ThreadData* pThreadData = createThreadData( NUM_TASKS, &m_taskData );
MThreadPool::newParallelRegion( createTasks, (void*)pThreadData );
itGeo.setAllPositions(m_taskData.points);
delete [] pThreadData;
return MS::kSuccess;
}
else if(multiThreadingType == 2)
{
tbb::parallel_for(size_t(0), size_t(itGeo.count()), [this](size_t i)
{
//const float w = weightValue(dataBlock, geomIndex, i);
const float w = 1.0;
if (m_taskData.useStressV == true && (m_taskData.stressV.length() > 0))
{
//deform
m_taskData.points[i] += (MVector(m_taskData.normals[i]) * m_taskData.bulgeAmount * m_taskData.envelope * w * m_taskData.stressV[i]);
}
else
{
//deform
m_taskData.points[i] += m_taskData.normals[i] * m_taskData.bulgeAmount * m_taskData.envelope * w;
}
});
}
//
else if(multiThreadingType == 3)
#pragma omp parallel for
for (int i = 0; i < itGeo.count(); i++)
{
float w = weightValue(dataBlock, geomIndex, itGeo.index());
if (useStressV == true && (stressV.length() > 0))
{
//deform
m_taskData.points[i] += (MVector(m_taskData.normals[i]) * bulgeAmount * m_taskData.envelope * w * m_taskData.stressV[i]);
}
else
{
//.........这里部分代码省略.........
示例3: deform
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;
//.........这里部分代码省略.........
示例4: initVertMapping
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 ));
}
示例5: deform
MStatus puttyNode::deform( MDataBlock& block, MItGeometry& iter, const MMatrix& worldMatrix, unsigned int multiIndex)
{
// MGlobal::displayInfo("deform");
MStatus status = MS::kSuccess;
/////////////////////////////////////////////////////////////////////////////////////////////////
//
// get inputs
//
// get the node ready flag
MDataHandle dh = block.inputValue(aScriptSourced,&status);
SYS_ERROR_CHECK(status, "Error getting aScriptSourced data handle\n");
bool scriptSourced = dh.asBool();
if (!scriptSourced)
return MS::kSuccess;
dh = block.inputValue(aNodeReady,&status);
SYS_ERROR_CHECK(status, "Error getting node ready data handle\n");
bool nodeReady = dh.asBool();
// if it's not ready, don't do anything
if (!nodeReady)
return MS::kSuccess;
dh = block.inputValue(aDefSpace,&status);
SYS_ERROR_CHECK(status, "Error getting defSpace data handle\n");
short defSpace = dh.asShort();
dh = block.inputValue(aDefWeights,&status);
SYS_ERROR_CHECK(status, "Error getting defWeights data handle\n");
short defWeights = dh.asShort();
dh = block.inputValue(aDefEnvelope,&status);
SYS_ERROR_CHECK(status, "Error getting defEnvelope data handle\n");
short defEnvelope = dh.asShort();
// get the command
dh = block.inputValue(aCmdBaseName,&status);
SYS_ERROR_CHECK(status, "Error getting aCmdBaseName handle\n");
MString script = dh.asString();
/* if (script == "")
{
status = MS::kFailure;
USER_ERROR_CHECK(status, "no script provided!\n");
}
*/
/////////////////////////////////////////////////////////////////////////////////////////////////
//
// build mel cmd string
//
// check if it's a valid cmd
// get the envelope
//
double env = 1;
if (defEnvelope == MSD_ENVELOPE_AUTO)
{
dh = block.inputValue(envelope,&status);
SYS_ERROR_CHECK(status, "Error getting envelope data handle\n");
env = double(dh.asFloat());
// early stop 'cause there is nothing more to do
if (env == 0.0)
return MS::kSuccess;
}
// get the points, transform them into the right space if needed
//
int count = iter.count();
MVectorArray points(count);
for ( ; !iter.isDone(); iter.next())
points[iter.index()] = iter.position();
if ( defSpace == MSD_SPACE_WORLD )
{
for (int i = 0;i<count;i++)
points[i] = MPoint(points[i]) * worldMatrix;
}
// get the weights
//
MDoubleArray weights;
if ( defWeights == MSD_WEIGHTS_AUTO)
{
weights.setLength(count);
for (int i = 0;i<count;i++)
weights[i] = weightValue(block,multiIndex,i);
}
//.........这里部分代码省略.........