Example #1
0
        public override void ReadData(Scene scene, BinaryReader stream)
        {
            //	A triangle mesh is basicly a Polygon, so create it.
            Polygon poly = new Polygon();
            Matrix matrix = new Matrix();

            do
            {
                //	Peep at the next chunk.
                MAXChunkHeader next = MAXChunkHeader.Peep(stream);

                if(next.type == ChunkType.CHUNK_VERTLIST)
                {
                    //	Read the vertices.
                    VertexListChunk chunk = new VertexListChunk();
                    chunk.Read(scene, stream);

                    //	Set them into the polygon.
                    poly.Vertices = chunk.vertices;
                }
                else if(next.type == ChunkType.CHUNK_FACELIST)
                {
                    //	Read the faces.
                    FaceListChunk chunk = new FaceListChunk();
                    chunk.Read(scene, stream);

                    //	Set them into the polygon.
                    poly.Faces = chunk.faces;
                }
                else if(next.type == ChunkType.CHUNK_MAPLIST)
                {
                    //	Read the uvs.
                    MapListChunk chunk = new MapListChunk();
                    chunk.Read(scene, stream);

                    //	Set them into the polygon.
                    poly.UVs = chunk.uvs;
                }
                else if(next.type == ChunkType.CHUNK_TRMATRIX)
                {
                    //	Here we just read the matrix (we'll use it later).
                    TrMatrixChunk chunk = new TrMatrixChunk();
                    chunk.Read(scene, stream);

                    matrix = chunk.matrix;
                }
                else
                {
                    //	We don't know what this chunk is, so just read the generic one.
                    MAXChunk chunk = new MAXChunk();
                    chunk.Read(scene, stream);
                }

            } while (MoreChunks(stream));

            //	Now we multiply each vertex by the matrix.
            for(int i = 0; i < poly.Vertices.Count; i++)
                poly.Vertices[i] *= matrix;

            //	Add the poly to the scene.
            scene.Polygons.Add(poly);
        }
Example #2
0
        public override void ReadData(Scene scene, BinaryReader stream)
        {
            //	A triangle mesh is basicly a Polygon, so create it.
            Polygon poly   = new Polygon();
            Matrix  matrix = new Matrix();

            do
            {
                //	Peep at the next chunk.
                MAXChunkHeader next = MAXChunkHeader.Peep(stream);

                if (next.type == ChunkType.CHUNK_VERTLIST)
                {
                    //	Read the vertices.
                    VertexListChunk chunk = new VertexListChunk();
                    chunk.Read(scene, stream);

                    //	Set them into the polygon.
                    poly.Vertices = chunk.vertices;
                }
                else if (next.type == ChunkType.CHUNK_FACELIST)
                {
                    //	Read the faces.
                    FaceListChunk chunk = new FaceListChunk();
                    chunk.Read(scene, stream);

                    //	Set them into the polygon.
                    poly.Faces = chunk.faces;
                }
                else if (next.type == ChunkType.CHUNK_MAPLIST)
                {
                    //	Read the uvs.
                    MapListChunk chunk = new MapListChunk();
                    chunk.Read(scene, stream);

                    //	Set them into the polygon.
                    poly.UVs = chunk.uvs;
                }
                else if (next.type == ChunkType.CHUNK_TRMATRIX)
                {
                    //	Here we just read the matrix (we'll use it later).
                    TrMatrixChunk chunk = new TrMatrixChunk();
                    chunk.Read(scene, stream);

                    matrix = chunk.matrix;
                }
                else
                {
                    //	We don't know what this chunk is, so just read the generic one.
                    MAXChunk chunk = new MAXChunk();
                    chunk.Read(scene, stream);
                }
            } while (MoreChunks(stream));

            //	Now we multiply each vertex by the matrix.
            for (int i = 0; i < poly.Vertices.Count; i++)
            {
                poly.Vertices[i] *= matrix;
            }

            //	Add the poly to the scene.
            scene.Polygons.Add(poly);
        }