Has anyone ever done ragdolls with a soft skinning shader?

Started by
1 comment, last by Momoko_Fan 15 years, 3 months ago
Has anyone ever done ragdolls with a soft skinning shader? I'm desperate, I'll take any information I can get, please help me! Anyone who has done this in any form please post source, I don't care what language you wrote the code in, I'll figure it out and I don't care what Physics API or Graphics API you used. I've been having a problem getting my ragdolls to work with my soft skinning shader, I've been working on it for 2 weeks with little to no success and it seems so simple yet I can't figure it out! I basically need to convert the world matrices that I get from the physics engine in to local matrices that would effect the vertices in the correct way. I've not just been working on this part time I've been working on it for 10 hours a day, every day and some times longer without a break! There is only so much I can take, help me please!!!
Remember Codeka is my alternate account, just remember that!
Advertisement
int bone_parents[NUM_BONES] = {-1, 0, 0, 1 ..... };Matrix world_tms[NUM_BONES] = { /* from physics */ };Matrix local_tms[NUM_BONES] = {};for(int i=0;i<NUM_BONES;++i){  if(bone_parents==-1)  {    local_tms = world_tms;  }  else  {    Matrix parent_inverse = world_tms[ bone_parents ];    parent_inverse.Invert();    local_tms = world_tms * parent_inverse;  }}
/**     * Updates the world transforms for this bone.     */    void updateWorldVectors(){        if (parent != null){            // worldRot = localRot * parentWorldRot            worldRot = parent.worldRot.mult(localRot);                        // worldPos = parentWorldPos + (parentWorldRot * localPos)            worldPos = parent.worldRot.mult(localPos);            worldPos.addLocal(parent.worldPos);        }else{            worldRot.set(localRot);            worldPos.set(localPos);        }    }


This computes the worldBindInverse transforms
/**     * Saves the current bone state as it's binding pose, including it's children.     */    void setBindingPose(){        initialPos.set(localPos);        initialRot.set(localRot);                // Save inverse derived position/scale/orientation, used for calculate offset transform later        worldBindInversePos.set(worldPos);        worldBindInversePos.negateLocal();                worldBindInverseRot.set(worldRot);        worldBindInverseRot.inverseLocal();                for (Bone b : children)            b.setBindingPose();    }


And this computes the matrix you should multiply your verticies by in the shader.
/**     * Stores the skinning transform in the specified Matrix4f.     * The skinning transform applies the animation of the bone to a vertex.     * @param m     */    void getOffsetTransform(Matrix4f m){        Quaternion rotate = worldRot.mult(worldBindInverseRot);        Vector3f translate = worldPos.add(rotate.mult(worldBindInversePos));                m.loadIdentity();        m.setTranslation(translate);        m.setRotationQuaternion(rotate);    }

(Full source: http://code.google.com/p/radakan/source/browse/trunk/ogreloader/src/com/radakan/jme/mxml/anim/Bone.java)

This topic is closed to new replies.

Advertisement