Game Development Community

dev|Pro Game Development Curriculum

GuiRadarCtrl TGEA

by Chris Byars · 04/02/2006 (10:28 am) · 11 comments

Download Code File

After painstaking and mind-numbing efforts, I was able to convert the GuiRadarCtrl resource from oh so long ago by Matt Webster to be fully functional in the Torque Game Engine Advanced, tested in versions MS3-1.03.

Put both of these files in engine/gui/game/, add them to your project, and compile it. Follow the same instructions as the old GuiRadarCtrl resource.

Note: The images default to:

fps/client/ui/radar_base
fps/client/ui/radarDot
fps/client/ui/radarUp
fps/client/ui/radarDown

If you want to change the filepaths, simply edit the GuiRadarCtrl.cpp file where they are hardcoded.

Enjoy.

#1
03/13/2006 (2:51 am)
Code doesnt take care of scaling when you change the radar range.

Do something along the lines of:

// Adjust object's vector to represent rotation of camera
float objectAngle = Vector3dToDegree(newCoord);
F32 HWidth = mBounds.extent.x/2.0;
float length = newCoord.len()*HWidth/mRadius;

Cant remember if that was part of the original ressource or a modification I did to it later
#2
04/18/2006 (7:25 pm)
For some reason this doesn't work with MS3+, any idea why?

(I did change the getServerConnection to getConnectionToServer, so it compiles, however TSE crashes once you double click to load TSE.exe.)
#3
04/20/2006 (6:16 am)
Hey C2. I'm having the same problem with my radar as of MS3. If I don't include it in the project then everythign works fine, but I get errors when I launch my game and load the GUI. If I include it in my project and change the getServerConnection to getConnectionToServer then it compiles fine but crashes immediately on loading.

If you figure out a fix, please let me know.
#4
04/21/2006 (10:32 am)
You guys arent running debug releases, are you?

If you had been, you would have seen the following error message:

"Attempting to get invalid GFX device."

being called from engine\gfx\gfxdecice.cpp

the error message is called on line 29 of that file.

With a little debugging I found that the error is called from guiRadarCtrl.cpp line 32... I had the path to the image wrong, which doesnt seem to be the issue.

The problem is that this line in gfxDecive:
AssertFatal( smActiveDeviceIndex > -1 && smGFXDevice[smActiveDeviceIndex] != NULL, "Attempting to get invalid GFX device." );

fails because smActiveDeviceIndex is -1.

I dont know much of anything about the TSE gfx layer.... but hopefully this info will help someone else solve the issue.
#5
04/21/2006 (10:55 am)
I ran it with the radar in and without.

When the radar is not in, the constructor gets called:

GFXDevice::GFXDevice()

then

GFXDevice *GFXDevice::get()

is called which is good.

Get gets called before the constructor when the radar is in, because the radar constructor calls it when it allocates textures. That is bad. Youre getting a device that doesnt exist, causing an error.

So either the radar constructor is being called earlier then its suppsoed to (I cant figure out where its called from) or it shouldnt be allocating textures in the constructor.
#6
04/21/2006 (12:04 pm)
Ok. here's what I did. It looks like it's working.

but I dont have a way to test it.

At least it doesnt crash or anything.

Add this to the public section of guiRadarCtrl.h
Quote:
bool onAdd();

add this to the cpp

Quote:
bool GuiRadarCtrl::onAdd()
{
if (!Parent::onAdd())
return false;

mTextureObject = GFXTexHandle("fps/client/ui/radar_base", &GFXDefaultGUIProfile);
mRadarDot = GFXTexHandle("fps/client/ui/radarDot", &GFXDefaultGUIProfile);
mRadarUp = GFXTexHandle("fps/client/ui/radarUp", &GFXDefaultGUIProfile);
mRadarDown = GFXTexHandle("fps/client/ui/radarDown", &GFXDefaultGUIProfile);

return true;
}

Comment out these 4 lines in the constructor:
Quote:
mTextureObject = GFXTexHandle("fps/client/ui/radar_base", &GFXDefaultGUIProfile);
mRadarDot = GFXTexHandle("fps/client/ui/radarDot", &GFXDefaultGUIProfile);
mRadarUp = GFXTexHandle("fps/client/ui/radarUp", &GFXDefaultGUIProfile);
mRadarDown = GFXTexHandle("fps/client/ui/radarDown", &GFXDefaultGUIProfile);

Now it should load the textures after the gfx device is created, which solves the problems.

Make sure you got your directory right ;)
#7
04/21/2006 (12:48 pm)
I tested this in multiplayer. My changes above work perfectly.

Enjoy

-Chris Labombard

EDIT: Anyone want to get the guiCompassCtrl working ?

EDIT2: Nevermind, I got the base iamge to rotate with the player instead. Now, the radar_base acts as the compass.
#8
11/11/2006 (12:03 am)
Do you know if this resource will work with TGE 1.5?
#9
11/14/2006 (1:33 pm)
This one won't; it's changed to work with TSE's rendering code. The radar for TGE should still work, just need to change a few include lines of code, I think.
#10
01/20/2007 (5:53 pm)
Just curious. Was anyone able to get the Compass to work for TSE? I see that a few people did, but there was no resource provided.

-Andy
#11
06/02/2007 (6:19 am)
Hi brainiac,
can you post your code for the radar_base acts as the compass?

thx :)