Esempio n. 1
0
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);
}
Esempio n. 2
0
void ManipulatorObject::ShowEntityGizmo(Ogre::Entity* pEntity, bool bShow, eEditMode mode, bool bDrift/* = false*/)
{
	if(!pEntity)
		return;

	assert(mode != eEditMode_None);
	if (mode == eEditMode_Select)
	{
		Ogre::SceneNode* aabbNode = dynamic_cast<Ogre::SceneNode*>(pEntity->getParentSceneNode()->getChild(pEntity->getName()));
		aabbNode->setVisible(bShow);
		if (bShow)
		{
			//显示包围盒
			Ogre::WireBoundingBox* pAABB = GetEntityAABBGizmo(pEntity);
			if(bDrift)		//显示为红色
				pAABB->setMaterial("RedEmissive_ZCheck");
			else			//显示为绿色
				pAABB->setMaterial("GreenEmissive_ZCheck");
		}
	}
	else
	{
		//显示坐标轴
		m_pGizmoAixs->Show(bShow, mode == eEditMode_Move || mode == eEditMode_Scale);
		if (bShow)
			m_pGizmoAixs->Attach(pEntity->getParentSceneNode());
	}
}
Esempio n. 3
0
void SelectionHandler::postRenderPass(uint32_t pass)
{
  M_HandleToBox::iterator it = boxes_.begin();
  M_HandleToBox::iterator end = boxes_.end();
  for (; it != end; ++it)
  {
    Ogre::WireBoundingBox* box = it->second.second;
    box->setVisible(true);
  }
}
Esempio n. 4
0
void ManipulatorObject::_UpdateAABBOfEntity( Ogre::Entity* pEntity )
{
	assert(pEntity);

	Ogre::SceneNode* aabbNode = dynamic_cast<Ogre::SceneNode*>(
		pEntity->getParentSceneNode()->getChild(pEntity->getName()));
	Ogre::WireBoundingBox* pAABB = GetEntityAABBGizmo(pEntity);
	pAABB->setupBoundingBox(pEntity->getWorldBoundingBox(true));
	//避免被裁减
	(const_cast<Ogre::AxisAlignedBox&>(pAABB->getBoundingBox())).setInfinite();
	aabbNode->_updateBounds();
}
Esempio n. 5
0
Ogre::Entity* ManipulatorObject::AddEntity( const STRING& meshname, const POS& worldPos, bool bOp, const ORIENT& orient, const SCALE& scale )
{
	static int counter = 0;

	Ogre::String entName("Entity_");
	entName += Ogre::StringConverter::toString(counter++);

	Ogre::Entity* newEntity = RenderManager.m_pSceneMgr->createEntity(entName, meshname);
	if(!newEntity)
		return nullptr;

	Ogre::SceneNode* pNode = RenderManager.m_pSceneMgr->getRootSceneNode()->createChildSceneNode(worldPos, orient);
	pNode->setScale(scale);
	pNode->attachObject(newEntity);

	//每个Entity创建一个包围盒节点
	Ogre::WireBoundingBox* aabb = new Ogre::WireBoundingBox;
	aabb->setMaterial("BaseWhiteNoLighting");
	aabb->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY);
	Ogre::SceneNode* aabbNode = pNode->createChildSceneNode(entName);
	aabbNode->attachObject(aabb);
	aabbNode->setVisible(false);

	_UpdateAABBOfEntity(newEntity);

	//设置查询掩码
	newEntity->setQueryFlags(eQueryMask_Entity);

	SObjectInfo* objInfo = new SObjectInfo;
	objInfo->m_meshname = meshname;
	objInfo->m_pos = worldPos;
	objInfo->m_rot = orient;
	objInfo->m_scale = scale;

	m_objects.insert(std::make_pair(newEntity, objInfo));

	//可撤销操作
	if (bOp)
	{
		opObjectAddRemove* op = ManipulatorSystem.GetOperation().NewOperation<opObjectAddRemove>();
		opObjectAddRemove::SOpItem item;
		item.bAddOrRemove = true;
		item.ent = newEntity;
		item.objInfo = *objInfo;
		op->AddOp(item);
		ManipulatorSystem.GetOperation().Commit(op);
	}
	
	return newEntity;
}
Esempio n. 6
0
void PointCloudSelectionHandler::getAABBs(const Picked& obj, V_AABB& aabbs)
{
  S_uint64::iterator it = obj.extra_handles.begin();
  S_uint64::iterator end = obj.extra_handles.end();
  for (; it != end; ++it)
  {
    M_HandleToBox::iterator find_it = boxes_.find(std::make_pair(obj.handle, *it - 1));
    if (find_it != boxes_.end())
    {
      Ogre::WireBoundingBox* box = find_it->second.second;

      aabbs.push_back(box->getWorldBoundingBox());
    }
  }
}
Esempio n. 7
0
void GameObject::showColliderBox() {
	auto var = geom->getBoundingBox();

	// Bullet uses half margins for collider
	auto size = var.getSize() / 2;

	btVector3 min(0, 0, 0);
	btVector3 max(0, 0, 0);
	shape->getAabb(tr, min, max);
	Ogre::WireBoundingBox* box = new Ogre::WireBoundingBox();
	Ogre::AxisAlignedBox abb(Ogre::Vector3(-size.x*scale, -size.y*scale, -size.z*scale), Ogre::Vector3(size.x*scale, size.y*scale, size.z*scale));
	box->setupBoundingBox(abb);
	box->setVisible(true);
	box->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY);
	sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(box);
}