fetch dynamic array of node pointers in SDK

fetch dynamic array of node pointers in SDK

Anonymous
Not applicable
681 Views
2 Replies
Message 1 of 3

fetch dynamic array of node pointers in SDK

Anonymous
Not applicable

How would you handle a fetch of node pointers to use later?

 

int N_Count = ip->GetSelNodeCount();
INode *MyNodes;
MyNodes = new INode[N_Count];

for (int i = 0; i < ip->GetSelNodeCount(); i++){
	MyNodes[i] = ip->GetSelNode(i);
}

 

Thanks

0 Likes
682 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

It depends if you expect any changes in scene structure between your calls.

If the scene will not change than it should be fine, though you might consider INodeTab for this.

Otherwise it's best to store Animatable::GetHandleByAnim and get INode* back with Animatable::GetAnimByHandle (just test if it's not NULL, like for deleted nodes).

Hope it helps.

Message 3 of 3

Anonymous
Not applicable

Got it, someone sent me some samples....

 

////INodeTab way

INodeTab nodes;
for (auto i = 0; i < ip->GetSelNodeCount(); ++i)
      nodes.AppendNode(ip->GetSelNode(i));

or

//// MaxSDK::Array

MaxSDK::Array<INode*> nodes;
for (auto i = 0; i < ip->GetSelNodeCount(); ++i)
      nodes.append(ip->GetSelNode(i));


or 

////std::vector

std::vector<INode*> nodes;
for (auto i = 0; i < ip->GetSelNodeCount(); ++i)
      nodes.push_back(ip->GetSelNode(i));

 All work well.

0 Likes