Content Scripting Python Sky
From Rex community wiki
This sample demonstrates how to set new skybox / skydome from Python script. The script will set a skydome.
import rxactor
import rxavatar
import rxworldinfo
import sys
import math
import clr
asm = clr.LoadAssemblyByName('OpenSim.Region.ScriptEngine.Common')
Vector3 = asm.OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3
class Sky(rxworldinfo.WorldInfo):
def GetScriptClassName():
return "samplesky.Sky"
def EventCreated(self):
super(self.__class__,self).EventCreated()
self.MyWorld.MyEventManager.onAddPresence += self.handleOnAddPresence
print "samplesky.Sky EventCreated"
def EventDestroyed(self):
self.MyWorld.MyEventManager.onAddPresence -= self.handleOnAddPresence
super(Sky,self).EventDestroyed()
def handleOnAddPresence(self,vAvatar):
vAvatar.rexSetSky(2, "b1f1da03-e22a-4108-a2c3-2f14fbe8a5a7", 50, 4)
Usage
The function you can use to set new sky for the world is
def rexSetSky(self,type,images,curvature,tiling)
Where
- type: Type of the sky
- 0: none
- 1: skybox
- 2: skydome
- images: List of image uuids - separated by space - to use for the sky. Skyboxes need 6 images, skydomes take one image
- curvature: Curvature of the skydome. Values around 10.0 are good for open spaces and landscapes. Not used with skyboxes.
- tiling: Skydome tiling. Not used with skyboxes.
Skybox
You need to supply 6 image uuids for skyboxes. Following command creates a skybox:
vAvatar.rexSetSky(1, "f08f085f-2396-49b1-b119-38eea771e54b_up b1f1da03-e22a-4108-a2c3-2f14fbe8a5a7_fr 02b85aa3-8ebe-44cf-950b-790b53a8b3f2_bk ca66566d-3db9-4889-b8d7-a0dc8c173c80_rt 52af4cc3-3a48-4248-9019-9efcf1657ffa_lf e9caee12-4cde-4f50-bef0-c7f105d31012_dn", 1, 1)
You can add suffix to the uuids to specify which side the texture should go to:
- _fr front
- _lf left
- _rt right
- _bk back
- _up up
- _dn down
It is not simply enough to have the python script present. After you have the skybox python script set up, you must attach it to an object on the Rex/Misc tab. To do this, you need to set the object's class under the Rex/Misc tab to the class name specified by the "GetScriptClassName():". In the script at the top of the article, this would be "samplesky.Sky". Do keep in mind that class names are capitalization specific.
|