Modifing figure geometry
Semicharm
Posts: 375
I'm trying to modify the geometry of a specific figure in order to fix a break between two groups. At the moment, the script prints the vertex values before and after setting them. The values seem to be set correctly, but if I run the script again, the "before" values are the same as last time. My changes don't seem to stick.
What am I missing?
var oNode = Scene.getPrimarySelection();// List of array objects in the format [ vertexIndex, xVale, yValue, zValue ]var vList; // *omitted*if( oNode ){ var oSkeleton = oNode.getSkeleton(); if( oSkeleton ){ oNode = oSkeleton; print(oNode.getName() + ": " + oNode.className()); var oObject = oNode.getObject(); if( oObject ){ var oShape = oObject.getCurrentShape(); if( oShape ){ var oVertexMesh = oShape.getModifiableAssemblyGeom( false ); if( oVertexMesh ){ print(oVertexMesh.getNumVertices()); oVertexMesh.beginEdit(); for( var i=0; i < vList.length; i++ ){ var oV = oVertexMesh.getVertex( vList[ i ][0] ); print(vList[ i ][0] + ": " + oV.x + ", " + oV.y + ", " + oV.z); oVertexMesh.setVertex( vList[ i ][0], DzVec3( vList[ i ][1], vList[ i ][2], vList[ i ][3] ) ); oV = oVertexMesh.getVertex( vList[ i ][0] ); print(vList[ i ][0] + ": " + oV.x + ", " + oV.y + ", " + oV.z); print(""); } oVertexMesh.finishEdit(); oNode.update(); } } } }}
Post edited by Richard Haseltine on
Comments
Never mind. Figured out that getModifiableAssemblyGeom creates a copy of the geometry, which is getting thrown away when the script finishes. To get to the actual mesh geometry, I needed to call getFacetMesh instead.
That sort of works, but the welding between the groups doesn't seem to be updated. To be more specific about the problem, DS isn't welding all of the vertices between the groups correctly. This isn't a problem in Poser though. DS seems to be more picky, as the vertices needed to be closer for welds to work properly.
It's possible to modify the original obj to correct this, but rather than putting everyone else through the trouble to doing the edits or decoding a modified obj file, I want to try to create a patch to automatically fix the figure when it loads in DS. I verified that the vertices are getting updated and they match the values from the corrected obj. However, the modified vertices aren't getting welded.
I think wlding happens at import, for a CR2 figure, so you may need to export the OBJ. However, I'm far from certain of that.
Is there a way to invoke it again after the obj has been imported?
I didn't see anything immediately on looking through the old scripting docs, but this is a new object type so it may have a way to trigger a weld.
There used to be a .ds script kicking around that fixed Miki2's neck for DS users, it edited the actual OBJ and welded the vertices of the neck, if you can find it you might be able to work out a way of doing that with the DS3 & 4 scripting language.