Ejemplo n.º 1
0
    /**
     * @brief Calculates the vertices, node values, UV mapping, tangents, and triangles of a square mesh.
     */
    private void calculateSquareMeshData()
    {
        //calculate vertices, node values, UV mapping, and tangents
        for (int i = 0, y = 0; y <= m_mapHeight; y++)
        {
            for (int x = 0; x <= m_mapWidth; x++, i++)
            {
                m_vertices[i] = new Vector3(x, 0, y);
                WorldMapVertex theNode = new WorldMapVertex();
                theNode.vertexIndex = i;
                //theNode.vertex = m_vertices[i];
                m_nodes[y, x] = theNode;
                m_uv[i]       = new Vector2((float)x / m_mapWidth, (float)y / m_mapHeight);
                m_tangents[i] = m_tangent;
            }
        }

        //calculate triangles
        for (int currentTriangle = 0, currentVertex = 0, y = 0; y < m_mapHeight; y++, currentVertex++)
        {
            for (int x = 0; x < m_mapWidth; x++, currentTriangle += 6, currentVertex++)
            {
                m_triangles[currentTriangle]     = currentVertex;
                m_triangles[currentTriangle + 3] = m_triangles[currentTriangle + 2] = currentVertex + 1;
                m_triangles[currentTriangle + 4] = m_triangles[currentTriangle + 1] = currentVertex + m_mapWidth + 1;
                m_triangles[currentTriangle + 5] = currentVertex + m_mapWidth + 2;
            }
        }
    }
Ejemplo n.º 2
0
 /**
  * Private Members
  */
 private void setVertices(int mapSize, int stabilizationPeriod)
 {
     m_worldMapVertices = new WorldMapVertex[mapSize + 1, mapSize + 1];
     for (int i = 0, y = 0; y <= mapSize; y++)
     {
         for (int x = 0; x <= mapSize; x++, i++)
         {
             WorldMapVertex theVertex = new WorldMapVertex();
             theVertex.init(stabilizationPeriod);
             theVertex.vertexIndex    = i;
             theVertex.position       = new Vector3(x, 0, y);
             m_worldMapVertices[y, x] = theVertex;
         }
     }
 }