Changeset 13041 for OpenSceneGraph/trunk/src/osgPlugins/obj/obj.h
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgPlugins/obj/obj.h (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/obj/obj.h
r9205 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 47 47 // textureReflection(false), 48 48 alpha(1.0f) {} 49 49 50 50 std::string name; 51 51 52 52 osg::Vec4 ambient; 53 53 osg::Vec4 diffuse; … … 56 56 float sharpness; 57 57 int illum; // read but not implemented (would need specific shaders or state manipulation) 58 58 59 59 osg::Vec4 Tf; 60 60 int Ni; … … 126 126 POLYGON 127 127 }; 128 128 129 129 Element(DataType type): 130 130 dataType(type) {} 131 131 132 132 enum CoordinateCombination 133 133 { … … 137 137 VERTICES_NORMALS_TEXCOORDS 138 138 }; 139 139 140 140 CoordinateCombination getCoordinateCombination() const 141 141 { 142 142 if (vertexIndices.size()==normalIndices.size()) 143 143 return (vertexIndices.size()==texCoordIndices.size()) ? VERTICES_NORMALS_TEXCOORDS : VERTICES_NORMALS; 144 else 144 else 145 145 return (vertexIndices.size()==texCoordIndices.size()) ? VERTICES_TEXCOORDS : VERTICES; 146 146 } 147 148 DataType dataType; 147 148 DataType dataType; 149 149 IndexList vertexIndices; 150 150 IndexList normalIndices; … … 159 159 coordinateCombination(Element::VERTICES), 160 160 smoothingGroup(0) {} 161 161 162 162 bool operator < (const ElementState& rhs) const 163 163 { … … 190 190 Model(): 191 191 currentElementList(0) {} 192 192 193 193 void setDatabasePath(const std::string& path) { databasePath = path; } 194 194 const std::string& getDatabasePath() const { return databasePath; } … … 197 197 bool readMTL(std::istream& fin); 198 198 bool readOBJ(std::istream& fin, const osgDB::ReaderWriter::Options* options); 199 199 200 200 bool readline(std::istream& fin, char* line, const int LINE_SIZE); 201 201 void addElement(Element* element); 202 202 203 203 osg::Vec3 averageNormal(const Element& element) const; 204 204 osg::Vec3 computeNormal(const Element& element) const; 205 205 bool needReverse(const Element& element) const; 206 206 207 207 int remapVertexIndex(int vi) { return (vi<0) ? vertices.size()+vi : vi-1; } 208 208 int remapNormalIndex(int vi) { return (vi<0) ? normals.size()+vi : vi-1; } 209 209 int remapTexCoordIndex(int vi) { return (vi<0) ? texcoords.size()+vi : vi-1; } 210 210 211 211 typedef std::map<std::string,Material> MaterialMap; 212 212 typedef std::vector< osg::Vec2 > Vec2Array; … … 214 214 typedef std::vector< osg::ref_ptr<Element> > ElementList; 215 215 typedef std::map< ElementState,ElementList > ElementStateMap; 216 216 217 217 218 218 std::string databasePath; 219 219 MaterialMap materialMap; 220 220 221 221 Vec3Array vertices; 222 222 Vec3Array normals; 223 223 Vec2Array texcoords; 224 224 225 225 ElementState currentElementState; 226 226 227 227 ElementStateMap elementStateMap; 228 228 ElementList* currentElementList;
