Generate Primitives, required.
82 SoState *state =
action->getState();
88 SbBool useTexFunction=
90 SoTextureCoordinateElement::FUNCTION);
95 const SoTextureCoordinateElement* tce = NULL;
98 tce = SoTextureCoordinateElement::getInstance(state);
104 SbVec3f point, normal;
109 #define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
110 point.setValue((float)(x),(float)(y),(float)(z)); \
111 normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
112 if (useTexFunction) { \
113 texCoord=tce->get(point,normal); \
115 texCoord[0]=(float)(s); \
116 texCoord[1]=(float)(t); \
118 pv.setPoint(point); \
119 pv.setNormal(normal); \
120 pv.setTextureCoords(texCoord); \
128 double rMax=
pRMax.getValue(),rMin=
pRMin.getValue();
129 double zMax=
pDz.getValue(),zMin=-zMax;
131 double cosPhi1=
cos(phi1), sinPhi1=
sin(phi1);
133 const bool noPhiCutout=fabs(
pDPhi.getValue())==0.F || fabs(fabs(
pDPhi.getValue())-2.0*
M_PI)<0.01;
134 const bool disableLighting(glIsEnabled(GL_LIGHTING));
135 const bool transparencyOn(glIsEnabled(GL_BLEND));
141 double sinPhi,cosPhi;
142 beginShape(
action,TRIANGLE_STRIP);
145 for (
i = 0;
i<=NPHI;
i++) {
146 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,cosPhi,sinPhi,0);
147 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,cosPhi,sinPhi,0);
148 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
155 beginShape(
action,TRIANGLE_STRIP);
158 for (
i = 0;
i<=NPHI;
i++) {
159 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,-cosPhi,-sinPhi,0);
160 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMin,1.0,1.0,-cosPhi,-sinPhi,0);
161 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
175 beginShape(
action,TRIANGLE_STRIP);
178 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
179 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
180 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
181 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
186 beginShape(
action,TRIANGLE_STRIP);
189 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
190 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
191 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
192 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
196 if (disableLighting) glDisable(GL_LIGHTING);
197 if (transparencyOn) glDisable(GL_BLEND);
200 glVertex3f(rMax*cosPhi0,rMax*sinPhi0, zMax);
201 glVertex3f(rMax*cosPhi0,rMax*sinPhi0, zMin);
202 glVertex3f(rMin*cosPhi0,rMin*sinPhi0, zMax);
203 glVertex3f(rMin*cosPhi0,rMin*sinPhi0, zMin);
204 glVertex3f(rMax*cosPhi1,rMax*sinPhi1, zMax);
205 glVertex3f(rMax*cosPhi1,rMax*sinPhi1, zMin);
206 glVertex3f(rMin*cosPhi1,rMin*sinPhi1, zMax);
207 glVertex3f(rMin*cosPhi1,rMin*sinPhi1, zMin);
209 if (disableLighting) glEnable(GL_LIGHTING);
210 if (transparencyOn) glEnable(GL_BLEND);
218 beginShape(
action,TRIANGLE_FAN);
222 for (
i = 0;
i<=NPHI;
i++) {
223 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
224 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
230 beginShape(
action,TRIANGLE_FAN);
234 for (
i = 0;
i<=NPHI;
i++) {
235 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
236 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
242 if (disableLighting) glDisable(GL_LIGHTING);
243 if (transparencyOn) glDisable(GL_BLEND);
244 glBegin(GL_LINE_STRIP);
247 if (!noPhiCutout) glVertex3f(0,0,zMax);
248 for (
i = 0;
i<=NPHI;
i++) {
249 glVertex3f(rMax*cosPhi,rMax*sinPhi,zMax);
250 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
252 if (!noPhiCutout) glVertex3f(0,0,zMax);
256 glBegin(GL_LINE_STRIP);
259 if (!noPhiCutout) glVertex3f(0,0,zMin);
260 for (
i = 0;
i<=NPHI;
i++) {
261 glVertex3f(rMax*cosPhi,rMax*sinPhi,zMin);
262 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
264 if (!noPhiCutout) glVertex3f(0,0,zMin);
268 if (disableLighting) glEnable(GL_LIGHTING);
269 if (transparencyOn) glEnable(GL_BLEND);
273 beginShape(
action,TRIANGLE_STRIP);
276 for (
i = 0;
i<=NPHI;
i++) {
277 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,0,0,1);
278 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
279 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
285 beginShape(
action,TRIANGLE_STRIP);
288 for (
i = 0;
i<=NPHI;
i++) {
289 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,0.0,0,0,-1);
290 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
291 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
296 if (disableLighting) glDisable(GL_LIGHTING);
297 if (transparencyOn) glDisable(GL_BLEND);
298 glBegin(GL_LINE_STRIP);
301 if (!noPhiCutout) glVertex3f(rMin*cosPhi,rMin*sinPhi,zMax);
302 for (
i = 0;
i<=NPHI;
i++) {
303 glVertex3f(rMax*cosPhi,rMax*sinPhi,zMax);
304 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
306 if (!noPhiCutout) glVertex3f(rMin*cosPhi1,rMin*sinPhi1,zMax);
309 glBegin(GL_LINE_STRIP);
312 for (
i = 0;
i<=NPHI;
i++) {
313 glVertex3f(rMin*cosPhi,rMin*sinPhi,zMax);
314 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
318 glBegin(GL_LINE_STRIP);
321 if (!noPhiCutout) glVertex3f(rMin*cosPhi,rMin*sinPhi,zMin);
322 for (
i = 0;
i<=NPHI;
i++) {
323 glVertex3f(rMax*cosPhi,rMax*sinPhi,zMin);
324 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
326 if (!noPhiCutout) glVertex3f(rMin*cosPhi1,rMin*sinPhi1,zMin);
329 glBegin(GL_LINE_STRIP);
332 for (
i = 0;
i<=NPHI;
i++) {
333 glVertex3f(rMin*cosPhi,rMin*sinPhi,zMin);
334 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
338 if (disableLighting) glEnable(GL_LIGHTING);
339 if (transparencyOn) glEnable(GL_BLEND);
344 if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
346 SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
347 #if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
348 SoGLCacheContextElement::incNumShapes(state);