![]() |
![]() |
|
|||||||
| Open Inventor Main Forum General discussions about Open Inventor from VSG |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Now,I have got an object (its type is SoNode) and the type of its parent is SoSeparator,how to get its parent?
How to get the child number of SoSeparator? Last edited by East2010; 04-15-2012 at 04:41 AM. |
|
#2
|
||||
|
||||
|
Quote:
- Call setNode() with the address of the node - Apply the action to the root of the scene graph - Call getPath() to get an SoPath - Call getIndexFromTail(0) to get the index (in its parent) of the node. To get a pointer to the node's parent call getNodeFromTail(1). |
|
#3
|
|||
|
|||
|
Hello,
Then to be faster, you also can use this peace of code. Code:
#include <Inventor/SoLists.h>
#include <Inventor/misc/SoNotification.h>
void buildHeadNodesList(SoNode* node, std::set<SoNode*>& nodelist)
{
if (node != NULL)
{
SoAuditorList* al = (SoAuditorList*)&(node->getAuditors());
int j;
int numParent = 0;
for ( j = 0; j < al->getLength(); j++ )
{
if (al->getType(j) == SoNotRec::PARENT)
{
SoNode* parentNode = (SoNode*)(al->getObject(j));
if (parentNode != NULL)
{
buildHeadNodesList(parentNode, nodelist);
numParent++;
}
}
}
if (numParent == 0)
nodelist.insert(node);
}
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|