From: Javier Sancho Date: Tue, 3 Dec 2019 09:24:38 +0000 (+0100) Subject: Appropiate method bindings X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=340d6bc2e11c89f4ae048d37a080a1cf371f47e6;p=guile-irrlicht.git Appropiate method bindings --- diff --git a/examples/01.HelloWorld.scm b/examples/01.HelloWorld.scm index ea5c5be..3f128cb 100644 --- a/examples/01.HelloWorld.scm +++ b/examples/01.HelloWorld.scm @@ -53,12 +53,12 @@ (define node (add-animated-mesh-scene-node scene-manager mesh)) (when node - (set-material-flag-am! node 'lighting #f) + (set-material-flag! node 'lighting #f) (set-md2-animation! node 'stand) - (set-material-texture-am! node 0 (get-texture driver "media/sydney.bmp"))) + (set-material-texture! node 0 (get-texture driver "media/sydney.bmp"))) ;; place camera -(add-camera-scene-node scene-manager #:position '(0 30 -40) #:lookat '(0 5 0)) +(add-camera-scene-node! scene-manager #:position '(0 30 -40) #:lookat '(0 5 0)) ;; draw everything (while (device-run? device) diff --git a/examples/02.Quake3Map.scm b/examples/02.Quake3Map.scm index a3b897b..45249ac 100644 --- a/examples/02.Quake3Map.scm +++ b/examples/02.Quake3Map.scm @@ -18,8 +18,8 @@ ;;; . -;;; Irrlicht 01.HelloWorld example -;;; http://irrlicht.sourceforge.net/docu/example001.html +;;; Irrlicht 02.Quake3Map example +;;; http://irrlicht.sourceforge.net/docu/example002.html (use-modules (irrlicht) @@ -65,7 +65,7 @@ (add-file-archive! (get-file-system device) "media/map-20kdm2.pk3") (define mesh (get-mesh scene-manager "20kdm2.bsp")) -(define node (add-octree-scene-node-am +(define node (add-octree-scene-node scene-manager mesh #:minimal-polys-per-node 1024)) (set-position! node '(-1300 -144 -1249)) diff --git a/irrlicht/bindings/scene.scm b/irrlicht/bindings/scene.scm index 63dc24c..6a54f18 100644 --- a/irrlicht/bindings/scene.scm +++ b/irrlicht/bindings/scene.scm @@ -56,8 +56,11 @@ (define-foreign add-camera-scene-node-fps '* "irr_scene_addCameraSceneNodeFPS" (list '* '* float float int '* int int float int int)) -(define-foreign add-octree-scene-node-am - '* "irr_scene_addOctreeSceneNodeAM" (list '* '* '* int int int)) +(define-foreign add-custom-scene-node + '* "irr_scene_addCustomSceneNode" (list '* '* int '*)) + +(define-foreign add-octree-scene-node + '* "irr_scene_addOctreeSceneNode" (list '* '* '* int int int)) (define-foreign draw-all void "irr_scene_drawAll" (list '*)) @@ -65,11 +68,14 @@ (define-foreign get-mesh '* "irr_scene_getMesh" (list '* '*)) -(define-foreign set-material-flag-am - void "irr_scene_setMaterialFlagAM" (list '* int int)) +(define-foreign get-root-scene-node + '* "irr_scene_getRootSceneNode" (list '*)) + +(define-foreign set-material-flag + void "irr_scene_setMaterialFlag" (list '* int int)) -(define-foreign set-material-texture-am - void "irr_scene_setMaterialTextureAM" (list '* int '*)) +(define-foreign set-material-texture + void "irr_scene_setMaterialTexture" (list '* int '*)) (define-foreign set-md2-animation void "irr_scene_setMD2Animation" (list '* int)) diff --git a/irrlicht/scene.scm b/irrlicht/scene.scm index 264a4bd..2f2aa50 100644 --- a/irrlicht/scene.scm +++ b/irrlicht/scene.scm @@ -26,13 +26,15 @@ #:use-module ((irrlicht bindings video) #:prefix ffi-video:) #:use-module (irrlicht util) #:export (add-animated-mesh-scene-node - add-camera-scene-node + add-camera-scene-node! add-camera-scene-node-fps! - add-octree-scene-node-am + add-custom-scene-node! + add-octree-scene-node get-mesh + get-root-scene-node scene-draw-all - set-material-flag-am! - set-material-texture-am! + set-material-flag! + set-material-texture! set-md2-animation! set-position!)) @@ -55,13 +57,13 @@ (bool->integer also-add-if-mesh-pointer-zero)))) (if (null-pointer? node) #f node))) -(define* (add-camera-scene-node scene-manager - #:key - (parent %null-pointer) - (position '(0 0 0)) - (lookat '(0 0 100)) - (id -1) - (make-active #t)) +(define* (add-camera-scene-node! scene-manager + #:key + (parent %null-pointer) + (position '(0 0 0)) + (lookat '(0 0 100)) + (id -1) + (make-active #t)) (let ((camera (ffi-scene:add-camera-scene-node scene-manager parent @@ -96,13 +98,23 @@ (bool->integer invert-mouse) (bool->integer make-active))) -(define* (add-octree-scene-node-am scene-manager mesh - #:key - (parent %null-pointer) - (id -1) - (minimal-polys-per-node 512) - (also-add-if-mesh-pointer-zero #f)) - (ffi-scene:add-octree-scene-node-am +(define (add-custom-scene-node! parent + scene-manager + id + custom-render) + (ffi-scene:add-custom-scene-node + parent + scene-manager + id + (procedure->pointer void custom-render '()))) + +(define* (add-octree-scene-node scene-manager mesh + #:key + (parent %null-pointer) + (id -1) + (minimal-polys-per-node 512) + (also-add-if-mesh-pointer-zero #f)) + (ffi-scene:add-octree-scene-node scene-manager mesh parent @@ -114,10 +126,13 @@ (let ((mesh (ffi-scene:get-mesh scene-manager (string->pointer filename)))) (if (null-pointer? mesh) #f mesh))) +(define (get-root-scene-node scene-manager) + (ffi-scene:get-root-scene-node scene-manager)) + (define (scene-draw-all scene-manager) (ffi-scene:draw-all scene-manager)) -(define (set-material-flag-am! node flag newvalue) +(define (set-material-flag! node flag newvalue) (let ((material-flag (match flag ('wireframe ffi-video:EMF_WIREFRAME) @@ -140,13 +155,13 @@ ('use-mip-maps ffi-video:EMF_USE_MIP_MAPS) ('blend-operation ffi-video:EMF_BLEND_OPERATION) ('polygon-offset ffi-video:EMF_POLYGON_OFFSET)))) - (ffi-scene:set-material-flag-am + (ffi-scene:set-material-flag node material-flag (bool->integer newvalue)))) -(define (set-material-texture-am! node texture-layer texture) - (ffi-scene:set-material-texture-am node texture-layer texture)) +(define (set-material-texture! node texture-layer texture) + (ffi-scene:set-material-texture node texture-layer texture)) (define (set-md2-animation! node anim) (let ((animation-type