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_event) (UnitRef, unsigned event_name_id32);
  73. void (*animation_trigger_event) (UnitRef unit_ref, unsigned event_name_id32, const char *optional_debug_event_name);
  74. void (*animation_trigger_event_with_parameters) (UnitRef unit_ref, unsigned event_name_id32, const char *optional_debug_event_name, struct AnimationEventParameters *parameters);
  75. unsigned (*animation_find_variable) (UnitRef, unsigned variable_name_id32, const char *optional_debug_variable_name);
  76. int (*animation_has_variable)(UnitRef unit_ref, unsigned variable_name_id32);
  77. float (*animation_get_variable) (UnitRef, unsigned index);
  78. void (*animation_set_variable) (UnitRef, unsigned index, float value);
  79. void (*animation_set_state) (UnitRef, struct AnimationStates*);
  80. struct AnimationStates (*animation_get_state) (UnitRef);
  81. void(*animation_set_seeds) (UnitRef, struct AnimationLayerSeeds*);
  82. struct AnimationLayerSeeds(*animation_get_seeds) (UnitRef);
  83. struct AnimationLayerInfo (*animation_layer_info) (UnitRef, unsigned index);
  84. void (*set_animation_merge_options) (UnitRef, float max_start_time, float max_drift, float clock_fidelity);
  85. void (*animation_set_moving)(UnitRef unit_ref, unsigned frames);
  86. int (*animation_get_curve_value)(UnitRef unit_ref, unsigned object_id32, unsigned parameter_id32, unsigned int float_index, float *out_curve_value);
  87. void (*set_animation_logging)(UnitRef unit_ref, int enable);
  88. void (*play_simple_animation)(UnitRef unit_ref, float from, float to, float speed, int loop, unsigned optional_group, const char *optional_debug_group_name);
  89. void (*stop_simple_animation)(UnitRef unit_ref, unsigned optional_group, const char *optional_debug_group_name);
  90. unsigned (*num_terrains) (UnitRef);
  91. unsigned (*find_terrain) (UnitRef, unsigned terrain_name_id32);
  92. TerrainPtr (*terrain) (UnitRef, unsigned index, const char *optional_debug_terrain_name);
  93. void (*terrain_update_height_field)(UnitRef unit_ref, void *data);
  94. JointPtr (*create_joint) (UnitRef, unsigned joint_name_id32, const char *optional_debug_joint_name);
  95. void (*destroy_joint) (UnitRef, unsigned joint_name_id32);
  96. JointPtr (*create_custom_joint) (UnitRef, unsigned joint_name_id32, ActorPtr optional_actor_1, ActorPtr optional_actor_2, ConstVector3Ptr optional_anchor_1,
  97. ConstVector3Ptr optional_anchor_2, ConstVector3Ptr optional_global_anchor, ConstVector3Ptr optional_global_axis,
  98. const char *optional_debug_joint_name);
  99. // Length of key_id32_array depenends on the path for the property
  100. void (*set_property) (UnitRef unit_ref, float value, unsigned key_id32_array[]);
  101. float (*get_property) (UnitRef unit_ref, unsigned key_id32_array[]);
  102. unsigned (*num_scene_graph_items) (UnitRef);
  103. unsigned (*find_scene_graph_parent) (UnitRef, unsigned index);
  104. void (*scene_graph_link) (UnitRef, unsigned index, unsigned parent_index);
  105. void (*scene_graph_link_to_none) (UnitRef, unsigned index);
  106. void (*copy_scene_graph_local_from) (UnitRef destination, UnitRef source);
  107. unsigned (*num_lod_objects) (UnitRef);
  108. unsigned (*find_lod_object) (UnitRef, unsigned lod_name_id32);
  109. LodObjectPtr (*lod_object) (UnitRef, unsigned index, const char *optional_debug_lod_name);
  110. unsigned (*num_steps_lod) (LodObjectPtr lod_obj_ptr);
  111. void (*lod_step_range) (LodObjectPtr lod_obj_ptr, unsigned step_index, float out_range[2]);
  112. unsigned (*num_mesh_lod_step) (LodObjectPtr lod_obj_ptr, unsigned step_index);
  113. const unsigned* (*lod_step_meshes) (LodObjectPtr lod_obj_ptr, unsigned step_index);
  114. unsigned (*num_lights) (UnitRef);
  115. unsigned (*find_light) (UnitRef, unsigned light_name_id32);
  116. LightPtr (*light) (UnitRef, unsigned index, const char *optional_debug_light_name);
  117. void (*set_light_material)(UnitRef unit_ref, LightPtr light_pointer, uint64_t material_name);
  118. VehiclePtr (*create_vehicle) (UnitRef);
  119. void (*destroy_vehicle) (UnitRef);
  120. int (*has_vehicle) (UnitRef);
  121. VehiclePtr (*vehicle) (UnitRef);
  122. void (*enable_physics) (UnitRef);
  123. void (*disable_physics) (UnitRef);
  124. void (*apply_initial_actor_velocities) (UnitRef, int should_wake_sleeping_actors);
  125. void (*set_unit_visibility) (UnitRef, int enabled);
  126. 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);
  127. 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);
  128. void (*set_visibility_group) (UnitRef, unsigned group_name_id32, int enabled, const char *optional_debug_group_name);
  129. int (*has_visibility_group) (UnitRef, unsigned group_name_id32);
  130. ClothPtr (*create_cloth) (UnitRef unit_ref, unsigned index, const char *optional_debug_cloth_name);
  131. void (*destroy_cloth) (UnitRef unit_ref, unsigned index, const char *optional_debug_cloth_name);
  132. unsigned (*num_cloths) (UnitRef unit_ref);
  133. unsigned (*find_cloth) (UnitRef unit_ref, unsigned cloth_name_id32);
  134. ClothPtr (*cloth) (UnitRef unit_ref, unsigned index, const char *optional_debug_cloth_name);
  135. unsigned (*num_cameras) (UnitRef);
  136. unsigned (*find_camera) (UnitRef, unsigned camera_name_id32);
  137. CameraPtr (*camera) (UnitRef, unsigned index, const char *optional_debug_camera_name);
  138. int (*has_node) (UnitRef, unsigned node_name_id32);
  139. unsigned (*node) (UnitRef, unsigned node_name_id32, const char *optional_debug_node_name);
  140. int (*resource_has_node)(uint64_t unit_resource_id64, unsigned node_id32, const char *optional_debug_unit_resource_name);
  141. unsigned (*resource_node)(uint64_t unit_resource_id64, unsigned node_id32, const char *optional_debug_unit_resource_name, const char *optional_debug_node_name);
  142. // Performance-warning; Fetches the local_pose, extracts a Matrix4x4 from it and returns a copy on the stack.
  143. CApiMatrix4x4 (*resource_local_pose)(uint64_t unit_resource_id64, unsigned node_index, const char *optional_debug_unit_resource_name);
  144. WorldPtr (*world) (UnitRef);
  145. LevelPtr (*level) (UnitRef);
  146. int (*is_alive) (UnitRef);
  147. uint64_t (*id_in_level) (UnitRef);
  148. int (*is_of_resource_type) (UnitRef, uint64_t resource_name);
  149. const char *(*unit_name_s)(UnitRef unit_ref);
  150. struct OOBBWrapper (*box) (UnitRef unit_ref, unsigned ignore_invisible_meshes);
  151. const char * (*debug_name)(UnitRef unit_ref);
  152. void (*name_hash)(UnitRef unit_ref, char out_name[8]);
  153. int (*is_a)(UnitRef unit_ref, uint64_t resource_id64);
  154. void (*set_id_in_level)(UnitRef unit_ref, uint64_t id);
  155. void (*draw_tree)(UnitRef unit_ref);
  156. unsigned (*mesh_raycast)(UnitRef unit_ref, ConstVector3Ptr from, ConstVector3Ptr dir, float threshold, int include_hidden_meshes,
  157. float *out_distance, CApiVector3 *out_normal_world);
  158. unsigned (*mesh_pick_raycast)(UnitRef unit_ref, ConstVector3Ptr from, ConstVector3Ptr dir, float threshold, int include_hidden_meshes,
  159. float *out_distance, CApiVector3 *out_normal_world, unsigned *out_best_mesh_index, unsigned *out_best_triangle_index);
  160. unsigned (*mesh_closest_point_raycast)(UnitRef unit_ref, ConstVector3Ptr from, ConstVector3Ptr dir, float ray_length,
  161. CApiVector3 *out_best_point_world, float *out_best_point_distance_along_ray, float *out_best_point_distance_to_ray);
  162. };
  163. #ifdef __cplusplus
  164. }
  165. #endif