Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Orientation problem on object attachment

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

This is a warehouse scenario, first a warehouse operator attaches to a hand trolley.
The attachment is fine, the method i use is to create a transformation matrix that follows the hand combined transformation matrix, the trolley attach point is also the child of this combined transformation matrix. During update of the trolley, I check the value of this transformation matrix and concatenate it to the world matrix of the operator. The problem is when the operator is walking in opposite direction, the trolley will appear up-side down (in the air). I notice this is because the trolley's transformation is equal to the combined transformation matrix of the hand, it would follow the hand movement. I am seeking for a solution that will allow the trolley to stay on ground all the times. Any pointers would be appreciated...
Let's see some code

void AttachToOperator(CrowdEntity* pObject, char* Name)
{
FrameEx *root = (FrameEx*) pObject->GetFrameRoot();

m_pOperator = dynamic_cast<COperator*>(pObject); // Save a reference to the operator

if (root != NULL)
{
FrameEx *f = (FrameEx*) D3DXFrameFind(root, Name);
if (f != NULL)
{
m_pCombineFrameMatrix = &f->matCombined;
m_Mesh.SetParent(f, "Handle", 1.5f);
}
}
}

/////////////////////////////////
// Set parent is very ugly
void CMesh::SetParent(LPD3DXFRAME pFrame, char *Name, int size)
{
LPD3DXFRAME f = D3DXFrameFind(GetFrameRoot(), Name);
pFrame->pFrameFirstChild = new D3DXFRAME();
pFrame->pFrameFirstChild = f;
FrameEx *f2 = (FrameEx*) pFrame;
FrameEx *f3 = (FrameEx*) f;

f3->matCombined = f2->matCombined;
f3->matCombined._11 = size;
f3->matCombined._22 = size;
f3->matCombined._33 = size;

}


Thanks
Jack

Share this post


Link to post
Share on other sites
Advertisement
Don't know why I cancel out all combined matrix values to identity except 41 42 43, the trolley is sometimes upside-down. Something to do with the right-hand-rule? Not too sure Any ideas? Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!