]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/raylib/demo/mesh-picking/mesh-picking.factor
factor: trim using lists
[factor.git] / extra / raylib / demo / mesh-picking / mesh-picking.factor
index 479ee8ca44f1a6bb719dbf7f3a4b02afca0860d8..2d9b98ad4d26a85662df1c11059ee622f56dc294 100644 (file)
@@ -1,8 +1,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.enums arrays classes.struct combinators.short-circuit
-continuations destructors formatting grouping io.backend io.pathnames kernel math
-math.functions.private math.vectors namespaces raylib sequences threads
-vocabs.metadata ;
+USING: accessors alien.enums arrays combinators.short-circuit
+continuations destructors formatting grouping io.backend io.pathnames
+kernel math math.functions.private math.vectors namespaces raylib
+sequences vocabs.metadata ;
 
 IN: raylib.demo.mesh-picking
 
@@ -12,12 +12,12 @@ CONSTANT: screen-height 800
     screen-width screen-height "raylib [models] example - mesh-picking" init-window ;
 
 : make-camera ( -- camera )
-    Camera3D <struct>
+    Camera3D new
     20 30 20 <Vector3> >>position
     0 10 0 <Vector3> >>target
     0 1.6 0 <Vector3> >>up
     45 >>fovy
-    CAMERA_PERSPECTIVE >>type ;
+    CAMERA_PERSPECTIVE >>projection ;
 
 : resource ( fname -- path )
     "raylib.demo.mesh-picking" "_resources" vocab-file-path swap append-path normalize-path ;
@@ -46,7 +46,7 @@ CONSTANT: screen-height 800
 TUPLE: hit-state name color nearest-hit ;
 : <hit-state> ( -- obj )
     "None" WHITE
-    RayCollision <struct>
+    RayCollision new
     most-positive-finite-float >>distance
     f >>hit
     hit-state boa ;
@@ -103,13 +103,13 @@ TUPLE: tower model bbox position ;
 : draw-cursor ( hit-state -- )
     dup nearest-hit>> hit>> [
         [
-            [ nearest-hit>> position>> ] [ color>> ] bi
+            [ nearest-hit>> point>> ] [ color>> ] bi
             '[ 0.3 0.3 0.3 _ draw-cube ]
             [ 0.3 0.3 0.3 RED draw-cube-wires ] bi
         ]
         [
             nearest-hit>>
-            [ position>> dup ] [ normal>> ] bi v+ RED draw-line-3d
+            [ point>> dup ] [ normal>> ] bi v+ RED draw-line-3d
         ] bi
 
     ]
@@ -127,7 +127,7 @@ SYMBOL: mesh-picking-frame
     ! LOG_ALL set-trace-log-level
     [
         make-camera :> camera
-        Ray <struct> :> ray
+        Ray new :> ray
         init-assets :> ( tower triangle )
 
         f :> bary!
@@ -149,7 +149,7 @@ SYMBOL: mesh-picking-frame
             ray handle-ground-hit
 
             ray triangle first3 handle-triangle-hit
-            [ dup nearest-hit>> position>> triangle first3 vector3-barycenter bary! ] [ f bary! ] if
+            [ dup nearest-hit>> point>> triangle first3 vector3-barycenter bary! ] [ f bary! ] if
 
             ray tower [ model>> ] [ bbox>> ] bi handle-mesh-hit hit-mesh-bbox!
 
@@ -171,7 +171,7 @@ SYMBOL: mesh-picking-frame
             nearest-hit>> dup hit>> [
                 70 :> ypos
                 [ distance>> "Distance: %3.2f" sprintf 10 ypos 10 BLACK draw-text ]
-                [ position>> first3 "Hit Pos: %3.2f %3.2f %3.2f" sprintf 10 ypos 15 + 10 BLACK draw-text ]
+                [ point>> first3 "Hit Pos: %3.2f %3.2f %3.2f" sprintf 10 ypos 15 + 10 BLACK draw-text ]
                 [ normal>> first3 "Hit Norm: %3.2f %3.2f %3.2f" sprintf 10 ypos 30 + 10 BLACK draw-text ]
                 tri
                 bary [ first3