Okay, so I set a "Parent" pointer in this function
Code:
CSceneNode * ParentNode;
void SetParentNode(CSceneNode* Parent)
{
ParentNode = Parent;
}
This sets the class adding a child as the parent of the child it just created, like so...
Code:
std::list<CSceneNode*> m_lstChildren;
void AddChild( CSceneNode* pNode )
{
pNode->SetParentNode(this);
m_lstChildren.push_back(pNode);
}
Here is where it gets funky..
In the geometry node class, we need to access the parent of this geometry node's "combined matrix" variable. The parent of this node WILL have a combined matrix variable, but the BASE class does not.
Like so:
(Parent Node)
Code:
class CDOFNode : public CSceneNode
{
public:
CDOFNode(float m[4][4])
{
.....
}
~CDOFNode() { }
void Update()
{
.....
}
void Initialize( float m[4][4] )
{
.....
}
private:
float LocalMatrix[4][4];
float CombinedMatrix[4][4];
};
See, this guy will be the parent of the geometry node, the geometry node will be in turn a parent to another DOF node..
Here is the Geometry Node:
Code:
class CGeometryNode : public CSceneNode
{
public:
CGeometryNode(boost::weak_ptr<MS3DModel> Resource_Observer)
{
.....
}
~CGeometryNode() { }
void Update()
{
..... // need to access parent->Combined matrix here!!!!!
}
private:
boost::weak_ptr<MS3DModel> Geometry;
float CombinedMatrix[4][4];
};
Now you would think this is work, the DOF node DID create the geometry node, he IS the parent, but...
The base SceneNode class does not have a combined matrix, and he shouldn't either!
Code:
class CSceneNode
{
public:
CSceneNode() { }
virtual ~CSceneNode() { ..... }
// deletes this node
void Release() { ...... }
// call update on all children
virtual void Update()
{
......
}
// recursively destroy all children and self
void Destroy()
{
.....
}
// add a child
void AddChild( CSceneNode* pNode )
{
.....
}
// Set the parent of the child
void SetParentNode(CSceneNode* Parent)
{
....
}
protected:
// list of children
std::list<CSceneNode*> m_lstChildren;
// pointer to parent
CSceneNode * ParentNode;
};
So obviously, this spawns an error, CombinedMatrix is not a member of CSceneNode, this error is true, but in ALL cases, the DOF node will be a parent of a geometry node, thus this problem will never happen during run time!!
What can I do?