note description: "The 3d object that receive the sound emit by sound sources." author: "Louis Marchand" date: "Tue, 07 Apr 2015 01:15:20 +0000" revision: "2.0" class AUDIO_LISTENER inherit AUDIO_3D_OBJECT create {AUDIO_LIBRARY_CONTROLLER} default_create feature -- Access initialize -- Set the default orientation, velocity and position. do set_position (0.0, 0.0, 0.0) set_velocity (0.0, 0.0, 0.0) set_orientation (0.0, 0.0, -1.0, 0.0, 1.0, 0.0) end set_orientation (a_x_at, a_y_at, a_z_at, a_x_up, a_y_up, a_z_up: REAL_32) -- Set the listener orientation (UP and AT). -- If you visualize the listener as a head, the UP is a vector representing the top of the head. -- The AT is the vector representing where the head is looking. require listener_orientation_at_and_up_orthogonal: a_x_at * a_x_up + a_y_at * a_y_up + a_z_at * a_z_up = 0.to_real do set_params_6_float ({AUDIO_EXTERNAL}.al_orientation, a_x_at, a_y_at, a_z_at, a_x_up, a_y_up, a_z_up) end orientation: TUPLE [a_x_at: REAL_32; a_y_at: REAL_32; a_z_at: REAL_32; a_x_up: REAL_32; a_y_up: REAL_32; a_z_up: REAL_32] -- Get the listener orientation (UP and AT). do Result := params_6_float ({AUDIO_EXTERNAL}.al_orientation) end feature {NONE} -- Implementation set_params_6_float (id: INTEGER_32; x_at, y_at, z_at, x_up, y_up, z_up: REAL_32) local params_vector: ARRAY [REAL_32] c_params: ANY do create params_vector.make_filled (0.0, 1, 6) params_vector.at (1) := x_at params_vector.at (2) := y_at params_vector.at (3) := z_at params_vector.at (4) := x_up params_vector.at (5) := y_up params_vector.at (6) := z_up c_params := params_vector.to_c clear_error set_params_float_pointer_c (id, $c_params.to_pointer) read_al_error ("Cannot set audio float parameters (6).") end params_6_float (a_id: INTEGER_32): TUPLE [x_at: REAL_32; y_at: REAL_32; z_at: REAL_32; x_up: REAL_32; y_up: REAL_32; z_up: REAL_32] local l_params_vector: ARRAY [REAL_32] l_params_c: ANY do create l_params_vector.make_filled (0.0, 1, 6) l_params_c := l_params_vector.to_c clear_error assign_params_float_pointer_c (a_id, $l_params_c.to_pointer) read_al_error ("Cannot get audio float parameters (6).") Result := [l_params_vector.at (1), l_params_vector.at (2), l_params_vector.at (3), l_params_vector.at (4), l_params_vector.at (5), l_params_vector.at (6)] end set_params_float_pointer_c (a_id: INTEGER_32; a_ptr: POINTER) do {AUDIO_EXTERNAL}.al_set_listener_fv (a_id, a_ptr) end assign_params_float_pointer_c (a_id: INTEGER_32; a_ptr: POINTER) do {AUDIO_EXTERNAL}.al_get_listener_fv (a_id, a_ptr) end end -- class AUDIO_LISTENER
Generated by ISE EiffelStudio