本文整理汇总了C++中MItGeometry::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ MItGeometry::setPosition方法的具体用法?C++ MItGeometry::setPosition怎么用?C++ MItGeometry::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MItGeometry
的用法示例。
在下文中一共展示了MItGeometry::setPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deform
MStatus SwirlDeformer::deform( MDataBlock& block, MItGeometry &iter,
const MMatrix &localToWorld, unsigned int geomIndex )
{
MStatus stat;
MDataHandle envData = block.inputValue( envelope );
float env = envData.asFloat();
if( env == 0.0 ) // Deformer has no effect
return MS::kSuccess;
MDataHandle matData = block.inputValue( deformSpace );
MMatrix mat = matData.asMatrix();
MMatrix invMat = mat.inverse();
MDataHandle startDistHnd = block.inputValue( startDist );
double startDist = startDistHnd.asDouble();
MDataHandle endDistHnd = block.inputValue( endDist );
double endDist = endDistHnd.asDouble();
MPoint pt;
float weight;
double dist;
double ang;
double cosAng;
double sinAng;
double x;
double distFactor;
for( iter.reset(); !iter.isDone(); iter.next() )
{
weight = weightValue( block, geomIndex, iter.index() );
if( weight == 0.0f )
continue;
pt = iter.position();
pt *= invMat;
dist = sqrt( pt.x * pt.x + pt.z * pt.z );
if( dist < startDist || dist > endDist )
continue;
distFactor = 1 - ((dist - startDist) / (endDist - startDist));
ang = distFactor * M_PI * 2.0 * env * weight;
if( ang == 0.0 )
continue;
cosAng = cos( ang );
sinAng = sin( ang );
x = pt.x * cosAng - pt.z * sinAng;
pt.z = pt.x * sinAng + pt.z * cosAng;
pt.x = x;
pt *= mat;
iter.setPosition( pt );
}
return stat;
}
示例2: skinLB
MStatus HRBFSkinCluster::skinLB(MMatrixArray& transforms,
int numTransforms,
MArrayDataHandle& weightListHandle,
MItGeometry& iter) {
MStatus returnStatus;
// Iterate through each point in the geometry.
//
for (; !iter.isDone(); iter.next()) {
MPoint pt = iter.position();
MPoint skinned;
// get the weights for this point -> must be dependent on the iterator somehow
MArrayDataHandle weightsHandle = weightListHandle.inputValue().child(weights);
// compute the skinning -> TODO: what's the order that the weights are given in? Appears to just be maya list relatives order.
for (int i = 0; i<numTransforms; ++i) {
if (MS::kSuccess == weightsHandle.jumpToElement(i)) {
skinned += (pt * transforms[i]) * weightsHandle.inputValue().asDouble();
}
}
// Set the final position.
iter.setPosition(skinned);
// advance the weight list handle
weightListHandle.next();
}
return returnStatus;
}
示例3:
MStatus
identityNode::deform( MDataBlock& block,
MItGeometry& iter,
const MMatrix& /*m*/,
unsigned int multiIndex)
//
// Method: deform
//
// Description: "Deforms" the point with an identity transformation
//
// Arguments:
// block : the datablock of the node
// iter : an iterator for the geometry to be deformed
// m : matrix to transform the point into world space
// multiIndex : the index of the geometry that we are deforming
//
//
{
MStatus returnStatus;
// Iterate through each point in the geometry.
//
for ( ; !iter.isDone(); iter.next()) {
MPoint pt = iter.position();
// Perform some calculation on pt.
// ...
// Set the final position.
iter.setPosition(pt);
}
return returnStatus;
}
示例4: weightValue
MStatus
offset::deform( MDataBlock& block,
MItGeometry& iter,
const MMatrix& /*m*/,
unsigned int multiIndex)
//
// Method: deform
//
// Description: Deform the point with a squash algorithm
//
// Arguments:
// block : the datablock of the node
// iter : an iterator for the geometry to be deformed
// m : matrix to transform the point into world space
// multiIndex : the index of the geometry that we are deforming
//
//
{
MStatus returnStatus;
// Envelope data from the base class.
// The envelope is simply a scale factor.
//
MDataHandle envData = block.inputValue(envelope, &returnStatus);
if (MS::kSuccess != returnStatus) return returnStatus;
float env = envData.asFloat();
// Get the matrix which is used to define the direction and scale
// of the offset.
//
MDataHandle matData = block.inputValue(offsetMatrix, &returnStatus );
if (MS::kSuccess != returnStatus) return returnStatus;
MMatrix omat = matData.asMatrix();
MMatrix omatinv = omat.inverse();
// iterate through each point in the geometry
//
for ( ; !iter.isDone(); iter.next()) {
MPoint pt = iter.position();
pt *= omatinv;
float weight = weightValue(block,multiIndex,iter.index());
// offset algorithm
//
pt.y = pt.y + env*weight;
//
// end of offset algorithm
pt *= omat;
iter.setPosition(pt);
}
return returnStatus;
}
示例5: deform
MStatus RippleDeformer::deform(MDataBlock& dataBlock,
MItGeometry& itGeo,
const MMatrix& localToWorldMatrix,
unsigned int geomIndex)
{
MStatus status;
//get attriubtes as a datahandle
float env = dataBlock.inputValue(envelope).asFloat();
float amplitude = dataBlock.inputValue(aAmplitude).asFloat();
float displace = dataBlock.inputValue(aDisplace).asFloat();
//get the mesh
//retrieve the handle to the input 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);
//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);
if (oInputGeom.isNull())
{
return MS::kSuccess;
}
MFloatVectorArray normals;
fnMesh.getVertexNormals(false, normals);
MPoint pointPos;
float weight;
for (; !itGeo.isDone(); itGeo.next())
{
//get current point position
pointPos = itGeo.position();
weight = weightValue(dataBlock, geomIndex, itGeo.index());
pointPos.x = pointPos.x + sin(itGeo.index() + displace) * amplitude * normals[itGeo.index()].x * weight * env;
pointPos.y = pointPos.y + sin(itGeo.index() + displace) * amplitude * normals[itGeo.index()].y * weight * env;
pointPos.z = pointPos.z + sin(itGeo.index() + displace) * amplitude * normals[itGeo.index()].z * weight * env;
//setPosition
itGeo.setPosition(pointPos);
}
return MS::kSuccess;
}
示例6: deform
MStatus DucttapeMergeDeformer::deform( MDataBlock& block,
MItGeometry& iter,
const MMatrix& m,
unsigned int multiIndex)
{
MStatus status;
MDataHandle envData = block.inputValue(envelope,&status);
const float env = envData.asFloat();
if(env < 1e-3f) return status;
if(multiIndex == 0) {
if(m_inputGeomIter) {
delete m_inputGeomIter;
m_inputGeomIter = NULL;
}
MDataHandle hmesh = block.inputValue(ainmesh);
MItGeometry * aiter = new MItGeometry( hmesh, true, &status );
if(!status) {
AHelper::Info<int>("DucttapeMergeDeformer error no geom it", 0);
return status;
}
m_inputGeomIter = aiter;
}
if(!m_inputGeomIter) return status;
MPoint pd;
MVector dv;
for (; !iter.isDone(); iter.next()) {
if(m_inputGeomIter->isDone() ) return status;
float wei = env * weightValue(block, multiIndex, iter.index() );
if(wei > 1e-3f) {
pd = iter.position();
dv = m_inputGeomIter->position() - pd;
pd = pd + dv * wei;
iter.setPosition(pd);
}
m_inputGeomIter->next();
}
return status;
}
示例7: deform
// COMPUTE ======================================
MStatus gear_curveCns::deform( MDataBlock& data, MItGeometry& iter, const MMatrix &mat, unsigned int mIndex )
{
MStatus returnStatus;
MArrayDataHandle adh = data.inputArrayValue( inputs );
int deformer_count = adh.elementCount( &returnStatus );
// Process
while (! iter.isDone()){
if (iter.index() < deformer_count){
adh.jumpToElement(iter.index());
MTransformationMatrix m(adh.inputValue().asMatrix() * mat.inverse());
MVector v = m.getTranslation(MSpace::kWorld, &returnStatus );
MPoint pt(v);
iter.setPosition(pt);
}
iter.next();
}
return MS::kSuccess;
}
示例8: deform
//.........这里部分代码省略.........
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++)
{
// convert to world
oldMeshPositionsA[i] = oldMeshPositionsA[i] * m;
}
oldMeshPositionsB.copy(oldMeshPositionsA);
oldMeshPositionsC.copy(oldMeshPositionsA); // cache
oldMeshPositionsD.copy(oldMeshPositionsA); // cache
}
// get back old date again
if (bTweakblur == true) { // restore cache
oldMeshPositionsA.copy(oldMeshPositionsC);
oldMeshPositionsB.copy(oldMeshPositionsD);
}
iter.allPositions(savedPoints);
for(int i=0; i < savedPoints.length(); i++)
{
// convert points to world points
savedPoints[i] = savedPoints[i] * m;
}
// Actual Iteration through points
for (; !iter.isDone(); iter.next()){
// get current position
ptA = iter.position();
// get old positions
ptB = oldMeshPositionsA[iter.index()] * matInv;
ptC = oldMeshPositionsB[iter.index()] * matInv;
fDistance = ptA.distanceTo(ptB);
fW = weightValue(block,multiIndex,iter.index());
if (fDistance * (fStrength*fW) < fThreshold && fThreshold > 0){
iter.setPosition(ptA);
} else {
// aim/direction vector to calculate strength
dirVector = (ptA - ptB); // (per punt)
dirVector.normalize();
normal = currentNormals[iter.index()];
dDotProduct = normal.x * dirVector.x + normal.y * dirVector.y + normal.z * dirVector.z;
if(bQuad == true){
MVector vecA(((ptB - ptC) + (ptA - ptB)) / 2);
vecA.normalize();
MPoint hiddenPt(ptB + (vecA * fDistance) * dKracht);
ptA = quadInterpBetween(ptB, hiddenPt, ptA, (1 - fStrength * fW) + (linearInterp(dDotProduct, -1, 1) * (fStrength * fW) ) );
} else {
MPoint halfway = (ptA - ptB) * 0.5;
MPoint offset = halfway * dDotProduct * (fStrength*fW);
ptA = ptA - ((halfway * (fStrength*fW)) - offset); // + (offset * strength);
}
// set new value
iter.setPosition(ptA);
}
}
if(bTweakblur == false){
oldMeshPositionsD.copy(oldMeshPositionsB);
oldMeshPositionsC.copy(oldMeshPositionsA);
oldMeshPositionsB.copy(oldMeshPositionsA);
oldMeshPositionsA.copy(savedPoints);
// Save back to plugs
objOldMeshA = fnPoints.create(oldMeshPositionsA);
objOldMeshB = fnPoints.create(oldMeshPositionsB);
objOldMeshC = fnPoints.create(oldMeshPositionsC);
objOldMeshD = fnPoints.create(oldMeshPositionsD);
oldMeshPositionsAPlug.setValue(objOldMeshA);
oldMeshPositionsBPlug.setValue(objOldMeshB);
oldMeshPositionsCPlug.setValue(objOldMeshC);
oldMeshPositionsDPlug.setValue(objOldMeshD);
}
return returnStatus;
}
示例9: McheckErr
//.........这里部分代码省略.........
{
MStatus status = MS::kSuccess;
// It's a fake data access try to workaround strange behavior on x86_64 linux systems...
MDataHandle dummyData = block.inputValue(dummy,&status);
MDataHandle lev_MampData = block.inputValue(lev_Mamp,&status);
McheckErr(status, "Error getting lev_Mamp data handle\n");
double _lev_Mamp = lev_MampData.asDouble();
MDataHandle lev_MfreqData = block.inputValue(lev_Mfreq,&status);
McheckErr(status, "Error getting lev_Mfreq data handle\n");
double lev_Mfreq = lev_MfreqData.asDouble();
MDataHandle levelsData = block.inputValue(levels,&status);
McheckErr(status, "Error getting frequency data handle\n");
short levels = levelsData.asShort();
MDataHandle scaleData = block.inputValue(scale,&status);
McheckErr(status, "Error getting scale data handle\n");
double scale = scaleData.asDouble();
MDataHandle scaleAmpXData = block.inputValue(scaleAmpX,&status);
McheckErr(status, "Error getting scaleAmpX data handle\n");
double scaleAmpX = scaleAmpXData.asDouble();
MDataHandle scaleAmpYData = block.inputValue(scaleAmpY,&status);
McheckErr(status, "Error getting scaleAmpY data handle\n");
double scaleAmpY = scaleAmpYData.asDouble();
MDataHandle scaleAmpZData = block.inputValue(scaleAmpZ,&status);
McheckErr(status, "Error getting scaleAmpZ data handle\n");
double scaleAmpZ = scaleAmpZData.asDouble();
MDataHandle scaleFreqXData = block.inputValue(scaleFreqX,&status);
McheckErr(status, "Error getting scaleFreqX data handle\n");
double scaleFreqX = scaleFreqXData.asDouble();
MDataHandle scaleFreqYData = block.inputValue(scaleFreqY,&status);
McheckErr(status, "Error getting scaleFreqY data handle\n");
double scaleFreqY = scaleFreqYData.asDouble();
MDataHandle scaleFreqZData = block.inputValue(scaleFreqZ,&status);
McheckErr(status, "Error getting scaleFreqZ data handle\n");
double scaleFreqZ = scaleFreqZData.asDouble();
MDataHandle variationData = block.inputValue(variation,&status);
McheckErr(status, "Error getting variation data handle\n");
double variation = variationData.asDouble();
MDataHandle envData = block.inputValue(envelope,&status);
McheckErr(status, "Error getting envelope data handle\n");
double env = envData.asDouble();
MDataHandle amplitudeData = block.inputValue(amplitude,&status);
McheckErr(status, "Error getting amplitude data handle\n");
double amplitude = amplitudeData.asDouble();
MDataHandle frequencyData = block.inputValue(frequency,&status);
McheckErr(status, "Error getting frequency data handle\n");
double frequency = frequencyData.asDouble();
amplitude = amplitude * scale;
frequency = frequency * 0.01 / scale;
for ( ; !iter.isDone(); iter.next()) {
MPoint pt = iter.position();
vector noisePnt;
noisePnt.x = 0;
noisePnt.y = 0;
noisePnt.z = 0;
double l_amp = amplitude;
double x = scaleFreqX * pt.x * frequency;
double y = scaleFreqY * pt.y * frequency;
double z = scaleFreqZ * pt.z * frequency;
for( int lev = 0; lev < levels; lev++)
{
x *= lev_Mfreq;
y *= lev_Mfreq;
z *= lev_Mfreq;
vector lev_Pnt = INoise::noise4d_v(x, y, z, variation);
noisePnt.x += lev_Pnt.x * l_amp;
noisePnt.y += lev_Pnt.y * l_amp;
noisePnt.z += lev_Pnt.z * l_amp;
l_amp *= _lev_Mamp;
}
pt.x += noisePnt.x * scaleAmpX;
pt.y += noisePnt.y * scaleAmpY;
pt.z += noisePnt.z * scaleAmpZ;
iter.setPosition(pt);
}
return status;
}
示例10: 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;
}
示例11: deform
/*!
* Description: Deform the point using the Sederberg-Parry FFD algorithm.
*
* Arguments:
* block : the datablock of the node
* iter : an iterator for the geometry to be deformed
* m : matrix to transform the point into world space
* multiIndex : the index of the geometry that we are deforming
*/
MStatus ffdPlanar::deform( MDataBlock& block,
MItGeometry& iter,
const MMatrix& /*m*/,
unsigned int multiIndex )
{
MStatus status = MS::kSuccess;
// Determine the displacement lattice points.
MDataHandle row1Data = block.inputValue( latticeRow1, &status );
MCheckErr( status, "Error getting r1 data handle\n" );
MVector row1Vector = row1Data.asVector();
MDataHandle row2Data = block.inputValue( latticeRow2, &status );
MCheckErr( status, "Error getting r2 data handle\n" );
MVector row2Vector = row2Data.asVector();
MDataHandle row3Data = block.inputValue( latticeRow3, &status );
MCheckErr( status, "Error getting r3 data\n" );
MVector row3Vector = row3Data.asVector();
// Determine the envelope (this is a global scale factor for the deformer).
MDataHandle envData = block.inputValue(envelope,&status);
MCheckErr(status, "Error getting envelope data handle\n");
float env = envData.asFloat();
// Generate the FFD lattice.
MVector lattice[FFD_LATTICE_POINTS_S][FFD_LATTICE_POINTS_T][FFD_LATTICE_POINTS_U] = { // Since dimensions known ahead of time, generate array now.
{ // x = 0
{ MVector(0.f, row1Vector.x, 0.f), MVector(0.f, row1Vector.y, .5f), MVector(0.f, row1Vector.z, 1.f) }, // y = 0
},
{ // x = 1
{ MVector(.5f, row2Vector.x, 0.f), MVector(.5f, row2Vector.y, .5f), MVector(.5f, row2Vector.z, 1.f) }, // y = 0
},
{ // x = 2
{ MVector(1.f, row3Vector.x, 0.f), MVector(1.f, row3Vector.y, .5f), MVector(1.f, row3Vector.z, 1.f) }, // y = 0
}
};
MBoundingBox boundingBox;
status = getBoundingBox( block, multiIndex, boundingBox );
MCheckErr( status, "Error getting bounding box\n" );
MTransformationMatrix transform = getXyzToStuTransformation( boundingBox );
MMatrix transformMatrix = transform.asMatrix();
MMatrix inverseMatrix = transform.asMatrixInverse();
// Iterate through each point in the geometry.
for ( ; !iter.isDone(); iter.next() )
{
MPoint pt = iter.position();
MPoint ptStu = pt * transformMatrix;
MPoint deformed = getDeformedPoint( ptStu, lattice ) * inverseMatrix;
if ( env != 1.f )
{
MVector diff = deformed - pt;
deformed = pt + env * diff;
}
iter.setPosition( deformed );
}
return status;
}
示例12: 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;
//.........这里部分代码省略.........
示例13: deform
MStatus snapDeformer::deform(MDataBlock &data, MItGeometry &iter, const MMatrix &mat, unsigned int multiIndex) {
MStatus stat;
//lets see if we need to do anything
MDataHandle DataHandle = data.inputValue(envelope, &stat);
float env = DataHandle.asFloat();
if (env == 0)
return stat;
DataHandle = data.inputValue(weight, &stat);
const float weight = DataHandle.asFloat();
if (weight == 0)
return stat;
env = (env*weight);
//space target
DataHandle = data.inputValue(space, &stat);
int SpaceInt = DataHandle.asInt();
//space source
DataHandle = data.inputValue(spaceSource, &stat);
int SpaceSourceInt = DataHandle.asInt();
//pointlist
MArrayDataHandle pointArrayHandle = data.inputArrayValue(pointList);
//snapMesh
MFnMesh SnapMesh;
DataHandle = data.inputValue(snapMesh, &stat);
if (!stat)
return Err(stat,"Can't get mesh to snap to");
MObject SnapMeshObj = DataHandle.asMesh();
SnapMesh.setObject(SnapMeshObj);
MPointArray snapPoints;
if (SpaceSourceInt==0)
SnapMesh.getPoints(snapPoints, MSpace::kWorld);
else
SnapMesh.getPoints(snapPoints, MSpace::kObject);
iter.reset();
for ( ; !iter.isDone(); iter.next()) {
//check for painted weights
float currEnv = env * weightValue(data, multiIndex, iter.index());
//get point to snap to
unsigned int index;
stat = pointArrayHandle.jumpToElement(iter.index());
if (!stat)
index = 0;
else {
DataHandle = pointArrayHandle.outputValue();
index = DataHandle.asInt();
}
if (index != -1) {
//calc point location
MPoint currPoint;
if (snapPoints.length() > index)
currPoint = snapPoints[index];
if (SpaceInt == 0)
currPoint *= mat.inverse();
if (currEnv !=1)
{
MPoint p = (currPoint- iter.position());
currPoint = iter.position() + (p*currEnv);
}
//set point location
iter.setPosition(currPoint);
}
}
return stat;
}
示例14: deform
//.........这里部分代码省略.........
MGlobal::displayWarning("[ExocortexAlembic] Identifier '" + identifier +
"' in archive '" + mFileName +
"' is not a Curves.");
return MStatus::kFailure;
}
mSchema = obj.getSchema();
}
if (!mSchema.valid()) {
return MStatus::kFailure;
}
{
ESS_PROFILE_SCOPE("AlembicCurvesDeformNode::deform readProps");
Alembic::Abc::ICompoundProperty arbProp = mSchema.getArbGeomParams();
Alembic::Abc::ICompoundProperty userProp = mSchema.getUserProperties();
readProps(inputTime, arbProp, dataBlock, thisMObject());
readProps(inputTime, userProp, dataBlock, thisMObject());
// Set all plugs as clean
// Even if one of them failed to get set,
// trying again in this frame isn't going to help
for (unsigned int i = 0; i < mGeomParamPlugs.length(); i++) {
dataBlock.outputValue(mGeomParamPlugs[i]).setClean();
}
for (unsigned int i = 0; i < mUserAttrPlugs.length(); i++) {
dataBlock.outputValue(mUserAttrPlugs[i]).setClean();
}
}
// get the sample
SampleInfo sampleInfo = getSampleInfo(inputTime, mSchema.getTimeSampling(),
mSchema.getNumSamples());
// check if we have to do this at all
if (mLastSampleInfo.floorIndex == sampleInfo.floorIndex &&
mLastSampleInfo.ceilIndex == sampleInfo.ceilIndex) {
return MStatus::kSuccess;
}
mLastSampleInfo = sampleInfo;
// access the camera values
AbcG::ICurvesSchema::Sample sample;
AbcG::ICurvesSchema::Sample sample2;
mSchema.get(sample, sampleInfo.floorIndex);
if (sampleInfo.alpha != 0.0) {
mSchema.get(sample2, sampleInfo.ceilIndex);
}
Abc::P3fArraySamplePtr samplePos = sample.getPositions();
Abc::P3fArraySamplePtr samplePos2;
if (sampleInfo.alpha != 0.0) {
samplePos2 = sample2.getPositions();
}
// iteration should not be necessary. the iteration is only
// required if the same mesh is attached to the same deformer
// several times
float blend = (float)sampleInfo.alpha;
float iblend = 1.0f - blend;
unsigned int index = 0;
for (iter.reset(); !iter.isDone(); iter.next()) {
index = iter.index();
// MFloatPoint pt = iter.position();
MPoint pt = iter.position();
MPoint abcPos = pt;
float weight = weightValue(dataBlock, geomIndex, index) * env;
if (weight == 0.0f) {
continue;
}
float iweight = 1.0f - weight;
if (index >= samplePos->size()) {
continue;
}
bool done = false;
if (sampleInfo.alpha != 0.0) {
if (samplePos2->size() == samplePos->size()) {
abcPos.x = iweight * pt.x +
weight * (samplePos->get()[index].x * iblend +
samplePos2->get()[index].x * blend);
abcPos.y = iweight * pt.y +
weight * (samplePos->get()[index].y * iblend +
samplePos2->get()[index].y * blend);
abcPos.z = iweight * pt.z +
weight * (samplePos->get()[index].z * iblend +
samplePos2->get()[index].z * blend);
done = true;
}
}
if (!done) {
abcPos.x = iweight * pt.x + weight * samplePos->get()[index].x;
abcPos.y = iweight * pt.y + weight * samplePos->get()[index].y;
abcPos.z = iweight * pt.z + weight * samplePos->get()[index].z;
}
iter.setPosition(abcPos);
}
return MStatus::kSuccess;
}
示例15: deform
//.........这里部分代码省略.........
currPlug.setValue(geometryType);
SYS_ERROR_CHECK(status, "error setting aCurrGeometryType value\n");
/////////////////////////////////////////////////////////////////////////////////////////////////
//
// execute the mel script
//
MString melCmd = script+"(\"" +name()+"\","+count+")";
MCommandResult melResult;
status = MGlobal::executeCommand(melCmd,melResult);
// if the command did not work, then try to resource the script
// (might have been that we were in a fresh scene and nothing was ready yet
if (status != MS::kSuccess)
{
dh = block.inputValue(aScript,&status);
SYS_ERROR_CHECK(status, "Error getting aCmdBaseName handle\n");
MString scriptFile = dh.asString();
// try to source the script
MString cmd = "source \"" + scriptFile+"\"";
MCommandResult melResult;
status = MGlobal::executeCommand(cmd,melResult);
// if successfull, retry the command
if (!status.error())
{
status = MGlobal::executeCommand(melCmd,melResult);
}
}
USER_ERROR_CHECK(status, "Error executing mel command, please check the function you provided is valid, error free and has the appropriate parameters!");
// check the result type
if ((melResult.resultType()) != (MCommandResult::kDoubleArray))
{
USER_ERROR_CHECK(MS::kFailure, "result of mel command has wrong type, should be doubleArray (which will be interpreted as vectorArray)!");
}
// get the result as a double array
MDoubleArray newP;
status = melResult.getResult(newP);
USER_ERROR_CHECK(status, "Error getting result of mel command!");
int newCount = newP.length()/3;
// size check
if (newCount != count)
{
USER_ERROR_CHECK(MS::kFailure, "the size of the result does not match the size of the input!");
}
// convert the double array into a vector array
MPointArray newPoints(newCount);
for(int i=0;i<newCount;i++)
newPoints[i]=MPoint(newP[i*3],newP[i*3+1],newP[i*3+2]);
/////////////////////////////////////////////////////////////////////////////////////////////////
//
// interprete and apply the result
//
// do the envelope and weights
if ((defEnvelope == MSD_ENVELOPE_AUTO)||((defWeights == MSD_WEIGHTS_AUTO)))
{
MDoubleArray envPP(count, env);
if (defWeights == MSD_WEIGHTS_AUTO)
{
for (int i = 0;i<count;i++)
envPP[i] *= weights[i];
}
// linear interpolation between old and new points
for (int i = 0;i<count;i++)
newPoints[i] = (points[i] * (1-envPP[i])) + (newPoints[i] * envPP[i]);
}
// retransform the result if it was in world space
if ( defSpace == MSD_SPACE_WORLD )
{
MMatrix worldMatrixInv = worldMatrix.inverse();
for (int i = 0;i<count;i++)
newPoints[i] *= worldMatrixInv;
}
// set the points
iter.reset();
for ( ; !iter.isDone(); iter.next())
iter.setPosition(newPoints[iter.index()]);
return status;
}