1 |
# (c) Janne V. Kujala and Tuomas J. Lukka |
# (c) Janne V. Kujala and Tuomas J. Lukka |
2 |
from org.nongnu.libvob.gl import GL, GLRen |
from org.nongnu.libvob.gl import GL, GLRen |
3 |
from vob.putil import cg |
from vob.putil import cg |
4 |
|
from vob.putil.misc import * |
5 |
from vob.putil.demokeys import * |
from vob.putil.demokeys import * |
6 |
|
|
7 |
|
from vob.paper.texcache import getCachedTexture |
8 |
|
noise = getCachedTexture( |
9 |
|
[1024, 512, 0, 4, "RGBA", "RGBA", "noise", |
10 |
|
[ "freq", "100", "bias", ".5", "scale", ".8" ]] |
11 |
|
) |
12 |
|
|
13 |
vp = [ |
vp = [ |
14 |
GL.createProgram(cg.compile(""" |
GL.createProgram(cg.compile(""" |
15 |
void main( |
void main( |
116 |
Toggle("perspective", 0, "perspective", "F"), |
Toggle("perspective", 0, "perspective", "F"), |
117 |
Toggle("texture", 0, "texture", "x"), |
Toggle("texture", 0, "texture", "x"), |
118 |
] |
] |
119 |
|
|
120 |
|
|
121 |
|
def drawFillets(self, vs, pc): |
122 |
|
vs.put(getDListNocoords(""" |
123 |
|
PushAttrib POLYGON_BIT ENABLE_BIT |
124 |
|
Enable DEPTH_TEST |
125 |
|
DepthFunc LEQUAL |
126 |
|
LineWidth %s |
127 |
|
PolygonOffset -100 -100 |
128 |
|
ShadeModel SMOOTH |
129 |
|
""" % self.linewidth)) |
130 |
|
|
131 |
|
if self.lines: |
132 |
|
vs.put(getDListNocoords("PolygonMode FRONT_AND_BACK LINE")) |
133 |
|
|
134 |
|
border = 2 |
135 |
|
conns = GLRen.createSortedConnections( |
136 |
|
GLRen.createFilletSpan2(border, self.dice, |
137 |
|
1 + |
138 |
|
4 * self.depthColor + |
139 |
|
16 * self.ellipses + |
140 |
|
64 * self.stretched + |
141 |
|
128 * self.sectors), |
142 |
|
2) |
143 |
|
conns_l = GLRen.createSortedConnections( |
144 |
|
GLRen.createFilletSpan2(border, self.dice, |
145 |
|
2 + |
146 |
|
4 * self.depthColor + |
147 |
|
16 * self.ellipses + |
148 |
|
64 * self.stretched + |
149 |
|
128 * self.sectors), |
150 |
|
2) |
151 |
|
conns_c = GLRen.createSortedConnections( |
152 |
|
GLRen.createFilletSpan2(1000, self.dice, |
153 |
|
2 + |
154 |
|
4 * self.depthColor + |
155 |
|
16 * self.ellipses + |
156 |
|
32 + |
157 |
|
64 * self.stretched + |
158 |
|
128 * self.sectors), |
159 |
|
2) |
160 |
|
|
161 |
|
conns3d = GLRen.createIterConnections( |
162 |
|
GLRen.createFillet3D(border, self.dice, 1), |
163 |
|
2) |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
if self.fillet3d: |
170 |
|
vs.put(getDListNocoords(""" |
171 |
|
Color 1 1 1 |
172 |
|
BindProgram VERTEX_PROGRAM_ARB %s |
173 |
|
Enable VERTEX_PROGRAM_ARB |
174 |
|
MatrixMode PROJECTION |
175 |
|
PushMatrix |
176 |
|
MatrixMode MODELVIEW |
177 |
|
PushMatrix |
178 |
|
""" % vp[0].getProgId())) |
179 |
|
|
180 |
|
if self.texture: |
181 |
|
vs.put(getDListNocoords(""" |
182 |
|
BindTexture TEXTURE_2D %s |
183 |
|
TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR |
184 |
|
TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR |
185 |
|
TexParameter TEXTURE_2D TEXTURE_MAX_ANISOTROPY_EXT 20 |
186 |
|
TexEnv TEXTURE_ENV TEXTURE_ENV_MODE MODULATE |
187 |
|
Enable TEXTURE_2D |
188 |
|
""" % noise.getTexId())) |
189 |
|
|
190 |
|
if self.perspective: |
191 |
|
vs.put(getDListNocoords(""" |
192 |
|
MatrixMode PROJECTION |
193 |
|
LoadIdentity |
194 |
|
Frustum -400 400 -400 400 500 2500 |
195 |
|
Scale 1 1 -1 |
196 |
|
MatrixMode MODELVIEW |
197 |
|
LoadIdentity |
198 |
|
Scale 1 1 -1 |
199 |
|
uLookAt 400 400 -1000 400 400 400 0 -1 0 |
200 |
|
""")) |
201 |
|
|
202 |
|
pc(conns3d) |
203 |
|
|
204 |
|
vs.put(getDListNocoords(""" |
205 |
|
MatrixMode PROJECTION |
206 |
|
PopMatrix |
207 |
|
MatrixMode MODELVIEW |
208 |
|
PopMatrix |
209 |
|
""")) |
210 |
|
else: |
211 |
|
vs.put(getDListNocoords(""" |
212 |
|
Color 1 1 1 |
213 |
|
""")) |
214 |
|
if self.drawInside: pc(conns) |
215 |
|
vs.put(getDListNocoords(""" |
216 |
|
Color 0 0 0 |
217 |
|
""")) |
218 |
|
if self.drawEdge: pc(conns_l) |
219 |
|
|
220 |
|
if self.curvature : pc(conns_c) |
221 |
|
|
222 |
|
|
223 |
|
vs.put(getDListNocoords(""" |
224 |
|
BindProgram VERTEX_PROGRAM_ARB 0 |
225 |
|
BindTexture TEXTURE_2D 0 |
226 |
|
PopAttrib |
227 |
|
""")) |