mfg
08-13-2009, 05:06 AM
so while i was researching nodes i came upon this site http://www.cgdna.com/cms/archives/170 , morteza wrote a polyInfo node.
so i checked out the source code and i am interested in understanding how he sets the datahandle's for the output.
...
MDataHandle vertexCountDataHandle = data.outputValue(cgdnaPolyinfo::vertexCount);
int &vertexCount_Output = getvertexCount;
vertexCountDataHandle.set( vertexCount_Output );
vertexCountDataHandle.setClean();
MDataHandle wsVertexPositionDataHandle = data.outputValue(cgdnaPolyinfo::wsVertexPosition);
MFloatVector &wsVertexPosition_Output = getwsVertexPosition;
wsVertexPositionDataHandle.set( wsVertexPosition_Output );
wsVertexPositionDataHandle.setClean();
...
so i tired to copy this approach. here is the compute part of my very simplified node
MStatus myVertexInfo::compute( const MPlug& plug, MDataBlock& data )
{
MStatus returnStatus;
if( plug == vertexCount || plug == wsVertexPosition )
{
MDataHandle inMeshHandle = data.inputValue( inMesh, &returnStatus );
if( returnStatus != MS::kSuccess )
MGlobal::displayError( "Node myVertexInfo cannot get value\n" );
MDataHandle inVertexIdHandle = data.inputValue(inVertexId, &returnStatus );
if( returnStatus != MS::kSuccess )
MGlobal::displayError( "Node myVertexInfo cannot get value\n" );
else
{
int inVertex = inVertexIdHandle.asInt();
MFnMesh meshFn = inMeshHandle.asMesh();
int Vcount = meshFn.numVertices();
MPoint pt;
meshFn.getPoint(inVertex,pt,MSpace::kWorld);
MVector Vpos = pt;
////
MDataHandle wsVertexPositionHandle = data.outputValue( myVertexInfo::wsVertexPosition );
MVector &wsVertexPosition_Output = Vpos;
wsVertexPositionHandle.set( wsVertexPosition_Output );
wsVertexPositionHandle.setClean();
MDataHandle vertexCountHandle = data.outputValue( myVertexInfo::vertexCount );
int &getvertexCount_Output = Vcount;
vertexCountHandle.set( getvertexCount_Output );
vertexCountHandle.setClean();
}
} else {
return MS::kUnknownParameter;
}
return MS::kSuccess;
}
so in maya i connect the outmesh of a polygon to the inmesh of the node.
(getAttr myVertexInfo1.vertexCount) returns the correct result
(getAttr myVertexInfo1.wsVertexPosition) the return here looks kinda like this (239487358239 -3 09478568947523)
so what am i doing wrong?
ty, for your time.
so i checked out the source code and i am interested in understanding how he sets the datahandle's for the output.
...
MDataHandle vertexCountDataHandle = data.outputValue(cgdnaPolyinfo::vertexCount);
int &vertexCount_Output = getvertexCount;
vertexCountDataHandle.set( vertexCount_Output );
vertexCountDataHandle.setClean();
MDataHandle wsVertexPositionDataHandle = data.outputValue(cgdnaPolyinfo::wsVertexPosition);
MFloatVector &wsVertexPosition_Output = getwsVertexPosition;
wsVertexPositionDataHandle.set( wsVertexPosition_Output );
wsVertexPositionDataHandle.setClean();
...
so i tired to copy this approach. here is the compute part of my very simplified node
MStatus myVertexInfo::compute( const MPlug& plug, MDataBlock& data )
{
MStatus returnStatus;
if( plug == vertexCount || plug == wsVertexPosition )
{
MDataHandle inMeshHandle = data.inputValue( inMesh, &returnStatus );
if( returnStatus != MS::kSuccess )
MGlobal::displayError( "Node myVertexInfo cannot get value\n" );
MDataHandle inVertexIdHandle = data.inputValue(inVertexId, &returnStatus );
if( returnStatus != MS::kSuccess )
MGlobal::displayError( "Node myVertexInfo cannot get value\n" );
else
{
int inVertex = inVertexIdHandle.asInt();
MFnMesh meshFn = inMeshHandle.asMesh();
int Vcount = meshFn.numVertices();
MPoint pt;
meshFn.getPoint(inVertex,pt,MSpace::kWorld);
MVector Vpos = pt;
////
MDataHandle wsVertexPositionHandle = data.outputValue( myVertexInfo::wsVertexPosition );
MVector &wsVertexPosition_Output = Vpos;
wsVertexPositionHandle.set( wsVertexPosition_Output );
wsVertexPositionHandle.setClean();
MDataHandle vertexCountHandle = data.outputValue( myVertexInfo::vertexCount );
int &getvertexCount_Output = Vcount;
vertexCountHandle.set( getvertexCount_Output );
vertexCountHandle.setClean();
}
} else {
return MS::kUnknownParameter;
}
return MS::kSuccess;
}
so in maya i connect the outmesh of a polygon to the inmesh of the node.
(getAttr myVertexInfo1.vertexCount) returns the correct result
(getAttr myVertexInfo1.wsVertexPosition) the return here looks kinda like this (239487358239 -3 09478568947523)
so what am i doing wrong?
ty, for your time.
