797 |
tex1code = CallGLCode(string(tex1.begin(), tex1.end()).c_str()); |
tex1code = CallGLCode(string(tex1.begin(), tex1.end()).c_str()); |
798 |
isectcode = CallGLCode(string(isect.begin(), isect.end()).c_str()); |
isectcode = CallGLCode(string(isect.begin(), isect.end()).c_str()); |
799 |
""", |
""", |
|
"ExtraClass" : """ |
|
|
//#include "../demo/clamptexture.cxx" |
|
|
""", |
|
800 |
"RenderCode" : """ |
"RenderCode" : """ |
801 |
DBG(dbg) << "Paper\\n"; |
DBG(dbg) << "Paper\\n"; |
802 |
GLERR |
GLERR |
1181 |
|
|
1182 |
for (int i = 0; i <= n; i++) { |
for (int i = 0; i <= n; i++) { |
1183 |
norm[i] = (vert[(i+1) % n] - vert[(i+n-1) % n]).cw90().normalize() |
norm[i] = (vert[(i+1) % n] - vert[(i+n-1) % n]).cw90().normalize() |
1184 |
* (0.5 * ripple_scale * texscale); |
* (ripple_scale * texscale); |
1185 |
} |
} |
1186 |
|
|
|
// Compute outer edge / inner edge length ratio |
|
|
// for segments before and after a point and use the |
|
|
// geometric average as the q component of the point. |
|
|
// Exact mapping of the texture to the segment |
|
|
// would require repeating the vertices. |
|
|
for (int i = 0; i <= n; i++) { |
|
|
ZPt p0 = vert[(i+n-1) % n]; |
|
|
ZPt p1 = vert[i]; |
|
|
ZPt p2 = vert[(i+1) % n]; |
|
|
ZVec n0 = norm[(i+n-1) % n]; |
|
|
ZVec n1 = norm[i]; |
|
|
ZVec n2 = norm[(i+1) % n]; |
|
|
|
|
|
float q0 = ((p0 + n0) - (p1 + n1)).length() / |
|
|
((p0 - n0) - (p1 - n1)).length(); |
|
|
|
|
|
float q1 = ((p1 + n1) - (p2 + n2)).length() / |
|
|
((p1 - n1) - (p2 - n2)).length(); |
|
|
|
|
|
texq[i] = sqrt(q0 * q1); |
|
|
} |
|
|
|
|
|
int angles = 3; |
|
|
|
|
1187 |
setup(); |
setup(); |
1188 |
|
float col0[] = {1,1,1,1}; |
1189 |
glBegin(GL_QUAD_STRIP); |
float col1[] = {0,0,0,0}; |
1190 |
for (int i = 0; i <= n; i++) { |
if (!mode) glColor4f(0,0,0,1); |
1191 |
ZPt p = vert[i]; |
Irregu::draw(coords1, vert, norm, texscale, |
1192 |
ZVec normal = norm[i]; |
-.5, .5, col0, col1, 3, 0, |
1193 |
float q = texq[i]; |
Irregu::SLICE_1D + Irregu::Y_SECCOLOR + |
1194 |
|
mode * Irregu::DOTVEC_COLOR); |
1195 |
float dotvec[4] = {0,0,0,0}; |
|
1196 |
float angle = atan2(-normal.x, normal.y); // angle(normal.cw90()) |
if (!mode) { |
1197 |
|
glDisable(GL_TEXTURE_2D); |
1198 |
float a = (angle + M_PI) * angles * (1 / M_PI); |
glDisable(GL_REGISTER_COMBINERS_NV); |
1199 |
int ind = (int)a; |
float col[4]; |
1200 |
float f = a - (int)a; |
glGetFloatv(GL_CONSTANT_COLOR0_NV, col); |
1201 |
|
glColor4fv(col); |
1202 |
dotvec[ind % angles] = 1 - f; |
Irregu::fill(coords1, coords2.transform(ZPt(0,0,0)), |
1203 |
dotvec[(ind + 1) % angles] = f; |
vert, norm, -.5); |
|
|
|
|
if (mode) |
|
|
glColor4fv(dotvec); |
|
|
else |
|
|
glColor4f(0, 0, 0, 1); |
|
|
|
|
|
glTexCoord4f(p.x, p.y, p.z, texscale); |
|
|
glSecondaryColor3fEXT(1,1,1); |
|
|
coords1.vertex(p - normal); |
|
|
glTexCoord4f(q * p.x, q * p.y, q * p.z, q * texscale); |
|
|
glSecondaryColor3fEXT(0,0,0); |
|
|
coords1.vertex(p + normal); |
|
1204 |
} |
} |
|
glEnd(); |
|
|
|
|
|
glDisable(GL_TEXTURE_2D); |
|
|
glDisable(GL_REGISTER_COMBINERS_NV); |
|
|
float col[4]; |
|
|
glGetFloatv(GL_CONSTANT_COLOR0_NV, col); |
|
|
glColor4fv(col); |
|
|
glBegin(GL_TRIANGLE_FAN); |
|
|
coords1.vertex(coords2.transform(ZPt(0,0,0))); |
|
|
for (int i = 0; i <= n; i++) { |
|
|
coords1.vertex(vert[i] - norm[i]); |
|
|
} |
|
|
glEnd(); |
|
1205 |
|
|
1206 |
glPopAttrib(); |
glPopAttrib(); |
1207 |
|
|