Sign in to follow this  

Finding Relative Transformation

This topic is 3865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites

This topic is 3865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this