Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoVertexShape.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_VERTEX_SHAPE_
51#define _SO_VERTEX_SHAPE_
52
59#include <Inventor/STL/map>
60#include <Inventor/SbPImpl.h>
62
64//
65// Class: SoVertexShape
66//
67// Abstract vertex-based shape node class. All nodes derived from
68// this class are shapes that are constructed from vertices at some
69// or all of the current coordinates. They all have vertexProperty nodes,
70// and vpCaches.
71//
73
75class SoNormalBundle;
76class SoNormalCache;
77class SoTangentBundle;
78class SoTangentCache;
80class SoState;
83class SiCoordinateGetter;
84
86
87class SoVertexAttribData;
88
89#ifdef _MSC_VER
90#pragma warning( push )
91#pragma warning(disable:4251)
92#endif
93
309class SoVertexShape : public SoShape {
310
312 SO_PIMPL_PUBLIC_HEADER(SoVertexShape)
313
314 public:
320
326 SoNormalCache *getNormalCache() const;
327
333 SoTangentCache* getTangentCache() const;
334
335 private:
336
337 // Subclasses may define this method to generate normals to use
338 // when the normal binding is DEFAULT and there aren't enough
339 // normals in the state. This should use the given SoNormalBundle
340 // to generate the normals. Returns TRUE if normals were generated.
341 virtual void generateDefaultNormals(SoState *state,
342 const SbVec3f *coords,
343 int numCoords,
344 SoNormalBundle *nb,
345 SbBool storeRef = FALSE);
346
347 //Common function for normal generation
348 void commonGenerateDefaultNormals(SoState *state, SoNormalBundle *nb);
349
350 virtual SbBool figureNormals(SoState *state, SoNormalBundle *nb);
351
358 virtual void generateDefaultTangents( SoState* state,
359 const SbVec3f* coords,
360 int numCoords,
361 SoTangentBundle* tb,
362 SbBool storeRef = FALSE );
363
364 // Common function for tangent generation
365 void commonGenerateDefaultTangents( SoState* state, SoTangentBundle* tb );
366
367 virtual SbBool figureTangents( SoState* state, SoTangentBundle* tb );
368
369 virtual void write(SoWriteAction *writeAction);
370
371 // Implements actions
372 virtual void GLRender(SoGLRenderAction *action);
373
374 private:
375 static void initClass();
376 static void exitClass();
377
378 // Redefines this to invalidate normal cache
379 virtual void notify(SoNotList *list);
380
381 const SiCoordinateGetter* getCoordinateGetter(const SoState* state, bool ignoreProjectionElementDepth = false);
382
383 private:
384 // Constructor - makes this abstract
386
387 virtual ~SoVertexShape();
388
389 // Returns TRUE if the shape should be rendered.
390 // Checks for transparency in vertexProperty node before invoking
391 // render action.
392 virtual SbBool shouldGLRender(SoGLRenderAction *action,
393 SbBool isPointsOrLines = FALSE);
394
395
396
397 //Free memory
398 virtual void exitRender(SoState *state,int stateFlag,
401
402 //------------------ Following result of glRender() factorization GT (Sep 2007)
403
404 // sometimes used in shapes
405 virtual void setupRenderFunctions(SoState *state,int &stateFlag);
406
407 virtual void callSetupIndices(SoState* state, const SoShapeStyleElement* shapeStyle,uint32_t useTexCoordsAnyway);
408
409 // check texture coordinates generation
410 virtual void shouldGenerateTextureCoordinates(SoGLRenderAction *action,
411 int &stateFlag,
412 SoShapeStyleElement *&shapeStyle,
413 uint32_t &useTexCoordsAnyway,
416
417 // check texture 3D coordinates generation
418 virtual SbBool shouldGenerateTexture3DCoordinates(){return FALSE;}
419
420 // check auto caching
421 virtual void checkAutoCaching(SoGLRenderAction* action, const SoShapeStyleElement* shapeStyle, SbBool settingVPCache);
422
423 // check 3D tex coords
424 virtual SbBool checkTex3Coords(){return FALSE;}
425
426 // actual rendering
427 virtual void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle);
428
429 // rendering
430 virtual void render(SoGLRenderAction *action,SbBool isPointsOrLines);
431
432 // check normal generation
433 virtual void shouldGenerateNormals(SoGLRenderAction *action,const SoShapeStyleElement *shapeStyle);
434
435 // check tangent generation
436 virtual void shouldGenerateTangents( SoGLRenderAction* action, const SoShapeStyleElement* shapeStyle );
437
438 //Whether to check or not shapeHints
439 virtual SbBool shouldCheckShapeHints(){ return FALSE;}
440
441 virtual SbBool shapeHintsTest( SoState *state = NULL );
442
443 // check shape hints
444 virtual SbBool checkShapeHints(SoGLRenderAction *action);
445
446 // setup lazy element
447 virtual void setupLazyElement(SoGLRenderAction *action,const SoShapeStyleElement *shapeStyle);
448
449 // check shape style
450 virtual void checkShapeStyle(SoState *state,const SoShapeStyleElement *shapeStyle);
451
452 // Internal routines used to allocate sequential indices so the
453 // same rendering loops can be used for indexed or non-indexed
454 // cases:
455 static int32_t* allocateSequential(const int howMany);
456 static int32_t* getConsecutiveIndices();
457
458 virtual bool hasGeneratePrimitiveCache()
459 {
460 return false;
461 }
462
463private:
464 void commonConstructor();
465
466 void setupColorMaterial(SoState* state);
467};
468
469inline void
470SoVertexShape::generateDefaultNormals(SoState *, const SbVec3f *, int , SoNormalBundle *, SbBool )
471{}
472
473inline void
474SoVertexShape::generateDefaultTangents( SoState*, const SbVec3f*, int, SoTangentBundle*, SbBool )
475{}
476
477inline void
478SoVertexShape::setupRenderFunctions(SoState *,int &)
479{}
480
481inline void
482SoVertexShape::callSetupIndices(SoState*, const SoShapeStyleElement* ,uint32_t )
483{}
484
485inline void
486SoVertexShape::doRendering(SoGLRenderAction *, const SoShapeStyleElement* )
487{}
488
489
490#ifdef _MSC_VER
491#pragma warning( pop )
492#endif
493
494#endif /* _SO_VERTEX_SHAPE_ */
495
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
SO_PIMPL_PUBLIC_DECLARATION(SoFileDataAdapter)
#define SO_NODE_ABSTRACT_HEADER(className)
Definition SoSubNode.h:118
SoTextureCoordinate3Bundle(SoAction *action, SbBool forRendering, SbBool setUpDefault, SbBool forMesh)
SoTextureCoordinateBundle(SoAction *action, SbBool forRendering, SbBool setUpDefault, SbBool forMesh, const SbIntList *texUnits=NULL)
3D vector class.
Definition SbVec.h:932
Renders a scene graph using Open Inventor's Render Engine.
Field containing a a node.
Definition SoSFNode.h:97
Abstract base class for all shape nodes.
Definition SoShape.h:115
Stores some information used by shapes.
Traversal state.
Definition SoState.h:74
Abstract base class for all vertex-based shape nodes.
SoSFNode vertexProperty
vertex property node.
SoTangentCache * getTangentCache() const
Returns the current tangent cache, or NULL if there is none.
SoNormalCache * getNormalCache() const
Returns the current normal cache, or NULL if there is none.
Writes a scene graph to a file.
int SbBool
Boolean type.
Definition SbBase.h:87