MCPcopy Create free account
hub / github.com/OGRECave/ogre-next / parseShape

Function parseShape

Tools/VRMLConverter/src/VRML2mesh.cpp:197–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197void parseShape(Mesh *mesh, const Shape *sh, Matrix4 mat)
198{
199try
200{
201 LogManager &log = LogManager::getSingleton();
202 log.logMessage("Found a Shape...");
203
204 IndexedFaceSet *ifs = dynamic_cast<IndexedFaceSet *>(sh->geometry);
205 if (!ifs)
206 throw "Geometry was not an IndexedFaceSet, keep looking";
207
208 Coordinate *coord = dynamic_cast<Coordinate *>(ifs->coord);
209 if (!coord)
210 throw "Invalid Coordinate node";
211 if (coord->point.empty())
212 throw "No coordinates found, ignoring this Shape";
213
214 SubMesh *sub;
215 if (const String *name = findNameRecursive(sh)) {
216 log.logMessage("Creating SubMesh: " + *name);
217 sub = mesh->createSubMesh(*name);
218 } else {
219 log.logMessage("Creating unnamed SubMesh");
220 sub = mesh->createSubMesh();
221 }
222
223 Appearance *app = dynamic_cast<Appearance *>(sh->appearance);
224 TextureCoordinate *tcs = dynamic_cast<TextureCoordinate *>(ifs->texCoord);
225 Normal *norm = dynamic_cast<Normal *>(ifs->normal);
226 Color *color = dynamic_cast<Color *>(ifs->color);
227
228 String message = "Found: geometry";
229 if (tcs)
230 message += ", texcoords";
231 if (norm)
232 message += ", normals";
233 if (color)
234 message += ", colours";
235 log.logMessage(message);
236
237 if (!tcs && !norm && !color)
238 log.logMessage("Warning: OGRE will refuse to render SubMeshes that have neither\n"
239 "\ttexture coordinates, normals or vertex colours.");
240
241 if (!norm) {
242 log.logMessage("Warning: No normals found.\n"
243 "\tVRML dictates that normals should be generated, but this program\n"
244 "\tdoes not do so. If you want the resulting mesh to contain normals,\n"
245 "\tmake sure they are exported.");
246 }
247
248 // process material
249 static std::map<Appearance *, Ogre::MaterialPtr> matMap;
250
251 Ogre::MaterialPtr material = matMap[app];
252 if (material && app) {
253 log.logMessage("Using material " + material->getName());
254 sub->setMaterialName(material->getName());

Callers 1

parseNodeFunction · 0.85

Calls 11

findNameRecursiveFunction · 0.85
findNameFunction · 0.85
parseMaterialFunction · 0.85
parseFacesFunction · 0.85
triangulateAndExpandFunction · 0.85
copyToSubMeshFunction · 0.85
logMessageMethod · 0.45
emptyMethod · 0.45
createSubMeshMethod · 0.45
getNameMethod · 0.45
setMaterialNameMethod · 0.45

Tested by

no test coverage detected