gpu.util.wasd: new utility word "wasd-pixel-ray" that converts a screen pixel position to a world-space vector, indicating direction from eye location

db4
Joe Groff 2010-06-23 00:48:17 -07:00
parent 68cd067f31
commit c7a2ef4d4f
1 changed files with 10 additions and 1 deletions

View File

@ -54,13 +54,22 @@ M: wasd-world wasd-fly-vertically? drop t ;
CONSTANT: fov 0.7 CONSTANT: fov 0.7
: wasd-fov-vector ( world -- fov )
dim>> dup first2 min >float v/n fov v*n ; inline
:: generate-p-matrix ( world -- matrix ) :: generate-p-matrix ( world -- matrix )
world wasd-near-plane :> near-plane world wasd-near-plane :> near-plane
world wasd-far-plane :> far-plane world wasd-far-plane :> far-plane
world dim>> dup first2 min >float v/n fov v*n near-plane v*n world wasd-fov-vector near-plane v*n
near-plane far-plane frustum-matrix4 ; near-plane far-plane frustum-matrix4 ;
:: wasd-pixel-ray ( world loc -- direction )
loc world dim>> [ /f 0.5 - 2.0 * ] 2map
world wasd-fov-vector v*
first2 neg -1.0 0.0 4array
world wasd-mv-inv-matrix swap m.v ;
: set-wasd-view ( world location yaw pitch -- world ) : set-wasd-view ( world location yaw pitch -- world )
[ >>location ] [ >>yaw ] [ >>pitch ] tri* ; [ >>location ] [ >>yaw ] [ >>pitch ] tri* ;