Re: [osg-users] Can't update my projection matrix amnually

2016-09-15 Thread Robert Osfield
On 15 September 2016 at 17:19, Bruno Oliveira
 wrote:
> I see. That means I need to manually keep updating my near/far plane.

NO.  If you want the OSG to use your projection matrices then you
simply need to switch off the automatic compute of the near/matrix as
I have already told you how to do.  That't it end of story.  I can't
help you anymore as I've already given you the answer you need you
just need to use it.  Simple.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Can't update my projection matrix amnually

2016-09-15 Thread Bruno Oliveira
I see. That means I need to manually keep updating my near/far plane.

Is there no other way?
 - Can I manually trigger a culling traversal?
 - I know the delta in z in which I am moving my camera. Can I calculate the 
new near and far planes the traversal will assign after the traversal? Example: 
newFarValue = oldFarValue + deltaZ
 - Is the near/far plane update code centralized in some public function that I 
can somehow use? If not, could you please tell me where this code is so that I 
can reproduce it?

> On 15 Sep 2016, at 17:09, Robert Osfield  wrote:
> 
> On 15 September 2016 at 16:57, Bruno Oliveira
>  wrote:
>> 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?
> 
> You can't manually force a compute of the near/far planes, it happens
> as part of the cull traversal as this is where the OSG can determine
> what objects are in the view frustum and hence what values would be
> appropriate to clamp the near and far planes so all objects are
> visible.
> 
> If you don't want this computation simple switch it off as per my
> previous email.
> 
> Robert.
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Can't update my projection matrix amnually

2016-09-15 Thread Robert Osfield
On 15 September 2016 at 16:57, Bruno Oliveira
 wrote:
> 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?

You can't manually force a compute of the near/far planes, it happens
as part of the cull traversal as this is where the OSG can determine
what objects are in the view frustum and hence what values would be
appropriate to clamp the near and far planes so all objects are
visible.

If you don't want this computation simple switch it off as per my
previous email.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Can't update my projection matrix amnually

2016-09-15 Thread Robert Osfield
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
 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@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org