Spherizer

From libopenmetaverse - libomv - Developer Wiki

Jump to: navigation, search

This script maps a texture onto a sphere by doing some simple math and stuff but it is fun so go make your face out of spheres.

vector size;
string name = "dongs"; //Name of prim we're using for allignment.
 
default
{
    state_entry()
    {
        llListen(1,"",llGetOwner(),"done");
    }
    
    touch_start(integer total_number)
    {
        size = llGetScale();
        llScaleTexture(size.x/10, size.y/5, 0);
        llSensor(name, "", PASSIVE, 10, TWO_PI);
    }
    
    on_rez(integer start_param)
    {
        llResetScript();
    }
    
    sensor(integer num_detected)
    {
        vector pos = llGetPos() - llDetectedPos(0);
        pos.x = pos.x/10;
        pos.y = pos.y/10 - size.y/20;
        llOffsetTexture(pos.x, pos.y, 0);
    }
    
    listen(integer channel, string name, key id, string message)
    {
        llRemoveInventory(llGetScriptName());   
    }
}