indexing description: " A scene that shows how to load objects and play with them .. (ESC returns to the main menu, M changes the model)." date: "$Date$" revision: "$Revision$" class OBJECT_SCENE inherit EM3D_TRACKBALL_SCENE rename make_scene as make redefine initialize_scene, handle_key_up_event end create make feature -- Initialization initialize_scene is -- Load the objects ... local main_light: EM3D_LIGHT tmp: EM3D_SCENE_NODE do Precursor create objects.make(0, 10) -- In order to have some basic shading we need to add a light to the scene main_light := scene_manager.light.create_new_point ( "main light" ) -- To achieve a headlight effect we can attach the light to the camera node active_camera_node.attach_object ( main_light ) -- To load a new object into our scene we first need to load the model scene_manager.model_factory.load_model ( "data/monkey.x" ) -- You can also load animated objects scene_manager.model_factory.load_model ( "data/em_phys.x" ) -- ... or textured ones scene_manager.model_factory.load_model ( "data/cube.x" ) -- ADD YOUR OWN OBJECTS HERE -- We can now attach any loaded model to a scene node -- In this case we use world (the root node of the scene) objects.put( scene_manager.model_factory.new_model ( "data/monkey.x", scene_manager.world ), 0 ) objects.put( scene_manager.model_factory.new_model ( "data/em_phys.x", scene_manager.world ), 1 ) scene_manager.animation.play ( objects.item(1).animation ( "AnimationSet0" ) ) objects.put( scene_manager.model_factory.new_model ( "data/cube.x", scene_manager.world ), 2 ) -- ADD YOUR OWN OBJECTS TO THE SCENE -- We also want a nicer background emgl_clear_color (0.05,0.05,0.2,1) -- showing the framecounter might be a good idea set_frame_counter_visibility ( true ) -- Hide all except the active object from active_object:=objects.lower until active_object>objects.upper or else objects[ active_object ]=void loop objects[ active_object ].set_visible ( false ) active_object := active_object + 1 end active_object:=objects.lower objects[ active_object ].set_visible ( true ) end objects: ARRAY[EM3D_ACTOR] active_object: INTEGER handle_key_up_event( a_keyboard_event: EM_KEYBOARD_EVENT ) is -- Change the model when we press a key do if a_keyboard_event.key=a_keyboard_event.sdlk_escape then set_next_scene ( create {MAIN_SCENE}.make ) start_next_scene elseif a_keyboard_event.key=a_keyboard_event.sdlk_m then objects[ active_object ].set_visible ( false ) active_object := active_object + 1 if active_object>objects.upper or else objects[ active_object ]=void then active_object:=objects.lower end objects[ active_object ].set_visible ( true ) end end end