Hi Federico, maybe you could create the foreground renderer in the constructor of your mapper. Use the mitk::RenderingManager to access all existing baserenderers and store the new forground renderer as a member of the mapper. This way it is created only once and outside of the rendering process. But I don't think that this will result in nice code...
If your goal is to have a text overlay at a 3D word position, which is in foreground and always facing the camera I would recommend to use the mitk::TextOverlay2D. The problem is, that it requires the position on the display (in pixels) to be placed, but you can transform a 3D point to display coordinates by using the following methods: vtkRenderer::SetWorldPoint vtkRenderer::WorldToDisplay vtkRenderer::GetDisplayPoint Btw, we have recently added a method to the mitk::BaseRenderer that does exactly this transformation: http://docs.mitk.org/nightly/classmitk_1_1BaseRenderer.html#a5e168576694876aa7a89b5fb252bc8ce Regards Christoph On Tue, 2015-09-08 at 01:35 +0200, Federico Milano wrote: Hi Christoph, I just need to have a foreground renderer to add some actors, but I cannot apply the fix you mentioned in your previous answer (I just can use the 2014.03 version with no mods), so I was wondering where could I add the foreground renderer inside the mapper. Right now Im adding a foreground render in a view and then getting the highest layer renderer in the mapper...but if I leave it like that it is a recipe for future disaster. I would really appreciate if you could give me a hint. Thanks, Fede El sep 7, 2015 7:08 p.m., "Kolb, Christoph" <[email protected]<mailto:[email protected]>> escribió: Hi Federico, I am not sure how you solved your previous problem, and wonder why the AddBaseRenderer Method is needed. This one is actually meant to register a new seperate renderer for the OverlayManager to manage. I would not recommend to use it for the registration of foreground renderers. Can you please explain how you want to use the foreground renderers? Regards Christoph ________________________________________ Von: Federico Milano [[email protected]<mailto:[email protected]>] Gesendet: Montag, 7. September 2015 22:04 An: Kolb, Christoph Cc: [email protected]<mailto:[email protected]> Betreff: Re: [mitk-users] Overlay in 3D problem Thank you Christoph. Another question, if I'm doing this in a VtkMapper, where should I add the renderer? Because if I do it in GenerateDataForRenderer() using something like mitk::OverlayManager::AddBaseRenderer() then I end up changing the vtkRendererCollection of the vtkRenderWindow while it is being traversed (GenerateDataForRenderer() is indirectly called by the Render() method of vtkRendererCollection). That invalidates the iterator and produces undefined behaviour (in my case, an Access Violation in the third overlay I add). It is clear to me how to add foreground renderers from other contexts, but I don't know how to add them in VtkMapper derived classes. Thanks in advance, Federico On Sun, Aug 30, 2015 at 1:47 PM, Kolb, Christoph <[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>> wrote: Hi Federico, prior to the 2015.05 Release, we have added a flag to the Overlays, that forces them to be drawn in front: <http://bugs.mitk.org/show_bug.cgi?id=18536>http://bugs.mitk.org/show_bug.cgi?id=18536 http://docs.mitk.org/nightly-qt4/classmitk_1_1OverlayManager.html#a78c770eb3f088025c9b8026d3c51fa7e Alternatively you could use the TextOverlay2D which is always on top. The difference is that this ones position is defined on the display. Regards Christoph On Sun, 2015-08-30 at 02:14 +0200, Federico Milano wrote: Hi. I'm trying to display an overlay in a 3D window. I'm using this document<http://mitk.org/images/d/d1/BugSquashingSeminars$Overlays_in_MITK.pdf>: as a guide. I've created a plugin that adds a TextOverlay3D to the 3D window renderer overlay manager (exaclty as it is stated in that document). The problem is that the TextOverlay3D is not being drawn over the scene. If you position, for example, a cube in front of it, it occludes the text (see attached screenshot). I'm using MITK 2014.03. I'll really appreciate any hint. Thanks, Federico ------------------------------------------------------------------------------ _______________________________________________ mitk-users mailing list [email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>> https://lists.sourceforge.net/lists/listinfo/mitk-users ------------------------------------------------------------------------------ _______________________________________________ mitk-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mitk-users
