Ejemplo n.º 1
0
void drawQuadRTP(const RenderMaterial & mat, TexturedQuad quat) {
	EE_RTP(quat.v[0].p, quat.v[0]);
	EE_RTP(quat.v[1].p, quat.v[1]);
	EE_RTP(quat.v[2].p, quat.v[2]);
	EE_RTP(quat.v[3].p, quat.v[3]);
	
	RenderBatcher::getInstance().add(mat, quat);
}
Ejemplo n.º 2
0
static void EERIERTPPoly2(EERIEPOLY & ep) {
	
	EE_RTP(ep.v[0].p, &ep.tv[0]);
	EE_RTP(ep.v[1].p, &ep.tv[1]);
	EE_RTP(ep.v[2].p, &ep.tv[2]);

	if(ep.type & POLY_QUAD)
		EE_RTP(ep.v[3].p, &ep.tv[3]);
	else
		ep.tv[3].p.z=1.f;
}
Ejemplo n.º 3
0
void drawTriangle(const RenderMaterial & mat, const TexturedVertexUntransformed * vertices) {
	
	TexturedVertex projected[3];
	EE_RTP(vertices[0].p, projected[0]);
	EE_RTP(vertices[1].p, projected[1]);
	EE_RTP(vertices[2].p, projected[2]);
	projected[0].color = vertices[0].color;
	projected[0].uv = vertices[0].uv;
	projected[1].color = vertices[1].color;
	projected[1].uv = vertices[1].uv;
	projected[2].color = vertices[2].color;
	projected[2].uv = vertices[2].uv;
	
	RenderBatcher::getInstance().add(mat, projected);
}
Ejemplo n.º 4
0
static void Cedric_ViewProjectTransform(EERIE_3DOBJ * eobj) {

	for(size_t i = 0; i < eobj->vertexlist.size(); i++) {
		EERIE_VERTEX * outVert = &eobj->vertexlist3[i];
		EE_RTP(outVert->v, outVert->vert);
	}
}
Ejemplo n.º 5
0
static void drawDebugLights() {
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	GRenderer->SetCulling(CullNone);
	
	GRenderer->SetBlendFunc(BlendOne, BlendOne);
	
	for(size_t i = 0; i < MAX_LIGHTS; i++) {
		
		EERIE_LIGHT * light = GLight[i];
		if(!light) {
			continue;
		}
		
		TexturedVertex center;
		EE_RTP(light->pos, center);
		
		const Rect mouseTestRect(
		center.p.x - 20,
		center.p.y - 20,
		center.p.x + 20,
		center.p.y + 20
		);
		
		if(mouseTestRect.contains(Vec2i(DANAEMouse))) {
			
			Sphere fallstart;
			fallstart.origin = light->pos;
			fallstart.radius = light->fallstart;
			drawLineSphere(fallstart, Color(Color3<u8>::green, 200));
			Sphere fallend;
			fallend.origin = light->pos;
			fallend.radius = light->fallend;
			drawLineSphere(fallend, Color(Color3<u8>::red, 200));
		}
		
		if(light->m_screenRect.valid())
			drawDebugBoundingBox(light->m_screenRect);
	}
	
	for(size_t i = 0; i < MAX_LIGHTS; i++) {
		
		EERIE_LIGHT * light = GLight[i];
		if(!light) {
			continue;
		}
		
		EERIEDrawSprite(light->pos, 11.f, g_lightSourceTexture, light->rgb.to<u8>(), 0.5f);
	}
	
	GRenderer->SetCulling(CullCCW);
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
	
}
Ejemplo n.º 6
0
void drawLine(const Vec3f & orgn, const Vec3f & dest, Color color1, Color color2, float zbias) {
	
	TexturedVertex v[2];
	
	EE_RTP(orgn, v[0]);
	if(v[0].p.z < 0.f) {
		return;
	}
	
	EE_RTP(dest, v[1]);
	if(v[1].p.z < 0.f) {
		return;
	}
	
	v[0].p.z -= zbias, v[1].p.z -= zbias;
	
	GRenderer->ResetTexture(0);
	v[0].color = color1.toRGBA();
	v[1].color = color2.toRGBA();
	
	EERIEDRAWPRIM(Renderer::LineList, v, 2);
}
Ejemplo n.º 7
0
static void ComputeLight2DPos(EERIE_LIGHT * _pL) {

    TexturedVertex out;
    EE_RTP(_pL->pos, &out);

    if(out.p.z > 0.f && out.p.z < 1000.f && out.rhw > 0) {
        float siz = 50;
        float fMaxdist = player.m_telekinesis ? 850 : 300;

        float t = siz * (1.0f - 1.0f / (out.rhw * fMaxdist)) + 10;

        _pL->m_screenRect.max.x = out.p.x + t;
        _pL->m_screenRect.min.x = out.p.x - t;
        _pL->m_screenRect.max.y = out.p.y + t;
        _pL->m_screenRect.min.y = out.p.y - t;
    }
}
Ejemplo n.º 8
0
void drawTextAt(Font * font, const Vec3f & pos, const std::string & text, Color color,
                const std::string & text2, Color color2) {
	
	// Project the 3d coordinates to get an on-screen position
	TexturedVertex out;
	EE_RTP(pos, out);
	if(out.p.z < 0.f) {
		// Don't draw text behind the camera!
		return;
	}
	
	Vec2f pos2d = Vec2f(out.p.x, out.p.y);
	drawTextCentered(font, pos2d, text, color);
	
	if(!text2.empty()) {
		pos2d.y += font->getLineHeight() + 2;
		drawTextCentered(font, pos2d, text2, color2);
	}
	
}
Ejemplo n.º 9
0
//***********************************************************************************************
// Draws a light source for EDITOR purpose...
//-----------------------------------------------------------------------------------------------
// VERIFIED (Cyril 2001/10/15)
//***********************************************************************************************
void EERIEDrawLight(EERIE_LIGHT * el) 
{
//	long i;
 
	TexturedVertex in;
	TexturedVertex center;
	GRenderer->SetCulling(Renderer::CullNone);
	
	if(!el || !el->treat)
		return;


	el->mins.x=999999999.f;
	in.p = el->pos;

	EERIEDrawSprite(&in, 11.f, lightsource_tc, el->rgb.to<u8>(), 2.f);


	el->mins = SPRmins;
	el->maxs = SPRmaxs;

	if(el->selected) {
		if((el->mins.x>=-200.f) && (el->mins.x<=1000.f))
		if((el->mins.y>=-200.f) && (el->mins.y<=1000.f)) {
			in.p = el->pos;
			EE_RTP(&in, &center);

			if(center.p.z > 0.f && center.p.z < 1000.f) {
				float t=(1.f-center.p.z)*ACTIVECAM->orgTrans.use_focal*( 1.0f / 3000 );
				float rad=el->fallstart*t;
				EERIEDrawCircle(center.p.x, center.p.y, rad, Color::yellow, 0.0001f);
				rad=el->fallend*t;
				EERIEDrawCircle(center.p.x, center.p.y, rad, Color::red, 0.0001f);
				rad=el->intensity*200.f*t;
				EERIEDrawCircle(center.p.x, center.p.y, rad, Color::green, 0.0001f);
			}
		}
	}
}
Ejemplo n.º 10
0
void AddFlare(const Vec2s & pos, float sm, short typ, Entity * io, bool bookDraw) {
	
	int oldest = 0;
	size_t i;
	for(i = 0; i < MAX_FLARES; i++) {
		if(!magicFlares[i].exist) {
			break;
		}
		if(magicFlares[i].tolive < magicFlares[oldest].tolive) {
			oldest = i;
		}
	}
	if(i >= MAX_FLARES) {
		removeFlare(magicFlares[oldest]);
		i = oldest;
	}

	FLARES * fl = &magicFlares[i];
	fl->exist = 1;
	flarenum++;

	if(!bookDraw)
		fl->bDrawBitmap = 0;
	else
		fl->bDrawBitmap = 1;

	fl->io = io;
	if(io) {
		fl->flags = 1;
		io->flarecount++;
	} else {
		fl->flags = 0;
	}

	fl->pos.x = float(pos.x) - rnd() * 4.f;
	fl->pos.y = float(pos.y) - rnd() * 4.f - 50.f;
	fl->tv.rhw = fl->v.rhw = 1.f;

	if(!bookDraw) {
		EERIE_CAMERA ka = *Kam;
		ka.angle = Anglef(360.f, 360.f, 360.f) - ka.angle;
		EERIE_CAMERA * oldcam = ACTIVECAM;
		SetActiveCamera(&ka);
		PrepareCamera(&ka, g_size);
		fl->v.p += ka.orgTrans.pos;
		EE_RTP(fl->tv.p, &fl->v);
		fl->v.p += ka.orgTrans.pos;

		float vx = -(fl->pos.x - subj.center.x) * 0.2173913f;
		float vy = (fl->pos.y - subj.center.y) * 0.1515151515151515f;
		if(io) {
			fl->v.p = io->pos;
			fl->v.p += angleToVectorXZ(io->angle.getPitch() + vx) * 100.f;
			fl->v.p.y += std::sin(glm::radians(MAKEANGLE(io->angle.getYaw() + vy))) * 100.f - 150.f;
		} else {
			fl->v.p.x = 1.0f  * float(pos.x - (g_size.width()  / 2)) * 156.f / (640.f * g_sizeRatio.y);
			fl->v.p.y = 0.75f * float(pos.y - (g_size.height() / 2)) * 156.f / (480.f * g_sizeRatio.y);
			fl->v.p.z = 75.f;
			ka = *oldcam;
			SetActiveCamera(&ka);
			PrepareCamera(&ka, g_size);
			float temp = (fl->v.p.y * -ka.orgTrans.xsin) + (fl->v.p.z * ka.orgTrans.xcos);
			fl->v.p.y = (fl->v.p.y * ka.orgTrans.xcos) - (-fl->v.p.z * ka.orgTrans.xsin);
			fl->v.p.z = (temp * ka.orgTrans.ycos) - (-fl->v.p.x * ka.orgTrans.ysin);
			fl->v.p.x = (temp * -ka.orgTrans.ysin) + (fl->v.p.x * ka.orgTrans.ycos);
			fl->v.p += oldcam->orgTrans.pos;
		}
		fl->tv.p = fl->v.p;
		SetActiveCamera(oldcam);
		PrepareCamera(oldcam, g_size);
	} else {
		fl->tv.p = Vec3f(fl->pos.x, fl->pos.y, 0.001f);
	}

	switch(PIPOrgb) {
		case 0: {
			fl->rgb = Color3f(.4f, 0.f, .4f) + Color3f(2.f/3, 2.f/3, 2.f/3) * randomColor3f();
			break;
		}
		case 1: {
			fl->rgb = Color3f(.5f, .5f, 0.f) + Color3f(.625f, .625f, .55f) * randomColor3f();
			break;
		}
		case 2: {
			fl->rgb = Color3f(.4f, 0.f, 0.f) + Color3f(2.f/3, .55f, .55f) * randomColor3f();
			break;
		}
	}

	if(typ == -1) {
		float zz = eeMousePressed1() ? 0.29f : ((sm > 0.5f) ? rnd() : 1.f);
		if(zz < 0.2f) {
			fl->type = 2;
			fl->size = rnd() * 42.f + 42.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else if(zz < 0.5f) {
			fl->type = 3;
			fl->size = rnd() * 52.f + 16.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else {
			fl->type = 1;
			fl->size = (rnd() * 24.f + 32.f) * sm;
			fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
		}
	} else {
		fl->type = (rnd() > 0.8f) ? 1 : 4;
		fl->size = (rnd() * 38.f + 64.f) * sm;
		fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
	}

	fl->dynlight = LightHandle::Invalid;

	for(long kk = 0; kk < 3; kk++) {

		if(rnd() < 0.5f) {
			continue;
		}

		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}

		if(!bookDraw) {
			pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
			if(!io) {
				pd->special |= PARTICLE_NOZBUFFER;
			}
		} else {
			pd->special = FADE_IN_AND_OUT;
		}

		pd->ov = fl->v.p + randomVec(-5.f, 5.f);
		pd->move = Vec3f(0.f, 5.f, 0.f);
		pd->scale = Vec3f(-2.f);
		pd->tolive = 1300 + kk * 100 + Random::get(0, 800);
		pd->tc = fire2;
		if(kk == 1) {
			pd->move.y = 4.f;
			pd->siz = 1.5f;
		} else {
			pd->siz = 1.f + rnd();
		}
		pd->rgb = Color3f(fl->rgb.r * (2.f/3), fl->rgb.g * (2.f/3), fl->rgb.b * (2.f/3));
		pd->fparam = 1.2f;

		if(bookDraw)
			pd->is2D = true;
	}
}
Ejemplo n.º 11
0
/*--------------------------------------------------------------------------*/
float CPortal::Render(LPDIRECT3DDEVICE7 device)
{
	SETALPHABLEND(device, TRUE);
	SETZWRITE(device, FALSE);

	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);

	//calcul sphere
	int			nb = this->spherenbpt;
	D3DTLVERTEX * v = this->sphered3d, d3dvs;
	EERIE_3D	* pt = this->spherevertex;
	int col = RGBA_MAKE(0, (int)(200.f * this->spherealpha), (int)(255.f * this->spherealpha), 255);

	while (nb)
	{
		d3dvs.sx = pt->x + this->pos.x;	//pt du bas
		d3dvs.sy = pt->y + this->pos.y;
		d3dvs.sz = pt->z + this->pos.z;
		EE_RTP(&d3dvs, v);

		if (!ARXPausedTimer) v->color = col;

		v++;
		pt++;
		nb--;
	}

	//update les couleurs aux impacts
	nb = 256;

	while (nb--)
	{
		if (this->tabeclair[nb].actif)
		{
			float a;

			a = 1.f - ((float)this->tabeclair[nb].currduration / (float)this->tabeclair[nb].duration);

			if (a < 0.f) a = 0.f;

			if (this->tabeclair[nb].numpt >= 0)
			{
				int r = (int)((0.f + (255.f - 0.f) * a) * this->spherealpha * 3.f);

				if (r > 255) r = 255;

				int g = (int)((200.f + (255.f - 200.f) * a) * this->spherealpha * 3.f);

				if (g > 255) g = 255;

				int b = (int)(255.f * this->spherealpha * 3.f);

				if (b > 255) b = 255;

				if (!ARXPausedTimer) this->sphered3d[this->tabeclair[nb].numpt].color = RGBA_MAKE(r, g, b, 255);
			}

		}
	}


	//affichage de la sphere back
	SETCULL(device, D3DCULL_CW);
	device->SetTexture(0, NULL);
	device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, this->sphered3d, this->spherenbpt, (unsigned short *)this->sphereind, this->spherenbfaces * 3, 0);

	//affichage eclair
	this->DrawAllEclair(device);

	//affichage des particules à l'interieur
	if (rnd() > .25f)
	{
		int j = ARX_PARTICLES_GetFree();

		if ((j != -1) && (!ARXPausedTimer))
		{
			ParticleCount++;
			particle[j].exist = 1;
			particle[j].zdec = 0;

			float a = rnd() * 360.f;
			float b = rnd() * 360.f;
			float rr = this->r * (rnd() + .25f) * 0.05f;

			particle[j].ov.x	=	this->pos.x;
			particle[j].ov.y	=	this->pos.y;
			particle[j].ov.z	=	this->pos.z;
			particle[j].move.x	=	rr * EEsin(DEG2RAD(a)) * EEcos(DEG2RAD(b));
			particle[j].move.y	=	rr * EEcos(DEG2RAD(a));
			particle[j].move.z	=	rr * EEsin(DEG2RAD(a)) * EEsin(DEG2RAD(b));
			particle[j].siz		=	10.f;
			particle[j].tolive	=	1000 + (unsigned long)(float)(rnd() * 1000.f);
			particle[j].scale.x	=	1.f;
			particle[j].scale.y	=	1.f;
			particle[j].scale.z	=	1.f;
			particle[j].timcreation	=	lARXTime;
			particle[j].tc		=	tp;
			particle[j].special	=	FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
			particle[j].fparam	=	0.0000001f;
			particle[j].r		=	1.f;
			particle[j].g		=	1.f;
			particle[j].b		=	1.f;
		}
	}

	//affichage de la sphere front
	SETCULL(device, D3DCULL_CCW);
	device->SetTexture(0, NULL);
	device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, this->sphered3d, this->spherenbpt, (unsigned short *)this->sphereind, this->spherenbfaces * 3, 0);

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

	return 0;
}
Ejemplo n.º 12
0
bool EERIECreateSprite(TexturedQuad& sprite, const Vec3f & in, float siz, Color color, float Zpos, float rot = 0) {

	TexturedVertex out;
	EE_RTP(in, &out);
	out.rhw *= 3000.f;

	if(   out.p.z > 0.f
	   && out.p.z < 1000.f
	   && out.p.x > -1000.f
	   && out.p.x < 2500.f
	   && out.p.y > -500.f
	   && out.p.y < 1800.f
	) {
		float use_focal=BASICFOCAL*g_sizeRatio.x;
		float t;

		if(siz < 0) {
			t = -siz;
		} else {
			t = siz * ((out.rhw-1.f)*use_focal*0.001f);

			if(t <= 0.f)
				t = 0.00000001f;
		}
		
		if(Zpos <= 1.f) {
			out.p.z = Zpos;
			out.rhw = 1.f - out.p.z;
		} else {
			out.rhw *= (1.f/3000.f);
		}		
		
		ColorRGBA col = color.toRGBA();
		
		sprite.v[0] = TexturedVertex(Vec3f(), out.rhw, col, Vec2f_ZERO);
		sprite.v[1] = TexturedVertex(Vec3f(), out.rhw, col, Vec2f_X_AXIS);
		sprite.v[2] = TexturedVertex(Vec3f(), out.rhw, col, Vec2f(1.f, 1.f));
		sprite.v[3] = TexturedVertex(Vec3f(), out.rhw, col, Vec2f_Y_AXIS);
		
		if(rot == 0) {
			Vec3f maxs = out.p + t;
			Vec3f mins = out.p - t;

			sprite.v[0].p = Vec3f(mins.x, mins.y, out.p.z);
			sprite.v[1].p = Vec3f(maxs.x, mins.y, out.p.z);
			sprite.v[2].p = Vec3f(maxs.x, maxs.y, out.p.z);
			sprite.v[3].p = Vec3f(mins.x, maxs.y, out.p.z);
		} else {
			for(long i=0;i<4;i++) {
				float tt = glm::radians(MAKEANGLE(rot+90.f*i+45+90));
				sprite.v[i].p.x = std::sin(tt) * t + out.p.x;
				sprite.v[i].p.y = std::cos(tt) * t + out.p.y;
				sprite.v[i].p.z = out.p.z;
			}
		}

		return true;
	}

	return false;
}
Ejemplo n.º 13
0
void AddFlare(const Vec2s & pos, float sm, short typ, Entity * io, bool bookDraw) {

	long i;
	for(i = 0; i < MAX_FLARES; i++) {
		if(!magicFlares[i].exist) {
			break;
		}
	}
	if(i >= MAX_FLARES) {
		return;
	}

	FLARES * fl = &magicFlares[i];
	fl->exist = 1;
	flarenum++;

	if(!bookDraw)
		fl->bDrawBitmap = 0;
	else
		fl->bDrawBitmap = 1;

	fl->io = io;
	if(io) {
		fl->flags = 1;
		io->flarecount++;
	} else {
		fl->flags = 0;
	}

	fl->x = float(pos.x) - rnd() * 4.f;
	fl->y = float(pos.y) - rnd() * 4.f - 50.f;
	fl->tv.rhw = fl->v.rhw = 1.f;
	fl->tv.specular = fl->v.specular = 1;

	if(!bookDraw) {
		EERIE_CAMERA ka = *Kam;
		ka.angle = Anglef(360.f, 360.f, 360.f) - ka.angle;
		EERIE_CAMERA * oldcam = ACTIVECAM;
		SetActiveCamera(&ka);
		PrepareCamera(&ka);
		fl->v.p += ka.orgTrans.pos;
		EE_RTP(&fl->tv, &fl->v);
		fl->v.p += ka.orgTrans.pos;

		float vx = -(fl->x - subj.center.x) * 0.2173913f;
		float vy = (fl->y - subj.center.y) * 0.1515151515151515f;
		if(io) {
			fl->v.p.x = io->pos.x - EEsin(radians(MAKEANGLE(io->angle.getPitch() + vx))) * 100.f;
			fl->v.p.y = io->pos.y + EEsin(radians(MAKEANGLE(io->angle.getYaw() + vy))) * 100.f - 150.f;
			fl->v.p.z = io->pos.z + EEcos(radians(MAKEANGLE(io->angle.getPitch() + vx))) * 100.f;
		} else {
			fl->v.p.x = float(pos.x - (g_size.width() / 2)) * 150.f / float(g_size.width());
			fl->v.p.y = float(pos.y - (g_size.height() / 2)) * 150.f / float(g_size.width());
			fl->v.p.z = 75.f;
			ka = *oldcam;
			SetActiveCamera(&ka);
			PrepareCamera(&ka);
			float temp = (fl->v.p.y * -ka.orgTrans.xsin) + (fl->v.p.z * ka.orgTrans.xcos);
			fl->v.p.y = (fl->v.p.y * ka.orgTrans.xcos) - (-fl->v.p.z * ka.orgTrans.xsin);
			fl->v.p.z = (temp * ka.orgTrans.ycos) - (-fl->v.p.x * ka.orgTrans.ysin);
			fl->v.p.x = (temp * -ka.orgTrans.ysin) + (fl->v.p.x * ka.orgTrans.ycos);
			fl->v.p += oldcam->orgTrans.pos;
		}
		fl->tv.p = fl->v.p;
		SetActiveCamera(oldcam);
		PrepareCamera(oldcam);
	} else {
		fl->tv.p = Vec3f(fl->x, fl->y, 0.001f);
	}

	switch(PIPOrgb) {
		case 0: {
			fl->rgb = Color3f(rnd() * (2.f/3) + .4f, rnd() * (2.f/3), rnd() * (2.f/3) + .4f);
			break;
		}
		case 1: {
			fl->rgb = Color3f(rnd() * .625f + .5f, rnd() * .625f + .5f, rnd() * .55f);
			break;
		}
		case 2: {
			fl->rgb = Color3f(rnd() * (2.f/3) + .4f, rnd() * .55f, rnd() * .55f);
			break;
		}
	}

	if(typ == -1) {
		float zz = (EERIEMouseButton & 1) ? 0.29f : ((sm > 0.5f) ? rnd() : 1.f);
		if(zz < 0.2f) {
			fl->type = 2;
			fl->size = rnd() * 42.f + 42.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else if(zz < 0.5f) {
			fl->type = 3;
			fl->size = rnd() * 52.f + 16.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else {
			fl->type = 1;
			fl->size = (rnd() * 24.f + 32.f) * sm;
			fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
		}
	} else {
		fl->type = (rnd() > 0.8f) ? 1 : 4;
		fl->size = (rnd() * 38.f + 64.f) * sm;
		fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
	}

	fl->dynlight = -1;
	fl->move = OPIPOrgb;

	for(long kk = 0; kk < 3; kk++) {

		if(rnd() < 0.5f) {
			continue;
		}

		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}

		if(!bookDraw) {
			pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
			if(!io) {
				pd->special |= PARTICLE_NOZBUFFER;
			}
		} else {
			pd->special = FADE_IN_AND_OUT;
		}

		pd->ov = fl->v.p + randomVec(-5.f, 5.f);
		pd->move = Vec3f(0.f, 5.f, 0.f);
		pd->scale = Vec3f(-2.f);
		pd->tolive = 1300 + kk * 100 + Random::get(0, 800);
		pd->tc = fire2;
		if(kk == 1) {
			pd->move.y = 4.f;
			pd->siz = 1.5f;
		} else {
			pd->siz = 1.f + rnd();
		}
		pd->rgb = Color3f(fl->rgb.r * (2.f/3), fl->rgb.g * (2.f/3), fl->rgb.b * (2.f/3));
		pd->fparam = 1.2f;

		if(bookDraw)
			pd->type = PARTICLE_2D;
	}
}
Ejemplo n.º 14
0
//-----------------------------------------------------------------------------
void CSummonCreature::RenderFissure(LPDIRECT3DDEVICE7 m_pd3dDevice)
{
    int i;
    float ff;
    D3DTLVERTEX vt[4];
    D3DTLVERTEX vr[4];
    D3DTLVERTEX target;

    EERIE_3D etarget;
    etarget.x = fBetaRadCos;
    etarget.y = 0;
    etarget.z = fBetaRadSin;

    //-------------------------------------------------------------------------
    // computation des sommets
    float fTempCos, fTempSin;

    for (i = 0; i <= min(end, int(fSizeIntro)); i++)
    {
        if (i <= end * 0.5f)
        {
            ff = i / (end * 0.5f);
        }
        else
        {
            ff = 1.0f - ((i - (end + 1) * 0.5f) / (end * 0.5f));
        }

        fTempCos = ff * fBetaRadCos;
        fTempSin = ff * fBetaRadSin;

        va[i].sx   = v1a[i].sx   + sizeF * fTempCos;
        va[i].sy   = v1a[i].sy;
        va[i].sz   = v1a[i].sz   + sizeF * fTempSin;

        vb[i].sx   = v1b[i].sx   - sizeF * fTempCos;
        vb[i].sy   = v1b[i].sy;
        vb[i].sz   = v1b[i].sz   - sizeF * fTempSin;

        va[i].sx += rnd() * 0.5f * fTempCos;
        va[i].sz += rnd() * 0.5f * fTempSin;
        vb[i].sx -= rnd() * 0.5f * fTempCos;
        vb[i].sz -= rnd() * 0.5f * fTempSin;
    }

    //-------------------------------------------------------------------------
    // rendu de la fissure
    SETALPHABLEND(m_pd3dDevice, false);
    vr[0].color = vr[1].color = vr[2].color = vr[3].color = D3DRGB(0, 0, 0);

    if (bIntro)
    {
        for (i = 0; i < min(end, (int)fSizeIntro); i++)
        {
            EE_RT2(&v1a[i], &vr[0]);
            EE_RT2(&v1b[i], &vr[1]);
            EE_RT2(&v1a[i+1], &vr[2]);
            EE_RT2(&v1b[i+1], &vr[3]);
            ARX_DrawPrimitive_SoftClippZ(&vr[0],
                                         &vr[1],
                                         &vr[2]);
            ARX_DrawPrimitive_SoftClippZ(&vr[1],
                                         &vr[2],
                                         &vr[3]);
        }
    }
    else
    {
        for (i = 0; i < min(end, (int)fSizeIntro); i++)
        {
            EE_RT2(&va[i], &vr[0]);
            EE_RT2(&vb[i], &vr[1]);
            EE_RT2(&va[i+1], &vr[2]);
            EE_RT2(&vb[i+1], &vr[3]);
            ARX_DrawPrimitive_SoftClippZ(&vr[0],
                                         &vr[1],
                                         &vr[2]);
            ARX_DrawPrimitive_SoftClippZ(&vr[1],
                                         &vr[2],
                                         &vr[3]);
        }
    }

    //-------------------------------------------------------------------------
    // rendu de la bordure
    SETALPHABLEND(m_pd3dDevice, true);
    vr[0].color = vr[1].color = D3DRGB(0, 0, 0);
    vr[2].color = vr[3].color = D3DRGB(fColorBorder[0], fColorBorder[1], fColorBorder[2]);

    for (i = 0; i < min(end, (int)fSizeIntro); i++)
    {
        vt[2].sx = va[i].sx   - (va[i].sx - eSrc.x) * 0.2f;
        vt[2].sy = va[i].sy   - (va[i].sy - eSrc.y) * 0.2f;
        vt[2].sz = va[i].sz   - (va[i].sz - eSrc.z) * 0.2f;
        vt[3].sx = va[i+1].sx - (va[i+1].sx - eSrc.x) * 0.2f;
        vt[3].sy = va[i+1].sy - (va[i+1].sy - eSrc.y) * 0.2f;
        vt[3].sz = va[i+1].sz - (va[i+1].sz - eSrc.z) * 0.2f;

        EE_RT2(&vt[3], &vr[0]);
        EE_RT2(&vt[2], &vr[1]);
        EE_RT2(&va[i+1], &vr[2]);
        EE_RT2(&va[i], &vr[3]);
        ARX_DrawPrimitive_SoftClippZ(&vr[0],
                                     &vr[1],
                                     &vr[2]);
        ARX_DrawPrimitive_SoftClippZ(&vr[1],
                                     &vr[2],
                                     &vr[3]);

        vt[2].sx = vb[i].sx   - (vb[i].sx - eSrc.x) * 0.2f;
        vt[2].sy = vb[i].sy   - (vb[i].sy - eSrc.y) * 0.2f;
        vt[2].sz = vb[i].sz   - (vb[i].sz - eSrc.z) * 0.2f;
        vt[3].sx = vb[i+1].sx - (vb[i+1].sx - eSrc.x) * 0.2f;
        vt[3].sy = vb[i+1].sy - (vb[i+1].sy - eSrc.y) * 0.2f;
        vt[3].sz = vb[i+1].sz - (vb[i+1].sz - eSrc.z) * 0.2f;

        EE_RT2(&vb[i], &vr[3]);
        EE_RT2(&vb[i+1], &vr[2]);
        EE_RT2(&vt[2], &vr[1]);
        EE_RT2(&vt[3], &vr[0]);
        ARX_DrawPrimitive_SoftClippZ(&vr[0],
                                     &vr[1],
                                     &vr[2]);
        ARX_DrawPrimitive_SoftClippZ(&vr[1],
                                     &vr[2],
                                     &vr[3]);

    }

    //-------------------------------------------------------------------------
    // rendu des faisceaux
    // blend additif ou mul
    // smooth sur les cot�s ou pas ..
    // texture sympa avec glow au milieu ou uv wrap
    SETALPHABLEND(m_pd3dDevice, true);

    if (tex_light && tex_light->m_pddsSurface)
    {
        SETTEXTUREWRAPMODE(m_pd3dDevice, D3DTADDRESS_MIRROR);
        SETTC(m_pd3dDevice, tex_light);
    }

    target.sx = eSrc.x + -fBetaRadSin * (1.5f * sizeF);
    target.sy = eSrc.y;
    target.sz = eSrc.z + fBetaRadCos * (1.5f * sizeF);

    EE_RTP(&vt[1], &vr[0]);
    vr[0].color = D3DRGB(fColorRays1[0], fColorRays1[1], fColorRays1[2]);
    vr[1].color = D3DRGB(fColorRays1[0], fColorRays1[1], fColorRays1[2]);
    vr[2].color = D3DRGB(fColorRays2[0], fColorRays2[1], fColorRays2[2]);
    vr[3].color = D3DRGB(fColorRays2[0], fColorRays2[1], fColorRays2[2]);

    vr[0].tu = fTexWrap;
    vr[0].tv = 1;
    vr[1].tu = 1.0f + fTexWrap;
    vr[1].tv = 1;
    vr[2].tu = fTexWrap;
    vr[2].tv = 0;
    vr[3].tu = 1.0f + fTexWrap;
    vr[3].tv = 0;

    for (i = 0; i < end - 1; i++)
    {
        if (i < fSizeIntro)
        {
            vt[0].sx = va[i].sx;
            vt[0].sy = va[i].sy;
            vt[0].sz = va[i].sz;
            vt[1].sx = va[i+1].sx;
            vt[1].sy = va[i+1].sy;
            vt[1].sz = va[i+1].sz;
            vt[2].sx = va[i].sx + (va[i].sx - target.sx) * 2;
            vt[2].sy = va[i].sy + (va[i].sy - target.sy) * 2;
            vt[2].sz = va[i].sz + (va[i].sz - target.sz) * 2;
            vt[3].sx = va[i+1].sx + (va[i+1].sx - target.sx) * 2;
            vt[3].sy = va[i+1].sy + (va[i+1].sy - target.sy) * 2;
            vt[3].sz = va[i+1].sz + (va[i+1].sz - target.sz) * 2;

            vr[0].color = D3DRGB(tfRaysa[i] * fColorRays1[0],   tfRaysa[i] * fColorRays1[1],   tfRaysa[i] * fColorRays1[2]);
            vr[1].color = D3DRGB(tfRaysa[i+1] * fColorRays1[0], tfRaysa[i+1] * fColorRays1[1], tfRaysa[i+1] * fColorRays1[2]);
            vr[2].color = D3DRGB(tfRaysa[i] * fColorRays2[0],   tfRaysa[i] * fColorRays2[1],   tfRaysa[i] * fColorRays2[2]);
            vr[3].color = D3DRGB(tfRaysa[i+1] * fColorRays2[0], tfRaysa[i+1] * fColorRays2[1], tfRaysa[i+1] * fColorRays2[2]);

            EE_RT2(&vt[0], &vr[3]);
            EE_RT2(&vt[1], &vr[2]);
            EE_RT2(&vt[2], &vr[1]);
            EE_RT2(&vt[3], &vr[0]);
            ARX_DrawPrimitive_SoftClippZ(&vr[0],
                                         &vr[1],
                                         &vr[2]);
            ARX_DrawPrimitive_SoftClippZ(&vr[1],
                                         &vr[2],
                                         &vr[3]);
        }

        if (i < fSizeIntro)
        {
            vt[0].sx = vb[i+1].sx;
            vt[0].sy = vb[i+1].sy;
            vt[0].sz = vb[i+1].sz;
            vt[1].sx = vb[i].sx;
            vt[1].sy = vb[i].sy;
            vt[1].sz = vb[i].sz;
            vt[2].sx = vb[i+1].sx + (vb[i+1].sx - target.sx) * 2;
            vt[2].sy = vb[i+1].sy + (vb[i+1].sy - target.sy) * 2;
            vt[2].sz = vb[i+1].sz + (vb[i+1].sz - target.sz) * 2;
            vt[3].sx = vb[i].sx + (vb[i].sx - target.sx) * 2;
            vt[3].sy = vb[i].sy + (vb[i].sy - target.sy) * 2;
            vt[3].sz = vb[i].sz + (vb[i].sz - target.sz) * 2;

            vr[0].color = D3DRGB(tfRaysb[i] * fColorRays1[0],   tfRaysb[i] * fColorRays1[1],   tfRaysb[i] * fColorRays1[2]);
            vr[1].color = D3DRGB(tfRaysb[i+1] * fColorRays1[0], tfRaysb[i+1] * fColorRays1[1], tfRaysb[i+1] * fColorRays1[2]);
            vr[2].color = D3DRGB(tfRaysb[i] * fColorRays2[0],   tfRaysb[i] * fColorRays2[1],   tfRaysb[i] * fColorRays2[2]);
            vr[3].color = D3DRGB(tfRaysb[i+1] * fColorRays2[0], tfRaysb[i+1] * fColorRays2[1], tfRaysb[i+1] * fColorRays2[2]);

            EE_RT2(&vt[0], &vr[3]);
            EE_RT2(&vt[1], &vr[2]);
            EE_RT2(&vt[2], &vr[1]);
            EE_RT2(&vt[3], &vr[0]);
            ARX_DrawPrimitive_SoftClippZ(&vr[0],
                                         &vr[1],
                                         &vr[2]);
            ARX_DrawPrimitive_SoftClippZ(&vr[1],
                                         &vr[2],
                                         &vr[3]);
        }

    }
}
Ejemplo n.º 15
0
void DrawEERIEInter_ViewProjectTransform(EERIE_3DOBJ *eobj) {
	for(size_t i = 0 ; i < eobj->vertexlist.size(); i++) {
		EE_RTP(eobj->vertexlist3[i].v, eobj->vertexlist[i].vert);
	}
}
Ejemplo n.º 16
0
void DrawGrille(CinematicGrid * grille, int col, int fx, CinematicLight * light, Vec3f * posgrille, float angzgrille)
{
	int nb = grille->nbvertexs;
	Vec3f * v = grille->vertexs;
	TexturedVertex * d3dv = AllTLVertex;

	LocalPos = *posgrille;
	LocalSin = (float)sin(radians(angzgrille));
	LocalCos = (float)cos(radians(angzgrille));

	if ((fx & 0x0000FF00) == FX_DREAM)
	{
		if (light)
		{
			float * dream = DreamTable;

			while (nb--)
			{
				TexturedVertex vtemp;
				Vec3f t;
				t.x = v->x + *dream++;
				t.y = v->y + *dream++;
				t.z = v->z;
				TransformLocalVertex(&t, &vtemp);
				EE_RTP(&vtemp, d3dv);
				d3dv->color = CalculLight(light, d3dv->p.x, d3dv->p.y, col);
				d3dv->p.x = ADJUSTX(d3dv->p.x);
				d3dv->p.y = ADJUSTY(d3dv->p.y);
				v++;
				d3dv++;
			}
		}
		else
		{
			float * dream = DreamTable;

			while (nb--)
			{
				TexturedVertex vtemp;
				Vec3f t;
				t.x = v->x + *dream++;
				t.y = v->y + *dream++;
				t.z = v->z;
				TransformLocalVertex(&t, &vtemp);
				EE_RTP(&vtemp, d3dv);
				d3dv->p.x = ADJUSTX(d3dv->p.x);
				d3dv->p.y = ADJUSTY(d3dv->p.y);
				d3dv->color = col;
				v++;
				d3dv++;
			}
		}
	}
	else
	{
		if (light)
		{
			while (nb--)
			{
				TexturedVertex vtemp;
				TransformLocalVertex(v, &vtemp);
				EE_RTP(&vtemp, d3dv);
				d3dv->color = CalculLight(light, d3dv->p.x, d3dv->p.y, col);
				d3dv->p.x = ADJUSTX(d3dv->p.x);
				d3dv->p.y = ADJUSTY(d3dv->p.y);
				v++;
				d3dv++;
			}
		}
		else
		{
			while (nb--)
			{
				TexturedVertex vtemp;
				TransformLocalVertex(v, &vtemp);
				EE_RTP(&vtemp, d3dv);
				d3dv->p.x = ADJUSTX(d3dv->p.x);
				d3dv->p.y = ADJUSTY(d3dv->p.y);
				d3dv->color = col;
				v++;
				d3dv++;
			}
		}
	}

	C_UV* uvs = grille->uvs;

	for(std::vector<C_INDEXED>::iterator it = grille->mats.begin(); it != grille->mats.end(); ++it)
	{
		C_INDEXED* mat = &(*it);

		if (mat->tex)
			GRenderer->SetTexture(0, mat->tex);
		else
			GRenderer->ResetTexture(0);
		
		int	nb2 = mat->nbvertexs;
		while(nb2--) {
			AllTLVertex[uvs->indvertex].uv = uvs->uv;
			uvs++;
		}
		
		GRenderer->drawIndexed(Renderer::TriangleList, AllTLVertex, grille->nbvertexs,
		                       &grille->inds->i1 + mat->startind, mat->nbind);
	}
}
Ejemplo n.º 17
0
//-----------------------------------------------------------------------------
void CSummonCreature::RenderFissure()
{
    int i;
    float ff;
    TexturedVertex vt[4];
    TexturedVertex vr[4];
    TexturedVertex target;

    Vec3f etarget;
    etarget.x = fBetaRadCos;
    etarget.y = 0;
    etarget.z = fBetaRadSin;

    //-------------------------------------------------------------------------
    // computation des sommets
    float fTempCos, fTempSin;

    for (i = 0; i <= std::min(end, int(fSizeIntro)); i++)
    {
        if (i <= end * 0.5f)
        {
            ff = i / (end * 0.5f);
        }
        else
        {
            ff = 1.0f - ((i - (end + 1) * 0.5f) / (end * 0.5f));
        }

        fTempCos = ff * fBetaRadCos;
        fTempSin = ff * fBetaRadSin;

        va[i].p.x   = v1a[i].p.x   + sizeF * fTempCos;
        va[i].p.y   = v1a[i].p.y;
        va[i].p.z   = v1a[i].p.z   + sizeF * fTempSin;

        vb[i].p.x   = v1b[i].p.x   - sizeF * fTempCos;
        vb[i].p.y   = v1b[i].p.y;
        vb[i].p.z   = v1b[i].p.z   - sizeF * fTempSin;

        va[i].p.x += rnd() * 0.5f * fTempCos;
        va[i].p.z += rnd() * 0.5f * fTempSin;
        vb[i].p.x -= rnd() * 0.5f * fTempCos;
        vb[i].p.z -= rnd() * 0.5f * fTempSin;
    }

    //-------------------------------------------------------------------------
    // rendu de la fissure
    GRenderer->SetRenderState(Renderer::AlphaBlending, false);
    vr[0].color = vr[1].color = vr[2].color = vr[3].color = Color::black.toBGR();

    if (bIntro)
    {
        for (i = 0; i < std::min(end, (int)fSizeIntro); i++)
        {
            EE_RT2(&v1a[i], &vr[0]);
            EE_RT2(&v1b[i], &vr[1]);
            EE_RT2(&v1a[i+1], &vr[2]);
            EE_RT2(&v1b[i+1], &vr[3]);
            ARX_DrawPrimitive(&vr[0],
                              &vr[1],
                              &vr[2]);
            ARX_DrawPrimitive(&vr[1],
                              &vr[2],
                              &vr[3]);
        }
    }
    else
    {
        for (i = 0; i < std::min(end, (int)fSizeIntro); i++)
        {
            EE_RT2(&va[i], &vr[0]);
            EE_RT2(&vb[i], &vr[1]);
            EE_RT2(&va[i+1], &vr[2]);
            EE_RT2(&vb[i+1], &vr[3]);
            ARX_DrawPrimitive(&vr[0],
                              &vr[1],
                              &vr[2]);
            ARX_DrawPrimitive(&vr[1],
                              &vr[2],
                              &vr[3]);
        }
    }

    //-------------------------------------------------------------------------
    // rendu de la bordure
    GRenderer->SetRenderState(Renderer::AlphaBlending, true);
    vr[0].color = vr[1].color = Color::black.toBGR();
    vr[2].color = vr[3].color = fColorBorder.toBGR();

    for (i = 0; i < std::min(end, (int)fSizeIntro); i++)
    {
        vt[2].p.x = va[i].p.x   - (va[i].p.x - eSrc.x) * 0.2f;
        vt[2].p.y = va[i].p.y   - (va[i].p.y - eSrc.y) * 0.2f;
        vt[2].p.z = va[i].p.z   - (va[i].p.z - eSrc.z) * 0.2f;
        vt[3].p.x = va[i+1].p.x - (va[i+1].p.x - eSrc.x) * 0.2f;
        vt[3].p.y = va[i+1].p.y - (va[i+1].p.y - eSrc.y) * 0.2f;
        vt[3].p.z = va[i+1].p.z - (va[i+1].p.z - eSrc.z) * 0.2f;

        EE_RT2(&vt[3], &vr[0]);
        EE_RT2(&vt[2], &vr[1]);
        EE_RT2(&va[i+1], &vr[2]);
        EE_RT2(&va[i], &vr[3]);
        ARX_DrawPrimitive(&vr[0],
                          &vr[1],
                          &vr[2]);
        ARX_DrawPrimitive(&vr[1],
                          &vr[2],
                          &vr[3]);

        vt[2].p.x = vb[i].p.x   - (vb[i].p.x - eSrc.x) * 0.2f;
        vt[2].p.y = vb[i].p.y   - (vb[i].p.y - eSrc.y) * 0.2f;
        vt[2].p.z = vb[i].p.z   - (vb[i].p.z - eSrc.z) * 0.2f;
        vt[3].p.x = vb[i+1].p.x - (vb[i+1].p.x - eSrc.x) * 0.2f;
        vt[3].p.y = vb[i+1].p.y - (vb[i+1].p.y - eSrc.y) * 0.2f;
        vt[3].p.z = vb[i+1].p.z - (vb[i+1].p.z - eSrc.z) * 0.2f;

        EE_RT2(&vb[i], &vr[3]);
        EE_RT2(&vb[i+1], &vr[2]);
        EE_RT2(&vt[2], &vr[1]);
        EE_RT2(&vt[3], &vr[0]);
        ARX_DrawPrimitive(&vr[0],
                          &vr[1],
                          &vr[2]);
        ARX_DrawPrimitive(&vr[1],
                          &vr[2],
                          &vr[3]);

    }

    //-------------------------------------------------------------------------
    // rendu des faisceaux
    // blend additif ou mul
    // smooth sur les cotés ou pas ..
    // texture sympa avec glow au milieu ou uv wrap
    GRenderer->SetRenderState(Renderer::AlphaBlending, true);
    GRenderer->GetTextureStage(0)->SetWrapMode(TextureStage::WrapMirror);
    GRenderer->SetTexture(0, tex_light);

    target.p.x = eSrc.x + -fBetaRadSin * (1.5f * sizeF);
    target.p.y = eSrc.y;
    target.p.z = eSrc.z + fBetaRadCos * (1.5f * sizeF);

    EE_RTP(&vt[1], &vr[0]);
    vr[0].color = vr[1].color = fColorRays1.toBGR();
    vr[2].color = vr[3].color = fColorRays2.toBGR();

    vr[0].uv.x = fTexWrap;
    vr[0].uv.y = 1;
    vr[1].uv.x = 1.0f + fTexWrap;
    vr[1].uv.y = 1;
    vr[2].uv.x = fTexWrap;
    vr[2].uv.y = 0;
    vr[3].uv.x = 1.0f + fTexWrap;
    vr[3].uv.y = 0;

    for (i = 0; i < end - 1; i++)
    {
        if (i < fSizeIntro)
        {
            vt[0].p.x = va[i].p.x;
            vt[0].p.y = va[i].p.y;
            vt[0].p.z = va[i].p.z;
            vt[1].p.x = va[i+1].p.x;
            vt[1].p.y = va[i+1].p.y;
            vt[1].p.z = va[i+1].p.z;
            vt[2].p.x = va[i].p.x + (va[i].p.x - target.p.x) * 2;
            vt[2].p.y = va[i].p.y + (va[i].p.y - target.p.y) * 2;
            vt[2].p.z = va[i].p.z + (va[i].p.z - target.p.z) * 2;
            vt[3].p.x = va[i+1].p.x + (va[i+1].p.x - target.p.x) * 2;
            vt[3].p.y = va[i+1].p.y + (va[i+1].p.y - target.p.y) * 2;
            vt[3].p.z = va[i+1].p.z + (va[i+1].p.z - target.p.z) * 2;

            vr[0].color = (fColorRays1 * tfRaysa[i]).toBGR();
            vr[1].color = (fColorRays1 * tfRaysa[i + 1]).toBGR();
            vr[2].color = (fColorRays2 * tfRaysa[i]).toBGR();
            vr[3].color = (fColorRays2 * tfRaysa[i + 1]).toBGR();

            EE_RT2(&vt[0], &vr[3]);
            EE_RT2(&vt[1], &vr[2]);
            EE_RT2(&vt[2], &vr[1]);
            EE_RT2(&vt[3], &vr[0]);
            ARX_DrawPrimitive(&vr[0],
                              &vr[1],
                              &vr[2]);
            ARX_DrawPrimitive(&vr[1],
                              &vr[2],
                              &vr[3]);
        }

        if (i < fSizeIntro)
        {
            vt[0].p.x = vb[i+1].p.x;
            vt[0].p.y = vb[i+1].p.y;
            vt[0].p.z = vb[i+1].p.z;
            vt[1].p.x = vb[i].p.x;
            vt[1].p.y = vb[i].p.y;
            vt[1].p.z = vb[i].p.z;
            vt[2].p.x = vb[i+1].p.x + (vb[i+1].p.x - target.p.x) * 2;
            vt[2].p.y = vb[i+1].p.y + (vb[i+1].p.y - target.p.y) * 2;
            vt[2].p.z = vb[i+1].p.z + (vb[i+1].p.z - target.p.z) * 2;
            vt[3].p.x = vb[i].p.x + (vb[i].p.x - target.p.x) * 2;
            vt[3].p.y = vb[i].p.y + (vb[i].p.y - target.p.y) * 2;
            vt[3].p.z = vb[i].p.z + (vb[i].p.z - target.p.z) * 2;

            vr[0].color = (fColorRays1 * tfRaysb[i]).toBGR();
            vr[1].color = (fColorRays1 * tfRaysb[i + 1]).toBGR();
            vr[2].color = (fColorRays2 * tfRaysb[i]).toBGR();
            vr[3].color = (fColorRays2 * tfRaysb[i + 1]).toBGR();

            EE_RT2(&vt[0], &vr[3]);
            EE_RT2(&vt[1], &vr[2]);
            EE_RT2(&vt[2], &vr[1]);
            EE_RT2(&vt[3], &vr[0]);
            ARX_DrawPrimitive(&vr[0],
                              &vr[1],
                              &vr[2]);
            ARX_DrawPrimitive(&vr[1],
                              &vr[2],
                              &vr[3]);
        }

    }
}
//-----------------------------------------------------------------------------
float CExplosion::Render(LPDIRECT3DDEVICE7 device)
{
	if (this->key > 1) return 0;

	SETALPHABLEND(device, TRUE);
	SETZWRITE(device, FALSE);

	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);

	//calcul du disque
	D3DTLVERTEX d3dvs, *d3dv;
	EERIE_3D	* vertex;
	int			nb, col, col2;
	float		rin;

	switch (key)
	{
		case 0:
			rin = 255.f * scale;
			vertex = disquevertex;
			d3dv = disqued3d;
			nb = disquenbvertex >> 1;

			while (nb)
			{
				d3dvs.sx = pos.x + (vertex + 1)->x + ((vertex->x - (vertex + 1)->x) * scale);
				d3dvs.sy = pos.y;
				d3dvs.sz = pos.z + (vertex + 1)->z + ((vertex->z - (vertex + 1)->z) * scale);
				EE_RTP(&d3dvs, d3dv);
				d3dv->color = RGBA_MAKE(255, 200, 0, 255);
				vertex++;
				d3dv++;

				d3dvs.sx = pos.x + vertex->x;
				d3dvs.sy = pos.y;
				d3dvs.sz = pos.z + vertex->z;
				EE_RTP(&d3dvs, d3dv);

				if (!ARXPausedTimer) d3dv->color = RGBA_MAKE((int)(rin * rnd()), 0, 0, 255);

				vertex++;
				d3dv++;
				nb--;
			}

			if (rnd() > .25f)
			{
				int j = ARX_PARTICLES_GetFree();

				if ((j != -1) && (!ARXPausedTimer))
				{
					ParticleCount++;
					particle[j].exist = 1;
					particle[j].zdec = 0;

					float a = DEG2RAD(360.f * scale);
					float b = rin; 

					particle[j].ov.x		=	pos.x + b * EEcos(a);
					particle[j].ov.y		=	pos.y;
					particle[j].ov.z		=	pos.z + b * EEsin(a);
					particle[j].move.x		=	0.f;
					particle[j].move.y		=	rnd();
					particle[j].move.z		=	0.f;
					particle[j].siz			=	10.f + 10.f * rnd();
					particle[j].tolive		=	500 + (unsigned long)(float)(rnd() * 500.f);
					particle[j].scale.x		=	1.f;
					particle[j].scale.y		=	1.f;
					particle[j].scale.z		=	1.f;
					particle[j].timcreation	=	lARXTime;
					particle[j].tc			=	tp;
					particle[j].special		=	FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
					particle[j].fparam		=	0.0000001f;
					particle[j].r			=	1.f;
					particle[j].g			=	1.f;
					particle[j].b			=	1.f;
				}

				j = ARX_PARTICLES_GetFree();

				if ((j != -1) && (!ARXPausedTimer))
				{
					ParticleCount++;
					particle[j].exist = 1;
					particle[j].zdec = 0;

					float a = DEG2RAD(-360.f * scale);
					float b = this->rin;

					particle[j].ov.x	=	pos.x + b * EEcos(a);
					particle[j].ov.y	=	pos.y;
					particle[j].ov.z	=	pos.z + b * EEsin(a);
					particle[j].move.x	=	0.f;
					particle[j].move.y	=	rnd();
					particle[j].move.z	=	0.f;
					particle[j].siz		=	10.f + 10.f * rnd();
					particle[j].tolive	=	500 + (unsigned long)(float)(rnd() * 500.f);
					particle[j].scale.x	=	1.f;
					particle[j].scale.y	=	1.f;
					particle[j].scale.z	=	1.f;
					particle[j].timcreation	=	lARXTime;
					particle[j].tc		=	tp;
					particle[j].special	=	FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
					particle[j].fparam	=	0.0000001f;
					particle[j].r		=	1.f;
					particle[j].g		=	1.f;
					particle[j].b		=	1.f;
				}
			}

			if (rnd() > .1f)
			{
				int j = ARX_PARTICLES_GetFree();

				if ((j != -1) && (!ARXPausedTimer))
				{
					ParticleCount++;
					particle[j].exist = 1;
					particle[j].zdec = 0;

					float a = rnd() * 360.f; 
					float b = rin * rnd();

					particle[j].ov.x	=	pos.x + b * EEcos(a);
					particle[j].ov.y	=	pos.y + 70.f;
					particle[j].ov.z	=	pos.z + b * EEsin(a);
					particle[j].move.x	=	0.f;
					particle[j].move.y	=	-(5.f + 10.f * rnd());
					particle[j].move.z	=	0.f;
					particle[j].siz		=	10.f + 20.f * rnd();
					particle[j].tolive	=	1000 + (unsigned long)(float)(rnd() * 1000.f);
					particle[j].scale.x	=	1.f;
					particle[j].scale.y	=	1.f;
					particle[j].scale.z	=	1.f;
					particle[j].timcreation	=	lARXTime;
					particle[j].tc		=	tp2;
					particle[j].special	=	FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
					particle[j].fparam	=	0.0000001f;
					particle[j].r		=	1.f;
					particle[j].g		=	1.f;
					particle[j].b		=	1.f;
				}
			}

			break;
		case 1:
			D3DTLVERTEX d3dvs2;
			rin = 1.f + (puissance * scale);
			vertex = disquevertex;
			d3dv = disqued3d;
			nb = disquenbvertex >> 1;
			float a = 1.f - scale;
			col = RGBA_MAKE((int)(255.f * a), (int)(200.f * a), 0, 255);
			col2 = RGBA_MAKE((int)(255.f * a * rnd()), 0, 0, 0);

			while (nb--)
			{
				d3dvs.sx = pos.x + vertex->x * rin;
				d3dvs.sy = pos.y;
				d3dvs.sz = pos.z + vertex->z * rin;
				vertex++;
				d3dvs2.sx = pos.x + vertex->x * rin;
				d3dvs2.sy = pos.y;
				d3dvs2.sz = pos.z + vertex->z * rin;
				vertex++;

				if (tactif[nb] >= 0)
				{
					EERIE_3D pos, dir;
					pos.x = d3dvs2.sx;
					pos.y = d3dvs2.sy;
					pos.z = d3dvs2.sz;
					dir.x = d3dvs.sx;
					dir.y = d3dvs.sy;
					dir.z = d3dvs.sz;

					DynLight[tactif[nb]].pos.x = dir.x;
					DynLight[tactif[nb]].pos.y = dir.y;
					DynLight[tactif[nb]].pos.z = dir.z;
					DynLight[tactif[nb]].intensity = .7f + 2.f * rnd();

					Collision(nb, &pos, &dir);
					ExplosionAddParticule(nb, &d3dvs, tp);
				}

				EE_RTP(&d3dvs, d3dv);

				if (!ARXPausedTimer) d3dv->color = col;

				d3dv++;

				EE_RTP(&d3dvs2, d3dv);

				if (!ARXPausedTimer) d3dv->color = col2;

				d3dv++;
			}

			break;
	}

	//tracé du disque
	SETCULL(device, D3DCULL_NONE);
	device->SetTexture(0, NULL);
	device->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, disqued3d, disquenbvertex, (unsigned short *)disqueind, disquenbvertex + 2, 0);

	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
	SETALPHABLEND(device, FALSE);
	SETZWRITE(device, TRUE);

	return 0;
}
Ejemplo n.º 19
0
void ARX_PARTICLES_Update(EERIE_CAMERA * cam)  {
	
	ARX_PROFILE_FUNC();
	
	if(!ACTIVEBKG) {
		return;
	}
	
	if(ParticleCount == 0) {
		return;
	}
	
	const ArxInstant now = arxtime.now();
	
	long pcc = ParticleCount;
	
	for(size_t i = 0; i < MAX_PARTICLES && pcc > 0; i++) {

		PARTICLE_DEF * part = &particle[i];
		if(!part->exist) {
			continue;
		}

		long framediff = part->timcreation + part->tolive - now;
		long framediff2 = now - part->timcreation;
		
		if(framediff2 < long(part->delay)) {
			continue;
		}
		
		if(part->delay > 0) {
			part->timcreation += part->delay;
			part->delay=0;
			if((part->m_flags & DELAY_FOLLOW_SOURCE) && part->sourceionum != EntityHandle()
					&& entities[part->sourceionum]) {
				part->ov = *part->source;
				Entity * target = entities[part->sourceionum];
				Vec3f vector = (part->ov - target->pos) * Vec3f(1.f, 0.5f, 1.f);
				vector = glm::normalize(vector);
				part->move = vector * Vec3f(18.f, 5.f, 18.f) + randomVec(-0.5f, 0.5f);
				
			}
			continue;
		}
		
		if(!part->is2D) {

			EERIE_BKG_INFO * bkgData = getFastBackgroundData(part->ov.x, part->ov.z);

			if(!bkgData || !bkgData->treat) {
				part->exist = false;
				ParticleCount--;
				continue;
			}
		}
		
		if(framediff <= 0) {
			if((part->m_flags & FIRE_TO_SMOKE) && Random::getf() > 0.7f) {
				
				part->ov += part->move;
				part->tolive = part->tolive * 1.375f;
				part->m_flags &= ~FIRE_TO_SMOKE;
				part->tc = smokeparticle;
				part->scale = glm::abs(part->scale * 2.4f);
				part->rgb = Color3f::gray(.45f);
				part->move *= 0.5f;
				part->siz *= 1.f / 3;
				part->timcreation = now;
				
				framediff = part->tolive;
				
			} else {
				part->exist = false;
				ParticleCount--;
				continue;
			}
		}
		
		float val = (part->tolive - framediff) * 0.01f;
		
		Vec3f in = part->ov + part->move * val;
		Vec3f inn = in;
		
		if(part->m_flags & GRAVITY) {
			in.y = inn.y = inn.y + 1.47f * val * val;
		}
		
		float fd = float(framediff2) / float(part->tolive);
		float r = 1.f - fd;
		if(part->m_flags & FADE_IN_AND_OUT) {
			long t = part->tolive / 2;
			if(framediff2 <= t) {
				r = float(framediff2) / float(t);
			} else {
				r = 1.f - float(framediff2 - t) / float(t);
			}
		}
		
		if(!part->is2D) {
			
			Sphere sp;
			sp.origin = in;
			
			TexturedVertex out;
			EE_RTP(inn, out);
			
			if(out.rhw < 0 || out.p.z > cam->cdepth * fZFogEnd) {
				continue;
			}
			
			if(part->m_flags & SPLAT_GROUND) {
				float siz = part->siz + part->scale.x * fd;
				sp.radius = siz * 10.f;
				if(CheckAnythingInSphere(sp, EntityHandle_Player, CAS_NO_NPC_COL)) {
					if(Random::getf() < 0.9f) {
						Color3f rgb = part->rgb;
						PolyBoomAddSplat(sp, rgb, 0);
					}
					part->exist = false;
					ParticleCount--;
					continue;
				}
			}
			
			if(part->m_flags & SPLAT_WATER) {
				float siz = part->siz + part->scale.x * fd;
				sp.radius = siz * Random::getf(10.f, 30.f);
				if(CheckAnythingInSphere(sp, EntityHandle_Player, CAS_NO_NPC_COL)) {
					if(Random::getf() < 0.9f) {
						Color3f rgb = part->rgb * 0.5f;
						PolyBoomAddSplat(sp, rgb, 2);
					}
					part->exist = false;
					ParticleCount--;
					continue;
				}
			}
			
			if((part->m_flags & DISSIPATING) && out.p.z < 0.05f) {
				out.p.z *= 20.f;
				r *= out.p.z;
			}
		}
		
		if(r <= 0.f) {
			pcc--;
			continue;
		}
		
		if(part->m_flags & PARTICLE_GOLDRAIN) {
			float v = Random::getf(-0.1f, 0.1f);
			if(part->rgb.r + v <= 1.f && part->rgb.r + v > 0.f
				&& part->rgb.g + v <= 1.f && part->rgb.g + v > 0.f
				&& part->rgb.b + v <= 1.f && part->rgb.b + v > 0.f) {
				part->rgb = Color3f(part->rgb.r + v, part->rgb.g + v, part->rgb.b + v);
			}
		}
		
		Color color = (part->rgb * r).to<u8>();
		if(player.m_improve) {
			color.g = 0;
		}
		
		TextureContainer * tc = part->tc;
		if(tc == explo[0] && (part->m_flags & PARTICLE_ANIMATED)) {
			long animrange = part->cval2 - part->cval1;
			long num = long(float(framediff2) / float(part->tolive) * animrange);
			num = glm::clamp(num, long(part->cval1), long(part->cval2));
			tc = explo[num];
		}
		
		float siz = part->siz + part->scale.x * fd;

		RenderMaterial mat;
		mat.setTexture(tc);
		mat.setDepthTest(!(part->m_flags & PARTICLE_NOZBUFFER));
		
		if(part->m_flags & PARTICLE_SUB2) {
			mat.setBlendType(RenderMaterial::Subtractive2);
			color.a = glm::clamp(r * 1.5f, 0.f, 1.f) * 255;
		} else if(part->m_flags & SUBSTRACT) {
			mat.setBlendType(RenderMaterial::Subtractive);
		} else {
			mat.setBlendType(RenderMaterial::Additive);
		}
		
		if(part->m_flags & ROTATING) {
			if(!part->is2D) {
				float rott = MAKEANGLE(float(now + framediff2) * part->m_rotation);
				
				float temp = (part->zdec) ? 0.0001f : 2.f;
				float size = std::max(siz, 0.f);
				EERIEAddSprite(mat, in, size, color, temp, rott);
				
			}
		} else if(part->is2D) {
			
			float siz2 = part->siz + part->scale.y * fd;
			EERIEAddBitmap(mat, in, siz, siz2, tc, color);
			
		} else {
			
			float temp = (part->zdec) ? 0.0001f : 2.f;
			EERIEAddSprite(mat, in, siz, color, temp);
			
		}
		
		pcc--;
	}
}
Ejemplo n.º 20
0
// TODO copy-paste spell effect Fissure
void CSummonCreature::RenderFissure()
{
	int i;
	float ff;
	Vec3f vt[4];
	TexturedVertex vr[4];
	Vec3f target;

	Vec3f etarget;
	etarget.x = fBetaRadCos;
	etarget.y = 0;
	etarget.z = fBetaRadSin;
	
	RenderMaterial mat;
	mat.setCulling(Renderer::CullNone);
	mat.setDepthTest(false);
	mat.setWrapMode(TextureStage::WrapClamp);
	mat.setBlendType(RenderMaterial::Opaque);
	
	
	mat.setLayer(RenderMaterial::EffectForeground);

	//-------------------------------------------------------------------------
	// computation des sommets

	for(i = 0; i <= std::min(end, int(fSizeIntro)); i++) {
		if(i <= end * 0.5f)
			ff = i / (end * 0.5f);
		else
			ff = 1.0f - ((i - (end + 1) * 0.5f) / (end * 0.5f));

		float fTempCos = ff * fBetaRadCos;
		float fTempSin = ff * fBetaRadSin;

		va[i].x   = v1a[i].x   + sizeF * fTempCos;
		va[i].y   = v1a[i].y;
		va[i].z   = v1a[i].z   + sizeF * fTempSin;

		vb[i].x   = v1b[i].x   - sizeF * fTempCos;
		vb[i].y   = v1b[i].y;
		vb[i].z   = v1b[i].z   - sizeF * fTempSin;

		va[i].x += rnd() * 0.5f * fTempCos;
		va[i].z += rnd() * 0.5f * fTempSin;
		vb[i].x -= rnd() * 0.5f * fTempCos;
		vb[i].z -= rnd() * 0.5f * fTempSin;
	}

	//-------------------------------------------------------------------------
	// rendu de la fissure
	mat.setBlendType(RenderMaterial::Opaque);
	vr[0].color = vr[1].color = vr[2].color = vr[3].color = Color::black.toRGB();

	if(bIntro) {
		for(i = 0; i < std::min(end, (int)fSizeIntro); i++) {
			vr[0].p = EE_RT(v1a[i]);
			vr[1].p = EE_RT(v1b[i]);
			vr[2].p = EE_RT(v1a[i+1]);
			vr[3].p = EE_RT(v1b[i+1]);
			drawTriangle(mat, &vr[0]);
			drawTriangle(mat, &vr[1]);
		}
	} else {
		for(i = 0; i < std::min(end, (int)fSizeIntro); i++) {
			vr[0].p = EE_RT(va[i]);
			vr[1].p = EE_RT(vb[i]);
			vr[2].p = EE_RT(va[i+1]);
			vr[3].p = EE_RT(vb[i+1]);
			drawTriangle(mat, &vr[0]);
			drawTriangle(mat, &vr[1]);
		}
	}

	//-------------------------------------------------------------------------
	// rendu de la bordure
	mat.setBlendType(RenderMaterial::Additive);
	vr[0].color = vr[1].color = Color::black.toRGB();
	vr[2].color = vr[3].color = fColorBorder.toRGB();

	for(i = 0; i < std::min(end, (int)fSizeIntro); i++) {
		vt[2] = va[i] - (va[i] - eSrc) * 0.2f;
		vt[3] = va[i + 1] - (va[i + 1] - eSrc) * 0.2f;
		
		vr[0].p = EE_RT(vt[3]);
		vr[1].p = EE_RT(vt[2]);
		vr[2].p = EE_RT(va[i+1]);
		vr[3].p = EE_RT(va[i]);
		drawTriangle(mat, &vr[0]);
		drawTriangle(mat, &vr[1]);
		
		vt[2] = vb[i] - (vb[i] - eSrc) * 0.2f;
		vt[3] = vb[i + 1] - (vb[i + 1] - eSrc) * 0.2f;
		
		vr[3].p = EE_RT(vb[i]);
		vr[2].p = EE_RT(vb[i+1]);
		vr[1].p = EE_RT(vt[2]);
		vr[0].p = EE_RT(vt[3]);
		drawTriangle(mat, &vr[0]);
		drawTriangle(mat, &vr[1]);
	}

	//-------------------------------------------------------------------------
	// rendu des faisceaux
	// blend additif ou mul
	// smooth sur les cotés ou pas ..
	// texture sympa avec glow au milieu ou uv wrap
	mat.setWrapMode(TextureStage::WrapMirror);
	mat.setTexture(tex_light);

	target.x = eSrc.x + -fBetaRadSin * (1.5f * sizeF); 
	target.y = eSrc.y;
	target.z = eSrc.z + fBetaRadCos * (1.5f * sizeF); 

	EE_RTP(vt[1], &vr[0]);
	vr[0].color = vr[1].color = fColorRays1.toRGB();
	vr[2].color = vr[3].color = fColorRays2.toRGB();

	vr[0].uv.x = fTexWrap;
	vr[0].uv.y = 1;
	vr[1].uv.x = 1.0f + fTexWrap;
	vr[1].uv.y = 1;
	vr[2].uv.x = fTexWrap;
	vr[2].uv.y = 0;
	vr[3].uv.x = 1.0f + fTexWrap;
	vr[3].uv.y = 0;

	for(i = 0; i < end - 1; i++) {
		
		if(i < fSizeIntro) {
			vt[0] = va[i];
			vt[1] = va[i + 1];
			vt[2] = va[i] + (va[i] - target) * 2.f;
			vt[3] = va[i + 1] + (va[i + 1] - target) * 2.f;
			
			vr[0].color = (fColorRays1 * tfRaysa[i]).toRGB();
			vr[1].color = (fColorRays1 * tfRaysa[i + 1]).toRGB();
			vr[2].color = (fColorRays2 * tfRaysa[i]).toRGB();
			vr[3].color = (fColorRays2 * tfRaysa[i + 1]).toRGB();
			
			vr[3].p = EE_RT(vt[0]);
			vr[2].p = EE_RT(vt[1]);
			vr[1].p = EE_RT(vt[2]);
			vr[0].p = EE_RT(vt[3]);
			drawTriangle(mat, &vr[0]);
			drawTriangle(mat, &vr[1]);
		}
		
		if(i < fSizeIntro) {
			vt[0] = vb[i + 1];
			vt[1] = vb[i];
			vt[2] = vb[i + 1] + (vb[i + 1] - target) * 2.f;
			vt[3] = vb[i] + (vb[i] - target) * 2.f;
			
			vr[0].color = (fColorRays1 * tfRaysb[i]).toRGB();
			vr[1].color = (fColorRays1 * tfRaysb[i + 1]).toRGB();
			vr[2].color = (fColorRays2 * tfRaysb[i]).toRGB();
			vr[3].color = (fColorRays2 * tfRaysb[i + 1]).toRGB();
			
			vr[3].p = EE_RT(vt[0]);
			vr[2].p = EE_RT(vt[1]);
			vr[1].p = EE_RT(vt[2]);
			vr[0].p = EE_RT(vt[3]);
			drawTriangle(mat, &vr[0]);
			drawTriangle(mat, &vr[1]);
		}
	}
}
Ejemplo n.º 21
0
void AddFlare(const Vec2f & pos, float sm, short typ, Entity * io, bool bookDraw) {
	
	size_t oldest = 0;
	size_t i;
	for(i = 0; i < g_magicFlaresMax; i++) {
		if(!g_magicFlares[i].exist) {
			break;
		}
		if(g_magicFlares[i].tolive < g_magicFlares[oldest].tolive) {
			oldest = i;
		}
	}
	if(i >= g_magicFlaresMax) {
		removeFlare(g_magicFlares[oldest]);
		i = oldest;
	}

	MagicFlare & flare = g_magicFlares[i];
	flare.exist = 1;
	g_magicFlaresCount++;

	if(!bookDraw)
		flare.bDrawBitmap = 0;
	else
		flare.bDrawBitmap = 1;

	flare.io = io;
	if(io) {
		flare.flags = 1;
		io->flarecount++;
	} else {
		flare.flags = 0;
	}

	flare.pos.x = pos.x - Random::getf(0.f, 4.f);
	flare.pos.y = pos.y - Random::getf(0.f, 4.f) - 50.f;
	flare.tv.rhw = flare.v.rhw = 1.f;

	if(!bookDraw) {
		EERIE_CAMERA ka = *g_magicFlareCamera;
		ka.angle = Anglef(360.f, 360.f, 360.f) - ka.angle;
		EERIE_CAMERA * oldcam = ACTIVECAM;
		SetActiveCamera(&ka);
		PrepareCamera(&ka, g_size);
		flare.v.p += ka.orgTrans.pos;
		EE_RTP(flare.tv.p, flare.v);
		flare.v.p += ka.orgTrans.pos;

		float vx = -(flare.pos.x - subj.center.x) * 0.2173913f;
		float vy = (flare.pos.y - subj.center.y) * 0.1515151515151515f;
		if(io) {
			flare.v.p = io->pos;
			flare.v.p += angleToVectorXZ(io->angle.getYaw() + vx) * 100.f;
			flare.v.p.y += std::sin(glm::radians(MAKEANGLE(io->angle.getPitch() + vy))) * 100.f - 150.f;
		} else {
			flare.v.p.x = 1.0f  * float(pos.x - (g_size.width()  / 2)) * 156.f / (640.f * g_sizeRatio.y);
			flare.v.p.y = 0.75f * float(pos.y - (g_size.height() / 2)) * 156.f / (480.f * g_sizeRatio.y);
			flare.v.p.z = 75.f;
			ka = *oldcam;
			SetActiveCamera(&ka);
			PrepareCamera(&ka, g_size);
			float temp = (flare.v.p.y * -ka.orgTrans.xsin) + (flare.v.p.z * ka.orgTrans.xcos);
			flare.v.p.y = (flare.v.p.y * ka.orgTrans.xcos) - (-flare.v.p.z * ka.orgTrans.xsin);
			flare.v.p.z = (temp * ka.orgTrans.ycos) - (-flare.v.p.x * ka.orgTrans.ysin);
			flare.v.p.x = (temp * -ka.orgTrans.ysin) + (flare.v.p.x * ka.orgTrans.ycos);
			flare.v.p += oldcam->orgTrans.pos;
		}
		flare.tv.p = flare.v.p;
		SetActiveCamera(oldcam);
		PrepareCamera(oldcam, g_size);
	} else {
		flare.tv.p = Vec3f(flare.pos.x, flare.pos.y, 0.001f);
	}

	switch(g_magicFlareCurrentColor) {
		case 0: {
			flare.rgb = Color3f(.4f, 0.f, .4f) + Color3f(2.f/3, 2.f/3, 2.f/3) * randomColor3f();
			break;
		}
		case 1: {
			flare.rgb = Color3f(.5f, .5f, 0.f) + Color3f(.625f, .625f, .55f) * randomColor3f();
			break;
		}
		case 2: {
			flare.rgb = Color3f(.4f, 0.f, 0.f) + Color3f(2.f/3, .55f, .55f) * randomColor3f();
			break;
		}
	}
	
	static const float FLARE_MUL = 2.f;
	
	if(typ == -1) {
		float zz = eeMousePressed1() ? 0.29f : ((sm > 0.5f) ? Random::getf() : 1.f);
		if(zz < 0.2f) {
			flare.type = 2;
			flare.size = Random::getf(42.f, 84.f);
			flare.tolive = Random::getf(800.f, 1600.f) * FLARE_MUL;
		} else if(zz < 0.5f) {
			flare.type = 3;
			flare.size = Random::getf(16.f, 68.f);
			flare.tolive = Random::getf(800.f, 1600.f) * FLARE_MUL;
		} else {
			flare.type = 1;
			flare.size = Random::getf(32.f, 56.f) * sm;
			flare.tolive = Random::getf(1700.f, 2200.f) * FLARE_MUL;
		}
	} else {
		flare.type = (Random::getf() > 0.8f) ? 1 : 4;
		flare.size = Random::getf(64.f, 102.f) * sm;
		flare.tolive = Random::getf(1700.f, 2200.f) * FLARE_MUL;
	}

	flare.dynlight = LightHandle();

	for(unsigned int kk = 0; kk < 3; kk++) {

		if(Random::getf() < 0.5f) {
			continue;
		}

		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}

		if(!bookDraw) {
			pd->m_flags = FADE_IN_AND_OUT | ROTATING | DISSIPATING;
			if(!io) {
				pd->m_flags |= PARTICLE_NOZBUFFER;
			}
		} else {
			pd->m_flags = FADE_IN_AND_OUT;
		}

		pd->ov = flare.v.p + randomVec(-5.f, 5.f);
		pd->move = Vec3f(0.f, 5.f, 0.f);
		pd->scale = Vec3f(-2.f);
		pd->tolive = 1300 + kk * 100 + Random::getu(0, 800);
		pd->tc = fire2;
		if(kk == 1) {
			pd->move.y = 4.f;
			pd->siz = 1.5f;
		} else {
			pd->siz = Random::getf(1.f, 2.f);
		}
		pd->rgb = Color3f(flare.rgb.r * (2.f/3), flare.rgb.g * (2.f/3), flare.rgb.b * (2.f/3));
		pd->m_rotation = 1.2f;

		if(bookDraw)
			pd->is2D = true;
	}
}