[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, 14 Aug 2003 08:24:41 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Janne V. Kujala <address@hidden> 03/08/14 08:24:41
Modified files:
include/vob/vobs: Fillet.hxx
vob/demo/multifil: multifil.py
vob/fillet : light3d.py
Log message:
add support for coloring multifilleted nodes; example in multifil.py
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Fillet.hxx.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil/multifil.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/fillet/light3d.py.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
Patches:
Index: libvob/include/vob/vobs/Fillet.hxx
diff -u libvob/include/vob/vobs/Fillet.hxx:1.50
libvob/include/vob/vobs/Fillet.hxx:1.51
--- libvob/include/vob/vobs/Fillet.hxx:1.50 Wed Aug 13 09:36:21 2003
+++ libvob/include/vob/vobs/Fillet.hxx Thu Aug 14 08:24:41 2003
@@ -587,9 +587,12 @@
int i;
vector<Vec> v;
+ vector<float> tex;
- for (i = 0; i <= ndice; i++)
+ for (i = 0; i <= ndice; i++) {
v.push_back(f0.point((float)i / ndice));
+ tex.push_back(0);
+ }
ZVec e0 = (t0.transform(ZVec(0,0,1)) -
t0.transform(ZVec(0,0,0))).normalized();
ZVec e1 = (t0.transform(ZVec(0,1,0)) -
t0.transform(ZVec(0,0,0))).normalized();
@@ -603,7 +606,7 @@
};
glPushMatrix();
glMultMatrixf(mat);
- render(v, computeNormals(v));
+ render(v, computeNormals(v), tex);
glPopMatrix();
}
@@ -636,12 +639,19 @@
int i;
vector<Vec> v;
+ vector<float> tex;
- for (i = 0; i < ndice; i++)
- v.push_back(f1.point((float)i / ndice));
+ float x0 = cos(conn.a) * r;
+ for (i = 0; i < ndice; i++) {
+ Vec p = f1.point((float)i / ndice);
+ v.push_back(p);
+ tex.push_back((p.x - x0) / (d - x0));
+ }
- for (i = 0; i <= ndice; i++)
+ for (i = 0; i <= ndice; i++) {
v.push_back(f0.point((float)i / ndice));
+ tex.push_back(0);
+ }
ZVec ref = t0.transform(ZVec(0,0,1)) - t0.transform(ZVec(0,0,0));
@@ -657,11 +667,12 @@
};
glPushMatrix();
glMultMatrixf(mat);
- render(v, computeNormals(v));
+ render(v, computeNormals(v), tex);
glPopMatrix();
}
- void render(const vector<Vec> &v, const vector<Vec> &n) const {
+ void render(const vector<Vec> &v, const vector<Vec> &n,
+ const vector<float> &tex) const {
size_t i;
int j;
@@ -677,7 +688,7 @@
float t = (float)j / ndice;
- glTexCoord2f(s0, t);
+ glTexCoord3f(s0, t, tex[i]);
glNormal3f(n[i].x,
cos(a) * n[i].y,
sin(a) * n[i].y);
@@ -685,7 +696,7 @@
cos(a) * v[i].y,
sin(a) * v[i].y);
- glTexCoord2f(s1, t);
+ glTexCoord3f(s1, t, tex[i + 1]);
glNormal3f(n[i + 1].x,
cos(a) * n[i + 1].y,
sin(a) * n[i + 1].y);
@@ -722,7 +733,7 @@
typedef Filletoid<StretchedCircleFillet> Conn;
ZVec blend(Conn *conns[], int N, float r, ZVec pt,
- int *maxip = NULL) const {
+ int *maxip = NULL, float *distfract = NULL) const {
int i, num = 0;
double sum = 0;
float x[N];
@@ -731,13 +742,22 @@
pt = pt.normalized();
+ if (distfract) *distfract = 0;
+
//cout << "Blending " << pt << ": ";
// Compute distances from the node for each fillet surface
for (i = 0; i < N; i++) {
bool success;
float t = conns[i]->rad(pt, success);
if (success && t > r) {
- if (t > maxt) maxt = t, maxi = i;
+ if (t > maxt) {
+ maxt = t;
+ maxi = i;
+ if (distfract) {
+ float x0 = cos(conns[i]->f.tangentAngle) * r;
+ *distfract = (t * conns[i]->dir.dot(pt) - x0) /
(conns[i]->c.d - x0);
+ }
+ }
x[num++] = (t - r) / r;
// Approximate the slope of the fillet surface
@@ -931,8 +951,9 @@
}
void renderCylinder2(const std::vector<ZVec> &pt,
- const std::vector<bool> &clip,
- int n, int m) const {
+ const std::vector<bool> &clip,
+ const std::vector<float> &tex,
+ int n, int m) const {
std::vector<ZVec> norm(n * m);
int i, j;
@@ -951,9 +972,11 @@
glBegin(GL_QUAD_STRIP);
for (i = 0; i < n; i++) {
+ glTexCoord3f(0, 0, tex[i * m + j]);
glNormal(norm[i * m + j]);
glVertex(pt[i * m + j]);
+ glTexCoord3f(0, 0, tex[i * m + (j + 1) % m]);
glNormal(norm[i * m + (j + 1) % m]);
glVertex(pt[i * m + (j + 1) % m]);
@@ -1030,21 +1053,23 @@
}
std::vector<bool> clip(pt.size());
+ std::vector<float> tex(pt.size());
// note: not blending the connection mid-point
for (j = 0; j < ndice; j++) {
pt[j] += p0;
clip[j] = false;
+ tex[j] = 1;
}
for (i = 1; i <= ndice; i++) {
for (j = 0; j < ndice; j++) {
int ind = i * ndice + j;
int maxi;
- pt[ind] = blend(conns, N, r, pt[ind], &maxi) + p0;
+ pt[ind] = blend(conns, N, r, pt[ind], &maxi, &tex[ind]) +
p0;
clip[ind] = (maxi != k);
}
}
- renderCylinder2(pt, clip, ndice + 1, ndice);
+ renderCylinder2(pt, clip, tex, ndice + 1, ndice);
if (k == 0 && mode == 0) {
for (i = 0; i <= ndice; i++) {
@@ -1063,6 +1088,7 @@
}
}
+ glTexCoord3f(0,0,0);
renderCylinder(pt, ndice + 1, ndice, false, true);
}
}
Index: libvob/vob/demo/multifil/multifil.py
diff -u libvob/vob/demo/multifil/multifil.py:1.20
libvob/vob/demo/multifil/multifil.py:1.21
--- libvob/vob/demo/multifil/multifil.py:1.20 Sun Jun 29 07:22:07 2003
+++ libvob/vob/demo/multifil/multifil.py Thu Aug 14 08:24:41 2003
@@ -56,11 +56,17 @@
# vs.put(conns, [d, a, b]);
vs.put(conns, cs + [b, e]);
+
+ vs.put(getDListNocoords("Color .7 .5 .3"))
+
vs.put(conns, cs + [c, e]);
# vs.put(GLRen.createDebugSwitch("Fillets", 1));
# vs.put(GLRen.createDebugSwitch("VFillets", 1));
#vs.put(GLRen.createDebugSwitch("Quadrics", 1));
+
+ vs.put(getDListNocoords("Color 1 0 0"))
+
vs.put(conns, cs + [e, b, c]);
# vs.put(GLRen.createDebugSwitch("Fillets", 0));
# vs.put(GLRen.createDebugSwitch("VFillets", 0));
Index: libvob/vob/fillet/light3d.py
diff -u libvob/vob/fillet/light3d.py:1.34 libvob/vob/fillet/light3d.py:1.35
--- libvob/vob/fillet/light3d.py:1.34 Wed Aug 13 09:36:21 2003
+++ libvob/vob/fillet/light3d.py Thu Aug 14 08:24:41 2003
@@ -98,11 +98,11 @@
dot(foo[2].xyz, norm)));
float3 lightvec = normalize(float3(-1, -1, -1));
- float3 diffusemat = float3(.2, .1, 1);
- float3 specularmat = float3(1, 1, 1);
-
+ float3 lightcolor = float3(1, .5, 1);
+ float3 specularcolor = float3(1, 1, 1);
+
float3 lightvec2 = normalize(float3(.5, .5, -1));
- float3 diffusemat2 = float3(.1, .5, .5);
+ float3 light2color = float3(.5, 1, .5);
float3 eyevec = float3(0,0,-1);
@@ -112,10 +112,15 @@
float specular = dot(normvec, halfvec);
float4 lighting = lit(diffuse, specular, 10);
-
- ocol.rgb = lighting.y * diffusemat + lighting.z * specularmat
- + max(diffuse2, 0) * diffusemat2
- ;//+ max(-normvec.z, 0) * col;
+ float t = (1 - tex0.z);
+ float3 defaultcolor = float3(.2, .2, 1);
+ float3 color = lerp(defaultcolor, col, t * t);
+
+ ocol.rgb = lighting.y * color * lightcolor
+ + lighting.z * specularcolor
+ + max(diffuse2, 0) * color * light2color
+ //+ max(-normvec.z, 0) * col;
+ ;
// Fog
// float t = 8*mul(glstate.matrix.mvp, pos).z;
// ocol.rgb = ocol.rgb * (1 - t) + float3(1,.5,.2) * t;
@@ -355,9 +360,11 @@
"""))
if self.blend3d:
+ vs.put(getDListNocoords("Color .2 .2 1"))
pc(conns3dblend, [thick, angle])
if self.drawInside:
+ vs.put(getDListNocoords("Color .2 .2 1"))
pc(conns3d, [thick, angle])
vs.put(getDListNocoords("""
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] libvob include/vob/vobs/Fillet.hxx vob/demo/mul...,
Janne V. Kujala <=