[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob include/vob/geom/Fillets2.hxx include/vo...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] libvob include/vob/geom/Fillets2.hxx include/vo... |
Date: |
Fri, 04 Jul 2003 09:57:32 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Janne V. Kujala <address@hidden> 03/07/04 09:57:31
Modified files:
include/vob/geom: Fillets2.hxx
include/vob/vobs: Fillet.hxx
vob/fillet : light3d.py
Log message:
add 'm' key for choosing blending mode
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/geom/Fillets2.hxx.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.44&tr2=1.45&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/fillet/light3d.py.diff?tr1=1.29&tr2=1.30&r1=text&r2=text
Patches:
Index: libvob/include/vob/geom/Fillets2.hxx
diff -u libvob/include/vob/geom/Fillets2.hxx:1.28
libvob/include/vob/geom/Fillets2.hxx:1.29
--- libvob/include/vob/geom/Fillets2.hxx:1.28 Fri Jul 4 08:49:53 2003
+++ libvob/include/vob/geom/Fillets2.hxx Fri Jul 4 09:57:30 2003
@@ -766,12 +766,9 @@
a0 = atan(0.5 * c.t / c.d);
- da = (f.tangentAngle - a0) / n;
- sin_da = sin(da);
-
for (int i = 1; i < n; i++) {
float t = i * (1.0 / n);
- float a = a0 + t * (f.tangentAngle - a0);
+ float a = a0 + (t*t) * (f.tangentAngle - a0);
bool success;
float fract;
ZVec pt = f.point(dirVec(a), success, &fract, .0001);
@@ -789,19 +786,26 @@
float rad_rtbl(Vec v) const {
int n = rtbl.size() - 1;
float a = v.atan();
- float t = (a - a0) / (f.tangentAngle - a0);
+ if (a < a0) return rtbl[0];
+ float t = sqrt((a - a0) / (f.tangentAngle - a0));
int i = (int)(t * n);
- if (t < 0) return rtbl[0];
if (i >= n) return rtbl[n];
float fract = t * n - i;
float r0 = rtbl[i];
float r1 = rtbl[i + 1];
- return r0 * r1 / (r0 * fract + r1 * (1-fract));
- return (1 - fract) * r0 + fract * r1;
- return r0 * r1 * sin_da / (r0 * sin(fract * da) +
- r1 * sin((1-fract) * da)) >? r1;
+ // lerp
+ //return (1 - fract) * r0 + fract * r1;
+
+ // polar lerp approximation
+ //return r0 * r1 / (r0 * fract + r1 * (1-fract));
+
+ // polar lerp
+ float da = (f.tangentAngle - a0) / n;
+ da *= 2 * t + 1E-4;// compensate for the squaring
+ return r0 * r1 * sin(da) / (r0 * sin(fract * da) +
+ r1 * sin((1-fract) * da)) >? r1;
}
};
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.44
libvob/include/vob/vobs/Fillet.hxx:1.45
--- libvob/include/vob/vobs/Fillet.hxx:1.44 Fri Jul 4 08:49:53 2003
+++ libvob/include/vob/vobs/Fillet.hxx Fri Jul 4 09:57:30 2003
@@ -671,9 +671,10 @@
int ndice;
float dicelen;
int tblsize;
+ int mode;
template<class F> void params(F &f) {
- f(ndice, dicelen, tblsize);
+ f(ndice, dicelen, tblsize, mode);
}
template<class T> float crad(const T &t) const {
@@ -772,6 +773,9 @@
float l1 = (v[j] - v[k]).length() * !(v[j].id && v[j].id ==
v[k].id);
float l2 = (v[k] - v[i]).length() * !(v[k].id && v[k].id ==
v[i].id);
+ if (!(l0 < 1000 && l1 < 1000 && l2 < 1000))
+ return -1;
+
if (l0 < dicelen && l1 < dicelen && l2 < dicelen)
return -1;
@@ -898,7 +902,7 @@
dirs.push_back((p1 - p0).normalized());
}
-#if 1
+ if (mode == 0 || mode == 1) {
for (int k = 0; k < N; k++) {
std::vector<ZVec> pt((ndice + 1) * ndice);
@@ -935,7 +939,7 @@
renderCylinder2(pt, clip, ndice + 1, ndice);
- if (k == 0) {
+ if (k == 0 && mode == 0) {
for (i = 0; i <= ndice; i++) {
float f = (float)i / ndice;
@@ -956,37 +960,42 @@
}
}
-#elif 1 // Old version without Dicer
+ } else if (mode == 2) {
- std::vector<ZVec> pt((ndice + 1) * (ndice * 2));
+ std::vector<ZVec> pt((ndice + 1) * (ndice * 2));
- for (i = 0; i <= ndice; i++) {
- float a = i * M_PI / ndice;
- float x = cos(a);
- float R = sin(a);
+ for (i = 0; i <= ndice; i++) {
+ float a = i * M_PI / ndice;
+ float x = cos(a);
+ float R = sin(a);
- for (j = 0; j < ndice*2; j++) {
- float b = j * M_PI * 2 / (ndice*2);
+ for (j = 0; j < ndice*2; j++) {
+ float b = j * M_PI * 2 / (ndice*2);
- float y = cos(b) * R;
- float z = sin(b) * R;
+ float y = cos(b) * R;
+ float z = sin(b) * R;
- pt[i * (ndice * 2) + j] = r * ZVec(x, y, z);
+ pt[i * (ndice * 2) + j] = r * ZVec(x, y, z);
+ }
}
- }
- for (i = 0; i < (ndice + 1) * (ndice * 2); i++)
- pt[i] = blend(conns, N, r, pt[i]) + p0;
- renderCylinder(pt, ndice + 1, ndice * 2);
+
+ for (i = 0; i < (ndice + 1) * (ndice * 2); i++)
+ pt[i] = blend(conns, N, r, pt[i]) + p0;
+
+ renderCylinder(pt, ndice + 1, ndice * 2);
+ } else {
-#else // use Dicer
+ // use Dicer
Verts verts(*this, conns, N, r);
::Vob::Dicer::Triangles<Verts> triangler(verts);
-#if 0 // use Delaunay triangulation based topology
+ if (mode == 3) {
+
+ // use Delaunay triangulation based topology
if (dirs.size() == 2) {
ZVec sum = dirs[0] + dirs[1];
@@ -1083,7 +1092,7 @@
triangler.add(nvert, poly[j], poly[(j+1) % poly.size()]);
}
-#else // Icosahedron topology
+ } else if (mode == 4) {
// icosahedron code adapted from sphere.c found in
// http://www.sgi.com/Technology/openGL/advanced/programs.html
@@ -1141,7 +1150,7 @@
triangler.add(Im1, Im0, Im5);
triangler.add(Im2, Im1, Im5);
-#endif
+ }
triangler.dice(DiceCrit(verts, verts.noblend ? .01 * dicelen :
dicelen));
@@ -1181,7 +1190,7 @@
}
glEnd();
-#endif // use Dicer
+ }
for (i = 0; i < N; i++) {
delete conns[i];
Index: libvob/vob/fillet/light3d.py
diff -u libvob/vob/fillet/light3d.py:1.29 libvob/vob/fillet/light3d.py:1.30
--- libvob/vob/fillet/light3d.py:1.29 Fri Jul 4 08:49:53 2003
+++ libvob/vob/fillet/light3d.py Fri Jul 4 09:57:31 2003
@@ -201,7 +201,8 @@
Toggle("perspective", 0, "perspective", "F"),
Toggle("texture", 0, "texture", "x"),
SlideLin("dicelen", 100, 5, "Dice length", "G", "g"),
- SlideLin("tblsize", 100, 1, "Table size", "<", ">"),
+ SlideLin("tblsize", 20, 1, "Table size", "<", ">"),
+ SlideLin("mode", 0, 1, "Blending mode", "M", "m"),
]
width = 0
@@ -283,7 +284,7 @@
GLRen.createFillet3D(border, self.dice, 1),
2)
- conns3dblend = GLRen.createFillet3DBlend(self.dice, self.dicelen,
self.tblsize);
+ conns3dblend = GLRen.createFillet3DBlend(self.dice, self.dicelen,
self.tblsize, self.mode);
thick = vs.coords.rational1D22(0, self.thick, 0, 0, 1, 1, 0);
angle = vs.coords.rational1D22(0, self.angle, 0, 0, 1, 0, 0);
@@ -330,7 +331,8 @@
if self.blend3d:
pc(conns3dblend, [thick, angle])
- elif self.drawInside:
+
+ if self.drawInside:
pc(conns3d, [thick, angle])
vs.put(getDListNocoords("""