コード例 #1
0
        public override void RenderModel(Camera camera, MeshRenderMode mode = MeshRenderMode.Solid)
        {
            RenderHelper.ModelShader.Use();
            RenderHelper.ModelShader.UseTexture.Set(mode != MeshRenderMode.Wireframe && Surface.SurfaceID > 0);

            RenderHelper.RenderWithStencil(IsSelected,
                                           () =>
            {
                RenderPartialMesh(mode, this, SurfaceModel.Material);
            },
                                           () =>
            {
                DrawWireframeModel(RenderHelper.SelectionOutlineColor, 4f);
            }
                                           );

            if (IsSelected && !BoundingBox.IsEmpty)
            {
                var selectionBox = BoundingBox;
                selectionBox.Size += new Vector3(0.1f);
                RenderHelper.DrawBoundingBox(Transform,
                                             selectionBox,
                                             new Vector4(0f, 1f, 1f, 1f), 1.5f);
            }

            if (Surface.SurfaceID > 0)
            {
                RenderHelper.ModelShader.Use();
                RenderHelper.ModelShader.UseTexture.Set(false);
            }
        }
コード例 #2
0
        public void Render(Camera camera, MeshRenderMode renderMode)
        {
            var visibleMeshes = MeshModels.Where(x => x.Visible)
                                .OrderByDescending(x => x.IsSelected).ToList();

            if (!visibleMeshes.Any())
            {
                return;
            }

            RenderHelper.ModelShader.Use();
            RenderHelper.ModelShader.UseTexture.Set(renderMode != MeshRenderMode.Wireframe && Surface.SurfaceID > 0);

            bool useOutlineStencil = visibleMeshes.Any(x => x.IsSelected);

            if (useOutlineStencil)
            {
                RenderHelper.EnableStencilTest();
            }

            foreach (var model in visibleMeshes)
            {
                if (model.IsSelected && !useOutlineStencil)
                {
                }

                RenderHelper.RenderWithStencil(model.IsSelected,
                                               () =>
                {
                    RenderPartialMesh(renderMode, model, Material);
                },
                                               () =>
                {
                    DrawWireframeModel(model, RenderHelper.SelectionOutlineColor, 4f);
                }
                                               );

                if (useOutlineStencil)
                {
                    RenderHelper.ClearStencil();
                }
            }

            if (useOutlineStencil)
            {
                RenderHelper.DisableStencilTest();
            }

            //Draw selected models bounding boxes
            foreach (var model in visibleMeshes)
            {
                if (model.IsSelected)
                {
                    var selectionBox = model.BoundingBox;
                    selectionBox.Size += new Vector3(0.1f);
                    RenderHelper.DrawBoundingBox(model.Transform, selectionBox,
                                                 new Vector4(0f, 1f, 1f, 1f), 1.5f);
                }
            }
        }
コード例 #3
0
        public override void RenderModel(Camera camera, MeshRenderMode mode = MeshRenderMode.Solid)
        {
            var modelColor    = new Vector4(1f, 0.6f, 0.1f, 0.5f);
            var wireColor     = IsSelected ? RenderHelper.SelectionOutlineColor : RenderHelper.WireframeColor;
            var wireThickness = IsSelected ? 4f : 2f;

            GL.Disable(EnableCap.CullFace);
            GL.Disable(EnableCap.DepthTest);
            ModelManager.SphereModel.DrawOutlined(SphereTransform * Transform, modelColor, wireColor, wireThickness);
            ModelManager.ConeModel.DrawOutlined(ConeTransform * Transform, modelColor, wireColor, wireThickness);
            ModelManager.CircleModel.DrawColored(ContourTransform * Transform, wireColor);
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);

            if (!BoneBounding.IsEmpty && IsSelected)
            {
                RenderHelper.DrawBoundingBox(Transform, BoneBounding,
                                             new Vector4(0f, 1f, 1f, 1f), IsSelected ? 1.5f : 1f);
            }
        }
コード例 #4
0
ファイル: CollisionModel.cs プロジェクト: JOJOyh/ldd-modder
        private void DrawBoxCollision()
        {
            var wireColor = IsSelected ? RenderHelper.WireframeColorAlt : RenderHelper.WireframeColor;

            RenderHelper.RenderWithStencil(IsSelected,
                                           () =>
            {
                RenderHelper.BeginDrawModel(ModelManager.CubeModel, ScaleTransform * Transform, RenderHelper.CollisionMaterial);
                RenderHelper.ModelShader.IsSelected.Set(IsSelected);

                ModelManager.CubeModel.DrawElements();

                RenderHelper.EndDrawModel(ModelManager.CubeModel);

                RenderHelper.DrawBoundingBox(Transform, BoundingBox, wireColor, 1.5f);
            },
                                           () =>
            {
                RenderHelper.DrawBoundingBox(Transform, BoundingBox, RenderHelper.SelectionOutlineColor, 4f);
            });
        }