コード例 #1
0
void DrawEERIEInter_Render(EERIE_3DOBJ *eobj, const TransformInfo &t, Entity *io, float invisibility) {

	ColorMod colorMod;
	colorMod.updateFromEntity(io, !io);

	Vec3f tv = t.pos;

	if(io && (io->ioflags & IO_ITEM))
		tv.y -= 60.f;
	else
		tv.y -= 90.f;

	UpdateLlights(tv, false);

	for(size_t i = 0; i < eobj->facelist.size(); i++) {
		const EERIE_FACE & face = eobj->facelist[i];

		if(CullFace(eobj, face))
			continue;

		if(face.texid < 0)
			continue;

		TextureContainer *pTex = eobj->texturecontainer[face.texid];
		if(!pTex)
			continue;

		float fTransp = 0.f;
		TexturedVertex *tvList = GetNewVertexList(pTex, face, invisibility, fTransp);

		for(size_t n = 0; n < 3; n++) {

			if(io && (io->ioflags & IO_ANGULAR)) {
				const Vec3f & position = eobj->vertexlist3[face.vid[n]].v;
				const Vec3f & normal = face.norm;

				eobj->vertexlist3[face.vid[n]].vert.color = ApplyLight(&t.rotation, position, normal, colorMod, 0.5f);
			} else {
				Vec3f & position = eobj->vertexlist3[face.vid[n]].v;
				Vec3f & normal = eobj->vertexlist[face.vid[n]].norm;

				eobj->vertexlist3[face.vid[n]].vert.color = ApplyLight(&t.rotation, position, normal, colorMod);
			}

			tvList[n] = eobj->vertexlist[face.vid[n]].vert;
			tvList[n].uv.x = face.u[n];
			tvList[n].uv.y = face.v[n];

			// Treat WATER Polys (modify UVs)
			if(face.facetype & POLY_WATER) {
				tvList[n].uv += getWaterFxUvOffset(eobj->vertexlist[face.vid[n]].v, 0.3f);
			}

			if(face.facetype & POLY_GLOW) {
				// unaffected by light
				tvList[n].color = 0xffffffff;
			} else {
				// Normal Illuminations
				tvList[n].color = eobj->vertexlist3[face.vid[n]].vert.color;
			}

			// TODO copy-paste
			if(io && Project.improve) {
				long lr=(tvList[n].color>>16) & 255;
				float ffr=(float)(lr);

				float dd = tvList[n].rhw;

				dd = clamp(dd, 0.f, 1.f);

				Vec3f & norm = eobj->vertexlist[face.vid[n]].norm;

				float fb=((1.f-dd)*6.f + (EEfabs(norm.x) + EEfabs(norm.y))) * 0.125f;
				float fr=((.6f-dd)*6.f + (EEfabs(norm.z) + EEfabs(norm.y))) * 0.125f;

				if(fr < 0.f)
					fr = 0.f;
				else
					fr = std::max(ffr, fr * 255.f);

				fr=std::min(fr,255.f);
				fb*=255.f;
				fb=std::min(fb,255.f);
				u8 lfr = fr;
				u8 lfb = fb;
				u8 lfg = 0x1E;
				tvList[n].color = (0xff000000L | (lfr << 16) | (lfg << 8) | (lfb));
			}

			// Transparent poly: storing info to draw later
			if((face.facetype & POLY_TRANS) || invisibility > 0.f) {
				tvList[n].color = Color::gray(fTransp).toBGR();
			}
		}

		// HALO HANDLING START
		if(io && (io->halo.flags & HALO_ACTIVE)) {
			AddFixedObjectHalo(face, t, io, tvList, eobj);
		}
	}
コード例 #2
0
static void Cedric_RenderObject(EERIE_3DOBJ * eobj, Skeleton * obj, Entity * io, const Vec3f & pos, float invisibility) {

	if(invisibility == 1.f)
		return;

	Entity *use_io = io;

	if(!io && IN_BOOK_DRAW && eobj == entities.player()->obj)
		use_io = entities.player();

	HaloInfo haloInfo;
	if(use_io) {
		if(use_io == entities.player()) {
			pushSlotHalo(haloInfo, EQUIP_SLOT_HELMET,   eobj->fastaccess.sel_head);
			pushSlotHalo(haloInfo, EQUIP_SLOT_ARMOR,    eobj->fastaccess.sel_chest);
			pushSlotHalo(haloInfo, EQUIP_SLOT_LEGGINGS, eobj->fastaccess.sel_leggings);
		}
	
		if(use_io->halo.flags & HALO_ACTIVE) {
			haloInfo.push(HaloRenderInfo(&use_io->halo));
		}
		
		if(haloInfo.size > 0) {
			PrepareAnimatedObjectHalo(haloInfo, pos, obj, eobj);
		}
	}

	bool glow = false;
	ColorRGBA glowColor;
	if(io && (io->sfx_flag & SFX_TYPE_YLSIDE_DEATH) && io->show != SHOW_FLAG_TELEPORTING) {
		const ArxDuration elapsed = arxtime.now() - io->sfx_time;
		if(elapsed >= ArxDurationMs(3000) && elapsed < ArxDurationMs(6000)) {
			float ratio = toMs(elapsed - ArxDurationMs(3000)) * (1.0f / 3000);
			glowColor = Color::gray(ratio).toRGB();
			glow = true;
		}
	}
	
	for(size_t i = 0; i < eobj->facelist.size(); i++) {
		const EERIE_FACE & face = eobj->facelist[i];

		if((face.facetype & POLY_HIDE) && !IN_BOOK_DRAW)
			continue;

		if(CullFace(eobj, face))
			continue;

		if(face.texid < 0)
			continue;

		TextureContainer *pTex = eobj->texturecontainer[face.texid];
		if(!pTex)
			continue;

		float fTransp = 0.f;

		TexturedVertex *tvList = GetNewVertexList(&pTex->m_modelBatch, face, invisibility, fTransp);

		for(size_t n = 0; n < 3; n++) {
			tvList[n].p     = eobj->vertexlist3[face.vid[n]].vert.p;
			tvList[n].rhw   = eobj->vertexlist3[face.vid[n]].vert.rhw;
			tvList[n].color = eobj->vertexlist3[face.vid[n]].vert.color;
			tvList[n].uv.x  = face.u[n];
			tvList[n].uv.y  = face.v[n];
		}

		if((face.facetype & POLY_TRANS) || invisibility > 0.f) {
			tvList[0].color = tvList[1].color = tvList[2].color = Color::gray(fTransp).toRGB();
		}

		if(haloInfo.size) {
			AddAnimatedObjectHalo(haloInfo, face.vid, invisibility, eobj, io, tvList);
		}
		
		if(glow) {
			TexturedVertex * tv2 = PushVertexInTable(&TexSpecialColor.m_modelBatch, BatchBucket_Opaque);
			std::copy(tvList, tvList + 3, tv2);
			tv2[0].color = tv2[1].color = tv2[2].color = glowColor;
		}
	}
}