My favorites | Sign in
Project Logo
       
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

"""
Instead of only one light, we added here two another lights.
"""

import sys
import math

import direct.directbase.DirectStart
from direct.interval.LerpInterval import LerpFunc
from pandac.PandaModules import PointLight

base.setBackgroundColor(0.0, 0.0, 0.0)
base.disableMouse()

base.camLens.setNearFar(1.0, 50.0)
base.camLens.setFov(45.0)

camera.setPos(0.0, -20.0, 10.0)
camera.lookAt(0.0, 0.0, 0.0)

root = render.attachNewNode("Root")

lights = []

for i in range(3):
light = render.attachNewNode("Light")
modelLight = loader.loadModel("misc/Pointlight.egg.pz")
modelLight.reparentTo(light)
lights += [ light ]

modelCube = loader.loadModel("cube.egg")

cubes = []
for x in [-3.0, 0.0, 3.0]:
cube = modelCube.copyTo(root)
cube.setPos(x, 0.0, 0.0)
cubes += [ cube ]

shader = loader.loadShader("11.sha")
for cube in cubes:
cube.setShader(shader)
for i in range(len(lights)):
cube.setShaderInput("light" + str(i), lights[i])

base.accept("escape", sys.exit)
base.accept("o", base.oobe)

def animate(t):
radius = 4.3
angle = math.radians(t)
x = math.cos(angle) * radius
y = math.sin(angle) * radius
z = math.sin(angle) * radius
lights[0].setPos(x, y, z)
lights[1].setPos(y, x, 0.0)
lights[2].setPos(z, 0.0, x)

def intervalStartPauseResume(i):
if i.isStopped():
i.start()
elif i.isPaused():
i.resume()
else:
i.pause()

interval = LerpFunc(animate, 10.0, 0.0, 360.0)

base.accept("i", intervalStartPauseResume, [interval])

def move(x, y, z):
root.setX(root.getX() + x)
root.setY(root.getY() + y)
root.setZ(root.getZ() + z)

base.accept("d", move, [1.0, 0.0, 0.0])
base.accept("a", move, [-1.0, 0.0, 0.0])
base.accept("w", move, [0.0, 1.0, 0.0])
base.accept("s", move, [0.0, -1.0, 0.0])
base.accept("e", move, [0.0, 0.0, 1.0])
base.accept("q", move, [0.0, 0.0, -1.0])

run()
Show details Hide details

Change log

r25 by azraiyl on Oct 12, 2008   Diff
Typos fixed.
Go to: 
Project members, sign in to write a code review

Older revisions

r20 by azraiyl on Oct 08, 2008   Diff
Added more or less everything I liked
to say. Spellcheck is still missing.
r14 by azraiyl on Sep 25, 2008   Diff
Example 8 - 11 added without any
comment yet.
All revisions of this file

File info

Size: 1989 bytes, 83 lines
Hosted by Google Code