Control of first person camera "near plane" via script
by Matthew Jessick · in Torque Game Engine · 05/18/2007 (7:44 am) · 0 replies
I was surprised to see that there doesn't seem to be any ability to control the camera "near plane" from script. This is the closest distance from the camera position that the system starts to render. Anything closer will be "clipped". If you happen to need to put a 3D object near the player's eye, this might have to be adjusted.
The following hard code in engine/game/game.cc seems to control the near plane in first person view
and could be hooked to a scripted override if desired:
bool GameProcessCameraQuery(CameraQuery *query)
{
GameConnection* connection = GameConnection::getConnectionToServer();
if (connection && connection->getControlCameraTransform(0.032f, &query->cameraMatrix))
{
query->object = connection->getControlObject();
query->nearPlane = 0.1f;
Changing the near plane is a very powerful adjustment that shouldn't be taken lightly. Making it too small could affect the ability of the engine to sort objects properly in the distance (cause excessive "Z Fighting"). Use it wisely.
The following hard code in engine/game/game.cc seems to control the near plane in first person view
and could be hooked to a scripted override if desired:
bool GameProcessCameraQuery(CameraQuery *query)
{
GameConnection* connection = GameConnection::getConnectionToServer();
if (connection && connection->getControlCameraTransform(0.032f, &query->cameraMatrix))
{
query->object = connection->getControlObject();
query->nearPlane = 0.1f;
Changing the near plane is a very powerful adjustment that shouldn't be taken lightly. Making it too small could affect the ability of the engine to sort objects properly in the distance (cause excessive "Z Fighting"). Use it wisely.