本文整理汇总了C++中ogre::MaterialPtr::getTechniqueIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialPtr::getTechniqueIterator方法的具体用法?C++ MaterialPtr::getTechniqueIterator怎么用?C++ MaterialPtr::getTechniqueIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MaterialPtr
的用法示例。
在下文中一共展示了MaterialPtr::getTechniqueIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetSelfIllumination
void EC_WidgetCanvas::SetSelfIllumination(bool illuminating)
{
if (material_name_.empty())
return;
Ogre::ColourValue emissiveColor;
if (illuminating)
emissiveColor = Ogre::ColourValue(1.0f, 1.0f, 1.0f, 1.0f);
else
emissiveColor = Ogre::ColourValue(0.0f, 0.0f, 0.0f, 0.0f);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(material_name_);
if (!material.isNull())
{
Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
while(iter.hasMoreElements())
{
Ogre::Technique *tech = iter.getNext();
if (!tech)
continue;
Ogre::Technique::PassIterator passIter = tech->getPassIterator();
while(passIter.hasMoreElements())
{
Ogre::Pass *pass = passIter.getNext();
if (pass)
pass->setSelfIllumination(emissiveColor);
}
}
}
}
示例2: destroyMaterial
/**
* Destroy / unload the memory of a material
* @param mat MaterialName
*/
void GUIHelper::destroyMaterial(const Ogre::String &matName)
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(matName);
if(mat.isNull()) return;
Ogre::Material::TechniqueIterator tit = mat->getTechniqueIterator();
while(tit.hasMoreElements()){
Ogre::Technique *t = tit.peekNext();
ASSERT(t);
Ogre::Technique::PassIterator pit = t->getPassIterator();
while(pit.hasMoreElements()){
Ogre::Pass *pass = pit.peekNext();
ASSERT(pass);
Ogre::Pass::TextureUnitStateIterator tuit =
pass->getTextureUnitStateIterator();
while(tuit.hasMoreElements()){
Ogre::TextureUnitState *tus = tuit.peekNext();
ASSERT(tus);
const Ogre::String &textName = tus->getTextureName();
Ogre::TextureManager::getSingleton().unload(textName);
Ogre::TextureManager::getSingleton().remove(textName);
tuit.moveNext();
}
pit.moveNext();
}
tit.moveNext();
}
Ogre::MaterialManager::getSingleton().unload(matName);
Ogre::MaterialManager::getSingleton().remove(matName);
}
示例3: ReplaceTextureOnMaterial
void ReplaceTextureOnMaterial(Ogre::MaterialPtr material, const std::string& original_name, const std::string& texture_name)
{
if (material.isNull())
return;
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::TexturePtr tex = tm.getByName(texture_name);
Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
while(iter.hasMoreElements())
{
Ogre::Technique *tech = iter.getNext();
assert(tech);
Ogre::Technique::PassIterator passIter = tech->getPassIterator();
while(passIter.hasMoreElements())
{
Ogre::Pass *pass = passIter.getNext();
Ogre::Pass::TextureUnitStateIterator texIter = pass->getTextureUnitStateIterator();
while(texIter.hasMoreElements())
{
Ogre::TextureUnitState *texUnit = texIter.getNext();
if (texUnit->getTextureName() == original_name)
{
if (tex.get())
texUnit->setTextureName(texture_name);
else
texUnit->setTextureName("TextureMissing.png");
}
}
}
}
}
示例4: Animation
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend)
{
mInsert = ptr.getRefData().getBaseNode();
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
assert (ref->base != NULL);
if(!ref->base->model.empty())
{
const std::string &mesh = "meshes\\" + ref->base->model;
std::string meshNumbered = mesh + getUniqueID(mesh) + ">|";
NifOgre::NIFLoader::load(meshNumbered);
mBase = mRend.getScene()->createEntity(meshNumbered);
mBase->setVisibilityFlags(RV_Actors);
bool transparent = false;
for (unsigned int i=0; i < mBase->getNumSubEntities(); ++i)
{
Ogre::MaterialPtr mat = mBase->getSubEntity(i)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements())
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
mBase->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
std::string meshZero = mesh + "0000>|";
if((mTransformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero)))
{
for(std::size_t init = 0; init < mTransformations->size(); init++)
{
mRindexI.push_back(0);
mTindexI.push_back(0);
}
mStopTime = mTransformations->begin()->getStopTime();
mStartTime = mTransformations->begin()->getStartTime();
mShapes = (NIFLoader::getSingletonPtr())->getShapes(meshZero);
}
mTextmappings = NIFLoader::getSingletonPtr()->getTextIndices(meshZero);
mInsert->attachObject(mBase);
}
}
示例5: Animation
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
{
mInsert = ptr.getRefData().getBaseNode();
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
assert (ref->mBase != NULL);
if(!ref->mBase->mModel.empty())
{
std::string mesh = "meshes\\" + ref->mBase->mModel;
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh);
for(size_t i = 0; i < mEntityList.mEntities.size(); i++)
{
Ogre::Entity *ent = mEntityList.mEntities[i];
ent->setVisibilityFlags(RV_Actors);
bool transparent = false;
for (unsigned int j=0; j < ent->getNumSubEntities() && !transparent; ++j)
{
Ogre::MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements() && !transparent)
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements() && !transparent)
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
}
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setEnabled(true);
state->setLoop(false);
}
}
}
}
示例6: while
void
Terrain::_applyFogMode(const Ogre::MaterialPtr& material, Ogre::FogMode oldFogMode, Ogre::FogMode newFogMode) const
{
if (oldFogMode == newFogMode)
return;
if (mData->mSupportedFogReplacements.empty())
return;
Ogre::String newProgramName;
Ogre::Material::TechniqueIterator ti = material->getTechniqueIterator();
while (ti.hasMoreElements())
{
Ogre::Technique* technique = ti.getNext();
Ogre::Technique::PassIterator pi = technique->getPassIterator();
while (pi.hasMoreElements())
{
Ogre::Pass* pass = pi.getNext();
if (pass->hasVertexProgram() &&
_checkFogProgramName(pass->getVertexProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setVertexProgram(newProgramName);
}
if (pass->hasFragmentProgram() &&
_checkFogProgramName(pass->getFragmentProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setFragmentProgram(newProgramName);
}
if (pass->hasShadowCasterVertexProgram() &&
_checkFogProgramName(pass->getShadowCasterVertexProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setShadowCasterVertexProgram(newProgramName);
}
if (pass->hasShadowReceiverVertexProgram() &&
_checkFogProgramName(pass->getShadowReceiverVertexProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setShadowReceiverVertexProgram(newProgramName);
}
if (pass->hasShadowReceiverFragmentProgram() &&
_checkFogProgramName(pass->getShadowReceiverFragmentProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setShadowReceiverFragmentProgram(newProgramName);
}
}
}
}
示例7: findFogPassesByName
void GroundFog::findFogPassesByName (const Ogre::String& passName) {
Ogre::MaterialManager *matManager = Ogre::MaterialManager::getSingletonPtr();
Ogre::MaterialManager::ResourceMapIterator matIt = matManager->getResourceIterator();
while (matIt.hasMoreElements()) {
Ogre::MaterialPtr mat = matIt.getNext();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements()) {
Ogre::Technique *tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements()) {
Ogre::Pass *pass = passIt.getNext();
if (pass->getName() == passName) {
mPasses.insert(pass);
}
}
}
}
forceUpdate();
}
示例8: GetTextureNamesFromMaterial
void GetTextureNamesFromMaterial(Ogre::MaterialPtr material, StringVector& textures)
{
textures.clear();
if (material.isNull())
return;
// Use a set internally to avoid duplicates
std::set<std::string> textures_set;
Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
while(iter.hasMoreElements())
{
Ogre::Technique *tech = iter.getNext();
assert(tech);
Ogre::Technique::PassIterator passIter = tech->getPassIterator();
while(passIter.hasMoreElements())
{
Ogre::Pass *pass = passIter.getNext();
Ogre::Pass::TextureUnitStateIterator texIter = pass->getTextureUnitStateIterator();
while(texIter.hasMoreElements())
{
Ogre::TextureUnitState *texUnit = texIter.getNext();
const std::string& texname = texUnit->getTextureName();
if (!texname.empty())
textures_set.insert(texname);
}
}
}
std::set<std::string>::iterator i = textures_set.begin();
while (i != textures_set.end())
{
textures.push_back(*i);
++i;
}
}
示例9: Animation
ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr)
: Animation(ptr)
{
MWWorld::LiveCellRef<ESM::Activator> *ref = mPtr.get<ESM::Activator>();
assert (ref->mBase != NULL);
if(!ref->mBase->mModel.empty())
{
std::string mesh = "meshes\\" + ref->mBase->mModel;
createEntityList(mPtr.getRefData().getBaseNode(), mesh);
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
{
Ogre::Entity *ent = mEntityList.mEntities[i];
bool transparent = false;
for (unsigned int j=0;j < ent->getNumSubEntities() && !transparent; ++j)
{
Ogre::MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements() && !transparent)
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements() && !transparent)
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
ent->setVisibilityFlags(RV_Misc);
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
}
setAnimationSource(mesh);
}
}
示例10: unloadTheMesh
// unload all about this mesh. The mesh itself and the textures.
// BETWEEN FRAME OPERATION
void VisCalcFrustDist::unloadTheMesh(Ogre::MeshPtr meshP) {
if (m_shouldCullTextures) {
Ogre::Mesh::SubMeshIterator smi = meshP->getSubMeshIterator();
while (smi.hasMoreElements()) {
Ogre::SubMesh* oneSubMesh = smi.getNext();
Ogre::String subMeshMaterialName = oneSubMesh->getMaterialName();
Ogre::MaterialPtr subMeshMaterial = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().getByName(subMeshMaterialName);
if (!subMeshMaterial.isNull()) {
Ogre::Material::TechniqueIterator techIter = subMeshMaterial->getTechniqueIterator();
while (techIter.hasMoreElements()) {
Ogre::Technique* oneTech = techIter.getNext();
Ogre::Technique::PassIterator passIter = oneTech->getPassIterator();
while (passIter.hasMoreElements()) {
Ogre::Pass* onePass = passIter.getNext();
Ogre::Pass::TextureUnitStateIterator tusIter = onePass->getTextureUnitStateIterator();
while (tusIter.hasMoreElements()) {
Ogre::TextureUnitState* oneTus = tusIter.getNext();
Ogre::String texName = oneTus->getTextureName();
Ogre::TexturePtr texP = (Ogre::TexturePtr)Ogre::TextureManager::getSingleton().getByName(texName);
if (!texP.isNull()) {
// if (texP.useCount() <= 1) {
texP->unload();
LG::IncStat(LG::StatCullTexturesUnloaded);
// LG::Log("unloadTheMesh: unloading texture %s", texName.c_str());
// }
}
}
}
}
}
}
}
if (m_shouldCullMeshes) {
LG::OLMeshTracker::Instance()->MakeUnLoaded(meshP->getName(), Ogre::String(), NULL);
LG::IncStat(LG::StatCullMeshesUnloaded);
// LG::Log("unloadTheMesh: unloading mesh %s", mshName.c_str());
}
}
示例11: findFogPassesByName
void GroundFog::findFogPassesByName (const Ogre::String& passName) {
Ogre::MaterialManager *matManager = Ogre::MaterialManager::getSingletonPtr();
Ogre::MaterialManager::ResourceMapIterator matIt = matManager->getResourceIterator();
while (matIt.hasMoreElements()) {
#if (OGRE_VERSION < ((1 << 16) | (9 << 8) | 0))
Ogre::MaterialPtr mat = matIt.getNext();
#else
Ogre::MaterialPtr mat = matIt.getNext().staticCast<Ogre::Material>();
#endif
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements()) {
Ogre::Technique *tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements()) {
Ogre::Pass *pass = passIt.getNext();
if (pass->getName() == passName) {
mPasses.insert(pass);
}
}
}
}
forceUpdate();
}
示例12: CreateProperties
bool OgreMaterialProperties::CreateProperties()
{
Ogre::MaterialPtr matPtr = material_->GetMaterial();
if (matPtr.isNull())
return false;
// Material
Ogre::Material::TechniqueIterator tIter = matPtr->getTechniqueIterator();
while(tIter.hasMoreElements())
{
// Technique
Ogre::Technique *tech = tIter.getNext();
Ogre::Technique::PassIterator pIter = tech->getPassIterator();
while(pIter.hasMoreElements())
{
// Pass
Ogre::Pass *pass = pIter.getNext();
if (!pass)
continue;
if(pass->hasVertexProgram())
{
// Vertex program
const Ogre::GpuProgramPtr &verProg = pass->getVertexProgram();
if (!verProg.isNull())
{
Ogre::GpuProgramParametersSharedPtr verPtr = pass->getVertexProgramParameters();
if (verPtr->hasNamedParameters())
{
// Named parameters (constants)
Ogre::GpuConstantDefinitionIterator mapIter = verPtr->getConstantDefinitionIterator();
while(mapIter.hasMoreElements())
{
QString paramName = mapIter.peekNextKey().c_str();
const Ogre::GpuConstantDefinition ¶mDef = mapIter.getNext();
// Filter names that end with '[0]'
int found = paramName.indexOf("[0]");
if (found != -1)
continue;
// Ignore auto parameters
bool is_auto_param = false;
Ogre::GpuProgramParameters::AutoConstantIterator autoConstIter = verPtr->getAutoConstantIterator();
while(autoConstIter.hasMoreElements())
{
Ogre::GpuProgramParameters::AutoConstantEntry autoConstEnt = autoConstIter.getNext();
if (autoConstEnt.physicalIndex == paramDef.physicalIndex)
{
is_auto_param = true;
break;
}
}
if (is_auto_param)
continue;
if (!paramDef.isFloat())
continue;
size_t count = paramDef.elementSize * paramDef.arraySize;
QVector<float> paramValue;
QVector<float>::iterator iter;
paramValue.resize(count);
verPtr->_readRawConstants(paramDef.physicalIndex, count, &*paramValue.begin());
QTextStream vector_string;
QString string;
vector_string.setString(&string, QIODevice::WriteOnly);
for(iter = paramValue.begin(); iter != paramValue.end(); ++iter)
vector_string << *iter << " ";
// Add QPROPERTY. Add to "VP" to the end of the parameter name in order to identify VP parameters.
QMap<QString, QVariant> typeValuePair;
typeValuePair[GpuConstantTypeToString(paramDef.constType)] = *vector_string.string();
setProperty(paramName.append(" VP").toLatin1(), QVariant(typeValuePair));
}
}
}
}
if(pass->hasFragmentProgram())
{
// Fragment program
const Ogre::GpuProgramPtr fragProg = pass->getFragmentProgram();
if (!fragProg.isNull())
{
Ogre::GpuProgramParametersSharedPtr fragPtr = pass->getFragmentProgramParameters();
if (!fragPtr.isNull())
{
if (fragPtr->hasNamedParameters())
{
// Named parameters (constants)
Ogre::GpuConstantDefinitionIterator mapIter = fragPtr->getConstantDefinitionIterator();
while(mapIter.hasMoreElements())
{
QString paramName = mapIter.peekNextKey().c_str();
const Ogre::GpuConstantDefinition ¶mDef = mapIter.getNext();
//.........这里部分代码省略.........
示例13: ToOgreMaterial
Ogre::MaterialPtr OgreMaterialProperties::ToOgreMaterial()
{
// Make clone from the original and uset that for creating the new material.
Ogre::MaterialPtr matPtr = material_->GetMaterial();
Ogre::MaterialPtr matPtrClone = matPtr->clone(objectName().toStdString() + "Clone");
// Material
if (!matPtrClone.isNull())
{
// Technique
Ogre::Material::TechniqueIterator tIter = matPtrClone->getTechniqueIterator();
while(tIter.hasMoreElements())
{
Ogre::Technique *tech = tIter.getNext();
Ogre::Technique::PassIterator pIter = tech->getPassIterator();
while(pIter.hasMoreElements())
{
// Pass
Ogre::Pass *pass = pIter.getNext();
if (!pass)
continue;
if (pass->hasVertexProgram())
{
// Vertex program
const Ogre::GpuProgramPtr &verProg = pass->getVertexProgram();
if (!verProg.isNull())
{
Ogre::GpuProgramParametersSharedPtr verPtr = pass->getVertexProgramParameters();
if (verPtr->hasNamedParameters())
{
// Named parameters (constants)
Ogre::GpuConstantDefinitionIterator mapIter = verPtr->getConstantDefinitionIterator();
int constNum = 0;
while(mapIter.hasMoreElements())
{
QString paramName(mapIter.peekNextKey().c_str());
const Ogre::GpuConstantDefinition ¶mDef = mapIter.getNext();
// Filter names that end with '[0]'
if (paramName.lastIndexOf("[0]") != -1)
continue;
if (!paramDef.isFloat())
continue;
size_t size = paramDef.elementSize * paramDef.arraySize;
QVector<float> newParamValue;
QVector<float>::iterator it;
newParamValue.resize(size);
// Find the corresponding property value.
QVariant val = property(paramName.append(" VP").toLatin1());
if (!val.isValid() || val.isNull())
continue;
TypeValuePair typeValuePair = val.toMap();
QString newValueString(typeValuePair.begin().value().toByteArray());
newValueString.trimmed();
// fill the float vector with new values
it = newParamValue.begin();
int i = 0, j = 0;
bool ok = true;
while(j != -1 && ok)
{
j = newValueString.indexOf(' ', i);
QString newValue = newValueString.mid(i, j == -1 ? j : j - i);
if (!newValue.isEmpty())
{
*it = newValue.toFloat(&ok);
++it;
}
i = j + 1;
}
// Set the new value.
///\todo use the exact count rather than just 4 values if needed.
if (size == 16)
{
Ogre::Matrix4 matrix(newParamValue[0], newParamValue[1], newParamValue[2], newParamValue[3],
newParamValue[4], newParamValue[5], newParamValue[6], newParamValue[7],
newParamValue[8], newParamValue[9], newParamValue[10], newParamValue[11],
newParamValue[12], newParamValue[13], newParamValue[14], newParamValue[15]);
#if OGRE_VERSION_MINOR <= 6 && OGRE_VERSION_MAJOR <= 1
verPtr->_writeRawConstant(paramDef.physicalIndex, matrix);
#else
verPtr->_writeRawConstant(paramDef.physicalIndex, matrix, size);
#endif
}
else
{
Ogre::Vector4 vector(newParamValue[0], newParamValue[1], newParamValue[2], newParamValue[3]);
verPtr->_writeRawConstant(paramDef.physicalIndex, vector);
}
}
}
}
}
//.........这里部分代码省略.........
示例14: insertMesh
void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
{
Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
assert(insert);
Ogre::AxisAlignedBox bounds = Ogre::AxisAlignedBox::BOX_NULL;
NifOgre::EntityList entities = NifOgre::NIFLoader::createEntities(insert, NULL, mesh);
for(size_t i = 0;i < entities.mEntities.size();i++)
{
const Ogre::AxisAlignedBox &tmp = entities.mEntities[i]->getBoundingBox();
bounds.merge(Ogre::AxisAlignedBox(insert->_getDerivedPosition() + tmp.getMinimum(),
insert->_getDerivedPosition() + tmp.getMaximum())
);
}
Ogre::Vector3 extents = bounds.getSize();
extents *= insert->getScale();
float size = std::max(std::max(extents.x, extents.y), extents.z);
bool small = (size < Settings::Manager::getInt("small object size", "Viewing distance")) && Settings::Manager::getBool("limit small object distance", "Viewing distance");
// do not fade out doors. that will cause holes and look stupid
if (ptr.getTypeName().find("Door") != std::string::npos)
small = false;
if (mBounds.find(ptr.getCell()) == mBounds.end())
mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL;
mBounds[ptr.getCell()].merge(bounds);
bool transparent = false;
for(size_t i = 0;i < entities.mEntities.size();i++)
{
Ogre::Entity *ent = entities.mEntities[i];
for (unsigned int i=0; i<ent->getNumSubEntities(); ++i)
{
Ogre::MaterialPtr mat = ent->getSubEntity(i)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements())
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
}
if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects") || transparent)
{
for(size_t i = 0;i < entities.mEntities.size();i++)
{
Ogre::Entity *ent = entities.mEntities[i];
ent->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Viewing distance") : 0);
ent->setVisibilityFlags(mIsStatic ? (small ? RV_StaticsSmall : RV_Statics) : RV_Misc);
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
}
}
else
{
Ogre::StaticGeometry* sg = 0;
if (small)
{
if( mStaticGeometrySmall.find(ptr.getCell()) == mStaticGeometrySmall.end())
{
uniqueID = uniqueID +1;
sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
mStaticGeometrySmall[ptr.getCell()] = sg;
sg->setRenderingDistance(Settings::Manager::getInt("small object distance", "Viewing distance"));
}
else
sg = mStaticGeometrySmall[ptr.getCell()];
}
else
{
if( mStaticGeometry.find(ptr.getCell()) == mStaticGeometry.end())
{
uniqueID = uniqueID +1;
sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
mStaticGeometry[ptr.getCell()] = sg;
}
else
sg = mStaticGeometry[ptr.getCell()];
}
// This specifies the size of a single batch region.
// If it is set too high:
// - there will be problems choosing the correct lights
// - the culling will be more inefficient
// If it is set too low:
// - there will be too many batches.
sg->setRegionDimensions(Ogre::Vector3(2500,2500,2500));
//.........这里部分代码省略.........
示例15: Animation
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& _inv, int visibilityFlags)
: Animation(), mStateID(-1), mInv(_inv), timeToChange(0), mVisibilityFlags(visibilityFlags),
robe(mInv.end()), helmet(mInv.end()), shirt(mInv.end()),
cuirass(mInv.end()), greaves(mInv.end()),
leftpauldron(mInv.end()), rightpauldron(mInv.end()),
boots(mInv.end()),
leftglove(mInv.end()), rightglove(mInv.end()), skirtiter(mInv.end()),
pants(mInv.end())
{
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
for (int init = 0; init < 27; init++)
{
mPartslots[init] = -1; //each slot is empty
mPartPriorities[init] = 0;
}
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.races.find(ref->base->mRace);
std::string hairID = ref->base->mHair;
std::string headID = ref->base->mHead;
headModel = "meshes\\" + store.bodyParts.find(headID)->mModel;
hairModel = "meshes\\" + store.bodyParts.find(hairID)->mModel;
npcName = ref->base->mName;
isFemale = !!(ref->base->mFlags&ESM::NPC::Female);
isBeast = !!(race->mData.mFlags&ESM::Race::Beast);
bodyRaceID = "b_n_"+ref->base->mRace;
std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower);
mInsert = node;
assert(mInsert);
std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif");
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, smodel);
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
{
Ogre::Entity *base = mEntityList.mEntities[i];
base->getUserObjectBindings ().setUserAny (Ogre::Any(-1));
base->setVisibilityFlags(mVisibilityFlags);
bool transparent = false;
for(unsigned int j=0;j < base->getNumSubEntities();++j)
{
Ogre::MaterialPtr mat = base->getSubEntity(j)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements())
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
base->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
}
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setEnabled(true);
state->setLoop(false);
}
}
float scale = race->mData.mHeight.mMale;
if (isFemale) {
scale = race->mData.mHeight.mFemale;
}
mInsert->scale(scale, scale, scale);
updateParts();
}