Okay, so I set a "Parent" pointer in this function
This sets the class adding a child as the parent of the child it just created, like so...Code:CSceneNode * ParentNode; void SetParentNode(CSceneNode* Parent) { ParentNode = Parent; }
Here is where it gets funky..Code:std::list<CSceneNode*> m_lstChildren; void AddChild( CSceneNode* pNode ) { pNode->SetParentNode(this); m_lstChildren.push_back(pNode); }
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)
See, this guy will be the parent of the geometry node, the geometry node will be in turn a parent to another DOF 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]; };
Here is the Geometry Node:
Now you would think this is work, the DOF node DID create the geometry node, he IS the parent, but...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]; };
The base SceneNode class does not have a combined matrix, and he shouldn't either!
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!!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; };
What can I do?



LinkBack URL
About LinkBacks



