GuiText Rotations
by Chris Groot · in Torque 3D Professional · 03/14/2011 (2:41 pm) · 5 replies
I'm looking to rotate text in my GUI so I can render text at any arbitrary angle. I am going about trying to use the GFX drawUtil function drawText( GFont *font, const Point2F &ptDraw, const UTF16 *in_string, const ColorI *colorTable, const U32 maxColorIndex , F32 rot ). I can easily add a floating point variable to the GuiControl class, set it to something non-zero and pass it to the above function.
The issue that seems to be happening is that the text is being rotated about the origin and if my GuiText control is not at the origin it gets rendered outside of its original render extents, making it not render at all sometimes.
Is this the intended functionality of this function, or am I missing a step somewhere along the way to get my text to rotate around it's current position and not the origin?
The issue that seems to be happening is that the text is being rotated about the origin and if my GuiText control is not at the origin it gets rendered outside of its original render extents, making it not render at all sometimes.
Is this the intended functionality of this function, or am I missing a step somewhere along the way to get my text to rotate around it's current position and not the origin?
#2
Kidding aside, can you post some screenshots of the problem and then perhaps post a screenshot mockup of the result you expected so that we can have a clearer picture of what is going on and it should give me an idea as to what do to about a solution to the problem.
03/24/2011 (1:06 pm)
Pics or didn't happen.Kidding aside, can you post some screenshots of the problem and then perhaps post a screenshot mockup of the result you expected so that we can have a clearer picture of what is going on and it should give me an idea as to what do to about a solution to the problem.
#3

This image is what I want to occur, to rotate the image as well as its bounding rect so that it doesn't get cut off by its bounding rect and it doesn't translate when rotated.(this image doesn't show the bounding box rotating but I'm not a photoshop guru, but the bounding rect should be rotated as well)

So the problem is two separate things, first I want to be able to rotate the bounding rect along with the text and the second issue is getting the text rotating about the rect center rather than some other unknown point, possibly the origin?
03/24/2011 (1:29 pm)
This image is what is currently occurring, the text is getting rotated around some point besides the center of the text. This is merely one degree of rotation, I know rotations are done in radians and I convert the degree value before applying it.
This image is what I want to occur, to rotate the image as well as its bounding rect so that it doesn't get cut off by its bounding rect and it doesn't translate when rotated.(this image doesn't show the bounding box rotating but I'm not a photoshop guru, but the bounding rect should be rotated as well)

So the problem is two separate things, first I want to be able to rotate the bounding rect along with the text and the second issue is getting the text rotating about the rect center rather than some other unknown point, possibly the origin?
#4
It may be tricky to rotate this region , take a look at GuiControl::renderChildControl()
I know about this problem,because I use bitmap rotations.
I modify the region that is large enough to cover the rotated bitmap and this avoids clipping.
About the translation - I think it is a result of a bad euler rotation.This is what happens when you rotate around an offset point.
03/24/2011 (2:19 pm)
It is the clip rectangle - it will clip everything outside the region.It may be tricky to rotate this region , take a look at GuiControl::renderChildControl()
I know about this problem,because I use bitmap rotations.
I modify the region that is large enough to cover the rotated bitmap and this avoids clipping.
About the translation - I think it is a result of a bad euler rotation.This is what happens when you rotate around an offset point.
#5
03/24/2011 (2:55 pm)
In order to do my rotations I'm just using the built in rotation in gfxFontRenderBatcher render function which is called from the original mentioned function. I haven't looked explicitly how rotations are occurring in there but if it doesn't implicitly support local rotations, I can attempt to implement it, I would just prefer to know for sure if it can support it before I go about trying to implement some nasty text rotation code that is already there :) Also it looks like when resizing the clip rect that the text is currently rotating about the left bounds center point. (i.e. point: x = cliprect.x and y = cliprect.extent.y/2)
Torque 3D Owner Chris Groot
VRSim