本文整理汇总了C++中ogre::MaterialPtr::setAmbient方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialPtr::setAmbient方法的具体用法?C++ MaterialPtr::setAmbient怎么用?C++ MaterialPtr::setAmbient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MaterialPtr
的用法示例。
在下文中一共展示了MaterialPtr::setAmbient方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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");
}
示例2: addToGraph
void BoxChunk::addToGraph(Ogre::SceneManager* sceneMgr)
{
// set up Ogre properties
entity = sceneMgr->createEntity(name, "cube.mesh");
// Create BoxChunk materials
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create(name+"Mat",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
entity->setMaterial(mat);
entity->setMaterial(mat);
entity->setCastShadows(false);
node = sceneMgr->getRootSceneNode()->createChildSceneNode(name);
node->attachObject(entity);
Ogre::Real cur_height = entity->getBoundingBox().getSize().y;
node->scale(height/cur_height, height/cur_height, height/cur_height);
node->rotate(Ogre::Quaternion(((float)(rand() % 10))/10.f, ((float)(rand() % 10))/10.f,
((float)(rand() % 10))/10.f, ((float)(rand() % 10))/10.f));
Ogre::ColourValue c(1, 0, 0, 1);
mat->setAmbient(c);
mat->setDiffuse(c);
mat->setSpecular(c);
}
示例3:
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);
}
示例4: createColorMaterial
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);
}
示例5: setColor
void DynamicLines::setColor(Ogre::ColourValue color)
{
// color-coded id
unsigned int matIndex = ((unsigned int)(color.r) << 24) +
((unsigned int)(color.g) << 16) +
((unsigned int)(color.b) << 8) +
((unsigned int)(color.a));
Ogre::String matName = "DL" + Ogre::StringConverter::toString(matIndex);
Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().createOrRetrieve(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME).first.staticCast<Ogre::Material>();
materialPtr->setAmbient(color);
setMaterial(matName);
}
示例6: DebugCreateAmbientColorMaterial
void DebugCreateAmbientColorMaterial(const std::string &materialName, float r, float g, float b)
{
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::MaterialPtr material = mm.getByName(materialName);
if (material.get()) // The given material already exists, so no need to create it again.
return;
material = mm.getByName("SolidAmbient");
if (!material.get())
return;
Ogre::MaterialPtr newMaterial = material->clone(materialName);
newMaterial->setAmbient(r, g, b);
}
示例7: createMaterialIfNotExists
std::string createMaterialIfNotExists(const float r, const float g, const float b, const float a)
{
char buf[128];
sprintf(buf, "ShapeColor%f;%f;%f;%f",r,g,b,a);
if(!Ogre::MaterialManager::getSingleton().getByName(buf, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME).isNull())
return buf;
Ogre::ColourValue color( r,g,b,a );
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create( buf, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
mat->setAmbient(color * 0.01f);
mat->setDiffuse(color);
mat->setLightingEnabled(true);
mat->setReceiveShadows(true);
mat->setCullingMode(Ogre::CULL_NONE);
return buf;
}
示例8: getColourName
Ogre::MaterialPtr
thrive::getColourMaterial(
const Ogre::ColourValue& colour
) {
Ogre::MaterialManager& manager = Ogre::MaterialManager::getSingleton();
Ogre::String name = getColourName(colour);
Ogre::MaterialPtr material = manager.getByName(
name
);
if (material.isNull()) {
material = manager.getDefaultSettings()->clone(
name
);
material->setAmbient(0.3 * colour);
material->setDiffuse(colour);
}
return material;
}
示例9: doExportMaterials
void MilkshapePlugin::doExportMaterials(msModel* pModel)
{
Ogre::LogManager& logMgr = Ogre::LogManager::getSingleton();
Ogre::MaterialManager matMgrSgl;
Ogre::String msg;
matMgrSgl.initialise();
int numMaterials = msModel_GetMaterialCount(pModel);
msg = "Number of materials: " + Ogre::StringConverter::toString(numMaterials);
logMgr.logMessage(msg);
OPENFILENAME ofn;
memset (&ofn, 0, sizeof (OPENFILENAME));
char szFile[MS_MAX_PATH];
char szFileTitle[MS_MAX_PATH];
char szDefExt[32] = "material";
char szFilter[128] = "OGRE .material Files (*.material)\0*.material\0All Files (*.*)\0*.*\0\0";
szFile[0] = '\0';
szFileTitle[0] = '\0';
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.lpstrDefExt = szDefExt;
ofn.lpstrFilter = szFilter;
ofn.lpstrFile = szFile;
ofn.nMaxFile = MS_MAX_PATH;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = MS_MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
ofn.lpstrTitle = "Export to OGRE Material";
if (!::GetSaveFileName (&ofn))
return;
// Strip off the path
Ogre::String matName = szFile;
size_t lastSlash = matName.find_last_of("\\");
matName = matName.substr(lastSlash+1);
// Set up
logMgr.logMessage("Trying to create Material object");
Ogre::MaterialSerializer matSer;
for (int i = 0; i < numMaterials; ++i)
{
msMaterial *mat = msModel_GetMaterialAt(pModel, i);
msg = "Creating material " + Ogre::String(mat->szName);
logMgr.logMessage(msg);
Ogre::MaterialPtr ogremat = matMgrSgl.create(mat->szName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
logMgr.logMessage("Created.");
ogremat->setAmbient(msVec4ToColourValue(mat->Ambient));
ogremat->setDiffuse(msVec4ToColourValue(mat->Diffuse));
ogremat->setSpecular(msVec4ToColourValue(mat->Specular));
ogremat->setShininess(mat->fShininess);
if (0 < strlen(mat->szDiffuseTexture))
ogremat->getTechnique(0)->getPass(0)->createTextureUnitState(mat->szDiffuseTexture);
if (0 < strlen(mat->szAlphaTexture))
ogremat->getTechnique(0)->getPass(0)->createTextureUnitState(mat->szAlphaTexture);
matSer.queueForExport(ogremat);
}
msg = "Exporting materials to " + matName;
logMgr.logMessage(msg);
matSer.exportQueued(matName);
}
示例10: loadSubMeshMaterial
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)
{
//.........这里部分代码省略.........