Example #1
0
        public TriMeshChunk(BinaryChunk c)
        {
            if (c.id != ChunkId.TRIANGULAR_MESH)
            {
                throw new Exception("Not a trimesh");
            }
            List <BinaryChunk> chunks = c.SubChunks;

            points  = ParsePoints(BinaryChunk.SelectChunk(ChunkId.VERTICES_LIST, chunks));
            mapping = ParseMapping(BinaryChunk.SelectChunk(ChunkId.MAPPING_COORDINATES_LIST, chunks));
            List <BinaryChunk> facechunks;

            faces = ParseFaces(BinaryChunk.SelectChunk(ChunkId.FACES_DESCRIPTION, chunks), out facechunks);
            List <FaceMaterialChunk> facematerials = new List <FaceMaterialChunk>();

            foreach (BinaryChunk bc in BinaryChunk.IterateChunks(ChunkId.FACES_MATERIAL, facechunks))
            {
                facematerials.Add(new FaceMaterialChunk(bc));
            }
            this.facematerials = facematerials;
            coordsys           = new LocalCoordinateSystemChunk(BinaryChunk.SelectChunk(ChunkId.LOCAL_COORDINATES_SYSTEM, chunks));
        }
Example #2
0
        public Editor3dChunk(BinaryChunk c)
        {
            if (c.id != ChunkId.EDITOR_3D_CHUNK)
            {
                throw new Exception("Not a 3d editor chunk");
            }
            List <BinaryChunk> chunks = c.SubChunks;

            List <ObjectChunk>   objects   = new List <ObjectChunk>();
            List <MaterialChunk> materials = new List <MaterialChunk>();

            foreach (BinaryChunk oc in BinaryChunk.IterateChunks(ChunkId.OBJECT_BLOCK, chunks))
            {
                objects.Add(new ObjectChunk(oc));
            }
            foreach (BinaryChunk mc in BinaryChunk.IterateChunks(ChunkId.MATERIAL_BLOCK, chunks))
            {
                materials.Add(new MaterialChunk(mc));
            }

            this.objects   = objects;
            this.materials = materials;
        }