Difference between revisions of "Virtual Tracking Guide"

From CRIPTWiki
Jump to: navigation, search
Line 3: Line 3:
 
Many command from LSL are recognized and used but the syntax is alterned and require extensive exploration for any complicated LSL command such as llSensor/llSensorRepeat/llRequestPermission
 
Many command from LSL are recognized and used but the syntax is alterned and require extensive exploration for any complicated LSL command such as llSensor/llSensorRepeat/llRequestPermission
  
Hence, we will be able to use exist LSL command embedding in python to run the command.
+
Hence, embedding existing LSL command in python is a hit and miss process for many at the moment.  
  
The key script that is used:
+
The key script that is used to do a few things:
 
+
To do a few things:
+
  
 
*IF (people within range) then
 
*IF (people within range) then
Line 16: Line 14:
 
***Get Position Information
 
***Get Position Information
 
***Get Rotation Information
 
***Get Rotation Information
***Output into FILES?
+
***Output into FILES? (not possible in SL version of the Script)
 
}  
 
}  
  
==This is a tracking script that I sloppily made==
+
==This is the SecondLife version of the tracking script==
 
+
//This version tracks user, their cam pos and rot at predeterimined interval
//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 detRange = 5.0;
float detRange = 5.0;
+
 
+
//Setting detection period to 1 sec   
//Setting detection period to 1 sec   
+
float detPer = 1.0;
float detPer = 1.0;
+
 
+
//Setting total detction cycle  
//Setting total detction cycle  
+
integer detCycle = 0;  
integer detCycle = 0;  
+
 
+
//Setting up detection target
//Setting up detection target
+
key detTarget;   
key detTarget;   
+
 
+
vector charVec;
vector charVec;
+
rotation charRot;
rotation charRot;
+
vector camVec;
 
+
rotation camRot;
vector camVec;
+
integer loopTime; //how frequently the loop is run
rotation camRot;
+
integer runTime = 0; //keep track of how many time the script has ran.
integer loopTime; //how frequently the loop is run
+
string msg;
integer runTime = 0; //keep track of how many time the script has ran.
+
string msg1;
string msg;
+
string msg2;
string msg1;
+
string msg2;
+
default
 
+
{
default
+
{
+
 
     //touch state.
 
     //touch state.
 
     touch_start(integer numberDetected)
 
     touch_start(integer numberDetected)
Line 57: Line 53:
 
llRequestPermissions(llDetectedKey(0), PERMISSION_TRACK_CAMERA);  
 
llRequestPermissions(llDetectedKey(0), PERMISSION_TRACK_CAMERA);  
 
     }
 
     }
   
+
   
 
     run_time_permissions(integer perm)
 
     run_time_permissions(integer perm)
 
     {
 
     {
Line 65: Line 61:
 
         }
 
         }
 
     }
 
     }
   
+
       
   
+
 
     //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 and all the first time notice item.
 
         //Notify number and name and all the first time notice item.
 
         //Return number detected.
 
         //Return number detected.
 
         llWhisper(0, "Detected in total, " + (string)numberDetected + " avatar(s).");   
 
         llWhisper(0, "Detected in total, " + (string)numberDetected + " avatar(s).");   
 
llWhisper(0, "Detected " + llDetectedName(0) + llGetTimestamp());
 
llWhisper(0, "Detected " + llDetectedName(0) + llGetTimestamp());
   
+
     
 
//Get Camera Position 3D Coordinate
 
//Get Camera Position 3D Coordinate
 
   //Returns a VECTOR
 
   //Returns a VECTOR
 
   camVec = llGetCameraPos();
 
   camVec = llGetCameraPos();
 
+
 
   //Get Camera Rotation
 
   //Get Camera Rotation
 
   //Returns a ROTATION
 
   //Returns a ROTATION
 
   camRot = llGetCameraRot();
 
   camRot = llGetCameraRot();
           
+
           
 
             llWhisper(0, "CPos: (" + (string)camVec.x + "," + (string)camVec.y + "," +(string)camVec.z + ")");
 
             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 + ")");
+
           llWhisper(0, "CRot: (" + (string)camRot.x + ","+ (string)camRot.y + ","+(string)camRot.z +","+ (string)camRot.s + ")");
 
+
 
+
 
           charVec = llDetectedPos(0);
 
           charVec = llDetectedPos(0);
 
         charRot = llDetectedRot(0);
 
         charRot = llDetectedRot(0);
 
+
 
           llWhisper(0, "Pos: (" + (string)charVec.x + "," + (string)charVec.y + "," +(string)charVec.z + ")");
 
           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 + ")");
 
           llWhisper(0, "Rot: (" + (string)charRot.x + ","+ (string)charRot.y + ","+(string)charRot.z +","+ (string)charRot.s + ")");
 
     }
 
     }
+
 
 
     no_sensor()
 
     no_sensor()
 
     {
 
     {
 
         llWhisper(0, "Nobody is near me at present.");
 
         llWhisper(0, "Nobody is near me at present.");
 
     }
 
     }
}
+
  }
==This is the RealXtend Version of the Script==
+
==This is the RealXtend Version of the Script with reduced functionality==
 
import rxactor
 
import rxactor
 
import rxavatar
 
import rxavatar

Revision as of 15:32, 17 June 2009

realXtend can run a version of script that is very similar to LSL but NOT LSL!

Many command from LSL are recognized and used but the syntax is alterned and require extensive exploration for any complicated LSL command such as llSensor/llSensorRepeat/llRequestPermission

Hence, embedding existing LSL command in python is a hit and miss process for many at the moment.

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? (not possible in SL version of the Script)

}

This is the SecondLife version of the tracking script

//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.");
   }
 }

This is the RealXtend Version of the Script with reduced functionality

import rxactor import rxavatar import sys import clr import random import math import time

asm = clr.LoadAssemblyByName('OpenSim.Region.ScriptEngine.Common') Vector3 = asm.OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3


  1. class SayHello(rxactor.Actor):

class SayHello(rxactor.Actor):

   def GetScriptClassName():
       return "FirstScript.SayHello"
   def EventTouch(self,vAvatar):
       str = self.llGetObjectName() +  " was touched in region "+self.llGetRegionName() + " by " + vAvatar.GetFullName()
       self.llShout(0,str)
  1. class getInfo

class GetInfo(rxactor.Actor):

   def GetScriptClassName():
       return "FirstScript.GetInfo"
   def EventTouch(self, vAvatar):
       self.llShout(0,"Acquiring 3D Coordinate and Positional Information!")
       stopLoop = 500
       while stopLoop > 0
           #Getting Position Information
           Px = str(vAvatar.llGetPos().x) 
           Py = str(vAvatar.llGetPos().y) 
           Pz = str(vAvatar.llGetPos().z) 
           Position = "("+Px + ","+Py+","+Pz+")"
           self.llShout(0,Position)
           #Getting Position Information
           Rx = str(vAvatar.llGetRot().x) 
           Ry = str(vAvatar.llGetRot().y) 
           Rz = str(vAvatar.llGetRot().z) 
           Rs = str(vAvatar.llGetRot().s) 
           #Getting Rotataional Information
           Rotation = "("+Rx + ","+Ry+","+Rz+","+Rs+")"
           self.llShout(0,Rotation)
           print(Position,Rotation file=stdout.txt)
           time.sleep(3)
           stopLoop--