本文整理汇总了C++中ogre::Entity::getSubEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::getSubEntity方法的具体用法?C++ Entity::getSubEntity怎么用?C++ Entity::getSubEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::getSubEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void RttManager::CDepthListener::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
Hydrax *mHydrax = mRttManager->mHydrax;
Ogre::SceneManager::MovableObjectIterator EntityIterator =
mHydrax->getSceneManager()->getMovableObjectIterator("Entity");
Ogre::Entity* CurrentEntity;
unsigned int k;
mMaterials.empty();
while (EntityIterator.hasMoreElements())
{
CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue());
for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
{
mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName());
CurrentEntity->getSubEntity(k)->setMaterialName(mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_DEPTH)->getName());
}
EntityIterator.moveNext();
}
if (Ogre::Math::Abs(mHydrax->getPosition().y - mHydrax->getCamera()->getDerivedPosition().y) > mHydrax->getPlanesError())
{
if (mHydrax->_isCurrentFrameUnderwater())
{
mRttManager->mPlanes[RTT_DEPTH]->normal = -mRttManager->mPlanes[RTT_DEPTH]->normal;
mRttManager->mPlanes[RTT_DEPTH]->getParentNode()->translate(0,-mHydrax->getPlanesError(),0);
}
else
{
mRttManager->mPlanes[RTT_DEPTH]->getParentNode()->translate(0,mHydrax->getPlanesError(),0);
mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[RTT_DEPTH]);
}
}
if (mHydrax->_isCurrentFrameUnderwater())
{
mHydrax->getMesh()->getEntity()->setVisible(true);
mHydrax->getMesh()->getEntity()->setMaterialName(
mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_SIMPLE_RED)->
getName());
mHydrax->getMesh()->getEntity()->setRenderQueueGroup(Ogre::RENDER_QUEUE_SKIES_EARLY);
mHydrax->getGodRaysManager()->setVisible(true);
}
else
{
mHydrax->getMesh()->getEntity()->setVisible(false);
}
}
示例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: 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 );
}
}
}
}
示例4: while
void RttManager::CDepthReflectionListener::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
Hydrax *mHydrax = mRttManager->mHydrax;
Ogre::SceneManager::MovableObjectIterator EntityIterator = mHydrax->getSceneManager()->getMovableObjectIterator("Entity");
Ogre::Entity* CurrentEntity;
unsigned int k;
while (EntityIterator.hasMoreElements()) {
CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue());
for (k = 0; k < CurrentEntity->getNumSubEntities(); k++) {
CurrentEntity->getSubEntity(k)->setMaterialName(mMaterials.front());
mMaterials.pop();
}
EntityIterator.moveNext();
}
mHydrax->getMesh()->getEntity()->setVisible(true);
if (mCameraPlaneDiff != 0) {
mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->translate(0, mCameraPlaneDiff, 0);
}
mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->translate(0, mHydrax->getPlanesError(), 0);
mHydrax->getCamera()->disableReflection();
mHydrax->getCamera()->disableCustomNearClipPlane();
}
示例5: 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);
}
}
示例6: save
void Cube::save(Ogre::String file)
{
if (rndCounter == 0)
{
std::ofstream output(file.c_str());
// Write cube size
output << size << std::endl;
for (int i = 0; i < size; ++i)
for (int j = 0; j < size; ++j)
for (int k = 0; k < size; ++k)
{
CubeElement *e = data[i][j][k];
Ogre::Entity *ent = static_cast<Ogre::Entity*>(e->node->getAttachedObject(0));
Ogre::SceneNode *node = e->node;
// Write name, indexes and position
output << node->getName() << "\n"
<< "\t" << i << " " << j << " " << k << "\n" // index in data array
<< "\t" << node->getPosition().x << " " << node->getPosition().y << " " << node->getPosition().z << "\n"; // position
// Write orientation
Ogre::Vector3 orient_axis;
Ogre::Degree orient_angle;
node->getOrientation().ToAngleAxis(orient_angle, orient_axis);
output << "\t" << orient_axis.x << " " << orient_axis.y << " " << orient_axis.z << " " // orientation axis
<< orient_angle.valueDegrees() << "\n"; // orientation angle
output << "\t" << ent->getSubEntity(0)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(1)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(2)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(3)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(4)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(5)->getMaterialName() << "\n";
// Write pivot info
output << "\t" << e->isPivot << "\n";
if (e->isPivot)
{
// pivot indexes
output << "\t" << e->pivotArrays[0] << " " << e->pivotArrayIndexes[0] << "\n"
<< "\t" << e->pivotArrays[1] << " " << e->pivotArrayIndexes[1] << "\n";
}
// flush
output << std::endl;
}
output.close();
}
}
示例7: createGrassMesh
bool
CGrassSticks::buildGrassSticks(Ogre::SceneManager* sceneMgr, btDynamicsWorld* dynamicsWorld, btSoftBodyWorldInfo &softBodyWorldInfo)
{
// create our grass mesh, and create a grass entity from it
if (!sceneMgr->hasEntity(GRASS_MESH_NAME))
{
createGrassMesh();
} // End if
const int n=16;
const int sg=4;
const btScalar sz=16;
const btScalar hg=4;
const btScalar in=1/(btScalar)(n-1);
int index = 0;
for(int y=0;y<n;++y)
{
for(int x=0;x<n;++x)
{
const btVector3 org(-sz+sz*2*x*in,
1,
-sz+sz*2*y*in);
btSoftBody* psb=btSoftBodyHelpers::CreateRope(softBodyWorldInfo, org,
org+btVector3(hg*0.001f,hg,0),
sg,
1);
psb->m_cfg.kDP = 0.005f;
psb->m_cfg.kCHR = 0.1f;
for(int i=0;i<3;++i)
{
psb->generateBendingConstraints(2+i);
}
psb->setMass(1,0);
psb->setTotalMass(0.01f);
static_cast<btSoftRigidDynamicsWorld*>(dynamicsWorld)->addSoftBody(psb);
const Ogre::String& strIndex = Ogre::StringConverter::toString(index++);
Ogre::Entity* grass = sceneMgr->createEntity("Grass" + strIndex, GRASS_MESH_NAME);
Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode("node_grass_" + strIndex
,Ogre::Vector3(org.getX(), org.getY(), org.getZ())
,Ogre::Quaternion(Ogre::Degree(0), Vector3::UNIT_Y));
node->attachObject(grass);
node->scale(1.0f, Ogre::Math::RangeRandom(0.85f, 1.15f), 1.0f);
node->setVisible(true);
psb->setUserPointer((void*)(grass->getSubEntity(0)));
} // End for
} // End for
dynamicsWorld->setInternalTickCallback(&CGrassSticks::simulationTickCallback);
return true;
}
示例8: while
void GodRaysManager::DepthMapListener::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
Ogre::SceneManager::MovableObjectIterator EntityIterator = mGodRaysManager->mHydrax->getSceneManager()->getMovableObjectIterator("Entity");
Ogre::Entity * CurrentEntity = NULL;
unsigned int k = 0;
mMaterials.empty();
mGodRaysManager->mHydrax->getMesh()->getEntity()->setVisible(false);
while(EntityIterator.hasMoreElements())
{
CurrentEntity = static_cast<Ogre::Entity *>(EntityIterator.peekNextValue());
for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
{
mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName());
CurrentEntity->getSubEntity(k)->setMaterialName(_def_GodRaysDepth_Material_Name);
}
EntityIterator.moveNext();
}
}
示例9: 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);
}
}
}
}
示例10: createBall
void BallApp::createBall(std::string entName, std::string nodeName,
int x, int y, int z,
int vx, int vy, int vz) {
Ogre::Entity *entity = mSceneMgr->createEntity(entName, "sphere.mesh");
entity->setCastShadows(true);
Ogre::SceneNode *newNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(nodeName);
newNode->attachObject(entity);
mPhysics->addRigidSphere(entity, newNode, 0.1f, 1.0f, btVector3(0,0,0), btVector3(x,y,z), new btQuaternion(1.0f, 1.0f, 0, 0))->setLinearVelocity(btVector3(vx, vy, vz));
// Change Entity Color
Ogre::MaterialPtr mat = entity->getSubEntity(0)->getMaterial();
Ogre::Pass *pass = mat->getTechnique(0)->getPass(0);
pass->setDiffuse(0,1,0,0.1);
pass->setSpecular(1,1,1,0.4);
entity->setMaterialName(mat->getName());
}
示例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: 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);
}
}
示例13: 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);
}
}
}
}
示例14: 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);
}
}
示例15: while
bool np::HubConstructionComponent::addToConstruction( np::NeuroPlayer* player, double amount)
{
std::list<np::HubConstructionSlot>::iterator iterator;
iterator = slots.begin();
while ( iterator != slots.end())
{
np::HubConstructionSlot& slot = *iterator;
if ( slot.player == player)
{
slot.amount += amount;
np::GraphicComponent* graphic = slot.proxyHub->getComponent<np::GraphicComponent>();
Ogre::Entity* entity = graphic->entities.front();
Ogre::MaterialPtr material = entity->getSubEntity(0)->getMaterial();
material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setAlphaOperation(
Ogre::LBX_SOURCE1,
Ogre::LBS_MANUAL,
Ogre::LBS_CURRENT,
( slot.amount / 60.0) * 0.6);
entity->setMaterial( material);
if ( slot.amount >= 60.0)
{
return true;
}
return false;
}
iterator++;
}
return false;
}