combineing 2d rhw raster polys with 3d TH&L polys

Started by
2 comments, last by Bobboau 20 years, 6 months ago
I have a game engine that I have been upgradeing from a software T&L system to a hardware one, and I now have the only component of the old system (the model rendering code) that will realy benifit from HT&L, fully operatinal. the problem is it seems the old software rotated transformed and projected polys now have an incompatable z value, the question is, is an RHW 2d poly somehow incopmpatable with a 3d poly as in it will always render over, becase no matter how much I add or subtract from the z and or w values of the ST&L polys they always render on top of what ever I'm rendering (they are rendered after the model as they are additive alpha effects) and I'm not sure how much help this will be without any sort of point of reference but the code used by the old ST&L engine was this
ubyte g3_rotate_vertex(vertex *dest,vector *src)
{
#if 0
	vector tempv;
	Assert( G3_count == 1 );
	vm_vec_sub(&tempv,src,&View_position);
	vm_vec_rotate( (vector *)&dest->x, &tempv, &View_matrix );
	dest->flags = 0;	//not projected

	return g3_code_vertex(dest);
#else
	float tx, ty, tz, x,y,z;
	ubyte codes;

	MONITOR_INC( NumRotations, 1 );	

	tx = src->xyz.x - View_position.xyz.x;
	ty = src->xyz.y - View_position.xyz.y;
	tz = src->xyz.z - View_position.xyz.z;

	x = tx * View_matrix.vec.rvec.xyz.x;
	x += ty * View_matrix.vec.rvec.xyz.y;
	x += tz * View_matrix.vec.rvec.xyz.z;

	y = tx * View_matrix.vec.uvec.xyz.x;
	y += ty * View_matrix.vec.uvec.xyz.y;
	y += tz * View_matrix.vec.uvec.xyz.z;

	z = tx * View_matrix.vec.fvec.xyz.x;
	z += ty * View_matrix.vec.fvec.xyz.y;
	z += tz * View_matrix.vec.fvec.xyz.z;

	codes = 0;

	if (x > z)			codes |= CC_OFF_RIGHT;
	if (x < -z)			codes |= CC_OFF_LEFT;
	if (y > z)			codes |= CC_OFF_TOP;
	if (y < -z)			codes |= CC_OFF_BOT;
	if (z < MIN_Z )	codes |= CC_BEHIND;

	dest->x = x;
	dest->y = y;
	dest->z = z;

	if ( G3_user_clip )	{
		// Check if behind user plane

		if ( g3_point_behind_user_plane((vector *)&dest->x))	{
			codes |= CC_OFF_USER;
		}
	}

	dest->codes = codes;

	dest->flags = 0;	// not projected


	vm_vec_copy_scale(&dest->real_pos, src,1);

	return codes;
#endif
}	

   int g3_project_vertex(vertex *p)
{
	float w;

	Assert( G3_count == 1 );

	if ( p->flags & PF_PROJECTED )
		return p->flags;

	//if ( p->z < MIN_Z ) {

	if ( p->z <= MIN_Z ) {
		p->flags |= PF_OVERFLOW;
	} else {
		// w = (p->z == 0.0f) ? 100.0f : 1.0f / p->z;

		w = 1.0f / p->z;
		p->sx = (Canvas_width + (p->x*Canvas_width*w))*0.5f;
		p->sy = (Canvas_height - (p->y*Canvas_height*w))*0.5f;

		if(gr_screen.mode == GR_GLIDE){
			if ( w > 61439.0f ) w = 61439.0f;
		} else {
			if ( w > 1.0f ) w = 1.0f;		
		}
		p->sw = w;
		p->flags |= PF_PROJECTED;
	}
	
	return p->flags;
}
the fact that it makes references to glide should be an indication as to how old this stuff is, we have prety much dropped suport for glide and added suport for OGL (as well as upgradeing the exsisting DX (version 3 I think) infastruture to 8.1b) one more thing, are RHW polys even effected by the transformation matrices? [edited by - Bobboau on October 13, 2003 10:23:41 PM]
Bobboau, bringing you products that work... in theory
Advertisement
:/
Bobboau, bringing you products that work... in theory
quote:Original post by Bobboau
one more thing, are RHW polys even effected by the transformation matrices?


No.

Niko Suni

well, that should make some things a little easier, good.

now any idea on the z buffer thingy?

Bobboau, bringing you products that work... in theory
Bobboau, bringing you products that work... in theory

This topic is closed to new replies.

Advertisement