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 _OSGDRAWACTIONBASE_H_ 00041 #define _OSGDRAWACTIONBASE_H_ 00042 #ifdef __sgi 00043 #pragma once 00044 #endif 00045 00046 //--------------------------------------------------------------------------- 00047 // Includes 00048 //--------------------------------------------------------------------------- 00049 00050 #include <OSGBaseTypes.h> 00051 #include <OSGFrustumVolume.h> 00052 #include <OSGStatCollector.h> 00053 #include <OSGStatElemTypes.h> 00054 #include <OSGAction.h> 00055 00056 OSG_BEGIN_NAMESPACE 00057 00058 //--------------------------------------------------------------------------- 00059 // Forward References 00060 //--------------------------------------------------------------------------- 00061 00062 class Camera; 00063 class Background; 00064 class Window; 00065 class Node; 00066 class Viewport; 00067 class Material; 00068 00069 //--------------------------------------------------------------------------- 00070 // Types 00071 //--------------------------------------------------------------------------- 00072 00073 //--------------------------------------------------------------------------- 00074 // Class 00075 //--------------------------------------------------------------------------- 00076 00077 class OSG_SYSTEMLIB_DLLMAPPING DrawActionBase : public Action 00078 { 00079 public: 00080 00081 //----------------------------------------------------------------------- 00082 // constants 00083 //----------------------------------------------------------------------- 00084 00085 static StatElemDesc<StatTimeElem> statTravTime; 00086 static StatElemDesc<StatIntElem> statCullTestedNodes; 00087 static StatElemDesc<StatIntElem> statCulledNodes; 00088 00089 //----------------------------------------------------------------------- 00090 // enums 00091 //----------------------------------------------------------------------- 00092 00093 //----------------------------------------------------------------------- 00094 // types 00095 //----------------------------------------------------------------------- 00096 00097 //----------------------------------------------------------------------- 00098 // class functions 00099 //----------------------------------------------------------------------- 00100 00101 //----------------------------------------------------------------------- 00102 // instance functions 00103 //----------------------------------------------------------------------- 00104 00105 virtual ~DrawActionBase(void); 00106 00107 /*------------------------- your_category -------------------------------*/ 00108 00109 // rendering state handling 00110 00111 Viewport *getViewport (void ) const; 00112 void setViewport (Viewport *viewport ); 00113 00114 Camera *getCamera (void ) const; 00115 void setCamera (Camera *cam ); 00116 const Matrix &getCameraToWorld(void); 00117 00118 Background *getBackground (void ) const; 00119 void setBackground (Background *background); 00120 00121 Window *getWindow (void ) const; 00122 void setWindow (Window * window ); 00123 00124 StatCollector *getStatistics (void ); 00125 void setStatistics (StatCollector * stat ); 00126 inline bool hasOwnStat (void ); 00127 00128 // frustum culling functions 00129 // these are just temporary, sooner or later they'll move into a 00130 // cacaded action 00131 00132 // control activation of frustum culling 00133 bool getFrustumCulling( void ) const; 00134 void setFrustumCulling( bool val = true ); 00135 00136 // control drawing of checked volumes 00137 bool getVolumeDrawing( void ) const; 00138 void setVolumeDrawing( bool val = false ); 00139 00140 // control automatic frustum calculation 00141 bool getAutoFrustum( void ) const; 00142 void setAutoFrustum( bool val = true ); 00143 00144 // control frustum 00145 const FrustumVolume & getFrustum( void ) const; 00146 void setFrustum( FrustumVolume & frust ); 00147 00148 virtual bool isVisible(Node* node) = 0; 00149 00150 // select all visible nodes 00151 UInt32 selectVisibles( void ); 00152 00153 00154 Material *getMaterial (void ) const; 00155 NodePtr getMaterialNode(void ) const; 00156 void setMaterial (Material *pMaterial, NodePtr node); 00157 00158 /*------------------------- your_operators ------------------------------*/ 00159 00160 // initialisation 00161 virtual Action::ResultE start(void); 00162 virtual Action::ResultE stop( Action::ResultE res ); 00163 00164 /*------------------------- assignment ----------------------------------*/ 00165 00166 /*------------------------- comparison ----------------------------------*/ 00167 00168 00169 protected: 00170 00171 //----------------------------------------------------------------------- 00172 // enums 00173 //----------------------------------------------------------------------- 00174 00175 //----------------------------------------------------------------------- 00176 // types 00177 //----------------------------------------------------------------------- 00178 00179 //----------------------------------------------------------------------- 00180 // class variables 00181 //----------------------------------------------------------------------- 00182 00183 //----------------------------------------------------------------------- 00184 // class functions 00185 //----------------------------------------------------------------------- 00186 00187 //----------------------------------------------------------------------- 00188 // instance variables 00189 //----------------------------------------------------------------------- 00190 00191 Camera *_camera; 00192 Background *_background; 00193 Window *_window; 00194 Viewport *_viewport; 00195 StatCollector *_statistics; 00196 bool _ownStat; 00197 00198 00199 Material *_pMaterial; 00200 NodePtr _pMaterialNode; 00201 00202 // frustum culling attributes 00203 00204 bool _frustumCulling; 00205 bool _volumeDrawing; 00206 bool _autoFrustum; 00207 FrustumVolume _frustum; 00208 Matrix _mCameraToWorld; 00209 00210 //----------------------------------------------------------------------- 00211 // instance functions 00212 //----------------------------------------------------------------------- 00213 00214 DrawActionBase(void); 00215 00216 DrawActionBase(const DrawActionBase &source); 00217 void operator =(const DrawActionBase &source); 00218 00219 virtual std::vector<Functor> *getDefaultEnterFunctors(void) = 0; 00220 virtual std::vector<Functor> *getDefaultLeaveFunctors(void) = 0; 00221 00222 private: 00223 00224 //----------------------------------------------------------------------- 00225 // enums 00226 //----------------------------------------------------------------------- 00227 00228 //----------------------------------------------------------------------- 00229 // types 00230 //----------------------------------------------------------------------- 00231 00232 typedef Action Inherited; 00233 00234 //----------------------------------------------------------------------- 00235 // friend classes 00236 //----------------------------------------------------------------------- 00237 00238 //----------------------------------------------------------------------- 00239 // friend functions 00240 //----------------------------------------------------------------------- 00241 00242 //----------------------------------------------------------------------- 00243 // class variables 00244 //----------------------------------------------------------------------- 00245 00246 static char cvsid[]; 00247 00248 //----------------------------------------------------------------------- 00249 // class functions 00250 //----------------------------------------------------------------------- 00251 00252 //----------------------------------------------------------------------- 00253 // instance variables 00254 //----------------------------------------------------------------------- 00255 00256 //----------------------------------------------------------------------- 00257 // instance functions 00258 //----------------------------------------------------------------------- 00259 00260 // prohibit default functions (move to 'public' if you need one) 00261 }; 00262 00263 //--------------------------------------------------------------------------- 00264 // Exported Types 00265 //--------------------------------------------------------------------------- 00266 00267 // class pointer 00268 00269 typedef DrawActionBase *DrawActionBaseP; 00270 00271 OSG_END_NAMESPACE 00272 00273 #include <OSGDrawActionBase.inl> 00274 00275 #endif /* _OSGDRAWACTIONBASE_H_ */
1.5.5