本文整理汇总了C++中ogre::SubEntity类的典型用法代码示例。如果您正苦于以下问题:C++ SubEntity类的具体用法?C++ SubEntity怎么用?C++ SubEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SubEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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];
for(unsigned int j=0; j < ent->getNumSubEntities(); ++j)
{
Ogre::SubEntity* subEnt = ent->getSubEntity(j);
subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main);
}
ent->setVisibilityFlags(RV_Misc);
}
setAnimationSource(mesh);
}
}
示例2: SetUnSelLook
// 设置正常的外观颜色.
void CEditDobject_NT::SetUnSelLook()
{
if(0 == m_materilaOldVector.size())
{
return;
}
int iCount = m_EntityList.size();
Ogre::Entity* pEntity = NULL;
int iIndex = 0;
for(int i = 0; i < iCount; i++)
{
pEntity = m_EntityList[i].pEntity;
if(pEntity)
{
Ogre::SubEntity* pSubEntiy = pEntity->getSubEntity(0);
if(pSubEntiy)
{
if(iIndex >= (int)m_materilaOldVector.size())
{
continue;
}
std::string strMaterialName = m_materilaOldVector[iIndex]->getName();
pSubEntiy->setMaterialName(strMaterialName);
iIndex++;
}
}
}
}
示例3: insertBoundedPart
NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int group, const std::string &bonename)
{
NifOgre::EntityList entities = NifOgre::Loader::createEntities(mEntityList.mSkelBase, bonename,
mInsert, mesh);
std::vector<Ogre::Entity*> &parts = entities.mEntities;
for(size_t i = 0;i < parts.size();i++)
{
parts[i]->getUserObjectBindings().setUserAny(Ogre::Any(group));
if (mVisibilityFlags != 0)
parts[i]->setVisibilityFlags(mVisibilityFlags);
for(unsigned int j=0; j < parts[i]->getNumSubEntities(); ++j)
{
Ogre::SubEntity* subEnt = parts[i]->getSubEntity(j);
subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main);
}
}
if(entities.mSkelBase)
{
Ogre::AnimationStateSet *aset = entities.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator asiter = aset->getAnimationStateIterator();
while(asiter.hasMoreElements())
{
Ogre::AnimationState *state = asiter.getNext();
state->setEnabled(false);
state->setLoop(false);
}
Ogre::SkeletonInstance *skelinst = entities.mSkelBase->getSkeleton();
Ogre::Skeleton::BoneIterator boneiter = skelinst->getBoneIterator();
while(boneiter.hasMoreElements())
boneiter.getNext()->setManuallyControlled(true);
}
return entities;
}
示例4: SetTransparence
// 设置模型的透明度
// 0 -- 完全透明。
// 1 -- 不透明。
void CEditDobject_NT::SetTransparence(float Transparence)
{
int iCount = m_EntityList.size();
Ogre::Entity* pEntity = NULL;
for(int i = 0; i < iCount; i++)
{
pEntity = m_EntityList[i].pEntity;
if(pEntity)
{
Ogre::SubEntity* pSubEntiy = pEntity->getSubEntity(0);
if(pSubEntiy)
{
Ogre::MaterialPtr material1 = pSubEntiy->getMaterial();
Ogre::Technique* t1 = material1->getBestTechnique();
Ogre::Pass* p1 = t1->getPass(0);
p1->setSceneBlending(Ogre::SBT_ADD );
p1->setSceneBlending(Ogre::SBF_SOURCE_ALPHA , Ogre::SBF_ONE_MINUS_SOURCE_ALPHA );
Ogre::TextureUnitState* pTextureState = p1->getTextureUnitState(0);
pTextureState->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_TEXTURE, Ogre::LBS_MANUAL, 1, Transparence, 1);
//Ogre::ColourValue color(1,0.0,0.0,0.1) ;
//pTextureState->setColourOperationEx(LBX_ADD , LBS_TEXTURE , LBS_MANUAL, color, color );
}
}
}
}
示例5: setSegmentIndex
void RigidObject::setSegmentIndex(int segment_ind) {
segment_ind_ = segment_ind;
Ogre::SubEntity *pSub = entity_->getSubEntity(0);
// mark segment index for vertex shader
pSub->setCustomParameter(1, Ogre::Vector4(segment_ind_, 0, 0, 0));
}
示例6: extractMaterials
void ShapeBase::extractMaterials( Ogre::Entity *entity, S_MaterialPtr &materials )
{
uint32_t num_sub_entities = entity->getNumSubEntities();
for (uint32_t i = 0; i < num_sub_entities; ++i)
{
Ogre::SubEntity* sub = entity->getSubEntity(i);
Ogre::MaterialPtr material = sub->getMaterial();
materials.insert( material );
}
}
示例7: operator
void operator()(Ogre::Entity *entity) const
{
if(mVisFlags != 0)
entity->setVisibilityFlags(mVisFlags);
entity->setRenderingDistance(mDist);
unsigned int numsubs = entity->getNumSubEntities();
for(unsigned int i = 0;i < numsubs;++i)
{
Ogre::SubEntity* subEnt = entity->getSubEntity(i);
sh::Factory::getInstance()._ensureMaterial(subEnt->getMaterial()->getName(), "Default");
subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? mTransQueue : mSolidQueue);
}
}
示例8:
void ResourceGroupReloader::UpdateMaterialRenderableVisitor::visit(
Ogre::Renderable *rend, Ogre::ushort lodIndex, bool isDebug, Ogre::Any *pAny)
{
const Ogre::MaterialPtr mat = rend->getMaterial();
if(!mat.isNull())
{
std::string newMatName = mat->getName();
Ogre::MaterialPtr newMat = Ogre::MaterialManager::getSingleton().getByName(newMatName);
if(newMat.isNull())
{
// this can happen if there was error during the reloading of the material.
// in that case, we keep the ancient one.
// Ice::Log::Instance().LogMessage(newMatName+" : new material is null!");
return;
}
// unfortunately, the renderable gives access only to a const MaterialPtr.
// and there is no 'setMaterial' or 'setMaterialName' method on renderables.
// so I have to try to down cast with known classes...
{
Ogre::SubEntity* lRend = dynamic_cast<Ogre::SubEntity*>(rend);
if(lRend){lRend->setMaterialName(newMatName);return;}
}
{
Ogre::SimpleRenderable* lRend = dynamic_cast<Ogre::SimpleRenderable*>(rend);
if(lRend){lRend->setMaterial(newMatName);return;}
}
{
Ogre::ShadowRenderable* lRend = dynamic_cast<Ogre::ShadowRenderable*>(rend);
if(lRend){lRend->setMaterial(newMat);return;}
}
{
Ogre::BillboardChain* lRend = dynamic_cast<Ogre::BillboardChain*>(rend);
if(lRend){lRend->setMaterialName(newMatName);return;}
}
{
Ogre::BillboardSet* lRend = dynamic_cast<Ogre::BillboardSet*>(rend);
if(lRend){lRend->setMaterialName(newMatName);return;}
}
{
Ogre::OverlayElement* lRend = dynamic_cast<Ogre::OverlayElement*>(rend);
if(lRend){lRend->setMaterialName(newMatName);return;}
}
}else{
// was there for debug...
// Ice::Log::Instance().LogMessage("material of renderable is null!");
}
}
示例9: update_settings
void LIRenAttachmentEntity::update_settings ()
{
if (entity == NULL)
return;
entity->setCastShadows (object->get_shadow_casting ());
entity->setRenderQueueGroup (object->get_render_queue ());
// Set the custom parameters of subentities.
const std::map<int, Ogre::Vector4>& params = object->get_custom_params ();
for (size_t subent_idx = 0 ; subent_idx < entity->getNumSubEntities () ; ++subent_idx)
{
Ogre::SubEntity* subent = entity->getSubEntity (subent_idx);
std::map<int, Ogre::Vector4>::const_iterator iter;
for (iter = params.begin () ; iter != params.end () ; iter++)
subent->setCustomParameter (iter->first, iter->second);
}
}
示例10: ReadEntity
void FvXMLAnimationModelSerializerImpl::ReadEntity(
FvXMLSectionPtr spSection, Ogre::SceneNode* pkNode, FvAnimationModel* pkDest )
{
Ogre::SceneManager *pkSceneManager = Ogre::Root::getSingleton().
_getCurrentSceneManager();
FV_ASSERT(pkSceneManager);
FvString kMeshIdentifier = spSection->ReadString("identifier");
FvString kMeshFile = spSection->ReadString("mesh");
Ogre::Entity *pkEntity = pkSceneManager->createEntity(
pkNode->getName() + "_" + kMeshIdentifier,kMeshFile);
FV_ASSERT(pkEntity);
pkEntity->setCastShadows(pkDest->m_bCastShadows);
pkNode->attachObject(pkEntity);
pkDest->m_akNodes[pkDest->m_u32CurrentLodLevel].m_kEntityList.push_back(pkEntity);
pkEntity->setRenderQueueGroup(RENDER_QUEUE_MAX);
AnimationStateSet *pkAnimations = pkEntity->getAllAnimationStates();
if(pkAnimations)
{
AnimationStateIterator kIt = pkAnimations->getAnimationStateIterator();
while (kIt.hasMoreElements())
{
AnimationState *pkAnim= kIt.getNext();
if(pkDest->GetAnimation(pkAnim->getAnimationName()) == NULL)
pkDest->m_kModelAnimations.insert(std::make_pair(pkAnim->getAnimationName(),pkAnim));
}
}
std::vector<FvXMLSectionPtr> kSubentities;
spSection->OpenSections("subentities/subentity",kSubentities);
std::vector<FvXMLSectionPtr>::iterator kSubIt = kSubentities.begin();
for(; kSubIt != kSubentities.end(); ++kSubIt)
{
int iIndex = (*kSubIt)->ReadInt("index",-1);
FvString kMaterialName = (*kSubIt)->ReadString("materialName");
Ogre::SubEntity *pkSubEntity = pkEntity->getSubEntity(iIndex);
if(pkSubEntity && !kMaterialName.empty())
pkSubEntity->setMaterialName(kMaterialName);
}
}
示例11: processEntity
void Level::processEntity(TiXmlElement *XMLNode, Ogre::SceneNode *parent)
{
Ogre::String name = getAttribute(XMLNode, "name");
Ogre::String meshFile = getAttribute(XMLNode, "meshFile");
TiXmlElement *element;
Ogre::Entity *entity = 0;
try
{
entity = mSceneMgr->createEntity(name, meshFile);
entity->setCastShadows(true);
PhysicsManager::instance()->createConvexMesh(entity);
element = XMLNode->FirstChildElement("subentities");
if(element)
{
element = element->FirstChildElement("subentity");
while (element)
{
Ogre::SubEntity *subEnt;
Ogre::String materialFile = getAttribute(element, "materialName");
unsigned int index = Ogre::StringConverter::parseInt(getAttribute(element,"index"));
subEnt = entity->getSubEntity(index);
subEnt->setMaterialName(materialFile);
element = element->NextSiblingElement("subentity");
}
}
entity->setRenderingDistance(1000);
parent->attachObject(entity);
}
catch(Ogre::Exception e)
{
Ogre::LogManager::getSingleton().logMessage("Error loading an entity!");
}
element = XMLNode->FirstChildElement("userDataReference");
}
示例12: build
void MaterialChain::build(){
Parent::build();
Ogre::Entity* entity = mGo->getEntity();
int j=entity->getNumManualLodLevels();
for (int i=-1;i<j;i++){
Ogre::Entity* lodEnt;
if (i > -1){
lodEnt = entity->getManualLodLevel(i);
}else{
lodEnt = entity;
}
for (int k=0;k<lodEnt->getNumSubEntities();k++){
Ogre::SubEntity* subEnt = lodEnt->getSubEntity(k);
if (subEnt->getMaterialName() == mSource){
mEntityToReplace.push_back(subEnt);
}
}
}
}
示例13: replace_texture_now
void LIRenAttachmentEntity::replace_texture_now (const Ogre::String& name, Ogre::TexturePtr& texture)
{
if (mesh.isNull () || entity == NULL)
return;
// Translate the name if already replaced before.
std::map<Ogre::String, Ogre::String>::const_iterator iter;
iter = applied_texture_replaces.find(name);
Ogre::String real_name;
if (iter != applied_texture_replaces.end())
real_name = iter->second;
else
real_name = name;
// Save the replaced name for future translations.
applied_texture_replaces[name] = texture->getName ();
// Replace in each submesh.
for (size_t subent_idx = 0 ; subent_idx < entity->getNumSubEntities () ; ++subent_idx)
{
// Get the material of the subent.
Ogre::SubEntity* subent = entity->getSubEntity (subent_idx);
Ogre::MaterialPtr submat = subent->getMaterial ();
if (submat.isNull ())
continue;
// Check if there are replaceable textures.
if (!render->material_utils->has_overridable_texture (submat, real_name))
continue;
// Create a modified version of the material.
Ogre::String new_name = render->id.next ();
Ogre::MaterialPtr material = submat->clone (new_name, true, LIREN_RESOURCES_TEMPORARY);
render->material_utils->replace_texture (material, real_name, texture->getName ());
subent->setMaterial (material);
}
}
示例14: extractMeshPositions
RigidObject::RigidObject(std::string file_name,
Ogre::SceneManager *scene_manager, int segment_ind)
: segment_ind_{ segment_ind }, scene_manager_{ scene_manager } {
Ogre::MeshPtr object_mesh = render::loadMeshFromResource(file_name);
entity_ = scene_manager_->createEntity(file_name);
Ogre::MaterialPtr mat =
Ogre::MaterialManager::getSingleton().getByName("textured");
std::stringstream ss;
ss << "textured_" << segment_ind_;
Ogre::MaterialPtr cloned_mat = mat->clone(ss.str());
Ogre::Pass *pass = cloned_mat->getTechnique(0)->getPass(0);
Ogre::TextureUnitState *tex_unit = pass->createTextureUnitState();
Ogre::MaterialPtr tmp = Ogre::MaterialManager::getSingleton().getByName(
object_mesh->getSubMesh(0)->getMaterialName());
tex_unit->setTextureName(tmp->getTechnique(0)
->getPass(0)
->getTextureUnitState(0)
->getTextureName());
entity_->setMaterial(cloned_mat);
texture_name_ = tex_unit->getTextureName();
file_name_ = file_name;
Ogre::SubEntity *pSub = entity_->getSubEntity(0);
// mark segment index for vertex shader
pSub->setCustomParameter(1, Ogre::Vector4(segment_ind_, 0, 0, 0));
visual_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();
visual_node_->attachObject(entity_);
// store the vertex positions
extractMeshPositions(object_mesh.get());
// std::cout << "extracted " << positions_.size() << " vertices\n";
// compute the bounding box
computeBoundingBox();
}
示例15: SetSelectLook
// 设置选中的外观颜色.
void CEditDobject_NT::SetSelectLook(Ogre::ColourValue color)
{
if(0 == m_materialSelVector.size())
{
// 选中材质的名字.
Ogre::String strCloneName;
int iCount = m_EntityList.size();
Ogre::Entity* pEntity = NULL;
for(int i = 0; i < iCount; i++)
{
pEntity = m_EntityList[i].pEntity;
if(pEntity)
{
Ogre::SubEntity* pSubEntiy = pEntity->getSubEntity(0);
if(pSubEntiy)
{
Ogre::MaterialPtr pMaterial = pSubEntiy->getMaterial();
if(pMaterial.isNull())
{
return;
}//
const Ogre::String& strName = pMaterial->getName();
if("BaseWhite" == strName)
{
continue;
}
strCloneName = strName;
strCloneName += "_select";
Ogre::MaterialManager* pMaterialManager = (Ogre::MaterialManager*)(pMaterial->getCreator());
if(NULL == pMaterialManager)
{
return;
}
Ogre::MaterialPtr pMaterialClone = pMaterialManager->getByName(strCloneName);
if(pMaterialClone.isNull())
{
pMaterialClone = pMaterial->clone(strCloneName);
}
//if(!pMaterialClone)
//{
// return;
//}//
Ogre::Technique* pTechnique = pMaterialClone->getBestTechnique();
Ogre::Pass* pPass = pTechnique->getPass(0);
//pPass->setSceneBlending(SBT_ADD);
//pPass->setSceneBlending(SBF_SOURCE_ALPHA , SBF_ONE_MINUS_SOURCE_ALPHA );
//pTextureState->setAlphaOperation(LBX_MODULATE, LBS_TEXTURE, LBS_MANUAL, 1, Transparence, 1);//
Ogre::TextureUnitState* pTextureState = pPass->getTextureUnitState(0);
pTextureState->setColourOperationEx(Ogre::LBX_ADD , Ogre::LBS_TEXTURE , Ogre::LBS_MANUAL, color, color );
pSubEntiy->setMaterialName(strCloneName);
m_materialSelVector.push_back(pMaterialClone);
m_materilaOldVector.push_back(pMaterial);
}
}
}
}
else
{
int iIndex = 0;
int iCount = m_EntityList.size();
Ogre::Entity* pEntity = NULL;
for(int i = 0; i < iCount; i++)
{
pEntity = m_EntityList[i].pEntity;
if(pEntity)
{
Ogre::SubEntity* pSubEntiy = pEntity->getSubEntity(0);
if(pSubEntiy)
{
if(iIndex >= (int)m_materialSelVector.size())
{
continue;
}
std::string strMaterialName = m_materialSelVector[iIndex]->getName();
pSubEntiy->setMaterialName(strMaterialName);
iIndex++;
}
}
//.........这里部分代码省略.........