2
$\begingroup$

Is there a way to figure out the frustum bounds of an orthographic camera using Blender Game Engine?

I'm trying to anchor some panels on the corners of the screen without success .

I'm working with two scenes , one with a camera perspective and another with the orthographic camera ( hud )

Thanks in advance

$\endgroup$
2
  • 1
    $\begingroup$ This is a good question. If you can add a screenshot of what you're trying to accomplish, it'd be even betterer. $\endgroup$
    – Matt
    Jun 16 '16 at 21:21
  • 1
    $\begingroup$ ...and welcome to B.SE, btw! $\endgroup$
    – Matt
    Jun 16 '16 at 21:22
1
$\begingroup$

Here is where you set it:

enter image description here

It says 7.314, therefore the camera is 7.314 wide.

As to doing it in real-time, the python API you are looking for is camera.orthoscale to get the width of the camera.

Sample code (untested):

aspect_ratio = bge.render.getScreenHeight() / bge.render.getScreenWidth()
height = aspect_ratio * camera.orthoscale
top_right = camera.getAxisVect([width/2, height/2, 0.5])
bottom_left = camera.getAxisVect([-width/2, -height/2, 0.5])

Note that the 0.5's in the getAxisVect are to place the object slightly forwards of the camera to ensure it get's viewed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.