[vtkusers] synchronize model view transformations between opengl and vtk windows

Dan Lipsa dan.r.lipsa at gmail.com
Wed Aug 8 12:36:17 EDT 2012


Hi Jana,
Thank you very much for your suggestions.

On Tue, Aug 7, 2012 at 11:00 PM, Jana Sefcikova <neollie at gmail.com> wrote:
> Hi Dan,
> all matrices can be found in vtkCamera (vtkCamera ::GetModelViewMatrix;
> vtkCamera::GetProjectionTransformMatrix). Also vtkOpenGLCamera::Render()
> method could serve as good starting point, because also viewport is preseted
> there.
>
> For direction VTK -> Opengl , this could be inspiration
> http://vtk.1045678.n5.nabble.com/How-to-forward-mouse-move-event-to-polydata-algorithm-and-get-there-direction-of-projection-td5714021.html#a5714029
> . In vtkCameraObserver there, you can implement code that update your OpenGL
> state (instead of mine case, where I wanted update vtk algorithm) .
>
> For oposite direction this thread could be inspiration
> http://vtk.1045678.n5.nabble.com/Question-on-manual-configuration-of-VTK-camera-td5059478.html
> . There is no direct method to set model view matrix, it is necessary use
> vtkCamera methods to preset camera (at least as I know )

I think I got it working using this method. It is rather tricky as I
had a set of transformations applied to the model in opengl. When
applying those to the camera, rotations have to be inversed and they
have to be applied in reverse order.

> Also I think that if you preset both contexts to same initial composition
> (modelview matrix or perhaps only view matrix), than you could use only
> vtkCamera::SetUserTransform and vtkCamera::GetUserTransform (for model
> matrix) for synchronization.

Earlier, I tried this, but this screws up the default light - it
starts following the camera instead of being fixed.

Thanks again for your valuable suggestions.
Dan



More information about the vtkusers mailing list