![]() |
http://www.sim.no http://www.coin3d.org |
00001 #ifndef COIN_SOSHAPE_H 00002 #define COIN_SOSHAPE_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Systems in Motion about acquiring 00018 * a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 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 SoCoordinateElement; 00039 class SbVec2f; 00040 class SoMaterialBundle; 00041 class SoBoundingBoxCache; 00042 00043 class COIN_DLL_API SoShape : public SoNode { 00044 typedef SoNode inherited; 00045 00046 SO_NODE_ABSTRACT_HEADER(SoShape); 00047 00048 public: 00049 static void initClass(void); 00050 00051 enum TriangleShape { 00052 TRIANGLE_STRIP, TRIANGLE_FAN, TRIANGLES, POLYGON, 00053 // The rest of the enums are not part of the original Inventor API. 00054 QUADS, QUAD_STRIP, POINTS, LINES, LINE_STRIP 00055 }; 00056 00057 virtual SbBool affectsState(void) const; 00058 virtual void notify(SoNotList * nl); 00059 00060 virtual void getBoundingBox(SoGetBoundingBoxAction * action); 00061 virtual void GLRender(SoGLRenderAction * action); 00062 virtual void rayPick(SoRayPickAction * action); 00063 virtual void callback(SoCallbackAction * action); 00064 virtual void computeBBox(SoAction * action, SbBox3f & box, 00065 SbVec3f & center) = 0; 00066 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action); 00067 00068 static void getScreenSize(SoState * const state, const SbBox3f & boundingbox, 00069 SbVec2s & rectsize); 00070 static float getDecimatedComplexity(SoState * state, float complexity); 00071 const SoBoundingBoxCache * getBoundingBoxCache(void) const; 00072 00073 protected: 00074 SoShape(void); 00075 virtual ~SoShape(); 00076 00077 float getComplexityValue(SoAction * action); 00078 virtual void generatePrimitives(SoAction * action) = 0; 00079 virtual SbBool shouldGLRender(SoGLRenderAction * action); 00080 void beginSolidShape(SoGLRenderAction * action); 00081 void endSolidShape(SoGLRenderAction * action); 00082 void GLRenderBoundingBox(SoGLRenderAction * action); 00083 SbBool shouldPrimitiveCount(SoGetPrimitiveCountAction * action); 00084 00085 SbBool shouldRayPick(SoRayPickAction * const action); 00086 void computeObjectSpaceRay(SoRayPickAction * const action); 00087 void computeObjectSpaceRay(SoRayPickAction * const action, 00088 const SbMatrix & matrix); 00089 virtual SoDetail * createTriangleDetail(SoRayPickAction * action, 00090 const SoPrimitiveVertex * v1, 00091 const SoPrimitiveVertex * v2, 00092 const SoPrimitiveVertex * v3, 00093 SoPickedPoint * pp); 00094 virtual SoDetail * createLineSegmentDetail(SoRayPickAction * action, 00095 const SoPrimitiveVertex * v1, 00096 const SoPrimitiveVertex * v2, 00097 SoPickedPoint * pp); 00098 virtual SoDetail * createPointDetail(SoRayPickAction * action, 00099 const SoPrimitiveVertex * v, 00100 SoPickedPoint * pp); 00101 00102 void invokeTriangleCallbacks(SoAction * const action, 00103 const SoPrimitiveVertex * const v1, 00104 const SoPrimitiveVertex * const v2, 00105 const SoPrimitiveVertex * const v3); 00106 void invokeLineSegmentCallbacks(SoAction * const action, 00107 const SoPrimitiveVertex * const v1, 00108 const SoPrimitiveVertex * const v2); 00109 void invokePointCallbacks(SoAction * const action, 00110 const SoPrimitiveVertex * const v); 00111 void beginShape(SoAction * const action, const TriangleShape shapetype, 00112 SoDetail * const detail = NULL); 00113 void shapeVertex(const SoPrimitiveVertex * const v); 00114 void endShape(void); 00115 00116 void generateVertex(SoPrimitiveVertex * const pv, 00117 const SbVec3f & point, 00118 const SbBool useTexFunc, 00119 const SoTextureCoordinateElement * const tce, 00120 const float s, 00121 const float t, 00122 const SbVec3f & normal); 00123 void generateVertex(SoPrimitiveVertex * const pv, 00124 const SbVec3f & point, 00125 const SbBool useTexFunc, 00126 const SoTextureCoordinateElement * const tce, 00127 const float s, 00128 const float t, 00129 const float r, 00130 const SbVec3f & normal); 00131 00132 SbBool startVertexArray(SoGLRenderAction * action, 00133 const SoCoordinateElement * coords, 00134 const SbVec3f * pervertexnormals, 00135 const SbBool texpervertex, 00136 const SbBool colorpervertex); 00137 00138 void finishVertexArray(SoGLRenderAction * action, 00139 const SbBool vbo, 00140 const SbBool normpervertex, 00141 const SbBool texpervertex, 00142 const SbBool colorpervertex); 00143 private: 00144 class SoShapeP * pimpl; 00145 00146 void getBBox(SoAction * action, SbBox3f & box, SbVec3f & center); 00147 void rayPickBoundingBox(SoRayPickAction * action); 00148 friend class soshape_primdata; // internal class 00149 friend class so_generate_prim_private; // a very private class 00150 }; 00151 00152 #endif // !COIN_SOSHAPE_H
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 23 16:33:32 2009 for Coin by Doxygen. 1.5.8