indexing description: "[ This factory creates a sky box ]" date: "$Date$" revision: "$Revision$" class SKYBOX_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 -- Initialization make is -- Create the object local a_texture: GL_STATIC_MIPMAP_TEXTURE do bitmap_factory.create_bitmap_from_image ("objects/sky_front.jpg") create a_texture.make_from_surface (bitmap_factory.last_bitmap) a_texture.save front := a_texture.id bitmap_factory.create_bitmap_from_image ("objects/sky_left.jpg") create a_texture.make_from_surface (bitmap_factory.last_bitmap) a_texture.save left := a_texture.id bitmap_factory.create_bitmap_from_image ("objects/sky_back.jpg") create a_texture.make_from_surface (bitmap_factory.last_bitmap) a_texture.save back := a_texture.id bitmap_factory.create_bitmap_from_image ("objects/sky_right.jpg") create a_texture.make_from_surface (bitmap_factory.last_bitmap) a_texture.save right := a_texture.id bitmap_factory.create_bitmap_from_image ("objects/sky_bottom.jpg") create a_texture.make_from_surface (bitmap_factory.last_bitmap) a_texture.save bottom := a_texture.id bitmap_factory.create_bitmap_from_image ("objects/sky_top.jpg") create a_texture.make_from_surface (bitmap_factory.last_bitmap) a_texture.save top := a_texture.id end feature -- Commands create_skybox_object: SKYBOX is -- Create a new skybox object that is collidable and includes the model do create result.make (create_object) end feature -- Status object_width: DOUBLE is 80.0 -- The size of the bounding box in x direction of created objects 40 object_height: DOUBLE is 15.0 -- The size of the bounding box in y direction of created objects 20 object_depth: DOUBLE is 80.0 -- The size of the bounding box in z direction of created objects 40 feature {NONE} -- Implementation front: INTEGER left: INTEGER back: INTEGER right: INTEGER bottom: INTEGER top: INTEGER -- Texture ids specify_object is -- Specify an object that can be drawn in the origin -- (front, left, lower corner of bounding box = 0,0,0) do -- back gl_bind_texture (Em_gl_texture_2d, front) gl_begin ( Em_gl_quads ) 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 ) gl_end -- left gl_bind_texture (Em_gl_texture_2d, left) gl_begin ( Em_gl_quads ) 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 ) gl_end -- front gl_bind_texture (Em_gl_texture_2d, back) gl_begin ( Em_gl_quads ) 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, -object_depth ) gl_end -- right gl_bind_texture (Em_gl_texture_2d, right) gl_begin ( Em_gl_quads ) 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 -- Bottom gl_bind_texture (Em_gl_texture_2d, bottom) gl_begin ( Em_gl_quads ) gl_tex_coord2f ( 0, 0 ) gl_vertex3d ( 0, 0, 0 ) gl_tex_coord2f ( 0, 1 ) gl_vertex3d ( 0, 0, -object_depth ) gl_tex_coord2f ( 1, 1 ) gl_vertex3d ( object_width, 0, -object_depth ) gl_tex_coord2f ( 1, 0 ) gl_vertex3d ( object_width, 0, 0 ) gl_end -- Top gl_bind_texture (Em_gl_texture_2d, top) gl_begin ( Em_gl_quads ) gl_tex_coord2f ( 0, 1 ) gl_vertex3d ( 0, object_height, 0 ) gl_tex_coord2f ( 0, 0 ) gl_vertex3d ( 0, object_height, -object_depth ) gl_tex_coord2f ( 1, 0 ) gl_vertex3d ( object_width, object_height, -object_depth ) gl_tex_coord2f ( 1, 1 ) gl_vertex3d ( object_width, object_height, 0 ) gl_end end end