From: Javier Sancho Date: Mon, 3 Feb 2020 14:54:52 +0000 (+0100) Subject: SMaterial and vertices X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=916ccc1a2ce8a81d8c611fc976fc537d6048dd47;p=guile-irrlicht.git SMaterial and vertices --- diff --git a/irrlicht/bindings/core.scm b/irrlicht/bindings/core.scm index 140506b..a5f06fd 100644 --- a/irrlicht/bindings/core.scm +++ b/irrlicht/bindings/core.scm @@ -58,15 +58,12 @@ (format port "#" (pointer-address (aabbox3df->pointer box))))) -(export aabbox3df->pointer) +(export pointer->aabbox3df + aabbox3df->pointer) (define-public aabbox3df (list vector3df vector3df)) -(define-public (make-aabbox3df) - (pointer->aabbox3df - (make-c-struct aabbox3df '((0 0 0) (0 0 0))))) - (define-foreign aabbox3d-add-internal-point void "irr_core_aabbox3d_addInternalPoint" (list '* '*)) diff --git a/irrlicht/bindings/video.scm b/irrlicht/bindings/video.scm index 0bdf0f0..8740d20 100644 --- a/irrlicht/bindings/video.scm +++ b/irrlicht/bindings/video.scm @@ -23,7 +23,55 @@ #:use-module ((irrlicht bindings core) #:prefix ffi-core:) #:use-module (irrlicht util foreign)) -;; E_DRIVER_TYPE enum +;; irr_video_E_BLEND_OPERATION enum +(define-public EBO_NONE 0) +(define-public EBO_ADD 1) +(define-public EBO_SUBTRACT 2) +(define-public EBO_REVSUBTRACT 3) +(define-public EBO_MIN 4) +(define-public EBO_MAX 5) +(define-public EBO_MIN_FACTOR 6) +(define-public EBO_MAX_FACTOR 7) +(define-public EBO_MIN_ALPHA 8) +(define-public EBO_MAX_ALPHA 9) + +;; irr_video_E_COMPARISON_FUNC enum +(define-public ECFN_NEVER 0) +(define-public ECFN_LESSEQUAL 1) +(define-public ECFN_EQUAL 2) +(define-public ECFN_LESS 3) +(define-public ECFN_NOTEQUAL 4) +(define-public ECFN_GREATEREQUAL 5) +(define-public ECFN_GREATER 6) +(define-public ECFN_ALWAYS 7) + +;; irr_video_E_COLOR_PLANE enum +(define-public ECP_NONE 0) +(define-public ECP_ALPHA 1) +(define-public ECP_RED 2) +(define-public ECP_GREEN 4) +(define-public ECP_BLUE 8) +(define-public ECP_RGB 14) +(define-public ECP_ALL 15) + +;; irr_video_E_ANTI_ALIASING_MODE enum +(define-public EAAM_OFF 0) +(define-public EAAM_SIMPLE 1) +(define-public EAAM_QUALITY 3) +(define-public EAAM_LINE_SMOOTH 4) +(define-public EAAM_POINT_SMOOTH 8) +(define-public EAAM_FULL_BASIC 15) +(define-public EAAM_ALPHA_TO_COVERAGE 16) + +;; irr_video_E_COLOR_MATERIAL enum +(define-public ECM_NONE 0) +(define-public ECM_DIFFUSE 1) +(define-public ECM_AMBIENT 2) +(define-public ECM_EMISSIVE 3) +(define-public ECM_SPECULAR 4) +(define-public ECM_DIFFUSE_AND_AMBIENT 5) + +;; irr_video_E_DRIVER_TYPE enum (define-public EDT_NULL 0) (define-public EDT_SOFTWARE 1) (define-public EDT_BURNINGSVIDEO 2) @@ -54,6 +102,37 @@ (define-public EMF_BLEND_OPERATION #x40000) (define-public EMF_POLYGON_OFFSET #x80000) +;; irr_video_E_POLYGON_OFFSET enum +(define-public EPO_BACK 0) +(define-public EPO_FRONT 1) + +;;irr_video_E_MATERIAL_TYPE enum +(define-public EMT_SOLID 0) +(define-public EMT_SOLID_2_LAYER 1) +(define-public EMT_LIGHTMAP 2) +(define-public EMT_LIGHTMAP_ADD 3) +(define-public EMT_LIGHTMAP_M2 4) +(define-public EMT_LIGHTMAP_M4 5) +(define-public EMT_LIGHTMAP_LIGHTING 6) +(define-public EMT_LIGHTMAP_LIGHTING_M2 7) +(define-public EMT_LIGHTMAP_LIGHTING_M4 8) +(define-public EMT_DETAIL_MAP 9) +(define-public EMT_SPHERE_MAP 10) +(define-public EMT_REFLECTION_2_LAYER 11) +(define-public EMT_TRANSPARENT_ADD_COLOR 12) +(define-public EMT_TRANSPARENT_ALPHA_CHANNEL 13) +(define-public EMT_TRANSPARENT_ALPHA_CHANNEL_REF 14) +(define-public EMT_TRANSPARENT_VERTEX_ALPHA 15) +(define-public EMT_TRANSPARENT_REFLECTION_2_LAYER 16) +(define-public EMT_NORMAL_MAP_SOLID 17) +(define-public EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR 18) +(define-public EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA 19) +(define-public EMT_PARALLAX_MAP_SOLID 20) +(define-public EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR 21) +(define-public EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA 22) +(define-public EMT_ONETEXTURE_BLEND 23) +(define-public EMT_FORCE_32BIT #x7fffffff) + ;; scolor struct (define-public scolor @@ -86,7 +165,8 @@ (format port "#" (pointer-address (s3dvertex->pointer vertex))))) -(export s3dvertex->pointer) +(export pointer->s3dvertex + s3dvertex->pointer) (define-public s3dvertex (list ffi-core:vector3df @@ -94,14 +174,6 @@ scolor ffi-core:vector2df)) -(define-public (make-s3dvertex position normal color t-coords) - (pointer->s3dvertex - (make-c-struct s3dvertex (list position normal color t-coords)))) - -(define-public (vertex-position vertex) - (let ((data (parse-c-struct (s3dvertex->pointer vertex) s3dvertex))) - (car data))) - ;; smateriallayer struct (define-public smateriallayer (list '* uint8 uint8 uint8 uint8 uint8 int8 '* '*)) @@ -114,7 +186,8 @@ (format port "#" (pointer-address (smaterial->pointer material))))) -(export smaterial->pointer) +(export pointer->smaterial + smaterial->pointer) (define-public smaterial (list smateriallayer smateriallayer smateriallayer smateriallayer ; textureLayer[4] @@ -146,8 +219,3 @@ (uint8 1) ; normalizeNormals:1 (uint8 1) ; useMipMaps:1 ))) - -;; (define-public (make-material #:key -;; (wireframe #f) -;; (lighting #t)) -;; material) diff --git a/irrlicht/core.scm b/irrlicht/core.scm index 7bc6208..a0cb973 100644 --- a/irrlicht/core.scm +++ b/irrlicht/core.scm @@ -19,9 +19,14 @@ (define-module (irrlicht core) + #:use-module (system foreign) #:use-module ((irrlicht bindings core) #:prefix ffi-core:) - #:export (aabbox3d-reset!) - #:re-export ((ffi-core:make-aabbox3df . make-aabbox3df))) + #:export (make-aabbox3df + aabbox3d-reset!)) + +(define (make-aabbox3df) + (ffi-core:pointer->aabbox3df + (make-c-struct ffi-core:aabbox3df '((0 0 0) (0 0 0))))) (define (aabbox3d-reset! box init-value) (ffi-core:aabbox3d-reset diff --git a/irrlicht/video.scm b/irrlicht/video.scm index b0f48d9..a394c01 100644 --- a/irrlicht/video.scm +++ b/irrlicht/video.scm @@ -23,13 +23,15 @@ #:use-module ((irrlicht bindings core) #:prefix ffi-core:) #:use-module ((irrlicht bindings video) #:prefix ffi-video:) #:use-module (irrlicht util) + #:use-module (irrlicht util foreign) #:export (begin-scene end-scene get-fps get-texture - get-video-driver-name) - #:re-export ((ffi-video:make-s3dvertex . make-s3dvertex) - (ffi-video:vertex-position . vertex-position))) + get-video-driver-name + make-s3dvertex + vertex-position + make-material)) (define* (begin-scene driver #:key @@ -59,3 +61,54 @@ (define (get-video-driver-name driver) (pointer->string (ffi-video:get-video-driver-name driver))) + +;; s3d vertices +(define (make-s3dvertex position normal color t-coords) + (ffi-video:pointer->s3dvertex + (make-c-struct ffi-video:s3dvertex + (list position normal color t-coords)))) + +(define (vertex-position vertex) + (let ((data (parse-c-struct (ffi-video:s3dvertex->pointer vertex) + ffi-video:s3dvertex))) + (car data))) + +;; smaterial +(define* (make-material #:key (wireframe #f) (lighting #t)) + (let ((material + (list + ;; textureLayer[4] + (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer) + (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer) + (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer) + (list %null-pointer 0 0 0 0 0 0 %null-pointer %null-pointer) + ffi-video:EMT_SOLID ; materialType + (list 255 255 255 255) ; ambientColor + (list 255 255 255 255) ; diffuseColor + (list 0 0 0 0) ; emissiveColor + (list 255 255 255 255) ; specularColor + 0 ; shininess + 0 ; materialTypeParam + 0 ; materialTypeParam2 + 1 ; thickness + ffi-video:ECFN_LESSEQUAL ; zBuffer + ffi-video:EAAM_SIMPLE ; antiAliasing + (list + ffi-video:ECP_ALL ; colorMask + ffi-video:ECM_DIFFUSE ; colorMaterial + ffi-video:EBO_NONE ; blendOperation + 0 ; polygonOffsetFactor + ffi-video:EPO_FRONT ; polygonOffsetDirection + (bool->integer wireframe) ; wireframe + (bool->integer #f) ; pointCloud + (bool->integer #t) ; gouraudShading + (bool->integer lighting) ; lighting + (bool->integer #t) ; zWriteEnable + (bool->integer #t) ; backfaceCulling + (bool->integer #f) ; frontfaceCulling + (bool->integer #f) ; fogEnable + (bool->integer #f) ; normalizeNormals + (bool->integer #t) ; useMipMaps + )))) + (ffi-video:pointer->smaterial + (make-c-struct+ ffi-video:smaterial material))))