[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/librenderables renderables.py
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx/librenderables renderables.py |
Date: |
Mon, 04 Nov 2002 10:47:07 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/11/04 10:47:07
Modified files:
gfx/librenderables: renderables.py
Log message:
Compute texture q coordinates in IrregularEllipse
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.129&tr2=1.130&r1=text&r2=text
Patches:
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.129
gzz/gfx/librenderables/renderables.py:1.130
--- gzz/gfx/librenderables/renderables.py:1.129 Mon Nov 4 05:45:03 2002
+++ gzz/gfx/librenderables/renderables.py Mon Nov 4 10:47:07 2002
@@ -1144,12 +1144,40 @@
int n = (int)(36 * dicefactor);
std::vector<ZPt> vert(n+1);
std::vector<ZVec> norm(n+1);
+ std::vector<float> texq(n+1);
for (int i = 0; i <= n; i++) {
float a = i * 2*M_PI / n;
vert[i] = coords2.transform(ZPt(cos(a), sin(a), 0));
}
+ for (int i = 0; i <= n; i++) {
+ norm[i] = (vert[(i+1) % n] - vert[(i+n-1) % n]).cw90().normalize()
+ * (0.5 * ripple_scale * texscale);
+ }
+
+ // Compute outer edge / inner edge length ratio
+ // for segments before and after a point and use the
+ // geometric average as the q component of the point.
+ // Exact mapping of the texture to the segment
+ // would require repeating the vertices.
+ for (int i = 0; i <= n; i++) {
+ ZPt p0 = vert[(i+n-1) % n];
+ ZPt p1 = vert[i];
+ ZPt p2 = vert[(i+1) % n];
+ ZVec n0 = norm[(i+n-1) % n];
+ ZVec n1 = norm[i];
+ ZVec n2 = norm[(i+1) % n];
+
+ float q0 = ((p0 + n0) - (p1 + n1)).length() /
+ ((p0 - n0) - (p1 - n1)).length();
+
+ float q1 = ((p1 + n1) - (p2 + n2)).length() /
+ ((p1 - n1) - (p2 - n2)).length();
+
+ texq[i] = sqrt(q0 * q1);
+ }
+
int angles = 3;
setup();
@@ -1157,12 +1185,11 @@
glBegin(GL_QUAD_STRIP);
for (int i = 0; i <= n; i++) {
ZPt p = vert[i];
- ZVec norm = (vert[(i+1) % n] - vert[(i+n-1) %
n]).cw90().normalize();
- norm *= 0.5 * ripple_scale * texscale;
-
+ ZVec normal = norm[i];
+ float q = texq[i];
float dotvec[4] = {0,0,0,0};
- float angle = atan2(-norm.x, norm.y); // angle(norm.cw90())
+ float angle = atan2(-normal.x, normal.y); // angle(normal.cw90())
float a = (angle + M_PI) * angles * (1 / M_PI);
int ind = (int)a;
@@ -1176,13 +1203,12 @@
else
glColor4f(0, 0, 0, 1);
- // XXX: need to compute multiplier according to
- // quad inside/outside length difference
glTexCoord4f(p.x, p.y, p.z, texscale);
glSecondaryColor3fEXT(1,1,1);
- coords1.vertex(p - norm);
+ coords1.vertex(p - normal);
+ glTexCoord4f(q * p.x, q * p.y, q * p.z, q * texscale);
glSecondaryColor3fEXT(0,0,0);
- coords1.vertex(p + norm);
+ coords1.vertex(p + normal);
}
glEnd();
@@ -1194,10 +1220,7 @@
glBegin(GL_TRIANGLE_FAN);
coords1.vertex(coords2.transform(ZPt(0,0,0)));
for (int i = 0; i <= n; i++) {
- ZPt p = vert[i];
- ZVec norm = (vert[(i+1) % n] - vert[(i+n-1) %
n]).cw90().normalize();
- norm *= 0.5 * ripple_scale * texscale;
- coords1.vertex(p - norm);
+ coords1.vertex(vert[i] - norm[i]);
}
glEnd();
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Matti Katila, 2002/11/01
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/11/04
- [Gzz-commits] gzz/gfx/librenderables renderables.py,
Janne V. Kujala <=
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/11/11
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/11/12
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/11/13
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/11/13