/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="game">Juego</param>
        /// <param name="terrainSize">Tamaño del terreno</param>
        /// <param name="position">Posición</param>
        /// <param name="textureAssetName">Nombre de la textura</param>
        public DemoScenery(Game game, float terrainSize, Vector3 position, string textureAssetName)
            : base(game)
        {
            float   size = terrainSize * 0.5f;
            Vector3 A    = new Vector3(size, 15, size) + position;
            Vector3 B    = new Vector3(size, 15, 0) + position;
            Vector3 C    = new Vector3(size, 15, -size) + position;
            Vector3 D    = new Vector3(0, -15, size) + position;
            Vector3 E    = new Vector3(0, 0, 0) + position;
            Vector3 F    = new Vector3(0, -15, -size) + position;
            Vector3 G    = new Vector3(-size, 15, size) + position;
            Vector3 H    = new Vector3(-size, 15, 0) + position;
            Vector3 I    = new Vector3(-size, 15, -size) + position;

            Triangle tr1 = new Triangle(A, D, B);
            Triangle tr2 = new Triangle(B, D, E);

            Triangle tr3 = new Triangle(B, E, C);
            Triangle tr4 = new Triangle(C, E, F);

            Triangle tr5 = new Triangle(D, G, E);
            Triangle tr6 = new Triangle(E, G, H);

            Triangle tr7 = new Triangle(E, H, F);
            Triangle tr8 = new Triangle(F, H, I);

            CollisionTriangleSoup triangleSoup = new CollisionTriangleSoup(new Triangle[] { tr1, tr2, tr3, tr4, tr5, tr6, tr7, tr8 }, float.PositiveInfinity);

            this.m_CollisionPrimitive = triangleSoup;

            this.m_Geometry = new VertexPositionTexture[9];

            this.m_Geometry[0] = new VertexPositionTexture(A, new Vector2(1.0f, 0.0f));
            this.m_Geometry[1] = new VertexPositionTexture(B, new Vector2(0.5f, 0.0f));
            this.m_Geometry[2] = new VertexPositionTexture(C, new Vector2(0.0f, 0.0f));

            this.m_Geometry[3] = new VertexPositionTexture(D, new Vector2(1.0f, 0.5f));
            this.m_Geometry[4] = new VertexPositionTexture(E, new Vector2(0.5f, 0.5f));
            this.m_Geometry[5] = new VertexPositionTexture(F, new Vector2(0.0f, 0.5f));

            this.m_Geometry[6] = new VertexPositionTexture(G, new Vector2(1.0f, 1.0f));
            this.m_Geometry[7] = new VertexPositionTexture(H, new Vector2(0.5f, 1.0f));
            this.m_Geometry[8] = new VertexPositionTexture(I, new Vector2(0.0f, 1.0f));

            this.m_PrimitiveCount = 8;

            this.m_TextureName = textureAssetName;
        }
Exemple #2
0
 public void RegisterTerrain(CollisionTriangleSoup collisionTriangleSoup)
 {
     this.m_TriangleSoup = collisionTriangleSoup;
 }