Exemple #1
0
CEntityClient* CEntityClient::GetSelectedEntity(CCoreSceneClient* pCoreScene)
{
	if (!CClientRenderScene::HasInst())
	{
		return NULL;
	}

	CRenderScene* pRenderScene = CClientRenderScene::GetInst();
	CRenderObject* pRenderObj = pRenderScene->GetSelectedObj();

	if(!pRenderObj||!pRenderObj->GetModelHandler())
		return NULL;

	CIntObjClientAdapter* pIntObjAdapter = dynamic_cast<CIntObjClientAdapter*>(pRenderObj->GetModelHandler());
	if (pIntObjAdapter)
	{
		return pIntObjAdapter->GetEntity();
	}
	CCharacterDirectorAdapter* pCharacterDirectorAdapter = dynamic_cast<CCharacterDirectorAdapter*>(pRenderObj->GetModelHandler());
	if (pCharacterDirectorAdapter)
	{
		return pCharacterDirectorAdapter->GetEntity();
}
	CCharacterFollowerAdapter* pCharacterFollowerAdapter = dynamic_cast<CCharacterFollowerAdapter*>(pRenderObj->GetModelHandler());
	if (pCharacterFollowerAdapter)
	{
		return pCharacterFollowerAdapter->GetEntity();
	}

		return NULL;
}
Exemple #2
0
// Creates the requested Render Object and returns to the Engine...
CRenderObject* CD3D_Device::CreateRenderObject(CRenderObject::RENDER_OBJECT_TYPES ObjectType) 
{
	CRenderObject* pNewObject = NULL;			// Create the Sucka...
	switch (ObjectType) 
	{
//	case CRenderObject::eDebugLine :
//		pNewObject = new CDIDebugLine(); break;
//	case CRenderObject::eDebugPolygon :
//		pNewObject = new CDIDebugPolygon(); break;
//	case CRenderObject::eDebugText :
//		pNewObject = new CDIDebugText(); break;
	case CRenderObject::eRigidMesh :
		pNewObject = new CD3DRigidMesh(); break;
	case CRenderObject::eSkelMesh :
		pNewObject = new CD3DSkelMesh(); break;
//	case CRenderObject::eVAMesh :
//		pNewObject = new CD3DVAMesh(); break;
//	case CRenderObject::eABCPieceLOD :
//		pNewObject = new ABCPieceLOD(); break;
	default : return NULL; 
	} //assert(0);  }

	if (pNewObject) 
	{							// Add it to the Render Object List...
		pNewObject->SetNext(g_Device.m_pRenderObjectList_Head); 
		g_Device.m_pRenderObjectList_Head = pNewObject; 
	}

	return pNewObject;
}
int CRenderWorld::AddSixEdgeRenderObject(std::string& imageName)
{
	m_iCurRenderObjectIndex++;
	CRenderObject* p = new CSixEdgeRenderObject;
	p->CreateVAO(m_pGLProgram[eST_Pawn]);
	p->CreateTexture(imageName);
	pair<int, CRenderObject*> new_RO(m_iCurRenderObjectIndex, p);
	m_mapRenderObject[eST_Pawn].insert(new_RO);
	return m_iCurRenderObjectIndex;
}
Exemple #4
0
// Release all the device objects (the Render Objects)...
bool CD3D_Device::ReleaseDevObjects()
{
	// Notify all RenderObjects that we're going to free the device (to give up all there device stuff)
	CRenderObject* pRenderObject = m_pRenderObjectList_Head;
	while (pRenderObject) { 
		pRenderObject->FreeDeviceObjects(); 
		pRenderObject = pRenderObject->GetNext(); }

	return true; 
}
Exemple #5
0
// If device we lost, restores the objects (calls ReCreateObject on all the Render Objects)...
bool CD3D_Device::RestoreDevObjects()
{
	// Notify all RenderObjects that they need to re-create themselves...
	CRenderObject* pRenderObject = m_pRenderObjectList_Head;
	while (pRenderObject) { 
		pRenderObject->ReCreateObject(); 
		pRenderObject = pRenderObject->GetNext(); }

	return true;
}
void CRenderQue::DrawQue()
{
	CRenderObject* temp = m_Parent;
	while(temp)
	{
		temp->Draw();
		temp = temp->m_Next;
	}

	ClearQue();
}
void CRenderWorld::Draw(EShaderType eST)
{
	map<int, CRenderObject*>::iterator itor;
	CRenderObject* cur = 0;
	for (itor = m_mapRenderObject[eST].begin(); itor != m_mapRenderObject[eST].end(); itor++)
	{
		cur = (itor)->second;
		if (cur)
		{
			cur->Draw();
		}
	}
}
Exemple #8
0
void CSoundPlayer::Play3DSoundByName(CCharacterFollower* pAttacker, string strSoundName)
{
	if (strSoundName.empty())
		return;

	CRenderObject* pRenderObject = pAttacker->GetRenderObject();
	if (NULL == pRenderObject)
		return;
	CVector3f pos = pRenderObject->GetCenterPosition();
	const static CVector3f nullVel;

	Play3DCue(strSoundName.c_str(), pos, nullVel);
}
Exemple #9
0
//------------------------------------------------------------------------------
void
CSoundPlayer::PlayFootstep(CCharacterFollower* pCharacter, string strCueNameTail)
{
	if (NULL == pCharacter)
		return;

	CRenderObject* pRenderObject = pCharacter->GetRenderObject();
	if (NULL == pRenderObject)
		return;

	string strCueName(""), strName("");

	if (pCharacter->CppGetCtrlState(eFCS_InNormalHorse) || pCharacter->CppGetCtrlState(eFCS_InBattleHorse))
	{
		strName = pCharacter->GetHorseName();
	}
	else
	{
		strName = GetNameByCharacter(pCharacter);
		if (strName.empty())
			return;
		
		if (!strCueNameTail.empty())
			strCueNameTail = "";
	}
	CSoundConfig* pSoundCfg = CSoundConfig::GetSoundCfg(strName);
	if (!pSoundCfg)
		return;
	strCueName = pSoundCfg->GetFootstepSound();
	if (strCueName.empty())
		return;

	int32 uMeterialID = pCharacter->GetHorseRenderObj()->GetTerrainMaterialIndex();
	string strMeterial = CSoundConfig::GetMeterialString(uMeterialID);

	if (strMeterial.empty())
		return;
	strCueName = strMeterial + "_" + strCueName;

	if (strCueNameTail != "")
		strCueName = strCueName + strCueNameTail;

	CVector3f pos = pRenderObject->GetCenterPosition();
	const static CVector3f nullVel;

	Play3DCue(strCueName.c_str(), pos, nullVel);
}
Exemple #10
0
// If device we lost, restores the objects (calls ReCreateObject on all the Render Objects)...
bool CD3D_Device::RestoreDevObjects()
{
	LTVertexShaderMgr::GetSingleton().RecreateVertexShaders();
	LTPixelShaderMgr::GetSingleton().RecreatePixelShaders();
	LTEffectShaderMgr::GetSingleton().RecreateEffectShaders();
	CRenderTargetMgr::GetSingleton().RecreateRenderTargets();

	// Notify all RenderObjects that they need to re-create themselves...
	CRenderObject* pRenderObject = m_pRenderObjectList_Head;
	while (pRenderObject)
	{
		pRenderObject->ReCreateObject();
		pRenderObject = pRenderObject->GetNext();
	}

	return true;
}
Exemple #11
0
// Release all the device objects (the Render Objects)...
bool CD3D_Device::ReleaseDevObjects(bool bFullRelease)
{
	//free the screen glow's resources
	CScreenGlowMgr::GetSingleton().FreeDeviceObjects();

	// free the vertex shaders
	LTVertexShaderMgr::GetSingleton().FreeDeviceObjects();

	// Free the pixel shaders.
	LTPixelShaderMgr::GetSingleton().FreeDeviceObjects();

	// Free the effect shaders.
	LTEffectShaderMgr::GetSingleton().FreeDeviceObjects();

	// Free the rendertarget textures and surfaces
	CRenderTargetMgr::GetSingleton().FreeDeviceObjects();

	// Notify all RenderObjects that we're going to free the device (to give up all there device stuff)
	CRenderObject* pRenderObject = m_pRenderObjectList_Head;
	while (pRenderObject)
	{
		pRenderObject->FreeDeviceObjects();
		pRenderObject = pRenderObject->GetNext();
	}

	if (m_pRenderWorld)
		m_pRenderWorld->Release();

	if( m_pEndOfFrameQuery )
	{
		m_pEndOfFrameQuery->Release();
		m_pEndOfFrameQuery = NULL;
	}

	FreeFrameTextures();

	// Don't actually delete them unless we really want to
	if (bFullRelease)
	{
		delete m_pRenderWorld;
		m_pRenderWorld = 0;
	}

	return true;
}
Exemple #12
0
// Creates the requested Render Object and returns to the Engine...
CRenderObject* CD3D_Device::CreateRenderObject(CRenderObject::RENDER_OBJECT_TYPES ObjectType)
{
	CRenderObject* pNewObject = NULL;			// Create the Sucka...
	switch (ObjectType)
	{
	case CRenderObject::eDebugLine :
		LT_MEM_TRACK_ALLOC(pNewObject = new CDIDebugLine(),LT_MEM_TYPE_RENDERER);
		break;
	case CRenderObject::eDebugPolygon :
		LT_MEM_TRACK_ALLOC(pNewObject = new CDIDebugPolygon(),LT_MEM_TYPE_RENDERER);
		break;
	case CRenderObject::eDebugText :
		LT_MEM_TRACK_ALLOC(pNewObject = new CDIDebugText(),LT_MEM_TYPE_RENDERER);
		break;
	case CRenderObject::eRigidMesh :
		LT_MEM_TRACK_ALLOC(pNewObject = new CD3DRigidMesh(),LT_MEM_TYPE_RENDERER);
		break;
	case CRenderObject::eSkelMesh :
		LT_MEM_TRACK_ALLOC(pNewObject = new CD3DSkelMesh(),LT_MEM_TYPE_RENDERER);
		break;
	case CRenderObject::eVAMesh :
		LT_MEM_TRACK_ALLOC(pNewObject = new CD3DVAMesh(),LT_MEM_TYPE_RENDERER);
		break;
	case CRenderObject::eNullMesh :
		LT_MEM_TRACK_ALLOC(pNewObject = new CDIModelDrawable,LT_MEM_TYPE_RENDERER);
		break;
	default :
		return NULL; break;
	}

	if (pNewObject)
	{
		// Add it to the Render Object List...
		pNewObject->SetNext(g_Device.m_pRenderObjectList_Head);
		g_Device.m_pRenderObjectList_Head = pNewObject;
	}
	return pNewObject;
}
Exemple #13
0
bool CD3D_Device::DestroyRenderObject(CRenderObject* pObject)
{
	if (pObject == g_Device.m_pRenderObjectList_Head) {	// Remove the sucka from the Render Object List...
		g_Device.m_pRenderObjectList_Head = pObject->GetNext(); }
	else {
		CRenderObject* pPrevObject = g_Device.m_pRenderObjectList_Head;
		while (pPrevObject->GetNext() && pPrevObject->GetNext() != pObject) {
			pPrevObject = pPrevObject->GetNext(); }
		if (pPrevObject->GetNext()) {
			pPrevObject->SetNext(pPrevObject->GetNext()->GetNext()); }
		else { assert(0); return false; } }		// It's not in the list!?!

	delete pObject;								// Ok, now delete the sucka...

	return true; 
}
Exemple #14
0
// Renders debug stuff
void CDebugGeometry::render()
{
	if (!mVisible) return;
	
	for (LineList::iterator it = mLines.begin();it != mLines.end();++it) {
		CRenderObject* pLine = (*it);
		pLine->Render(); }							// Draw the Lines...

	for (PolygonList::iterator ip = mPolygons.begin();ip != mPolygons.end();++ip) {
		CRenderObject* pPoly = (*ip);
		pPoly->Render(); }							// Draw the Poly List...

	for (TextList::iterator iz = mText.begin();iz != mText.end();++iz) {
		CRenderObject* pText = (*iz);
		pText->Render(); }							// Draw the Text List...
}
Exemple #15
0
bool CD3D_Device::DestroyRenderObject(CRenderObject* pObject)
{
	if (pObject == g_Device.m_pRenderObjectList_Head)
	{
		// Remove the sucka from the Render Object List...
		g_Device.m_pRenderObjectList_Head = pObject->GetNext();
	}
	else
	{
		if (!g_Device.m_pRenderObjectList_Head)
		{
			// It's not in the list!?!
			//assert(0); // Note : This really should assert, but this happens VERY frequently and doesn't seem to be causing any problems
			return false;
		}
		CRenderObject* pPrevObject = g_Device.m_pRenderObjectList_Head;
		while (pPrevObject->GetNext() && pPrevObject->GetNext() != pObject)
		{
			pPrevObject = pPrevObject->GetNext();
		}
		if (pPrevObject->GetNext())
		{
			pPrevObject->SetNext(pPrevObject->GetNext()->GetNext());
		}
		else
		{
			// It's not in the list!?!
			assert(0);
			return false;
		}
	}

	delete pObject;								// Ok, now delete the sucka...

	return true;
}
void  Render()
{
   Matrix mat,mat1,mat2;
   Bulid_XYZ_RotationMatrix(mat1,0.0,0.0,g_roty);
   BuildTranslateMatrix(mat2,0.0,0.0,g_tranz);
   static bool bDrawNonTextureCube=false;
   if(KEY_DOWN(VK_F1))
   {
	   //Draw the color cube. don't use texture
	   bDrawNonTextureCube = !bDrawNonTextureCube;
   }
 
   int icount = g_RenderManager.RenderObjectSize();
   for(int i = 0; i < icount;++i)
   {
       CRenderObject *pobj = g_RenderManager[i];
	   POLYGONLIST &polygonlist = pobj->m_PolyGonList;
	   int polygonsize = polygonlist.size();
	   for( int j = 0; j < polygonsize;++j)
	   {
		   POLYGON &polygon = polygonlist[j];
		   if(bDrawNonTextureCube)
			   polygon.state &= ~OBJECT_HAS_TEXTURE;
		   else 
			   polygon.state |= OBJECT_HAS_TEXTURE;
	   }
	  
	   pobj->Transform(mat1);//transform local
	   pobj->world_pos *= mat2;
	  
   }
   //local->world,world->camera,camera->screen
   static bool bEnableLighting = false;
   static bool bEableBackfaceRemove =false;
   static bool bEnableInvZBuffer = false;
   if(KEY_DOWN(VK_HOME))
   {
	   //user press p
	   for(int i=0; i< g_lights.GetLightsCount();++i)
	   {
		   CLight* pLight = g_lights.GetLight(i);
		    pLight->EnableLight();
		 /*  if(pLight->GetLightType() == CLight::kAmbientLight)
		   {
			   pLight->EnableLight();
			   break;
		   }*/
	   }
	   bEnableLighting = true;
	   
   }
   else if(KEY_DOWN(VK_END))
   {
	   bEnableLighting = false;
   }
   else if(KEY_DOWN(VK_F2))
   {
	   bEableBackfaceRemove = true;
   }
   else if(KEY_DOWN(VK_F3))
   {
	   bEableBackfaceRemove = false;
   }
   else if(KEY_DOWN(VK_F4))
   {
	   bEnableInvZBuffer = true;
   }
   else if(KEY_DOWN(VK_F5))
   {
	   bEnableInvZBuffer = false;
   }
   if(bEnableInvZBuffer)
    ZBuffer::GetInstance()->Clear(0);
   else
    ZBuffer::GetInstance()->Clear((1<<30)-1);

   g_RenderManager.Render(bEnableLighting,bEableBackfaceRemove,!bEnableInvZBuffer);
   g_fps++;
}