Open Source Platform
for interconnected virtual worlds

Content Scripting Python World Lighting

From RexWiki

Each world in realXtend has their own day cycle. Sometimes, however, one might want to override the default day cycle to create a world that has eternal sunshine for example, or perpetual night. This sample script will demonstrate how to override the default lighting conditions and ambient light in the world.

Note that this override is a hard one. The user will be unable to change the lighting conditions in any way after they are overridden.

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 Ambient(rxworldinfo.WorldInfo):
    def GetScriptClassName():
        return "testambient.Ambient"

    def EventCreated(self):
        super(self.__class__,self).EventCreated()
        self.MyWorld.MyEventManager.onAddPresence += self.handleOnAddPresence
        print "testambient.Ambient EventCreated"

    def EventDestroyed(self):
        self.MyWorld.MyEventManager.onAddPresence -= self.handleOnAddPresence
        super(Ambient,self).EventDestroyed()

    def handleOnAddPresence(self,vAvatar):
        vAvatar.rexSetAmbientLight(Vector3(0,0,1), Vector3(0.1,0.1,0.1), Vector3(0.1,0.1,0.1))

The noteworthy function is:

def rexSetAmbientLight(self,lightDirection,lightColour,ambientColour):

where

  • lightDirection Direction of the global light (sun).
  • lightColour Colour of the global light.
  • ambientColour Colour of the ambient light (the light that is always present)
  • All color are based on Red Green Blue in Percentage.