コード例 #1
0
// 把一个物体放到指定得摄影机位置
void CFakeObjectEntityManager::CreateObject(LPCTSTR szObjName, CObjEntityActor* pNode, CObjEntityActor* pAttachNode, LPCTSTR szCameraName, int nTexWidth, int nTexHeight, LPCTSTR szBackgroundName)
{
	// 先根据该fake object的名称来获取摆放位置
	m_fvPosition = Ogre::Vector3(_GetFakeObjPos(szObjName), 10000.f, 0.f);

	//物体不存在,创建新的渲染环境
	FakeObjectMap::iterator it = _GetFakeNode(szObjName, pNode, szCameraName, nTexWidth, nTexHeight, szBackgroundName);

	if(it == m_mapObject.end()) return;

	it->second.pEntityNode = pNode;
	it->second.pAttachEntityNode = pAttachNode;
	//将需要渲染的实体放入渲染环境中

	// 如果骑在马上的,要设置马的位置,把人的位置复位
	Fairy::LogicModel* modelImpl = pNode->GetActorImpl();

	if (modelImpl->isAttached())
	{
		Fairy::LogicModel* parentModel = modelImpl->getAttachModel();

		KLAssert (parentModel);

		modelImpl->setPosition(Ogre::Vector3(0.0f, 0.0f, 0.0f));

		parentModel->setPosition(Ogre::Vector3(m_fvPosition.x, m_fvPosition.y, m_fvPosition.z));
		parentModel->setVisible(true);
	}
	else
		pNode->SetGfxPosition(fVector3(m_fvPosition.x, m_fvPosition.y, m_fvPosition.z));

	//初始就显示,在运行过程中会一直保持visible为true的状态
	pNode->SetVisible(TRUE);
}
コード例 #2
0
//----laim
void CEngineInterface::SetShowObjectByType( LPCTSTR szName)
{
	
		
		static bool blogic=TRUE;
		static bool bstaticentity = TRUE;
		static bool bliquid = TRUE;
		static bool effect = TRUE;
		static bool pareticle = TRUE;
		static long lshowType = ENUM_OBJ_TYPE::ALL_TYPE;;

		 Ogre::String currentName = szName;

		if (currentName == "lm")
		{

		lshowType =lshowType ^ ( blogic << 5);

		}

		if (currentName == "se"){

		 lshowType =lshowType ^ bstaticentity;
		//  bstaticentity =!bstaticentity;
		}

		if (currentName == "sl"){
		lshowType = lshowType ^ (bliquid <<2);//ENUM_OBJ_TYPE::TERRAINLIQUIDOBJ_TYPE;
		//bliquid =!bliquid;
		}

		if (currentName == "ef"){
		lshowType = lshowType ^ (effect <<3);
		//effect =!effect;
		}

		if (currentName == "ps"){
		 lshowType =  lshowType ^ (effect <<1);
		//  pareticle =!pareticle;
		}

		if (currentName == "all"){
			lshowType = ENUM_OBJ_TYPE::ALL_TYPE;
		}



		//obj
		Fairy::LogicModelManager::LogicModelMap logicmap = Fairy::LogicModelManager::getSingleton().getModelMap();

		for ( Fairy::LogicModelManager::LogicModelMap::iterator i = logicmap.begin();
			i != logicmap.end(); ++i )
		{
			Fairy::LogicModel* model = i->second;
			model->setVisible(lshowType & ENUM_OBJ_TYPE::LOGICMODEL_TYPE);
		}

		Fairy::Scene::Objects objs = CEngineInterface::GetMe()->GetFairySystem()->getSceneInfo()->getObjects();
		Fairy::Scene::Objects::const_iterator it = objs.begin();
		for ( ; it != objs.end(); it++)
		{
			const Fairy::ObjectPtr& object = *it;
			if ( object->getType()== "StaticEntity" )
			{	
			
				Fairy::StaticEntityObject* entity = static_cast<Fairy::StaticEntityObject*>(object.get());
				Ogre::SceneNode* parentNode = entity->getSceneNode();
				if(parentNode)
					parentNode->setVisible( lshowType & ENUM_OBJ_TYPE::STATICENTITY_TYPE );

			}


			if( object->getType()==  "TerrainLiquid")
			{
				Fairy::TerrainLiquidObject* liquid = static_cast< Fairy::TerrainLiquidObject *>(object.get());
				Fairy::TerrainLiquid * parentNode = liquid->getTerrainLiquid();
				if(parentNode)
					parentNode->setVisible(lshowType & ENUM_OBJ_TYPE::TERRAINLIQUIDOBJ_TYPE);
			}


			if( object->getType()==  "Effect")  
			{
				Fairy::EffectObject* effect = static_cast<Fairy::EffectObject*>(object.get());
				Ogre::SceneNode* parentNode = effect->getSceneNode();
				if(parentNode)
					parentNode->setVisible(lshowType & ENUM_OBJ_TYPE::EFFECTOBJ_TYPE);
			}



			if(object->getType()==  "ParticleSystem")  
			{
				Fairy::ParticleSystemObject* particle = static_cast<Fairy::ParticleSystemObject*>(object.get());
				Ogre::SceneNode* parentNode = particle->getSceneNode();
				if(parentNode)
					parentNode->setVisible( lshowType & ENUM_OBJ_TYPE::PARTICLE_TYPE);
			}

		}
		
			return;
}