solstice_c.h (4958B)
1 /* Copyright (C) 2018-2026 |Meso|Star> (contact@meso-star.com) 2 * Copyright (C) 2016-2018 CNRS 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 17 #ifndef SOLSTICE_C_H 18 #define SOLSTICE_C_H 19 20 #include "solstice.h" 21 #include "parser/solparser.h" 22 23 #include <rsys/ref_count.h> 24 #include <rsys/str.h> 25 26 #include <solstice/sanim.h> 27 28 enum solstice_node_type { 29 SOLSTICE_NODE_GEOMETRY, 30 SOLSTICE_NODE_TARGET, 31 SOLSTICE_NODE_PIVOT, 32 SOLSTICE_NODE_EMPTY, 33 SOLSTICE_NODE_TYPES_COUNT__ 34 }; 35 36 struct solstice_node { 37 struct sanim_node anim; 38 struct str name; 39 enum solstice_node_type type; 40 struct ssol_instance* instance; /* Available for geometry nodes */ 41 42 ref_T ref; 43 struct mem_allocator* allocator; 44 }; 45 46 struct ssol_instance; 47 48 extern LOCAL_SYM res_T 49 solstice_draw 50 (struct solstice* solstice); 51 52 extern LOCAL_SYM res_T 53 solstice_solve 54 (struct solstice* solstice); 55 56 extern LOCAL_SYM res_T 57 solstice_dump 58 (struct solstice* solstice); 59 60 extern LOCAL_SYM res_T 61 solstice_create_sun 62 (struct solstice* solstice); 63 64 extern LOCAL_SYM res_T 65 solstice_create_atmosphere 66 (struct solstice* solstice); 67 68 extern LOCAL_SYM res_T 69 solstice_setup_entities 70 (struct solstice* solstice); 71 72 extern LOCAL_SYM res_T 73 solstice_update_entities 74 (struct solstice* solstice, 75 const double sun_dir[3]); 76 77 extern LOCAL_SYM res_T 78 solstice_create_ssol_spectrum 79 (struct solstice* solstice, 80 const struct solparser_spectrum_id spectrum_id, 81 struct ssol_spectrum** spectrum); 82 83 extern LOCAL_SYM res_T 84 solstice_create_scaled_ssol_spectrum 85 (struct solstice* solstice, 86 const struct solparser_spectrum_id spectrum_id, 87 const double scale_factor, /* Scale factor applied to the spectrum data */ 88 struct ssol_spectrum** spectrum); 89 90 extern LOCAL_SYM res_T 91 mtl_to_ssol_data 92 (struct solstice* solstice, 93 const struct solparser_mtl_data* mtl_data, 94 struct ssol_data* data); 95 96 extern LOCAL_SYM res_T 97 scaled_mtl_to_ssol_data 98 (struct solstice* solstice, 99 const struct solparser_mtl_data* mtl_data, 100 const double scale_factor, 101 struct ssol_data* data); 102 103 extern LOCAL_SYM res_T 104 solstice_create_ssol_material 105 (struct solstice* solstice, 106 const struct solparser_material_id mtl_id, 107 struct ssol_material** mtl); 108 109 extern LOCAL_SYM res_T 110 solstice_instantiate_geometry 111 (struct solstice* solstice, 112 const struct solparser_geometry_id geom_id, 113 struct ssol_instance** inst); 114 115 extern LOCAL_SYM res_T 116 solstice_node_geometry_create 117 (struct mem_allocator* allocator, 118 struct ssol_instance* instance, 119 struct solstice_node** node); 120 121 extern LOCAL_SYM res_T 122 solstice_node_empty_create 123 (struct mem_allocator* allocator, 124 struct solstice_node** node); 125 126 extern LOCAL_SYM res_T 127 solstice_node_pivot_create 128 (struct mem_allocator* allocator, 129 const struct sanim_pivot* pivot, 130 const struct sanim_tracking* tracking, 131 struct solstice_node** node); 132 133 extern LOCAL_SYM res_T 134 solstice_node_target_create 135 (struct mem_allocator* allocator, 136 struct solstice_node** node); 137 138 extern LOCAL_SYM void 139 solstice_node_ref_get 140 (struct solstice_node* node); 141 142 extern LOCAL_SYM void 143 solstice_node_ref_put 144 (struct solstice_node* node); 145 146 extern LOCAL_SYM res_T 147 solstice_node_set_name 148 (struct solstice_node* node, 149 const char* name); 150 151 extern LOCAL_SYM const char* 152 solstice_node_get_name 153 (const struct solstice_node* node); 154 155 extern LOCAL_SYM res_T 156 solstice_node_geometry_set_primary 157 (struct solstice_node* node, 158 const int is_primary); 159 160 extern LOCAL_SYM res_T 161 solstice_node_geometry_set_receiver 162 (struct solstice_node* node, 163 const int mask, /* Combination of ssol_side_flag */ 164 const int per_primitive); /* Enable the per primitive integration */ 165 166 extern LOCAL_SYM void 167 solstice_node_target_get_tracking 168 (const struct solstice_node* node, 169 struct sanim_tracking* tracking); 170 171 extern LOCAL_SYM res_T 172 solstice_node_add_child 173 (struct solstice_node* node, 174 struct solstice_node* child); 175 176 static INLINE void 177 solstice_node_set_translation 178 (struct solstice_node* node, 179 const double translation[3]) 180 { 181 ASSERT(node && translation); 182 SANIM(node_set_translation(&node->anim, translation)); 183 } 184 185 static INLINE void 186 solstice_node_set_rotations 187 (struct solstice_node* node, 188 const double rotations[3]) /* In radians */ 189 { 190 ASSERT(node && rotations && node->type != SOLSTICE_NODE_TARGET); 191 SANIM(node_set_rotations(&node->anim, rotations)); 192 } 193 194 #endif /* SOLSTICE_C_H */ 195