00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined SOBUFFEREDSHAPE_H
00024 #define SOBUFFEREDSHAPE_H
00025
00026 #include <Inventor/fields/SoSFEnum.h>
00027 #include <Inventor/fields/SoMFEnum.h>
00028 #include <Inventor/fields/SoSFInt32.h>
00029 #include <Inventor/fields/SoMFInt32.h>
00030 #include <Inventor/fields/SoSFShort.h>
00031 #include <Inventor/fields/SoSFBox3f.h>
00032 #include <Inventor/fields/SoSFBufferObject.h>
00033 #include <Inventor/fields/SoMFBufferObject.h>
00034
00035 #include <Inventor/devices/SoCpuBufferObject.h>
00036 #include <Inventor/devices/SoGLBufferObject.h>
00037
00038 #include <Inventor/nodes/SoShape.h>
00039
00040 #include <Inventor/elements/SoDrawStyleElement.h>
00041
00042 #include <Inventor/SbPImpl.h>
00043
00044
00045 class SoGLBufferObject;
00046 class SoAction;
00047
00048 SO_PIMPL_PUBLIC_DECLARATION(SoBufferedShape)
00049
00050
00401 class SoBufferedShape : public SoShape
00402 {
00403 SO_NODE_HEADER( SoBufferedShape );
00404 SO_PIMPL_PUBLIC_HEADER(SoBufferedShape)
00405
00406
00407
00408 public:
00409
00413 enum Type
00414 {
00416 POINTS,
00417
00420 LINE_STRIP,
00421
00424 LINE_LOOP,
00425
00429 LINES,
00430
00433 TRIANGLE_STRIP,
00434
00437 TRIANGLE_FAN,
00438
00441 TRIANGLES,
00442
00445 QUAD_STRIP,
00446
00449 QUADS,
00450
00452 POLYGON
00453 };
00454
00458 enum Usage
00459 {
00463 STATIC,
00468 DYNAMIC
00469 };
00470
00474 SoBufferedShape();
00475
00489 SoSFEnum shapeUsage;
00490
00505 SoSFBool primitiveRestartEnabled;
00506
00513 SoSFInt32 primitiveRestartValue;
00514
00527 SoSFBool useNormalsGenerator;
00528
00533 SoSFEnum shapeType;
00534
00552 SoMFInt32 numVertices;
00553
00560 SoSFBufferObject vertexBuffer;
00561
00566 SoSFShort vertexComponentsCount;
00567
00572 SoSFEnum vertexComponentsType;
00573
00584 SoSFShort vertexStride;
00585
00590 SoSFInt32 vertexOffset;
00591
00598 SoSFBufferObject normalBuffer;
00599
00604 SoSFEnum normalComponentsType;
00605
00616 SoSFShort normalStride;
00617
00622 SoSFInt32 normalOffset;
00623
00630 SoSFBufferObject indexBuffer;
00631
00638 SoSFEnum indexType;
00639
00644 SoSFInt32 indexOffset;
00645
00652 SoSFBufferObject colorBuffer;
00653
00658 SoSFEnum colorComponentsType;
00659
00670 SoSFInt32 colorStride;
00671
00676 SoSFInt32 colorOffset;
00677
00682 SoSFInt32 colorComponentsCount;
00683
00690 SoMFBufferObject texCoordsBuffer;
00691
00696 SoMFEnum texCoordsComponentsType;
00697
00708 SoMFInt32 texCoordsStride;
00709
00714 SoMFInt32 texCoordsOffset;
00715
00720 SoMFInt32 texCoordsComponentsCount;
00721
00722 private:
00728 virtual void GLRender(SoGLRenderAction *action );
00729
00735 virtual void getBoundingBox( SoGetBoundingBoxAction *action );
00736
00740 virtual void computeBBox( SoAction *action, SbBox3f &box, SbVec3f ¢er );
00741
00745 virtual void computeBBox(SoAction *action, SbXfBox3d &box, SbVec3d ¢er);
00746
00752 virtual void rayPick(SoRayPickAction *action );
00753
00759 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action );
00760
00761
00762
00763 private:
00764
00766 static void initClass();
00767
00769 static void exitClass();
00770
00771 void notify( SoNotList* list );
00772
00773 int getNumPrim( SoState* state = NULL );
00774
00775
00776
00777 private:
00778
00780 virtual ~SoBufferedShape();
00781
00782 virtual SbBool shouldCheckShapeHints();
00783
00784 virtual SbBool shouldGLRender( SoGLRenderAction *action, SbBool isPointsOrLines = FALSE );
00785
00795 virtual SbBool isLightingUsable( const void* normalBufferPtr );
00796
00800 virtual SbBool isTransparent(SoState* state) const;
00801
00802 virtual void generatePrimitives( SoAction *action );
00803
00804
00810 virtual void GLRenderBoundingBox( SoGLRenderAction *action );
00811
00812
00813 virtual SoDetail* createTriangleDetail( SoRayPickAction *action,
00814 const SoPrimitiveVertex *v1,
00815 const SoPrimitiveVertex *v2,
00816 const SoPrimitiveVertex *v3,
00817 SoPickedPoint *pp );
00818
00819 virtual SoDetail* createLineSegmentDetail( SoRayPickAction *action,
00820 const SoPrimitiveVertex *v1,
00821 const SoPrimitiveVertex *v2,
00822 SoPickedPoint *pp );
00823
00824 virtual SoDetail* createPointDetail( SoRayPickAction *action,
00825 const SoPrimitiveVertex *v,
00826 SoPickedPoint *pp );
00827
00828
00829
00830
00831
00832
00833 private:
00835 void commonConstructor();
00836
00840 unsigned int computeSmallestBatchSize(const SoNodeList* vertexAttribsList, unsigned int numInstances);
00841
00842
00843
00844 bool arePointsNeededAsPrimitives( SoDrawStyleElement::Style drawStyle ) const;
00845
00846 template< class T > void computeBBoxTemplate_POINTS( SoAction *action, SbBox3f &box, SbVec3f ¢er );
00847
00848 template< class T > void computeBBoxTemplate( SoAction *action, SbBox3f &box, SbVec3f ¢er, const SbVec2d &psize );
00849
00850 template< class T > void computeBBoxTemplateSP( SoAction *action, SbBox3f &box, SbVec3f ¢er, const SbVec2d &psize );
00851
00852 template< class T, int MODE > void computeBBoxTemplate_( SoAction *, SbBox3f &box, SbVec3f ¢er, const SbVec2d &pSize );
00853
00854
00855 bool isRenderExtraDataNeededInCurrentContext() const;
00856
00857
00858 bool isRenderExtraDataNeededByGraphicCardInCurrentContext() const;
00859
00860
00861
00862 bool isRenderExtraDataNeededByShapeType() const;
00863
00864
00865
00866
00867
00868 static bool isRenderExtraDataNeededByGraphicCard( const SbString& graphicCardName );
00869 };
00870
00871
00872
00873 #endif // SOBUFFEREDSHAPE_H
00874
00875