本文整理汇总了C++中MDataHandle::asShort方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::asShort方法的具体用法?C++ MDataHandle::asShort怎么用?C++ MDataHandle::asShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataHandle
的用法示例。
在下文中一共展示了MDataHandle::asShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
OpenSubdivShader::setInternalValueInContext(const MPlug &plug, const MDataHandle &handle, MDGContext &)
{
if (plug == aLevel) {
_hbrMeshDirty = true;
_level = handle.asLong();
} else if (plug == aTessFactor) {
_tessFactor = handle.asLong();
} else if (plug == aScheme) {
_hbrMeshDirty = true;
_scheme = (OsdMeshData::SchemeType)handle.asShort();
} else if (plug == aKernel) {
_hbrMeshDirty = true;
_kernel = (OsdMeshData::KernelType)handle.asShort();
} else if (plug == aInterpolateBoundary) {
_hbrMeshDirty = true;
_interpolateBoundary = (OsdMeshData::InterpolateBoundaryType)handle.asShort();
} else if (plug == aAdaptive) {
_hbrMeshDirty = true;
_adaptiveDirty = true;
_adaptive = handle.asBool();
} else if (plug == aDiffuseMapFile) {
_diffuseMapDirty = true;
_diffuseMapFile = handle.asString();
} else if (plug == aUVSet) {
_hbrMeshDirty = true;
_uvSet = handle.asString();
} else if (plug == aInterpolateUVBoundary) {
_hbrMeshDirty = true;
_interpolateUVBoundary = (OsdMeshData::InterpolateBoundaryType)handle.asShort();
} else if (plug == aShaderSource) {
_shaderSourceFilename = handle.asString();
std::ifstream ifs;
ifs.open(_shaderSourceFilename.asChar());
if (ifs.fail()) {
printf("Using default shader\n");
_shaderSource.clear();
_shaderSourceFilename.clear();
} else {
printf("Using %s shader\n", _shaderSourceFilename.asChar());
std::stringstream buffer;
buffer << ifs.rdbuf();
_shaderSource = buffer.str();
}
ifs.close();
_shaderSourceDirty = true;
}
return false;
}
示例2: if
//------------------------------------------------------------------------------
bool
OpenSubdivShader::setInternalValueInContext(const MPlug &plug, const MDataHandle &handle, MDGContext &)
{
if(plug == aLevel)
{
_level = handle.asLong();
}
else if(plug == aScheme)
{
_scheme = handle.asShort();
}
else if(plug == aKernel)
{
_kernel = handle.asShort();
}
return false;
}
示例3:
MStatus
PolyColourNode::compute( const MPlug& plug, MDataBlock& data )
{
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 inputMesh = data.inputValue( m_inMesh, &status );
//MCheckStatus(status,"ERROR getting inMesh");
//MDataHandle outputMesh = data.outputValue( m_outMesh, &status );
//MCheckStatus(status,"ERROR getting outMesh");
// Simply redirect the inMesh to the outMesh for the PassThrough effect
//
//outputMesh.set(inputMesh.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 (1)
{
}
else
{
status = MS::kUnknownParameter;
}
}
return status;
}
示例4: depNodeFn
//----------------------------------------------------------------------------
MStatus BPT_InsertVtx::compute(const MPlug& plug, MDataBlock& data)
//----------------------------------------------------------------------------
{
// FactoryWerte setzen
// (hier ueueberall eventuell noch MCheck nutzen fueuer Debug wenn nueuetig)
MStatus status;
MDataHandle stateHandle = data.outputValue(state);
if(stateHandle.asShort() == 1)
{
MDataHandle inMeshHandle = data.inputValue(IVinMesh);
MDataHandle outMeshHandle = data.outputValue(IVoutMesh);
// inMesh direkt an outMesh und MObject mesh an factory geben
outMeshHandle.set(inMeshHandle.asMesh());
outMeshHandle.setClean();
}
else
{
if( (plug == IVoutMesh) )
{
if(meshDirty)
{
MPRINT("COMPLETE COMPUTE!!!!!!!!!!!!!!!!!!!!!!!!!!!")
status = doCompleteCompute(data);
INVIS(cout<<"MeshDirty ist "<<meshDirty<<endl;)
meshDirty = false;
INVIS(cout<<"--------------------------------"<<endl;)
MFnDependencyNode depNodeFn(thisMObject());
INVIS(cout<<"---------------"<<endl;)
INVIS(cout<<depNodeFn.name().asChar()<<endl;)
示例5: if
bool
OpenSubdivPtexShader::setInternalValueInContext(const MPlug &plug, const MDataHandle &handle, MDGContext &)
{
if (plug == aLevel) {
_hbrMeshDirty = true;
_level = handle.asLong();
} else if (plug == aTessFactor) {
_tessFactor = handle.asLong();
} else if (plug == aScheme) {
_hbrMeshDirty = true;
_scheme = (OsdPtexMeshData::SchemeType)handle.asShort();
} else if (plug == aKernel) {
_hbrMeshDirty = true;
_kernel = (OsdPtexMeshData::KernelType)handle.asShort();
} else if (plug == aInterpolateBoundary) {
_hbrMeshDirty = true;
_interpolateBoundary = (OsdPtexMeshData::InterpolateBoundaryType)handle.asShort();
} else if (plug == aAdaptive) {
_hbrMeshDirty = true;
_adaptiveDirty = true;
_adaptive = handle.asBool();
} else if (plug == aShaderSource) {
_shaderSourceFilename = handle.asString();
std::ifstream ifs;
ifs.open(_shaderSourceFilename.asChar());
if (ifs.fail()) {
printf("Using default shader\n");
_shaderSource.clear();
_shaderSourceFilename.clear();
} else {
printf("Using %s shader\n", _shaderSourceFilename.asChar());
std::stringstream buffer;
buffer << ifs.rdbuf();
_shaderSource = buffer.str();
}
ifs.close();
_shaderSourceDirty = true;
} else if (plug == aDiffuseEnvironmentMapFile) {
_diffEnvMapDirty = true;
_diffEnvMapFile = handle.asString();
} else if (plug == aSpecularEnvironmentMapFile) {
_specEnvMapDirty = true;
_specEnvMapFile = handle.asString();
} else if (plug == aColorFile) {
_ptexColorDirty = true;
_colorFile = handle.asString();
} else if (plug == aDisplacementFile) {
_ptexDisplacementDirty = true;
_displacementFile = handle.asString();
} else if (plug == aOcclusionFile) {
_ptexOcclusionDirty = true;
_occlusionFile = handle.asString();
} else if (plug == aEnableColor) {
_enableColor = handle.asBool();
} else if (plug == aEnableDisplacement) {
_enableDisplacement = handle.asBool();
} else if (plug == aEnableOcclusion) {
_enableOcclusion = handle.asBool();
} else if (plug == aEnableNormal) {
_enableNormal = handle.asBool();
}
return false;
}
示例6: McheckErr
MStatus
tm_noisePerlin::deform( MDataBlock& block,
MItGeometry& iter,
const MMatrix& /*m*/,
unsigned int /*multiIndex*/)
{
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;
//.........这里部分代码省略.........
示例7: compute
MStatus AlembicNode::compute(const MPlug & plug, MDataBlock & dataBlock)
{
MStatus status;
// update the frame number to be imported
MDataHandle speedHandle = dataBlock.inputValue(mSpeedAttr, &status);
double speed = speedHandle.asDouble();
MDataHandle offsetHandle = dataBlock.inputValue(mOffsetAttr, &status);
double offset = offsetHandle.asDouble();
MDataHandle timeHandle = dataBlock.inputValue(mTimeAttr, &status);
MTime t = timeHandle.asTime();
double inputTime = t.as(MTime::kSeconds);
double fps = getFPS();
// scale and offset inputTime.
inputTime = computeAdjustedTime(inputTime, speed, offset/fps);
// this should be done only once per file
if (mFileInitialized == false)
{
mFileInitialized = true;
MDataHandle dataHandle = dataBlock.inputValue(mAbcFileNameAttr);
MFileObject fileObject;
fileObject.setRawFullName(dataHandle.asString());
MString fileName = fileObject.resolvedFullName();
// TODO, make sure the file name, or list of files create a valid
// Alembic IArchive
// initialize some flags for plug update
mSubDInitialized = false;
mPolyInitialized = false;
// When an alembic cache will be imported at the first time using
// AbcImport, we need to set mIncludeFilterAttr (filterHandle) to be
// mIncludeFilterString for later use. When we save a maya scene(.ma)
// mIncludeFilterAttr will be saved. Then when we load the saved
// .ma file, mIncludeFilterString will be set to be mIncludeFilterAttr.
MDataHandle includeFilterHandle =
dataBlock.inputValue(mIncludeFilterAttr, &status);
MString& includeFilterString = includeFilterHandle.asString();
if (mIncludeFilterString.length() > 0)
{
includeFilterHandle.set(mIncludeFilterString);
dataBlock.setClean(mIncludeFilterAttr);
}
else if (includeFilterString.length() > 0)
{
mIncludeFilterString = includeFilterString;
}
MDataHandle excludeFilterHandle =
dataBlock.inputValue(mExcludeFilterAttr, &status);
MString& excludeFilterString = excludeFilterHandle.asString();
if (mExcludeFilterString.length() > 0)
{
excludeFilterHandle.set(mExcludeFilterString);
dataBlock.setClean(mExcludeFilterAttr);
}
else if (excludeFilterString.length() > 0)
{
mExcludeFilterString = excludeFilterString;
}
MFnDependencyNode dep(thisMObject());
MPlug allSetsPlug = dep.findPlug("allColorSets");
CreateSceneVisitor visitor(inputTime, !allSetsPlug.isNull(),
MObject::kNullObj, CreateSceneVisitor::NONE, "",
mIncludeFilterString, mExcludeFilterString);
{
mData.getFrameRange(mSequenceStartTime, mSequenceEndTime);
MDataHandle startFrameHandle = dataBlock.inputValue(mStartFrameAttr,
&status);
startFrameHandle.set(mSequenceStartTime*fps);
MDataHandle endFrameHandle = dataBlock.inputValue(mEndFrameAttr,
&status);
endFrameHandle.set(mSequenceEndTime*fps);
}
}
// Retime
MDataHandle cycleHandle = dataBlock.inputValue(mCycleTypeAttr, &status);
short playType = cycleHandle.asShort();
inputTime = computeRetime(inputTime, mSequenceStartTime, mSequenceEndTime,
playType);
clamp<double>(mSequenceStartTime, mSequenceEndTime, inputTime);
// update only when the time lapse is big enough
if (fabs(inputTime - mCurTime) > 0.00001)
{
mOutRead = std::vector<bool>(mOutRead.size(), false);
//.........这里部分代码省略.........
示例8: compute
//.........这里部分代码省略.........
}*/
MFnIntArrayData selectedForceVertsArrayData(selectedForceVertsData.data());
MIntArray sf = selectedForceVertsArrayData.array();
vector<int> selectedForceVertIndices;
for (int i = 0 ; i < sf.length() ; i++)
{
selectedForceVertIndices.push_back(sf[i]);
}
// temporarily create force direction vector
double *forceDir = forceDirectionData.asDouble3();
vector<double> dir;
dir.push_back(forceDir[0]); dir.push_back(forceDir[1]);dir.push_back(forceDir[2]);
prevDeformed = 0;
double youngsModulusDouble = youngsModulusData.asDouble();
double poissonRatioDouble = poissonRatioData.asDouble();
double objectDensityDouble = objectDensityData.asDouble();
double frictionDouble = frictionData.asDouble();
double restitutionDouble = restitutionData.asDouble();
double dampingDouble = dampingData.asDouble();
double userSuppliedDtDouble = userSuppliedDtData.asDouble();
double forceMagnitudeDouble = forceMagnitudeData.asDouble();
int fAppT = forceApplicationTimeData.asInt();
int fReleasedT = forceReleasedTimeData.asInt();
int fIncT = forceIncrementTimeData.asInt();
int fStartT = forceStartTimeData.asInt();
int fStopT = forceStopTimeData.asInt();
int integrationTypeInt = integrationTypeData.asShort();
int forceModelTypeInt = forceModelTypeData.asShort();
bool useSuppliedForceBool = useSuppliedForceData.asBool();
bool useSuppliedConstraintsBool = useSuppliedConstraintsData.asBool();
double contactKs = contactKsData.asDouble();
double contactKd = contactKdData.asDouble();
if( sm)
{
delete sm;
}
sm = new SoftBodySim(youngsModulusDouble,poissonRatioDouble,objectDensityDouble,
frictionDouble,restitutionDouble,dampingDouble, eleArrayLen, eleArray, vertArrayLen, vertArray,integrationTypeInt,forceModelTypeInt);
sm->setContactAttributes(contactKs,contactKd);
if (useSuppliedConstraintsBool)
sm->initialize("",userSuppliedDtDouble, selectedConstraintVertIndices);
else
{
vector<int> empty;
sm->initialize("",userSuppliedDtDouble, empty);
}
if (useSuppliedForceBool)
sm->setUserForceAttributes(forceMagnitudeDouble, dir,selectedForceVertIndices,fAppT,fReleasedT,fIncT,fStartT,fStopT);
std::vector<int> childList=fdg.GetDomainChild(currentConstriant);
if(childList.size()!=0){//not the root
for(int i=0;i<childList.size();i++){
int childIndex=-1;
for(int j=0;j<fdomain_list.size();j++){
if(fdomain_list[j]->index==childList[i]){
示例9: compute
//.........这里部分代码省略.........
CHECK_MSTATUS ( cameraPosition.normalize() );
if ( currentLight.child(aLightSpecular).asBool() )
{
MFloatVector specLightDirection = lightDirection;
MDataHandle directionH = block.inputValue( aRayDirection );
MFloatVector direction = directionH.asFloatVector();
float lightAttenuation = 1.0;
specLightDirection = MRenderUtil::maximumSpecularReflection( blindData,
lightDirection, point, surfaceNormal, direction );
lightAttenuation = MRenderUtil::lightAttenuation( blindData, point, surfaceNormal, false );
// Are we facing the light
if ( specLightDirection * surfaceNormal > 0.0f )
{
float power2 = block.inputValue( aPower ).asFloat();
MFloatVector rv = 2 * surfaceNormal * ( surfaceNormal * direction ) - direction;
float s = spec * powf( rv * specLightDirection, power2 );
specularR += lightIntensity[0] * s * lightAttenuation;
specularG += lightIntensity[1] * s * lightAttenuation;
specularB += lightIntensity[2] * s * lightAttenuation;
}
}
}
if( !lightData.next() ) break;
}
// factor incident light with surface color and add incandescence
resultColor[0] = ( diffuseR * surfaceColor[0] ) + specularR + incandescence[0];
resultColor[1] = ( diffuseG * surfaceColor[1] ) + specularG + incandescence[1];
resultColor[2] = ( diffuseB * surfaceColor[2] ) + specularB + incandescence[2];
// add the reflection color
if (reflectGain > 0.0) {
MStatus status;
// required attributes for using raytracer
// origin, direction, sampler, depth, and object id.
//
MDataHandle originH = block.inputValue( aRayOrigin, &status);
MFloatVector origin = originH.asFloatVector();
MDataHandle directionH = block.inputValue( aRayDirection, &status);
MFloatVector direction = directionH.asFloatVector();
MDataHandle samplerH = block.inputValue( aRaySampler, &status);
void*& samplerPtr = samplerH.asAddr();
MDataHandle depthH = block.inputValue( aRayDepth, &status);
short depth = depthH.asShort();
MDataHandle objH = block.inputValue( aObjectId, &status);
void*& objId = objH.asAddr();
MFloatVector reflectColor;
MFloatVector reflectTransparency;
MFloatVector& triangleNormal = block.inputValue( aTriangleNormalCamera ).asFloatVector();
// compute reflected ray
MFloatVector l = -direction;
float dot = l * normal;
if( dot < 0.0 ) dot = -dot;
MFloatVector refVector = 2 * normal * dot - l; // reflection ray
float dotRef = refVector * triangleNormal;
if( dotRef < 0.0 ) {
const float s = 0.01f;
MFloatVector mVec = refVector - dotRef * triangleNormal;
mVec.normalize();
refVector = mVec + s * triangleNormal;
}
CHECK_MSTATUS ( refVector.normalize() );
status = MRenderUtil::raytrace(
point, // origin
refVector, // direction
objId, // object id
samplerPtr, // sampler info
depth, // ray depth
reflectColor, // output color and transp
reflectTransparency);
// add in the reflection color
resultColor[0] += reflectGain * (reflectColor[0]);
resultColor[1] += reflectGain * (reflectColor[1]);
resultColor[2] += reflectGain * (reflectColor[2]);
}
// set ouput color attribute
MDataHandle outColorHandle = block.outputValue( aOutColor );
MFloatVector& outColor = outColorHandle.asFloatVector();
outColor = resultColor;
outColorHandle.setClean();
return MS::kSuccess;
}
示例10: compute
//.........这里部分代码省略.........
vertArray[v+1] = mpoint.y;
vertArray[v+2] = mpoint.z;
}
MFnIntArrayData restEleArrayData(restElementsData.data());
MIntArray ele = restEleArrayData.array();
int eleArrayLen = ele.length();
int *eleArray = new int[eleArrayLen];
ele.get(eleArray);
MFnIntArrayData selectedConstraintVertsArrayData(selectedConstraintVertsData.data());
MIntArray sv = selectedConstraintVertsArrayData.array();
// building selectedConstraintVerts
vector<int> selectedConstraintVertIndices;
for (int i = 0 ; i < sv.length() ; i++)
{
selectedConstraintVertIndices.push_back(sv[i]);
}
MFnIntArrayData selectedForceVertsArrayData(selectedForceVertsData.data());
MIntArray sf = selectedForceVertsArrayData.array();
vector<int> selectedForceVertIndices;
for (int i = 0 ; i < sf.length() ; i++)
{
selectedForceVertIndices.push_back(sf[i]);
}
// temporarily create force direction vector
double *forceDir = forceDirectionData.asDouble3();
vector<double> dir;
dir.push_back(forceDir[0]); dir.push_back(forceDir[1]);dir.push_back(forceDir[2]);
prevDeformed = 0;
double youngsModulusDouble = youngsModulusData.asDouble();
double poissonRatioDouble = poissonRatioData.asDouble();
double objectDensityDouble = objectDensityData.asDouble();
double frictionDouble = frictionData.asDouble();
double restitutionDouble = restitutionData.asDouble();
double dampingDouble = dampingData.asDouble();
double userSuppliedDtDouble = userSuppliedDtData.asDouble();
double forceMagnitudeDouble = forceMagnitudeData.asDouble();
int fAppT = forceApplicationTimeData.asInt();
int fReleasedT = forceReleasedTimeData.asInt();
int fIncT = forceIncrementTimeData.asInt();
int fStartT = forceStartTimeData.asInt();
int fStopT = forceStopTimeData.asInt();
int integrationTypeInt = integrationTypeData.asShort();
int forceModelTypeInt = forceModelTypeData.asShort();
bool useSuppliedForceBool = useSuppliedForceData.asBool();
bool useSuppliedConstraintsBool = useSuppliedConstraintsData.asBool();
double contactKs = contactKsData.asDouble();
double contactKd = contactKdData.asDouble();
if( sm)
{
delete sm;
}
sm = new SoftBodySim(youngsModulusDouble,poissonRatioDouble,objectDensityDouble,
frictionDouble,restitutionDouble,dampingDouble, eleArrayLen, eleArray, vertArrayLen, vertArray,integrationTypeInt,forceModelTypeInt);
sm->setContactAttributes(contactKs,contactKd);
if (useSuppliedConstraintsBool)
sm->initialize("",userSuppliedDtDouble, selectedConstraintVertIndices);
else
{
vector<int> empty;
sm->initialize("",userSuppliedDtDouble, empty);
}
if (useSuppliedForceBool)
sm->setUserForceAttributes(forceMagnitudeDouble, dir,selectedForceVertIndices,fAppT,fReleasedT,fIncT,fStartT,fStopT);
}
else
{
sm->update();
}
MFnMesh surfFn(rs,&stat);
McheckErr( stat, "compute - MFnMesh error" );
MFnMeshData ouputMeshDataCreator;
MObject oMesh = ouputMeshDataCreator.create(&stat);
buildOutputMesh(surfFn, sm->m_vertices,oMesh);
outputMeshData.set(oMesh);
data.setClean(plug);
}
else
stat = MS::kUnknownParameter;
return stat;
}
示例11: compute
MStatus updateTCCDataNode::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 - stored as short)
//
// (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");
MIntArray vR = MFnIntArrayData( data.inputValue( vtxRemap ).data() ).array(&status);
MCheckStatus(status,"ERROR getting vtxRemap");
MIntArray pO = MFnIntArrayData( data.inputValue( polyOrder ).data() ).array(&status);
MCheckStatus(status,"ERROR getting polyOrder");
MIntArray cS = MFnIntArrayData( data.inputValue( cShift ).data() ).array(&status);
MCheckStatus(status,"ERROR getting cShift");
MIntArray dnFV = MFnIntArrayData( data.inputValue( delta_nFV ).data() ).array(&status);
MCheckStatus(status,"ERROR getting deltanFV");
MIntArray dF = MFnIntArrayData( data.inputValue( delta_F ).data() ).array(&status);
MCheckStatus(status,"ERROR getting deltaF");
int nVtx = data.inputValue( nV ).asInt();
MCheckStatus(status,"ERROR getting nV");
// Copy the inMesh to the outMesh, and now you can
// perform operations in-place on the outMesh
//
outputData.set(inputData.asMesh());
MObject mesh = outputData.asMesh();
fupdateTCCDataFactory.setMesh( mesh );
fupdateTCCDataFactory.setVtxRemap( vR );
fupdateTCCDataFactory.setPolyOrder( pO );
fupdateTCCDataFactory.setCShift( cS );
fupdateTCCDataFactory.setDelta_nFV( dnFV );
fupdateTCCDataFactory.setDelta_F( dF );
fupdateTCCDataFactory.setnV( nVtx );
// Now, perform the updateTCCData
//
status = fupdateTCCDataFactory.doIt();
// Mark the output mesh as clean
//
outputData.setClean();
}
else
{
status = MS::kUnknownParameter;
}
}
return status;
}
示例12: 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);
}
//.........这里部分代码省略.........
示例13: compute
MStatus splitUVNode::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 - stored as short)
//
// (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 uvList and use it to perform
// the operation on this mesh
//
MDataHandle inputUVs = data.inputValue( uvList, &status);
MCheckStatus(status,"ERROR getting uvList");
// Copy the inMesh to the outMesh, and now you can
// perform operations in-place on the outMesh
//
outputData.set(inputData.asMesh());
MObject mesh = outputData.asMesh();
// Retrieve the UV 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 = inputUVs.data();
MFnComponentListData compListFn( compList );
unsigned i;
int j;
MIntArray uvIds;
for( i = 0; i < compListFn.length(); i++ )
{
MObject comp = compListFn[i];
if( comp.apiType() == MFn::kMeshMapComponent )
{
MFnSingleIndexedComponent uvComp( comp );
for( j = 0; j < uvComp.elementCount(); j++ )
{
int uvId = uvComp.element(j);
uvIds.append( uvId );
}
}
}
// Set the mesh object and uvList on the factory
//
fSplitUVFactory.setMesh( mesh );
fSplitUVFactory.setUVIds( uvIds );
// Now, perform the splitUV
//
status = fSplitUVFactory.doIt();
// Mark the output mesh as clean
//.........这里部分代码省略.........
示例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 resetVtxRemapNode::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 - stored as short)
//
// (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");
// Copy the inMesh to the outMesh, and now you can
// perform operations in-place on the outMesh
//
outputData.set(inputData.asMesh());
MObject mesh = outputData.asMesh();
fresetVtxRemapFactory.setMesh( mesh );
status = fresetVtxRemapFactory.doIt();
outputData.setClean();
}
else
{
status = MS::kUnknownParameter;
}
}
return status;
}