175 * |
180 * |
176 * @param node the node to unlink |
181 * @param node the node to unlink |
177 */ |
182 */ |
178 void asc_scene_node_unlink(AscSceneNode *node); |
183 void asc_scene_node_unlink(AscSceneNode *node); |
179 |
184 |
180 void asc_node_update(AscSceneNode *node); |
185 void asc_scene_node_update(AscSceneNode *node); |
181 |
186 |
182 void asc_node_update_transform(AscSceneNode *node); |
187 void asc_scene_node_update_transform(AscSceneNode *node); |
183 |
188 |
|
189 void asc_scene_node_allocate_data(AscSceneNode *node, size_t n); |
184 |
190 |
185 /** |
191 /** |
186 * This is the z-position a simple 2D element should have to allow |
192 * This is the z-position a simple 2D element should have to allow |
187 * stacking 2D elements with depth-test. |
193 * stacking 2D elements with depth-test. |
188 */ |
194 */ |
189 #define ASC_SCENE_2D_DEPTH_OFFSET 0.0078125f |
195 #define ASC_SCENE_2D_DEPTH_OFFSET 0.0078125f |
190 |
196 |
191 static inline void asc_node_set_position(AscSceneNode *node, asc_vec3f position) { |
197 static inline void asc_scene_node_set_position(AscSceneNode *node, asc_vec3f position) { |
192 node->position = position; |
198 node->position = position; |
193 asc_node_update_transform(node); |
199 asc_scene_node_update_transform(node); |
194 } |
200 } |
195 |
201 |
196 static inline void asc_node_set_scale(AscSceneNode *node, asc_vec3f scale) { |
202 static inline void asc_scene_node_move(AscSceneNode *node, asc_vec3f offset) { |
|
203 node->position.x += offset.x; |
|
204 node->position.y += offset.y; |
|
205 node->position.z += offset.z; |
|
206 asc_scene_node_update_transform(node); |
|
207 } |
|
208 |
|
209 static inline void asc_scene_node_set_scale(AscSceneNode *node, asc_vec3f scale) { |
197 node->scale = scale; |
210 node->scale = scale; |
198 asc_node_update_transform(node); |
211 asc_scene_node_update_transform(node); |
199 } |
212 } |
200 |
213 |
201 static inline void asc_node_set_origin(AscSceneNode *node, asc_vec3f origin) { |
214 static inline void asc_scene_node_set_origin(AscSceneNode *node, asc_vec3f origin) { |
202 node->origin = origin; |
215 node->origin = origin; |
203 asc_node_update_transform(node); |
216 asc_scene_node_update_transform(node); |
204 } |
217 } |
205 |
218 |
206 static inline void asc_node_set_position2f(AscSceneNode *node, asc_vec2f position) { |
219 static inline void asc_scene_node_set_position2f(AscSceneNode *node, asc_vec2f position) { |
207 node->position.x = position.x; |
220 node->position.x = position.x; |
208 node->position.y = position.y; |
221 node->position.y = position.y; |
209 asc_node_update_transform(node); |
222 asc_scene_node_update_transform(node); |
210 } |
223 } |
211 |
224 |
212 static inline void asc_node_set_scale2f(AscSceneNode *node, asc_vec2f scale) { |
225 static inline void asc_scene_node_move2f(AscSceneNode *node, asc_vec2f offset) { |
|
226 node->position.x += offset.x; |
|
227 node->position.y += offset.y; |
|
228 asc_scene_node_update_transform(node); |
|
229 } |
|
230 |
|
231 static inline void asc_scene_node_set_scale2f(AscSceneNode *node, asc_vec2f scale) { |
213 node->scale.width = scale.width; |
232 node->scale.width = scale.width; |
214 node->scale.height = scale.height; |
233 node->scale.height = scale.height; |
215 asc_node_update_transform(node); |
234 asc_scene_node_update_transform(node); |
216 } |
235 } |
217 |
236 |
218 static inline void asc_node_set_origin2f(AscSceneNode *node, asc_vec2f origin) { |
237 static inline void asc_scene_node_set_origin2f(AscSceneNode *node, asc_vec2f origin) { |
219 node->origin.x = origin.x; |
238 node->origin.x = origin.x; |
220 node->origin.y = origin.y; |
239 node->origin.y = origin.y; |
221 asc_node_update_transform(node); |
240 asc_scene_node_update_transform(node); |
222 } |
241 } |
223 |
242 |
224 static inline void asc_node_set_rotation(AscSceneNode *node, asc_transform rotation) { |
243 static inline void asc_scene_node_set_rotation(AscSceneNode *node, asc_transform rotation) { |
225 memcpy(node->rotation, rotation, ASC_TRANSFORM_SIZE); |
244 memcpy(node->rotation, rotation, ASC_TRANSFORM_SIZE); |
226 asc_node_update_transform(node); |
245 asc_scene_node_update_transform(node); |
227 } |
246 } |
228 |
247 |
229 static inline void asc_node_roll_deg(AscSceneNode *node, float angle) { |
248 static inline void asc_scene_node_roll_deg(AscSceneNode *node, float angle) { |
230 asc_transform r, d; |
249 asc_transform r, d; |
231 asc_transform_roll(r, asc_rad(angle)); |
250 asc_transform_roll(r, asc_rad(angle)); |
232 asc_transform_apply(d, r, node->rotation); |
251 asc_transform_apply(d, r, node->rotation); |
233 asc_transform_copy(node->rotation, d); |
252 asc_transform_copy(node->rotation, d); |
234 asc_node_update_transform(node); |
253 asc_scene_node_update_transform(node); |
235 } |
254 } |
236 |
255 |
237 #endif |
256 #endif |