00001
00002
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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef _SO_SHAPE_
00052 #define _SO_SHAPE_
00053
00054 #include <Inventor/SbBox.h>
00055 #include <Inventor/SbMatrix.h>
00056 #include <Inventor/nodes/SoNode.h>
00057 #include <Inventor/fields/SoSFBool.h>
00058 #include <Inventor/SbPImpl.h>
00059
00060 class SoDetail;
00061 class SbVec2s;
00062 class SoFaceDetail;
00063 class SoPickedPoint;
00064 class SoPrimitiveVertex;
00065 class SoState;
00066 class SoMFInt32;
00067 class PickedPointListImpl;
00068
00069 typedef SoPrimitiveVertex *jySoPrimitiveVertexPtr;
00070 typedef SoDetail *jySoDetailPtr;
00071
00072 SO_PIMPL_PUBLIC_DECLARATION(SoShape)
00073
00074
00075
00076
00077
00078
00079
00080
00082
00114 class SoShape : public SoNode
00115 {
00116 SO_NODE_ABSTRACT_HEADER(SoShape);
00117 SO_PIMPL_PUBLIC_HEADER(SoShape)
00118
00119 public:
00123 SoSFBool boundingBoxIgnoring;
00124
00128 virtual SbBool affectsState() const;
00129
00135 enum ShapeType {
00137 POINTS,
00139 LINES,
00141 POLYGONS,
00143 TEXT
00144 };
00145
00149 ShapeType getShapeType();
00150
00159 static SbBool isPrimitiveRestartAvailable(SoState* state = NULL);
00160
00161 private:
00162
00168 enum TriangleShape {
00169 TRIANGLE_STRIP,
00170 TRIANGLE_FAN,
00171 TRIANGLES,
00172 POLYGON,
00173 SEGMENT_STRIP,
00174 POINT_SET
00175 };
00176
00199 void beginShape( SoAction *action, TriangleShape shapeType,
00200 SoFaceDetail *faceDetail = NULL);
00201
00206 void shapeVertex(const SoPrimitiveVertex *v);
00207
00208
00209
00213 void endShape();
00214
00219 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00220
00225 virtual void GLRender(SoGLRenderAction *action);
00226
00232 virtual void rayPick(SoRayPickAction *action);
00233
00238 virtual void callback(SoCallbackAction *action);
00239
00246 static void getScreenSize(SoState *state, const SbBox3f &boundingBox, SbVec2s &rectSize);
00247
00256 static float getDecimatedComplexity(SoState *state, float complexity);
00257
00265 virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er) = 0;
00266
00283 virtual void computeBBox(SoAction *action, SbXfBox3d &box, SbVec3d ¢er)
00284 {
00285
00286 SbBox3f boxf;
00287 SbVec3f centerf;
00288 computeBBox(action, boxf, centerf);
00289
00290 box.setTransform(SbMatrixd::identity());
00291 box.makeEmpty();
00292 box.setBounds(SbVec3d(boxf.getMin().getValue()),SbVec3d(boxf.getMax().getValue()));
00293 center.setValue(centerf);
00294 }
00295
00301 inline virtual SbBool isBoundingBoxIgnoring() const
00302 { return boundingBoxIgnoring.getValue(); }
00303
00309 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
00310
00311
00312
00313
00314
00315 static SbBool getMultiTextureInfo(SoState *state, SbIntList &imageTextUnitList) ;
00316
00320 void setShapeType(SoShape::ShapeType st);
00321
00322
00323
00324
00325
00326
00327
00328 void invokeTriangleCallbacks(SoAction *action,
00329 const SoPrimitiveVertex *v1,
00330 const SoPrimitiveVertex *v2,
00331 const SoPrimitiveVertex *v3);
00332
00333 void invokeLineSegmentCallbacks(SoAction *action,
00334 const SoPrimitiveVertex *v1,
00335 const SoPrimitiveVertex *v2);
00336
00337 void invokePointCallbacks(SoAction *action,
00338 const SoPrimitiveVertex *v);
00339
00340
00341 private:
00342 static void initClass();
00343 static void exitClass();
00344
00345
00346 virtual void GLRenderP(SoGLRenderAction *action);
00347
00348 SB_THREAD_TLS_HEADER();
00349
00350
00351 SbBool m_forceDisableProjection;
00352
00353 void setForceDisableProjection( SbBool disable ){m_forceDisableProjection = disable;}
00354
00355 static bool isVertexArrayAvailable(SoState* state=NULL);
00356 static bool isMultiDrawArrayAvailable(SoState* state=NULL);
00357 static bool isVertexBufferAvailable(SoState* state=NULL);
00358
00359
00360 static int getPrimitiveRestartMode(SoState* state = NULL);
00361
00362 static int getMaxPrimitiveLoop();
00363
00364 static int getMinVertexNumForVA();
00365
00366 static int getMinVertexNumForVBO();
00367
00368 static int getMinVertexNumForVAVBONoCache();
00369
00370 static bool isDesindexingAllowed();
00371
00372 static bool isTrisStripAllowedForQuadMesh();
00373
00374 static SbBool isDetailDebugEnabled();
00375
00376 static bool isCreaseAngleFixSet();
00377
00378
00379
00380 void endShape( int wt, SoMFInt32* indexes );
00381
00382
00383
00384
00385 SbBool shouldPrimitiveCount(SoGetPrimitiveCountAction *action);
00386
00387 virtual int getNumVert(SoState *state = NULL ){ return getNumPrim( state ); }
00388
00389 virtual int getNumPrim( SoState *state = NULL );
00390
00391 private:
00392
00393 SoShape();
00394
00395 virtual SbBool checkShapeHints(SoGLRenderAction *action);
00396
00397 inline virtual void countPrim( SoState *state = NULL );
00398
00399 virtual SbBool checkTransparency(SoGLRenderAction *action, SbBool isPointsOrLines);
00400
00401 virtual SbBool isRenderingPointsOrLines(SoGLRenderAction *action);
00402
00403 virtual SbBool shouldRenderNow(SoGLRenderAction *action,SbBool &isPointsOrLines);
00404
00405
00406
00407
00408
00409
00410 virtual void generatePrimitives(SoAction *action) = 0;
00411
00412
00413
00414
00415 virtual SbBool shouldGLRender(SoGLRenderAction *action,
00416 SbBool isPointsOrLines = FALSE);
00417
00418
00419
00420
00421
00422
00423 SbBool shouldGLRenderCore(SoGLRenderAction *action,
00424 SbBool isPointsOrLines = FALSE,
00425 SbBool hasTessellationShader = FALSE);
00426
00427
00428
00429
00430 SbBool handleInvisibleOrBBox(SoGLRenderAction *action,
00431 SbBool isPointsOrLines = FALSE);
00432
00433
00434
00435 SbBool shouldRayPick(SoRayPickAction *action);
00436
00437
00438
00440
00441
00442
00443 void beginSolidShape(SoGLRenderAction *action);
00444 void endSolidShape(SoGLRenderAction *action);
00445
00446
00447
00448
00449
00450
00451
00452 void computeObjectSpaceRay(SoRayPickAction *action);
00453 void computeObjectSpaceRay(SoRayPickAction *action,
00454 const SbMatrix &matrix);
00455
00456
00457
00458
00459
00460
00461
00462
00463 virtual SoDetail *createTriangleDetail(SoRayPickAction *action,
00464 const SoPrimitiveVertex *v1,
00465 const SoPrimitiveVertex *v2,
00466 const SoPrimitiveVertex *v3,
00467 SoPickedPoint *pp);
00468 virtual SoDetail *createLineSegmentDetail(SoRayPickAction *action,
00469 const SoPrimitiveVertex *v1,
00470 const SoPrimitiveVertex *v2,
00471 SoPickedPoint *pp);
00472 virtual SoDetail *createPointDetail(SoRayPickAction *action,
00473 const SoPrimitiveVertex *v,
00474 SoPickedPoint *pp);
00475
00476
00477
00478 virtual ~SoShape();
00479
00480
00481
00482 virtual void GLRenderBoundingBox(SoGLRenderAction *action);
00483
00484
00485
00486 virtual void applyFullSceneAntialiasingFilter(SoState* state);
00487
00488
00489
00490 void setNeedToProjectCoord(bool isProjectCoordNeeded);
00491
00492 private:
00493
00494 static int s_keepReset;
00495 static int s_forceSend;
00496 static SbBool s_noClip;
00497
00498 private:
00499
00500
00501
00502 void rayPickBoundingBox(SoRayPickAction *action);
00503
00504 void commonConstructor();
00505 };
00506
00507 inline SbBool
00508 SoShape::checkShapeHints(SoGLRenderAction *)
00509 {
00510 return FALSE;
00511 }
00512
00513 void
00514 SoShape::countPrim( SoState* )
00515 {}
00516
00517 #endif
00518