سؤال

Model doesn't display correctly in XNA, ignores some bone deformations Reply Quote Edit I am very new to 3D modelling, however I am required to do some for a project I have undertaken.

The basic principal is that I need a human model that can be deformed to the users measurements (measured using Kinect, but that is another story!). For example I want to stretch the stomach area for larger users etc.

Using 3Ds Max I have been able to rig a human model using a biped and then add some extra bones to change the stomach:

enter image description here

This all looks well and good, however when I load it into XNA, the stomach deformation has vanished-

enter image description here

I am somewhat at a loss as to why this has happened and any suggestions would be most welcome, or any links to tutorials on how this kind of thing should be done.

Furthermore, when I view the exported FBX in an FBX viewer plugin for QuickTime, the deformations show absolutely fine.

enter image description here

The code for displaying the model (its F# code, converted form a c# example, however I have tried it with the original c# code and get the same results) is:

override this.Draw(gameTime)=
            // Copy any parent transforms.
            let (transforms:Matrix array) = Array.zeroCreate model.Bones.Count
            model.CopyAbsoluteBoneTransformsTo(transforms);
            this.Game.GraphicsDevice.BlendState <- BlendState.Opaque
            this.Game.GraphicsDevice.DepthStencilState <- DepthStencilState.Default
            // Draw the model. A model can have multiple meshes, so loop.
            for mesh in model.Meshes do
                // This is where the mesh orientation is set, as well 
                // as our camera and projection.
                for e:Effect in mesh.Effects do
                    let effect = e :?> BasicEffect
                    effect.EnableDefaultLighting()
                    effect.World <- mesh.ParentBone.Transform *
                        Matrix.CreateRotationZ(modelRotation)
                        * Matrix.CreateTranslation(modelPosition)
                    effect.View <- Matrix.CreateLookAt(cameraPosition, 
                        focusPoint, Vector3.Up)
                    effect.Projection <- Matrix.CreatePerspectiveFieldOfView(
                        MathHelper.ToRadians(45.0f), aspectRatio, 
                        1.0f, 10000.0f)
                // Draw the mesh, using the effects set above.
                mesh.Draw();
            base.Draw(gameTime);

Wonder if anyone has any ideas as to what has gone wrong or any ideas of how to sort this.

Any suggestions would be much appreciated.

Thanks

هل كانت مفيدة؟

المحلول

If you added the extra bones to the stomach, then told max to morph some associated vertices in accordance with the new bones by some weighting factor, then you would need to modify Xna's default content processor to tell it how to build the model to take that into account. By default, it won't.

Look at the Skinned model sample on the app hub: http://create.msdn.com/en-US/education/catalog/sample/skinned_model

All the joints(elbows, knees, etc) morph a bit as the joints flex. Ultimately, you are wanting a single vertex to be influenced by more than one transform.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top