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
parent
68cd067f31
commit
c7a2ef4d4f
|
@ -54,13 +54,22 @@ M: wasd-world wasd-fly-vertically? drop t ;
|
|||
|
||||
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 )
|
||||
world wasd-near-plane :> near-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 ;
|
||||
|
||||
:: 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 )
|
||||
[ >>location ] [ >>yaw ] [ >>pitch ] tri* ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue