Difference between revisions of "User:Opensource Obscure/Reflexive llSetLinkPrimitiveParamsFast"

From Second Life Wiki
Jump to navigation Jump to search
m (Created page with '* this needs server 1.38 * put it in the root prim * add child prims to the linkset as needed <lsl> float rate = 0.1; vector NEAR_COL = <1.0, 1.0, 0.0>; vector FAR_COL = <0....')
 
m (templatizationingsx)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{User:Opensource_Obscure/Backlink}}
* this needs server 1.38
* this needs server 1.38
* put it in the root prim  
* put it in the root prim  
* add child prims to the linkset as needed
* add child prims to the linkset as needed


<lsl>
<lsl>
float rate = 1;


float rate = 0.1;
vector NEAR_COL = <0.9, 0.8, 0.0>;
 
vector FAR_COL = <0.2, 0.0, 0.7>;
vector NEAR_COL = <1.0, 1.0, 0.0>;
vector FAR_COL = <0.2, 0.0, 0.5>;
 
float distance_moltiplier = 0.1; // x alpha


vector NEAR_SIZE = <1, 2, 4.0>;
vector FAR_SIZE = <0.5, .5, 10>;


float NEAR = 5.0;
vector NEAR_SIZE = <1.0, 0.3, 0.4>;
float FAR = 20.0;
vector FAR_SIZE = <.3, .5, 2>;


//------- don't change below
float NEAR = 0.5;
float FAR = 10.0;


float DIFF;
float DIFF;
Line 58: Line 55:
             if (scale_local < 0.0) scale_local = 0.0;       
             if (scale_local < 0.0) scale_local = 0.0;       
             llSetLinkPrimitiveParamsFast(i, [
             llSetLinkPrimitiveParamsFast(i, [
             PRIM_COLOR, ALL_SIDES, NEAR_COL + ((COL_DIFF) * scale_local),
             PRIM_COLOR, ALL_SIDES, NEAR_COL + ((COL_DIFF) * scale_local),1,
            1,
              //  distance_local*distance_moltiplier,
             PRIM_SIZE, NEAR_SIZE + ((SIZE_DIFF) * scale_local)
             PRIM_SIZE, NEAR_SIZE + ((SIZE_DIFF) * scale_local)
             ]);
             ]);

Latest revision as of 03:16, 22 April 2011

Go back to Opensource Obscure's userpage



  • this needs server 1.38
  • put it in the root prim
  • add child prims to the linkset as needed

<lsl> float rate = 1;

vector NEAR_COL = <0.9, 0.8, 0.0>; vector FAR_COL = <0.2, 0.0, 0.7>;


vector NEAR_SIZE = <1.0, 0.3, 0.4>; vector FAR_SIZE = <.3, .5, 2>;

float NEAR = 0.5; float FAR = 10.0;

float DIFF; vector COL_DIFF; vector SIZE_DIFF; vector pos_init; rotation rot_init; integer prim_number;

vector GetLinkLocalPos(integer link) {//This function may not produce a perfect result, expect there to be some drift. This will not work in attachments.

   //vector pos = llGetRootPosition();
   return (llList2Vector(llGetObjectDetails(llGetLinkKey(link), (list)OBJECT_POS) + pos_init, 0) - pos_init) / rot_init;

}

default {

   state_entry()
   {
       pos_init = llGetPos();
       rot_init = llGetRootRotation();
       prim_number = llGetObjectPrimCount( llGetKey() );
       DIFF = FAR - NEAR;
       COL_DIFF = FAR_COL - NEAR_COL;
       SIZE_DIFF = FAR_SIZE - NEAR_SIZE;
       llSensorRepeat("", NULL_KEY, AGENT, FAR, PI, rate);        
   }
   
   sensor(integer total_number)
   {
       vector pos_det = llDetectedPos(0);
       integer i;      
       for(i=1; i<=prim_number; ++i)
       {
           vector pos_local = (pos_init + GetLinkLocalPos(i));
           float distance_local = llVecMag(pos_det - pos_local);
           float scale_local = (distance_local - NEAR) / (DIFF);            
           if (scale_local < 0.0) scale_local = 0.0;      
           llSetLinkPrimitiveParamsFast(i, [
           PRIM_COLOR, ALL_SIDES, NEAR_COL + ((COL_DIFF) * scale_local),1,
           PRIM_SIZE, NEAR_SIZE + ((SIZE_DIFF) * scale_local)
           ]);
       }        
   }    

} </lsl>