[osg-users] Can't update my projection matrix amnually
Bruno Oliveira
bruno.manata.oliveira at gmail.com
Thu Sep 15 08:57:26 PDT 2016
Hello,
I just verified and it is indeed related to near and far planes.
I am zooming my camera, and therefore, somewhere along the OSG update loops, the near and far planes will change but I don’t know what the new value is going to be.
I need to reproduce that in my code, as in:
>> camera->setViewMatrix(getInverseMatrix());
>> camera->setProjectionMatrixAsPerspective(...);
Can I somehow trigger the near/far plane recalculation?
> On 15 Sep 2016, at 16:49, Robert Osfield <robert.osfield at gmail.com> wrote:
>
> Hi Bruno,
>
> There a few two many unknowns for us to know what is going on. So we
> can only guess.
>
> Could it be that the OSG's default clamping of the near/far values to
> fit with the bounds of the scene in the view frustum is what is
> adjusting the projection matrix?
>
> Try setting the ComputeFarMode to DO_NOT_COMPUTE_NEAR_FAR via
>
> viewer.getCamera()->setComputeFarMode(osg::CullSetting::DO_NOT_COMPUTE_NEAR_FAR);
>
> Then see what happens.
>
> Robert.
>
> On 15 September 2016 at 16:18, Bruno Oliveira
> <bruno.manata.oliveira at gmail.com> wrote:
>> Hello,
>>
>>
>> I am trying to set my view and projection camera matrix. I do this inside a
>> custom camera manipulator code I am building.
>>
>> I set the camera view matrix as
>>
>> camera->setViewMatrix(getInverseMatrix());
>>
>> After this, since I am using a perspective projection matrix, I know I need
>> to update my projection matrix. I try to do this with
>>
>> camera->setProjectionMatrixAsPerspective(30.f, aspectRatio, 0.5f, 500.f);
>>
>> This results in the following projection matrix,
>>
>> 2.69691 0 0 0
>>
>> 0 3.73205 0 0
>>
>> 0 0 -1.002 -1
>>
>> 0 0 -1.001 0
>>
>>
>> However this is wrong, my matrix should be something similar to
>>
>> 2.69691 0 0 0
>>
>> 0 3.73205 0 0
>>
>> 0 0 -50 -1
>>
>> 0 0 -1.01309e+06 0
>>
>>
>> What am I doing wrong? What else do I need to correctly compute the
>> projection matrix?
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
More information about the osg-users
mailing list