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
the .cpp file
put this in the play gui or another gui
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);
};
#endifthe .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";
};About the author
#22
would be nice to have a server side component, so that if you have things that are cloaked for example, that it doesnt show on the radar and cant hack your way to see it since the server wouldn't let you.
although maybe it could be done by not sending the objects data if cloaked and so the radar wouldnt show it either.
anyway just curious :)
11/08/2011 (11:13 am)
I admit I have not had a chance to dig through the code, but is this implemented so that the server determines what you see on the radar or is it completely client side?would be nice to have a server side component, so that if you have things that are cloaked for example, that it doesnt show on the radar and cant hack your way to see it since the server wouldn't let you.
although maybe it could be done by not sending the objects data if cloaked and so the radar wouldnt show it either.
anyway just curious :)
#23
...But by the looks of things, you should be able to put a check in the routine above to see if the object is cloaked or not. I assume by setting some "cloaked = true" variable on the object, and making sure that variable gets transferred with the ghost.
Not sure if that would work or not, but perhaps you could give it a try?
11/08/2011 (11:24 am)
It appears to be done client-side:// 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;...But by the looks of things, you should be able to put a check in the routine above to see if the object is cloaked or not. I assume by setting some "cloaked = true" variable on the object, and making sure that variable gets transferred with the ghost.
Not sure if that would work or not, but perhaps you could give it a try?
Paul Weston
Gambit Realm
I realize I could have zipped up the files and put them somewhere, but figured there had already been enough confusion over the different versions, etc, and it would be nice to just have the code right here.
Anyhow, if it helps one person that's a good thing :)