Exemple #1
0
        public NewHavokAnimation(NewAnimSkeleton skeleton, HKX.HKADefaultAnimatedReferenceFrame refFrame, HKX.HKAAnimationBinding binding)
        {
            Skeleton = skeleton;
            if (refFrame != null)
            {
                RootMotionFrames = new Vector4[refFrame.ReferenceFrameSamples.Size];
                for (int i = 0; i < refFrame.ReferenceFrameSamples.Size; i++)
                {
                    RootMotionFrames[i] = new Vector4(
                        refFrame.ReferenceFrameSamples[i].Vector.X,
                        refFrame.ReferenceFrameSamples[i].Vector.Y,
                        refFrame.ReferenceFrameSamples[i].Vector.Z,
                        refFrame.ReferenceFrameSamples[i].Vector.W);
                }
            }

            lock (_lock_boneMatrixStuff)
            {
                blendableTransforms = new List <NewBlendableTransform>();
                for (int i = 0; i < skeleton.HkxSkeleton.Count; i++)
                {
                    blendableTransforms.Add(NewBlendableTransform.Identity);
                }
            }

            BlendHint = binding.BlendHint;
        }
Exemple #2
0
 public void Dispose()
 {
     DbgPrimDrawer?.Dispose();
     ChrAsm?.Dispose();
     Skeleton      = null;
     AnimContainer = null;
     MainMesh?.Dispose();
     // Do not need to dispose DummyPolyMan because it goes
     // stores its primitives in the model's DbgPrimDrawer
 }
Exemple #3
0
        protected NewHavokAnimation(HavokAnimationData data, NewAnimSkeleton skeleton, NewAnimationContainer container)
        {
            this.data = data;

            ParentContainer = container;
            Skeleton        = skeleton;

            lock (_lock_boneMatrixStuff)
            {
                blendableTransforms = new NewBlendableTransform[skeleton.HkxSkeleton.Count];
            }

            RotMatrixAtStartOfAnim = ParentContainer.MODEL.CurrentRootMotionRotation;
        }
        protected NewHavokAnimation(HavokAnimationData data, NewAnimSkeleton skeleton, NewAnimationContainer container)
        {
            this.data = data;

            ParentContainer = container;
            Skeleton        = skeleton;

            lock (_lock_boneMatrixStuff)
            {
                blendableTransforms = new List <NewBlendableTransform>();
                for (int i = 0; i < skeleton.HkxSkeleton.Count; i++)
                {
                    blendableTransforms.Add(NewBlendableTransform.Identity);
                }
            }

            RotMatrixAtStartOfAnim = ParentContainer.MODEL.CurrentRootMotionRotation;
        }
Exemple #5
0
 public void InitSkeleton(NewAnimSkeleton skeleton)
 {
     Skeleton       = skeleton;
     boneIndexRemap = new Dictionary <string, int>();
     for (int i = 0; i < skeleton.FlverSkeleton.Count; i++)
     {
         if (skeleton.FlverSkeleton[i].Name == "R_Weapon")
         {
             RightWeaponBoneIndex = i;
         }
         else if (skeleton.FlverSkeleton[i].Name == "L_Weapon")
         {
             LeftWeaponBoneIndex = i;
         }
         if (!boneIndexRemap.ContainsKey(skeleton.FlverSkeleton[i].Name))
         {
             boneIndexRemap.Add(skeleton.FlverSkeleton[i].Name, i);
         }
     }
 }
Exemple #6
0
        private void LoadFLVER2(FLVER2 flver, bool useSecondUV, int baseDmyPolyID = 0, bool ignoreStaticTransforms = false)
        {
            Type = ModelType.ModelTypeFlver;

            Skeleton = new NewAnimSkeleton(this, flver.Bones);

            MainMesh = new NewMesh(flver, useSecondUV, null, ignoreStaticTransforms);

            Bounds = MainMesh.Bounds;

            DummyPolyMan.AddAllDummiesFromFlver(flver);

            //DEBUG//
            //Console.WriteLine($"{flver.Meshes[0].DefaultBoneIndex}");
            //Console.WriteLine();
            //Console.WriteLine();
            //foreach (var mat in flver.Materials)
            //{
            //    Console.WriteLine($"{mat.Name}: {mat.MTD}");
            //}
            /////////
        }
        public NewHavokAnimation_SplineCompressed(NewAnimSkeleton skeleton, HKX.HKADefaultAnimatedReferenceFrame refFrame, HKX.HKAAnimationBinding binding, HKX.HKASplineCompressedAnimation anim)
            : base(skeleton, refFrame, binding)
        {
            Duration   = anim.Duration;// Math.Max(anim.Duration, anim.FrameDuration * anim.FrameCount);
            FrameCount = anim.FrameCount;

            FrameDuration = anim.FrameDuration;

            BlockCount        = anim.BlockCount;
            NumFramesPerBlock = anim.FramesPerBlock - 1;

            HkxBoneIndexToTransformTrackMap = new int[skeleton.HkxSkeleton.Count];
            TransformTrackIndexToHkxBoneMap = new int[binding.TransformTrackToBoneIndices.Size];

            for (int i = 0; i < binding.TransformTrackToBoneIndices.Size; i++)
            {
                TransformTrackIndexToHkxBoneMap[i] = -1;
            }

            for (int i = 0; i < skeleton.HkxSkeleton.Count; i++)
            {
                HkxBoneIndexToTransformTrackMap[i] = -1;
            }

            for (int i = 0; i < binding.TransformTrackToBoneIndices.Size; i++)
            {
                short boneIndex = binding.TransformTrackToBoneIndices[i].data;
                if (boneIndex >= 0)
                {
                    HkxBoneIndexToTransformTrackMap[boneIndex] = i;
                }
                TransformTrackIndexToHkxBoneMap[i] = boneIndex;
            }

            Tracks = Havok.SplineCompressedAnimation.ReadSplineCompressedAnimByteBlock(
                isBigEndian: false, anim.GetData(), anim.TransformTrackCount, anim.BlockCount);
        }
Exemple #8
0
            public DummyPolyInfo(FLVER.Dummy dmy, NewAnimSkeleton skeleton)
            {
                dummy           = dmy;
                ReferenceID     = dmy.ReferenceID;
                ReferenceMatrix = Matrix.CreateWorld(
                    Vector3.Zero,
                    Vector3.Normalize(new Vector3(dmy.Forward.X, dmy.Forward.Y, dmy.Forward.Z)),
                    dmy.UseUpwardVector ? Vector3.Normalize(new Vector3(dmy.Upward.X, dmy.Upward.Y, dmy.Upward.Z)) : Vector3.Up)
                                  * Matrix.CreateTranslation(new Vector3(dmy.Position.X, dmy.Position.Y, dmy.Position.Z))
                                  * (dmy.ParentBoneIndex >= 0 ? skeleton.FlverSkeleton[dmy.ParentBoneIndex].ReferenceMatrix : Matrix.Identity);
                AttachMatrix = Matrix.Identity;

                ArrowPrimitive = new DbgPrimWireArrow("DummyPoly Spawns", Transform.Default, Color.White)
                {
                    //Wireframe = true,
                    //BackfaceCulling = true,
                    //DisableLighting = true,
                    Category      = DbgPrimCategory.DummyPolySpawnArrow,
                    OverrideColor = Color.Cyan,
                };

                SpawnPrinter.Font          = DBG.DEBUG_FONT_SMALL;
                SpawnPrinter.FullyOutlined = true;
            }
 public NewHavokAnimation_InterleavedUncompressed(string name, NewAnimSkeleton skeleton,
                                                  HKX.HKADefaultAnimatedReferenceFrame refFrame, HKX.HKAAnimationBinding binding, HKX.HKAInterleavedUncompressedAnimation anim, NewAnimationContainer container)
     : base(new HavokAnimationData_InterleavedUncompressed(name, skeleton.OriginalHavokSkeleton, refFrame, binding, anim), skeleton, container)
 {
 }