void  OgreWidget::mouseSelect(QPoint const & pos, bool multiple)
{
  /*
    Apercu de ce que pourrait donner d'une selection par volume.

  Ogre::Real x = pos.x() / (float)width();
  Ogre::Real y = pos.y() / (float)height();

  Ogre::Ray ray = m_camera->getCamera()->getCameraToViewportRay(x, y);
  Ogre::RaySceneQuery * query = m_sceneManager->createRayQuery(ray);
  Ogre::RaySceneQueryResult & queryResult = query->execute();
  Ogre::RaySceneQueryResult::iterator queryResultIterator = queryResult.begin();
  Ogre::PlaneBoundedVolume volume = m_camera->getCameraToViewportBoxVolume();
  Ogre::PlaneBoundedVolumeListSceneQuery * query = m_sceneManager->createPlaneBoundedVolumeQuery(volume);
  Ogre::SceneQueryResult & queryResult = query->execute();*/

  Ogre::Entity *  selectedEntity = m_selectionBuffer->OnSelectionClick(pos.x(), pos.y());

  if (selectedEntity)
    {
      Ogre::SceneNode * node = selectedEntity->getParentSceneNode();

      while (node->getParentSceneNode() != m_sceneManager->getRootSceneNode())
        node = node->getParentSceneNode();
      selectItem(Ogre::any_cast<InstItem *>(node->getUserObjectBindings().getUserAny()), multiple);
    }
  else
    unselectItem();
}
void CFakeObjectEntityManager::_DestroyFakeNode(FakeObject& obj)
{
	//销毁摄像机
	CEngineInterface::GetMe()->GetFairySystem()->getSceneManager()->destroyCamera(obj.pCamera);

	//销毁ViewPort
	if(!obj.ptrRenderTexture.isNull() && obj.ptrRenderTexture->getBuffer()->getRenderTarget())
	{
		obj.ptrRenderTexture->getBuffer()->getRenderTarget()->removeAllViewports();
	}

	//销毁RenderTexture
	obj.ptrRenderTexture.setNull();
	Ogre::TextureManager::getSingleton().remove(
		Ogre::String(obj.strName) + "_RenderTexture");

	//销毁Rectangle2D
	if (obj.pRectange)
	{
		Ogre::SceneNode* parentNode = obj.pRectange->getParentSceneNode();

		if (parentNode)
		{
			parentNode->detachObject(obj.pRectange);

			// 摧毁Rectangle2D所挂接的scene node
			if (parentNode->getParentSceneNode())
				parentNode->getParentSceneNode()->removeAndDestroyChild(parentNode->getName());
		}

		delete obj.pRectange;
		obj.pRectange = NULL;
	}
}
Пример #3
0
void
RenderingManager::updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur)
{
    Ogre::SceneNode *child =
        mRendering.getScene()->getSceneNode(old.getRefData().getHandle());

    Ogre::SceneNode *parent = child->getParentSceneNode();
    parent->removeChild(child);

    if (old.getClass().isActor()) {
        mActors->updateObjectCell(old, cur);
    } else {
        mObjects->updateObjectCell(old, cur);
    }
}
Пример #4
0
void OGRE3DPointRenderable::removeSceneNode(const Ogre::String& name)
{
 if (mRenderSystem->getSceneManager()->hasSceneNode(name) == false)
  return;

 Ogre::SceneNode* node = mRenderSystem->getSceneManager()->getSceneNode(name);
 Ogre::SceneNode* pnode = node->getParentSceneNode();

 if (pnode == 0)
  return;

 if (pnode == mNode)
  pnode->removeChild(node);

}
Пример #5
0
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);
  }
}
TowerTemporal::~TowerTemporal(void)
{
  printf("~TowerTemporal\n");
  if (mpShotGraphics)
  {
    // Remove from scene node
    Ogre::SceneNode* node = mpShotGraphics->getParentSceneNode();
    if (node)
    {
      node->removeAndDestroyAllChildren();
      node->getParentSceneNode()->removeChild(node);
      mpsSceneMgr->destroySceneNode(node);
      node = NULL;
    }

    // Destroy shot graphics
    mpsSceneMgr->destroyManualObject(mpShotGraphics);
    mpShotGraphics = NULL;
  }
}
// -------------------------------------------------------------------------
void CollisionsWorld::setShowDebugContactPoints(bool show)
{
	if (show && !mShowDebugContactPoints)
	{
		assert (mDebugContactPoints == 0);
		mDebugContactPoints = new DebugLines();
		getSceneManager()->getRootSceneNode ()->createChildSceneNode ("DebugContactPoints")->attachObject (mDebugContactPoints);
		mShowDebugContactPoints = true;
		return;
	}
	if (!show && mShowDebugContactPoints)
	{
		assert (mDebugContactPoints != 0);
		Ogre::SceneNode * n = (Ogre::SceneNode *)getSceneManager()->getRootSceneNode ()->getChild ("DebugContactPoints");
		n->detachObject (mDebugContactPoints);
		n->getParentSceneNode()->removeAndDestroyChild("DebugContactPoints");
		delete mDebugContactPoints;
        mDebugContactPoints = 0;
		mShowDebugContactPoints = false;
		return;
	}
}
Пример #8
0
	void LightningManager::update(const Ogre::Real& timeSinceLastFrame)
	{
		if (!mCreated)
		{
			return;
		}

		if (mEnabled)
		{
			mRemainingTime -= timeSinceLastFrame;

			if (mRemainingTime <= 0)
			{
				mRemainingTime = Ogre::Math::RangeRandom(0, 2*mAverageLightningApparitionTime);

				// Select a random camera to place the lightning
				if (!mVClouds->_getCamerasData().empty())
				{
					Ogre::Camera* c = mVClouds->_getCamerasData().at(mVClouds->_getCamerasData().size()*0.999).camera;

					Ogre::Real prob = Ogre::Math::RangeRandom(0,1);
					
					// Cloud-to-ground
					if (prob < 0.5)
					{
						addLightning(
							// Ray position
							Ogre::Vector3(c->getDerivedPosition().x + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5), mVClouds->getGeometrySettings().Height.x + 0.2*mVClouds->getGeometrySettings().Height.y, c->getDerivedPosition().z + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5)), 
							// Ray direction
							Ogre::Vector3(0,-1,0), 
							// Ray length
							mVClouds->getGeometrySettings().Height.x + 0.1*mVClouds->getGeometrySettings().Height.y);
					}
					// Cloud-to-cloud
					else if (prob < 0.7)
					{
						addLightning(
							// Ray position
							Ogre::Vector3(c->getDerivedPosition().x + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5), mVClouds->getGeometrySettings().Height.x + 0.2*mVClouds->getGeometrySettings().Height.y, c->getDerivedPosition().z + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5)), 
							// Ray direction
							Ogre::Vector3(Ogre::Math::RangeRandom(-1,1),Ogre::Math::RangeRandom(-0.1,0.1),Ogre::Math::RangeRandom(-1,1)).normalisedCopy(), 
							// Ray length
							Ogre::Math::RangeRandom(0.5,1.5f)*0.2*mVClouds->getGeometrySettings().Height.y);
					}
					// Cloud-to-ground + cloud-to-cloud
					else
					{
						addLightning(
							// Ray position
							Ogre::Vector3(c->getDerivedPosition().x + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5), mVClouds->getGeometrySettings().Height.x + 0.2*mVClouds->getGeometrySettings().Height.y, c->getDerivedPosition().z + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5)), 
							// Ray direction
							Ogre::Vector3(0,-1,0), 
							// Ray length
							mVClouds->getGeometrySettings().Height.x + 0.1*mVClouds->getGeometrySettings().Height.y);

						addLightning(
							// Ray position
							Ogre::Vector3(c->getDerivedPosition().x + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5), mVClouds->getGeometrySettings().Height.x + 0.2*mVClouds->getGeometrySettings().Height.y, c->getDerivedPosition().z + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5)), 
							// Ray direction
							Ogre::Vector3(Ogre::Math::RangeRandom(-1,1),Ogre::Math::RangeRandom(-0.1,0.1),Ogre::Math::RangeRandom(-1,1)).normalisedCopy(), 
							// Ray length
							Ogre::Math::RangeRandom(0.5,1.5f)*0.2*mVClouds->getGeometrySettings().Height.y);
					}

					updateMaterial();
				}
			}
		}

		for(std::vector<Lightning*>::iterator it = mLightnings.begin(); it != mLightnings.end();)
		{
			if ((*it)->isFinished())
			{
				Ogre::SceneNode* sn = (*it)->getSceneNode();

				delete (*it);
				it = mLightnings.erase(it);

				// Remove the associated scene node
				for(std::vector<Ogre::SceneNode*>::iterator it2 = mSceneNodes.begin(); it2 != mSceneNodes.end(); it2++)
				{
					if ((*it2) == sn)
					{
						sn->getParentSceneNode()->removeAndDestroyChild(sn);
						mSceneNodes.erase(it2);
						break;
					}
				}
			}
			else
			{
				(*it)->update(timeSinceLastFrame);
				it++;
			}
		}
	}