The algorithm is for global coordinates using integer math.
 
To convert region coordinates into global coordinates simply multiple by 256.
 
gx = rx * 256
gy = ry * 256
 
r = (gx * (256^4) + gy
 
or
 
r = ((rx * 256) * (256^4)) + (ry * 256)
 
example:
 
Sim: Chartreuse
Handle: 1098412116406272
RegionX: 999
RegionY: 1008
 
gx = 999 * 256
gx = 255744
 
gy = 1008 * 256
gy = 258048
 
r = (255744 * (256^4)) + 258048
r = (255744 * 4294967296) + 258048
r = 1098412116148224 + 258048
r = 1098412116406272
 
* Note: The example data you give below is wrong. You are either using the wrong region handle, or the wrong region coordinates for the Andretti sim.

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Ortman
Sent: Monday, July 17, 2006 6:32 AM
To: Development list for libsecondlife
Subject: Re: [libsecondlife-dev] Region Handle (U64) Issues

Chad. I tried your math but something is wrong; I used:
My Sim: Andretti; Handle: 1276533000103936;RegionX: 1162; Region Y: 999; Estimated?: 4990751998951

And tried in calculator the formulas:
r = (1162 * (256^4)) + 999; I get 4990751998951, the estimated? in the message

I was curious and took the handle sent from the current region and divided it by the number I got:
1276533000103936/4990751998951 = 255.77969018942413788717730727627
Which is damn close to 256 and is in range of 255; a byte's max.

Any Ideas?
Michael

On 7/17/06, Chad Boyda <[EMAIL PROTECTED]> wrote:
Region Handles
 
r = (x * (256^4)) + y
y = r % (256^4)
x = r / (256^4)
 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Mike Ortman
Sent: Sunday, July 16, 2006 6:56 PM
To: libsecondlife-dev@gna.org
Subject: [libsecondlife-dev] Region Handle (U64) Issues

Hey everyone! Ive created class MapData (seen in code) that handles the client's map information (positions, name, agents, map textures, etc) with the main goal of getting a region handle by name (by finding a sim in an ArrayList of MapData objects and returning the region handle composed of the Global X and Y positions. The problem I having is the generation of the U64 handle (named regionHandle in the MapData class; assigned in the contructor). Ive tried everything I could think of (while admitting not being a *guru*) and I am praying for someone to find what is going wrong.

Please note:
The Login info (First, last, and password) needs to be added into MapDataText.cs

IMing the bot with 'current' sends you the data for its current sim... Estimated? is the result of MapData.regionHandle
IMing the bot with 'teleport' then a sim name (this will be easier later) will teleport to that sim at your local position; it fails because the region handle is incorrect

Thanks in advanced,
Michael Ortman AKA Ming Chen

_______________________________________________
libsecondlife-dev mailing list
libsecondlife-dev@gna.org
https://mail.gna.org/listinfo/libsecondlife-dev



_______________________________________________
libsecondlife-dev mailing list
libsecondlife-dev@gna.org
https://mail.gna.org/listinfo/libsecondlife-dev

Reply via email to