|
Zozo Plympton
Registered User
Join date: 26 Oct 2006
Posts: 26
|
01-01-2007 19:55
Hi Guys and Girls (if any!  I did make a HUD panel which is attached to the Top Left HUD attachement point. If I attacht it now to the Top Right attachement point it will "displayed" outside of the screen area! Is there a way to make a HUD unit to show up nicely no matter the attachement point? Thanks. Zozo
|
|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
01-01-2007 19:57
I'm not sure if it's possible for an attached item to tell where it's attached at, but if it is possible, then you can use llSetPos() on the root prim of your HUD to have it properly align itself depending on which attachment point it's on.
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
Zozo Plympton
Registered User
Join date: 26 Oct 2006
Posts: 26
|
01-01-2007 20:01
Sure it is Possible. llGetAttached() returns the Id of the attachement point. Just in this case I am not sure how to calculate the right coordinate for each attachement point. Also the grid crashed and coulnd't finish my testing about this exact workaround 
|
|
Bones Outlander
Registered User
Join date: 16 Jan 2008
Posts: 30
|
01-24-2008 04:01
Was a solution ever found for this?
I haev created a HUD, but on my friends comuter it's positioned off the screen when attached as our resolutions are different.
Is there a way of getting the HUD to align itself correctly on and screen?
Thanks
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
01-24-2008 04:30
Go pick yourself up a ZHAO II Animation Override, I was poking around in there and there seems to be some "sanity code" for just such a thing. (I may be wrong, I was only skimming)
Anyways the premise goes something like this
ON attach... what was my attachment point last time? What is my attachment point now? are they the same? if not, look up the attachment point in a list. If point 0, set my position here. if point 1, set my position here. etc.
When all that's done, record my current attachment point so next time I'm attached I can tell if it's a new location.
----------
Oh and just for good measure, on state entry (saving the script) have it reset it's position. You might also want to save "current owner's key" every time it's attached, so that if it's attached on someone else, it will "reset it's position to factory settings on the new person's screen.
(nothing is worse than going to all the trouble of adding sanity code for them changing positions, only to push the hud into a convenient place while you're working with it, and forget to reset it before throwing it in the box for selling.)
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
01-24-2008 05:03
While automatic repositioning may seem nice at first, I personally prefer to set the attachments exact position myself. You cannot ever get it right for a 4:3 resolution AND a 16:10 widescreen resolution in either of the corners at the same time.
What looks like a perfect fit at a 1024x768 resolution will not work on a 1280x800 or even 1680x1050 or any other odd resolution.
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
01-24-2008 08:42
One of the problems with automatic HUD positioning is that screen coordinates vary from client to client because of display aspect ratio. Since this is entirely client-side, there's no way for the script to access that, even though it only applies to one client at any given time.
The thing to remember about the coordinate system is that the height of the rendered window is always 1 unit (it doesn't really make sense to use meters in this context) and the width is proportionate to that. So if viewing fullscreen on a 4:3 display, the width of the window is slightly more than 1.333 units, due to the menu bar across the top skewing the aspect ratio slightly, the exact amount of which itself depends on the specific screen dimensions and GUI scale.
Where the grid is centered, and therefore the coordinate range of the visible screen space itself, depends on which point the object is attached to. For center and center2, the screen area ranges from <0, -width/2, -0.5> to <0, width/2, 0.5>. For the top_left point, the screen area ranges from <0, 0, 0> to <0, width, 1>. Oddly, though, the snap grid and coordinates displayed at the top of the screen when moving a HUD attachment are always relative to the center of the screen, even when not attached to the center or center2 attachment points. This might be a bug, I'm not sure.
Maybe we could make a Jira proposal to add a set of functions and events that only apply to HUD attachments, such as:
llGetScreenSize() - Returns a vector containing the pixel width and height of the agent's viewer to which the object is attached. (ZERO_VECTOR if not a HUD attachment)
llGetGUIScale() - Returns the GUI Scale of client described above (since this can affect the offset of hovertext)
screen_changed( integer width, integer height ) - raised when the relevant client changes window size. (Or maybe just add CHANGED_SCREEN to the existing changed event, at which point llGetScreenSize() can be called to determine the new size)
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
01-24-2008 08:50
I don't think ZHAO-II is quite that smart, but it should be  I like your idea of auto-repositioning if the attach point or owner changes. That way, someone can manually position it, and as long as they continue to use the same attach point, it doesn't re-position itself each time you wear it. I think ZHAO-II re-positions on attach, so you can wear it, move it, and if you leave it on, it stays where you put it. Didn't think about remembering the last attach point, that's a good idea. From: someone The thing to remember about the coordinate system is that the height of the rendered window is always 1 unit (it doesn't really make sense to use meters in this context) and the width is proportionate to that. Hmm... I move the prim by 1/2 the prim's dimension, and I thought that worked OK. Maybe it looks off on other screen dimensions, I really haven't tested that too much. Haven't had any complaints about the buttons rezzing partially off-screen.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-24-2008 09:18
BECAUSE of the attachment point coordinates being different for different HUD attachment points, you can use the bounding box of the attachment to position it in a place where it will always be visible on the screen (if not too large). It may not be an extremely aesthetic location, but that can be played with, and the user could reposition if they can see it to start with. Note also that if you have ANY visible HUD attachment, you can edit it and then ALT zoom out to find attachments that might be off the screen. You can then pull them back onto the screen (which is clearly marked with a rectangle when you zoom like that) and chastise them thoroughly. 
|