Game Development Community

3D Radar -TGEA help

by James Laker (BurNinG) · in Torque Game Engine Advanced · 03/18/2008 (6:56 am) · 5 replies

I'm having some problems porting the 3D Radar I received from Guy Allard. Check out this thread for screenshots.

Before I post the resource I would like to have both versions, TGE and TGEA working. So here I am again in need of your help.

My attempt at the TGEA port can be found here. Nothing shows up however except for the the Radar Texture. I brought down the (detail) quality of the sphere.

Can anyone help out here please.

Thanks
James

burningza.googlepages.com/radar03.jpg

#1
03/18/2008 (8:13 am)
James, the first link points to some google site, no screenshots there :)
#2
03/18/2008 (10:00 am)
Hehe... oops...
Link fixed
#3
03/18/2008 (10:44 am)
James,

I finally bit the bullet and got myself a TGEA license.
I've got the basics of the control pretty much working under TGEA. An issue I came across is that there are no functions in DX for drawing points of a specific size, or lines of a specific width (anyone want to tell me I'm wrong there?), it has to be done using textured polygons.

Give me a bell on MSN, and we can compare notes.
#4
03/18/2008 (11:16 pm)
Actually, it's not that nothing else is showing, it's that it's occluding everything else. so far this end:

1- ganked the
struct SortInfo 
{
   U32 idx;
   F32 dot;
};
static int QSORT_CALLBACK alphaSort(const void* p1, const void* p2)
{
   const SortInfo* ip1 = (const SortInfo*)p1;
   const SortInfo* ip2 = (const SortInfo*)p2;

   if(ip1->dot > ip2->dot)
      return(1);
   if(ip1->dot == ip2->dot)
      return(0);
   return(-1);
}
from the latest edittsctrl.cpp and tossed it on into the .h for now, included that in the guiradarcntrl.cpp, and replaced the chunk in the if (mSphereOn) check with the following:

if (mSphereOn)
	{
		const Sphere::TriangleMesh *sphereMesh = sphere.getMesh(2);

		// sort the surfaces back->front
		Vector<SortInfo> sortInfos;
		sortInfos.setSize(sphereMesh->numPoly);
		for(U32 i = 0; i < sphereMesh->numPoly; i++)
		{
			sortInfos[i].idx = i;
			sortInfos[i].dot = mDot(Point3F(0.0f,-1.0f,0.0f), sphereMesh->poly[i].normal);
		}
		dQsort(sortInfos.address(), sortInfos.size(), sizeof(SortInfo), alphaSort);

		GFX->setAlphaBlendEnable( true );
		GFX->setSrcBlend( GFXBlendSrcAlpha );
		GFX->setDestBlend( GFXBlendInvSrcAlpha );

		PrimBuild::color(mSphereColor);
		PrimBuild::begin(GFXTriangleStrip,sphereMesh->numPoly*3);
			for(int i=0; i<sphereMesh->numPoly; i++)
			{
				//Sphere::Triangle *tri = &sphereMesh->poly[i];
				Sphere::Triangle * tri = &sphereMesh->poly[sortInfos[i].idx];

				for( S32 j = 2; j >= 0; j-- )
				{
					PrimBuild::vertex3fv(tri->pnt[j]);
				}
			}
		PrimBuild::end();
		GFX->setAlphaBlendEnable( false );
	}

(note: most of that ganked from ConsoleMethod(EditTSCtrl, renderSphere, void, 4, 5, "(Point3F pos, float radius, int subdivisions=NULL)") )

then cut the alpha value all the way down to

sphereColor = "0 0.5 0 0.0125";

results in:

img502.imageshack.us/img502/9999/96201878xg7.th.jpg

still not quite right for the dot-product culler check there, hence toning the alpha way way on down, but mebbey one of the math-wizes arround can help a bit more...
#5
03/19/2008 (7:11 am)
Well... I got it working too. And Guy also sent me an updated version. I'll add to it your features too Kirk. Thanx a mil!