dotXSI and bones/skinning code 2005-06-06 - By Daniel
Back Hi,
I have moved all my engine work over from using custom plugin for xsi into using the dotXSI format and the FTK. Its all working great for all geometry, etc but i have problems with getting the bones to work correct.
My basic code looks kinda of like this: What this code is supposed to do is to calculated the global inverse matrix of the the rest position of the bone.
buildSkinInfo(CSLModel* model) { // cut away some init, setup, etc, code
CSLEnvelope** envelopList = model->GetEnvelopeList();
for (int i = 0; i < model->GetEnvelopeCount(); ++i) { CSLEnvelope* envelope = envelopList[i];
CSLModel* deformerModel = envelope->GetDeformer(); Node* boneNode = findNode(deformerModel); // node is a own type of node , basic just a simple Node in a scenegraph m_bones[i].setTarget(boneNode); // stores the target for the node
CSLTransform* transform = deformerModel->GetBasePose(); transform->ComputeGlobalMatrix(); CSIBCMatrix4x4& globalMatrix = transform->GetGlobalMatrix(); CSIBCMatrix4x4 inversMatrix;
globalMatrix.GetInverse(inversMatrix); m_bones[i].setRestTransform(inversMatrix);
//... }
And later in my update function
void update(float time) { // this code assumes that all targets have been updated with animations, positions, etc already
for (uint i = 0; i < bones.count(); ++i) m_bones[i].setTransform(m_bones[i].restTransform() * m_bones[i].target()- >worldTransform()); // matrix multiply the 4x4 matrises
// and then use the matrices calculated here with the weights etc stored in the envelopes. }
I wonder if anyone on this list has done anything similar to this and got it working, any help would be very appreciated.
Daniel
--- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|