116{
119
120 SoState *state = aAction->getState();
121 if (!state)
122 return;
123 SbBool useTexFunction =
124 (SoTextureCoordinateElement::getType(state) ==
125 SoTextureCoordinateElement::FUNCTION);
126 const SoTextureCoordinateElement *tce = NULL;
127 SbVec4f texCoord;
128 if (useTexFunction) {
129 tce = SoTextureCoordinateElement::getInstance(state);
130 } else {
131 texCoord[2] = 0.0;
132 texCoord[3] = 1.0;
133 }
134
135
136 if(true) {
137 SoPrimitiveVertex
pv;
138 SbVec3f point, normal;
140
141#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
142 point.setValue(x,y,z); \
143 normal.setValue(nx,ny,nz); \
144 if (useTexFunction) { \
145 texCoord=tce->get(point,normal); \
146 } else { \
147 texCoord[0]=s; \
148 texCoord[1]=t; \
149 } \
150 pv.setPoint(point); \
151 pv.setNormal(normal); \
152 pv.setTextureCoords(texCoord); \
153 shapeVertex(&pv);
154
157
159 if ( aAction->getTypeId().isDerivedFrom(SoPickAction::getClassTypeId()) ){
160
161 bool notLastFace;
162 do {
164 notLastFace =
m_polyhedron->GetNextUnitNormal(unitNormal);
165
166 beginShape(aAction,POLYGON);
167 bool notLastEdge;
168 int edgeFlag = 1;
169 do {
171 notLastEdge =
m_polyhedron->GetNextVertex(vertex,edgeFlag);
173 vertex[0],
174 vertex[1],
175 vertex[2],
176 0.0,0.0,
177 unitNormal[0],
178 unitNormal[1],
179 unitNormal[2]);
180 } while (notLastEdge);
181 endShape();
182 } while (notLastFace);
183 }
184 else
185 {
187 glEnableClientState(GL_VERTEX_ARRAY);
189 glEnableClientState(GL_NORMAL_ARRAY);
192
194
196
198 glDrawArrays(GL_TRIANGLES, 0,
m_vcount);
199 glDisableClientState(GL_VERTEX_ARRAY);
200 glDisableClientState(GL_NORMAL_ARRAY);
201 }
202 }
203 } else {
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274 }
275
276 if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
277
278 SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
279#if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
280 SoGLCacheContextElement::incNumShapes(state);
281#endif
282 }
283}
#define GEN_VERTEX(pv, x, y, z, s, t, nx, ny, nz)