00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * This library is free software; you can redistribute it and/or modify it * 00016 * under the terms of the GNU Library General Public License as published * 00017 * by the Free Software Foundation, version 2. * 00018 * * 00019 * This library is distributed in the hope that it will be useful, but * 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this library; if not, write to the Free Software * 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00027 * * 00028 \*---------------------------------------------------------------------------*/ 00029 /*---------------------------------------------------------------------------*\ 00030 * Changes * 00031 * * 00032 * * 00033 * * 00034 * * 00035 * * 00036 * * 00037 \*---------------------------------------------------------------------------*/ 00038 00039 00040 #ifndef _OSGGEOMETRY_H_ 00041 #define _OSGGEOMETRY_H_ 00042 #ifdef __sgi 00043 #pragma once 00044 #endif 00045 00046 #include <OSGConfig.h> 00047 #include <OSGAction.h> 00048 #include <OSGWindow.h> 00049 00050 #include <OSGGeometryBase.h> 00051 #include <OSGGeoPropPtrs.h> 00052 #include <OSGMaterial.h> 00053 00054 #include <OSGActorBase.h> 00055 00056 00057 OSG_BEGIN_NAMESPACE 00058 00059 class DrawActionBase; 00060 00061 class TriangleIterator; 00062 class PrimitiveIterator; 00063 class FaceIterator; 00064 class LineIterator; 00065 class EdgeIterator; 00066 class GeoVBO; 00067 00070 class OSG_SYSTEMLIB_DLLMAPPING Geometry : public GeometryBase 00071 { 00072 /*========================== PUBLIC =================================*/ 00073 public: 00074 00075 /*---------------------------------------------------------------------*/ 00079 static const UInt16 MapPosition; 00080 static const UInt16 MapNormal; 00081 static const UInt16 MapColor; 00082 static const UInt16 MapSecondaryColor; 00083 static const UInt16 MapTexCoords; 00084 static const UInt16 MapTexCoords1; 00085 static const UInt16 MapTexCoords2; 00086 static const UInt16 MapTexCoords3; 00087 static const UInt16 MapTexCoords4; 00088 static const UInt16 MapTexCoords5; 00089 static const UInt16 MapTexCoords6; 00090 static const UInt16 MapTexCoords7; 00091 static const UInt16 MapEmpty; 00092 00094 /*---------------------------------------------------------------------*/ 00098 static const char *getClassname(void) { return "Geometry"; }; 00099 00101 /*---------------------------------------------------------------------*/ 00105 static const char *mapType (UInt8 type); 00106 00107 Int16 calcMappingIndex (UInt16 attrib) const; 00108 00109 virtual void changed (BitVector whichField, 00110 UInt32 origin ); 00111 00112 GeometryPtr getPtr (void) const; 00113 00114 GeometryPtr clone (void); 00115 00116 virtual void dump ( UInt32 uiIndent = 0, 00117 const BitVector bvFlags = 0) const; 00118 00119 bool isMergeable (const GeometryPtr other); 00120 00121 bool merge (const GeometryPtr other); 00122 00123 UInt32 getCachedGfxMemoryUsage(void); 00124 00126 /*---------------------------------------------------------------------*/ 00130 #ifndef OSG_SUPPORT_NO_GEO_INTERFACE 00131 virtual GeoPropertyArrayInterface *getProperty(Int32 mapID); 00132 #endif 00133 00134 00136 /*---------------------------------------------------------------------*/ 00140 void setTypes (const GeoPTypesPtr &value); 00141 void setLengths (const GeoPLengthsPtr &value); 00142 void setPositions (const GeoPositionsPtr &value); 00143 void setNormals (const GeoNormalsPtr &value); 00144 void setColors (const GeoColorsPtr &value); 00145 void setSecondaryColors(const GeoColorsPtr &value); 00146 void setTexCoords (const GeoTexCoordsPtr &value); 00147 void setTexCoords1 (const GeoTexCoordsPtr &value); 00148 void setTexCoords2 (const GeoTexCoordsPtr &value); 00149 void setTexCoords3 (const GeoTexCoordsPtr &value); 00150 void setTexCoords4 (const GeoTexCoordsPtr &value); 00151 void setTexCoords5 (const GeoTexCoordsPtr &value); 00152 void setTexCoords6 (const GeoTexCoordsPtr &value); 00153 void setTexCoords7 (const GeoTexCoordsPtr &value); 00154 void setIndices (const GeoIndicesPtr &value); 00155 void setMaterial (const MaterialPtr &value); 00156 00158 /*---------------------------------------------------------------------*/ 00162 TriangleIterator beginTriangles (void) const; 00163 TriangleIterator endTriangles (void) const; 00164 00165 PrimitiveIterator beginPrimitives (void) const; 00166 PrimitiveIterator endPrimitives (void) const; 00167 00168 FaceIterator beginFaces (void) const; 00169 FaceIterator endFaces (void) const; 00170 00171 LineIterator beginLines (void) const; 00172 LineIterator endLines (void) const; 00173 00174 EdgeIterator beginEdges (void) const; 00175 EdgeIterator endEdges (void) const; 00176 00178 /*---------------------------------------------------------------------*/ 00182 // should these be public? 00183 virtual Action::ResultE drawPrimitives (DrawActionBase * action ); 00184 Action::ResultE intersect (Action * action ); 00185 00186 NewActionTypes::ResultE intersectActor(ActorBase::FunctorArgumentType &funcArg); 00187 00188 void invalidateDlistCache (void); 00189 00191 /*---------------------------------------------------------------------*/ 00195 // this only calculates a bbox - therefore it is useful and does no harm 00196 void adjustVolume (Volume & volume); 00197 00199 /*========================= PROTECTED ===============================*/ 00200 protected: 00201 00202 /*---------------------------------------------------------------------*/ 00206 Geometry(void); 00207 Geometry(const Geometry &source); 00208 00210 /*---------------------------------------------------------------------*/ 00214 virtual ~Geometry(void); 00215 00217 /*---------------------------------------------------------------------*/ 00221 void handleGL(Window* win, UInt32 id); 00222 00223 void onCreate(const Geometry *source = NULL); 00224 void onDestroy(void); 00225 00226 bool CompareMaterials(MaterialPtr m1, MaterialPtr m2); 00227 Int16 MergeIndex( const GeometryPtr other ); 00228 00229 void merge0( const GeometryPtr other ); 00230 void merge1( const GeometryPtr other ); 00231 void merge2( const GeometryPtr other ); 00232 void merge3( const GeometryPtr other ); 00233 void merge4( const GeometryPtr other ); 00234 void merge5( const GeometryPtr other ); 00235 void merge6( const GeometryPtr other ); 00236 00237 bool updateLowHighIndices( void ); 00238 00240 /*========================== PRIVATE ================================*/ 00241 private: 00242 00243 typedef GeometryBase Inherited; 00244 00245 friend class FieldContainer; 00246 friend class GeometryBase; 00247 00248 static void initMethod( void ); 00249 00250 void operator =(const Geometry &source); 00251 00252 void createVBO(Window *win, UInt32 id); 00253 void destroyVBO(Window *win, UInt32 id); 00254 void updateVBO(Window *win, UInt32 id); 00255 bool drawVBO(Window *win, UInt32 id); 00256 00257 static std::vector<GeoVBO *> _vbos; 00258 00259 UInt32 _numBytesOnGfxCard; 00260 }; 00261 00262 typedef Geometry *GeometryP; 00263 00264 OSG_END_NAMESPACE 00265 00266 #include <OSGGeometryBase.inl> 00267 #include <OSGGeometry.inl> 00268 00269 #define OSGGEOMETRY_HEADER_CVSID "@(#)$Id: $" 00270 00271 #endif /* _OSGGEOMETRY_H_ */
1.5.5