7 |
|
|
8 |
from math import sin |
from math import sin |
9 |
import math |
import math |
10 |
|
import jarray |
11 |
|
|
12 |
|
if not hasattr(vob.putil.demowindow, "font"): |
13 |
|
|
14 |
|
font = GL.createFont(None, 64) |
15 |
|
vob.putil.demowindow.font = font |
16 |
|
fonttexs = [] |
17 |
|
|
18 |
|
fn = jarray.zeros(10*10, 'b') |
19 |
|
fn2 = jarray.zeros(10*10, 'h') |
20 |
|
|
21 |
|
fn[15] = 1 |
22 |
|
for i in range(0,20): # exercise JVM |
23 |
|
print "Exercise ",i |
24 |
|
vob.util.TexManip.minDist(fn, fn2, 10, 10, 10) |
25 |
|
|
26 |
|
for y in range(0,10): |
27 |
|
print " ".join([str(fn2[10*y + i]) for i in range(0,10)]) |
28 |
|
|
29 |
|
|
30 |
|
print "Tex: ", font.getNTextures(); |
31 |
|
for i in range(0, font.getNTextures()): |
32 |
|
t = font.getTexture(i) |
33 |
|
vob.putil.texture.printTex(t.getTexId()) |
34 |
|
w = int(t.getLevelParameter(0, "TEXTURE_WIDTH")[0]) |
35 |
|
h = int(t.getLevelParameter(0, "TEXTURE_HEIGHT")[0]) |
36 |
|
print "T",i,t,w,h |
37 |
|
|
38 |
|
fn = jarray.zeros(2*w*h, 'b') |
39 |
|
fn2 = jarray.zeros(w*h, 'h') |
40 |
|
|
41 |
|
t.getTexImage(0, "ALPHA", "UNSIGNED_BYTE", fn) |
42 |
|
# for i in range(0, w*h, 5): |
43 |
|
# fn[i] += int(20 * sin(i)) |
44 |
|
|
45 |
|
# for x in range(0,w,20): |
46 |
|
# for y in range(0,w,20): |
47 |
|
# print fn[x + w*y] |
48 |
|
|
49 |
|
# Distance * 16 |
50 |
|
vob.util.TexManip.minDist(fn, fn2, w, h, 16) |
51 |
|
print "Maniped1" |
52 |
|
vob.util.TexManip.b2s(fn2, fn) |
53 |
|
|
54 |
|
print "Maniped" |
55 |
|
|
56 |
|
# for x in range(0,w,20): |
57 |
|
# for y in range(0,w,20): |
58 |
|
# print fn[x + w*y] |
59 |
|
|
60 |
|
t.setTexParameter("TEXTURE_2D", "GENERATE_MIPMAP_SGIS", "TRUE"); |
61 |
|
|
62 |
|
t.texImage2D(0, "LUMINANCE_ALPHA", w, h, 0, "LUMINANCE_ALPHA", "UNSIGNED_BYTE", fn) |
63 |
|
|
64 |
|
fonttexs.append(t) |
65 |
|
|
66 |
|
else: |
67 |
|
font = vob.putil.demowindow.font |
68 |
|
for i in range(0, font.getNTextures()): |
69 |
|
t = font.getTexture(i) |
70 |
|
t.setTexParameter("TEXTURE_2D", "TEXTURE_MIN_FILTER", "NEAREST"); |
71 |
|
|
72 |
from org.nongnu.libvob.paper.texcache import getCachedTexture |
from org.nongnu.libvob.paper.texcache import getCachedTexture |
73 |
|
|
84 |
|
|
85 |
tex = getCachedTexture(args[7]) |
tex = getCachedTexture(args[7]) |
86 |
|
|
87 |
|
# 16 * texel [1/512] |
88 |
|
|
89 |
fp = [ |
fp = [ |
90 |
GL.createProgram("""!!FP1.0 |
GL.createProgram("""!!FP1.0 |
91 |
MOV R10, f[TEX0].xyzw; |
MOV R10, f[TEX0].xyzw; |
92 |
DDX R8, R10; |
DDX R8, R10; |
93 |
DDY R9, R10; |
DDY R9, R10; |
94 |
|
|
95 |
|
DP4 R6, R8.xyxy, R8.xyxy; |
96 |
|
DP4 R7, R9.xyxy, R9.xyxy; |
97 |
|
ADD R6, R6, R7; |
98 |
|
RSQ R6, R6.x; |
99 |
|
|
100 |
|
RCP R6, R6.x; |
101 |
|
MUL R6, R6, 512; |
102 |
|
|
103 |
|
TEX R0, f[TEX0].xyzw, TEX0, 2D; |
104 |
|
# MAD R0, R0.w, 256, R0.x; |
105 |
|
MAD R0, R0.x, 256, R0.w; |
106 |
|
|
107 |
|
# Scale |
108 |
|
MUL R0, R0, .0625; |
109 |
|
MUL R0, R0, 256; |
110 |
|
|
111 |
|
MUL R6, R6, .5; |
112 |
|
|
113 |
|
SLT R0, R0, R6; |
114 |
|
|
115 |
|
MOV R0.xyz, 0; |
116 |
|
MOV o[COLR], R0; |
117 |
|
|
118 |
|
END"""), |
119 |
|
GL.createProgram("""!!FP1.0 |
120 |
|
MOV R10, f[TEX0].xyzw; |
121 |
|
DDX R8, R10; |
122 |
|
DDY R9, R10; |
123 |
MUL R18, R8, 1; |
MUL R18, R8, 1; |
124 |
MUL R19, R9, 1; |
MUL R19, R9, 1; |
125 |
|
|
318 |
Enable ALPHA_TEST |
Enable ALPHA_TEST |
319 |
AlphaFunc GREATER 0.99 |
AlphaFunc GREATER 0.99 |
320 |
""")) |
""")) |
321 |
tx = vob.vobs.TextVob(vob.GraphicsAPI.getInstance().getTextStyle( |
#tx = vob.vobs.TextVob(vob.GraphicsAPI.getInstance().getTextStyle( |
322 |
"serif", 1, 64), |
# "serif", 1, 64), |
323 |
"sofesjif@342oFAEOFJ", 0, None) |
# "sofesjif@342oFAEOFJ", 0, None) |
324 |
for x in range(-10,11): |
for x in range(-10,11): |
325 |
for y in range(-10,11): |
for y in range(-10,11): |
326 |
d = 1 - math.hypot(x,y) / 20 |
d = 1 - math.hypot(x,y) / 20 |
367 |
cs = vs.orthoCS(0, "a", 0, self.x, self.y, 1, 1) |
cs = vs.orthoCS(0, "a", 0, self.x, self.y, 1, 1) |
368 |
|
|
369 |
cs = vs.rotateCS(cs, "b", self.a) |
cs = vs.rotateCS(cs, "b", self.a) |
370 |
|
|
371 |
for i in range(7,15): |
tx = vob.gl.GLRen.createText1(font, "sofesjif@32FEF", 0, 0) |
372 |
csi = vs.orthoCS(cs, str(i), 0, 0, i*(i+1), i, i) |
|
373 |
putText(vs, csi, " ".join(words[0:3])) |
y = 0 |
374 |
|
for i in range(7,20,2): |
375 |
|
y += i*1.5 |
376 |
|
csi = vs.orthoCS(cs, str(i), 0, 0, y, 2*i, 2*i) |
377 |
|
vs.put(tx, csi) |
378 |
|
|
379 |
putnoc(vs, getDListNocoords("PopAttrib")) |
putnoc(vs, getDListNocoords("PopAttrib")) |
380 |
|
|