#include <OSGChunkMaterial.h>
Inheritance diagram for osg::ChunkMaterial:

Rendering | |
| StatePtr | getState (void) |
| *typedef TypedFunctor1Base< Action::ResultE, PtrCallArg< DrawActionBase > > | DrawFunctor |
Public Types | |
| typedef ChunkMaterialPtr | Ptr |
| enum | { ChunksFieldId = Inherited::NextFieldId, SlotsFieldId = ChunksFieldId + 1, NextFieldId = SlotsFieldId + 1 } |
Public Member Functions | |
Sync | |
| *virtual void | changed (BitVector whichField, UInt32 origin) |
Output | |
| *virtual void | dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const |
Rendering | |
| *virtual void | draw (DrawFunctor &func, DrawActionBase *action) |
| virtual void | draw (Geometry *geo, DrawActionBase *action) |
| virtual StatePtr | makeState (void) |
| virtual void | rebuildState (void) |
| virtual bool | isTransparent (void) const |
Access | |
| *bool | addChunk (StateChunkPtr chunk, Int32 slot=State::AutoSlotReplace) |
| bool | subChunk (StateChunkPtr chunk, Int32 slot=State::AutoSlotReplace) |
| Int32 | find (StateChunkPtr chunk) |
| StateChunkPtr | find (const FieldContainerType &type, Int32 slot=State::AutoSlotReplace) |
| virtual bool | operator== (const Material &other) |
FieldContainer Get | |
| *virtual FieldContainerType & | getType (void) |
| virtual const FieldContainerType & | getType (void) const |
| virtual UInt32 | getContainerSize (void) const |
Field Get | |
| *MFStateChunkPtr * | getMFChunks (void) |
| Get the ChunkMaterial::_mfChunks field. | |
| MFInt32 * | getMFSlots (void) |
| Get the ChunkMaterial::_mfSlots field. | |
| StateChunkPtr & | getChunks (const UInt32 index) |
| Get the value of the index element the ChunkMaterial::_mfChunks field. | |
| MFStateChunkPtr & | getChunks (void) |
| Get the ChunkMaterial::_mfChunks field. | |
| const MFStateChunkPtr & | getChunks (void) const |
| Get the ChunkMaterial::_mfChunks field. | |
| Int32 & | getSlots (const UInt32 index) |
| Get the value of the index element the ChunkMaterial::_mfSlots field. | |
| MFInt32 & | getSlots (void) |
| Get the ChunkMaterial::_mfSlots field. | |
| const MFInt32 & | getSlots (void) const |
| Get the ChunkMaterial::_mfSlots field. | |
Binary Access | |
| *virtual UInt32 | getBinSize (const BitVector &whichField) |
| virtual void | copyToBin (BinaryDataHandler &pMem, const BitVector &whichField) |
| virtual void | copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField) |
Copy | |
| *virtual FieldContainerPtr | shallowCopy (void) const |
Static Public Member Functions | |
Class Get | |
| *static const char * | getClassname (void) |
Class Get | |
| *static FieldContainerType & | getClassType (void) |
| access the type of the class | |
| static UInt32 | getClassTypeId (void) |
| access the numerical type of the class | |
Construction | |
| *static ChunkMaterialPtr | create (void) |
| create a new instance of the class | |
| static ChunkMaterialPtr | createEmpty (void) |
| create an empty new instance of the class, do not copy the prototype | |
Static Public Attributes | |
| static const osg::BitVector | ChunksFieldMask |
| static const osg::BitVector | SlotsFieldMask |
| static const osg::BitVector | MTInfluenceMask |
| static const osg::BitVector | SortKeyFieldMask |
| static const BitVector | AttachmentsFieldMask |
| static const BitVector | NextFieldMask |
Protected Member Functions | |
Constructors | |
| * | ChunkMaterial (void) |
| ChunkMaterial (const ChunkMaterial &source) | |
Destructor | |
| *virtual | ~ChunkMaterial (void) |
Sync | |
| *void | executeSyncImpl (ChunkMaterialBase *pOther, const BitVector &whichField) |
| virtual void | executeSync (FieldContainer &other, const BitVector &whichField) |
Protected Attributes | |
| StatePtr | _pState |
Fields | |
| *MFStateChunkPtr | _mfChunks |
| MFInt32 | _mfSlots |
Private Types | |
| typedef ChunkMaterialBase | Inherited |
Private Member Functions | |
| void | operator= (const ChunkMaterial &source) |
Static Private Member Functions | |
| static void | initMethod (void) |
Static Private Attributes | |
| static char | cvsid [] |
Friends | |
| class | FieldContainer |
| class | ChunkMaterialBase |
Chunks can be attached and detached from the material using osg::ChunkMaterial::addChunk() and osg::ChunkMaterial::subChunk(). For more complex manipulation of the chunk list use the osg::ChunkMaterial::_mfChunks field's functions.
Definition at line 55 of file OSGChunkMaterial.h.
|
|
Reimplemented from osg::ChunkMaterialBase. Reimplemented in osg::FresnelMaterial, osg::FresnelMaterialBase, osg::PhongMaterial, osg::PhongMaterialBase, osg::SimpleMaterial, osg::SimpleMaterialBase, osg::SimpleTexturedMaterial, osg::SimpleTexturedMaterialBase, osg::DVRAppearance, and osg::DVRAppearanceBase. Definition at line 135 of file OSGChunkMaterial.h. |
|
|
Reimplemented from osg::MaterialBase. Reimplemented in osg::FresnelMaterialBase, osg::PhongMaterialBase, osg::SimpleMaterialBase, osg::SimpleTexturedMaterialBase, and osg::DVRAppearanceBase. Definition at line 91 of file OSGChunkMaterialBase.h. |
|
|
Reimplemented from osg::MaterialBase. Definition at line 93 of file OSGChunkMaterialBase.h. 00094 { 00095 ChunksFieldId = Inherited::NextFieldId, 00096 SlotsFieldId = ChunksFieldId + 1, 00097 NextFieldId = SlotsFieldId + 1 00098 };
|
|
|
Definition at line 95 of file OSGChunkMaterial.cpp. 00095 : 00096 Inherited() 00097 { 00098 }
|
|
|
Definition at line 100 of file OSGChunkMaterial.cpp. 00100 : 00101 Inherited(source) 00102 { 00103 }
|
|
|
Definition at line 105 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::MField< FieldTypeT, fieldNameSpace >::begin(), osg::MField< FieldTypeT, fieldNameSpace >::end(), and osg::subRefCP(). 00106 { 00107 MFStateChunkPtr::iterator matIt = _mfChunks.begin(); 00108 MFStateChunkPtr::iterator matEnd = _mfChunks.end (); 00109 00110 while(matIt != matEnd) 00111 { 00112 subRefCP(*matIt); 00113 00114 ++matIt; 00115 } 00116 }
|
|
|
Reimplemented from osg::Material. Reimplemented in osg::SimpleMaterial. Definition at line 64 of file OSGChunkMaterial.h.
|
|
||||||||||||
|
Reimplemented from osg::Material. Reimplemented in osg::FresnelMaterial, osg::PhongMaterial, osg::SimpleMaterial, osg::SimpleTexturedMaterial, and osg::DVRAppearance. Definition at line 118 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::ChangedOrigin::Abstract, osg::addRefCP(), osg::MField< FieldTypeT, fieldNameSpace >::begin(), osg::Material::changed(), and osg::MField< FieldTypeT, fieldNameSpace >::end(). Referenced by osg::SimpleMaterial::changed(), osg::PhongMaterial::changed(), osg::FresnelMaterial::changed(), and osg::DVRAppearance::changed(). 00119 { 00120 if(origin & ChangedOrigin::Abstract) 00121 { 00122 MFStateChunkPtr::iterator matIt = _mfChunks.begin(); 00123 MFStateChunkPtr::iterator matEnd = _mfChunks.end (); 00124 00125 while(matIt != matEnd) 00126 { 00127 addRefCP(*matIt); 00128 00129 ++matIt; 00130 } 00131 } 00132 00133 Inherited::changed(whichField, origin); 00134 }
|
|
||||||||||||
|
Reimplemented from osg::Material. Reimplemented in osg::FresnelMaterial, osg::PhongMaterial, osg::SimpleMaterial, osg::SimpleTexturedMaterial, and osg::DVRAppearance. Definition at line 349 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::ChunkMaterialBase::_mfSlots, osg::State::AutoSlotReplace, osg::MField< FieldTypeT, fieldNameSpace >::size(), and SLOG. 00351 { 00352 SLOG << "ChunkMaterial at " << this << std::endl; 00353 SLOG << "Chunks: " << std::endl; 00354 00355 UInt32 i; 00356 00357 for(i = 0; i < _mfChunks.size(); ++i) 00358 SLOG << _mfChunks[i] << " " 00359 << static_cast<Int32>((i < _mfSlots.size()) 00360 ? _mfSlots[i] 00361 : State::AutoSlotReplace) 00362 << std::endl; 00363 }
|
|
||||||||||||
|
Draw the function behind the functor with this material. The functored function should be very careful changing OpenGL state, better just use glBegin(), glEnd() and the standard stuff in between. Implements osg::Material. Definition at line 274 of file OSGChunkMaterial.cpp. References osg::addRefCP(), makeState(), and osg::subRefCP(). 00275 { 00276 StatePtr state = makeState(); 00277 00278 addRefCP(state); 00279 00280 state->activate(action); 00281 00282 func.call(action); 00283 00284 state->deactivate(action); 00285 00286 subRefCP(state); // kill it 00287 }
|
|
||||||||||||
|
Draw the geometry with this material. Implements osg::Material. Definition at line 254 of file OSGChunkMaterial.cpp. References osg::addRefCP(), osg::Geometry::drawPrimitives(), makeState(), and osg::subRefCP(). 00255 { 00256 StatePtr state = makeState(); 00257 00258 addRefCP(state); 00259 00260 state->activate(action); 00261 00262 geo->drawPrimitives(action); 00263 00264 state->deactivate(action); 00265 00266 subRefCP(state); // kill it 00267 }
|
|
|
Create a osg::State that represents this Material and return it. Implements osg::Material. Reimplemented in osg::FresnelMaterial, osg::PhongMaterial, osg::SimpleMaterial, and osg::SimpleTexturedMaterial. Definition at line 292 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::ChunkMaterialBase::_mfSlots, osg::State::AutoSlotReplace, osg::StateBase::create(), and osg::MField< FieldTypeT, fieldNameSpace >::size(). Referenced by draw(). 00293 { 00294 StatePtr state = State::create(); 00295 UInt32 i; 00296 00297 for(i = 0; i < _mfChunks.size(); ++i) 00298 state->addChunk(_mfChunks[i], 00299 (i < _mfSlots.size()) ? _mfSlots[i] 00300 : State::AutoSlotReplace); 00301 00302 return state; 00303 }
|
|
|
Rebuild the internal State. Just collects the chunks in the State. Implements osg::Material. Reimplemented in osg::FresnelMaterial, osg::PhongMaterial, osg::SimpleMaterial, and osg::SimpleTexturedMaterial. Definition at line 308 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::ChunkMaterialBase::_mfSlots, osg::Material::_pState, osg::addRefCP(), osg::State::AutoSlotReplace, osg::StateBase::create(), osg::NullFC, and osg::MField< FieldTypeT, fieldNameSpace >::size(). 00309 { 00310 if(_pState != NullFC) 00311 { 00312 _pState->clearChunks(); 00313 } 00314 else 00315 { 00316 _pState = State::create(); 00317 00318 addRefCP(_pState); 00319 } 00320 00321 UInt32 i; 00322 00323 for(i = 0; i < _mfChunks.size(); ++i) 00324 _pState->addChunk(_mfChunks[i], 00325 (i < _mfSlots.size()) ? _mfSlots[i] 00326 : State::AutoSlotReplace); 00327 }
|
|
|
Check if the Material (i.e. any of its chunks) is transparent.. Implements osg::Material. Reimplemented in osg::FresnelMaterial, osg::PhongMaterial, osg::SimpleMaterial, and osg::SimpleTexturedMaterial. Definition at line 332 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::MField< FieldTypeT, fieldNameSpace >::begin(), and osg::MField< FieldTypeT, fieldNameSpace >::end(). Referenced by osg::SimpleMaterial::isTransparent(), osg::PhongMaterial::isTransparent(), and osg::FresnelMaterial::isTransparent(). 00333 { 00334 bool returnValue = false; 00335 00336 MFStateChunkPtr::const_iterator it = _mfChunks.begin(); 00337 MFStateChunkPtr::const_iterator chunksEnd = _mfChunks.end(); 00338 00339 for(; it != chunksEnd && returnValue == false; ++it) 00340 { 00341 returnValue =(*it)->isTransparent(); 00342 } 00343 00344 return returnValue; 00345 }
|
|
||||||||||||
|
Add the given chunk to the material. It is possible to specify which slot this chunk should be associated with. See StateChunkClass for a general description of the slots concept. The default slot is State::AutoSlotReplace. Definition at line 144 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::ChunkMaterialBase::_mfSlots, osg::addRefCP(), osg::State::AutoSlotReplace, osg::MField< FieldTypeT, fieldNameSpace >::push_back(), and osg::MField< FieldTypeT, fieldNameSpace >::size(). 00145 { 00146 if(slot != State::AutoSlotReplace) 00147 { 00148 while(_mfSlots.size() < _mfChunks.size()) 00149 _mfSlots.push_back(State::AutoSlotReplace); 00150 } 00151 00152 _mfChunks.push_back(chunk); 00153 00154 if(slot != State::AutoSlotReplace) 00155 _mfSlots.push_back(slot); 00156 00157 addRefCP(chunk); 00158 00159 return true; 00160 }
|
|
||||||||||||
|
Remove the given chunk from the material. If the slot is not State::AutoSlotReplace, only the given slot will be searched and removed if found. Returns true if the chunk couldn't be found. Definition at line 166 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::ChunkMaterialBase::_mfSlots, osg::State::AutoSlotReplace, osg::MField< FieldTypeT, fieldNameSpace >::begin(), osg::MField< FieldTypeT, fieldNameSpace >::erase(), osg::MField< FieldTypeT, fieldNameSpace >::size(), osg::subRefCP(), and SWARNING. 00167 { 00168 UInt32 i; 00169 00170 for(i = 0; i < _mfChunks.size(); ++i) 00171 { 00172 if(_mfChunks[i] == chunk && 00173 ((i < _mfSlots.size() && _mfSlots[i] == slot) || 00174 slot == State::AutoSlotReplace)) 00175 { 00176 subRefCP(chunk); 00177 _mfChunks.erase(_mfChunks.begin() + i); 00178 if(i < _mfSlots.size()) 00179 _mfSlots.erase(_mfSlots.begin() + i); 00180 return false; 00181 } 00182 } 00183 00184 SWARNING << "ChunkMaterial::subChunk(" << this << ") has no chunk " 00185 << chunk << " with slot " << slot << std::endl; 00186 00187 return true; 00188 }
|
|
|
Search the list of chunks for the given chunk. Returns its index, -1 if the chunk is not used in the material. Definition at line 194 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, and osg::MField< FieldTypeT, fieldNameSpace >::size(). 00195 { 00196 UInt32 i; 00197 00198 for(i = 0; i < _mfChunks.size(); ++i) 00199 { 00200 if(_mfChunks[i] == chunk) 00201 return i; 00202 } 00203 00204 return -1; 00205 }
|
|
||||||||||||
|
Search the list of chunks for a chunk of the given type and the given slot. If slot is State::AutoSlotReplace, all slots are searched and the first found chunk is returned. Definition at line 212 of file OSGChunkMaterial.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::State::AutoSlotReplace, osg::ChunkMaterialBase::getSlots(), osg::NullFC, p, and osg::MField< FieldTypeT, fieldNameSpace >::size(). 00214 { 00215 UInt32 index = 0; 00216 for(UInt32 i = 0; i < _mfChunks.size(); ++i) 00217 { 00218 StateChunkPtr p = _mfChunks[i]; 00219 Int32 s = State::AutoSlotReplace; 00220 00221 if(i < getSlots().size()) 00222 s = getSlots(i); 00223 00224 if(s == State::AutoSlotReplace) 00225 s = index; 00226 00227 if(p->getType() == type) 00228 { 00229 if(slot == State::AutoSlotReplace || slot == s) 00230 return (p); 00231 ++index; 00232 } 00233 } 00234 return NullFC; 00235 }
|
|
|
Add the given chunk to the material. It is possible to specify which slot this chunk should be associated with. See StateChunkClass for a general description of the slots concept. The default slot is State::AutoSlotReplace. Definition at line 237 of file OSGChunkMaterial.cpp. 00238 { 00239 Material& thisBase = *this; 00240 if (!(thisBase == other)) 00241 return false; 00242 00243 const ChunkMaterial* othercm = dynamic_cast<const ChunkMaterial*>(&other); 00244 if (!othercm) 00245 return false; 00246 00247 // ? 00248 return false; 00249 }
|
|
|
Reimplemented from osg::Material. Reimplemented in osg::FresnelMaterial, osg::PhongMaterial, osg::SimpleMaterial, osg::SimpleTexturedMaterial, and osg::DVRAppearance. Definition at line 85 of file OSGChunkMaterial.cpp.
|
|
|
|
|
|
Reimplemented from osg::MaterialBase. Reimplemented in osg::FresnelMaterialBase, osg::PhongMaterialBase, osg::SimpleMaterialBase, osg::SimpleTexturedMaterialBase, and osg::DVRAppearanceBase. Definition at line 58 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_type. Referenced by osg::ChunkMaterialBase::create(). 00059 { 00060 return _type; 00061 }
|
|
|
Reimplemented from osg::MaterialBase. Reimplemented in osg::FresnelMaterialBase, osg::PhongMaterialBase, osg::SimpleMaterialBase, osg::SimpleTexturedMaterialBase, and osg::DVRAppearanceBase. Definition at line 65 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_type, and osg::TypeBase::getId(). 00066 { 00067 return _type.getId(); 00068 }
|
|
|
Reimplemented from osg::MaterialBase. Reimplemented in osg::FresnelMaterialBase, osg::PhongMaterialBase, osg::SimpleMaterialBase, osg::SimpleTexturedMaterialBase, and osg::DVRAppearanceBase. Definition at line 117 of file OSGChunkMaterialBase.cpp. References osg::ChunkMaterialBase::_type. 00118 { 00119 return _type; 00120 }
|
|
|
Reimplemented from osg::MaterialBase. Reimplemented in osg::FresnelMaterialBase, osg::PhongMaterialBase, osg::SimpleMaterialBase, osg::SimpleTexturedMaterialBase, and osg::DVRAppearanceBase. Definition at line 122 of file OSGChunkMaterialBase.cpp. References osg::ChunkMaterialBase::_type. 00123 { 00124 return _type; 00125 }
|
|
|
Reimplemented from osg::MaterialBase. Reimplemented in osg::FresnelMaterialBase, osg::PhongMaterialBase, osg::SimpleMaterialBase, osg::SimpleTexturedMaterialBase, and osg::DVRAppearanceBase. Definition at line 137 of file OSGChunkMaterialBase.cpp. 00138 { 00139 return sizeof(ChunkMaterial); 00140 }
|
|
|
Definition at line 101 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_mfChunks. 00102 { 00103 return &_mfChunks; 00104 }
|
|
|
Definition at line 108 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_mfSlots. 00109 { 00110 return &_mfSlots; 00111 }
|
|
|
Definition at line 117 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_mfChunks. 00118 { 00119 return _mfChunks[index]; 00120 }
|
|
|
Definition at line 124 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_mfChunks. 00125 { 00126 return _mfChunks; 00127 }
|
|
|
Definition at line 131 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_mfChunks. 00132 { 00133 return _mfChunks; 00134 }
|
|
|
Definition at line 138 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_mfSlots. 00139 { 00140 return _mfSlots[index]; 00141 }
|
|
|
Definition at line 145 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_mfSlots. Referenced by find(). 00146 { 00147 return _mfSlots; 00148 }
|
|
|
Definition at line 152 of file OSGChunkMaterialBase.inl. References osg::ChunkMaterialBase::_mfSlots. 00153 { 00154 return _mfSlots; 00155 }
|
|
|
||||||||||||
|
Reimplemented from osg::MaterialBase. Reimplemented in osg::FresnelMaterialBase, osg::PhongMaterialBase, osg::SimpleMaterialBase, osg::SimpleTexturedMaterialBase, and osg::DVRAppearanceBase. Definition at line 221 of file OSGChunkMaterialBase.cpp. References osg::ChunkMaterialBase::_mfChunks, osg::ChunkMaterialBase::_mfSlots, osg::ChunkMaterialBase::ChunksFieldMask, osg::MField< FieldTypeT, fieldNameSpace >::copyToBin(), osg::MaterialBase::copyToBin(), osg::FieldBits::NoField, and osg::ChunkMaterialBase::SlotsFieldMask. Referenced by osg::SimpleMaterialBase::copyToBin(), osg::PhongMaterialBase::copyToBin(), osg::FresnelMaterialBase::copyToBin(), and osg::DVRAppearanceBase::copyToBin(). 00223 { 00224 Inherited::copyToBin(pMem, whichField); 00225 00226 if(FieldBits::NoField != (ChunksFieldMas |