PASTE NAVIGATION MENU CODE

Saturday 23 June 2012

Task 1: Building a Functional Stool

| | with 0 comments |
Describing Second Life is not an easy task. Some call it a virtual world, others call it a game, whereas others call it an interactive building environment. The truth is that Second Life is all of this, an economy, a social experience and much more. 

In this section, I shall build a basic object in Second Life which the user can sit on - a stool.

The first step in building is to find a sandbox. In Second Life, land is owned by players, consequently items cannot be built on other player's land. However, several public sandboxes exist, where players can practice building their items without having to purchase land.

To build the stool, I chose the St. Leo University Public Sandbox found at - Link. The first step is to right-click on the terrain and enter build mode. This brings up the build dialog where players can create their objects. Objects are created using a number of basic shapes known as "prims" (short for primitives). The prims are dragged onto the landscape and rotated, shized, shaped and combined together to create an item.



To create the stool, two cylinder prims were used. First, a long, thin cylinder was used as the stool's base, and then a flat short cylinder was placed on top to create the seat of the stool.



Once an object is created, textures can be applied to each face of the stool.



This is done by using the "Select Face" mode of the build tool, and then selecting a texture from texture tab. Once the textures are applied, the two cylinders making up the stool have to be combined to form one object. To do this, both prims are selected and the "link" button is used.



With the object created, the primary test was next - sitting on the stool. When an object is created, Second Life automatically makes the top face of the object an area which the player can sit on. Hence, right-clicking and selecting sit makes the player sit on the face.



Taking it Further - Changing the Camera View

For this task, it was also decided to change the camera view of the player when the player is sitting. This is accomplished using LSL - Linden Scripting Language. LSL scripts can be attached to object which control what happens in response to a number of triggers such as a player approaching an object, sitting on an object, touching an object, taking an object etc…


default{
    state_entry(){
        llSitTarget(<0.2,0.0,0.45>, ZERO_ROTATION );
    }
}

As can be seen from the script above, the camera angle is set when the user sits. Additionally, a target for sitting is defined using the LSL function llSitTarget, which specifies the rotation, elevation and depth of the player when sitting on the stool. This script will make the player face the same direction when sitting, no matter how the stool is placed or which angle the stool is approached from.

Taking it Further - Adjusting Height


To make the stool more realistic, it was decided to add a functionality to adjust the height according to the avatar's preference. To accomplish this function, a script was written to adjust the Z Position of the stool which would result in either increasing or decreasing it's height. The core part of the written script is shown below.

            else if (message == "Size--"){
                    vector currentPosition = llGetPos();
                    if (currentPosition.z > 24.180){
                        vector scaledPosition = <currentPosition.x,currentPosition.y,currentPosition.z-0.2>;
                        setPosition(scaledPosition);
                    } else {
                        setPosition(currentPosition);
                         llOwnerSay("Minimum Height Reached.");
                    }
            }
            else if (message == "Size++")
            {
                    vector currentPosition = llGetPos();
                    if (currentPosition.z < 24.640){
                        vector scaledPosition = <currentPosition.x,currentPosition.y,currentPosition.z+0.2>;
                        setPosition(scaledPosition);
                    } else {
                        setPosition(currentPosition);
                         llOwnerSay("Maximum Height Reached.");
                    }
            }

As can be seen above, the script is first requesting the current Z Position of the stool. Once that is obtained, a decision is made to check whether the prim has gone above a set maximum or minimum height. If this decision results to be true, then an output message is displayed to the user informing him that the maximum/minimum height have been reached. Otherwise, the stool is seen changing height in 0.2 (meter) increments.

Post a Comment

Please enter your comments here..

0 comments: