Global Coordinates
Global coordinates are used to describe a
position relative to one point on the entire
Second Life world, hence the word "global". This means that
every place on the
grid has a different
vector value when represented in global coordinates. This allows global coordinates to describe a position without adverse effects occuring when a
sim border is crossed.
A
region coordinate can be converted into a global coordinate by adding to it the
region corner of the simulator the coordinate is relative to.
Using global coordinates, it's easy to create an
object that can traverse the world.
llSetPos and
llMoveToTarget use region coordiantes; to use these
functions to travel to a particular global coordinate, pass the result of subtracting the current
region's corner from the global coordinate to the function. This converts the global coordinate into a region coordinate.
Example:
// 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.
}
}
Q & A:
Q: Is the global coordinate origin point (<0, 0, 0>) located somewhere in the sim Da Boom?
A: No, Da Boom is merely the sim from which it all started. See coordinate.
Now to complicate things. Say you want to move a prim from one sim into another sim that is diagonal from it. An example situation would be calling llSetPos(<257,257,50>); from <254,254,50>. Your prim will first transfer into the sim on the x axis of the move and then into the sim on the y axis. If there is no sim on the x axis your prim will go offworld. So if you move a prim from Tan to Kissling it will go off world. But if you move a prim from Kissling to Tan it won't. -
BW
(
map)
Q: What is the cutoff of a vector being interpreted as local or global? >256? >256000 ?
A: There is no cutoff. Any coordinate of any manitude, positive or negative, is a valid local or global coordinate, although it may or may not correspond to an existing in-world location. Whether a vector is interpreted as local or global is determined by context, not value. For example, any vector sent to a function that takes a local coordinate is interpreted as a local coodinate, regardless of the values. Since it's perfectly valid to specify out-of-sim locations in terms of the local coodinate system, this is a Good Thing(tm).
Coordinates |
Local Coordinates |
Region Coordinates |
Region Corner |
Grid/
World