Esempio n. 1
0
        public static void ClearSelection()
        {
            HitVertices        = null;
            HitIndices         = null;
            SphereTransforms   = null;
            CylinderTransforms = null;
            PhysicsVertices    = null;
            PhysicsIndices     = null;

            if (RenderLinks != null)
            {
                RenderLinks.Dispose();
                RenderLinks = null;
            }
        }
Esempio n. 2
0
        public static void BuildLinks(WorldObject wo)
        {
            if (RenderLinks != null)
            {
                RenderLinks.Dispose();
            }

            RenderLinks = null;

            var node = new LinkNode(wo);

            node.AddParentChains();
            node.AddChildTrees();

            if (node.Parent != null || node.Children != null)
            {
                RenderLinks = new RenderLinks(node);
            }
        }
Esempio n. 3
0
        public static void DrawHitPoly()
        {
            if (HitVertices == null)
            {
                return;
            }

            if (PickResult.PhysicsObj?.IsDestroyed ?? false)
            {
                ClearSelection();
                return;
            }

            var rs = new RasterizerState();

            rs.CullMode = Microsoft.Xna.Framework.Graphics.CullMode.None;
            rs.FillMode = FillMode.WireFrame;
            GraphicsDevice.RasterizerState = rs;

            if (SphereTransforms == null && CylinderTransforms == null && PhysicsVertices == null)
            {
                Effect.CurrentTechnique = Effect.Techniques["Picker"];

                foreach (var pass in Effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, HitVertices, 0, HitVertices.Length, HitIndices, 0, HitIndices.Length / 2);
                }
            }
            else
            {
                if (SphereTransforms != null)
                {
                    foreach (var sphereTransform in SphereTransforms)
                    {
                        SpherePrimitive.Draw(sphereTransform, Camera.ViewMatrix, Camera.ProjectionMatrix, Color.Orange);
                    }
                }

                if (CylinderTransforms != null)
                {
                    foreach (var cylinderTransform in CylinderTransforms)
                    {
                        CylinderPrimitive.Draw(cylinderTransform, Camera.ViewMatrix, Camera.ProjectionMatrix, Color.Orange);
                    }
                }

                if (PhysicsVertices != null)
                {
                    Effect.CurrentTechnique = Effect.Techniques["Picker"];

                    foreach (var pass in Effect.CurrentTechnique.Passes)
                    {
                        pass.Apply();
                        GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, PhysicsVertices, 0, PhysicsVertices.Length, PhysicsIndices, 0, PhysicsIndices.Length / 2);
                    }
                }
            }

            if (RenderLinks != null)
            {
                if (!RenderLinks.Head.WorldObject.PhysicsObj.IsDestroyed)
                {
                    RenderLinks.Draw();
                }
                else
                {
                    RenderLinks.Dispose();
                    RenderLinks = null;
                }
            }
        }