Page MenuHomePhabricator

TextOverlay3D should interpret offset as relative to the camera
Closed, ResolvedPublic

Description

TextOverlay3D takes an offset and adds it to the overlay text position. The intention was probably to set the position to some reference position in a visible object and then add an offset to avoid an overlap between the label and the labeled position.

Currently, TextOverlay3D interprets the offset vector as relative to the "world" and not relative to the camera. Consequently, the text label will visually change position and the perceived offset between position and text changes constantly when we rotate the camera. This makes the offset less valuable.

I propose to change the offset calculation so that it interprets the given vector as relative to the VTK camera. The first component would be the camera's "right" vector, the second component the "up" vector, the third one the view direction.

The necessary change is local to TextOverlay3D and works fine (for me).

Event Timeline

User maleike has pushed new remote branch:

bug-19589-textoverlay-relative-to-camera

Thank you for the fix! I agree.
You could alternatively provide the offset vector in display coordinates (pixel units) and transform them with:
mitk::BaseRenderer::DisplayToWorld(Point2D display, Point3D world).
This would result in offsets which are independent of the camera distance. I am not sure if that is desired.

BUT: since the rendering in a foreground renderer (mitkVtkLayerController) currently doesn't work for some reason, it makes sense to provide a third offset component in camera direction.

new reference for mitkTextOverlay3DColorRenderingTest_ball.png (Windows)

mitkTextOverlay3DColorRenderingTest_ball.png (480×640 px, 27 KB)

new reference for mitkTextOverlay3DRendering2DTest_ball.png (Windows)

mitkTextOverlay3DRendering2DTest_ball.png (480×640 px, 3 KB)

new reference for mitkTextOverlay3DRendering3DTest_ball.png (Windows)

mitkTextOverlay3DRendering3DTest_ball.png (480×640 px, 27 KB)

Attached new reference screenshots for rendering tests work fine for my Windows and Linux machines. Would be nice if someone could verify behavior on a Mac.

Rendering tests work fine on osx.

(In reply to Jonas Cordes from comment #7)

Rendering tests work fine on osx.

Ok, thanks! I'm waiting for an updated MITK-Data package, then I'll integrate.

[6ac76c]: Merge branch 'bug-19589-textoverlay-relative-to-camera'

Merged commits:

2016-03-09 11:04:39 Daniel Maleike [74af15]
Update MITK-Data version


2016-03-07 17:56:48 Daniel Maleike [84907c]
Interpret text overlay offset as relative to the camera