Jump to content

[SOLVED] Problem with the horizontal field of view


photo

Recommended Posts

Hi,

I am rendering trough the camera of my playerSpectator with a horizontal field of view of 60.0, I am calculating the vertical field with the following code.

	//FOV
	double aspectRatio = static_cast<double>(Unigine::App::getWidth()) / static_cast<double>(Unigine::App::getHeight());	
	double fovhRad = fovh * M_1_PI / 180.0;	
	double fovvRad = 2.0 * Unigine::Math::atan(Unigine::Math::tan(fovhRad*0.5) / aspectRatio);	
	double fovv = fovvRad * 180 / M_1_PI;
	mpWorldLogic->getVisualizationSupervisor()->GetUnigineCurrentPlayerSpectator()->setFov(static_cast<float>(fovv));

	//Offset horizontal
	
	Unigine::Math::mat3 rotation_matrixX;
	Unigine::Math::mat3 rotation_matrixY;
	Unigine::Math::mat3 rotation_matrixZ;
	mpWorldLogic->getVisualizationSupervisor()->GetUnigineCurrentPlayerSpectator()->setRotation(Unigine::Math::quat(-90, hoffset, 0));

I am then applying an horizontal rotation (hoffset) to my playerspectator.

In brief, I'm rendering my scene with a horizontal fov of 60.0 then i am rotating of +60 degrees still with a field of view of 60 and the rendered images are not matching.  

In the following images there is a little angle that is not covered by the any of the images.

How is it possible, what am I doing wrong ?

 

0offset.png

60offset.png

Link to comment

setFov recalculate projection matrix with aspect ratio = 1

try to modificate

double aspectRatio = static_cast<double>(Unigine::App::getWidth()) / static_cast<double>(Unigine::App::getHeight());	
double fovhRad = fovh * M_1_PI / 180.0;	
double fovvRad = 2.0 * Unigine::Math::atan(Unigine::Math::tan(fovhRad*0.5) / aspectRatio);	
double fovv = fovvRad * 180 / M_1_PI;

auto player = mpWorldLogic->getVisualizationSupervisor()->GetUnigineCurrentPlayerSpectator();
float znear = player->getZNear();
float zfar = player->getZFar();
Mat4 proj = perspective(fovv, aspectRatio, znear, zfar); // calculate projection matrix with right aspect
player->setProjection(proj);


	//Offset horizontal
	
Unigine::Math::mat3 rotation_matrixX;
Unigine::Math::mat3 rotation_matrixY;
Unigine::Math::mat3 rotation_matrixZ;
mpWorldLogic->getVisualizationSupervisor()->GetUnigineCurrentPlayerSpectator()->setRotation(Unigine::Math::quat(-90, hoffset, 0));

image.png

  • Like 2
  • Thanks 1
Link to comment
  • silent changed the title to [SOLVED] Problem with the horizontal field of view
×
×
  • Create New...