]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
set-rotation! set-scale!
authorJavier Sancho <jsf@jsancho.org>
Sat, 11 Apr 2020 11:28:05 +0000 (13:28 +0200)
committerJavier Sancho <jsf@jsancho.org>
Sat, 11 Apr 2020 11:28:05 +0000 (13:28 +0200)
src/scene-node.cpp
src/scene-node.h

index 31109eae09e65d6d39dd616d8ac4b8ae5d431a6c..50d402b3866031277d9fab2edf9ca143dde2b3a1 100644 (file)
@@ -23,6 +23,7 @@
 #include <libguile.h>
 
 #include "animated-mesh-scene-node.h"
+#include "camera-scene-node.h"
 #include "gsubr.h"
 #include "material-flags.h"
 #include "matrix4.h"
@@ -42,6 +43,8 @@ extern "C" {
     DEFINE_GSUBR ("add-animator!", 2, 0, 0, irr_scene_addAnimator);
     DEFINE_GSUBR ("get-absolute-transformation", 1, 0, 0, irr_scene_getAbsoluteTransformation);
     DEFINE_GSUBR ("set-material-texture!", 3, 0, 0, irr_scene_setMaterialTexture);
+    DEFINE_GSUBR ("set-rotation!", 2, 0, 0, irr_scene_setRotation);
+    DEFINE_GSUBR ("set-scale!", 2, 0, 0, irr_scene_setScale);
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::ISceneNode*, "scene-node",
@@ -163,4 +166,54 @@ extern "C" {
     return SCM_UNSPECIFIED;
   }
 
+  SCM
+  irr_scene_setRotation (SCM wrapped_scene_node,
+                         SCM rotation)
+  {
+#define SET_ROTATION(NODE) NODE->setRotation (scm_to_vector3df (rotation));
+
+    if (animated_mesh_scene_node_p (wrapped_scene_node))
+      {
+        SET_ROTATION (unwrap_animated_mesh_scene_node (wrapped_scene_node));
+      }
+    else if (camera_scene_node_p (wrapped_scene_node))
+      {
+        SET_ROTATION (unwrap_camera_scene_node (wrapped_scene_node));
+      }
+    else if (scene_node_p (wrapped_scene_node))
+      {
+        SET_ROTATION (unwrap_scene_node (wrapped_scene_node));
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot set rotation to object: ~S",
+                   scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node));
+      }
+
+    return SCM_UNSPECIFIED;
+  }
+
+  SCM
+  irr_scene_setScale (SCM wrapped_scene_node,
+                      SCM scale)
+  {
+#define SET_SCALE(NODE) NODE->setScale (scm_to_vector3df (scale));
+
+    if (animated_mesh_scene_node_p (wrapped_scene_node))
+      {
+        SET_SCALE (unwrap_animated_mesh_scene_node (wrapped_scene_node));
+      }
+    else if (scene_node_p (wrapped_scene_node))
+      {
+        SET_SCALE (unwrap_scene_node (wrapped_scene_node));
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot set scale to object: ~S",
+                   scm_list_1 (wrapped_scene_node), scm_list_1 (wrapped_scene_node));
+      }
+
+    return SCM_UNSPECIFIED;
+  }
+
 }
index 3246b8b45d09a5e67bc606f0da34e1e70d40beea..038601f4f7ca71ad8b27e4b0cee255a5f0deef5d 100644 (file)
@@ -55,6 +55,14 @@ extern "C" {
   irr_scene_setPosition (SCM wrapped_scene_node,
                          SCM position);
 
+  SCM
+  irr_scene_setRotation (SCM wrapped_scene_node,
+                         SCM rotation);
+
+  SCM
+  irr_scene_setScale (SCM wrapped_scene_node,
+                      SCM scale);
+
 }
 
 #endif