Exemple #1
0
        private VerticeAgua[,] crearMatriz()
        {
            vertices = new VerticeAgua[TOTAL_VERTICES_DIMENSION, TOTAL_VERTICES_DIMENSION];
            float z_vertice = DIMENSION_ESQUINA;

            for (int z = 0; z < TOTAL_VERTICES_DIMENSION; z++)
            {
                float x_vertice = DIMENSION_ESQUINA;
                for (int x = 0; x < TOTAL_VERTICES_DIMENSION; x++)
                {
                    VerticeAgua verticeAgua = new VerticeAgua();
                    verticeAgua.Pos = new Vector3(x_vertice, HEIGHT_CENTER, z_vertice);
                    float uvX = (float)x / (float)DIMENSION;
                    float uvZ = (float)z / (float)DIMENSION;
                    verticeAgua.UV = new Vector2(uvX, uvZ);
                    vertices[x, z] = verticeAgua;
                    x_vertice     += distancia_verices;
                }
                z_vertice += distancia_verices;
            }
            return(vertices);
        }
Exemple #2
0
        private void crearVertices()
        {
            int i = 0;
            int b = 0;

            for (int z = 0; z < DIMENSION; z++)
            {
                for (int x = 0; x < DIMENSION; x++)
                {
                    /*Cuadrado
                     * 1--4
                     |  |
                     | 2--3
                     */
                    //vertice 1
                    VerticeAgua v1 = vertices[x, z];
                    //vertice 2
                    VerticeAgua v2 = vertices[x, z + 1];
                    //vertice 3
                    VerticeAgua v3 = vertices[x + 1, z + 1];
                    //vertice 4
                    VerticeAgua v4 = vertices[x + 1, z];

                    //vertice 1
                    Vector3 n1 = Vector3.Cross(v1.Pos - v2.Pos, v1.Pos - v4.Pos);
                    //Vector3 n1 = Vector3.Cross(v2.Pos - v1.Pos, v4.Pos-v1.Pos);
                    //normals.Add(TgcArrow.fromDirection(v1.Pos, Vector3.Scale(n1, 10f)));
                    n1.Normalize();
                    //Vector3 n1 = new Vector3(0, 1, 0);
                    data[i + 0] = new CustomVertex.PositionNormalTextured(v1.Pos, n1, v1.UV.X, v1.UV.Y);

                    //vertice 2
                    Vector3 n2 = Vector3.Cross(v2.Pos - v3.Pos, v2.Pos - v1.Pos);
                    //Vector3 n2 = Vector3.Cross(v3.Pos - v2.Pos, v1.Pos - v2.Pos);
                    //normals.Add(TgcArrow.fromDirection(v2.Pos, Vector3.Scale(n2, 10f)));
                    n2.Normalize();
                    //Vector3 n2 = new Vector3(0, 1, 0);
                    data[i + 1] = new CustomVertex.PositionNormalTextured(v2.Pos, n2, v2.UV.X, v2.UV.Y);

                    //vertice 3
                    Vector3 n3 = Vector3.Cross(v3.Pos - v4.Pos, v3.Pos - v2.Pos);
                    //Vector3 n3 = Vector3.Cross(v4.Pos - v3.Pos, v2.Pos - v3.Pos);
                    //normals.Add(TgcArrow.fromDirection(v3.Pos, Vector3.Scale(n3, 10f)));
                    n3.Normalize();
                    //Vector3 n3 = new Vector3(0,1,0);
                    data[i + 2] = new CustomVertex.PositionNormalTextured(v3.Pos, n3, v3.UV.X, v3.UV.Y);

                    //vertice 4
                    Vector3 n4 = Vector3.Cross(v4.Pos - v1.Pos, v4.Pos - v3.Pos);
                    //Vector3 n4 = Vector3.Cross(v1.Pos - v4.Pos, v3.Pos - v4.Pos);
                    //normals.Add(TgcArrow.fromDirection(v4.Pos, Vector3.Scale(n4, 10f)));
                    n4.Normalize();
                    //Vector3 n4 = new Vector3(0,1,0);
                    data[i + 3] = new CustomVertex.PositionNormalTextured(v4.Pos, n4, v4.UV.X, v4.UV.Y);

                    //Buffer
                    indice[b + 0] = i + 0;
                    indice[b + 1] = i + 1;
                    indice[b + 2] = i + 2;
                    indice[b + 3] = i + 3;
                    indice[b + 4] = i + 0;
                    indice[b + 5] = i + 2;
                    i            += 4;
                    b            += 6;
                }
            }
        }