CastRay using a cone-shape?
by Stefan Lundmark · in Torque Game Engine · 07/15/2006 (3:30 am) · 9 replies
What I need is a castRay function which checks for objects within a cone instead of a straight line. Correct me if I'm wrong, but to my knowledge this is not possible without engine modifications.
It does sound like it shouldn't be too difficult to implement or modify, but I'm not having much success.

I found a few solutions, but they were either too heavy (ex: iterating trough object list and compare with the vector supplied) for using on a server or they did not work on both (ex: containerBoxEmpty) which I need for prediction.
Anyone implemented this before who can give pointers? Perhaps there's already functions which do this that I've overlooked?
Any info is appreciated.
It does sound like it shouldn't be too difficult to implement or modify, but I'm not having much success.

I found a few solutions, but they were either too heavy (ex: iterating trough object list and compare with the vector supplied) for using on a server or they did not work on both (ex: containerBoxEmpty) which I need for prediction.
Anyone implemented this before who can give pointers? Perhaps there's already functions which do this that I've overlooked?
Any info is appreciated.
About the author
#2
07/15/2006 (7:05 am)
Pyramid or "frustrum culling" is well documented. Maybe that would be simpler and just as effective. If so, resources embedded in the engine to support camera views might be useful in detecting the objects in the viewing frustrum.
#4
I've used that (basically just a dot product compare) for both selecting objects and missile "lock-on" sort of things. It seems to work well enough.
07/15/2006 (11:59 am)
Is iterating through the object list really too heavy?I've used that (basically just a dot product compare) for both selecting objects and missile "lock-on" sort of things. It seems to work well enough.
#5
T.
07/15/2006 (2:14 pm)
On the subject of frustrum culling, check out util/frustrumCuller.cc in 1.4 ... its really damn useful.T.
#6
I was trying to achieve a missile lock system. I settled on a less secure method where the client was authorative and selected objects much like guiShapeNameHud does.
Your resource (once again) looks to be useful though so I'll try that and reimplement.
Thanks alot! (:
@Max:
We did quick tests today with only 3 people so no in-depth testing - but that's the impression I got when profiling.
Thanks everyone.
07/15/2006 (3:29 pm)
@Orion:I was trying to achieve a missile lock system. I settled on a less secure method where the client was authorative and selected objects much like guiShapeNameHud does.
Your resource (once again) looks to be useful though so I'll try that and reimplement.
Thanks alot! (:
@Max:
We did quick tests today with only 3 people so no in-depth testing - but that's the impression I got when profiling.
Thanks everyone.
#7
I am about to dive into this as well, so I was glad to see this thread.
I'm not sure I understand how either Orion's functions or the frustum culler functions would help the performance problem that Stefan indicated. It seems like his solution to iterate through the, much smaller, client list (at the cost of security) is the only thing that address the performance cost.
I'm sure I'm missing something obvious....could one of you enlighten me?
Thanks
Todd
07/15/2006 (5:41 pm)
Hey guys,I am about to dive into this as well, so I was glad to see this thread.
I'm not sure I understand how either Orion's functions or the frustum culler functions would help the performance problem that Stefan indicated. It seems like his solution to iterate through the, much smaller, client list (at the cost of security) is the only thing that address the performance cost.
I'm sure I'm missing something obvious....could one of you enlighten me?
Thanks
Todd
#8
It'll give you a list that you can iterate through, I don't remember entirely how you do that and I don't think the function is utilized in normal TGE in the engine, though it can be done just fine.
07/15/2006 (6:41 pm)
Actually I forgot one step I usually take is to narrow down my potential search list by using the container method initRadiusSearch . You should be able to do it server side (gServerContainer) and also you can use a typemask so you only bother looking at vehicles, or vehicles/players/statics, or whatever your game has.It'll give you a list that you can iterate through, I don't remember entirely how you do that and I don't think the function is utilized in normal TGE in the engine, though it can be done just fine.
Associate Manoel Neto
Default Studio Name