[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul... |
Date: |
Thu, 26 Jun 2003 05:26:18 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Janne V. Kujala <address@hidden> 03/06/26 05:26:18
Modified files:
include/vob/vobs: Fillet.hxx
Added files:
vob/demo/multifil: fillet3d.py
Log message:
Start Fillet3D renderable
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil/fillet3d.py?rev=1.1
Patches:
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.26
libvob/include/vob/vobs/Fillet.hxx:1.27
--- libvob/include/vob/vobs/Fillet.hxx:1.26 Wed Jun 25 10:26:46 2003
+++ libvob/include/vob/vobs/Fillet.hxx Thu Jun 26 05:26:18 2003
@@ -511,6 +511,115 @@
};
VOB_DEFINED(FilletSpan2);
+struct Fillet3D {
+ enum { NTrans = -1 };
+
+ float border;
+ int ndice;
+ int flags;
+
+ template<class F> void params(F &f) {
+ f(border, ndice, flags);
+ }
+
+ template<class T> float crad(const T &t) const {
+ return t.getSqSize().x;
+ }
+
+ ZVec norm(ZVec v) const {
+ if (v.length() > 0)
+ return v.normalized();
+ return ZVec(0,0,0);
+ }
+
+ void render(const Transform **t, int) const {
+ const Transform &thick_t = *t[0];
+ const Transform &angle_t = *t[1];
+
+ const Transform &t0 = *t[2];
+ const Transform &t1 = *t[3];
+
+ ZVec p0 = t0.transform(t0.getSqSize());
+ ZVec p1 = t1.transform(t1.getSqSize());
+
+ float d = (p1 - p0).length() / 2;
+ float r = crad(t0);
+
+ FilletSpan2::Conn conn(thick_t, angle_t, t0, t1, d);
+
+ CircularNode node(ZVec(0,0,0), r);
+ LinearConnectionHalf c1(node, 0/*angle*/, d, conn.th, 1, 0/*z*/);
+
+ StretchedCircleFillet f1(node, c1, conn.a);
+
+ CircularNodeSpan f0(node, conn.a, M_PI);
+
+ int i;
+ vector<Vec> v;
+
+ for (i = 0; i < ndice; i++)
+ v.push_back(f1.point(i / (ndice - 1.0)));
+ for (i = 0; i < ndice; i++)
+ v.push_back(f0.point(i / (ndice - 1.0)));
+
+ vector<Vec> n(v.size());
+
+ n[0] = (v[1] - v[0]).cw90().normalized();
+ for (i = 1; i < v.size() - 1; i++)
+ n[i] = (v[i+1] - v[i-1]).cw90().normalized();
+ n[v.size() - 1] = (v[v.size()-1] - v[v.size()-2]).cw90().normalized();
+
+ ZVec e0 = (p1 - p0).normalized();
+ ZVec e1 = e0.crossp(ZVec(0,0,1)).normalized();
+ ZVec e2 = e0.crossp(e1);
+
+ float mat[16] = {
+ e0.x, e0.y, e0.z, 0,
+ e1.x, e1.y, e1.z, 0,
+ e2.x, e2.y, e2.z, 0,
+ p0.x, p0.y, p0.z, 1,
+ };
+ glPushMatrix();
+ glMultMatrixf(mat);
+ render(v, n);
+ glPopMatrix();
+ }
+
+ void render(const vector<Vec> &v, const vector<Vec> &n) const {
+ int i, j;
+
+ if (v.size() < 2) return;
+
+ for (i = 0; i < v.size() - 1; i++) {
+ glBegin(GL_QUAD_STRIP);
+
+ for (j = 0; j <= ndice; j++) {
+ float a = 2 * M_PI * j / ndice;
+
+ glVertex3f(v[i].x,
+ cos(a) * v[i].y,
+ sin(a) * v[i].y);
+ glNormal3f(n[i].x,
+ cos(a) * n[i].y,
+ sin(a) * n[i].y);
+
+ glVertex3f(v[i + 1].x,
+ cos(a) * v[i + 1].y,
+ sin(a) * v[i + 1].y);
+ glNormal3f(n[i + 1].x,
+ cos(a) * n[i + 1].y,
+ sin(a) * n[i + 1].y);
+ }
+ glEnd();
+ }
+ }
+
+};
+VOB_DEFINED(Fillet3D);
+
+
+
+
}
}
- [Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul..., Tuomas J. Lukka, 2003/06/06
- [Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul..., Janne V. Kujala, 2003/06/25
- [Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul...,
Janne V. Kujala <=
- [Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul..., Janne V. Kujala, 2003/06/26
- [Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul..., Janne V. Kujala, 2003/06/27
- [Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul..., Janne V. Kujala, 2003/06/27
- [Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul..., Janne V. Kujala, 2003/06/27