[Interest] [Qt 3D] Using an orthographic projection

Adrián Chaves Fernández adriyetichaves at gmail.com
Fri Mar 25 10:16:28 CET 2016


2016-03-25 9:32 GMT+01:00 Sean Harmer <sean.harmer at kdab.com>:
> The camera lens just constructs the view volume. In this case a cuboid
from
> -10 to +10 in x and y but your near plane and far plane values look
strange
> (2.0f and -1.0f). Try setting these to something like 0.01 and 20.0 to
give
> you a viewing volume that is (almost) a cube. This defines the volume of
space
> relative to your camera that will get rendered.

That was it, many thanks!

I had to:
- Switch the nearPlane and farPlane values (2.0f, -1.0f → -1.0f, 2.0f). In
the perspective projection the near plane is the closest to the camera
position and the far planest is the farthest, but it looks like it is the
opposite in the orthographic projection.
- Increase the value of the farPlane to include the camera (2.0f → 6.0f).
In the perspective projection the camera does not need to be inside the
rendering area, but it looks like it does in the orthographic projection.
- Define the aspect ratio through the left/right/bottom/top parameters
(-10.0f, 10.0f, -10.0f, 10.0f → -16.0f, 16.0f, -9.0f, 9.0f). That was easy
to figure out once I was able to see the rendering results.

Result:
    cameraEntity->setUpVector(QVector3D(0, 1, 0));
    cameraEntity->setViewCenter(QVector3D(0, 0, 0));
    cameraEntity->setPosition(QVector3D(0.0f, 0.0f, 5.0f));
    //     cameraEntity->lens()->setPerspectiveProjection(60.0f, 16.0f /
9.0f, 2.0f, -1.0f);
    cameraEntity->lens()->setOrthographicProjection(-16.0f, 16.0f, -9.0f,
9.0f, -1.0f, 6.0f);

PS: Answering to the list this time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160325/ae0a6646/attachment.html>


More information about the Interest mailing list