Topo Changes on Referenced Models / Workaround
February 14th, 2007 by Helge Mathee - Viewed 2836 times - Popularity: 14% [?]As in the current implementation of the referenced models it is not allowed to do topological changes on top, here’s a workaround which has proven to work well in production:
Basically, for a flexible workflow, I use scripted operators to copy the pointcloud from a referenced object to a local copy in the scene, to deformations on top, and then copy it back into the referenced model. This requires the geometry to exist twice, in the ref model. However, a more complex example could be to use ONE operator to do both copies, this way you wouldn’t need two meshes inside the ref model.
For the sake of simplicity, here’s the example with a simple pointcloud-copy scripted operator in JScript. Just run this in an empty scene.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | var myProject = ActiveProject.path; // create the model NewScene(false,false); // create two cylinders var source = CreatePrim("Cylinder", "MeshSurface", null, null); var target = CreatePrim("Cylinder", "MeshSurface", null, null); SetValue("cylinder1.Name", "cylinder_out", null); FreezeObj("cylinder,cylinder_out"); // create a skeleton Create2DSkeleton(0, 4, 0, 0, 0, 1, 0, 90, 0, 4, null, null); AppendBone("eff", 0, -4, 0, null); ApplyFlexEnv("cylinder;root,bone,bone1,eff", null, 2); // apply the copy op to the second cylinders createCopyPosOp(source,target); DeselectAll(); // create an empty model CreateModel(); ToggleVisibility("cylinder"); // put all objects (cylinders and chains) below the model ParentObj("model","cylinder_out,cylinder,root"); // export the model to the current project ExportModel("Model", myProject + "\\Models\\ref_geo.emdl"); // create the scene with a referenced model NewScene(false,false); SICreateRefModel(myProject + "\\Models\\ref_geo.emdl"); // create the local meshcopy var result = addLocalMeshCopy( Dictionary.GetObject("ref_geo.cylinder"), Dictionary.GetObject("ref_geo.cylinder_out")); // do a deform on top ApplyOp("Push", result+".pnt[0,2,3,7,8,12,13,17,18,22,23,27,28,32,33,37,38]"); SetValue("cylinder_local.polymsh.pushop.ampl", 1 ); SelectObj("ref_geo.eff"); // the function to create a mesh copy function addLocalMeshCopy(source,target) { // retrieve the mesh data var meshData = source.ActivePrimitive.Geometry.Get2().toArray(); var points = meshData[0].toArray(); var polies = meshData[1].toArray(); // create a new mesh var newMesh = ActiveSceneRoot.AddPolygonmesh(points,polies,source.name+"_local"); // copy the point positions from the enveloped // mesh to the local copy createCopyPosOp(source,newMesh); // turn off the original copy op SetValue(target+".polymsh.copyPos.mute", true); // now copy the point positions from the local copy to the final output createCopyPosOp(newMesh,target); return newMesh; } // the function to create the point position copy operator function createCopyPosOp(source,target) { // create the op var op = XSIFactory.CreateScriptedOp( "copyPos", copyPos_Update.toString(), "JScript" ); // create two ports for in and out and connect it op.AddOutputPort( target.ActivePrimitive ); op.AddInputPort( source.ActivePrimitive ); op.Connect(); } // the update code for the point pos copy operator function copyPos_Update(ctxt,outMesh,inMesh) { var pos = inMesh.value.geometry.points.positionarray.toArray(); outMesh.value.geometry.points.positionarray = pos; } |
Popularity: 14% [?]





Hi Helge,
I’ll try this for sure but I got a question for you :)
you said:
“As in the CURRENT implementation of the referenced models it is not allowed to do topological changes…”
Does that mean you are working for make it possible in the future? it would be great!
I can’t comment on that, sorry.
:) I understand…
Thank you anyway