Advertisement Jump to content
Sign in to follow this  

[MDX] Skeletal animation - UpdateSkinnedMesh() explosion

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

Hi everyone. I've ran into a serious problem while trying to use skeletal animation. As soon as I move a bone and update the mesh, it either ends up filling my game with garbage polys in the best case, or dying with an access violation or an ExecutionEngine exception in the worst cases. It's always a surprise! I believe it may have something to do with the way I am handling the vertex buffers. I'd really appreciate any suggestions you might have on what the problem might be. Thanks!
class Harpoon 

public Harpoon() 
            //Retrieve the mesh container for the tube geometry 
            this.tubeMeshCont = this.tubeEntity.GetFrame("TubeShape").MeshContainer as PPMeshContainer; 
            this.skinInfo = this.tubeMeshCont.SkinInformation; 
            //Make a copy of the mesh for use in skin updating 
            this.meshUnalteredClone = this.tubeMeshCont.MeshData.Mesh.Clone(MeshFlags.Managed, this.tubeMeshCont.MeshData.Mesh.VertexFormat, Engine.currentDevice); 

public void Update(float elapsedTime) 
            Matrix[] offsetMatrices; 
            Vector3 force; 
            GraphicsStream sourceVertices; 
            GraphicsStream destinationVertices; 

            //Update tube end's velocity 
            force = this.GetSpringForce(this.velocity, this.currentTubeEndPos - this.startPoint); 
            this.velocity += force; 
            this.currentTubeEndPos += this.velocity * elapsedTime; 

            //Move the end bone of the tube to the location where the end of the tube should be now 
            this.skinInfo.SetBoneOffsetMatrix(endBone, Matrix.Translation(this.currentTubeEndPos)); 
            //Get current bone location matrices 
            offsetMatrices = this.tubeMeshCont.GetOffsetMatrices(); 

            //Get vertex locations from the copy of the original mesh 
            sourceVertices = this.meshUnalteredClone.LockVertexBuffer(LockFlags.ReadOnly); 

            //Get a ref to the renderable vertex buffer so we can write to it 
            destinationVertices = tubeMeshCont.MeshData.Mesh.LockVertexBuffer(0); 

            this.skinInfo.UpdateSkinnedMesh(offsetMatrices, null, sourceVertices, destinationVertices); 
            //Unlock the vertex buffers 



Share this post

Link to post
Share on other sites
Oh, do you remember what you did to fix the problem? I'm afraid posting all the code would be a bit silly, but if there's some routine in particular you'd like for me to post, I can do that. Thank you for the reply, by the way!


Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!