/// <summary> /// nastaveni kosti animace /// </summary> /// <param name="mesh">frame s animaci</param> private void SetupBoneMatrices(anim.AnimationMeshContainer mesh) { // Is there skin information? If so, setup the matrices if (mesh.SkinInformation != null) { int numberBones = mesh.SkinInformation.NumberBones; anim.AnimationFrame[] frameMatrices = new anim.AnimationFrame[numberBones]; for (int i = 0; i < numberBones; i++) { anim.AnimationFrame frame = Frame.Find(rootFrame.FrameHierarchy, mesh.SkinInformation.GetBoneName(i)) as anim.AnimationFrame; if (frame == null) { throw new InvalidOperationException("Could not find valid bone."); } frameMatrices[i] = frame; } mesh.SetFrames(frameMatrices); } }
/*private MeshContainer getAnimationMesh(AnimationRootFrame rootFrame,List<MeshContainer> meshes) * { * * Frame rf = rootFrame.FrameHierarchy; * while (rf.MeshContainer == null) * { * if(rf.FrameFirstChild == null) * { * rf =rf.FrameSibling; * } * else{ * rf = rf.FrameFirstChild; * } * } * return (rf.MeshContainer); * }*/ /// <summary> /// Nastaveni kosti animace /// </summary> /// <param name="frame">RootFrame animace</param> private void SetupBoneMatrices(anim.AnimationFrame frame) { if (frame == null) { return; } // First do the mesh container this frame contains (if it does) if (frame.MeshContainer != null) { SetupBoneMatrices(frame.MeshContainer as anim.AnimationMeshContainer); } // Next do any siblings this frame may contain if (frame.FrameSibling != null) { SetupBoneMatrices(frame.FrameSibling as anim.AnimationFrame); } // Finally do the children of this frame if (frame.FrameFirstChild != null) { SetupBoneMatrices(frame.FrameFirstChild as anim.AnimationFrame); } }