Am creating my own scenenode (CMyNode) and have a question about the children and rendering a node without any parent. Since I am learning the engine, I need some preventive advice.
The scenenode contains his own custom scenenodes (CMyOtherNode). These 'children' scenenodes shouldn't be accesible outside of this cMyNode class. Therfor the parent of the CMyOtherNode isn't set to the instance of CMyNode nor it it set to sceneManager->getRootSceneNode(). They are not added to ISceneNode::Children but to an array member.
Since both classes decent from ISceneNode I have overridden the OnRegisterSceneNode, as below, for both. Now all m_myOthers are rendered too, yeah.
My question: Is this correct or am I heading towards a nasty bug in my application?
Code: Select all
class CMyOtherNode;
class CMyNode : public scene::ISceneNode
{
core::array<CMyOtherNode*> m_myOthers; // can have nulled entries
public:
CMyNode ::CMyNode(...) : ISceneNode( parent, sceneManager, id, position, rotation, scale )
{
for( u32 i = 0; i < 4; --i )
{
// Add other
CMyOtherNode* other = new CMyOtherNode( 0, SceneManager ); // No parent!
m_myOthers.push_back( other );
}
}
void OnRegisterSceneNode()
{
// Same for CMyOtherNode
if( IsVisible )
{
SceneManager->registerNodeForRendering( this );
u32 size = m_myOthers.size();
for( u32 i = 0; i < size; ++i )
m_myOthers[ i ]->OnRegisterSceneNode();
}
ISceneNode::OnRegisterSceneNode();
}
}