Notifications
Clear all

[Closed] [SDK] TriObject of INode after specific modifier on the stack

Hi,
I’m trying to get TriObject* from INode with some modifier applied. I have such function:

TriObject* vSkin::GetTriObjectFromNode(INode *node, TimeValue pTime)
{
	Object *obj = node->EvalWorldState(pTime).obj;
	if (obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
	{
		TriObject *tri = (TriObject *) obj->ConvertToType(czas, Class_ID(TRIOBJ_CLASS_ID, 0));
		return tri;
	}
	else return NULL;
}

It gives me the TriObject which is the result of the the node’s pipeline.
Is it possible to get the TriObject which is the output of the first modifier for example, when the node has lots of modifiers on the stack?

2 Replies

Oh, as always solution comes just after you post on forum

	Object* pObject = node->GetObjectRef();
	IDerivedObject* pDerivedObject = NULL;
	if (pObject->SuperClassID() == GEN_DERIVOB_CLASS_ID)
		pDerivedObject = static_cast<IDerivedObject *>(pObject);
	else
	{
		pDerivedObject = CreateDerivedObject();
		pDerivedObject->TransferReferences(pObject);
		pDerivedObject->ReferenceObject(pObject);
	}
	ObjectState os = pDerivedObject->Eval(time, modIndex);
	Object* objAfterMod = os.obj;
	if (objAfterMod ->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
	{
		TriObject *tri = (TriObject *) objAfterMod ->ConvertToType(czas, Class_ID(TRIOBJ_CLASS_ID, 0));
		return tri;
	}
	else return NULL;

wouldn’t just

pDerivedObject = CreateDerivedObject(pObject);

instead of…

pDerivedObject = CreateDerivedObject(); 
pDerivedObject->TransferReferences(pObject);
 pDerivedObject->ReferenceObject(pObject);

?