Object Selection in TGEA
by Tim Tebow · in Torque Game Engine Advanced · 08/24/2008 (7:43 pm) · 9 replies
I posted this in another forum but had no luck it doesn't seem as many people post there as they do here so requested it to be deleted and posting here.
I'm trying to implement object selection and have tried to port a few of the object selection resources out there to TGEA 1.7.1 but with no luck as usual :)
I'm not asking how to do it but maybe some pointers on where to start, or maybe a resource that's more updated for us to use.
Here are a couple things -
I thought oh hey why not dig into how the editor selects objects and port that over so the client can do the same thing. I don't even know where to start here I have been trying to find something that maybe will tell me what functions are being called whenever I do something. For instance if I turn the mouse on it shows it in the console, or if I select a object while in the editor it shows what function its calling so i can dig into it that way. But cannot find how to tell that.
It seems the hurdle is getting guiNameShapeHud to work with your mouse click event. Ive tried reading some docs but really just not understanding why there needs to be a gui over the whole screen. why not just in areas you want them to be.
That being said object selection should be pretty simple you would think. Click get your 2d coords, then convert that into a 3d coord and just check your z index over and over to see if it runs into something x yards away.
Do you even need to do a bunch of source code changes for this?
Sorry if it seems like randomness some of it I was thinking up while writing. Any help surely would be great. This is just one of those things im just stumped on completely. I would go buy the afx package but that wont tell me how to do it just provide the code that does.
I'm trying to implement object selection and have tried to port a few of the object selection resources out there to TGEA 1.7.1 but with no luck as usual :)
I'm not asking how to do it but maybe some pointers on where to start, or maybe a resource that's more updated for us to use.
Here are a couple things -
I thought oh hey why not dig into how the editor selects objects and port that over so the client can do the same thing. I don't even know where to start here I have been trying to find something that maybe will tell me what functions are being called whenever I do something. For instance if I turn the mouse on it shows it in the console, or if I select a object while in the editor it shows what function its calling so i can dig into it that way. But cannot find how to tell that.
It seems the hurdle is getting guiNameShapeHud to work with your mouse click event. Ive tried reading some docs but really just not understanding why there needs to be a gui over the whole screen. why not just in areas you want them to be.
That being said object selection should be pretty simple you would think. Click get your 2d coords, then convert that into a 3d coord and just check your z index over and over to see if it runs into something x yards away.
Do you even need to do a bunch of source code changes for this?
Sorry if it seems like randomness some of it I was thinking up while writing. Any help surely would be great. This is just one of those things im just stumped on completely. I would go buy the afx package but that wont tell me how to do it just provide the code that does.
#2
*EDIT*
I am just going to have to play around with it more the link on your other post was the one ive been working with and trying to port and keep getting around 500 errors. it seems many of the methods/functions they used are not in TGEA which is the pain in the butt piece of this.
It seems you got the object selection to work really well in your project it looks good. Ill keep posting here next couple of days(don't have work so I can work on it all day next couple days)
08/24/2008 (9:09 pm)
Ok I will probably post back tomorrow or Tuesday after I have some time to try it out. Thank you for the quick reply.*EDIT*
I am just going to have to play around with it more the link on your other post was the one ive been working with and trying to port and keep getting around 500 errors. it seems many of the methods/functions they used are not in TGEA which is the pain in the butt piece of this.
It seems you got the object selection to work really well in your project it looks good. Ill keep posting here next couple of days(don't have work so I can work on it all day next couple days)
#3
%searchMasks = $TypeMasks::PlayerObjectType;
have some printf's set up so i know it going thru the code then have
if (%scanTarg)
{
echo("In scanTarg");
%targetObject = firstWord(%scanTarg);
%client.setSelectedObject(%targetObject);
echo(%targetObject);
}
but it keeps saying im selecting the terrain not sure why its even registering because my searchMask doesnt have that in there to register.
Any Ideas?
08/25/2008 (11:19 am)
Ok go it to half way register that im clicking I changed the search mask to this%searchMasks = $TypeMasks::PlayerObjectType;
have some printf's set up so i know it going thru the code then have
if (%scanTarg)
{
echo("In scanTarg");
%targetObject = firstWord(%scanTarg);
%client.setSelectedObject(%targetObject);
echo(%targetObject);
}
but it keeps saying im selecting the terrain not sure why its even registering because my searchMask doesnt have that in there to register.
Any Ideas?
#4
What you're describing should not happen. Without seeing the modified engine code and script, I have no clue why it's doing that.
08/26/2008 (1:15 am)
Use breakpoints in the engine instead of printf's. Check the values around the object selection code. Follow the code, it has all the answers.What you're describing should not happen. Without seeing the modified engine code and script, I have no clue why it's doing that.
#5
08/26/2008 (5:33 am)
It looks to be TSStatic Object type. I placed a buggy in stronghold and shot at it and it exploded when it hit the buggy which would tell me there is in fact a collision box but cannot select them.
#6
I have objects that do not collide, but I can select. I have objects that do collide, but I can not select (since I'm not interested in server side selection).
Also, if you notice. A vehicle is of VehicleObjectType not PlayerObjectType.
I hope I'm understanding correctly. I'd be happy to help, but I'd need to see some code.
08/26/2008 (11:08 am)
Collision does not equal selection.I have objects that do not collide, but I can select. I have objects that do collide, but I can not select (since I'm not interested in server side selection).
Also, if you notice. A vehicle is of VehicleObjectType not PlayerObjectType.
I hope I'm understanding correctly. I'd be happy to help, but I'd need to see some code.
#7
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7335
Few things you have to change for TGEA but nothing that would affect this issue.
Other then that it seems I can select everything execpt for anything that comes up as a "TSStatic" object and player characters.
I have also tried changing my search mask to
%searchMasks =
$TypeMasks::StaticObjectType | $TypeMasks::EnvironmentObjectType | $TypeMasks::TerrainObjectType |
$TypeMasks::InteriorObjectType | $TypeMasks::WaterObjectType | $TypeMasks::TriggerObjectType |
$TypeMasks::MarkerObjectType | $TypeMasks::ForceFieldObjectType | $TypeMasks::GameBaseObjectType |
$TypeMasks::ShapeBaseObjectType | $TypeMasks::CameraObjectType | $TypeMasks::StaticShapeObjectType |
$TypeMasks::PlayerObjectType | $TypeMasks::ItemObjectType | $TypeMasks::VehicleObjectType |
$TypeMasks::VehicleBlockerObjectType | $TypeMasks::ProjectileObjectType | $TypeMasks::ExplosionObjectType |
$TypeMasks::CorpseObjectType | $TypeMasks::DebrisObjectType | $TypeMasks::PhysicalZoneObjectType |
$TypeMasks::StaticTSObjectType | $TypeMasks::GuiControlObjectType | $TypeMasks::StaticRenderedObjectType |
$TyeMasks::DamagableItemObjectType ;
And still same results. Cant select the buggy or players, I can select terrain, water, interiors. Cannot select anything else in the defualt strong hold mission such as players, health pack, weapon, fire
Id be more then willing to post some code just let me know what you need to see.
I have a bunch of printf's it goes thru the code like its suppose to and displays everything correctly if i select a interior or terrain ect.. But if i click on a player it just acts stupid and like its not there.
08/26/2008 (11:13 am)
The code is almost 100% the same as the link that was on your post you pointed me to which has a link hat points tohttp://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7335
Few things you have to change for TGEA but nothing that would affect this issue.
Other then that it seems I can select everything execpt for anything that comes up as a "TSStatic" object and player characters.
I have also tried changing my search mask to
%searchMasks =
$TypeMasks::StaticObjectType | $TypeMasks::EnvironmentObjectType | $TypeMasks::TerrainObjectType |
$TypeMasks::InteriorObjectType | $TypeMasks::WaterObjectType | $TypeMasks::TriggerObjectType |
$TypeMasks::MarkerObjectType | $TypeMasks::ForceFieldObjectType | $TypeMasks::GameBaseObjectType |
$TypeMasks::ShapeBaseObjectType | $TypeMasks::CameraObjectType | $TypeMasks::StaticShapeObjectType |
$TypeMasks::PlayerObjectType | $TypeMasks::ItemObjectType | $TypeMasks::VehicleObjectType |
$TypeMasks::VehicleBlockerObjectType | $TypeMasks::ProjectileObjectType | $TypeMasks::ExplosionObjectType |
$TypeMasks::CorpseObjectType | $TypeMasks::DebrisObjectType | $TypeMasks::PhysicalZoneObjectType |
$TypeMasks::StaticTSObjectType | $TypeMasks::GuiControlObjectType | $TypeMasks::StaticRenderedObjectType |
$TyeMasks::DamagableItemObjectType ;
And still same results. Cant select the buggy or players, I can select terrain, water, interiors. Cannot select anything else in the defualt strong hold mission such as players, health pack, weapon, fire
Id be more then willing to post some code just let me know what you need to see.
I have a bunch of printf's it goes thru the code like its suppose to and displays everything correctly if i select a interior or terrain ect.. But if i click on a player it just acts stupid and like its not there.
#9
static void consoleInit();
in gameTSCtrl.cpp file
That did the trick I didn't see that in V2 of the resource...
So I have everything working execpt the stupid bounding box and its driving me crazy. For some reason in shapebase.cpp the renderObject is not being called when I click on a object. I'm guessing TGEA takes a different route.
So im trying to take the code from that renderObject and make my own function. Anyone have any tips/ ideas.
Thanks!
08/26/2008 (2:02 pm)
What did it was adding static void consoleInit();
in gameTSCtrl.cpp file
That did the trick I didn't see that in V2 of the resource...
So I have everything working execpt the stupid bounding box and its driving me crazy. For some reason in shapebase.cpp the renderObject is not being called when I click on a object. I'm guessing TGEA takes a different route.
So im trying to take the code from that renderObject and make my own function. Anyone have any tips/ ideas.
Thanks!
Torque 3D Owner Avid Gamer
I understand your question is for TGEA and not TGE, but the calls are very similar. Check out this thread to see the answer to the exact same question you asked.
If you don't have a custom GUI, just use the object selection code directly. To get it to pick up client side only objects, check out the containerRayCast consolefunction in C++ and make your own that simply uses gClientContainer instead of gServerContainer.
Hope that makes sense. Happy to elaborate if wanted.