X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela_draw.lisp;h=15b61e0ca96f0ba03d2b7d70e6d7bb21d603c435;hb=3c076309ea8727753bf689c3524d20116f45a0a3;hp=4b6f58fb126ec746a7c6b0b9d995226ae29bc03e;hpb=862921d72ab5a90aee46074c40da8c0688a3a20d;p=gacela.git diff --git a/gacela_draw.lisp b/gacela_draw.lisp index 4b6f58f..15b61e0 100644 --- a/gacela_draw.lisp +++ b/gacela_draw.lisp @@ -128,7 +128,7 @@ (defun draw-square (&key (size 1) texture) (draw-rectangle size size :texture texture)) -(defun draw-cube (&key size texture texture-1 texture-2 texture-3 texture-4 texture-5 texture-6) +(defun draw-cube (&key (size 1) texture texture-1 texture-2 texture-3 texture-4 texture-5 texture-6) (let ((-size (neg size))) (progn-textures (glNormal3f 0 0 1) @@ -155,10 +155,27 @@ (defun translate (x y &optional (z 0)) (glTranslatef x y z)) -(defun rotate (xrot yrot zrot) +(defun rotate (&rest rot) + (cond ((3d-mode?) (apply #'3d-rotate rot)) + (t (apply #'2d-rotate rot)))) + +(defun 3d-rotate (xrot yrot zrot) (glRotatef xrot 1 0 0) (glRotatef yrot 0 1 0) (glRotatef zrot 0 0 1)) (defun 2d-rotate (rot) - (rotate 0 0 rot)) \ No newline at end of file + (glRotatef rot 0 0 1)) + +(defun to-origin () + (glLoadIdentity) + (cond ((3d-mode?) (camera-look)))) + +(let ((camera-eye '(0 0 0)) (camera-center '(0 0 -100)) (camera-up '(0 1 0))) + (defun set-camera (&key eye center up) + (cond (eye (setq camera-eye eye))) + (cond (center (setq camera-center center))) + (cond (up (setq camera-up up)))) + + (defun camera-look () + (apply #'gluLookAt (concatenate 'list camera-eye camera-center camera-up))))