Difference between revisions of "Primitive"

From Second Life Wiki
Jump to navigation Jump to search
(→‎Shape types: Added script and note about mass and how type effects it. Valuable?)
Line 39: Line 39:
# ring: another variant of torus
# ring: another variant of torus
# [[sculpt]]ed: new as of 2007, used for highly variable organic shapes
# [[sculpt]]ed: new as of 2007, used for highly variable organic shapes
----
*Setting a different type can effect more than the shape. E.g. The [[llGetMass|mass]] can change in a prim that has <u>only</u> the type changed.
<lsl>// A simple study of how mass is effected by prim shape/types. The X,Y,Z size is not changed but the mass does.
// Material type and/or physics seem to not effect mass.
default
{
    state_entry()
    {
        llSetScale(<1.0, 1.0, 1.0>); // 1 meter cubed
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX,
        PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
       
        llOwnerSay("BOX: " + (string)llGetMass()); // Output: Object: 10.000000
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER,
        PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
       
        llOwnerSay("CYLINDER: " + (string)llGetMass()); // Output: Object: 10.000000
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_PRISM,
        PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
       
        llOwnerSay("PRISM: " + (string)llGetMass()); // Output: Object: 10.000000
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SPHERE,
        PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>]);
       
        llOwnerSay("SPHERE: " + (string)llGetMass()); // Output: Object: 5.235988
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS,
        PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
       
        llOwnerSay("TORUS: " + (string)llGetMass()); // Output: Object: 5.235988
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TUBE,
        PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
       
        llOwnerSay("TUBE: " + (string)llGetMass()); // Output: Object: 5.235988
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_RING,
        PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
       
        llOwnerSay("RING: " + (string)llGetMass()); // Output: Object: 5.235988
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "bea82b0f-27c6-730b-fd7f-733f2340b449", PRIM_SCULPT_TYPE_SPHERE] );
       
        llOwnerSay("SCULPTED APPLE: " + (string)llGetMass()); // Output: Object: 5.229262
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "d1b6cc53-ac61-291f-9ce1-dc18170aa6a6", PRIM_SCULPT_TYPE_SPHERE] );
       
        llOwnerSay("SCULPTED APPLE STEM: " + (string)llGetMass()); // Output: Object: 5.229262
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "d962089b-2197-993c-9ec9-4993eb0a95f2", PRIM_SCULPT_TYPE_SPHERE] );
       
        llOwnerSay("SCULPTED BANANA: " + (string)llGetMass()); // Output: Object: 5.229262
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "fb39e9be-0609-2d1e-0988-803d1c04411e", PRIM_SCULPT_TYPE_SPHERE] );
       
        llOwnerSay("SCULPTED PLATE: " + (string)llGetMass()); // Output: Object: 5.229262
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "", PRIM_SCULPT_TYPE_PLANE] );
       
        llOwnerSay("SCULPT (no map): " + (string)llGetMass()); // Output: Object: 5.229262
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "", PRIM_SCULPT_TYPE_CYLINDER] );
       
        llOwnerSay("SCULPT (no map): " + (string)llGetMass()); // Output: Object: 5.229262
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "", PRIM_SCULPT_TYPE_TORUS] );
       
        llOwnerSay("SCULPT (no map): " + (string)llGetMass()); // Output: Object: 5.229262
       
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "", PRIM_SCULPT_TYPE_MASK] );
       
        llOwnerSay("SCULPT (no map): " + (string)llGetMass()); // Output: Object: 5.229262
    }
}</lsl>


==Properties==
==Properties==

Revision as of 08:29, 26 April 2010

This article is about primitives. For LSL related information, see Category:LSL Prim.

A primitive, or prim, is a single-part object. Multi-part objects will have multiple parts ("prims").

In Second Life, virtual physical objects such as cars, houses, jewelry, and even less obvious things like hair and clothing are made out of one or more prims. Objects made from prims are usually created in-world using the built-in object editing tool. This tool is used for all sorts of 3D modeling in Second Life, playing the same role as 3D Max, Maya, or Blender, but customized for the Second Life way of doing things.

Each prim is represented by a set of parameters, including shape/type, position, scale/size, rotation, cut, hollow, twist, shear, etc. These parameters are sent from a server to the viewer running on the resident's desktop, where the local video card is used to render the visual appearance of everything. (Rendering on the server would probably create a much higher amount of network traffic.)

The color, texture, bumpiness, shininess, and transparency of prims can also be adjusted, and images (textures) can be applied to each surface (face/side) of a prim to change its appearance. Box, cylinder, and prism prim shape types can also be made flexible.

Prims can be linked together into link sets. They can also be attached to avatars, but this process is separate from (thought similar to) linking.

In the Viewer source code, primitives are implemented in LLPrimitive, with vertex generation performed in LLVolume and rendering in LLVOVolume.

Shape types

There are eight primitive shape types:

  1. box: all kinds of rectangular shapes
  2. cylinder: round tables, floors, long pipes
  3. prism: a box with one very small face
  4. sphere: can be used for ellipsoids of all shapes
  5. torus: most complex, can be modified in many exotic ways
  6. tube: another form of hollow cylinder
  7. ring: another variant of torus
  8. sculpted: new as of 2007, used for highly variable organic shapes

  • Setting a different type can effect more than the shape. E.g. The mass can change in a prim that has only the type changed.

<lsl>// A simple study of how mass is effected by prim shape/types. The X,Y,Z size is not changed but the mass does.

// Material type and/or physics seem to not effect mass.

default {

   state_entry()
   {
       llSetScale(<1.0, 1.0, 1.0>); // 1 meter cubed
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX,
       PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
       
       llOwnerSay("BOX: " + (string)llGetMass()); // Output: Object: 10.000000
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_CYLINDER,
       PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
       
       llOwnerSay("CYLINDER: " + (string)llGetMass()); // Output: Object: 10.000000
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_PRISM,
       PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
       
       llOwnerSay("PRISM: " + (string)llGetMass()); // Output: Object: 10.000000
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SPHERE,
       PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>]);
       
       llOwnerSay("SPHERE: " + (string)llGetMass()); // Output: Object: 5.235988
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS,
       PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
       
       llOwnerSay("TORUS: " + (string)llGetMass()); // Output: Object: 5.235988
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TUBE,
       PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
       
       llOwnerSay("TUBE: " + (string)llGetMass()); // Output: Object: 5.235988
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_RING,
       PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
       
       llOwnerSay("RING: " + (string)llGetMass()); // Output: Object: 5.235988
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "bea82b0f-27c6-730b-fd7f-733f2340b449", PRIM_SCULPT_TYPE_SPHERE] );
       
       llOwnerSay("SCULPTED APPLE: " + (string)llGetMass()); // Output: Object: 5.229262
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "d1b6cc53-ac61-291f-9ce1-dc18170aa6a6", PRIM_SCULPT_TYPE_SPHERE] );
       
       llOwnerSay("SCULPTED APPLE STEM: " + (string)llGetMass()); // Output: Object: 5.229262
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "d962089b-2197-993c-9ec9-4993eb0a95f2", PRIM_SCULPT_TYPE_SPHERE] );
       
       llOwnerSay("SCULPTED BANANA: " + (string)llGetMass()); // Output: Object: 5.229262
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "fb39e9be-0609-2d1e-0988-803d1c04411e", PRIM_SCULPT_TYPE_SPHERE] );
       
       llOwnerSay("SCULPTED PLATE: " + (string)llGetMass()); // Output: Object: 5.229262
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "", PRIM_SCULPT_TYPE_PLANE] );
       
       llOwnerSay("SCULPT (no map): " + (string)llGetMass()); // Output: Object: 5.229262
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "", PRIM_SCULPT_TYPE_CYLINDER] );
       
       llOwnerSay("SCULPT (no map): " + (string)llGetMass()); // Output: Object: 5.229262
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "", PRIM_SCULPT_TYPE_TORUS] );
       
       llOwnerSay("SCULPT (no map): " + (string)llGetMass()); // Output: Object: 5.229262
       
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "", PRIM_SCULPT_TYPE_MASK] );
       
       llOwnerSay("SCULPT (no map): " + (string)llGetMass()); // Output: Object: 5.229262
   }

}</lsl>

Properties

Property survival
Property Script Set Not Running Script Removal Take unscripted and re-rez Shift-drag-copy
Sit Target Yes Yes Yes ?
Particles Yes Yes Yes ?
Floating Text Yes Yes Yes No
Spin Yes No ? ?
Collision Sound Yes Yes ? ?
Looped Sound Yes Yes Yes No
Remote Script Access Pin Yes Yes ? ?
Light Yes Yes Yes Yes
Status Yes Yes Yes Yes
Buoyancy ? No No ?
Texture Animation Yes Yes Yes No

It should be noted that when a script (in an object) moves from one simulator into another while being set as "Not Running" (either by llSetScriptState or via the checkbox in the script editor) the script's state will be lost. See SVC-1853 for details.

Materials

There are seven primitive material types that determine things like friction and sound:

  1. stone
  2. metal
  3. glass
  4. wood
  5. flesh
  6. plastic
  7. rubber

Help

Scripting

Video tutorials

See also

External links