[2.2] Orthographic camera culling problems

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
marbey
Gnoblar
Posts: 3
Joined: Tue May 04, 2021 4:26 pm
x 1

[2.2] Orthographic camera culling problems

Post by marbey »

Hello,

I have some culling problems when I rotate orthographic camera. I have an object positionned at the origin.

Code: Select all

// Initialization
pCamera = pSceneManager->createCamera("CameraMainOrthographic");
const float fScale = 1.f / 50.f;
pCamera->setNearClipDistance(0.0001f);
pCamera->setFarClipDistance(10000.f);
pCamera->setProjectionType(Ogre::ProjectionType::PT_ORTHOGRAPHIC);
pCamera->setOrthoWindow(Ogre::Real(width * fScale), Ogre::Real(height * fScale));
pCamera->setFixedYawAxis(false);

Code: Select all

// Update
m_pCamera->setOrthoWindowHeight(m_pCamera->getOrthoWindowHeight() * m_fScale);
m_pCamera->setOrthoWindowWidth(m_pCamera->getOrthoWindowWidth() * m_fScale);
m_fScale = 1.f;

m_pCamera->yaw(Ogre::Radian(m_fCameraYaw));
m_pCamera->pitch(Ogre::Radian(m_fCameraPitch));
m_fCameraYaw = 0.0f;
m_fCameraPitch = 0.0f;
Am I doing something wrong ?
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 186
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 44

Re: [2.2] Orthographic camera culling problems

Post by sercero »

Hello,

Could you give a graphic example of what is the problem (screen capture)?

Also:

Code: Select all

m_pCamera->yaw(Ogre::Radian(m_fCameraYaw));
m_pCamera->pitch(Ogre::Radian(m_fCameraPitch));
m_fCameraYaw = 0.0f;
m_fCameraPitch = 0.0f;
Why are you setting the variables after being used?
What values do they contain before?
Have you tried other values for NearClipDistance?
marbey
Gnoblar
Posts: 3
Joined: Tue May 04, 2021 4:26 pm
x 1

Re: [2.2] Orthographic camera culling problems

Post by marbey »

Thanks,

Image Image

Yes, I try to change NearClipDistance, but it doesn't change anything.

I move the pitch and yaw with mouse move + click, I don't want the camera continue to move when I release mouse click, it works well :)
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 186
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 44

Re: [2.2] Orthographic camera culling problems

Post by sercero »

Please check these forum threads:

* Orthographic coordinates
viewtopic.php?t=70709

* Orthographic projection
viewtopic.php?t=30980

* Orthographic camera FOV question
viewtopic.php?t=10864

* FOV and ORTHOGRAPHIC camera
viewtopic.php?t=16124

I used them as reference to implement an Orthographic camera for an editor.
marbey
Gnoblar
Posts: 3
Joined: Tue May 04, 2021 4:26 pm
x 1

Re: [2.2] Orthographic camera culling problems

Post by marbey »

I solved my problem by positioning the camera far away

Code: Select all

const float fScale = 1.f / 50.f;
pCamera->setProjectionType(Ogre::ProjectionType::PT_ORTHOGRAPHIC);
pCamera->setPosition(Ogre::Vector3(0, 0, 10000));
pCamera->lookAt(Ogre::Vector3(0, 0, 0));
pCamera->setNearClipDistance(.01f);
pCamera->setOrthoWindow(Ogre::Real(width * fScale), Ogre::Real(height * fScale));
Thanks for help :D
Post Reply