This repository has been archived by the owner on Feb 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul Alkhimov
committed
Feb 22, 2011
0 parents
commit f089d45
Showing
12 changed files
with
1,542 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# OBJ file created by ply_to_obj.c | ||
# | ||
g Object001 | ||
|
||
v -0.57735 -0.57735 0.57735 | ||
v 0.934172 0.356822 0 | ||
v 0.934172 -0.356822 0 | ||
v -0.934172 0.356822 0 | ||
v -0.934172 -0.356822 0 | ||
v 0 0.934172 0.356822 | ||
v 0 0.934172 -0.356822 | ||
v 0.356822 0 -0.934172 | ||
v -0.356822 0 -0.934172 | ||
v 0 -0.934172 -0.356822 | ||
v 0 -0.934172 0.356822 | ||
v 0.356822 0 0.934172 | ||
v -0.356822 0 0.934172 | ||
v 0.57735 0.57735 -0.57735 | ||
v 0.57735 0.57735 0.57735 | ||
v -0.57735 0.57735 -0.57735 | ||
v -0.57735 0.57735 0.57735 | ||
v 0.57735 -0.57735 -0.57735 | ||
v 0.57735 -0.57735 0.57735 | ||
v -0.57735 -0.57735 -0.57735 | ||
|
||
f 19 3 2 | ||
f 12 19 2 | ||
f 15 12 2 | ||
f 8 14 2 | ||
f 18 8 2 | ||
f 3 18 2 | ||
f 20 5 4 | ||
f 9 20 4 | ||
f 16 9 4 | ||
f 13 17 4 | ||
f 1 13 4 | ||
f 5 1 4 | ||
f 7 16 4 | ||
f 6 7 4 | ||
f 17 6 4 | ||
f 6 15 2 | ||
f 7 6 2 | ||
f 14 7 2 | ||
f 10 18 3 | ||
f 11 10 3 | ||
f 19 11 3 | ||
f 11 1 5 | ||
f 10 11 5 | ||
f 20 10 5 | ||
f 20 9 8 | ||
f 10 20 8 | ||
f 18 10 8 | ||
f 9 16 7 | ||
f 8 9 7 | ||
f 14 8 7 | ||
f 12 15 6 | ||
f 13 12 6 | ||
f 17 13 6 | ||
f 13 1 11 | ||
f 12 13 11 | ||
f 19 12 11 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
(in-package :kd) | ||
|
||
(defun remove-comment (line) | ||
(subseq line 0 (position #\# line))) | ||
|
||
(defun parse-vertex (line) | ||
(destructuring-bind (label x y z &optional w) | ||
(cl-ppcre:split "\\s+" (remove-comment line)) | ||
(declare (ignorable label w)) | ||
(list (parse-number x) | ||
(parse-number y) | ||
(parse-number z)))) | ||
|
||
(defun parse-face-point (string) | ||
(destructuring-bind (vertex-index &optional texture-coordinate normal) | ||
(cl-ppcre:split "/" string) | ||
(declare (ignorable texture-coordinate normal)) | ||
(parse-number vertex-index))) | ||
|
||
(defun parse-face (line) | ||
(destructuring-bind (label &rest face-points) | ||
(cl-ppcre:split "\\s+" (remove-comment line)) | ||
(declare (ignorable label)) | ||
(map 'list #'parse-face-point face-points))) | ||
|
||
(defun parse-obj-file (filespec) | ||
(with-open-file (in-stream filespec :direction :input) | ||
(loop for line = (read-line in-stream nil) | ||
while line | ||
when (cl-ppcre:scan "^v " line) collect (parse-vertex line) into vertices | ||
when (cl-ppcre:scan "^f " line) collect (parse-face line) into faces | ||
finally (return (list vertices faces))))) | ||
|
||
(defun load-patch (filename) | ||
(let* ((data (parse-obj-file filename)) | ||
(patch (make-instance 'tri-patch | ||
:vertexes (first data) | ||
:indexes (second data)))) | ||
patch)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(in-package #:kd) | ||
|
||
(defmethod initialize-instance :after ((patch tri-patch) &key vertexes indexes) | ||
(let* ((vx-len (length vertexes)) | ||
(ix-len (length indexes))) | ||
(setf (slot-value patch 'vertexes) | ||
(make-array (list vx-len 3) | ||
:element-type 'coordinate | ||
:adjustable nil)) | ||
(setf (slot-value patch 'indexes) | ||
(make-array (list ix-len 3) | ||
:element-type 'index-type | ||
:adjustable nil)) | ||
;; copy vertexes: coerce | ||
(do ((v vertexes (cdr v)) | ||
(i 0 (1+ i))) | ||
((not v)) | ||
(do ((coord (car v) (cdr coord)) | ||
(j 0 (1+ j))) | ||
((or (> j 2) (not coord))) | ||
(setf (aref (slot-value patch 'vertexes) i j) | ||
(coerce (car coord) 'coordinate)))) | ||
;; copy indexes: 1- and coerce | ||
(do ((ix indexes (cdr ix)) | ||
(i 0 (1+ i))) | ||
((not ix)) | ||
(do ((index (car ix) (cdr index)) | ||
(j 0 (1+ j))) | ||
((or (> j 2) (not index))) | ||
(setf (aref (slot-value patch 'indexes) i j) | ||
(coerce (1- (car index)) 'index-type)))) | ||
;; aabb | ||
(setf (slot-value patch 'aabb) | ||
(calc-aabb (slot-value patch 'vertexes))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(in-package #:kd) | ||
|
||
(defclass tri-patch () | ||
((vertexes :accessor vertexes | ||
:initform (make-array '(0 3) | ||
:element-type 'coordinate | ||
:adjustable t)) | ||
(indexes :accessor indexes | ||
:initform (make-array '(0 3) | ||
:element-type 'index-type | ||
:adjustable t)) | ||
(aabb :accessor aabb | ||
:type aabb | ||
:initform (make-instance 'aabb)) | ||
(tree :accessor tree | ||
:type kd-node | ||
:initform nil))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- | ||
|
||
(defsystem srt | ||
:description "Sandbox RayTracer." | ||
:author "Paul Alkhimov <[email protected]>" | ||
:version "0.0.1" | ||
:licence "BSD" | ||
:depends-on (:cl-ppcre :parse-number) | ||
:components | ||
((:module types | ||
:serial t | ||
:components | ||
((:file "packages") | ||
(:file "base-types") | ||
(:file "aabb") | ||
(:file "kd-tree") | ||
(:file "kd-tree-impl"))) | ||
(:module patch | ||
:depends-on (types) | ||
:serial t | ||
:components | ||
((:file "patch") | ||
(:file "patch-impl"))) | ||
(:module obj | ||
:depends-on (patch) | ||
:components | ||
((:file "obj-file"))) | ||
(:module traverse | ||
:depends-on (patch) | ||
:components | ||
((:file "traverse-kd-tree"))))) | ||
|
Oops, something went wrong.