| 1 | package OpenGL::Earth::NetworkHits; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 0 | ▶ | use OpenGL; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 6 | use OpenGL::Earth::Coords; | ||
| 7 | |||
| 8 | our @NETWORK_HITS; | ||
| 9 | |||
| 10 | sub display { | ||
| 11 | my ($hits) = \@NETWORK_HITS; | ||
| 12 | |||
| 13 | push @{ $hits }, generate_random(); | ||
| 14 | |||
| 15 | for my $s (@{ $hits }) { | ||
| 16 | spike($s->[0], $s->[1], $s->[2], 1.5); | ||
| 17 | $s->[2]--; | ||
| 18 | } | ||
| 19 | |||
| 20 | @{ $hits } = grep { $_->[2] > 0 } @{ $hits }; | ||
| 21 | |||
| 22 | return; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub generate_random { | ||
| 26 | |||
| 27 | my $lon = rand(360) - 180; | ||
| 28 | my $lat = rand(180) - 90; | ||
| 29 | my $amplitude = int rand(50) + 50; | ||
| 30 | |||
| 31 | return [ $lat, $lon, $amplitude ]; | ||
| 32 | } | ||
| 33 | |||
| 34 | sub spike { | ||
| 35 | my ($lat, $long, $amount, $radius) = @_; | ||
| 36 | |||
| 37 | # Apply texture offset | ||
| 38 | $long -= 90; | ||
| 39 | |||
| 40 | my ($x1, $y1, $z1) = OpenGL::Earth::Coords::earth_to_xyz($lat, $long, $radius + $amount/200); | ||
| 41 | my ($x2, $y2, $z2) = OpenGL::Earth::Coords::earth_to_xyz($lat, $long + 0.4, $radius); | ||
| 42 | my ($x3, $y3, $z3) = OpenGL::Earth::Coords::earth_to_xyz($lat, $long - 0.4, $radius); | ||
| 43 | |||
| 44 | glBegin(GL_TRIANGLES); | ||
| 45 | glColor3f(1.0, 0.3, 0.3); | ||
| 46 | glVertex3f($x1, $y1, $z1); | ||
| 47 | glVertex3f($x2, $y2, $z2); | ||
| 48 | glVertex3f($x3, $y3, $z3); | ||
| 49 | glEnd(); | ||
| 50 | |||
| 51 | #glLineWidth(1); | ||
| 52 | #glBegin(GL_LINES); | ||
| 53 | # glColor4f(1.0, 0.2, 0.2, 0.6); | ||
| 54 | # glVertex3f(0, 0, 0); | ||
| 55 | # glVertex3f($x1, $y1, $z1); | ||
| 56 | #glEnd(); | ||
| 57 | |||
| 58 | return; | ||
| 59 | } | ||
| 60 | |||
| 61 | 1; | ||
| 62 | |||