diff options
author | CasperW | 2009-12-17 18:40:34 +0100 |
---|---|---|
committer | CasperW | 2009-12-17 18:40:34 +0100 |
commit | 6dbe25360ec3dc3c998378da8b422751d3e032a9 (patch) | |
tree | 34a3e2078b444111993a56d52d5c857ae226efb3 /OpenSim/Region/CoreModules | |
parent | Fix GetWorldRotation(), and a host of related Sit fixes. (diff) | |
download | opensim-SC_OLD-6dbe25360ec3dc3c998378da8b422751d3e032a9.zip opensim-SC_OLD-6dbe25360ec3dc3c998378da8b422751d3e032a9.tar.gz opensim-SC_OLD-6dbe25360ec3dc3c998378da8b422751d3e032a9.tar.bz2 opensim-SC_OLD-6dbe25360ec3dc3c998378da8b422751d3e032a9.tar.xz |
Add cmSetWindlightSceneTargeted. Add restrictions on windlight script use.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs | 127 |
1 files changed, 78 insertions, 49 deletions
diff --git a/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs index f180b47..72b0b38 100644 --- a/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs +++ b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs | |||
@@ -70,64 +70,69 @@ namespace OpenSim.Region.CoreModules.World.Meta7Windlight | |||
70 | if (m_enableWindlight) | 70 | if (m_enableWindlight) |
71 | { | 71 | { |
72 | m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent; | 72 | m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent; |
73 | m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile; | 73 | m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile; |
74 | m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted; | ||
74 | } | 75 | } |
75 | 76 | ||
76 | InstallCommands(); | 77 | InstallCommands(); |
77 | 78 | ||
78 | m_log.Debug("[WINDLIGHT]: Initialised windlight module"); | 79 | m_log.Debug("[WINDLIGHT]: Initialised windlight module"); |
80 | } | ||
81 | |||
82 | private List<byte[]> compileWindlightSettings(RegionMeta7WindlightData wl) | ||
83 | { | ||
84 | byte[] mBlock = new Byte[249]; | ||
85 | int pos = 0; | ||
86 | |||
87 | wl.waterColor.ToBytes(mBlock, 0); pos += 12; | ||
88 | Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4; | ||
89 | Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4; | ||
90 | wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12; | ||
91 | Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4; | ||
92 | Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4; | ||
93 | Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4; | ||
94 | Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4; | ||
95 | Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4; | ||
96 | wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8; | ||
97 | wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8; | ||
98 | wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16; | ||
99 | wl.horizon.ToBytes(mBlock, pos); pos += 16; | ||
100 | Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4; | ||
101 | wl.blueDensity.ToBytes(mBlock, pos); pos += 16; | ||
102 | Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4; | ||
103 | Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4; | ||
104 | Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4; | ||
105 | wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16; | ||
106 | Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4; | ||
107 | wl.ambient.ToBytes(mBlock, pos); pos += 16; | ||
108 | Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4; | ||
109 | Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4; | ||
110 | Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4; | ||
111 | Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4; | ||
112 | Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4; | ||
113 | wl.cloudColor.ToBytes(mBlock, pos); pos += 16; | ||
114 | wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12; | ||
115 | Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4; | ||
116 | Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4; | ||
117 | wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12; | ||
118 | Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4; | ||
119 | Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4; | ||
120 | Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2; | ||
121 | mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++; | ||
122 | mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++; | ||
123 | mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++; | ||
124 | List<byte[]> param = new List<byte[]>(); | ||
125 | param.Add(mBlock); | ||
126 | return param; | ||
79 | } | 127 | } |
80 | public void SendProfileToClient(ScenePresence presence) | 128 | public void SendProfileToClient(ScenePresence presence) |
81 | { | 129 | { |
130 | IClientAPI client = presence.ControllingClient; | ||
82 | if (m_enableWindlight) | 131 | if (m_enableWindlight) |
83 | { | 132 | { |
84 | if (presence.IsChildAgent == false) | 133 | if (presence.IsChildAgent == false) |
85 | { | 134 | { |
86 | IClientAPI client = presence.ControllingClient; | 135 | List<byte[]> param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings); |
87 | RegionMeta7WindlightData wl = m_scene.RegionInfo.WindlightSettings; | ||
88 | byte[] mBlock = new Byte[249]; | ||
89 | int pos = 0; | ||
90 | |||
91 | wl.waterColor.ToBytes(mBlock, 0); pos += 12; | ||
92 | Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4; | ||
93 | Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4; | ||
94 | wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12; | ||
95 | Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4; | ||
96 | Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4; | ||
97 | Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4; | ||
98 | Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4; | ||
99 | Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4; | ||
100 | wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8; | ||
101 | wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8; | ||
102 | wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16; | ||
103 | wl.horizon.ToBytes(mBlock, pos); pos += 16; | ||
104 | Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4; | ||
105 | wl.blueDensity.ToBytes(mBlock, pos); pos += 16; | ||
106 | Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4; | ||
107 | Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4; | ||
108 | Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4; | ||
109 | wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16; | ||
110 | Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4; | ||
111 | wl.ambient.ToBytes(mBlock, pos); pos += 16; | ||
112 | Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4; | ||
113 | Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4; | ||
114 | Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4; | ||
115 | Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4; | ||
116 | Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4; | ||
117 | wl.cloudColor.ToBytes(mBlock, pos); pos += 16; | ||
118 | wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12; | ||
119 | Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4; | ||
120 | Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4; | ||
121 | wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12; | ||
122 | Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4; | ||
123 | Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4; | ||
124 | Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2; | ||
125 | mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++; | ||
126 | mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++; | ||
127 | mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++; | ||
128 | List<byte[]> param = new List<byte[]>(); | ||
129 | param.Add(mBlock); | ||
130 | |||
131 | client.SendGenericMessage("Windlight", param); | 136 | client.SendGenericMessage("Windlight", param); |
132 | } | 137 | } |
133 | } | 138 | } |
@@ -136,13 +141,37 @@ namespace OpenSim.Region.CoreModules.World.Meta7Windlight | |||
136 | //We probably don't want to spam chat with this.. probably | 141 | //We probably don't want to spam chat with this.. probably |
137 | //m_log.Debug("[WINDLIGHT]: Module disabled"); | 142 | //m_log.Debug("[WINDLIGHT]: Module disabled"); |
138 | } | 143 | } |
144 | } | ||
145 | public void SendProfileToClient(ScenePresence presence, RegionMeta7WindlightData wl) | ||
146 | { | ||
147 | IClientAPI client = presence.ControllingClient; | ||
148 | if (m_enableWindlight) | ||
149 | { | ||
150 | if (presence.IsChildAgent == false) | ||
151 | { | ||
152 | List<byte[]> param = compileWindlightSettings(wl); | ||
153 | client.SendGenericMessage("Windlight", param); | ||
154 | } | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | //We probably don't want to spam chat with this.. probably | ||
159 | //m_log.Debug("[WINDLIGHT]: Module disabled"); | ||
160 | } | ||
139 | } | 161 | } |
140 | private void EventManager_OnMakeRootAgent(ScenePresence presence) | 162 | private void EventManager_OnMakeRootAgent(ScenePresence presence) |
141 | { | 163 | { |
142 | m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); | 164 | m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); |
143 | SendProfileToClient(presence); | 165 | SendProfileToClient(presence); |
166 | } | ||
167 | private void EventManager_OnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID pUUID) | ||
168 | { | ||
169 | ScenePresence Sc; | ||
170 | if (m_scene.TryGetAvatar(pUUID,out Sc)) | ||
171 | { | ||
172 | SendProfileToClient(Sc,wl); | ||
173 | } | ||
144 | } | 174 | } |
145 | |||
146 | private void EventManager_OnSaveNewWindlightProfile() | 175 | private void EventManager_OnSaveNewWindlightProfile() |
147 | { | 176 | { |
148 | m_scene.ForEachScenePresence(SendProfileToClient); | 177 | m_scene.ForEachScenePresence(SendProfileToClient); |