Difference between revisions of "Virtual Tracking Guide"

From CRIPTWiki
Jump to: navigation, search
Line 17: Line 17:
 
}  
 
}  
  
==Detecting Users in Range==
+
==This is a tracking script that I sloppily made==
 +
 
 +
//This version tracks user, their cam pos and rot at predeterimined interval
  
 
//Setting detection range to 5 meters
 
//Setting detection range to 5 meters
float range = 5.0;
+
float detRange = 5.0;
   
+
 
 +
//Setting detection period to 1 sec  
 +
float detPer = 1.0;
 +
 
 +
//Setting total detction cycle
 +
integer detCycle = 0;
 +
 
 +
//Setting up detection target
 +
key detTarget; 
 +
 
 +
vector charVec;
 +
rotation charRot;
 +
 
 +
vector camVec;
 +
rotation camRot;
 +
integer loopTime; //how frequently the loop is run
 +
integer runTime = 0; //keep track of how many time the script has ran.
 +
string msg;
 +
string msg1;
 +
string msg2;
 +
 
 
default
 
default
 
{
 
{
Line 27: Line 49:
 
     touch_start(integer numberDetected)
 
     touch_start(integer numberDetected)
 
     {
 
     {
        // activates the sensor. Look for avatars (i.e. not moving objects) on all sides of the object
+
        // activates the sensor. Look for avatars (i.e. not moving objects) on all sides of the object
        llSensor("", "", AGENT, range, PI);  
+
        llWhisper(0,"Starting Detection Runs");
 +
                 
 +
//Request permission to track camera pos/rotation
 +
llRequestPermissions(llDetectedKey(0), PERMISSION_TRACK_CAMERA);  
 
     }
 
     }
+
   
 +
    run_time_permissions(integer perm)
 +
    {
 +
    llSay(0,"Reached RTP");   
 +
        if(PERMISSION_TRACK_CAMERA & perm){
 +
        llSensorRepeat("", "", AGENT, detRange, PI, detPer);
 +
        }
 +
    }
 +
   
 +
   
 
     //When object sensed. Passed on number deteced as parameter
 
     //When object sensed. Passed on number deteced as parameter
 
     sensor (integer numberDetected)
 
     sensor (integer numberDetected)
     {
+
     {  
         //Notify number and name
+
          
        string msg = "Detected " + (string)numberDetected + " avatar(s): " + llDetectedName(0);
+
        //Notify number and name and all the first time notice item.
 +
        //Return number detected.
 +
        llWhisper(0, "Detected in total, " + (string)numberDetected + " avatar(s)."); 
 +
llWhisper(0, "Detected " + llDetectedName(0) + llGetTimestamp());
 +
   
 +
//Get Camera Position 3D Coordinate
 +
  //Returns a VECTOR
 +
  camVec = llGetCameraPos();
 +
 
 +
  //Get Camera Rotation
 +
  //Returns a ROTATION
 +
  camRot = llGetCameraRot();
 +
           
 +
            llWhisper(0, "CPos: (" + (string)camVec.x + "," + (string)camVec.y + "," +(string)camVec.z + ")");
 +
          llWhisper(0, "CRot: (" + (string)camRot.x + ","+ (string)camRot.y + ","+(string)camRot.z +","+ (string)camRot.s + ")");
 +
 
  
        integer i = 0;
+
          charVec = llDetectedPos(0);
 +
        charRot = llDetectedRot(0);
  
        while(numberDetected > ++i)//skips the first item which suits this application
+
          llWhisper(0, "Pos: (" + (string)charVec.x + "," + (string)charVec.y + "," +(string)charVec.z + ")");
        {
+
          llWhisper(0, "Rot: (" + (string)charRot.x + ","+ (string)charRot.y + ","+(string)charRot.z +","+ (string)charRot.s + ")");
          msg += ", " + llDetectedPos(0) + llDetectedRot(0);
+
        }
+
        llWhisper(0, msg);
+
 
     }
 
     }
 
   
 
   
Line 51: Line 98:
 
     }
 
     }
 
}
 
}
==
 
 
 
 
integer perm = llGetPermissions();
 
vector CamVec;
 
rotation CamRot;
 
integer loopTime; //how frequently the loop is run
 
 
 
if (perm & PERMISSION_TRACK_CAMERA) // using & is important! perm is a bitmask!
 
{
 
  //Get Camera Position 3D Coordinate
 
  //Returns a VECTOR
 
  CamVec = llGetCameraPos();
 
 
  //Get Camera Rotation
 
  //Returns a ROTATION
 
  CamRot = llGetCameraRot();
 
 
 
  //Get User Name
 
  llRequestAgentData(llDetectedKey(0), DATA_BORN);
 
 
  //Request creation date
 
    }
 
    dataserver(key queryid, string data)
 
    {
 
        llSay(0, "You were born on: " + data);
 
    }
 
}
 
 
}
 
 
Source: http://lslwiki.net/lslwiki/wakka.php?wakka=ScriptPermissions
 

Revision as of 04:24, 11 June 2009

realXtend can run LSL scrpit no problem.

Hence, we will be able to use exist LSL command embedding in python to run the command.

The key script that is used:

To do a few things:

  • IF (people within range) then
    • SHOUT to the person about being tracked for the FIRST time
    • Ask for permission to track user.
    • IF (POS/ROT not BOTH EQUAL ZERO) THEN
      • Get Time Stamp
      • Get Position Information
      • Get Rotation Information
      • Output into FILES?

}

This is a tracking script that I sloppily made

//This version tracks user, their cam pos and rot at predeterimined interval

//Setting detection range to 5 meters float detRange = 5.0;

//Setting detection period to 1 sec float detPer = 1.0;

//Setting total detction cycle integer detCycle = 0;

//Setting up detection target key detTarget;

vector charVec; rotation charRot;

vector camVec; rotation camRot; integer loopTime; //how frequently the loop is run integer runTime = 0; //keep track of how many time the script has ran. string msg; string msg1; string msg2;

default {

   //touch state.
   touch_start(integer numberDetected)
   {
       // activates the sensor. Look for avatars (i.e. not moving objects) on all sides of the object
       llWhisper(0,"Starting Detection Runs");
                 

//Request permission to track camera pos/rotation llRequestPermissions(llDetectedKey(0), PERMISSION_TRACK_CAMERA);

   }
   
   run_time_permissions(integer perm)
   {
   	llSay(0,"Reached RTP");    	
       if(PERMISSION_TRACK_CAMERA & perm){
       	llSensorRepeat("", "", AGENT, detRange, PI, detPer);
       }
   }
   
   
   //When object sensed. Passed on number deteced as parameter
   sensor (integer numberDetected)
   { 	   
       
       	//Notify number and name and all the first time notice item.
       	//Return number detected.
       	llWhisper(0, "Detected in total, " + (string)numberDetected + " avatar(s).");   

llWhisper(0, "Detected " + llDetectedName(0) + llGetTimestamp());

//Get Camera Position 3D Coordinate

 			//Returns a VECTOR
 			camVec = llGetCameraPos();
 			//Get Camera Rotation
 			//Returns a ROTATION
 			camRot = llGetCameraRot();
           
           llWhisper(0, "CPos: (" + (string)camVec.x + "," + (string)camVec.y + "," +(string)camVec.z + ")");
          	llWhisper(0, "CRot: (" + (string)camRot.x + ","+ (string)camRot.y + ","+(string)camRot.z +","+ (string)camRot.s + ")");


          	charVec = llDetectedPos(0);
       	charRot = llDetectedRot(0);
          	llWhisper(0, "Pos: (" + (string)charVec.x + "," + (string)charVec.y + "," +(string)charVec.z + ")");
          	llWhisper(0, "Rot: (" + (string)charRot.x + ","+ (string)charRot.y + ","+(string)charRot.z +","+ (string)charRot.s + ")");
   }

   no_sensor()
   {
       llWhisper(0, "Nobody is near me at present.");
   }

}