示例#1
0
        protected override Entity Create()
        {
            var root = base.Create();

            pointMesh = new LightPointMesh(GraphicsDevice);
            pointMesh.Build();

            pointMaterial = GizmoEmissiveColorMaterial.Create(GraphicsDevice, (Color) new Color4(GetLightColor(GraphicsDevice), 1f));

            pointEntity = new Entity("Point Mesh of {0}".ToFormat(root.Id))
            {
                new ModelComponent
                {
                    Model = new Model
                    {
                        pointMaterial,
                        new Mesh {
                            Draw = pointMesh.MeshDraw
                        },
                    },
                    RenderGroup = RenderGroup,
                }
            };

            return(root);
        }
示例#2
0
        protected override Entity Create()
        {
            var root = base.Create();

            var renderingSettings = Game.PackageSettings?.GetConfiguration <RenderingSettings>();
            var aspect            = (renderingSettings == null) ? 1.7778f : (float)renderingSettings.DefaultBackBufferWidth / (float)renderingSettings.DefaultBackBufferHeight;

            cameraParameters = new CameraParameters(Component, aspect);

            frustumMesh = new CameraFrustumMesh(GraphicsDevice);
            frustumMesh.Build(GraphicsCommandList, cameraParameters);

            var frustumMaterial = GizmoEmissiveColorMaterial.Create(GraphicsDevice, new Color(0.75f, 0.75f, 1f, 1f));

            frustum = new Entity("Camera frustumMesh of {0}".ToFormat(root.Id))
            {
                new ModelComponent
                {
                    Model = new Model
                    {
                        frustumMaterial,
                        new Mesh {
                            Draw = frustumMesh.MeshDraw
                        },
                    },
                    RenderGroup = RenderGroup,
                }
            };

            return(root);
        }
示例#3
0
        protected override Entity Create()
        {
            debugRootEntity = new Entity($"Voxel volume of {Component.Entity.Name}");

            material = GizmoEmissiveColorMaterial.Create(GraphicsDevice, Color.CornflowerBlue);

            box = new BoxMesh(GraphicsDevice);
            box.Build();

            debugEntity = new Entity($"Voxel volume mesh of {Component.Entity.Name}")
            {
                new ModelComponent
                {
                    Model = new Model
                    {
                        material,
                        new Mesh {
                            Draw = box.MeshDraw
                        },
                    },
                    RenderGroup = RenderGroup,
                }
            };

            return(debugRootEntity);
        }
示例#4
0
        protected override Entity Create()
        {
            var root = base.Create();

            lightRay    = new Entity($"Light ray for light gizmo {root.Id}");
            rayMaterial = GizmoEmissiveColorMaterial.Create(GraphicsDevice, (Color) new Color4(GetLightColor(GraphicsDevice), 1f));

            // build the ray mesh
            var coneMesh = GeometricPrimitive.Cone.New(GraphicsDevice, ConeRadius, ConeHeight, GizmoTessellation).ToMeshDraw();
            var bodyMesh = GeometricPrimitive.Cylinder.New(GraphicsDevice, BodyLength, BodyRadius, GizmoTessellation).ToMeshDraw();

            var coneEntity = new Entity($"Light ray for light gizmo {root.Id}")
            {
                new ModelComponent {
                    Model = new Model {
                        rayMaterial, new Mesh {
                            Draw = coneMesh
                        }
                    }, RenderGroup = RenderGroup
                }
            };

            coneEntity.Transform.Rotation   = Quaternion.RotationX(-MathUtil.PiOverTwo);
            coneEntity.Transform.Position.Z = -BodyLength - ConeHeight * 0.5f;
            lightRay.AddChild(coneEntity);

            var bodyEntity = new Entity($"Light ray body for light gizmo {root.Id}")
            {
                new ModelComponent {
                    Model = new Model {
                        rayMaterial, new Mesh {
                            Draw = bodyMesh
                        }
                    }, RenderGroup = RenderGroup
                }
            };

            bodyEntity.Transform.Position.Z = -BodyLength / 2;
            bodyEntity.Transform.Rotation   = Quaternion.RotationX(-MathUtil.PiOverTwo);
            lightRay.AddChild(bodyEntity);

            return(root);
        }
示例#5
0
        private static Material GetMaterial(Graphics.GraphicsDevice device, Color color)
        {
            if (!MaterialCache.TryGetValue(device, out var cache))
            {
                cache = new Dictionary <Color, Material>();
                MaterialCache.Add(device, cache);
            }

            if (!cache.TryGetValue(color, out var material))
            {
                if (color.A == byte.MaxValue)
                {
                    material = GizmoEmissiveColorMaterial.Create(device, color, intensity: 0.85f);
                }
                else
                {
                    material = GizmoEmissiveColorMaterial.Create(device, color, intensity: 0.5f);
                }

                cache.Add(color, material);
            }

            return(material);
        }
示例#6
0
 /// <summary>
 /// Creates an emissive color material.
 /// </summary>
 /// <param name="color">The color of the material</param>
 /// <returns>the material</returns>
 protected Material CreateEmissiveColorMaterial(Color color)
 {
     return(GizmoEmissiveColorMaterial.Create(GraphicsDevice, color, 0.75f));
 }