Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First four nehe tutorials finished. See examples/ for the source. Edi…

…t launcher.scm to open one.
  • Loading branch information...
commit a1d91b5e5e918cf2ad96ebb4cfc4b34cafc3fb79 1 parent 35341cb
Sean Grove authored
View
18 config/environment.scm
@@ -1,18 +0,0 @@
-(define *debug-mode* #f)
-
-(define *window-title* "Schope")
-
-(define *window-resolution* '(640 480))
-(define *window-position* '(100 100))
-(define *clear-color* '(0 0 0 0))
-(define *clear-depth* 1.0)
-
-(define *ignore-key-repeat* #f)
-
-(define *shade-model* gl:SMOOTH)
-
-(define (pre-main-hook)
- (move-camera (vertex 5 10 5))
- (turn-camera (vertex 45 225 0)))
-
-(define *texture-files* '("rpg-char-4.bmp" "rpg-char-4-2.bmp" "grid.bmp" "tree.bmp" "corner_test.bmp" "grass.bmp"))
View
2  config/settings.scm
@@ -11,4 +11,4 @@
(define *shade-model* gl:SMOOTH)
-(define *texture-files* '("resources/rpg-char-4.bmp" "resources/rpg-char-4-2.bmp" "resources/grid.bmp" "resources/tree.bmp" "resources/corner_test.bmp" "resources/grass.bmp" "resources/water_64x64.bmp" "resources/grass-water_64x64.bmp"))
+(define *texture-files* '("resources/grid.bmp" "resources/corner_test.bmp" "resources/example.bmp"))
View
34 examples/nehe_tutorials_2.scm
@@ -0,0 +1,34 @@
+;; Tutorial-specific settings
+(define *clear-color* '(0 0 0 0))
+
+(define (game-loop delta)
+ (let* ((total-time (- (current-milliseconds) *start-time*))
+ (seconds (/ (inexact->exact (truncate total-time)) 1000))
+ (current-texture (inexact->exact (truncate (remainder seconds 2)))))
+
+ ;; Get a new matrix (same as pushing and popping the matrix)
+ (with-new-matrix
+
+ ;; Move left 1.5 units and "out of" the screen 6 units
+ (gl:Translatef -1.5 0.0 -6.0)
+
+ ;; Draw a flat-colored (one-color) triangle
+ (flat-triangle (color 1 1 1) ;; White
+ (vertex 0 0 0) ;; Top
+ (vertex -1 -1 0) ;; Bottom Left
+ (vertex 1 -1 0)) ;; Bottom Right
+
+ ;; Move right 3 units
+ (gl:Translatef 3 0 0)
+
+ ;; Draw a flat-colored (one-color) quad
+ (flat-quad (color 1 1 1) ;; White
+ (vertex -1 1 0) ;; Top Left
+ (vertex 1 1 0) ;; Top Right
+ (vertex 1 -1 0) ;; Bottom Right
+ (vertex -1 -1 0)) ;; Bottom Left
+ )))
+
+;; No keyboard control in this tutorial
+(define (handle-keyboard-state delta)
+ '())
View
36 examples/nehe_tutorials_3.scm
@@ -0,0 +1,36 @@
+;; Tutorial-specific settings
+(define *clear-color* '(0 0 0 0))
+
+(define (game-loop delta)
+ (let* ((total-time (- (current-milliseconds) *start-time*))
+ (seconds (/ (inexact->exact (truncate total-time)) 1000))
+ (current-texture (inexact->exact (truncate (remainder seconds 2)))))
+
+ ;; Get a new matrix (same as pushing and popping the matrix)
+ (with-new-matrix
+
+ ;; Move left 1.5 units and "out of" the screen 6 units
+ (gl:Translatef -1.5 0.0 -6.0)
+
+ ;; Draw a colored triangle
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 1 0) ;; Green
+ (vertex -1 -1 0) ;; Bottom Left
+ (color 0 0 1) ;; Blue
+ (vertex 1 -1 0)) ;; Bottom Right
+
+ ;; Move right 3 units
+ (gl:Translatef 3 0 0)
+
+ ;; Draw a flat-colored (one-color) quad
+ (flat-quad (color 0 0 1) ;; Blue
+ (vertex -1 1 0) ;; Top Left
+ (vertex 1 1 0) ;; Top Right
+ (vertex 1 -1 0) ;; Bottom Right
+ (vertex -1 -1 0)) ;; Bottom Left
+ )))
+
+;; No keyboard control in this tutorial
+(define (handle-keyboard-state delta)
+ '())
View
48 examples/nehe_tutorials_4.scm
@@ -0,0 +1,48 @@
+;; Tutorial-specific settings
+(define *clear-color* '(0 0 0 0))
+
+(define (game-loop delta)
+ (let* ((total-time (- (current-milliseconds) *start-time*))
+ (seconds (/ (inexact->exact (truncate total-time)) 1000))
+ (current-texture (inexact->exact (truncate (remainder seconds 2))))
+ (triangle-rotation (/ total-time 4))
+ (quad-rotation (/ total-time 2)))
+
+ ;; Get a new matrix (same as pushing and popping the matrix)
+ (with-new-matrix
+
+ ;; Move left 1.5 units and "out of" the screen 6 units
+ (gl:Translatef -1.5 0.0 -6.0)
+
+ ;; Rotate about the Y axis before we draw the triangle
+ (gl:Rotatef triangle-rotation 0 1 0)
+
+ ;; Draw a colored triangle
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 1 0) ;; Green
+ (vertex -1 -1 0) ;; Bottom Left
+ (color 0 0 1) ;; Blue
+ (vertex 1 -1 0)) ;; Bottom Right
+ )
+
+ ;; Reset to the default matrix
+ (with-new-matrix
+
+ ;; Move left 1.5 units and "out of" the screen 6 units
+ (gl:Translatef 1.5 0.0 -6.0)
+
+ ;; Rotate about the Y axis before we draw the triangle
+ (gl:Rotatef quad-rotation 1 0 0)
+
+ ;; Draw a flat-colored (one-color) quad
+ (flat-quad (color 0 0 1) ;; Blue
+ (vertex -1 1 0) ;; Top Left
+ (vertex 1 1 0) ;; Top Right
+ (vertex 1 -1 0) ;; Bottom Right
+ (vertex -1 -1 0)) ;; Bottom Left
+ )))
+
+;; No keyboard control in this tutorial
+(define (handle-keyboard-state delta)
+ '())
View
99 examples/nehe_tutorials_5.scm
@@ -0,0 +1,99 @@
+;; Tutorial-specific settings
+(define *clear-color* '(0 0 0 0))
+
+(define (game-loop delta)
+ (let* ((total-time (- (current-milliseconds) *start-time*))
+ (seconds (/ (inexact->exact (truncate total-time)) 1000))
+ (current-texture (inexact->exact (truncate (remainder seconds 2))))
+ (triangle-rotation (/ total-time 4))
+ (quad-rotation (/ total-time 2)))
+
+ ;; Get a new matrix (same as pushing and popping the matrix)
+ (with-new-matrix
+
+ ;; Move left 1.5 units and "out of" the screen 6 units
+ (gl:Translatef -1.5 0.0 -6.0)
+
+ ;; Rotate about the Y axis before we draw the triangle
+ (gl:Rotatef triangle-rotation 0 1 0)
+
+ ;; Draw one face of the pyramid (a colored triangle)
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 1 0) ;; Green
+ (vertex -1 -1 1) ;; Bottom Left
+ (color 0 0 1) ;; Blue
+ (vertex 1 -1 1)) ;; Bottom Right
+
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 0 1) ;; Blue
+ (vertex 1 -1 1) ;; Bottom Left
+ (color 0 1 0) ;; Green
+ (vertex 1 -1 -1)) ;; Bottom Right
+
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 1 0) ;; Green
+ (vertex 1 -1 -1) ;; Bottom Left
+ (color 0 0 1) ;; Blue
+ (vertex -1 -1 -1)) ;; Bottom Right
+
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 0 1) ;; Blue
+ (vertex -1 -1 -1) ;; Bottom Left
+ (color 0 1 0) ;; Green
+ (vertex -1 -1 1)) ;; Bottom Right
+ )
+
+ ;; Reset to the default matrix
+ (with-new-matrix
+
+ ;; Move left 1.5 units and "out of" the screen 6 units
+ (gl:Translatef 1.5 0.0 -7.0)
+
+ ;; Rotate about the X, Y, and Z axis before we draw the triangle
+ (gl:Rotatef quad-rotation 1 1 1)
+
+ ;; Draw a flat-colored (one-color) quad
+ (flat-quad (color 0 1 0) ;; Green
+ (vertex 1 1 -1) ;; Top Left
+ (vertex -1 1 -1) ;; Top Right
+ (vertex -1 1 1) ;; Bottom Right
+ (vertex 1 1 1)) ;; Bottom Left
+
+ (flat-quad (color 1 0.5 1) ;; Orange
+ (vertex 1 -1 1) ;; Top Left
+ (vertex -1 -1 1) ;; Top Right
+ (vertex -1 -1 -1) ;; Bottom Right
+ (vertex 1 -1 -1)) ;; Bottom Left
+
+ (flat-quad (color 1 0 0) ;; Red
+ (vertex 1 1 1) ;; Top Left
+ (vertex -1 1 1) ;; Top Right
+ (vertex -1 -1 1) ;; Bottom Right
+ (vertex 1 -1 1)) ;; Bottom Left
+
+ (flat-quad (color 1 1 0) ;; Yellow
+ (vertex 1 -1 -1) ;; Top Left
+ (vertex -1 -1 -1) ;; Top Right
+ (vertex -1 1 -1) ;; Bottom Right
+ (vertex 1 1 -1)) ;; Bottom Left
+
+ (flat-quad (color 0 0 1) ;; Blue
+ (vertex -1 1 1) ;; Top Left
+ (vertex -1 1 -1) ;; Top Right
+ (vertex -1 -1 -1) ;; Bottom Right
+ (vertex -1 -1 1)) ;; Bottom Left
+
+ (flat-quad (color 1 0 1) ;; Violet
+ (vertex 1 1 -1) ;; Top Left
+ (vertex 1 1 1) ;; Top Right
+ (vertex 1 -1 1) ;; Bottom Right
+ (vertex 1 -1 -1)) ;; Bottom Left
+ )))
+
+;; No keyboard control in this tutorial
+(define (handle-keyboard-state delta)
+ '())
View
2  game.scm
@@ -147,7 +147,7 @@
(if (kb:key-pressed? #\space) (returnable-repl))))
;; --- Main loop
-(define (game-looper delta)
+(define (game-loop delta)
(print "Do something here!")
(print delta)
(define (textured-triangle-example delta)
View
5 launcher.scm
@@ -1 +1,6 @@
+;; (define *logic-file* "examples/nehe_tutorials_2.scm")
+;; (define *logic-file* "examples/nehe_tutorials_3.scm")
+;; (define *logic-file* "examples/nehe_tutorials_4.scm")
+(define *logic-file* "examples/nehe_tutorials_5.scm")
+
(load "lib/core.scm")
View
74 lib/camera.scm
@@ -1,27 +1,31 @@
-(define camera-position (vertex 0 0 0))
-(define camera-velocity (vertex 0 0 0))
-(define camera-angle (vertex 0 0 0))
-(define camera-rotation (vertex 0 0 0))
-(define camera-orbit-angle (vertex 0 0 0))
+(define camera-position (vertex 0.0 0.0 0.0))
+(define camera-velocity (vertex 0.0 0.0 0.0))
+(define camera-angle (vertex 0.0 0.0 0.0))
+(define camera-rotation (vertex 0.0 0.0 0.0))
+(define camera-orbit-angle (vertex 0.0 0.0 0.0))
(define camera-orbit-offset 10)
(define (current-camera-position)
camera-position)
+(define (current-camera-angle)
+ camera-angle)
+
(define (update-camera delta)
(set! camera-position (map (lambda (a b) (+ a b)) camera-position camera-velocity))
;(stop-camera)
- ;(camera-look-at (vertex 0 0 0))
- (set! camera-angle (map (lambda (a b) (print (+ a b)) (if (equal? (inexact->exact (+ a b)) 0) 0 (remainder 360 (+ a b)))) camera-angle camera-rotation))
- (print (string-append "Position: " (vertex->string camera-position)))
- (print (string-append "Angle : " (vertex->string camera-angle)))
- (print (string-append "Offset : " (number->string camera-orbit-offset)))
- (stop-camera)
- (print "------------------------------------------------------------------------------"))
+ ;(camera-look-at (vertex 0.0 0.0 0.0))
+ (set! camera-angle (map (lambda (a b) (+ a b)) camera-angle camera-rotation))
+ ;; (print (string-append "Position: " (vertex->string camera-position)))
+ ;; (print (string-append "Angle : " (vertex->string camera-angle)))
+ ;; (print (string-append "Offset : " (number->string camera-orbit-offset)))
+ ;; (print "------------------------------------------------------------------------------")
+ (stop-camera))
+
(define (turn-camera rotation)
- (print "Turning camera!")
- (print (vertex->string rotation))
+ ;(print "Turning camera!")
+ ;(print (vertex->string rotation))
(set! camera-rotation (map (lambda (a b) (+ a b)) camera-rotation rotation)))
;; TODO: Currently 2d. Make it 3d
@@ -82,40 +86,37 @@
(move-x (* distance (cos (degrees->radians angle-y))))
(move-z (* distance (sin (degrees->radians angle-y))))
(movement (vertex move-x 0 move-z)))
- (print (string-append "Pointing: " (vertex->string camera-angle)))
- (print (string-append "Angle : " (number->string (degrees->radians angle-y)) " (" (number->string angle-y) "d)"))
- (print (string-append "Moving : " (vertex->string movement)))
- (print (string-append "Velocity: " (vertex->string (map (lambda (a b) (+ a b)) movement camera-velocity))))
(move-camera movement)))
-(define (strafe-camera distances)
- (let ((x (vertex-x distances))
- (y (vertex-y distances))
- (z (vertex-z distances)))
+(define (strafe-camera distance)
+ (let* ((x (vertex-x distance))
+ (y (vertex-y distance))
+ (z (vertex-z distance))
+ (x-offset (* x (sin (degrees->radians (+ 90 (vertex-y camera-angle))))))
+ (z-offset (* x (cos (degrees->radians (+ 90 (vertex-y camera-angle)))))))
(move-camera (vertex
- (* x (cos (degrees->radians (+ 90 (vertex-y camera-angle)))))
+ x-offset
0
- (* x ( (degrees->radians (+ 90 (vertex-y camera-angle)))))))))
-
+ z-offset))))
(define (stop-camera)
- (set! camera-velocity (vertex 0 0 0))
- (set! camera-rotation (vertex 0 0 0)))
+ (set! camera-velocity (vertex 0.0 0.0 0.0))
+ (set! camera-rotation (vertex 0.0 0.0 0.0)))
(define (reset-camera-angle)
- (set! camera-angle (vertex 0 0 0))
- (set! camera-rotation (vertex 0 0 0)))
+ (set! camera-angle (vertex 0.0 0.0 0.0))
+ (set! camera-rotation (vertex 0.0 0.0 0.0)))
(define (reset-camera-position)
- (set! camera-position (vertex 0 0 0))
- (set! camera-velocity (vertex 0 0 0)))
+ (set! camera-position (vertex 0.0 0.0 0.0))
+ (set! camera-velocity (vertex 0.0 0.0 0.0)))
(define (reset-camera)
(reset-camera-position)
(reset-camera-angle))
(define (camera-debug debug-function)
- (let ((orbit-center (get-orbit-center)))
+ (let ((orbit-center (get-orbit-center 10)))
(map debug-function (list (string-append "POSITION: " (number->string (vertex-x camera-position)) ", " (number->string (vertex-y camera-position)) ", " (number->string (vertex-z camera-position)))
(string-append "VELOCITY: " (number->string (vertex-x camera-velocity)) ", " (number->string (vertex-y camera-velocity)) ", " (number->string (vertex-z camera-velocity)))
(string-append "ANGLE: " (number->string (vertex-x camera-angle)) ", " (number->string (vertex-y camera-angle)) ", " (number->string (vertex-z camera-angle)))
@@ -123,11 +124,10 @@
(string-append "ORBIT: " (number->string (vertex-x camera-orbit-angle)) ", " (number->string (vertex-y camera-orbit-angle)) ", " (number->string (vertex-z camera-orbit-angle)))
(string-append "O-CENTER: " (number->string (vertex-x orbit-center)) ", " (number->string (vertex-y orbit-center)) ", " (number->string (vertex-z orbit-center)))))))
-(define (get-orbit-center)
- (let* ((distance 10.0)
- (angle-y (+ 0 (vertex-y camera-angle)))
- (move-x (* distance (cos (degrees->radians angle-y))))
- (move-z (* distance (sin (degrees->radians angle-y)))))
+(define (get-orbit-center distance)
+ (let* ((angle-y (+ 0 (vertex-y camera-angle)))
+ (move-x (* distance (sin (degrees->radians angle-y))))
+ (move-z (- (* distance (cos (degrees->radians angle-y))))))
(vertex-add camera-position (vertex move-x 0 move-z))))
View
5 lib/core.scm
@@ -41,7 +41,7 @@
(print "Loading custom logic...")
;; User's logic
-(load "main.scm")
+(load *logic-file*)
(print "Scaffolding application...")
(set! *start-time* (current-milliseconds))
@@ -67,8 +67,7 @@
(gl:MatrixMode gl:MODELVIEW)
(gl:LoadIdentity)
(let ((delta (- *last-frame* (current-milliseconds))))
- (+ 1 1)
- (game-looper delta))
+ (game-loop delta))
(gl:Flush)
(set! *last-frame* (current-milliseconds))
(post-display-hook))
View
38 lib/gl_utils.scm
@@ -21,6 +21,9 @@
(define (vertex-invert vertex)
(map - vertex))
+(define (vertex-truncate vertex #!optional precision)
+ (map (lambda (i) (round-to i 0.01)) vertex))
+
(define (vertex-add vertex-1 vertex-2)
(map (lambda (a b) (+ a b)) vertex-1 vertex-2))
@@ -149,6 +152,41 @@
(vector x (+ y s) 0)
(vector x (+ y s) 0.25)))
+(define (flat-quad quad-color
+ vertex-1
+ vertex-2
+ vertex-3
+ vertex-4)
+
+ (quad quad-color
+ vertex-1
+ quad-color
+ vertex-2
+ quad-color
+ vertex-3
+ quad-color
+ vertex-4))
+
+(define (quad color-1
+ vertex-1
+ color-2
+ vertex-2
+ color-3
+ vertex-3
+ color-4
+ vertex-4)
+
+ (gl:Begin gl:QUADS)
+ (apply gl:Color3f color-1)
+ (apply gl:Vertex3f vertex-1)
+ (apply gl:Color3f color-2)
+ (apply gl:Vertex3f vertex-2)
+ (apply gl:Color3f color-3)
+ (apply gl:Vertex3f vertex-3)
+ (apply gl:Color3f color-4)
+ (apply gl:Vertex3f vertex-4)
+ (gl:End))
+
(define (textured-quad texture
upper-left
upper-right
View
3  lib/math_utils.scm
@@ -8,3 +8,6 @@
(define (^2 b)
(* b b))
+
+(define (round-to n d)
+ (if (= 0 n) n (/ (round (* n (/ 1.0 d))) (/ 1.0 d))))
View
BIN  resources/corner_test.bmp
Binary file not shown
View
BIN  resources/example.bmp
Binary file not shown
View
BIN  resources/grid.bmp
Binary file not shown
View
203 tests/camera_test.scm
@@ -0,0 +1,203 @@
+(require-extension test)
+(load "lib/math_utils.scm")
+(load "lib/list_utils.scm")
+(load "lib/gl_utils.scm")
+(load "lib/camera.scm")
+
+(parameterize ((current-test-epsilon 1e-0))
+
+ (test-begin "Camera system")
+ (test-begin "Default camera global variables")
+
+ (test "Default (current-camera-position)"
+ (vertex 0.0 0.0 0.0)
+ (current-camera-position))
+
+ (test "Default camera position"
+ camera-position
+ (current-camera-position))
+
+ (test "Default (current-camera-angle)"
+ (vertex 0.0 0.0 0.0)
+ (current-camera-angle))
+
+ (test "Default camera angle"
+ camera-angle
+ (current-camera-angle))
+
+ (test-end)
+ (test-begin "Camera movement")
+
+ (test "Move camera on x-axis"
+ (vertex 5.0 0.0 0.0)
+ (begin
+ (move-camera (vertex 5 0 0))
+ (update-camera 1)
+ (current-camera-position)))
+ (reset-camera)
+
+ (test "Move camera on y-axis"
+ (vertex 0.0 5.0 0.0)
+ (begin
+ (move-camera (vertex 0 5 0))
+ (update-camera 1)
+ (current-camera-position)))
+ (reset-camera)
+
+ (test "Move camera on z-axis"
+ (vertex 0.0 0.0 5.0)
+ (begin
+ (move-camera (vertex 0 0 5))
+ (update-camera 1)
+ (current-camera-position)))
+ (reset-camera)
+
+ (test "Move camera on all axis"
+ (vertex 5.0 5.0 5.0)
+ (begin
+ (move-camera (vertex 5 5 5))
+ (update-camera 1)
+ (current-camera-position)))
+
+ (reset-camera)
+ (test "Turn 0 degrees, move camera forward 2"
+ (vertex 0.0 0.0 -2.0)
+ (vertex-truncate (begin
+ (move-camera-forward 2)
+ (update-camera 1)
+ (current-camera-position))))
+
+ (reset-camera)
+ (test "Turn 45 degrees, move forward 2"
+ (vertex 1.41 0.0 -1.41)
+ (vertex-truncate (begin
+ (turn-camera (vertex 0 45 0))
+ (update-camera 1)
+ (move-camera-forward 2)
+ (update-camera 1)
+ (current-camera-position))))
+
+ (reset-camera)
+ (test "Turn 65 degrees, move forward 3"
+ (vertex 2.72 0.0 -1.27)
+ (vertex-truncate (begin
+ (turn-camera (vertex 0 65 0))
+ (update-camera 1)
+ (move-camera-forward 3)
+ (update-camera 1)
+ (current-camera-position))))
+
+ (reset-camera)
+
+ (test "Turn -65 degrees, move forward 4"
+ (vertex -3.63 0.0 -1.69)
+ (vertex-truncate (begin
+ (turn-camera (vertex 0 -65 0))
+ (update-camera 1)
+ (move-camera-forward 4)
+ (update-camera 1)
+ (current-camera-position))))
+
+ (reset-camera)
+ (test "Turn -65 degrees, move forward 4, turn 20, move forward 5"
+ (vertex -7.16 0.0 -5.23)
+ (vertex-truncate (begin
+ (turn-camera (vertex 0 -65 0))
+ (update-camera 1)
+ (move-camera-forward 4)
+ (update-camera 1)
+ (turn-camera (vertex 0 20 0))
+ (update-camera 1)
+ (move-camera-forward 5)
+ (update-camera 1)
+ (current-camera-position))))
+
+ (reset-camera)
+ (test "Turn 0 degrees, strafe left 5"
+ (vertex -5.0 0.0 0.0)
+ (vertex-truncate (begin
+ (strafe-camera (vertex -5 0 0))
+ (update-camera 1)
+ (current-camera-position))))
+
+ (reset-camera)
+ (test "Turn 0 degrees, strafe right 5"
+ (vertex 5.0 0.0 0.0)
+ (vertex-truncate (begin
+ (strafe-camera (vertex 5 0 0))
+ (update-camera 1)
+ (current-camera-position))))
+
+ (reset-camera)
+ (test "Turn 16 degrees, strafe left 10"
+ (vertex -9.61 0.0 2.76)
+ (vertex-truncate (begin
+ (turn-camera (vertex 0 16 0))
+ (update-camera 1)
+ (strafe-camera (vertex -10 0 0))
+ (update-camera 1)
+ (current-camera-position))))
+
+ (test-end)
+
+ (test-begin "Camera rotation")
+ (reset-camera)
+ (test "Rotate camera about x-axis"
+ (vertex 5.0 0.0 0.0)
+ (begin
+ (turn-camera (vertex 5 0 0))
+ (update-camera 1)
+ (current-camera-angle)))
+ (reset-camera)
+
+ (test "Rotate camera about y-axis"
+ (vertex 0.0 5.0 0.0)
+ (begin
+ (turn-camera (vertex 0 5 0))
+ (update-camera 1)
+ (current-camera-angle)))
+
+ (reset-camera)
+ (test "Rotate camera about z-axis"
+ (vertex 0.0 0.0 5.0)
+ (begin
+ (turn-camera (vertex 0 0 5))
+ (update-camera 1)
+ (current-camera-angle)))
+
+ (reset-camera)
+ (test "Rotate camera about all axis"
+ (vertex 5.0 5.0 5.0)
+ (begin
+ (turn-camera (vertex 5 5 5))
+ (update-camera 1)
+ (current-camera-angle)))
+ (reset-camera)
+ (test-end)
+
+
+ (test-begin "Camera orbiting")
+ (reset-camera)
+ (test "From origin, turn 50 degrees, (get-orbit-center 10)"
+ (vertex 7.66 0.0 -6.43)
+ (vertex-truncate (begin
+ (turn-camera (vertex 0 50 0))
+ (update-camera 1)
+ (get-orbit-center 10))))
+
+ (reset-camera)
+ (test "From origin, turn 70 degrees, walk-forward 5, turn 20 degrees (get-orbit-center 10)"
+ (vertex 14.7 0.0 -1.71)
+ (vertex-truncate (begin
+ (turn-camera (vertex 0 70 0))
+ (update-camera 1)
+ (move-camera-forward 5)
+ (update-camera 1)
+ (turn-camera (vertex 0 20 0))
+ (update-camera 1)
+ (get-orbit-center 10))))
+ (reset-camera)
+ (test-end)
+ (test-end))
+
+(exit)
Please sign in to comment.
Something went wrong with that request. Please try again.