Difference between revisions of "Virtual Tracking Guide"

From CRIPTWiki
Jump to: navigation, search
Line 49: 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);  
 
     }
 
     }
 
      
 
      

Revision as of 15:36, 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--