Changeset 13041 for OpenSceneGraph/trunk/src/osgPlugins/obj/obj.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgPlugins/obj/obj.cpp (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/obj/obj.cpp
r11494 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 */ … … 48 48 if (s[0] != '-') 49 49 break; 50 50 51 51 int n; 52 52 if (s[1] == 's' || s[1] == 'o') … … 137 137 if (skipNewline) 138 138 { 139 skipNewline = false; 139 skipNewline = false; 140 140 *ptr++ = ' '; 141 141 continue; … … 147 147 if (skipNewline) 148 148 { 149 skipNewline = false; 149 skipNewline = false; 150 150 *ptr++ = ' '; 151 151 continue; … … 167 167 { 168 168 // need to keep return; 169 skipNewline = true; 169 skipNewline = true; 170 170 } 171 171 else if (c!=std::ifstream::traits_type::eof()) // don't copy eof. … … 179 179 } 180 180 } 181 182 183 } 184 181 182 183 } 184 185 185 // strip trailing spaces 186 186 while (ptr>line && *(ptr-1)==' ') … … 190 190 191 191 *ptr = 0; 192 192 193 193 if (changeTabsToSpaces) 194 194 { 195 195 196 196 for(ptr = line; *ptr != 0; ++ptr) 197 197 { … … 199 199 } 200 200 } 201 201 202 202 return true; 203 203 } … … 448 448 // map_opacity doesn't exist in the spec, but was already in the plugin 449 449 // so leave it or plugin will break for some users 450 else if (strncmp(line,"map_opacity ",12)==0) 450 else if (strncmp(line,"map_opacity ",12)==0) 451 451 { 452 452 material->maps.push_back(parseTextureMap(strip(line+12),Material::Map::OPACITY)); … … 496 496 OSG_NOTICE <<"*** line not handled *** :"<<line<<std::endl; 497 497 } 498 498 499 499 } 500 500 … … 563 563 { 564 564 char* ptr = line+2; 565 565 566 566 Element* element = new Element( (line[0]=='p') ? Element::POINTS : 567 567 (line[0]=='l') ? Element::POLYLINE : … … 575 575 // skip white space 576 576 while(*ptr==' ') ++ptr; 577 577 578 578 if (sscanf(ptr, "%d/%d/%d", &vi, &ti, &ni) == 3) 579 579 { … … 603 603 // skip to white space or end of line 604 604 while(*ptr!=' ' && *ptr!=0) ++ptr; 605 606 } 607 605 606 } 607 608 608 if (!element->normalIndices.empty() && element->normalIndices.size() != element->vertexIndices.size()) 609 609 { 610 610 element->normalIndices.clear(); 611 611 } 612 612 613 613 if (!element->texCoordIndices.empty() && element->texCoordIndices.size() != element->vertexIndices.size()) 614 614 { 615 615 element->texCoordIndices.clear(); 616 616 } 617 617 618 618 if (!element->vertexIndices.empty()) 619 619 { … … 705 705 if (strncmp(line+2,"off",3)==0) smoothingGroup = 0; 706 706 else sscanf(line+2,"%d",&smoothingGroup); 707 707 708 708 if (currentElementState.smoothingGroup != smoothingGroup) 709 709 { … … 716 716 OSG_NOTICE <<"*** line not handled *** :"<<line<<std::endl; 717 717 } 718 718 719 719 } 720 720 … … 726 726 OSG_NOTICE <<"materials :"<<materialMap.size()<<std::endl; 727 727 OSG_NOTICE <<"elementStates :"<<elementStateMap.size()<<std::endl; 728 728 729 729 unsigned int pos=0; 730 730 for(ElementStateMap::iterator itr=elementStateMap.begin(); … … 740 740 OSG_NOTICE<<" es.smoothGroup="<<es.smoothingGroup<<std::endl; 741 741 OSG_NOTICE<<" ElementList ="<<el.size()<<std::endl; 742 742 743 743 } 744 744 #endif … … 754 754 } 755 755 currentElementList->push_back(element); 756 756 757 757 } 758 758 … … 767 767 } 768 768 normal.normalize(); 769 769 770 770 return normal; 771 771 } … … 783 783 } 784 784 normal.normalize(); 785 785 786 786 return normal; 787 787 } … … 790 790 { 791 791 if (element.normalIndices.empty()) return false; 792 792 793 793 return computeNormal(element)*averageNormal(element) < 0.0f; 794 794 }
