GameDiamondMoreWinderComponent::GameDiamondMoreWinderComponent(void):_moreWinnerInterface(new CGameDiamondMoreWinderInterface),_updater(new Updater),_number(0),_step(0) { _moreWinnerInterface->init = boost::bind(&GameDiamondMoreWinderComponent::init, this, _1); _moreWinnerInterface->addEntity = boost::bind(&GameDiamondMoreWinderComponent::addEntity, this, _1, _2); _moreWinnerInterface->bigger = boost::bind(&GameDiamondMoreWinderComponent::bigger, this); _moreWinnerInterface->reset = boost::bind(&GameDiamondMoreWinderComponent::reset, this); _moreWinnerInterface->run = boost::bind(&GameDiamondMoreWinderComponent::run, this, _1); _moreWinnerInterface->step = boost::bind(&GameDiamondMoreWinderComponent::step, this); _moreWinnerInterface->stop = boost::bind(&GameDiamondMoreWinderComponent::stop, this); for(int i =0 ; i<12; i++) { std::string mname = "diamond"+boost::lexical_cast<std::string>(i); //ent->setMaterialName(mname); Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(mname); material->setSelfIllumination(1.0f,1.0f,1.0f); material->setAmbient(0,0,0); material->setDiffuse(0,0,0,0); } //_rotationComp = Orz::ComponentFactories::getInstance().create("Rotation"); }
void LagomPlayerBase::AddConstructionCapability(LagomActorFactory* f) { if(!f) return; if(_actorFactories.find(f) != _actorFactories.end()) return; Ogre::SceneManager* manager = _state.GetSceneManager(); Ogre::SceneNode* node = manager->createSceneNode(); Ogre::Entity* constructionObject = manager->createEntity(f->Mesh.c_str()); Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(getIntFactory().ConstructingMaterial); materialPtr->setSelfIllumination(1.0f,1.0f,1.0f); constructionObject->setCastShadows(false); constructionObject->setRenderQueueGroup(RENDER_QUEUE_SKIES_LATE); constructionObject->setMaterialName(getIntFactory().ConstructingMaterial); node->attachObject(constructionObject); node->setScale( f->MeshScale ); _actorFactories.insert(FactoryMap::value_type(f,node)); if( _selectedActorFactory ==_actorFactories.end()) _selectedActorFactory=_actorFactories.begin(); }
void Terrain::_applySurfaceParams(const Ogre::MaterialPtr& material) const { material->setAmbient(mData->mSurfaceParams.ambient); material->setDiffuse(mData->mSurfaceParams.diffuse); material->setSpecular(mData->mSurfaceParams.specular); material->setSelfIllumination(mData->mSurfaceParams.emissive); material->setShininess(mData->mSurfaceParams.shininess); }
void createColorMaterial(const std::string& name, const Ogre::ColourValue& color, bool use_self_illumination) { Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create( name, ROS_PACKAGE_NAME ); mat->setAmbient(color * 0.5f); mat->setDiffuse(color); if( use_self_illumination ) { mat->setSelfIllumination(color); } mat->setLightingEnabled(true); mat->setReceiveShadows(false); }
void MaterialEditorDialog::OnSaveButtonDown(wxCommandEvent &e) { if (mCurrentMaterial.isNull()==false) { Ogre::String matName; switch (gEffectSettingGlobalData.mCurrentEditEffectType) { case CEFT_EFFECT_PROJECTOR: { matName = gEffectSettingGlobalData.mOriginProjectorMaterial; Ogre::MaterialPtr newMat = Ogre::MaterialManager::getSingleton().getByName(matName); mCurrentMaterial->copyDetailsTo(newMat); newMat->setSelfIllumination(0.0f, 0.0f, 0.0f); Ogre::String pathFileName = EFFECT_PATH + matName + ".material"; Ogre::MaterialSerializer ser; ser.queueForExport(newMat); ser.exportQueued(pathFileName); break; } default: { matName = mCurrentMaterial->getName(); Ogre::String pathFileName = EFFECT_PATH + matName + ".material"; Ogre::MaterialSerializer ser; ser.queueForExport(mCurrentMaterial); ser.exportQueued(pathFileName); break; } } wxMessageBox("Success Save!"); Hide(); } }
void gkMaterialLoader::loadSubMeshMaterial(gkSubMesh* mesh, const gkString& group) { using namespace Ogre; gkMaterialProperties& gma = mesh->getMaterial(); if (gma.m_name.empty()) gma.m_name = "<gkBuiltin/DefaultMaterial>"; Ogre::MaterialPtr oma = Ogre::MaterialManager::getSingleton().getByName(gma.m_name.c_str(), group); if (!oma.isNull()) return; oma = Ogre::MaterialManager::getSingleton().create(gma.m_name, group); if (gma.m_mode & gkMaterialProperties::MA_INVISIBLE) { // disable writing to this material oma->setReceiveShadows(false); oma->setColourWriteEnabled(false); oma->setDepthWriteEnabled(false); oma->setDepthCheckEnabled(false); oma->setLightingEnabled(false); return; } if (gma.m_mode & gkMaterialProperties::MA_TWOSIDE) { oma->setCullingMode(Ogre::CULL_NONE); oma->setManualCullingMode(Ogre::MANUAL_CULL_NONE); } // apply lighting params bool enableLights = (gma.m_mode & gkMaterialProperties::MA_LIGHTINGENABLED) != 0; oma->setReceiveShadows((gma.m_mode & gkMaterialProperties::MA_RECEIVESHADOWS) != 0); oma->setLightingEnabled(enableLights); if (enableLights) { gkColor emissive, ambient, specular, diffuse; emissive = gma.m_diffuse * gma.m_emissive; ambient = gma.m_diffuse * gma.m_ambient; specular = gma.m_specular * gma.m_spec; diffuse = gma.m_diffuse * (gma.m_emissive + gma.m_refraction); emissive.a = ambient.a = specular.a = 1.f; oma->setSelfIllumination(emissive); oma->setAmbient(ambient); oma->setSpecular(specular); oma->setDiffuse(diffuse); oma->setShininess(gma.m_hardness); } Ogre::Pass* pass = oma->getTechnique(0)->getPass(0); bool matBlending = gkEngine::getSingleton().getUserDefs().matblending; if (matBlending && (gma.m_mode & gkMaterialProperties::MA_HASRAMPBLEND)) { switch (gma.m_rblend) { case GK_BT_MULTIPLY: pass->setSceneBlending(SBT_MODULATE); break; case GK_BT_SUBTRACT: pass->setSceneBlending(SBF_ONE_MINUS_SOURCE_COLOUR, SBF_ONE); break; case GK_BT_DARKEN: pass->setSceneBlendingOperation(SBO_MIN); pass->setSceneBlending(SBF_ONE, SBF_ONE); break; case GK_BT_LIGHTEN: pass->setSceneBlendingOperation(SBO_MAX); pass->setSceneBlending(SBF_ONE, SBF_ONE); break; case GK_BT_SCREEN: pass->setSceneBlending(SBF_ONE_MINUS_DEST_COLOUR, SBF_ONE); break; case GK_BT_ADDITIVE: pass->setSceneBlending(SBT_ADD); break; case GK_BT_MIXTURE: default: pass->setSceneBlending(SBF_ONE, SBF_ZERO); break; } } bool hasNormap = false; bool rtss = gkEngine::getSingleton().getUserDefs().rtss; for (int i = 0; i < gma.m_totaltex; ++i) { gkTextureProperties& gte = gma.m_textures[i]; #ifdef OGREKIT_USE_RTSHADER_SYSTEM if (gte.m_mode & gkTextureProperties::TM_NORMAL) { hasNormap = true; continue; } #endif Ogre::TextureUnitState* otus = pass->createTextureUnitState(gte.m_name, gte.m_layer); LayerBlendOperationEx op = LBX_MODULATE; switch (gte.m_blend) { case GK_BT_ADDITIVE: op = LBX_ADD; break; case GK_BT_SUBTRACT: op = LBX_SUBTRACT; break; case GK_BT_DARKEN: case GK_BT_LIGHTEN: case GK_BT_SCREEN: case GK_BT_COLOR: //break; TODO: support more mode case GK_BT_MULTIPLY: case GK_BT_MIXTURE: default: op = LBX_MODULATE; break; } if (i == 0) otus->setColourOperationEx(op, LBS_DIFFUSE, LBS_TEXTURE); else otus->setColourOperationEx(op); otus->setTextureScale(gte.m_scale[0],gte.m_scale[1]); } if (gma.m_mode & gkMaterialProperties::MA_ALPHABLEND) { pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); pass->setDepthWriteEnabled(false); } if (gma.m_mode & gkMaterialProperties::MA_ALPHACLIP) { pass->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 254); } #ifdef OGREKIT_USE_RTSHADER_SYSTEM if (rtss) { //pass->setSpecular(ColourValue::Black); //pass->setShininess(0.0); RTShader::RenderState* rs = 0; RTShader::ShaderGenerator* sg = Ogre::RTShader::ShaderGenerator::getSingletonPtr(); bool ok = sg->createShaderBasedTechnique(gma.m_name, group, Ogre::MaterialManager::DEFAULT_SCHEME_NAME, Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME); if (ok && hasNormap) { rs = sg->getRenderState(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, gma.m_name, 0); rs->reset(); for (int i = 0; i < gma.m_totaltex; ++i) { gkTextureProperties& gte = gma.m_textures[i]; if (gte.m_mode & gkTextureProperties::TM_NORMAL) { GK_ASSERT(rs); RTShader::SubRenderState* srs= sg->createSubRenderState(RTShader::NormalMapLighting::Type); RTShader::NormalMapLighting* nsrs = static_cast<RTShader::NormalMapLighting*>(srs); if (gte.m_texmode & gkTextureProperties::TX_OBJ_SPACE) nsrs->setNormalMapSpace(RTShader::NormalMapLighting::NMS_OBJECT); else nsrs->setNormalMapSpace(RTShader::NormalMapLighting::NMS_TANGENT); nsrs->setNormalMapTextureName(gte.m_name); nsrs->setTexCoordIndex(gte.m_layer); rs->addTemplateSubRenderState(srs); } } sg->invalidateMaterial(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, gma.m_name); } } #endif }