#include <OSGOFFSceneFileType.h>
Inheritance diagram for osg::OFFSceneFileType:

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