Discussion:
[mitk-users] Render vtkCamera position update on QMitkRenderWindow
Albert Alises
2017-02-24 12:13:04 UTC
Permalink
Hello everyone,

I am having trouble rendering the update of a vtkCamera on a
QMitkRenderWindow. I have a renderWindow which looks at a given scene. I
get its associated *vtkRenderWindow *and from it, the *ActiveCamera() *(Which
is a vtkCamera object).

I then modify the position and the view of that camera by doing that:

currentCamera->SetPosition(0.0,0.0,0.0);
currentCamera->SetViewUp(1.0,0.0,0.0);
currentCamera->SetFocalPoint(0.7, 0.3, 0.4);
vtkTransform* translationToPoint = vtkTransform::New();
translationToPoint->Translate(40, 20, 30);
currentCamera->ApplyTransform(translationToPoint);


After applying these transformations, the renderwindow turns black, which
suggests that the render has not been updated. I have tried:

currentCamera->Modified();
this->RequestRenderWindowsUpdate();
Paint method of the Base Renderer from MITK
vtkRenderWindow->Update();

and rendering the camera, render windows, renderer associated.... None of
them is working though.... However, the rendering is updated correctly when
scrolling on the window with the mouse. Which method is the correct one to
call for the window to show the new scene after modifying the vtkCamera
associated to a the window? (the one the WheelEvent method on the
QMitkRenderWindows seems to call).

Thank you very much,
Albert.
Ingmar Wegner
2017-02-24 14:05:28 UTC
Permalink
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Albert Alises
2017-02-24 14:20:17 UTC
Permalink
Hello Ingmar,

Thank you for your response! I did try to do that but unfortunately the
scene keeps going black after executing these changes. Calling any event on
the window makes the view to render correctly (wheel event, or just moving
around), so it has to be a method called when doing that on a
QmitkRenderWindow, just cannot seem to find it...

Thank you,
Albert.
Hi Albert,
did you try orthogonalizing the view up vector before calling
RequestUpdate?
currentCamera->OrthogonalizeViewUp();
RenderingManager::REQUEST_UPDATE_3DWINDOWS);// For 3D widget only
This recomputes the view up vector to force it to be perpendicular to
camera->focal point vector. (See vtkCamera docu)
Ingmar
(Written on cellphone)
Post by Albert Alises
Hello everyone,
I am having trouble rendering the update of a vtkCamera on a
QMitkRenderWindow. I have a renderWindow which looks at a given scene. I
get its associated* vtkRenderWindow* and from it, the* ActiveCamera()*
(Which is a vtkCamera object).
currentCamera->SetPosition(0.0,0.0,0.0);
currentCamera->SetViewUp(1.0,0.0,0.0);
currentCamera->SetFocalPoint(0.7, 0.3, 0.4);
vtkTransform* translationToPoint = vtkTransform::New();
translationToPoint->Translate(40, 20, 30);
currentCamera->ApplyTransform(translationToPoint);
After applying these transformations, the renderwindow turns black, which
currentCamera->Modified();
this->RequestRenderWindowsUpdate();
Paint method of the Base Renderer from MITK
vtkRenderWindow->Update();
and rendering the camera, render windows, renderer associated.... None of
them is working though.... However, the rendering is updated correctly when
scrolling on the window with the mouse. Which method is the correct one to
call for the window to show the new scene after modifying the vtkCamera
associated to a the window? (the one the WheelEvent method on the
QMitkRenderWindows seems to call).
Thank you very much,
Albert.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging
tech sites, SlashDot.org! http://sdm.link/slashdot______
_________________________________________ mitk-users mailing list
lists/listinfo/mitk-users
Girish Lande
2017-02-27 03:33:18 UTC
Permalink
Hi Albert,
Can you try changing this position vector.
currentCamera->SetPosition(0.0,0.0,0.0);

in my observation setPosition actually defines direction vector in which
camera is looking at the object.
So I think it should have some direction .

For e.g to look at same object in 3 different directions(standard x,y,z) I
do this

case 0:

cam->SetFocalPoint(0,0,0);

cam->SetPosition(1,0,0);

cam->SetViewUp(0,0,1);

break;


case 1:

cam->SetFocalPoint(0,0,0);

cam->SetPosition(0,-1,0);

cam->SetViewUp(0,0,1);

break;


case 2:

cam->SetFocalPoint(0,0,0);

cam->SetPosition(0,0,1);

cam->SetViewUp(0,1,0);

break;



regards,
Girish
Post by Albert Alises
Hello Ingmar,
Thank you for your response! I did try to do that but unfortunately the
scene keeps going black after executing these changes. Calling any event on
the window makes the view to render correctly (wheel event, or just moving
around), so it has to be a method called when doing that on a
QmitkRenderWindow, just cannot seem to find it...
Thank you,
Albert.
Hi Albert,
did you try orthogonalizing the view up vector before calling
RequestUpdate?
currentCamera->OrthogonalizeViewUp();
mitk::RenderingManager::GetInstance()->RequestUpdateAll(
mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS);// For 3D widget only
This recomputes the view up vector to force it to be perpendicular to
camera->focal point vector. (See vtkCamera docu)
Ingmar
(Written on cellphone)
Post by Albert Alises
Hello everyone,
I am having trouble rendering the update of a vtkCamera on a
QMitkRenderWindow. I have a renderWindow which looks at a given scene. I
get its associated* vtkRenderWindow* and from it, the* ActiveCamera()*
(Which is a vtkCamera object).
currentCamera->SetPosition(0.0,0.0,0.0);
currentCamera->SetViewUp(1.0,0.0,0.0);
currentCamera->SetFocalPoint(0.7, 0.3, 0.4);
vtkTransform* translationToPoint = vtkTransform::New();
translationToPoint->Translate(40, 20, 30);
currentCamera->ApplyTransform(translationToPoint);
After applying these transformations, the renderwindow turns black,
currentCamera->Modified();
this->RequestRenderWindowsUpdate();
Paint method of the Base Renderer from MITK
vtkRenderWindow->Update();
and rendering the camera, render windows, renderer associated.... None
of them is working though.... However, the rendering is updated correctly
when scrolling on the window with the mouse. Which method is the correct
one to call for the window to show the new scene after modifying the
vtkCamera associated to a the window? (the one the WheelEvent method on the
QMitkRenderWindows seems to call).
Thank you very much,
Albert.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging
tech sites, SlashDot.org! http://sdm.link/slashdot______
_________________________________________ mitk-users mailing list
lists/listinfo/mitk-users
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
mitk-users mailing list
https://lists.sourceforge.net/lists/listinfo/mitk-users
--
thanks & regards,
Girish
--
-------------------------------------------------------------------------------------------------------------------------
*Disclaimer:* This email message including any attachments is confidential,
and may be privileged and proprietary to Agiliad. If you are not the
intended recipient, please notify us immediately by replying to this
message and destroy all copies of this message including any attachments.
You are NOT authorized to read, print, retain, copy, disseminate,
distribute, or use this message or any part thereof. Thank you.
------------------------------------------------------------------------------------------------------------------------
Loading...