Re: [osg-users] Model attached to Camera

2013-11-14 Thread Trajce Nikolov NICK
Hi Robert,

thanks for the hint. I don't have CameraManipulator. Anyway I made it work
with HUD like approach.

Thanks again

Nick


On Thu, Nov 14, 2013 at 2:55 PM, Robert Milharcic <
robert.milhar...@ib-caddy.si> wrote:

> On 14.11.2013 11:32, Trajce Nikolov NICK wrote:
>
>> It doesn't look right. What is wrong with this code? Also, there is some
>> delay (when I don't apply the orientation just for debug), the model when
>> attached is sort of delayed following the camera. Any hints?
>>
>
> Hi Nick,
>
> I'm just guessing here, but if model is delayed, it probably means that
> camera's view matrix wasn't updated yet. If I remember correctly, Viewer
> will update its camera by calling cameraManipulator->updateCamera()
> somewhere in the update traversal too... so, maybe node callback is called
> before updateCamera()? Maybe you could cast camera->getView() to
> osg::Viewer::View and then call getViewerBase(), cast it to proper Viewer
> and call viewer->getCameraManipulator()->updateCamera() ...
>
> Robert Milharcic
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



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


Re: [osg-users] Model attached to Camera

2013-11-14 Thread Robert Milharcic

On 14.11.2013 11:32, Trajce Nikolov NICK wrote:

It doesn't look right. What is wrong with this code? Also, there is some
delay (when I don't apply the orientation just for debug), the model when
attached is sort of delayed following the camera. Any hints?


Hi Nick,

I'm just guessing here, but if model is delayed, it probably means that 
camera's view matrix wasn't updated yet. If I remember correctly, Viewer 
will update its camera by calling cameraManipulator->updateCamera() 
somewhere in the update traversal too... so, maybe node callback is 
called before updateCamera()? Maybe you could cast camera->getView() to 
osg::Viewer::View and then call getViewerBase(), cast it to proper 
Viewer and call viewer->getCameraManipulator()->updateCamera() ...


Robert Milharcic

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


Re: [osg-users] Model attached to Camera

2013-11-14 Thread Trajce Nikolov NICK
I gave up on this approach. Used another Camera that mimic HUD but with
Prespective projection. Works now. Have to learn to stress less when
looking for answers :-)

Cheers,

Nick


On Thu, Nov 14, 2013 at 1:32 PM, Trajce Nikolov NICK <
trajce.nikolov.n...@gmail.com> wrote:

> Hi Community,
>
> I would like to do this mentioned in the subject and I am facing issues.
> Sounds pretty simple but need help.
>
> The model is attached to osg::MatrixTransform and I have
> osg::UpdateCallback attached to it that sets the Matrix based on the
> camera. So here is the snippet from the callback:
>
> osg::MatrixTransform* mxt = dynamic_cast(node);
>
> osg::Vec3 pos = camera->getInverseViewMatrix().getTrans();
> osg::Quat rot = camera->getInverseViewMatrix().getRotate();
>
> mxt->setMatrix(osg::Matrix::rotate(rot)*osg::Matrix::translate(pos)).
>
> It doesn't look right. What is wrong with this code? Also, there is some
> delay (when I don't apply the orientation just for debug), the model when
> attached is sort of delayed following the camera. Any hints?
>
> Thanks a bunch
>
> Nick
>
> --
> trajce nikolov nick
>



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