예제 #1
0
파일: DBG.cs 프로젝트: katalash/TAE-DX
 public static void AddPrimitive(IDbgPrim primitive)
 {
     lock (_lock_primitives)
     {
         Primitives.Add(primitive);
     }
 }
            public FlverBoneInfo(FLVER.Bone bone, List <FLVER.Bone> boneList)
            {
                Matrix GetBoneMatrix(SoulsFormats.FLVER.Bone b)
                {
                    SoulsFormats.FLVER.Bone parentBone = b;

                    var result = Matrix.Identity;

                    do
                    {
                        result *= Matrix.CreateScale(parentBone.Scale.X, parentBone.Scale.Y, parentBone.Scale.Z);
                        result *= Matrix.CreateRotationX(parentBone.Rotation.X);
                        result *= Matrix.CreateRotationZ(parentBone.Rotation.Z);
                        result *= Matrix.CreateRotationY(parentBone.Rotation.Y);
                        result *= Matrix.CreateTranslation(parentBone.Translation.X, parentBone.Translation.Y, parentBone.Translation.Z);

                        if (parentBone.ParentIndex >= 0)
                        {
                            parentBone = boneList[parentBone.ParentIndex];
                        }
                        else
                        {
                            parentBone = null;
                        }
                    }while (parentBone != null);

                    return(result);
                }

                ReferenceMatrix = GetBoneMatrix(bone);
                Name            = bone.Name;

                if (bone.Unk3C == 0)
                {
                    BonePrim = new DbgPrimWireBone(bone.Name, new Transform(ReferenceMatrix), DBG.COLOR_FLVER_BONE)
                    {
                        Category = DbgPrimCategory.FlverBone,
                    };

                    BoundingBoxPrim = new DbgPrimWireBox(Transform.Default,
                                                         new Vector3(bone.BoundingBoxMin.X, bone.BoundingBoxMin.Y, bone.BoundingBoxMin.Z),
                                                         new Vector3(bone.BoundingBoxMax.X, bone.BoundingBoxMax.Y, bone.BoundingBoxMax.Z),
                                                         DBG.COLOR_FLVER_BONE_BBOX)
                    {
                        Category = DbgPrimCategory.FlverBoneBoundingBox,
                    };
                }
            }
예제 #3
0
        private void UpdatePivotPrim()
        {
            if (pivotPrimVisRatio_Timer < 0)
            {
                PivotPrimVisRatio = 1;
            }
            else
            {
                PivotPrimVisRatio = 1 - MathHelper.Clamp(pivotPrimVisRatio_Timer / pivotPrimVisRatio_FadeOutDuration, 0, 1);
            }

            if (PivotPrim == null)
            {
                PivotPrim = new DbgPrimWireBox(Transform.Default, -Vector3.One, Vector3.One, Color.Transparent);
            }

            if (PivotPrim_DrawOver == null)
            {
                PivotPrim_DrawOver = new DbgPrimWireBox(Transform.Default, -Vector3.One, Vector3.One, Color.Transparent);
            }

            float pulseRatio = (float)Math.Sin(MathHelper.Pi * (pivotPrimDrawoverPulseTimer / pivotPrimDrawoverPulseTimerModulo));

            PivotPrim.Transform = PivotPrim_DrawOver.Transform = new Transform(Matrix.CreateScale(
                                                                                   pivotPrimVisRatio_MaxScale + (pivotPrimVisRatio_MaxScale * (1 + (pulseRatio * pulseRatio * 0.1f)))
                                                                                   * PivotPrimVisRatio * ProjectionVerticalFovRatio)
                                                                               // * Matrix.CreateFromQuaternion(CameraLookDirection)
                                                                               * Matrix.CreateRotationY(-RootMotionFollow_Rotation)
                                                                               * Matrix.CreateTranslation(CameraOrbitOrigin + Vector3.Transform(RootMotionFollow_Translation, Matrix_World)));

            PivotPrim.OverrideColor = Color.Lerp(
                new Color(Main.Colors.ColorHelperCameraPivot.R,
                          Main.Colors.ColorHelperCameraPivot.G,
                          Main.Colors.ColorHelperCameraPivot.B, (byte)0), Main.Colors.ColorHelperCameraPivot, PivotPrimVisRatio);



            PivotPrim_DrawOver.OverrideColor = Color.Lerp(
                new Color(Main.Colors.ColorHelperCameraPivot.R,
                          Main.Colors.ColorHelperCameraPivot.G,
                          Main.Colors.ColorHelperCameraPivot.B, (byte)0),
                new Color(Main.Colors.ColorHelperCameraPivot.R,
                          Main.Colors.ColorHelperCameraPivot.G,
                          Main.Colors.ColorHelperCameraPivot.B,
                          (byte)(255f * 0.25f)), PivotPrimVisRatio);
        }
예제 #4
0
            public DummyPolyInfo(FLVER.Dummy dmy, NewAnimSkeleton_FLVER 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,
                };
            }
예제 #5
0
            public DummyPolyInfo(FLVER.Dummy dmy, NewAnimSkeleton skeleton)
            {
                ReferenceID     = dmy.ReferenceID;
                FollowBoneIndex = dmy.AttachBoneIndex;
                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);
                CurrentMatrix = ReferenceMatrix;

                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;
            }
예제 #6
0
            public FlverBoneInfo(FLVER.Bone bone, List <FLVER.Bone> boneList)
            {
                ParentIndex = bone.ParentIndex;

                if (GlobalBonePrim == null)
                {
                    GlobalBonePrim = new DbgPrimWireBone("(BONE)", new Transform(Matrix.Identity), DBG.COLOR_FLVER_BONE)
                    {
                        Category = DbgPrimCategory.FlverBone,
                    };
                }

                Matrix GetBoneMatrix(SoulsFormats.FLVER.Bone b, bool saveParentBone)
                {
                    SoulsFormats.FLVER.Bone parentBone = b;

                    var result = Matrix.Identity;

                    bool isTopBone = true;

                    do
                    {
                        result *= Matrix.CreateScale(parentBone.Scale.X, parentBone.Scale.Y, parentBone.Scale.Z);
                        result *= Matrix.CreateRotationX(parentBone.Rotation.X);
                        result *= Matrix.CreateRotationZ(parentBone.Rotation.Z);
                        result *= Matrix.CreateRotationY(parentBone.Rotation.Y);
                        result *= Matrix.CreateTranslation(parentBone.Translation.X, parentBone.Translation.Y, parentBone.Translation.Z);

                        if (parentBone.ParentIndex >= 0)
                        {
                            parentBone = boneList[parentBone.ParentIndex];
                        }
                        else
                        {
                            parentBone = null;
                        }

                        isTopBone = false;

                        if (saveParentBone && isTopBone)
                        {
                            ParentReferenceMatrix = GetBoneMatrix(parentBone, saveParentBone: false);
                        }
                    }while (parentBone != null);

                    return(result);
                }

                ReferenceMatrix = GetBoneMatrix(bone, saveParentBone: true);
                Name            = bone.Name;

                //SpawnPrinter.AppendLine(Name, DBG.COLOR_FLVER_BONE);

                if (bone.Unk3C == 0)
                {
                    var nubBone = boneList.Where(bn => bn.Name == bone.Name + "Nub").FirstOrDefault();

                    if (nubBone != null)
                    {
                        var nubMat = Matrix.Identity;
                        nubMat *= Matrix.CreateScale(nubBone.Scale.X, nubBone.Scale.Y, nubBone.Scale.Z);
                        nubMat *= Matrix.CreateRotationX(nubBone.Rotation.X);
                        nubMat *= Matrix.CreateRotationZ(nubBone.Rotation.Z);
                        nubMat *= Matrix.CreateRotationY(nubBone.Rotation.Y);
                        nubMat *= Matrix.CreateTranslation(nubBone.Translation.X, nubBone.Translation.Y, nubBone.Translation.Z);

                        NubReferenceMatrix = nubMat;
                    }
                }

                IsNub = bone.Unk3C != 0;

                BoundingBoxPrim = new DbgPrimWireBox(Transform.Default,
                                                     new Vector3(bone.BoundingBoxMin.X, bone.BoundingBoxMin.Y, bone.BoundingBoxMin.Z),
                                                     new Vector3(bone.BoundingBoxMax.X, bone.BoundingBoxMax.Y, bone.BoundingBoxMax.Z),
                                                     DBG.COLOR_FLVER_BONE_BBOX)
                {
                    Category = DbgPrimCategory.FlverBoneBoundingBox,
                };
            }
예제 #7
0
        public void Draw(IDbgPrim parentPrim, Matrix world)
        {
            PreDraw();

            // Always draw unparented children :fatcat:
            foreach (var c in UnparentedChildren)
            {
                c.Draw(this, world);
            }

            if (!EnableDraw)
            {
                return;
            }

            if (!DBG.CategoryEnableDraw[Category])
            {
                return;
            }

            if (Shader == GFX.DbgPrimSolidShader || Shader == GFX.DbgPrimWireShader)
            {
                if (OverrideColor.HasValue)
                {
                    var overrideColor = new Vector3(OverrideColor.Value.R / 255f, OverrideColor.Value.G / 255f, OverrideColor.Value.B / 255f);
                    if (Shader is DbgPrimSolidShader solid)
                    {
                        solid.VertexColorEnabled = false;
                        solid.DiffuseColor       = overrideColor;
                    }
                    else if (Shader is DbgPrimWireShader wire)
                    {
                        wire.VertexColorEnabled = false;
                        wire.DiffuseColor       = overrideColor * 5;
                    }
                }
                else
                {
                    if (Shader is DbgPrimSolidShader solid)
                    {
                        solid.VertexColorEnabled = true;
                        solid.DiffuseColor       = Vector3.One * 2;
                    }
                    else if (Shader is DbgPrimWireShader wire)
                    {
                        wire.VertexColorEnabled = true;
                        wire.DiffuseColor       = Vector3.One * 2;
                    }
                }
            }


            var techniques = ShaderTechniquesSelection;

            var effect = Shader.Effect;

            if (techniques != null)
            {
                foreach (var techniqueName in techniques)
                {
                    effect.CurrentTechnique = effect.Techniques[techniqueName];
                    foreach (var pass in effect.CurrentTechnique.Passes)
                    {
                        if (Shader == GFX.DbgPrimSolidShader || Shader == GFX.DbgPrimWireShader)
                        {
                            GFX.World.ApplyViewToShader(Shader, Transform.WorldMatrix * world);
                        }
                        pass.Apply();
                        DrawPrimitive();
                    }
                }
            }
            else
            {
                foreach (var pass in effect.CurrentTechnique.Passes)
                {
                    if (Shader == GFX.DbgPrimSolidShader || Shader == GFX.DbgPrimWireShader)
                    {
                        GFX.World.ApplyViewToShader(Shader, Transform.WorldMatrix * world);
                    }
                    pass.Apply();
                    DrawPrimitive();
                }
            }

            if (Shader == GFX.DbgPrimSolidShader || Shader == GFX.DbgPrimWireShader)
            {
                if (Shader is DbgPrimSolidShader solid)
                {
                    solid.VertexColorEnabled = true;
                    solid.DiffuseColor       = Vector3.One * 2;
                }
                else if (Shader is DbgPrimWireShader wire)
                {
                    wire.VertexColorEnabled = true;
                    wire.DiffuseColor       = Vector3.One * 2;
                }
            }

            foreach (var c in Children)
            {
                c.Draw(this, Transform.WorldMatrix * world);
            }
        }
예제 #8
0
 public static void AddPrimitive(IDbgPrim primitive)
 {
     Primitives.Add(primitive);
 }
예제 #9
0
        public void Draw(IDbgPrim parentPrim, Matrix world)
        {
            PreDraw();

            // Always draw unparented children :fatcat:
            foreach (var c in UnparentedChildren)
            {
                c.Draw(this, world);
            }

            if (!EnableDraw)
            {
                return;
            }

            if (Category != DbgPrimCategory.AlwaysDraw && !DBG.GetCategoryEnableDraw(Category))
            {
                return;
            }

            if (Shader == GFX.DbgPrimSolidShader || Shader == GFX.DbgPrimWireShader)
            {
                if (OverrideColor.HasValue)
                {
                    var overrideColor = new Vector3(OverrideColor.Value.R / 255f, OverrideColor.Value.G / 255f, OverrideColor.Value.B / 255f);
                    if (Shader is DbgPrimSolidShader solid)
                    {
                        solid.VertexColorEnabled = false;
                        solid.DiffuseColor       = overrideColor;
                        solid.Alpha = OverrideColor.Value.A / 255f;
                    }
                    else if (Shader is DbgPrimWireShader wire)
                    {
                        wire.VertexColorEnabled = false;
                        wire.DiffuseColor       = overrideColor;
                        wire.Alpha = OverrideColor.Value.A / 255f;
                    }
                }
                else
                {
                    if (Shader is DbgPrimSolidShader solid)
                    {
                        solid.VertexColorEnabled = true;
                        solid.DiffuseColor       = Vector3.One;
                        solid.Alpha = 1;
                    }
                    else if (Shader is DbgPrimWireShader wire)
                    {
                        wire.VertexColorEnabled = true;
                        wire.DiffuseColor       = Vector3.One;
                        wire.Alpha = 1;
                    }
                }
            }

            var effect = Shader.Effect;

            foreach (var pass in effect.CurrentTechnique.Passes)
            {
                if (Shader == GFX.DbgPrimSolidShader || Shader == GFX.DbgPrimWireShader)
                {
                    GFX.World.ApplyViewToShader(Shader, Transform.WorldMatrix * world);
                }
                pass.Apply();
                DrawPrimitive();
            }

            if (Shader == GFX.DbgPrimSolidShader || Shader == GFX.DbgPrimWireShader)
            {
                if (Shader is DbgPrimSolidShader solid)
                {
                    solid.VertexColorEnabled = true;
                    solid.DiffuseColor       = Vector3.One * 2;
                }
                else if (Shader is DbgPrimWireShader wire)
                {
                    wire.VertexColorEnabled = true;
                    wire.DiffuseColor       = Vector3.One * 2;
                }
            }

            foreach (var c in Children)
            {
                c.Draw(this, Transform.WorldMatrix * world);
            }
        }