Exemple #1
0
  void CLasers::Render()
  {
    for (auto &l : lasers)
    {
      Abathur::TAbathurEntity *e = Abathur::GetEntity(l.mCollisionMesh);
      Abathur::TPhysXComponent *phyx_comp = e->QueryComponent<Abathur::TPhysXComponent>();
      if (phyx_comp->mEnabled) {
        unsigned color = 0xffffffff;
        if (l.mType == ELaserType::RED_LASER)
          color = COLOR_ARGB(0xff, 0xff, 0x0, 0x0);
        else if (l.mType == ELaserType::GREEN_LASER)
          color = COLOR_ARGB(0xff, 0x0, 0xff, 0x0);
        else if (l.mType == ELaserType::BLUE_LASER)
          color = COLOR_ARGB(0xff, 0x0, 0x0, 0xff);

        for (auto &r : l.mRays)
        {
          Abathur::TAbathurEntity *src = Abathur::GetEntity(r.mSource);
          Abathur::TLocationComponent *src_loc = src->QueryComponent<Abathur::TLocationComponent>();
          Abathur::TAbathurEntity *tgt = Abathur::GetEntity(r.mTarget);
          Abathur::TLocationComponent *tgt_loc = tgt->QueryComponent<Abathur::TLocationComponent>();
          Vector3 src_pos = src_loc->mtx.GetTranslation();
          Vector3 tgt_pos = tgt_loc->mtx.GetTranslation();
          Abathur::drawLine(src_pos, tgt_pos, color);
        }
      }
    }
  }
CDebugView::CDebugView ( CGUI * pManager, CVector2D & vecPosition ) : CChat ()
{
    CChat * pChat = g_pChat;
    g_pChat = this;

    m_pManager = pManager;    

    CVector2D vecResolution = m_pManager->GetResolution ();
    m_vecScale = CVector2D ( vecResolution.fX / 800.0f, vecResolution.fY / 600.0f );
    vecPosition = vecPosition * vecResolution;
    m_vecBackgroundPosition = vecPosition;

    m_bUseCEGUI = false;
    m_ulChatLineLife = 0;
    m_ulChatLineFadeOut = 0;
    m_bCssStyleText = false;
    m_bCssStyleBackground = false;
    m_bVisible = false;
    m_bInputVisible = false;
    m_uiNumLines = 7;
    m_uiMostRecentLine = 0;
    m_uiScrollOffset = 0;
    m_fSmoothScroll = 0;
    m_fSmoothLastTimeSeconds = 0;
    m_fSmoothAllowAfter = 0;
    m_fSmoothScrollResetTime = 0;
    m_fSmoothRepeatTimer = 0;
    m_pFont = m_pManager->GetBoldFont ();
    m_pDXFont = g_pCore->GetGraphics ()->GetFont ();
    m_fNativeWidth = DEBUGVIEW_WIDTH;
    m_bCanChangeWidth = false;
    m_iScrollingBack = 0;
    m_fCssStyleOverrideAlpha = 0.0f;
    m_fBackgroundAlpha = 0.0f;
    m_fInputBackgroundAlpha = 0.f;
    m_Color = CColor ( 0, 0, 0, 100 );
    m_TextColor = DEBUGVIEW_TEXT_COLOR;
    unsigned long ulBackgroundColor = COLOR_ARGB ( m_Color.A, m_Color.R, m_Color.G, m_Color.B );

    m_pBackground = m_pManager->CreateStaticImage ();
    m_pBackgroundTexture = m_pManager->CreateTexture ();

    m_pBackgroundTexture->LoadFromMemory ( &ulBackgroundColor, 1, 1 );
    m_pBackground->LoadFromTexture ( m_pBackgroundTexture );
    m_pBackground->MoveToBack ();
    m_pBackground->SetPosition ( m_vecBackgroundPosition );
    m_pBackground->SetSize ( m_vecBackgroundSize );
    m_pBackground->SetEnabled ( false );
    m_pBackground->SetVisible ( false );

    m_pInput = NULL;
    m_pInputTexture = NULL;

    g_pChat = pChat;

    UpdateGUI ();
}
Exemple #3
0
unsigned int Gl_Color_2_Xe (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{
	return COLOR_ARGB
	(
		BYTE_CLAMP(alpha),
		BYTE_CLAMP(red),
		BYTE_CLAMP(green),
		BYTE_CLAMP(blue)
	);
}
Exemple #4
0
/**
 * mode / type
 **/ 
void glDrawElements(GLenum mode, GLsizei numIndexes, GLenum type, const GLvoid * indices)
{
	int i = 0;
	
	union {
		float f;
		unsigned int u32;
	} color;
	
	// Begin
	xe_PrevNumVerts = xe_NumVerts;
	xe_PrevNumIndices = xe_NumIndices;
	
	unsigned int * indexes = (unsigned int*)indices;
	void * vertice_ptr = vertexPointer.pointer;
	void * color_ptr = colorPointer.pointer;
	void * texcoords0_ptr = texCoordPointer[0].pointer;
	void * texcoords1_ptr = texCoordPointer[1].pointer;
	
	// vertices
	for (i = 0 ; i < vertexPointer.count ; i++) {
		float * v = (float*) vertice_ptr;
		float * t0 = (float*) texcoords0_ptr;
		float * t1 = (float*) texcoords1_ptr;
		unsigned char * c = (unsigned char*) color_ptr;
		color.u32 = COLOR_ARGB(c[3], c[2], c[1], c[0]);
		//color.u32 = 0xFFFFFFFF;
		
		*xe_Vertices++ = v[0];
		*xe_Vertices++ = v[1];
		*xe_Vertices++ = v[2];
		*xe_Vertices++ = 1;
		
		if (texcoords0_ptr) {
			*xe_Vertices++ = t0[0];
			*xe_Vertices++ = t0[1];
		} else {
			*xe_Vertices++ = 0;
			*xe_Vertices++ = 0;
		}
		
		if (texcoords1_ptr) {
			*xe_Vertices++ = t1[0];
			*xe_Vertices++ = t1[1];
		} else {
			*xe_Vertices++ = 0;
			*xe_Vertices++ = 0;
		}
		
		*xe_Vertices++ = color.f;		
		
		vertice_ptr += vertexPointer.stride;
		if (texcoords0_ptr) {
			texcoords0_ptr += 2 * sizeof(float);
		}
		if (texcoords1_ptr) {
			texcoords1_ptr += 2 * sizeof(float);
		}
		color_ptr += 4 * sizeof(char);
				
		xe_NumVerts++;
	}
	
	// indices
	for (i = 0 ; i < numIndexes ; i++) {
		*xe_indices++ = indexes[i] + xe_PrevNumVerts;
		xe_NumIndices++;
	}
	
	
	XeUpdateStates();
	XeGlCheckDirtyMatrix(&projection_matrix);
	XeGlCheckDirtyMatrix(&modelview_matrix);
	
	// setup shaders and textures
	Xe_SetShader(xe, SHADER_TYPE_VERTEX, pVertexShader, 0);
	GL_SelectShaders();
	GL_SelectTextures();
	
	Xe_SetIndices(xe, pIbGL);
	Xe_SetStreamSource(xe, 0, pVbGL, 0, 10);
		
	Xe_DrawIndexedPrimitive(
		xe, 
		XE_PRIMTYPE_TRIANGLELIST, 
		0, 0,
		vertexPointer.count, 
		xe_PrevNumIndices, 
		numIndexes/3
	);
}
Exemple #5
0
//--------------------------------------------------------------------
// Función:    CParticles::Update
// Creador:    Nacho (AMD)
// Fecha:      Wednesday  14/02/2007  19:48:41
//--------------------------------------------------------------------
void CParticles::Update(float dt, CLevel* pTheLevel, CSound* pSoundPlayer)
{	
	CVideo * pVideo = CVideo::GetSingleton();

	m_fAngType3 += (240.0f * dt);
	m_fAngType3 = MAT_NormalizarAngulo360(m_fAngType3);

	CBall* pBall = pTheLevel->GetBall();
	CSmoke* pSmoke = pTheLevel->GetSmoke();

	VECTOR3 vecBallPos = pBall->GetPosition();
	VECTOR2 vecBallVel = pBall->GetVelocity();
	float fBallRadius = pBall->GetRadius();

	sceGuEnable(GU_BLEND);
	sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
	sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);

	ENEMY* pEnemies = pTheLevel->GetEnemies();
	int iNumEnemies = pTheLevel->GetNumEnemies();
	
	///--- TIPO 0: Disparo amarillo
	//////////////////////////////////////////////////////////////////////

	pVideo->EnableTexture(m_pTexture[0]);

	for (int i=0; i<MAX_PARTICLES; i++)
	{
		if (m_pParticleArray[0][i].enable)
		{			
			m_pParticleArray[0][i].timeStamp += dt;

			if (m_pParticleArray[0][i].timeStamp >= 5.0f)
			{
				m_pParticleArray[0][i].enable = false;
				m_pParticleArray[0][i].next = m_iFreeSlot[0];
				m_iFreeSlot[0] = i;

				continue;
			}

			m_pParticleArray[0][i].pos.x += m_pParticleArray[0][i].vel.x * dt;
			m_pParticleArray[0][i].pos.y += m_pParticleArray[0][i].vel.y * dt;


			stCollisionData data;

			data.radius = 1.0f;
			data.x = m_pParticleArray[0][i].pos.x;
			data.y = m_pParticleArray[0][i].pos.y;
			data.velX = m_pParticleArray[0][i].vel.x;
			data.velY = m_pParticleArray[0][i].vel.y;

			if (pTheLevel->TestCollision(&data, false))
			{		
				m_pParticleArray[0][i].pos.x = data.x;
				m_pParticleArray[0][i].pos.y = data.y;
				m_pParticleArray[0][i].vel.x = data.velX;
				m_pParticleArray[0][i].vel.y = data.velY;
			}

			for (int a=0; a<iNumEnemies; a++)
			{
				if (pEnemies[a].active)
				{					
					///--- sierra
					///--- rebota
					if ((pEnemies[a].type == 0) || (pEnemies[a].type == 3))
					{
						VECTOR3 vDis;
						VECTOR3 vTemp = {m_pParticleArray[0][i].pos.x, m_pParticleArray[0][i].pos.y, 4.0f};
						VECTOR3 vTemp2 = {pEnemies[a].posX + 4.0f, pEnemies[a].posY + 4.0f, 4.0f};

						MAT_VectorSubtract(&vDis, &vTemp2, &vTemp);

						float length = MAT_VectorQuadraticLength(&vDis);

						if (length < 6.25f)
						{
							m_pParticleArray[0][i].enable = false;
							m_pParticleArray[0][i].next = m_iFreeSlot[0];
							m_iFreeSlot[0] = i;

							pSmoke->AddExplosion(vTemp2, 20.0f, true);

							pEnemies[a].active = false;

							pSoundPlayer->Play(SOUND_ENE_EXPLO);

							break;
						}
					}
					///--- dirigidos
					///--- rectos
					else if ((pEnemies[a].type == 1) || (pEnemies[a].type == 2))
					{	
						VECTOR3 vTemp = {0};

						if (pEnemies[a].rot==0)
						{
							vTemp.x = pEnemies[a].posX+2.0f;
							vTemp.y = pEnemies[a].posY+4.0f;
						}						
						else if (pEnemies[a].rot==3)
						{
							vTemp.x = pEnemies[a].posX+4.0f;
							vTemp.y = pEnemies[a].posY+2.0f;
						}
						else if (pEnemies[a].rot==2)
						{
							vTemp.x = pEnemies[a].posX+6.0f;
							vTemp.y = pEnemies[a].posY+4.0f;
						}
						else if (pEnemies[a].rot==1)
						{
							vTemp.x = pEnemies[a].posX+4.0f;
							vTemp.y = pEnemies[a].posY+6.0f;						
						}	

						vTemp.z = 4.0f;

						VECTOR3 vDis;
						VECTOR3 vTemp2 = {m_pParticleArray[0][i].pos.x, m_pParticleArray[0][i].pos.y, 4.0f};
						
						MAT_VectorSubtract(&vDis, &vTemp, &vTemp2);

						float disx = vecBallPos.x - m_pParticleArray[0][i].pos.x,;

						float length = MAT_VectorQuadraticLength(&vDis);

						if (length < 6.0f)
						{
							m_pParticleArray[0][i].enable = false;
							m_pParticleArray[0][i].next = m_iFreeSlot[0];
							m_iFreeSlot[0] = i;

							pSmoke->AddExplosion(vTemp, 20.0f, true);

							pEnemies[a].active = false;

							pSoundPlayer->Play(SOUND_ENE_EXPLO);

							int pan = 127;

							if (disx < 0.0f)
							{
								if (disx < -32.0f)
								{
									pan = 255;
								}
								else
								{
									pan = MAT_Clamp(128 + (int)(((-disx) / 32.0f) * 127.0f), 128, 255);									
								}
							}
							else

							{
								if (disx > 32.0f)
								{
									pan = 0;
								}
								else
								{ 
									pan = MAT_Clamp((int)(127.0f - ((disx / 32.0f) * 127.0f)), 0, 127);
								}
							}

							pSoundPlayer->Play(SOUND_ENE_EXPLO, pan);

							break;
						}						
					}				
				}
			}

			if (!m_pParticleArray[0][i].enable)
				continue;

			///--- render

			sceGumMatrixMode(GU_MODEL);
			sceGumLoadIdentity();
			{
				VECTOR3 pos =  { m_pParticleArray[0][i].pos.x -1.0f,
					-(m_pParticleArray[0][i].pos.y + 1.0f), 4.0f };
				VECTOR3 scale = { 2.0f, 2.0f, 2.0f };
				sceGumTranslate(&pos);
				sceGumScale(&scale);			
			}			

			if (m_pParticleArray[0][i].timeStamp >= 4.0f)
			{
				int alpha = (int)MAT_Clampf((5.0f - m_pParticleArray[0][i].timeStamp) * 255.0f, 0.0f, 255.0f);

				sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);

				sceGuAmbientColor(COLOR_ARGB(alpha, 255, 255, 255));

				m_pQuad->Render();

				sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, COLOR_ARGB(alpha, alpha, alpha, alpha), 0xffffffff);

				m_pQuad->Render();

				sceGuAmbientColor(0xffffffff);
			}
			else
			{
				sceGuAmbientColor(0xffffffff);

				m_pQuad->Render();

				sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xffffffff, 0xffffffff);

				m_pQuad->Render();
			}

			sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);			
		}