27 |
from vob.putil import cg |
from vob.putil import cg |
28 |
from vob.putil.misc import * |
from vob.putil.misc import * |
29 |
from vob.putil.demokeys import * |
from vob.putil.demokeys import * |
|
from vob.paper.texcache import getCachedTexture |
|
30 |
|
|
31 |
from vob.fillet import light3d; |
from vob.fillet import light3d |
32 |
|
|
33 |
from random import Random |
from random import Random |
|
|
|
|
noise = getCachedTexture( |
|
|
[1024, 512, 0, 4, "RGBA", "RGBA", "noise", |
|
|
[ "freq", "100", "bias", ".5", "scale", ".8" ]] |
|
|
) |
|
34 |
|
|
35 |
class Scene: |
class Scene: |
36 |
"Random graph" |
"Random graph" |
43 |
) |
) |
44 |
def scene(self, vs): |
def scene(self, vs): |
45 |
vs.put( background((.5,1,.2))) |
vs.put( background((.5,1,.2))) |
|
vs.put(getDListNocoords(""" |
|
|
PushAttrib POLYGON_BIT ENABLE_BIT |
|
|
Enable DEPTH_TEST |
|
|
DepthFunc LEQUAL |
|
|
LineWidth %s |
|
|
PolygonOffset -100 -100 |
|
|
ShadeModel SMOOTH |
|
|
""" % self.linewidth)) |
|
|
|
|
|
if self.lines: |
|
|
vs.put(getDListNocoords("PolygonMode FRONT_AND_BACK LINE")) |
|
|
|
|
|
border = 2 |
|
|
conns = GLRen.createSortedConnections( |
|
|
GLRen.createFilletSpan2(border, self.dice, |
|
|
1 + |
|
|
4 * self.depthColor + |
|
|
8 * (1-self.fillets) + |
|
|
16 * self.ellipses + |
|
|
64 * self.stretched + |
|
|
128 * self.sectors), 2) |
|
|
|
|
|
conns_l = GLRen.createSortedConnections( |
|
|
GLRen.createFilletSpan2(border, self.dice, |
|
|
2 + |
|
|
4 * self.depthColor + |
|
|
8 * (1-self.fillets) + |
|
|
16 * self.ellipses + |
|
|
64 * self.stretched + |
|
|
128 * self.sectors), 2) |
|
|
|
|
|
conns3d = GLRen.createIterConnections( |
|
|
GLRen.createFillet3D(border, self.dice, 0), 2); |
|
|
|
|
46 |
|
|
47 |
rng = Random(self.seed) |
rng = Random(self.seed) |
48 |
N2 = 2*self.N/3 |
N2 = 2*self.N/3 |
94 |
if node["conns"]: |
if node["conns"]: |
95 |
vs.put(conns, [thick, angle, node["cs"]] + node["conns"]) |
vs.put(conns, [thick, angle, node["cs"]] + node["conns"]) |
96 |
|
|
97 |
if self.fillet3d: |
light3d.drawFillets(self, vs, pc) |
|
vs.put(getDListNocoords(""" |
|
|
Color 1 1 1 |
|
|
BindProgram VERTEX_PROGRAM_ARB %s |
|
|
Enable VERTEX_PROGRAM_ARB |
|
|
MatrixMode PROJECTION |
|
|
PushMatrix |
|
|
MatrixMode MODELVIEW |
|
|
PushMatrix |
|
|
""" % light3d.vp[0].getProgId())) |
|
|
|
|
|
if self.texture: |
|
|
vs.put(getDListNocoords(""" |
|
|
BindTexture TEXTURE_2D %s |
|
|
TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR |
|
|
TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR |
|
|
TexParameter TEXTURE_2D TEXTURE_MAX_ANISOTROPY_EXT 20 |
|
|
TexEnv TEXTURE_ENV TEXTURE_ENV_MODE MODULATE |
|
|
Enable TEXTURE_2D |
|
|
""" % noise.getTexId())) |
|
|
|
|
|
if self.perspective: |
|
|
vs.put(getDListNocoords(""" |
|
|
MatrixMode PROJECTION |
|
|
LoadIdentity |
|
|
Frustum -400 400 -400 400 500 2500 |
|
|
Scale 1 1 -1 |
|
|
MatrixMode MODELVIEW |
|
|
LoadIdentity |
|
|
Scale 1 1 -1 |
|
|
uLookAt 400 400 -1000 400 400 400 0 -1 0 |
|
|
""")) |
|
|
|
|
|
pc(conns3d) |
|
|
|
|
|
vs.put(getDListNocoords(""" |
|
|
MatrixMode PROJECTION |
|
|
PopMatrix |
|
|
MatrixMode MODELVIEW |
|
|
PopMatrix |
|
|
""")) |
|
|
else: |
|
|
vs.put(getDListNocoords(""" |
|
|
Color 1 1 1 |
|
|
""")) |
|
|
if self.drawInside: pc(conns) |
|
|
vs.put(getDListNocoords(""" |
|
|
Color 0 0 0 |
|
|
""")) |
|
|
if self.drawEdge: pc(conns_l) |
|
|
|
|
|
vs.put(getDListNocoords(""" |
|
|
BindProgram VERTEX_PROGRAM_ARB 0 |
|
|
BindTexture TEXTURE_2D 0 |
|
|
PopAttrib |
|
|
""")) |
|
|
|
|