Difference between revisions of "Virtual Tracking Guide"

From CRIPTWiki
Jump to: navigation, search
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
realXtend can run LSL scrpit no problem.
+
realXtend can run a version of script that is very similar to LSL but NOT LSL!
  
Hence, we will be able to use exist LSL command embedding in python to run the command.
+
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
  
The key script that is used:
+
Hence, embedding existing LSL command in python is a hit and miss process for many at the moment.
  
To do a few things:
+
The key script that is used to do a few things:
  
 
*IF (people within range) then
 
*IF (people within range) then
Line 14: 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 51: Line 49:
 
         // 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
 
         llWhisper(0,"Starting Detection Runs");
 
         llWhisper(0,"Starting Detection Runs");
                 
+
                 
//Request permission to track camera pos/rotation  
+
//Request permission to track camera pos/rotation  
llRequestPermissions(llDetectedKey(0), PERMISSION_TRACK_CAMERA);  
+
llRequestPermissions(llDetectedKey(0), PERMISSION_TRACK_CAMERA);  
 
     }
 
     }
   
+
   
 
     run_time_permissions(integer perm)
 
     run_time_permissions(integer perm)
 
     {
 
     {
Line 63: 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
import sys
+
import sys
import clr
+
import clr
import random
+
import random
import math
+
import math
import time
+
import time
  
asm = clr.LoadAssemblyByName('OpenSim.Region.ScriptEngine.Common')
+
asm = clr.LoadAssemblyByName('OpenSim.Region.ScriptEngine.Common')
Vector3 = asm.OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3
+
Vector3 = asm.OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3
  
 
+
#class SayHello(rxactor.Actor):  
 
+
class SayHello(rxactor.Actor):
#class SayHello(rxactor.Actor):
+
class SayHello(rxactor.Actor):
+
 
     def GetScriptClassName():
 
     def GetScriptClassName():
 
         return "FirstScript.SayHello"
 
         return "FirstScript.SayHello"
 
 
     def EventTouch(self,vAvatar):
 
     def EventTouch(self,vAvatar):
 
         str = self.llGetObjectName() +  " was touched in region "+self.llGetRegionName() + " by " + vAvatar.GetFullName()
 
         str = self.llGetObjectName() +  " was touched in region "+self.llGetRegionName() + " by " + vAvatar.GetFullName()
 
         self.llShout(0,str)
 
         self.llShout(0,str)
 
+
   
#class getInfo
+
#class getInfo
class GetInfo(rxactor.Actor):
+
class GetInfo(rxactor.Actor):
 
+
 
     def GetScriptClassName():
 
     def GetScriptClassName():
 
         return "FirstScript.GetInfo"
 
         return "FirstScript.GetInfo"
 
 
     def EventTouch(self, vAvatar):
 
     def EventTouch(self, vAvatar):
 
         self.llShout(0,"Acquiring 3D Coordinate and Positional Information!")
 
         self.llShout(0,"Acquiring 3D Coordinate and Positional Information!")
Line 137: Line 127:
 
             Position = "("+Px + ","+Py+","+Pz+")"
 
             Position = "("+Px + ","+Py+","+Pz+")"
 
             self.llShout(0,Position)
 
             self.llShout(0,Position)
 
+
 
 
             #Getting Position Information
 
             #Getting Position Information
 
             Rx = str(vAvatar.llGetRot().x)  
 
             Rx = str(vAvatar.llGetRot().x)  
Line 143: Line 133:
 
             Rz = str(vAvatar.llGetRot().z)  
 
             Rz = str(vAvatar.llGetRot().z)  
 
             Rs = str(vAvatar.llGetRot().s)  
 
             Rs = str(vAvatar.llGetRot().s)  
 
+
 
 
             #Getting Rotataional Information
 
             #Getting Rotataional Information
 
             Rotation = "("+Rx + ","+Ry+","+Rz+","+Rs+")"
 
             Rotation = "("+Rx + ","+Ry+","+Rz+","+Rs+")"
 
             self.llShout(0,Rotation)
 
             self.llShout(0,Rotation)
 
+
 
 
             print(Position,Rotation file=stdout.txt)
 
             print(Position,Rotation file=stdout.txt)
 
             time.sleep(3)
 
             time.sleep(3)
 
             stopLoop--
 
             stopLoop--
 +
 +
 +
[[Category:realXtend]]

Latest revision as of 19:50, 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
#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)
   
#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--