indexing description: "A submesh has its own indices ans material" date: "$Date$" revision: "$Revision$" class EM3D_SUB_MESH inherit EMGL_ARRAY_RENDERER export {NONE} all end EM3D_RESOURCE create {EM3D_MESH} make feature {NONE} -- Initialize make( a_scene_manager: like scene_manager; a_mesh: like mesh; some_indices: like indices; a_material: like material ) is -- Create a new sub_mesh require valid_indices: some_indices /= void valid_material: a_material /= void valid_mesh: a_mesh /= void do mesh := a_mesh indices := some_indices material := a_material scene_manager := a_scene_manager end feature {NONE} -- Implementation internal_material: EM3D_MATERIAL scene_manager: EM3D_SCENE_MANAGER feature -- Access mesh: EM3D_MESH material: STRING indices: EM3D_VBO_ELEMENT_ARRAY feature -- Status changed: BOOLEAN is -- Has the submesh changed? do result := indices.changed end update is -- Update the mesh do indices.update end render_opengl is -- Render the sub_mesh do if internal_material=void then internal_material := scene_manager.material_factory.new_material( material ) end internal_material.render_opengl if indices.is_vbo_supported then indices.bind emgl_draw_elements( em_gl_triangles, indices.count, em_gl_unsigned_int, default_pointer ) else emgl_draw_elements( em_gl_triangles, indices.count, em_gl_unsigned_int, indices ) end end feature -- File storage store_in_file( a_file: RAW_FILE ) is -- Store the VBO in a_file do indices.store_in_file( a_file ) a_file.put_integer ( material.count ) a_file.put_string ( material ) end load_from_file( a_file: RAW_FILE ) is -- Load the VBO from a_file do indices.load_from_file( a_file ) a_file.read_integer a_file.read_stream ( a_file.last_integer ) material := a_file.last_string.twin end end