Esempio n. 1
0
        public void SetCustomCameraView_Additive(NewBlendableTransform view, float fovMult, float weight)
        {
            NewBlendableTransform viewMod = NewBlendableTransform.Lerp(NewBlendableTransform.Identity, view, weight);

            CUSTOM_VIEW_MULTIPLY = new CustomCameraView()
            {
                Location        = CUSTOM_VIEW_MULTIPLY.Location * ((view.GetMatrixScale() * view.GetMatrix()).ToXna()),
                VerticalFovMult = CUSTOM_VIEW_MULTIPLY.VerticalFovMult * (MathHelper.Lerp(1, fovMult, weight)),
            };
        }
        public override NewBlendableTransform GetBlendableTransformOnCurrentFrame(int hkxBoneIndex)
        {
            var track = HkxBoneIndexToTransformTrackMap[hkxBoneIndex];

            if (track == -1)
            {
                var skeleTransform = Skeleton.OriginalHavokSkeleton.Transforms[hkxBoneIndex];

                NewBlendableTransform defaultBoneTransformation = new NewBlendableTransform();

                defaultBoneTransformation.Scale.X = skeleTransform.Scale.Vector.X;
                defaultBoneTransformation.Scale.Y = skeleTransform.Scale.Vector.Y;
                defaultBoneTransformation.Scale.Z = skeleTransform.Scale.Vector.Z;

                defaultBoneTransformation.Rotation = new Quaternion(
                    skeleTransform.Rotation.Vector.X,
                    skeleTransform.Rotation.Vector.Y,
                    skeleTransform.Rotation.Vector.Z,
                    skeleTransform.Rotation.Vector.W);

                defaultBoneTransformation.Translation.X = skeleTransform.Position.Vector.X;
                defaultBoneTransformation.Translation.Y = skeleTransform.Position.Vector.Y;
                defaultBoneTransformation.Translation.Z = skeleTransform.Position.Vector.Z;

                return(defaultBoneTransformation);
            }

            float frame = (CurrentFrame % FrameCount) % NumFramesPerBlock;

            if (frame >= FrameCount - 1)
            {
                NewBlendableTransform currentFrame = GetTransformOnSpecificBlockAndFrame(track,
                                                                                         block: CurrentBlock, frame: (float)Math.Floor(frame));
                NewBlendableTransform nextFrame = GetTransformOnSpecificBlockAndFrame(track, block: 0, frame: 0);
                currentFrame = NewBlendableTransform.Lerp(frame % 1, currentFrame, nextFrame);
                return(currentFrame);
            }
            // Regular frame
            else
            {
                NewBlendableTransform currentFrame = GetTransformOnSpecificBlockAndFrame(track,
                                                                                         block: CurrentBlock, frame);
                return(currentFrame);
            }
        }
Esempio n. 3
0
        public static void UpdateRemoTime(float time)
        {
            // JUST FOR MATH TESTING
            //BakeSibcam();

            float frame      = time / (1f / 30f);
            int   frameFloor = Math.Min(Math.Max((int)Math.Floor(frame), 0), CurrentCutCameraMotion.Length - 1);
            int   frameCeil  = Math.Min(Math.Max((int)Math.Ceiling(frame), 0), CurrentCutCameraMotion.Length - 1);
            float frameMod   = frame % 1;

            if (CurrentCutCameraMotion == null || CurrentCutFoV == null)
            {
                return;
            }

            var a    = CurrentCutCameraMotion[frameFloor];
            var fovA = CurrentCutFoV[frameFloor];

            if (frameCeil < CurrentCutSibcam.CameraAnimation.Count)
            {
                var b = CurrentCutCameraMotion[frameCeil];
                a = NewBlendableTransform.Lerp(a, b, frameMod);

                var fovB = CurrentCutFoV[frameCeil];
                fovA = MathHelper.Lerp(fovA, fovB, frameMod);
            }

            if (EnableRemoCameraInViewport)
            {
                GFX.World.SetCustomCameraView_Override(a, fovA);
            }
            else
            {
                GFX.World.ClearCustomCameraView_Override();
            }



            RemoEventSim.Update(ViewportInteractor.Graph, time);
        }
Esempio n. 4
0
        private static void BakeSibcam()
        {
            int hkxFrameCount = (int)CurrentCutSibcam.NumFrames;

            CurrentCutCameraMotion = new NewBlendableTransform[hkxFrameCount];
            CurrentCutFoV          = new float[hkxFrameCount];

            int lastKeyIndex        = -1;
            var lastKeyValue_Motion = NewBlendableTransform.Identity;

            for (int frame = 0; frame < CurrentCutSibcam.CameraAnimation.Count; frame++)
            //foreach (var keyPos in CurrentCutSibcam.CameraAnimation)
            {
                var keyPos = CurrentCutSibcam.CameraAnimation[frame];
                //int frame = (int)keyPos.Index;

                var currentKeyValue_Motion = SibcamAnimFrameToTransform(keyPos);

                if (frame >= 0 && frame < CurrentCutCameraMotion.Length)
                {
                    CurrentCutCameraMotion[frame] = currentKeyValue_Motion;
                }

                // Fill in from the last keyframe to this one
                for (int f = Math.Max(lastKeyIndex + 1, 0); f <= Math.Min(frame - 1, CurrentCutCameraMotion.Length - 1); f++)
                {
                    float lerpS     = 1f * (f - lastKeyIndex) / (frame - lastKeyIndex);
                    var   blendFrom = lastKeyValue_Motion;
                    var   blendTo   = currentKeyValue_Motion;

                    var blended = NewBlendableTransform.Lerp(blendFrom, blendTo, lerpS);

                    CurrentCutCameraMotion[f] = blended;
                }
                lastKeyIndex        = frame;
                lastKeyValue_Motion = currentKeyValue_Motion;
            }
            // Fill in from last key to end of animation.
            for (int f = Math.Max(lastKeyIndex + 1, 0); f <= CurrentCutCameraMotion.Length - 1; f++)
            {
                CurrentCutCameraMotion[f] = lastKeyValue_Motion;
            }



            lastKeyIndex = -1;
            float lastKeyValue_Fov = CurrentCutSibcam.InitialFoV;

            foreach (var keyPos in CurrentCutSibcam.FoVDataList)
            {
                int frame = (int)keyPos.FrameIdx;

                float currentKeyValue_Fov = keyPos.FoV;

                if (frame >= 0 && frame < CurrentCutFoV.Length)
                {
                    CurrentCutFoV[frame] = currentKeyValue_Fov;
                }

                // Fill in from the last keyframe to this one
                for (int f = Math.Max(lastKeyIndex + 1, 0); f <= Math.Min(frame - 1, CurrentCutFoV.Length - 1); f++)
                {
                    float lerpS     = 1f * (f - lastKeyIndex) / (frame - lastKeyIndex);
                    var   blendFrom = lastKeyValue_Fov;
                    var   blendTo   = currentKeyValue_Fov;

                    var blended = MathHelper.Lerp(blendFrom, blendTo, lerpS);

                    CurrentCutFoV[f] = blended;
                }
                lastKeyIndex     = frame;
                lastKeyValue_Fov = currentKeyValue_Fov;
            }
            // Fill in from last key to end of animation.
            for (int f = Math.Max(lastKeyIndex + 1, 0); f <= CurrentCutFoV.Length - 1; f++)
            {
                CurrentCutFoV[f] = lastKeyValue_Fov;
            }
        }