summaryrefslogtreecommitdiffstats
path: root/qtruby/rubylib/examples/ruboids/ruboids/CloudView.rb
blob: 75c621779bcb409df16d4a38d107fb35f6745442 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#
# Copyright (c) 2001 by Jim Menard <jimm@io.com>
#
# Released under the same license as Ruby. See
# http://www.ruby-lang.org/en/LICENSE.txt.
#

require 'Qt'
require 'View'
require 'Cloud'
require 'Params'
require 'World'
require 'Graphics'

class CloudView < View

    def initialize(cloud)
	super(cloud)
    end

    def makeObject
	@object = GenLists(1)
	NewList(@object, COMPILE)

	@model.bubbles.each { | bubble |
  	    Color(bubble.color)
	    PushMatrix()
	    Translate(bubble.loc.x, bubble.loc.y, bubble.loc.z)
	    Scale(bubble.radius, bubble.radius, bubble.radius)
	    Graphics.sphere()
	    PopMatrix()
	}

	EndList()
    end

    def makeShadow
	@shadow = GenLists(1)
	NewList(@shadow, COMPILE)

	groundLevel = -($PARAMS['world_height'] / 2) + 1
	@model.bubbles.each { | bubble |
  	    Color(shadowColorForHeight(model.position.y + bubble.loc.y))
	    PushMatrix()
	    Translate(bubble.loc.x, groundLevel, bubble.loc.z)
	    Scale(bubble.radius, 1.0, bubble.radius)
	    Graphics.circle(2)
	    PopMatrix()
	}

	EndList()
    end

end