PDA

View Full Version : [API] UV Deformer updating mesh


chadmv
11-27-2007, 08:29 PM
I've written a deformer that modifies a meshes UV's but I'm having trouble getting the mesh to redraw itself in real-time in the viewport. The UV's are modified using the matrix of an accessory node. When I move the accessory node around, the UVs do not update but then when I move the deformed mesh, the UV's snap to where they should be after getting deformed. Also when I disconnect and reconnect the inMesh attribute of my deformed node, the mesh updates to its correct state.

One wierd thing I noticed is that when I put a polySmooth node downstream from my deformer with the node state set to HasNoEffect, the mesh will update in real-time just fine. Is there a flag or something I need to set to get the mesh to redraw itself? My compute method has:

// Get the output
MDataHandle hOutput = block.outputValue( plug, &returnStatus );
hOutput.copy( hGeom );
MObject oOutMesh = hOutput.asMesh();

MVector vect = tMatrix.getTranslation( MSpace::kTransform );

MFnMesh fnOutMesh( oOutMesh );
MItMeshVertex itVert( oOutMesh );
MIntArray vertices;while ( !itVert.isDone() )
{
itVert.getUVs( uArray, vArray, faceIds );
float weight = weightValue( block, index, itVert.index() );
int numUVs = uArray.length();
for ( int i = 0; i < numUVs; i++ )
{
uArray[i] = uArray[i] - (vect.x * weight) * env;
vArray[i] = vArray[i] + (vect.z * weight) * env;
}
itVert.setUVs( uArray, vArray, faceIds );
itVert.next();
}

fnOutMesh.updateSurface();
hOutput.set( oOutMesh );
block.setClean( outputGeom );

I have that updateSurface call, but it doesn't seem to do anything.

CGTalk Moderation
11-27-2007, 08:29 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.