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.
#442
For some reason, after we added our startup GUIs and 3DS-Max objects, the camera starts in first-person as the player falls to the ground. Why does this happen? Even odder is that we found, after commenting out the line
05/01/2008 (2:32 pm)
Our game torqueDemo.exe has been set up with the observer camera, focused on a torque logo, movable while holding down the right mouse button. Clicking the terrain with the left mouse button causes the player to move toward that spot. This works!For some reason, after we added our startup GUIs and 3DS-Max objects, the camera starts in first-person as the player falls to the ground. Why does this happen? Even odder is that we found, after commenting out the line
createServer("SinglePlayer", expandFilename("./data/missions/flat.mis"));from loadMyMission in the tutorial.base main.cs file, that it starts in observer mode like we want. However it freezes before LOADING MISSION and you have to press F11 to unfreeze it.. and then it works how we want it to. How can we fix this?
#443
When the lookAtOffset has a horizontal component (in the x or y direction) it is possible that the camera can appear on the far side of a collision volume. You can see the problem if you walk up to a very steep slope in the terrain (like the base of a cliff), where the lookAtOffset is pointing towards the slope.
The error comes up in the runCameraCollisionCheck(...) function.
The fix is to rotate mCurrentLookAtOffset to point in the direction of the player. Now, given how this function is called, I made a quick fix that solves the problem but removes some of the scalability. Change
and then in the else block, changed
So the update assumes that the startPos (passed into the function) is the player's rendertransform, so if this function is called in any other context, it will probably give you the wrong answer.
05/02/2008 (8:02 am)
I found a neat little bug in the code with the lookAtOffset.When the lookAtOffset has a horizontal component (in the x or y direction) it is possible that the camera can appear on the far side of a collision volume. You can see the problem if you walk up to a very steep slope in the terrain (like the base of a cliff), where the lookAtOffset is pointing towards the slope.
The error comes up in the runCameraCollisionCheck(...) function.
if (!gClientContainer.castRay(startpos + mCurrentLookAtOffset, endpos, mask, &collisionInfo)) {will start the ray at the requested start position + the lookatoffset, and here's the bug: the lookatoffset is in world space, not model space, so as you rotate your player, this calculation does not change.The fix is to rotate mCurrentLookAtOffset to point in the direction of the player. Now, given how this function is called, I made a quick fix that solves the problem but removes some of the scalability. Change
// Cast ray and check for collision with terrain and interiors
if (!gClientContainer.castRay(startpos + mCurrentLookAtOffset, endpos, mask, &collisionInfo)) {toPoint3F offsetStartPos;
MatrixF objToWorld = getRenderTransform();
objToWorld.mulP(mCurrentLookAtOffset, &offsetStartPos);
// Cast ray and check for collision with terrain and interiors
if (!gClientContainer.castRay([b]offsetStartPos[/b], endpos, mask, &collisionInfo)) {and then in the else block, changed
Point3F LookDir = startpos + mCurrentLookAtOffset - collisionInfo.point;to
Point3F LookDir = [b]offsetStartPos[/b] - collisionInfo.point;
So the update assumes that the startPos (passed into the function) is the player's rendertransform, so if this function is called in any other context, it will probably give you the wrong answer.
#444
05/04/2008 (8:06 pm)
i would like to create a camera that loks over the shoulder of the player and has a bouyant floaty feel to it basicaly set up like gears of war, army of two, or resident evil 4 is there anyone who can help i have applied the above resource correctly but do not know where to begin to do with it what i want
#445
When i make changes to the game connections, i get a few error message regarding ShapeBase, which was previously GameBase. I'm using the new TGEA 1.7.0. In TGEA 1.7.0 i only see GameBase, nothing about ShapeBase. But i still get the second set of errors if i replace ShapeBase to GameBase.
I get these error messages. What am i doing wrong here? Thank you for any help.
05/06/2008 (8:22 pm)
Hello,When i make changes to the game connections, i get a few error message regarding ShapeBase, which was previously GameBase. I'm using the new TGEA 1.7.0. In TGEA 1.7.0 i only see GameBase, nothing about ShapeBase. But i still get the second set of errors if i replace ShapeBase to GameBase.
1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(326) : error C2065: 'ShapeBase' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(326) : error C2065: 'obj' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(327) : error C2448: 'GameConnection::setControlObject' : function-style initializer appears to be a function definition 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(360) : error C2065: 'ShapeBase' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(360) : error C2065: 'obj' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(361) : error C2448: 'GameConnection::setCameraObject' : function-style initializer appears to be a function definition 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(831) : error C2065: 'ShapeBase' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(831) : error C2065: 'obj' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(831) : error C2061: syntax error : identifier 'ShapeBase' 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(832) : error C2065: 'obj' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(833) : error C2065: 'obj' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(833) : error C2227: left of '->readPacketData' must point to class/struct/union/generic type 1> type is ''unknown-type'' 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(1572) : error C2065: 'ShapeBase' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(1572) : error C2065: 'gb' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(1573) : error C2065: 'gb' : undeclared identifier 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(1576) : error C2065: 'gb' : undeclared identifier
1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(397) : error C3861: 'isServerConnection': identifier not found 1>c:\torque2\tgea_1_7_0\engine\source\t3d\gameconnection.cpp(400) : error C3861: 'GameSetCameraFov': identifier not found
I get these error messages. What am i doing wrong here? Thank you for any help.
#446
Periodically, I get this:
TerrainRender::renderBlock: Mismatch in (0, 0) of world!
TerrainRender::renderBlock: Mismatch in (0, 1) of world!
TerrainRender::renderBlock: Mismatch in (0, 2) of world!
TerrainRender::renderBlock: Mismatch in (0, 3) of world!
TerrainRender::renderBlock: Mismatch in (1, 0) of world!
TerrainRender::renderBlock: Mismatch in (1, 1) of world!
TerrainRender::renderBlock: Mismatch in (1, 2) of world!
TerrainRender::renderBlock: Mismatch in (1, 3) of world!
TerrainRender::renderBlock: Mismatch in (2, 0) of world!
TerrainRender::renderBlock: Mismatch in (2, 1) of world!
TerrainRender::renderBlock: Mismatch in (2, 2) of world!
TerrainRender::renderBlock: Mismatch in (2, 3) of world!
This is pretty much every thing I use to change the camera:
%viewClientControl = %viewClient.getControlObject();
if(%viewClientControl != -1)
{
%this.advCamera.setPlayerObject(%viewClientControl);
%this.advCamera.setThirdPersonMode();
%this.advCamera.setFollowTerrainMode(false);
%this.advCamera.setVerticalFreedomMode(false);
%this.setCameraObject(%this.advCamera);
%this.setControlObject(%this.advCamera);
}
I have tried several other settings as well but with sometimes even worse results.
05/21/2008 (9:05 pm)
I have been trying to use this to set up a spectator camera system using the setPlayerObject function. It almost works perfectly with one bad exception. Periodically, I get this:
TerrainRender::renderBlock: Mismatch in (0, 0) of world!
TerrainRender::renderBlock: Mismatch in (0, 1) of world!
TerrainRender::renderBlock: Mismatch in (0, 2) of world!
TerrainRender::renderBlock: Mismatch in (0, 3) of world!
TerrainRender::renderBlock: Mismatch in (1, 0) of world!
TerrainRender::renderBlock: Mismatch in (1, 1) of world!
TerrainRender::renderBlock: Mismatch in (1, 2) of world!
TerrainRender::renderBlock: Mismatch in (1, 3) of world!
TerrainRender::renderBlock: Mismatch in (2, 0) of world!
TerrainRender::renderBlock: Mismatch in (2, 1) of world!
TerrainRender::renderBlock: Mismatch in (2, 2) of world!
TerrainRender::renderBlock: Mismatch in (2, 3) of world!
This is pretty much every thing I use to change the camera:
%viewClientControl = %viewClient.getControlObject();
if(%viewClientControl != -1)
{
%this.advCamera.setPlayerObject(%viewClientControl);
%this.advCamera.setThirdPersonMode();
%this.advCamera.setFollowTerrainMode(false);
%this.advCamera.setVerticalFreedomMode(false);
%this.setCameraObject(%this.advCamera);
%this.setControlObject(%this.advCamera);
}
I have tried several other settings as well but with sometimes even worse results.
#447
Also, is dampening like the lagOffset for the player and vehicle cameras?
05/21/2008 (9:44 pm)
Ok I think I see where I am getting my crash and I have seen another guy had the same problem in the past. It is when setting the player object and camera passes through the terrain it is causing me to see a rendering issue. Is there anyway to just have the camera position itself behind the player object rather than the zooming in effect? Also, is dampening like the lagOffset for the player and vehicle cameras?
#448
05/22/2008 (4:23 pm)
OK I figured out that orbit mode would work great for me with one small exception, I would like to have it start out facing the rear of the vehicle. So what I would like to know is if there is just some way to set the yaw and pitch angle? Not with Manoel's mouse option, I mean in actual script.
#449
In essence it would behave as WOW does with the left mouse button orbit.
06/09/2008 (10:19 am)
How do I change the height and tilt of the orbit camera so it is at the players level and tilt set to 0 degrees?In essence it would behave as WOW does with the left mouse button orbit.
#450
added these to default.bind and config
moveMap.bind(mouse0, "xaxis", rotateCameraHorizontal);
moveMap.bind(mouse0, "yaxis", rotateCameraVertical);
I set a breakpoint in the engine at void AdvancedCamera::advanceTime(F32 dt) and the code is being touched.
Anyone offer some help?
07/09/2008 (8:38 am)
I got this running in the engine ok, set third person mode and the yaw/pitch doesn't work.added these to default.bind and config
moveMap.bind(mouse0, "xaxis", rotateCameraHorizontal);
moveMap.bind(mouse0, "yaxis", rotateCameraVertical);
I set a breakpoint in the engine at void AdvancedCamera::advanceTime(F32 dt) and the code is being touched.
Anyone offer some help?
#451
Change all instances of the word "ShapeBase" to say "GameBase". That will fix a lot of errors.
Another fix is to change 'isServerConnection' to say 'isConnectionToServer'
I am still working on the final fix for changing 'GameSetCameraFov' to the TGEA compatible identifier which is the final fix we need to get this working.
07/20/2008 (4:54 pm)
Lathieeshe - Change all instances of the word "ShapeBase" to say "GameBase". That will fix a lot of errors.
Another fix is to change 'isServerConnection' to say 'isConnectionToServer'
I am still working on the final fix for changing 'GameSetCameraFov' to the TGEA compatible identifier which is the final fix we need to get this working.
#452
So yeah, if I rotate the camera around the player, while the player is still, then push 'w' to move forward, I want to make the player move forward based on the camera's forward vector. I think I can do this, but I don't know how/where the player's movement/controls is handled. Has anyone achieved this effect?
Thx.
08/29/2008 (6:57 am)
Hello, I've sifted throught this massively long forum post and didn't seem to find an answer to one of the questions posted aboveQuote:
I want to control my character using the orbit camera. In other words, when my orbit camera changes direction, I want to be able to read the angle it's facing and give this to the player so he can move too.
So yeah, if I rotate the camera around the player, while the player is still, then push 'w' to move forward, I want to make the player move forward based on the camera's forward vector. I think I can do this, but I don't know how/where the player's movement/controls is handled. Has anyone achieved this effect?
Thx.
#453
client.setCameraObject(orbitCam)
client.setControlObject(player)
08/29/2008 (12:23 pm)
Try something like:client.setCameraObject(orbitCam)
client.setControlObject(player)
#454
09/03/2008 (9:04 am)
Does anyone know why the orbit camera seems to rock as you zoom closer to the player? This is very frustrating behavior that is anything but intuitive.
#455
09/19/2008 (7:49 am)
Added to TGE 1.5.2 with AFX 1.1.0 and TMK. I applied the bandwidth fix by Shannon "ScarWars" Scarvaci posted in this thread. The camera worked from the get-go.
#456
Do i have to change something in the advancedCamera script or somehow "push" the objects to the newcam?
10/04/2008 (4:33 pm)
Hi i use this code in TGEA 1.7.1 but i have some weird bug that i can't see any object except the player in my world when i use the advancedCamera.Do i have to change something in the advancedCamera script or somehow "push" the objects to the newcam?
#457
I will mail it or post it when i manage to finish it might be a while and some head banging to go. Also i am completely clueless as to how the networking really works so my code will prob be missing that part or i may need some help on that.
*crosses fingers*
10/11/2008 (6:01 pm)
Hi i am thinking of putting togheter a method for the tracking camera to let you give it a position and maybe a rate value and move the tracking camera to that position at the rate you give it. I do not think it would be too hard to do despite me being very new to the engine. I think it could be quite useful for doing all sorts of camera panning effects. Also for this sort of thing i think it would be useful to make the tracking camera also be able to focus on a xyz point instead of just an player object or if i am wanting to get particularly flashy could make a method to let you move that point of focus as well.I will mail it or post it when i manage to finish it might be a while and some head banging to go. Also i am completely clueless as to how the networking really works so my code will prob be missing that part or i may need some help on that.
*crosses fingers*
#458
Thx.
12/08/2008 (3:38 pm)
Hello, I have started a new project with TGEA 1.7.1 with AFX and have followed this tutorial and Cory Osborn's Resource and for some reason as soon as I go into camera mode, by hitting Tab then F8, so I can do some world editing, it immediately locks the camera's position. I cannot move with the keyboard or mouse. Other keys such as tilde, esc all work fine, it's just the actual movement some seems to be disabled. Has anyone experienced this? Any suggestions?Thx.
#459
I want to have the camera static but the player still move based on input. When I use the static camera it makes it so the player doesn't move.
Is the player not moving during the static camera something that I am doing wrong or is that the expected behavior of the static camera?
If that is how the static camera works, how can I get the behavior I am looking for?
Thanks,
Taylor
12/25/2008 (10:00 pm)
Hey,I want to have the camera static but the player still move based on input. When I use the static camera it makes it so the player doesn't move.
Is the player not moving during the static camera something that I am doing wrong or is that the expected behavior of the static camera?
If that is how the static camera works, how can I get the behavior I am looking for?
Thanks,
Taylor
#460
01/10/2009 (9:25 pm)
I checked a few modes, god and orbit and found that they are working fine except for the particle and collisions. The particals are behaving abnormally and are sometimes visible and sometimes not. The weapon fire does give player(kork) damage and screen goes red but the particle flair does not show up. But sometimes it does. It seems to me that the default camera and the Advanced camera may be interfering each other as I haven't commented the code for default cam. Please give any suggestion on this. Same for Items like health and crossbow. 
Torque 3D Owner Nicolai Dutka
Just to cover the basics, did you try switching cameras? You might have the code applied as an observer camera which is free floating. You want to effect the camera on the player's eye node.