/// <summary>
		/// Add services :
		/// </summary>
		protected override void Initialize ()
		{
			base.Initialize();

			constBuffer = new ConstantBuffer(GraphicsDevice, typeof(CBData));

			LoadContent();
			Reloading += (s, e) => LoadContent();

			GetService<Camera>().FreeCamPosition = new Vector3Fusion(0, 12, 21);
						
			//	fill vertex buffer for cube:
			Vector4Fusion color = new Vector4Fusion(Vector3Fusion.Zero, 1);
			Fusion.Mathematics.Vector2 texcoord = Fusion.Mathematics.Vector2.Zero;

			// back face
			var v0 = new CubeVertex { Position = new Vector3Fusion(-0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(-1.0f, 0, 0), Color = color, TexCoord = texcoord };
			var v1 = new CubeVertex { Position = new Vector3Fusion(-0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(-1.0f, 0, 0), Color = color, TexCoord = texcoord };
			var v2 = new CubeVertex { Position = new Vector3Fusion(-0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(-1.0f, 0, 0), Color = color, TexCoord = texcoord };
			var v3 = new CubeVertex { Position = new Vector3Fusion(-0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(-1.0f, 0, 0), Color = color, TexCoord = texcoord };

			// front
			var v4 = new CubeVertex { Position = new Vector3Fusion(0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(1.0f, 0, 0), Color = color, TexCoord = texcoord };
			var v5 = new CubeVertex { Position = new Vector3Fusion(0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(1.0f, 0, 0), Color = color, TexCoord = texcoord };
			var v6 = new CubeVertex { Position = new Vector3Fusion(0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(1.0f, 0, 0), Color = color, TexCoord = texcoord };
			var v7 = new CubeVertex { Position = new Vector3Fusion(0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(1.0f, 0, 0), Color = color, TexCoord = texcoord };

			// left
			var v8 = new CubeVertex { Position = new Vector3Fusion(-0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(0, 0, -1.0f), Color = color, TexCoord = texcoord };
			var v9 = new CubeVertex { Position = new Vector3Fusion(0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(0, 0, -1.0f), Color = color, TexCoord = texcoord };
			var v10 = new CubeVertex { Position = new Vector3Fusion(0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(0, 0, -1.0f), Color = color, TexCoord = texcoord };
			var v11 = new CubeVertex { Position = new Vector3Fusion(-0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(0, 0, -1.0f), Color = color, TexCoord = texcoord };

			// right
			var v12 = new CubeVertex { Position = new Vector3Fusion(-0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(0, 0, 1.0f), Color = color, TexCoord = texcoord };
			var v13 = new CubeVertex { Position = new Vector3Fusion(0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(0, 0, 1.0f), Color = color, TexCoord = texcoord };
			var v14 = new CubeVertex { Position = new Vector3Fusion(0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(0, 0, 1.0f), Color = color, TexCoord = texcoord };
			var v15 = new CubeVertex { Position = new Vector3Fusion(-0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(0, 0, 1.0f), Color = color, TexCoord = texcoord };

			// top
			var v16 = new CubeVertex { Position = new Vector3Fusion(0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(0, 1.0f, 0), Color = color, TexCoord = texcoord };
			var v17 = new CubeVertex { Position = new Vector3Fusion(0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(0, 1.0f, 0), Color = color, TexCoord = texcoord };
			var v18 = new CubeVertex { Position = new Vector3Fusion(-0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(0, 1.0f, 0), Color = color, TexCoord = texcoord };
			var v19 = new CubeVertex { Position = new Vector3Fusion(-0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(0, 1.0f, 0), Color = color, TexCoord = texcoord };

			// bottom
			var v20 = new CubeVertex { Position = new Vector3Fusion(0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(0, -1.0f, 0), Color = color, TexCoord = texcoord };
			var v21 = new CubeVertex { Position = new Vector3Fusion(0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(0, -1.0f, 0), Color = color, TexCoord = texcoord };
			var v22 = new CubeVertex { Position = new Vector3Fusion(-0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(0, -1.0f, 0), Color = color, TexCoord = texcoord };
			var v23 = new CubeVertex { Position = new Vector3Fusion(-0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(0, -1.0f, 0), Color = color, TexCoord = texcoord };

			data = new CubeVertex[] { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23 };
			vb.SetData(data, 0, 24);

			// fill the index buffer
			var index = new int[] { 3, 1, 0,	// back
									3, 2, 1,
									4, 5, 7,	// front
									7, 5, 6,
									8, 9, 11,	// left
									11, 9, 10,
									14, 13, 12,	// right
									14, 12, 15,
									19, 16, 17,	// top
									19, 17, 18,
									20, 23, 22,	// bottom
									20, 22, 21};
			ib.SetData(index);
		}
Exemple #2
0
        /// <summary>
        /// Add services :
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            constBuffer = new ConstantBuffer(GraphicsDevice, typeof(CBData));

            LoadContent();
            Reloading += (s, e) => LoadContent();

            GetService <Camera>().FreeCamPosition = new Vector3Fusion(0, 12, 21);

            //	fill vertex buffer for cube:
            Vector4Fusion color = new Vector4Fusion(Vector3Fusion.Zero, 1);

            Fusion.Mathematics.Vector2 texcoord = Fusion.Mathematics.Vector2.Zero;

            // back face
            var v0 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(-1.0f, 0, 0), Color = color, TexCoord = texcoord
            };
            var v1 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(-1.0f, 0, 0), Color = color, TexCoord = texcoord
            };
            var v2 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(-1.0f, 0, 0), Color = color, TexCoord = texcoord
            };
            var v3 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(-1.0f, 0, 0), Color = color, TexCoord = texcoord
            };

            // front
            var v4 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(1.0f, 0, 0), Color = color, TexCoord = texcoord
            };
            var v5 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(1.0f, 0, 0), Color = color, TexCoord = texcoord
            };
            var v6 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(1.0f, 0, 0), Color = color, TexCoord = texcoord
            };
            var v7 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(1.0f, 0, 0), Color = color, TexCoord = texcoord
            };

            // left
            var v8 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(0, 0, -1.0f), Color = color, TexCoord = texcoord
            };
            var v9 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(0, 0, -1.0f), Color = color, TexCoord = texcoord
            };
            var v10 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(0, 0, -1.0f), Color = color, TexCoord = texcoord
            };
            var v11 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(0, 0, -1.0f), Color = color, TexCoord = texcoord
            };

            // right
            var v12 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(0, 0, 1.0f), Color = color, TexCoord = texcoord
            };
            var v13 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(0, 0, 1.0f), Color = color, TexCoord = texcoord
            };
            var v14 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(0, 0, 1.0f), Color = color, TexCoord = texcoord
            };
            var v15 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(0, 0, 1.0f), Color = color, TexCoord = texcoord
            };

            // top
            var v16 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(0, 1.0f, 0), Color = color, TexCoord = texcoord
            };
            var v17 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(0, 1.0f, 0), Color = color, TexCoord = texcoord
            };
            var v18 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, 0.5f, 0.5f), Normal = new Vector3Fusion(0, 1.0f, 0), Color = color, TexCoord = texcoord
            };
            var v19 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, 0.5f, -0.5f), Normal = new Vector3Fusion(0, 1.0f, 0), Color = color, TexCoord = texcoord
            };

            // bottom
            var v20 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(0, -1.0f, 0), Color = color, TexCoord = texcoord
            };
            var v21 = new CubeVertex {
                Position = new Vector3Fusion(0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(0, -1.0f, 0), Color = color, TexCoord = texcoord
            };
            var v22 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, -0.5f, 0.5f), Normal = new Vector3Fusion(0, -1.0f, 0), Color = color, TexCoord = texcoord
            };
            var v23 = new CubeVertex {
                Position = new Vector3Fusion(-0.5f, -0.5f, -0.5f), Normal = new Vector3Fusion(0, -1.0f, 0), Color = color, TexCoord = texcoord
            };

            data = new CubeVertex[] { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23 };
            vb.SetData(data, 0, 24);

            // fill the index buffer
            var index = new int[] { 3, 1, 0,                    // back
                                    3, 2, 1,
                                    4, 5, 7,                    // front
                                    7, 5, 6,
                                    8, 9, 11,                   // left
                                    11, 9, 10,
                                    14, 13, 12,                 // right
                                    14, 12, 15,
                                    19, 16, 17,                 // top
                                    19, 17, 18,
                                    20, 23, 22,                 // bottom
                                    20, 22, 21 };

            ib.SetData(index);
        }