本文整理汇总了C++中ogre::Entity::detachFromParent方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::detachFromParent方法的具体用法?C++ Entity::detachFromParent怎么用?C++ Entity::detachFromParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::detachFromParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMesh
//-------------------------------------------------------------------------------------------
void MagickWidget::loadMesh(Ogre::MeshPtr pMesh)
{
QString directory(OgitorsRoot::getSingletonPtr()->GetProjectOptions()->ProjectDir.c_str());
if(directory.isEmpty())
directory = "./";
QDir(directory).mkpath("entitycache");
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( "MeshMagickTex",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
512, 512, 0, Ogre::PF_R8G8B8A8 , Ogre::TU_RENDERTARGET );
Ogre::RenderTexture *rttTex = texture->getBuffer()->getRenderTarget();
Ogre::SceneManager *mSceneMgr = Ogre::Root::getSingletonPtr()->createSceneManager("OctreeSceneManager", "MeshMagickTexMgr");
Ogre::Light *dirl = mSceneMgr->createLight("DisplayLight");
dirl->setDirection(-1,-1,-1);
dirl->setDiffuseColour(1,1,1);
dirl->setType(Ogre::Light::LT_DIRECTIONAL);
Ogre::Camera* RTTCam = mSceneMgr->createCamera("MeshMagickCam");
RTTCam->setNearClipDistance(0.01F);
RTTCam->setFarClipDistance(0);
RTTCam->setAspectRatio(1);
RTTCam->setFOVy(Ogre::Degree(90));
RTTCam->setPosition(0,0,1);
RTTCam->lookAt(0,0,0);
Ogre::Viewport *v = rttTex->addViewport( RTTCam );
v->setClearEveryFrame( true );
v->setBackgroundColour(Ogre::ColourValue(0,0,0));
Ogre::Entity *mEntity;
mEntity = mSceneMgr->createEntity("scbDisplay", pMesh->getName());
mSceneMgr->getRootSceneNode()->attachObject(mEntity);
Ogre::Vector3 vSize = mEntity->getBoundingBox().getHalfSize();
Ogre::Vector3 vCenter = mEntity->getBoundingBox().getCenter();
vSize += Ogre::Vector3(vSize.z, vSize.z, vSize.z);
float maxsize = std::max(std::max(vSize.x,vSize.y),vSize.z);
vSize = Ogre::Vector3(0, 0, maxsize * 1.15f) + vCenter;
RTTCam->setPosition(vSize.x,vSize.y,vSize.z);
RTTCam->lookAt(vCenter.x,vCenter.y,vCenter.z);
rttTex->update();
Ogre::String imagefile = OgitorsUtils::QualifyPath(directory.toStdString() + "/entitycache/meshmagick.png");
rttTex->writeContentsToFile(imagefile);
mEntity->detachFromParent();
mSceneMgr->destroyEntity(mEntity);
rttTex->removeAllViewports();
Ogre::Root::getSingletonPtr()->destroySceneManager(mSceneMgr);
mDisplayWidget->setImage(QString(imagefile.c_str()));
}
示例2: destroy
bool VehicleRenderable::destroy()
{
while(!mEntities.empty())
{
Ogre::Entity* ent = mEntities.back();
//detach and remove all entities the object created
ent->detachFromParent();
mSceneMgr->destroyEntity(ent);
mEntities.pop_back();
}
while(!mSceneNodes.empty())
{
Ogre::SceneNode* sn = mSceneNodes.back();
//detach and remove all scene node only the object created
sn->detachAllObjects();
mSceneMgr->destroySceneNode(sn);
mSceneNodes.pop_back();
}
return true;
}
示例3: updateLocomote
void Ninja::updateLocomote(Ogre::Real deltaTime)
{
int xOffset = ((this->grid->getRows() * this->grid->getHeight()) - this->grid->getHeight())/2;
int yOffset = ((this->grid->getCols() * this->grid->getHeight()) - this->grid->getHeight())/2;
int x = (xOffset + mDestination.x)/grid->getHeight();
int y = (yOffset + mDestination.z)/grid->getHeight();
if (mDirection == Ogre::Vector3::ZERO)
{
if (nextLocation()) // a check to see if there is another destination
{
// Set walking animation
this->setBaseAnimation(ANIM_WALK, true);
//this->setTopAnimation(ANIM_WALK, true);
}
}
else
{
Ogre::Real move = mWalkSpeed * deltaTime;
mDistance -= move;
if (mDistance <= 0.0f) // over shooting target
{
this->mBodyNode->setPosition(mDestination);
this->setCurrentNode(grid->getNode(x, y));
while(this->getCurrentNode()->getItemList()->size() > 0)
{
Ogre::Entity* ent = this->getCurrentNode()->getItemList()->front();
this->inventory->push_back(ent);
this->getCurrentNode()->getItemList()->pop();
ent->detachFromParent();
this->getmBodyEntity()->attachObjectToBone("Joint13", ent);
ent->getParentNode()->scale(1.15f,1.15f,1.15f);
ent->setVisible(true);
}
mDirection = Ogre::Vector3::ZERO;
if (!nextLocation()) // a check to see if there is another destination
{
this->setCurrentNode(grid->getNode(x, y));
this->setBaseAnimation(ANIM_IDLE_1, true);
//this->setTopAnimation(ANIM_IDLE_1, true);
}
else
{
Ogre::Vector3 src = this->mBodyNode->getOrientation() * Ogre::Vector3::UNIT_X;
if ((1.0f + src.dotProduct(mDirection)) < 0.0001f)
{
this->mBodyNode->yaw(Ogre::Degree(180));
}
else
{
Ogre::Quaternion quat = src.getRotationTo(mDirection);
this->mBodyNode->rotate(quat);
this->mBodyNode->yaw(Ogre::Degree(angleOffset)); // To correct for models facing different directions
}
}
}
else
{
this->mBodyNode->translate(mDirection * move);
}
}
}
示例4: _createImages
void ZoneListWidget::_createImages(ImageMap& retlist)
{
retlist.clear();
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( "EntityTex",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
256, 256, 0, Ogre::PF_A8R8G8B8 , Ogre::TU_RENDERTARGET );
Ogre::RenderTexture *rttTex = texture->getBuffer()->getRenderTarget();
Ogre::SceneManager *mSceneMgr = Ogre::Root::getSingletonPtr()->createSceneManager("OctreeSceneManager", "EntityTexMgr");
Ogre::Light *dirl = mSceneMgr->createLight("DisplayLight");
dirl->setDirection(-1,-1,-1);
dirl->setDiffuseColour(1,1,1);
dirl->setType(Ogre::Light::LT_DIRECTIONAL);
Ogre::Camera* RTTCam = mSceneMgr->createCamera("EntityCam");
RTTCam->setNearClipDistance(0.01F);
RTTCam->setFarClipDistance(0);
RTTCam->setAspectRatio(1);
RTTCam->setFOVy(Ogre::Degree(90));
RTTCam->setPosition(0,0,1);
RTTCam->lookAt(0,0,0);
Ogre::Viewport *v = rttTex->addViewport( RTTCam );
v->setClearEveryFrame( true );
v->setBackgroundColour(Ogre::ColourValue(0,0,0,0));
ModularZoneFactory* factory = dynamic_cast<ModularZoneFactory*>(OgitorsRoot::getSingletonPtr()->GetEditorObjectFactory("Modular Zone Object"));
if(!factory)return;
factory->loadZoneTemplates();
ZoneInfoMap zoneTemplates = factory->getZoneTemplateMap();
Ogre::Entity *mEntity;
unsigned char dataptr[300 * 300 * 6];
unsigned char *dataptr2;
Ogre::PixelBox pb(256,256,1,Ogre::PF_A8R8G8B8, dataptr);
EntityMap entities;
ZoneInfoMap::iterator zi;
for(zi=zoneTemplates.begin();zi!=zoneTemplates.end();++zi)
{
Ogre::String addstr = (*zi).second.mMesh;
if(entities.find((*zi).first) == entities.end())
entities.insert(EntityMap::value_type((*zi).first,addstr));
}
EntityMap::const_iterator ite = entities.begin();
while(ite != entities.end())
{
Ogre::String addstr = ite->second;
mEntity = mSceneMgr->createEntity("MZP_Preview", addstr);
mSceneMgr->getRootSceneNode()->attachObject(mEntity);
//TODO: It would be nice to retrieve a Preview Camera Position from
//the .zone file
//TODO: also render portal outlines clearly so that the user can see
//how the zone is laid out
Ogre::Vector3 vSize = mEntity->getBoundingBox().getCorner(Ogre::AxisAlignedBox::NEAR_RIGHT_TOP);//.getHalfSize();//============
Ogre::Vector3 vCenter = mEntity->getBoundingBox().getCenter();
//FIXME ------ NICE PREVIEWS NEEDED - bigger
vSize += Ogre::Vector3(vSize.z, vSize.z, vSize.z);
float maxsize = std::max(std::max(vSize.x,vSize.y),vSize.z);
//vSize = Ogre::Vector3(0, 0, maxsize * 1.1f) + vCenter;
vSize = Ogre::Vector3(maxsize * 0.5f, vSize.y, maxsize * 0.5f) + vCenter;
//vSize.x +=vSize.x/2;//Maybe test to see which is larger x/2 or z/2 and use that?
//vSize.z +=vSize.x/2;
//RTTCam->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
RTTCam->setPosition(vSize.x,vSize.y,vSize.z);
RTTCam->lookAt(vCenter.x,vCenter.y,vCenter.z);
rttTex->update();
rttTex->copyContentsToMemory(pb, Ogre::RenderTarget::FB_FRONT);
dataptr2 = new unsigned char[96 * 96 * 4];
Ogre::PixelBox pb2(96,96,1,Ogre::PF_A8R8G8B8, dataptr2);
Ogre::Image::scale(pb,pb2);
addstr.erase(addstr.length() - 5, 5);
retlist.insert(ImageMap::value_type((*ite).first, dataptr2));
mEntity->detachFromParent();
mSceneMgr->destroyEntity(mEntity);
ite++;
}
rttTex->removeAllViewports();
Ogre::Root::getSingletonPtr()->destroySceneManager(mSceneMgr);
Ogre::TextureManager::getSingletonPtr()->unload(texture->getName());
//.........这里部分代码省略.........