00001 #ifndef COIN_SOSHAPE_H
00002 #define COIN_SOSHAPE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <Inventor/nodes/SoSubNode.h>
00028 #include <Inventor/SbMatrix.h>
00029 #include <Inventor/SbVec2s.h>
00030 #include <Inventor/SbBox3f.h>
00031
00032 class SoPrimitiveVertex;
00033 class SoDetail;
00034 class SoPickedPoint;
00035 class SoFaceDetail;
00036 class SoState;
00037 class SoTextureCoordinateElement;
00038 class SbVec2f;
00039 class SoMaterialBundle;
00040 class SoBoundingBoxCache;
00041
00042 class COIN_DLL_API SoShape : public SoNode {
00043 typedef SoNode inherited;
00044
00045 SO_NODE_ABSTRACT_HEADER(SoShape);
00046
00047 public:
00048 static void initClass(void);
00049
00050 enum TriangleShape {
00051 TRIANGLE_STRIP, TRIANGLE_FAN, TRIANGLES, POLYGON,
00052
00053 QUADS, QUAD_STRIP, POINTS, LINES, LINE_STRIP
00054 };
00055
00056 virtual SbBool affectsState(void) const;
00057 virtual void notify(SoNotList * nl);
00058
00059 virtual void getBoundingBox(SoGetBoundingBoxAction * action);
00060 virtual void GLRender(SoGLRenderAction * action);
00061 virtual void rayPick(SoRayPickAction * action);
00062 virtual void callback(SoCallbackAction * action);
00063 virtual void computeBBox(SoAction * action, SbBox3f & box,
00064 SbVec3f & center) = 0;
00065 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00066
00067 static void getScreenSize(SoState * const state, const SbBox3f & boundingbox,
00068 SbVec2s & rectsize);
00069 static float getDecimatedComplexity(SoState * state, float complexity);
00070 const SoBoundingBoxCache * getBoundingBoxCache(void) const;
00071
00072 protected:
00073 SoShape(void);
00074 virtual ~SoShape();
00075
00076 float getComplexityValue(SoAction * action);
00077 virtual void generatePrimitives(SoAction * action) = 0;
00078 virtual SbBool shouldGLRender(SoGLRenderAction * action);
00079 void beginSolidShape(SoGLRenderAction * action);
00080 void endSolidShape(SoGLRenderAction * action);
00081 void GLRenderBoundingBox(SoGLRenderAction * action);
00082 SbBool shouldPrimitiveCount(SoGetPrimitiveCountAction * action);
00083
00084 SbBool shouldRayPick(SoRayPickAction * const action);
00085 void computeObjectSpaceRay(SoRayPickAction * const action);
00086 void computeObjectSpaceRay(SoRayPickAction * const action,
00087 const SbMatrix & matrix);
00088 virtual SoDetail * createTriangleDetail(SoRayPickAction * action,
00089 const SoPrimitiveVertex * v1,
00090 const SoPrimitiveVertex * v2,
00091 const SoPrimitiveVertex * v3,
00092 SoPickedPoint * pp);
00093 virtual SoDetail * createLineSegmentDetail(SoRayPickAction * action,
00094 const SoPrimitiveVertex * v1,
00095 const SoPrimitiveVertex * v2,
00096 SoPickedPoint * pp);
00097 virtual SoDetail * createPointDetail(SoRayPickAction * action,
00098 const SoPrimitiveVertex * v,
00099 SoPickedPoint * pp);
00100
00101 void invokeTriangleCallbacks(SoAction * const action,
00102 const SoPrimitiveVertex * const v1,
00103 const SoPrimitiveVertex * const v2,
00104 const SoPrimitiveVertex * const v3);
00105 void invokeLineSegmentCallbacks(SoAction * const action,
00106 const SoPrimitiveVertex * const v1,
00107 const SoPrimitiveVertex * const v2);
00108 void invokePointCallbacks(SoAction * const action,
00109 const SoPrimitiveVertex * const v);
00110 void beginShape(SoAction * const action, const TriangleShape shapetype,
00111 SoDetail * const detail = NULL);
00112 void shapeVertex(const SoPrimitiveVertex * const v);
00113 void endShape(void);
00114
00115 void generateVertex(SoPrimitiveVertex * const pv,
00116 const SbVec3f & point,
00117 const SbBool useTexFunc,
00118 const SoTextureCoordinateElement * const tce,
00119 const float s,
00120 const float t,
00121 const SbVec3f & normal);
00122 void generateVertex(SoPrimitiveVertex * const pv,
00123 const SbVec3f & point,
00124 const SbBool useTexFunc,
00125 const SoTextureCoordinateElement * const tce,
00126 const float s,
00127 const float t,
00128 const float r,
00129 const SbVec3f & normal);
00130
00131 private:
00132 class SoShapeP * pimpl;
00133
00134 void getBBox(SoAction * action, SbBox3f & box, SbVec3f & center);
00135 void rayPickBoundingBox(SoRayPickAction * action);
00136 friend class soshape_primdata;
00137 friend class so_generate_prim_private;
00138 };
00139
00140 #endif // !COIN_SOSHAPE_H