I am using a ManualObject to load in a .OBJ file and then trying to assign a MaterialPtr via name to the ManualObject->begin, it compiles successfully but the material is white, which i presume Ogre defaults to "BaseWhiteNoLighting". I changed the setDiffuse to take the ColorValue red as a test.
m_material refers to the data loaded in from the .MTL file, this works perfectly fine
I can't understand why the code below doesn't work:
Creating the material
Code: Select all
m_materialPtr = Ogre::MaterialManager::getSingleton().create(ss.str(), "General", true); //create a material
m_technique = m_materialPtr->getTechnique(0);
m_pass = m_technique->getPass(0);
m_materialPtr->setSceneBlending(Ogre::SceneBlendType::SBT_TRANSPARENT_ALPHA);
m_materialPtr->setDepthWriteEnabled(false);
//load diffuse data from MTL
m_pass->setEmissive(Ogre::ColourValue(m_material->m_diffuse.x,
m_material->m_diffuse.y, m_material->m_diffuse.z, 1.0f));
m_pass->setDiffuse(Ogre::ColourValue::Red);
//Load the ambient colour values from data from MTL
m_pass->setAmbient(Ogre::ColourValue(m_material->m_ambient.x,
m_material->m_ambient.y, m_material->m_ambient.z, 1.0f));
//set the specular colours from the MTL
m_pass->setSpecular(Ogre::ColourValue(m_material->m_spec.x,
m_material->m_spec.y, m_material->m_spec.z, 1.0f));
//set the power of the specular light
m_pass->setShininess(m_material->m_spec_focus);
//Ogre::TextureUnitState* lTextureUnit = m_pass->createTextureUnitState();
//lTextureUnit->setTextureName("TexName.jpeg", Ogre::TEX_TYPE_2D);
//lTextureUnit->setTextureCoordSet(0);
m_materialPtr->compile();
m_materialPtr->load();
Code: Select all
m_sceneNode_OBJ->begin(m_material->name(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
// push the vertices into the OBJ
for (unsigned int i = 0; i < _verts_indices.size(); i++)
{
m_sceneNode_OBJ->position(_verts_indices.at(i));
m_sceneNode_OBJ->textureCoord(_uv_coords.at(i));
m_sceneNode_OBJ->normal(_normals.at(i));
}
// end rendering phase
m_sceneNode_OBJ->end();