indexing description: "[ This class describes a target ]" date: "$Date$" revision: "$Revision$" "This class describes a target" date: "$Date$" revision: "$Revision$" class TARGET inherit EM_3D_SPHERE_COLLIDABLE EM_3D_OBJECT GLU_FUNCTIONS export {NONE} all end DOUBLE_MATH export {NONE} all end create make feature {NONE} -- Initialization make (a_model: EM_3D_OBJECT) is -- Create target. do model := a_model width := model.width height := model.height depth := model.depth scale.set(1,1,1) end feature -- Commands register_target_reached (an_action: PROCEDURE [ANY, TUPLE[]]) is -- Register a handler to execute when target is reached. require an_action_not_void: an_action /= Void do target_reached_action := an_action end feature -- Status type_id: INTEGER is 2 -- Id given to all instances of `current' generating class feature -- Collision detection bounding_sphere_center: EM_3D_VECT is -- Center of bounding sphere do result.set (origin.x + 0.5*width, origin.y+0.5*height, origin.z - 0.5*depth) end bounding_sphere_radius: DOUBLE is -- Radius of bounding sphere do result := width.max (depth) result := result.max (height) result := result / 2 end feature {EM_3D_OBJECT} -- Implementation of the 3d object draw_object is -- Draw object. do model.draw_object end feature {EM_COLLISION_DETECTOR} -- Implementation of collision detection on_collide (other: EM_COLLIDABLE_3D) is -- Handle `Current' collided with `other'. do target_reached_action.call(void) end feature {NONE} -- Implementation model: EM_3D_OBJECT -- Target model target_reached_action: PROCEDURE [ANY, TUPLE[]] -- Action to execute when target is reached end