Beispiel #1
0
        public static MAXChunkHeader Peep(BinaryReader stream)
        {
            //	Read a header.
            MAXChunkHeader header = new MAXChunkHeader();

            header.Read(stream);

            //	Go back.
            stream.BaseStream.Seek(-6, System.IO.SeekOrigin.Current);

            //	Return the header.
            return(header);
        }
Beispiel #2
0
        protected override object LoadData(Stream stream)
        {
            //	We use a binary reader.
            BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.ASCII);

            //	Create a new scene to load to.
            Scene scene = new Scene();

            //	Peep the first chunk to make sure it's a 'main' chunk.
            if (MAXChunkHeader.Peep(reader).type != ChunkType.CHUNK_MAIN)
            {
                return(false);
            }

            //	The first chunk is always the main chunk, so read it.
            MainChunk main = new MainChunk();

            main.Read(scene, reader);

            return(scene);
        }
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 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 #4
0
        public static MAXChunkHeader Peep(BinaryReader stream)
        {
            //	Read a header.
            MAXChunkHeader header = new MAXChunkHeader();
            header.Read(stream);

            //	Go back.
            stream.BaseStream.Seek(-6, System.IO.SeekOrigin.Current);

            //	Return the header.
            return header;
        }
Beispiel #5
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);
        }