Changeset 10147 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Dec 25, 2006, 1:30:44 PM (18 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 8 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/Makefile.am
r10033 r10147 25 25 \ 26 26 obj/objModel.cc \ 27 \ 28 oif/object_information_file.cc \ 29 oif/resource_oif.cc \ 27 30 \ 28 31 bsp/bsp_manager.cc \ … … 79 82 obj/objModel.h \ 80 83 \ 84 oif/object_information_file.h \ 85 oif/resource_oif.h \ 86 \ 81 87 md2/md2Model.h \ 82 88 md2/resource_md2.h \ -
trunk/src/lib/graphics/importer/model.h
r9869 r10147 83 83 inline unsigned int getTriangleCount() const { return this->pModelInfo.numTriangles; }; 84 84 85 /** function to extract the mount points from the model data */ 86 virtual void extractMountPoints() {} 87 88 85 89 protected: 86 90 Model(); -
trunk/src/lib/graphics/importer/obj/objModel.cc
r10033 r10147 44 44 45 45 this->finalize(); 46 47 this->extractMountPoints(); 46 48 } 47 49 … … 138 140 this->addVertexTexture(buffer+3); 139 141 } 140 // case group 141 else if (!strncmp(buffer, "g ", 2) )142 // case group or object (depends on the exporter program) 143 else if (!strncmp(buffer, "g ", 2) || !strncmp(buffer, "o ", 2)) 142 144 { 143 145 this->addGroup (buffer+2); -
trunk/src/lib/graphics/importer/obj/objModel.h
r10033 r10147 16 16 OBJModel(const std::string& fileName, float scaling = 1.0); 17 17 virtual ~OBJModel(); 18 18 19 19 20 private: -
trunk/src/lib/graphics/importer/static_model.cc
r9869 r10147 91 91 this->updateBase(); 92 92 } 93 94 95 96 /** 97 * extract the mount points from this file: looking at each group and checking if the group realy is a mountpoint marker 98 * if so get place and orientation 99 */ 100 void StaticModel::extractMountPoints() 101 { 102 103 // go through all groups and check if they are mounts 104 std::vector<StaticModelData::Group>::const_iterator groupIt = this->data->getGroups().begin(); 105 for( ; groupIt != this->data->getGroups().end(); groupIt++) 106 { 107 //PRINTF(0)("Found a MountPoint: %s\n", groupName.c_str()); 108 109 // get the name of this group and check if it's a mout point identifier 110 std::string groupName = (*groupIt).name; 111 std::vector<Vector> vertices; 112 113 if( groupName.find("MP.", 0) != std::string::npos) 114 { 115 PRINTF(0)("Found a MountPoint: %s\n", groupName.c_str()); 116 117 // now check if it is a mount point identifier 118 if( this->data->getGroups().size() != 5) { 119 PRINTF(1)("the face count of %s is wrong, perhaps you missnamed this object or used the wrong mount point object\n", groupName.c_str()); 120 } 121 122 // now extract the direction from the length: 123 std::vector<StaticModelData::Face>::const_iterator faceIt = (*groupIt)._faces.begin(); 124 for( ; faceIt < (*groupIt)._faces.end(); faceIt++) 125 { 126 // now go through all modelfaceelements 127 std::vector<StaticModelData::FaceElement>::const_iterator faceElementIt = (*faceIt)._elements.begin(); 128 for( ; faceElementIt < (*faceIt)._elements.end(); faceElementIt++) 129 { 130 int vert = (*faceElementIt).vertexNumber; 131 vertices.push_back(Vector(this->data->getVertices()[vert*3], 132 this->data->getVertices()[vert*3 + 1], 133 this->data->getVertices()[vert*3 + 2])); 134 } 135 } 136 137 // vertex with the max count is the up-point 138 std::vector<Vector>::const_iterator it = vertices.begin(); 139 Vector tmpPoint; 140 int tmpCount; 141 Vector upPoint; 142 int maxCount = 0; 143 for( ; it < vertices.end(); it++) 144 { 145 tmpCount = 0; 146 tmpPoint = (*it); 147 // 148 std::vector<Vector>::const_iterator it2 = vertices.begin(); 149 for( ; it2 < vertices.end(); it2++) 150 if( tmpPoint == *it2) 151 tmpCount++; 152 153 // if this is the vertex with the most surrounding vertices 154 if( tmpCount > maxCount) 155 { 156 upPoint = tmpPoint; 157 maxCount = tmpCount; 158 } 159 } 160 161 // now get the center of the object 162 Vector center; 163 it = vertices.begin(); 164 for( ; it < vertices.end(); it++) 165 center += (*it); 166 // scale 167 center /= vertices.size(); 168 169 170 } 171 172 } 173 174 175 } 176 177 93 178 94 179 /** -
trunk/src/lib/graphics/importer/static_model.h
r10141 r10147 58 58 59 59 void finalize(); 60 void extractMountPoints(); 60 61 61 62 void acquireData(const StaticModelData::Pointer& data); -
trunk/src/lib/graphics/importer/static_model_data.cc
r10141 r10147 276 276 bool StaticModelData::addGroup(const std::string& groupString) 277 277 { 278 PRINTF( 5)("Read Group: %s.\n", groupString.c_str());278 PRINTF(4)("Read Group: %s.\n", groupString.c_str()); 279 279 if (!_modelGroups.empty() && !_modelGroups.back()._faces.empty()) 280 280 _modelGroups.push_back(Group()); 281 281 282 if (groupString == "default") 283 _modelGroups.back().name = groupString; 284 // setting the group name if not default. 282 _modelGroups.back().name = groupString; 285 283 return true; 286 284 } -
trunk/src/lib/graphics/importer/static_model_data.h
r10141 r10147 129 129 ///! HACK SOLUTION sTriangleExt should be const in the modelInfo. 130 130 sTriangleExt* getTrianglesExt() { return &this->triangles[0]; }; 131 const std::vector<Group>& getGroups() { return this->_modelGroups; } 131 132 132 133 float getScaleFactor() const { return scaleFactor; }
Note: See TracChangeset
for help on using the changeset viewer.