[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: |
Tue, 17 Sep 2002 06:13:07 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/09/17 06:13:06
Modified files:
gfx/librenderables: renderables.py
Log message:
Use inverse coordinate systems
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.37&tr2=1.38&r1=text&r2=text
Patches:
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.37
gzz/gfx/librenderables/renderables.py:1.38
*** gzz/gfx/librenderables/renderables.py:1.37 Tue Sep 17 05:23:23 2002
--- gzz/gfx/librenderables/renderables.py Tue Sep 17 06:13:06 2002
***************
*** 566,593 ****
""",
"ExtraClass" : """
//#include "../demo/clamptexture.cxx"
- template <class Coords>
- Pt invtransform(Coords cs, ZPt p) {
- ZPt orig = cs.transform(Pt(0, 0));
- ZVec e0 = cs.transform(Pt(1, 0)) - orig;
- ZVec e1 = cs.transform(Pt(0, 1)) - orig;
-
- ZVec v = p - orig;
-
- float m = 1.0 / (e0.x * e1.y - e1.x * e0.y);
- float inv[4] = {
- m * e1.y, -m * e1.x,
- -m * e0.y, m * e0.x
- };
- return Pt(inv[0] * v.x + inv[1] * v.y,
- inv[2] * v.x + inv[3] * v.y/*,
- v.z*/);
- }
""",
"RenderCode" : """
DBG(dbg) << "Paper\\n";
GLERR
for(Paper::Paper::iterator it = paper->begin(); it != paper->end();
++it) {
if (dbg) cout << "Pass\\n";
--- 566,579 ----
""",
"ExtraClass" : """
//#include "../demo/clamptexture.cxx"
""",
"RenderCode" : """
DBG(dbg) << "Paper\\n";
GLERR
+ AffineCoords cs1inv = coords1.getInverse();
+ AffineCoords cs2inv = coords2.getInverse();
+
for(Paper::Paper::iterator it = paper->begin(); it != paper->end();
++it) {
if (dbg) cout << "Pass\\n";
***************
*** 599,605 ****
//clampTexture2D(1.0);
Pt p[] = { Pt(x0,y0), Pt(x0,y1), Pt(x1,y1), Pt(x1,y0) };
! Pt q;
// Draw the first texture
(*it).setupcode();
--- 585,591 ----
//clampTexture2D(1.0);
Pt p[] = { Pt(x0,y0), Pt(x0,y1), Pt(x1,y1), Pt(x1,y0) };
! ZPt q;
// Draw the first texture
(*it).setupcode();
***************
*** 611,617 ****
for (int i = 0; i < 4; i++) {
ZPt v = coords1.transform(p[i]);
glMultiTexCoord2fARB(0, p[i].x, p[i].y);
! q = invtransform(coords2, v);
glMultiTexCoord2fARB(1, q.x, q.y);
coords1.vertex(p[i]);
}
--- 597,603 ----
for (int i = 0; i < 4; i++) {
ZPt v = coords1.transform(p[i]);
glMultiTexCoord2fARB(0, p[i].x, p[i].y);
! q = cs2inv.transform(v);
glMultiTexCoord2fARB(1, q.x, q.y);
coords1.vertex(p[i]);
}
***************
*** 630,636 ****
for (int i = 0; i < 4; i++) {
ZPt v = coords2.transform(p[i]);
glMultiTexCoord2fARB(1, p[i].x, p[i].y);
! q = invtransform(coords1, v);
glMultiTexCoord2fARB(0, q.x, q.y);
coords2.vertex(p[i]);
}
--- 616,622 ----
for (int i = 0; i < 4; i++) {
ZPt v = coords2.transform(p[i]);
glMultiTexCoord2fARB(1, p[i].x, p[i].y);
! q = cs1inv.transform(v);
glMultiTexCoord2fARB(0, q.x, q.y);
coords2.vertex(p[i]);
}
***************
*** 649,655 ****
for (int i = 0; i < 4; i++) {
ZPt v = coords2.transform(p[i]);
glMultiTexCoord2fARB(1, p[i].x, p[i].y);
! q = invtransform(coords1, v);
glMultiTexCoord2fARB(0, q.x, q.y);
coords2.vertex(p[i]);
}
--- 635,641 ----
for (int i = 0; i < 4; i++) {
ZPt v = coords2.transform(p[i]);
glMultiTexCoord2fARB(1, p[i].x, p[i].y);
! q = cs1inv.transform(v);
glMultiTexCoord2fARB(0, q.x, q.y);
coords2.vertex(p[i]);
}
***************
*** 683,705 ****
setup = CallGLCode(string(setupcode.begin(),
setupcode.end()).c_str());
""",
"ExtraClass" : """
- template <class Coords>
- Pt invtransform(Coords cs, ZPt p) {
- ZPt orig = cs.transform(Pt(0, 0));
- ZVec e0 = cs.transform(Pt(1, 0)) - orig;
- ZVec e1 = cs.transform(Pt(0, 1)) - orig;
-
- ZVec v = p - orig;
-
- float m = 1.0 / (e0.x * e1.y - e1.x * e0.y);
- float inv[4] = {
- m * e1.y, -m * e1.x,
- -m * e0.y, m * e0.x
- };
- return Pt(inv[0] * v.x + inv[1] * v.y,
- inv[2] * v.x + inv[3] * v.y/*,
- v.z*/);
- }
Pt lerp(float f, Pt a, Pt b) {
return Pt((1 - f) * a.x + f * b.x,
(1 - f) * a.y + f * b.y);
--- 669,674 ----
***************
*** 711,716 ****
--- 680,687 ----
setup();
GLERR;
+ AffineCoords cs2inv = coords2.getInverse();
+
float x0b = x0 - border;
float y0b = y0 - border;
float x1b = x1 + border;
***************
*** 732,739 ****
glBegin(GL_QUADS);
for (int i = 0; i < 4; i++) {
! Pt tex0 = invtransform(coords2, coords1.transform(lerp(texf,
sides[i][0], sides[i][3])));
! Pt tex1 = invtransform(coords2, coords1.transform(lerp(texf,
sides[i][1], sides[i][2])));
glSecondaryColor3fEXT(1, 1, 1);
--- 703,710 ----
glBegin(GL_QUADS);
for (int i = 0; i < 4; i++) {
! ZPt tex0 = cs2inv.transform(coords1.transform(lerp(texf,
sides[i][0], sides[i][3])));
! ZPt tex1 = cs2inv.transform(coords1.transform(lerp(texf,
sides[i][1], sides[i][2])));
glSecondaryColor3fEXT(1, 1, 1);
***************
*** 769,776 ****
float w = 1E-4;
glBegin(GL_QUADS);
for (int i = 0; i < 4; i++) {
! Pt tex0 = invtransform(coords2, coords1.transform(lerp(texf,
corners[i][0], corners[i][1])));
! Pt tex1 = invtransform(coords2, coords1.transform(lerp(texf,
corners[i][0], corners[i][2])));
glSecondaryColor3fEXT(1, 1, 1);
--- 740,747 ----
float w = 1E-4;
glBegin(GL_QUADS);
for (int i = 0; i < 4; i++) {
! ZPt tex0 = cs2inv.transform(coords1.transform(lerp(texf,
corners[i][0], corners[i][1])));
! ZPt tex1 = cs2inv.transform(coords1.transform(lerp(texf,
corners[i][0], corners[i][2])));
glSecondaryColor3fEXT(1, 1, 1);
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/09/11
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/09/12
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/09/16
- [Gzz-commits] gzz/gfx/librenderables renderables.py,
Janne V. Kujala <=
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/09/18
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/09/18
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Tuomas J. Lukka, 2002/09/20
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/09/27
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/09/27
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/09/27
- [Gzz-commits] gzz/gfx/librenderables renderables.py, Janne V. Kujala, 2002/09/28