00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #pragma once
00013
00015 #include "nvsgcommon.h"
00016
00017 #include "nvsg/Object.h"
00018 #include <vector>
00019
00020 namespace nvsg
00021 {
00022 class GeoNode;
00023 class StateAttribute;
00024
00026
00029 class StateSet : public Object
00030 {
00031 public:
00033
00034 NVSG_API static const StateSet * create( void );
00035
00037
00038 NVSG_API static const StateSet * createFromBase( const Object &rhs );
00039
00041
00042 NVSG_API virtual const StateSet * clone( void ) const;
00043
00045
00046 NVSG_API virtual bool isDataShared( void ) const;
00047
00049
00050 NVSG_API virtual DataID getDataID( void ) const;
00051
00053
00059 NVSG_API void addAttribute( const StateAttribute *attrib
00060 );
00061
00063
00064 NVSG_API size_t getNumberOfAttributes( void ) const;
00065
00067
00069 NVSG_API const StateAttribute * getAttribute( size_t index
00070 ) const;
00071
00073
00075 NVSG_API const StateAttribute * getAttributeByObjectCode( unsigned int oc
00076 ) const;
00077
00079
00080 NVSG_API bool removeAttribute( const StateAttribute * attrib
00081 );
00082
00084
00085 NVSG_API bool removeAttribute( size_t index
00086 );
00087
00089
00091 NVSG_API bool removeAttributeByObjectCode( unsigned int oc
00092 );
00093
00095
00096 NVSG_API size_t getNumberOfOwners( void ) const;
00097
00099
00100 NVSG_API const GeoNode * getOwner( size_t index
00101 ) const;
00102
00104
00105 NVSG_API virtual bool containsCgFx( void ) const;
00106
00108
00109 NVSG_API virtual void invalidateCgFxContainment( void );
00110
00112
00113 NVSG_API virtual bool containsTransparentMaterial( void ) const;
00114
00116
00117 NVSG_API virtual void invalidateTransparentMaterialContainment( void );
00118
00120
00121 NVSG_API virtual bool containsTransparentTexture( void ) const;
00122
00124
00125 NVSG_API virtual void invalidateTransparentTextureContainment( void );
00126 protected:
00128 NVSG_API StateSet( void );
00129
00131 NVSG_API StateSet( const Object &rhs );
00132
00134 NVSG_API StateSet( const StateSet& rhs );
00135
00137 NVSG_API virtual ~StateSet( void );
00138
00140
00141 NVSG_API void invalidateCaches( const StateAttribute *attrib, bool insert );
00142
00143 private:
00144
00145
00146 friend class GeoNode;
00147 void addOwner( const GeoNode * geoNode );
00148 void removeOwner( const GeoNode * geoNode );
00149
00150 private:
00151 std::vector<const StateAttribute*> m_stateAttribs;
00152 std::vector<const GeoNode*> m_owners;
00153
00154
00155 mutable bool m_containsCgFx;
00156 mutable bool m_containsCgFxValid;
00157 mutable bool m_containsTransparentMaterial;
00158 mutable bool m_containsTransparentMaterialValid;
00159 mutable bool m_containsTransparentTexture;
00160 mutable bool m_containsTransparentTextureValid;
00161
00162 };
00163
00164 inline const StateAttribute * StateSet::getAttribute( size_t index ) const
00165 {
00166 __TRACE();
00167 __ASSERT(index<m_stateAttribs.size());
00168 return m_stateAttribs[index];
00169 }
00170
00171 inline size_t StateSet::getNumberOfAttributes( void ) const
00172 {
00173 __TRACE();
00174 return( m_stateAttribs.size() );
00175 }
00176
00177 inline size_t StateSet::getNumberOfOwners( void ) const
00178 {
00179 __TRACE();
00180 return( m_owners.size() );
00181 }
00182
00183 inline const GeoNode * StateSet::getOwner( size_t index ) const
00184 {
00185 __TRACE();
00186 __ASSERT( index < m_owners.size() );
00187 return m_owners[index];
00188 }
00189
00190
00191
00197 NVSG_API bool operator==( const StateSet &lhs
00198 , const StateSet &rhs
00199 );
00200
00201 }