Archived

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

How can track the position and rotation in world corordinate?

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

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 on other sites
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 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;

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633735
• Total Posts
3013596
×