Пример #1
0
 public void BuildData(ref List <Model3D.MeshData> meshes)
 {
     finalMesh = newFinalMesh();
     for (int t = 0; t < TempMeshes.Count; t++)
     {
         uint             indexCount = 0;
         Model3D.MeshData md         = new Model3D.MeshData();
         Bitmap           bmp        = textureImages[t];
         md.texture = ContentPipe.LoadTexture(ref bmp);
         md.texture.TextureParamS = textureInfo[t].wrapS;
         md.texture.TextureParamT = textureInfo[t].wrapT;
         TempMesh temp = TempMeshes[t];
         for (int i = 0; i < temp.vertices.Count; i++)
         {
             int vExists = doesVertexAlreadyExist(t, temp.vertices[i], temp.texCoords[i], temp.colors[i]);
             if (vExists < 0)
             {
                 Vector2 texCoord = temp.texCoords[i];
                 texCoord.X /= (float)bmp.Width * 32.0f;
                 texCoord.Y /= (float)bmp.Height * 32.0f;
                 temp.final.vertices.Add(temp.vertices[i]);
                 temp.final.texCoords.Add(texCoord);
                 temp.final.colors.Add(temp.colors[i]);
                 temp.final.indices.Add(indexCount);
                 indexCount++;
             }
             else
             {
                 temp.final.indices.Add((uint)vExists);
             }
         }
         meshes.Add(md);
     }
 }
Пример #2
0
        private FinalMesh newFinalMesh()
        {
            FinalMesh m = new FinalMesh();

            m.vertices  = new List <Vector3>();
            m.texCoords = new List <Vector2>();
            m.colors    = new List <Vector4>();
            m.indices   = new List <uint>();
            return(m);
        }
Пример #3
0
        public void BuildData(List <Model3D.MeshData> meshes)
        {
            //TextureAtlasBuilder.TextureAtlas atlas = new TextureAtlasBuilder.TextureAtlas(textureImages);
            //atlas.outputToPNG("TestAtlas.png");

            finalMesh = newFinalMesh();
            for (int t = 0; t < TempMeshes.Count; t++)
            {
                uint indexCount = 0;
                meshes.Add(new Model3D.MeshData());
                //if (t != 0) continue;
                //TextureAtlasBuilder.TextureAtlas.AtlasEntry atlasEntry = atlas.getEntryFromID((uint)t);
                Model3D.MeshData md = meshes[t];
                md.texture = ContentPipe.LoadTexture(textureImages[t]);
                md.texture.TextureParamS = textureInfo[t].wrapS;
                md.texture.TextureParamT = textureInfo[t].wrapT;
                //Console.WriteLine("[Building]: " + (OpenTK.Graphics.OpenGL.All)md.texture.TextureParamS + "," +(OpenTK.Graphics.OpenGL.All)md.texture.TextureParamT);
                TempMesh temp = TempMeshes[t];
                for (int i = 0; i < temp.vertices.Count; i++)
                {
                    int vExists = doesVertexAlreadyExist(t, temp.vertices[i], temp.texCoords[i], temp.colors[i]);
                    if (vExists < 0)
                    {
                        Vector2 texCoord = temp.texCoords[i];
                        texCoord.X /= (float)textureImages[t].Width * 32.0f;
                        texCoord.Y /= (float)textureImages[t].Height * 32.0f;
                        temp.final.vertices.Add(temp.vertices[i]);
                        temp.final.texCoords.Add(texCoord);
                        temp.final.colors.Add(temp.colors[i]);
                        temp.final.indices.Add(indexCount);
                        indexCount++;
                    }
                    else
                    {
                        temp.final.indices.Add((uint)vExists);
                    }
                }
            }
        }