From e7d470e954d0a17ab1b2fe0065f46f78475272f9 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 8 Apr 2020 17:10:29 -0400 Subject: Add chickade 0.5.0 stuff. --- manuals/chickadee/3D-Models.html | 157 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 manuals/chickadee/3D-Models.html (limited to 'manuals/chickadee/3D-Models.html') diff --git a/manuals/chickadee/3D-Models.html b/manuals/chickadee/3D-Models.html new file mode 100644 index 0000000..1e6d2ca --- /dev/null +++ b/manuals/chickadee/3D-Models.html @@ -0,0 +1,157 @@ + + + + + + +3D Models (The Chickadee Game Toolkit) + + + + + + + + + + + + + + + + + + + +
+

+Next: , Previous: , Up: Graphics   [Contents][Index]

+
+
+

2.3.8 3D Models

+ +

Disclaimer: Chickadee is alpha software, but 3D model support is +even more alpha than that. There are many missing features in both +the model loading and rendering components, so set your expectations +accordingly! +

+

Chickadee can load and render 3D models in the classic OBJ and more +modern glTF 2.0 formats. +

+

Here’s some basic boilerplate to render a 3D model: +

+
+
(use-modules (chickadee)
+             (chickadee math)
+             (chickadee math matrix)
+             (chickadee render model))
+
+(define model #f)
+(define projection-matrix
+  (perspective-projection (/ pi 3.0) (/ 4.0 3.0) 0.1 500.0))
+;; Adjust these 2 matrices so that you can actually see the model.
+(define view-matrix (make-identity-matrix4))
+(define model-matrix (make-identity-matrix4))
+
+(define (load)
+  (set! model (load-obj "model.obj"))
+
+(define (draw alpha)
+  (with-projection projection-matrix
+    (with-depth-test #t
+      (draw-model model model-matrix view-matrix))))
+
+(run-game #:load load #:draw draw)
+
+ +
+
Procedure: load-obj file-name
+

Load the OBJ formatted model in file-name and return a 3D model +object. +

+

OBJ models are rendered using a Phong lighting model, which is a +work-in-progress. +

+ +
+
Procedure: load-gltf file-name
+

Load the glTF 2.0 formatted model in file-name and return a 3D +model object. +

+

glTF models are rendered using a physically based lighting model, +which is currently a stub to be implemented later. +

+ +
+
Procedure: model? obj
+

Return #t if obj is a 3D model. +

+ +
+
Procedure: draw-model model model-matrix view-matrix
+

Render model with the transformation matrices model-matrix +and view-matrix applied. +

+ + + + + + -- cgit v1.2.3