本文整理汇总了C++中MDataHandle::data方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::data方法的具体用法?C++ MDataHandle::data怎么用?C++ MDataHandle::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataHandle
的用法示例。
在下文中一共展示了MDataHandle::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadInternal
bool ProxyViz::loadInternal(MDataBlock& block)
{
MDataHandle tmH = block.inputValue(aplantTransformCache);
MFnPointArrayData tmFn(tmH.data());
MPointArray plantTms = tmFn.array();
if(plantTms.length() < 1) return false;
MDataHandle idH = block.inputValue(aplantIdCache);
MFnIntArrayData idFn(idH.data());
MIntArray plantIds = idFn.array();
if(plantIds.length() < 1) return false;
MDataHandle triH = block.inputValue(aplantTriangleIdCache);
MFnIntArrayData triFn(triH.data());
MIntArray plantTris = triFn.array();
if(plantTris.length() < 1) return false;
MDataHandle crdH = block.inputValue(aplantTriangleCoordCache);
MFnVectorArrayData crdFn(crdH.data());
MVectorArray plantCoords = crdFn.array();
if(plantCoords.length() < 1) return false;
MDataHandle cotH = block.inputValue(aplantOffsetCache);
MFnVectorArrayData cotFn(cotH.data());
MVectorArray plantOffsets = cotFn.array();
return loadPlants(plantTms, plantIds, plantTris, plantCoords, plantOffsets);
}
示例2: compute
MStatus VoxelShape::compute( const MPlug& plug, MDataBlock& data ) {
MStatus stat;
// Check which output attribute we have been asked to compute. If this
// node doesn't know how to compute it, we must return
// MS::kUnknownParameter.
//
if( plug == outData )
{
// Get a handle to the input attribute that we will need for the
// computation. If the value is being supplied via a connection
// in the dependency graph, then this call will cause all upstream
// connections to be evaluated so that the correct value is supplied.
//
MDataHandle inputDataHandle = data.inputValue( voxelData, &stat );
MObject inputDataObj = inputDataHandle.data();
MFnPluginData fnDataCreator;
MTypeId tmpid( VoxelPreviewDataWrapper::id );
VoxelPreviewDataWrapper * newData = NULL;
MDataHandle outHandle = data.outputValue( outData );
newData = (VoxelPreviewDataWrapper*)outHandle.asPluginData();
if ( newData == NULL ) {
// Create some output data
fnDataCreator.create( tmpid, &stat );
MCHECKERROR( stat, "compute : error creating VoxelPreviewDataWrapper")
newData = (VoxelPreviewDataWrapper*)fnDataCreator.data( &stat );
MCHECKERROR( stat, "compute : error getting proxy VoxelPreviewDataWrapper object")
}
示例3: compute
MStatus cvColor::compute( const MPlug& plug, MDataBlock& data )
{
MStatus stat;
// cout << "cvColor::compute\n";
if ( plug == cvLocations ) {
MDataHandle inputData = data.inputValue ( inputSurface, &stat );
if (!stat) {
stat.perror("cvColor::compute get inputSurface");
return stat;
}
MObject surf = inputData.asNurbsSurface();
MFnNurbsSurface surfFn (surf, &stat);
if (!stat) {
stat.perror("cvColor::compute surface creator");
return stat;
}
MDataHandle outputData = data.outputValue ( cvLocations, &stat );
if (!stat) {
stat.perror("cvColor::compute get cvLocations");
return stat;
}
MObject cvs = outputData.data();
MFnPointArrayData cvData(cvs, &stat);
if (!stat) {
stat.perror("cvColor::compute point array data creator");
return stat;
}
MPointArray cvArray;
stat = surfFn.getCVs( cvArray, MSpace::kObject);
if (!stat) {
stat.perror("cvColor::compute getCVs");
return stat;
}
stat = cvData.set ( cvArray );
if (!stat) {
stat.perror("cvColor::compute setCVs");
return stat;
}
outputData.set ( cvs );
stat = data.setClean ( plug );
if (!stat) {
stat.perror("cvColor::compute setClean");
return stat;
}
} else {
return MS::kUnknownParameter;
}
return MS::kSuccess;
}
示例4: setMDoubleArray
MStatus setMDoubleArray(MObject &node, MString attrString, MDoubleArray &arr)
{
MStatus stat;
MFnDependencyNode nodeFn(node);
MObject attr = nodeFn.attribute( attrString, &stat ); MCheckStatus(stat,"ERROR node.attribute()");
MPlug plug( node, attr );
MDataHandle handle; plug.getValue( handle );
MFnDoubleArrayData(handle.data()).array().copy(arr);
plug.destructHandle(handle);
return MS::kSuccess;
}
示例5: compute
MStatus ReduceArrayNode::compute(const MPlug& plug, MDataBlock& data)
{
if (plug != aOutput)
return MS::kUnknownParameter;
MStatus status;
MDataHandle inputHandle = data.inputValue(aInput, &status);
CHECK_MSTATUS_AND_RETURN_IT(status);
MFnDoubleArrayData inputArrayData(inputHandle.data());
MDoubleArray inputArray = inputArrayData.array();
int numInputs = inputArray.length();
short operation = data.inputValue(aOperation).asShort();
double output = numInputs > 0 ? inputArray[0] : 0.0;
if (operation == kLENGTH)
{
output = double(numInputs);
} else {
for (int i = 1; i < numInputs; i++)
{
output = computeOutput(output, inputArray[i], operation, status);
if (!status)
{
reportComputeError(this, operation);
break;
}
}
}
MDataHandle outputHandle = data.outputValue(this->aOutput);
outputHandle.setDouble(output);
outputHandle.setClean();
return MS::kSuccess;
}
示例6: compute
MStatus ProxyViz::compute( const MPlug& plug, MDataBlock& block )
{
if(!m_enableCompute) return MS::kSuccess;
if( plug == outValue ) {
updateWorldSpace(thisMObject() );
MStatus status;
ExampVox * defBox = plantExample(0);
defBox->setGeomSizeMult(block.inputValue(aradiusMult).asFloat() );
defBox->setGeomBox(block.inputValue(abboxminx).asFloat(),
block.inputValue(abboxminy).asFloat(),
block.inputValue(abboxminz).asFloat(),
block.inputValue(abboxmaxx).asFloat(),
block.inputValue(abboxmaxy).asFloat(),
block.inputValue(abboxmaxz).asFloat());
float grdsz = defBox->geomExtent() * 32.f ;
if(grdsz < 32.f) {
AHelper::Info<float>(" ProxyViz input box is too small", grdsz);
grdsz = 32.f;
AHelper::Info<float>(" trancated to", grdsz);
}
if(m_toSetGrid) {
m_toSetGrid = false;
resetGrid(grdsz);
}
if(_firstLoad) {
/// internal cache only, initializing from external cache is obsolete
if(!loadInternal(block) )
std::cout<<"\n ERROR proxviz cannot load internal cache";
_firstLoad = 0;
}
if(!m_toCheckVisibility) {
MArrayDataHandle groundMeshArray = block.inputArrayValue(agroundMesh );
MArrayDataHandle groundSpaceArray = block.inputArrayValue(agroundSpace );
/// in case no ground is connected
if(updateGround(groundMeshArray, groundSpaceArray )) {
moveWithGround();
AHelper::Info<std::string>(" ProxyViz ground ", groundBuildLog() );
}
}
if(!m_hasParticle) {
block.setClean(plug);
return MS::kSuccess;
}
const int ngroups = block.inputValue(agroupcount).asInt();
MDataHandle hdata = block.inputValue(outPositionPP, &status);
MFnVectorArrayData farray(hdata.data(), &status);
if(!status) {
MGlobal::displayInfo("proxy viz is not properly connected to a particle system");
block.setClean(plug);
return MS::kSuccess;
}
MDataHandle scaledata = block.inputValue(outScalePP, &status);
MFnVectorArrayData scalearray(scaledata.data(), &status);
if(!status) {
MGlobal::displayInfo("proxy viz is not properly connected to a particle system");
block.setClean(plug);
return MS::kSuccess;
}
MDataHandle rotatedata = block.inputValue(outRotationPP, &status);
MFnVectorArrayData rotatearray(rotatedata.data(), &status);
if(!status) {
MGlobal::displayInfo("proxy viz is not properly connected to a particle system");
block.setClean(plug);
return MS::kSuccess;
}
MDataHandle replaceData = block.inputValue(outReplacePP, &status);
MFnDoubleArrayData replaceArrayFn(replaceData.data(), &status);
if(!status) {
MGlobal::displayInfo("proxy viz is not properly connected to a particle system, needs userScalarPP");
block.setClean(plug);
return MS::kSuccess;
}
MVectorArray outPosArray = farray.array();
MVectorArray outScaleArray = scalearray.array();
MVectorArray outRotateArray = rotatearray.array();
MDoubleArray outReplaceArray = replaceArrayFn.array();
if( outPosArray.length() < 1) {
block.setClean(plug);
return MS::kSuccess;
}
computePPAttribs(outPosArray, outRotateArray, outScaleArray, outReplaceArray,
//.........这里部分代码省略.........
示例7: compute
MStatus LSSolverNode::compute(const MPlug& plug, MDataBlock& data)
{
MStatus stat;
if( plug == deformed)
{
MDataHandle tetWorldMatrixData = data.inputValue(tetWorldMatrix, &returnStatus);
McheckErr(returnStatus, "Error getting tetWorldMatrix data handle\n");
MDataHandle restShapeData = data.inputValue(restShape, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle restVerticesData = data.inputValue(restVertices, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle restElementsData = data.inputValue(restElements, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle selectedConstraintVertsData = data.inputValue(selectedConstraintVerts, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle selectedForceVertsData = data.inputValue(selectedForceVerts, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle timeData = data.inputValue(time, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle outputMeshData = data.outputValue(deformed, &returnStatus);
McheckErr(returnStatus, "Error getting outputMesh data handle\n");
MMatrix twmat = tetWorldMatrixData.asMatrix();
MObject rs = restShapeData.asMesh();
double t = timeData.asDouble();
MDataHandle poissonRatioData = data.inputValue(poissonRatio, &returnStatus);
McheckErr(returnStatus, "Error getting poissonRatio data handle\n");
MDataHandle youngsModulusData = data.inputValue(youngsModulus, &returnStatus);
McheckErr(returnStatus, "Error getting youngsmodulus data handle\n");
MDataHandle objectDensityData = data.inputValue(objectDensity, &returnStatus);
McheckErr(returnStatus, "Error getting objectDensity data handle\n");
MDataHandle frictionData = data.inputValue(friction, &returnStatus);
McheckErr(returnStatus, "Error getting friction data handle\n");
MDataHandle restitutionData = data.inputValue(restitution, &returnStatus);
McheckErr(returnStatus, "Error getting restitution data handle\n");
MDataHandle dampingData = data.inputValue(damping, &returnStatus);
McheckErr(returnStatus, "Error getting damping data handle\n");
MDataHandle userSuppliedDtData = data.inputValue(userSuppliedDt, &returnStatus);
McheckErr(returnStatus, "Error getting user supplied dt data handle\n");
MDataHandle integrationTypeData = data.inputValue(integrationType, &returnStatus);
McheckErr(returnStatus, "Error getting user integrationTypeData\n");
MDataHandle forceModelTypeData = data.inputValue(forceModelType, &returnStatus);
McheckErr(returnStatus, "Error getting user forceModelTypeData\n");
MDataHandle forceApplicationTimeData = data.inputValue(forceApplicationTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceApplicationTime\n");
MDataHandle forceReleasedTimeData = data.inputValue(forceReleasedTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceReleasedTime\n");
MDataHandle forceIncrementTimeData = data.inputValue(forceIncrementTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceIncrementTime\n");
MDataHandle forceStartTimeData = data.inputValue(forceStartTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceStartTime\n");
MDataHandle forceStopTimeData = data.inputValue(forceStopTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceStopTime\n");
MDataHandle forceMagnitudeData = data.inputValue(forceMagnitude, &returnStatus);
McheckErr(returnStatus, "Error getting user forceIdleTime\n");
MDataHandle useSuppliedForceData = data.inputValue(useSuppliedForce, &returnStatus);
McheckErr(returnStatus, "Error getting user forceIdleTime\n");
MDataHandle useSuppliedConstraintsData = data.inputValue(useSuppliedConstraints, &returnStatus);
McheckErr(returnStatus, "Error getting user forceIdleTime\n");
MDataHandle forceDirectionData = data.inputValue(forceDirection, &returnStatus);
McheckErr(returnStatus, "Error getting user forceDirection\n");
MDataHandle contactKsData = data.inputValue(contactKs, &returnStatus);
McheckErr(returnStatus, "Error getting user forceDirection\n");
MDataHandle contactKdData = data.inputValue(contactKd, &returnStatus);
McheckErr(returnStatus, "Error getting user forceDirection\n");
MTime currentTime, maxTime;
currentTime = MAnimControl::currentTime();
maxTime = MAnimControl::maxTime();
if (currentTime == MAnimControl::minTime())
//.........这里部分代码省略.........
示例8: compute
MStatus geometrySurfaceConstraint::compute( const MPlug& plug, MDataBlock& block )
{
MStatus returnStatus;
if(plug == constraintTranslateX || plug == constraintTranslateY || plug == constraintTranslateZ) {
if(!m_isInitd) {
// read rest position
MDataHandle htgo = block.inputValue(targetRestP);
double3 & tgo = htgo.asDouble3();
MGlobal::displayInfo(MString("target rest p ")+tgo[0]+" "+tgo[1]+" "+tgo[2]);
m_restPos = MPoint(tgo[0],tgo[1],tgo[2]);
m_isInitd = true;
}
MArrayDataHandle targetArray = block.inputArrayValue( compoundTarget );
const unsigned int targetArrayCount = targetArray.elementCount();
MMatrix tm;
tm.setToIdentity();
unsigned int i;
for ( i = 0; i < targetArrayCount; i++ ) {
MDataHandle targetElement = targetArray.inputValue(&returnStatus);
if(!returnStatus) {
MGlobal::displayInfo("failed to get input value target element");
}
MDataHandle htm = targetElement.child(targetTransform);
MFnMatrixData ftm(htm.data(), &returnStatus);
if(!returnStatus) {
MGlobal::displayInfo("failed to get matrix data");
}
tm = ftm.matrix();
targetArray.next();
}
MDataHandle hparentInvMat = block.inputValue(constraintParentInverseMatrix);
MMatrix parentInvMat = hparentInvMat.asMatrix();
// world position
MPoint curPos(tm(3,0), tm(3,1), tm(3,2));
// offset in local space
m_offsetToRest = m_restPos - curPos;
// object position in world space
MPoint localP = m_offsetToRest * tm + curPos;
// in local space
localP *= parentInvMat;
MDataHandle hout;
if(plug == constraintTranslateX) {
hout = block.outputValue(constraintTranslateX);
hout.set(localP.x);
}
else if(plug == constraintTranslateY) {
hout = block.outputValue(constraintTranslateY);
hout.set(localP.y);
}
else if(plug == constraintTranslateZ) {
hout = block.outputValue(constraintTranslateZ);
hout.set(localP.z);
}
//MPlug pgTx(thisMObject(), constraintTargetX);
//pgTx.setValue(m_lastPos.x);
//MPlug pgTy(thisMObject(), constraintTargetY);
//pgTy.setValue(m_lastPos.y);
//MPlug pgTz(thisMObject(), constraintTargetZ);
//pgTz.setValue(m_lastPos.z);
MPlug pgOx(thisMObject(), constraintObjectX);
pgOx.setValue(m_offsetToRest.x);
MPlug pgOy(thisMObject(), constraintObjectY);
pgOy.setValue(m_offsetToRest.y);
MPlug pgOz(thisMObject(), constraintObjectZ);
pgOz.setValue(m_offsetToRest.z);
// MFnNumericData nd;
//MObject offsetData = nd.create( MFnNumericData::k3Double);
//nd.setData3Double(m_lastPos.x, m_lastPos.y, m_lastPos.z);
//MPlug pgTgo(thisMObject(), targetOffset);
//pgTgo.setValue(offsetData);
}
else
return MS::kUnknownParameter;
return MS::kSuccess;
}
示例9: fnSweptData
void
simpleFluidEmitter::surfaceFluidEmitter(
MFnFluid& fluid,
const MMatrix& fluidWorldMatrix,
int plugIndex,
MDataBlock& block,
double dt,
double conversion,
double dropoff
)
//==============================================================================
//
// Method:
//
// simpleFluidEmitter::surfaceFluidEmitter
//
// Description:
//
// Emits fluid from one of a predefined set of volumes (cube, sphere,
// cylinder, cone, torus).
//
// Parameters:
//
// fluid: fluid into which we are emitting
// fluidWorldMatrix: object->world matrix for the fluid
// plugIndex: identifies which fluid connected to the emitter
// we are emitting into
// block: datablock for the emitter, to retrieve attribute
// values
// dt: time delta for this frame
// conversion: mapping from UI emission rates to internal units
// dropoff: specifies how much emission rate drops off as
// the surface points move away from the centers
// of the voxels in which they lie.
//
// Notes:
//
// To associate an owner object with an emitter, use the
// addDynamic MEL command, e.g. "addDynamic simpleFluidEmitter1 pPlane1".
//
//==============================================================================
{
// get relevant world matrices
//
MMatrix fluidInverseWorldMatrix = fluidWorldMatrix.inverse();
// get emission rates for density, fuel, heat, and emission color
//
double densityEmit = fluidDensityEmission( block );
double fuelEmit = fluidFuelEmission( block );
double heatEmit = fluidHeatEmission( block );
bool doEmitColor = fluidEmitColor( block );
MColor emitColor = fluidColor( block );
// rate modulation based on frame time, user value conversion factor, and
// standard emitter "rate" value (not actually exposed in most fluid
// emitters, but there anyway).
//
double theRate = getRate(block) * dt * conversion;
// get voxel dimensions and sizes (object space)
//
double size[3];
unsigned int res[3];
fluid.getDimensions( size[0], size[1], size[2] );
fluid.getResolution( res[0], res[1], res[2] );
// voxel sizes
double dx = size[0] / res[0];
double dy = size[1] / res[1];
double dz = size[2] / res[2];
// voxel centers
double Ox = -size[0]/2;
double Oy = -size[1]/2;
double Oz = -size[2]/2;
// get the "swept geometry" data for the emitter surface. This structure
// tracks the motion of each emitter triangle over the time interval
// for this simulation step. We just use positions on the emitter
// surface at the end of the time step to do the emission.
//
MDataHandle sweptHandle = block.inputValue( mSweptGeometry );
MObject sweptData = sweptHandle.data();
MFnDynSweptGeometryData fnSweptData( sweptData );
// for "non-jittered" sampling, just reset the random state for each
// triangle, which gives us a fixed set of samples all the time.
// Sure, they're still jittered, but they're all jittered the same,
// which makes them kinda uniform.
//
bool jitter = fluidJitter(block);
if( !jitter )
{
resetRandomState( plugIndex, block );
}
if( fnSweptData.triangleCount() > 0 )
{
// average voxel face area - use this as the canonical unit that
//.........这里部分代码省略.........
示例10: optionsArray
//----------------------------------------------------------------------------
MStatus BPT_InsertVtx::doCompleteCompute( MDataBlock& data )
//----------------------------------------------------------------------------
{
SPEED("Berechne EdgeSplit neu: ");
MStatus status;
MPRINT("MACHE KOMPLETTE BERECHNUNG")
MDataHandle inMeshHandle = data.inputValue(IVinMesh);
MDataHandle outMeshHandle = data.outputValue(IVoutMesh);
//splitCount setzen
MDataHandle countHandle = data.inputValue(IVcount);
fIVfty.setCount(countHandle.asInt());
MDataHandle spinHandle = data.inputValue(IVspin);
fIVfty.setSpin(spinHandle.asInt());
int initialVtxCount; //wird spueueter benueuetigt, um das ValidIndicesArray gleich in der rictigen grueueueuee zu erstellen und zu schreiben
//gleich zu beginn muss der MeshPath initialisiert werden, damit der MeshPath an die fty ueuebergeben werden kann
// Dies geschieht besser durch die STE - sie ist darauf ausgelegt
softTransformationEngine::gatherAttributeObjects(thisMObject());
softTransformationEngine::saveMeshPathes();
fIVfty.setMeshPath(meshPath);
MDataHandle rHandle = data.inputValue(IVslideRelative);
fIVfty.setRelative(rHandle.asInt());
MDataHandle nRelativeHandle = data.inputValue(IVnormalRelative);
fIVfty.setNormalRelative(nRelativeHandle.asInt());
//selection setzen
MFnIntArrayData intDataArray;
MDataHandle arrayHandle = data.inputValue(IVselEdgeIDs);
intDataArray.setObject(arrayHandle.data());
fIVfty.setEdgeIDs( intDataArray.array() );
arrayHandle = data.inputValue(IVselVertIDs);
intDataArray.setObject(arrayHandle.data());
fIVfty.setVertIDs(intDataArray.array());
// optionen holen
arrayHandle = data.inputValue(IVoptions);
intDataArray.setObject(arrayHandle.data());
MIntArray optionsArray(intDataArray.array());
fIVfty.setOptions(optionsArray);
MDataHandle slideHandle = data.inputValue(IVslide);
fIVfty.setSlide(slideHandle.asDouble());
//whichSide attribute wird nur fueuer SLide selbst verwendet und kann nicht bereits beim command gestetzt werden
MObject inMeshRef = inMeshHandle.asMesh();
fIVfty.setMesh(inMeshRef);
MFnMesh meshFn(inMeshHandle.asMesh());
initialVtxCount = meshFn.numVertices();
//ACTION
try
{
status = fIVfty.doIt();
//.........这里部分代码省略.........
示例11: compute
MStatus LSSolverNode::compute(const MPlug& plug, MDataBlock& data)
{
MStatus stat;
if( plug == deformed)
{
MDataHandle tetWorldMatrixData = data.inputValue(tetWorldMatrix, &returnStatus);
McheckErr(returnStatus, "Error getting tetWorldMatrix data handle\n");
MDataHandle restShapeData = data.inputValue(restShape, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle restVerticesData = data.inputValue(restVertices, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle restElementsData = data.inputValue(restElements, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle selectedConstraintVertsData = data.inputValue(selectedConstraintVerts, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle selectedForceVertsData = data.inputValue(selectedForceVerts, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle timeData = data.inputValue(time, &returnStatus);
McheckErr(returnStatus, "Error getting step data handle\n");
MDataHandle outputMeshData = data.outputValue(deformed, &returnStatus);
McheckErr(returnStatus, "Error getting outputMesh data handle\n");
MMatrix twmat = tetWorldMatrixData.asMatrix();
MObject rs = restShapeData.asMesh();
double t = timeData.asDouble();
MDataHandle poissonRatioData = data.inputValue(poissonRatio, &returnStatus);
McheckErr(returnStatus, "Error getting poissonRatio data handle\n");
MDataHandle youngsModulusData = data.inputValue(youngsModulus, &returnStatus);
McheckErr(returnStatus, "Error getting youngsmodulus data handle\n");
MDataHandle objectDensityData = data.inputValue(objectDensity, &returnStatus);
McheckErr(returnStatus, "Error getting objectDensity data handle\n");
MDataHandle frictionData = data.inputValue(friction, &returnStatus);
McheckErr(returnStatus, "Error getting friction data handle\n");
MDataHandle restitutionData = data.inputValue(restitution, &returnStatus);
McheckErr(returnStatus, "Error getting restitution data handle\n");
MDataHandle dampingData = data.inputValue(damping, &returnStatus);
McheckErr(returnStatus, "Error getting damping data handle\n");
MDataHandle userSuppliedDtData = data.inputValue(userSuppliedDt, &returnStatus);
McheckErr(returnStatus, "Error getting user supplied dt data handle\n");
MDataHandle integrationTypeData = data.inputValue(integrationType, &returnStatus);
McheckErr(returnStatus, "Error getting user integrationTypeData\n");
MDataHandle forceModelTypeData = data.inputValue(forceModelType, &returnStatus);
McheckErr(returnStatus, "Error getting user forceModelTypeData\n");
MDataHandle forceApplicationTimeData = data.inputValue(forceApplicationTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceApplicationTime\n");
MDataHandle forceReleasedTimeData = data.inputValue(forceReleasedTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceReleasedTime\n");
MDataHandle forceIncrementTimeData = data.inputValue(forceIncrementTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceIncrementTime\n");
MDataHandle forceStartTimeData = data.inputValue(forceStartTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceStartTime\n");
MDataHandle forceStopTimeData = data.inputValue(forceStopTime, &returnStatus);
McheckErr(returnStatus, "Error getting user forceStopTime\n");
MDataHandle forceMagnitudeData = data.inputValue(forceMagnitude, &returnStatus);
McheckErr(returnStatus, "Error getting user forceIdleTime\n");
MDataHandle useSuppliedForceData = data.inputValue(useSuppliedForce, &returnStatus);
McheckErr(returnStatus, "Error getting user forceIdleTime\n");
MDataHandle useSuppliedConstraintsData = data.inputValue(useSuppliedConstraints, &returnStatus);
McheckErr(returnStatus, "Error getting user forceIdleTime\n");
MDataHandle forceDirectionData = data.inputValue(forceDirection, &returnStatus);
McheckErr(returnStatus, "Error getting user forceDirection\n");
MDataHandle contactKsData = data.inputValue(contactKs, &returnStatus);
McheckErr(returnStatus, "Error getting user forceDirection\n");
MDataHandle contactKdData = data.inputValue(contactKd, &returnStatus);
McheckErr(returnStatus, "Error getting user forceDirection\n");
MTime currentTime, maxTime;
currentTime = MAnimControl::currentTime();
maxTime = MAnimControl::maxTime();
if (currentTime == MAnimControl::minTime())
//.........这里部分代码省略.........
示例12: fnOwnerPos
void
simpleFluidEmitter::omniFluidEmitter(
MFnFluid& fluid,
const MMatrix& fluidWorldMatrix,
int plugIndex,
MDataBlock& block,
double dt,
double conversion,
double dropoff
)
//==============================================================================
//
// Method:
//
// simpleFluidEmitter::omniFluidEmitter
//
// Description:
//
// Emits fluid from a point, or from a set of object control points.
//
// Parameters:
//
// fluid: fluid into which we are emitting
// fluidWorldMatrix: object->world matrix for the fluid
// plugIndex: identifies which fluid connected to the emitter
// we are emitting into
// block: datablock for the emitter, to retrieve attribute
// values
// dt: time delta for this frame
// conversion: mapping from UI emission rates to internal units
// dropoff: specifies how much emission rate drops off as
// we move away from each emission point.
//
// Notes:
//
// If no owner object is present for the emitter, we simply emit from
// the emitter position. If an owner object is present, then we emit
// from each control point of that object in an identical fashion.
//
// To associate an owner object with an emitter, use the
// addDynamic MEL command, e.g. "addDynamic simpleFluidEmitter1 pPlane1".
//
//==============================================================================
{
// find the positions that we need to emit from
//
MVectorArray emitterPositions;
// first, try to get them from an owner object, which will have its
// "ownerPositionData" attribute feeding into the emitter. These
// values are in worldspace
//
bool gotOwnerPositions = false;
MObject ownerShape = getOwnerShape();
if( ownerShape != MObject::kNullObj )
{
MStatus status;
MDataHandle hOwnerPos = block.inputValue( mOwnerPosData, &status );
if( status == MS::kSuccess )
{
MObject dOwnerPos = hOwnerPos.data();
MFnVectorArrayData fnOwnerPos( dOwnerPos );
MVectorArray posArray = fnOwnerPos.array( &status );
if( status == MS::kSuccess )
{
// assign vectors from block to ownerPosArray.
//
for( unsigned int i = 0; i < posArray.length(); i ++ )
{
emitterPositions.append( posArray[i] );
}
gotOwnerPositions = true;
}
}
}
// there was no owner object, so we just use the emitter position for
// emission.
//
if( !gotOwnerPositions )
{
MPoint emitterPos = getWorldPosition();
emitterPositions.append( emitterPos );
}
// get emission rates for density, fuel, heat, and emission color
//
double densityEmit = fluidDensityEmission( block );
double fuelEmit = fluidFuelEmission( block );
double heatEmit = fluidHeatEmission( block );
bool doEmitColor = fluidEmitColor( block );
MColor emitColor = fluidColor( block );
// rate modulation based on frame time, user value conversion factor, and
// standard emitter "rate" value (not actually exposed in most fluid
// emitters, but there anyway).
//
double theRate = getRate(block) * dt * conversion;
//.........这里部分代码省略.........
示例13: geometryData
MObject VoxelShape::geometryData() const {
VoxelShape* nonConstThis = const_cast<VoxelShape*>(this);
MDataBlock datablock = nonConstThis->forceCache();
MDataHandle handle = datablock.inputValue( outData );
return handle.data();
}
示例14: compute
MStatus meshOpNode::compute( const MPlug& plug, MDataBlock& data )
//
// Description:
// This method computes the value of the given output plug based
// on the values of the input attributes.
//
// Arguments:
// plug - the plug to compute
// data - object that provides access to the attributes for this node
//
{
MStatus status = MS::kSuccess;
MDataHandle stateData = data.outputValue( state, &status );
MCheckStatus( status, "ERROR getting state" );
// Check for the HasNoEffect/PassThrough flag on the node.
//
// (stateData is an enumeration standard in all depend nodes)
//
// (0 = Normal)
// (1 = HasNoEffect/PassThrough)
// (2 = Blocking)
// ...
//
if( stateData.asShort() == 1 )
{
MDataHandle inputData = data.inputValue( inMesh, &status );
MCheckStatus(status,"ERROR getting inMesh");
MDataHandle outputData = data.outputValue( outMesh, &status );
MCheckStatus(status,"ERROR getting outMesh");
// Simply redirect the inMesh to the outMesh for the PassThrough effect
//
outputData.set(inputData.asMesh());
}
else
{
// Check which output attribute we have been asked to
// compute. If this node doesn't know how to compute it,
// we must return MS::kUnknownParameter
//
if (plug == outMesh)
{
MDataHandle inputData = data.inputValue( inMesh, &status );
MCheckStatus(status,"ERROR getting inMesh");
MDataHandle outputData = data.outputValue( outMesh, &status );
MCheckStatus(status,"ERROR getting outMesh");
// Now, we get the value of the component list and the operation
// type and use it to perform the mesh operation on this mesh
//
MDataHandle inputIDs = data.inputValue( cpList, &status);
MCheckStatus(status,"ERROR getting componentList");
MDataHandle opTypeData = data.inputValue( opType, &status);
MCheckStatus(status,"ERROR getting opType");
// Copy the inMesh to the outMesh, so you can
// perform operations directly on outMesh
//
outputData.set(inputData.asMesh());
MObject mesh = outputData.asMesh();
// Retrieve the ID list from the component list.
//
// Note, we use a component list to store the components
// because it is more compact memory wise. (ie. comp[81:85]
// is smaller than comp[81], comp[82],...,comp[85])
//
MObject compList = inputIDs.data();
MFnComponentListData compListFn( compList );
// Get what operation is requested and
// what type of component is expected for this operation.
MeshOperation operationType = (MeshOperation) opTypeData.asShort();
MFn::Type componentType =
meshOpFty::getExpectedComponentType(operationType);
unsigned i;
int j;
MIntArray cpIds;
for( i = 0; i < compListFn.length(); i++ )
{
MObject comp = compListFn[i];
if( comp.apiType() == componentType )
{
MFnSingleIndexedComponent siComp( comp );
for( j = 0; j < siComp.elementCount(); j++ )
cpIds.append( siComp.element(j) );
}
}
// Set the mesh object and component List on the factory
//
fmeshOpFactory.setMesh( mesh );
fmeshOpFactory.setComponentList( compList );
//.........这里部分代码省略.........
示例15: compute
MStatus dynExprField::compute(const MPlug& plug, MDataBlock& block)
//
// Descriptions:
// compute output force.
//
{
MStatus status;
if( !(plug == mOutputForce) )
return( MS::kUnknownParameter );
// get the logical index of the element this plug refers to.
//
int multiIndex = plug.logicalIndex( &status );
McheckErr(status, "ERROR in plug.logicalIndex.\n");
// Get input data handle, use outputArrayValue since we do not
// want to evaluate both inputs, only the one related to the
// requested multiIndex. Evaluating both inputs at once would cause
// a dependency graph loop.
MArrayDataHandle hInputArray = block.outputArrayValue( mInputData, &status );
McheckErr(status,"ERROR in hInputArray = block.outputArrayValue().\n");
status = hInputArray.jumpToElement( multiIndex );
McheckErr(status, "ERROR: hInputArray.jumpToElement failed.\n");
// get children of aInputData.
MDataHandle hCompond = hInputArray.inputValue( &status );
McheckErr(status, "ERROR in hCompond=hInputArray.inputValue\n");
MDataHandle hPosition = hCompond.child( mInputPositions );
MObject dPosition = hPosition.data();
MFnVectorArrayData fnPosition( dPosition );
MVectorArray points = fnPosition.array( &status );
McheckErr(status, "ERROR in fnPosition.array(), not find points.\n");
// Comment out the following since velocity, and mass are
// not needed in this field.
//
// MDataHandle hVelocity = hCompond.child( mInputVelocities );
// MObject dVelocity = hVelocity.data();
// MFnVectorArrayData fnVelocity( dVelocity );
// MVectorArray velocities = fnVelocity.array( &status );
// McheckErr(status, "ERROR in fnVelocity.array(), not find velocities.\n");
//
// MDataHandle hMass = hCompond.child( mInputMass );
// MObject dMass = hMass.data();
// MFnDoubleArrayData fnMass( dMass );
// MDoubleArray masses = fnMass.array( &status );
// McheckErr(status, "ERROR in fnMass.array(), not find masses.\n");
// The attribute mInputPPData contains the attribute in an array form
// parpared by the particleShape if the particleShape has per particle
// attribute fieldName_attrName.
//
// Suppose a field with the name dynExprField1 is connecting to
// particleShape1, and the particleShape1 has per particle float attribute
// dynExprField1_magnitude and vector attribute dynExprField1_direction,
// then hInputPPArray will contains a MdoubleArray with the corresponding
// name "magnitude" and a MvectorArray with the name "direction". This
// is a mechanism to allow the field attributes being driven by dynamic
// expression.
MArrayDataHandle mhInputPPData = block.inputArrayValue( mInputPPData, &status );
McheckErr(status,"ERROR in mhInputPPData = block.inputArrayValue().\n");
status = mhInputPPData.jumpToElement( multiIndex );
McheckErr(status, "ERROR: mhInputPPArray.jumpToElement failed.\n");
MDataHandle hInputPPData = mhInputPPData.inputValue( &status );
McheckErr(status, "ERROR in hInputPPData = mhInputPPData.inputValue\n");
MObject dInputPPData = hInputPPData.data();
MFnArrayAttrsData inputPPArray( dInputPPData );
MDataHandle hOwnerPPData = block.inputValue( mOwnerPPData, &status );
McheckErr(status, "ERROR in hOwnerPPData = block.inputValue\n");
MObject dOwnerPPData = hOwnerPPData.data();
MFnArrayAttrsData ownerPPArray( dOwnerPPData );
const MString magString("magnitude");
MFnArrayAttrsData::Type doubleType(MFnArrayAttrsData::kDoubleArray);
bool arrayExist;
MDoubleArray magnitudeArray;
arrayExist = inputPPArray.checkArrayExist(magString, doubleType, &status);
// McheckErr(status, "ERROR in checkArrayExist(magnitude)\n");
if(arrayExist) {
magnitudeArray = inputPPArray.getDoubleData(magString, &status);
// McheckErr(status, "ERROR in inputPPArray.doubleArray(magnitude)\n");
}
MDoubleArray magnitudeOwnerArray;
arrayExist = ownerPPArray.checkArrayExist(magString, doubleType, &status);
// McheckErr(status, "ERROR in checkArrayExist(magnitude)\n");
if(arrayExist) {
magnitudeOwnerArray = ownerPPArray.getDoubleData(magString, &status);
// McheckErr(status, "ERROR in ownerPPArray.doubleArray(magnitude)\n");
//.........这里部分代码省略.........