Hey gamedev,
for a college project I need to create a ragdoll using DirectX and PhysX.
I'm still in the first phase of laying out the structure for this ragdoll. At this moment I'm trying to map
actors to the bones that are imported together with mesh data. The problem I have at this moment is
that I can move my actor to the position of the bone (all offsets + world = worldmatrix).
But when I want it to follow the animation, my bone gets translated and rotated (axis) correctly, but my shape
doesn't rotate. Only the axis changes.
This engine is an engine written by some teachers, so I can't share it here. Also, the architecture is still
rough. Here are some snippets of where the issue is.
I hope this is a know issue and someone can help me with this one! It is pretty important for my project.
Thank you in advance guys/girls!!
void PhysxBone::MapToBone(MeshFilter* pMeshFilter)
{
//........................
m_matModelSpace *= m_pBone->Offset;
//..................
D3DXMATRIX world;
D3DXMatrixIdentity(&world);
m_matWorldSpace = m_matModelSpace * world;
}
void PhysxBone::Update(D3DXMATRIX matKeyTransform)
{
m_matWorldSpace = matKeyTransform * m_matModelSpace;
NxMat34 nPos;
PhysicsManager::GetInstance()->DMatToNMat(nPos, m_matWorldSpace);
m_pActor->setGlobalPose(nPos);
}
void PhysicsManager::DMatToNMat(NxMat34& NxMat, const D3DXMATRIX& D3DMat)
{
NxVec3 vTmp;
vTmp = NxVec3(D3DMat._11, D3DMat._21, D3DMat._31);
NxMat.M.setRow(0, vTmp);
vTmp = NxVec3(D3DMat._12, D3DMat._22, D3DMat._32);
NxMat.M.setRow(1, vTmp);
vTmp = NxVec3(D3DMat._13, D3DMat._23, D3DMat._33);
NxMat.M.setRow(2, vTmp);
NxMat.t.set(D3DMat._41, D3DMat._42, D3DMat._43);
}