示例#1
0
        public MaterialChunk(BinaryChunk c)
        {
            if (c.id != ChunkId.MATERIAL_BLOCK)
            {
                throw new Exception("Not a material chunk");
            }
            List <BinaryChunk> chunks = c.SubChunks;

            name     = new StringChunk(BinaryChunk.SelectChunk(ChunkId.MATERIAL_NAME, chunks));
            ambient  = new ColorChunk(BinaryChunk.SelectChunkOrNull(ChunkId.AMBIENT_COLOR, chunks));
            diffuse  = new ColorChunk(BinaryChunk.SelectChunkOrNull(ChunkId.DIFFUSE_COLOR, chunks));
            specular = new ColorChunk(BinaryChunk.SelectChunkOrNull(ChunkId.SPECULAR_COLOR, chunks));
            texture  = new StringChunk(BinaryChunk.SelectChunk(ChunkId.TEXTURE_MAP_1, chunks).getSub(ChunkId.MAPPING_FILENAME));
        }
示例#2
0
        public ObjectChunk(BinaryChunk c)
        {
            if (c.id != ChunkId.OBJECT_BLOCK)
            {
                throw new Exception("Not a object block");
            }

            List <BinaryChunk> chunks = new List <BinaryChunk>();
            Binary             b      = new Binary(c.bytes);

            name = b.ReadString();
            BinaryChunk.ReadFromBinary(chunks, b);
            BinaryChunk tm = BinaryChunk.SelectChunk(ChunkId.TRIANGULAR_MESH, chunks);

            if (tm == null)
            {
                throw new Exception("Missing a trimesh chunk");
            }
            trimesh = new TriMeshChunk(tm);
        }
示例#3
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));
        }