/// <summary>
        /// Llena la informacion del VertexBuffer con los vertices especificados
        /// </summary>
        /// <param name="verticesCoordinates"></param>
        private void fillVertexBufferData(float[] verticesCoordinates)
        {
            switch (renderType)
            {
            case MeshRenderType.VERTEX_COLOR:
                TgcKeyFrameLoader.VertexColorVertex[] data1 = new TgcKeyFrameLoader.VertexColorVertex[originalData.coordinatesIndices.Length];
                for (int i = 0; i < originalData.coordinatesIndices.Length; i++)
                {
                    TgcKeyFrameLoader.VertexColorVertex v = new TgcKeyFrameLoader.VertexColorVertex();

                    //vertices
                    int coordIdx = originalData.coordinatesIndices[i] * 3;
                    v.Position = new Vector3(
                        verticesCoordinates[coordIdx],
                        verticesCoordinates[coordIdx + 1],
                        verticesCoordinates[coordIdx + 2]
                        );

                    //color
                    int colorIdx = originalData.colorIndices[i];
                    v.Color = originalData.verticesColors[colorIdx];

                    data1[i] = v;
                }
                d3dMesh.SetVertexBufferData(data1, LockFlags.None);
                break;

            case MeshRenderType.DIFFUSE_MAP:
                TgcKeyFrameLoader.DiffuseMapVertex[] data2 = new TgcKeyFrameLoader.DiffuseMapVertex[originalData.coordinatesIndices.Length];
                for (int i = 0; i < originalData.coordinatesIndices.Length; i++)
                {
                    TgcKeyFrameLoader.DiffuseMapVertex v = new TgcKeyFrameLoader.DiffuseMapVertex();

                    //vertices
                    int coordIdx = originalData.coordinatesIndices[i] * 3;
                    v.Position = new Vector3(
                        verticesCoordinates[coordIdx],
                        verticesCoordinates[coordIdx + 1],
                        verticesCoordinates[coordIdx + 2]
                        );

                    //texture coordinates diffuseMap
                    int texCoordIdx = originalData.texCoordinatesIndices[i] * 2;
                    v.Tu = originalData.textureCoordinates[texCoordIdx];
                    v.Tv = originalData.textureCoordinates[texCoordIdx + 1];

                    //color
                    int colorIdx = originalData.colorIndices[i];
                    v.Color = originalData.verticesColors[colorIdx];

                    data2[i] = v;
                }
                d3dMesh.SetVertexBufferData(data2, LockFlags.None);
                break;
            }
        }
Exemple #2
0
        /// <summary>
        /// Llena la informacion del VertexBuffer con los vertices especificados
        /// </summary>
        /// <param name="verticesCoordinates"></param>
        private void fillVertexBufferData(float[] verticesCoordinates)
        {
            switch (renderType)
            {
                case MeshRenderType.VERTEX_COLOR:
                    TgcKeyFrameLoader.VertexColorVertex[] data1 = new TgcKeyFrameLoader.VertexColorVertex[originalData.coordinatesIndices.Length];
                    for (int i = 0; i < originalData.coordinatesIndices.Length; i++)
                    {
                        TgcKeyFrameLoader.VertexColorVertex v = new TgcKeyFrameLoader.VertexColorVertex();

                        //vertices
                        int coordIdx = originalData.coordinatesIndices[i] * 3;
                        v.Position = new Vector3(
                            verticesCoordinates[coordIdx],
                            verticesCoordinates[coordIdx + 1],
                            verticesCoordinates[coordIdx + 2]
                            );

                        //color
                        int colorIdx = originalData.colorIndices[i];
                        v.Color = originalData.verticesColors[colorIdx];

                        data1[i] = v;
                    }
                    d3dMesh.SetVertexBufferData(data1, LockFlags.None);
                    break;

                case MeshRenderType.DIFFUSE_MAP:
                    TgcKeyFrameLoader.DiffuseMapVertex[] data2 = new TgcKeyFrameLoader.DiffuseMapVertex[originalData.coordinatesIndices.Length];
                    for (int i = 0; i < originalData.coordinatesIndices.Length; i++)
                    {
                        TgcKeyFrameLoader.DiffuseMapVertex v = new TgcKeyFrameLoader.DiffuseMapVertex();

                        //vertices
                        int coordIdx = originalData.coordinatesIndices[i] * 3;
                        v.Position = new Vector3(
                            verticesCoordinates[coordIdx],
                            verticesCoordinates[coordIdx + 1],
                            verticesCoordinates[coordIdx + 2]
                            );

                        //texture coordinates diffuseMap
                        int texCoordIdx = originalData.texCoordinatesIndices[i] * 2;
                        v.Tu = originalData.textureCoordinates[texCoordIdx];
                        v.Tv = originalData.textureCoordinates[texCoordIdx + 1];

                        //color
                        int colorIdx = originalData.colorIndices[i];
                        v.Color = originalData.verticesColors[colorIdx];

                        data2[i] = v;
                    }
                    d3dMesh.SetVertexBufferData(data2, LockFlags.None);
                    break;
            }
        }