indexing description: "[ This class describes the arrow pointing to the target ]" date: "$Date$" revision: "$Revision$" "This class describes the arrow pointing to the target" date: "$Date$" revision: "$Revision$" class ARROW inherit EM_3D_OBJECT EM_TIME_SINGLETON export {NONE} all end DOUBLE_MATH export {NONE} all end create make feature {NONE} -- Initialization make is -- Create arrow local obj_loader: EM_3D_OBJ_LOADER do create obj_loader.make obj_loader.load_file ("objects/arrow.obj") obj_loader.set_color (0, 1, 1, 1) model := obj_loader.create_object scale.set(1,1,1) width := model.width height := model.height depth := model.depth set_scale (0.2, 0.2, 0.2) end feature -- Commands update (a_start_location: EM_3D_VECT; a_target_location: EM_3D_VECT) is -- Update arrow to be at a_start_location and point in direction to a_target_location. local direction: EM_3D_VECT angle: DOUBLE do direction := a_target_location - a_start_location -- at the moment only the case in the x-z plane is handled -- TODO handle all cases direction.set (direction.x, 0, direction.z) if direction.x < 0 then angle := 270+(arc_sine (direction.z/direction.length)/(2*pi)*360) else angle := 90-(arc_sine (direction.z/direction.length)/(2*pi)*360) end set_rotation (0, angle, 0) set_origin (a_start_location.x, a_start_location.y+1, a_start_location.z) end feature {NONE} -- Implementation model: EM_3D_OBJECT -- The arrow model feature {EM_3D_OBJECT} -- Implementation of the 3d object draw_object is do model.draw_object end end