示例#1
0
bool CLightningFX::Render()
{
	if(!CBaseFX::Render())
		return false;
	
	// Render the bolts...

	uint32 nTris = 0;
	uint32 nVerts = 0;

	LT_POLYGT3 *pTri = g_pTris;
	LTVector *pVerts = g_pVerts;


	ILTDrawPrim *pDrawPrimLT;
	pDrawPrimLT = m_pLTClient->GetDrawPrim();

	if(!pDrawPrimLT)
		return false;

	// Draw the polylist
	pDrawPrimLT->SetTexture( m_hTexture );
	pDrawPrimLT->SetReallyClose( m_bReallyClose );
	pDrawPrimLT->SetCamera( m_hCamera );
	pDrawPrimLT->SetTransformType( DRAWPRIM_TRANSFORM_CAMERA );
	pDrawPrimLT->SetZBufferMode( DRAWPRIM_ZRO );
	pDrawPrimLT->SetFillMode( GetProps()->m_eFillMode );
	pDrawPrimLT->SetAlphaTestMode( GetProps()->m_eAlphaTest );
	pDrawPrimLT->SetAlphaBlendMode( GetProps()->m_eBlendMode );
	pDrawPrimLT->SetColorOp( GetProps()->m_eColorOp );

	pDrawPrimLT->BeginDrawPrim();

	CLinkListNode<PT_TRAIL_SECTION> *pNode = LTNULL;
	CLightningBolt *pBolt = LTNULL;
	LightningBolts::iterator iter;
	
	for( iter = m_lstBolts.begin(); iter != m_lstBolts.end(); ++iter )
	{
		pBolt = *iter;

		if( !pBolt->m_bActive )
			continue;

		pNode = pBolt->m_collPathPts.GetHead();
	
		while (pNode->m_pNext)
		{
			LTVector vStart = pNode->m_Data.m_vTran;
			LTVector vEnd   = pNode->m_pNext->m_Data.m_vTran;
		
			LTVector vBisector1 = pNode->m_Data.m_vBisector;
			LTVector vBisector2 = pNode->m_pNext->m_Data.m_vBisector;

			*pVerts ++ = vStart + vBisector1;
			*pVerts ++ = vEnd + vBisector2;
			*pVerts ++ = vEnd - vBisector2;
			*pVerts ++ = vStart - vBisector1;

			uint8 r1 = pNode->m_Data.m_red;
			uint8 g1 = pNode->m_Data.m_green;
			uint8 b1 = pNode->m_Data.m_blue;
			uint8 a1 = pNode->m_Data.m_alpha;
			
			uint8 r2 = pNode->m_pNext->m_Data.m_red;
			uint8 g2 = pNode->m_pNext->m_Data.m_green;
			uint8 b2 = pNode->m_pNext->m_Data.m_blue;
			uint8 a2 = pNode->m_pNext->m_Data.m_alpha;
			

			SetupVert(pTri, 0, g_pVerts[nVerts], r1, g1, b1, a1, 0.0f, 0.0f);
			SetupVert(pTri, 1, g_pVerts[nVerts + 1], r2, g2, b2, a2, 1.0f, 0.0f);
			SetupVert(pTri, 2, g_pVerts[nVerts + 2], r2, g2, b2, a2, 1.0f, 1.0f);

			pTri ++;
			nTris ++;

			SetupVert(pTri, 0, g_pVerts[nVerts], r1, g1, b1, a1, 0.0f, 0.0f);
			SetupVert(pTri, 1, g_pVerts[nVerts + 2], r2, g2, b2, a2, 1.0f, 1.0f);
			SetupVert(pTri, 2, g_pVerts[nVerts + 3], r1, g1, b1, a1, 0.0f, 1.0f);

			pTri ++;
			nTris ++;

			nVerts += 4;

			pNode = pNode->m_pNext;

			//see if we need to flush our buffer
			if(nTris >= MAX_BUFFER_TRIS - 2)
			{
				pDrawPrimLT->DrawPrim(g_pTris, nTris);
				nTris = 0;
				nVerts = 0;
				pTri = g_pTris;
				pVerts = g_pVerts;
			}
		}
	}

	if(nTris > 0)
	{
		pDrawPrimLT->DrawPrim(g_pTris, nTris);
	}

	pDrawPrimLT->EndDrawPrim();

	return true;
}
示例#2
0
bool CPolyTubeFX::Render()
{
	if(!CBaseFX::Render())
		return false;

	CLinkListNode<PT_TRAIL_SECTION> *pNode = m_collPathPts.GetHead();

	//make sure that we have at least one node
	if(!pNode)
		return true;

	ILTDrawPrim *pDrawPrimLT;
	pDrawPrimLT = m_pLTClient->GetDrawPrim();

	// Draw the polylist
	if( !pDrawPrimLT )
		return false;

	pDrawPrimLT->SetTexture( m_hTexture );
	pDrawPrimLT->SetReallyClose( m_bReallyClose );
	pDrawPrimLT->SetCamera( m_hCamera );
	pDrawPrimLT->SetTransformType( (GetProps()->m_eAllignment == ePTA_Camera ? DRAWPRIM_TRANSFORM_CAMERA : DRAWPRIM_TRANSFORM_WORLD) );
	pDrawPrimLT->SetZBufferMode( DRAWPRIM_ZRO );
	pDrawPrimLT->SetFillMode( GetProps()->m_eFillMode );
	pDrawPrimLT->SetAlphaTestMode( GetProps()->m_eAlphaTest );
	pDrawPrimLT->SetAlphaBlendMode( GetProps()->m_eBlendMode );
	pDrawPrimLT->SetColorOp( GetProps()->m_eColorOp );

	uint32 nTris = 0;
	uint32 nVerts = 0;

	LT_POLYGT3 *pTri = g_pTris;
	LTVector *pVerts = g_pVerts;

	pDrawPrimLT->BeginDrawPrim();

	while (pNode->m_pNext)
	{
		LTVector vStart = pNode->m_Data.m_vTran;
		LTVector vEnd   = pNode->m_pNext->m_Data.m_vTran;
	
		LTVector vBisector1 = pNode->m_Data.m_vBisector;
		LTVector vBisector2 = pNode->m_pNext->m_Data.m_vBisector;

		*pVerts ++ = vStart + vBisector1;
		*pVerts ++ = vEnd + vBisector2;
		*pVerts ++ = vEnd - vBisector2;
		*pVerts ++ = vStart - vBisector1;

		uint8 r1 = pNode->m_Data.m_red;
		uint8 g1 = pNode->m_Data.m_green;
		uint8 b1 = pNode->m_Data.m_blue;
		uint8 a1 = pNode->m_Data.m_alpha;
		float u1 = pNode->m_Data.m_uVal + m_uOffset;

		uint8 r2 = pNode->m_pNext->m_Data.m_red;
		uint8 g2 = pNode->m_pNext->m_Data.m_green;
		uint8 b2 = pNode->m_pNext->m_Data.m_blue;
		uint8 a2 = pNode->m_pNext->m_Data.m_alpha;
		float u2 = pNode->m_pNext->m_Data.m_uVal + m_uOffset;		

		SetupVert(pTri, 0, g_pVerts[nVerts], r1, g1, b1, a1, u1, 0.0f);
		SetupVert(pTri, 1, g_pVerts[nVerts + 1], r2, g2, b2, a2, u2, 0.0f);
		SetupVert(pTri, 2, g_pVerts[nVerts + 2], r2, g2, b2, a2, u2, 1.0f);

		pTri ++;
		nTris ++;

		SetupVert(pTri, 0, g_pVerts[nVerts], r1, g1, b1, a1, u1, 0.0f);
		SetupVert(pTri, 1, g_pVerts[nVerts + 2], r2, g2, b2, a2, u2, 1.0f);
		SetupVert(pTri, 2, g_pVerts[nVerts + 3], r1, g1, b1, a1, u1, 1.0f);

		pTri ++;
		nTris ++;

		nVerts += 4;

		pNode = pNode->m_pNext;

		//see if we need to flush our buffer
		if(nTris >= MAX_BUFFER_TRIS - 2)
		{
			pDrawPrimLT->DrawPrim(g_pTris, nTris);
			nTris = 0;
			nVerts = 0;
			pTri = g_pTris;
			pVerts = g_pVerts;
		}
	}


	if(nTris > 0)
	{
		pDrawPrimLT->DrawPrim(g_pTris, nTris);
	}

	pDrawPrimLT->EndDrawPrim();

	return true;
}