]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
Transformation
authorJavier Sancho <jsf@jsancho.org>
Wed, 5 Feb 2020 09:19:51 +0000 (10:19 +0100)
committerJavier Sancho <jsf@jsancho.org>
Wed, 5 Feb 2020 09:19:51 +0000 (10:19 +0100)
irrlicht/bindings/scene.scm
irrlicht/bindings/video.scm
irrlicht/scene.scm
irrlicht/video.scm

index 9c7eb64f2e96f742209fe3010fb1013d04d8cf1c..cbb75a4d516f9b83cea4e0a668e70593ca0d8349 100644 (file)
@@ -71,6 +71,9 @@
 (define-foreign draw-all
   void "irr_scene_drawAll" (list '*))
 
+(define-foreign get-absolute-transformation
+  '* "irr_scene_getAbsoluteTransformation" (list '*))
+
 (define-foreign get-mesh
   '* "irr_scene_getMesh" (list '* '*))
 
index d3f8b48118fe9788bb82ba231ec0d59d3afad599..d9f92fae0efa58bb93e99deea07978f8bd0d70d5 100644 (file)
 (define-public EMT_ONETEXTURE_BLEND                       23)
 (define-public EMT_FORCE_32BIT                    #x7fffffff)
 
+;; irr_video_E_TRANSFORMATION_STATE enum
+(define-public ETS_VIEW        0)
+(define-public ETS_WORLD       1)
+(define-public ETS_PROJECTION  2)
+(define-public ETS_TEXTURE_0   3)
+(define-public ETS_TEXTURE_1   4)
+(define-public ETS_TEXTURE_2   5)
+(define-public ETS_TEXTURE_3   6)
+(define-public ETS_TEXTURE_4   7)
+(define-public ETS_TEXTURE_5   8)
+(define-public ETS_TEXTURE_6   9)
+(define-public ETS_TEXTURE_7  10)
+(define-public ETS_COUNT      11)
+
 
 ;; scolor struct
 (define-public scolor
 (define-foreign set-material
   void "irr_video_setMaterial" (list '* '*))
 
+(define-foreign set-transform
+  void "irr_video_setTransform" (list '* int '*))
+
 ;; s3dvertex struct
 (define-wrapped-pointer-type s3dvertex-type
   s3dvertex?
index 3beff2806652fd37602e1bf16370eb03cd93bae9..83eb9ba9a4b0a5a02623268628813a3c86e4b9fa 100644 (file)
@@ -32,6 +32,7 @@
             add-custom-scene-node!
             add-octree-scene-node
             create-rotation-animator
+            get-absolute-transformation
             get-mesh
             get-root-scene-node
             scene-draw-all
                    (ffi-core:vector3df->pointer rotation-speed))))
     (if (null-pointer? animator) #f animator)))
 
+(define (get-absolute-transformation node)
+  (ffi-scene:get-absolute-transformation node))
+
 (define (get-mesh scene-manager filename)
   (let ((mesh (ffi-scene:get-mesh scene-manager (string->pointer filename))))
     (if (null-pointer? mesh) #f mesh)))
index 1df01fe47a04d9bd251f77455fafaa90d808893c..dc61f644279cb1e90e18e4c45fc2a42065d697b2 100644 (file)
@@ -19,6 +19,7 @@
 
 
 (define-module (irrlicht video)
+  #:use-module (ice-9 match)
   #:use-module (system foreign)
   #:use-module ((irrlicht bindings core) #:prefix ffi-core:)
   #:use-module ((irrlicht bindings video) #:prefix ffi-video:)
@@ -30,6 +31,7 @@
             get-texture
             get-video-driver-name
             set-material!
+            set-transform!
             make-s3dvertex
             vertex-position
             make-material))
    driver
    (ffi-video:smaterial->pointer material)))
 
+(define (set-transform! driver state mat)
+  (let ((transform-state
+         (match state
+                ('view ffi-video:ETS_VIEW)
+                ('world ffi-video:ETS_WORLD)
+                ('projection ffi-video:ETS_PROJECTION)
+                ('texture0 ffi-video:ETS_TEXTURE_0)
+                ('texture1 ffi-video:ETS_TEXTURE_1)
+                ('texture2 ffi-video:ETS_TEXTURE_2)
+                ('texture3 ffi-video:ETS_TEXTURE_3)
+                ('texture4 ffi-video:ETS_TEXTURE_4)
+                ('texture5 ffi-video:ETS_TEXTURE_5)
+                ('texture6 ffi-video:ETS_TEXTURE_6)
+                ('texture7 ffi-video:ETS_TEXTURE_7)
+                ('count ffi-video:ETS_COUNT))))
+    (ffi-video:set-transform
+     driver
+     transform-state
+     mat)))
+
 ;; s3d vertices
 (define (make-s3dvertex position normal color t-coords)
   (ffi-video:pointer->s3dvertex