Generate Primitives, required.
77 SoState *state =
action->getState();
83 SbBool useTexFunction=
85 SoTextureCoordinateElement::FUNCTION);
90 const SoTextureCoordinateElement* tce = NULL;
93 tce = SoTextureCoordinateElement::getInstance(state);
99 SbVec3f point, normal;
104 #define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
105 point.setValue((float)(x),(float)(y),(float)(z)); \
106 normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
107 if (useTexFunction) { \
108 texCoord=tce->get(point,normal); \
110 texCoord[0]=(float)(s); \
111 texCoord[1]=(float)(t); \
113 pv.setPoint(point); \
114 pv.setNormal(normal); \
115 pv.setTextureCoords(texCoord); \
123 double rMax=
pRMax.getValue(),rMin=
pRMin.getValue();
124 double zMax=
pDz.getValue(),zMin=-zMax;
126 double cosPhi1=
cos(phi1), sinPhi1=
sin(phi1);
128 const bool noPhiCutout=fabs(
pDPhi.getValue())==0.F || fabs(fabs(
pDPhi.getValue())-2.0*
M_PI)<0.01;
129 const bool disableLighting(glIsEnabled(GL_LIGHTING));
130 const bool transparencyOn(glIsEnabled(GL_BLEND));
136 double sinPhi,cosPhi;
137 beginShape(
action,TRIANGLE_STRIP);
140 for (
i = 0;
i<=NPHI;
i++) {
141 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,cosPhi,sinPhi,0);
142 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,cosPhi,sinPhi,0);
143 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
150 beginShape(
action,TRIANGLE_STRIP);
153 for (
i = 0;
i<=NPHI;
i++) {
154 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,-cosPhi,-sinPhi,0);
155 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMin,1.0,1.0,-cosPhi,-sinPhi,0);
156 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
170 beginShape(
action,TRIANGLE_STRIP);
173 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
174 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
175 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
176 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
181 beginShape(
action,TRIANGLE_STRIP);
184 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
185 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
186 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
187 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
191 if (disableLighting) glDisable(GL_LIGHTING);
192 if (transparencyOn) glDisable(GL_BLEND);
195 glVertex3f(rMax*cosPhi0,rMax*sinPhi0, zMax);
196 glVertex3f(rMax*cosPhi0,rMax*sinPhi0, zMin);
197 glVertex3f(rMin*cosPhi0,rMin*sinPhi0, zMax);
198 glVertex3f(rMin*cosPhi0,rMin*sinPhi0, zMin);
199 glVertex3f(rMax*cosPhi1,rMax*sinPhi1, zMax);
200 glVertex3f(rMax*cosPhi1,rMax*sinPhi1, zMin);
201 glVertex3f(rMin*cosPhi1,rMin*sinPhi1, zMax);
202 glVertex3f(rMin*cosPhi1,rMin*sinPhi1, zMin);
204 if (disableLighting) glEnable(GL_LIGHTING);
205 if (transparencyOn) glEnable(GL_BLEND);
213 beginShape(
action,TRIANGLE_FAN);
217 for (
i = 0;
i<=NPHI;
i++) {
218 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
219 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
225 beginShape(
action,TRIANGLE_FAN);
229 for (
i = 0;
i<=NPHI;
i++) {
230 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
231 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
237 if (disableLighting) glDisable(GL_LIGHTING);
238 if (transparencyOn) glDisable(GL_BLEND);
239 glBegin(GL_LINE_STRIP);
242 if (!noPhiCutout) glVertex3f(0,0,zMax);
243 for (
i = 0;
i<=NPHI;
i++) {
244 glVertex3f(rMax*cosPhi,rMax*sinPhi,zMax);
245 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
247 if (!noPhiCutout) glVertex3f(0,0,zMax);
251 glBegin(GL_LINE_STRIP);
254 if (!noPhiCutout) glVertex3f(0,0,zMin);
255 for (
i = 0;
i<=NPHI;
i++) {
256 glVertex3f(rMax*cosPhi,rMax*sinPhi,zMin);
257 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
259 if (!noPhiCutout) glVertex3f(0,0,zMin);
263 if (disableLighting) glEnable(GL_LIGHTING);
264 if (transparencyOn) glEnable(GL_BLEND);
268 beginShape(
action,TRIANGLE_STRIP);
271 for (
i = 0;
i<=NPHI;
i++) {
272 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,0,0,1);
273 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
274 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
280 beginShape(
action,TRIANGLE_STRIP);
283 for (
i = 0;
i<=NPHI;
i++) {
284 GEN_VERTEX(
pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,0.0,0,0,-1);
285 GEN_VERTEX(
pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
286 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
291 if (disableLighting) glDisable(GL_LIGHTING);
292 if (transparencyOn) glDisable(GL_BLEND);
293 glBegin(GL_LINE_STRIP);
296 if (!noPhiCutout) glVertex3f(rMin*cosPhi,rMin*sinPhi,zMax);
297 for (
i = 0;
i<=NPHI;
i++) {
298 glVertex3f(rMax*cosPhi,rMax*sinPhi,zMax);
299 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
301 if (!noPhiCutout) glVertex3f(rMin*cosPhi1,rMin*sinPhi1,zMax);
304 glBegin(GL_LINE_STRIP);
307 for (
i = 0;
i<=NPHI;
i++) {
308 glVertex3f(rMin*cosPhi,rMin*sinPhi,zMax);
309 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
313 glBegin(GL_LINE_STRIP);
316 if (!noPhiCutout) glVertex3f(rMin*cosPhi,rMin*sinPhi,zMin);
317 for (
i = 0;
i<=NPHI;
i++) {
318 glVertex3f(rMax*cosPhi,rMax*sinPhi,zMin);
319 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
321 if (!noPhiCutout) glVertex3f(rMin*cosPhi1,rMin*sinPhi1,zMin);
324 glBegin(GL_LINE_STRIP);
327 for (
i = 0;
i<=NPHI;
i++) {
328 glVertex3f(rMin*cosPhi,rMin*sinPhi,zMin);
329 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
333 if (disableLighting) glEnable(GL_LIGHTING);
334 if (transparencyOn) glEnable(GL_BLEND);
339 if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
341 SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
342 #if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
343 SoGLCacheContextElement::incNumShapes(state);