00001 // Copyright NVIDIA Corporation 2002-2004 00002 // TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED 00003 // *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS 00004 // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY 00005 // AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS 00006 // BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES 00007 // WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, 00008 // BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) 00009 // ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS 00010 // BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 00011 00012 #pragma once 00013 00015 #include "nvsgcommon.h" 00016 00017 #include "nvtraverser/Traverser.h" 00018 00019 namespace nvsg 00020 { 00021 class MonoCamera; 00022 template<typename T> class Animation; 00023 template<typename T> class InterpolatedAnimation; 00024 } 00025 00026 namespace nvtraverser 00027 { 00029 00031 class SearchTraverser : public Traverser 00032 { 00033 public: 00035 NVSG_API SearchTraverser(void); 00036 00038 typedef std::vector<const nvsg::Object*>::const_iterator iterator; 00039 00041 00042 NVSG_API const std::vector<const nvsg::Object*> & getResults( void ) const; 00043 00045 00047 NVSG_API void setClassName( const std::string& name 00048 ); 00049 00051 00054 NVSG_API void setBaseClassSearch( bool enable 00055 ); 00056 00057 protected: 00059 NVSG_API virtual ~SearchTraverser(void); 00060 00062 NVSG_API virtual void doApply( const nvsg::ViewState *pViewState 00063 , const nvsg::Scene *pScene 00064 ); 00065 00067 NVSG_API virtual void handleGeoNode( 00068 const nvsg::GeoNode * p 00069 ); 00070 00072 NVSG_API virtual void handleGroup( 00073 const nvsg::Group * p 00074 ); 00075 00077 NVSG_API virtual void handleLOD( 00078 const nvsg::LOD * p 00079 ); 00080 00082 NVSG_API virtual void handleSwitch( 00083 const nvsg::Switch * p 00084 ); 00085 00087 NVSG_API virtual void handleTransform( 00088 const nvsg::Transform * p 00089 ); 00090 00092 NVSG_API virtual void handleAnimatedTransform( 00093 const nvsg::AnimatedTransform * p 00094 ); 00095 00097 NVSG_API virtual void handleDirectedLight( 00098 const nvsg::DirectedLight * p 00099 ); 00100 00102 NVSG_API virtual void handlePointLight( 00103 const nvsg::PointLight * p 00104 ); 00105 00107 NVSG_API virtual void handleSpotLight( 00108 const nvsg::SpotLight * p 00109 ); 00110 00112 NVSG_API virtual void handleQuads( 00113 const nvsg::Quads * p 00114 ); 00115 00117 NVSG_API virtual void handleAnimatedQuads( 00118 const nvsg::AnimatedQuads * p 00119 ); 00120 00122 NVSG_API virtual void handleQuadStrips( 00123 const nvsg::QuadStrips * p 00124 ); 00125 00127 NVSG_API virtual void handleTriangles( 00128 const nvsg::Triangles * p 00129 ); 00130 00132 00133 NVSG_API virtual void handleAnimatedTriangles( 00134 const nvsg::AnimatedTriangles * p 00135 ); 00136 00138 NVSG_API virtual void handleSkinnedTriangles( 00139 const nvsg::SkinnedTriangles * p 00140 ); 00141 00143 NVSG_API virtual void handleTriStrips( 00144 const nvsg::TriStrips * p 00145 ); 00146 00148 NVSG_API virtual void handleStateSet( 00149 const nvsg::StateSet * p 00150 ); 00151 00153 NVSG_API virtual void handleCgFx( 00154 const nvsg::CgFx * p 00155 ); 00156 00158 NVSG_API virtual void handleFaceAttribute( 00159 const nvsg::FaceAttribute * p 00160 ); 00161 00163 NVSG_API virtual void handleMaterial( 00164 const nvsg::Material * p 00165 ); 00166 00168 00169 NVSG_API virtual void handleTextureAttribute( 00170 const nvsg::TextureAttribute * p 00171 ); 00172 00174 NVSG_API virtual void handleJitterCamera( 00175 const nvsg::JitterCamera * p 00176 , const nvsg::Node * root 00177 ); 00178 00180 NVSG_API virtual void handleParallelCamera( 00181 const nvsg::ParallelCamera * p 00182 , const nvsg::Node * root 00183 ); 00184 00186 00187 NVSG_API virtual void handlePerspectiveCamera( 00188 const nvsg::PerspectiveCamera * p 00189 , const nvsg::Node * root 00190 ); 00191 00193 NVSG_API virtual void handleStereoCamera( 00194 const nvsg::StereoCamera * p 00195 , const nvsg::Node * root 00196 ); 00197 00199 NVSG_API virtual void handleFramedTrafoAnimation( 00200 const nvsg::FramedAnimation<nvmath::Trafo> * p 00201 ); 00202 00204 00205 NVSG_API virtual void handleFramedVNVectorAnimation( 00206 const nvsg::FramedAnimation<nvsg::VNVector> * p 00207 ); 00208 00210 NVSG_API virtual void handleLinearInterpolatedTrafoAnimation( 00211 const nvsg::LinearInterpolatedAnimation<nvmath::Trafo> * p 00212 ); 00213 00215 NVSG_API virtual void handleLinearInterpolatedVNVectorAnimation( 00216 const nvsg::LinearInterpolatedAnimation<nvsg::VNVector> * p 00217 ); 00218 00219 00221 00222 NVSG_API virtual void search( const nvsg::Animation<nvmath::Trafo> *p 00223 ); 00224 00226 00227 NVSG_API virtual void search( const nvsg::Animation<nvsg::VNVector> *p 00228 ); 00229 00231 00232 NVSG_API virtual void search( const nvsg::Camera *p 00233 ); 00234 00236 00237 NVSG_API virtual void search( const nvsg::Drawable *p 00238 ); 00239 00241 00242 NVSG_API virtual void search( const nvsg::GeoSet *p 00243 ); 00244 00246 00247 NVSG_API virtual void search( const nvsg::Group *p 00248 ); 00249 00251 00252 NVSG_API virtual void search( const nvsg::InterpolatedAnimation<nvmath::Trafo> *p 00253 ); 00254 00256 00257 NVSG_API virtual void search( const nvsg::InterpolatedAnimation<nvsg::VNVector> *p 00258 ); 00259 00261 00262 NVSG_API virtual void search( const nvsg::LightSource *p 00263 ); 00264 00266 00267 NVSG_API virtual void search( const nvsg::MonoCamera *p 00268 ); 00269 00271 00272 NVSG_API virtual void search( const nvsg::Node *p 00273 ); 00274 00276 00277 NVSG_API virtual void search( const nvsg::Object *p 00278 ); 00279 00281 00282 NVSG_API virtual void search( const nvsg::Quads *p 00283 ); 00284 00286 00287 NVSG_API virtual void search( const nvsg::StateAttribute *p 00288 ); 00289 00291 00292 NVSG_API virtual void search( const nvsg::Transform *p 00293 ); 00294 00296 00297 NVSG_API virtual void search( const nvsg::Triangles *p 00298 ); 00299 00300 private: 00301 void addItem( const nvsg::Object* T ); 00302 00303 bool m_searchBaseClass; 00304 std::string m_className; 00305 std::vector<const nvsg::Object*> m_results; 00306 }; 00307 00308 inline const std::vector<const nvsg::Object*> & SearchTraverser::getResults( void ) const 00309 { 00310 return( m_results ); 00311 } 00312 00313 inline void SearchTraverser::setClassName( const std::string& name ) 00314 { 00315 m_className = name; 00316 } 00317 00318 inline void SearchTraverser::setBaseClassSearch( bool enable ) 00319 { 00320 m_searchBaseClass = enable; 00321 } 00322 00323 }