[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx demo/fisheye.py librenderables/renderab...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx demo/fisheye.py librenderables/renderab... |
Date: |
Wed, 11 Sep 2002 09:18:16 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/09/11 09:18:16
Modified files:
gfx/demo : fisheye.py
gfx/librenderables: renderables.py
Log message:
Implement fisheye distortion; "make runfisheye" to test
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/fisheye.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/fisheye.py
diff -c gzz/gfx/demo/fisheye.py:1.1 gzz/gfx/demo/fisheye.py:1.2
*** gzz/gfx/demo/fisheye.py:1.1 Wed Sep 11 08:02:54 2002
--- gzz/gfx/demo/fisheye.py Wed Sep 11 09:18:16 2002
***************
*** 8,13 ****
--- 8,19 ----
return GZZGL.createFisheyePaperQuad(pap, -1, -1, 1, 1)
+ bx = 600
+ by = 450
+ bs = .15
+
+ rng = java.util.Random()
+
class FisheyeScene:
def __init__(self):
self.bgcolor = (1,1,1)
***************
*** 18,30 ****
self.fpq = getfisheyepaper(self.seed);
def key(self, k):
! pass
def scene(self, vs):
putnoc(vs, background(self.bgcolor))
! cs1 = vs.coords.affineCoordsys(0, "1", 10, 600, 500, 450, 0, 0, 450)
! cs2 = vs.coords.affineCoordsys(0, "1", 10, 600, 500, 450, 0, 0, 450)
vs.map.put(self.fpq, cs1, cs2)
--- 24,47 ----
self.fpq = getfisheyepaper(self.seed);
def key(self, k):
! global bx, by, bs
! if k == "Up": by -= 100
! elif k == "Down": by += 100
! elif k == "Left": bx -= 100
! elif k == "Right": bx += 100
! elif k == "+": bs += .05
! elif k == "-": bs -= .05
! elif k == "v":
! self.seed = rng.nextInt(2000000000)
! self.initpaper()
! AbstractUpdateManager.setNoAnimation()
def scene(self, vs):
putnoc(vs, background(self.bgcolor))
! cs1 = vs.coords.affineCoordsys(0, "1", 10, 600, 450, 400, 0, 0, 400)
!
! cs2 = vs.coords.affineCoordsys(0, "2", 10, bx, by, bs*400, 0, 0, bs*400)
vs.map.put(self.fpq, cs1, cs2)
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.20
gzz/gfx/librenderables/renderables.py:1.21
*** gzz/gfx/librenderables/renderables.py:1.20 Wed Sep 11 07:34:02 2002
--- gzz/gfx/librenderables/renderables.py Wed Sep 11 09:18:16 2002
***************
*** 421,436 ****
{
"Type" : "2",
"Name": "FisheyePaperQuad",
! "Data": "Pt corners[4]; Paper::Paper* paper; ",
"Params" : """
Paper paper, float x0, float y0, float x1, float y1
""",
"ParamCode" : """
this->paper = paper;
! corners[0].x = corners[1].x = x0;
! corners[0].y = corners[3].y = y0;
! corners[2].x = corners[3].x = x1;
! corners[1].y = corners[2].y = y1;
""",
"RenderCode" : """
DBG(dbg) << "Paper\\n";
--- 421,436 ----
{
"Type" : "2",
"Name": "FisheyePaperQuad",
! "Data": "Paper::Paper* paper; float x0, y0, x1, y1;",
"Params" : """
Paper paper, float x0, float y0, float x1, float y1
""",
"ParamCode" : """
this->paper = paper;
! this->x0 = x0;
! this->y0 = y0;
! this->x1 = x1;
! this->y1 = y1;
""",
"RenderCode" : """
DBG(dbg) << "Paper\\n";
***************
*** 440,445 ****
--- 440,452 ----
ZVec paperx = coords1.transform(Pt(1, 0)) - paperorigin;
ZVec papery = coords1.transform(Pt(0, 1)) - paperorigin;
+ ZPt borig = coords2.transform(Pt(0, 0));
+ ZVec b0 = coords2.transform(Pt(1, 0)) - borig;
+ ZVec b1 = coords2.transform(Pt(0, 1)) - borig;
+
+ b0 = 1.0 / (b0.x * b0.x + b0.y * b0.y) * b0;
+ b1 = 1.0 / (b1.x * b1.x + b1.y * b1.y) * b1;
+
Paper::LightParam lightParam;
lightParam.orig = paperorigin-ZPt(0,0,0);
lightParam.e0 = paperx;
***************
*** 455,471 ****
lightParam.e0 << " " <<
lightParam.e1 << " " <<
lightParam.e2 << " " <<
! "\\nCorners" <<
! corners[0] <<
! corners[1] <<
! corners[2] <<
! corners[3] <<
! "\\nCorners trans:" <<
! coords1.transform(corners[0]) <<
! coords1.transform(corners[1]) <<
! coords1.transform(corners[2]) <<
! coords1.transform(corners[3]) <<
! "\\n"
;
}
GLERR
--- 462,470 ----
lightParam.e0 << " " <<
lightParam.e1 << " " <<
lightParam.e2 << " " <<
! "\\nx0,x1,y0,y1: " <<
! x0 << " " << x1 << " " <<
! y0 << " " << y1 << "\\n"
;
}
GLERR
***************
*** 474,494 ****
if (dbg) cout << "Pass\\n";
(*it).setUpVP(&lightParam);
! GLERR
! glBegin(GL_QUADS);
!
! glTexCoord2f(corners[0].x,corners[0].y);
! coords1.vertex(corners[0]);
!
! glTexCoord2f(corners[1].x,corners[1].y);
! coords1.vertex(corners[1]);
!
! glTexCoord2f(corners[2].x,corners[2].y);
! coords1.vertex(corners[2]);
! glTexCoord2f(corners[3].x,corners[3].y);
! coords1.vertex(corners[3]);
! glEnd();
GLERR
(*it).tearDownVP();
--- 473,502 ----
if (dbg) cout << "Pass\\n";
(*it).setUpVP(&lightParam);
! float xstep = (x1 - x0) / 16;
! float ystep = (y1 - y0) / 16;
! for (float y_ = y0; y_ + ystep <= y1; y_ += ystep) {
! glBegin(GL_QUAD_STRIP);
! for (float x = x0; x <= x1; x += xstep) {
! int i = 0;
! for (float y = y_; i < 2; i++, y += ystep) {
! glTexCoord2f(x, y);
!
! // Map (x,y) into coords2 as (a,b)
!
! ZPt pos = coords1.transform(Pt(x,y));
! float a = b0.dot(pos - borig);
! float b = b1.dot(pos - borig);
!
! // Modulate distance from coords2 origin
! float m = 1 + 2.0 / (1 + a * a + b * b);
!
! coords2.vertex(Pt(m*a, m*b));
! }
! }
! glEnd();
! }
GLERR
(*it).tearDownVP();
- [Gzz-commits] gzz/gfx demo/fisheye.py librenderables/renderab...,
Janne V. Kujala <=