Exemple #1
0
        public override void OnStart()
        {
            base.OnStart();

            Vertex[] vertices = new Vertex[]
            {
                new Vertex
                {
                    Location = new System.Numerics.Vector3(-0.5f, -0.5f, 0),
                    Color    = Color.Gold,
                    UV       = Vector2.Zero,
                },
                new Vertex
                {
                    Location = new System.Numerics.Vector3(0.5f, -0.5f, 0),
                    Color    = Color.Red,
                    UV       = Vector2.Zero,
                },
                new Vertex
                {
                    Location = new System.Numerics.Vector3(0.5f, 0.5f, 0),
                    Color    = Color.Blue,
                    UV       = Vector2.Zero,
                },
                new Vertex
                {
                    Location = new System.Numerics.Vector3(-0.5f, 0.5f, 0),
                    Color    = Color.Green,
                    UV       = Vector2.Zero,
                },
            };

            ushort[] ind = new ushort[]
            {
                0, 1, 2,
                2, 3, 0,
            };

            CameraComp = new CameraComponent(null);
            CameraComp.Register();
            CameraComp.MakeActive();

            const bool TestPerspective = false;

            if (TestPerspective)
            {
                CameraComp.Mode     = CameraComponent.ProjectionMode.Perspective;
                CameraComp.Location = new Vector3(200, 100, 500);
                CameraComp.LookAt(Vector3.Zero);
            }
            else
            {
                CameraComp.Mode = CameraComponent.ProjectionMode.Orthographic;
            }


            IVertexBuffer VertexBuffer = Renderer.RendererResourceFactory.CreateVertexBuffer();

            VertexBuffer.SetVertexData(vertices, ind);

            Command = Renderer.RendererResourceFactory.CreateRenderCommand()
                      .WithDebugName("Sample Game Render")
                      .WithMaterial(Renderer.DefaultMaterialPtr.Get <Material>())
                      .WithVertexBuffer(VertexBuffer);


            SampleRenderable renderable = new SampleRenderable(Command);

            Renderer.AddRenderable(renderable);
        }