Gui Reticle HUD for TGE(A) With Target Cycling
by Martin Schultz · 12/17/2007 (7:59 am) · 67 comments
Download Code File
This resource contains a gui control element which displays a rectangle around every shape in the view frustrum and displays the currently selected shape in a different color (target selection). The display style of the rectangles can be chosen between full rectangles and rendering only the corners around the shape. Furthermore the normal / selected colors can be freely chosen as well as the minimum size of the rectangle once the shape is very far away (minimum rectangle size).
Cycling through the targets is done by using the mouse wheel. The client transmits then the selected ghost id to the server and the server then does a lookup to find out the server player id. The id is then stored in the %client variable for the corresponding client. This player id can then be used in an weapon onFire function to actually track the target for example when using a homing missile.
The attached zip cointains a readme file and the source file for TGE and TGEA.
Please note that the target cycling code is somewhat buggy and not battle-proven, so excuse that the cycling code is not perfect yet. Will improve this soon. :-)
This resource contains a gui control element which displays a rectangle around every shape in the view frustrum and displays the currently selected shape in a different color (target selection). The display style of the rectangles can be chosen between full rectangles and rendering only the corners around the shape. Furthermore the normal / selected colors can be freely chosen as well as the minimum size of the rectangle once the shape is very far away (minimum rectangle size).
Cycling through the targets is done by using the mouse wheel. The client transmits then the selected ghost id to the server and the server then does a lookup to find out the server player id. The id is then stored in the %client variable for the corresponding client. This player id can then be used in an weapon onFire function to actually track the target for example when using a homing missile.
The attached zip cointains a readme file and the source file for TGE and TGEA.
Please note that the target cycling code is somewhat buggy and not battle-proven, so excuse that the cycling code is not perfect yet. Will improve this soon. :-)
#2
11/04/2007 (6:41 am)
Hehe, have fun with it! :-) Let me know if you have any questions and post them here - I'm subscribed to this resource and get mail notification.
#3
say all of the planets in range (shown in my screenshot in a previous post) what would
I need to change in the code? I ask, not only to be able to "target" the planets, but I'm
going to run into the same issue with space stations.
I feel like I'm coming across as someone that wants others to do all the work for me, but
I'm really trying to learn and dig into the code before I ask these questions. I have other
modifications I want to make to this target reticle, but I'm going to work on that myself for
a few days.
11/06/2007 (11:34 am)
Ok, this might seem like a silly question, but if I were to want to show a reticle onsay all of the planets in range (shown in my screenshot in a previous post) what would
I need to change in the code? I ask, not only to be able to "target" the planets, but I'm
going to run into the same issue with space stations.
I feel like I'm coming across as someone that wants others to do all the work for me, but
I'm really trying to learn and dig into the code before I ask these questions. I have other
modifications I want to make to this target reticle, but I'm going to work on that myself for
a few days.
#4
What kind of object type is your planet? Look in line 149 of the guiReticleHud:
if ((*itr)->getType() & ShapeBaseObjectType)
It currently "selects" only shape based object types and 2 lines below the first also this one:
if (shape != control && shape->getShapeName())
So the planets also need to have a valid shapeName (or comment out the second part of this if statement).
Does that help?
11/06/2007 (11:37 am)
It's not a silly question! :-) What kind of object type is your planet? Look in line 149 of the guiReticleHud:
if ((*itr)->getType() & ShapeBaseObjectType)
It currently "selects" only shape based object types and 2 lines below the first also this one:
if (shape != control && shape->getShapeName())
So the planets also need to have a valid shapeName (or comment out the second part of this if statement).
Does that help?
#5
file and made that change. So I was close.. :-)
11/06/2007 (11:43 am)
The planets are probably missing the shapename. I had found those lines in the guiReticleHud.ccfile and made that change. So I was close.. :-)
#6
11/06/2007 (11:43 am)
Hehe, great! :-)
#7
Thus if I ever want to do anything with them like say, follow their orbit paths...
Then they need to be a different type of object, which will likely make it easier to
have a reticle show up on them.
11/06/2007 (12:55 pm)
The Planets are added to the mission as TSStatic objects. Thus if I ever want to do anything with them like say, follow their orbit paths...
Then they need to be a different type of object, which will likely make it easier to
have a reticle show up on them.
#8
11/14/2007 (6:22 pm)
Would it be possible to change the targeting boxes to images instead?
#9
11/14/2007 (10:18 pm)
Yes, quite easy. Exchange the dglDrawRect call by a drawBitmap call.
#10
Regards!
11/18/2007 (7:04 am)
Very good, going to try it tonight :) does it have a arrow pointer if the target is off screen?Regards!
#11
11/18/2007 (7:19 am)
Thanks. No, no arrow included, but good idea!
#12
11/21/2007 (12:54 am)
Martin, does the blocks/reticule resize as the shapes come closer or goes further?
#13
11/21/2007 (12:56 am)
Yes, it takes the bounding box of the shape and draws the rectangle around that. So it scales up and down according to the distance. At a very far distance, the minSize kicks in and and the rectangle wouldn't scale smaller than the minSize parameter.
#14
11/21/2007 (1:08 am)
Fantastic. Now to rip it all apart and make it work with my guiTargetReticule. I use a bitmaps rather than a box, so I hope the changes aren't too hard.
#15
11/21/2007 (1:10 am)
I guess it works too with bitmaps. In the rendering section there's the block calculating the bounding box and then drawing depending on the config the corresponding rectangle or cornered rectangle. Replace that with your dglDrawBitmapStretched call and it should work. :-)
#16
11/22/2007 (5:16 am)
I'm working on making the reticle animated (like the other TGEA resource) The reticle resource is very useful - I added distance fading, ship and team naming, and enemy coloring to it (target selected is now a double solid rectangle) - sensor lock fills between the two. The targeting selection helped my target selection hud as well.
#17
11/22/2007 (5:35 am)
Great! :-)
#18
12/20/2007 (2:49 pm)
I've got a problem: I cannot select a target/The target is not displayed in another color. What did I do wrong?
#19
12/21/2007 (12:26 am)
Well, did you send from the client to the server a command to select the target? There's a function for that inside.
#20
12/21/2007 (1:12 am)
I just added the code as said in the readme. When I start my game the opponents are selected, but I cannot change the red target, actually there is no red target... 
Torque Owner Daniel Buckmaster
T3D Steering Committee