summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render/model.scm82
1 files changed, 41 insertions, 41 deletions
diff --git a/chickadee/render/model.scm b/chickadee/render/model.scm
index 9f29240..56f5c39 100644
--- a/chickadee/render/model.scm
+++ b/chickadee/render/model.scm
@@ -487,47 +487,6 @@
(loop a c rest #t))))))
(_
(parse-error "invalid face" args))))
- ;; Register default material
- (hash-set! material-map "default" default-phong-material)
- ;; Parse file.
- (let loop ((material "default"))
- (match (read-line port)
- ((? eof-object?)
- #f)
- (line
- (match (delete "" (string-split line char-set:whitespace))
- ((or () ("#" . _)) ; ignore comments and blank lines
- (loop material))
- (("f" . args)
- (parse-face args material)
- (loop material))
- (("g" . _) ; ignore group name for now
- (loop material))
- (("mtllib" mtl-file-name)
- (load-mtl (scope-file mtl-file-name))
- (loop material))
- (("o" . _) ;ignore object name for now
- (loop material))
- (("s" . _) ; ignore smoothing group for now
- (loop material))
- (("usemtl" new-material)
- (loop new-material))
- (("v" . args)
- (parse-vertex args)
- (loop material))
- (("vn" . args)
- (parse-normal args)
- (loop material))
- (("vt" . args)
- (parse-texcoord args)
- (loop material))
- (data
- (format (current-error-port)
- "warning: ~a:~d: unsupported OBJ data: ~s~%"
- file-name
- (port-line port)
- data)
- (loop material))))))
;; Build a vertex array for all the faces of a single
;; material.
;;
@@ -603,6 +562,47 @@
(2 . ,normal-view)))
(or (hash-ref material-map material)
(hash-ref material-map "default"))))))
+ ;; Register default material
+ (hash-set! material-map "default" default-phong-material)
+ ;; Parse file.
+ (let loop ((material "default"))
+ (match (read-line port)
+ ((? eof-object?)
+ #f)
+ (line
+ (match (delete "" (string-split line char-set:whitespace))
+ ((or () ("#" . _)) ; ignore comments and blank lines
+ (loop material))
+ (("f" . args)
+ (parse-face args material)
+ (loop material))
+ (("g" . _) ; ignore group name for now
+ (loop material))
+ (("mtllib" mtl-file-name)
+ (load-mtl (scope-file mtl-file-name))
+ (loop material))
+ (("o" . _) ;ignore object name for now
+ (loop material))
+ (("s" . _) ; ignore smoothing group for now
+ (loop material))
+ (("usemtl" new-material)
+ (loop new-material))
+ (("v" . args)
+ (parse-vertex args)
+ (loop material))
+ (("vn" . args)
+ (parse-normal args)
+ (loop material))
+ (("vt" . args)
+ (parse-texcoord args)
+ (loop material))
+ (data
+ (format (current-error-port)
+ "warning: ~a:~d: unsupported OBJ data: ~s~%"
+ file-name
+ (port-line port)
+ data)
+ (loop material))))))
;; Construct a mesh by composing primitives. One primitive
;; per material.
(let* ((model-name (basename file-name))