Class: CloudView

Inherits:
View show all
Defined in:
ext/ruby/qtruby/examples/ruboids/ruboids/CloudView.rb

Constant Summary

Constants inherited from View

View::SHADOW_COLOR

Instance Attribute Summary

Attributes inherited from View

#color, #model, #object, #shadow

Instance Method Summary collapse

Methods inherited from View

#draw, #drawObject, #drawShadow, #shadowColorForHeight

Constructor Details

#initialize(cloud) ⇒ CloudView

Returns a new instance of CloudView.



17
18
19
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CloudView.rb', line 17

def initialize(cloud)
	super(cloud)
end

Instance Method Details

#makeObjectObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CloudView.rb', line 21

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

#makeShadowObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CloudView.rb', line 37

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