c_api_unit.h - Engine C API Reference

c_api_unit.h
  1. #pragma once
  2. #include "c_api_types.h"
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. struct UnitCApi
  7. {
  8. ConstVector3Ptr (*local_position) (UnitRef, unsigned index);
  9. CApiQuaternion (*local_rotation) (UnitRef, unsigned index);
  10. ConstVector3Ptr (*local_scale) (UnitRef, unsigned index);
  11. ConstLocalTransformPtr (*local_pose) (UnitRef, unsigned index);
  12. void (*set_local_position) (UnitRef, unsigned index, ConstVector3Ptr);
  13. void (*set_local_rotation) (UnitRef, unsigned index, ConstQuaternionPtr);
  14. void (*set_local_scale) (UnitRef, unsigned index, ConstVector3Ptr);
  15. void (*set_local_pose) (UnitRef, unsigned index, ConstLocalTransformPtr);
  16. ConstVector3Ptr (*world_position) (UnitRef, unsigned index);
  17. ConstMatrix4x4Ptr (*world_pose) (UnitRef, unsigned index);
  18. // Performance-warning; Fetches the world_pose, extracts a Matrix3x3 from it and returns a copy on the stack.
  19. CApiQuaternion (*world_rotation) (UnitRef, unsigned index);
  20. void (*teleport_local_position) (UnitRef, unsigned index, ConstVector3Ptr);
  21. void (*teleport_local_rotation) (UnitRef, unsigned index, ConstQuaternionPtr);
  22. void (*teleport_local_scale) (UnitRef, unsigned index, ConstVector3Ptr);
  23. void (*teleport_local_pose) (UnitRef, unsigned index, ConstLocalTransformPtr);
  24. CApiVector3 (*delta_position) (UnitRef, unsigned index);
  25. CApiQuaternion (*delta_rotation) (UnitRef, unsigned index);
  26. struct CApiMatrix4x4 (*delta_pose) (UnitRef, unsigned index);
  27. ActorPtr (*create_actor) (UnitRef, unsigned index, float inherit_velocity, const char* optional_debug_actor_name);
  28. void (*destroy_actor) (UnitRef, unsigned index, const char* optional_debug_actor_name);
  29. unsigned (*num_actors) (UnitRef);
  30. unsigned (*find_actor) (UnitRef, unsigned actor_name_id32, const char* optional_debug_actor_name);
  31. ActorPtr (*actor) (UnitRef, unsigned index, const char* optional_debug_actor_name);
  32. unsigned (*num_movers) (UnitRef);
  33. unsigned (*find_mover) (UnitRef, unsigned mover_name_id32);
  34. MoverPtr (*set_mover) (UnitRef, unsigned index, const char *optional_debug_mover_name);
  35. void (*set_mover_to_none) (UnitRef);
  36. MoverPtr (*mover) (UnitRef);
  37. struct MoverFitsAtResult (*mover_fits_at) (UnitRef unit_ref, unsigned index, ConstVector3Ptr position, float permitted_move_threshold, const char *optional_debug_mover_name);
  38. void (*trigger_flow_event) (UnitRef, unsigned event_name_id32);
  39. void* (*flow_variable) (UnitRef unit_ref, unsigned variable_name_id32, unsigned *out_type);
  40. void (*set_flow_variable) (UnitRef, unsigned variable_name_id32, void* value);
  41. void (*trigger_unit_spawned)(UnitRef unit_ref);
  42. uint64_t (*set_material) (UnitRef, unsigned slot_name_id32, uint64_t material_resource_name_id64, const char *optional_debug_material_resource_name, unsigned debug_suppress_slot_assignment_warning);
  43. uint64_t (*set_material_to_none) (UnitRef, unsigned slot_name_id32);
  44. unsigned (*query_material)(UnitRef unit_ref, ConstVector3Ptr start, ConstVector3Ptr end, unsigned context_count, unsigned context_id32s[], unsigned out_material[]);
  45. MaterialDataPtr (*save_instance_material_data)(UnitRef unit_ref);
  46. void (*restore_instance_material_data)(UnitRef unit_ref, MaterialDataPtr data);
  47. int (*is_using_material_set)(UnitRef unit_ref);
  48. unsigned (*num_meshes) (UnitRef);
  49. unsigned (*find_mesh) (UnitRef, unsigned mesh_name_id32);
  50. MeshPtr (*mesh) (UnitRef, unsigned index, const char *optional_debug_mesh_name);
  51. struct BoneNamesWrapper (*bones) (UnitRef);
  52. CApiMatrix4x4 (*animation_wanted_root_pose) (UnitRef);
  53. void (*animation_set_bones_lod) (UnitRef, unsigned);
  54. enum AnimationBoneRootMode (*animation_root_mode) (UnitRef);
  55. enum AnimationBoneRootMode (*animation_bone_mode) (UnitRef);
  56. void (*set_animation_root_mode) (UnitRef, enum AnimationBoneRootMode);
  57. void (*set_animation_bone_mode) (UnitRef, enum AnimationBoneRootMode);
  58. unsigned (*animation_find_constraint_target) (UnitRef unit_ref, unsigned constraint_target_name_id32, const char *optional_debug_target_name);
  59. unsigned (*animation_has_constraint_target)(UnitRef unit_ref, unsigned constraint_target_name_id32);
  60. ConstMatrix4x4Ptr (*animation_get_constraint_target) (UnitRef, unsigned index);
  61. void (*animation_set_constraint_target_pose) (UnitRef, unsigned index, ConstMatrix4x4Ptr);
  62. void (*animation_set_constraint_target_position) (UnitRef, unsigned index, ConstVector3Ptr);
  63. void (*animation_set_constraint_target_rotation) (UnitRef, unsigned index, ConstQuaternionPtr);
  64. unsigned (*crossfade_animation) (UnitRef, uint64_t animation_name_id64, const char *optional_debug_animation_name, unsigned layer, float blend_time, int should_loop, enum AnimationBlendType);
  65. unsigned (*is_crossfading_animation) (UnitRef);
  66. void (*crossfade_animation_set_time) (UnitRef, unsigned id, float time, int should_cap_to_range);
  67. void (*crossfade_animation_set_speed) (UnitRef, unsigned id, float speed);
  68. void (*disable_animation_state_machine) (UnitRef);
  69. void (*enable_animation_state_machine) (UnitRef);
  70. void (*set_animation_state_machine) (UnitRef, uint64_t machine_name_id64, const char *optional_debug_machine_name);
  71. int (*has_animation_state_machine) (UnitRef);
  72. int (*has_animation_blender) (UnitRef);
  73. int (*has_animation_event) (UnitRef, unsigned event_name_id32);
  74. void (*animation_trigger_event) (UnitRef unit_ref, unsigned event_name_id32, const char *optional_debug_event_name);
  75. void (*animation_trigger_event_with_parameters) (UnitRef unit_ref, unsigned event_name_id32, const char *optional_debug_event_name, struct AnimationEventParameters *parameters);
  76. unsigned (*animation_find_variable) (UnitRef, unsigned variable_name_id32, const char *optional_debug_variable_name);
  77. int (*animation_has_variable)(UnitRef unit_ref, unsigned variable_name_id32);
  78. float (*animation_get_variable) (UnitRef, unsigned index);
  79. void (*animation_set_variable) (UnitRef, unsigned index, float value);
  80. void (*animation_set_state) (UnitRef, struct AnimationStates*);
  81. struct AnimationStates (*animation_get_state) (UnitRef);
  82. void(*animation_set_seeds) (UnitRef, struct AnimationLayerSeeds*);
  83. struct AnimationLayerSeeds(*animation_get_seeds) (UnitRef);
  84. struct AnimationLayerInfo (*animation_layer_info) (UnitRef, unsigned index);
  85. void (*set_animation_merge_options) (UnitRef, float max_start_time, float max_drift, float clock_fidelity);
  86. void (*animation_set_moving)(UnitRef unit_ref, unsigned frames);
  87. int (*animation_get_curve_value)(UnitRef unit_ref, unsigned object_id32, unsigned parameter_id32, unsigned int float_index, float *out_curve_value);
  88. void (*set_animation_logging)(UnitRef unit_ref, int enable);
  89. void (*play_simple_animation)(UnitRef unit_ref, float from, float to, float speed, int loop, unsigned optional_group, const char *optional_debug_group_name);
  90. void (*stop_simple_animation)(UnitRef unit_ref, unsigned optional_group, const char *optional_debug_group_name);
  91. unsigned (*num_terrains) (UnitRef);
  92. unsigned (*find_terrain) (UnitRef, unsigned terrain_name_id32);
  93. TerrainPtr (*terrain) (UnitRef, unsigned index, const char *optional_debug_terrain_name);
  94. void (*terrain_update_height_field)(UnitRef unit_ref, void *data);
  95. JointPtr (*create_joint) (UnitRef, unsigned joint_name_id32, const char *optional_debug_joint_name);
  96. void (*destroy_joint) (UnitRef, unsigned joint_name_id32);
  97. JointPtr (*create_custom_joint) (UnitRef, unsigned joint_name_id32, ActorPtr optional_actor_1, ActorPtr optional_actor_2, ConstVector3Ptr optional_anchor_1,
  98. ConstVector3Ptr optional_anchor_2, ConstVector3Ptr optional_global_anchor, ConstVector3Ptr optional_global_axis,
  99. const char *optional_debug_joint_name);
  100. // Length of key_id32_array depenends on the path for the property
  101. void (*set_property) (UnitRef unit_ref, float value, unsigned key_id32_array[]);
  102. float (*get_property) (UnitRef unit_ref, unsigned key_id32_array[]);
  103. unsigned (*num_scene_graph_items) (UnitRef);
  104. unsigned (*find_scene_graph_parent) (UnitRef, unsigned index);
  105. void (*scene_graph_link) (UnitRef, unsigned index, unsigned parent_index);
  106. void (*scene_graph_link_to_none) (UnitRef, unsigned index);
  107. void (*copy_scene_graph_local_from) (UnitRef destination, UnitRef source);
  108. unsigned (*num_lod_objects) (UnitRef);
  109. unsigned (*find_lod_object) (UnitRef, unsigned lod_name_id32);
  110. LodObjectPtr (*lod_object) (UnitRef, unsigned index, const char *optional_debug_lod_name);
  111. unsigned (*num_steps_lod) (LodObjectPtr lod_obj_ptr);
  112. void (*lod_step_range) (LodObjectPtr lod_obj_ptr, unsigned step_index, float out_range[2]);
  113. unsigned (*num_mesh_lod_step) (LodObjectPtr lod_obj_ptr, unsigned step_index);
  114. const unsigned* (*lod_step_meshes) (LodObjectPtr lod_obj_ptr, unsigned step_index);
  115. unsigned (*num_lights) (UnitRef);
  116. unsigned (*find_light) (UnitRef, unsigned light_name_id32);
  117. LightPtr (*light) (UnitRef, unsigned index, const char *optional_debug_light_name);
  118. void (*set_light_material)(UnitRef unit_ref, LightPtr light_pointer, uint64_t material_name);
  119. VehiclePtr (*create_vehicle) (UnitRef);
  120. void (*destroy_vehicle) (UnitRef);
  121. int (*has_vehicle) (UnitRef);
  122. VehiclePtr (*vehicle) (UnitRef);
  123. void (*enable_physics) (UnitRef);
  124. void (*disable_physics) (UnitRef);
  125. void (*apply_initial_actor_velocities) (UnitRef, int should_wake_sleeping_actors);
  126. void (*set_unit_visibility) (UnitRef, int enabled);
  127. void (*set_mesh_visibility) (UnitRef unit_ref, unsigned index, unsigned visbility_context_id32, int enabled, const char *optional_debug_mesh_name, const char *optional_debug_visbility_context_name);
  128. void (*set_cloth_visibility) (UnitRef unit_ref, unsigned index, unsigned state, unsigned visbility_context_id32, const char *optional_debug_cloth_name, const char *optional_debug_visbility_context_name);
  129. void (*set_visibility_group) (UnitRef, unsigned group_name_id32, int enabled, const char *optional_debug_group_name);
  130. int (*has_visibility_group) (UnitRef, unsigned group_name_id32);
  131. ClothPtr (*create_cloth) (UnitRef unit_ref, unsigned index, const char *optional_debug_cloth_name);
  132. void (*destroy_cloth) (UnitRef unit_ref, unsigned index, const char *optional_debug_cloth_name);
  133. unsigned (*num_cloths) (UnitRef unit_ref);
  134. unsigned (*find_cloth) (UnitRef unit_ref, unsigned cloth_name_id32);
  135. ClothPtr (*cloth) (UnitRef unit_ref, unsigned index, const char *optional_debug_cloth_name);
  136. unsigned (*num_cameras) (UnitRef);
  137. unsigned (*find_camera) (UnitRef, unsigned camera_name_id32);
  138. CameraPtr (*camera) (UnitRef, unsigned index, const char *optional_debug_camera_name);
  139. int (*has_node) (UnitRef, unsigned node_name_id32);
  140. unsigned (*node) (UnitRef, unsigned node_name_id32, const char *optional_debug_node_name);
  141. int (*resource_has_node)(uint64_t unit_resource_id64, unsigned node_id32, const char *optional_debug_unit_resource_name);
  142. unsigned (*resource_node)(uint64_t unit_resource_id64, unsigned node_id32, const char *optional_debug_unit_resource_name, const char *optional_debug_node_name);
  143. // Performance-warning; Fetches the local_pose, extracts a Matrix4x4 from it and returns a copy on the stack.
  144. CApiMatrix4x4 (*resource_local_pose)(uint64_t unit_resource_id64, unsigned node_index, const char *optional_debug_unit_resource_name);
  145. WorldPtr (*world) (UnitRef);
  146. LevelPtr (*level) (UnitRef);
  147. int (*is_alive) (UnitRef);
  148. uint64_t (*id_in_level) (UnitRef);
  149. int (*is_of_resource_type) (UnitRef, uint64_t resource_name);
  150. const char *(*unit_name_s)(UnitRef unit_ref);
  151. struct OOBBWrapper (*box) (UnitRef unit_ref, unsigned ignore_invisible_meshes);
  152. const char * (*debug_name)(UnitRef unit_ref);
  153. void (*name_hash)(UnitRef unit_ref, char out_name[8]);
  154. int (*is_a)(UnitRef unit_ref, uint64_t resource_id64);
  155. void (*set_id_in_level)(UnitRef unit_ref, uint64_t id);
  156. void (*draw_tree)(UnitRef unit_ref);
  157. unsigned (*mesh_raycast)(UnitRef unit_ref, ConstVector3Ptr from, ConstVector3Ptr dir, float threshold, int include_hidden_meshes,
  158. float *out_distance, CApiVector3 *out_normal_world);
  159. unsigned (*mesh_pick_raycast)(UnitRef unit_ref, ConstVector3Ptr from, ConstVector3Ptr dir, float threshold, int include_hidden_meshes,
  160. float *out_distance, CApiVector3 *out_normal_world, unsigned *out_best_mesh_index, unsigned *out_best_triangle_index);
  161. unsigned (*mesh_closest_point_raycast)(UnitRef unit_ref, ConstVector3Ptr from, ConstVector3Ptr dir, float ray_length,
  162. CApiVector3 *out_best_point_world, float *out_best_point_distance_along_ray, float *out_best_point_distance_to_ray);
  163. };
  164. #ifdef __cplusplus
  165. }
  166. #endif