Advanced Camera
by Thomas \"Man of Ice\" Lund · 04/03/2008 (11:57 am) · 480 comments
Download Code File
Description
Over time a lot of people have released camera resources, but some do not work anymore, others are hard to implement etc.
I've tried to assemble a single class to add to the engine that implements them all in one go using the same basic architecture. This enables minimum code bloat and makes it way easier to keep the code up to date.
Change log
March 3rd, 2005
Manoel made some changes to the orbit camera. Works in multiplayer now and is much nicer by using console variables
February 3rd, 2005
Fixed small big in interpolation.
February 2nd, 2005
Major changes in this one with various contributors.
* Static camera mode
* Smooth interpolation and transition between modes
* Smooth orbit camera!!!
* Vertical freedom mode when in 3rd person
* Better collision check with terrain and interiors
* Mouse control of orbit camera
* Totally reworked codebase and lots of cleanups. Much more readable now
Manoel Neto contributed the new orbit camera and the interpolation
Zik Saleeba contributed the vertical freedom mode and better collision check
Thanks a lot!!!!
I have marked changes with a New in the text below for those who upgrade
January 23rd, 2005
Minor changes. Larger update soon with new functionality
* Now takes GameBase objects as target + player
* Removed debug message in orbit camera
* Added getters for player and target object
June 25th, 2004
Updated the bindings for orbit camera. Switched left+right.
June 23rd, 2004
A big thanks to Stephen Zepp for contributing with an orbit camera mode. Its added to the resource, and is perfect for RTS games and action adventures. It allows for a camera to rotate around a user as if placed on a sphere. The user can zoom in/out, rotate and tilt the camera.
June 9th, 2004
Added getter/setter for the 3 offset values accessible from script
Added a "follow terrain" mode for the third person camera, so the camera follows the terrain slope - doesnt work perfectly
April 5th, 2004
All camera modes now use a raycast to not get hidden behind terrain or interiors
April 3rd, 2004
This release is the first release, and might not be as "advanced" as the author would like, but its time to release it and get some feedback to further enhance it down the road.
Camera Modes Implemented
The resource currently implements the following camera systems:
* Track Mode
This is the same as the tracking camera resource posted by Cory Osborn. A stationary camera tracks the player and keeps him in focus.
* New Static Mode
Camera stays in its position and rotation. Useful for e.g. scene based adventures where the camera doesnt move with the players
* Third Person Mode
The camera is placed at an offset behind the player and rotates with the player. The camera itself is not controllable
* Third Person Track Mode
The camera is placed in third person mode but rotated so it always looks at a specified object, but with the player in full view
* God View
Camera is placed at an offset from the player and does not rotate with the player. This is your typical "Diablo" kind of camera.
* New Orbit Mode
Camera is placed on a sphere looking at the player, and can rotate/tilt and zoom controlled by the player. There are bindings to the mouse when in single player game (server and client on same machine)
Movie
Here is a small movie displaying the different camera modes (3 MB)
www.codejar.com/advancedcamerademo.wmv
How to Add
First off all you need to take the attached advancedCamera.cc/h files and add to engine\game and add them to the project.
Then you need to expose the camera object in GameConnection as described in Cory's resource www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4720
I took the liberty to paste the relevant parts in here too
Exposing mCameraObject
The first thing you want to do is add console method's to access the GameConnection setCameraObject/getCameraObject methods. I added these to GameConnection.cc right after the console method for getControlObject:
After playing around with it, I also found you need some adjustments to the setCameraObject and setControlObject methods - otherwise the client connection can screw things up if you bounce the same object from your connection's control to camera or vice versa. Here is my GameConnection::setControlObject:
and here is my GameConnection::setCameraObject:
Camera read/write packets
None of this will work unless the client copy of the camera object gets packets updated. Here we're going to modify GameConnection::readPacket and GameConnection::writePacket.
In GameConnection::readPacket, find this block of code:
and change it to
In GameConnection::writePacket, find this block of code:
and change it to:
Recompile it all and the engine is ready to go.
Script
To use the camera you need to follow some of Corys resource, but with some modifications. Datablock and naming has changed
First, add a datablock for the tracking camera to /fps/server/scripts/camera.cs:
Next, add it to the connection just like is currently done with the base camera class. Add this inside GameConnection::onClientEnterGame (/fps/server/scripts/game.cs), right after %this.camera is set up:
We'll need to clean it up after the client leaves the game, so add this to GameConnection::onClientLeaveGame
We need to tell it what to do when added and assign the connection's camera object, so add this to the end of GameConnection::createPlayer:
And we'll want to unhook it when the player dies. Insert this at the beginning of GameConnection::onDeath:
The last thing to know, is if you're in first-person mode, GameConnection automatically uses the control object to render the engine rather than the camera object. So if you don't see this working when you first enter a mission, toggle out of first-person.
Orbit mode
To use the orbit camera, one needs to add some key binds to manipulating the camera.
All you need to do, is add the following to your client\config.cs or better to your client\scripts\default.bind.cs
Remember to comment out the mouse commands for the player movement, as these are overwritten by the orbit camera controls
Script API
To use the different camera modes you can use the following API
Selecting the camera mode is done with e.g.:
Prior to calling the above modes you have to set the PlayerObject using
To use the 3rd person target mode you also need to set a TargetObject using
To use the static or tracking camera you need to set the position the camera should be placed suing
To use the follow terrain mode in 3rd person you give a bool to
To use the vertical freedom mode in 3rd person you give a bool to
The offset values in the datablock can be changed for the camera object via script using
The orbit camera can be manipulated from script using
You can also manipulate the orbit camera directly by assigning values to the following variables
[code]
$advCamera::Yaw
$advCamera::Pitch
$advCamera::Zoom
$advCamera::azimuth
$advCamera::declination
$advCamera::zoomDistance
[code]
All camera modes coexist, so you can set the position, player object and target object once and then switch camera modes around as you see fit. Switching mode will not clear the old objects/positions.
Description
Over time a lot of people have released camera resources, but some do not work anymore, others are hard to implement etc.
I've tried to assemble a single class to add to the engine that implements them all in one go using the same basic architecture. This enables minimum code bloat and makes it way easier to keep the code up to date.
Change log
March 3rd, 2005
Manoel made some changes to the orbit camera. Works in multiplayer now and is much nicer by using console variables
February 3rd, 2005
Fixed small big in interpolation.
February 2nd, 2005
Major changes in this one with various contributors.
* Static camera mode
* Smooth interpolation and transition between modes
* Smooth orbit camera!!!
* Vertical freedom mode when in 3rd person
* Better collision check with terrain and interiors
* Mouse control of orbit camera
* Totally reworked codebase and lots of cleanups. Much more readable now
Manoel Neto contributed the new orbit camera and the interpolation
Zik Saleeba contributed the vertical freedom mode and better collision check
Thanks a lot!!!!
I have marked changes with a New in the text below for those who upgrade
January 23rd, 2005
Minor changes. Larger update soon with new functionality
* Now takes GameBase objects as target + player
* Removed debug message in orbit camera
* Added getters for player and target object
June 25th, 2004
Updated the bindings for orbit camera. Switched left+right.
June 23rd, 2004
A big thanks to Stephen Zepp for contributing with an orbit camera mode. Its added to the resource, and is perfect for RTS games and action adventures. It allows for a camera to rotate around a user as if placed on a sphere. The user can zoom in/out, rotate and tilt the camera.
June 9th, 2004
Added getter/setter for the 3 offset values accessible from script
Added a "follow terrain" mode for the third person camera, so the camera follows the terrain slope - doesnt work perfectly
April 5th, 2004
All camera modes now use a raycast to not get hidden behind terrain or interiors
April 3rd, 2004
This release is the first release, and might not be as "advanced" as the author would like, but its time to release it and get some feedback to further enhance it down the road.
Camera Modes Implemented
The resource currently implements the following camera systems:
* Track Mode
This is the same as the tracking camera resource posted by Cory Osborn. A stationary camera tracks the player and keeps him in focus.
* New Static Mode
Camera stays in its position and rotation. Useful for e.g. scene based adventures where the camera doesnt move with the players
* Third Person Mode
The camera is placed at an offset behind the player and rotates with the player. The camera itself is not controllable
* Third Person Track Mode
The camera is placed in third person mode but rotated so it always looks at a specified object, but with the player in full view
* God View
Camera is placed at an offset from the player and does not rotate with the player. This is your typical "Diablo" kind of camera.
* New Orbit Mode
Camera is placed on a sphere looking at the player, and can rotate/tilt and zoom controlled by the player. There are bindings to the mouse when in single player game (server and client on same machine)
Movie
Here is a small movie displaying the different camera modes (3 MB)
www.codejar.com/advancedcamerademo.wmv
How to Add
First off all you need to take the attached advancedCamera.cc/h files and add to engine\game and add them to the project.
Then you need to expose the camera object in GameConnection as described in Cory's resource www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4720
I took the liberty to paste the relevant parts in here too
Exposing mCameraObject
The first thing you want to do is add console method's to access the GameConnection setCameraObject/getCameraObject methods. I added these to GameConnection.cc right after the console method for getControlObject:
ConsoleMethod( GameConnection, setCameraObject, bool, 3, 3, "(ShapeBase object)")
{
ShapeBase *gb;
if(!Sim::findObject(argv[2], gb))
return false;
object->setCameraObject(gb);
return true;
}
ConsoleMethod( GameConnection, getCameraObject, S32, 2, 2, "")
{
argv;
SimObject* cp = object->getCameraObject();
return cp ? cp->getId(): 0;
}
ConsoleMethod( GameConnection, clearCameraObject, void, 2, 2, "")
{
object->setCameraObject(NULL);
}After playing around with it, I also found you need some adjustments to the setCameraObject and setControlObject methods - otherwise the client connection can screw things up if you bounce the same object from your connection's control to camera or vice versa. Here is my GameConnection::setControlObject:
void GameConnection::setControlObject(ShapeBase *obj)
{
if(mControlObject == obj)
return;
if(mControlObject && mControlObject != mCameraObject)
mControlObject->setControllingClient(0);
if(obj)
{
// Nothing else is permitted to control this object.
if (ShapeBase* coo = obj->getControllingObject())
coo->setControlObject(0);
if (GameConnection *con = obj->getControllingClient())
{
if (this != con)
{
// was it controlled via camera or control?
if (con->getControlObject() == obj)
con->setControlObject(0);
else
con->setCameraObject(0);
}
}
// We are now the controlling client of this object.
obj->setControllingClient(this);
}
// Okay, set our control object.
mControlObject = obj;
if (mCameraObject.isNull())
setScopeObject(mControlObject);
}and here is my GameConnection::setCameraObject:
void GameConnection::setCameraObject(ShapeBase *obj)
{
if(mCameraObject == obj)
return;
if(mCameraObject && mCameraObject != mControlObject)
mCameraObject->setControllingClient(0);
if (obj) {
// Nothing else is permitted to control this object.
if (ShapeBase* coo = obj->getControllingObject())
coo->setControlObject(0);
if (GameConnection *con = obj->getControllingClient())
{
if (this != con)
{
// was it controlled via camera or control?
if (con->getControlObject() == obj)
con->setControlObject(0);
else
con->setCameraObject(0);
}
}
// We are now the controlling client of this object.
obj->setControllingClient(this);
}
// Okay, set our camera object.
mCameraObject = obj;
if (mCameraObject.isNull()) {
setScopeObject(mControlObject);
} else {
setScopeObject(mCameraObject);
// if this is a client then set the fov and active image
if(isServerConnection())
{
F32 fov = mCameraObject->getDefaultCameraFov();
GameSetCameraFov(fov);
}
}
}Camera read/write packets
None of this will work unless the client copy of the camera object gets packets updated. Here we're going to modify GameConnection::readPacket and GameConnection::writePacket.
In GameConnection::readPacket, find this block of code:
if (bstream->readFlag())
{
S32 gIndex = bstream->readInt(10);
ShapeBase* obj = static_cast<ShapeBase*>(resolveGhost(gIndex));
setCameraObject(obj);
}
else
setCameraObject(0);and change it to
if (bstream->readFlag())
{
S32 gIndex = bstream->readInt(NetConnection::GhostIdBitSize);
ShapeBase* obj = static_cast<ShapeBase*>(resolveGhost(gIndex));
setCameraObject(obj);
obj->readPacketData(this, bstream);
}
else
setCameraObject(0);In GameConnection::writePacket, find this block of code:
if (!mCameraObject.isNull() && mCameraObject != mControlObject)
{
gIndex = getGhostIndex(mCameraObject);
if (bstream->writeFlag(gIndex != -1))
bstream->writeInt(gIndex, 10);
}
else
bstream->writeFlag( false );and change it to:
if (!mCameraObject.isNull() && mCameraObject != mControlObject)
{
gIndex = getGhostIndex(mCameraObject);
if (bstream->writeFlag(gIndex != -1)) {
bstream->writeInt(gIndex, NetConnection::GhostIdBitSize);
mCameraObject->writePacketData(this, bstream);
}
}
else
bstream->writeFlag( false );Recompile it all and the engine is ready to go.
Script
To use the camera you need to follow some of Corys resource, but with some modifications. Datablock and naming has changed
First, add a datablock for the tracking camera to /fps/server/scripts/camera.cs:
...
datablock AdvancedCameraData(AdvCameraData)
{
lookAtOffset = "0 0 2";
thirdPersonOffset = "0 -3 3";
godViewOffset = "0 -20 20";
maxTerrainDiff = 2;
orbitMinMaxZoom = "5 100";
orbitMinMaxDeclination = "10 80";
damping = 0.25;
};
...Next, add it to the connection just like is currently done with the base camera class. Add this inside GameConnection::onClientEnterGame (/fps/server/scripts/game.cs), right after %this.camera is set up:
...
// create advanced camera
%this.advCamera = new AdvancedCamera() {
dataBlock = AdvCameraData;
};
MissionCleanup.add(%this.advCamera);
%this.advCamera.scopeToClient(%this);
...We'll need to clean it up after the client leaves the game, so add this to GameConnection::onClientLeaveGame
...
if (isObject(%this.advCamera))
%this.advCamera.delete();
...We need to tell it what to do when added and assign the connection's camera object, so add this to the end of GameConnection::createPlayer:
... // We set the camera system to run in 3rd person mode around the %player %this.advCamera.setPlayerObject(%player); %this.advCamera.setThirdPersonMode(); %this.advCamera.setFollowTerrainMode(false); %this.advCamera.setVerticalFreedomMode(false); %this.setCameraObject(%this.advCamera); ...
And we'll want to unhook it when the player dies. Insert this at the beginning of GameConnection::onDeath:
... // clear connections camera %this.advCamera.clearPlayerObject(); %this.advCamera.clearTargetObject(); %this.clearCameraObject(); ...
The last thing to know, is if you're in first-person mode, GameConnection automatically uses the control object to render the engine rather than the camera object. So if you don't see this working when you first enter a mission, toggle out of first-person.
Orbit mode
To use the orbit camera, one needs to add some key binds to manipulating the camera.
All you need to do, is add the following to your client\config.cs or better to your client\scripts\default.bind.cs
//------------------------------------------------------------------------------
// Advanced Camera Movement
//------------------------------------------------------------------------------
$cameraYawSpeed = -100.0;
$cameraPitchSpeed = -50.0;
$cameraZoomSpeed = -5.0;
function rotateCameraHorizontal(%val)
{
$advCamera::Yaw = getMouseAdjustAmount(%val)*$cameraYawSpeed ;
}
function rotateCameraVertical(%val)
{
$advCamera::Pitch = getMouseAdjustAmount(%val)*$cameraPitchSpeed;
}
function zoomCamera(%val)
{
$advCamera::Zoom = getMouseAdjustAmount(%val)*$cameraZoomSpeed;
}
moveMap.bind( mouse, xaxis, rotateCameraHorizontal);
moveMap.bind( mouse, yaxis, rotateCameraVertical );
moveMap.bind( mouse, zaxis, zoomCamera );Remember to comment out the mouse commands for the player movement, as these are overwritten by the orbit camera controls
//moveMap.bind( mouse, xaxis, yaw ); //moveMap.bind( mouse, yaxis, pitch );
Script API
To use the different camera modes you can use the following API
Selecting the camera mode is done with e.g.:
%this.advCamera.setTrackMode(); %this.advCamera.setThirdPersonMode(); %this.advCamera.setThirdPersonTargetMode(); %this.advCamera.setGodViewMode(); %this.advCamera.setOrbitMode(); %this.advCamera.setStaticMode();
Prior to calling the above modes you have to set the PlayerObject using
setPlayerObject();
To use the 3rd person target mode you also need to set a TargetObject using
setTargetObject();
To use the static or tracking camera you need to set the position the camera should be placed suing
setCameraPosition(Point3F pos);
To use the follow terrain mode in 3rd person you give a bool to
setFollowTerrainMode(true/false);
To use the vertical freedom mode in 3rd person you give a bool to
setVerticalFreedomMode(true/false);This only works if the player object is a Player, because it uses the head movement.
The offset values in the datablock can be changed for the camera object via script using
get/setLookAtOffset(); get/setThirdPersonOffset(); get/setGodViewOffset();The setters take a Point3F as argument.
The orbit camera can be manipulated from script using
get/setOrbitMinMaxZoom() get/setOrbitMinMaxDeclination()The min/max take a Point2F
You can also manipulate the orbit camera directly by assigning values to the following variables
[code]
$advCamera::Yaw
$advCamera::Pitch
$advCamera::Zoom
$advCamera::azimuth
$advCamera::declination
$advCamera::zoomDistance
[code]
All camera modes coexist, so you can set the position, player object and target object once and then switch camera modes around as you see fit. Switching mode will not clear the old objects/positions.
#422
Has anyone experienced the following situation with this resource and the "Move Relative to Camera" resource?:
I can move around relatively fine, but when I let go of the movement keys, the player rotates to the same angle as when standing still. No matter what direction I rotate the camera, the player wants to stare in the upper/left corner of the screen. It seems to be related to the Advanced Camera itself? I would like to be able to have the character face any direction while standing, as I have Melee combat set up and intend to use.
Any ideas?
Edit: Ahhh, nevermind, the culprit seems to be something else entirely. I am using a gamepad, and the bindings for the movement directions don't work exactly the same as a keyboard. So I'll have to figure that aspect out separately.
01/02/2008 (11:42 am)
Another Advanced Camera oddity here... Has anyone experienced the following situation with this resource and the "Move Relative to Camera" resource?:
I can move around relatively fine, but when I let go of the movement keys, the player rotates to the same angle as when standing still. No matter what direction I rotate the camera, the player wants to stare in the upper/left corner of the screen. It seems to be related to the Advanced Camera itself? I would like to be able to have the character face any direction while standing, as I have Melee combat set up and intend to use.
Any ideas?
Edit: Ahhh, nevermind, the culprit seems to be something else entirely. I am using a gamepad, and the bindings for the movement directions don't work exactly the same as a keyboard. So I'll have to figure that aspect out separately.
#423
I got a strange problem here... I'm using TGE 1.5.2 with AFX... I've added everything like mentioned above and also the advancedCamera.cc is compiled into the Project:
7>aiWheeledVehicle.cc
7>aiPlayer.cc
7>aiConnection.cc
7>advancedCamera.cc
7>Code wird generiert...
7>Kompilieren...
Whatever, when I try to access the console Methods like getCameraPosition etc. I always got the error Messages like:
arcane.fx/server/scripts/commands.cs (152): Unable to find object: '' attempting to call function 'getThirdPersonOffset'
arcane.fx/server/scripts/commands.cs (169): Unable to find object: '' attempting to call function 'setThirdPersonOffset'
M
and:
==>getThirdPersonOffset();
(0): Unable to find function getThirdPersonOffset
Any Idea why I can't access these functions? I'm 100% sure that the advancedCamera.cc is compiled into my project... Help. :-(
Benny
01/17/2008 (12:43 pm)
Hi,I got a strange problem here... I'm using TGE 1.5.2 with AFX... I've added everything like mentioned above and also the advancedCamera.cc is compiled into the Project:
7>aiWheeledVehicle.cc
7>aiPlayer.cc
7>aiConnection.cc
7>advancedCamera.cc
7>Code wird generiert...
7>Kompilieren...
Whatever, when I try to access the console Methods like getCameraPosition etc. I always got the error Messages like:
arcane.fx/server/scripts/commands.cs (152): Unable to find object: '' attempting to call function 'getThirdPersonOffset'
arcane.fx/server/scripts/commands.cs (169): Unable to find object: '' attempting to call function 'setThirdPersonOffset'
M
and:
==>getThirdPersonOffset();
(0): Unable to find function getThirdPersonOffset
Any Idea why I can't access these functions? I'm 100% sure that the advancedCamera.cc is compiled into my project... Help. :-(
Benny
#424
I have some problems too thoug: it seems like everything compiled fine, i can create advanced camera, and i does not say that it cant find the functions related to advanced camera. Problem is, when said functions is used on a playerobject, nothing happens at all, i have made a advancedCamera datablock, i have made sure that the camera is assigned to the player. Also, for some reason the game crashes when in f11 mode, this is because of some faulty scripting by me, since th executable does not crash with other script. Any ideas?
Allright now i got it to do something at least, but it will only do so if press f8 first, which i find odd since i included all code in the function f8 triggers in the createPlayer part(i used the right handle). Is there some function in the executable that f8 calls?
Very odd, before i can use the advanced camera, i have to make the client controll the camera instead of the player avatar. And when i let the client control the avatar again, the camera goes to the models eye node(i think)
I am using afx 1.52 with afx, slighly modified, but nothing extensive. Also all of mine modifications was following resources, so i guess they are kind of clean
01/18/2008 (12:23 pm)
Thats because those functions are related to the afxCamera, which is partialy made on this camera. And it looks to me like your calling maybe the handel %camera, when you have named the camera handle %advCamera inside your game.cs file. At least i think thats what the problem is.I have some problems too thoug: it seems like everything compiled fine, i can create advanced camera, and i does not say that it cant find the functions related to advanced camera. Problem is, when said functions is used on a playerobject, nothing happens at all, i have made a advancedCamera datablock, i have made sure that the camera is assigned to the player. Also, for some reason the game crashes when in f11 mode, this is because of some faulty scripting by me, since th executable does not crash with other script. Any ideas?
Allright now i got it to do something at least, but it will only do so if press f8 first, which i find odd since i included all code in the function f8 triggers in the createPlayer part(i used the right handle). Is there some function in the executable that f8 calls?
Very odd, before i can use the advanced camera, i have to make the client controll the camera instead of the player avatar. And when i let the client control the avatar again, the camera goes to the models eye node(i think)
I am using afx 1.52 with afx, slighly modified, but nothing extensive. Also all of mine modifications was following resources, so i guess they are kind of clean
#425
01/20/2008 (12:04 pm)
@Ted: i have exactly the same problem, and i`m sure its related to afx. can you get though loading screen? and what your f8 exactly does?
#426
%this.setControlObject(%player);
at the end of GameConnection::createPlayer before
%this.advCamera.setPlayerObject(%player);
%this.advCamera.setThirdPersonMode();
%this.advCamera.setFollowTerrainMode(false);
...
EDIT:
well found out that i had another problem and it was because i commented out afx camera. nvm i`ll keep trying
01/20/2008 (12:18 pm)
@Ted: ok just fixed it. add %this.setControlObject(%player);
at the end of GameConnection::createPlayer before
%this.advCamera.setPlayerObject(%player);
%this.advCamera.setThirdPersonMode();
%this.advCamera.setFollowTerrainMode(false);
...
EDIT:
well found out that i had another problem and it was because i commented out afx camera. nvm i`ll keep trying
#427
Still no goose =(
The player keeps staring out of his godamn eye node. It seems that as soon as a player does not have direct control over the advanced camera object, it regresses to watching out of the eye node
So henry, if i understand you correctly, you have not magaed to incorporate advanced camera properly? If that is the case, then i am pretty sure that tge 1.52 + afx does NOT work with advanced camera. Which certainly is silly since afxCamera is based on this....
Now for an entirely different question:
The offset values in the datablock can be changed for the camera object via script using
get/setLookAtOffset();
get/setThirdPersonOffset();
get/setGodViewOffset();
Im confused, does that mean that only the players camera object is subjected to the changes, or does it mean that the datablock is changed, meaning everyones cameras?
01/21/2008 (10:12 am)
Looks nice, henry, ill try it outStill no goose =(
The player keeps staring out of his godamn eye node. It seems that as soon as a player does not have direct control over the advanced camera object, it regresses to watching out of the eye node
So henry, if i understand you correctly, you have not magaed to incorporate advanced camera properly? If that is the case, then i am pretty sure that tge 1.52 + afx does NOT work with advanced camera. Which certainly is silly since afxCamera is based on this....
Now for an entirely different question:
The offset values in the datablock can be changed for the camera object via script using
get/setLookAtOffset();
get/setThirdPersonOffset();
get/setGodViewOffset();
Im confused, does that mean that only the players camera object is subjected to the changes, or does it mean that the datablock is changed, meaning everyones cameras?
#428
thats because of the lookatoffset.
Is there a way to make it view at least the upper half of the player body when zooming close?
02/03/2008 (6:40 pm)
In Orbit mode, when you zoom in so close the camera always position at the very top view of the head,thats because of the lookatoffset.
Is there a way to make it view at least the upper half of the player body when zooming close?
#429
03/05/2008 (5:54 am)
Hello, When in 3rd person View the player is not moving in straight line.How this problem can be solved?Help me..
#430
BTW, I've got an issue here. I'm using a static camera FYI. Now, if my player is behind / inside a dif / interior, the camera will always zoom to near the player. It's not what I wanted though. Obviously, I used a static camera because it should be static no matter what. How do I fix this issue? Thanks a lot.
03/10/2008 (12:33 am)
Hi, just drop by to say this resource is really great. Furthermore, my current game doesn't use the first / third person view so this has helped A LOT. 5 stars no doubt.BTW, I've got an issue here. I'm using a static camera FYI. Now, if my player is behind / inside a dif / interior, the camera will always zoom to near the player. It's not what I wanted though. Obviously, I used a static camera because it should be static no matter what. How do I fix this issue? Thanks a lot.
#431
03/23/2008 (10:30 am)
Does anyone have this working for the new TGEA Beta? It seems like all the folders have been moved around.
#432
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13617
By the way, both resources are made for TGE, not TGEA. Doesn't mean it won't work, but it will likely require a little extra work on your part.
03/23/2008 (10:55 am)
This resource is very outdated. Please go here for the new one:www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13617
By the way, both resources are made for TGE, not TGEA. Doesn't mean it won't work, but it will likely require a little extra work on your part.
#433
I have a flying vehicle that can roll completely upside down. I would like to have a 3rd person camera that will roll correctly with the vehicle as if it were attached to the top of the vehicle.
Can this be done with the advanced camera? Has anyone else implemented something like this?
Thanks.
03/23/2008 (3:21 pm)
I think this has been asked before, but I'm not sure any solution had been posted.I have a flying vehicle that can roll completely upside down. I would like to have a 3rd person camera that will roll correctly with the vehicle as if it were attached to the top of the vehicle.
Can this be done with the advanced camera? Has anyone else implemented something like this?
Thanks.
#434
In terms of the roll, Torque's standard camera ignores that. I can't remember what the Advanced Camera does, it's been a couple of years since I've worked with it - lately I've mostly been working with the standard Torque camera to derive new camera implementations.
Here's a question I answered in a forum before that at least gives a starting point about working with roll:
http://www.garagegames.com/mg/forums/result.thread.php?qt=63715
03/23/2008 (6:38 pm)
Hey Jason,In terms of the roll, Torque's standard camera ignores that. I can't remember what the Advanced Camera does, it's been a couple of years since I've worked with it - lately I've mostly been working with the standard Torque camera to derive new camera implementations.
Here's a question I answered in a forum before that at least gives a starting point about working with roll:
http://www.garagegames.com/mg/forums/result.thread.php?qt=63715
#435
This seems to work well for giving me the correct camera position, however I am getting a lot of camera jittering. I cannot seem to find out what is causing this, and although I have a feeling that it might be due to client/server synchronization problems, I cannot for the life of me figure out what changes need to be made to remove this problem.
Any help is greatly appreciated!
Thanks
03/24/2008 (7:28 am)
I have been able to get camera roll working for my purposes by modifying the getCameraParameters and getCameraTransform functions within the vehicle to use the up vector of my vehicle as the offset rather than using (0,0,1).This seems to work well for giving me the correct camera position, however I am getting a lot of camera jittering. I cannot seem to find out what is causing this, and although I have a feeling that it might be due to client/server synchronization problems, I cannot for the life of me figure out what changes need to be made to remove this problem.
Any help is greatly appreciated!
Thanks
#436
Quickly looking at the resource code, it appears the Advanced Camera may not be using the render transform:
But looking at the path camera, it does do this:
\engine\game\pathCamera.cpp
When I used getRenderEyeTransform() in my getCameraTransform() function, the jitters in my camera went away.
Not sure what your code is doing, but it's something to consider.
03/24/2008 (8:26 am)
It could be a few different things (I know not the answer you want to hear). When I had the problem of choppy motion (again not with the advanced camera but a custom one) it turned out I was using the wrong transform in my getCameraTransform() function. There is the regular object transform, which is updated every 32 milliseconds, and the renderTransform, which is updated constantly. So, if the camera is being rendered constantly with the standard transform, it may appear choppy.Quickly looking at the resource code, it appears the Advanced Camera may not be using the render transform:
void AdvancedCamera::getCameraTransform(F32* pos, MatrixF* mat) {
getEyeTransform(mat);
}But looking at the path camera, it does do this:
\engine\game\pathCamera.cpp
void PathCamera::getCameraTransform(F32* pos, MatrixF* mat)
{
// Overide the ShapeBase method to skip all the first/third person support.
getRenderEyeTransform(mat);
}When I used getRenderEyeTransform() in my getCameraTransform() function, the jitters in my camera went away.
Not sure what your code is doing, but it's something to consider.
#437
04/05/2008 (6:47 pm)
Does anyone know what happened with this resource to cause the date to be reset to April 3, 2008? I guess a better question might be, does anyone know if this was updated?
#439
04/19/2008 (7:56 am)
I just wanted to confirm that this resource is working fine with TGEA 1.7 and AFX 1.1.2
#440
04/28/2008 (10:36 am)
i've started over with a new build and have entered the code from Advanced Camera into my scripts. But the camera is stuck in the starting position up in the sky. How can you get out of this starting camera mode? 
Torque Owner Ed Johnson
I have implemented the resource that lets me move relatively to the screen, and have gotten rid of the up/down command bindings, so the character can only move left and right. However, the camera jitters or turns a bit when moving, making the character move slightly diagonally instead of in a line left and right.
Any way to get rid of this jitter? Or perhaps a better way of making the camera look from the "side" ?.