How can track the position and rotation in world corordinate?

Started by
1 comment, last by luck_bird_bj 20 years, 8 months ago
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!!
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);    }}

Everything is better with Metal.

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

Everything is better with Metal.

This topic is closed to new replies.

Advertisement