Scenegraph searching/traversal
by Rob Segal · in Torque Game Engine · 01/15/2006 (1:50 pm) · 4 replies
I gotta be missing something here. Surely there is a way I can traverse/search the scene graph to find an object of a specific name?
#2
01/17/2006 (3:49 pm)
Sim::findObject may be what I'm looking for I will have to check that out. I was looking for functions like this because I want to be able to access arbitrary objects on the scenegraph to query information about them. That's the short of what I would like to do.
#3
You can also (although ::findObject is very quick with named objects) simply keep track of important objects--if they are singletons then a global pointer works well (see things like gClientSceneGraph/gServerSceneGraph, etc.), or create a SimSet container and then iterate over those whenever you need to access/modify one. The (script) ClientGroup is an example of this.
EDIT: If your only search limitation criteria is physical distance of game objects (search within 10 meters, etc.), then you'll want something like containerRadiusSearch() (script console method), or Container::castRay() for LoS type searches.
01/17/2006 (3:52 pm)
Then Sim::findObject is what you are looking for. It has two primary options: lookup by object name (you have to name your objects on creation for this to work), or lookup via ObjectId (must be the object id, not a ghost id, etc.).You can also (although ::findObject is very quick with named objects) simply keep track of important objects--if they are singletons then a global pointer works well (see things like gClientSceneGraph/gServerSceneGraph, etc.), or create a SimSet container and then iterate over those whenever you need to access/modify one. The (script) ClientGroup is an example of this.
EDIT: If your only search limitation criteria is physical distance of game objects (search within 10 meters, etc.), then you'll want something like containerRadiusSearch() (script console method), or Container::castRay() for LoS type searches.
#4
01/17/2006 (4:24 pm)
That is solid info Stephen. Thanks for your help. I think this will work quite nicely.
Torque 3D Owner Stephen Zepp
There is very little reason to traverse the scenegraph itself, instead you should be searching the simulation (specifically the container system) for proximity based checks. Either Sim::findObject(), or containerRayCast() should solve most of your needs.