WARNING LOTS OF HIGH SCHOOL MATHEMATICS WRITTEN AS CASUAL LISP Kind of a mastodon-ish question. Is this a useful notion of VR? Imagine I'm in a box (in one of jns' VR mechs). I keep my head in a precise position. I know the exact relative position of a monitor. I am a cyclops. (defparameter eyes #(0 0 0)) (defparameter tl-mon '#(a b c)) (defparameter top-vec-mon '#(tmx tmy tmz)) (defparameter left-vec-mon '#(lmx lmy lmz)) ;;The monitor and my cyclopean eye are defined; ;;The monitor might have liked to have been in spherical polar ;;but it doesn't matter. ;; Then in cyberspace, I have panels. Panels are the same as monitors. (defparameter tl-pan '#(d e f)) (defparameter top-vec-pan '#(tpx tpy tpz)) (defparameter left-vec-pan '#(lpx lpy lpz)) ;;The vectors are unnormalised; their mag is their mag ;;Then I need to map points on the monitor to positions on the ;;plane of the VR panel as a function of my eye-position. ;;This is easy, because my eye is at #(0 0 0) so every position ;;on my monitor is just the position on my monitor. (defun dot (scale simple-array) (loop for n from 0 for a_n across simple-array for scaled-a_n = (* scale a_n) do (setf (aref simple-array n) scaled-a_n))) (defun add->vec1 (vec1 vec2) (loop for val across vec2 for n from 0 do (incf (aref vec val)) finally (return vec1))) (defun eye->panel (t1 t2) (add->vec1 (dot t1 top-vec-pan) (dot t2 left-vecpan))) ;;Which forms a vector, to intersect with the plane the VR panel ;;lies on. (defun intersect (x y &aux norm (norm (eye->panel x y))) "Hmmm how does this work again it's been a while since high school" (let ((coef (/ (norm tl-pan) norm)) (eyeliner (dot (/ norm) (eye->panel x y)))) (dot coef eyeliner))) ;;Well I will check my high school algebra working later ;;but it turns out to be easy to pass a line from the eye ;;through one planar window some distance onto a second plane ;;(where it could be somewhere within bounds of the panel) #| Given that this is trivial, I can have any number of monitor windows projecting onto any number of VR panels. I guess I still need to project whatever of the panel is visible onto the plane whose normal is the line from the eye (averaged). High school algebra is pretty hardcore tbh The operations used are level-1 BLAS. This is trivial to render with a monospace font in SDL2. Now, what was gopherVR again... |#