llGetAspectRatio() for huds
complete
Chaser Zaks
float llGetAspectRatio();
This would return the aspect ratio of the wearing agent's screen. For privacy purposes(i.e. preventing "fingerprinting"), this should only work on the agent wearing the object, and if the object is attached to the hud.
The data would be pulled from the existing AgentHeightWidth packet, and would be the result of AgentHeightWidth.HeightWidthBlock.Width / AgentHeightWidth.HeightWidthBlock.Height.
This is currently possible, but in a tedious way. A resident must attach a object to one of the corners of the HUD with the following script:
default
{
touch_start(integer total_number)
{
vector scale = llGetScale();
vector off_point = llGetLocalPos();
vector face_pos = llDetectedTouchST(0);
vector screen_pos = llDetectedTouchPos(0);
float screen_width = ((face_pos.x-.5)*scale.y-off_point.y+screen_pos.y)*2;
llOwnerSay((string)screen_width);
}
}
Example output:
Assuming the following block has been sent to the server:
AgentHeightWidth
AgentData
AgentID 796b1537-70d8-497d-934e-0abcc2a60050
SessionID 00000000-0000-0000-0000-000000000000
HeightWidthBlock
GenCounter 0
Height 1061
Width 1920
And object's root is attached to ATTACH_HUD_*
Then the following should be true:
llGetAspectRatio() == 1.8096135721017907 //(1920 / 1061)
If not attached to HUD, or the simulator has no AgentWidthHeight cached, then return 0 or FALSE. This will be safe as no screen will can have a ratio of zero.
Log In
This post was marked as
complete
Vincent Nacon
🎉
rhet0rica Resident
Following on what Sayrah Parx said, I don't think this goes far enough—I'd like to have the screen width and height, in pixels, exposed to HUD developers for the purposes of correctly displaying textures at their native resolution.
Currently I'm using a calibration screen to have users do this, and it's a big ask.
Tex Evans
rhet0rica Resident: I agree. While I understand the issue with fingerprinting, I'm not sure that a simple "current window dimension" in pixels (or HUD plane meters) is enough data points to actually do useful fingerprinting to be worried about.
I have had a similar issue with trying to figure out a method to autoposition and size a HUD before that this basic info, along with a standard 0, 0 origin is center of the screen regardless of HUD attachment point, that I had to waste a lot of code to come up with something workable.
((BTW, anybody interested in the code I came up with, contact me in world. I'm willing to share the code.))
Sayrah Parx
I really appreciate this after discovering years ago that automatic HUD positioning is impossible without knowing an individual user's screen width, and having to make a calibration HUD for that purpose. A way for HUDs to get the screen aspect ratio automatically would be so much better.
Signal Linden
in progress