Game Development Community

Find Hidden shapes?

by Firas · in Torque Game Engine · 08/16/2005 (10:28 am) · 15 replies

Hi guys

I have a small problem about the hidden objects

For my bot I use the function: InitContainerRadiusSearch to check the place around me if there is any objects so try to avoid but I have a small problem which is:

the function : InitContainerRadiusSearch

can't detect the hidden objects like hidden nodes or hidden trees
for ex : I have a node it's number is 1908 I use 1908.sethidden(true);

so how can I make my bot detect the hidden nodes or objects?

#1
08/16/2005 (11:31 am)
Would it find the object if it was normally visible?

Why do you need to detect hidden objects?
#2
08/16/2005 (11:18 pm)
1- yes it can find the objects if it was normally visible.

2- becouse my game need this feature, I wont to place some hidden objects and nodes and if some king of bots detect them there will be an interaction between them.

so is there a solution for his situation?
#3
08/17/2005 (1:01 am)
Have you tried tracing the code to find where it's rejecting hidden objects? It might be a quick flag add to control this behavior.
#4
08/17/2005 (1:13 pm)
Please see this code:

function ch(%bot)
{
%position = getWords(%bot.gettransform(), 0, 2);
InitContainerRadiusSearch(%position, 100, $TypeMasks::StaticObjectType);
while ((%targetObject = containerSearchNext()) != 0)
echo("TargetID: " @ %targetObject @ " | targetName: " @ %targetObject.getname());
}

now I'm placing some objects and hide them like nodes , when I execute this function I have a list of the objects around my bot but when I hide my objects (shapes) and execute this function (the bot stand on the same place) I will have nothing (the InitContainerRadiusSearch will not detect them)
so please help?
#5
08/17/2005 (1:17 pm)
Quote:
becouse my game need this feature, I wont to place some hidden objects and nodes and if some king of bots detect them there will be an interaction between them.

Exactly what kind of interaction are we talking here?? Nothing as bad as Hot Coffee I hope!
#6
08/17/2005 (1:24 pm)
One thing you could do rather than alterning ContainerRadiusSearch would be to double up on nodes you want the AI to interact with. Add a non-graphical marker of some sort (like path nodes), that the RaduisSearch could look for instead of StaticObjectType.

Come to think of it, there may be a "hidden" typeMask. I don't see one listed however, though there is a "MarkerType" that would go with my initial suggestion.
#7
08/17/2005 (4:15 pm)
I imagine the ContainerRadiusSearch code has an if statement in it somewhere that checks if an object is hidden. If you remove it, then you'll find that stuff. This is in the C++ code.
#8
08/18/2005 (8:13 pm)
Ben
I was looking for the If statment that avoid the hidden objects so I did the following:
1- I have search for initRadiusSearch and found this function in SceneObject.cc and I look carefully insude
this function and found nothing about hidding objects.

2- inside the initRadiusSearch function there was a call to findobjects function so I check it too, but
found nothing inside it about hidden objects.

3- I think maybe the function containerSearchNext is the function that avoid th hidden objects so
I search there and found nothing too.

so please can you give me any help here?
#9
08/18/2005 (10:17 pm)
Calling setHidden on a shape removes it from the scene, which in turn pulls it out of the server and client containers. You'll need to find a different way of hiding objects. One option is to use a visiblity thread, either as part of the model or forced in code.
#10
08/18/2005 (10:26 pm)
Hmm, yup, looks like you're right.

But you didn't check setHidden().

void ShapeBase::setHidden(bool hidden)
{
   if (hidden != mHidden) {
      // need to set a mask bit to make the ghost manager delete copies of this object
      // hacky, but oh well.
      setMaskBits(CloakMask);
      if (mHidden)
         addToScene();
      else
         removeFromScene();

      mHidden = hidden;
   }
}

Notice how it's removed from the scene? :)
#11
08/18/2005 (10:53 pm)
I'm pretty sure I'm missing something. From my limited knowledge of how Torque functions, I would say that we remove the object from the server scene, and then when it comes time to send the data to our ghosts, the ghost manager runs a quick sanity check, wonders why it needs to bother with an object that isn't in the server scene, and then procedes to send out notifications to delete the client side ghosts of our object.

Offhand I'd say the best way to change that would be to use the CloakMask to send mHidden over the net, and if mHidden is true, just remove our object from the client scene. Assuming my knowledge of Torque at this level isn't completely wrong, that'll keep it from rendering and colliding on the client, but we'll still be sending over updates from the server.

Correct me if I'm wrong. I'm really quite interested in knowing what you have in mind.
#12
08/19/2005 (12:28 am)
Note my last reply was written before you posted, Alex. Not sure there's any real confusion going on, just want to make sure. :)
#13
08/19/2005 (12:37 am)
Okay, that makes a bit more sense now. I thought you were asking me to find some odd way that this removeFromScene() is different from any others. On the plus side, I think I suggested a viable solution.
#14
08/19/2005 (6:49 am)
2cents:
If the object needs to be invisible, cant you just scale it to 0,0,0 until found?
j
#15
08/19/2005 (7:05 am)
You could replace it with an invisible object. instead of:
%obj.setHidden(true);

use:

%obj.delete();
%newObj = new item() .....


My mounted particle emitters resource comes with an invisible object if you don't want ot make your own.