[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx demo/irregu4.py demo/opengl/texform.py ...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx demo/irregu4.py demo/opengl/texform.py ... |
Date: |
Tue, 12 Nov 2002 02:18:27 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/11/12 02:18:25
Modified files:
gfx/demo : irregu4.py
gfx/demo/opengl: texform.py
gfx/librenderables: renderables.py
gfx/libutil : Irregu.hxx
Log message:
Add SHIFTS and scaling reference size to irregu lib
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu4.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/opengl/texform.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.140&tr2=1.141&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/Irregu.hxx.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/irregu4.py
diff -u gzz/gfx/demo/irregu4.py:1.5 gzz/gfx/demo/irregu4.py:1.6
--- gzz/gfx/demo/irregu4.py:1.5 Mon Nov 11 12:40:23 2002
+++ gzz/gfx/demo/irregu4.py Tue Nov 12 02:18:25 2002
@@ -183,6 +183,7 @@
INTERP_DOTVEC = 8;
SLICE_1D = 16;
SLICE_2D = 32;
+ SHIFTS = 64;
inner_code = code % {"tex" : texRGBA.getTexId(),
"color" : "1 1 1 1" }
@@ -190,30 +191,14 @@
"color" : "0 0 0 0" }
texscale = 1.0
- linewidth = 1./128
+ linewidth = 2
+ refsize = 128
scale_pow = 0
border0 = -.5 * ripple_scale * texscale
border1 = .5 * ripple_scale * texscale
SLICE = (SLICE_2D, SLICE_1D)[self.flags >> 4 & 1]
- self.outer = GLRen.createIrregularEdge(
- texscale, linewidth, scale_pow, border0, border1,
- "1 1 1 1 0 0 0 0", "", 3, 0,
- Y_SECCOLOR + SLICE + DOTVEC_COLOR + INTERP_DOTVEC,
- outer_code, 1.0);
-
- if (GL.getGLFloat("MAX_GENERAL_COMBINERS_NV")[0] >= 4 and
- GL.getGLFloat("MAX_TEXTURE_UNITS")[0] >= 3 and
- 1):
- outer_code = code2 % {"tex" : texINTENSITY.getTexId(),
- "color" : "0 0 0 0" }
- self.outer = GLRen.createIrregularEdge(
- texscale, linewidth, scale_pow, border0, border1,
- "1 1 1 1 0 0 0 0", "", 0, 1,
- Y_SECCOLOR + SLICE,
- outer_code, 1.0);
-
stdcode = """
PushAttrib ENABLE_BIT TEXTURE_BIT
BindTexture TEXTURE_2D %s
@@ -224,18 +209,47 @@
Enable ALPHA_TEST
AlphaFunc GEQUAL 1.0
""" % texINTENSITY.getTexId()
-
+
+ self.outer = GLRen.createIrregularEdge(
+ texscale, linewidth, refsize, scale_pow, border0, border1,
+ "0 0 0 1 0 0 0 0", "",
+ 0, 0,
+ SLICE + Y_COLOR + SHIFTS, stdcode + """
+ BlendFunc ZERO ZERO
+ Enable BLEND
+ """, 1.0)
+
if (self.flags & 1) == 0:
stdcode += "Disable TEXTURE_2D\n"
if (self.flags & 4) == 0:
stdcode += "Disable ALPHA_TEST\n"
self.inner = GLRen.createIrregularEdge(
- texscale, linewidth, scale_pow, border0, border1,
+ texscale, linewidth, refsize, scale_pow, border0, border1,
("0 0 0 0 0 0 0 0", "1 1 1 1 0 0 0 0")[self.flags >> 1 & 1], "",
0, 0,
- SLICE + Y_COLOR, stdcode, 1.0);
-
+ SLICE + Y_COLOR, stdcode, 1.0)
+
+ if GL.hasExtension("GL_NV_register_combiners"):
+ self.outer = GLRen.createIrregularEdge(
+ texscale, linewidth, refsize, scale_pow, border0, border1,
+ "1 1 1 1 0 0 0 0", "", 3, 0,
+ Y_SECCOLOR + SLICE + DOTVEC_COLOR + INTERP_DOTVEC,
+ outer_code, 1.0)
+
+ if (GL.hasExtension("GL_NV_register_combiners") and
+ GL.getGLFloat("MAX_GENERAL_COMBINERS_NV")[0] >= 4 and
+ GL.getGLFloat("MAX_TEXTURE_UNITS")[0] >= 3 and
+ 1):
+ outer_code = code2 % {"tex" : texINTENSITY.getTexId(),
+ "color" : "0 0 0 0" }
+ self.outer = GLRen.createIrregularEdge(
+ texscale, linewidth, refsize, scale_pow, border0, border1,
+ "1 1 1 1 0 0 0 0", "", 0, 1,
+ Y_SECCOLOR + SLICE,
+ outer_code, 1.0)
+
+
def scene(self, vs):
putnoc(vs, self.bg)
Index: gzz/gfx/demo/opengl/texform.py
diff -u gzz/gfx/demo/opengl/texform.py:1.3 gzz/gfx/demo/opengl/texform.py:1.4
--- gzz/gfx/demo/opengl/texform.py:1.3 Wed Oct 23 10:55:39 2002
+++ gzz/gfx/demo/opengl/texform.py Tue Nov 12 02:18:25 2002
@@ -4,13 +4,13 @@
from gfx.libutil.texture import printTex
-scroll = gzz.media.impl.PageImageScroll(None, gzz.mediaserver.Mediaserver.Id(
-"0000000008000000E9573F43E00004CB42D4BEFEBAA27C20403F7D57693141B9E4D9A46329AC9C"))
+#scroll = gzz.media.impl.PageImageScroll(None, gzz.mediaserver.Mediaserver.Id(
+#"0000000008000000E9573F43E00004CB42D4BEFEBAA27C20403F7D57693141B9E4D9A46329AC9C"))
-rect = GLSpans.getRect(scroll.getCurrent())
+#rect = GLSpans.getRect(scroll.getCurrent())
-print "PageImageScroll\n"
-printTex(rect.texId)
+#print "PageImageScroll\n"
+#printTex(rect.texId)
for inter, exter, ncomps in (
("ALPHA", "ALPHA", "1"),
@@ -59,5 +59,5 @@
):
tex = GL.createTexture()
print "Now: ",inter
- tex.shade(64, 64, 0, int(ncomps), inter, exter, "noise", ())
+ tex.shade_all_levels(64, 64, 0, int(ncomps), inter, exter, "noise", ())
printTex(tex.getTexId())
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.140
gzz/gfx/librenderables/renderables.py:1.141
--- gzz/gfx/librenderables/renderables.py:1.140 Tue Nov 12 01:11:54 2002
+++ gzz/gfx/librenderables/renderables.py Tue Nov 12 02:18:25 2002
@@ -1255,7 +1255,7 @@
setup();
float col[] = {1,1,1,1,0,0,0,0};
if (!mode) glColor4f(0,0,0,1);
- Irregu::draw(coords1, vert, norm, texscale, 1.0/128, 0,
+ Irregu::draw(coords1, vert, norm, texscale, 2.0, 128, 0,
-.5, .5, col, NULL, 3, 0,
Irregu::SLICE_1D + Irregu::Y_SECCOLOR +
mode * Irregu::DOTVEC_COLOR + Irregu::INTERP_DOTVEC);
@@ -1284,12 +1284,12 @@
{
"Type" : "2",
"Name": "IrregularEdge",
- "Data": """float texscale, linewidth, scale_pow, border0, border1;
+ "Data": """float texscale, linewidth, refsize, scale_pow, border0, border1;
vector<float> const0, const1; int angles, multi, flags;
CallGLCode setup;
float dicefactor;""",
"Params" : """
- float texscale, float linewidth, float scale_pow,
+ float texscale, float linewidth, float refsize, float scale_pow,
float border0, float border1,
UTF8String const0, UTF8String const1, int angles, int multi, int
flags,
UTF8String setupcode, float dicefactor
@@ -1310,6 +1310,7 @@
"ParamCode" : """
this->texscale = texscale;
this->linewidth = linewidth;
+ this->refsize = refsize;
this->scale_pow = scale_pow;
this->border0 = border0;
this->border1 = border1;
@@ -1345,7 +1346,8 @@
setup();
GLERR;
- Irregu::draw(coords1, vert, norm, texscale, linewidth, scale_pow,
+ Irregu::draw(coords1, vert, norm, texscale,
+ linewidth, refsize, scale_pow,
border0, border1,
&const0[0], &const1[0],
angles, multi, flags);
Index: gzz/gfx/libutil/Irregu.hxx
diff -u gzz/gfx/libutil/Irregu.hxx:1.6 gzz/gfx/libutil/Irregu.hxx:1.7
--- gzz/gfx/libutil/Irregu.hxx:1.6 Mon Nov 11 12:40:23 2002
+++ gzz/gfx/libutil/Irregu.hxx Tue Nov 12 02:18:25 2002
@@ -47,6 +47,7 @@
const unsigned INTERP_DOTVEC = 8;
const unsigned SLICE_1D = 16;
const unsigned SLICE_2D = 32;
+ const unsigned SHIFTS = 64;
template <class Coords>
void fill(Coords &coords, ZPt center,
@@ -70,7 +71,7 @@
template <class Coords>
void draw(Coords &coords,
const vector<ZPt> &pt, const vector<ZVec> &norm,
- float texscale, float linewidth, float scale_pow,
+ float texscale, float linewidth, float refsize, float scale_pow,
float border0, float border1,
const float c0[], const float c1[],
int angles, int multi,
@@ -123,21 +124,25 @@
ZVec dv0 = vert[i][0] - vert[j][0];
ZVec dv1 = vert[i][1] - vert[j][1];
+ ZVec dv0t;
+ ZVec dv1t;
ZVec d0, d1;
float dy0, dy1;
+ float scale0, scale1;
- if (multi > 0) {
- ZVec dv0t = vert2[j][0] - vert2[i][0];
- ZVec dv1t = vert2[j][1] - vert2[i][1];
- ZVec dt = pt[j] - pt[i];
-
- float scale0 = linewidth * dv0t.length() / dv0.length();
- float scale1 = linewidth * dv1t.length() / dv1.length();
- scale0 = pow(scale0, scale_pow);
- scale1 = pow(scale1, scale_pow);
+ if (multi > 0 || (flags & SHIFTS)) {
+ dv0t = vert2[j][0] - vert2[i][0];
+ dv1t = vert2[j][1] - vert2[i][1];
+
+ scale0 = dv0t.length() / (refsize * dv0.length());
+ scale1 = dv1t.length() / (refsize * dv1.length());
+ scale0 = linewidth * pow(scale0, scale_pow);
+ scale1 = linewidth * pow(scale1, scale_pow);
+ if (multi > 0) {
// XXX: 1.5 hardcoded
+ ZVec dt = pt[j] - pt[i];
d0 = scale0 * dt * (1.5 / dv0t.length());
d1 = scale1 * dt * (1.5 / dv1t.length());
@@ -146,12 +151,33 @@
dy0 = scale0 * dy;
dy1 = scale1 * dy;
//std::cout << dy << " " << dy0 << " " << dy1 << "\n";
+ }
}
float q1 = dv0.dot(dv1) / dv0.dot(dv0);
ZPt a1q = pt[i] * q1;
ZPt b1q = pt[j] * q1;
+ ZVec shift0(0,0,0);
+ ZVec shift1(0,0,0);
+
+ for (int s = 0; s < (flags & SHIFTS ? 3 : 1); s++) {
+ if (flags & SHIFTS) {
+ switch (s) {
+ case 0:
+ shift0 = scale1 * dv0t.normalize().cw90();
+ shift1 = scale1 * dv0t.normalize().cw90();
+ break;
+ case 1:
+ shift0 = scale1 * dv1t.normalize();
+ shift1 = scale1 * dv1t.normalize();
+ break;
+ case 2:
+ shift0 = -scale1 * dv1t.normalize();
+ shift1 = -scale1 * dv1t.normalize();
+ }
+ }
+
if (flags & DOTVEC_COLOR) {
float angle = flags & INTERP_DOTVEC ?
atan2(-norm[i].x, norm[i].y) :
@@ -172,7 +198,7 @@
multiTexCoord(u++, a1q + d * q1 * d1, texscale * q1);
multiTexCoord(u++, a1q - d * q1 * d1, texscale * q1);
}
- vertex(vert2[i][1]);
+ vertex(vert2[i][1] + shift1);
if (multi > 0) glColor4f(0,0,dy0,dy0);
colorfv(c0);
@@ -182,7 +208,7 @@
multiTexCoord(u++, pt[i] + d * d0, texscale);
multiTexCoord(u++, pt[i] - d * d0, texscale);
}
- vertex(vert2[i][0]);
+ vertex(vert2[i][0] + shift0);
if ((flags & DOTVEC_COLOR) && (flags & INTERP_DOTVEC)) {
float angle = atan2(-norm[j].x, norm[j].y);
@@ -198,7 +224,7 @@
multiTexCoord(u++, pt[j] + d * d0, texscale);
multiTexCoord(u++, pt[j] - d * d0, texscale);
}
- vertex(vert2[j][0]);
+ vertex(vert2[j][0] + shift0);
if (multi > 0) glColor4f(0,0,dy1,dy1);
colorfv(c0 + 4);
@@ -208,7 +234,8 @@
multiTexCoord(u++, b1q + d * q1 * d1, texscale * q1);
multiTexCoord(u++, b1q - d * q1 * d1, texscale * q1);
}
- vertex(vert2[j][1]);
+ vertex(vert2[j][1] + shift1);
+ }
}
glEnd();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx demo/irregu4.py demo/opengl/texform.py ...,
Janne V. Kujala <=