[SOLVED] Orthographic camera


Recommended Posts

Hello everyone, I`m having a bit of a problem setting up a proper orthographic camera with C++ API in my projects. It seems that there is no way for me to change a camera projection without creating my own mat4 and passing it as an argument to setProjection to the class camera. Is there any other way around to acomplish this task without going in depth with matrix conversations?

Edited by fedorov.ilya
Link to post

Hello Ilya,

You can set up orthographic projection for your camera via the Camera::setProjection() or Player::setProjection() methods.

For example, you can set up perspective projection for your current camera like this:

#include <UniginePlayers.h>
#include <UnigineGame.h>
using namespace Unigine;

/* ... */

int AppWorldLogic::init()
	/* ... */
  	// getting our current player
	PlayerPtr player = Game::get()->getPlayer();
	// setting up near and far clipping planes
	float znear = 0.001f;
	float zfar = 10000.0f;
	// setting up orthographic projection
	player->setProjection(Math::ortho(-1.0f, 1.0f, -1.0f, 1.0f, znear, zfar));

	return 1;

Hope this helps!


  • Like 1
Link to post