indexing description: "Stores Meshes in a binary format, so that the mesh files don't need to be parsed every time" date: "$Date$" revision: "$Revision$" class EM3D_MESH_BIN_FACTORY inherit EM3D_MESH_FACTORY feature {EM3D_MESH_FACTORY}-- Store a mesh magic: STRING is "EM3D" store_mesh( a_filename: STRING; some_meshes: ARRAY[ EM_PAIR[ STRING, EM3D_MESH ] ]; some_material_files: ARRAY[ STRING ] ) is -- Store meshes in a file require valid_materials: some_material_files /= void valid_meshes: some_meshes /= void valid_filename: a_filename /= void local file: RAW_FILE i, j: INTEGER mesh: EM3D_MESH sub_mesh: EM3D_SUB_MESH do create file.make_open_write ( a_filename ) file.put_string ( magic ) file.put_integer ( some_material_files.count ) from i:=some_material_files.lower until i>some_material_files.upper loop file.put_integer ( some_material_files[i].count ) file.put_string ( some_material_files[i] ) i := i + 1 end file.put_integer ( some_meshes.count ) from i:=some_meshes.lower until i>some_meshes.upper loop file.put_integer ( some_meshes[i].first.count ) file.put_string ( some_meshes[i].first ) some_meshes[i].second.store_in_file ( file ) i := i + 1 end file.close end load_mesh_internal( a_filename: STRING ) is -- Load a binary mesh file local file: RAW_FILE i: INTEGER name : STRING mesh: EM3D_MESH do create file.make_open_read ( a_filename ) file.read_stream ( 4 ) if file.last_string.is_equal ( magic ) then -- Load the material file.read_integer from i:=file.last_integer until i=0 loop file.read_integer file.read_stream ( file.last_integer ) scene_manager.material_factory.load_material ( file.last_string ) i := i - 1 end -- load the meshes file.read_integer from i:=file.last_integer until i=0 loop file.read_integer file.read_stream ( file.last_integer ) name := file.last_string.twin create mesh.make ( scene_manager, false ) mesh.load_from_file ( file ) add_mesh ( mesh, name) i := i - 1 end end file.close end end