Aircraft_script - Outerra/anteworld GitHub Wiki
const ot::objdef_params& get_objdef_params() const; |
||
Parameter Description | Returns | Description |
---|---|---|
return: objdef parameters | Get the objdef parameters associated with the vehicle | |
bool resolve_path(ot::path_rel_to ref, const coid::token& path, ifc_out coid::charstr& dst) const; |
||
Parameter Description | Returns | Description |
ref: The reference path path: The relative path dst: The resolved path |
return: false on argument error | Resolve relative path |
iref<ot::geomob> get_geomob(int id = 0) const; |
||
Parameter Description | Returns | Description |
id: Object ID | return: geomob object | Get geomob |
bool get_objdef_info(ifc_out ot::pkginfo::obj& info) const; |
||
Parameter Description | Returns | Description |
info: Object definition information | return: objdef information | Get objdef information |
(coid::token get_objdef_param(const coid::token& key, const coid::token& group = coid::token()) const; |
||
Parameter Description | Returns | Description |
key: Key of the parameter group: Group of the parameter |
return: parameter value | Get parameter from objdef |
uint get_collision_group(ifc_out uint* mask) const; |
||
Parameter Description | Returns | Description |
mask: Optional mask value | return: collision group | Get the collision group |
void set_collision_group(uint group, uint mask); |
||
Parameter Description | Returns | Description |
group: Collision group ID mask: Collision mask |
Set the collision group | |
void fade(const coid::token& text) const; |
||
Parameter Description | Returns | Description |
text: Message to post to the fading log | Posts a message to the fading log | |
ot::ECameraMode get_camera_mode() const; |
||
Parameter Description | Returns | Description |
return: camera mode | Get the camera mode | |
uint64 get_custom_data_value() const; |
||
Parameter Description | Returns | Description |
return: custom data value | Get the custom data value | |
float3 heading_pitch_roll() const; |
||
Parameter Description | Returns | Description |
return: float3 | Get heading/pitch/roll angles of the object in radians | |
void extra_force(const float3& mpos, const float3& force, bool worldspace = false); |
||
Parameter Description | Returns | Description |
mpos: Model-space position to act on force: Model or world-space force vector worldspace: True for world-space force vector |
Add extra force to be applied to the object | |
void extra_impulse(const float3& mpos, const float3& impulse, bool worldspace = false); |
||
Parameter Description | Returns | Description |
mpos: Model-space position to act on impulse: Model or world-space force impulse vector worldspace: True for world-space force vector |
Apply extra force impulse (force * dt), one-time impulse, non-persistent | |
uint get_joint_id(const coid::token& name) const; |
||
Parameter Description | Returns | Description |
name: Bone name | return: joint/bone id or -1 if doesn't exist | Get joint/bone id for given bone name |
uint get_mesh_id(const coid::token& name, uint8 lod_group = 0xff, uint8 mat_group = 0xff) const; |
||
Parameter Description | Returns | Description |
name: Mesh name lod_group: LOD group for given base name mat_group: Material group for given base name |
return: mesh id for given params or -1 if doesn't exist | Get mesh id for given params or -1 if doesn't exist |
void fire(const float3& pos, const float3& dir, float speed, float caliber, const float3& color, uint joint = pkg::InvalidBoneId); |
||
Parameter Description | Returns | Description |
---|---|---|
pos: Model-space launch position dir: Model-space launch direction speed: Firing velocity in m/s caliber: Diameter of the ray [m] color: Plasma color joint: Bone id to attach to |
Fire a colored plasma thing | |
void explode_ground(const ot::ground_explosion& ge); |
||
Parameter Description | Returns | Description |
---|---|---|
ge: Explosion parameters | Explode ground at model position | |
float elevation_test(const float3& pos, float maxdist, float negdist = -FLT_MIN, uint joint = pkg::InvalidBoneId) const; |
||
Parameter Description | Returns | Description |
---|---|---|
pos: Model-space position maxdist: Max distance/height to check negdist: Max negative distance to test joint: Bone id to be relative to |
return: height above terrain or >= maxdist if no hit, <= negdist if under terrain | Elevation test |
float elevation_test_ext(const float3& pos, float maxdist, float negdist = -FLT_MIN, ifc_out ot::hitpoint* hp = 0, ot::hit_flags hpflags = {.hit = true, .normal = true}, uint joint = pkg::InvalidBoneId) const; |
||
Parameter Description | Returns | Description |
---|---|---|
pos: Model-space position maxdist: Max distance/height to check negdist: Max negative distance to test hp: Hitpoint result hpflags: Query flags joint: Bone id to be relative to |
return: height above terrain or >= maxdist if no hit, <= negdist if under terrain | Elevation test with extended info |
float ray_test(const float3& pos, const float3& dir, float maxdist, float negdist = -FLT_MIN, ifc_out ot::hitpoint* hp = 0, ot::hit_flags hpflags = {.hit = true, .normal = true}, uint joint = pkg::InvalidBoneId) const; |
||
Parameter Description | Returns | Description |
---|---|---|
pos: Model-space (or bone-space) position dir: Model-space (or bone-space) ray direction maxdist: Max distance/height to check negdist: Max negative distance to test hp: Hitpoint result hpflags: Query flags joint: Bone id to be relative to |
return: intersection distance or >= maxdist if no hit, <= negdist if under terrain | Test if ray from model intersects with terrain |
iref<ot::object> object_test(const float3& pos, const float3& dir, float maxdist, ifc_out ot::hitpoint* hp = 0, ot::hit_flags hpflags = {.hit = true, .normal = true, .objects = true, .dynamic = true, .selftest = false}, uint joint = pkg::InvalidBoneId) const; |
||
Parameter Description | Returns | Description |
---|---|---|
pos: Model-space (or bone-space) position dir: Model-space (or bone-space) ray direction maxdist: Max ray distance to check hp: Hitpoint result hpflags: Query flags joint: Bone id to be relative to |
return: object hit | Test if ray from model hits an object |
void attach_object(const iref<ot::object>& obj, uint joint_id, const float3& pos, const quat& rot, uint custom_id); |
||
Parameter Description | Returns | Description |
---|---|---|
obj: Object to attach joint_id: Bone id pos: Relative attachment offset rot: Relative attachment rotation custom_id: ID to identify the attached object when detaching |
Attach object | |
iref<ot::object> detach_object(uint custom_id, bool activate); |
||
Parameter Description | Returns | Description |
custom_id: ID set previously by attach_geom activate: Activate object (if it's not a static one) |
return: detached object, if found | Detach specified object |
iref<ot::object> get_attached_to() const; |
||
Parameter Description | Returns | Description |
return: the object this object is attached to or nullptr if this object is free | Get object we are attached to | |
bool detach_ot_object(const iref<ot::object≶& object, bool activate); |
||
Parameter Description | Returns | Description |
object: Attached object activate: Activate object (if it's not a static one) |
return: true if successful | Detach specified object |
void set_fps_camera_pos(const float3& pos, uint joint_id = UMAX32, ot::EJointRotationMode joint_rotation = ot::JointRotModeEnable); |
||
Parameter Description | Returns | Description |
---|---|---|
pos: Model space position joint_id: Joint ID joint_rotation: Joint rotation mode |
Set model space position for FPS camera | |
void set_fps_camera_rot(const quat& rot, ot::ERotationMode mouse_rotation); |
||
Parameter Description | Returns | Description |
---|---|---|
rot: Model space rotation mouse_rotation: Mouse rotation mode: 0 freeze, 1 reset & disable, 2 enable, 3 reset & enable |
Set model space rotation frame | |
void set_fps_camera_fov(float hfov, float vfov = 0); |
||
Parameter Description | Returns | Description |
hfov: Horizontal FOV in degrees, 0 to reset to the default one vfov: Optional vertical FOV in degrees, otherwise computed from aspect ratio |
Set FOV to chassis FPS preset and current camera if vehicle is entered and FPS camera is active | |
float3 get_fps_camera_pos() const; |
||
Parameter Description | Returns | Description |
return: current FPS camera position | Get current FPS camera position | |
quat get_fps_camera_rot(bool base = false) const; |
||
Parameter Description | Returns | Description |
base: True for the base orientation frame, false for current camera orientation as altered by mouse | return: current FPS camera rotation in model space | Get current FPS camera rotation in model space |
float2 get_fps_camera_fov() const; |
||
Parameter Description | Returns | Description |
return: FPS camera preset FOV for this chassis | Get FPS camera preset FOV for this chassis | |
void set_fps_camera_ypr(float yaw, float pitch, float roll, ot::ERotationMode mouse_rotation); |
||
Parameter Description | Returns | Description |
yaw: Yaw angle in radians, positive values to the right pitch: Pitch angle in radians, positive up roll: Roll angle in radians, positive clockwise mouse_rotation: Mouse rotation mode: 0 freeze, 1 reset & disable, 2 enable, 3 reset & enable |
Set model space orientation for FPS camera | |
float3 get_fps_camera_ypr(bool base = false) const; |
||
Parameter Description | Returns | Description |
base: True for the base orientation frame, false for current camera orientation as altered by mouse | return: current yaw/pitch/roll angles of the camera in model space in radians | Get current yaw/pitch/roll angles of the camera in model space |
bool set_fps_camera_tracking_point(const double3& target, bool level_horizon); |
||
Parameter Description | Returns | Description |
target: ECEF coordinates of the point level_horizon: Align horizon level with gravity |
Sets a tracking point as FPS camera orientation | |
bool set_fps_camera_tracking(bool level_horizon); |
||
Parameter Description | Returns | Description |
level_horizon: Keep horizon level (roll the camera) | return: true if tracking was enabled, false if center wasn't on terrain or the current camera mode is not FPS | Enable tracking of the current world point (in screen center) |
bool set_fps_camera_tracking_off(); |
||
Parameter Description | Returns | Description |
Disable tracking | ||
iref<ot::sndgrp> sound(); |
||
Parameter Description | Returns | Description |
return: of::snd_group interface | Get sound interface | |
int register_handler_ext(const coid::token& name, uint group = 0); |
||
Parameter Description | Returns | Description |
name: Hierarchic action name, file/group/action group: Activation group where the action is assigned (can be enabled/disabled together) |
return: slot id or -1 on fail | Register action handler for an existing knob |
int register_event_ext(const coid::token& name, bool release_event, uint group = 0); |
||
Parameter Description | Returns | Description |
name: Hierarchic action name, file/group/action release_event: True if handler should also receive release events (if bound to key) group: Activation group where the action is assigned (can be enabled/disabled together) |
return: slot id or -1 on fail | Register event action handler |
int register_axis_ext(const coid::token& name, const ot::ramp_params& ramp, uint group = 0); |
||
Parameter Description | Returns | Description |
name: Hierarchic action name, file/group/action ramp: Value limiter parameters (ignored for buttons) group: Activation group where the action is assigned (can be enabled/disabled together) |
return: slot id or -1 on fail | Register axis action handler |
int register_handler(const coid::token& name, ot::fn_event_action&& handler, int handler_id = 0, uint group = 0); |
||
Parameter Description | Returns | Description |
---|---|---|
name: Hierarchic action name handler: Handler for changed value handler_id: Optional extra data for the handler group: Activation group where the action is assigned (can be enabled/disabled together) |
return: slot id or -1 on fail | Register input action for an existing knob, create new using def_ramp if doesn't exist |
int register_handler_default(const coid::token& name, ot::fn_event_action&& handler, const ot::ramp_params& def_ramp, int handler_id = 0, const float* def_val = nullptr, uint group = 0); |
||
Parameter Description | Returns | Description |
---|---|---|
name: Hierarchic action name handler: Handler for changed value def_ramp: Action options to use if knob wasn't found, if nullptr do not create handler_id: Optional extra data for the handler def_val: Optional default action value group: Activation group where the action is assigned (can be enabled/disabled together) |
return: slot id or -1 on fail | Register input action for an existing knob, if doesn't exist create new if def_ramp |
int register_axis_handler(const coid::token& name, ot::fn_axis_action&& handler, const ot::ramp_params& ramp, int handler_id = 0, const float* def_val = nullptr, uint group = 0); |
||
Parameter Description | Returns | Description |
---|---|---|
name: Hierarchic action name handler: Optional handler for changed value handler_id: Optional extra data for the handler def_val: Optional default action value ramp: Value limiter parameters group: Activation group where the action is assigned (can be enabled/disabled together) |
return: slot id or -1 on fail | Register input action sending events on value change (full state button and axis) |
int register_event_handler(const coid::token& name, ot::fn_event_action&& handler, int handler_id = 0, uint group = 0, uint extra_channels = 0); |
||
Parameter Description | Returns | Description |
---|---|---|
name: Hierarchic action name handler: Optional handler for changed value handler_id: Optional extra data for the handler extra_channels: Number of extra channels that are handled (multiple engines etc) group: Activation group where the action is assigned (can be enabled/disabled together) |
return: slot id or -1 on fail | Register input action sending events on button press (value > 0) |
void action_group(uint group, bool activate); |
||
Parameter Description | Returns | Description |
---|---|---|
group: Group ID activate: Activate/deactivate the group |
Activate or deactivate given action group | |
void set_center_value(int action, float center); |
||
Parameter Description | Returns | Description |
action: Action ID center: Center value, will be clamped to minval..maxval range |
Set the value to center to, default 0 | |
void set_action_value(int action, float value, bool hold); |
||
Parameter Description | Returns | Description |
action: Action ID value: Action value, will be clamped to minval..maxval range hold: True if the value should be held (disabled centering) |
Set action value | |
void set_instant_action_value(int action, float value, bool notify); |
||
Parameter Description | Returns | Description |
action: Action ID value: Action value, will be clamped to minval..maxval range notify: Invoke/don't invoke the handler |
Set action value | |
uint add_spot_light(const float3& offset, const float3& dir, const ot::light_params& lp, const coid::token& joint = coid::token()); |
||
Parameter Description | Returns | Description |
---|---|---|
offset: Model-space offset relative to the bone or model pivot dir: Light direction lp: Light parameters joint: Joint name to attach the light to |
return: light emitter id | Define circular spotlight source (can be called only from within init_chassis) |
uint add_point_light(const float3& offset, const ot::light_params& lp, const coid::token& joint = coid::token()); |
||
Parameter Description | Returns | Description |
---|---|---|
offset: Model-space offset relative to the bone or model pivot lp: Light parameters joint: Joint name to attach the light to |
return: light emitter id | Define point light source (can be called only from within init_chassis) |
void light(uint id, bool on); |
||
Parameter Description | Returns | Description |
---|---|---|
id: Light ID on: Turn light on/off |
Turn light on/off | |
void light_mask(uint mask, bool on, uint offset = 0); |
||
Parameter Description | Returns | Description |
mask: Light mask on: Turn light on/off offset: Offset |
Turn light on/off using mask | |
void light_toggle(uint id); |
||
Parameter Description | Returns | Description |
id: Light ID | Toggle light | |
void light_toggle_mask(uint mask, uint offset = 0); |
||
Parameter Description | Returns | Description |
mask: Light mask offset: Offset |
Toggle lights by bit mask | |
void light_color(uint id, const float4& color, float range = 0); |
||
Parameter Description | Returns | Description |
id: Light ID color: Light color range: Light range |
Set light color/intensity | |
void lights_off(bool instant = false); |
||
Parameter Description | Returns | Description |
instant: Turn off lights instantly or not | All lights off | |
void solar_time(ifc_out double& time, ifc_out float& sun_coef) const; |
||
Parameter Description | Returns | Description |
time: Solar time at vehicle location, in milliseconds sun_coef: Sun position relative to horizon: 0 sun at horizon, 1 sun at zenith, -1 sun at anti-zenith |
Return current solar time and cosine of sun-zenith angle | |
int add_display(float width, float height, const coid::token& mesh_name); |
||
Parameter Description | Returns | Description |
width: Width of the display height: Height of the display mesh_name: Name of the display's mesh in geomob |
return: id of the display | Add new display |
iref<ot::canvas> get_display_canvas(uint display_id); |
||
Parameter Description | Returns | Description |
display_id: Display ID | return: display canvas | Get display canvas |
coid::dynarray<coid::charstr> get_display_names(); |
||
Parameter Description | Returns | Description |
return: display names | Get display names | |
uint add_smoke_emitter(const coid::token& joint, const coid::token& texture, const ot::particle_emitter_params& params); |
||
Parameter Description | Returns | Description |
---|---|---|
joint: Name of the joint emitter will be attached to texture: Relative path of the texture to use as particle billboard (must be in RGBA8 dds format) params: Emitter parameters |
return: smoke emitter id | Add smoke emitter |
uint add_dust_emitter(const coid::token& joint, const coid::token& texture); |
||
Parameter Description | Returns | Description |
---|---|---|
joint: Name of the joint emitter will be attached to texture: Relative path of the texture to use |
Add dust emitter | |
void set_emitter_color(uint emitter, ot::color color); |
||
Parameter Description | Returns | Description |
emitter: Emitter ID color: Particle color |
Set overall emitter alpha | |
void pause_emitter(uint emitter, bool pause); |
||
Parameter Description | Returns | Description |
emitter: Handle of emitter pause: Pause/resume |
Pause emitter | |
uint load_sound(const coid::token& filename); |
||
Parameter Description | Returns | Description |
filename: Sound file name | Load sound buffer | |
uint add_sound_emitter(const coid::token& joint, int type = 0, float ref_distance = 0); |
||
Parameter Description | Returns | Description |
joint: Bone name to attach to type: Sound type: -1 interior only, 0 universal, 1 exterior only ref_distance: Reference distance (saturated volume distance) |
Attach sound emitter to a model joint | |
uint add_sound_emitter_id(uint joint_id, int type = 0, float ref_distance = 0); |
||
Parameter Description | Returns | Description |
joint_id: Bone ID to attach to type: Sound type: -1 interior only, 0 universal, 1 exterior only ref_distance: Reference distance (saturated volume distance) |
Attach sound emitter to a model joint by ID | |
void set_interior_sound_attenuation(float att); |
||
Parameter Description | Returns | Description |
att: Attenuation value | Set attenuation for sounds coming from outside | |
void fetch_controls(coid::dynarray32<int32>& buf, bool append); |
||
Parameter Description | Returns | Description |
buf: Buffer to fetch controls into append: Append to existing buffer or not |
Fetch controls | |
void apply_controls(const int32* cmd, uint ncmds); |
||
Parameter Description | Returns | Description |
cmd: Commands array ncmds: Number of commands |
Apply controls | |
void open(int openid, ot::kbd_modifier modifiers); |
||
Parameter Description | Returns | Description |
openid: ID of the openable part (script specific) modifiers: Keyboard modifiers (LSHIFT=1, RSHIFT=2, LCTRL=4, RCTRL=8) |
Insert an open door command | |
coref<ot::component::animator> get_animator(); |
||
Parameter Description | Returns | Description |
return: Animator component | Get animator component | |
iref<ot::jsb> jsb(); |
||
Parameter Description | Returns | Description |
return: ot::jsb interface | Get ot::jsb interface to JSBSim instance | |
const ot::aircraft_data& get_aircraft_data() const; |
||
Parameter Description | Returns | Description |
return: Aircraft data | Get aircraft data | |
void reset_ic(); |
||
Parameter Description | Returns | Description |
Reset simulation | ||
void initialize_ic(); |
||
Parameter Description | Returns | Description |
Initialize simulation from initial conditions | ||
bool engine_running() const; |
||
Parameter Description | Returns | Description |
return: true if running | Check if engine is running | |
void activate_event_group(const coid::token& name); |
||
Parameter Description | Returns | Description |
name: Event group name | Activate event group | |
bool has_animator() const; |
||
Parameter Description | Returns | Description |
return: true if exists | Check if animator component exists | |
int get_animator_input_index(const coid::token& input_name) const; |
||
Parameter Description | Returns | Description |
input_name: Name of the input defined in animation graph | return: Input index | Get index of input by name |
float get_animator_input_float(uint input_index) const; |
||
Parameter Description | Returns | Description |
input_index: Input index | return: Float value | Get current input index value as float |
bool get_animator_input_bool(uint input_index) const; |
||
Parameter Description | Returns | Description |
input_index: Input index | return: Boolean value | Get current input index value as boolean |
int get_animator_input_int(uint input_index) const; |
||
Parameter Description | Returns | Description |
input_index: Input index | return: Integer value | Get current input index value as integer |
void set_animator_input_float(uint input_index, float value); |
||
Parameter Description | Returns | Description |
input_index: Input index value: Value to set |
Set current input index value as float | |
void set_animator_input_bool(uint input_index, bool value); |
||
Parameter Description | Returns | Description |
input_index: Input index value: Value to set |
Set current input index value as boolean | |
void set_animator_input_int(uint input_index, int value); |
||
Parameter Description | Returns | Description |
input_index: Input index value: Value to set |
Set current input index value as integer | |
virtual ot::chassis_params init_chassis( const coid::charstr& params ){ throw coid::exception(HANDLER_NOT_IMPLEMENTED_MESSAGE); } |
||
Parameter Description | Returns | Description |
---|---|---|
params: Custom parameters from objdef | return: Chassis parameters | Initialize chassis (shared across all aircraft instances of the same type) |
virtual ot::chassis_params init_chassis_script( const coid::charstr& params ) { return ot::chassis_params(); } |
||
Parameter Description | Returns | Description |
---|---|---|
params: Custom parameters from objdef | return: Chassis parameters | Initialize chassis using script (shared across all aircraft instances of the same type) |
virtual void update_actions_script( float dt, const coid::range<int32>& actbuf ) {} |
||
Parameter Description | Returns | Description |
dt: Time step for the update actbuf: Range of action buffers |
Interface event for handling aircraft state before rendering (inputs, animating joints etc) | |
virtual void engine( bool start ) {} |
||
Parameter Description | Returns | Description |
start: Flag indicating whether to start or stop the engine | Start/stop engine | |
virtual float ext_param( const coid::token& name, const float* value ){ throw coid::exception(HANDLER_NOT_IMPLEMENTED_MESSAGE); } |
||
Parameter Description | Returns | Description |
---|---|---|
name: Parameter name value: Value to set, null means requesting value |
return: New/existing param value | Set/get externally provided parameter |
virtual void initialize( bool reload ) {} |
||
Parameter Description | Returns | Description |
---|---|---|
reload: True if object is being reloaded | Interface event for initialization and script reload | |
virtual void update_frame( float dt ) {} |
||
Parameter Description | Returns | Description |
dt: Time step for the update | Interface event for handling aircraft state before rendering (inputs, animating joints etc.) | |
virtual void force_bind_script_events() {} |
||
Parameter Description | Returns | Description |
Force bind script events | ||