From: Javier Sancho Date: Wed, 5 Feb 2020 09:19:51 +0000 (+0100) Subject: Transformation X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=86e2a7367842fd005dda3b20454f370d4ebfcf2c;p=guile-irrlicht.git Transformation --- diff --git a/irrlicht/bindings/scene.scm b/irrlicht/bindings/scene.scm index 9c7eb64..cbb75a4 100644 --- a/irrlicht/bindings/scene.scm +++ b/irrlicht/bindings/scene.scm @@ -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 '* '*)) diff --git a/irrlicht/bindings/video.scm b/irrlicht/bindings/video.scm index d3f8b48..d9f92fa 100644 --- a/irrlicht/bindings/video.scm +++ b/irrlicht/bindings/video.scm @@ -133,6 +133,20 @@ (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 @@ -160,6 +174,9 @@ (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? diff --git a/irrlicht/scene.scm b/irrlicht/scene.scm index 3beff28..83eb9ba 100644 --- a/irrlicht/scene.scm +++ b/irrlicht/scene.scm @@ -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 @@ -152,6 +153,9 @@ (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))) diff --git a/irrlicht/video.scm b/irrlicht/video.scm index 1df01fe..dc61f64 100644 --- a/irrlicht/video.scm +++ b/irrlicht/video.scm @@ -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)) @@ -68,6 +70,26 @@ 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