private static ThreeDSObject ParseMeshData(DataReader3DS dataSegment) { string name = dataSegment.GetString(); DataReader3DS subSegment = dataSegment.GetNextSubSegment(); ThreeDSObject obj = new ThreeDSObject(); obj.name = name; while (subSegment != null) { switch ((ChunkCodes)subSegment.Tag) { case ChunkCodes.OBJ_MESH: // Current subsegment contains the polygonal information obj.meshes.Add(ParsePolygonalData(subSegment)); break; default: // Ignore all other subsegment types break; } subSegment = dataSegment.GetNextSubSegment(); } return(obj); }
private static ThreeDSObject ReadNAMED_OBJECT(FileStream file, Chunk thischunk) { ThreeDSObject obj = new ThreeDSObject(); uint bytesRead = 7; // Establish the length of the object name uint nameLen = 0; while (file.ReadByte() != 0) { nameLen++; } bytesRead += nameLen; // Go back and then read the name into a buffer /*file.Seek(-nameLen, SeekOrigin.Current); * byte[] name = new byte[]; * file.Read(*/ while (bytesRead < thischunk.length) { Chunk chunk = ReadChunk(file); switch ((ChunkCodes)chunk.ID) { case ChunkCodes.BLANK: break; case ChunkCodes.OBJ_MESH: obj.meshes.Add(LoadMeshOBJ_MESH(file, chunk)); break; default: file.Seek(chunk.length, SeekOrigin.Current); break; } bytesRead += chunk.length; } return(obj); }
private static ThreeDSObject ParseMeshData(DataReader3DS dataSegment) { string name = dataSegment.GetString(); DataReader3DS subSegment = dataSegment.GetNextSubSegment(); ThreeDSObject obj = new ThreeDSObject(); obj.name = name; while (subSegment != null) { switch ((ChunkCodes)subSegment.Tag) { case ChunkCodes.OBJ_MESH: // Current subsegment contains the polygonal information obj.meshes.Add(ParsePolygonalData(subSegment)); break; default: // Ignore all other subsegment types break; } subSegment = dataSegment.GetNextSubSegment(); } return obj; }