#include <OSGOFFSceneFileType.h>

Public Types | |
| typedef std::vector < FieldContainerPtr > | FCPtrStore |
Flags | |
| enum | { OSG_READ_SUPPORTED = 1, OSG_WRITE_SUPPORTED = 2 } |
Public Member Functions | |
Destructors | |
| virtual | ~OFFSceneFileType (void) |
Get | |
| virtual const Char8 * | getName (void) const |
Read | |
| virtual NodePtr | read (std::istream &is, const Char8 *fileNameOrExtension) const |
Set | |
| void | setOptions (const Char8 *options) |
Get | |
| virtual std::list< IDString > & | suffixList (void) |
| bool | doOverride (void) |
| UInt32 | getOverridePriority (void) |
| UInt32 | getFlags (void) |
| const Char8 * | getOptions (void) |
Read | |
| virtual NodePtr | readFile (const Char8 *fileName) const |
Write | |
| virtual bool | write (const NodePtr &node, std::ostream &os, const Char8 *fileNameOrExtension) const |
| virtual bool | writeFile (const NodePtr &node, const Char8 *fileName) const |
Debug | |
| void | print (void) |
Static Public Member Functions | |
Class Get | |
| static OFFSceneFileType & | the (void) |
Protected Member Functions | |
Constructors | |
| OFFSceneFileType (const Char8 *suffixArray[], UInt16 suffixByteCount, bool override, UInt32 overridePriority, UInt32 flags) | |
| OFFSceneFileType (const OFFSceneFileType &obj) | |
Protected Attributes | |
Member | |
| std::list< IDString > | _suffixList |
| bool | _override |
| UInt32 | _overridePriority |
| UInt32 | _flags |
| std::string | _options |
Static Protected Attributes | |
Member | |
| static const Char8 * | _suffixA [] = { "off" } |
| static OFFSceneFileType | _the |
Private Types | |
| typedef SceneFileType | Inherited |
Private Member Functions | |
| void | operator= (const OFFSceneFileType &source) |
| prohibit default function (move to 'public' if needed) | |
Definition at line 54 of file OSGOFFSceneFileType.h.
typedef SceneFileType osg::OFFSceneFileType::Inherited [private] |
Definition at line 115 of file OSGOFFSceneFileType.h.
typedef std::vector<FieldContainerPtr> osg::SceneFileType::FCPtrStore [inherited] |
Reimplemented in osg::OSGSceneFileType, and osg::VRMLSceneFileType.
Definition at line 65 of file OSGSceneFileType.h.
anonymous enum [inherited] |
Definition at line 78 of file OSGSceneFileType.h.
00079 { 00080 OSG_READ_SUPPORTED = 1, 00081 OSG_WRITE_SUPPORTED = 2 00082 };
| OFFSceneFileType::~OFFSceneFileType | ( | void | ) | [virtual] |
| OFFSceneFileType::OFFSceneFileType | ( | const Char8 * | suffixArray[], | |
| UInt16 | suffixByteCount, | |||
| bool | override, | |||
| UInt32 | overridePriority, | |||
| UInt32 | flags | |||
| ) | [protected] |
constructors & destructors
Definition at line 445 of file OSGOFFSceneFileType.cpp.
00448 : 00449 SceneFileType(suffixArray, suffixByteCount, 00450 override, overridePriority, flags) 00451 { 00452 }
| OFFSceneFileType::OFFSceneFileType | ( | const OFFSceneFileType & | obj | ) | [protected] |
constructors & destructors
Definition at line 474 of file OSGOFFSceneFileType.cpp.
00474 : 00475 SceneFileType(obj) 00476 { 00477 return; 00478 }
| OFFSceneFileType & OFFSceneFileType::the | ( | void | ) | [static] |
Definition at line 500 of file OSGOFFSceneFileType.cpp.
References _the.
00501 { 00502 return _the; 00503 }
| const Char8 * OFFSceneFileType::getName | ( | void | ) | const [virtual] |
| NodePtr OFFSceneFileType::read | ( | std::istream & | is, | |
| const Char8 * | fileNameOrExtension | |||
| ) | const [virtual] |
Reimplemented from osg::SceneFileType.
Definition at line 120 of file OSGOFFSceneFileType.cpp.
References osg::FieldBits::AllFields, osg::beginEditCP(), osg::calcVertexNormals(), osg::Node::CoreFieldMask, osg::SimpleMaterialBase::create(), osg::GeoProperty< GeoPropertyDesc >::create(), osg::GeometryBase::create(), osg::Node::create(), osg::createSharedIndex(), osg::endEditCP(), FDEBUG, FFATAL, FNOTICE, FWARNING, osg::NullFC, osg::Color4< ValueTypeT >::setValuesRGBA(), osg::SceneFileHandler::the(), and osg::SceneFileHandler::updateReadProgress().
00121 { 00122 typedef std::vector<int> Face; 00123 00124 std::vector<Face> faceVec; 00125 00126 char head[256]; 00127 NodePtr root; 00128 GeometryPtr geo; 00129 Pnt3f point; 00130 Vec3f norm; 00131 Color4f color; 00132 Vec2f texcoord; 00133 GeoPositions3fPtr points; 00134 GeoIndicesUI32Ptr index; 00135 GeoPLengthsPtr lens; 00136 GeoPTypesPtr type; 00137 GeoNormals3fPtr norms; 00138 GeoColors4fPtr colors; 00139 GeoTexCoords2fPtr texcoords; 00140 SimpleMaterialPtr mat; 00141 Int32 i, j, k, n, vN, fN, pType; 00142 Int32 triCount = 0, vertexCount, faceCount, edgeCount; 00143 Real32 x, y, z, a; 00144 bool hasNormals = false, hasColors = false, hasTexCoords = false, 00145 has4DimPoints = false; 00146 00147 if(!is) 00148 { 00149 return NullFC; 00150 } 00151 00152 is >> head >> vertexCount >> faceCount >> edgeCount; 00153 00154 FDEBUG(("OFF Head/vertexCount/faceCount: %s/%d/%d\n", head, 00155 vertexCount, faceCount)); 00156 00157 if(!vertexCount || !faceCount) 00158 { 00159 return NullFC; 00160 } 00161 00162 if(strstr(head, "ST")) 00163 { 00164 hasTexCoords = true; 00165 } 00166 00167 if(strstr(head, "C")) 00168 { 00169 hasColors = true; 00170 } 00171 00172 if(strstr(head, "N")) 00173 { 00174 hasNormals = true; 00175 } 00176 00177 if(strstr(head, "4")) 00178 { 00179 has4DimPoints = true; 00180 } 00181 00182 if(strstr(head, "nOFF")) 00183 { 00184 int ndim; 00185 00186 is >> ndim; 00187 00188 if(ndim != 3) 00189 { 00190 FWARNING(("OFFSceneFileType::read: nOFF with ndim != 3 not supported.\n")); 00191 return NullFC; 00192 } 00193 } 00194 00195 if(has4DimPoints) 00196 { 00197 FWARNING(("OFFSceneFileType::read: 4D points not supported.\n")); 00198 return NullFC; 00199 } 00200 00201 00202 //------------------------------------------------------------------- 00203 // create the OSG objects 00204 root = Node::create(); 00205 geo = Geometry::create(); 00206 points = GeoPositions3f::create(); 00207 index = GeoIndicesUI32::create(); 00208 lens = GeoPLengthsUI32::create(); 00209 type = GeoPTypesUI8::create(); 00210 mat = SimpleMaterial::create(); 00211 if (hasNormals) 00212 norms = GeoNormals3f::create(); 00213 if (hasColors) 00214 colors = GeoColors4f::create(); 00215 if (hasTexCoords) 00216 texcoords = GeoTexCoords2f::create(); 00217 00218 beginEditCP(mat); 00219 { 00220 mat->setDiffuse(Color3f(0.42, 0.42, 0.52)); 00221 mat->setSpecular(Color3f(1, 1, 1)); 00222 mat->setShininess(20); 00223 } 00224 endEditCP(mat); 00225 00226 beginEditCP(root, Node::CoreFieldMask); 00227 { 00228 root->setCore(geo); 00229 } 00230 endEditCP(root, Node::CoreFieldMask); 00231 00232 beginEditCP(geo); 00233 { 00234 geo->setPositions(points); 00235 geo->setIndices(index); 00236 geo->setLengths(lens); 00237 geo->setTypes(type); 00238 geo->setMaterial(mat); 00239 if (hasNormals) 00240 geo->setNormals(norms); 00241 if (hasColors) 00242 geo->setColors(colors); 00243 if (hasTexCoords) 00244 geo->setTexCoords(texcoords); 00245 00246 } 00247 endEditCP(geo); 00248 00249 //------------------------------------------------------------------- 00250 // read/set the points 00251 beginEditCP(points); 00252 if(hasNormals) 00253 beginEditCP(norms); 00254 if(hasColors) 00255 beginEditCP(colors); 00256 if(hasTexCoords) 00257 beginEditCP(texcoords); 00258 00259 { 00260 for(i = 0; (!is.eof()) && (i < vertexCount); i++) 00261 { 00262 SceneFileHandler::the().updateReadProgress(); 00263 is >> x >> y >> z; 00264 point.setValues(Real32(x), Real32(y), Real32(z)); 00265 points->push_back(point); 00266 00267 if(hasNormals) 00268 { 00269 is >> x >> y >> z; 00270 norm.setValues(Real32(x), Real32(y), Real32(z)); 00271 norms->push_back(norm); 00272 } 00273 00274 if(hasColors) 00275 { 00276 is >> x >> y >> z >> a; 00277 color.setValuesRGBA(Real32(x), 00278 Real32(y), 00279 Real32(z), 00280 Real32(a)); 00281 colors->getField().push_back(color); 00282 } 00283 00284 if(hasTexCoords) 00285 { 00286 is >> x >> y; 00287 texcoord.setValues(Real32(x), Real32(y)); 00288 texcoords->push_back(texcoord); 00289 } 00290 } 00291 } 00292 endEditCP(points); 00293 if(hasNormals) 00294 endEditCP(norms); 00295 if(hasColors) 00296 endEditCP(colors); 00297 if(hasTexCoords) 00298 endEditCP(texcoords); 00299 00300 //------------------------------------------------------------------- 00301 // read the faces 00302 // TODO; should we 'reserve' some index mem (3,4,..) ? 00303 faceVec.resize(faceCount); 00304 triCount = 0; 00305 for(i = 0; (!is.eof()) && (i < faceCount); i++) 00306 { 00307 is >> n; 00308 if(n >= 0) 00309 { 00310 triCount += n - 2; 00311 for(j = 0; (!is.eof()) && (j < n); j++) 00312 { 00313 is >> k; 00314 if((k >= 0) && (k < vertexCount)) 00315 faceVec[i].push_back(k); 00316 else 00317 { 00318 FFATAL(("Invalid vertex index %d in face %d\n", k, i 00319 )); 00320 } 00321 } 00322 is.ignore(1000, '\n'); 00323 } 00324 else 00325 { 00326 FFATAL(("Invalid face vec num %d\n", n)); 00327 } 00328 } 00329 00330 //------------------------------------------------------------------- 00331 // set the faces 00332 for(i = 3; i <= 5; i++) 00333 { 00334 n = 0; 00335 for(j = 0; j < faceCount; j++) 00336 { 00337 fN = faceVec[j].size(); 00338 if(fN >= 5) 00339 fN = 5; 00340 if(fN == i) 00341 { 00342 n += vN = faceVec[j].size(); 00343 for(k = vN - 1; k >= 0; k--) 00344 { 00345 index->getFieldPtr()->push_back(faceVec[j][k]); 00346 } 00347 00348 if(i == 5) 00349 { 00350 beginEditCP(lens); 00351 { 00352 lens->push_back(n); 00353 } 00354 endEditCP(lens); 00355 00356 beginEditCP(type, FieldBits::AllFields); 00357 { 00358 type->push_back(GL_POLYGON); 00359 } 00360 endEditCP(type, FieldBits::AllFields); 00361 } 00362 } 00363 } 00364 00365 if(n) 00366 { 00367 switch(i) 00368 { 00369 case 3: 00370 pType = GL_TRIANGLES; 00371 break; 00372 case 4: 00373 pType = GL_QUADS; 00374 break; 00375 default: 00376 pType = 0; 00377 break; 00378 } 00379 00380 if(pType) 00381 { 00382 beginEditCP(lens); 00383 { 00384 lens->push_back(n); 00385 } 00386 endEditCP(lens); 00387 00388 beginEditCP(type, FieldBits::AllFields); 00389 { 00390 type->push_back(pType); 00391 } 00392 endEditCP(type, FieldBits::AllFields); 00393 } 00394 } 00395 } 00396 00397 FNOTICE(("Number of triangle read: %d\n", triCount)); 00398 00399 createSharedIndex(geo); 00400 if(!hasNormals) 00401 calcVertexNormals(geo); 00402 00403 SceneFileHandler::the().updateReadProgress(100); 00404 return root; 00405 }
| void osg::OFFSceneFileType::operator= | ( | const OFFSceneFileType & | source | ) | [private] |
| void SceneFileType::setOptions | ( | const Char8 * | options | ) | [inherited] |
Definition at line 115 of file OSGSceneFileType.cpp.
References osg::SceneFileType::_options.
Referenced by osg::SceneFileHandler::setOptions().
00116 { 00117 _options = options; 00118 }
| std::list< IDString > & SceneFileType::suffixList | ( | void | ) | [virtual, inherited] |
Definition at line 138 of file OSGSceneFileType.cpp.
References osg::SceneFileType::_suffixList.
Referenced by osg::SceneFileHandler::addSceneFileType(), and osg::SceneFileHandler::subSceneFileType().
00139 { 00140 return _suffixList; 00141 }
| bool SceneFileType::doOverride | ( | void | ) | [inherited] |
Definition at line 145 of file OSGSceneFileType.cpp.
References osg::SceneFileType::_override.
Referenced by osg::SceneFileHandler::addSceneFileType(), and osg::SceneFileHandler::FindOverride::operator()().
00146 { 00147 return _override; 00148 }
| UInt32 SceneFileType::getOverridePriority | ( | void | ) | [inherited] |
Definition at line 152 of file OSGSceneFileType.cpp.
References osg::SceneFileType::_overridePriority.
Referenced by osg::SceneFileHandler::addSceneFileType(), and osg::SceneFileHandler::FindOverride::operator()().
00153 { 00154 return _overridePriority; 00155 }
| UInt32 SceneFileType::getFlags | ( | void | ) | [inherited] |
Definition at line 159 of file OSGSceneFileType.cpp.
References osg::SceneFileType::_flags.
Referenced by osg::SceneFileHandler::getSuffixList(), and osg::SceneFileHandler::print().
00160 { 00161 return _flags; 00162 }
| const Char8 * SceneFileType::getOptions | ( | void | ) | [inherited] |
Definition at line 166 of file OSGSceneFileType.cpp.
References osg::SceneFileType::_options.
Referenced by osg::SceneFileHandler::getOptions().
00167 { 00168 return _options.c_str(); 00169 }
Definition at line 181 of file OSGSceneFileType.cpp.
References FWARNING, and osg::NullFC.
Referenced by osg::SceneFileHandler::read().
| bool SceneFileType::write | ( | const NodePtr & | node, | |
| std::ostream & | os, | |||
| const Char8 * | fileNameOrExtension | |||
| ) | const [virtual, inherited] |
Reimplemented in osg::BINSceneFileType, osg::OBJSceneFileType, osg::OSGSceneFileType, and osg::VRMLSceneFileType.
Definition at line 188 of file OSGSceneFileType.cpp.
References FWARNING.
Referenced by osg::SceneFileHandler::write().
00191 { 00192 FWARNING (("STREAM INTERFACE NOT IMPLEMENTED!\n")); 00193 return false; 00194 }
| bool SceneFileType::writeFile | ( | const NodePtr & | node, | |
| const Char8 * | fileName | |||
| ) | const [virtual, inherited] |
Definition at line 197 of file OSGSceneFileType.cpp.
References FWARNING.
Referenced by osg::SceneFileHandler::write().
00199 { 00200 FWARNING (("FILE INTERFACE NOT IMPLEMENTED!\n")); 00201 return false; 00202 }
| void SceneFileType::print | ( | void | ) | [inherited] |
Definition at line 121 of file OSGSceneFileType.cpp.
References osg::SceneFileType::_suffixList, osg::SceneFileType::getName(), osg::LOG_DEBUG, osg::osgLog(), and osg::Log::stream().
00122 { 00123 std::list<IDString>::iterator sI; 00124 00125 osgLog() << getName(); 00126 00127 if (_suffixList.empty()) 00128 osgLog() << "NONE"; 00129 else 00130 for (sI = _suffixList.begin(); sI != _suffixList.end(); sI++) 00131 osgLog().stream(OSG::LOG_DEBUG) << sI->str() << " "; 00132 00133 osgLog() << std::endl; 00134 }
const Char8 * OFFSceneFileType::_suffixA = { "off" } [static, protected] |
Definition at line 95 of file OSGOFFSceneFileType.h.
OFFSceneFileType OFFSceneFileType::_the [static, protected] |
std::list<IDString> osg::SceneFileType::_suffixList [protected, inherited] |
Definition at line 152 of file OSGSceneFileType.h.
Referenced by osg::SceneFileType::print(), osg::SceneFileType::SceneFileType(), and osg::SceneFileType::suffixList().
bool osg::SceneFileType::_override [protected, inherited] |
UInt32 osg::SceneFileType::_overridePriority [protected, inherited] |
Definition at line 155 of file OSGSceneFileType.h.
Referenced by osg::SceneFileType::getOverridePriority().
UInt32 osg::SceneFileType::_flags [protected, inherited] |
std::string osg::SceneFileType::_options [protected, inherited] |
Definition at line 158 of file OSGSceneFileType.h.
Referenced by osg::SceneFileType::getOptions(), osg::SceneFileType::setOptions(), and osg::VRMLSceneFileType::write().
1.5.5