- SCM size = scm_from_double (10);
- SCM parent = SCM_UNDEFINED;
- SCM id = scm_from_int32 (-1);
- SCM position = scm_list_3 (scm_from_double (0),
- scm_from_double (0),
- scm_from_double (0));
- SCM rotation = scm_list_3 (scm_from_double (0),
- scm_from_double (0),
- scm_from_double (0));
- SCM scale = scm_list_3 (scm_from_double (1),
- scm_from_double (1),
- scm_from_double (1));
-
- scm_c_bind_keyword_arguments ("add-cube-scene-node!", rest, (scm_t_keyword_arguments_flags)0,
- scm_from_utf8_keyword ("size"), &size,
- scm_from_utf8_keyword ("parent"), &parent,
- scm_from_utf8_keyword ("id"), &id,
- scm_from_utf8_keyword ("position"), &position,
- scm_from_utf8_keyword ("rotation"), &rotation,
- scm_from_utf8_keyword ("scale"), &scale,
- SCM_UNDEFINED);
-
- irr::scene::ISceneManager* smgr = unwrap_scene_manager (wrapped_scene_manager);
- irr::scene::IMeshSceneNode* node =
- smgr->addCubeSceneNode (scm_to_double (size),
- parent == SCM_UNDEFINED ? 0 : unwrap_scene_node (parent),
+ SCM scm_render;
+ SCM scm_get_bounding_box;
+ SCM scm_get_material_count;
+ SCM scm_get_material;
+
+ public:
+ CustomSceneNode (scene::ISceneNode* parent,
+ scene::ISceneManager* smgr,
+ s32 id,
+ const core::vector3df& position,
+ const core::vector3df& rotation,
+ const core::vector3df& scale,
+ SCM render,
+ SCM get_bounding_box,
+ SCM get_material_count,
+ SCM get_material)
+ : scene::ISceneNode (parent, smgr, id, position, rotation, scale)
+ {
+ scm_render = render;
+ scm_get_bounding_box = get_bounding_box;
+ scm_get_material_count = get_material_count;
+ scm_get_material = get_material;
+ }
+
+ virtual void OnRegisterSceneNode ()
+ {
+ if (IsVisible)
+ {
+ SceneManager->registerNodeForRendering (this);
+ }
+ ISceneNode::OnRegisterSceneNode ();
+ }
+
+ virtual void render ()
+ {
+ scm_call_0 (scm_render);
+ }
+
+ virtual const core::aabbox3d<f32>& getBoundingBox () const
+ {
+ SCM box = scm_call_0 (scm_get_bounding_box);
+ return *((core::aabbox3d<f32>*) scm_to_pointer (box));
+ }
+
+ virtual u32 getMaterialCount () const
+ {
+ return scm_to_uint32 (scm_call_0 (scm_get_material_count));
+ }
+
+ virtual video::SMaterial& getMaterial (u32 i)
+ {
+ SCM material = scm_call_1 (scm_get_material, scm_from_uint32 (i));
+ return *((video::SMaterial*) scm_to_pointer (material));
+ }
+ };
+
+ CustomSceneNode* node =
+ new CustomSceneNode ((TParent) scm_to_pointer (parent),
+ (scene::ISceneManager*) scm_to_pointer (scene_manager),
+ scm_to_int32 (id),
+ scm_to_vector3df (position),
+ scm_to_vector3df (rotation),
+ scm_to_vector3df (scale),
+ proc_render,
+ proc_get_bounding_box,
+ proc_get_material_count,
+ proc_get_material);
+ return scm_from_pointer ((void*) node, NULL);
+}
+
+
+template <typename TParent, typename TMesh>
+SCM
+scene_ISceneManager_addOctreeSceneNode (SCM scene_manager,
+ SCM mesh,
+ SCM parent,
+ SCM id,
+ SCM minimal_polys_per_node,
+ SCM also_add_if_mesh_pointer_zero)
+{
+ scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+ scene::IMeshSceneNode* node =
+ smgr->addOctreeSceneNode ((TMesh) scm_to_pointer (mesh),
+ (TParent) scm_to_pointer (parent),
+ scm_to_int32 (id),
+ scm_to_int32 (minimal_polys_per_node),
+ scm_to_bool (also_add_if_mesh_pointer_zero));
+ return scm_from_pointer ((void*) node, NULL);
+}
+
+
+template <typename TParent>
+SCM
+scene_ISceneManager_addSphereSceneNode (SCM scene_manager,
+ SCM radius,
+ SCM poly_count,
+ SCM parent,
+ SCM id,
+ SCM position,
+ SCM rotation,
+ SCM scale)
+{
+ scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_pointer (scene_manager);
+ scene::IMeshSceneNode* node =
+ smgr->addSphereSceneNode (scm_to_double (radius),
+ scm_to_int32 (poly_count),
+ (TParent) scm_to_pointer (parent),