コード例 #1
0
static void Cedric_AnimateDrawEntityRender(EERIE_3DOBJ * eobj, const Vec3f & pos,
                                           Entity * io, float invisibility) {
	
	Skeleton *obj = eobj->m_skeleton;
	
	if(!obj)
		return;
	
	ColorMod colorMod;
	colorMod.updateFromEntity(io);
	
	/* Get nearest lights */
	Vec3f tv = pos;
	
	if(io && io->obj->fastaccess.head_group_origin != ObjVertHandle()) {
		tv.y = io->obj->vertexlist3[io->obj->fastaccess.head_group_origin.handleData()].v.y + 10;
	} else {
		tv.y -= 90.f;
	}
	
	ShaderLight lights[llightsSize];
	int lightsCount;
	UpdateLlights(lights, lightsCount, tv, false);
	
	Cedric_ApplyLighting(lights, lightsCount, eobj, obj, colorMod);
	
	Cedric_RenderObject(eobj, obj, io, pos, invisibility);
	
	// Now we can render Linked Objects
	for(size_t k = 0; k < eobj->linked.size(); k++) {
		const EERIE_LINKED & link = eobj->linked[k];
		
		if(link.lgroup == ObjVertGroup() || !link.obj)
			continue;
		
		// specific check to avoid drawing player weapon on its back when in subjective view
		if(io == entities.player() &&
			link.lidx == entities.player()->obj->fastaccess.weapon_attach &&
			!EXTERNALVIEW
		) {
			continue;
		}
		
		TransformInfo t(
			actionPointPosition(eobj, link.lidx),
			eobj->m_skeleton->bones[link.lgroup.handleData()].anim.quat,
			link.io ? link.io->scale : 1.f,
			link.obj->vertexlist[link.lidx2.handleData()].v - link.obj->vertexlist[link.obj->origin].v);
		
		DrawEERIEInter(link.obj, t, link.io, true, invisibility);
	}
}
コード例 #2
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);
		}
	}