Notifications
Clear all
[Closed] SDK: snapshotAsMesh?
Page 2 / 2
Prev
Apr 13, 2016 11:18 pm
Your function doesn’t make much sense to me.
Firstly, you're getting a copy of your new TriObject's mesh (which is likely null...although maybe the TriObject constructor assigns an empty mesh? I haven't checked)....instead of the sourceNode's mesh? Aren't you trying to get a snapshot of the source node?
Then after assigning an empty mesh to your TriObject, you are converting it to a TriObject? ...Why?
Steps should be (borrowing from Denis):
1) Get source TriObject from sourceNode ObjectState with ConvertToType function
2) Get mesh from source TriObject
3) Assign copy of mesh to your constructed TriObject
4) Cleanup source TriObject if it was made by collapsing sourceNode
INode *Snapshot(INode *sourceNode, TimeValue t) //we should have only gotten this far if "CanConvertToType(triObjectClassID)" returns true for our sourceNode
{
ObjectState os = sourceNode->EvalWorldState(t);
TriObject *tri = (TriObject*)os.obj->ConvertToType(t, triObjectClassID);
TriObject *newTri = new TriObject;
INode *node = GetCOREInterface()->CreateObjectNode(newTri);
newTri->mesh = Mesh(tri->GetMesh());
if (tri != os.obj)
{
tri->AutoDelete();
}
}
Apr 13, 2016 11:18 pm
I was just trying to follow the steps you had both given me, but looking back now I realize I was doing things backwards.
At any rate, the function you just gave me still results in a “Mesh” rather than an “Editable Mesh”…
Apr 13, 2016 11:18 pm
Approaching things slightly differently, I have gotten to this. Sometimes it works perfectly, but it is extremely unstable. Any tips would be appreciated.
INode *Snapshot(INode *sourceNode, TimeValue t) {
ObjectState os = sourceNode->EvalWorldState(t);
if (!os.obj->CanConvertToType(triObjectClassID)) return NULL;
Object *Obj = (Object *)os.obj->CollapseObject();
INode *node = GetCOREInterface()->CreateObjectNode(Obj);
if (Obj == os.obj) Obj = (Object *)CloneRefHierarchy(Obj);
TriObject *TriObj = (TriObject *)Obj->ConvertToType(t, triObjectClassID);
node->SetObjectRef(TriObj);
return node;
}
Page 2 / 2
Prev