note description: "[ Represent the direction that an effect come from (an not where it goes, be carefull). Direction is encoded by three position (X axis, Y axix and Z axis). Cardinal directions of the haptic device are relative to the positioning of the device. North is considered to be away from the user, south is toward the user, east is right, and west is left of the user: .--. |__| .-------. |=.| |.-----.| |--| || || | | |'-----'| |__|~')_____(' [ COMPUTER ] North (0,-1,0) ^ | | (-1,0,0) West <----[ HAPTIC ]----> East (1,0,0) | | v South (0,1,0) [ USER ] \|||/ (o o) ---ooO-(_)-Ooo--- ]" author: "Louis Marchand" date: "Tue, 03 Mar 2015 15:22:37 +0000" revision: "2.0" class GAME_HAPTIC_CARTESIAN_DIRECTION inherit GAME_HAPTIC_DIRECTION redefine make, is_values_equal end create {GAME_HAPTIC_EFFECT} make_from_other create make, make_with_2_axis, make_with_axis feature {NONE} -- Initialization make_from_other (a_other: GAME_HAPTIC_DIRECTION) -- Initalization of Current using a_other as source require other_exists: a_other.exists other_cartesian: a_other.is_cartesian do make copy (a_other) ensure exists: exists type_is_valid: type = {GAME_SDL_EXTERNAL}.sdl_haptic_cartesian is_equal_other: is_values_equal (a_other) end make -- Initialization of Current do Precursor set_type ({GAME_SDL_EXTERNAL}.sdl_haptic_cartesian) ensure then exists: exists type_is_valid: type = {GAME_SDL_EXTERNAL}.sdl_haptic_cartesian x_axis_valid: x = 0 y_axis_valid: y = 0 z_axis_valid: z = 0 end make_with_2_axis (a_x, a_y: INTEGER_32) -- Initialization of Current using a_x as x axis and a_y as y axis do make_with_axis (a_x, a_y, 0) ensure exists: exists type_is_valid: type = {GAME_SDL_EXTERNAL}.sdl_haptic_cartesian x_axis_valid: x = a_x y_axis_valid: y = a_y z_axis_valid: z = 0 end make_with_axis (a_x, a_y, a_z: INTEGER_32) -- Initialization of Current using a_ as x axis, a_y as -- y axis and a_z as z axis. do make set_position (a_x, a_y, a_z) ensure exists: exists type_is_valid: type = {GAME_SDL_EXTERNAL}.sdl_haptic_cartesian x_axis_valid: x = a_x y_axis_valid: y = a_y z_axis_valid: z = a_z end feature -- Access position: TUPLE [x: INTEGER_32; y: INTEGER_32; z: INTEGER_32] -- The coordinate of the origin of Current require exists: exists do Result := [x, y, z] end set_position (a_x, a_y, a_z: INTEGER_32) -- Assign position with the value of a_x, a_y and a_z require exists: exists do set_x (a_x) set_y (a_y) set_z (a_z) ensure x_axis_valid: x = a_x y_axis_valid: y = a_y z_axis_valid: z = a_z end x: INTEGER_32 assign set_x -- The horizontal coordinate of the origin of Current require exists: exists do Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_direction_struct_dir_i (item, 0) end set_x (a_x: INTEGER_32) -- Assign x with the value of a_x require exists: exists do {GAME_SDL_EXTERNAL}.set_sdl_haptic_direction_struct_dir_i (item, 0, a_x) ensure is_assign: x = a_x end y: INTEGER_32 assign set_y -- The vertical coordinate of the origin of Current require exists: exists do Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_direction_struct_dir_i (item, 1) end set_y (a_y: INTEGER_32) -- Assign y with the value of a_y require exists: exists do {GAME_SDL_EXTERNAL}.set_sdl_haptic_direction_struct_dir_i (item, 2, a_y) ensure is_assign: y = a_y end z: INTEGER_32 assign set_z -- The depth coordinate of the origin of Current. -- To use this coordinate, you need a 3 axis haptic -- (See: GAME_HAPTIC.axes_count) require exists: exists do Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_direction_struct_dir_i (item, 2) end set_z (a_z: INTEGER_32) -- Assign z with the value of a_z require exists: exists do {GAME_SDL_EXTERNAL}.set_sdl_haptic_direction_struct_dir_i (item, 2, a_z) ensure is_assign: z = a_z end is_values_equal (a_other: GAME_HAPTIC_DIRECTION): BOOLEAN -- Are the important values inside Current are equvalent do if exists then if a_other.exists then Result := attached {GAME_HAPTIC_CARTESIAN_DIRECTION} a_other as la_other and then (type = la_other.type and x = la_other.x and y = la_other.y and z = la_other.z) else Result := False end else Result := not a_other.exists end end invariant type_valid: type = {GAME_SDL_EXTERNAL}.sdl_haptic_cartesian position_valid: attached position as la_position and then (la_position.x = x and la_position.y = y and la_position.z = z) end -- class GAME_HAPTIC_CARTESIAN_DIRECTION
Generated by ISE EiffelStudio