Пример #1
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());
	}
}
Пример #2
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);
}
Пример #3
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;
}