Game Development Community

function serverCmdToggleCamera(%client)

by Ron Yacketta · in Torque Game Engine · 10/07/2002 (12:11 pm) · 17 replies

All,

In an attempt to create a couple new camera positions I
went looking at existing code (alt-c) for camera
positions. I found this little bugger in commands.cs,
but have yet to be able to track down the values for
toggleCameraFly and observerFly. I have searched the
entire torque tree (did a search of *.*) and found
nothing.

function serverCmdToggleCamera(%client)
{
   %control = %client.getControlObject();
   if (%control == %client.player)
   {
      %control = %client.camera;
      %control.mode = toggleCameraFly;
   }
   else
   {
      %control = %client.player;
      %control.mode = observerFly;
   }
   %client.setControlObject(%control);
}

Can someone shed some light here? I would like to add 2
additional camera states to TGE

1) top down view
2) chase cam type where the camera is fixed above and
behind the player looking over the players head at a
downward angle.

Regards,

Ron

#1
10/08/2002 (2:33 pm)
Your best bet is to look at the camera.cs file in "fps/server/scripts" and from there create a new datablock called "datablock CameraData(TopView)" or one of your likeing.

Next notice the setMode function, this is where the cases will be read and the correct camera be found. This could be tricky since you will need to view through the camera and still have control of the player. Look up how the 3rd person cam works and go from there. I know the initial function comes from default.binds.cs located in the client/functions section but where the accual funtion on moving the cam would probably be in camera.cc located in the game folder of the SDK.

Good luck.
Sam
#2
10/08/2002 (3:20 pm)
Sam,

I already have the camera in 3rd person and can control the player via the mouse (click -> move).

I just found it very odd that .mode was set to something with no value, that is toggleCamerFly is not defined etc.

I am thinking of taking the players eyePostion, incrase the X axis up in the air and figureing out (never was good with vector math etc) a good way to rotate the camer along the Z axis to look down. This would only hold true if my assumption that X is up/down Y is in/out and Z is rotational is true.


-Ron
#3
10/08/2002 (4:12 pm)
Ron,

I believe these values are actually engine variables and define how the camera acts in game.

ie. can it freefly, is it gonna follow an object, etc

Going from memory these were in camera.cc
#4
10/08/2002 (4:20 pm)
Daniel,

That even adds more wierdness to this entire soup bowl, I did a search from the torque directory down on *.* and only found those variables in the .cs files.
#5
10/08/2002 (6:02 pm)
Hmm
Thats very odd.
I definetly remember that they related to camera.cc cause I was looking at the code when making some new camera views in TAC2 (A T2 mod I work on)
#6
10/08/2002 (6:06 pm)
Daniel,

if time permiting could you contact me off forum? maybe you can shed some light on my current headache.

Regadrs,

Ron
#7
10/11/2002 (10:40 am)
Hi Ron,
for what I know, X is left/right Y is in/out Z is up/down, it's a right-handed coordinate system.
About the camera position, it's defined in the getCameraTransform function defined in the shapeBase class, it's a virtual function so you can overload it, take a look at it and you will see how the camera position is computed, if you change the mHead.x and mHead.z value with a number you can obtain a fixed camera position, this is the base, from this you can build what you want, also the Z-Rotation-clamping problem can be solved using this function.
I'm curious to know how you have implemented the click->move with the AIPlayer class.
Bye
Davide
#8
10/11/2002 (1:21 pm)
Davide,

I plan on submitting what I have accomplished back to the community as a resource. Why horde something that can benefit all!!!
#9
10/11/2002 (4:00 pm)
All,

anyone willing to lend a hand with vector math etc? I am totaly worthless in this area. I know what I want and where it should go, but lost with the math involved.

-Ron
#10
10/11/2002 (10:18 pm)
Well, I'm interested in lending a hand, because I need to dive into camera code myself. However, I'm worthless at the vector math myself too :-/ But, well, if two heads are better than one, I'm quite willin' to chip in and try and help, Ron!
#11
10/12/2002 (12:44 am)
Ill help ya as much as I can Rn, but my vector math abilities are not what I would call advance.

I can do basic vector calcs but thats about my limits.
#12
10/12/2002 (5:55 am)
Well I for one would be interested in following the vector math and quarternon discussion. I undertook trying to get a flying vehicle bot to use aiPlayer to set its' destination and move, upon issuance of the move command it just flys in loops. I attempted to code for Z axis calculation but couldn't figure out my vector/matrix issues along with vehicle physics.
I believe I have a decent understanding of the math but can't seem to integrate it along with vehicle physics to get a result, so therefore I can't confirm my theorys.
I suggest that maybe a forum in a chat session be scheduled and all interested parties rendevous for a discussion. I personally prefer a voice chat as I hate typing a lot. (Seems contradictory being a programmer/hacker type.)
#13
10/12/2002 (9:13 am)
WoW!

I was not expecting such a response. Here is what I am attempting to accomplish.

1) top down view, where the camera is directly above the player looking down.

2) chase cam type, directly behind player (locked). The camera sits behind the player looking at a downward angle over the players head. Player has no control over the camera

3) current 3rd person mode, but fix the collision detection so the camera does not spaz out so easily.

I am sure we can come up with a few other camera modes to add in. All of these should be controled via one key, which cycles through the modes.

-Ron
#14
04/12/2003 (10:25 am)
Hello Ron,

I need the camera modes you just described. I'm actually combing the forum when I stumbed into this post.

Were you able to make this work?

Any help would be appreciated. Thanks.

Alex
#16
04/12/2003 (12:05 pm)
Quote:
I need the camera modes you just described. I'm actually combing the forum when I stumbed into this post.
"Just"? Read the date in that last post :)
#17
04/12/2003 (9:47 pm)
Hello Ron,

I navigated the link and I was surprised that it was the mouse controlled player movement code. I actually applied that resource to my game a few months back and it was cool. My only problem with it is that its using the AIPlayer class. I even converted the code to use the Player class by merging the AIPlayer class into the Player class with jimomighthy's C++ bot codes. The problem was it was jerking the camera all over the place. In the end, I had to give up on it and just stick with an FPS game. :((

What I actually want is something like this:
CAM
_____*
_______*
_________*
___________*
_____O *******
_____l-
_____A

NOTE: Ignore all the "_". Its just a place holder so that the "*" would line up diagonally and the "stick" figure will be move farther from the "camera". :D 
The "*" by the way, represents the CAM and the Players line of sight.
Where the camera is a little bit higher than the player but the target is still the intersection of the camera FOV and the Player line of sight.

Any help would be appreciated. :D

Alex

P.S.
I was smiling all the while when I was typing this. I didn't really looked at the date when this was posted until eXuDuS pointed it out. LOL.

8-D

Edit: fixed the "diagram"