[SlimDX] Animation

Started by
1 comment, last by skowronkow 15 years, 4 months ago
Hi! I get back to my work on Animation in SlimDX and ofcourse i have problem with it. I created CustomFrame, CustomMeshContainer and CustomAllocateHierarchy and then i loaded "tiny.x".

root = Frame.LoadHierarchyFromX(Device, "tiny.x", MeshFlags.Managed, new CustomAllocateHierarchy("tiny.x"), null, out ac);
It works fine. I can get BoundSphere etc. I can render my loaded object too

protected void RenderFrame(Frame frame, Matrix parentTransformationMatrix)
        {
            // First, render all sibling frames at this level passing the parent's
            // aggregated transformation matrix.
            if (frame.Sibling != null)
            {
                this.RenderFrame(frame.Sibling, parentTransformationMatrix);
            }


            Matrix tm = frame.TransformationMatrix * ((CustomFrame)frame).CustomTransform * parentTransformationMatrix;

            // Go on and render the children of this frame, passing the transformation
            // we just aggregated.
            if (frame.FirstChild != null)
            {
                this.RenderFrame(frame.FirstChild, tm);
            }


            // TODO: Adjust for the possibility of a mesh container hierarchy.

            // Perform the actual rendering for this frame.
            if (frame.MeshContainer != null)
            {
                
                world = tm;

                ExtendedMaterial[] em = frame.MeshContainer.GetMaterials();
                Texture[] t = ((CustomMeshContainer)(frame.MeshContainer)).Textures;
                for (int i = 0; i < em.Length; i++)
                {
                    this.Device.Material = em.MaterialD3D;
                    if (t != null)
                    {
                        this.Device.SetTexture(0, t);
                    }

                    frame.MeshContainer.Mesh.Mesh.DrawSubset(i);
                }
                
            }
        }
.. end it works fine too, i have little boy on screen;) but... I cant get to work my animation. I invoked ac.AdvanceTime(timeElapsed, null) (where ac is aniamation controller) before i render the object but i animation doesn't work. I get static mesh only. What i missed? Sorry for my English Thank's!
Advertisement
After you advance the time on the animation controller, you need to update all of your bone matrices again. Do you do that?

Also, quite coincidentally, I just finished a SkinnedMesh sample and added it to the repository. If you get an SVN client and check out the latest version of the code, you can look at that to see what you're doing wrong.
Mike Popoloski | Journal | SlimDX
Thx Mike:)

This topic is closed to new replies.

Advertisement