[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob ./TODO include/vob/LinearPrimitives.hxx ...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] libvob ./TODO include/vob/LinearPrimitives.hxx ... |
Date: |
Wed, 12 Mar 2003 11:17:20 -0500 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Changes by: Tuomas J. Lukka <address@hidden> 03/03/12 11:17:20
Modified files:
. : TODO
include/vob : LinearPrimitives.hxx Primitives.hxx
src/jni : Gen.cxx
test/vob/gl : glvobcoorder.test
Log message:
BOTH AWT AND GL TEST PASS\!\!\!
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/TODO.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/LinearPrimitives.hxx.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/Primitives.hxx.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Gen.cxx.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/test/vob/gl/glvobcoorder.test.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: libvob/TODO
diff -u libvob/TODO:1.9 libvob/TODO:1.10
--- libvob/TODO:1.9 Wed Mar 12 08:37:57 2003
+++ libvob/TODO Wed Mar 12 11:17:17 2003
@@ -9,6 +9,8 @@
vegai:
- .cvsignores
- make sure libvob works right with kaffe
+ humppake:
+ - fix testCulling
0.1alpha2: Vital fixes for packages depending on this
tjl:
Index: libvob/include/vob/LinearPrimitives.hxx
diff -u libvob/include/vob/LinearPrimitives.hxx:1.9
libvob/include/vob/LinearPrimitives.hxx:1.10
--- libvob/include/vob/LinearPrimitives.hxx:1.9 Mon Mar 10 13:15:53 2003
+++ libvob/include/vob/LinearPrimitives.hxx Wed Mar 12 11:17:20 2003
@@ -54,7 +54,7 @@
void tr(const ZPt &from, ZPt &to) const {
to = from + vec;
}
- void performGL() {
+ void performGL() const {
glTranslatef(vec.x, vec.y, vec.z);
}
typedef TranslateXYZ InverseType;
@@ -79,7 +79,7 @@
void tr(const ZPt &from, ZPt &to) const {
to = from * vec;
}
- void performGL() {
+ void performGL() const {
glScalef(vec.x, vec.y, vec.z);
}
typedef ScaleXYZ InverseType;
@@ -171,7 +171,7 @@
void tr(const ZPt &from, ZPt &to) const {
to = from;
}
- void performGL() {
+ void performGL() const {
}
typedef Unit InverseType;
void inverse(InverseType &into) const { }
@@ -195,7 +195,7 @@
void tr(const ZPt &from, ZPt &to) const {
to = from;
}
- void performGL() {
+ void performGL() const {
}
Pt getSqSize() const { return box; }
@@ -218,6 +218,61 @@
};
VOB_PRIMITIVETRANS_DEFINED(Box_Explicit, "box");
+ struct RotateXYZ:
+ public PrimitiveTransform,
+ public GLPerformablePrimitiveTransform
+ {
+ public:
+ ZVec vec;
+ /** Angle, degs.
+ */
+ float a;
+ /** Sine and cosine of angle.
+ */
+ float s, c;
+
+ void angleWasSet() {
+ s = sin(a * M_PI / 180);
+ c = cos(a * M_PI / 180);
+ }
+
+ void tr(const ZPt &from, ZPt &to) const {
+ ZVec v(from);
+ float same = v.dot(vec);
+ ZVec para = v - same*vec;
+ float paral = para.length();
+ para = (1/paral)*para;
+ ZVec ortho = para.crossp(vec).normalized();
+ to = ZPt( same * vec + paral * (c * para - s * ortho) );
+ }
+ virtual void performGL() const {
+ glRotatef(a, vec.x, vec.y, vec.z);
+ }
+ typedef RotateXYZ InverseType;
+ void inverse(InverseType &inv) const {
+ inv.vec = vec;
+ inv.a = -a;
+ inv.angleWasSet();
+ }
+ };
+
+ struct RotateXYZ_Explicit :
+ public RotateXYZ,
+ public ParametrizedPrimitiveTransform
+ {
+ enum { NParams = 4 };
+ template<class Ptr> void setParams(Ptr p) {
+ vec.x = p[0];
+ vec.y = p[1];
+ vec.z = p[2];
+ vec = vec.normalized();
+ a = p[3];
+
+ angleWasSet();
+ }
+ };
+ VOB_PRIMITIVETRANS_DEFINED(RotateXYZ_Explicit, "rotateXYZ");
+
/** Affine coordinate system (in xy), offset in z.
* Can't be used in HierarchicalTransform directly
* because parameters are required.
@@ -239,7 +294,7 @@
to.y += ydot.dot(from);
to.z += from.z;
}
- void performGL() {
+ void performGL() const {
GLfloat matrix[16] = {
xdot.x, ydot.x, 0, 0,
xdot.y, ydot.y, 0, 0,
@@ -307,7 +362,7 @@
to.y = y + from.y * sy;
to.z = z + from.z;
}
- void performGL() {
+ void performGL() const {
glTranslatef(x, y, z);
glScalef(sx, sy, 1);
}
@@ -385,6 +440,7 @@
};
VOB_PRIMITIVETRANS_DEFINED(UnitSqBox, "unitSqBox");
+
}
}
Index: libvob/include/vob/Primitives.hxx
diff -u libvob/include/vob/Primitives.hxx:1.12
libvob/include/vob/Primitives.hxx:1.13
--- libvob/include/vob/Primitives.hxx:1.12 Mon Mar 10 11:02:05 2003
+++ libvob/include/vob/Primitives.hxx Wed Mar 12 11:17:20 2003
@@ -109,6 +109,12 @@
void performGL() { }
};
+ class PotentiallyGLPerformablePrimitiveTransform {
+ public:
+ bool canPerformGL() { return false; }
+ bool performGL() { return false; }
+ };
+
class NonlinearPrimitiveTransform {
public:
float nonlinearity(ZPt p, float radius) { return 0; }
@@ -231,81 +237,90 @@
{
const Transform *super;
Transform *inverse;
+
Primitive t;
// Dispatching by the tag classes of t:
// alternative versions for transforms with and without
// given features.
- bool performGL(GLPerformablePrimitiveTransform &t) const {
+ bool performGL(const GLPerformablePrimitiveTransform *_) const {
+ if(!super->performGL()) return false;
+ t.performGL();
+ return true;
+ }
+ bool performGL(const PotentiallyGLPerformablePrimitiveTransform *_)
const {
if(!super->performGL()) return false;
return t.performGL();
}
- template<class T> bool performGL(T &t) const {
+ bool performGL(const void *_) const {
return false;
}
- bool canPerformGL(GLPerformablePrimitiveTransform &t) const {
+ bool canPerformGL(const GLPerformablePrimitiveTransform *_) const {
return super->canPerformGL();
}
- template<class T> bool canPerformGL(T &t) const {
+ bool canPerformGL(const PotentiallyGLPerformablePrimitiveTransform *_)
const {
+ return t.canPerformGL() && super->canPerformGL() ;
+ }
+ bool canPerformGL(const void *_) const {
return false;
}
- float selfNonlinearity(NonlinearPrimitiveTransform &t,
+ float selfNonlinearity(const NonlinearPrimitiveTransform *_,
const ZPt &p, float radius) const {
return t.nonlinearity(p, radius);
}
- template<class T> float selfNonlinearity(T &t,
+ float selfNonlinearity(const void *_,
const ZPt &p, float radius) const {
return 0;
}
- int getNParams(void *t) const {
+ int getNParams(const void *_) const {
return 0;
}
- int getNParams(ParametrizedPrimitiveTransform *t) const {
+ int getNParams(const ParametrizedPrimitiveTransform *_) const {
return Primitive::NParams;
}
- int getNDepends(DependentPrimitiveTransform &t) const {
+ int getNDepends(const DependentPrimitiveTransform *_) const {
return Primitive::NDepends;
}
- template<class T> int getNDepends(T &t) const {
+ int getNDepends(const void *_) const {
return 1;
}
- Pt getSqSize(const BoxPrimitiveTransform *t__) const {
+ Pt getSqSize(const BoxPrimitiveTransform *___) const {
return t.getSqSize();
}
- Pt getSqSize(const void *t) const {
+ Pt getSqSize(const void *_) const {
return Pt(1,1);
}
// Difficult: double switches: dependent, parametrized for setParams..
- void setParams(DependentPrimitiveTransform *t__,
+ void setParams(const DependentPrimitiveTransform *___,
const Transform **depends, float *p) {
setDependentParams(&t, depends, p);
}
- void setParams(void *__t,
+ void setParams(const void *__t,
const Transform **depends, float *p) {
setNondependentParams(&t, p);
}
- void setDependentParams(ParametrizedPrimitiveTransform *t__,
+ void setDependentParams(const ParametrizedPrimitiveTransform *___,
const Transform **depends, float *p) {
t.setParams(depends, p);
}
- void setDependentParams(void *t__,
+ void setDependentParams(const void *___,
const Transform **depends, float *p) {
t.setParams(depends);
}
- void setNondependentParams(void *t__,
+ void setNondependentParams(const void *___,
float *p) {
// noop
}
- void setNondependentParams(ParametrizedPrimitiveTransform *t__,
+ void setNondependentParams(const ParametrizedPrimitiveTransform *___,
float *p) {
t.setParams(p);
}
@@ -324,7 +339,7 @@
return getNParams(&t);
}
virtual int getNDepends() {
- return getNDepends(t);
+ return getNDepends(&t);
}
virtual void setParams(const Transform **depends, float *p) {
@@ -345,12 +360,12 @@
super->vertex(mp);
}
- virtual bool performGL() const { return performGL(t); }
+ virtual bool performGL() const { return performGL(&t); }
- virtual bool canPerformGL() const { return canPerformGL(t); }
+ virtual bool canPerformGL() const { return canPerformGL(&t); }
virtual float nonlinearity(const ZPt &p, float radius) const {
- float s = selfNonlinearity(t, p, radius);
+ float s = selfNonlinearity(&t, p, radius);
ZPt mp;
t.tr(p, mp);
float su = super->nonlinearity(mp, radius);
Index: libvob/src/jni/Gen.cxx
diff -u libvob/src/jni/Gen.cxx:1.11 libvob/src/jni/Gen.cxx:1.12
--- libvob/src/jni/Gen.cxx:1.11 Tue Mar 11 07:57:04 2003
+++ libvob/src/jni/Gen.cxx Wed Mar 12 11:17:20 2003
@@ -42,6 +42,7 @@
#include <vob/vobs/Trivial.hxx>
#include <vob/vobs/Pixel.hxx>
#include <vob/LinearPrimitives.hxx>
+#include <vob/FunctionalPrimitives.hxx>
int main() {
std::ifstream templ("src/jni/GLRen.template.java");
@@ -76,6 +77,7 @@
jni << "#include <vob/vobs/Trivial.hxx>\n";
jni << "#include <vob/vobs/Pixel.hxx>\n";
jni << "#include <vob/LinearPrimitives.hxx>\n";
+ jni << "#include <vob/FunctionalPrimitives.hxx>\n";
jni << "#include \"org_nongnu_libvob_gl_GLRen.h\"\n";
jni << "using namespace Vob::JNI;\n";
jni << "using namespace Vob::Primitives;\n";
Index: libvob/test/vob/gl/glvobcoorder.test
diff -u libvob/test/vob/gl/glvobcoorder.test:1.3
libvob/test/vob/gl/glvobcoorder.test:1.4
--- libvob/test/vob/gl/glvobcoorder.test:1.3 Wed Mar 12 04:00:50 2003
+++ libvob/test/vob/gl/glvobcoorder.test Wed Mar 12 11:17:20 2003
@@ -48,8 +48,6 @@
checkTrans(vs, cs, [0, 0, 0, 1, 1, 1, 2, 2, 2], [10, 15, 5, 11, 18, 9, 12,
21, 13])
- cs3 = c.distort(0, 0, 0, 0.1, 0.1, 20, 5)
- checkTrans(vs, cs3, [0, 0, 0, 0.001, 0.001, 1], [0, 0, 0, 0.02, 0.02, 1],
delta=0.00001, alsoRender = 0)
@@ -59,16 +57,6 @@
# Clockwise rotation
c.setRotateParams(r, 90)
checkTrans(vs, r, [0, 0, 0, 0, 50, 0], [100, 100, 0, 50, 100, 0])
-
- cs4 = c.affineCoordsys(0, 0, 0, 0, 100, 0, 0, 100)
- cs4clip = c.affineCoordsys(0, 0, 50, 50, 10, 0, 0, 10)
-
- cs4cull = c.cull(cs4, cs4clip)
- checkTrans(vs, cs4cull, [0, 0, 0, 1, 1, 1, 2, 2, 2], [0, 0, 0, 100, 100,
1, 200, 200, 2])
-
- c.setAffineParams(cs4clip, 0, 1500, 1500, 10, 0, 0, 10)
- checkNoTrans(vs, cs4cull)
-
def checkInverse(c, cs):
# unit cube
src = array([
@@ -99,7 +87,7 @@
c.transformPoints3(cs, src, dst)
c.inverseTransformPoints3(cs, dst, src2)
- cs_inv = c.invert(cs)
+ cs_inv = c.concatInverse(0, cs)
c.transformPoints3(cs_inv, dst, src3)
c.inverseTransformPoints3(cs_inv, src2, dst2)
@@ -128,7 +116,7 @@
def testInverses():
for i in range(0,5):
- c = GLVobCoorder()
+ c = getvs().coords
cs_ortho = c.ortho(0, 2, 3.5, 9.1, 1.2, 3.9)
cs_ortho2 = c.ortho(cs_ortho, -1.92, 4.1, 2.951, 2.52, 291)
@@ -149,12 +137,8 @@
checkInverse(c, cs_ortho4)
checkInverse(c, cs_ortho5)
- cs_dist = c.distort(0, 0, 0, 0.5, 0.1, 20, 5)
-
- checkInverse(c, cs_dist)
-
- cs_affine = c.affineCoordsys(0, 0, 0, 0, 100, 0, 0, 100)
- cs_affine_clip = c.affineCoordsys(0, 0, 50, 50, 10, 0, 0, 10)
+ cs_affine = c.affine(0, 0, 0, 0, 100, 0, 0, 100)
+ cs_affine_clip = c.affine(0, 0, 50, 50, 10, 0, 0, 10)
cs_cull = c.cull(cs_affine, cs_affine_clip)
checkInverse(c, cs_cull)
@@ -166,16 +150,6 @@
c.getSqSize(cs_box, box)
failUnlessEqual(box[0], 420)
failUnlessEqual(box[1], 430)
- cs_nadir = c.nadirUnitSq(cs_box, cs_ortho)
- c.getSqSize(cs_nadir, box)
- failUnlessEqual(box[0], 420)
- failUnlessEqual(box[1], 430)
- checkInverse(c, cs_nadir)
- cs_nadir = c.nadirOrigin(cs_box, cs_ortho)
- c.getSqSize(cs_nadir, box)
- failUnlessEqual(box[0], 420)
- failUnlessEqual(box[1], 430)
- checkInverse(c, cs_nadir)
def testInterpolateTranslation():
@@ -188,72 +162,6 @@
[55, 15, 0]
)
-def testInterpolateBuoy():
-
- cs_anchor = c1.translate(0, 10, 0)
- cs_b1 = c1.buoyOnCircle(0, cs_anchor, 0, 0, 20, -20, 0, 0)
-
- checkTrans(vs1, cs_b1,
- [0, 0, 0],
- [20, 0, 0],
- 1)
-
- cs_b2t = c2.affineCoordsys(0, 0, 200, 200, 1, 0, 0, 1)
- interp[cs_b1] = cs_b2t
-
- checkInterp(vs1, vs2, interp, .5, cs_b1,
- [0, 0, 0],
- [110, 100, 0],
- 1)
-
-def testNadir():
-
- # Check that a simple nadir cs does the right thing
- cs_nadir = c1.translate(0, 50, 100)
- cs_center = c1.translate(0, 50, 20)
- cs_rot = c1.nadirOrigin(cs_center, cs_nadir)
-
- checkTrans(vs1, cs_rot,
- [0, 0, 0, 0, 10, 0],
- [50, 20, 0, 50, 30, 0],
- .1)
-
- # Even after translate params.
- c1.setTranslateParams(cs_center, 20, 100)
-
- checkTrans(vs1, cs_rot,
- [0, 0, 0, 0, 10, 0],
- [20, 100, 0, 30, 100, 0],
- .1)
-
- # Check that an orthoBox CS is rotated around the
- # center of the box by nadirUnitSq
- # center = 600, 600
- cs_orthobox = c1.orthoBox(0, 0, 500, 500, .2, .2, 1000, 1000)
- cs_nadir = c1.translate(0, 600, 1000)
- cs_rot = c1.nadirUnitSq(cs_orthobox, cs_nadir)
-
- checkTrans(vs1, cs_rot,
- [500, 500, 0, 600, 500, 0],
- [600, 600, 0, 620, 600, 0],
- .1)
-
- center = vs1.translateCS(0, "Center", 400, 300)
-
- main = vs1.orthoBoxCS(center, "MAINVP", 0,
- -100, -100, .2, .2, 1000, 1000)
-
- nadirCS = vs1.translateCS(0, "NADIRORIGIN", 400, 1500)
-
- n = vs1.coords.nadirUnitSq(main, nadirCS)
-
-
- checkTrans(vs1, n,
- [0, 0, 0, 500, 500, 0],
- [300, 200, 0, 400, 300, 0],
- .1)
-
-
def testCulling():
@@ -273,8 +181,8 @@
font = GL.createFont("gfx/fonts/a010013l.pfb", 16)
renderable = GLRen.createHorizText2(font, "FOO", 1, 1, 1, 1)
- cs = c.affineCoordsys(0, 0, 10, 10, 100, 0, 0, 100)
- cs_clip = c.affineCoordsys(0, 0, 0, 0, 200, 0, 0, 200)
+ cs = c.affine(0, 0, 10, 10, 100, 0, 0, 100)
+ cs_clip = c.affine(0, 0, 0, 0, 200, 0, 0, 200)
cs_cull = c.cull(cs, cs_clip)
putThings()
@@ -304,68 +212,78 @@
checkNotAvgColor(0, 0, 200, 200, (255, 0, 0), delta=50)
#test same area
- cs_clip = c.affineCoordsys(0, 0, 10, 10, 100, 0, 0, 100)
+ cs_clip = c.affine(0, 0, 10, 10, 100, 0, 0, 100)
cs_cull = c.cull(cs, cs_clip)
putThings()
checkNotAvgColor(10, 10, 100, 100, (255, 0, 0), delta=50)
#test normal intersection
- cs_clip = c.affineCoordsys(0, 0, 60, 60, 100, 0, 0, 100)
+ cs_clip = c.affine(0, 0, 60, 60, 100, 0, 0, 100)
cs_cull = c.cull(cs, cs_clip)
putThings()
checkNotAvgColor(10, 10, 100, 100, (255, 0, 0), delta=50)
#test clip inside
- cs_clip = c.affineCoordsys(0, 0, 60, 60, 10, 0, 0, 10)
+ cs_clip = c.affine(0, 0, 60, 60, 10, 0, 0, 10)
cs_cull = c.cull(cs, cs_clip)
putThings()
checkNotAvgColor(10, 10, 100, 100, (255, 0, 0), delta=50)
#test side touch (should not be drawn)
- cs = c.affineCoordsys(0, 0, 10, 10, 100, 0, 0, 100)
- cs_clip = c.affineCoordsys(0, 0, 110, 60, 10, 0, 0, 10)
+ cs = c.affine(0, 0, 10, 10, 100, 0, 0, 100)
+ cs_clip = c.affine(0, 0, 110, 60, 10, 0, 0, 10)
cs_cull = c.cull(cs, cs_clip)
putThings()
checkAvgColor(10, 10, 100, 100, (255, 0, 0), delta=50)
#test corner-touch (should not be drawn)
- cs = c.affineCoordsys(0, 0, 10, 10, 100, 0, 0, 100)
- cs_clip = c.affineCoordsys(0, 0, 110, 110, 10, 0, 0, 10)
+ cs = c.affine(0, 0, 10, 10, 100, 0, 0, 100)
+ cs_clip = c.affine(0, 0, 110, 110, 10, 0, 0, 10)
cs_cull = c.cull(cs, cs_clip)
putThings()
checkAvgColor(10, 10, 100, 100, (255, 0, 0), delta=50)
#test clip outside (should not be drawn)
- cs = c.affineCoordsys(0, 0, 10, 10, 100, 0, 0, 100)
- cs_clip = c.affineCoordsys(0, 0, 120, 60, 10, 0, 0, 10)
+ cs = c.affine(0, 0, 10, 10, 100, 0, 0, 100)
+ cs_clip = c.affine(0, 0, 120, 60, 10, 0, 0, 10)
cs_cull = c.cull(cs, cs_clip)
putThings()
checkAvgColor(10, 10, 100, 100, (255, 0, 0), delta=50)
#test distorted inside (should be drawn)
- cs = c.affineCoordsys(0, 0, 10, 10, 100, 0, 0, 100)
+ cs = c.affine(0, 0, 10, 10, 100, 0, 0, 100)
cs_d = c.distort(cs, 0, 0, 1, 1, 1, 0.1)
- cs_clip = c.affineCoordsys(0, 0, 10, 90, 100, 0, 0, 100)
+ cs_clip = c.affine(0, 0, 10, 90, 100, 0, 0, 100)
cs_cull = c.cull(cs_d, cs_clip)
putThings()
checkNotAvgColor(10, 10, 100, 100, (255, 0, 0), delta=50)
#test distorted outside (should not be drawn)
- cs = c.affineCoordsys(0, 0, 10, 10, 100, 0, 0, 100)
+ cs = c.affine(0, 0, 10, 10, 100, 0, 0, 100)
cs_d = c.distort(cs, 0, 0, 1, 1, 1, 0.1)
#normally without distortion this should be drawn
- cs_clip = c.affineCoordsys(0, 0, 10, 100, 100, 0, 0, 100)
+ cs_clip = c.affine(0, 0, 10, 100, 100, 0, 0, 100)
cs_cull = c.cull(cs_d, cs_clip)
putThings()
checkAvgColor(10, 10, 80, 80, (255, 0, 0), delta=50)
+
+ cs4 = c.affine(0, 0, 0, 0, 100, 0, 0, 100)
+ cs4clip = c.affine(0, 0, 50, 50, 10, 0, 0, 10)
+
+ cs4cull = c.cull(cs4, cs4clip)
+ checkTrans(vs, cs4cull, [0, 0, 0, 1, 1, 1, 2, 2, 2], [0, 0, 0, 100, 100,
1, 200, 200, 2])
+
+ c.setAffineParams(cs4clip, 0, 1500, 1500, 10, 0, 0, 10)
+ checkNoTrans(vs, cs4cull)
+
def testInterpolateType():
"""Test that cses of different types get interpolated