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 OSG_BEGIN_NAMESPACE 00057 00058 class DrawActionBase; 00059 00060 class TriangleIterator; 00061 class PrimitiveIterator; 00062 class FaceIterator; 00063 class LineIterator; 00064 class EdgeIterator; 00065 00066 00069 class OSG_SYSTEMLIB_DLLMAPPING Geometry : public GeometryBase 00070 { 00071 /*========================== PUBLIC =================================*/ 00072 public: 00073 00074 /*---------------------------------------------------------------------*/ 00078 static const UInt16 MapPosition; 00079 static const UInt16 MapNormal; 00080 static const UInt16 MapColor; 00081 static const UInt16 MapSecondaryColor; 00082 static const UInt16 MapTexCoords; 00083 static const UInt16 MapTexCoords1; 00084 static const UInt16 MapTexCoords2; 00085 static const UInt16 MapTexCoords3; 00086 static const UInt16 MapEmpty; 00087 00089 /*---------------------------------------------------------------------*/ 00093 static const char *getClassname(void) { return "Geometry"; }; 00094 00096 /*---------------------------------------------------------------------*/ 00100 static const char *mapType (UInt8 type); 00101 00102 Int16 calcMappingIndex (UInt16 attrib) const; 00103 00104 virtual void changed (BitVector whichField, 00105 UInt32 origin ); 00106 00107 GeometryPtr getPtr (void) const; 00108 00109 GeometryPtr clone (void); 00110 00111 virtual void dump ( UInt32 uiIndent = 0, 00112 const BitVector bvFlags = 0) const; 00113 00114 bool isMergeable (const GeometryPtr other); 00115 00116 bool merge (const GeometryPtr other); 00117 00119 /*---------------------------------------------------------------------*/ 00123 #ifndef OSG_SUPPORT_NO_GEO_INTERFACE 00124 virtual GeoPropertyArrayInterface *getProperty(Int32 mapID); 00125 #endif 00126 00127 00129 /*---------------------------------------------------------------------*/ 00133 void setTypes (const GeoPTypesPtr &value); 00134 void setLengths (const GeoPLengthsPtr &value); 00135 void setPositions (const GeoPositionsPtr &value); 00136 void setNormals (const GeoNormalsPtr &value); 00137 void setColors (const GeoColorsPtr &value); 00138 void setSecondaryColors(const GeoColorsPtr &value); 00139 void setTexCoords (const GeoTexCoordsPtr &value); 00140 void setTexCoords1 (const GeoTexCoordsPtr &value); 00141 void setTexCoords2 (const GeoTexCoordsPtr &value); 00142 void setTexCoords3 (const GeoTexCoordsPtr &value); 00143 void setIndices (const GeoIndicesPtr &value); 00144 void setMaterial (const MaterialPtr &value); 00145 00147 /*---------------------------------------------------------------------*/ 00151 TriangleIterator beginTriangles (void) const; 00152 TriangleIterator endTriangles (void) const; 00153 00154 PrimitiveIterator beginPrimitives (void) const; 00155 PrimitiveIterator endPrimitives (void) const; 00156 00157 FaceIterator beginFaces (void) const; 00158 FaceIterator endFaces (void) const; 00159 00160 LineIterator beginLines (void) const; 00161 LineIterator endLines (void) const; 00162 00163 EdgeIterator beginEdges (void) const; 00164 EdgeIterator endEdges (void) const; 00165 00167 /*---------------------------------------------------------------------*/ 00171 // should these be public? 00172 virtual Action::ResultE drawPrimitives (DrawActionBase * action ); 00173 Action::ResultE intersect (Action * action ); 00174 00175 NewActionTypes::ResultE intersect (ActorBase::FunctorArgumentType &funcArg); 00176 00177 void invalidateDlistCache (void); 00178 00180 /*---------------------------------------------------------------------*/ 00184 // this only calculates a bbox - therefore it is useful and does no harm 00185 void adjustVolume (Volume & volume); 00186 00188 /*========================= PROTECTED ===============================*/ 00189 protected: 00190 00191 /*---------------------------------------------------------------------*/ 00195 Geometry(void); 00196 Geometry(const Geometry &source); 00197 00199 /*---------------------------------------------------------------------*/ 00203 virtual ~Geometry(void); 00204 00206 /*---------------------------------------------------------------------*/ 00210 void handleGL(Window* win, UInt32 id); 00211 00212 void onCreate(const Geometry *source = NULL); 00213 00214 bool CompareMaterials(MaterialPtr m1, MaterialPtr m2); 00215 Int16 MergeIndex( const GeometryPtr other ); 00216 00217 void merge0( const GeometryPtr other ); 00218 void merge1( const GeometryPtr other ); 00219 void merge2( const GeometryPtr other ); 00220 void merge3( const GeometryPtr other ); 00221 void merge4( const GeometryPtr other ); 00222 void merge5( const GeometryPtr other ); 00223 void merge6( const GeometryPtr other ); 00224 00226 /*========================== PRIVATE ================================*/ 00227 private: 00228 00229 typedef GeometryBase Inherited; 00230 00231 friend class FieldContainer; 00232 friend class GeometryBase; 00233 00234 static void initMethod( void ); 00235 00236 void operator =(const Geometry &source); 00237 00238 }; 00239 00240 typedef Geometry *GeometryP; 00241 00242 OSG_END_NAMESPACE 00243 00244 #include <OSGGeometryBase.inl> 00245 #include <OSGGeometry.inl> 00246 00247 #define OSGGEOMETRY_HEADER_CVSID "@(#)$Id: $" 00248 00249 #endif /* _OSGGEOMETRY_H_ */
1.4.3