Open Inventor Release 2025.2.0
 
Loading...
Searching...
No Matches
SoBufferedShape.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2025 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23#if !defined SOBUFFEREDSHAPE_H
24#define SOBUFFEREDSHAPE_H
25
26#include <Inventor/fields/SoSFEnum.h>
27#include <Inventor/fields/SoMFEnum.h>
28#include <Inventor/fields/SoSFInt32.h>
29#include <Inventor/fields/SoMFInt32.h>
30#include <Inventor/fields/SoSFShort.h>
31#include <Inventor/fields/SoSFBox3f.h>
32#include <Inventor/fields/SoSFBufferObject.h>
33#include <Inventor/fields/SoMFBufferObject.h>
34
35#include <Inventor/devices/SoCpuBufferObject.h>
36#include <Inventor/devices/SoGLBufferObject.h>
37
38#include <Inventor/nodes/SoShape.h>
39
40#include <Inventor/elements/SoDrawStyleElement.h>
41
42#include <Inventor/SbPImpl.h>
43
44
46class SoAction;
47
48SO_PIMPL_PUBLIC_DECLARATION(SoBufferedShape)
49
50
406class SoBufferedShape : public SoShape
407{
408 SO_NODE_HEADER( SoBufferedShape );
409 SO_PIMPL_PUBLIC_HEADER(SoBufferedShape)
410
411 // ----------------------- Public usage --------------------------------------
412
413public:
414
459
463 enum Usage
464 {
474 };
475
480
495
511
519
533
539
558
566
572
578
590
596
604
610
622
628
636
644
650
658
664
676
682
688
696
702
714
720
727
728private:
734 virtual void GLRender(SoGLRenderAction *action );
735
741 virtual void getBoundingBox( SoGetBoundingBoxAction *action );
742
746 virtual void computeBBox( SoAction *action, SbBox3f &box, SbVec3f &center );
747
751 virtual void computeBBox(SoAction *action, SbXfBox3d &box, SbVec3d &center);
752
758 virtual void rayPick(SoRayPickAction *action );
759
765 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action );
766
767// ----------------------- Private usage -------------------------------------
768// INTERNAL
769private:
770
772 static void initClass();
773
775 static void exitClass();
776
777 void notify( SoNotList* list );
778
779 int getNumPrim( SoState* state = NULL );
780
781 // ----------------------- Protected usage -------------------------------------
782
783private:
784
786 virtual ~SoBufferedShape();
787
788 virtual SbBool shouldCheckShapeHints();
789
790 virtual SbBool shouldGLRender( SoGLRenderAction *action, SbBool isPointsOrLines = FALSE );
791
801 virtual SbBool isLightingUsable( const void* normalBufferPtr );
802
806 virtual SbBool isTransparent(SoState* state) const;
807
808 virtual void generatePrimitives( SoAction *action );
809
810
816 virtual void GLRenderBoundingBox( SoGLRenderAction *action );
817
818 // Overrides standard method to create an SoFaceDetail instance
819 virtual SoDetail* createTriangleDetail( SoRayPickAction *action,
820 const SoPrimitiveVertex *v1,
821 const SoPrimitiveVertex *v2,
822 const SoPrimitiveVertex *v3,
823 SoPickedPoint *pp );
824
825 virtual SoDetail* createLineSegmentDetail( SoRayPickAction *action,
826 const SoPrimitiveVertex *v1,
827 const SoPrimitiveVertex *v2,
828 SoPickedPoint *pp );
829
830 virtual SoDetail* createPointDetail( SoRayPickAction *action,
831 const SoPrimitiveVertex *v,
832 SoPickedPoint *pp );
833
834 //Transforms the polygons into lines before rendering them.
835 //It can be used if :
836 //- shapeStyle = TRIANGLE, TRIANGLE_STRIP, TRIANGLE_FAN, TRIANGLES, QUAD_STRIP, QUADS or POLYGON
837 //- SoDrawStyle::style = LINES
838 // ----------------------- Private usage -------------------------------------
839private:
841 void commonConstructor();
842
846 unsigned int computeSmallestBatchSize(const SoNodeList* vertexAttribsList, unsigned int numInstances);
847
848 //In some cases primitives need to be transformed to POINTS to have a correct rendering
849 //with POINTS as drawStyle.
850 bool arePointsNeededAsPrimitives( SoDrawStyleElement::Style drawStyle ) const;
851
852 template< class T > void computeBBoxTemplate_POINTS( SoAction *action, SbBox3f &box, SbVec3f &center );
853
854 template< class T > void computeBBoxTemplate( SoAction *action, SbBox3f &box, SbVec3f &center, const SbVec2d &psize );
855
856 template< class T > void computeBBoxTemplateSP( SoAction *action, SbBox3f &box, SbVec3f &center, const SbVec2d &psize );
857
858 template< class T, int MODE > void computeBBoxTemplate_( SoAction *, SbBox3f &box, SbVec3f &center, const SbVec2d &pSize );
859
860 //A GL context must exist to use this method.
861 bool isRenderExtraDataNeededInCurrentContext() const;
862
863 //A GL context must exist to use this method.
864 bool isRenderExtraDataNeededByGraphicCardInCurrentContext() const;
865
866 //For some shapeType values, the render extra data process must be launched ( without considering
867 //OIV_SHAPES_PRIMITIVES_OPTIM ) in order to have a correct rendering with LINES as drawStyle.
868 bool isRenderExtraDataNeededByShapeType() const;
869
870 //Some graphic cards has bad performance when glPolygonMode is used to render the
871 //shape with LINES as draw style.
872 //
873 //Returns true if the polygons must be transformed in lines before rendering them.
874 static bool isRenderExtraDataNeededByGraphicCard( const SbString& graphicCardName );
875};
876
877//------------------------------------------------------------------------------
878
879#endif // SOBUFFEREDSHAPE_H
880
3D box class.
Definition SbBox.h:649
Class for smart character strings.
Definition SbString.h:202
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 2D vector class ...
Definition SbVec.h:314
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D vector class ...
Definition SbVec.h:1214
3D vector class.
Definition SbVec.h:932
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D box with an a...
Definition SbBox.h:1513
Abstract base class for all actions.
Definition SoAction.h:132
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Node to render g...
Usage
This enum is used to set the shapeUsage field.
@ STATIC
The shape is static, its buffers are never modified or modified infrequently.
@ DYNAMIC
The shape is dynamic, this will prevent some optimizations but it is recommended when the buffers are...
SoSFEnum shapeUsage
Defines the usage of the shape.
SoSFEnum colorComponentsType
SbDataType::DataType type for the color values.
SoSFEnum vertexComponentsType
SbDataType::DataType for vertices.
SoSFShort vertexComponentsCount
Number of components in each vertex.
SoMFEnum texCoordsComponentsType
SbDataType::DataType type for the texture coordinates.
SoMFInt32 numVertices
Total number of vertices/indices or number of vertices/indices to be used per primitive.
SoMFInt32 texCoordsComponentsCount
Number of components in each texture coordinate.
SoSFBufferObject normalBuffer
Buffer object that contains the (optional) normal vectors.
SoMFBufferObject texCoordsBuffer
Buffer objects that contains the (optional) texture coordinates.
SoSFEnum normalComponentsType
SbDataType::DataType type for the normal vectors.
Type
Type of shape that will be rendered.
@ POINTS
Draws each vertex as a single point.
@ QUAD_STRIP
Draws a strip of connected quadrilaterals.
@ TRIANGLE_STRIP
Draws a strip of connected triangles.
@ LINE_LOOP
Like LINE_STRIP, but an extra line segment is drawn connecting the last vertex to the first vertex.
@ TRIANGLES
Draws unconnected triangles.
@ TRIANGLE_FAN
Draws a fan of triangles.
@ QUADS
Draws unconnected quadrilaterals.
@ LINE_STRIP
Connects all the vertices to form a polyline.
@ LINES
Connects each pair of vertices with a line.
@ POLYGON
Draws a single polygon using all the vertices (in each primitive).
SoSFInt32 primitiveRestartValue
Index value for the primitive restart feature.
SoSFBufferObject vertexBuffer
Buffer object that contains the vertex data.
SoBufferedShape()
Default constructor.
SoSFBufferObject colorBuffer
Buffer object that contains the (optional) color values.
SoSFShort vertexStride
Stride in bytes between the first component of two consecutive vertices.
SoSFInt32 colorStride
Stride in bytes between the first component of two consecutive colors.
SoSFEnum shapeType
Shape type to render.
SoSFInt32 indexOffset
Offset in bytes to the first index in the buffer.
SoSFBool primitiveRestartEnabled
Enable/disable the primitive restart feature.
SoSFInt32 normalOffset
Offset in bytes to the first normal vector in the buffer.
SoSFInt32 vertexOffset
Offset in bytes to the first vertex within the buffer.
SoSFBufferObject indexBuffer
Buffer object that contains the (optional) indices.
SoSFInt32 colorComponentsCount
Number of components in each color value.
SoSFInt32 colorOffset
Offset in bytes to the first color value in the buffer.
SoSFShort normalStride
Stride in bytes between the first component of two consecutive normals.
SoMFInt32 texCoordsStride
Stride in bytes between the first component of two consecutive texture coordinates.
SoSFBool useNormalsGenerator
Indicates if the node should use the internal normal vector generator if no normals are defined.
SoSFEnum indexType
SbDataType::DataType type for the indices.
SoMFInt32 texCoordsOffset
Offset in bytes to the first texture coordinate in the buffer.
Base class for describing detail information about a shape node.
Definition SoDetail.h:99
Style
These are the available draw styles.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> OpenGL buffer ob...
Renders a scene graph using Open Inventor's Render Engine.
Computes bounding box of a scene.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Counts number of...
Multiple-value field containing any number of buffer objects.
Multiple-value field containing any number of enumerated type values.
Definition SoMFEnum.h:95
Multiple-value field containing any number of int32_t integers.
Definition SoMFInt32.h:88
friend class SoAction
Definition SoNode.h:472
Maintains a list of pointers to nodes.
Definition SoNodeList.h:74
Represents point on surface of picked object.
Represents a vertex of a generated primitive.
Intersects objects with a ray cast into scene.
Field containing a single Boolean value.
Definition SoSFBool.h:79
Field containing an enumerated value.
Definition SoSFEnum.h:89
Field containing a int32_t integer.
Definition SoSFInt32.h:80
Field containing a short integer.
Definition SoSFShort.h:81
Traversal state.
Definition SoState.h:74
int SbBool
Boolean type.
Definition SbBase.h:87