63 |
SlideLin("seed", 42, 1, "seed number", "A", "a"), |
SlideLin("seed", 42, 1, "seed number", "A", "a"), |
64 |
SlideLin("seed2", 42, 1, "highlihght seed number", "Z", "z"), |
SlideLin("seed2", 42, 1, "highlihght seed number", "Z", "z"), |
65 |
Toggle("path2", 0, "length-2 path", "2"), |
Toggle("path2", 0, "length-2 path", "2"), |
66 |
|
Toggle("perspective", 0, "perspective", "F"), |
67 |
*light3d.commonkeys |
*light3d.commonkeys |
68 |
) |
) |
69 |
self.list = None |
self.list = None |
|
|
|
70 |
self.box = 800 |
self.box = 800 |
71 |
|
self.hl_only = 0 |
72 |
|
|
73 |
class Listener(RelativeAxisListener): |
class Listener(RelativeAxisListener): |
74 |
def __init__(self, changed): |
def __init__(self, changed): |
146 |
nodes) |
nodes) |
147 |
|
|
148 |
if 1: |
if 1: |
149 |
|
# path2 = direct neighbor |
150 |
if self.path2: |
if self.path2: |
151 |
nodes2 = filter(lambda y: y["cs"] in x["conns"], nodes) |
nodes2 = filter(lambda y: y["cs"] in x["conns"], nodes) |
152 |
else: |
else: |
170 |
x, y = None, None |
x, y = None, None |
171 |
|
|
172 |
def pc(conns, cs): |
def pc(conns, cs): |
173 |
|
if self.hl_only: |
174 |
|
vs.put(getDListNocoords("Color 1 0 0")) |
175 |
|
if x != None: vs.put(conns, cs + [x["cs"]]) |
176 |
|
if y != None: vs.put(conns, cs + [y["cs"]]) |
177 |
|
return |
178 |
|
|
179 |
for node in nodes: |
for node in nodes: |
180 |
if node in [x, y]: |
if node in [x, y]: |
181 |
vs.put(getDListNocoords("Color 1 0 0")) |
vs.put(getDListNocoords("Color 1 0 0")) |
206 |
def scene(self, vs): |
def scene(self, vs): |
207 |
vs.put( background((.5,1,.2))) |
vs.put( background((.5,1,.2))) |
208 |
|
|
|
cs = vs.scaleCS(0, "cs", 1, 1, 1) |
|
209 |
size = vs.getSize() |
size = vs.getSize() |
210 |
|
|
211 |
|
cs = 0 |
212 |
|
if self.perspective: |
213 |
|
fov = 45 |
214 |
|
zmin = 1 |
215 |
|
zmax = 2500 |
216 |
|
dist = 1500 |
217 |
|
|
218 |
|
y = zmin * math.tan(fov * math.pi / 360) |
219 |
|
aspect = float(size.width) / size.height |
220 |
|
|
221 |
|
vs.put(getDListNocoords(""" |
222 |
|
MatrixMode PROJECTION |
223 |
|
LoadIdentity |
224 |
|
Frustum %s %s %s %s %s %s |
225 |
|
Scale 1 -1 -1 |
226 |
|
Translate -%s -%s %s |
227 |
|
MatrixMode MODELVIEW |
228 |
|
""" % (-aspect * y, aspect * y, -y, y, zmin, zmax, |
229 |
|
0.5 * size.width, 0.5 * size.height, dist))) |
230 |
|
|
231 |
cs = vs.translateCS(cs, "Trans", |
cs = vs.translateCS(cs, "Trans", |
232 |
0.5 * size.width, |
0.5 * size.width, |
233 |
0.5 * size.height, |
0.5 * size.height, |
234 |
0.5 * self.box); |
0.5 * self.box); |
235 |
|
|
236 |
cs = vs.coords.rotateQuaternion(cs, *self.rot) |
cs = vs.coords.rotateQuaternion(cs, *self.rot) |
237 |
vs.matcher.add(cs, "Rot") |
vs.matcher.add(cs, "Rot") |
238 |
|
|