[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz gfx/libcoords/Coords.cxx gfx/libcoords/Coor...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz gfx/libcoords/Coords.cxx gfx/libcoords/Coor... |
Date: |
Tue, 08 Oct 2002 14:23:44 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/10/08 14:23:43
Modified files:
gfx/libcoords : Coords.cxx Coords.hxx
gfx/libutil : effects.py
gzz/gfx/gl : GLVobCoorder.java
gzz/modules/pp : PlaneView.java demotest.py
Log message:
Implement part of PEG 1010: now can interpolate between buoy and affine
coordsystems\!
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.33&tr2=1.34&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.hxx.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/effects.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLVobCoorder.java.diff?tr1=1.38&tr2=1.39&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/PlaneView.java.diff?tr1=1.51&tr2=1.52&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/demotest.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
Patches:
Index: gzz/gfx/libcoords/Coords.cxx
diff -c gzz/gfx/libcoords/Coords.cxx:1.33 gzz/gfx/libcoords/Coords.cxx:1.34
*** gzz/gfx/libcoords/Coords.cxx:1.33 Mon Oct 7 04:51:24 2002
--- gzz/gfx/libcoords/Coords.cxx Tue Oct 8 14:23:43 2002
***************
*** 117,122 ****
--- 117,125 ----
virtual float nonlinearity(const ZPt &p, float radius) {
return 0;
}
+ virtual bool shouldBeDrawn() {
+ return true;
+ }
};
/** Affine coordinate system (in xy), offset in z.
***************
*** 282,291 ****
*/
class BuoyOnCircleCoords : public CoordSys {
ZVec tr;
public:
BuoyOnCircleCoords() : tr() { }
BuoyOnCircleCoords(ZVec tr) : tr(tr) { }
! enum { NParams = 6, NPrevious = 1 };
virtual void setParams(float *params) {
float pointdir = params[5];
ZVec ctr(params[0], params[1], 0);
--- 285,299 ----
*/
class BuoyOnCircleCoords : public CoordSys {
ZVec tr;
+ CoordSys *anchor;
public:
BuoyOnCircleCoords() : tr() { }
BuoyOnCircleCoords(ZVec tr) : tr(tr) { }
! enum { NParams = 6, NPrevious = 2, NParents = 1 };
! virtual void setSuper(CoordSys **super) {
! CoordSys::setSuper(super);
! this->anchor = super[1];
! }
virtual void setParams(float *params) {
float pointdir = params[5];
ZVec ctr(params[0], params[1], 0);
***************
*** 298,304 ****
}
// Get the anchor of the buoy
! ZPt anchor = super->transform(ZPt(0,0,0));
// Now that we have the anchor, project
// from it to the circle.
ZVec amc = proj - ctr; amc.z = 0;
--- 306,312 ----
}
// Get the anchor of the buoy
! ZPt anchor = this->anchor->transform(ZPt(0,0,0));
// Now that we have the anchor, project
// from it to the circle.
ZVec amc = proj - ctr; amc.z = 0;
***************
*** 341,346 ****
--- 349,368 ----
glTranslatef(tr.x, tr.y, tr.z);
return true;
}
+ virtual bool getOthertypeParams(int type, float *into) {
+ // Parameter layout: x, y, depth, xx, xy, yx, yy
+ if(type == 1) { // translation
+ into[0] = tr.x;
+ into[1] = tr.y;
+ into[2] = tr.z;
+ into[3] = 1;
+ into[4] = 0;
+ into[5] = 0;
+ into[6] = 1;
+ return true;
+ }
+ return false;
+ }
};
/** Rotation around 3D vector.
***************
*** 531,537 ****
CoordSys::setSuper(super);
this->super2 = super[1];
}
! enum { NParams = 0, NPrevious = 2 } ;
virtual void setParams(float *params) { }
virtual CoordSys *createInverse() {
return new ConcatCoordSys( super2->getInverse(),
super->getInverse(),
--- 553,559 ----
CoordSys::setSuper(super);
this->super2 = super[1];
}
! enum { NParams = 0, NPrevious = 2, NParents = 2 } ;
virtual void setParams(float *params) { }
virtual CoordSys *createInverse() {
return new ConcatCoordSys( super2->getInverse(),
super->getInverse(),
***************
*** 558,569 ****
--- 580,595 ----
if(!super2->performGL()) return false;
return super->performGL();
}
+ virtual bool shouldBeDrawn() {
+ return super->shouldBeDrawn() && super2->shouldBeDrawn();
+ }
};
struct SomeFactory {
virtual int nparams() = 0;
virtual int nprevious() = 0;
+ virtual int nparents() = 0;
virtual CoordSys *create() = 0;
};
***************
*** 571,582 ****
--- 597,610 ----
public:
virtual int nparams() { return C::NParams; }
virtual int nprevious() { return 1; }
+ virtual int nparents() { return 1; }
virtual CoordSys *create() { return new TransformCoordSys<C>(); }
};
template<class C> class NoTransFactory : public SomeFactory {
public:
virtual int nparams() { return C::NParams; }
virtual int nprevious() { return C::NPrevious; }
+ virtual int nparents() { return C::NParents; }
virtual CoordSys *create() { return new C(); }
};
***************
*** 599,604 ****
--- 627,644 ----
0
};
+ bool canconvert[9][9] = { // [source][target]
+ { 1, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 1, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 1, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 1, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 1, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 1, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 1, 0, 0 },
+ { 0, 1, 0, 0, 0, 0, 0, 1, 0 }, // buoyoncircle -> affine
+ { 0, 0, 0, 0, 0, 0, 0, 0, 1 }
+ };
+
int CoordSet::nprevious(int typecode) {
return facs[typecode]->nprevious();
}
***************
*** 631,636 ****
--- 671,680 ----
cs[0] = new RootCoords();
DBG(dbg) << "setroot\n";
int lastIndSize = 1;
+
+ CoordSet *cs1_tmp = 0;
+ CoordSet *cs2_tmp = 0;
+
for(int i=1; i<ninds; i+=lastIndSize) {
DBG(dbg) << "loop "<<i<<"\n";
int parind = params.size();
***************
*** 643,664 ****
lastIndSize = nprev + 2; // typecode, prevs and paramind
CoordSys *prev[nprev];
-
- for(int j=0; j<nprev; j++) {
- int parent = inds1[i+1+j];
- CoordSys *parentcs = cs[parent];
- if(parentcs == 0) {
- DBG(dbg) << "Parent "<<j<<" not interp\n";
- goto nextInd; // If parent's not interpolating, neither are
we.
- }
- prev[j] = parentcs;
- }
ind1 = inds1[i+1+nprev];
csind2 = ((interpinds && i < interpinds[0]) ? interpinds[i] : -1);
DBG(dbg) << "inds: "<<parind<<" typ:"<<tp<<" npars:"<<npars<<
" parent:"<<prev[0]<<" "<<
" ind1:"<<ind1<<" "<<csind2<<"\n";
if(csind2 <= 0) {
if(show1) {
for(int j = 0; j<npars; j++) {
--- 687,700 ----
lastIndSize = nprev + 2; // typecode, prevs and paramind
CoordSys *prev[nprev];
ind1 = inds1[i+1+nprev];
csind2 = ((interpinds && i < interpinds[0]) ? interpinds[i] : -1);
DBG(dbg) << "inds: "<<parind<<" typ:"<<tp<<" npars:"<<npars<<
" parent:"<<prev[0]<<" "<<
" ind1:"<<ind1<<" "<<csind2<<"\n";
+
+
if(csind2 <= 0) {
if(show1) {
for(int j = 0; j<npars; j++) {
***************
*** 668,681 ****
continue;
}
} else {
! int ind2 = inds2[csind2 + 2];
! for(int j = 0; j<npars; j++) {
! DBG(dbg) << "Interpolating "<<(ind1+j)<<" "<<(ind2+j)<<" =
"<<
! points1[ind1+j]<<" "<< points2[ind2+j]<<"\n";
! params.push_back(lerp(points1[ind1 + j], points2[ind2 + j],
fract));
}
}
{
CoordSys *c = create(tp);
cs[i] = c;
c->setSuper(prev);
--- 704,791 ----
continue;
}
} else {
! int t2 = inds2[csind2];
! int ind2 = inds2[csind2 + 1 + nprevious(t2)];
! if(t2 == tp) {
! for(int j = 0; j<npars; j++) {
! DBG(dbg) << "Interpolating "
! <<(ind1+j)<<" " <<(ind2+j)<<" = "
! << points1[ind1+j]<<" "<< points2[ind2+j]<<"\n";
! params.push_back(
! lerp(points1[ind1 + j],
! points2[ind2 + j], fract));
! }
! } else {
! // Now, the hairy case.
! DBG(dbg) << "It got hairy now: "<<tp<<" "<<t2<<"\n";
! if(!cs1_tmp) {
! cs1_tmp = new CoordSet();
! cs1_tmp->setPoints(ninds, inds1, points1,
! 0, 0, 0, 0, true);
! }
! if(!cs2_tmp) {
! int maxind = 0;
! for(int k = 1; k<interpinds[0]; k++)
! if(interpinds[k] > maxind)
! maxind = interpinds[k];
! cs2_tmp = new CoordSet();
! cs2_tmp->setPoints(maxind+1, inds2, points2, 0, 0, 0,
! 0, true);
! }
! CoordSys *cs1_non = cs1_tmp->get(i);
! CoordSys *cs2_non = cs2_tmp->get(csind2);
! // Next, the conversion.
! // For now, insist on one converting directly
! // to the other. Later need to search
! // inheritance tree
! int cs1_np = npars;
! int cs2_np = nparams(t2);
! // Just try each conversion routine;
! int maxpar = cs1_np >? cs2_np; // gnu c++-ism.
! float newpars[maxpar];
! DBG(dbg) << "Try getOther: "<<maxpar<<
! " " << cs1_non << " "
! << cs2_non << "\n";
! if(cs1_non->getOthertypeParams(t2, newpars)) {
! DBG(dbg) << "Changed 1\n";
! for(int i=0; i<cs2_np; i++) {
! DBG(dbg) << "Interp "<<newpars[i]<<"
"<<points2[ind2+i]<<"\n";
! params.push_back(
! lerp(newpars[i],
! points2[ind2 + i],
! fract));
! }
! // NOTE!!!
! tp = t2;
! nprev = nprevious(tp);
! // Now, fall through, it gets created right.
! } else if(cs2_non->getOthertypeParams(tp, newpars)) {
! DBG(dbg) << "Changed 2\n";
! for(int i=0; i<cs1_np; i++) {
! DBG(dbg) << "Interp "<<points1[ind1+i]<<"
"<<newpars[i]<<" "<<"\n";
! params.push_back(
! lerp(points1[ind1 + i],
! newpars[i],
! fract));
! }
! // Fall through, it's the right type
! }
! DBG(dbg) << "Done getother: "<<tp<<"\n";
}
}
{
+
+ for(int j=0; j<nprev; j++) {
+ int parent = inds1[i+1+j];
+ CoordSys *parentcs = cs[parent];
+ if(parentcs == 0) {
+ DBG(dbg) << "Parent "<<j<<" not interp\n";
+ goto nextInd; // If parent's not interpolating, neither
are we.
+ }
+ prev[j] = parentcs;
+ }
+ DBG(dbg) << "CS assigned "<<tp<<"\n";
+
CoordSys *c = create(tp);
cs[i] = c;
c->setSuper(prev);
***************
*** 683,697 ****
}
nextInd:;
}
DBG(dbg) << "end\n";
}
bool CoordSys::performGL() {
! DBG(dbg) << "Potential problem: performGL default implementation
called, means incorrect rendering\n";
return false;
}
CoordSys *CoordSys::createInverse() {
! DBG(dbg) << "Potential problem: createInverse default implementation
called, means incorrect rendering\n";
return new RootCoords();
}
--- 793,811 ----
}
nextInd:;
}
+ if(cs1_tmp) delete cs1_tmp;
+ if(cs2_tmp) delete cs2_tmp;
DBG(dbg) << "end\n";
}
bool CoordSys::performGL() {
! DBG(dbg) << "Potential problem: performGL default implementation"
! " called, means incorrect rendering\n";
return false;
}
CoordSys *CoordSys::createInverse() {
! DBG(dbg) << "Potential problem: createInverse default implementation"
! " called, means incorrect rendering\n";
return new RootCoords();
}
Index: gzz/gfx/libcoords/Coords.hxx
diff -c gzz/gfx/libcoords/Coords.hxx:1.14 gzz/gfx/libcoords/Coords.hxx:1.15
*** gzz/gfx/libcoords/Coords.hxx:1.14 Mon Oct 7 04:51:24 2002
--- gzz/gfx/libcoords/Coords.hxx Tue Oct 8 14:23:43 2002
***************
*** 89,94 ****
--- 89,108 ----
virtual void dump() {
cout << "Unknown coordsys\n";
}
+
+ virtual bool shouldBeDrawn() {
+ return super->shouldBeDrawn();
+ }
+
+ /** Get the parameters of a compatible type.
+ * Does not find mutual ancestor etc; simply
+ * converts if it can and if not, fails.
+ * @return true if successful, and into is filled, or false
+ * if conversion cannot be performed.
+ */
+ virtual bool getOthertypeParams(int type, float *into) {
+ return false;
+ }
};
/** A class that manages a set of coordinate systems.
*/
Index: gzz/gfx/libutil/effects.py
diff -c gzz/gfx/libutil/effects.py:1.15 gzz/gfx/libutil/effects.py:1.16
*** gzz/gfx/libutil/effects.py:1.15 Tue Oct 8 06:25:40 2002
--- gzz/gfx/libutil/effects.py Tue Oct 8 14:23:43 2002
***************
*** 8,14 ****
self.__dict__.update(locals())
def buoyCoordsys(self, anchorCS, key):
cs = self.vs.coords.buoyOnCircle(
! anchorCS,
self.center[0], self.center[1],
self.radius,
self.p[0], self.p[1],
--- 8,14 ----
self.__dict__.update(locals())
def buoyCoordsys(self, anchorCS, key):
cs = self.vs.coords.buoyOnCircle(
! self.parent, anchorCS,
self.center[0], self.center[1],
self.radius,
self.p[0], self.p[1],
Index: gzz/gzz/gfx/gl/GLVobCoorder.java
diff -c gzz/gzz/gfx/gl/GLVobCoorder.java:1.38
gzz/gzz/gfx/gl/GLVobCoorder.java:1.39
*** gzz/gzz/gfx/gl/GLVobCoorder.java:1.38 Mon Oct 7 04:51:24 2002
--- gzz/gzz/gfx/gl/GLVobCoorder.java Tue Oct 8 14:23:43 2002
***************
*** 29,35 ****
import gzz.client.gl.*;
public class GLVobCoorder extends AffineVobCoorder {
! public static final String rcsid = "$Id: GLVobCoorder.java,v 1.38 2002/10/07
08:51:24 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
--- 29,35 ----
import gzz.client.gl.*;
public class GLVobCoorder extends AffineVobCoorder {
! public static final String rcsid = "$Id: GLVobCoorder.java,v 1.39 2002/10/08
18:23:43 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
***************
*** 125,131 ****
return was;
}
! public int buoyOnCircle(int into, float cx, float cy,
float rad, float px, float py,
float pointdir) {
floats[nfloats + 0] = cx;
--- 125,131 ----
return was;
}
! public int buoyOnCircle(int into, int anchor, float cx, float cy,
float rad, float px, float py,
float pointdir) {
floats[nfloats + 0] = cx;
***************
*** 139,147 ****
inds[ninds + 0] = 7; // buoy xyz
inds[ninds + 1] = into;
! inds[ninds + 2] = paramInd;
int was = ninds;
! ninds += 3;
return was;
}
--- 139,148 ----
inds[ninds + 0] = 7; // buoy xyz
inds[ninds + 1] = into;
! inds[ninds + 2] = anchor;
! inds[ninds + 3] = paramInd;
int was = ninds;
! ninds += 4;
return was;
}
Index: gzz/gzz/modules/pp/PlaneView.java
diff -c gzz/gzz/modules/pp/PlaneView.java:1.51
gzz/gzz/modules/pp/PlaneView.java:1.52
*** gzz/gzz/modules/pp/PlaneView.java:1.51 Tue Oct 8 03:39:29 2002
--- gzz/gzz/modules/pp/PlaneView.java Tue Oct 8 14:23:43 2002
***************
*** 40,46 ****
*/
public class PlaneView {
! public static final String rcsid = "$Id: PlaneView.java,v 1.51 2002/10/08
07:39:29 tjl Exp $";
public static boolean dbg = true;
private static void pa(String s) { System.err.println(s); }
--- 40,46 ----
*/
public class PlaneView {
! public static final String rcsid = "$Id: PlaneView.java,v 1.52 2002/10/08
18:23:43 tjl Exp $";
public static boolean dbg = true;
private static void pa(String s) { System.err.println(s); }
***************
*** 73,84 ****
BgVob bg = BgVob.create(plane);
int bginto = vs.coords.coordsys(viewport2screen, 500, 0, 0, 1, 1);
int bgpap = vs.coords.coordsys(paper2viewport, 0, 0, 0, 100, 100);
! vs.matcher.add(bginto, "BGTRANS");
vs.map.put(bg, bginto, bgpap);
vs.map.put(GLCache.getCallList("Color 0 0 0"));
int into = ((GLVobCoorder)vs.coords).concat(viewport2screen,
paper2viewport);
Space space = cursor.space;
Dim d_1 = space.getDim(Ids.d_1);
--- 73,86 ----
BgVob bg = BgVob.create(plane);
int bginto = vs.coords.coordsys(viewport2screen, 500, 0, 0, 1, 1);
int bgpap = vs.coords.coordsys(paper2viewport, 0, 0, 0, 100, 100);
! vs.matcher.addSub(viewport2screen, bginto, "BGTRANS");
! vs.matcher.addSub(paper2viewport, bgpap, "BGPAP");
vs.map.put(bg, bginto, bgpap);
vs.map.put(GLCache.getCallList("Color 0 0 0"));
int into = ((GLVobCoorder)vs.coords).concat(viewport2screen,
paper2viewport);
+ vs.matcher.addSub(viewport2screen, into, "PLANEINTO");
Space space = cursor.space;
Dim d_1 = space.getDim(Ids.d_1);
Index: gzz/gzz/modules/pp/demotest.py
diff -c gzz/gzz/modules/pp/demotest.py:1.6 gzz/gzz/modules/pp/demotest.py:1.7
*** gzz/gzz/modules/pp/demotest.py:1.6 Tue Oct 8 07:04:07 2002
--- gzz/gzz/modules/pp/demotest.py Tue Oct 8 14:23:43 2002
***************
*** 5,10 ****
--- 5,11 ----
from gzz.media.impl import *
from gzz.modules.pp import *
import math
+ from java.lang import Math
from gfx.libutil import effects
***************
*** 35,51 ****
lineconn = GLRen.createLineConnector(-10, -10)
class PlaneViewScene:
def __init__(self):
self.pv = PlaneView(VobKeyer())
self.scale = 0.01
def scene(self, vs):
dim = vs.getSize()
ctr = (dim.width/2, dim.height/2)
! (w,h) = 600, 500
! bf = effects.CircleFloater4(vs, 0, ctr, 300, (0,ctr[1]))
vs.map.put(background((0.4,0.5,0.8)))
# Viewport
--- 36,60 ----
lineconn = GLRen.createLineConnector(-10, -10)
+ anchors = [
+ (i, Math.random() * 100, Math.random() * 100)
+ for i in range(0,1)]
+
class PlaneViewScene:
def __init__(self):
self.pv = PlaneView(VobKeyer())
self.scale = 0.01
+ self.floatbuoys = 1
def scene(self, vs):
dim = vs.getSize()
ctr = (dim.width/2, dim.height/2)
! # XXX!!! Viewport widht, height must be same
! # because of concatenating transforms
! (w,h) = 600, 600
! r = 400
! bf = effects.CircleFloater4(vs, 0, ctr, r, (ctr[0]-r,ctr[1]))
vs.map.put(background((0.4,0.5,0.8)))
# Viewport
***************
*** 55,85 ****
vs.matcher.add(self.cs1, "Global")
vs.matcher.add(self.cs2, "p")
vs.map.put(clip, self.cs1)
! self.pv.renderPaper(vs, cursor, -1, self.cs1, self.cs2, None, None)
# vs.map.put(getDListNocoords("""Disable TEXTURE_2D"""))
# vs.map.put(coloredQuad((1,0,0)), self.cs1)
vs.map.put(stopclip, self.cs1)
into = vs.coords.concat(self.cs1, self.cs2)
! anchor = vs.coords.coordsys(into, 0, 10, 20, 10, 20)
!
! flo = bf.buoyCoordsys(anchor, "FOO")
! (w,h) = (100,100)
! mag = vs.coords.coordsys(flo, -5, -w/2, -h/2, w, h)
!
! vs.map.put(coloredQuad((1,0,0)), mag)
!
! vs.map.put(getDListNocoords("""
! Color 0 0 0
! LineWidth 2
! """))
! vs.map.put(lineconn, anchor, flo)
self.currentvs = vs
def key(self, key):
! pass
def mouse(self, ev):
if ev.getID() == ev.MOUSE_CLICKED:
pass
--- 64,105 ----
vs.matcher.add(self.cs1, "Global")
vs.matcher.add(self.cs2, "p")
vs.map.put(clip, self.cs1)
! if 1:
! self.pv.renderPaper(vs, cursor, -1, self.cs1, self.cs2, None, None)
# vs.map.put(getDListNocoords("""Disable TEXTURE_2D"""))
# vs.map.put(coloredQuad((1,0,0)), self.cs1)
vs.map.put(stopclip, self.cs1)
into = vs.coords.concat(self.cs1, self.cs2)
+ vs.matcher.add(into, "fouisesge")
! for a in anchors:
! anchor = vs.coords.coordsys(into, 0, a[1], a[2], 10, 20)
!
! if self.floatbuoys:
! flo = bf.buoyCoordsys(anchor, a[0])
! else:
! flo = vs.coords.affineCoordsys(0,
! 0, 0, 700*Math.random(), 1, 0, 0, 1)
! vs.matcher.add(flo, a[0])
! (w,h) = (100,100)
!
! mag = vs.coords.coordsys(flo, -5, -w/2, -h/2, w, h)
! vs.matcher.addSub(flo, mag, "M")
!
! vs.map.put(coloredQuad((1,0,0)), mag)
!
! vs.map.put(getDListNocoords("""
! Color 0 0 0
! LineWidth 2
! """))
! vs.map.put(lineconn, anchor, flo)
self.currentvs = vs
def key(self, key):
! if key == "f":
! self.floatbuoys = not self.floatbuoys
def mouse(self, ev):
if ev.getID() == ev.MOUSE_CLICKED:
pass
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz gfx/libcoords/Coords.cxx gfx/libcoords/Coor...,
Tuomas J. Lukka <=