Global to Region Coordinates
|
Johnny Mann
Registered User
Join date: 1 Oct 2005
Posts: 202
|
05-05-2006 17:36
Hello everyone,
I am designing a pod that will bring me anywhere I want to. Everything works great in the sim it is in. BUT...
I can't figure out how to transform Global coordinates into Region Coordinates.
I know how to get the global coordinates (I used a script that basically Says them outloud)
Does anyone know the equation to transform Global into a region Vector that I can use with llSetPos ?
Thanks!
|
Sky Honey
Coder
Join date: 16 May 2005
Posts: 105
|
05-05-2006 17:51
|
Mappa Novi
Registered User
Join date: 15 Jan 2007
Posts: 3
|
02-25-2007 07:54
Page does not exist anymore! Would really like to find out how to do this.. does anyone have an updated link/info on how to do this?
|
Elsewhere Essex
Registered User
Join date: 8 Sep 2006
Posts: 50
|
02-25-2007 15:47
//take your global postion and substract the region corner of the current sim from it vector global2regional = youstoredglobalpos - llGetRegionCorner();
http://lslwiki.org/index.php/GlobalCoordinate
|
Jeff Kelley
Registered User
Join date: 8 Nov 2006
Posts: 223
|
02-25-2007 19:05
Not sure global coordinates work correctly. vector pos = llGetPos(); llSetPos(pos+<1,0,0>);
will move you one meter but pos = llGetPos()+llGetRegionCorner(); llSetPos(pos+<1,0,0>);
will not. Anyway, you will be lucky if you can travel more than half a sim without being screwed by a ban line. I'm trying to experiment and I crash (loop, hang, ends in weird states forcing logout) because my north and west neighbours use "NO ENTRY" and "BUY PASS" lines, and south and east are off-world. You can detect out-of-world condition with llEdgeOfWorld(vector pos, vector dir) before jumping, but I've found no way to detect various ban conditions.
|
Elsewhere Essex
Registered User
Join date: 8 Sep 2006
Posts: 50
|
02-25-2007 20:07
From: Jeff Kelley Not sure global coordinates work correctly. vector pos = llGetPos(); llSetPos(pos+<1,0,0>);
will move you one meter but pos = llGetPos()+llGetRegionCorner(); llSetPos(pos+<1,0,0>);
will not. Anyway, you will be lucky if you can travel more than half a sim without being screwed by a ban line. I'm trying to experiment and I crash (loop, hang, ends in weird states forcing logout) because my north and west neighbours use "NO ENTRY" and "BUY PASS" lines, and south and east are off-world. You can detect out-of-world condition with llEdgeOfWorld(vector pos, vector dir) before jumping, but I've found no way to detect various ban conditions. llGetPos() is region local coords your math of llGetPos() + llGetRegionCorner() is how one woud get a global position if you look a litte more colosely at mylast post, i posted pos - llGetRegionCorner(), which assumes that pos is already a global position and subracting the region corner from it would give you a region local position vector.
|
Jeff Kelley
Registered User
Join date: 8 Nov 2006
Posts: 223
|
02-26-2007 04:21
From: Elsewhere Essex llGetPos() is region local coords your math of llGetPos() + llGetRegionCorner() is how one woud get a global position
I had misuderstood the wiki example, assuming it was trying to llSetPos to a global position, when it was really llSetPos-ing to an offset between global positions: // Pass a global position to this function, and the object // will move there. setGlobalPos(vector globalDest) { vector localDest; do { localDest = globalDest - llGetRegionCorner(); llSetPos(localDest); } while (llVecDist(llGetPos(), ....localDest) > 0.1); }
default { state_entry() { vector DABOOM_CORNER = <256000, 256000, 0>; // DaBoom's region corner. setGlobalPos(DABOOM_CORNER + <128, 128, 128>); // Travel to <128,128,128> in DaBoom. } }
Suppose we are in Luna <128,128,128>+<254464, 256000, 0>. localDest would evaluate to <256128, 256128, 128> - <254464, 256000, 0> = <1664,128,128>. The loop will move us 10 meters east to and llGetPos() evaluate to <138,128,128>... Tricky. But I'm still in Luna, bouncing on and off near my starting position 
|
Mappa Novi
Registered User
Join date: 15 Jan 2007
Posts: 3
|
02-26-2007 16:16
From: Jeff Kelley I had misuderstood the wiki example, assuming it was trying to llSetPos to a global position, when it was really llSetPos-ing to an offset between global positions:
In my case I am fine with using the Map to teleport, however llMapDestination() requires a region name and local coordinates. Anyway to get that conversion from the global coords? (short of trying to warpPos over there to find out  )
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
02-26-2007 16:31
The destination of llMapDestination is relative to the corner of the specified region name. IE, if you have global coordinate vector GlobalPos = <Gx,Gy,Gz>, then the correct llMapDestination call to get to it from the avatar's current position would be: llMapDestination(llGetRegionName(), GlobalPos - llGetRegionCorner(), ZERO_VECTOR);
When the third parameter is implemented, I suppose it will be the Euler representation of the destination rotation for the avatar.
|
Mappa Novi
Registered User
Join date: 15 Jan 2007
Posts: 3
|
02-26-2007 16:53
Perfect... and obvious now. Thanks for the help!
|