00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #pragma once
00013
00015 #include "nvsgcommon.h"
00016
00017 #include "nvmath/Vec3f.h"
00018 #include "nvsg/StateAttribute.h"
00019 #include "nvutil/BitMask.h"
00020
00021
00022 namespace nvsg
00023 {
00024 class FaceAttribute;
00025
00027 class FaceAttributeData : public nvutil::RCObject
00028 {
00029 friend class FaceAttribute;
00030
00031 public:
00033 NVSG_API FaceAttributeData(const FaceAttributeData& rhs);
00034
00035 private:
00036
00037 FaceAttributeData();
00038 ~FaceAttributeData();
00039
00040 FaceAttributeData& operator=(const FaceAttributeData& rhs) {}
00041
00042 private:
00043 nvmath::Vec3f m_ambientColor;
00044 bool m_backFaceCulling;
00045 struct
00046 {
00047 bool enabled;
00048 float factor;
00049 float units;
00050 } m_polygonOffset;
00051 bool m_twoSidedLighting;
00052 };
00053
00055 class FaceAttribute : public StateAttribute
00056 {
00057 public:
00059
00060 NVSG_API static const FaceAttribute * create( void );
00061
00063
00064 NVSG_API static const FaceAttribute * createFromBase( const StateAttribute &rhs );
00065
00067
00068 NVSG_API virtual const FaceAttribute * clone( void ) const;
00069
00071
00072 NVSG_API virtual bool isDataShared( void ) const;
00073
00075
00076 NVSG_API virtual DataID getDataID( void ) const;
00077
00079
00083 NVSG_API const nvmath::Vec3f& getAmbientColor( void ) const;
00084
00086
00089 NVSG_API float getPolygonOffsetFactor( void ) const;
00090
00092
00095 NVSG_API float getPolygonOffsetUnits( void ) const;
00096
00098
00102 NVSG_API bool isBackFaceCulling( void ) const;
00103
00105
00110 NVSG_API bool isPolygonOffset( void ) const;
00111
00113
00119 NVSG_API bool isTwoSidedLighting( void ) const;
00120
00122
00125 NVSG_API void setAmbientColor( const nvmath::Vec3f &color
00126 );
00127
00129
00132 NVSG_API void setBackFaceCulling( bool onOff
00133 );
00134
00136
00140 NVSG_API void setPolygonOffset( bool onOff
00141 );
00142
00144
00147 NVSG_API void setPolygonOffset( float factor
00148 , float units
00149 );
00150
00152
00157 NVSG_API void setTwoSidedLighting( bool onOff
00158 );
00159
00160 protected:
00162 NVSG_API FaceAttribute();
00163
00165 NVSG_API FaceAttribute( const StateAttribute &rhs );
00166
00168 NVSG_API FaceAttribute( const FaceAttribute &rhs );
00169
00171 NVSG_API virtual ~FaceAttribute( void );
00172
00173 private:
00174
00175 nvutil::RCPtr<FaceAttributeData> m_faceAttribute;
00176 };
00177
00178 inline const nvmath::Vec3f& FaceAttribute::getAmbientColor( void ) const
00179 {
00180 __TRACE();
00181 return( m_faceAttribute->m_ambientColor );
00182 }
00183
00184 inline void FaceAttribute::setAmbientColor( const nvmath::Vec3f &color )
00185 {
00186 __TRACE();
00187 nvutil::writeAccess( m_faceAttribute );
00188 m_faceAttribute->m_ambientColor = color;
00189 }
00190
00191 inline void FaceAttribute::setBackFaceCulling( bool onOff )
00192 {
00193 __TRACE();
00194 nvutil::writeAccess( m_faceAttribute );
00195 m_faceAttribute->m_backFaceCulling = onOff;
00196 }
00197
00198 inline bool FaceAttribute::isBackFaceCulling( void ) const
00199 {
00200 __TRACE();
00201 return m_faceAttribute->m_backFaceCulling;
00202 }
00203
00204 inline void FaceAttribute::setPolygonOffset( bool onOff )
00205 {
00206 __TRACE();
00207 nvutil::writeAccess( m_faceAttribute );
00208 m_faceAttribute->m_polygonOffset.enabled = onOff;
00209 }
00210
00211 inline void FaceAttribute::setPolygonOffset( float factor, float units )
00212 {
00213 __TRACE();
00214 nvutil::writeAccess( m_faceAttribute );
00215 m_faceAttribute->m_polygonOffset.factor = factor;
00216 m_faceAttribute->m_polygonOffset.units = units;
00217 }
00218
00219 inline bool FaceAttribute::isPolygonOffset( void ) const
00220 {
00221 __TRACE();
00222 return( m_faceAttribute->m_polygonOffset.enabled );
00223 }
00224
00225 inline float FaceAttribute::getPolygonOffsetFactor( void ) const
00226 {
00227 __TRACE();
00228 return( m_faceAttribute->m_polygonOffset.factor );
00229 }
00230
00231 inline float FaceAttribute::getPolygonOffsetUnits( void ) const
00232 {
00233 __TRACE();
00234 return( m_faceAttribute->m_polygonOffset.units );
00235 }
00236
00237 inline void FaceAttribute::setTwoSidedLighting( bool onOff )
00238 {
00239 __TRACE();
00240 nvutil::writeAccess( m_faceAttribute );
00241 m_faceAttribute->m_twoSidedLighting = onOff;
00242 }
00243
00244 inline bool FaceAttribute::isTwoSidedLighting( void ) const
00245 {
00246 __TRACE();
00247 return( m_faceAttribute->m_twoSidedLighting );
00248 }
00249
00250 }