1
0

sampleavatarrotate.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # sampleavatarrotate.py
  2. #print "sampleavatarrotate.................................."
  3. import rxactor
  4. import sys
  5. import clr
  6. asm = clr.LoadAssemblyByName('OpenSim.Region.ScriptEngine.Common')
  7. Vector3 = asm.OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3
  8. import random
  9. import math
  10. # Rotate avatar relatively 90 degrees right
  11. class RotRight(rxactor.Actor):
  12. def GetScriptClassName():
  13. return "sampleavatarrotate.RotRight"
  14. def EventCreated(self):
  15. super(self.__class__,self).EventCreated()
  16. print "ClientScripting.RotRight created"
  17. def EventTouch(self,vAvatar):
  18. rotresult = self.llEuler2Rot(Vector3(0,0,math.pi*-0.5))
  19. vAvatar.SetRelativeRot(rotresult)
  20. self.llShout(0,"90 degrees right")
  21. # Rotate north, south, east,west
  22. class RotMainDirs(rxactor.Actor):
  23. def GetScriptClassName():
  24. return "sampleavatarrotate.RotMainDirs"
  25. def EventCreated(self):
  26. super(self.__class__,self).EventCreated()
  27. print "ClientScripting.RotMainDirs created"
  28. self.Status = 0
  29. def EventTouch(self,vAvatar):
  30. if(self.Status == 0): # North
  31. rotresult = self.llEuler2Rot(Vector3(0,0,math.pi*0.5))
  32. self.llShout(0,"North")
  33. elif(self.Status == 1): # South
  34. rotresult = self.llEuler2Rot(Vector3(0,0,math.pi*1.5))
  35. self.llShout(0,"South")
  36. elif(self.Status == 2): # East
  37. rotresult = self.llEuler2Rot(Vector3(0,0,0))
  38. self.llShout(0,"East")
  39. elif(self.Status == 3): # West
  40. rotresult = self.llEuler2Rot(Vector3(0,0,math.pi))
  41. self.llShout(0,"West")
  42. self.Status += 1
  43. if(self.Status > 3):
  44. self.Status = 0
  45. vAvatar.llSetRot(rotresult)
  46. # Rotate avatar towards this object
  47. class RotTowardsMe(rxactor.Actor):
  48. def GetScriptClassName():
  49. return "sampleavatarrotate.RotTowardsMe"
  50. def EventCreated(self):
  51. super(self.__class__,self).EventCreated()
  52. print "ClientScripting.RotTowardsMe created"
  53. def EventTouch(self,vAvatar):
  54. avatar_forward = self.llRot2Fwd(vAvatar.llGetRot())
  55. avatar_toward = self.llVecNorm(self.llGetPos() - vAvatar.llGetPos())
  56. rotresult = self.llRotBetween(avatar_forward,avatar_toward)
  57. vAvatar.llSetRot(rotresult)
  58. self.llShout(0,"Towards me!")