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
00395 class SoBufferedShape : public SoShape
00396 {
00397 SO_NODE_HEADER( SoBufferedShape );
00398 SO_PIMPL_PUBLIC_HEADER(SoBufferedShape)
00399
00400
00401
00402 public:
00403
00407 enum Type
00408 {
00410 POINTS,
00411
00414 LINE_STRIP,
00415
00418 LINE_LOOP,
00419
00422 LINES,
00423
00426 TRIANGLE_STRIP,
00427
00430 TRIANGLE_FAN,
00431
00434 TRIANGLES,
00435
00438 QUAD_STRIP,
00439
00442 QUADS,
00443
00445 POLYGON
00446 };
00447
00452 enum Usage
00453 {
00457 STATIC,
00463 DYNAMIC
00464 };
00465
00469 SoBufferedShape();
00470
00487 SoSFEnum shapeUsage;
00488
00503 SoSFBool primitiveRestartEnabled;
00504
00511 SoSFInt32 primitiveRestartValue;
00512
00525 SoSFBool useNormalsGenerator;
00526
00531 SoSFEnum shapeType;
00532
00544 SoMFInt32 numVertices;
00545
00552 SoSFBufferObject vertexBuffer;
00553
00558 SoSFShort vertexComponentsCount;
00559
00564 SoSFEnum vertexComponentsType;
00565
00576 SoSFShort vertexStride;
00577
00582 SoSFInt32 vertexOffset;
00583
00590 SoSFBufferObject normalBuffer;
00591
00596 SoSFEnum normalComponentsType;
00597
00608 SoSFShort normalStride;
00609
00614 SoSFInt32 normalOffset;
00615
00622 SoSFBufferObject indexBuffer;
00623
00628 SoSFEnum indexType;
00629
00634 SoSFInt32 indexOffset;
00635
00642 SoSFBufferObject colorBuffer;
00643
00648 SoSFEnum colorComponentsType;
00649
00660 SoSFInt32 colorStride;
00661
00666 SoSFInt32 colorOffset;
00667
00672 SoSFInt32 colorComponentsCount;
00673
00680 SoMFBufferObject texCoordsBuffer;
00681
00686 SoMFEnum texCoordsComponentsType;
00687
00698 SoMFInt32 texCoordsStride;
00699
00704 SoMFInt32 texCoordsOffset;
00705
00710 SoMFInt32 texCoordsComponentsCount;
00711
00712 private:
00718 virtual void GLRender(SoGLRenderAction *action );
00719
00725 virtual void getBoundingBox( SoGetBoundingBoxAction *action );
00726
00730 virtual void computeBBox( SoAction *action, SbBox3f &box, SbVec3f ¢er );
00731
00735 virtual void computeBBox(SoAction *action, SbXfBox3d &box, SbVec3d ¢er);
00736
00742 virtual void rayPick(SoRayPickAction *action );
00743
00749 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action );
00750
00751
00752
00753 private:
00754
00756 static void initClass();
00757
00759 static void exitClass();
00760
00761 void notify( SoNotList* list );
00762
00763 int getNumPrim( SoState* state = NULL );
00764
00765
00766
00767 private:
00768
00770 virtual ~SoBufferedShape();
00771
00772 virtual SbBool shouldCheckShapeHints();
00773
00774 virtual SbBool shouldGLRender( SoGLRenderAction *action, SbBool isPointsOrLines = FALSE );
00775
00785 virtual SbBool isLightingUsable( const void* normalBufferPtr );
00786
00790 virtual SbBool isTransparent(SoState* state) const;
00791
00792 virtual void generatePrimitives( SoAction *action );
00793
00794
00800 virtual void GLRenderBoundingBox( SoGLRenderAction *action );
00801
00802
00803 virtual SoDetail* createTriangleDetail( SoRayPickAction *action,
00804 const SoPrimitiveVertex *v1,
00805 const SoPrimitiveVertex *v2,
00806 const SoPrimitiveVertex *v3,
00807 SoPickedPoint *pp );
00808
00809 virtual SoDetail* createLineSegmentDetail( SoRayPickAction *action,
00810 const SoPrimitiveVertex *v1,
00811 const SoPrimitiveVertex *v2,
00812 SoPickedPoint *pp );
00813
00814 virtual SoDetail* createPointDetail( SoRayPickAction *action,
00815 const SoPrimitiveVertex *v,
00816 SoPickedPoint *pp );
00817
00818
00819
00820
00821
00822
00823 private:
00825 void commonConstructor();
00826
00830 unsigned int computeSmallestBatchSize(const SoNodeList* vertexAttribsList, unsigned int numInstances);
00831
00832
00833
00834 bool arePointsNeededAsPrimitives( SoDrawStyleElement::Style drawStyle ) const;
00835
00836 template< class T > void computeBBoxTemplate_POINTS( SoAction *action, SbBox3f &box, SbVec3f ¢er );
00837
00838 template< class T > void computeBBoxTemplate( SoAction *action, SbBox3f &box, SbVec3f ¢er, const SbVec2d &psize );
00839
00840 template< class T > void computeBBoxTemplateSP( SoAction *action, SbBox3f &box, SbVec3f ¢er, const SbVec2d &psize );
00841
00842 template< class T, int MODE > void computeBBoxTemplate_( SoAction *, SbBox3f &box, SbVec3f ¢er, const SbVec2d &pSize );
00843
00844
00845 bool isRenderExtraDataNeededInCurrentContext() const;
00846
00847
00848 bool isRenderExtraDataNeededByGraphicCardInCurrentContext() const;
00849
00850
00851
00852 bool isRenderExtraDataNeededByShapeType() const;
00853
00854
00855
00856
00857
00858 static bool isRenderExtraDataNeededByGraphicCard( const SbString& graphicCardName );
00859 };
00860
00861
00862
00863 #endif // SOBUFFEREDSHAPE_H
00864
00865