-
Notifications
You must be signed in to change notification settings - Fork 0
/
leafPanel.sj
59 lines (50 loc) · 1.46 KB
/
leafPanel.sj
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
55
56
57
58
leafPanel #model (
textures : array!texture()
children := array!heap #model()
_world : mat4_identity()
update(sceneRect : 'rect, projection : 'mat4, view : 'mat4, world : 'mat4, light : 'light)'void {
for i : 0 to children.count {
c : children[i]
c.update(sceneRect, projection, view, world, light)
}
void
}
getZ() { 0.0f }
getCenter() { vec3() }
getWorld() { _world }
renderOrQueue(zqueue : 'list!heap #model)'void {
for i : 0 to children.count {
c : children[i]
c.renderOrQueue(zqueue)
}
}
render() {
void
}
fireMouseEvent(mouseEvent : 'mouseEvent)'void {
for i : 0 to children.count {
c : children[i]
c.fireMouseEvent(mouseEvent)
}
}
_angle := 0.1f;
textureToModel(texture : 'texture) {
noise : f32_random() - 0.5f
x : _angle * 2.0f + noise * 0.2f;
y : noise * 3.0f;
z : f32_cos(_angle + noise * 0.2f) * 2.0f;
_angle += 0.8f;
heap model(
id : valid("leaf" + z.asString())
texture : texture
shader : phongTextureShader
model : mat4_translate(vec3(x, y, z))
vertexBuffer : planeVertexBuffer()
hasAlpha : true
) as #model
}
) {
_angle = textures.count as f32 * 0.8f / 2.0f
children = textures.map!heap #model(this.textureToModel)
this
}