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

Function parseMaterial

Tools/VRMLConverter/src/VRML2mesh.cpp:476–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

474}
475
476Ogre::MaterialPtr parseMaterial(const Appearance *app, const String &name)
477{
478 vrmllib::Material *vm = app ? dynamic_cast<vrmllib::Material *>(app->material) : 0;
479 vrmllib::ImageTexture *texture = app ? dynamic_cast<vrmllib::ImageTexture *>(app->texture) : 0;
480
481 Ogre::MaterialPtr m = MaterialManager::getSingleton().create(name,
482 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
483
484 ColourValue diffuse = texture ? ColourValue::White : col(vm->diffuseColor);
485 // diffuse colour is unused by VRML when a texture is avaliable,
486 // set to white to give the same effect in OGRE
487
488 ColourValue a = diffuse;
489 a.r *= vm->ambientIntensity;
490 a.g *= vm->ambientIntensity;
491 a.b *= vm->ambientIntensity;
492 m->setAmbient(a);
493 m->setDiffuse(diffuse);
494 m->setSelfIllumination(col(vm->emissiveColor));
495 m->setShininess(vm->shininess);
496 m->setSpecular(col(vm->specularColor));
497
498 m->setLightingEnabled(app);
499
500 if (texture && !texture->url.empty()) {
501 String texName = texture->url.front();
502 size_t p = texName.find_last_of("/\\");
503 if (p != texName.npos) {
504 LogManager::getSingleton().logMessage("Stripping path from texture " + texName);
505 texName.erase(0, p+1);
506 }
507
508 LogManager::getSingleton().logMessage("Adding texture layer for " + texName);
509
510 Ogre::TextureUnitState *l = m->addTextureLayer(texName);
511 l->setTextureAddressingMode(texture->repeatS ?
512 Ogre::TextureUnitState::TAM_WRAP : Ogre::TextureUnitState::TAM_CLAMP);
513 }
514
515 return m;
516}
517
518Matrix4 transMat(vrmllib::vec3 v, bool inverse)
519{

Callers 1

parseShapeFunction · 0.85

Calls 14

colFunction · 0.85
find_last_ofMethod · 0.80
createMethod · 0.45
setAmbientMethod · 0.45
setDiffuseMethod · 0.45
setSelfIlluminationMethod · 0.45
setShininessMethod · 0.45
setSpecularMethod · 0.45
setLightingEnabledMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected