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 inline SbBool isRenderable(SoGLRenderAction* action)
00392 {
00393 return shouldGLRender(action, FALSE);
00394 }
00395
00396 private:
00397
00398 SoShape();
00399
00400 virtual SbBool checkShapeHints(SoGLRenderAction *action);
00401
00402 inline virtual void countPrim( SoState *state = NULL );
00403
00404 virtual SbBool checkTransparency(SoGLRenderAction *action, SbBool isPointsOrLines);
00405
00406 virtual SbBool isRenderingPointsOrLines(SoGLRenderAction *action);
00407
00408 virtual SbBool shouldRenderNow(SoGLRenderAction *action,SbBool &isPointsOrLines);
00409
00410
00411
00412
00413
00414
00415 virtual void generatePrimitives(SoAction *action) = 0;
00416
00417
00418
00419
00420 virtual SbBool shouldGLRender(SoGLRenderAction *action,
00421 SbBool isPointsOrLines = FALSE);
00422
00423
00424
00425
00426
00427
00428 SbBool shouldGLRenderCore(SoGLRenderAction *action,
00429 SbBool isPointsOrLines = FALSE,
00430 SbBool hasTessellationShader = FALSE);
00431
00432
00433
00434
00435 SbBool handleInvisibleOrBBox(SoGLRenderAction *action,
00436 SbBool isPointsOrLines = FALSE);
00437
00438
00439
00440 SbBool shouldRayPick(SoRayPickAction *action);
00441
00442
00443
00445
00446
00447
00448 void beginSolidShape(SoGLRenderAction *action);
00449 void endSolidShape(SoGLRenderAction *action);
00450
00451
00452
00453
00454
00455
00456
00457 void computeObjectSpaceRay(SoRayPickAction *action);
00458 void computeObjectSpaceRay(SoRayPickAction *action,
00459 const SbMatrix &matrix);
00460
00461
00462
00463
00464
00465
00466
00467
00468 virtual SoDetail *createTriangleDetail(SoRayPickAction *action,
00469 const SoPrimitiveVertex *v1,
00470 const SoPrimitiveVertex *v2,
00471 const SoPrimitiveVertex *v3,
00472 SoPickedPoint *pp);
00473 virtual SoDetail *createLineSegmentDetail(SoRayPickAction *action,
00474 const SoPrimitiveVertex *v1,
00475 const SoPrimitiveVertex *v2,
00476 SoPickedPoint *pp);
00477 virtual SoDetail *createPointDetail(SoRayPickAction *action,
00478 const SoPrimitiveVertex *v,
00479 SoPickedPoint *pp);
00480
00481
00482
00483 virtual ~SoShape();
00484
00485
00486
00487 virtual void GLRenderBoundingBox(SoGLRenderAction *action);
00488
00489
00490
00491 virtual void applyFullSceneAntialiasingFilter(SoState* state);
00492
00493
00494
00495 void setNeedToProjectCoord(bool isProjectCoordNeeded);
00496
00497 private:
00498
00499 static int s_keepReset;
00500 static int s_forceSend;
00501 static SbBool s_noClip;
00502
00503 private:
00504
00505
00506
00507 void rayPickBoundingBox(SoRayPickAction *action);
00508
00509 void commonConstructor();
00510 };
00511
00512 inline SbBool
00513 SoShape::checkShapeHints(SoGLRenderAction *)
00514 {
00515 return FALSE;
00516 }
00517
00518 void
00519 SoShape::countPrim( SoState* )
00520 {}
00521
00522 #endif
00523