Beispiel #1
0
//=====================================================================================
//	User_RenderPolyList
//=====================================================================================
geBoolean User_RenderPolyList(gePoly *PolyList)
{
	int32			i, NumSortedPolys;
	gePoly			*Poly;

	assert(PolyList);

	NumSortedPolys = 0;

	for (Poly = PolyList; Poly; Poly = Poly->Next)
	{
		assert(geWorld_PolyIsValid(Poly));

		if ((Poly->RenderFlags & GE_RENDER_DEPTH_SORT_BF) && NumSortedPolys < USER_MAX_SORTED_POLYS)
		{
			// Sorted polys (within this list) go in the SortedPoly list, and are sorted and drawn below
			geVec3d		Src;
			geVec3d		Dest;

			Src.X = Poly->Verts->X;
			Src.Y = Poly->Verts->Y;
			Src.Z = Poly->Verts->Z;

			geCamera_Transform(gCamera, &Src, &Dest);
			Poly->ZOrder = Dest.Z;

			SortedPolys[NumSortedPolys++] = Poly;
			continue;
		}

		// If it is not a sorted poly, render it now...
		RenderUserPoly(gCamera, Poly);
	}

	if (!NumSortedPolys)		// nothing more to do, if no sorted polys
		return GE_TRUE;

	// Now render all sorted polys
	// Sort the polys
	qsort(&SortedPolys, NumSortedPolys, sizeof(SortedPolys[0]), PolyComp);

	// Render them
	for (i=0; i< NumSortedPolys; i++)
	{
		Poly = SortedPolys[i];

		RenderUserPoly(gCamera, Poly);
	}

	return GE_TRUE;	
}
Beispiel #2
0
//=====================================================================================
//	RenderTexturedPoly
//=====================================================================================
static void RenderTexturedPoly(DRV_Driver *RDriver, gePoly *Poly, Frustum_Info *FInfo, geCamera *Camera)
{
	geVec3d			Dest1[30], Dest2[30], *pDest1, *pDest2, *pDest3, *pTempDest;
	GE_LVertex		*pLVert;
	Surf_TexVert	Tex1[30], Tex2[30];
	Surf_TexVert	*pTex1, *pTex2, *pTempTex;
	DRV_TLVertex	Clipped1[90];
	int32			Length1, Length2;
	geBitmap		*pBitmap;
	GFX_Plane		*pFPlanes;
	int32			i, p;
	uint32			RenderFlags;
// skydome
	int32			plan;
//	FILE *fp;

	assert(geWorld_PolyIsValid(Poly));

	pFPlanes = FInfo->Planes;
	
	pDest1 = Dest1;
	pTex1 = Tex1;
	pLVert = Poly->Verts;

	for (i=0; i< Poly->NumVerts; i++)
	{
		pDest1->X = pLVert->X;
		pDest1->Y = pLVert->Y;
		pDest1->Z = pLVert->Z;

		pTex1->u = pLVert->u;
		pTex1->v = pLVert->v;
		pTex1->r = pLVert->r;
		pTex1->g = pLVert->g;
		pTex1->b = pLVert->b;
		
		pDest1++;
		pLVert++;
		pTex1++;
	}

	pDest1 = Dest1;
	pDest2 = Dest2;
	pTex1 = Tex1;
	pTex2 = Tex2;
	Length1 = Poly->NumVerts;

// skydome
	plan = FInfo->NumPlanes;
// changed QD Clipping
//	if (((Poly->RenderFlags & GE_RENDER_NO_CLIP)==GE_RENDER_NO_CLIP) && plan==5)
	if (((Poly->RenderFlags & GE_RENDER_NO_CLIP)==GE_RENDER_NO_CLIP) && plan==6)
		plan -= 1;

	for (p=0; p< plan; p++, pFPlanes++)
	{
		if (!Frustum_ClipToPlaneUVRGB(pFPlanes, pDest1, pDest2, pTex1, pTex2, Length1, &Length2))
			return;

		// Swap them
		pTempDest = pDest1;
		pDest1 = pDest2;
		pDest2 = pTempDest;
	
		pTempTex = pTex1;
		pTex1 = pTex2;
		pTex2 = pTempTex;

		Length1 = Length2;
	}

	if (Length1 < 3)
		return;

	pDest3 = pDest2;
	for (i=0; i< Length1; i++)
	{
		//geXForm3d_Transform(&Camera->XForm, pDest1, pDest2);
		geCamera_Transform(Camera,pDest1,pDest2);
		pDest1++;
		pDest2++;
	}

	Frustum_ProjectRGB(pDest3, pTex1, Clipped1, Length1, Camera);

	pBitmap = Poly->Bitmap;
		
	Clipped1[0].a = Poly->Verts[0].a;


	if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_OTHERS)
	{
		RenderFlags = DRV_RENDER_NO_ZWRITE;
	}
	else
		RenderFlags = 0;

	if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_SELF)
	{	
		RenderFlags |= DRV_RENDER_NO_ZMASK;
	}
	
	if (Clipped1[0].a != 255.0f)
	{
		RenderFlags |= DRV_RENDER_ALPHA;
	}

/* 01/30/2003 Wendell Buckner 
     Driver render flush is probably causing a slow down! */
	if (Poly->RenderFlags & GE_RENDER_DEPTH_SORT_BF) 
	{	
		RenderFlags |= DRV_RENDER_FLUSH;
	}

	if (Poly->RenderFlags & GE_RENDER_CLAMP_UV)
	{	
		RenderFlags |= DRV_RENDER_CLAMP_UV;
	}

	if (Poly->RenderFlags & GE_RENDER_NO_FOG) // skybox fog
	{	
		RenderFlags |= DRV_RENDER_POLY_NO_FOG;
	}

	// Render it...
	assert(geWorld_HasBitmap(gWorld, pBitmap));
	assert(geBitmap_GetTHandle(pBitmap));

/* 08/08/2004 Wendell Buckner
     BUG FIX: Allways call geBitmap_SetRenderFlags() before calling a textured rendering function(for embm, dot3, & etc...). */
	geBitmap_SetRenderFlags(pBitmap, &RenderFlags);

	RDriver->RenderMiscTexturePoly(Clipped1, Length1, geBitmap_GetTHandle(pBitmap), RenderFlags);

}
Beispiel #3
0
//=====================================================================================
//	RenderTexturedPoint
//=====================================================================================
static geBoolean RenderTexturedPoint(DRV_Driver *RDriver, gePoly *Poly, Frustum_Info *FInfo, geCamera *Camera)
{
	assert(geWorld_PolyIsValid(Poly));

	if (MirrorRecursion > 0)
	{
		GE_LVertex		*pVerts, Save;
		geVec3d			Up, Left, Start;
		geFloat			Scale, XScale, YScale;
		const geXForm3d	*MXForm;

		pVerts = Poly->Verts;

		Poly->NumVerts = 4;

		Start.X = pVerts[0].X;
		Start.Y = pVerts[0].Y;
		Start.Z = pVerts[0].Z;

		Save = pVerts[1] = pVerts[2] = pVerts[3] = pVerts[0];

		MXForm = geCamera_GetWorldSpaceXForm(Camera);

		geXForm3d_GetLeft(MXForm, &Left);
		geXForm3d_GetUp(MXForm, &Up);

		Scale = Poly->Scale * 0.5f;

		XScale = (geFloat)geBitmap_Width(Poly->Bitmap) * Scale;
		YScale = (geFloat)geBitmap_Height(Poly->Bitmap) * Scale;

		geVec3d_Scale(&Left, XScale, &Left);
		geVec3d_Scale(&Up, YScale, &Up);

		pVerts->X = Start.X - Left.X + Up.X;
		pVerts->Y = Start.Y - Left.Y + Up.Y;
		pVerts->Z = Start.Z - Left.Z + Up.Z;
		pVerts->u = 0.0f;
		pVerts->v = 0.0f;

		pVerts++;
	
		pVerts->X = Start.X + Left.X + Up.X;
		pVerts->Y = Start.Y + Left.Y + Up.Y;
		pVerts->Z = Start.Z + Left.Z + Up.Z;
		pVerts->u = 1.0f;
		pVerts->v = 0.0f;
	
		pVerts++;
	
		pVerts->X = Start.X + Left.X - Up.X;
		pVerts->Y = Start.Y + Left.Y - Up.Y;
		pVerts->Z = Start.Z + Left.Z - Up.Z;
		pVerts->u = 1.0f;
		pVerts->v = 1.0f;

		pVerts++;
	
		pVerts->X = Start.X - Left.X - Up.X;
		pVerts->Y = Start.Y - Left.Y - Up.Y;
		pVerts->Z = Start.Z - Left.Z - Up.Z;
		pVerts->u = 1.0f;
		pVerts->v = 0.0f;

		RenderTexturedPoly(RDriver, Poly, FInfo, Camera);

		Poly->NumVerts = 1;		// Restore the poly
		Poly->Verts[0] = Save;
	}
	else
	{
		//GFX_Plane		*Planes;
		geVec3d			Src, Dest;
		GE_LVertex		*pVerts;
		DRV_TLVertex	ScreenPnts[4];
		geBitmap		*Bitmap;
		geFloat			Sx, Sy, z, UVAdd, Width, Height;
		geFloat			Left, Right, Top, Bottom;
		geFloat			Scale;
		uint32			RenderFlags;
		int32			i;
		
		assert(Poly != NULL);
		assert(Camera != NULL);

		pVerts = &Poly->Verts[0];
	
		// Xform the point 
		Src.X = pVerts->X;
		Src.Y = pVerts->Y;
		Src.Z = pVerts->Z;

		geCamera_Transform(Camera,&Src,&Dest);

		geCamera_Project(Camera, &Dest, &Src);

		for (i=0; i<4; i++)
		{
			ScreenPnts[i].x = Src.X;
			ScreenPnts[i].y = Src.Y;
			ScreenPnts[i].z = Src.Z;
			ScreenPnts[i].r = pVerts->r;
			ScreenPnts[i].g = pVerts->g;
			ScreenPnts[i].b = pVerts->b;
			ScreenPnts[i].a = pVerts->a;
		}
	
		z = -Dest.Z;

		if (z < 1)
			return GE_TRUE;

		{
			geRect Rect;
			geCamera_GetClippingRect(Camera,&Rect);

			Left   = (geFloat)Rect.Left;
			Right  = (geFloat)Rect.Right+1.0f;
			Top    = (geFloat)Rect.Top;
			Bottom = (geFloat)Rect.Bottom+1.0f;
		}

		Scale = ((geCamera_GetScale(Camera) / z) * Poly->Scale);

		Bitmap = Poly->Bitmap;
		Width = (geFloat)geBitmap_Width(Bitmap) * Scale;
		Height = (geFloat)geBitmap_Height(Bitmap) * Scale;

		Sx = Width * 0.5f;
		Sy = Height * 0.5f;

		// Build the screen poly from the point
		ScreenPnts[0].x -= Sx;
		ScreenPnts[0].y -= Sy;

		ScreenPnts[1].x += Sx;
		ScreenPnts[1].y -= Sy;

		ScreenPnts[2].x += Sx;
		ScreenPnts[2].y += Sy;

		ScreenPnts[3].x -= Sx;
		ScreenPnts[3].y += Sy;

		ScreenPnts[0].u = 0.0f + pVerts->u;
		ScreenPnts[0].v = 0.0f + pVerts->v;
		ScreenPnts[1].u = 1.0f + pVerts->u;
		ScreenPnts[1].v = 0.0f + pVerts->v;
		ScreenPnts[2].u = 1.0f + pVerts->u;
		ScreenPnts[2].v = 1.0f + pVerts->v;
		ScreenPnts[3].u = 0.0f + pVerts->u;
		ScreenPnts[3].v = 1.0f + pVerts->v;

		// Now, clip it against the 2d camera viewport
		if (ScreenPnts[0].x < Left)
		{
			if (ScreenPnts[1].x <= Left)
				return GE_TRUE;

			UVAdd = (Left-ScreenPnts[0].x) / Width;
			Width -= Left-ScreenPnts[0].x;
		
			ScreenPnts[0].u += UVAdd;
			ScreenPnts[3].u += UVAdd;

			ScreenPnts[0].x = Left;
			ScreenPnts[3].x = Left;
		}
		if (ScreenPnts[0].y < Top)
		{
			if (ScreenPnts[2].y <= Top)
				return GE_TRUE;

			UVAdd = (Top-ScreenPnts[0].y) / Height;
			Height -= (Top-ScreenPnts[0].y);
		
			ScreenPnts[0].v += UVAdd;
			ScreenPnts[1].v += UVAdd;

			ScreenPnts[0].y = Top;
			ScreenPnts[1].y = Top;
		}
		if (ScreenPnts[1].x >= Right)
		{
			if (ScreenPnts[0].x >= Right)
				return GE_TRUE;
	
			UVAdd = (ScreenPnts[1].x-Right) / Width;
			Width -= (ScreenPnts[1].x-Right);
		
			ScreenPnts[1].u -= UVAdd;
			ScreenPnts[2].u -= UVAdd;
		
			ScreenPnts[1].x	= Right-1;
			ScreenPnts[2].x	= Right-1;
		}
		if (ScreenPnts[2].y >= Bottom)
		{
			if (ScreenPnts[0].y >= Bottom)
				return GE_TRUE;

			UVAdd = (ScreenPnts[2].y-Bottom) / Height;
			Height -= (ScreenPnts[2].x-Bottom);
		
			ScreenPnts[2].v -= UVAdd;
			ScreenPnts[3].v -= UVAdd;

			ScreenPnts[2].y	= Bottom-1;
			ScreenPnts[3].y	= Bottom-1;
		}

		// Lastly, render it...
		ScreenPnts[0].a = pVerts->a;
		// Fixed bug where i fogot to set RGB's...
		ScreenPnts[0].r = pVerts->r;
		ScreenPnts[0].g = pVerts->g;
		ScreenPnts[0].b = pVerts->b;

		if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_OTHERS)
			RenderFlags = DRV_RENDER_NO_ZWRITE;
		else
			RenderFlags = 0;

		if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_SELF)
			RenderFlags |= DRV_RENDER_NO_ZMASK;

		if (pVerts->a != 255.0f)
			RenderFlags |= DRV_RENDER_ALPHA;

/* 01/30/2003 Wendell Buckner 
     Driver render flush is probably causing a slow down! */
		if (Poly->RenderFlags & GE_RENDER_DEPTH_SORT_BF)    
			RenderFlags |= DRV_RENDER_FLUSH;                 

		if (Poly->RenderFlags & GE_RENDER_CLAMP_UV)
			RenderFlags |= DRV_RENDER_CLAMP_UV;

		if (Poly->RenderFlags & GE_RENDER_NO_FOG) // skybox fog
			RenderFlags |= DRV_RENDER_POLY_NO_FOG;


		assert(geWorld_HasBitmap(gWorld, Bitmap));
		assert(geBitmap_GetTHandle(Bitmap));

/* 08/08/2004 Wendell Buckner
     BUG FIX: Allways call geBitmap_SetRenderFlags() before calling a textured rendering function(for embm, dot3, & etc...). */
		geBitmap_SetRenderFlags(Bitmap, &RenderFlags);

		RDriver->RenderMiscTexturePoly((DRV_TLVertex*)ScreenPnts, 4, geBitmap_GetTHandle(Bitmap), RenderFlags);
	}

	return GE_TRUE;
}
Beispiel #4
0
//=====================================================================================
//	RenderGouraudPoly
//=====================================================================================
static void RenderGouraudPoly(DRV_Driver *RDriver, gePoly *Poly, Frustum_Info *FInfo, geCamera *Camera)
{
	geVec3d			Verts[30], *pVert;
	GE_LVertex		*pLVert;
	geVec3d			Dest1[30], Dest2[30], *pDest1, *pDest2, *pDest3;
	Surf_TexVert	Tex1[30], Tex2[30];
	Surf_TexVert	*pTex1, *pTex2;
	DRV_TLVertex	Clipped1[90];
	int32			Length1, Length2;
	GFX_Plane		*pFPlanes;
	int32			i, p;
	uint32			RenderFlags;

	assert(geWorld_PolyIsValid(Poly));

	pFPlanes = FInfo->Planes;
	
	pVert = Verts;
	pLVert = Poly->Verts;
	pTex1 = Tex1;

	for (i=0; i< Poly->NumVerts; i++)
	{
		pVert->X = pLVert->X;
		pVert->Y = pLVert->Y;
		pVert->Z = pLVert->Z;

		pTex1->r = pLVert->r;
		pTex1->g = pLVert->g;
		pTex1->b = pLVert->b;
		
		pVert++;
		pLVert++;
		pTex1++;
	}

	pDest1 = Verts;
	pDest2 = Dest2;
	pTex1 = Tex1;
	pTex2 = Tex2;
	Length1 = Poly->NumVerts;

	for (p=0; p< 4; p++)
	{
		if (!Frustum_ClipToPlaneRGB(&pFPlanes[p], pDest1, pDest2, pTex1, pTex2, Length1, &Length2))
			return;

		if (pDest1 == Dest2)
		{
			pDest1 = Dest1;
			pDest2 = Dest2;
			pTex1 = Tex1;
			pTex2 = Tex2;
		}
		else
		{
			pDest1 = Dest2;
			pDest2 = Dest1;
			pTex1 = Tex2;
			pTex2 = Tex1;
		}
		Length1 = Length2;
	}

	if (Length1 < 3)
		return;

	pDest3 = pDest2;
	for (i=0; i< Length1; i++)
	{
		//geXForm3d_Transform(&Camera->XForm, pDest1, pDest2);
		geCamera_Transform(Camera, pDest1, pDest2);
		pDest1++;
		pDest2++;
	}

	Frustum_ProjectRGB(pDest3, pTex1, Clipped1, Length1, Camera);
		
	Clipped1[0].a = Poly->Verts[0].a;

	if(Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_OTHERS)
	{
		RenderFlags = DRV_RENDER_NO_ZWRITE;
	}
	else
	{
		RenderFlags = 0;
	}

	if(Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_SELF)
	{
		RenderFlags |= DRV_RENDER_NO_ZMASK;
	}

	if (Clipped1[0].a != 255.0f)
		RenderFlags |= DRV_RENDER_ALPHA;

	// Render it...
	RDriver->RenderGouraudPoly(Clipped1, Length1, RenderFlags);

}
Beispiel #5
0
//=====================================================================================
//	RenderTexturedPoly
//=====================================================================================
static void RenderTexturedPoly(DRV_Driver *RDriver, gePoly *Poly, Frustum_Info *FInfo, geCamera *Camera)
{
	geVec3d			Dest1[30], Dest2[30], *pDest1, *pDest2, *pDest3, *pTempDest;
	GE_LVertex		*pLVert;
	Surf_TexVert	Tex1[30], Tex2[30];
	Surf_TexVert	*pTex1, *pTex2, *pTempTex;
	DRV_TLVertex	Clipped1[90];
	int32			Length1, Length2;
	geBitmap		*pBitmap;
	GFX_Plane		*pFPlanes;
	int32			i, p;
	uint32			RenderFlags;
// skydome
	int32			plan;

	assert(geWorld_PolyIsValid(Poly));

	pFPlanes = FInfo->Planes;
	
	pDest1 = Dest1;
	pTex1 = Tex1;
	pLVert = Poly->Verts;

	for (i=0; i< Poly->NumVerts; i++)
	{
		pDest1->X = pLVert->X;
		pDest1->Y = pLVert->Y;
		pDest1->Z = pLVert->Z;

		pTex1->u = pLVert->u;
		pTex1->v = pLVert->v;
		pTex1->r = pLVert->r;
		pTex1->g = pLVert->g;
		pTex1->b = pLVert->b;
		
		pDest1++;
		pLVert++;
		pTex1++;
	}

	pDest1 = Dest1;
	pDest2 = Dest2;
	pTex1 = Tex1;
	pTex2 = Tex2;
	Length1 = Poly->NumVerts;

// skydome
	plan = FInfo->NumPlanes;
	if (((Poly->RenderFlags & GE_RENDER_NO_CLIP)==GE_RENDER_NO_CLIP) && plan==5)
		plan -= 1;

	for (p=0; p< plan; p++, pFPlanes++)
	{
		if (!Frustum_ClipToPlaneUVRGB(pFPlanes, pDest1, pDest2, pTex1, pTex2, Length1, &Length2))
			return;

		// Swap them
		pTempDest = pDest1;
		pDest1 = pDest2;
		pDest2 = pTempDest;
	
		pTempTex = pTex1;
		pTex1 = pTex2;
		pTex2 = pTempTex;

		Length1 = Length2;
	}

	if (Length1 < 3)
		return;

	pDest3 = pDest2;
	for (i=0; i< Length1; i++)
	{
		//geXForm3d_Transform(&Camera->XForm, pDest1, pDest2);
		geCamera_Transform(Camera,pDest1,pDest2);
		pDest1++;
		pDest2++;
	}

	Frustum_ProjectRGB(pDest3, pTex1, Clipped1, Length1, Camera);

	pBitmap = Poly->Bitmap;
		
	Clipped1[0].a = Poly->Verts[0].a;

	if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_OTHERS)
		RenderFlags = DRV_RENDER_NO_ZWRITE;
	else
		RenderFlags = 0;

	if (Poly->RenderFlags & GE_RENDER_DO_NOT_OCCLUDE_SELF)
		RenderFlags |= DRV_RENDER_NO_ZMASK;
	
	if (Clipped1[0].a != 255.0f)
		RenderFlags |= DRV_RENDER_ALPHA;

	if (Poly->RenderFlags & GE_RENDER_DEPTH_SORT_BF)
		RenderFlags |= DRV_RENDER_FLUSH;

	if (Poly->RenderFlags & GE_RENDER_CLAMP_UV)
		RenderFlags |= DRV_RENDER_CLAMP_UV;

	if (Poly->RenderFlags & GE_RENDER_NO_FOG) // skybox fog
		RenderFlags |= DRV_RENDER_POLY_NO_FOG;

	// Render it...
	assert(geWorld_HasBitmap(gWorld, pBitmap));
	assert(geBitmap_GetTHandle(pBitmap));

	RDriver->RenderMiscTexturePoly(Clipped1, Length1, geBitmap_GetTHandle(pBitmap), RenderFlags);

}