Game Development Community

3d radar for t3d

by graham mcinnes · in Torque 3D Professional · 09/08/2009 (12:29 am) · 23 replies

credits to :
kirk longendyke : sphere fix code
james laker (burning) : both 3d radar resources

http://www.garagegames.com/community/forums/viewthread/73196
http://www.garagegames.com/community/resources/view/16417


here is a screen shot (1.3mb)
http://2.bp.blogspot.com/_SplDgn8nyYc/SqXMVpdYyCI/AAAAAAAAAAc/oWgz_bMgwFE/s1600-h/screenshot_003-00000.png

yeah i basically stood on the shoulders of giants and ripped
out all of the drawing code that was incompatible with t3d,
and botched it to work in the new version...

added scaling in colours and sizes, based on the range.

you need a picture for the elliptical plane, you either need the one from
the original resource (the plane picture needs to go in 'art' folder),
or need to manually point it to another file.

:edit: 9/9/2009 : added more controls for the control
and fixed default values

--(tested to work on t3d beta 4 + 5)--

the .h file
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

#ifndef _GUIRADARTSCTRL_H_
#define _GUIRADARTSCTRL_H_

//#ifndef _DGL_H_
//#include "dgl/dgl.h"
//#endif

#ifndef _GAME_H_
#include "app/game.h"
#endif
#ifndef _GUITSCONTROL_H_
#include "gui/3d/guiTSControl.h"
#endif

//----------------------------------------------------------------------------
class GuiRadarTSCtrl : public GuiTSCtrl
{
private:
   typedef GuiTSCtrl Parent;

   StringTableEntry  mEllipticBitmap;     // path to the bitmap for the horizontal plane
   //TextureHandle mEllipticTextureHandle;  // texture handle for the horizontal plane
	GFXTexHandle mEllipticTextureHandle;  // texture handle for the horizontal plane

	GFXStateBlockRef mRenderObjectStuff; //new crap

   ColorF   mEllipticColor;   // color to use when drawing the elliptic plane
   ColorF   mSphereColor;     // color of the sphere
   ColorF   mBlipColor;       // color for the radar 'blips'
   ColorF   mUnBlipColor;       // color for the radar 'blips'
   ColorF   mvehBlipColor;       // color for the radar 'blips'
   ColorF   mvehUnBlipColor;       // color for the radar 'blips'
   ColorF   mStemColor;       // color for the stems of the blips
   F32      mRange;           // range of the radar
   F32      mBlipSize;        // base size for the blips
   F32		mCloseBlipSize;		//close scale multiplyer for the blip
   F32		mFarBlipSize;		//far scale multiplyer for the blip

	bool		mSphereOn;			//Turn the sphere On/Off
	bool		mStemsOn;			//Turn the radar Lines On/Off

	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);   
}  
   
public:
   GuiRadarTSCtrl();

   bool processCameraQuery(CameraQuery *query);
   void renderWorld(const RectI &updateRect);
   
   static void initPersistFields();
   bool onWake();
	void onSleep();

   // gets and sets
   void setEllipticBitmap(const char *name);
   void setRange(F32 range) { mRange = range; }
   void SetBlipSize(F32 newblipsize) { mBlipSize = newblipsize; }
   void SetCloseBlipSize(F32 newcloseblipsize) { mCloseBlipSize = newcloseblipsize; }
   void SetFarBlipSize(F32 newfarblipsize) { mFarBlipSize = newfarblipsize; }
   F32 getRange() { return mRange; }
   void setEllipticColor(ColorF color) { mEllipticColor = color; }
   void setSphereColor(ColorF color) { mSphereColor = color; }
   void setBlipColor(ColorF color) { mBlipColor = color; }
   void setUnBlipColor(ColorF color) { mUnBlipColor = color; }
   void setvehBlipColor(ColorF color) { mvehBlipColor = color; }
   void setvehUnBlipColor(ColorF color) { mvehUnBlipColor = color; }
   void setStemColor(ColorF color) { mStemColor = color; }

   DECLARE_CONOBJECT(GuiRadarTSCtrl);
};

#endif

the .cpp file
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//
// Class: GuiRadarTSCtrl
// A 3d spherical radar system, ideal for space and flight games
// If you've played Elite, you know the score :)
// uses some ideas from the GuiRadarCtrl by Matt "CaptFallout" Webster
// Guy Allard 2008
//-----------------------------------------------------------------------------

#include "t3d/hud/3dradar.h"
#include "console/consoleTypes.h"
#include "t3d/gameConnection.h"
#include "t3d/shapeBase.h"
#include "t3d/sphere.h"
#include "gfx/primBuilder.h"
#include "gfx/gfxDrawUtil.h"
#include "gfx/sim/debugDraw.h"

IMPLEMENT_CONOBJECT(GuiRadarTSCtrl);

// vertices for the quad used for rendering the elliptic plane
Point3F quadVerts[4]=
{
   Point3F(-1, 1, 0),
   Point3F(1, 1, 0),
   Point3F(1, -1, 0),
   Point3F(-1, -1, 0)
};

// texture coords for the quad
Point2F quadTexCoords[4] =
{
   Point2F(0,0),
   Point2F(1,0),
   Point2F(1,1),
   Point2F(0,1)
};

// sphere
static Sphere sphere(Sphere::Icosahedron);

//--------------------------------------------------------------------------
GuiRadarTSCtrl::GuiRadarTSCtrl()
{
   mEllipticBitmap = StringTable->insert("");
   mEllipticTextureHandle = NULL;
   mEllipticColor.set(0.0, 0.75, 0.0, 0.75);
   mSphereColor.set(0.0f, 0.5f, 0.0f, 0.0125f);
   mBlipColor.set(1.0f, 0.0f, 0.0f, 0.75f);
   mUnBlipColor.set(0.5f, 0.0f, 0.0f, 0.75f);
   mvehBlipColor.set(0.0f, 1.0f, 0.0f, 0.75f);
   mvehUnBlipColor.set(0.0f, 0.5f, 0.0f, 0.75f);
   mStemColor.set(1.0f, 1.0f, 1.0f, 0.5f);

   mCloseBlipSize = 0.75f;
   mFarBlipSize = 0.5f;

   mBlipSize = 1.0f;
   mRange = 50.0f;
	mSphereOn = true;
	mStemsOn = true;
}

//---------------------------------------------------------------------------
void GuiRadarTSCtrl::initPersistFields()
{
	Parent::initPersistFields();

	addGroup("Radar");
	addField("Bitmap",		TypeFilename,	   Offset(mEllipticBitmap,    GuiRadarTSCtrl));
   addField("PlaneColor",  TypeColorF,       Offset(mEllipticColor,     GuiRadarTSCtrl));
   addField("blipColor",	TypeColorF,       Offset(mBlipColor,         GuiRadarTSCtrl));
   addField("unblipColor",	TypeColorF,       Offset(mUnBlipColor,         GuiRadarTSCtrl));
   addField("vehblipColor",	TypeColorF,       Offset(mvehBlipColor,         GuiRadarTSCtrl));
   addField("vehunblipColor",	TypeColorF,       Offset(mvehUnBlipColor,         GuiRadarTSCtrl));
   addField("BlipSize",       TypeF32,          Offset(mBlipSize,          GuiRadarTSCtrl));
   addField("CloseBlipSize",       TypeF32,          Offset(mCloseBlipSize,          GuiRadarTSCtrl));
   addField("FarBlipSize",       TypeF32,          Offset(mFarBlipSize,          GuiRadarTSCtrl));
	addField("StemsOn",		TypeBool,			Offset(mStemsOn,				GuiRadarTSCtrl));
   addField("stemColor",   TypeColorF,       Offset(mStemColor,         GuiRadarTSCtrl));
	addField("SphereOn",		TypeBool,			Offset(mSphereOn,				GuiRadarTSCtrl));
   addField("sphereColor", TypeColorF,       Offset(mSphereColor,       GuiRadarTSCtrl));
   addField("range",       TypeF32,          Offset(mRange,             GuiRadarTSCtrl));
	endGroup("Radar");
}

//---------------------------------------------------------------------------
void GuiRadarTSCtrl::setEllipticBitmap(const char *name)
{
   mEllipticBitmap = StringTable->insert(name);

   if (*mEllipticBitmap) 
   {
      
		//mEllipticTextureHandle = TextureHandle(mEllipticBitmap, BitmapTexture, true);
	  	mEllipticTextureHandle.set(mEllipticBitmap, &GFXDefaultGUIProfile,"");
	  
		
   }
   else 
   {
      // Reset handles if UI object is hidden
	  mEllipticTextureHandle = NULL;
   }
   setUpdate();
}

//---------------------------------------------------------------------------
bool GuiRadarTSCtrl::onWake()
{
	if (! Parent::onWake())
		return false;
	setActive(true);

	setEllipticBitmap(mEllipticBitmap);

   return true;
}

//--------------------------------------------------------------------------
void GuiRadarTSCtrl::onSleep()
{
	mEllipticTextureHandle = NULL;
	Parent::onSleep();
}

//---------------------------------------------------------------------------
// set up the camera position for rendering the sub-scene
bool GuiRadarTSCtrl::processCameraQuery(CameraQuery *camq)
{
   // pretty hacky hardcoded values
   // gives a reasonable viewing angle
   camq->nearPlane = 0.1f; // near clip plane
   camq->farPlane = 2000.0f; // far clip plane
   camq->fov = M_PI/6;     // field of view
   MatrixF cam;
   cam.set(EulerF(M_PI/8, 0, 0)); // rotation
   cam.setColumn(3, Point3F(0, -4, 1.65)); // position
   camq->cameraMatrix = cam;
   return (true);
}

//---------------------------------------------------------------------------
// render the world that this control sees
void GuiRadarTSCtrl::renderWorld(const RectI &updateRect)
{

   // Must have a connection
	GameConnection* conn = GameConnection::getConnectionToServer();
   if (!conn) return;
   
   // Must have controlled object
   //shapeBase* control = conn->getControlObject();
   //edit :: shapeBase* control = conn->getControlObject();
   //if (!control) return;
   
   // Must have controlled object
   GameBase * control = dynamic_cast<GameBase*>(conn->getControlObject());
   if (!control) return;

   // get the camera transform for the connection
   MatrixF camMat;
   conn->getControlCameraTransform(0,&camMat);
   // get the position for use later
   Point3F camPos = camMat.getPosition();

   // invert the camera transform - 
   // this will then allow us to transform other objects into our own object space
   camMat.inverse();

/*
	//TGEA stuff
	GFX->setBaseRenderState();
	GFX->clearBitmapModulation();
	GFX->setAlphaBlendEnable(true);
	GFX->setZEnable(false);
	GFX->setZWriteEnable(false);

	GFX->setSrcBlend(GFXBlendSrcAlpha);
	GFX->setDestBlend(GFXBlendInvSrcAlpha);
*/	
   
   
   // first draw the elliptic plane if we need to
   if(mEllipticTextureHandle)
   {
		GFXTexHandle texture = (GFXTexHandle) mEllipticTextureHandle; 

		//RectI rect(offset, getExtent());
		//GFX->getDrawUtil()->clearBitmapModulation();
		GFX->getDrawUtil()->drawBitmapStretch(texture, updateRect);
		//renderChildControls( offset, updateRect);
		//GFX->setTextureStageColorOp( 0, GFXTOPModulate );
		//GFX->setTextureStageColorOp( 1, GFXTOPDisable );
		GFX->setTexture( 0, mEllipticTextureHandle );
		

		PrimBuild::color4f(mEllipticColor.red,mEllipticColor.green,mEllipticColor.blue,mEllipticColor.alpha);

		PrimBuild::begin(GFXTriangleFan, 4);
         for(int i=0; i<4; i++)
         {
				PrimBuild::texCoord2f(quadTexCoords[i].x,quadTexCoords[i].y);
				Point3F p = quadVerts[i];
				PrimBuild::vertex3fv(p);
         }

		PrimBuild::end();

   }

   //GFX->getDrawUtil()->clearBitmapModulation();

   if ( mRenderObjectStuff.isNull() )
   {
      GFXStateBlockDesc desca;
      desca.setCullMode( GFXCullNone );
      desca.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
      desca.setZReadWrite( false, false );
      mRenderObjectStuff = GFX->createStateBlock( desca );
   }

   GFX->setStateBlock(mRenderObjectStuff);
  
   
	//GFX->setBaseRenderState();
	//GFX->clearBitmapModulation();
		//GFX->getDrawUtil()->clearBitmapModulation();
		
/*
   // then the sphere
	if (mSphereOn)
	{

		PrimBuild::color(mSphereColor);
		const Sphere::TriangleMesh *sphereMesh = sphere.getMesh(4);
		
		PrimBuild::begin(GFXTriangleStrip,sphereMesh->numPoly*3);
			for(int i=0; i<sphereMesh->numPoly; i++)
			{
				Sphere::Triangle *tri = &sphereMesh->poly[i];
				for(int j=0; j<3; j++)
				{
					PrimBuild::vertex3fv(tri->pnt[j]);
				}
			}
		PrimBuild::end();
	}
	*/
   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 );   
    }  

	//GFX->setBaseRenderState();
	//GFX->clearBitmapModulation();
		
		

   // Now do the radar signatures
   // Go through all ghosted objects on connection (client-side)
	for (SimSetIterator itr(conn); *itr; ++itr) 
   {
	   // Make sure that the object is a shapebase object
	   if ((*itr)->getType() & ShapeBaseObjectType) 
      {
		   ShapeBase* shape = static_cast<ShapeBase*>(*itr);
		   // Make sure that the object isn't the client
		   if (shape != control /*&& shape->getShapeName()*/) 
         {
			   // Make sure the shapebase object is a player (or Vehicle)
			   if (shape->getType() & ( PlayerObjectType | VehicleObjectType) ) 
            {
               // get position of object
				   Point3F objPos = shape->getPosition();

               // get vector between object and observer
               Point3F objVec = objPos - camPos;

			   

               // don't draw if outside of current radar range
               if(objVec.lenSquared() > (mRange * mRange))
                  continue;
               F32 colorscale = sqrt(objVec.lenSquared());
			   colorscale /= mRange;
			   

               // transform it into the coordinate space of the viewer
               camMat.mulP(objPos);

               // scale it according to the current radar range
               objPos /= mRange;

               // compress the z transform a bit, just for looks
               objPos.z *= 0.5f;

			   /*
               // draw the blip
					PrimBuild::color(mBlipColor);
					PrimBuild::begin(GFXPointList,1);
						PrimBuild::vertex3fv(objPos);
					PrimBuild::end();
					*/

			   // Now do the radar signatures
			   // firstly, we will be drawing billboards, so get the current world transform matrix
			   MatrixF worldMat = GFX->getWorldMatrix();
			   // extract the up and right vectors
			   Point3F up;
			   Point3F right;
			   worldMat.getRow(0,&right);
			   worldMat.getRow(2,&up);
			   right.normalize();
			   up.normalize();
				// then build the coordinates that we'll use for the billboards
				// oops, another hard coded value, ah well...

				// blip close and blip far nm might be backwards :: check this
			   
				right *= mBlipSize * (mCloseBlipSize - (mFarBlipSize * colorscale)) * 0.1f; //0.05f *
				up    *= mBlipSize * (mCloseBlipSize - (mFarBlipSize * colorscale)) * 0.1f; //0.05f *


				// new colours are here // // // // // // //
				//
				//				far color and near color(un)
				//
				//				un color is closer to white (1,1,1)
				//
				if(shape->getType() &  PlayerObjectType )
				{
					F32 temred;
					F32 temgre;
					F32 temblu;
					F32 temalp;

					temred = mUnBlipColor.red - mBlipColor.red;
					temgre = mUnBlipColor.green - mBlipColor.green;
					temblu = mUnBlipColor.blue - mBlipColor.blue;
					temalp = mUnBlipColor.alpha - mBlipColor.alpha;

					temred = mBlipColor.red + (temred*colorscale);
					temgre = mBlipColor.green + (temgre*colorscale);
					temblu = mBlipColor.blue + (temblu*colorscale);
					temalp = mBlipColor.alpha + (temalp*colorscale);
				
					// divides all the colours up, gets the un color and multiplies by the scale (0<>1)
					// and adds that to the blip color
					
					// so it should scale from the un blip color to the blip color by the scale amount


					PrimBuild::color4f(temred, temgre, temblu, temalp); //PrimBuild::color(mUnBlipColor);
				}
				else
				{
					//VehicleObjectType
					F32 vehtemred;
					F32 vehtemgre;
					F32 vehtemblu;
					F32 vehtemalp;

					vehtemred = mvehUnBlipColor.red - mvehBlipColor.red;
					vehtemgre = mvehUnBlipColor.green - mvehBlipColor.green;
					vehtemblu = mvehUnBlipColor.blue - mvehBlipColor.blue;
					vehtemalp = mvehUnBlipColor.alpha - mvehBlipColor.alpha;

					vehtemred = mvehBlipColor.red + (vehtemred*colorscale);
					vehtemgre = mvehBlipColor.green + (vehtemgre*colorscale);
					vehtemblu = mvehBlipColor.blue + (vehtemblu*colorscale);
					vehtemalp = mvehBlipColor.alpha + (vehtemalp*colorscale);
				



					PrimBuild::color4f(vehtemred, vehtemgre, vehtemblu, vehtemalp); //PrimBuild::color(mUnBlipColor);
//					PrimBuild::color(mvehBlipColor); // primbuild::color(mvehunblipcolor);
				}
					

               PrimBuild::begin(GFXTriangleStrip, 4);
                  PrimBuild::texCoord2f(quadTexCoords[0].x, quadTexCoords[0].y);
                  PrimBuild::vertex3fv(objPos - right + up);
                  PrimBuild::texCoord2f(quadTexCoords[1].x, quadTexCoords[1].y);
                  PrimBuild::vertex3fv(objPos + right + up);
                  PrimBuild::texCoord2f(quadTexCoords[2].x, quadTexCoords[2].y);
                  PrimBuild::vertex3fv(objPos - right - up);
                  PrimBuild::texCoord2f(quadTexCoords[3].x, quadTexCoords[3].y);
                  PrimBuild::vertex3fv(objPos + right - up);
               PrimBuild::end();

			   


               // draw a line from the blip to the elliptic
               // end point of line
					if (mStemsOn)
					{
						Point3F endPos = objPos;
						endPos.z = 0;

						// draw the line
						PrimBuild::color(mStemColor);
						PrimBuild::begin(GFXLineStrip,2);
							PrimBuild::vertex3fv(objPos);
							PrimBuild::vertex3fv(endPos);
						PrimBuild::end();

					}
			   }
		   }
	   }
   }

   //GFX->setZWriteEnable( true );
   //GFX->setZEnable( true );
   //GFX->setAlphaTestEnable( false );
   //GFX->setBaseRenderState();
	
	

}

//------------------------------------------------------------------------
// script interface
ConsoleMethod( GuiRadarTSCtrl, setEllipticBitmap, void, 3, 3, "(string filename)"
              "Set the bitmap for the horizontal plane of the control.")
{
   object->setEllipticBitmap(argv[2]);
}

ConsoleMethod( GuiRadarTSCtrl, SetRange, void, 3, 3, "(float)"
              "Sets the Range of the the control. Default is 250")
{
   object->setRange(dAtof(argv[2]));
}

ConsoleMethod( GuiRadarTSCtrl, SetBlipSize, void, 3, 3, "(float)"
              "Sets the blipsize of the the control. Default is 1")
{
   object->SetBlipSize(dAtof(argv[2]));
}

ConsoleMethod( GuiRadarTSCtrl, SetCloseBlipSize, void, 3, 3, "(float)"
              "Sets the closeblipsize of the the control. Default is 0.75")
{
   object->SetCloseBlipSize(dAtof(argv[2]));
}

ConsoleMethod( GuiRadarTSCtrl, SetFarBlipSize, void, 3, 3, "(float)"
              "Sets the farblipsize of the the control. Default is 0.5")
{
   object->SetFarBlipSize(dAtof(argv[2]));
}

ConsoleMethod( GuiRadarTSCtrl, getRange, F32, 2, 2, "()"
              "gets the current range of the control")
{
   return object->getRange();
}

ConsoleMethod( GuiRadarTSCtrl, setEllipticColor, void, 3, 3, "(Color)"
              "set the color of the horizontal plane")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setEllipticColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setSphereColor, void, 3, 3, "(Color)"
              "set the color of the sphere")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setSphereColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setBlipColor, void, 3, 3, "(Color)"
              "set the color of the radar blips")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setBlipColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setUnBlipColor, void, 3, 3, "(Color)"
              "set the color of the radar blips")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setUnBlipColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setvehBlipColor, void, 3, 3, "(Color)"
              "set the color of the radar blips")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setvehBlipColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setvehUnBlipColor, void, 3, 3, "(Color)"
              "set the color of the radar blips")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setvehUnBlipColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setStemColor, void, 3, 3, "(Color)"
              "set the color of the blip lines")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setStemColor(color);
}

put this in the play gui or another gui
new GuiRadarTSCtrl(Radar) {
      cameraZRot = "0";
      forceFOV = "0";
      reflectPriority = "1";
      Margin = "0 0 0 0";
      Padding = "0 0 0 0";
      AnchorTop = "1";
      AnchorBottom = "0";
      AnchorLeft = "1";
      AnchorRight = "0";
      isContainer = "0";
      Profile = "GuiDefaultProfile";
      HorizSizing = "right";
      VertSizing = "bottom";
      Position = "9 2";
      Extent = "149 152";
      MinExtent = "8 2";
      canSave = "1";
      Visible = "1";
      tooltipprofile = "GuiToolTipProfile";
      hovertime = "1000";
      canSaveDynamicFields = "0";
      Bitmap = "art/radar3D.png";
      PlaneColor = "0 0.3 1 0.75";
      blipColor = "1 0 0 1";
      unblipColor = "0.5 0 0 0.5";
      vehblipColor = "0 1 0 1";
      vehunblipColor = "0 0.5 0 0.5";
      BlipSize = "1";
      CloseBlipSize = "0.75";
      FarBlipSize = "0.5";
      StemsOn = "1";
      stemColor = "1 1 1 1";
      SphereOn = "1";
      sphereColor = "0 0 0.5 0.0125";
      range = "50";
   };
Page «Previous 1 2
#2
09/08/2009 (10:27 pm)
Thanks for porting the radar code to T3D! I tried adding your code to my project but ended up getting that 'Unable to instantiate non-conobject class GuiRadarTSCtrl' error message.

From a browse in the forums, most people recommended checking the DECLARE_CONOBJECT and IMPLEMENT_CONOBJECT, which the code has, so I'm not sure what's causing the error.

Also, is there a way to insert this GUIControl in the GUI editor palette?
#3
09/09/2009 (4:53 am)
to post #1 :
thanks !

to post #2 :
yeah i'm not sure what you are doing wrong, sounds like you are copying the code, but have not inluded the actual files into your project.
or something like that.

i just tested this on a fresh version with no errors, so i'm not sure what is going wrong.

when it is working, its in the 'categorized' palette menu, under 3d>GuiRadarTSCtrl
#4
09/09/2009 (6:56 am)
What I did was to copy the code, add them to the files guiRadarTSCtrl.cpp and .h, placed them in the gui/3d folder, and changed the .cpp file to point to the correct .h file.

Next I opened the project solution file, added those two files in the gui/3d directory in Visual Studio 2005, and built it.

It built without errors, but when I started up T3D, it gave me that 'Unable to instantiate' error.
#5
09/10/2009 (3:18 am)
Did I miss out any steps in the building process?
#6
09/14/2009 (12:19 am)
sorry for the late reply,
no that sounds all correct, and i'm not sure where the problem is.
i built it on v.s. 2008, but i don't think thats the issue.

i will have a look into this the next chance i get,
i'm no expert though...

[edit]
sounds like it might be a similar bug to this :
http://www.garagegames.com/community/resources/view/17413/1#comment-127563
that was caused by multiple versions of directX...
[/edit]
#7
12/28/2009 (2:54 pm)
ty for the new radar code, it works fine on T3D Alpha.
#8
01/08/2010 (5:53 pm)
I love a nice portable resource like this; no modification to existing files, lots of commentary left in to describe the changes from TGEA->T3D, not to mention that it provides a nice template for how to handle 3D GUI components for T3D. Thanks. =)
#10
11/04/2011 (9:35 am)
Updated for 1.1 Final, because someone was asking and I did not see a newer update than above anywhere...

I can't take credit for much, if any, of this - it is merely a collection of all the previous ports, etc, along with a couple of small fixes that I caught myself when implementing in 1.1 Final.

So for anyone trying to get this running in 1.1 Final, here is the skinny:


Most recent version of the resource I could find is in this thread, in the post above (download the ZIP file and use the enclosed assets/images, but use the engine source below instead of what's included in the ZIP).

Add this file (guiRadarTSCtrl.h) to your project, in the T3D folder of the source:

//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

#ifndef _GUIRADARTSCTRL_H_
#define _GUIRADARTSCTRL_H_

#ifndef _GUITSCONTROL_H_
#include "gui/3d/guiTSControl.h"
#endif
#ifndef _GFXTEXTUREHANDLE_H_
#include "gfx/gfxTextureHandle.h"
#endif

//----------------------------------------------------------------------------
class GuiRadarTSCtrl : public GuiTSCtrl
{
private:
   typedef GuiTSCtrl Parent;

   StringTableEntry  mEllipticBitmap;           // path to the bitmap for the horizontal plane
   GFXTexHandle      mEllipticTextureHandle;    // texture handle for the horizontal plane

   StringTableEntry  mBlipBitmap;               // path to the bitmap we'll use for the blips
   GFXTexHandle      mBlipTextureHandle;        // texture handle for the blip texture

   StringTableEntry  mTargetBlipBitmap;               // path to the bitmap we'll use for the blips
   GFXTexHandle      mTargetBlipTextureHandle;        // texture handle for the blip texture

	 S32			mSphereDetail;

   ColorF   mEllipticColor;   // color to use when drawing the elliptic plane
   ColorF   mSphereColor;     // color of the sphere
   ColorF   mBlipColor;       // color for the radar 'blips'
   ColorF   mUnBlipColor;       // color for the radar 'blips'
   ColorF   mvehBlipColor;       // color for the radar 'blips'
   ColorF   mvehUnBlipColor;       // color for the radar 'blips'
   ColorF   mStemColor;       // color for the stems of the blips
   F32      mRange;           // range of the radar
   F32      mBlipSize;        // base size for the blips

	char		mTargetShapeName[32]; //This keeps the name of the locked target
  
public:
   GuiRadarTSCtrl();

   bool processCameraQuery(CameraQuery *query);
   void renderWorld(const RectI &updateRect);
   
   static void initPersistFields();
   bool onWake();
	void onSleep();

   // gets and sets
   void setEllipticBitmap(const char *name);
   void setBlipBitmap(const char *name);
   void setRange(F32 range) { mRange = range; }
   F32 getRange() { return mRange; }
   void setEllipticColor(ColorF color) { mEllipticColor = color; }
   void setSphereColor(ColorF color) { mSphereColor = color; }
   void setBlipColor(ColorF color) { mBlipColor = color; }
   void setUnBlipColor(ColorF color) { mUnBlipColor = color; }
   void setvehBlipColor(ColorF color) { mvehBlipColor = color; }
   void setvehUnBlipColor(ColorF color) { mvehUnBlipColor = color; }
   void setStemColor(ColorF color) { mStemColor = color; }

	void setTarget(const char *TargetShapeBaseName);

   DECLARE_CONOBJECT(GuiRadarTSCtrl);
};

#endif


END of guiRadarTSCtrl.h


... continued in next post
#11
11/04/2011 (9:43 am)


Next, add this file (guiRadarTSCtrl.cpp) to your project, also in the T3D folder of the source where you put the .h file above:

//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// Class: GuiRadarTSCtrl for TGEA
// Tested with TGEA 1.0.3
// A 3d Spherical Radar system, ideal for space and flight games
// If you've played Elite, you know the score :)
// Uses some ideas from the GuiRadarCtrl by Matt "CaptFallout" Webster
// Guy Allard 2008
//-----------------------------------------------------------------------------
// Upgraded and cleaned by James Laker
//-----------------------------------------------------------------------------
#include "platform/platform.h"

#include "gui/core/guiControl.h"
#include "gfx/gfxDrawUtil.h"
#include "T3D/player.h"

#include "console/console.h"

#include "gfx/gfxDevice.h"
#include "app/game.h"

#include "T3D/ShapeBase.h"
#include "guiRadarTSCtrl.h"
#include "console/consoleTypes.h"
#include "T3D/gameBase/gameConnection.h"
#include "T3D/shapeBase.h"
#include "T3D/sphere.h"
#include "gfx/primBuilder.h"

IMPLEMENT_CONOBJECT(GuiRadarTSCtrl);

// vertices for the quad used for rendering the elliptic plane
static const Point3F planeVerts[4]=
{
   Point3F(-1, 1, 0),
   Point3F(1, 1, 0),
   Point3F(-1, -1, 0),
   Point3F(1, -1, 0)
};

// and these are for the blip billboards
static const Point3F quadVerts[4]=
{
   Point3F(-1, 0, 1),
   Point3F(1, 0, 1),
   Point3F(-1, 0, -1),
   Point3F(1, 0, -1)
};

// texture coords for the quads (when drawn as a trianglestrip)
static const Point2F quadTexCoords[4] =
{
   Point2F(0,0),
   Point2F(1,0),
   Point2F(0,1),
   Point2F(1,1)
};

// sphere
static Sphere sphere(Sphere::Icosahedron);

//--------------------------------------------------------------------------
GuiRadarTSCtrl::GuiRadarTSCtrl()
{

	 mSphereDetail = 2;

   // textures
   mEllipticBitmap = StringTable->insert("");
   mEllipticTextureHandle = NULL;
   mBlipBitmap = StringTable->insert("");
   mBlipTextureHandle = NULL;
	mTargetBlipBitmap = StringTable->insert("");
	mTargetBlipTextureHandle = NULL;

	strcpy(mTargetShapeName,"");

   // colors
   mEllipticColor.set(0.0, 0.75, 0.0, 0.75);
   mSphereColor.set(0.0f, 0.5f, 0.0f, 0.25f);
   mBlipColor.set(1.0f, 1.0f, 1.0f, 1.0f);
   mUnBlipColor.set(0.5f, 0.0f, 0.0f, 0.75f);
   mvehBlipColor.set(0.0f, 1.0f, 0.0f, 0.75f);
   mvehUnBlipColor.set(0.0f, 0.5f, 0.0f, 0.75f);
   mStemColor.set(1.0f, 1.0f, 1.0f, 1.0f);

   // range
   mRange = 50.0f;

   // blip size
   mBlipSize = 1.0f;
}

... continued in next post
#12
11/04/2011 (9:45 am)
//---------------------------------------------------------------------------
void GuiRadarTSCtrl::initPersistFields()
{
	Parent::initPersistFields();

	addGroup("Radar");
	addField("PlaneBitmap",		TypeFilename,	   Offset(mEllipticBitmap,    GuiRadarTSCtrl));
   addField("PlaneColor",     TypeColorF,       Offset(mEllipticColor,     GuiRadarTSCtrl));
   addField("BlipBitmap",     TypeFilename,     Offset(mBlipBitmap,        GuiRadarTSCtrl));
   addField("BlipColor",	   TypeColorF,       Offset(mBlipColor,         GuiRadarTSCtrl));
   addField("unblipColor",	TypeColorF,       Offset(mUnBlipColor,         GuiRadarTSCtrl));
   addField("vehblipColor",	TypeColorF,       Offset(mvehBlipColor,         GuiRadarTSCtrl));
   addField("vehunblipColor",	TypeColorF,       Offset(mvehUnBlipColor,         GuiRadarTSCtrl));
   addField("BlipSize",       TypeF32,          Offset(mBlipSize,          GuiRadarTSCtrl));
   addField("StemColor",      TypeColorF,       Offset(mStemColor,         GuiRadarTSCtrl));
   addField("SphereColor",    TypeColorF,       Offset(mSphereColor,       GuiRadarTSCtrl));
	 addField("SphereDetail",    TypeS32,       Offset(mSphereDetail,       GuiRadarTSCtrl));
   addField("Range",          TypeF32,          Offset(mRange,             GuiRadarTSCtrl));
	endGroup("Radar");
}

void GuiRadarTSCtrl::setTarget(const char *TargetShapeBaseName)
{
	if (*TargetShapeBaseName)
		strcpy(mTargetShapeName,TargetShapeBaseName);	
}

//---------------------------------------------------------------------------
void GuiRadarTSCtrl::setEllipticBitmap(const char *name)
{
   mEllipticBitmap = StringTable->insert(name);

   if (*mEllipticBitmap) 
	  mEllipticTextureHandle = GFXTexHandle(mEllipticBitmap, &GFXDefaultStaticDiffuseProfile, "Adescription");
      //mEllipticTextureHandle = GFXTexHandle(mEllipticBitmap, &GFXDefaultStaticDiffuseProfile);
   else 
      // Reset handles if UI object is hidden
	   mEllipticTextureHandle = NULL;
   
   setUpdate();
}

//---------------------------------------------------------------------------
void GuiRadarTSCtrl::setBlipBitmap(const char *name)
{
   mBlipBitmap = StringTable->insert(name);

   if (*mBlipBitmap) 
	  mBlipTextureHandle = GFXTexHandle(mBlipBitmap, &GFXDefaultStaticDiffuseProfile, "Adescription");
      //mBlipTextureHandle = GFXTexHandle(mBlipBitmap, &GFXDefaultStaticDiffuseProfile);
   else 
      // Reset handles if UI object is hidden
	   mBlipTextureHandle = NULL;
   
   setUpdate();
}

//---------------------------------------------------------------------------
bool GuiRadarTSCtrl::onWake()
{
	if (! Parent::onWake())
		return false;
	setActive(true);

	setEllipticBitmap(mEllipticBitmap);
   setBlipBitmap(mBlipBitmap);

   return true;
}

//--------------------------------------------------------------------------
void GuiRadarTSCtrl::onSleep()
{
	mEllipticTextureHandle = NULL;
   mBlipTextureHandle = NULL;
	Parent::onSleep();
}

//---------------------------------------------------------------------------
// set up the camera position for rendering the 3D scene within this control
bool GuiRadarTSCtrl::processCameraQuery(CameraQuery *camq)
{
   // pretty hacky hardcoded values
   // gives a reasonable viewing angle
   camq->nearPlane = 0.1f; // near clip plane
   camq->farPlane = 20.0f; // far clip plane
   camq->fov = (F32)M_PI/6;     // field of view
   MatrixF cam;
   cam.set(EulerF((F32)M_PI/8, 0, 0)); // rotation
   cam.setColumn(3, Point3F(0, -4, 1.65f)); // position
   camq->cameraMatrix = cam;
   return (true);
}

... continued in next post
#13
11/04/2011 (9:47 am)
//---------------------------------------------------------------------------
// render the world that this control sees
void GuiRadarTSCtrl::renderWorld(const RectI &updateRect)
{
   // Must have a connection
   GameConnection* conn = GameConnection::getConnectionToServer();
   if (!conn) return;
   
   // Must have controlled object
   GameBase * control = dynamic_cast<GameBase*>(conn->getControlObject());
   if (!control) return;

   // get the camera transform for the connection
   MatrixF camMat;
   conn->getControlCameraTransform(0,&camMat);
   // get the position for use later
   Point3F camPos = camMat.getPosition();

   // invert the camera transform - 
   // this will then allow us to transform other objects into our own object space
   camMat.inverse();

   GFXStateBlockDesc desc;
   desc.zEnable = false;
   desc.ffLighting = false;  
   desc.setCullMode( GFXCullNone );  
   desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);  
   desc.samplers[0].textureColorOp = GFXTOPModulate;  
   desc.samplers[1].textureColorOp = GFXTOPDisable;
   GFXStateBlockRef myState = GFX->createStateBlock(desc);  
   GFX->setStateBlock(myState);
   // first draw the elliptic plane if we need to
   if(mEllipticTextureHandle)
   {
      GFXTextureObject *texture = mEllipticTextureHandle;
      GFX->setTexture(0, texture);

	   PrimBuild::color(mEllipticColor);
      PrimBuild::begin(GFXTriangleStrip, 4);
      for(int i=0; i<4; i++)
      {
         PrimBuild::texCoord2f(quadTexCoords[i].x, quadTexCoords[i].y);
		   PrimBuild::vertex3fv(planeVerts[i]);
      }
      PrimBuild::end();
   }
   
	 if (mSphereDetail > 4)
			mSphereDetail = 4;

   // then the sphere
	const Sphere::TriangleMesh *sphereMesh = sphere.getMesh(mSphereDetail); // sphere.getMesh(2) gives a slighty 'chunky' sphere - go higher if you can handle the framerate hit
	S32 numPoly = sphereMesh->numPoly;
	S32 totalPoly = 0;

	GFXVertexBufferHandle<GFXVertexPC> verts(GFX, numPoly*3, GFXBufferTypeVolatile);
	verts.lock();
	S32 vertexIndex = 0;
	for (S32 i=0; i<numPoly; i++)
	{
		totalPoly++;

		verts[vertexIndex].point = sphereMesh->poly[i].pnt[0];
		verts[vertexIndex].color = mSphereColor;
		vertexIndex++;

		verts[vertexIndex].point = sphereMesh->poly[i].pnt[1];
		verts[vertexIndex].color = mSphereColor;
		vertexIndex++;

		verts[vertexIndex].point = sphereMesh->poly[i].pnt[2];
		verts[vertexIndex].color = mSphereColor;
		vertexIndex++;
	}
	verts.unlock();

	GFXStateBlockDesc desc2;
	desc2.setCullMode(GFXCullNone);
	desc2.zEnable = false;
	desc2.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);

	GFX->setStateBlockByDesc( desc2 );
	GFX->setupGenericShaders( GFXDevice::GSColor );

	GFX->setVertexBuffer( verts );
	GFX->drawPrimitive( GFXTriangleList, 0, totalPoly );

	GFX->setStateBlockByDesc( desc );
	GFX->setupGenericShaders();
   
   // Now do the radar signatures
   // firstly, we will be drawing billboards, so get the current world transform matrix
   MatrixF worldMat = GFX->getWorldMatrix();
   // extract the up and right vectors
   Point3F up;
   Point3F right;
   worldMat.getRow(0,&right);
   worldMat.getRow(2,&up);
   right.normalize();
   up.normalize();
   // then build the coordinates that we'll use for the billboards
   // oops, another hard coded value, ah well...
   right *= mBlipSize * 0.05f;
   up    *= mBlipSize * 0.05f; 

   // set up the texture that we'll use for the blips
   // is this the correct way to do it???
   GFXTextureObject *texture = mBlipTextureHandle;
	GFXTextureObject *targetTexture = mTargetBlipTextureHandle;

... continued in next post
#14
11/04/2011 (9:48 am)
// Go through all ghosted objects on connection (client-side)
   for (SimSetIterator itr(conn); *itr; ++itr) 
   {
	   // Make sure that the object is a shapebase object
	   //if ((*itr)->getTypeMask() & ShapeBaseObjectType) 
      //{
		   ShapeBase* shape = dynamic_cast<ShapeBase*>(*itr);
		   // Make sure that the object isn't the client

       if ( shape ) {

		   if (shape != control) 
         {
			   // Make sure the shapebase object is a player (or Vehicle)
			   if (shape->getTypeMask() & ( PlayerObjectType | VehicleObjectType ) ) 
            {
               // get position of object
				   Point3F objPos = shape->getPosition();

               // get vector between object and observer
               Point3F objVec = objPos - camPos;

               // don't draw if outside of current radar range
               if(objVec.lenSquared() > (mRange * mRange))
                  continue;
               
               // transform it into the coordinate space of the viewer
               camMat.mulP(objPos);

               // scale it according to the current radar range
               objPos /= mRange;

               // compress the z transform a bit, just for looks
               //objPos.z *= 0.5f;

					if (!strcmp(mTargetShapeName,""))
						GFX->setTexture(0, targetTexture);
					else
						GFX->setTexture(0, texture);

               // draw the blip
               // unfortunately, DX doesn't appear to allow specification of point size or line width like opengl
               // SO, lets build a quad using the view aligned coordinates we generated earlier....
               desc.samplers[0].textureColorOp = GFXTOPModulate;
			//GFX->setTextureStageColorOp(0, GFXTOPModulate);
			   if (shape->getTypeMask() & ( PlayerObjectType ) ) 
				{
					PrimBuild::color(mBlipColor);
				} else {
					PrimBuild::color(mvehBlipColor);
				}

               PrimBuild::begin(GFXTriangleStrip, 4);
                  PrimBuild::texCoord2f(quadTexCoords[0].x, quadTexCoords[0].y);
                  PrimBuild::vertex3fv(objPos - right + up);
                  PrimBuild::texCoord2f(quadTexCoords[1].x, quadTexCoords[1].y);
                  PrimBuild::vertex3fv(objPos + right + up);
                  PrimBuild::texCoord2f(quadTexCoords[2].x, quadTexCoords[2].y);
                  PrimBuild::vertex3fv(objPos - right - up);
                  PrimBuild::texCoord2f(quadTexCoords[3].x, quadTexCoords[3].y);
                  PrimBuild::vertex3fv(objPos + right - up);
               PrimBuild::end();
               
               // draw a line from the blip to the elliptic - will have to use quads if you want a line thicker than 1px
               // end point of line
               Point3F endPos = objPos;
               endPos.z = 0;

               // draw the line
			   desc.samplers[1].textureColorOp = GFXTOPDisable;
               //GFX->setTextureStageColorOp(0, GFXTOPDisable);
               PrimBuild::color(mStemColor);
               PrimBuild::begin(GFXLineList, 2);
                  PrimBuild::vertex3fv(objPos);
                  PrimBuild::vertex3fv(endPos);
               PrimBuild::end();
			   }
		   }
	   }
   }
   
   // all done
   GFX->setClipRect(updateRect);
       
}

... continued in next post
#15
11/04/2011 (9:49 am)
//------------------------------------------------------------------------
// script interface
ConsoleMethod( GuiRadarTSCtrl, setEllipticBitmap, void, 3, 3, "(string filename)"
              "Set the bitmap for the horizontal plane of the control.")
{
   object->setEllipticBitmap(argv[2]);
}

ConsoleMethod( GuiRadarTSCtrl, SetRange, void, 3, 3, "(float)"
              "Sets the Range of the the control. Default is 250")
{
   object->setRange(dAtof(argv[2]));
}

ConsoleMethod( GuiRadarTSCtrl, getRange, F32, 2, 2, "()"
              "gets the current range of the control")
{
   return object->getRange();
}

ConsoleMethod( GuiRadarTSCtrl, setEllipticColor, void, 3, 3, "(Color)"
              "set the color of the horizontal plane")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setEllipticColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setSphereColor, void, 3, 3, "(Color)"
              "set the color of the sphere")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setSphereColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setBlipColor, void, 3, 3, "(Color)"
              "set the color of the radar blips")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setBlipColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setStemColor, void, 3, 3, "(Color)"
              "set the color of the blip lines")
{
   ColorF color;
   dSscanf(argv[2], "%g %g %g %g", &color.red, &color.green, &color.blue, &color.alpha);
   object->setStemColor(color);
}

ConsoleMethod( GuiRadarTSCtrl, setTarget, void, 2, 3, "(str Target ShapebaseName)"
               "Set the target ShapeBaseName, if no Target is sent it is cleared.")
{
	if (argv[2])
		object->setTarget(argv[2]);
	else
		object->setTarget("");

}


END of guiRadarTSCtrl.cpp


... continued in next post
#16
11/04/2011 (9:53 am)
That's it for the engine changes...

In your PlayGUI or other GUI, put this to create the object (adjust the PlaneBitmap line to point to where you placed the images for the radar):

new GuiRadarTSCtrl(Radar3D) {
      cameraZRot = "0";
      forceFOV = "0";
      reflectPriority = "1";
      margin = "0 0 0 0";
      padding = "0 0 0 0";
      anchorTop = "1";
      anchorBottom = "0";
      anchorLeft = "1";
      anchorRight = "0";
      position = "832 384";
      extent = "192 191";
      minExtent = "8 2";
      horizSizing = "relative";
      vertSizing = "relative";
      profile = "GuiDefaultProfile";
      visible = "0";
      active = "1";
      tooltipProfile = "GuiToolTipProfile";
      hovertime = "1000";
      isContainer = "0";
      hidden = "1";
      canSave = "1";
      canSaveDynamicFields = "0";
      PlaneBitmap = "art/gui/radar/radar3D.png";
      PlaneColor = "0.321569 0.498039 0.858824 0.75";
      BlipColor = "1 0 0 1";
      unblipColor = "0.5 0 0 0.75";
      vehblipColor = "0 1 0 0.75";
      vehunblipColor = "0 0.5 0 0.75";
      BlipSize = "0.75";
      StemColor = "1 1 1 1";
      SphereColor = "0 0.0941177 1 0.0125";
      SphereDetail = "2";
      range = "1000";
   };

That should do it I think... Please post if it does not work, as I may have missed something. But the resource works fine in our installation of AFX 2.0 for T3D 1.1 Final, using this code, so hopefully it should work for you as well.

Note that this radar works well alongside the standard Compass resource, so for example you can have the Compass as the default radar when walking, but when you mount a flying vehicle it hides the Compass and shows the 3D Radar instead.

I can also post the current working code for the Compass if anyone needs it, just let me know.

Happy hunting!
#17
11/04/2011 (10:29 am)
Ty Paul, i think this will help much. As soon as i get the time, i will test this:)
#18
11/04/2011 (1:37 pm)
Paul, it would have been much better if you simply archived up those files to a zip file and uploaded it somewhere, and then linked it here instead of the multiple forum posts. ;)
#20
11/07/2011 (7:59 am)
Seems that 1.1 final miss the sphere.h and sphere.cpp . So i just copyed from 1.1 beta3 and now the radar works.

Page «Previous 1 2