indexing description: "[ This factory creates buildings. ]" date: "$Date$" revision: "$Revision$" class BUILDING_FACTORY inherit EM_3D_OBJECT_FACTORY EM_SHARED_BITMAP_FACTORY export {NONE} all end EM_CONSTANTS export {NONE} all end GL_FUNCTIONS export {NONE} all end create make feature {NONE} -- Initialization make is -- Initialise object. do bitmap_factory.create_bitmap_from_image ("objects/build_side.png") create tex_side.make_from_surface (bitmap_factory.last_bitmap) tex_side.save end feature -- Commands create_building_object: BUILDING is -- Create a new building object that is collidable and includes the model do create result.make (create_object) end feature -- Status object_width: DOUBLE is 2.0 -- The size of the bounding box in x direction of created objects object_height: DOUBLE is 8.0 -- The size of the bounding box in y direction of created objects object_depth: DOUBLE is 2.0 -- The size of the bounding box in z direction of created objects feature {NONE} -- implementation tex_side: GL_STATIC_MIPMAP_TEXTURE -- Side texture id specify_object is -- Specify an object that can be drawn in the origin -- (front, left, lower corner of bounding box = 0,0,0) do gl_push_attrib ( Em_gl_enable_bit | Em_gl_color_buffer_bit) gl_enable (Em_gl_texture_2d) gl_bind_texture (Em_gl_texture_2d, tex_side.id) gl_begin ( Em_gl_quads ) -- front gl_tex_coord2f ( 0, 1 ) gl_vertex3d ( 0, 0, 0 ) gl_tex_coord2f ( 0, 0 ) gl_vertex3d ( 0, object_height, 0 ) gl_tex_coord2f ( 1, 0 ) gl_vertex3d ( object_width, object_height, 0 ) gl_tex_coord2f ( 1, 1 ) gl_vertex3d ( object_width, 0, 0 ) -- left gl_tex_coord2f ( 0, 1 ) gl_vertex3d ( 0, 0, -object_depth ) gl_tex_coord2f ( 0, 0 ) gl_vertex3d ( 0, object_height, -object_depth ) gl_tex_coord2f ( 1, 0 ) gl_vertex3d ( 0, object_height, 0 ) gl_tex_coord2f ( 1, 1 ) gl_vertex3d ( 0, 0, 0 ) -- back gl_tex_coord2f ( 0, 1 ) gl_vertex3d ( object_width, 0, -object_depth ) gl_tex_coord2f ( 0, 0 ) gl_vertex3d ( object_width, object_height, -object_depth ) gl_tex_coord2f ( 1, 0 ) gl_vertex3d ( 0, object_height, -object_depth ) gl_tex_coord2f ( 1, 1 ) gl_vertex3d ( 0, 0, -2 ) -- right gl_tex_coord2f ( 0, 1 ) gl_vertex3d ( object_width, 0, 0 ) gl_tex_coord2f ( 0, 0 ) gl_vertex3d ( object_width, object_height, 0 ) gl_tex_coord2f ( 1, 0 ) gl_vertex3d ( object_width, object_height, -object_depth ) gl_tex_coord2f ( 1, 1 ) gl_vertex3d ( object_width, 0, -object_depth ) gl_end gl_begin ( Em_gl_quads ) -- deactivate texture gl_disable (Em_gl_texture_2d) gl_color3f (0,0,0) -- Bottom gl_vertex3d ( 0, 0, 0 ) gl_vertex3d ( 0, 0, -2 ) gl_vertex3d ( object_width, 0, -object_depth ) gl_vertex3d ( object_width, 0, 0 ) -- Top gl_vertex3d ( 0, object_height, 0 ) gl_vertex3d ( 0, object_height, -object_depth ) gl_vertex3d ( object_width, object_height, -object_depth ) gl_vertex3d ( object_width, object_height, 0 ) gl_end -- restore old attrib stack gl_pop_attrib end end