(define gui-env (get-gui-environment device))
;; create the node which will be moved with the WSAD keys
-(define wall (add-sphere-scene-node! scene-manager))
-(set-position! wall '(0 0 30))
-(set-material-texture! wall 0 (get-texture driver "media/wall.bmp"))
-(set-material-flag! wall 'lighting #f)
+(define ball (add-sphere-scene-node! scene-manager))
+(set-position! ball '(0 0 30))
+(set-material-texture! ball 0 (get-texture driver "media/wall.bmp"))
+(set-material-flag! ball 'lighting #f)
;; create another node, movable using a scene node animator
(let ((cube (add-cube-scene-node! scene-manager))
- (anim (create-fly-circle-animator scene-manager #:center '(0 0 30))))
+ (anim (create-fly-circle-animator scene-manager #:center '(0 0 30) #:radius 20)))
(set-material-texture! cube 0 (get-texture driver "media/t351sml.jpg"))
(set-material-flag! cube 'lighting #f)
(add-animator! cube anim)
(set! then now)
;; check if W, S, A or D are pressed
- (let* ((node-position (get-position wall))
+ (let* ((node-position (get-position ball))
(pos-x (car node-position))
(pos-y (cadr node-position))
(pos-z (caddr node-position)))
(set! pos-x (- pos-x (* movement-speed frame-delta-time))))
(if (is-key-down? 'key-d)
(set! pos-x (+ pos-x (* movement-speed frame-delta-time))))
- (set-position! wall (list pos-x pos-y pos-z))))
+ (set-position! ball (list pos-x pos-y pos-z))))
(begin-scene driver #:color '(255 113 113 133))
(draw-all scene-manager)
}
else
{
- scm_error (scm_arg_type_key, NULL, "Cannot add animator flag to object: ~S",
+ scm_error (scm_arg_type_key, NULL, "Cannot add animator to object: ~S",
scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node));
}
-
return SCM_UNSPECIFIED;
}
SCM
irr_scene_getPosition (SCM wrapped_scene_node)
{
- irr::scene::ISceneNode* node = unwrap_scene_node (wrapped_scene_node, false);
- return scm_from_vector3df (node->getPosition ());
+#define GET_POSITION(NODE) scm_from_vector3df (NODE->getPosition ());
+
+ if (scene_node_p (wrapped_scene_node))
+ {
+ return GET_POSITION (unwrap_scene_node (wrapped_scene_node));
+ }
+ else if (mesh_scene_node_p (wrapped_scene_node))
+ {
+ return GET_POSITION (unwrap_mesh_scene_node (wrapped_scene_node));
+ }
+ else
+ {
+ scm_error (scm_arg_type_key, NULL, "Cannot get position from object: ~S",
+ scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node));
+ }
}
SCM
WRAP (TYPE foreign_obj); \
\
TYPE \
- UNWRAP (SCM wrapped_obj, bool assert_type = true); \
+ UNWRAP (SCM wrapped_obj); \
\
bool \
PRED (SCM wrapped_obj);
} \
\
TYPE \
- UNWRAP (SCM wrapped_obj, bool assert_type) \
+ UNWRAP (SCM wrapped_obj) \
{ \
- if (assert_type) \
- { \
- scm_assert_foreign_object_type (wrapped_##INIT, wrapped_obj); \
- } \
+ scm_assert_foreign_object_type (wrapped_##INIT, wrapped_obj); \
return (TYPE)scm_foreign_object_ref (wrapped_obj, 0); \
} \
\