Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

luck_bird_bj

How can track the position and rotation in world corordinate?

This topic is 5438 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

Image a 3ds model, for example. an persion with arms, when the person changes his position and rotation (in world coordinate), his arms also change rotation and position (in local coordinate).How can i track the persion''s position and his arm''s position,both in world coordinate? I have read some articles about extract infomation from projection and modelview matrix plus camera''s position in OpenGL,but fail. can anyone give me an example or tuturial? thanks!!

Share this post


Link to post
Share on other sites
Advertisement
it''s a hierarchy thing. Each bone''s position depends on it''s parent position.

Say, you have the global person''s position and orientation in world coordinate, and the top bone in the hierarchy (I use the head ), you just pass the transform through the hierarchy.



void cHierarchy::CalcualteWorldCoord(const Vector& Pos, const Matrix& Ori)
{
m_pxHead->CalcualteWorldCoord(Pos, Ori);
}

void cBone::CalcualteWorldCoord(const Vector& ParentWorldPos, const Matrix& ParentWorldOri)
{
m_WorldPos = m_LocalPos * ParentOri + ParentPos;
m_WorldOri = m_LocalOri * ParentOri;

for(int i = 0; i < m_iNumChildBones; i ++)
{
m_pxChildBone[i]->CalcualteWorldCoord(m_WorldPos, m_WorldOri);
}
}

Share this post


Link to post
Share on other sites
quote:
Original post by oliii
it''s a hierarchy thing. Each bone''s position depends on it''s parent position.

Say, you have the global person''s position and orientation in world coordinate, and the top bone in the hierarchy (I use the head ), you just pass the transform through the hierarchy.



void cHierarchy::CalcualteWorldCoord(const Vector& Pos, const Matrix& Ori)
{
m_pxHead->CalcualteWorldCoord(Pos, Ori);
}

void cBone::CalcualteWorldCoord(const Vector& ParentWorldPos, const Matrix& ParentWorldOri)
{
m_WorldPos = m_LocalPos * ParentOri + ParentPos;
m_WorldOri = m_LocalOri * ParentOri;

for(int i = 0; i < m_iNumChildBones; i ++)
{
m_pxChildBone[i]->CalcualteWorldCoord(m_WorldPos, m_WorldOri);
}
}




or is it


m_WorldOri = ParentOri * m_LocalOri;


not too sure about this one. I get confused with matrices

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!