Generate Primitives, required.
81 SoState *state =
action->getState();
87 SbBool useTexFunction=
89 SoTextureCoordinateElement::FUNCTION);
94 const SoTextureCoordinateElement *tce = NULL;
97 tce = SoTextureCoordinateElement::getInstance(state);
102 SbVec3f point, normal;
106 #define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
107 point.setValue((float)(x),(float)(y),(float)(z)); \
108 normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
109 if (useTexFunction) { \
110 texCoord=tce->get(point,normal); \
112 texCoord[0]=(float)(s); \
113 texCoord[1]=(float)(t); \
115 pv.setPoint(point); \
116 pv.setNormal(normal); \
117 pv.setTextureCoords(texCoord); \
126 int nSeg =
fRmin.getNum()-1;
131 for (
int p=0;
p<nSeg;
p++) {
139 double zMin =
fDz[
p];
140 double zMax=
fDz[
p+1];
149 double cosPhi1 =
cos(phi1);
150 double sinPhi1 =
sin(phi1);
158 const bool noPhiCutout=fabs(
fDPhi.getValue())==0.F || fabs(fabs(
fDPhi.getValue())-2.0*
M_PI)<0.01;
159 const bool disableLighting(glIsEnabled(GL_LIGHTING));
160 const bool transparencyOn(glIsEnabled(GL_BLEND));
168 double dR =rMax2-rMax1;
169 double dZ =zMax-zMin;
170 double cosTheta = -dR/sqrt(dR*dR+dZ*dZ);
171 double sinTheta = dZ/sqrt(dR*dR+dZ*dZ);
173 beginShape(
action,TRIANGLE_STRIP);
176 for (
i = 0;
i<=NPHI;
i++) {
177 GEN_VERTEX(
pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);
178 GEN_VERTEX(
pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);
179 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
184 if (disableLighting) glDisable(GL_LIGHTING);
185 if (transparencyOn) glDisable(GL_BLEND);
186 glBegin(GL_LINE_STRIP);
189 if (!noPhiCutout &&
p==0) glVertex3f(rMin1*cosPhi,rMin1*sinPhi,zMin);
190 for (
i = 0;
i<=NPHI;
i++) {
191 glVertex3f(rMax1*cosPhi,rMax1*sinPhi,zMin);
192 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
194 if (!noPhiCutout &&
p==0) glVertex3f(rMin1*cosPhi1,rMin1*sinPhi1,zMin);
196 if (disableLighting) glEnable(GL_LIGHTING);
197 if (transparencyOn) glEnable(GL_BLEND);
206 beginShape(
action,TRIANGLE_STRIP);
212 cosTheta = -dR/sqrt(dR*dR+dZ*dZ);
213 sinTheta = dZ/sqrt(dR*dR+dZ*dZ);
215 for (
i = 0;
i<=NPHI;
i++) {
216 GEN_VERTEX(
pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,-cosPhi*sinTheta,-sinPhi*sinTheta,-cosTheta);
217 GEN_VERTEX(
pv,rMin1*cosPhi,rMin1*sinPhi,zMin,1.0,1.0,-cosPhi*sinTheta,-sinPhi*sinTheta,-cosTheta);
218 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
223 if (disableLighting) glDisable(GL_LIGHTING);
224 if (transparencyOn) glDisable(GL_BLEND);
225 glBegin(GL_LINE_STRIP);
229 for (
i = 0;
i<=NPHI;
i++) {
230 glVertex3f(rMin1*cosPhi,rMin1*sinPhi,zMin);
231 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
235 if (disableLighting) glEnable(GL_LIGHTING);
236 if (transparencyOn) glEnable(GL_BLEND);
246 beginShape(
action,TRIANGLE_STRIP);
249 GEN_VERTEX(
pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
250 GEN_VERTEX(
pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
251 GEN_VERTEX(
pv,rMin2*cosPhi,rMin2*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
252 GEN_VERTEX(
pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
257 beginShape(
action,TRIANGLE_STRIP);
260 GEN_VERTEX(
pv,rMax2*cosPhi,rMax2*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
261 GEN_VERTEX(
pv,rMax1*cosPhi,rMax1*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
262 GEN_VERTEX(
pv,rMin2*cosPhi,rMin2*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
263 GEN_VERTEX(
pv,rMin1*cosPhi,rMin1*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
267 if (disableLighting) glDisable(GL_LIGHTING);
268 if (transparencyOn) glDisable(GL_BLEND);
271 glVertex3f(rMax2*cosPhi0,rMax2*sinPhi0, zMax);
272 glVertex3f(rMax1*cosPhi0,rMax1*sinPhi0, zMin);
273 glVertex3f(rMin2*cosPhi0,rMin2*sinPhi0, zMax);
274 glVertex3f(rMin1*cosPhi0,rMin1*sinPhi0, zMin);
275 glVertex3f(rMax2*cosPhi1,rMax2*sinPhi1, zMax);
276 glVertex3f(rMax1*cosPhi1,rMax1*sinPhi1, zMin);
277 glVertex3f(rMin2*cosPhi1,rMin2*sinPhi1, zMax);
278 glVertex3f(rMin1*cosPhi1,rMin1*sinPhi1, zMin);
280 if (disableLighting) glEnable(GL_LIGHTING);
281 if (transparencyOn) glEnable(GL_BLEND);
290 beginShape(
action,TRIANGLE_STRIP);
293 for (
i = 0;
i<=NPHI;
i++) {
294 GEN_VERTEX(
pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,0,0,1);
295 GEN_VERTEX(
pv,rMax2*cosPhi,rMax2*sinPhi,zMax,1.0,1.0,0,0,1);
296 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
301 if (disableLighting) glDisable(GL_LIGHTING);
302 if (transparencyOn) glDisable(GL_BLEND);
303 glBegin(GL_LINE_STRIP);
306 if (!noPhiCutout) glVertex3f(rMin1*cosPhi,rMin1*sinPhi,zMax);
307 for (
i = 0;
i<=NPHI;
i++) {
308 glVertex3f(rMax1*cosPhi,rMax1*sinPhi,zMax);
309 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
311 if (!noPhiCutout) glVertex3f(rMin1*cosPhi1,rMin1*sinPhi1,zMax);
313 if (disableLighting) glEnable(GL_LIGHTING);
314 if (transparencyOn) glEnable(GL_BLEND);
322 beginShape(
action,TRIANGLE_STRIP);
325 for (
i = 0;
i<=NPHI;
i++) {
326 GEN_VERTEX(
pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,0.0,0,0,-1);
327 GEN_VERTEX(
pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,0,0,-1);
328 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
334 if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
336 SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
337 #if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
338 SoGLCacheContextElement::incNumShapes(state);