Game Development Community

Near plane view frustum issue

by David Dougher · in Torque Game Engine Advanced · 09/28/2006 (7:01 am) · 2 replies

In game.cpp the player's view of the situation is set in this small piece of code

bool GameProcessCameraQuery(CameraQuery *query)
{
GameConnection *connection = GameConnection::getConnectionToServer();

if (connection && connection->getControlCameraTransform(0.032f, &query->cameraMatrix))
{
query->object = connection->getControlObject();
//old line
//query->nearPlane = 0.1f;

Sky *pSky = gClientSceneGraph->getCurrentSky();

if (pSky)
query->farPlane = pSky->getVisibleDistance();
else
query->farPlane = 1000.0f;

//new line added
query->nearPlane = query->farPlane/5000.0f; <<-----------------------------This line is the question.

F32 cameraFov;
if (!connection->getControlCameraFov(&cameraFov))
return false;

query->fov = mDegToRad(cameraFov);
return true;
}
return false;
}

The far plane is being picked up from the mission file line in the "Sky" portion.

visibleDistance = "800"; //"35000";

Using the division works fine as long as the value remains fairly small (under 2000). However, as the distance begins to approach 5000 the near plane begins to move away from the character's eye node and out into the screen. This can cause some rather odd views as you look out. Using the 35000 setting shown above the near plane was out so far that the characters body and shadows were completely lost and I was seeing water beneath the terrain where the player was standing instead of the terrain itself.

While we are using the large visibleDistance to allow us to get very far from the terrain for editing purposes I could see someone trying to use it for a flight game.

The fix we used was to revert back to the older code which set the near plane arbitrarily to 0.1f. However, I wanted to see why the code was implemented this way - if it was some sort of optimization. I noticed that similar changes were made to guiPlayerView.cpp and to EditTSCtrl.cpp

About the author

Owner - Pariah Games, Adjunct Professor - Bristol Community College, Mentor - Game Design - Met School Newport, Mentor - Game Design - Met School Providence


#1
09/28/2006 (11:05 am)
We changed it back to 0.1f as well in Air Ace - no noticable effects, and we wondered too why the change was made + why the arbitrary value of / 5000.0f?
#2
09/28/2006 (12:10 pm)
Ya, there are some problems with that, and it's been reverted. Guess it didn't make it out on the last CVS push.