本文整理汇总了C++中ogre::SceneNode::detachAllObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::detachAllObjects方法的具体用法?C++ SceneNode::detachAllObjects怎么用?C++ SceneNode::detachAllObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::detachAllObjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createBox
void SelectionHandler::createBox(const std::pair<CollObjectHandle, uint64_t>& handles, const Ogre::AxisAlignedBox& aabb, const std::string& material_name)
{
Ogre::WireBoundingBox* box = 0;
Ogre::SceneNode* node = 0;
M_HandleToBox::iterator it = boxes_.find(handles);
if (it == boxes_.end())
{
Ogre::SceneManager* scene_manager = context_->getSceneManager();
node = scene_manager->getRootSceneNode()->createChildSceneNode();
box = new Ogre::WireBoundingBox;
bool inserted = boxes_.insert(std::make_pair(handles, std::make_pair(node, box))).second;
ROS_ASSERT(inserted);
}
else
{
node = it->second.first;
box = it->second.second;
}
box->setMaterial(material_name);
box->setupBoundingBox(aabb);
node->detachAllObjects();
node->attachObject(box);
}
示例2: allocateTexts
void FootstepDisplay::allocateTexts(size_t num) {
if (num > texts_.size()) {
// need to allocate
for (size_t i = texts_.size(); i < num; i++) {
// create nodes
Ogre::SceneNode* node = scene_node_->createChildSceneNode();
rviz::MovableText* text
= new rviz::MovableText("not initialized", "Arial", 0.05);
text->setVisible(false);
text->setTextAlignment(rviz::MovableText::H_CENTER,
rviz::MovableText::V_ABOVE);
node->attachObject(text);
texts_.push_back(text);
text_nodes_.push_back(node);
}
}
else if (num < texts_.size()) {
for (int i = texts_.size() - 1; i >= (int)num; i--) {
Ogre::SceneNode* node = text_nodes_[i];
node->detachAllObjects();
node->removeAndDestroyAllChildren();
scene_manager_->destroySceneNode(node);
}
text_nodes_.resize(num);
texts_.resize(num);
}
}
示例3: Destroy
void EC_Terrain::Destroy()
{
assert(GetFramework());
if (!GetFramework())
return;
boost::shared_ptr<OgreRenderer::Renderer> renderer = GetFramework()->GetServiceManager()->GetService<OgreRenderer::Renderer>().lock();
if (!renderer) // Oops! Inconvenient dtor order - can't delete our own stuff since we can't get an instance to the owner.
return;
Ogre::SceneManager *sceneMgr = renderer->GetSceneManager();
if (!sceneMgr) // Oops! Same as above.
return;
for(int y = 0; y < cNumPatchesPerEdge; ++y)
for(int x = 0; x < cNumPatchesPerEdge; ++x)
{
Ogre::SceneNode *node = GetPatch(x, y).node;
if (!node)
continue;
sceneMgr->getRootSceneNode()->removeChild(node);
// sceneMgr->destroyManualObject(dynamic_cast<Ogre::ManualObject*>(node->getAttachedObject(0)));
node->detachAllObjects();
sceneMgr->destroySceneNode(node);
}
}
示例4: setEntity
void OgreEntityRenderer::setEntity(Ogre::Entity* entity)
{
mActiveAnimation = nullptr;
Ogre::SceneNode* node = mTexture->getRenderContext()->getSceneNode();
node->detachAllObjects();
if (mEntity) {
if (mMeshListener) {
mEntity->getMesh()->removeListener(mMeshListener);
}
if (mEntity->hasSkeleton()) {
mEntity->getSkeleton()->removeListener(mSkeletonListener);
}
}
mSkeletonDisplay.reset();
if (entity) {
node->attachObject(entity);
mTexture->getRenderContext()->repositionCamera();
if (mAutoShowFull) {
showFull();
}
entity->getMesh()->addListener(mMeshListener);
if (entity->hasSkeleton()) {
entity->getSkeleton()->addListener(mSkeletonListener);
if (mShowSkeleton) {
mSkeletonDisplay.reset(new SkeletonDisplay(*entity));
}
}
}
}
示例5: unloadEntity
void OgreEntityRenderer::unloadEntity()
{
Ogre::SceneNode* node = mTexture->getRenderContext()->getSceneNode();
node->detachAllObjects();
if (mEntity) {
Ogre::SceneManager* scenemgr = mTexture->getRenderContext()->getSceneManager();
scenemgr->destroyEntity(mEntity);
mEntity = nullptr;
}
}
示例6: setEntity
void OgreEntityRenderer::setEntity(Ogre::Entity* entity)
{
Ogre::SceneNode* node = mTexture->getRenderContext()->getSceneNode();
node->detachAllObjects();
node->attachObject(entity);
mTexture->getRenderContext()->repositionCamera();
if (mAutoShowFull) {
showFull();
}
}
示例7: removeCamera
void OgreVehicle::removeCamera()
{
if (mCam)
{
Ogre::SceneNode* pNodeCam = (Ogre::SceneNode*)(mNode->getChild("Cam"+mNode->getName()));
if (pNodeCam)
{
pNodeCam->detachAllObjects();
}
mCam = NULL;
}
}
示例8: destroyBox
void SelectionHandler::destroyBox(const std::pair<CollObjectHandle, uint64_t>& handles)
{
M_HandleToBox::iterator it = boxes_.find(handles);
if (it != boxes_.end())
{
Ogre::SceneNode* node = it->second.first;
Ogre::WireBoundingBox* box = it->second.second;
node->detachAllObjects();
node->getParentSceneNode()->removeAndDestroyChild(node->getName());
delete box;
boxes_.erase(it);
}
}
示例9: setModel
void ModelRenderer::setModel(Model::Model* model)
{
Ogre::SceneNode* node = mTexture->getRenderContext()->getSceneNode();
node->detachAllObjects();
if (model) {
node->attachObject(model);
repositionSceneNode();
mTexture->getRenderContext()->repositionCamera();
if (mAutoShowFull) {
mModelReloadedConnection = mModel->Reloaded.connect(sigc::mem_fun(*this, &ModelRenderer::model_Reloaded));
showFull();
}
}
}
示例10:
FootstepDisplay::~FootstepDisplay()
{
delete alpha_property_;
delete width_property_;
delete height_property_;
delete depth_property_;
delete show_name_property_;
delete use_group_coloring_property_;
delete line_;
// remove all the nodes
for (size_t i = 0; i < text_nodes_.size(); i++) {
Ogre::SceneNode* node = text_nodes_[i];
node->removeAndDestroyAllChildren();
node->detachAllObjects();
scene_manager_->destroySceneNode(node);
}
}
示例11: RemoveObstacle
void MapManager::RemoveObstacle(MapArea* area, Objects* input)
{
char areaString[30];
sprintf(areaString, "map_area_%d", area->getIndex());
//get the area node from map node.
Ogre::SceneNode* areaNode = (Ogre::SceneNode*)mMapNode->getChild(Ogre::String(areaString));
char cubeString[30];
sprintf(cubeString, "cube_%d", input->index);
Ogre::SceneNode* objectNode = (Ogre::SceneNode*)areaNode->getChild(Ogre::String(cubeString));
objectNode->detachAllObjects();
mSceneMgr->destroyEntity(Ogre::String(cubeString));
//remove the object node from areanode
areaNode->removeAndDestroyChild(Ogre::String(cubeString));
input->mLoaded = false;
//we also need to remove rigid body
std::vector<OgreBulletDynamics::RigidBody*>::iterator rigidBodyIterator;
for(rigidBodyIterator = mRigidBodyList.begin(); rigidBodyIterator != mRigidBodyList.end(); rigidBodyIterator++)
{
//is this the rigid body for this cube?
if((*rigidBodyIterator)->getName().compare("BoxRigid" + Ogre::StringConverter::toString(input->index)))
{
//yes!
//get out of this loop
break;
}
}
//remove it from the physic manager
PhysicManager::getSingletonPtr()->removeRigidBody((*rigidBodyIterator), BODIES_NONE);
//remove from the list
mRigidBodyList.erase(rigidBodyIterator);
mNumEntitiesInstanced--;
}
示例12: 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;
}
示例13: renderTextures
//.........这里部分代码省略.........
//Disable fog
Ogre::FogMode oldFogMode = sceneMgr->getFogMode();
Ogre::ColourValue oldFogColor = sceneMgr->getFogColour();
Ogre::Real oldFogDensity = sceneMgr->getFogDensity();
Ogre::Real oldFogStart = sceneMgr->getFogStart();
Ogre::Real oldFogEnd = sceneMgr->getFogEnd();
sceneMgr->setFog(Ogre::FOG_NONE);
// Get current status of the queue mode
Ogre::SceneManager::SpecialCaseRenderQueueMode OldSpecialCaseRenderQueueMode =
sceneMgr->getSpecialCaseRenderQueueMode();
//Only render the entity
sceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_INCLUDE);
sceneMgr->addSpecialCaseRenderQueue(renderQueueGroup);
Ogre::uint8 oldRenderQueueGroup = entity->getRenderQueueGroup();
entity->setRenderQueueGroup(renderQueueGroup);
bool oldVisible = entity->getVisible();
entity->setVisible(true);
float oldMaxDistance = entity->getRenderingDistance();
entity->setRenderingDistance(0);
//Calculate the filename hash used to uniquely identity this render
std::string strKey = entityKey;
char key[32] = {0};
Ogre::uint32 i = 0;
for (std::string::const_iterator it = entityKey.begin(); it != entityKey.end(); ++it) {
key[i] ^= *it;
i = (i+1) % sizeof(key);
}
for (i = 0; i < sizeof(key); ++i)
key[i] = (key[i] % 26) + 'A';
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
GetUserDir().string(), "FileSystem", "BinFolder");
std::string fileNamePNG =
"Rendered." + std::string(key, sizeof(key)) + '.' +
Ogre::StringConverter::toString(textureSize) + ".png";
//Attempt to load the pre-render file if allowed
bool needsRegen = false;
if (!needsRegen) {
try{
texture = Ogre::TextureManager::getSingleton().load(
fileNamePNG, "BinFolder", Ogre::TEX_TYPE_2D, 0);
} catch (...) {
needsRegen = true;
}
}
if (needsRegen) {
//If this has not been pre-rendered, do so now
//Position camera
camNode->setPosition(0, 0, 0);
// TODO camNode->setOrientation(Quaternion(yaw, Vector3::UNIT_Y) * Quaternion(-pitch, Vector3::UNIT_X));
camNode->translate(Ogre::Vector3(0, 0, objDist), Ogre::Node::TS_LOCAL);
renderTarget->update();
//Save RTT to file
renderTarget->writeContentsToFile((GetUserDir() / fileNamePNG).string());
//Load the render into the appropriate texture view
texture = Ogre::TextureManager::getSingleton().load(fileNamePNG, "BinFolder", Ogre::TEX_TYPE_2D, 0);
ggTexture = ClientUI::GetTexture(GetUserDir() / fileNamePNG);
}
entity->setVisible(oldVisible);
entity->setRenderQueueGroup(oldRenderQueueGroup);
entity->setRenderingDistance(oldMaxDistance);
sceneMgr->removeSpecialCaseRenderQueue(renderQueueGroup);
// Restore original state
sceneMgr->setSpecialCaseRenderQueueMode(OldSpecialCaseRenderQueueMode);
//Re-enable mipmapping
mm->setDefaultTextureFiltering(oldMinFilter, oldMagFilter, oldMipFilter);
//Re-enable fog
sceneMgr->setFog(oldFogMode, oldFogColor, oldFogDensity, oldFogStart, oldFogEnd);
//Delete camera
renderTarget->removeViewport(0);
renderCamera->getSceneManager()->destroyCamera(renderCamera);
//Delete scene node
node->detachAllObjects();
if (oldSceneNode)
oldSceneNode->attachObject(entity);
//Delete RTT texture
assert(!renderTexture.isNull());
std::string texName2(renderTexture->getName());
renderTexture.setNull();
if (Ogre::TextureManager::getSingletonPtr())
Ogre::TextureManager::getSingleton().remove(texName2);
}
示例14: UpdateLoadedList
//update that checks the loaded list for adding or removing objects inside
void MapManager::UpdateLoadedList(std::vector<MapArea*> *input)
{
//run through our current list
//see if there is anything in the list to be updated
std::vector<MapArea*>::iterator loadedIterator;
for(loadedIterator = input->begin(); loadedIterator != input->end(); loadedIterator++)
{
//No matter if the area is fully inside or not, let's check if the area is now outside of the HOLDRADIUS
if(!IsAreaInsideLoadRadius((*loadedIterator)))
{
if(!IsAreaInsideHoldRadius((*loadedIterator)))
{
//now, time to remove the area node
//std::cout << "REMOVING AREA NODE!\n";
char areaString[30];
sprintf(areaString, "map_area_%d", (*loadedIterator)->getIndex());
//get the area node from map node.
Ogre::SceneNode* areaNode = (Ogre::SceneNode*)mMapNode->getChild(Ogre::String(areaString));
//delete ground node
char groundString[30];
sprintf(groundString, "map_area_ground_%d", (*loadedIterator)->getIndex());
Ogre::SceneNode* groundNode = (Ogre::SceneNode*)areaNode->getChild(Ogre::String(groundString));
groundNode->removeAndDestroyAllChildren();
groundNode->detachAllObjects();
areaNode->removeAndDestroyChild(groundString);
areaNode->removeAndDestroyAllChildren();
areaNode->detachAllObjects();
mMapNode->removeAndDestroyChild(areaString);
//set the map area to be unloaded
(*loadedIterator)->setLoaded(false);
//remove it from the list
input->erase(loadedIterator);
return;
}
}
//since this area is not fully inside, lets check if this object is currently inside the scene
std::vector<Objects*>::iterator obstacleIterator;
for(obstacleIterator = (*loadedIterator)->_mObstacleList.begin(); obstacleIterator!=(*loadedIterator)->_mObstacleList.end(); obstacleIterator++)
{
//is this object in the load radius?
if(IsObjectInsideRadius((*obstacleIterator), LOADRADIUS))
{
//yes
//is this object already loaded in the game?
if((*obstacleIterator)->mLoaded)
{
//yes
//skip
continue;
}
else
{
//no
//add it into the game
AddObstacle((*loadedIterator), (*obstacleIterator));
}
}
//is this object out of hold radius?
else if(!IsObjectInsideRadius((*obstacleIterator), HOLDRADIUS))
{
//no
//is this object already loaded in the game?
if((*obstacleIterator)->mLoaded)
{
//yes
//remove it
RemoveObstacle((*loadedIterator),(*obstacleIterator));
}
else
{
//no
//skip
continue;
}
}
}
std::vector<Objects*>::iterator enemyIterator;
for(enemyIterator = (*loadedIterator)->_mEnemySpawnPointList.begin(); enemyIterator!=(*loadedIterator)->_mEnemySpawnPointList.end(); enemyIterator++)
{
//is this object inside the load radius?
if(IsObjectInsideRadius((*enemyIterator), ENEMY_LOADRADIUS))
{
//yes
//is this enemy spawn point already loaded?
if(!(*enemyIterator)->mLoaded)
{
//no
//add enemy
//.........这里部分代码省略.........
示例15: UpdateTerrain
// Given a scene node for a terrain, find the manual object on that scene node and
// update the manual object with the heightmap passed. If there is no manual object on
// the scene node, remove all it's attachments and add the manual object.
// The heightmap is passed in a 1D array ordered by width rows (for(width) {for(length) {hm[w,l]}})
// This must be called between frames since it touches the scene graph
// BETWEEN FRAME OPERATION
void Region::UpdateTerrain(const int hmWidth, const int hmLength, const float* hm) {
Ogre::SceneNode* node = this->TerrainSceneNode;
LG::Log("Region::UpdateTerrain: updating terrain for region %s", this->Name.c_str());
if (node == NULL) {
LG::Log("Region::UpdateTerrain: terrain scene node doesn't exist. Not updating terrain.");
return;
}
// Find the movable object attached to the scene node. If not found remove all.
if (node->numAttachedObjects() > 0) {
Ogre::MovableObject* attached = node->getAttachedObject(0);
if (attached->getMovableType() != "ManualObject") {
// don't know why this would ever happen but clean out the odd stuff
LG::Log("Found extra stuff on terrain scene node");
node->detachAllObjects();
}
}
// if there is not a manual object on the node, create a new one
if (node->numAttachedObjects() == 0) {
LG::Log("Region::UpdateTerrain: creating terrain ManualObject for region %s", this->Name.c_str());
// if no attached objects, we add our dynamic ManualObject
Ogre::ManualObject* mob = LG::RendererOgre::Instance()->m_sceneMgr->createManualObject("ManualObject/" + node->getName());
mob->addQueryFlags(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK);
mob->setDynamic(true);
mob->setCastShadows(true);
mob->setVisible(true);
node->attachObject(mob);
// m_visCalc->RecalculateVisibility();
}
Ogre::ManualObject* mo = (Ogre::ManualObject*)node->getAttachedObject(0);
// stuff our heightmap information into the dynamic manual object
mo->estimateVertexCount(hmWidth * hmLength);
mo->estimateIndexCount(hmWidth * hmLength * 6);
if (mo->getNumSections() == 0) {
// if first time
mo->begin(LG::GetParameter("Renderer.Ogre.DefaultTerrainMaterial"));
}
else {
mo->beginUpdate(0); // we've been here before
}
int loc = 0;
for (int xx = 0; xx < hmWidth; xx++) {
for (int yy = 0; yy < hmLength; yy++) {
mo->position((Ogre::Real)xx, (Ogre::Real)yy, hm[loc++]);
mo->textureCoord((float)xx / (float)hmWidth, (float)yy / (float)hmLength);
mo->normal(0.0, 1.0, 0.0); // always up (for the moment)
}
}
for (int px = 0; px < hmLength-1; px++) {
for (int py = 0; py < hmWidth-1; py++) {
mo->quad(px + py * hmWidth,
px + (py + 1) * hmWidth,
(px + 1) + (py + 1) * hmWidth,
(px + 1) + py * hmWidth
);
}
}
mo->end();
return;
}