Notifications
Clear all

[Closed] (3ds max SDK) How do I get the node of a Control?

I am implementing a LookAt Controller plugin by deriving from the Control class.

Everything works fine, except that I don’t understand how I can get a INode pointer to the node that the Control belongs to. How do I get that pointer from within my LookAt class?

7 Replies
class MyEnumProc : public DependentEnumProc 
 {
 	public :
 		virtual int proc(ReferenceMaker *rmaker); 
 		INode* node;			 
 };
 
  int MyEnumProc::proc(ReferenceMaker *rmaker) 
 { 
 	  if (rmaker->SuperClassID()==BASENODE_CLASS_ID)
 	  {
 			node = static_cast<INode *>(rmaker);
 			return DEP_ENUM_HALT;
 	  }
 	  return DEP_ENUM_CONTINUE;
 }
 

then when you need the node…

MyEnumProc dep;			  
 DoEnumDependents(&dep); // inherited by your control from ReferenceMaker
 if(dep.node)
 {....

What if we have multiple nodes referencing a single modifier instance?
How do we get self node in such case?

the “self” node would go with the modcontext that relates to that node not the actual modifier

Thanks, but it is probably not what I need. Or I just don’t get it…

My actual goal is to calc exact vert-vert distances between the mesh that has modifier and a target mesh
I’m struggling to get node TM from inside of the ModifyObject function.

That’s what I have.

// from sdk samples
class MyEnumProc : public DependentEnumProc
{
public:
	virtual int proc(ReferenceMaker *rmaker);
	INodeTab Nodes;
};
int MyEnumProc::proc(ReferenceMaker *rmaker)
{
	if (rmaker->SuperClassID() == BASENODE_CLASS_ID)
		Nodes.Append(1, (INode **)&rmaker);
	return DEP_ENUM_CONTINUE;
}


...


void MyModifier::ModifyObject(TimeValue t, ModContext& mc, ObjectState* os, INode* node)
{
	
	INode* this_node = NULL;

	MyEnumProc dep;
	DoEnumDependents(&dep);
		
	if (dep.Nodes.Count() > 0)
	{
		mprintf(_T("dependents count: %d\n"), dep.Nodes.Count());
		
		for ( int j = 0; j < dep.Nodes.Count(); j++ )
		{
                        // successfully prints all the nodes names that share this modifier
			mprintf(_T("node: %s\n"), dep.Nodes[j]->NodeName() ); 
		}

		this_node = dep.Nodes[  ???  ]; // how do I know which one corresponds to current os->obj ?
		
	}
	
	...

Interface::GetModContexts(…)
gives you a list of nodes being edited
if list-size is 1, that’s your node
if list-size is >1, then there is no way to tell which one it is

but that doesnt work when your modifie is not the current edited one
i see some problem here…

strange that there is no SDK-method for things like that

it’s quite complicated especially when you need really time updating there’s and example of being done in clstnode.cpp (which can be simplified slightly). But ideally if you need access to the node being modified it should be handled with a world space modifier not an object space one.

It is indeed pretty hard to make it work.

GetNodeFromModContext from volumeselect modifier source (selmod.cpp) returns the correct node, unless I copy node with already applied modifier as instance. After that GetNodeFromModContext returns the newly created node only.
But no problem whatsoever if I apply mod to a dozen of instances… it keeps returning the right node from the given modcontexts

will check it out, thanks