~ubuntu-app-review-contributors/ubuntu-app-reviews/tetracity

« back to all changes in this revision

Viewing changes to buildingviewer.rb

  • Committer: App Bot
  • Date: 2012-06-12 11:22:25 UTC
  • Revision ID: appbot@holba.ch-20120612112225-v3lrlhszpurkxf56
initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
###
 
2
#
 
3
#    TetraCity
 
4
#    Copyright (C) 2010, 2011 Levi D. Smith
 
5
#
 
6
#    TetraCity is free software: you can redistribute it and/or modify
 
7
#    it under the terms of the GNU General Public License as published by
 
8
#    the Free Software Foundation, either version 3 of the License, or
 
9
#    (at your option) any later version.
 
10
#
 
11
#    TetraCity is distributed in the hope that it will be useful,
 
12
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
#    GNU General Public License for more details.
 
15
#
 
16
#    You should have received a copy of the GNU General Public License
 
17
#    along with TetraCity.  If not, see <http://www.gnu.org/licenses/gpl.txt>.
 
18
#
 
19
###
 
20
 
 
21
LIGHT_SPEED = 0.05 #the speed at which the flashlight moves
 
22
 
 
23
class BuildingViewerOptions
 
24
 
 
25
  def initialize()
 
26
    @x_translate = 0.0
 
27
    @y_translate = 0.0
 
28
    @z_translate = 0.0
 
29
    
 
30
    @x_rotate = 0.0
 
31
    @y_rotate = 0.0
 
32
    @z_rotate = 0.0
 
33
    
 
34
    @x_light = 0.0
 
35
    @y_light = 0.0
 
36
    @z_light = 0.0
 
37
    
 
38
    @rotate_toggle = false
 
39
    @light_control_toggle = false
 
40
    
 
41
    @x_translate_vel = 0.0
 
42
    @y_translate_vel = 0.0
 
43
    @z_translate_vel = 0.0
 
44
    
 
45
    @x_rotate_vel = 0.0
 
46
    @y_rotate_vel = 0.0
 
47
    @z_rotate_vel = 0.0
 
48
    
 
49
    @x_light_vel = 0.0
 
50
    @y_light_vel = 0.0
 
51
    @z_light_vel = 0.0
 
52
 
 
53
  end
 
54
  
 
55
  def x_translate
 
56
    @x_translate
 
57
  end
 
58
 
 
59
  def y_translate
 
60
    @y_translate
 
61
  end
 
62
  
 
63
  def z_translate
 
64
    @z_translate
 
65
  end
 
66
  
 
67
  def rotate_toggle
 
68
    @rotate_toggle
 
69
  end
 
70
  
 
71
  def x_rotate
 
72
    @x_rotate
 
73
  end
 
74
  
 
75
  def y_rotate
 
76
    @y_rotate
 
77
  end
 
78
 
 
79
  def z_rotate
 
80
    @z_rotate
 
81
  end
 
82
 
 
83
  def x_light
 
84
    @x_light
 
85
  end
 
86
 
 
87
  def y_light
 
88
    @y_light
 
89
  end
 
90
 
 
91
  def z_light
 
92
    @z_light
 
93
  end
 
94
 
 
95
  def x_translate_vel
 
96
    @x_translate_vel
 
97
  end
 
98
 
 
99
  def y_translate_vel
 
100
    @y_translate_vel
 
101
  end
 
102
  
 
103
  def z_translate_vel
 
104
    @z_translate_vel
 
105
  end
 
106
  
 
107
  def x_rotate_vel
 
108
    @x_rotate_vel
 
109
  end
 
110
  
 
111
  def y_rotate_vel
 
112
    @y_rotate_vel
 
113
  end
 
114
 
 
115
  def z_rotate_vel
 
116
    @z_rotate_vel
 
117
  end
 
118
 
 
119
  def x_light_vel
 
120
    @x_light_vel
 
121
  end
 
122
 
 
123
  def y_light_vel
 
124
    @y_light_vel
 
125
  end
 
126
 
 
127
  def z_light_vel
 
128
    @z_light_vel
 
129
  end
 
130
 
 
131
  attr_accessor :x_translate
 
132
  attr_accessor :y_translate
 
133
  attr_accessor :z_translate
 
134
  attr_accessor :x_rotate
 
135
  attr_accessor :y_rotate
 
136
  attr_accessor :z_rotate  
 
137
  attr_accessor :x_light
 
138
  attr_accessor :y_light
 
139
  attr_accessor :z_light
 
140
 
 
141
  attr_accessor :rotate_toggle
 
142
  attr_accessor :light_control_toggle
 
143
 
 
144
  attr_accessor :x_translate_vel
 
145
  attr_accessor :y_translate_vel
 
146
  attr_accessor :z_translate_vel
 
147
  attr_accessor :x_rotate_vel
 
148
  attr_accessor :y_rotate_vel
 
149
  attr_accessor :z_rotate_vel  
 
150
  attr_accessor :x_light_vel
 
151
  attr_accessor :y_light_vel
 
152
  attr_accessor :z_light_vel
 
153
 
 
154
end
 
155
 
 
156
$theBuildingViewerOptions = BuildingViewerOptions.new()
 
157
$viewingObject = 0
 
158
 
 
159
def buildingViewerLoop
 
160
  keepLooping = true
 
161
 
 
162
  initBuildingViewer() 
 
163
  resetView()
 
164
  
 
165
  while keepLooping
 
166
    drawBuildingViewer
 
167
    updateCoordinates
 
168
    
 
169
    while event = SDL::Event2.poll
 
170
      case event
 
171
        when SDL::Event::KeyUp
 
172
          puts "Key Up"
 
173
          $theBuildingViewerOptions.x_rotate_vel = 0.0
 
174
          $theBuildingViewerOptions.y_rotate_vel = 0.0
 
175
          $theBuildingViewerOptions.z_rotate_vel = 0.0
 
176
          
 
177
          $theBuildingViewerOptions.x_translate_vel = 0.0
 
178
          $theBuildingViewerOptions.y_translate_vel = 0.0
 
179
          $theBuildingViewerOptions.z_translate_vel = 0.0
 
180
 
 
181
          $theBuildingViewerOptions.x_light_vel = 0.0
 
182
          $theBuildingViewerOptions.y_light_vel = 0.0
 
183
          $theBuildingViewerOptions.z_light_vel = 0.0
 
184
 
 
185
          
 
186
        when SDL::Event::KeyDown
 
187
          case event.sym
 
188
            when SDL::Key::UP
 
189
              puts "UP pressed"
 
190
              
 
191
              if ($theBuildingViewerOptions.rotate_toggle)
 
192
                $theBuildingViewerOptions.x_rotate_vel -= 1
 
193
              elsif ($theBuildingViewerOptions.light_control_toggle)
 
194
                $theBuildingViewerOptions.z_light_vel -= LIGHT_SPEED
 
195
              else 
 
196
                $theBuildingViewerOptions.z_translate_vel -= 0.05
 
197
              end
 
198
              
 
199
 
 
200
            when SDL::Key::DOWN
 
201
              puts "DOWN pressed"
 
202
 
 
203
              if ($theBuildingViewerOptions.rotate_toggle)
 
204
                $theBuildingViewerOptions.x_rotate_vel += 1
 
205
              elsif ($theBuildingViewerOptions.light_control_toggle)
 
206
                $theBuildingViewerOptions.z_light_vel += LIGHT_SPEED
 
207
              else 
 
208
                $theBuildingViewerOptions.z_translate_vel += 0.05
 
209
              end
 
210
              
 
211
              
 
212
            when SDL::Key::LEFT
 
213
              puts "LEFT pressed"
 
214
              
 
215
              if ($theBuildingViewerOptions.rotate_toggle)
 
216
                $theBuildingViewerOptions.y_rotate_vel -= 1
 
217
              elsif ($theBuildingViewerOptions.light_control_toggle)
 
218
                $theBuildingViewerOptions.x_light_vel -= LIGHT_SPEED
 
219
              else 
 
220
                $theBuildingViewerOptions.x_translate_vel -= 0.05
 
221
              end
 
222
 
 
223
              
 
224
 
 
225
            when SDL::Key::RIGHT
 
226
              puts "RIGHT pressed"
 
227
 
 
228
              if ($theBuildingViewerOptions.rotate_toggle)
 
229
                $theBuildingViewerOptions.y_rotate_vel += 1
 
230
              elsif ($theBuildingViewerOptions.light_control_toggle)
 
231
                $theBuildingViewerOptions.x_light_vel += LIGHT_SPEED
 
232
 
 
233
              else 
 
234
                $theBuildingViewerOptions.x_translate_vel += 0.05
 
235
              end
 
236
 
 
237
            when SDL::Key::A
 
238
              puts "A pressed"
 
239
 
 
240
              if ($theBuildingViewerOptions.rotate_toggle)
 
241
                $theBuildingViewerOptions.z_rotate_vel -= 1
 
242
              elsif ($theBuildingViewerOptions.light_control_toggle)
 
243
                $theBuildingViewerOptions.y_light_vel -= LIGHT_SPEED
 
244
 
 
245
              else 
 
246
                $theBuildingViewerOptions.y_translate_vel -= 0.05
 
247
              end
 
248
 
 
249
            when SDL::Key::S
 
250
              puts "S pressed"
 
251
 
 
252
              if ($theBuildingViewerOptions.rotate_toggle)
 
253
                $theBuildingViewerOptions.z_rotate_vel += 1
 
254
                
 
255
              elsif ($theBuildingViewerOptions.light_control_toggle)
 
256
                $theBuildingViewerOptions.y_light_vel += LIGHT_SPEED
 
257
                
 
258
              else 
 
259
                $theBuildingViewerOptions.y_translate_vel += 0.05
 
260
              end
 
261
 
 
262
            when SDL::Key::BACKSPACE
 
263
              puts "Reset"
 
264
              resetView()
 
265
              
 
266
 
 
267
            when SDL::Key::SPACE
 
268
              puts "SPACE pressed"
 
269
              $viewingObject += 1
 
270
              
 
271
              if ($viewingObject > 8)
 
272
                  $viewingObject = 0
 
273
              end
 
274
 
 
275
              puts "Viewing object #{$viewingObject}"
 
276
 
 
277
            if ($viewingObject == 0)
 
278
              puts "R1"
 
279
            elsif ($viewingObject == 1)
 
280
              puts "R2"
 
281
            elsif ($viewingObject == 2)
 
282
              puts "R3"
 
283
            elsif ($viewingObject == 3)
 
284
              puts "C1"
 
285
            elsif ($viewingObject == 4)
 
286
              puts "C2"
 
287
            elsif ($viewingObject == 5)
 
288
              puts "C3"
 
289
            elsif ($viewingObject == 6)
 
290
              puts "I1"
 
291
            elsif ($viewingObject == 7)
 
292
              puts "I2"
 
293
            elsif ($viewingObject == 8)
 
294
              puts "I3"
 
295
            end
 
296
 
 
297
              
 
298
            when SDL::Key::R
 
299
              puts "R pressed"
 
300
              $theBuildingViewerOptions.rotate_toggle = true
 
301
              $theBuildingViewerOptions.light_control_toggle = false
 
302
 
 
303
            when SDL::Key::L
 
304
              puts "L pressed"
 
305
              $theBuildingViewerOptions.rotate_toggle = false
 
306
              $theBuildingViewerOptions.light_control_toggle = true
 
307
 
 
308
            when SDL::Key::T
 
309
              puts "T pressed"
 
310
              $theBuildingViewerOptions.rotate_toggle = false
 
311
              $theBuildingViewerOptions.light_control_toggle = false
 
312
              
 
313
            when SDL::Key::D
 
314
              puts "D pressed"
 
315
              puts "Display coordinates"
 
316
              
 
317
              puts "translate: #{$theBuildingViewerOptions.x_translate}, #{$theBuildingViewerOptions.y_translate}, #{$theBuildingViewerOptions.z_translate}"
 
318
              puts "rotate: #{$theBuildingViewerOptions.x_rotate}, #{$theBuildingViewerOptions.y_rotate}, #{$theBuildingViewerOptions.z_rotate}"
 
319
              puts "light: #{$theBuildingViewerOptions.x_light}, #{$theBuildingViewerOptions.y_light}, #{$theBuildingViewerOptions.z_light}"
 
320
 
 
321
 
 
322
            when SDL::Key::Q
 
323
              keepLooping = false
 
324
              
 
325
            end
 
326
            
 
327
          end
 
328
 
 
329
    end            
 
330
 
 
331
  end
 
332
  
 
333
  
 
334
end
 
335
 
 
336
def resetView()
 
337
              $theBuildingViewerOptions.x_translate = 0.0
 
338
              $theBuildingViewerOptions.y_translate = 0.0
 
339
              $theBuildingViewerOptions.z_translate = -22.0
 
340
 
 
341
              $theBuildingViewerOptions.x_rotate = 33.0
 
342
              $theBuildingViewerOptions.y_rotate = 33.0
 
343
              $theBuildingViewerOptions.z_rotate = 0.0
 
344
              
 
345
              $theBuildingViewerOptions.x_light = 6.0
 
346
              $theBuildingViewerOptions.y_light = 0.0
 
347
              $theBuildingViewerOptions.z_light = 0.0
 
348
  
 
349
end
 
350
 
 
351
def updateCoordinates
 
352
  $theBuildingViewerOptions.x_translate += $theBuildingViewerOptions.x_translate_vel
 
353
  $theBuildingViewerOptions.y_translate += $theBuildingViewerOptions.y_translate_vel
 
354
  $theBuildingViewerOptions.z_translate += $theBuildingViewerOptions.z_translate_vel
 
355
 
 
356
  $theBuildingViewerOptions.x_rotate += $theBuildingViewerOptions.x_rotate_vel
 
357
  $theBuildingViewerOptions.y_rotate += $theBuildingViewerOptions.y_rotate_vel
 
358
  $theBuildingViewerOptions.z_rotate += $theBuildingViewerOptions.z_rotate_vel
 
359
 
 
360
  $theBuildingViewerOptions.x_light += $theBuildingViewerOptions.x_light_vel
 
361
  $theBuildingViewerOptions.y_light += $theBuildingViewerOptions.y_light_vel
 
362
  $theBuildingViewerOptions.z_light += $theBuildingViewerOptions.z_light_vel
 
363
  
 
364
end
 
365
 
 
366
def initBuildingViewer
 
367
glViewport( 0, 0, 1024, 768 );
 
368
glMatrixMode( GL_PROJECTION );
 
369
glLoadIdentity( );
 
370
 
 
371
  gluPerspective(45.0, 1024.0/768.0, 0.1, 50.0)
 
372
 
 
373
glMatrixMode( GL_MODELVIEW );
 
374
glLoadIdentity( );
 
375
 
 
376
glEnable(GL_DEPTH_TEST);
 
377
 
 
378
glDepthFunc(GL_LESS);
 
379
 
 
380
glShadeModel(GL_SMOOTH);
 
381
 
 
382
### LIGHTING ###
 
383
 
 
384
  ambientLight = [0.2, 0.2, 0.2, 1.0]
 
385
  diffuseLight = [0.8, 0.8, 0.8, 1.0]
 
386
  specularLight = [0.5, 0.5, 0.5, 1.0]
 
387
 
 
388
  position = [ 0.0, 0.0, 8.0, 1.0]
 
389
 
 
390
  glLight(GL_LIGHT0, GL_AMBIENT, ambientLight)
 
391
  glLight(GL_LIGHT0, GL_DIFFUSE, diffuseLight)
 
392
  glLight(GL_LIGHT0, GL_SPECULAR, specularLight)
 
393
  
 
394
  glEnable(GL_COLOR_MATERIAL)
 
395
  glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE)
 
396
 
 
397
### END LIGHTING ###
 
398
end
 
399
 
 
400
def drawBuildingViewer
 
401
  useMultipleColors = false
 
402
 
 
403
cube =
 
404
  [[ 0.5,  0.5, -0.5], 
 
405
  [ 0.5, -0.5, -0.5],
 
406
  [-0.5, -0.5, -0.5],
 
407
  [-0.5,  0.5, -0.5],
 
408
  [-0.5,  0.5,  0.5],
 
409
  [ 0.5,  0.5,  0.5],
 
410
  [ 0.5, -0.5,  0.5],
 
411
  [-0.5, -0.5,  0.5]]
 
412
  
 
413
  
 
414
    glClearColor(0.0, 0.0, 0.0, 1.0);
 
415
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
 
416
 
 
417
  glLoadIdentity
 
418
 
 
419
  position = [$theBuildingViewerOptions.x_light, $theBuildingViewerOptions.y_light, $theBuildingViewerOptions.z_light]
 
420
 
 
421
  glLight(GL_LIGHT0, GL_POSITION, position)  
 
422
 
 
423
  glLoadIdentity
 
424
 
 
425
  glTranslate($theBuildingViewerOptions.x_translate, $theBuildingViewerOptions.y_translate, $theBuildingViewerOptions.z_translate)
 
426
  glRotate($theBuildingViewerOptions.x_rotate, 1.0, 0.0, 0.0)
 
427
  glRotate($theBuildingViewerOptions.y_rotate, 0.0, 1.0, 0.0)
 
428
  glRotate($theBuildingViewerOptions.z_rotate, 0.0, 0.0, 1.0)
 
429
  
 
430
 
 
431
  drawFlashlight
 
432
  glEnable(GL_LIGHTING)
 
433
  glEnable(GL_LIGHT0)
 
434
 
 
435
    glTranslate(-1.0, 0.0, 0.0)
 
436
    quadratic = gluNewQuadric()
 
437
    gluSphere(quadratic, 1.3, 16, 16)
 
438
 
 
439
  glTranslate(5.0, 0.0, 0.0)
 
440
 
 
441
            buildingColor = [1.0, 1.0, 1.0]
 
442
 
 
443
            if ($viewingObject == 0)
 
444
              theModel = $modelR1
 
445
              theDisplayList = $displayListR1
 
446
              buildingColor = [1.0, 0.0, 0.0]
 
447
            elsif ($viewingObject == 1)
 
448
              theModel = $modelR2
 
449
              theDisplayList = $displayListR2
 
450
              buildingColor = [1.0, 0.0, 0.0]
 
451
            elsif ($viewingObject == 2)
 
452
              theModel = $modelR3
 
453
              theDisplayList = $displayListR3
 
454
              buildingColor = [1.0, 0.0, 0.0]
 
455
            elsif ($viewingObject == 3)
 
456
              theModel = $modelC1
 
457
              theDisplayList = $displayListC1
 
458
              buildingColor = [0.0, 0.0, 1.0]
 
459
            elsif ($viewingObject == 4)
 
460
              theModel = $modelC2
 
461
              theDisplayList = $displayListC2
 
462
              buildingColor = [0.0, 0.0, 1.0]
 
463
            elsif ($viewingObject == 5)
 
464
              theModel = $modelC3
 
465
              theDisplayList = $displayListC3
 
466
              buildingColor = [0.0, 0.0, 1.0]
 
467
            elsif ($viewingObject == 6)
 
468
              theModel = $modelI1
 
469
              theDisplayList = $displayListI1
 
470
              buildingColor = [1.0, 1.0, 0.0]
 
471
            elsif ($viewingObject == 7)
 
472
              theModel = $modelI2
 
473
              theDisplayList = $displayListI2
 
474
              buildingColor = [1.0, 1.0, 0.0]
 
475
            elsif ($viewingObject == 8)
 
476
              theModel = $modelI3
 
477
              theDisplayList = $displayListI3
 
478
              buildingColor = [1.0, 1.0, 0.0]
 
479
            else
 
480
              theModel = $modelR1
 
481
              theDisplayList = $displayListR1
 
482
            end
 
483
 
 
484
            
 
485
 
 
486
              glColor(buildingColor)
 
487
              glCallList(theDisplayList)
 
488
 
 
489
  glDisable(GL_LIGHT0)
 
490
  glDisable(GL_LIGHTING)
 
491
  
 
492
  glMatrixMode(GL_MODELVIEW);
 
493
  
 
494
  SDL::GL.swap_buffers
 
495
  
 
496
end
 
497
 
 
498
def drawBuilding(theModel, xTranslate, yTranslate, zTranslate)
 
499
 
 
500
  glPushMatrix()
 
501
    glTranslate(xTranslate, yTranslate, zTranslate)
 
502
 
 
503
              for iModelFace in 0 .. (theModel.faceVertexArray.length - 1)
 
504
                
 
505
                glBegin(GL_POLYGON) 
 
506
                  
 
507
 
 
508
                for iVertexIndex in 0 .. (theModel.faceVertexArray[iModelFace].length - 1)
 
509
                  
 
510
                  iVertex = theModel.faceVertexArray[iModelFace][iVertexIndex]
 
511
                  iNormal = theModel.faceNormalArray[iModelFace][iVertexIndex]
 
512
                  
 
513
                  glNormal(theModel.normalArray[iNormal][0], theModel.normalArray[iNormal][1], theModel.normalArray[iNormal][2])
 
514
                  glVertex(theModel.vertexArray[iVertex][0], theModel.vertexArray[iVertex][1], theModel.vertexArray[iVertex][2])
 
515
                  
 
516
                end
 
517
 
 
518
              glEnd
 
519
 
 
520
              end
 
521
 
 
522
  glPopMatrix()
 
523
 
 
524
end
 
525
 
 
526
def calculateNormal(p1, p2, p3)
 
527
  
 
528
  normalVector = [0.0, 0.0, 0.0]
 
529
  
 
530
  v1 = [ p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] ]
 
531
  v2 = [ p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2] ]
 
532
  
 
533
  
 
534
  
 
535
  crossX = (v1[1] * v2[2]) - (v1[2] * v2[1])
 
536
  crossY = -((v2[2] * v1[0]) - (v2[0] * v1[2]))
 
537
  crossZ = (v1[0] * v2[1]) - (v1[1] * v2[0])
 
538
  
 
539
  normal = [crossX, crossY, crossZ]
 
540
  
 
541
  normalFactor = ( (crossX ** 2) + (crossY ** 2) + (crossZ ** 2)) ** 0.5
 
542
  
 
543
  if (normalFactor != 0.0) 
 
544
    normal[0]  = normal[0] / normalFactor
 
545
    normal[1] = normal[1] / normalFactor
 
546
    normal[2] = normal[2] / normalFactor
 
547
  end
 
548
  
 
549
 
 
550
  return normal
 
551
end
 
552
 
 
553
def drawCoordinatesText()
 
554
  
 
555
 
 
556
  glPushMatrix
 
557
  glLoadIdentity()
 
558
  
 
559
  colorFgSDL = [255, 255, 255]
 
560
  colorBkgSDL = [192, 192, 192]
 
561
 
 
562
  glOrtho(0, 1024, 768, 0, -1, 1)
 
563
  glColor(1.0, 1.0, 1.0)
 
564
 
 
565
  colorBkgSDL = [192, 192, 192]
 
566
  if (!$theBuildingViewerOptions.rotate_toggle && !$theBuildingViewerOptions.light_control_toggle)
 
567
    colorBkgSDL = [0, 0, 255]
 
568
  end
 
569
 
 
570
  drawMenuText( "TranslateX: #{$theBuildingViewerOptions.x_translate}", 0, (16 * 0), 128, 16, colorFgSDL, colorBkgSDL )
 
571
  drawMenuText( "TranslateY: #{$theBuildingViewerOptions.y_translate}", 0, (16 * 1), 128, 16, colorFgSDL, colorBkgSDL )
 
572
  drawMenuText( "TranslateZ: #{$theBuildingViewerOptions.z_translate}", 0, (16 * 2), 128, 16, colorFgSDL, colorBkgSDL )
 
573
 
 
574
  colorBkgSDL = [192, 192, 192]
 
575
  if ($theBuildingViewerOptions.rotate_toggle)
 
576
    colorBkgSDL = [0, 0, 255]
 
577
  end
 
578
 
 
579
  drawMenuText( "RotateX: #{$theBuildingViewerOptions.x_rotate}", 0, (16 * 3), 128, 16, colorFgSDL, colorBkgSDL )
 
580
  drawMenuText( "RotateY: #{$theBuildingViewerOptions.y_rotate}", 0, (16 * 4), 128, 16, colorFgSDL, colorBkgSDL )
 
581
  drawMenuText( "RotateZ: #{$theBuildingViewerOptions.z_rotate}", 0, (16 * 5), 128, 16, colorFgSDL, colorBkgSDL )
 
582
 
 
583
  colorBkgSDL = [192, 192, 192]
 
584
  if (!$theBuildingViewerOptions.rotate_toggle && $theBuildingViewerOptions.light_control_toggle)
 
585
    colorBkgSDL = [0, 0, 255]
 
586
  end
 
587
 
 
588
  drawMenuText( "LightX: #{$theBuildingViewerOptions.x_light}", 0, (16 * 6), 128, 16, colorFgSDL, colorBkgSDL )
 
589
  drawMenuText( "LightY: #{$theBuildingViewerOptions.y_light}", 0, (16 * 7), 128, 16, colorFgSDL, colorBkgSDL )
 
590
  drawMenuText( "LightZ: #{$theBuildingViewerOptions.z_light}", 0, (16 * 8), 128, 16, colorFgSDL, colorBkgSDL )
 
591
 
 
592
  glPopMatrix
 
593
 
 
594
end
 
595
 
 
596
def drawFlashlight
 
597
  glBegin(GL_QUADS)
 
598
    glColor(1.0, 1.0, 0.0)  
 
599
    glVertex($theBuildingViewerOptions.x_light, $theBuildingViewerOptions.y_light + 0.1, $theBuildingViewerOptions.z_light)
 
600
    glVertex($theBuildingViewerOptions.x_light, $theBuildingViewerOptions.y_light, $theBuildingViewerOptions.z_light)
 
601
    glVertex($theBuildingViewerOptions.x_light + 0.1, $theBuildingViewerOptions.y_light, $theBuildingViewerOptions.z_light)
 
602
    glVertex($theBuildingViewerOptions.x_light + 0.1, $theBuildingViewerOptions.y_light + 0.1, $theBuildingViewerOptions.z_light)
 
603
 
 
604
  glColor(1.0, 1.0, 1.0)
 
605
    glVertex($theBuildingViewerOptions.x_light, $theBuildingViewerOptions.y_light + 0.1, $theBuildingViewerOptions.z_light - 0.1)
 
606
    glVertex($theBuildingViewerOptions.x_light, $theBuildingViewerOptions.y_light, $theBuildingViewerOptions.z_light - 0.1)
 
607
    glVertex($theBuildingViewerOptions.x_light + 0.1, $theBuildingViewerOptions.y_light, $theBuildingViewerOptions.z_light - 0.1)
 
608
    glVertex($theBuildingViewerOptions.x_light + 0.1, $theBuildingViewerOptions.y_light + 0.1, $theBuildingViewerOptions.z_light - 0.1)
 
609
  
 
610
  glEnd
 
611
  
 
612
end