Ejemplo n.º 1
0
	void Material::update() {
		if(!baseMaterial.isNull()) {
			Ogre::ColourValue ambient = baseMaterial->getTechnique(0)->getPass(0)->getAmbient();
			Ogre::ColourValue diffuse = baseMaterial->getTechnique(0)->getPass(0)->getDiffuse();
			Ogre::ColourValue specular = baseMaterial->getTechnique(0)->getPass(0)->getSpecular();
			Ogre::ColourValue emissive = baseMaterial->getTechnique(0)->getPass(0)->getEmissive();
			float shininess = baseMaterial->getTechnique(0)->getPass(0)->getShininess();
			GLuint tex = 0;
			if(baseMaterial->getNumTechniques()!=0 && baseMaterial->getTechnique(0)->getNumPasses()!=0 && baseMaterial->getTechnique(0)->getPass(0)->getNumTextureUnitStates()!=0) {
				Ogre::String texName = baseMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName();
				if(Ogre::TextureManager::getSingleton().resourceExists(texName)) {
					Ogre::TexturePtr texPtr = Ogre::TextureManager::getSingleton().getByName(texName);
					Ogre::Image img;
					texPtr->convertToImage(img);
					Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual(texPtr->getName()+"_optixformat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, texPtr->getWidth(), texPtr->getHeight(), 0, Ogre::PF_FLOAT32_RGBA, Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
					texture->loadImage(img);
					tex = ((Ogre::GLTexturePtr)texture)->getGLID();
				}
			}
			prepareMaterial(glm::vec3(ambient.r,ambient.g,ambient.b),
							glm::vec3(diffuse.r,diffuse.g,diffuse.b),
							glm::vec3(specular.r,specular.g,specular.b),
							glm::vec3(emissive.r,emissive.g,emissive.b),
							shininess,tex);
		}
	}
void GraphicsObject::render(const GraphicsContext &context)
{

    glPushMatrix();

    transform();

    prepareMaterial();

/*    if (_shader)
        bindShader(*_shader, context);*/

    drawGeometry();

   /* if (_shader)
        releaseShader();*/

    releaseMaterial();

    for (object_vector_t::iterator i = _childs.begin();
        i != _childs.end(); 
        i++)
        (*i)->render(context);

    glPopMatrix();
}
Ejemplo n.º 3
0
	Material::Material(optix::Context context, glm::vec3 ambient, glm::vec3 diffuse, glm::vec3 specular, glm::vec3 emissive, float shininess, float reflexive, float opacity, float refractiveIndex,  GLuint tex) {
		this->context = context;
		createMaterial();
		this->reflexive=reflexive;
		this->opacity=opacity;
		this->refractiveIndex=refractiveIndex;
		prepareMaterial(ambient, diffuse, specular, emissive, shininess, tex);
	}
Ejemplo n.º 4
0
bool CRenderSystem::prepareMaterial(const char* szMaterialName, float fOpacity)
{
	return prepareMaterial(getMaterialMgr().getItem(szMaterialName),fOpacity);
}