z Rotate a label?

Have jReality programming problems or questions? Post them here.
Post Reply
STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

z Rotate a label?

Post by STRESS » Wed 1. Apr 2009, 11:23

Is there a way to z Rotate a Label by 90 or -90 degress? At the moment labels are always facing the camera that includes when the object or camera is rotated around the viewing direction IIRC. But I sometimes want to write Labels 90 rotated so instead of aligning horizontal on a line it should align vertical on a line. Can this be done without any core code modifications?

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Post by gunn » Fri 3. Apr 2009, 12:41

The short answer: it's not possible to have non-horizontal orientation of 3D text in jReality.

Technically, it wouldn't be difficult to imagine adding an "orientation angle" parameter to the text shader which would rotate the text by the specified angle in screen space. However, it needs a little thought to figure out exactly when to apply the rotation, since there are two sorts of offsets applied to the position, one coming from the method setOffset() and the other from the method setAlighment() (methods on DefaultTextShader), and one needs to decide when to apply the rotation -- I guess it should be applied between these two translations.

In any case, this extenstion will need to wait until after Easter holidays -- for me, April 20 or so. Barring unforeseen difficulties, I'd guess there will be something available by the end of the month. If it's not there, please remind me then.

If you want to try doing something yourself, you'll need to extend the method calculateBillboardMatrix() in de.jreality.backends.label.LabelUtility.
jReality core developer

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Post by STRESS » Fri 3. Apr 2009, 14:44

Hmm thanks gunn! Sounds promising.

Couldn't you just use a textureMatrix when you render the label that flips the texture coordinates? Okay it might make the alignment a bit strange in that case but I don't think the alignment makes any sense for vertical orientated labels anyway.

Thanks for the pointer I might have a look at it because I might need it before the end of this month.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Post by gunn » Fri 3. Apr 2009, 15:09

The problem with flipping the texture coordinates while leaving the geometry (rectangle) alone is, unless your text approximately square, when you flip u and v directions, the text will be stretched or compressed unnaturally. Say, my text is "text" which is about 4 times long as it is high, that is, it's stretchd out in the u direction. If I flip u and v, then I will see "text" oriented vertically, it's true, but it will be mapped onto the same (untransformed) rectangle as before, so all the letters will be unnaturally thin and elongated.
jReality core developer

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Post by STRESS » Tue 14. Apr 2009, 10:54

Well I added a vertical flip flag. Which z rotates the label after translation by 90 degrees when set. That fits my purposes. :D

I was a bit confused since calculateBillboardMatrix() is called through two different places by the different backends one calls it directly (JOGL) and the other one calles it through another function (sofware, renderman, etc.) when generating the SceneGraphNode.

Btw which software backend is actually currently used the new one or the old one?

Post Reply