Exemplo n.º 1
0
        private void CreateContainer(Vector3 pos, Color color)
        {
            var g = Program.Inst.GraphicsDevice;

            var size      = 0.8f;
            var height    = 0.5f;
            var thickness = 0.1f;

            var box1Transform = Matrix.CreateScale(new Vector3(size, height, thickness))
                                * Matrix.CreateTranslation(pos + 0.5f * size * Vector3.Backward + 0.5f * height * Vector3.Up);
            var box1Mesh = MeshGen.Box().Transform(box1Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb   {
                Aabb = box1Mesh.Aabb()
            },
                                    new CMesh   {
                Mesh = box1Mesh.Gpu(g)
            }, new CShadow()));

            var box2Transform = Matrix.CreateScale(new Vector3(thickness, height, size))
                                * Matrix.CreateTranslation(pos + 0.5f * size * Vector3.Right + 0.5f * height * Vector3.Up);
            var box2Mesh = MeshGen.Box().Transform(box2Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb {
                Aabb = box2Mesh.Aabb()
            },
                                    new CMesh {
                Mesh = box2Mesh.Gpu(g)
            }, new CShadow()));

            var box3Transform = Matrix.CreateScale(new Vector3(size, height, thickness))
                                * Matrix.CreateTranslation(pos + 0.5f * size * Vector3.Forward + 0.5f * height * Vector3.Up);
            var box3Mesh = MeshGen.Box().Transform(box3Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb {
                Aabb = box3Mesh.Aabb()
            },
                                    new CMesh {
                Mesh = box3Mesh.Gpu(g)
            }, new CShadow()));

            var box4Transform = Matrix.CreateScale(new Vector3(thickness, height, size))
                                * Matrix.CreateTranslation(pos + 0.5f * size * Vector3.Left + 0.5f * height * Vector3.Up);
            var box4Mesh = MeshGen.Box().Transform(box4Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb {
                Aabb = box4Mesh.Aabb()
            },
                                    new CMesh {
                Mesh = box4Mesh.Gpu(g)
            }, new CShadow()));

            var box5Transform = Matrix.CreateScale(new Vector3(size, thickness, size))
                                * Matrix.CreateTranslation(pos + (-0.5f * thickness + 0.01f) * Vector3.Up);
            var box5Mesh = MeshGen.Box().Transform(box5Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb {
                Aabb = box5Mesh.Aabb()
            },
                                    new CMesh {
                Mesh = box5Mesh.Gpu(g)
            }, new CShadow()
            {
                Y = 0.005f
            }));
        }
Exemplo n.º 2
0
        private void InitScene(Vector3 containerPos)
        {
            var g = Program.Inst.GraphicsDevice;

            var roomSize = 7.0f;

            var floorColor     = new Color(0.1f, 0.2f, 0.9f);
            var floorTransform = Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f))
                                 * Matrix.CreateScale(roomSize * Vector3.One);
            var floorMesh = MeshGen.Quad().Transform(floorTransform).Color(floorColor);

            AddEntity(new EcsEntity(new CMesh {
                Mesh = floorMesh.Gpu(g)
            }));

            var roomColor     = new Color(1.0f, 1.0f, 1.0f);
            var roomTransform = Matrix.CreateScale(roomSize * Vector3.One);
            var roomMesh      = MeshGen.Box().FlipTris().Transform(roomTransform).Color(roomColor);

            AddEntity(new EcsEntity(new CMesh {
                Mesh = roomMesh.Gpu(g)
            }));

            AddEntity(
                new EcsEntity(
                    new CMesh {
                Mesh = MeshGen.Quad(roomSize, 1.2f)
                       .Color(new Color(0.3f, 0.3f, 0.3f))
                       .Transform(
                    Matrix.CreateRotationY(MathHelper.ToRadians(90.0f))
                    * Matrix.CreateTranslation(new Vector3(-0.5f * roomSize + 0.01f, 1.8f, 0.0f)))
                       .Gpu(g)
            }
                    )
                );

            AddEntity(
                new EcsEntity(
                    new CMesh {
                Mesh = MeshGen.Quad(roomSize, 1.2f)
                       .Color(new Color(0.3f, 0.3f, 0.3f))
                       .Transform(
                    Matrix.CreateRotationY(MathHelper.ToRadians(-90.0f))
                    * Matrix.CreateTranslation(new Vector3(0.5f * roomSize - 0.01f, 1.8f, 0.0f)))
                       .Gpu(g)
            }
                    )
                );

            AddEntity(
                new EcsEntity(
                    new CMesh {
                Mesh = MeshGen.Quad(roomSize, 1.2f)
                       .Color(new Color(0.3f, 0.3f, 0.3f))
                       .Transform(Matrix.CreateTranslation(new Vector3(0.0f, 1.8f, -0.5f * roomSize + 0.01f)))
                       .Gpu(g)
            }
                    )
                );

            AddEntity(
                new EcsEntity(
                    new CMesh {
                Mesh = MeshGen.Quad(roomSize, 1.2f)
                       .Color(new Color(0.3f, 0.3f, 0.3f))
                       .Transform(Matrix.CreateTranslation(new Vector3(0.0f, 1.8f, 0.5f * roomSize - 0.01f)))
                       .Gpu(g)
            }
                    )
                );


            CreateContainer(new Vector3(-0.6f, 0.0f, 1.0f), new Color(0.2f, 0.6f, 1.0f));
            CreateContainer(new Vector3(0.6f, 0.0f, 1.0f), Color.OrangeRed);
            CreateConveyor();
        }
Exemplo n.º 3
0
        public void CreateConveyor()
        {
            var g = Program.Inst.GraphicsDevice;

            var width     = 0.6f;
            var length    = 6.0f;
            var height    = 0.1f;
            var thickness = 0.1f;
            var pos       = new Vector3(2.0f, 0.5f, -1.0f);
            var color     = new Color(0.02f, 0.02f, 0.02f);

            var box1Transform = Matrix.CreateScale(new Vector3(length, height, thickness))
                                * Matrix.CreateTranslation(pos + 0.5f * width * Vector3.Backward + 0.5f * height * Vector3.Up);
            var box1Mesh = MeshGen.Box().Transform(box1Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb   {
                Aabb = box1Mesh.Aabb()
            },
                                    new CMesh   {
                Mesh = box1Mesh.Gpu(g)
            }, new CShadow()));

            var box2Transform = Matrix.CreateScale(new Vector3(thickness, height, width))
                                * Matrix.CreateTranslation(pos + 0.5f * length * Vector3.Right + 0.5f * height * Vector3.Up);
            var box2Mesh = MeshGen.Box().Transform(box2Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb {
                Aabb = box2Mesh.Aabb()
            },
                                    new CMesh {
                Mesh = box2Mesh.Gpu(g)
            }, new CShadow()));

            var box3Transform = Matrix.CreateScale(new Vector3(length, height, thickness))
                                * Matrix.CreateTranslation(pos + 0.5f * width * Vector3.Forward + 0.5f * height * Vector3.Up);
            var box3Mesh = MeshGen.Box().Transform(box3Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb {
                Aabb = box3Mesh.Aabb()
            },
                                    new CMesh {
                Mesh = box3Mesh.Gpu(g)
            }, new CShadow()));

            var box4Transform = Matrix.CreateScale(new Vector3(thickness, height, width))
                                * Matrix.CreateTranslation(pos + 0.5f * length * Vector3.Left + 0.5f * height * Vector3.Up);
            var box4Mesh = MeshGen.Box().Transform(box4Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb {
                Aabb = box4Mesh.Aabb()
            },
                                    new CMesh {
                Mesh = box4Mesh.Gpu(g)
            }, new CShadow()));

            var box5Transform = Matrix.CreateScale(new Vector3(length, thickness, width))
                                * Matrix.CreateTranslation(pos + (-0.5f * height + 0.01f) * Vector3.Up);
            var box5Mesh = MeshGen.Box().Transform(box5Transform).Color(color);

            AddEntity(new EcsEntity(new CAabb {
                Aabb = box5Mesh.Aabb()
            },
                                    new CMesh {
                Mesh = box5Mesh.Gpu(g)
            }, new CShadow()));
        }