コード例 #1
0
ファイル: ManipulatorObject.cpp プロジェクト: mavaL/MiniCraft
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;
}
コード例 #2
0
ファイル: GameObject.cpp プロジェクト: koalanis/oort
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);
}