Game Development Community

Camera position

by Andrew "Anger" · in Torque Game Engine · 01/19/2006 (10:49 am) · 4 replies

The problem is pretty lame, I'm certain... However it's been killing me slowly for days, and I can't seem to find any suitable solution. What I want, is to highlight an object, which player is curently looking at, on the client (this part is trivial). Then, when player clicks RMB, I want to get camera position and direction (forward vector), and send it to server, so it can cast a ray, and perform some action on the object, that is hit. So far so good... I map RMB to "action()", which in turn calls the GameTSCtrl::onMouseDown() (there was no other way, because controls don't process input, if the cursor is off)... onMouseDown() calls GameGetCameraTransform(), and I find out that camera position is "0 0 0", no matter where in the world it actually is... The funny thing, that performing same set of actions in GuiCrosshairHud::onRender() (the per-frame highlight check) gives me a real camera position. What can be wrong?
Thanks in advance.

#1
01/19/2006 (10:56 am)
I'd be interested to find out what's going on there as well.

one workaround,
since you're already highlighting the object,
you already know the mouse is over the object,
so why not just send the object ID on RMB ?

ie, make a script global or something along the lines of "mouseHoverObject".
#2
01/19/2006 (11:14 am)
As far as I know, client and server object IDs don't match... So no use sending client-side object IDs to the server. There probably has to be some explanation to why this is happening.
#3
01/19/2006 (11:17 am)
True,
but there's functions for translating from one to the other.

here's an example from our codebase:
function ServerCmdUsableObjectClick(%client, %ghostIndexClnt)
{
   %obj = %client.resolveObjectFromGhostIndex(%ghostIndexClnt);
   if(isObject(%obj))
   {
       %obj.getDataBlock().onUse(%obj, %client.player);
   }
}
#4
01/19/2006 (11:05 pm)
Thanks, this thing actually works :) (although I don't like workarounds, because they eventually lead you to hell :) ) But it would still be curious to find out, why isn't camera giving out it's real position. Any Torque devs out there, who might know what's the problem? Thanks :)