Debian Codegraph @

lib/database/src/so/nodes/SoQuadSet.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990,91 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.1.1.1 $
44 |
45 | Classes:
46 | SoQuadMesh
47 |
48 | Note: This file was preprocessed from another file. Do not edit it.
49 |
50 | Author(s) : Paul S. Strauss
51 |
52 ______________ S I L I C O N G R A P H I C S I N C . ____________
53 _______________________________________________________________________
54 */
55
56 #include <GL/gl.h>
57 #include <Inventor/SoPickedPoint.h>
58 #include <Inventor/SoPrimitiveVertex.h>
59 #include <Inventor/actions/SoGLRenderAction.h>
60 #include <Inventor/actions/SoRayPickAction.h>
61 #include <Inventor/bundles/SoNormalBundle.h>
62 #include <Inventor/bundles/SoTextureCoordinateBundle.h>
63 #include <Inventor/caches/SoNormalCache.h>
64 #include <Inventor/details/SoFaceDetail.h>
65 #include <Inventor/elements/SoGLCoordinateElement.h>
66 #include <Inventor/elements/SoGLTextureCoordinateElement.h>
67 #include <Inventor/elements/SoNormalBindingElement.h>
68 #include <Inventor/elements/SoShapeHintsElement.h>
69 #include <Inventor/elements/SoGLLazyElement.h>
70 #include <Inventor/elements/SoGLCacheContextElement.h>
71 #include <Inventor/errors/SoDebugError.h>
72 #include <Inventor/misc/SoState.h>
73 #include <Inventor/nodes/SoMaterialBinding.h>
74 #include <Inventor/nodes/SoNormalBinding.h>
75 #include <Inventor/nodes/SoQuadMesh.h>
76 //////////////////////////////////////////////////////////////////////////////
77
78 // Constants for influencing auto-caching algorithm:
79
80 // If fewer than this many vertices, AND not using the vertexProperty
81 // node, auto-cache.
82
83 const int AUTO_CACHE_QM_MIN_WITHOUT_VP = 20;
84
85 // And the number above which we'll say caches definitely SHOULDN'T be
86 // built (because they'll use too much memory):
87 const int AUTO_CACHE_QM_MAX = 1000;
88
89
90 SO_NODE_SOURCE(SoQuadMesh);
91
92 ////////////////////////////////////////////////////////////////////////
93 //
94 // Description:
95 // Constructor
96 //
97 // Use: public
98
99 SoQuadMesh::SoQuadMesh()
100 //
101 ////////////////////////////////////////////////////////////////////////
102 {
103 SO_NODE_CONSTRUCTOR(SoQuadMesh);
104 SO_NODE_ADD_FIELD(verticesPerColumn, (1));
105 SO_NODE_ADD_FIELD(verticesPerRow, (1));
106 isBuiltIn = TRUE;
107 }
108
109 ////////////////////////////////////////////////////////////////////////
110 //
111 // Description:
112 // Destructor
113 //
114 // Use: private
115
116 SoQuadMesh::~SoQuadMesh()
117 //
118 ////////////////////////////////////////////////////////////////////////
119 {
120 }
121
122
123 ////////////////////////////////////////////////////////////////////////
124 //
125 // Description:
126 // Computes bounding box of vertices of mesh.
127 //
128 // Use: protected
129
130 void
131 SoQuadMesh::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
132 //
133 ////////////////////////////////////////////////////////////////////////
134 {
135 // compute the number of vertices the mesh uses
136 int numVerts = (int) (verticesPerColumn.getValue() *
137 verticesPerRow.getValue());
138 // Next, call the method on SoNonIndexedShape that computes the
139 // bounding box and center of the given number of coordinates
140 computeCoordBBox(action, numVerts, box, center);
141 }
142
143 ////////////////////////////////////////////////////////////////////////
144 //
145 // Description:
146 // Overrides standard method to create an SoFaceDetail instance
147 // representing a picked intersection with a quad in the mesh.
148 //
149 // Use: protected, virtual
150
151 SoDetail *
152 SoQuadMesh::createTriangleDetail(SoRayPickAction *action,
153 const SoPrimitiveVertex *v1,
154 const SoPrimitiveVertex *,
155 const SoPrimitiveVertex *,
156 SoPickedPoint *)
157 //
158 ////////////////////////////////////////////////////////////////////////
159 {
160 // When we get here, the detail in each vertex already points to an
161 // SoFaceDetail (on the stack in generatePrimitives()). This detail
162 // contains the correct part index for the row and face index for the
163 // correct quad. However, this face detail does not contain any point
164 // details. We have to create a new SoFaceDetail instance and set up
165 // the SoPointDetail instances inside it to contain the 4 vertices of
166 // the picked quad.
167
168 SoFaceDetail *newFD = new SoFaceDetail;
169 const SoFaceDetail *oldFD = (const SoFaceDetail *) v1->getDetail();
170
171 // Make room in the detail for 4 vertices
172 newFD->setNumPoints(4);
173
174 // Find index of quad that was hit and the row it is in
175 int quadIndex = (int) oldFD->getFaceIndex();
176 int row = (int) oldFD->getPartIndex();
177
178 // We need the bindings to set up the material/normals stuff
179 Binding materialBinding = getMaterialBinding(action);
180 Binding normalBinding = getNormalBinding(action);
181 if (normalBinding == PER_VERTEX)
182 normalBinding = PER_VERTEX;
183
184 SoPointDetail pd;
185 int vert;
186 SoTextureCoordinateBundle tcb(action, FALSE);
187
188 // "Upper left" corner
189 vert = row + quadIndex; // Number of quads + 1 extra per row
190 pd.setCoordinateIndex(vert);
191 pd.setMaterialIndex(getBindIndex(materialBinding, row, quadIndex, vert));
192 pd.setNormalIndex(getBindIndex(normalBinding, row, quadIndex, vert));
193 pd.setTextureCoordIndex(tcb.isFunction() ? 0 : vert);
194 newFD->setPoint(0, &pd);
195
196 // "Lower left" corner
197 vert += (int) verticesPerRow.getValue();
198 pd.setCoordinateIndex(vert);
199 pd.setMaterialIndex(getBindIndex(materialBinding, row, quadIndex, vert));
200 pd.setNormalIndex(getBindIndex(normalBinding, row, quadIndex, vert));
201 pd.setTextureCoordIndex(tcb.isFunction() ? 0 : vert);
202 newFD->setPoint(1, &pd);
203
204 // "Lower right" corner
205 vert++;
206 pd.setCoordinateIndex(vert);
207 pd.setMaterialIndex(getBindIndex(materialBinding, row, quadIndex, vert));
208 pd.setNormalIndex(getBindIndex(normalBinding, row, quadIndex, vert));
209 pd.setTextureCoordIndex(tcb.isFunction() ? 0 : vert);
210 newFD->setPoint(2, &pd);
211
212 // "Upper right" corner
213 vert -= (int) verticesPerRow.getValue();
214 pd.setCoordinateIndex(vert);
215 pd.setMaterialIndex(getBindIndex(materialBinding, row, quadIndex, vert));
216 pd.setNormalIndex(getBindIndex(normalBinding, row, quadIndex, vert));
217 pd.setTextureCoordIndex(tcb.isFunction() ? 0 : vert);
218 newFD->setPoint(3, &pd);
219
220 // The face/part indices are in the incoming details
221 newFD->setFaceIndex(quadIndex);
222 newFD->setPartIndex(row);
223
224 return newFD;
225 }
226
227 ////////////////////////////////////////////////////////////////////////
228 //
229 // Description:
230 // Returns current material binding from action's state.
231 //
232 // Use: private, static
233
234 SoQuadMesh::Binding
235 SoQuadMesh::getMaterialBinding(SoAction *action)
236 //
237 ////////////////////////////////////////////////////////////////////////
238 {
239 switch (SoMaterialBindingElement::get(action->getState())) {
240 case SoMaterialBindingElement::OVERALL:
241 return OVERALL;
242
243 case SoMaterialBindingElement::PER_PART:
244 case SoMaterialBindingElement::PER_PART_INDEXED:
245 return PER_ROW;
246
247 case SoMaterialBindingElement::PER_FACE:
248 case SoMaterialBindingElement::PER_FACE_INDEXED:
249 return PER_QUAD;
250
251 case SoMaterialBindingElement::PER_VERTEX:
252 case SoMaterialBindingElement::PER_VERTEX_INDEXED:
253 return PER_VERTEX;
254 }
255 return OVERALL; // Shut up C++ compiler
256 }
257
258 ////////////////////////////////////////////////////////////////////////
259 //
260 // Description:
261 // Returns current normal binding from action's state.
262 //
263 // Use: private, static
264
265 SoQuadMesh::Binding
266 SoQuadMesh::getNormalBinding(SoAction *action)
267 //
268 ////////////////////////////////////////////////////////////////////////
269 {
270 switch (SoNormalBindingElement::get(action->getState())) {
271 case SoNormalBindingElement::OVERALL:
272 return OVERALL;
273
274 case SoNormalBindingElement::PER_PART:
275 case SoNormalBindingElement::PER_PART_INDEXED:
276 return PER_ROW;
277
278 case SoNormalBindingElement::PER_FACE:
279 case SoNormalBindingElement::PER_FACE_INDEXED:
280 return PER_QUAD;
281
282 case SoNormalBindingElement::PER_VERTEX:
283 case SoNormalBindingElement::PER_VERTEX_INDEXED:
284 return PER_VERTEX;
285 }
286 return OVERALL; // Shut up C++ compiler
287 }
288
289 ////////////////////////////////////////////////////////////////////////
290 //
291 // Description:
292 // Returns index (of material or normal) based on given binding.
293 //
294 // Use: private, static
295
296 int
297 SoQuadMesh::getBindIndex(Binding binding, int row, int quad, int vert)
298 //
299 ////////////////////////////////////////////////////////////////////////
300 {
301 int ret;
302
303 switch (binding) {
304 case OVERALL:
305 ret = 0;
306 break;
307 case PER_ROW:
308 ret = row;
309 break;
310 case PER_QUAD:
311 ret = quad;
312 break;
313 case PER_VERTEX:
314 ret = vert;
315 break;
316 }
317
318 return ret;
319 }
320
321 ////////////////////////////////////////////////////////////////////////
322 //
323 // Description:
324 // Figures out normals, if necessary. Returns TRUE if normals were
325 // figured out (and the normal binding should be PER_VERTEX).
326 //
327 // Use: private
328
329 void
330 SoQuadMesh::figureNormals(SoState *state, SoNormalBundle *nb)
331 //
332 ////////////////////////////////////////////////////////////////////////
333 {
334 // See if there is a valid normal cache. If so, tell the normal
335 // bundle to use it.
336 SoNormalCache *normCache = getNormalCache();
337 if (normCache != NULL && normCache->isValid(state)) {
338 nb->set(normCache->getNum(), normCache->getNormals());
339 return;
340 }
341
342 const SoNormalElement *normElt = SoNormalElement::getInstance(state);
343
344 int numNeeded = (int) (verticesPerColumn.getValue() *
345 verticesPerRow.getValue());
346
347 // See if there are enough normals in the state...
348 if (normElt->getNum() < numNeeded)
349 generateDefaultNormals(state, nb);
350 }
351
352 ////////////////////////////////////////////////////////////////////////
353 //
354 // Description:
355 // Generate default normals, if necessary. Returns non-NULL if normals
356 // were generated (and the normal binding should be PER_VERTEX).
357 // If they are generated, a state->push() is done-- the calling
358 // code MUST do a state->pop() after using the normals! Also, the
359 // calling code is responsible for freeing the normals returned.
360 //
361 // Use: private
362
363 SbBool
364 SoQuadMesh::generateDefaultNormals(SoState *state, SoNormalBundle *nb)
365 //
366 ////////////////////////////////////////////////////////////////////////
367 {
368 // Because we know the connectivity of a quad mesh, we can do this
369 // much more efficiently than the other shapes. Need to check for
370 // wrap-around between the first and last rows and columns.
371
372 int32_t c, r, t, r0, r1, c0, c1;
373 SbVec3f dr, dc, norm, *normals;
374 const SoCoordinateElement *ce = NULL;
375 const SbVec3f *vpCoords = NULL;
376
377 SoVertexProperty *vp = (SoVertexProperty *)vertexProperty.getValue();
378 if (vp && vp->vertex.getNum() > 0) {
379 vpCoords = vp->vertex.getValues(0);
380 } else {
381 ce = SoCoordinateElement::getInstance(state);
382 }
383
384
385 // Figure out whether or not polys are clockwise or
386 // counter-clockwise
387 SoShapeHintsElement::VertexOrdering vertexOrdering;
388 SoShapeHintsElement::ShapeType shapeType;
389 SoShapeHintsElement::FaceType faceType;
390 SoShapeHintsElement::get(state, vertexOrdering, shapeType, faceType);
391 SbBool ccw = TRUE;
392 if (vertexOrdering == SoShapeHintsElement::CLOCKWISE) ccw = FALSE;
393
394 int32_t curCoord = startIndex.getValue();
395 int startInd = (int) curCoord;
396 int32_t numPerCol = verticesPerColumn.getValue();
397 int32_t numPerRow = verticesPerRow.getValue();
398
399 t = startIndex.getValue();
400
401 int32_t numNeeded = startInd + (numPerCol*numPerRow);
402 normals = new SbVec3f[numNeeded];
403
404 #define CX(r, c) ce->get3((int) (t + (r) * numPerRow + (c)))
405 #define VX(r, c) vpCoords[((int) (t + (r) * numPerRow + (c)))]
406
407 // r is row number, it goes from 0 to numPerCol
408 // c is col number, it goes from 0 to numPerRow
409
410 for(r = 0; r < numPerCol; r++) {
411 for(c = 0; c < numPerRow; c++) {
412 // for now, forget about wraparound
413 r0 = r - 1;
414 r1 = r + 1;
415 c0 = c - 1;
416 c1 = c + 1;
417 if (ce == NULL){
418 if (r0 < 0)
419 if (VX(0, c) == VX(numPerCol - 1, c)) r0 = numPerCol - 2;
420 else r0 = 0;
421 if (r1 == numPerCol)
422 if (VX(0, c) == VX(numPerCol - 1, c)) r1 = 1;
423 else r1 = numPerCol - 1;
424
425 if (c0 < 0)
426 if (VX(r, 0) == VX(r, numPerRow - 1)) c0 = numPerRow - 2;
427 else c0 = 0;
428 if (c1 == numPerRow)
429 if (VX(r, 0) == VX(r, numPerRow - 1)) c1 = 1;
430 else c1 = numPerRow - 1;
431
432 dr = VX(r1, c) - VX(r0, c);
433 dc = VX(r, c1) - VX(r, c0);
434
435 }
436 else if (ce->is3D()) {
437 if (r0 < 0)
438 if (CX(0, c) == CX(numPerCol - 1, c)) r0 = numPerCol - 2;
439 else r0 = 0;
440 if (r1 == numPerCol)
441 if (CX(0, c) == CX(numPerCol - 1, c)) r1 = 1;
442 else r1 = numPerCol - 1;
443
444 if (c0 < 0)
445 if (CX(r, 0) == CX(r, numPerRow - 1)) c0 = numPerRow - 2;
446 else c0 = 0;
447 if (c1 == numPerRow)
448 if (CX(r, 0) == CX(r, numPerRow - 1)) c1 = 1;
449 else c1 = numPerRow - 1;
450
451 dr = CX(r1, c) - CX(r0, c);
452 dc = CX(r, c1) - CX(r, c0);
453 }
454 // For 4D coordinates, ce->get3() returns a reference to a
455 // value that goes away on the next call, so we have to
456 // save them
457 else {
458 SbVec3f t3;
459 if (r0 < 0) {
460 t3 = CX(0, c);
461 if (t3 == CX(numPerCol - 1, c)) r0 = numPerCol - 2;
462 else r0 = 0;
463 }
464 if (r1 == numPerCol) {
465 t3 = CX(0, c);
466 if (t3 == CX(numPerCol - 1, c)) r1 = 1;
467 else r1 = numPerCol - 1;
468 }
469
470 if (c0 < 0) {
471 t3 = CX(r, 0);
472 if (t3 == CX(r, numPerRow - 1)) c0 = numPerRow - 2;
473 else c0 = 0;
474 }
475 if (c1 == numPerRow) {
476 t3 = CX(r, 0);
477 if (t3 == CX(r, numPerRow - 1)) c1 = 1;
478 else c1 = numPerRow - 1;
479 }
480
481 t3 = CX(r1, c);
482 dr = t3 - CX(r0, c);
483 t3 = CX(r, c1);
484 dc = t3 - CX(r, c0);
485 }
486 norm = dr.cross(dc);
487 norm.normalize();
488 if (!ccw) norm.negate();
489 normals[startInd + r * numPerRow + c] = norm;
490 }
491 }
492
493 nb->set(numNeeded, normals);
494
495 // Cache the resulting normals
496 setNormalCache(state, numNeeded, normals);
497
498 return TRUE;
499 }
500
501 ////////////////////////////////////////////////////////////////////////
502 //
503 // Description:
504 // Implements GL rendering.
505 //
506 // Use: extender
507
508 void
509 SoQuadMesh::GLRender(SoGLRenderAction *action)
510 //
511 ////////////////////////////////////////////////////////////////////////
512 {
513 SoState *state = action->getState();
514
515 // Get ShapeStyleElement
516 const SoShapeStyleElement *shapeStyle = SoShapeStyleElement::get(state);
517
518 // First see if the object is visible and should be rendered now:
519 if (shapeStyle->mightNotRender()) {
520 if (! shouldGLRender(action))
521 return;
522 }
523
524 if (vpCache.mightNeedSomethingFromState(shapeStyle)) {
525 SoVertexProperty *vp = (SoVertexProperty *)vertexProperty.getValue();
526 vpCache.fillInCache(vp, state);
527
528 totalNumVertices = verticesPerColumn.getValue()*
529 verticesPerRow.getValue();
530
531 if (vpCache.shouldGenerateNormals(shapeStyle)) {
532
533 // See if there is a normal cache we can use. If not,
534 // generate normals and cache them.
535 SoNormalCache *normCache = getNormalCache();
536 if (normCache == NULL || ! normCache->isValid(state)) {
537 SoNormalBundle nb(action, FALSE);
538 nb.initGenerator(totalNumVertices);
539 generateDefaultNormals(state, &nb);
540 normCache = getNormalCache();
541 }
542 vpCache.numNorms = normCache->getNum();
543 vpCache.normalPtr = (const char *) normCache->getNormals();
544 }
545
546 SoTextureCoordinateBundle *tcb = NULL;
547 uint32_t useTexCoordsAnyway = 0;
548 if (vpCache.shouldGenerateTexCoords(shapeStyle)) {
549 state->push();
550 tcb = new SoTextureCoordinateBundle(action, TRUE, TRUE);
551 }
552 else if (shapeStyle->isTextureFunction() && vpCache.haveTexCoordsInVP()){
553 state->push();
554 useTexCoordsAnyway = SoVertexPropertyCache::TEXCOORD_BIT;
555 SoGLTextureCoordinateElement::setTexGen(state, this, NULL);
556 }
557
558 //If lighting or texturing is off, this vpCache and other things
559 //need to be reconstructed when lighting or texturing is turned
560 //on, so we set the bits in the VP cache:
561 if(! shapeStyle->needNormals()) vpCache.needFromState |=
562 SoVertexPropertyCache::NORMAL_BITS;
563 if(! shapeStyle->needTexCoords()) vpCache.needFromState |=
564 SoVertexPropertyCache::TEXCOORD_BIT;
565
566 // If doing multiple colors, turn on ColorMaterial:
567 if (vpCache.getNumColors() > 1) {
568 SoGLLazyElement::setColorMaterial(state, TRUE);
569 }
570 //
571 // Ask LazyElement to setup:
572 //
573 SoGLLazyElement *lazyElt = (SoGLLazyElement *)
574 SoLazyElement::getInstance(state);
575
576 if(vpCache.colorIsInVtxProp()){
577 lazyElt->send(state, SoLazyElement::ALL_MASK);
578 lazyElt->sendVPPacked(state, ( unsigned char*)
579 vpCache.getColors(0));
580 }
581 else lazyElt->send(state, SoLazyElement::ALL_MASK);
582
583 #ifdef DEBUG
584 // check if enough vertices:
585 if (vpCache.numVerts < totalNumVertices + startIndex.getValue()){
586 SoDebugError::post("SoQuadMesh::GLRender",
587 "Too few vertices specified;"
588 " need %d, have %d", totalNumVertices + startIndex.getValue(),
589 vpCache.numVerts);
590 }
591 // Check for enough colors, normals, texcoords:
592 int numNormalsNeeded = 0;
593 if (shapeStyle->needNormals()) switch (vpCache.getNormalBinding()) {
594 case SoNormalBindingElement::OVERALL:
595 numNormalsNeeded = 1;
596 break;
597 case SoNormalBindingElement::PER_VERTEX:
598 case SoNormalBindingElement::PER_VERTEX_INDEXED:
599 numNormalsNeeded = totalNumVertices + startIndex.getValue();
600 break;
601 //Note that PER_FACE is really PER_QUAD
602 case SoNormalBindingElement::PER_FACE:
603 case SoNormalBindingElement::PER_FACE_INDEXED:
604 numNormalsNeeded = (verticesPerColumn.getValue()-1)*
605 (verticesPerRow.getValue()-1);
606 break;
607 //Note that PER_PART is really PER_ROW
608 case SoNormalBindingElement::PER_PART:
609 case SoNormalBindingElement::PER_PART_INDEXED:
610 numNormalsNeeded = (verticesPerColumn.getValue()-1);
611 break;
612 }
613 if (vpCache.getNumNormals() < numNormalsNeeded)
614 SoDebugError::post("SoQuadMesh::GLRender",
615 "Too few normals specified;"
616 " need %d, have %d", numNormalsNeeded,
617 vpCache.getNumNormals());
618
619 if ((shapeStyle->needTexCoords() || useTexCoordsAnyway) &&
620 !vpCache.shouldGenerateTexCoords(shapeStyle)) {
621
622 if (vpCache.getNumTexCoords() <
623 totalNumVertices+startIndex.getValue())
624 SoDebugError::post("SoQuadMesh::GLRender",
625 "Too few texture coordinates specified;"
626 " need %d, have %d", totalNumVertices+startIndex.getValue(),
627 vpCache.getNumTexCoords());
628 }
629 int numColorsNeeded = 0;
630 switch (vpCache.getMaterialBinding()) {
631 case SoMaterialBindingElement::OVERALL:
632 break;
633 case SoMaterialBindingElement::PER_VERTEX:
634 case SoMaterialBindingElement::PER_VERTEX_INDEXED:
635 numColorsNeeded = verticesPerColumn.getValue()*
636 verticesPerRow.getValue() + startIndex.getValue();
637 break;
638 case SoMaterialBindingElement::PER_FACE:
639 case SoMaterialBindingElement::PER_FACE_INDEXED:
640 numColorsNeeded = (verticesPerColumn.getValue()-1)*
641 (verticesPerRow.getValue()-1);
642 break;
643 case SoMaterialBindingElement::PER_PART:
644 case SoMaterialBindingElement::PER_PART_INDEXED:
645 numColorsNeeded = (verticesPerColumn.getValue()-1);
646 break;
647 }
648 if (vpCache.getNumColors() < numColorsNeeded)
649 SoDebugError::post("SoQuadMesh::GLRender",
650 "Too few diffuse colors specified;"
651 " need %d, have %d", numColorsNeeded,
652 vpCache.getNumColors());
653 #endif
654
655 // Call the appropriate render loop:
656 (this->*renderFunc[useTexCoordsAnyway |
657 vpCache.getRenderCase(shapeStyle)])(action);
658
659 // If doing multiple colors, turn off ColorMaterial:
660 if (vpCache.getNumColors() > 1) {
661 SoGLLazyElement::setColorMaterial(state, FALSE);
662 ((SoGLLazyElement *)SoLazyElement::getInstance(state))->
663 reset(state, SoLazyElement::DIFFUSE_MASK);
664 }
665
666 // Influence auto-caching algorithm:
667 if (verticesPerColumn.getValue() < AUTO_CACHE_QM_MIN_WITHOUT_VP &&
668 vpCache.mightNeedSomethingFromState(shapeStyle)) {
669 SoGLCacheContextElement::shouldAutoCache(state,
670 SoGLCacheContextElement::DO_AUTO_CACHE);
671 } else if (totalNumVertices > AUTO_CACHE_QM_MAX &&
672 !SoGLCacheContextElement::getIsRemoteRendering(state)) {
673 SoGLCacheContextElement::shouldAutoCache(state,
674 SoGLCacheContextElement::DONT_AUTO_CACHE);
675 }
676
677 if (tcb) {
678 delete tcb;
679 state->pop();
680 } else if (useTexCoordsAnyway)
681 state->pop();
682
683 }
684 else {
685 // If doing multiple colors, turn on ColorMaterial:
686 if (vpCache.getNumColors() > 1) {
687 SoGLLazyElement::setColorMaterial(state, TRUE);
688 }
689 //
690 // Ask LazyElement to setup:
691 //
692 SoGLLazyElement *lazyElt = (SoGLLazyElement *)
693 SoLazyElement::getInstance(state);
694
695 if(vpCache.colorIsInVtxProp()){
696 lazyElt->send(state, SoLazyElement::ALL_MASK);
697 lazyElt->sendVPPacked(state, (unsigned char*)
698 vpCache.getColors(0));
699 }
700 else lazyElt->send(state, SoLazyElement::ALL_MASK);
701
702 // Call the appropriate render loop:
703 (this->*renderFunc[vpCache.getRenderCase(shapeStyle)])(action);
704
705 // If doing multiple colors, turn off ColorMaterial:
706 if (vpCache.getNumColors() > 1) {
707 SoGLLazyElement::setColorMaterial(state, FALSE);
708 ((SoGLLazyElement *)SoLazyElement::getInstance(state))->
709 reset(state, SoLazyElement::DIFFUSE_MASK);
710 }
711
712 // Influence auto-caching algorithm:
713 if (totalNumVertices > AUTO_CACHE_QM_MAX &&
714 !SoGLCacheContextElement::getIsRemoteRendering(state)) {
715
716 SoGLCacheContextElement::shouldAutoCache(state,
717 SoGLCacheContextElement::DONT_AUTO_CACHE);
718 }
719 }
720
721 return;
722 }
723
724
725 ////////////////////////////////////////////////////////////////////////
726 //
727 // Description:
728 // Redefines this to invalidate caches.
729 //
730 // Use: private
731
732 void
733 SoQuadMesh::notify(SoNotList *list)
734 //
735 ////////////////////////////////////////////////////////////////////////
736 {
737 if ((list->getLastRec()->getType() == SoNotRec::CONTAINER) &&
738 ((list->getLastField() == &vertexProperty) ||
739 (list->getLastField() == &verticesPerRow) ||
740 (list->getLastField() == &verticesPerColumn))) {
741 vpCache.invalidate();
742 }
743
744 SoShape::notify(list);
745 }
746
747
748
749
750 ////////////////////////////////////////////////////////////////////////
751 //
752 // Description:
753 // Generates triangles representing a quad mesh.
754 //
755 // Use: protected
756
757 void
758 SoQuadMesh::generatePrimitives(SoAction *action)
759 //
760 ////////////////////////////////////////////////////////////////////////
761 {
762 // When generating primitives for picking, there is no need to
763 // create details now, since they will be created in
764 // createTriangleDetail() when an intersection is found (but we
765 // need to use the face detail to figure out the rest of it).
766 // Otherwise, we create a face detail containing the 3 points of
767 // the generated triangle, using the stuff in SoShape.
768 // We also delay computing default texture coordinates.
769 SbBool forPicking = action->isOfType(SoRayPickAction::getClassTypeId());
770
771 //put the vertexProperty into the state:
772 SoState *state = action->getState();
773 state->push();
774 SoVertexProperty* vp = (SoVertexProperty*)vertexProperty.getValue();
775 if(vp){
776 vp->doAction(action);
777 }
778
779
780 SoPrimitiveVertex pv;
781 SoFaceDetail fd;
782 SoPointDetail pd;
783 const SoCoordinateElement *ce;
784 int topVert, botVert, curVert;
785 int quadIndex, matlIndex, normIndex, tcIndex;
786 int row, col, numRows, numCols;
787 Binding materialBinding, normalBinding;
788 SoNormalBundle nb(action, FALSE);
789 SoTextureCoordinateBundle tcb(action, FALSE, ! forPicking);
790
791 ce = SoCoordinateElement::getInstance(action->getState());
792
793 materialBinding = getMaterialBinding(action);
794 normalBinding = getNormalBinding(action);
795
796 // Get number of rows and columns (of quads, not vertices)
797 numRows = (int) verticesPerColumn.getValue() - 1;
798 numCols = (int) verticesPerRow.getValue() - 1;
799
800 topVert = (int) startIndex.getValue();
801 botVert = topVert + numCols + 1;
802
803 if (forPicking) {
804 pv.setTextureCoords(SbVec4f(0.0, 0.0, 0.0, 0.0));
805 pv.setDetail(&fd);
806 }
807 else
808 pv.setDetail(&pd);
809
810 // Generate default normals, if necessary:
811 if (SoNormalElement::getInstance(state)->getNum() == 0) {
812 figureNormals(action->getState(), &nb);
813 normalBinding = PER_VERTEX;
814 }
815
816 for (row = 0; row < numRows; row++) {
817
818 fd.setPartIndex(row);
819
820 // If either material or normal binding is per quad, we have
821 // to generate each quad separately, to get the materials and
822 // normals in the details to be correct
823 if (materialBinding == PER_QUAD || normalBinding == PER_QUAD) {
824
825 for (col = -1; col < numCols; col++) {
826 if (col >= 0) {
827 // Generate a triangle strip from the 4 vertices of the
828 // independent quad, in this order:
829 // topVert-1, botVert-1, botVert, topVert
830
831 quadIndex = row * numCols + col;
832
833 fd.setFaceIndex(quadIndex);
834
835 beginShape(action, TRIANGLE_STRIP,
836 forPicking ? NULL : &fd);
837
838 curVert = topVert - 1;
839 matlIndex = getBindIndex(materialBinding, row, quadIndex, curVert);
840 normIndex = getBindIndex(normalBinding, row, quadIndex, curVert);
841 tcIndex = tcb.isFunction() ? 0 : curVert;
842
843 pv.setPoint(ce->get3(curVert));
844 pv.setNormal(nb.get(normIndex));
845 pv.setMaterialIndex(matlIndex);
846
847 if (! tcb.isFunction())
848 pv.setTextureCoords(tcb.get(tcIndex));
849
850 if (! forPicking) {
851 if (tcb.isFunction())
852 pv.setTextureCoords(tcb.get(pv.getPoint(),
853 pv.getNormal()));
854 pd.setCoordinateIndex(curVert);
855 pd.setMaterialIndex(matlIndex);
856 pd.setNormalIndex(normIndex);
857 pd.setTextureCoordIndex(tcIndex);
858 }
859
860 shapeVertex(&pv);
861
862 curVert = botVert - 1;
863 matlIndex = getBindIndex(materialBinding, row, quadIndex, curVert);
864 normIndex = getBindIndex(normalBinding, row, quadIndex, curVert);
865 tcIndex = tcb.isFunction() ? 0 : curVert;
866
867 pv.setPoint(ce->get3(curVert));
868 pv.setNormal(nb.get(normIndex));
869 pv.setMaterialIndex(matlIndex);
870
871 if (! tcb.isFunction())
872 pv.setTextureCoords(tcb.get(tcIndex));
873
874 if (! forPicking) {
875 if (tcb.isFunction())
876 pv.setTextureCoords(tcb.get(pv.getPoint(),
877 pv.getNormal()));
878 pd.setCoordinateIndex(curVert);
879 pd.setMaterialIndex(matlIndex);
880 pd.setNormalIndex(normIndex);
881 pd.setTextureCoordIndex(tcIndex);
882 }
883
884 shapeVertex(&pv);
885
886 curVert = topVert;
887 matlIndex = getBindIndex(materialBinding, row, quadIndex, curVert);
888 normIndex = getBindIndex(normalBinding, row, quadIndex, curVert);
889 tcIndex = tcb.isFunction() ? 0 : curVert;
890
891 pv.setPoint(ce->get3(curVert));
892 pv.setNormal(nb.get(normIndex));
893 pv.setMaterialIndex(matlIndex);
894
895 if (! tcb.isFunction())
896 pv.setTextureCoords(tcb.get(tcIndex));
897
898 if (! forPicking) {
899 if (tcb.isFunction())
900 pv.setTextureCoords(tcb.get(pv.getPoint(),
901 pv.getNormal()));
902 pd.setCoordinateIndex(curVert);
903 pd.setMaterialIndex(matlIndex);
904 pd.setNormalIndex(normIndex);
905 pd.setTextureCoordIndex(tcIndex);
906 }
907
908 shapeVertex(&pv);
909
910 curVert = botVert;
911 matlIndex = getBindIndex(materialBinding, row, quadIndex, curVert);
912 normIndex = getBindIndex(normalBinding, row, quadIndex, curVert);
913 tcIndex = tcb.isFunction() ? 0 : curVert;
914
915 pv.setPoint(ce->get3(curVert));
916 pv.setNormal(nb.get(normIndex));
917 pv.setMaterialIndex(matlIndex);
918
919 if (! tcb.isFunction())
920 pv.setTextureCoords(tcb.get(tcIndex));
921
922 if (! forPicking) {
923 if (tcb.isFunction())
924 pv.setTextureCoords(tcb.get(pv.getPoint(),
925 pv.getNormal()));
926 pd.setCoordinateIndex(curVert);
927 pd.setMaterialIndex(matlIndex);
928 pd.setNormalIndex(normIndex);
929 pd.setTextureCoordIndex(tcIndex);
930 }
931
932 shapeVertex(&pv);
933
934 endShape();
935 }
936
937 topVert++;
938 botVert++;
939 }
940 }
941
942 // We can generate triangle strips, which is a little easier
943 else {
944 beginShape(action, TRIANGLE_STRIP, forPicking ? NULL : &fd);
945
946 for (col = -1; col < numCols; col++) {
947
948 quadIndex = row * numCols + col;
949
950 fd.setFaceIndex(quadIndex);
951
952 // Generate two vertices for each column:
953 // topVert, then botVert
954
955 curVert = topVert;
956 matlIndex = getBindIndex(materialBinding, row, quadIndex, curVert);
957 normIndex = getBindIndex(normalBinding, row, quadIndex, curVert);
958 tcIndex = tcb.isFunction() ? 0 : curVert;
959
960 pv.setPoint(ce->get3(curVert));
961 pv.setNormal(nb.get(normIndex));
962 pv.setMaterialIndex(matlIndex);
963
964 if (! tcb.isFunction())
965 pv.setTextureCoords(tcb.get(tcIndex));
966
967 if (! forPicking) {
968 if (tcb.isFunction())
969 pv.setTextureCoords(tcb.get(pv.getPoint(),
970 pv.getNormal()));
971 pd.setCoordinateIndex(curVert);
972 pd.setMaterialIndex(matlIndex);
973 pd.setNormalIndex(normIndex);
974 pd.setTextureCoordIndex(tcIndex);
975 }
976
977 shapeVertex(&pv);
978
979 curVert = botVert;
980 matlIndex = getBindIndex(materialBinding, row, quadIndex, curVert);
981 normIndex = getBindIndex(normalBinding, row, quadIndex, curVert);
982 tcIndex = tcb.isFunction() ? 0 : curVert;
983
984 pv.setPoint(ce->get3(curVert));
985 pv.setNormal(nb.get(normIndex));
986 pv.setMaterialIndex(matlIndex);
987
988 if (! tcb.isFunction())
989 pv.setTextureCoords(tcb.get(tcIndex));
990
991 if (! forPicking) {
992 if (tcb.isFunction())
993 pv.setTextureCoords(tcb.get(pv.getPoint(),
994 pv.getNormal()));
995 pd.setCoordinateIndex(curVert);
996 pd.setMaterialIndex(matlIndex);
997 pd.setNormalIndex(normIndex);
998 pd.setTextureCoordIndex(tcIndex);
999 }
1000
1001 shapeVertex(&pv);
1002
1003 topVert++;
1004 botVert++;
1005 }
1006
1007 endShape();
1008 }
1009 }
1010
1011 state->pop();
1012 }
1013
1014 //////////////////////////////////////////////////////////////////////////
1015 // Following preprocessor-generated routines handle all combinations of
1016 // Normal binding (per vertex, per face, per part, overall/none)
1017 // Color Binding (per vertex, per face, per part, overall)
1018 // Textures (on or off)
1019 //////////////////////////////////////////////////////////////////////////
1020
1021 // 32 different rendering loops; the 5 bits used to determine the
1022 // rendering case are:
1023 // 43210 BITS Routine suffix
1024 // ----- ---- --------------
1025 // 00... Overall mtl (Om)
1026 // 01... Part mtl (Pm)
1027 // 10... Face mtl (Fm)
1028 // 11... Vtx mtl (Vm)
1029 // ..00. Overall/No norm (On)
1030 // ..01. Part norm (Pn)
1031 // ..10. Face norm (Fn)
1032 // ..11. Vtx norm (Vn)
1033 // ....0 No texcoord -none-
1034 // ....1 Vtx texcoord (T)
1035 //
1036 SoQuadMesh::PMQM SoQuadMesh::renderFunc[32] = {
1037 &SoQuadMesh::OmOn, &SoQuadMesh::OmOnT,
1038 &SoQuadMesh::OmPn, &SoQuadMesh::OmPnT,
1039 &SoQuadMesh::OmFn, &SoQuadMesh::OmFnT,
1040 &SoQuadMesh::OmVn, &SoQuadMesh::OmVnT,
1041 &SoQuadMesh::PmOn, &SoQuadMesh::PmOnT,
1042 &SoQuadMesh::PmPn, &SoQuadMesh::PmPnT,
1043 &SoQuadMesh::PmFn, &SoQuadMesh::PmFnT,
1044 &SoQuadMesh::PmVn, &SoQuadMesh::PmVnT,
1045 &SoQuadMesh::FmOn, &SoQuadMesh::FmOnT,
1046 &SoQuadMesh::FmPn, &SoQuadMesh::FmPnT,
1047 &SoQuadMesh::FmFn, &SoQuadMesh::FmFnT,
1048 &SoQuadMesh::FmVn, &SoQuadMesh::FmVnT,
1049 &SoQuadMesh::VmOn, &SoQuadMesh::VmOnT,
1050 &SoQuadMesh::VmPn, &SoQuadMesh::VmPnT,
1051 &SoQuadMesh::VmFn, &SoQuadMesh::VmFnT,
1052 &SoQuadMesh::VmVn, &SoQuadMesh::VmVnT,
1053 };
1054
1055
1056
1057 void
1058 SoQuadMesh::
1059 OmOn
1060 (SoGLRenderAction* ) {
1061
1062 // Send one normal, if there are any normals in vpCache:
1063 if (vpCache.getNumNormals() > 0)
1064 vpCache.sendNormal(vpCache.getNormals(0));
1065 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1066 const unsigned int vertexStride = vpCache.getVertexStride();
1067 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1068 const unsigned int vertexRowStride = vertexStride*
1069 verticesPerRow.getValue();
1070
1071 const int numRows = verticesPerColumn.getValue() - 1;
1072 const int nv = verticesPerRow.getValue();
1073
1074 int v;
1075 for (int row = 0; row < numRows; row++) {
1076
1077 //Do Strip rendering if both ~Fn and ~Fm
1078 glBegin(GL_TRIANGLE_STRIP);
1079 for (v = 0; v < nv; v++) {
1080
1081 (*vertexFunc)(vertexPtr);
1082
1083 (*vertexFunc)(vertexPtr+vertexRowStride);
1084 vertexPtr += vertexStride;
1085 }
1086
1087 glEnd();
1088
1089 }
1090 }
1091
1092
1093 void
1094 SoQuadMesh::
1095 OmOnT
1096 (SoGLRenderAction* ) {
1097
1098 // Send one normal, if there are any normals in vpCache:
1099 if (vpCache.getNumNormals() > 0)
1100 vpCache.sendNormal(vpCache.getNormals(0));
1101 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1102 const unsigned int vertexStride = vpCache.getVertexStride();
1103 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1104 const unsigned int vertexRowStride = vertexStride*
1105 verticesPerRow.getValue();
1106 const char *texCoordPtr = vpCache.getTexCoords(0);
1107 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1108 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1109 const unsigned int texCoordRowStride = texCoordStride*
1110 verticesPerRow.getValue();
1111
1112 const int numRows = verticesPerColumn.getValue() - 1;
1113 const int nv = verticesPerRow.getValue();
1114
1115 int v;
1116 for (int row = 0; row < numRows; row++) {
1117
1118 //Do Strip rendering if both ~Fn and ~Fm
1119 glBegin(GL_TRIANGLE_STRIP);
1120 for (v = 0; v < nv; v++) {
1121
1122 (*texCoordFunc)(texCoordPtr);
1123 (*vertexFunc)(vertexPtr);
1124
1125 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1126 texCoordPtr += texCoordStride;
1127 (*vertexFunc)(vertexPtr+vertexRowStride);
1128 vertexPtr += vertexStride;
1129 }
1130
1131 glEnd();
1132
1133 }
1134 }
1135
1136
1137 void
1138 SoQuadMesh::
1139 OmPn
1140 (SoGLRenderAction* ) {
1141
1142 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1143 const unsigned int vertexStride = vpCache.getVertexStride();
1144 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1145 const unsigned int vertexRowStride = vertexStride*
1146 verticesPerRow.getValue();
1147 const char *normalPtr = vpCache.getNormals(0);
1148 const unsigned int normalStride = vpCache.getNormalStride();
1149 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1150
1151 const int numRows = verticesPerColumn.getValue() - 1;
1152 const int nv = verticesPerRow.getValue();
1153
1154 int v;
1155 for (int row = 0; row < numRows; row++) {
1156 (*normalFunc)(normalPtr); normalPtr += normalStride;
1157
1158 //Do Strip rendering if both ~Fn and ~Fm
1159 glBegin(GL_TRIANGLE_STRIP);
1160 for (v = 0; v < nv; v++) {
1161
1162 (*vertexFunc)(vertexPtr);
1163
1164 (*vertexFunc)(vertexPtr+vertexRowStride);
1165 vertexPtr += vertexStride;
1166 }
1167
1168 glEnd();
1169
1170 }
1171 }
1172
1173
1174 void
1175 SoQuadMesh::
1176 OmPnT
1177 (SoGLRenderAction* ) {
1178
1179 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1180 const unsigned int vertexStride = vpCache.getVertexStride();
1181 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1182 const unsigned int vertexRowStride = vertexStride*
1183 verticesPerRow.getValue();
1184 const char *normalPtr = vpCache.getNormals(0);
1185 const unsigned int normalStride = vpCache.getNormalStride();
1186 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1187 const char *texCoordPtr = vpCache.getTexCoords(0);
1188 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1189 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1190 const unsigned int texCoordRowStride = texCoordStride*
1191 verticesPerRow.getValue();
1192
1193 const int numRows = verticesPerColumn.getValue() - 1;
1194 const int nv = verticesPerRow.getValue();
1195
1196 int v;
1197 for (int row = 0; row < numRows; row++) {
1198 (*normalFunc)(normalPtr); normalPtr += normalStride;
1199
1200 //Do Strip rendering if both ~Fn and ~Fm
1201 glBegin(GL_TRIANGLE_STRIP);
1202 for (v = 0; v < nv; v++) {
1203
1204 (*texCoordFunc)(texCoordPtr);
1205 (*vertexFunc)(vertexPtr);
1206
1207 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1208 texCoordPtr += texCoordStride;
1209 (*vertexFunc)(vertexPtr+vertexRowStride);
1210 vertexPtr += vertexStride;
1211 }
1212
1213 glEnd();
1214
1215 }
1216 }
1217
1218
1219 void
1220 SoQuadMesh::
1221 OmFn
1222 (SoGLRenderAction* ) {
1223
1224 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1225 const unsigned int vertexStride = vpCache.getVertexStride();
1226 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1227 const unsigned int vertexRowStride = vertexStride*
1228 verticesPerRow.getValue();
1229 const char *normalPtr = vpCache.getNormals(0);
1230 const unsigned int normalStride = vpCache.getNormalStride();
1231 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1232
1233 const int numRows = verticesPerColumn.getValue() - 1;
1234 const int nv = verticesPerRow.getValue() - 1;
1235
1236 int v;
1237 for (int row = 0; row < numRows; row++) {
1238 glBegin(GL_QUADS);
1239 for(v = 0; v < nv; v++) {
1240 (*normalFunc)(normalPtr); normalPtr += normalStride;
1241 (*vertexFunc)(vertexPtr);
1242 (*vertexFunc)(vertexPtr+vertexRowStride);
1243 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
1244 (*vertexFunc)(vertexPtr+vertexStride);
1245 vertexPtr += vertexStride;
1246 }
1247 glEnd(); //GL_QUADS
1248 //At the end of a row skip over last vertex:
1249 vertexPtr += vertexStride;
1250
1251
1252 //Do Strip rendering if both ~Fn and ~Fm
1253
1254 }
1255 }
1256
1257
1258 void
1259 SoQuadMesh::
1260 OmFnT
1261 (SoGLRenderAction* ) {
1262
1263 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1264 const unsigned int vertexStride = vpCache.getVertexStride();
1265 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1266 const unsigned int vertexRowStride = vertexStride*
1267 verticesPerRow.getValue();
1268 const char *normalPtr = vpCache.getNormals(0);
1269 const unsigned int normalStride = vpCache.getNormalStride();
1270 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1271 const char *texCoordPtr = vpCache.getTexCoords(0);
1272 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1273 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1274 const unsigned int texCoordRowStride = texCoordStride*
1275 verticesPerRow.getValue();
1276
1277 const int numRows = verticesPerColumn.getValue() - 1;
1278 const int nv = verticesPerRow.getValue() - 1;
1279
1280 int v;
1281 for (int row = 0; row < numRows; row++) {
1282 glBegin(GL_QUADS);
1283 for(v = 0; v < nv; v++) {
1284 (*normalFunc)(normalPtr); normalPtr += normalStride;
1285 (*texCoordFunc)(texCoordPtr);
1286 (*vertexFunc)(vertexPtr);
1287 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1288 (*vertexFunc)(vertexPtr+vertexRowStride);
1289 (*texCoordFunc)(texCoordPtr+texCoordStride+texCoordRowStride);
1290 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
1291 (*texCoordFunc)(texCoordPtr+texCoordStride);
1292 texCoordPtr += texCoordStride;
1293 (*vertexFunc)(vertexPtr+vertexStride);
1294 vertexPtr += vertexStride;
1295 }
1296 glEnd(); //GL_QUADS
1297 //At the end of a row skip over last vertex:
1298 vertexPtr += vertexStride;
1299 texCoordPtr += texCoordStride;
1300
1301
1302 //Do Strip rendering if both ~Fn and ~Fm
1303
1304 }
1305 }
1306
1307
1308 void
1309 SoQuadMesh::
1310 OmVn
1311 (SoGLRenderAction* ) {
1312
1313 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1314 const unsigned int vertexStride = vpCache.getVertexStride();
1315 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1316 const unsigned int vertexRowStride = vertexStride*
1317 verticesPerRow.getValue();
1318 const char *normalPtr = vpCache.getNormals(startIndex.getValue());
1319 const unsigned int normalStride = vpCache.getNormalStride();
1320 const unsigned int normalRowStride = normalStride*verticesPerRow.getValue();
1321 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1322
1323 const int numRows = verticesPerColumn.getValue() - 1;
1324 const int nv = verticesPerRow.getValue();
1325
1326 int v;
1327 for (int row = 0; row < numRows; row++) {
1328
1329 //Do Strip rendering if both ~Fn and ~Fm
1330 glBegin(GL_TRIANGLE_STRIP);
1331 for (v = 0; v < nv; v++) {
1332
1333 (*normalFunc)(normalPtr);
1334 (*vertexFunc)(vertexPtr);
1335
1336 (*normalFunc)(normalPtr+normalRowStride);
1337 normalPtr += normalStride;
1338 (*vertexFunc)(vertexPtr+vertexRowStride);
1339 vertexPtr += vertexStride;
1340 }
1341
1342 glEnd();
1343
1344 }
1345 }
1346
1347
1348 void
1349 SoQuadMesh::
1350 OmVnT
1351 (SoGLRenderAction* ) {
1352
1353 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1354 const unsigned int vertexStride = vpCache.getVertexStride();
1355 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1356 const unsigned int vertexRowStride = vertexStride*
1357 verticesPerRow.getValue();
1358 const char *normalPtr = vpCache.getNormals(startIndex.getValue());
1359 const unsigned int normalStride = vpCache.getNormalStride();
1360 const unsigned int normalRowStride = normalStride*verticesPerRow.getValue();
1361 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1362 const char *texCoordPtr = vpCache.getTexCoords(0);
1363 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1364 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1365 const unsigned int texCoordRowStride = texCoordStride*
1366 verticesPerRow.getValue();
1367
1368 const int numRows = verticesPerColumn.getValue() - 1;
1369 const int nv = verticesPerRow.getValue();
1370
1371 int v;
1372 for (int row = 0; row < numRows; row++) {
1373
1374 //Do Strip rendering if both ~Fn and ~Fm
1375 glBegin(GL_TRIANGLE_STRIP);
1376 for (v = 0; v < nv; v++) {
1377
1378 (*normalFunc)(normalPtr);
1379 (*texCoordFunc)(texCoordPtr);
1380 (*vertexFunc)(vertexPtr);
1381
1382 (*normalFunc)(normalPtr+normalRowStride);
1383 normalPtr += normalStride;
1384 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1385 texCoordPtr += texCoordStride;
1386 (*vertexFunc)(vertexPtr+vertexRowStride);
1387 vertexPtr += vertexStride;
1388 }
1389
1390 glEnd();
1391
1392 }
1393 }
1394
1395
1396 void
1397 SoQuadMesh::
1398 PmOn
1399 (SoGLRenderAction* ) {
1400
1401 // Send one normal, if there are any normals in vpCache:
1402 if (vpCache.getNumNormals() > 0)
1403 vpCache.sendNormal(vpCache.getNormals(0));
1404 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1405 const unsigned int vertexStride = vpCache.getVertexStride();
1406 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1407 const unsigned int vertexRowStride = vertexStride*
1408 verticesPerRow.getValue();
1409 const char *colorPtr = vpCache.getColors(0);
1410 const unsigned int colorStride = vpCache.getColorStride();
1411 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1412
1413 const int numRows = verticesPerColumn.getValue() - 1;
1414 const int nv = verticesPerRow.getValue();
1415
1416 int v;
1417 for (int row = 0; row < numRows; row++) {
1418 (*colorFunc)(colorPtr); colorPtr += colorStride;
1419
1420 //Do Strip rendering if both ~Fn and ~Fm
1421 glBegin(GL_TRIANGLE_STRIP);
1422 for (v = 0; v < nv; v++) {
1423
1424 (*vertexFunc)(vertexPtr);
1425
1426 (*vertexFunc)(vertexPtr+vertexRowStride);
1427 vertexPtr += vertexStride;
1428 }
1429
1430 glEnd();
1431
1432 }
1433 }
1434
1435
1436 void
1437 SoQuadMesh::
1438 PmOnT
1439 (SoGLRenderAction* ) {
1440
1441 // Send one normal, if there are any normals in vpCache:
1442 if (vpCache.getNumNormals() > 0)
1443 vpCache.sendNormal(vpCache.getNormals(0));
1444 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1445 const unsigned int vertexStride = vpCache.getVertexStride();
1446 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1447 const unsigned int vertexRowStride = vertexStride*
1448 verticesPerRow.getValue();
1449 const char *colorPtr = vpCache.getColors(0);
1450 const unsigned int colorStride = vpCache.getColorStride();
1451 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1452 const char *texCoordPtr = vpCache.getTexCoords(0);
1453 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1454 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1455 const unsigned int texCoordRowStride = texCoordStride*
1456 verticesPerRow.getValue();
1457
1458 const int numRows = verticesPerColumn.getValue() - 1;
1459 const int nv = verticesPerRow.getValue();
1460
1461 int v;
1462 for (int row = 0; row < numRows; row++) {
1463 (*colorFunc)(colorPtr); colorPtr += colorStride;
1464
1465 //Do Strip rendering if both ~Fn and ~Fm
1466 glBegin(GL_TRIANGLE_STRIP);
1467 for (v = 0; v < nv; v++) {
1468
1469 (*texCoordFunc)(texCoordPtr);
1470 (*vertexFunc)(vertexPtr);
1471
1472 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1473 texCoordPtr += texCoordStride;
1474 (*vertexFunc)(vertexPtr+vertexRowStride);
1475 vertexPtr += vertexStride;
1476 }
1477
1478 glEnd();
1479
1480 }
1481 }
1482
1483
1484 void
1485 SoQuadMesh::
1486 PmPn
1487 (SoGLRenderAction* ) {
1488
1489 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1490 const unsigned int vertexStride = vpCache.getVertexStride();
1491 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1492 const unsigned int vertexRowStride = vertexStride*
1493 verticesPerRow.getValue();
1494 const char *colorPtr = vpCache.getColors(0);
1495 const unsigned int colorStride = vpCache.getColorStride();
1496 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1497 const char *normalPtr = vpCache.getNormals(0);
1498 const unsigned int normalStride = vpCache.getNormalStride();
1499 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1500
1501 const int numRows = verticesPerColumn.getValue() - 1;
1502 const int nv = verticesPerRow.getValue();
1503
1504 int v;
1505 for (int row = 0; row < numRows; row++) {
1506 (*colorFunc)(colorPtr); colorPtr += colorStride;
1507 (*normalFunc)(normalPtr); normalPtr += normalStride;
1508
1509 //Do Strip rendering if both ~Fn and ~Fm
1510 glBegin(GL_TRIANGLE_STRIP);
1511 for (v = 0; v < nv; v++) {
1512
1513 (*vertexFunc)(vertexPtr);
1514
1515 (*vertexFunc)(vertexPtr+vertexRowStride);
1516 vertexPtr += vertexStride;
1517 }
1518
1519 glEnd();
1520
1521 }
1522 }
1523
1524
1525 void
1526 SoQuadMesh::
1527 PmPnT
1528 (SoGLRenderAction* ) {
1529
1530 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1531 const unsigned int vertexStride = vpCache.getVertexStride();
1532 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1533 const unsigned int vertexRowStride = vertexStride*
1534 verticesPerRow.getValue();
1535 const char *colorPtr = vpCache.getColors(0);
1536 const unsigned int colorStride = vpCache.getColorStride();
1537 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1538 const char *normalPtr = vpCache.getNormals(0);
1539 const unsigned int normalStride = vpCache.getNormalStride();
1540 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1541 const char *texCoordPtr = vpCache.getTexCoords(0);
1542 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1543 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1544 const unsigned int texCoordRowStride = texCoordStride*
1545 verticesPerRow.getValue();
1546
1547 const int numRows = verticesPerColumn.getValue() - 1;
1548 const int nv = verticesPerRow.getValue();
1549
1550 int v;
1551 for (int row = 0; row < numRows; row++) {
1552 (*colorFunc)(colorPtr); colorPtr += colorStride;
1553 (*normalFunc)(normalPtr); normalPtr += normalStride;
1554
1555 //Do Strip rendering if both ~Fn and ~Fm
1556 glBegin(GL_TRIANGLE_STRIP);
1557 for (v = 0; v < nv; v++) {
1558
1559 (*texCoordFunc)(texCoordPtr);
1560 (*vertexFunc)(vertexPtr);
1561
1562 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1563 texCoordPtr += texCoordStride;
1564 (*vertexFunc)(vertexPtr+vertexRowStride);
1565 vertexPtr += vertexStride;
1566 }
1567
1568 glEnd();
1569
1570 }
1571 }
1572
1573
1574 void
1575 SoQuadMesh::
1576 PmFn
1577 (SoGLRenderAction* ) {
1578
1579 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1580 const unsigned int vertexStride = vpCache.getVertexStride();
1581 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1582 const unsigned int vertexRowStride = vertexStride*
1583 verticesPerRow.getValue();
1584 const char *colorPtr = vpCache.getColors(0);
1585 const unsigned int colorStride = vpCache.getColorStride();
1586 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1587 const char *normalPtr = vpCache.getNormals(0);
1588 const unsigned int normalStride = vpCache.getNormalStride();
1589 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1590
1591 const int numRows = verticesPerColumn.getValue() - 1;
1592 const int nv = verticesPerRow.getValue() - 1;
1593
1594 int v;
1595 for (int row = 0; row < numRows; row++) {
1596 (*colorFunc)(colorPtr); colorPtr += colorStride;
1597 glBegin(GL_QUADS);
1598 for(v = 0; v < nv; v++) {
1599 (*normalFunc)(normalPtr); normalPtr += normalStride;
1600 (*vertexFunc)(vertexPtr);
1601 (*vertexFunc)(vertexPtr+vertexRowStride);
1602 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
1603 (*vertexFunc)(vertexPtr+vertexStride);
1604 vertexPtr += vertexStride;
1605 }
1606 glEnd(); //GL_QUADS
1607 //At the end of a row skip over last vertex:
1608 vertexPtr += vertexStride;
1609
1610
1611 //Do Strip rendering if both ~Fn and ~Fm
1612
1613 }
1614 }
1615
1616
1617 void
1618 SoQuadMesh::
1619 PmFnT
1620 (SoGLRenderAction* ) {
1621
1622 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1623 const unsigned int vertexStride = vpCache.getVertexStride();
1624 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1625 const unsigned int vertexRowStride = vertexStride*
1626 verticesPerRow.getValue();
1627 const char *colorPtr = vpCache.getColors(0);
1628 const unsigned int colorStride = vpCache.getColorStride();
1629 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1630 const char *normalPtr = vpCache.getNormals(0);
1631 const unsigned int normalStride = vpCache.getNormalStride();
1632 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1633 const char *texCoordPtr = vpCache.getTexCoords(0);
1634 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1635 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1636 const unsigned int texCoordRowStride = texCoordStride*
1637 verticesPerRow.getValue();
1638
1639 const int numRows = verticesPerColumn.getValue() - 1;
1640 const int nv = verticesPerRow.getValue() - 1;
1641
1642 int v;
1643 for (int row = 0; row < numRows; row++) {
1644 (*colorFunc)(colorPtr); colorPtr += colorStride;
1645 glBegin(GL_QUADS);
1646 for(v = 0; v < nv; v++) {
1647 (*normalFunc)(normalPtr); normalPtr += normalStride;
1648 (*texCoordFunc)(texCoordPtr);
1649 (*vertexFunc)(vertexPtr);
1650 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1651 (*vertexFunc)(vertexPtr+vertexRowStride);
1652 (*texCoordFunc)(texCoordPtr+texCoordStride+texCoordRowStride);
1653 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
1654 (*texCoordFunc)(texCoordPtr+texCoordStride);
1655 texCoordPtr += texCoordStride;
1656 (*vertexFunc)(vertexPtr+vertexStride);
1657 vertexPtr += vertexStride;
1658 }
1659 glEnd(); //GL_QUADS
1660 //At the end of a row skip over last vertex:
1661 vertexPtr += vertexStride;
1662 texCoordPtr += texCoordStride;
1663
1664
1665 //Do Strip rendering if both ~Fn and ~Fm
1666
1667 }
1668 }
1669
1670
1671 void
1672 SoQuadMesh::
1673 PmVn
1674 (SoGLRenderAction* ) {
1675
1676 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1677 const unsigned int vertexStride = vpCache.getVertexStride();
1678 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1679 const unsigned int vertexRowStride = vertexStride*
1680 verticesPerRow.getValue();
1681 const char *colorPtr = vpCache.getColors(0);
1682 const unsigned int colorStride = vpCache.getColorStride();
1683 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1684 const char *normalPtr = vpCache.getNormals(startIndex.getValue());
1685 const unsigned int normalStride = vpCache.getNormalStride();
1686 const unsigned int normalRowStride = normalStride*verticesPerRow.getValue();
1687 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1688
1689 const int numRows = verticesPerColumn.getValue() - 1;
1690 const int nv = verticesPerRow.getValue();
1691
1692 int v;
1693 for (int row = 0; row < numRows; row++) {
1694 (*colorFunc)(colorPtr); colorPtr += colorStride;
1695
1696 //Do Strip rendering if both ~Fn and ~Fm
1697 glBegin(GL_TRIANGLE_STRIP);
1698 for (v = 0; v < nv; v++) {
1699
1700 (*normalFunc)(normalPtr);
1701 (*vertexFunc)(vertexPtr);
1702
1703 (*normalFunc)(normalPtr+normalRowStride);
1704 normalPtr += normalStride;
1705 (*vertexFunc)(vertexPtr+vertexRowStride);
1706 vertexPtr += vertexStride;
1707 }
1708
1709 glEnd();
1710
1711 }
1712 }
1713
1714
1715 void
1716 SoQuadMesh::
1717 PmVnT
1718 (SoGLRenderAction* ) {
1719
1720 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1721 const unsigned int vertexStride = vpCache.getVertexStride();
1722 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1723 const unsigned int vertexRowStride = vertexStride*
1724 verticesPerRow.getValue();
1725 const char *colorPtr = vpCache.getColors(0);
1726 const unsigned int colorStride = vpCache.getColorStride();
1727 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1728 const char *normalPtr = vpCache.getNormals(startIndex.getValue());
1729 const unsigned int normalStride = vpCache.getNormalStride();
1730 const unsigned int normalRowStride = normalStride*verticesPerRow.getValue();
1731 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1732 const char *texCoordPtr = vpCache.getTexCoords(0);
1733 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1734 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1735 const unsigned int texCoordRowStride = texCoordStride*
1736 verticesPerRow.getValue();
1737
1738 const int numRows = verticesPerColumn.getValue() - 1;
1739 const int nv = verticesPerRow.getValue();
1740
1741 int v;
1742 for (int row = 0; row < numRows; row++) {
1743 (*colorFunc)(colorPtr); colorPtr += colorStride;
1744
1745 //Do Strip rendering if both ~Fn and ~Fm
1746 glBegin(GL_TRIANGLE_STRIP);
1747 for (v = 0; v < nv; v++) {
1748
1749 (*normalFunc)(normalPtr);
1750 (*texCoordFunc)(texCoordPtr);
1751 (*vertexFunc)(vertexPtr);
1752
1753 (*normalFunc)(normalPtr+normalRowStride);
1754 normalPtr += normalStride;
1755 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1756 texCoordPtr += texCoordStride;
1757 (*vertexFunc)(vertexPtr+vertexRowStride);
1758 vertexPtr += vertexStride;
1759 }
1760
1761 glEnd();
1762
1763 }
1764 }
1765
1766
1767 void
1768 SoQuadMesh::
1769 FmOn
1770 (SoGLRenderAction* ) {
1771
1772 // Send one normal, if there are any normals in vpCache:
1773 if (vpCache.getNumNormals() > 0)
1774 vpCache.sendNormal(vpCache.getNormals(0));
1775 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1776 const unsigned int vertexStride = vpCache.getVertexStride();
1777 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1778 const unsigned int vertexRowStride = vertexStride*
1779 verticesPerRow.getValue();
1780 const char *colorPtr = vpCache.getColors(0);
1781 const unsigned int colorStride = vpCache.getColorStride();
1782 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1783
1784 const int numRows = verticesPerColumn.getValue() - 1;
1785 const int nv = verticesPerRow.getValue() - 1;
1786
1787 int v;
1788 for (int row = 0; row < numRows; row++) {
1789 glBegin(GL_QUADS);
1790 for(v = 0; v < nv; v++) {
1791 (*colorFunc)(colorPtr); colorPtr += colorStride;
1792 (*vertexFunc)(vertexPtr);
1793 (*vertexFunc)(vertexPtr+vertexRowStride);
1794 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
1795 (*vertexFunc)(vertexPtr+vertexStride);
1796 vertexPtr += vertexStride;
1797 }
1798 glEnd(); //GL_QUADS
1799 //At the end of a row skip over last vertex:
1800 vertexPtr += vertexStride;
1801
1802
1803 //Do Strip rendering if both ~Fn and ~Fm
1804
1805 }
1806 }
1807
1808
1809 void
1810 SoQuadMesh::
1811 FmOnT
1812 (SoGLRenderAction* ) {
1813
1814 // Send one normal, if there are any normals in vpCache:
1815 if (vpCache.getNumNormals() > 0)
1816 vpCache.sendNormal(vpCache.getNormals(0));
1817 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1818 const unsigned int vertexStride = vpCache.getVertexStride();
1819 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1820 const unsigned int vertexRowStride = vertexStride*
1821 verticesPerRow.getValue();
1822 const char *colorPtr = vpCache.getColors(0);
1823 const unsigned int colorStride = vpCache.getColorStride();
1824 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1825 const char *texCoordPtr = vpCache.getTexCoords(0);
1826 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1827 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1828 const unsigned int texCoordRowStride = texCoordStride*
1829 verticesPerRow.getValue();
1830
1831 const int numRows = verticesPerColumn.getValue() - 1;
1832 const int nv = verticesPerRow.getValue() - 1;
1833
1834 int v;
1835 for (int row = 0; row < numRows; row++) {
1836 glBegin(GL_QUADS);
1837 for(v = 0; v < nv; v++) {
1838 (*colorFunc)(colorPtr); colorPtr += colorStride;
1839 (*texCoordFunc)(texCoordPtr);
1840 (*vertexFunc)(vertexPtr);
1841 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1842 (*vertexFunc)(vertexPtr+vertexRowStride);
1843 (*texCoordFunc)(texCoordPtr+texCoordStride+texCoordRowStride);
1844 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
1845 (*texCoordFunc)(texCoordPtr+texCoordStride);
1846 texCoordPtr += texCoordStride;
1847 (*vertexFunc)(vertexPtr+vertexStride);
1848 vertexPtr += vertexStride;
1849 }
1850 glEnd(); //GL_QUADS
1851 //At the end of a row skip over last vertex:
1852 vertexPtr += vertexStride;
1853 texCoordPtr += texCoordStride;
1854
1855
1856 //Do Strip rendering if both ~Fn and ~Fm
1857
1858 }
1859 }
1860
1861
1862 void
1863 SoQuadMesh::
1864 FmPn
1865 (SoGLRenderAction* ) {
1866
1867 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1868 const unsigned int vertexStride = vpCache.getVertexStride();
1869 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1870 const unsigned int vertexRowStride = vertexStride*
1871 verticesPerRow.getValue();
1872 const char *colorPtr = vpCache.getColors(0);
1873 const unsigned int colorStride = vpCache.getColorStride();
1874 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1875 const char *normalPtr = vpCache.getNormals(0);
1876 const unsigned int normalStride = vpCache.getNormalStride();
1877 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1878
1879 const int numRows = verticesPerColumn.getValue() - 1;
1880 const int nv = verticesPerRow.getValue() - 1;
1881
1882 int v;
1883 for (int row = 0; row < numRows; row++) {
1884 (*normalFunc)(normalPtr); normalPtr += normalStride;
1885 glBegin(GL_QUADS);
1886 for(v = 0; v < nv; v++) {
1887 (*colorFunc)(colorPtr); colorPtr += colorStride;
1888 (*vertexFunc)(vertexPtr);
1889 (*vertexFunc)(vertexPtr+vertexRowStride);
1890 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
1891 (*vertexFunc)(vertexPtr+vertexStride);
1892 vertexPtr += vertexStride;
1893 }
1894 glEnd(); //GL_QUADS
1895 //At the end of a row skip over last vertex:
1896 vertexPtr += vertexStride;
1897
1898
1899 //Do Strip rendering if both ~Fn and ~Fm
1900
1901 }
1902 }
1903
1904
1905 void
1906 SoQuadMesh::
1907 FmPnT
1908 (SoGLRenderAction* ) {
1909
1910 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1911 const unsigned int vertexStride = vpCache.getVertexStride();
1912 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1913 const unsigned int vertexRowStride = vertexStride*
1914 verticesPerRow.getValue();
1915 const char *colorPtr = vpCache.getColors(0);
1916 const unsigned int colorStride = vpCache.getColorStride();
1917 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1918 const char *normalPtr = vpCache.getNormals(0);
1919 const unsigned int normalStride = vpCache.getNormalStride();
1920 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1921 const char *texCoordPtr = vpCache.getTexCoords(0);
1922 const unsigned int texCoordStride = vpCache.getTexCoordStride();
1923 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
1924 const unsigned int texCoordRowStride = texCoordStride*
1925 verticesPerRow.getValue();
1926
1927 const int numRows = verticesPerColumn.getValue() - 1;
1928 const int nv = verticesPerRow.getValue() - 1;
1929
1930 int v;
1931 for (int row = 0; row < numRows; row++) {
1932 (*normalFunc)(normalPtr); normalPtr += normalStride;
1933 glBegin(GL_QUADS);
1934 for(v = 0; v < nv; v++) {
1935 (*colorFunc)(colorPtr); colorPtr += colorStride;
1936 (*texCoordFunc)(texCoordPtr);
1937 (*vertexFunc)(vertexPtr);
1938 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
1939 (*vertexFunc)(vertexPtr+vertexRowStride);
1940 (*texCoordFunc)(texCoordPtr+texCoordStride+texCoordRowStride);
1941 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
1942 (*texCoordFunc)(texCoordPtr+texCoordStride);
1943 texCoordPtr += texCoordStride;
1944 (*vertexFunc)(vertexPtr+vertexStride);
1945 vertexPtr += vertexStride;
1946 }
1947 glEnd(); //GL_QUADS
1948 //At the end of a row skip over last vertex:
1949 vertexPtr += vertexStride;
1950 texCoordPtr += texCoordStride;
1951
1952
1953 //Do Strip rendering if both ~Fn and ~Fm
1954
1955 }
1956 }
1957
1958
1959 void
1960 SoQuadMesh::
1961 FmFn
1962 (SoGLRenderAction* ) {
1963
1964 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
1965 const unsigned int vertexStride = vpCache.getVertexStride();
1966 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
1967 const unsigned int vertexRowStride = vertexStride*
1968 verticesPerRow.getValue();
1969 const char *colorPtr = vpCache.getColors(0);
1970 const unsigned int colorStride = vpCache.getColorStride();
1971 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
1972 const char *normalPtr = vpCache.getNormals(0);
1973 const unsigned int normalStride = vpCache.getNormalStride();
1974 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
1975
1976 const int numRows = verticesPerColumn.getValue() - 1;
1977 const int nv = verticesPerRow.getValue() - 1;
1978
1979 int v;
1980 for (int row = 0; row < numRows; row++) {
1981 glBegin(GL_QUADS);
1982 for(v = 0; v < nv; v++) {
1983 (*colorFunc)(colorPtr); colorPtr += colorStride;
1984 (*normalFunc)(normalPtr); normalPtr += normalStride;
1985 (*vertexFunc)(vertexPtr);
1986 (*vertexFunc)(vertexPtr+vertexRowStride);
1987 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
1988 (*vertexFunc)(vertexPtr+vertexStride);
1989 vertexPtr += vertexStride;
1990 }
1991 glEnd(); //GL_QUADS
1992 //At the end of a row skip over last vertex:
1993 vertexPtr += vertexStride;
1994
1995
1996 //Do Strip rendering if both ~Fn and ~Fm
1997
1998 }
1999 }
2000
2001
2002 void
2003 SoQuadMesh::
2004 FmFnT
2005 (SoGLRenderAction* ) {
2006
2007 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2008 const unsigned int vertexStride = vpCache.getVertexStride();
2009 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2010 const unsigned int vertexRowStride = vertexStride*
2011 verticesPerRow.getValue();
2012 const char *colorPtr = vpCache.getColors(0);
2013 const unsigned int colorStride = vpCache.getColorStride();
2014 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2015 const char *normalPtr = vpCache.getNormals(0);
2016 const unsigned int normalStride = vpCache.getNormalStride();
2017 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
2018 const char *texCoordPtr = vpCache.getTexCoords(0);
2019 const unsigned int texCoordStride = vpCache.getTexCoordStride();
2020 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
2021 const unsigned int texCoordRowStride = texCoordStride*
2022 verticesPerRow.getValue();
2023
2024 const int numRows = verticesPerColumn.getValue() - 1;
2025 const int nv = verticesPerRow.getValue() - 1;
2026
2027 int v;
2028 for (int row = 0; row < numRows; row++) {
2029 glBegin(GL_QUADS);
2030 for(v = 0; v < nv; v++) {
2031 (*colorFunc)(colorPtr); colorPtr += colorStride;
2032 (*normalFunc)(normalPtr); normalPtr += normalStride;
2033 (*texCoordFunc)(texCoordPtr);
2034 (*vertexFunc)(vertexPtr);
2035 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
2036 (*vertexFunc)(vertexPtr+vertexRowStride);
2037 (*texCoordFunc)(texCoordPtr+texCoordStride+texCoordRowStride);
2038 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
2039 (*texCoordFunc)(texCoordPtr+texCoordStride);
2040 texCoordPtr += texCoordStride;
2041 (*vertexFunc)(vertexPtr+vertexStride);
2042 vertexPtr += vertexStride;
2043 }
2044 glEnd(); //GL_QUADS
2045 //At the end of a row skip over last vertex:
2046 vertexPtr += vertexStride;
2047 texCoordPtr += texCoordStride;
2048
2049
2050 //Do Strip rendering if both ~Fn and ~Fm
2051
2052 }
2053 }
2054
2055
2056 void
2057 SoQuadMesh::
2058 FmVn
2059 (SoGLRenderAction* ) {
2060
2061 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2062 const unsigned int vertexStride = vpCache.getVertexStride();
2063 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2064 const unsigned int vertexRowStride = vertexStride*
2065 verticesPerRow.getValue();
2066 const char *colorPtr = vpCache.getColors(0);
2067 const unsigned int colorStride = vpCache.getColorStride();
2068 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2069 const char *normalPtr = vpCache.getNormals(startIndex.getValue());
2070 const unsigned int normalStride = vpCache.getNormalStride();
2071 const unsigned int normalRowStride = normalStride*verticesPerRow.getValue();
2072 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
2073
2074 const int numRows = verticesPerColumn.getValue() - 1;
2075 const int nv = verticesPerRow.getValue() - 1;
2076
2077 int v;
2078 for (int row = 0; row < numRows; row++) {
2079 glBegin(GL_QUADS);
2080 for(v = 0; v < nv; v++) {
2081 (*colorFunc)(colorPtr); colorPtr += colorStride;
2082 (*normalFunc)(normalPtr);
2083 (*vertexFunc)(vertexPtr);
2084 (*normalFunc)(normalPtr+normalRowStride);
2085 (*vertexFunc)(vertexPtr+vertexRowStride);
2086 (*normalFunc)(normalPtr+normalStride+normalRowStride);
2087 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
2088 (*normalFunc)(normalPtr+normalStride);
2089 normalPtr += normalStride;
2090 (*vertexFunc)(vertexPtr+vertexStride);
2091 vertexPtr += vertexStride;
2092 }
2093 glEnd(); //GL_QUADS
2094 //At the end of a row skip over last vertex:
2095 vertexPtr += vertexStride;
2096 normalPtr += normalStride;
2097
2098
2099 //Do Strip rendering if both ~Fn and ~Fm
2100
2101 }
2102 }
2103
2104
2105 void
2106 SoQuadMesh::
2107 FmVnT
2108 (SoGLRenderAction* ) {
2109
2110 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2111 const unsigned int vertexStride = vpCache.getVertexStride();
2112 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2113 const unsigned int vertexRowStride = vertexStride*
2114 verticesPerRow.getValue();
2115 const char *colorPtr = vpCache.getColors(0);
2116 const unsigned int colorStride = vpCache.getColorStride();
2117 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2118 const char *normalPtr = vpCache.getNormals(startIndex.getValue());
2119 const unsigned int normalStride = vpCache.getNormalStride();
2120 const unsigned int normalRowStride = normalStride*verticesPerRow.getValue();
2121 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
2122 const char *texCoordPtr = vpCache.getTexCoords(0);
2123 const unsigned int texCoordStride = vpCache.getTexCoordStride();
2124 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
2125 const unsigned int texCoordRowStride = texCoordStride*
2126 verticesPerRow.getValue();
2127
2128 const int numRows = verticesPerColumn.getValue() - 1;
2129 const int nv = verticesPerRow.getValue() - 1;
2130
2131 int v;
2132 for (int row = 0; row < numRows; row++) {
2133 glBegin(GL_QUADS);
2134 for(v = 0; v < nv; v++) {
2135 (*colorFunc)(colorPtr); colorPtr += colorStride;
2136 (*normalFunc)(normalPtr);
2137 (*texCoordFunc)(texCoordPtr);
2138 (*vertexFunc)(vertexPtr);
2139 (*normalFunc)(normalPtr+normalRowStride);
2140 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
2141 (*vertexFunc)(vertexPtr+vertexRowStride);
2142 (*normalFunc)(normalPtr+normalStride+normalRowStride);
2143 (*texCoordFunc)(texCoordPtr+texCoordStride+texCoordRowStride);
2144 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
2145 (*normalFunc)(normalPtr+normalStride);
2146 normalPtr += normalStride;
2147 (*texCoordFunc)(texCoordPtr+texCoordStride);
2148 texCoordPtr += texCoordStride;
2149 (*vertexFunc)(vertexPtr+vertexStride);
2150 vertexPtr += vertexStride;
2151 }
2152 glEnd(); //GL_QUADS
2153 //At the end of a row skip over last vertex:
2154 vertexPtr += vertexStride;
2155 texCoordPtr += texCoordStride;
2156 normalPtr += normalStride;
2157
2158
2159 //Do Strip rendering if both ~Fn and ~Fm
2160
2161 }
2162 }
2163
2164
2165
2166 void
2167 SoQuadMesh::
2168 VmOn
2169 (SoGLRenderAction* ) {
2170
2171 // Send one normal, if there are any normals in vpCache:
2172 if (vpCache.getNumNormals() > 0)
2173 vpCache.sendNormal(vpCache.getNormals(0));
2174 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2175 const unsigned int vertexStride = vpCache.getVertexStride();
2176 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2177 const unsigned int vertexRowStride = vertexStride*
2178 verticesPerRow.getValue();
2179 const char *colorPtr = vpCache.getColors(startIndex.getValue());
2180 const unsigned int colorStride = vpCache.getColorStride();
2181 const unsigned int colorRowStride = colorStride*
2182 verticesPerRow.getValue();
2183 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2184
2185 const int numRows = verticesPerColumn.getValue() - 1;
2186 const int nv = verticesPerRow.getValue();
2187
2188 int v;
2189 for (int row = 0; row < numRows; row++) {
2190
2191 //Do Strip rendering if both ~Fn and ~Fm
2192 glBegin(GL_TRIANGLE_STRIP);
2193 for (v = 0; v < nv; v++) {
2194
2195 (*colorFunc)(colorPtr);
2196 (*vertexFunc)(vertexPtr);
2197
2198 (*colorFunc)(colorPtr+colorRowStride);
2199 colorPtr += colorStride;
2200 (*vertexFunc)(vertexPtr+vertexRowStride);
2201 vertexPtr += vertexStride;
2202 }
2203
2204 glEnd();
2205
2206 }
2207 }
2208
2209
2210 void
2211 SoQuadMesh::
2212 VmOnT
2213 (SoGLRenderAction* ) {
2214
2215 // Send one normal, if there are any normals in vpCache:
2216 if (vpCache.getNumNormals() > 0)
2217 vpCache.sendNormal(vpCache.getNormals(0));
2218 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2219 const unsigned int vertexStride = vpCache.getVertexStride();
2220 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2221 const unsigned int vertexRowStride = vertexStride*
2222 verticesPerRow.getValue();
2223 const char *colorPtr = vpCache.getColors(startIndex.getValue());
2224 const unsigned int colorStride = vpCache.getColorStride();
2225 const unsigned int colorRowStride = colorStride*
2226 verticesPerRow.getValue();
2227 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2228 const char *texCoordPtr = vpCache.getTexCoords(0);
2229 const unsigned int texCoordStride = vpCache.getTexCoordStride();
2230 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
2231 const unsigned int texCoordRowStride = texCoordStride*
2232 verticesPerRow.getValue();
2233
2234 const int numRows = verticesPerColumn.getValue() - 1;
2235 const int nv = verticesPerRow.getValue();
2236
2237 int v;
2238 for (int row = 0; row < numRows; row++) {
2239
2240 //Do Strip rendering if both ~Fn and ~Fm
2241 glBegin(GL_TRIANGLE_STRIP);
2242 for (v = 0; v < nv; v++) {
2243
2244 (*colorFunc)(colorPtr);
2245 (*texCoordFunc)(texCoordPtr);
2246 (*vertexFunc)(vertexPtr);
2247
2248 (*colorFunc)(colorPtr+colorRowStride);
2249 colorPtr += colorStride;
2250 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
2251 texCoordPtr += texCoordStride;
2252 (*vertexFunc)(vertexPtr+vertexRowStride);
2253 vertexPtr += vertexStride;
2254 }
2255
2256 glEnd();
2257
2258 }
2259 }
2260
2261
2262 void
2263 SoQuadMesh::
2264 VmPn
2265 (SoGLRenderAction* ) {
2266
2267 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2268 const unsigned int vertexStride = vpCache.getVertexStride();
2269 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2270 const unsigned int vertexRowStride = vertexStride*
2271 verticesPerRow.getValue();
2272 const char *colorPtr = vpCache.getColors(startIndex.getValue());
2273 const unsigned int colorStride = vpCache.getColorStride();
2274 const unsigned int colorRowStride = colorStride*
2275 verticesPerRow.getValue();
2276 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2277 const char *normalPtr = vpCache.getNormals(0);
2278 const unsigned int normalStride = vpCache.getNormalStride();
2279 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
2280
2281 const int numRows = verticesPerColumn.getValue() - 1;
2282 const int nv = verticesPerRow.getValue();
2283
2284 int v;
2285 for (int row = 0; row < numRows; row++) {
2286 (*normalFunc)(normalPtr); normalPtr += normalStride;
2287
2288 //Do Strip rendering if both ~Fn and ~Fm
2289 glBegin(GL_TRIANGLE_STRIP);
2290 for (v = 0; v < nv; v++) {
2291
2292 (*colorFunc)(colorPtr);
2293 (*vertexFunc)(vertexPtr);
2294
2295 (*colorFunc)(colorPtr+colorRowStride);
2296 colorPtr += colorStride;
2297 (*vertexFunc)(vertexPtr+vertexRowStride);
2298 vertexPtr += vertexStride;
2299 }
2300
2301 glEnd();
2302
2303 }
2304 }
2305
2306
2307 void
2308 SoQuadMesh::
2309 VmPnT
2310 (SoGLRenderAction* ) {
2311
2312 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2313 const unsigned int vertexStride = vpCache.getVertexStride();
2314 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2315 const unsigned int vertexRowStride = vertexStride*
2316 verticesPerRow.getValue();
2317 const char *colorPtr = vpCache.getColors(startIndex.getValue());
2318 const unsigned int colorStride = vpCache.getColorStride();
2319 const unsigned int colorRowStride = colorStride*
2320 verticesPerRow.getValue();
2321 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2322 const char *normalPtr = vpCache.getNormals(0);
2323 const unsigned int normalStride = vpCache.getNormalStride();
2324 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
2325 const char *texCoordPtr = vpCache.getTexCoords(0);
2326 const unsigned int texCoordStride = vpCache.getTexCoordStride();
2327 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
2328 const unsigned int texCoordRowStride = texCoordStride*
2329 verticesPerRow.getValue();
2330
2331 const int numRows = verticesPerColumn.getValue() - 1;
2332 const int nv = verticesPerRow.getValue();
2333
2334 int v;
2335 for (int row = 0; row < numRows; row++) {
2336 (*normalFunc)(normalPtr); normalPtr += normalStride;
2337
2338 //Do Strip rendering if both ~Fn and ~Fm
2339 glBegin(GL_TRIANGLE_STRIP);
2340 for (v = 0; v < nv; v++) {
2341
2342 (*colorFunc)(colorPtr);
2343 (*texCoordFunc)(texCoordPtr);
2344 (*vertexFunc)(vertexPtr);
2345
2346 (*colorFunc)(colorPtr+colorRowStride);
2347 colorPtr += colorStride;
2348 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
2349 texCoordPtr += texCoordStride;
2350 (*vertexFunc)(vertexPtr+vertexRowStride);
2351 vertexPtr += vertexStride;
2352 }
2353
2354 glEnd();
2355
2356 }
2357 }
2358
2359
2360 void
2361 SoQuadMesh::
2362 VmFn
2363 (SoGLRenderAction* ) {
2364
2365 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2366 const unsigned int vertexStride = vpCache.getVertexStride();
2367 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2368 const unsigned int vertexRowStride = vertexStride*
2369 verticesPerRow.getValue();
2370 const char *colorPtr = vpCache.getColors(startIndex.getValue());
2371 const unsigned int colorStride = vpCache.getColorStride();
2372 const unsigned int colorRowStride = colorStride*
2373 verticesPerRow.getValue();
2374 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2375 const char *normalPtr = vpCache.getNormals(0);
2376 const unsigned int normalStride = vpCache.getNormalStride();
2377 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
2378
2379 const int numRows = verticesPerColumn.getValue() - 1;
2380 const int nv = verticesPerRow.getValue() - 1;
2381
2382 int v;
2383 for (int row = 0; row < numRows; row++) {
2384 glBegin(GL_QUADS);
2385 for(v = 0; v < nv; v++) {
2386 (*normalFunc)(normalPtr); normalPtr += normalStride;
2387 (*colorFunc)(colorPtr);
2388 (*vertexFunc)(vertexPtr);
2389 (*colorFunc)(colorPtr+colorRowStride);
2390 (*vertexFunc)(vertexPtr+vertexRowStride);
2391 (*colorFunc)(colorPtr+colorStride+colorRowStride);
2392 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
2393 (*colorFunc)(colorPtr+colorStride);
2394 colorPtr += colorStride;
2395 (*vertexFunc)(vertexPtr+vertexStride);
2396 vertexPtr += vertexStride;
2397 }
2398 glEnd(); //GL_QUADS
2399 //At the end of a row skip over last vertex:
2400 vertexPtr += vertexStride;
2401 colorPtr += colorStride;
2402
2403
2404 //Do Strip rendering if both ~Fn and ~Fm
2405
2406 }
2407 }
2408
2409
2410 void
2411 SoQuadMesh::
2412 VmFnT
2413 (SoGLRenderAction* ) {
2414
2415 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2416 const unsigned int vertexStride = vpCache.getVertexStride();
2417 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2418 const unsigned int vertexRowStride = vertexStride*
2419 verticesPerRow.getValue();
2420 const char *colorPtr = vpCache.getColors(startIndex.getValue());
2421 const unsigned int colorStride = vpCache.getColorStride();
2422 const unsigned int colorRowStride = colorStride*
2423 verticesPerRow.getValue();
2424 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2425 const char *normalPtr = vpCache.getNormals(0);
2426 const unsigned int normalStride = vpCache.getNormalStride();
2427 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
2428 const char *texCoordPtr = vpCache.getTexCoords(0);
2429 const unsigned int texCoordStride = vpCache.getTexCoordStride();
2430 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
2431 const unsigned int texCoordRowStride = texCoordStride*
2432 verticesPerRow.getValue();
2433
2434 const int numRows = verticesPerColumn.getValue() - 1;
2435 const int nv = verticesPerRow.getValue() - 1;
2436
2437 int v;
2438 for (int row = 0; row < numRows; row++) {
2439 glBegin(GL_QUADS);
2440 for(v = 0; v < nv; v++) {
2441 (*normalFunc)(normalPtr); normalPtr += normalStride;
2442 (*colorFunc)(colorPtr);
2443 (*texCoordFunc)(texCoordPtr);
2444 (*vertexFunc)(vertexPtr);
2445 (*colorFunc)(colorPtr+colorRowStride);
2446 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
2447 (*vertexFunc)(vertexPtr+vertexRowStride);
2448 (*colorFunc)(colorPtr+colorStride+colorRowStride);
2449 (*texCoordFunc)(texCoordPtr+texCoordStride+texCoordRowStride);
2450 (*vertexFunc)(vertexPtr+vertexStride+vertexRowStride);
2451 (*colorFunc)(colorPtr+colorStride);
2452 colorPtr += colorStride;
2453 (*texCoordFunc)(texCoordPtr+texCoordStride);
2454 texCoordPtr += texCoordStride;
2455 (*vertexFunc)(vertexPtr+vertexStride);
2456 vertexPtr += vertexStride;
2457 }
2458 glEnd(); //GL_QUADS
2459 //At the end of a row skip over last vertex:
2460 vertexPtr += vertexStride;
2461 texCoordPtr += texCoordStride;
2462 colorPtr += colorStride;
2463
2464
2465 //Do Strip rendering if both ~Fn and ~Fm
2466
2467 }
2468 }
2469
2470
2471 void
2472 SoQuadMesh::
2473 VmVn
2474 (SoGLRenderAction* ) {
2475
2476 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2477 const unsigned int vertexStride = vpCache.getVertexStride();
2478 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2479 const unsigned int vertexRowStride = vertexStride*
2480 verticesPerRow.getValue();
2481 const char *colorPtr = vpCache.getColors(startIndex.getValue());
2482 const unsigned int colorStride = vpCache.getColorStride();
2483 const unsigned int colorRowStride = colorStride*
2484 verticesPerRow.getValue();
2485 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2486 const char *normalPtr = vpCache.getNormals(startIndex.getValue());
2487 const unsigned int normalStride = vpCache.getNormalStride();
2488 const unsigned int normalRowStride = normalStride*verticesPerRow.getValue();
2489 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
2490
2491 const int numRows = verticesPerColumn.getValue() - 1;
2492 const int nv = verticesPerRow.getValue();
2493
2494 int v;
2495 for (int row = 0; row < numRows; row++) {
2496
2497 //Do Strip rendering if both ~Fn and ~Fm
2498 glBegin(GL_TRIANGLE_STRIP);
2499 for (v = 0; v < nv; v++) {
2500
2501 (*colorFunc)(colorPtr);
2502 (*normalFunc)(normalPtr);
2503 (*vertexFunc)(vertexPtr);
2504
2505 (*colorFunc)(colorPtr+colorRowStride);
2506 colorPtr += colorStride;
2507 (*normalFunc)(normalPtr+normalRowStride);
2508 normalPtr += normalStride;
2509 (*vertexFunc)(vertexPtr+vertexRowStride);
2510 vertexPtr += vertexStride;
2511 }
2512
2513 glEnd();
2514
2515 }
2516 }
2517
2518
2519 void
2520 SoQuadMesh::
2521 VmVnT
2522 (SoGLRenderAction* ) {
2523
2524 const char *vertexPtr = vpCache.getVertices(startIndex.getValue());
2525 const unsigned int vertexStride = vpCache.getVertexStride();
2526 SoVPCacheFunc *const vertexFunc = vpCache.vertexFunc;
2527 const unsigned int vertexRowStride = vertexStride*
2528 verticesPerRow.getValue();
2529 const char *colorPtr = vpCache.getColors(startIndex.getValue());
2530 const unsigned int colorStride = vpCache.getColorStride();
2531 const unsigned int colorRowStride = colorStride*
2532 verticesPerRow.getValue();
2533 SoVPCacheFunc *const colorFunc = vpCache.colorFunc;
2534 const char *normalPtr = vpCache.getNormals(startIndex.getValue());
2535 const unsigned int normalStride = vpCache.getNormalStride();
2536 const unsigned int normalRowStride = normalStride*verticesPerRow.getValue();
2537 SoVPCacheFunc *const normalFunc = vpCache.normalFunc;
2538 const char *texCoordPtr = vpCache.getTexCoords(0);
2539 const unsigned int texCoordStride = vpCache.getTexCoordStride();
2540 SoVPCacheFunc *const texCoordFunc = vpCache.texCoordFunc;
2541 const unsigned int texCoordRowStride = texCoordStride*
2542 verticesPerRow.getValue();
2543
2544 const int numRows = verticesPerColumn.getValue() - 1;
2545 const int nv = verticesPerRow.getValue();
2546
2547 int v;
2548 for (int row = 0; row < numRows; row++) {
2549
2550 //Do Strip rendering if both ~Fn and ~Fm
2551 glBegin(GL_TRIANGLE_STRIP);
2552 for (v = 0; v < nv; v++) {
2553
2554 (*colorFunc)(colorPtr);
2555 (*normalFunc)(normalPtr);
2556 (*texCoordFunc)(texCoordPtr);
2557 (*vertexFunc)(vertexPtr);
2558
2559 (*colorFunc)(colorPtr+colorRowStride);
2560 colorPtr += colorStride;
2561 (*normalFunc)(normalPtr+normalRowStride);
2562 normalPtr += normalStride;
2563 (*texCoordFunc)(texCoordPtr+texCoordRowStride);
2564 texCoordPtr += texCoordStride;
2565 (*vertexFunc)(vertexPtr+vertexRowStride);
2566 vertexPtr += vertexStride;
2567 }
2568
2569 glEnd();
2570
2571 }
2572 }
2573
2574