Exemplo n.º 1
0
void CPoisonProjectile::Render() {
	
	if(m_elapsed >= m_duration)
		return;
	
	GRenderer->SetCulling(CullNone);
	GRenderer->SetRenderState(Renderer::DepthWrite, false);
	GRenderer->SetBlendFunc(BlendOne, BlendOne);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	
	int n = BEZIERPrecision;
	float delta = 1.0f / n;
	
	Vec3f lastpos = pathways[0];
	
	int i = 0;
	for(i = 0; i < 9; i++) {
		
		int kpprec = std::max(i - 1, 0);
		int kpsuiv = i + 1 ;
		int kpsuivsuiv = (i < (9 - 2)) ? kpsuiv + 1 : kpsuiv;
		
		for(int toto = 1; toto < n; toto++) {
			
			if(fTrail < i * n + toto) {
				break;
			}
			
			float t = toto * delta;
			
			const Vec3f prevPos = pathways[kpprec];
			const Vec3f currentPos = pathways[i];
			const Vec3f nextPos = pathways[kpsuiv];
			const Vec3f next2Pos = pathways[kpsuivsuiv];
			
			lastpos = glm::catmullRom(prevPos, currentPos, nextPos, next2Pos, t);
		}
	}
	
	eCurPos = lastpos;
	
	if(fTrail >= (i * n)) {
		LaunchPoisonExplosion(lastpos);
	}
	
	GRenderer->SetCulling(CullNone);
	GRenderer->SetRenderState(Renderer::DepthWrite, false);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
}
Exemplo n.º 2
0
void CPoisonProjectile::Render() {
	
	if(m_elapsed >= m_duration)
		return;
	
	int n = BEZIERPrecision;
	float delta = 1.0f / n;
	
	Vec3f lastpos = pathways[0];
	
	int i = 0;
	for(i = 0; i < 9; i++) {
		
		int kpprec = std::max(i - 1, 0);
		int kpsuiv = i + 1;
		int kpsuivsuiv = (i < (9 - 2)) ? kpsuiv + 1 : kpsuiv;
		
		for(int toto = 1; toto < n; toto++) {
			
			if(fTrail < i * n + toto) {
				break;
			}
			
			float t = toto * delta;
			
			const Vec3f prevPos = pathways[kpprec];
			const Vec3f currentPos = pathways[i];
			const Vec3f nextPos = pathways[kpsuiv];
			const Vec3f next2Pos = pathways[kpsuivsuiv];
			
			lastpos = arx::catmullRom(prevPos, currentPos, nextPos, next2Pos, t);
		}
	}
	
	eCurPos = lastpos;
	
	if(fTrail >= (i * n)) {
		LaunchPoisonExplosion(lastpos);
	}
	
}
//---------------------------------------------------------------------
float CPoisonProjectile::Render(LPDIRECT3DDEVICE7 m_pd3dDevice)
{
	int i = 0;

	if (ulCurrentTime >= ulDuration)
	{
		return 0.f;
	}

	SETCULL(m_pd3dDevice, D3DCULL_NONE);
	SETZWRITE(m_pd3dDevice, FALSE);
	//-------------------------------------------------------------------------
	m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ONE);
	m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
	SETALPHABLEND(m_pd3dDevice, TRUE);

	// ------------------------------------------------------------------------
	int n = BEZIERPrecision;
	float delta = 1.0f / n;

	EERIE_3D lastpos, newpos;
	EERIE_3D v;

	lastpos.x = pathways[0].sx;
	lastpos.y = pathways[0].sy;
	lastpos.z = pathways[0].sz;

	int arx_check_init = -1;
	newpos.x = 0;
	newpos.y = 0;
	newpos.z = 0;


	for (i = 0; i < 9; i++)
	{
		int kp = i;
		int kpprec = (i > 0) ? kp - 1 : kp ;
		int kpsuiv = kp + 1 ;
		int kpsuivsuiv = (i < (9 - 2)) ? kpsuiv + 1 : kpsuiv;

		for (int toto = 1; toto < n; toto++)
		{
			if (fTrail < i * n + toto) break;

			float t = toto * delta;

			float t1 = t;
			float t2 = t1 * t1 ;
			float t3 = t2 * t1 ;
			float f0 = 2.f * t3 - 3.f * t2 + 1.f ;
			float f1 = -2.f * t3 + 3.f * t2 ;
			float f2 = t3 - 2.f * t2 + t1 ;
			float f3 = t3 - t2 ;

			float val = pathways[kpsuiv].sx;
			float p0 = 0.5f * (val - pathways[kpprec].sx) ;
			float p1 = 0.5f * (pathways[kpsuivsuiv].sx - pathways[kp].sx) ;
			v.x = f0 * pathways[kp].sx + f1 * val + f2 * p0 + f3 * p1 ;

			val = pathways[kpsuiv].sy ;
			p0 = 0.5f * (val - pathways[kpprec].sy);
			p1 = 0.5f * (pathways[kpsuivsuiv].sy - pathways[kp].sy) ;
			v.y = f0 * pathways[kp].sy + f1 * val + f2 * p0 + f3 * p1 ;

			val = pathways[kpsuiv].sz ;
			p0 = 0.5f * (val - pathways[kpprec].sz) ;
			p1 = 0.5f * (pathways[kpsuivsuiv].sz - pathways[kp].sz) ;
			v.z = f0 * pathways[kp].sz + f1 * val + f2 * p0 + f3 * p1 ;

			newpos.x = v.x;
			newpos.y = v.y;
			newpos.z = v.z;

			if (!((fTrail - (i * n + toto)) > 70))
			{
				float c = 1.0f - ((fTrail - (i * n + toto)) / 70.0f);
				c += frand2() * 0.1f;

				if (c < 0) c = 0;

				if (c > 1) c = 1;
			}

			float nx = lastpos.x;
			float ny = lastpos.y;
			float nz = lastpos.z;

			lastpos.x = newpos.x;
			lastpos.y = newpos.y;
			lastpos.z = newpos.z;

			newpos.x = nx;
			newpos.y = ny;
			newpos.z = nz;
			++arx_check_init;
		}
	}

	EERIE_3D stiteangle;
	EERIE_3D stitepos;
	EERIE_3D stitescale;
	EERIE_RGB stitecolor;

	EERIE_3D av;
	ARX_CHECK_NOT_NEG(arx_check_init);
	av.x = newpos.x - lastpos.x;
	av.y = newpos.y - lastpos.y;
	av.z = newpos.z - lastpos.z;

	TRUEVector_Normalize(&av);

	float bubu = GetAngle(av.x, av.z, 0, 0);
	float bubu1 = GetAngle(av.x, av.y, 0, 0);

	stitepos.x = lastpos.x;
	stitepos.y = lastpos.y;
	stitepos.z = lastpos.z;
	stiteangle.b = -RAD2DEG(bubu);
	stiteangle.a = 0;
	stiteangle.g = -90 - RAD2DEG(bubu1);
	stitecolor.r = 0.7f;
	stitecolor.g = 0.7f;
	stitecolor.b = 0.7f;
	stitescale.x = 2;
	stitescale.y = 2;
	stitescale.z = 2;

	eCurPos.x = lastpos.x;
	eCurPos.y = lastpos.y;
	eCurPos.z = lastpos.z;

	if (fTrail >= (i * n))
	{
		LaunchPoisonExplosion(&lastpos);
	}

	SETCULL(m_pd3dDevice, D3DCULL_NONE);
	SETZWRITE(m_pd3dDevice, FALSE);
	SETALPHABLEND(m_pd3dDevice, TRUE);

	return 1;
}
Exemplo n.º 4
0
float CPoisonProjectile::Render() {
	
	if(ulCurrentTime >= ulDuration) {
		return 0.f;
	}
	
	GRenderer->SetCulling(Renderer::CullNone);
	GRenderer->SetRenderState(Renderer::DepthWrite, false);
	GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	
	int n = BEZIERPrecision;
	float delta = 1.0f / n;
	
	Vec3f lastpos = pathways[0].p;
	
	int arx_check_init = -1;
	
	int i = 0;
	for(i = 0; i < 9; i++) {
		
		int kpprec = std::max(i - 1, 0);
		int kpsuiv = i + 1 ;
		int kpsuivsuiv = (i < (9 - 2)) ? kpsuiv + 1 : kpsuiv;
		
		for(int toto = 1; toto < n; toto++) {
			
			if(fTrail < i * n + toto) {
				break;
			}
			
			float t = toto * delta;
			
			float t2 = t * t ;
			float t3 = t2 * t ;
			float f0 = 2.f * t3 - 3.f * t2 + 1.f ;
			float f1 = -2.f * t3 + 3.f * t2 ;
			float f2 = t3 - 2.f * t2 + t ;
			float f3 = t3 - t2 ;
			
			float val = pathways[kpsuiv].p.x;
			float p0 = 0.5f * (val - pathways[kpprec].p.x);
			float p1 = 0.5f * (pathways[kpsuivsuiv].p.x - pathways[i].p.x);
			lastpos.x = f0 * pathways[i].p.x + f1 * val + f2 * p0 + f3 * p1;
			
			val = pathways[kpsuiv].p.y;
			p0 = 0.5f * (val - pathways[kpprec].p.y);
			p1 = 0.5f * (pathways[kpsuivsuiv].p.y - pathways[i].p.y);
			lastpos.y = f0 * pathways[i].p.y + f1 * val + f2 * p0 + f3 * p1;
			
			val = pathways[kpsuiv].p.z;
			p0 = 0.5f * (val - pathways[kpprec].p.z);
			p1 = 0.5f * (pathways[kpsuivsuiv].p.z - pathways[i].p.z);
			lastpos.z = f0 * pathways[i].p.z + f1 * val + f2 * p0 + f3 * p1;
			
			++arx_check_init;
		}
	}
	
	// arx_assert(arx_check_init >= 0); TODO why should this hold?
	
	eCurPos = lastpos;
	
	if(fTrail >= (i * n)) {
		LaunchPoisonExplosion(&lastpos);
	}
	
	GRenderer->SetCulling(Renderer::CullNone);
	GRenderer->SetRenderState(Renderer::DepthWrite, false);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	
	return 1;
}