@@ -13,17 +13,14 @@ class FlightPatterns < Processing::App
1313 attr_reader :flee , :radius
1414
1515 def settings
16- size 1024 , 750 , P3D
16+ size 1024 , 750 , P2D
1717 end
1818
1919 def setup
20- sketch_title 'Flight Patterns'
20+ sketch_title 'Flight Patterns'
2121 sphere_detail 8
2222 color_mode RGB , 1.0
2323 no_stroke
24- shininess 1.0
25- specular 0.3 , 0.1 , 0.1
26- emissive 0.03 , 0.03 , 0.1
2724 @radius = 0.02 * height
2825 @click = false
2926 @flee = false
@@ -41,24 +38,19 @@ def key_pressed
4138
4239 def draw
4340 background 0.05
44- ambient_light 0.01 , 0.01 , 0.01
45- light_specular 0.4 , 0.2 , 0.2
46- point_light 1.0 , 1.0 , 1.0 , mouse_x , mouse_y , 190
4741 @flocks . each_with_index do |flock , i |
48- flock . goal ( target : Vec3D . new ( mouse_x , mouse_y , 0 ) , flee : @flee )
42+ flock . goal ( target : Vec2D . new ( mouse_x , mouse_y ) , flee : @flee )
4943 flock . update ( goal : 185 , limit : 13.5 )
5044 flock . each do |boid |
51- r = ( 0.15 * boid . pos . z ) + radius
5245 case i
5346 when 0 then fill 0.85 , 0.65 , 0.65
5447 when 1 then fill 0.65 , 0.85 , 0.65
5548 when 2 then fill 0.65 , 0.65 , 0.85
5649 end
5750 push_matrix
58- point_array = ( boid . pos . to_a ) . map { |p | p - ( r / 2.0 ) }
51+ point_array = ( boid . pos . to_a ) . map { |p | p - ( radius / 2.0 ) }
5952 translate ( *point_array )
60- @click ? sphere ( r / 2 ) : ellipse ( 0 , 0 , r , r )
61- @click ? hint ( ENABLE_DEPTH_TEST ) : hint ( DISABLE_DEPTH_TEST )
53+ ellipse ( 0 , 0 , radius , radius )
6254 pop_matrix
6355 end
6456 end
0 commit comments