Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoVertexShape.h
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-2024 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
53#include <Inventor/nodes/SoShape.h>
54#include <Inventor/nodes/SoVertexProperty.h>
55#include <Inventor/fields/SoSFNode.h>
56#include <Inventor/threads/SbThreadSpinlock.h>
57#include <Inventor/elements/SoNormalBindingElement.h>
58#include <Inventor/elements/SoTangentBindingElement.h>
59#include <Inventor/STL/map>
60#include <Inventor/SbPImpl.h>
61#include <Inventor/nodes/SoVertexShader.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;
81class SoTextureCoordinateBundle;
82class SoTextureCoordinate3Bundle;
83class SiCoordinateGetter;
84
85SO_PIMPL_PUBLIC_DECLARATION( SoVertexShape )
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
311 SO_NODE_ABSTRACT_HEADER(SoVertexShape);
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
370 uint32_t m_vpVertexTimeStamp;
371
372 virtual void write(SoWriteAction *writeAction);
373
374 // Implements actions
375 virtual void GLRender(SoGLRenderAction *action);
376
377 private:
378 static void initClass();
379 static void exitClass();
380
381 // Redefines this to invalidate normal cache
382 virtual void notify(SoNotList *list);
383
384 const SiCoordinateGetter* getCoordinateGetter(const SoState* state, bool ignoreProjectionElementDepth = false);
385
386 private:
387 // Constructor - makes this abstract
389
390 virtual ~SoVertexShape();
391
392 // Returns TRUE if the shape should be rendered.
393 // Checks for transparency in vertexProperty node before invoking
394 // render action.
395 virtual SbBool shouldGLRender(SoGLRenderAction *action,
396 SbBool isPointsOrLines = FALSE);
397
398
399
400 //Free memory
401 virtual void exitRender(SoState *state,int stateFlag,
402 SoTextureCoordinateBundle *tcb,
403 SoTextureCoordinate3Bundle *tc3b);
404
405 //------------------ Following result of glRender() factorization GT (Sep 2007)
406
407 // sometimes used in shapes
408 virtual void setupRenderFunctions(SoState *state,int &stateFlag);
409
410 virtual void callSetupIndices(SoState* state, const SoShapeStyleElement* shapeStyle,uint32_t useTexCoordsAnyway);
411
412 // check texture coordinates generation
413 virtual void shouldGenerateTextureCoordinates(SoGLRenderAction *action,
414 int &stateFlag,
415 SoShapeStyleElement *&shapeStyle,
416 uint32_t &useTexCoordsAnyway,
417 SoTextureCoordinateBundle *&tcb,
418 SoTextureCoordinate3Bundle *&tc3b);
419
420 // check texture 3D coordinates generation
421 virtual SbBool shouldGenerateTexture3DCoordinates(){return FALSE;}
422
423 // check auto caching
424 virtual void checkAutoCaching(SoGLRenderAction* action, const SoShapeStyleElement* shapeStyle, SbBool settingVPCache);
425
426 // check 3D tex coords
427 virtual SbBool checkTex3Coords(){return FALSE;}
428
429 // actual rendering
430 virtual void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle);
431
432 // rendering
433 virtual void render(SoGLRenderAction *action,SbBool isPointsOrLines);
434
435 // check normal generation
436 virtual void shouldGenerateNormals(SoGLRenderAction *action,const SoShapeStyleElement *shapeStyle);
437
438 // check tangent generation
439 virtual void shouldGenerateTangents( SoGLRenderAction* action, const SoShapeStyleElement* shapeStyle );
440
441 //Whether to check or not shapeHints
442 virtual SbBool shouldCheckShapeHints(){ return FALSE;}
443
444 virtual SbBool shapeHintsTest( SoState *state = NULL );
445
446 // check shape hints
447 virtual SbBool checkShapeHints(SoGLRenderAction *action);
448
449 // setup lazy element
450 virtual void setupLazyElement(SoGLRenderAction *action,const SoShapeStyleElement *shapeStyle);
451
452 // check shape style
453 virtual void checkShapeStyle(SoState *state,const SoShapeStyleElement *shapeStyle);
454
455 // Internal routines used to allocate sequential indices so the
456 // same rendering loops can be used for indexed or non-indexed
457 // cases:
458 static int32_t* allocateSequential(const int howMany);
459 static int32_t* getConsecutiveIndices();
460
461 virtual bool hasGeneratePrimitiveCache()
462 {
463 return false;
464 }
465
466private:
467 void commonConstructor();
468
469 void setupColorMaterial(SoState* state);
470};
471
472inline void
473SoVertexShape::generateDefaultNormals(SoState *, const SbVec3f *, int , SoNormalBundle *, SbBool )
474{}
475
476inline void
477SoVertexShape::generateDefaultTangents( SoState*, const SbVec3f*, int, SoTangentBundle*, SbBool )
478{}
479
480inline void
481SoVertexShape::setupRenderFunctions(SoState *,int &)
482{}
483
484inline void
485SoVertexShape::callSetupIndices(SoState*, const SoShapeStyleElement* ,uint32_t )
486{}
487
488inline void
489SoVertexShape::doRendering(SoGLRenderAction *, const SoShapeStyleElement* )
490{}
491
492
493#ifdef _MSC_VER
494#pragma warning( pop )
495#endif
496
497#endif /* _SO_VERTEX_SHAPE_ */
498
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:116
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