Esempio n. 1
0
void CFlashAnimation::RepositionFlashAnimation()
{
	if(m_pFlashPlayer)
	{
		IRenderer *pRenderer = gEnv->pRenderer;

		float fMovieRatio		=	((float)m_pFlashPlayer->GetWidth()) / ((float)m_pFlashPlayer->GetHeight());
		float fRenderRatio	=	((float)pRenderer->GetWidth()) / ((float)pRenderer->GetHeight());

		float fWidth				=	pRenderer->GetWidth();
		float fHeight				=	pRenderer->GetHeight();
		float fXPos = 0.0f;
		float fYPos = 0.0f;

		float fXOffset			= (fWidth - (fMovieRatio * fHeight));

		if(fRenderRatio != fMovieRatio && !(m_dock & eFD_Stretch))
		{
			fWidth = fWidth-fXOffset;

			if (m_dock & eFD_Left)
				fXPos = 0;
			else if (m_dock & eFD_Right)
				fXPos = fXOffset;
			else if (m_dock & eFD_Center)
				fXPos = fXOffset * 0.5;
		}

		m_pFlashPlayer->SetViewport(int(fXPos),0,int(fWidth),int(fHeight));
	}
}
Esempio n. 2
0
void CFlashMenuScreen::UpdateRatio()
{
    if(IsLoaded())
    {
        IFlashPlayer* pFlashPlayer = GetFlashPlayer();
        IRenderer* pRenderer = gEnv->pRenderer;

        // Native width/height/ratio
        float fMovieWidth			= (float) pFlashPlayer->GetWidth();
        float fMovieHeight		= (float) pFlashPlayer->GetHeight();
        float fMovieRatio			=	fMovieWidth / fMovieHeight;

        // Current renderer width/height/ratio
        float fRendererWidth	=	(float) pRenderer->GetWidth();
        float fRendererHeight	=	(float) pRenderer->GetHeight();
        float fRendererRatio	=	fRendererWidth / fRendererHeight;

        // Compute viewport so that it fits
        float fViewportX			= 0.0f;
        float fViewportY			= 0.0f;
        float fViewportWidth	= 0.0f;
        float fViewportHeight	= 0.0f;

        /*
        	All the Flash files have been designed either in 4/3 or 16/9 aspect ratios in resolutions
        	such as 1024x768 or 1366x768. Problem is that minimum aspect ratio is NOT 4/3 but 5/4,
        	mainly because of LCD monitors. We need to rescale accordingly in screen resolutions like
        	1280x1024	so that we use the file in its 4/3 mode. Hence, there is wasted place in both
        	vertical and horizontal areas but this is the only way to fits right.
        */

        if(fRendererRatio >= 4.0f/3.0f)
        {
            fViewportHeight	= fRendererHeight;

            fViewportX = (fRendererWidth - (fRendererHeight * fMovieRatio)) * 0.5f;
            fViewportWidth = fRendererHeight * fMovieRatio;
        }
        else
        {
            fViewportX = (fRendererWidth - ((fRendererWidth * 3.0f / 4.0f) * fMovieRatio)) * 0.5f;
            fViewportY = (fRendererHeight - (fRendererWidth * 3.0f / 4.0f)) * 0.5f;

            fViewportWidth = (fRendererWidth * 3.0f / 4.0f) * fMovieRatio;
            fViewportHeight = fRendererWidth * 3.0f / 4.0f;
        }

        pFlashPlayer->SetViewport((int)fViewportX,(int)fViewportY,(int)fViewportWidth,(int)fViewportHeight);
    }
}
Esempio n. 3
0
void CBitmapUi::DrawFullscreenQuad( const int textureId ) const
{
	assert( m_pUiDraw != NULL );

	IRenderer* pRenderer = gEnv->pRenderer;
	assert( pRenderer != NULL );
	if ( pRenderer == NULL )
	{
		return;
	}

	float screenWidth = static_cast< float >( pRenderer->GetWidth() );
	float screenHeight = static_cast< float >( pRenderer->GetHeight() );
	
	m_pUiDraw->DrawQuadSimple( 0, 0, screenWidth, screenHeight, 0xFFFFFFFF, textureId );
}
Esempio n. 4
0
void Mouse::Update()
{	
	IRenderer* renderer = gEnv->pRenderer;
		
	int width = renderer->GetWidth();
	int height = renderer->GetHeight();

	// Get window rectangle and add some margins
	RECT rect;
	GetWindowRect((HWND)renderer->GetHWND(), &rect);
	rect.left += 10;
	rect.right -= 10;
	rect.top += 35;
	rect.bottom -= 10;

	// Absolute mouse position
	float mouseX, mouseY;
	gEnv->pHardwareMouse->GetHardwareMousePosition(&mouseX, &mouseY);
	
	if (mouseX <= rect.left)
	{			
		m_hPosition = LEFT;
	}
	else if (mouseX > rect.left && mouseX < rect.right)
	{			
		m_hPosition = HCENTER;
	}
	else if (mouseX >= rect.right)
	{	
		m_hPosition = RIGHT;
	}

	if (mouseY >= rect.bottom)
	{		
		m_vPosition = BOTTOM;
	}
	else if (mouseY > rect.top && mouseY < rect.bottom)
	{			
		m_vPosition = VCENTER;
	}
	else if (mouseY <= rect.top)
	{		
		m_vPosition = TOP;
	}
		
	m_clickFeedback.Update();
}
Esempio n. 5
0
EntityId Mouse::getEntityUnderCursor()
{
	IRenderer* pRenderer = gEnv->pRenderer;

	if(!gEnv->pHardwareMouse || !pRenderer || !gEnv->p3DEngine || !gEnv->pSystem || !gEnv->pEntitySystem || !g_pGame->GetIGameFramework())
		return false;

	IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();

	if (!pClientActor)
		return false;

	float mx, my, cx, cy, cz = 0.0f;

	mx = m_x;
	my = pRenderer->GetHeight() - m_y;

	pRenderer->UnProjectFromScreen(mx, my, 0.0f, &cx, &cy, &cz);

	IPhysicalEntity *pPhysicalEnt = pClientActor->GetEntity() ? pClientActor->GetEntity()->GetPhysics() : NULL;

	if(!pPhysicalEnt)
		return false;

	entity_query_flags queryFlags = ent_all; // see physicsnterface.h for details	
	static const unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
	float  fRange = gEnv->p3DEngine->GetMaxViewDistance();

	Vec3 vCamPos = gEnv->pSystem->GetViewCamera().GetPosition();
	Vec3 vDir = (Vec3(cx, cy, cz) - vCamPos).GetNormalizedSafe();

	static ray_hit hit;

	if (gEnv->pPhysicalWorld && gEnv->pPhysicalWorld->RayWorldIntersection(vCamPos, vDir * fRange, queryFlags, flags, &hit, 1, pPhysicalEnt))
	{
		CryLogAlways("Entity position: %f, %f, %f", hit.pt.x, hit.pt.y, hit.pt.z);
		if (IEntity* pEntity = gEnv->pEntitySystem->GetEntityFromPhysics(hit.pCollider))
		{						
			CryLogAlways("Entity name:", pEntity->GetName());
			return pEntity->GetId();
		}		
	}

	return 0;
}
Esempio n. 6
0
bool Mouse::getWorldCoords( float& x, float& y, float& z )
{
	IRenderer* pRenderer = gEnv->pRenderer;

	if(!gEnv->pHardwareMouse || !pRenderer || !gEnv->p3DEngine || !gEnv->pSystem || !gEnv->pEntitySystem || !g_pGame->GetIGameFramework())
		return false;

	IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();

	if (!pClientActor)
		return false;

	float mx, my, cx, cy, cz = 0.0f;

	mx = m_x - 4;
	my = pRenderer->GetHeight() - m_y + 10;

	pRenderer->UnProjectFromScreen(mx, my, 0.0f, &cx, &cy, &cz);
	
	IPhysicalEntity *pPhysicalEnt = pClientActor->GetEntity() ? pClientActor->GetEntity()->GetPhysics() : NULL;

	if(!pPhysicalEnt)
		return false;

	entity_query_flags queryFlags = ent_terrain; // see physicsnterface.h for details	
	static const unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
	float  fRange = gEnv->p3DEngine->GetMaxViewDistance();

	Vec3 vCamPos = gEnv->pSystem->GetViewCamera().GetPosition();
	Vec3 vDir = (Vec3(cx, cy, cz) - vCamPos).GetNormalizedSafe();

	static ray_hit hit;

	if (gEnv->pPhysicalWorld && gEnv->pPhysicalWorld->RayWorldIntersection(vCamPos, vDir * fRange, queryFlags, flags, &hit, 1, pPhysicalEnt))
	{
		x = hit.pt.x;
		y = hit.pt.y;
		z = hit.pt.z;

		return true;
	}

	return false;
}
Esempio n. 7
0
void CBitmapUi::DrawCenteredQuad( const int textureId, const float textureWidth, const float textureHeight ) const
{
	assert( m_pUiDraw != NULL );

	IRenderer* pRenderer = gEnv->pRenderer;
	assert( pRenderer != NULL );
	if ( pRenderer == NULL )
	{
		return;
	}

	float screenCentreX = pRenderer->GetWidth()	* 0.5f;
	float screenCentreY = pRenderer->GetHeight()* 0.5f;

	float offsetX = screenCentreX - textureWidth * 0.5f;
	float offsetY = screenCentreY - textureHeight * 0.5f;

	m_pUiDraw->DrawQuadSimple( offsetX, offsetY, textureWidth, textureHeight, 0xFFFFFFFF, textureId );
}
Esempio n. 8
0
//------------------------------------------------------------------------
void CDebugGun::Update( SEntityUpdateContext& ctx, int update)
{ 
  if (!IsSelected())
    return;
  
  static float drawColor[4] = {1,1,1,1};
  static const int dx = 5; 
  static const int dy = 15;
  static const float font = 1.2f;
  static const float fontLarge = 1.4f;

  IRenderer* pRenderer = gEnv->pRenderer;
  IRenderAuxGeom* pAuxGeom = pRenderer->GetIRenderAuxGeom();
  pAuxGeom->SetRenderFlags(e_Def3DPublicRenderflags);

  pRenderer->Draw2dLabel(pRenderer->GetWidth()/5.f, pRenderer->GetHeight()-35, fontLarge, drawColor, false, "Firemode: %s (%.1f)", m_fireModes[m_fireMode].first.c_str(), m_fireModes[m_fireMode].second);      

  ray_hit rayhit;
  int hits = 0;
  
  unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
  if (m_fireModes[m_fireMode].first == "pierceability")
  { 
    flags = (unsigned int)m_fireModes[m_fireMode].second & rwi_pierceability_mask;
  }
  
  // use cam, no need for firing pos/dir
  CCamera& cam = GetISystem()->GetViewCamera();

  if (hits = gEnv->pPhysicalWorld->RayWorldIntersection(cam.GetPosition()+cam.GetViewdir(), cam.GetViewdir()*HIT_RANGE, ent_all, flags, &rayhit, 1))
  {
    IMaterialManager* pMatMan = gEnv->p3DEngine->GetMaterialManager();
    IActorSystem* pActorSystem = g_pGame->GetIGameFramework()->GetIActorSystem();
    IVehicleSystem* pVehicleSystem = g_pGame->GetIGameFramework()->GetIVehicleSystem();
    
    int x = (int)(pRenderer->GetWidth() *0.5f) + dx;
    int y = (int)(pRenderer->GetHeight()*0.5f) + dx - dy;

    // draw normal
    ColorB colNormal(200,0,0,128);
    Vec3 end = rayhit.pt + 0.75f*rayhit.n;
    pAuxGeom->DrawLine(rayhit.pt, colNormal, end, colNormal);
    pAuxGeom->DrawCone(end, rayhit.n, 0.1f, 0.2f, colNormal);

    IEntity * pEntity = (IEntity*)rayhit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY);
    if(pEntity)
    {  
      pRenderer->Draw2dLabel(x, y+=dy, fontLarge, drawColor, false, pEntity->GetName());      
    }
    
    // material
    const char* matName = pMatMan->GetSurfaceType(rayhit.surface_idx)->GetName();

    if (matName[0])      
      pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%s (%i)", matName, rayhit.surface_idx);

    pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.1f m", rayhit.dist);

    if (pEntity)
    {
      IScriptTable* pScriptTable = pEntity->GetScriptTable();

      // physics 
      if (IPhysicalEntity* pPhysEnt = pEntity->GetPhysics())
      {
        pe_status_dynamics status;
        if (pPhysEnt->GetStatus(&status))
        {        
          if (status.mass > 0.f)
            pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.1f kg", status.mass);

          pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "pe_type: %i", pPhysEnt->GetType());                

          if (status.submergedFraction > 0.f)
            pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.2f submerged", status.submergedFraction);

          if (status.v.len2() > 0.0001f)
            pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.2f m/s", status.v.len());
        }   
      }  

      if (pScriptTable)
      {
        HSCRIPTFUNCTION func = 0;
        if (pScriptTable->GetValue("GetFrozenAmount", func) && func)
        {
          float frozen = 0.f;
          Script::CallReturn(gEnv->pScriptSystem, func, pScriptTable, frozen);
					gEnv->pScriptSystem->ReleaseFunc(func);
          
          if (frozen > 0.f)
            pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "Frozen: %.2f", frozen); 
        }
      }
     
      // class-specific stuff
      if (IActor* pActor = pActorSystem->GetActor(pEntity->GetId()))
      {
        pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%i health", pActor->GetHealth());
      }
      else if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(pEntity->GetId()))
      {
        const SVehicleStatus& status = pVehicle->GetStatus();
        
        pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.0f%% health", 100.f*status.health);
        pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%i passengers", status.passengerCount);
        
        if (pVehicle->GetMovement() && pVehicle->GetMovement()->IsPowered())
        {
          pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "Running");
        }
      }
      else
      {
        if (pScriptTable)
        {
          HSCRIPTFUNCTION func = 0;
          if (pScriptTable->GetValue("GetHealth", func) && func)
          {
            float health = 0.f;
            if (Script::CallReturn(gEnv->pScriptSystem, func, pScriptTable, health))
            {
              pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.0f health", health);
            }
						gEnv->pScriptSystem->ReleaseFunc(func);
          }
        }
      }
    }    
  }  
}
void CCodeCheckpointDebugMgr::DrawDebugInfo()
{
	int displayLevel = m_debug_ccoverage;
	
	IRenderer* pRenderer = gEnv->pRenderer;

	int totalHit = (int) std::count_if(m_unwatchedPoints.begin(), m_unwatchedPoints.end(), RecordHasHits);
	int watchedHit = (int) std::count_if(m_watchedPoints.begin(), m_watchedPoints.end(), RecordHasHits);

	totalHit += watchedHit;

	TCheckpointDebugVector outputPoints;
	outputPoints.reserve(m_watchedPoints.size() + m_unwatchedPoints.size());

	//Get the sorted output points. For now assume you want to sort based on time

	//Only show watched
	if(displayLevel == 1)
	{
		outputPoints.assign(m_watchedPoints.begin(), m_watchedPoints.end());
		std::sort(outputPoints.begin(), outputPoints.end(), SortDebugRecord);
	}
	//Only show unwatched
	else if(displayLevel == 2)
	{
		outputPoints.assign(m_unwatchedPoints.begin(), m_unwatchedPoints.end());
		std::sort(outputPoints.begin(), outputPoints.end(), SortDebugRecord);

	}
	//Show both with watched having priority
	else if(displayLevel == 3)
	{
		///Retrieve and sort watched
		TCheckpointDebugVector watchedPts;
		watchedPts.assign(m_watchedPoints.begin(), m_watchedPoints.end());
		std::sort(watchedPts.begin(), watchedPts.end(), SortDebugRecord);

		///Retrieve and sort unwatched
		TCheckpointDebugVector unwatchedPts;
		unwatchedPts.assign(m_unwatchedPoints.begin(), m_unwatchedPoints.end());
		std::sort(unwatchedPts.begin(), unwatchedPts.end(), SortDebugRecord);

		///Combined with watched first
		outputPoints.assign(watchedPts.begin(), watchedPts.end());
		outputPoints.insert(outputPoints.end(),unwatchedPts.begin(), unwatchedPts.end());
	}
	//Show both with equal priority
	else if(displayLevel == 4)
	{
		///Combine sort
		outputPoints.assign(m_unwatchedPoints.begin(), m_unwatchedPoints.end());
		outputPoints.insert(outputPoints.end(), m_watchedPoints.begin(), m_watchedPoints.end());
		std::sort(outputPoints.begin(), outputPoints.end(), SortDebugRecord);
	}

	float percHit = 0.0f;
	if(!m_watchedPoints.empty())
		percHit = (float) watchedHit / m_watchedPoints.size();

	static float statusColor[] = {1.0f, 1.0f, 1.0f, 1.0f};
	float height = (float) 0.05 * pRenderer->GetHeight();
	pRenderer->Draw2dLabel(30.f, height, 2.f, statusColor, false, 
		"THit: %i | TWatched: %" PRISIZE_T " | WatchedHit: %i | %% WatchedHit: %.2f", 
		totalHit, m_watchedPoints.size(), watchedHit, percHit * 100.0f );

	//Output the interesting lines
	float outputOffset = 0.08f;
	int numberOutput = 0;
	int maxNumberOutput =  m_debug_ccoverage_maxlines;
	for(TCheckpointDebugVector::iterator outputIt = outputPoints.begin(); 
		outputIt != outputPoints.end() && numberOutput < maxNumberOutput;
		++outputIt)
	{
		static float watchedColor[] = {1.0f, 0.0f, 1.0f, 1.0f};
		static float unwatchedColor[] = {0.0f, 0.0f, 1.0f, 1.0f};

		//Check filters and skip outputting of ones that don't qualify
		int filterMin = m_debug_ccoverage_filter_mincount, filterMax = m_debug_ccoverage_filter_maxcount;
		if(filterMax && (int)outputIt->m_currHitcount > filterMax)
			continue;
		else if(filterMin && (int)outputIt->m_currHitcount < filterMin)
			continue;

		pRenderer->Draw2dLabel(30.f, outputOffset * pRenderer->GetHeight(), 2.f, outputIt->m_queried? watchedColor : unwatchedColor, false, 
			"CheckPoint: %s Count:%i", outputIt->m_name.c_str(), outputIt->m_currHitcount);

		//Update the display output height
		outputOffset += 0.03f;
		 ++numberOutput;
	}

}