Example #1
0
/*
================
R_AliasPrepareUnclippedPoints
================
*/
void R_AliasPrepareUnclippedPoints (void)
{
	stvert_t	*pstverts;
	finalvert_t	*fv;

	pstverts = (stvert_t *)((byte *)paliashdr + paliashdr->stverts);
	r_anumverts = pmdl->numverts;
// FIXME: just use pfinalverts directly?
	fv = pfinalverts;
#ifdef INTERPOL7
	R_AliasTransformAndProjectFinalVertsLerp (fv, pstverts);
#else
	R_AliasTransformAndProjectFinalVerts (fv, pstverts);
#endif

	if (r_affinetridesc.drawtype)
		D_PolysetDrawFinalVerts (fv, r_anumverts);

	r_affinetridesc.pfinalverts = pfinalverts;
	r_affinetridesc.ptriangles = (mtriangle_t *)
			((byte *)paliashdr + paliashdr->triangles);
	r_affinetridesc.numtriangles = pmdl->numtris;

	D_PolysetDraw ();
}
Example #2
0
/*
================
R_AliasPrepareUnclippedPoints
================
*/
void R_AliasPrepareUnclippedPoints (void)
{
	stvert_t	*pstverts;
	finalvert_t	*fv;

	GpError("R_AliasPrepareUnliccpedPoints A",12);

	pstverts = (stvert_t *)((byte *)paliashdr + paliashdr->stverts);
	r_anumverts = pmdl->numverts;
// FIXME: just use pfinalverts directly?
	fv = pfinalverts;

	GpError("R_AliasPrepareUnliccpedPoints B",12);
	R_AliasTransformAndProjectFinalVerts (fv, pstverts);

	if (r_affinetridesc.drawtype){
		GpError("R_AliasPrepareUnliccpedPoints B",13);
		D_PolysetDrawFinalVerts (fv, r_anumverts);
	}

	r_affinetridesc.pfinalverts = pfinalverts;
	r_affinetridesc.ptriangles = (mtriangle_t *)
			((byte *)paliashdr + paliashdr->triangles);
	r_affinetridesc.numtriangles = pmdl->numtris;

	GpError("R_AliasPrepareUnliccpedPoints C",13);
	D_PolysetDraw ();
	GpError("R_AliasPrepareUnliccpedPoints end",13);
}
Example #3
0
static void
R_IQMPreparePoints (iqm_t *iqm, swiqm_t *sw, iqmframe_t *frame)
{
	finalvert_t *fv = pfinalverts;
	auxvert_t  *av = pauxverts;
	int         i;
	uint32_t    j;
	finalvert_t *pfv[3];

	for (i = 0; i < iqm->num_verts; i++, fv++, av++) {
		byte       *vert = iqm->vertices + i * iqm->stride;
		uint32_t    bind = *(uint32_t *) (vert + sw->bindices->offset);
		vec_t      *mat = (vec_t *) &frame[bind];
		float      *position = (float *) (vert + sw->position->offset);
		float      *normal = (float *) (vert + sw->normal->offset);
		int32_t    *texcoord = (int32_t *) (vert + sw->texcoord->offset);
		vec3_t      tv, tn;
		Mat4MultVec (mat, position, tv);
		Mat4as3MultVec (mat, normal, tn);
		av->fv[0] = DotProduct (tv, aliastransform[0]) + aliastransform[0][3];
		av->fv[1] = DotProduct (tv, aliastransform[1]) + aliastransform[1][3];
		av->fv[2] = DotProduct (tv, aliastransform[2]) + aliastransform[2][3];
		fv->v[2] = texcoord[0];
		fv->v[3] = texcoord[1];
		fv->flags = 0;
		fv->v[4] = calc_light (tn);
		R_AliasClipAndProjectFinalVert (fv, av);
	}

	for (i = 0; i < iqm->num_meshes; i++) {
		iqmmesh    *mesh = &iqm->meshes[i];
		mtriangle_t *mtri;

		iqm_setup_skin (sw, i);

		mtri = (mtriangle_t *) iqm->elements + mesh->first_triangle;
		r_affinetridesc.numtriangles = 1;
		for (j = 0; j < mesh->num_triangles; j++, mtri++) {
			pfv[0] = &pfinalverts[mtri->vertindex[0]];
			pfv[1] = &pfinalverts[mtri->vertindex[1]];
			pfv[2] = &pfinalverts[mtri->vertindex[2]];

			if (pfv[0]->flags & pfv[1]->flags & pfv[2]->flags
				& (ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP))
				continue;					// completely clipped

			if (!((pfv[0]->flags | pfv[1]->flags | pfv[2]->flags)
				  & (ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP))) {// totally unclipped
				r_affinetridesc.pfinalverts = pfinalverts;
				r_affinetridesc.ptriangles = mtri;
				D_PolysetDraw ();
			} else {						// partially clipped
				R_AliasClipTriangle (mtri);
			}
		}
	}
}
Example #4
0
/*
	R_AliasPreparePoints

	General clipped case
*/
static void
R_AliasPreparePoints (void)
{
	int         i;
	stvert_t   *pstverts;
	finalvert_t *fv;
	auxvert_t  *av;
	mtriangle_t *ptri;
	finalvert_t *pfv[3];

	pstverts = (stvert_t *) ((byte *) paliashdr + paliashdr->stverts);
	r_anumverts = pmdl->numverts;
	fv = pfinalverts;
	av = pauxverts;

	if (pmdl->ident == HEADER_MDL16) {
		for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
				 pstverts++) {
			R_AliasTransformFinalVert16 (av, r_apverts);
			R_AliasTransformFinalVert (fv, r_apverts, pstverts);
			R_AliasClipAndProjectFinalVert (fv, av);
		}
	} else {
		for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
				 pstverts++) {
			R_AliasTransformFinalVert8 (av, r_apverts);
			R_AliasTransformFinalVert (fv, r_apverts, pstverts);
			R_AliasClipAndProjectFinalVert (fv, av);
		}
	}

	// clip and draw all triangles
	r_affinetridesc.numtriangles = 1;

	ptri = (mtriangle_t *) ((byte *) paliashdr + paliashdr->triangles);
	for (i = 0; i < pmdl->numtris; i++, ptri++) {
		pfv[0] = &pfinalverts[ptri->vertindex[0]];
		pfv[1] = &pfinalverts[ptri->vertindex[1]];
		pfv[2] = &pfinalverts[ptri->vertindex[2]];

		if (pfv[0]->flags & pfv[1]->flags & pfv[2]->flags
			& (ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP))
			continue;					// completely clipped

		if (!((pfv[0]->flags | pfv[1]->flags | pfv[2]->flags)
			  & (ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP))) {	// totally unclipped
			r_affinetridesc.pfinalverts = pfinalverts;
			r_affinetridesc.ptriangles = ptri;
			D_PolysetDraw ();
		} else {						// partially clipped
			R_AliasClipTriangle (ptri);
		}
	}
}
Example #5
0
void R_AliasPrepareUnclippedPointsFPM (void)
{
	stvert_t	*pstverts;
	finalvert_t	*fv;

	pstverts = (stvert_t *)((byte *)paliashdr + paliashdr->stverts);
	r_anumverts = pmdlFPM->numverts;
// FIXME: just use pfinalverts directly?
	fv = pfinalverts;

	R_AliasTransformAndProjectFinalVertsFPM (fv, pstverts);

	if (r_affinetridesc.drawtype)
	  //		D_PolysetDrawFinalVertsFPM (fv, r_anumverts); // FPM doesn't exist
		D_PolysetDrawFinalVerts (fv, r_anumverts);

	r_affinetridesc.pfinalverts = pfinalverts;
	r_affinetridesc.ptriangles = (mtriangle_t *)
			((byte *)paliashdr + paliashdr->triangles);
	r_affinetridesc.numtriangles = pmdlFPM->numtris;

	D_PolysetDraw ();
}
Example #6
0
static void
R_IQMPrepareUnclippedPoints (iqm_t *iqm, swiqm_t *sw, iqmframe_t *frame)
{
	int         i;

	R_IQMTransformAndProjectFinalVerts (iqm, sw, frame);

	if (r_affinetridesc.drawtype)
		D_PolysetDrawFinalVerts (pfinalverts, iqm->num_verts);

	r_affinetridesc.pfinalverts = pfinalverts;
	for (i = 0; i < iqm->num_meshes; i++) {
		iqmmesh    *mesh = &iqm->meshes[i];
		uint16_t   *tris;

		iqm_setup_skin (sw, i);

		tris = iqm->elements + mesh->first_triangle;
		r_affinetridesc.ptriangles = (mtriangle_t *) tris;
		r_affinetridesc.numtriangles = mesh->num_triangles;
		D_PolysetDraw ();
	}
}
Example #7
0
/*
================
R_AliasPreparePoints

General clipped case
================
*/
void R_AliasPreparePoints(void)
{
	int			i;
	stvert_t	*pstverts;
	finalvert_t	*fv;
	auxvert_t	*av;
	mtriangle_t	*ptri;
	finalvert_t	*pfv[3];

	pstverts = (stvert_t *)((byte *)paliashdr + paliashdr->stverts);
	r_anumverts = pmdl->numverts;
	fv = pfinalverts;
	av = pauxverts;

	for (i=0 ; i<r_anumverts ; i++, fv++, av++, r_apverts++, pstverts++)
	{
		R_AliasTransformFinalVert(fv, av, r_apverts, pstverts);
		if (av->fv[2] < ALIAS_Z_CLIP_PLANE)
		{
			fv->flags |= ALIAS_Z_CLIP;
		}
		else
		{
			R_AliasProjectFinalVert(fv, av);

			if (fv->v[0] < r_refdef.aliasvrect.x)
			{
				fv->flags |= ALIAS_LEFT_CLIP;
			}
			if (fv->v[1] < r_refdef.aliasvrect.y)
			{
				fv->flags |= ALIAS_TOP_CLIP;
			}
			if (fv->v[0] > r_refdef.aliasvrectright)
			{
				fv->flags |= ALIAS_RIGHT_CLIP;
			}
			if (fv->v[1] > r_refdef.aliasvrectbottom)
			{
				fv->flags |= ALIAS_BOTTOM_CLIP;
			}
		}
	}

//
// clip and draw all triangles
//
	r_affinetridesc.numtriangles = 1;

	ptri = (mtriangle_t *)((byte *)paliashdr + paliashdr->triangles);
	for (i=0 ; i<pmdl->numtris ; i++, ptri++)
	{
		pfv[0] = &pfinalverts[ptri->vertindex[0]];
		pfv[1] = &pfinalverts[ptri->vertindex[1]];
		pfv[2] = &pfinalverts[ptri->vertindex[2]];

		if (pfv[0]->flags & pfv[1]->flags & pfv[2]->flags & (ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP))
		{
			continue;    // completely clipped
		}

		if (!((pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) &
				(ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP)))
		{
			// totally unclipped
			r_affinetridesc.pfinalverts = pfinalverts;
			r_affinetridesc.ptriangles = ptri;
			D_PolysetDraw();
		}
		else
		{
			// partially clipped
			R_AliasClipTriangle(ptri);
		}
	}
}
/*
================
R_AliasClipTriangle
================
*/
void R_AliasClipTriangle (mtriangle_t *ptri)
{
	int			i, k, pingpong;
	mtriangle_t		mtri;
	unsigned int		clipflags;

// copy vertexes and fix seam texture coordinates
	if (ptri->facesfront)
	{
		fv[0][0] = pfinalverts[ptri->vertindex[0]];
		fv[0][1] = pfinalverts[ptri->vertindex[1]];
		fv[0][2] = pfinalverts[ptri->vertindex[2]];
	}
	else
	{
		for (i = 0; i < 3; i++)
		{
			fv[0][i] = pfinalverts[ptri->vertindex[i]];

			if (fv[0][i].flags & ALIAS_ONSEAM)
				fv[0][i].v[2] += r_affinetridesc.seamfixupX16;
		}
	}

// clip
	clipflags = fv[0][0].flags | fv[0][1].flags | fv[0][2].flags;

	if (clipflags & ALIAS_Z_CLIP)
	{
		for (i = 0; i < 3; i++)
			av[i] = pauxverts[ptri->vertindex[i]];

		k = R_AliasClip (fv[0], fv[1], ALIAS_Z_CLIP, 3, R_Alias_clip_z);
		if (k == 0)
			return;

		pingpong = 1;
		clipflags = fv[1][0].flags | fv[1][1].flags | fv[1][2].flags;
	}
	else
	{
		pingpong = 0;
		k = 3;
	}

	if (clipflags & ALIAS_LEFT_CLIP)
	{
		k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
							ALIAS_LEFT_CLIP, k, R_Alias_clip_left);
		if (k == 0)
			return;

		pingpong ^= 1;
	}

	if (clipflags & ALIAS_RIGHT_CLIP)
	{
		k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
							ALIAS_RIGHT_CLIP, k, R_Alias_clip_right);
		if (k == 0)
			return;

		pingpong ^= 1;
	}

	if (clipflags & ALIAS_BOTTOM_CLIP)
	{
		k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
							ALIAS_BOTTOM_CLIP, k, R_Alias_clip_bottom);
		if (k == 0)
			return;

		pingpong ^= 1;
	}

	if (clipflags & ALIAS_TOP_CLIP)
	{
		k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
							ALIAS_TOP_CLIP, k, R_Alias_clip_top);
		if (k == 0)
			return;

		pingpong ^= 1;
	}

	for (i = 0; i < k; i++)
	{
		if (fv[pingpong][i].v[0] < r_refdef.aliasvrect.x)
			fv[pingpong][i].v[0] = r_refdef.aliasvrect.x;
		else if (fv[pingpong][i].v[0] > r_refdef.aliasvrectright)
			fv[pingpong][i].v[0] = r_refdef.aliasvrectright;

		if (fv[pingpong][i].v[1] < r_refdef.aliasvrect.y)
			fv[pingpong][i].v[1] = r_refdef.aliasvrect.y;
		else if (fv[pingpong][i].v[1] > r_refdef.aliasvrectbottom)
			fv[pingpong][i].v[1] = r_refdef.aliasvrectbottom;

		fv[pingpong][i].flags = 0;
	}

// draw triangles
	mtri.facesfront = ptri->facesfront;
	r_affinetridesc.ptriangles = &mtri;
	r_affinetridesc.pfinalverts = fv[pingpong];

// FIXME: do all at once as trifan?
	mtri.vertindex[0] = 0;
	for (i = 1; i < k - 1; i++)
	{
		mtri.vertindex[1] = i;
		mtri.vertindex[2] = i+1;
		if ((currententity->model->flags & EF_SPECIAL_TRANS))
			D_PolysetDrawT5 ();
		else if (currententity->drawflags & DRF_TRANSLUCENT)
			D_PolysetDrawT ();
		else if ((currententity->model->flags & EF_TRANSPARENT))
			D_PolysetDrawT2 ();
		else if ((currententity->model->flags & EF_HOLEY))
			D_PolysetDrawT3 ();
		else
			D_PolysetDraw ();
	}
}
Example #9
0
/*
================
R_AliasPrepareUnclippedPoints
================
*/
void R_AliasPrepareUnclippedPoints (void)
{
	stvert_t	*pstverts;
	finalvert_t	*fv;
	mtriangle_t	*ptri;
	int	i;

	pstverts = (stvert_t *)((byte *)paliashdr + paliashdr->stverts);
	r_anumverts = pmdl->numverts;
// FIXME: just use pfinalverts directly?
	fv = pfinalverts;

	R_AliasTransformAndProjectFinalVerts (fv, pstverts);

	r_affinetridesc.pfinalverts = pfinalverts;
	r_affinetridesc.ptriangles = (mtriangle_t *)
					((byte *)paliashdr + paliashdr->triangles);
	r_affinetridesc.numtriangles = 1;//pmdl->numtris;

	ptri = (mtriangle_t *)((byte *)paliashdr + paliashdr->triangles);
	for (i = 0 ; i < pmdl->numtris ; i++, ptri++)
	{
		finalvert_t	*pfv[3];

		pfv[0] = &pfinalverts[ptri->vertindex[0]];
		pfv[1] = &pfinalverts[ptri->vertindex[1]];
		pfv[2] = &pfinalverts[ptri->vertindex[2]];

		//jfm: fill in the triangles s and t into the finalvert
		pfv[0]->v[2] = pstverts[ptri->stindex[0]].s;
		pfv[0]->v[3] = pstverts[ptri->stindex[0]].t;
		pfv[0]->flags = pstverts[ptri->stindex[0]].onseam;

		pfv[1]->v[2] = pstverts[ptri->stindex[1]].s;
		pfv[1]->v[3] = pstverts[ptri->stindex[1]].t;
		pfv[1]->flags = pstverts[ptri->stindex[1]].onseam;

		pfv[2]->v[2] = pstverts[ptri->stindex[2]].s;
		pfv[2]->v[3] = pstverts[ptri->stindex[2]].t;
		pfv[2]->flags = pstverts[ptri->stindex[2]].onseam;

		r_affinetridesc.ptriangles = ptri;

		if (r_affinetridesc.drawtype)
		{
			if ((currententity->model->flags & EF_SPECIAL_TRANS))
			{
				D_PolysetDrawFinalVertsT5 (pfv[0],pfv[1],pfv[2]);
				D_PolysetDrawT5 ();
			}
			else if (currententity->drawflags & DRF_TRANSLUCENT)
			{
				D_PolysetDrawFinalVertsT (pfv[0],pfv[1],pfv[2]);
				D_PolysetDrawT ();
			}
			else if ((currententity->model->flags & EF_TRANSPARENT))
			{
				D_PolysetDrawFinalVertsT2 (pfv[0],pfv[1],pfv[2]);
				D_PolysetDrawT2 ();
			}
			else if ((currententity->model->flags & EF_HOLEY))
			{
				D_PolysetDrawFinalVertsT3 (pfv[0],pfv[1],pfv[2]);
				D_PolysetDrawT3 ();
			}
			else
			{
				D_PolysetDrawFinalVerts (pfv[0],pfv[1],pfv[2]);
				D_PolysetDraw ();
			}
		}
		else
		{
			if ((currententity->model->flags & EF_SPECIAL_TRANS))
				D_PolysetDrawT5 ();
			else if (currententity->drawflags & DRF_TRANSLUCENT)
				D_PolysetDrawT ();
			else if ((currententity->model->flags & EF_TRANSPARENT))
				D_PolysetDrawT2 ();
			else if ((currententity->model->flags & EF_HOLEY))
				D_PolysetDrawT3 ();
			else
				D_PolysetDraw ();
		}
	}
}
Example #10
0
/*
================
R_AliasPreparePoints

General clipped case
================
*/
static void R_AliasPreparePoints (void)
{
	int			i;
	stvert_t	*pstverts;
	finalvert_t	*fv;
	auxvert_t	*av;
	mtriangle_t	*ptri;
	finalvert_t	*pfv[3];

	pstverts = (stvert_t *)((byte *)paliashdr + paliashdr->stverts);
	r_anumverts = pmdl->numverts;
	fv = pfinalverts;
	av = pauxverts;

	for (i = 0 ; i < r_anumverts ; i++, fv++, av++, r_apverts++)
	{
		fv->flags = 0;
		R_AliasTransformFinalVert (fv, av, r_apverts);
		if (av->fv[2] < ALIAS_Z_CLIP_PLANE)
			fv->flags |= ALIAS_Z_CLIP;
		else
		{
			R_AliasProjectFinalVert (fv, av);

			if (fv->v[0] < r_refdef.aliasvrect.x)
				fv->flags |= ALIAS_LEFT_CLIP;
			if (fv->v[1] < r_refdef.aliasvrect.y)
				fv->flags |= ALIAS_TOP_CLIP;
			if (fv->v[0] > r_refdef.aliasvrectright)
				fv->flags |= ALIAS_RIGHT_CLIP;
			if (fv->v[1] > r_refdef.aliasvrectbottom)
				fv->flags |= ALIAS_BOTTOM_CLIP;
		}
	}

//
// clip and draw all triangles
//
	r_affinetridesc.numtriangles = 1;

	ptri = (mtriangle_t *)((byte *)paliashdr + paliashdr->triangles);
	for (i = 0 ; i < pmdl->numtris ; i++, ptri++)
	{
		pfv[0] = &pfinalverts[ptri->vertindex[0]];
		pfv[1] = &pfinalverts[ptri->vertindex[1]];
		pfv[2] = &pfinalverts[ptri->vertindex[2]];

		if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags & (ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP) )
			continue;		// completely clipped

		//jfm: fill in the triangles s and t into the finalvert
		pfv[0]->v[2] = pstverts[ptri->stindex[0]].s;
		pfv[0]->v[3] = pstverts[ptri->stindex[0]].t;
		pfv[0]->flags |= pstverts[ptri->stindex[0]].onseam;

		pfv[1]->v[2] = pstverts[ptri->stindex[1]].s;
		pfv[1]->v[3] = pstverts[ptri->stindex[1]].t;
		pfv[1]->flags |= pstverts[ptri->stindex[1]].onseam;

		pfv[2]->v[2] = pstverts[ptri->stindex[2]].s;
		pfv[2]->v[3] = pstverts[ptri->stindex[2]].t;
		pfv[2]->flags |= pstverts[ptri->stindex[2]].onseam;

		if ( ! ( (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) & (ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP) ) )
		{	// totally unclipped
			r_affinetridesc.pfinalverts = pfinalverts;
			r_affinetridesc.ptriangles = ptri;

			if ((currententity->model->flags & EF_SPECIAL_TRANS))
				D_PolysetDrawT5 ();
			else if (currententity->drawflags & DRF_TRANSLUCENT)
				D_PolysetDrawT ();
			else if ((currententity->model->flags & EF_TRANSPARENT))
				D_PolysetDrawT2 ();
			else if ((currententity->model->flags & EF_HOLEY))
				D_PolysetDrawT3 ();
			else
				D_PolysetDraw ();
		}
		else
		{	// partially clipped
			R_AliasClipTriangle (ptri);
		}
	}
}