Exemplo n.º 1
0
        public override void Start()
        {
            this.Configuration.BackgroundColour = Rgba32.DarkSlateGrey;

            MeshAsset meshAsset = this.Engine.Assets.Load<MeshAsset> ("assets/darius.bba");
            vb = Platform.Graphics.CreateVertexBuffer (meshAsset.VertexDeclaration, meshAsset.VertexData.Length);
            ib = Platform.Graphics.CreateIndexBuffer (meshAsset.IndexData.Length);
            vb.SetDataEx (meshAsset.VertexData);
            ib.SetData (meshAsset.IndexData);
            var mushMesh0 = new Mesh (vb, ib);

            // set up the debug renderer
            ShaderAsset unlitShaderAsset = this.Engine.Assets.Load<ShaderAsset> ("assets/vertex_lit.bba");
            shader = this.Platform.Graphics.CreateShader (unlitShaderAsset);
            TextureAsset texAsset = this.Engine.Assets.Load <TextureAsset> ("assets/darius_tex.bba");
            tex = this.Platform.Graphics.CreateTexture (texAsset);

            entity = SceneGraph.CreateSceneObject ("entity");
            entity.Transform.LocalPosition = new Vector3 (0f, 0f, 0f);
            entity.Transform.LocalScale = new Vector3 (0.1f, 0.1f, 0.1f);

            var mat = new Material ("Default", shader);
            mat.SetTexture ("TextureSampler", tex);

            MeshRendererTrait meshRendererTrait0 = entity.AddTrait<MeshRendererTrait> ();
            meshRendererTrait0.Material = mat;
            meshRendererTrait0.Mesh = mushMesh0;
            meshRendererTrait0.CullMode = CullMode.None;

            returnScene = this;

            var t = SceneGraph.CreateSceneObject ("T");
            t.Transform.LocalPosition = new Vector3 (0, 2.3f, 0);
            Entity camSo = SceneGraph.CreateSceneObject ("Scene X Camera");
            camSo.AddTrait<CameraTrait> ();
            var lookatTrait = camSo.AddTrait<LookAtSubjectTrait> ();
            lookatTrait.Subject = t.Transform;
            var orbitTrait = camSo.AddTrait<OrbitAroundSubjectTrait> ();
            orbitTrait.CameraSubject = Transform.Origin;

            camSo.Transform.LocalPosition = new Vector3 (-7f,3f,1f);

            this.RuntimeConfiguration.SetRenderPassCameraTo("Debug", camSo);
            this.RuntimeConfiguration.SetRenderPassCameraTo("Default", camSo);

            this.Engine.InputEventSystem.Tap += this.OnTap;
        }
Exemplo n.º 2
0
        public override void Start()
        {
            this.Configuration.BackgroundColour = Rgba32.DarkSlateGrey;
            //var goBoardMesh = new CubePrimitive (this.Platform.Graphics).Mesh;

            MeshAsset mushMeshAsset0 = this.Engine.Assets.Load<MeshAsset> ("assets/big_mushroom.bba");
            vb0 = Platform.Graphics.CreateVertexBuffer (mushMeshAsset0.VertexDeclaration, mushMeshAsset0.VertexData.Length);
            ib0 = Platform.Graphics.CreateIndexBuffer (mushMeshAsset0.IndexData.Length);
            vb0.SetDataEx (mushMeshAsset0.VertexData);
            ib0.SetData (mushMeshAsset0.IndexData);
            var mushMesh0 = new Mesh (vb0, ib0);

            MeshAsset mushMeshAsset1 = this.Engine.Assets.Load<MeshAsset> ("assets/small_mushroom_1.bba");
            vb1 = Platform.Graphics.CreateVertexBuffer (mushMeshAsset1.VertexDeclaration, mushMeshAsset1.VertexData.Length);
            ib1 = Platform.Graphics.CreateIndexBuffer (mushMeshAsset1.IndexData.Length);
            vb1.SetDataEx (mushMeshAsset1.VertexData);
            ib1.SetData (mushMeshAsset1.IndexData);
            var mushMesh1 = new Mesh (vb1, ib1);

            MeshAsset mushMeshAsset2 = this.Engine.Assets.Load<MeshAsset> ("assets/small_mushroom_2.bba");
            vb2 = Platform.Graphics.CreateVertexBuffer (mushMeshAsset2.VertexDeclaration, mushMeshAsset2.VertexData.Length);
            ib2 = Platform.Graphics.CreateIndexBuffer (mushMeshAsset2.IndexData.Length);
            vb2.SetDataEx (mushMeshAsset2.VertexData);
            ib2.SetData (mushMeshAsset2.IndexData);
            var mushMesh2 = new Mesh (vb2, ib2);

            // set up the debug renderer
            ShaderAsset unlitShaderAsset = this.Engine.Assets.Load<ShaderAsset> ("assets/pixel_lit.bba");
            shader = this.Platform.Graphics.CreateShader (unlitShaderAsset);
            TextureAsset woodTexAsset = this.Engine.Assets.Load <TextureAsset> ("assets/toadstool_diffuse.bba");
            woodTex = this.Platform.Graphics.CreateTexture (woodTexAsset);

            mush0 = SceneGraph.CreateSceneObject ("mush0");
            mush0.Transform.LocalPosition = new Vector3 (0f, 0f, 0f);
            mush0.Transform.LocalScale = new Vector3 (1f, 1f, 1f);

            mush1 = SceneGraph.CreateSceneObject ("mush1");
            mush1.Transform.LocalPosition = new Vector3 (0.8f, 0f, 0.8f);
            mush1.Transform.LocalScale = new Vector3 (1f, 1f, 1f);

            mush2 = SceneGraph.CreateSceneObject ("mush2");
            mush2.Transform.LocalPosition = new Vector3 (0.5f, 0f, 0f);
            mush2.Transform.LocalScale = new Vector3 (1f, 1f, 1f);

            var mat = new Material ("Default", shader);
            mat.SetTexture ("TextureSampler", woodTex);

            MeshRendererTrait meshRendererTrait0 = mush0.AddTrait<MeshRendererTrait> ();
            meshRendererTrait0.Material = mat;
            meshRendererTrait0.Mesh = mushMesh0;
            meshRendererTrait0.CullMode = CullMode.None;

            MeshRendererTrait meshRendererTrait1 = mush1.AddTrait<MeshRendererTrait> ();
            meshRendererTrait1.Material = mat;
            meshRendererTrait1.Mesh = mushMesh1;
            meshRendererTrait1.CullMode = CullMode.None;

            MeshRendererTrait meshRendererTrait2 = mush2.AddTrait<MeshRendererTrait> ();
            meshRendererTrait2.Material = mat;
            meshRendererTrait2.Mesh = mushMesh2;
            meshRendererTrait2.CullMode = CullMode.None;

            returnScene = this;

            var t = SceneGraph.CreateSceneObject ("T");
            t.Transform.LocalPosition = new Vector3 (0, 1f, 0);
            Entity camSo = SceneGraph.CreateSceneObject ("Scene X Camera");
            camSo.AddTrait<CameraTrait>();
            var lookatTrait = camSo.AddTrait<LookAtSubjectTrait>();
            lookatTrait.Subject = t.Transform;
            var orbitTrait = camSo.AddTrait<OrbitAroundSubjectTrait>();
            orbitTrait.CameraSubject = Transform.Origin;

            camSo.Transform.LocalPosition = new Vector3(6f,3f,6f);

            this.RuntimeConfiguration.SetRenderPassCameraTo("Debug", camSo);
            this.RuntimeConfiguration.SetRenderPassCameraTo("Default", camSo);

            this.Engine.InputEventSystem.Tap += this.OnTap;
        }