1 |
|
from __future__ import nested_scopes |
2 |
|
import math |
3 |
|
|
4 |
import vob |
import vob |
5 |
from org.nongnu.libvob.gl import GL, GLRen |
from org.nongnu.libvob.gl import GL, GLRen |
6 |
from vob.putil import cg |
from vob.putil import cg |
19 |
return float2(-v.y, v.x); |
return float2(-v.y, v.x); |
20 |
} |
} |
21 |
|
|
|
float4 norm2(float4 v) { |
|
|
float2 nv = normalize(v.xy / v.w); |
|
|
return float4(nv.x, nv.y, v.z / v.w, 1); |
|
|
} |
|
|
|
|
22 |
void main( |
void main( |
23 |
float4 pos: POSITION, |
float4 pos: POSITION, |
24 |
uniform float4 boxc: C0, |
uniform float2 center: C0, |
25 |
uniform float4 box0: C1, |
uniform float3 zooms: C1, |
26 |
uniform float4 box1: C2, |
uniform float3 zs: C2, |
27 |
uniform float4 fpar: C3, |
uniform float3 angles: C3, |
28 |
|
uniform float3 dists: C4, |
29 |
|
uniform float4 params: C5, |
30 |
out float4 opos: POSITION, |
out float4 opos: POSITION, |
31 |
out float4 col: COLOR |
out float4 col: COLOR |
32 |
) { |
) { |
|
// The initial calculations are constants over the primitive |
|
|
// and should be done in the special code |
|
|
float4 ctr = float4(.5,.5,0,1); |
|
|
float4 ctr0 = ctr; |
|
|
float4 ctr1 = ctr; |
|
|
ctr.xy *= boxc.xy ; |
|
|
ctr0.xy *= box0.xy ; |
|
|
ctr1.xy *= box1.xy ; |
|
|
float2 o_ctr = mul(glstate.matrix.modelview[0], ctr).xy; |
|
|
float2 o_ctr0 = mul(glstate.matrix.program[0], ctr0).xy; |
|
|
float2 o_ctr1 = mul(glstate.matrix.program[1], ctr1).xy; |
|
|
|
|
|
float2 v0 = o_ctr0 - o_ctr; |
|
|
float2 v1 = o_ctr1 - o_ctr; |
|
|
|
|
|
// Rotate the 90deg |
|
|
|
|
|
float2 r0 = r90(normalize(v0)); |
|
|
float2 r1 = rn90(normalize(v1)); |
|
|
|
|
|
float2 x0 = o_ctr + .5 * v0 + fpar.x * r0.xy; |
|
|
float2 x1 = o_ctr; |
|
33 |
|
|
34 |
float2 x2 = o_ctr + .5 * v1 + fpar.x * r1.xy; |
float pi = 3.141592; |
35 |
|
|
36 |
x0 = o_ctr0; |
float ang = pos.x / 2.01; |
|
x2 = o_ctr1; |
|
37 |
|
|
38 |
// The non-uniform part starts here |
float curang = lerp(angles.y, angles.z, ang); |
39 |
|
float curdist = lerp(dists.y, dists.z, ang); |
40 |
|
|
41 |
|
|
42 |
|
float2 v = float2(sin(curang), cos(curang)); |
43 |
|
float2 dv = angles.x * r90(v); |
44 |
|
|
45 |
float4 coeff = float4( |
float sfact = (1-sqrt(sqrt(1-(1-pos.x)*(1-pos.x)*(1-pos.x)*(1-pos.x)))); |
|
(1-pos.x) * (1-pos.x), |
|
|
2 * pos.x * (1-pos.x), |
|
|
pos.x * pos.x, |
|
|
0 |
|
|
); |
|
|
float4 dercoeff = float4( |
|
|
2 * -1 * (1-pos.x), |
|
|
2 * pos.x * -1 + 2 * (1-pos.x) , |
|
|
2 * pos.x, |
|
|
0 |
|
|
); |
|
|
|
|
|
float2 dervec = dercoeff.x * x0 + |
|
|
dercoeff.y * x1 + |
|
|
dercoeff.z * x2; |
|
|
dervec = r90(dervec); |
|
|
|
|
|
float4 rpos; |
|
|
rpos.xy = |
|
|
coeff.x * x0 + |
|
|
coeff.y * x1 + |
|
|
coeff.z * x2 + |
|
|
pos.y * fpar.y * normalize(dervec); |
|
|
rpos.z = 0; |
|
|
rpos.w = 1; |
|
46 |
|
|
47 |
opos = mul(glstate.matrix.projection, rpos); |
float2 rpos = center + |
48 |
|
(dists.x + sfact * (curdist-dists.x)) * v + |
49 |
|
(1-pos.x) * (10 - sfact * ang * pi * curdist ) * dv + |
50 |
|
// rand offset |
51 |
|
pos.y * 2 * v + pos.y * 2 * dv; |
52 |
|
|
53 |
|
float4 rpos4 = float4(0,0,0,1); |
54 |
|
rpos4.xy = rpos; |
55 |
|
|
56 |
|
opos = mul(glstate.matrix.mvp, rpos4); |
57 |
|
|
|
// pos.y * rpos + (1-pos.y) * float4(300*pos.x, 0, 0, 1)); |
|
58 |
col = pos; |
col = pos; |
59 |
col.w = .8; |
col.w = .8; |
60 |
} |
} |
65 |
def __init__(self): |
def __init__(self): |
66 |
self.key = KeyPresses( |
self.key = KeyPresses( |
67 |
self, |
self, |
68 |
SlideLin("x", 400, 50, "x coord", "Left", "Right"), |
SlideLin("l1", 200, 20, "l1", "Left", "Right"), |
69 |
SlideLin("y", 400, 50, "y coord", "Up", "Down"), |
SlideLin("l2", 300, 20, "l2", "Up", "Down"), |
70 |
SlideLin("a", 0, 15, "Rotation", "Prior", "Next"), |
SlideLin("ang", 0, .1, "Rotation", "Prior", "Next"), |
71 |
) |
) |
72 |
def scene(self, vs): |
def scene(self, vs): |
73 |
putnoc(vs, background((.2,1,1))) |
putnoc(vs, background((.2,1,1))) |
74 |
|
|
|
vs.put(GLRen.createTransMatrix("MATRIX0_ARB"), |
|
|
vs.orthoCS(0, "A", 0, 200, 200, 1, 1)) |
|
|
vs.put(GLRen.createTransMatrix("MATRIX1_ARB"), |
|
|
vs.rotateCS( |
|
|
vs.orthoCS(0, "B", 0, self.x, self.y, 1, 1), |
|
|
"R", self.a |
|
|
)) |
|
|
|
|
75 |
vs.put(getDListNocoords(""" |
vs.put(getDListNocoords(""" |
76 |
PushAttrib ENABLE_BIT CURRENT_BIT COLOR_BUFFER_BIT TEXTURE_BIT |
PushAttrib ENABLE_BIT CURRENT_BIT COLOR_BUFFER_BIT TEXTURE_BIT |
77 |
|
|
80 |
""" % ( |
""" % ( |
81 |
vp[0].getProgId(), |
vp[0].getProgId(), |
82 |
))) |
))) |
|
|
|
|
vs.put(GLRen.createProgramLocalParameterARB( |
|
|
"VERTEX_PROGRAM_ARB", 0), |
|
|
vs.orthoCS(0, "i0", 0, 100, 100, 0, 0)) |
|
|
vs.put(GLRen.createProgramLocalParameterARB( |
|
|
"VERTEX_PROGRAM_ARB", 1), |
|
|
vs.orthoCS(0, "i1", 0, 100, 100, 0, 0)) |
|
|
vs.put(GLRen.createProgramLocalParameterARB( |
|
|
"VERTEX_PROGRAM_ARB", 2), |
|
|
vs.orthoCS(0, "i2", 0, 100, 100, 0, 0)) |
|
|
vs.put(GLRen.createProgramLocalParameterARB( |
|
|
"VERTEX_PROGRAM_ARB", 3), |
|
|
vs.orthoCS(0, "i3", 0, 5, 5, 0, 0)) |
|
83 |
|
|
84 |
vs.put(GLRen.createQuad(40,40,1), |
a = [] |
85 |
vs.orthoCS(0, "C", 0, 100, 500, 1, 1)) |
|
86 |
|
def param(i, v1=0, v2=0, v3=0, v4=0): |
87 |
|
vs.put(GLRen.createProgramLocalParameterARB( |
88 |
|
"VERTEX_PROGRAM_ARB", i), |
89 |
|
vs.orthoCS(0, str(len(a)), 0, v1, v2, v3, v4)) |
90 |
|
a.append(0) |
91 |
|
|
92 |
|
param(0, 300, 300) |
93 |
|
|
94 |
|
q = GLRen.createQuad(500, 2, 1) |
95 |
|
|
96 |
|
param(3, -1, 3, self.ang) |
97 |
|
param(4, 30, self.l1, self.l2) |
98 |
|
|
99 |
|
vs.put(q, 0) |
100 |
|
|
101 |
|
param(3, 1, self.ang, 3) |
102 |
|
param(4, 30, self.l2, self.l1) |
103 |
|
|
104 |
|
vs.put(q, 0) |
105 |
|
|
106 |
|
param(3, 1, 3, self.ang + 2*math.pi) |
107 |
|
param(4, 30, self.l1, self.l2) |
108 |
|
|
109 |
|
vs.put(q, 0) |
110 |
|
|
111 |
|
param(3, -1, self.ang + 2*math.pi, 3) |
112 |
|
param(4, 30, self.l2, self.l1) |
113 |
|
|
114 |
|
vs.put(q, 0) |
115 |
|
|
116 |
|
|
117 |
putnoc(vs, getDListNocoords("PopAttrib")) |
putnoc(vs, getDListNocoords("PopAttrib")) |
118 |
|
|