Finding Relative Transformation

Started by
0 comments, last by lubby 16 years, 11 months ago
My question is about the math involved in scene graphs and how they determine relative translations.. Say I have a node in my tree that is the terrain, positioned at 0, 0, 0. What mathematical equation do I use to find the transformation variables for a dwarf which is located relatively to the above node... I know you have to take the terrains transformation matrix, which should read out 0, 0, 0 to gltranslate... but do I add the dwarf's transformation matrix to find his relative location, or multiply it? I havn't taken any math classes in over 2 years and I admit I'm a bit rusty with my algebra. I'll show you the code I have...

class CDOFNode : public CSceneNode
{
public:

	CDOFNode() 
	{
	}

	~CDOFNode() { }

	void Update()
	{

		glPushMatrix();
		this->FinalMatrix = LocalMatrix * ParentNode->FinalMatrix;
		glMultMatrixf(this->FinalMatrix.readArray());

		CSceneNode::Update();
		glPopMatrix();
	}

	void Initialize( Vector4 translation) // Updates local matrix
	{
		LocalMatrix.Translation(translation);
	}

private:

	Matrix4 LocalMatrix;
};
This doesn't work at all, seeing as how when my program runs I get polygons all over the screen, kinda like a kaleidoscope. I ran the debug and it's obvious that my FinalMatrix is not what it should be. Any help?
Advertisement
multiply it

This topic is closed to new replies.

Advertisement