Beispiel #1
0
        public override void ReadData(Scene scene, BinaryReader stream)
        {
            do
            {
                //	Peep at the next chunk.
                MAXChunkHeader next = MAXChunkHeader.Peep(stream);

                //	If it's an Trimesh Block, we can read that.
                if (next.type == ChunkType.CHUNK_TRIMESH)
                {
                    TriangleMeshChunk chunk = new TriangleMeshChunk();
                    chunk.Read(scene, stream);
                }
                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));
        }
Beispiel #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);
        }
Beispiel #3
0
        public override void ReadData(Scene scene, BinaryReader stream)
        {
            do
            {
                //	Peep at the next chunk.
                MAXChunkHeader next = MAXChunkHeader.Peep(stream);

                //	If it's an Object Block, we can read that.
                if(next.type == ChunkType.CHUNK_OBJBLOCK)
                {
                    ObjectBlockChunk chunk = new ObjectBlockChunk();
                    chunk.Read(scene, stream);
                }
                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));
        }
Beispiel #4
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);
        }