Пример #1
0
void AddFixedObjectHalo(const EERIE_FACE & face, const TransformInfo & t, const Entity * io, TexturedVertex * tvList, const EERIE_3DOBJ * eobj)
{
	float mdist=ACTIVECAM->cdepth;
	float ddist = mdist-fdist(t.pos, ACTIVECAM->orgTrans.pos);
	ddist = ddist/mdist;
	ddist = std::pow(ddist, 6);

	ddist = clamp(ddist, 0.25f, 0.9f);

	float tot=0;
	float _ffr[3];

	for(long o = 0; o < 3; o++) {
		Vec3f temporary3D;
		temporary3D = t.rotation * eobj->vertexlist[face.vid[o]].norm;

		float power = 255.f-(float)EEfabs(255.f*(temporary3D.z)*( 1.0f / 2 ));

		power = clamp(power, 0.f, 255.f);

		tot += power;
		_ffr[o] = power;

		u8 lfr = io->halo.color.r * power;
		u8 lfg = io->halo.color.g * power;
		u8 lfb = io->halo.color.b * power;
		tvList[o].color = ((0xFF << 24) | (lfr << 16) | (lfg << 8) | (lfb));
	}

	if(tot > 150.f) {
		long first;
		long second;
		long third;

		if(_ffr[0] >= _ffr[1] && _ffr[1] >= _ffr[2]) {
			first = 0;
			second = 1;
			third = 2;
		} else if(_ffr[0] >= _ffr[2] && _ffr[2] >= _ffr[1]) {
			first = 0;
			second = 2;
			third = 1;
		} else if(_ffr[1] >= _ffr[0] && _ffr[0] >= _ffr[2]) {
			first = 1;
			second = 0;
			third = 2;
		} else if(_ffr[1] >= _ffr[2] && _ffr[2] >= _ffr[0]) {
			first = 1;
			second = 2;
			third = 0;
		} else if(_ffr[2] >= _ffr[0] && _ffr[0] >= _ffr[1]) {
			first = 2;
			second = 0;
			third = 1;
		} else {
			first = 2;
			second = 1;
			third = 0;
		}

		if(_ffr[first] > 70.f && _ffr[second] > 60.f) {
			TexturedVertex vert[4];

			vert[0] = tvList[first];
			vert[1] = tvList[first];
			vert[2] = tvList[second];
			vert[3] = tvList[second];

			float siz = ddist * (io->halo.radius * 1.5f * (EEsin(arxtime.get_frame_time() * .01f) * .1f + .7f)) * .6f;

			Vec3f vect1;
			vect1.x = tvList[first].p.x - tvList[third].p.x;
			vect1.y = tvList[first].p.y - tvList[third].p.y;
			float len1 = 1.f / ffsqrt(vect1.x * vect1.x + vect1.y * vect1.y);

			if(vect1.x < 0.f)
				len1 *= 1.2f;

			vect1.x *= len1;
			vect1.y *= len1;

			Vec3f vect2;
			vect2.x = tvList[second].p.x - tvList[third].p.x;
			vect2.y = tvList[second].p.y - tvList[third].p.y;
			float len2 = 1.f / ffsqrt(vect2.x * vect2.x + vect2.y * vect2.y);

			if(vect2.x < 0.f)
				len2 *= 1.2f;

			vect2.x *= len2;
			vect2.y *= len2;

			vert[1].p.x += (vect1.x + 0.2f - rnd() * 0.1f) * siz;
			vert[1].p.y += (vect1.y + 0.2f - rnd() * 0.1f) * siz;
			vert[1].color = 0xFF000000;

			vert[0].p.z += 0.0001f;
			vert[3].p.z += 0.0001f;
			vert[1].rhw *= .8f;
			vert[2].rhw *= .8f;

			vert[2].p.x += (vect2.x + 0.2f - rnd() * 0.1f) * siz;
			vert[2].p.y += (vect2.y + 0.2f - rnd() * 0.1f) * siz;

			if(io->halo.flags & HALO_NEGATIVE)
				vert[2].color = 0x00000000;
			else
				vert[2].color = 0xFF000000;

			Halo_AddVertices(vert);
		}
	}
}
Пример #2
0
// TODO copy-paste halo
static void AddAnimatedObjectHalo(HaloInfo & haloInfo, const unsigned short * paf,
                                  float invisibility, EERIE_3DOBJ * eobj, Entity * io,
                                  TexturedVertex * tvList) {
	
	IO_HALO * curhalo = NULL;

	for(size_t h = 0; h < haloInfo.size; h++) {
		const HaloRenderInfo & entry = haloInfo.entries[h];
		if(entry.selection == ObjSelection() || IsInSelection(eobj, paf[0], entry.selection)) {
			curhalo = entry.halo;
			break;
		}
	}

	if(!curhalo)
		return;

	float tot = 0;
	float _ffr[3];
	ColorRGBA colors[3];

	for(size_t o = 0; o < 3; o++) {
		float tttz	= glm::abs(eobj->vertexlist3[paf[o]].norm.z) * ( 1.0f / 2 );
		float power = 255.f - (float)(255.f * tttz);
		power *= (1.f - invisibility);

		power = glm::clamp(power, 0.f, 255.f);

		tot += power;
		_ffr[o] = power;

		u8 lfr = curhalo->color.r * power;
		u8 lfg = curhalo->color.g * power;
		u8 lfb = curhalo->color.b * power;
		colors[o] = Color(lfr, lfg, lfb, 255).toRGBA();
	}

	if(tot > 260) {
		long first;
		long second;
		long third;

		if(_ffr[0] >= _ffr[1] && _ffr[1] >= _ffr[2]) {
			first = 0;
			second = 1;
			third = 2;
		} else if(_ffr[0] >= _ffr[2] && _ffr[2] >= _ffr[1]) {
			first = 0;
			second = 2;
			third = 1;
		} else if(_ffr[1] >= _ffr[0] && _ffr[0] >= _ffr[2]) {
			first = 1;
			second = 0;
			third = 2;
		} else if(_ffr[1] >= _ffr[2] && _ffr[2] >= _ffr[0]) {
			first = 1;
			second = 2;
			third = 0;
		} else if(_ffr[2] >= _ffr[0] && _ffr[0] >= _ffr[1]) {
			first = 2;
			second = 0;
			third = 1;
		} else {
			first = 2;
			second = 1;
			third = 0;
		}

		if(_ffr[first] > 150.f && _ffr[second] > 110.f) {
			TexturedVertex vert[4];

			vert[0] = tvList[first];
			vert[1] = tvList[first];
			vert[2] = tvList[second];
			vert[3] = tvList[second];

			vert[0].color = colors[first];
			vert[1].color = colors[first];
			vert[2].color = colors[second];
			vert[3].color = colors[second];

			float siz = haloInfo.ddist * (curhalo->radius * (std::sin(arxtime.get_frame_time() * .01f) * .1f + 1.f)) * .6f;

			if(io == entities.player() && haloInfo.ddist > 0.8f && !EXTERNALVIEW)
				siz *= 1.5f;

			Vec3f vect1;
			vect1.x = tvList[first].p.x - tvList[third].p.x;
			vect1.y = tvList[first].p.y - tvList[third].p.y;
			float len1 = 2.f / ffsqrt(vect1.x * vect1.x + vect1.y * vect1.y);

			if(vect1.x < 0.f)
				len1 *= 1.2f;

			vect1.x *= len1;
			vect1.y *= len1;

			Vec3f vect2;
			vect2.x = tvList[second].p.x - tvList[third].p.x;
			vect2.y = tvList[second].p.y - tvList[third].p.y;
			float len2 = 1.f / ffsqrt(vect2.x * vect2.x + vect2.y * vect2.y);

			if(vect2.x < 0.f)
				len2 *= 1.2f;

			vect2.x *= len2;
			vect2.y *= len2;

			vert[1].p.x += (vect1.x + Random::getf(0.1f, 0.2f)) * siz;
			vert[1].p.y += (vect1.y + Random::getf(0.1f, 0.2f)) * siz;
			vert[1].color = Color(0, 0, 0, 255).toRGBA();

			float valll;
			valll = 0.005f + (glm::abs(tvList[first].p.z) - glm::abs(tvList[third].p.z))
						   + (glm::abs(tvList[second].p.z) - glm::abs(tvList[third].p.z));
			valll = 0.0001f + valll * ( 1.0f / 10 );

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

			vert[1].p.z	+= valll;
			vert[2].p.z	+= valll;

			vert[0].p.z	+= 0.0001f;
			vert[3].p.z	+= 0.0001f;//*( 1.0f / 2 );
			vert[1].rhw	*= .98f;
			vert[2].rhw	*= .98f;
			vert[0].rhw	*= .98f;
			vert[3].rhw	*= .98f;

			vert[2].p.x += (vect2.x + Random::getf(0.1f, 0.2f)) * siz;
			vert[2].p.y += (vect2.y + Random::getf(0.1f, 0.2f)) * siz;

			vert[1].p.z = (vert[1].p.z + haloInfo.MAX_ZEDE) * ( 1.0f / 2 );
			vert[2].p.z = (vert[2].p.z + haloInfo.MAX_ZEDE) * ( 1.0f / 2 );

			if(curhalo->flags & HALO_NEGATIVE)
				vert[2].color = Color(0, 0, 0, 0).toRGBA();
			else
				vert[2].color = Color(0, 0, 0, 255).toRGBA();

			Halo_AddVertices(vert);
		}
	}
}