From: Javier Sancho Date: Tue, 17 Dec 2019 17:49:33 +0000 (+0100) Subject: Support for aabbox3d X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=ca1d1d0dd811558f133bfdad62b2b645a31695ff;p=guile-irrlicht.git Support for aabbox3d --- diff --git a/irrlicht.scm b/irrlicht.scm index f3474c6..aaa58ea 100644 --- a/irrlicht.scm +++ b/irrlicht.scm @@ -23,7 +23,8 @@ (eval-when (eval load compile) ;; load public symbols into current module (let ((public-modules - '((irrlicht device) + '((irrlicht aabbox3d) + (irrlicht device) (irrlicht gui) (irrlicht io) (irrlicht scene) diff --git a/irrlicht/aabbox3d.scm b/irrlicht/aabbox3d.scm new file mode 100644 index 0000000..55d71a4 --- /dev/null +++ b/irrlicht/aabbox3d.scm @@ -0,0 +1,63 @@ +;;; guile-irrlicht --- FFI bindings for Irrlicht Engine +;;; Copyright (C) 2019 Javier Sancho +;;; +;;; This file is part of guile-irrlicht. +;;; +;;; Guile-irrlicht is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU Lesser General Public License as +;;; published by the Free Software Foundation; either version 3 of the +;;; License, or (at your option) any later version. +;;; +;;; Guile-irrlicht is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU Lesser General Public +;;; License along with guile-irrlicht. If not, see +;;; . + + +(define-module (irrlicht aabbox3d) + #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) + #:use-module (system foreign) + #:use-module ((irrlicht bindings core) #:prefix ffi-core:) + #:export (make-aabbox3d + aabbox3d-min-edge + aabbox3d-max-edge + aabbox3d-reset! + aabbox3d-add-internal-point!)) + +(define-record-type + (make-raw-aabbox3d c-pointer) + aabbox3d? + (c-pointer aabbox3d-c-pointer)) + +(define* (make-aabbox3d #:optional (min-edge '(0 0 0)) (max-edge min-edge)) + (make-raw-aabbox3d + (make-c-struct ffi-core:aabbox3d_f32 (append min-edge max-edge)))) + +(define (aabbox3d-min-edge box) + (let ((data (parse-c-struct (aabbox3d-c-pointer box) ffi-core:aabbox3d_f32))) + (list-head data 3))) + +(define (aabbox3d-max-edge box) + (let ((data (parse-c-struct (aabbox3d-c-pointer box) ffi-core:aabbox3d_f32))) + (list-tail data 3))) + +(define (aabbox3d-reset! box point) + (ffi-core:aabbox3d-reset + (aabbox3d-c-pointer box) + (make-c-struct ffi-core:vector3df point))) + +(define (aabbox3d-add-internal-point! box point) + (ffi-core:aabbox3d-add-internal-point + (aabbox3d-c-pointer box) + (make-c-struct ffi-core:vector3df point))) + +(set-record-type-printer! + (lambda (record port) + (let ((min (aabbox3d-min-edge record)) + (max (aabbox3d-max-edge record))) + (format port "#" min max)))) diff --git a/irrlicht/bindings/core.scm b/irrlicht/bindings/core.scm index 6d9a579..c432714 100644 --- a/irrlicht/bindings/core.scm +++ b/irrlicht/bindings/core.scm @@ -19,7 +19,21 @@ (define-module (irrlicht bindings core) - #:use-module (system foreign)) + #:use-module (system foreign) + #:use-module (irrlicht util)) + +;; aabbox3d f32 struct and functions +(define-public aabbox3d_f32 + (list + float float float ;minEdge + float float float ;maxEdge + )) + +(define-foreign aabbox3d-add-internal-point + void "irr_core_aabbox3d_addInternalPoint" (list '* '*)) + +(define-foreign aabbox3d-reset + void "irr_core_aabbox3d_reset" (list '* '*)) ;; dimension2d struct (define-public dimension2d