Difference between revisions of "A Technical overview of Second Life"

From Second Life Wiki
Jump to navigation Jump to search
Line 30: Line 30:


==Basic Rotations==
==Basic Rotations==
Imagine an object that looks like an airplane.  The airplane is pointing in some direction (duh!) and has some roll around the direction it is pointing.  One rotation is called the ZERO_ROTATION, which is nose (local front) pointing exactly East, the left wing (local left) pointing  exactly North, and the top (local up) of the airplane pointing exactly Up.


==LSL Fundamentals==
==LSL Fundamentals==

Revision as of 17:01, 15 May 2007

Intro

Many activities in SL, especially ones related to content creation, require some technical knowledge. This includes Building using prims, Scripting using LSL, and other activities such as creating clothing and textures, though perhaps to a lesser degree.

Positions and Vectors

Every place in SL has a unique position. Look at the top of your viewer screen to see the current position of your Avatar in the current region, for example Ross/19.5/245.6/51.3. This means you are in the Ross region, 19.5 meters east of the leftmost edge, 245.6 meters north of the bottom edge, and 51.3 meters up from the bottom (which might be both underground and underwater). In LSL, positions are usually stored in a data structure called a vector, and might look like

  vector pos = < 19.5, 245.6, 51.3 >; 

The Southwest corner of every region is 0/0/0. The positions in a region relative to that corner are sometimes called world, region, global, or sim coordinates. We will talk about local coordinates in a minute. In World coordinates, the first number is always East, the second is always North, and the third is always Up, though negative numbers can also be used to mean West, South, and Down.

Given the position pos above, you can find other points. Exactly 10 meters East would be

vector p1 = pos + <10, 0, 0 >;

Five meters below would be

vector p2 = pos - < 0, 0, -5 >;

Given two points, p1 and p2, a point exactly halfway between them is

vector halfway = (p1 + p2)/2;

and the distance between them is

 float d = llVecDist( p1, p2 );

Local coordinates

An object or an avatar in SL always has some position in World coordinates, but it also has local coordinates as well. The local position of an object is always < 0, 0, 0 >. This might seem boring, because it is, but there are also the directions to consider. The x-direction is considered the front of the object, the y-direction is left, and the z-direction is up. You can see the x, y, and z directions in the Edit window, just select some object and the Local coordinates (not World). The red arrow is, by definition, front. In local coordinates, < 1.5, 0, 0 > is 1.5 meters in front of the object, and <0, -1, 0> is 1 meter below, all in local coordinates.

Of course, you need to be able to convert from local to world, and from world to local. We will see how to do this as soon as we talk about rotations.

Basic Rotations

Imagine an object that looks like an airplane. The airplane is pointing in some direction (duh!) and has some roll around the direction it is pointing. One rotation is called the ZERO_ROTATION, which is nose (local front) pointing exactly East, the left wing (local left) pointing exactly North, and the top (local up) of the airplane pointing exactly Up.

LSL Fundamentals

Physics, Force, and Movement

Non-physical Movement