diff options
author | UbitUmarov | 2018-04-01 01:50:07 +0100 |
---|---|---|
committer | UbitUmarov | 2018-04-01 01:50:07 +0100 |
commit | ee6034f75159b0cc623533fd86e4ff45a11890db (patch) | |
tree | c2d7e1e841b17448cee28b1dfd2f21f17fb6d5d1 /OpenSim/Region/ScriptEngine | |
parent | Merge branch 'master' into httptests (diff) | |
download | opensim-SC-ee6034f75159b0cc623533fd86e4ff45a11890db.zip opensim-SC-ee6034f75159b0cc623533fd86e4ff45a11890db.tar.gz opensim-SC-ee6034f75159b0cc623533fd86e4ff45a11890db.tar.bz2 opensim-SC-ee6034f75159b0cc623533fd86e4ff45a11890db.tar.xz |
several changes to materials, add llSet*PrimtiveParams*() support for them. They may be very broken now :(
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 547 |
1 files changed, 467 insertions, 80 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0124e32..014de69 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -124,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
124 | protected bool m_debuggerSafe = false; | 124 | protected bool m_debuggerSafe = false; |
125 | protected IUrlModule m_UrlModule = null; | 125 | protected IUrlModule m_UrlModule = null; |
126 | 126 | ||
127 | protected IMaterialsModule m_materialsModule = null; | ||
128 | |||
127 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); | 129 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); |
128 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | 130 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. |
129 | protected int m_sleepMsOnSetTexture = 200; | 131 | protected int m_sleepMsOnSetTexture = 200; |
@@ -306,6 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
306 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); | 308 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); |
307 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 309 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
308 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); | 310 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); |
311 | m_materialsModule = m_ScriptEngine.World.RequestModuleInterface<IMaterialsModule>(); | ||
309 | 312 | ||
310 | AsyncCommands = new AsyncCommandManager(m_ScriptEngine); | 313 | AsyncCommands = new AsyncCommandManager(m_ScriptEngine); |
311 | } | 314 | } |
@@ -2458,7 +2461,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2458 | return; | 2461 | return; |
2459 | } | 2462 | } |
2460 | 2463 | ||
2461 | |||
2462 | Primitive.TextureEntry tex = part.Shape.Textures; | 2464 | Primitive.TextureEntry tex = part.Shape.Textures; |
2463 | int nsides = GetNumberOfSides(part); | 2465 | int nsides = GetNumberOfSides(part); |
2464 | 2466 | ||
@@ -8910,6 +8912,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8910 | SceneObjectGroup parentgrp = part.ParentGroup; | 8912 | SceneObjectGroup parentgrp = part.ParentGroup; |
8911 | 8913 | ||
8912 | bool positionChanged = false; | 8914 | bool positionChanged = false; |
8915 | bool materialChanged = false; | ||
8913 | LSL_Vector currentPosition = GetPartLocalPos(part); | 8916 | LSL_Vector currentPosition = GetPartLocalPos(part); |
8914 | 8917 | ||
8915 | try | 8918 | try |
@@ -10206,6 +10209,231 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10206 | 10209 | ||
10207 | break; | 10210 | break; |
10208 | 10211 | ||
10212 | case ScriptBaseClass.PRIM_ALPHA_MODE: | ||
10213 | if (remain < 3) | ||
10214 | return new LSL_List(); | ||
10215 | |||
10216 | try | ||
10217 | { | ||
10218 | face = rules.GetLSLIntegerItem(idx++); | ||
10219 | } | ||
10220 | catch(InvalidCastException) | ||
10221 | { | ||
10222 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ALPHA_MODE: arg #{1} - must be integer", rulesParsed, idx - idxStart - 1)); | ||
10223 | return new LSL_List(); | ||
10224 | } | ||
10225 | |||
10226 | int materialAlphaMode; | ||
10227 | try | ||
10228 | { | ||
10229 | materialAlphaMode = rules.GetLSLIntegerItem(idx++); | ||
10230 | } | ||
10231 | catch(InvalidCastException) | ||
10232 | { | ||
10233 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ALPHA_MODE: arg #{1} - must be integer", rulesParsed, idx - idxStart - 1)); | ||
10234 | return new LSL_List(); | ||
10235 | } | ||
10236 | |||
10237 | if(materialAlphaMode < 0 || materialAlphaMode > 3) | ||
10238 | { | ||
10239 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ALPHA_MODE: arg #{1} - must be 0 to 3", rulesParsed, idx - idxStart - 1)); | ||
10240 | return new LSL_List(); | ||
10241 | } | ||
10242 | |||
10243 | int materialMaskCutoff; | ||
10244 | try | ||
10245 | { | ||
10246 | materialMaskCutoff = rules.GetLSLIntegerItem(idx++); | ||
10247 | } | ||
10248 | catch(InvalidCastException) | ||
10249 | { | ||
10250 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ALPHA_MODE: arg #{1} - must be integer", rulesParsed, idx - idxStart - 1)); | ||
10251 | return new LSL_List(); | ||
10252 | } | ||
10253 | |||
10254 | if(materialMaskCutoff < 0 || materialMaskCutoff > 255) | ||
10255 | { | ||
10256 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ALPHA_MODE: arg #{1} - must be 0 to 255", rulesParsed, idx - idxStart - 1)); | ||
10257 | return new LSL_List(); | ||
10258 | } | ||
10259 | |||
10260 | materialChanged |= SetMaterialAlphaMode(part, face, materialAlphaMode, materialMaskCutoff); | ||
10261 | break; | ||
10262 | |||
10263 | case ScriptBaseClass.PRIM_NORMAL: | ||
10264 | if (remain < 5) | ||
10265 | return new LSL_List(); | ||
10266 | |||
10267 | try | ||
10268 | { | ||
10269 | face = rules.GetLSLIntegerItem(idx++); | ||
10270 | } | ||
10271 | catch(InvalidCastException) | ||
10272 | { | ||
10273 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NORMAL: arg #{1} - must be integer", rulesParsed, idx - idxStart - 1)); | ||
10274 | return new LSL_List(); | ||
10275 | } | ||
10276 | |||
10277 | string mapname = rules.Data[idx++].ToString(); | ||
10278 | |||
10279 | UUID mapID = ScriptUtils.GetAssetIdFromItemName(m_host, mapname, (int)AssetType.Texture); | ||
10280 | if (mapID == UUID.Zero) | ||
10281 | { | ||
10282 | if (!UUID.TryParse(mapname, out mapID)) | ||
10283 | { | ||
10284 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NORMAL: arg #{1} - must be a UUID or a texture name on object inventory", rulesParsed, idx - idxStart - 1)); | ||
10285 | return new LSL_List(); | ||
10286 | } | ||
10287 | } | ||
10288 | |||
10289 | LSL_Vector mnrepeat; | ||
10290 | try | ||
10291 | { | ||
10292 | mnrepeat = rules.GetVector3Item(idx++); | ||
10293 | } | ||
10294 | catch(InvalidCastException) | ||
10295 | { | ||
10296 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NORMAL: arg #{1} - must be vector", rulesParsed, idx - idxStart - 1)); | ||
10297 | return new LSL_List(); | ||
10298 | } | ||
10299 | |||
10300 | LSL_Vector mnoffset; | ||
10301 | try | ||
10302 | { | ||
10303 | mnoffset = rules.GetVector3Item(idx++); | ||
10304 | } | ||
10305 | catch(InvalidCastException) | ||
10306 | { | ||
10307 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NORMAL: arg #{1} - must be vector", rulesParsed, idx - idxStart - 1)); | ||
10308 | return new LSL_List(); | ||
10309 | } | ||
10310 | |||
10311 | LSL_Float mnrot; | ||
10312 | try | ||
10313 | { | ||
10314 | mnrot = rules.GetLSLFloatItem(idx++); | ||
10315 | } | ||
10316 | catch(InvalidCastException) | ||
10317 | { | ||
10318 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NORMAL: arg #{1} - must be float", rulesParsed, idx - idxStart - 1)); | ||
10319 | return new LSL_List(); | ||
10320 | } | ||
10321 | |||
10322 | float repeatX = (float)Util.Clamp(mnrepeat.x,-100.0, 100.0); | ||
10323 | float repeatY = (float)Util.Clamp(mnrepeat.y,-100.0, 100.0); | ||
10324 | float offsetX = (float)Util.Clamp(mnoffset.x, 0, 1.0); | ||
10325 | float offsetY = (float)Util.Clamp(mnoffset.y, 0, 1.0); | ||
10326 | |||
10327 | materialChanged |= SetMaterialNormalMap(part, face, mapID, repeatX, repeatY, offsetX, offsetY, (float)mnrot); | ||
10328 | break; | ||
10329 | |||
10330 | case ScriptBaseClass.PRIM_SPECULAR: | ||
10331 | if (remain < 8) | ||
10332 | return new LSL_List(); | ||
10333 | |||
10334 | try | ||
10335 | { | ||
10336 | face = rules.GetLSLIntegerItem(idx++); | ||
10337 | } | ||
10338 | catch(InvalidCastException) | ||
10339 | { | ||
10340 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be integer", rulesParsed, idx - idxStart - 1)); | ||
10341 | return new LSL_List(); | ||
10342 | } | ||
10343 | |||
10344 | string smapname = rules.Data[idx++].ToString(); | ||
10345 | |||
10346 | UUID smapID = ScriptUtils.GetAssetIdFromItemName(m_host, smapname, (int)AssetType.Texture); | ||
10347 | if (smapID == UUID.Zero) | ||
10348 | { | ||
10349 | if (!UUID.TryParse(smapname, out smapID)) | ||
10350 | { | ||
10351 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be a UUID or a texture name on object inventory", rulesParsed, idx - idxStart - 1)); | ||
10352 | return new LSL_List(); | ||
10353 | } | ||
10354 | } | ||
10355 | |||
10356 | LSL_Vector msrepeat; | ||
10357 | try | ||
10358 | { | ||
10359 | msrepeat = rules.GetVector3Item(idx++); | ||
10360 | } | ||
10361 | catch(InvalidCastException) | ||
10362 | { | ||
10363 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be vector", rulesParsed, idx - idxStart - 1)); | ||
10364 | return new LSL_List(); | ||
10365 | } | ||
10366 | |||
10367 | LSL_Vector msoffset; | ||
10368 | try | ||
10369 | { | ||
10370 | msoffset = rules.GetVector3Item(idx++); | ||
10371 | } | ||
10372 | catch(InvalidCastException) | ||
10373 | { | ||
10374 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be vector", rulesParsed, idx - idxStart - 1)); | ||
10375 | return new LSL_List(); | ||
10376 | } | ||
10377 | |||
10378 | LSL_Float msrot; | ||
10379 | try | ||
10380 | { | ||
10381 | msrot = rules.GetLSLFloatItem(idx++); | ||
10382 | } | ||
10383 | catch(InvalidCastException) | ||
10384 | { | ||
10385 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be float", rulesParsed, idx - idxStart - 1)); | ||
10386 | return new LSL_List(); | ||
10387 | } | ||
10388 | |||
10389 | LSL_Vector mscolor; | ||
10390 | try | ||
10391 | { | ||
10392 | mscolor = rules.GetVector3Item(idx++); | ||
10393 | } | ||
10394 | catch(InvalidCastException) | ||
10395 | { | ||
10396 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be vector", rulesParsed, idx - idxStart - 1)); | ||
10397 | return new LSL_List(); | ||
10398 | } | ||
10399 | |||
10400 | LSL_Integer msgloss; | ||
10401 | try | ||
10402 | { | ||
10403 | msgloss = rules.GetLSLIntegerItem(idx++); | ||
10404 | } | ||
10405 | catch(InvalidCastException) | ||
10406 | { | ||
10407 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be integer", rulesParsed, idx - idxStart - 1)); | ||
10408 | return new LSL_List(); | ||
10409 | } | ||
10410 | |||
10411 | LSL_Integer msenv; | ||
10412 | try | ||
10413 | { | ||
10414 | msenv = rules.GetLSLIntegerItem(idx++); | ||
10415 | } | ||
10416 | catch(InvalidCastException) | ||
10417 | { | ||
10418 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be integer", rulesParsed, idx - idxStart - 1)); | ||
10419 | return new LSL_List(); | ||
10420 | } | ||
10421 | |||
10422 | float srepeatX = (float)Util.Clamp(msrepeat.x, -100.0, 100.0); | ||
10423 | float srepeatY = (float)Util.Clamp(msrepeat.y, -100.0, 100.0); | ||
10424 | float soffsetX = (float)Util.Clamp(msoffset.x, -1.0, 1.0); | ||
10425 | float soffsetY = (float)Util.Clamp(msoffset.y, -1.0, 1.0); | ||
10426 | byte colorR = (byte)(255.0 * Util.Clamp(mscolor.x, 0, 1.0) + 0.5); | ||
10427 | byte colorG = (byte)(255.0 * Util.Clamp(mscolor.y, 0, 1.0) + 0.5); | ||
10428 | byte colorB = (byte)(255.0 * Util.Clamp(mscolor.z, 0, 1.0) + 0.5); | ||
10429 | byte gloss = (byte)Util.Clamp((int)msgloss, 0, 255); | ||
10430 | byte env = (byte)Util.Clamp((int)msenv, 0, 255); | ||
10431 | |||
10432 | materialChanged |= SetMaterialSpecMap(part, face, smapID, srepeatX, srepeatY, soffsetX, soffsetY, | ||
10433 | (float)msrot, colorR, colorG, colorB, gloss, env); | ||
10434 | |||
10435 | break; | ||
10436 | |||
10209 | case ScriptBaseClass.PRIM_LINK_TARGET: | 10437 | case ScriptBaseClass.PRIM_LINK_TARGET: |
10210 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 10438 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. |
10211 | return new LSL_List(); | 10439 | return new LSL_List(); |
@@ -10242,11 +10470,194 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10242 | part.ScheduleTerseUpdate(); | 10470 | part.ScheduleTerseUpdate(); |
10243 | } | 10471 | } |
10244 | } | 10472 | } |
10473 | if(materialChanged) | ||
10474 | { | ||
10475 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) | ||
10476 | { | ||
10477 | part.TriggerScriptChangedEvent(Changed.TEXTURE); | ||
10478 | part.ScheduleFullUpdate(); | ||
10479 | part.ParentGroup.HasGroupChanged = true; | ||
10480 | } | ||
10481 | } | ||
10245 | } | 10482 | } |
10246 | 10483 | ||
10247 | return new LSL_List(); | 10484 | return new LSL_List(); |
10248 | } | 10485 | } |
10249 | 10486 | ||
10487 | protected bool SetMaterialAlphaMode(SceneObjectPart part, int face, int materialAlphaMode, int materialMaskCutoff) | ||
10488 | { | ||
10489 | if(m_materialsModule == null) | ||
10490 | return false; | ||
10491 | |||
10492 | int nsides = part.GetNumberOfSides(); | ||
10493 | |||
10494 | if(face == ScriptBaseClass.ALL_SIDES) | ||
10495 | { | ||
10496 | bool changed = false; | ||
10497 | for(int i = 0; i < nsides; i++) | ||
10498 | changed |= SetFaceMaterialAlphaMode(part, i, materialAlphaMode, materialMaskCutoff); | ||
10499 | return changed; | ||
10500 | } | ||
10501 | |||
10502 | if( face >= 0 && face < nsides) | ||
10503 | return SetFaceMaterialAlphaMode(part, face, materialAlphaMode, materialMaskCutoff); | ||
10504 | |||
10505 | return false; | ||
10506 | } | ||
10507 | |||
10508 | protected bool SetFaceMaterialAlphaMode(SceneObjectPart part, int face, int materialAlphaMode, int materialMaskCutoff) | ||
10509 | { | ||
10510 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
10511 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); | ||
10512 | if(texface == null) | ||
10513 | return false; | ||
10514 | |||
10515 | FaceMaterial mat = null; | ||
10516 | UUID oldid = texface.MaterialID; | ||
10517 | |||
10518 | if(oldid != UUID.Zero) | ||
10519 | mat = m_materialsModule.GetMaterialCopy(oldid); | ||
10520 | |||
10521 | if(mat == null) | ||
10522 | mat = new FaceMaterial(); | ||
10523 | |||
10524 | mat.DiffuseAlphaMode = (byte)materialAlphaMode; | ||
10525 | mat.AlphaMaskCutoff = (byte)materialMaskCutoff; | ||
10526 | |||
10527 | UUID id = m_materialsModule.AddNewMaterial(mat); | ||
10528 | if(oldid == id) | ||
10529 | return false; | ||
10530 | |||
10531 | texface.MaterialID = id; | ||
10532 | part.Shape.TextureEntry = tex.GetBytes(); | ||
10533 | m_materialsModule.RemoveMaterial(oldid); | ||
10534 | return true; | ||
10535 | } | ||
10536 | |||
10537 | protected bool SetMaterialNormalMap(SceneObjectPart part, int face, UUID mapID, float repeatX, float repeatY, | ||
10538 | float offsetX, float offsetY, float rot) | ||
10539 | { | ||
10540 | if(m_materialsModule == null) | ||
10541 | return false; | ||
10542 | |||
10543 | int nsides = part.GetNumberOfSides(); | ||
10544 | |||
10545 | if(face == ScriptBaseClass.ALL_SIDES) | ||
10546 | { | ||
10547 | bool changed = false; | ||
10548 | for(int i = 0; i < nsides; i++) | ||
10549 | changed |= SetFaceMaterialNormalMap(part, i, mapID, repeatX, repeatY, offsetX, offsetY, rot); | ||
10550 | return changed; | ||
10551 | } | ||
10552 | |||
10553 | if( face >= 0 && face < nsides) | ||
10554 | return SetFaceMaterialNormalMap(part, face, mapID, repeatX, repeatY, offsetX, offsetY, rot); | ||
10555 | |||
10556 | return false; | ||
10557 | } | ||
10558 | |||
10559 | protected bool SetFaceMaterialNormalMap(SceneObjectPart part, int face, UUID mapID, float repeatX, float repeatY, | ||
10560 | float offsetX, float offsetY, float rot) | ||
10561 | |||
10562 | { | ||
10563 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
10564 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); | ||
10565 | if(texface == null) | ||
10566 | return false; | ||
10567 | |||
10568 | FaceMaterial mat = null; | ||
10569 | UUID oldid = texface.MaterialID; | ||
10570 | |||
10571 | if(oldid != UUID.Zero) | ||
10572 | mat = m_materialsModule.GetMaterialCopy(oldid); | ||
10573 | |||
10574 | if(mat == null) | ||
10575 | mat = new FaceMaterial(); | ||
10576 | |||
10577 | mat.NormalMapID = mapID; | ||
10578 | mat.NormalOffsetX = offsetX; | ||
10579 | mat.NormalOffsetY = offsetY; | ||
10580 | mat.NormalRepeatX = repeatX; | ||
10581 | mat.NormalRepeatY = repeatY; | ||
10582 | mat.NormalRotation = rot; | ||
10583 | |||
10584 | UUID id = m_materialsModule.AddNewMaterial(mat); | ||
10585 | if(oldid == id) | ||
10586 | return false; | ||
10587 | |||
10588 | texface.MaterialID = id; | ||
10589 | part.Shape.TextureEntry = tex.GetBytes(); | ||
10590 | m_materialsModule.RemoveMaterial(oldid); | ||
10591 | return true; | ||
10592 | } | ||
10593 | |||
10594 | protected bool SetMaterialSpecMap(SceneObjectPart part, int face, UUID mapID, float repeatX, float repeatY, | ||
10595 | float offsetX, float offsetY, float rot, | ||
10596 | byte colorR, byte colorG, byte colorB, | ||
10597 | byte gloss, byte env) | ||
10598 | { | ||
10599 | if(m_materialsModule == null) | ||
10600 | return false; | ||
10601 | |||
10602 | int nsides = part.GetNumberOfSides(); | ||
10603 | |||
10604 | if(face == ScriptBaseClass.ALL_SIDES) | ||
10605 | { | ||
10606 | bool changed = false; | ||
10607 | for(int i = 0; i < nsides; i++) | ||
10608 | changed |= SetFaceMaterialSpecMap(part, i, mapID, repeatX, repeatY, offsetX, offsetY, rot, | ||
10609 | colorR, colorG, colorB, gloss, env); | ||
10610 | return changed; | ||
10611 | } | ||
10612 | |||
10613 | if( face >= 0 && face < nsides) | ||
10614 | return SetFaceMaterialSpecMap(part, face, mapID, repeatX, repeatY, offsetX, offsetY, rot, | ||
10615 | colorR, colorG, colorB, gloss, env); | ||
10616 | |||
10617 | return false; | ||
10618 | } | ||
10619 | |||
10620 | protected bool SetFaceMaterialSpecMap(SceneObjectPart part, int face, UUID mapID, float repeatX, float repeatY, | ||
10621 | float offsetX, float offsetY, float rot, | ||
10622 | byte colorR, byte colorG, byte colorB, | ||
10623 | byte gloss, byte env) | ||
10624 | { | ||
10625 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
10626 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); | ||
10627 | if(texface == null) | ||
10628 | return false; | ||
10629 | |||
10630 | FaceMaterial mat = null; | ||
10631 | UUID oldid = texface.MaterialID; | ||
10632 | |||
10633 | if(oldid != UUID.Zero) | ||
10634 | mat = m_materialsModule.GetMaterialCopy(oldid); | ||
10635 | |||
10636 | if(mat == null) | ||
10637 | mat = new FaceMaterial(); | ||
10638 | |||
10639 | mat.SpecularMapID = mapID; | ||
10640 | mat.SpecularOffsetX = offsetX; | ||
10641 | mat.SpecularOffsetY = offsetY; | ||
10642 | mat.SpecularRepeatX = repeatX; | ||
10643 | mat.SpecularRepeatY = repeatY; | ||
10644 | mat.SpecularRotation = rot; | ||
10645 | mat.SpecularLightColorR = colorR; | ||
10646 | mat.SpecularLightColorG = colorG; | ||
10647 | mat.SpecularLightColorB = colorB; | ||
10648 | mat.SpecularLightExponent = gloss; | ||
10649 | mat.EnvironmentIntensity = env; | ||
10650 | |||
10651 | UUID id = m_materialsModule.AddNewMaterial(mat); | ||
10652 | if(oldid == id) | ||
10653 | return false; | ||
10654 | |||
10655 | texface.MaterialID = id; | ||
10656 | part.Shape.TextureEntry = tex.GetBytes(); | ||
10657 | m_materialsModule.RemoveMaterial(oldid); | ||
10658 | return true; | ||
10659 | } | ||
10660 | |||
10250 | protected LSL_List SetAgentParams(ScenePresence sp, LSL_List rules, string originFunc, ref uint rulesParsed) | 10661 | protected LSL_List SetAgentParams(ScenePresence sp, LSL_List rules, string originFunc, ref uint rulesParsed) |
10251 | { | 10662 | { |
10252 | int idx = 0; | 10663 | int idx = 0; |
@@ -11363,107 +11774,83 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11363 | return new LSL_List(); | 11774 | return new LSL_List(); |
11364 | } | 11775 | } |
11365 | 11776 | ||
11366 | /* | 11777 | private string GetMaterialTextureUUIDbyRights(UUID origID, SceneObjectPart part) |
11367 | private string filterTextureUUIDbyRights(UUID origID, SceneObjectPart part, bool checkTaskInventory, bool returnInvName) | ||
11368 | { | 11778 | { |
11369 | if(checkTaskInventory) | 11779 | if(World.Permissions.CanEditObject(m_host.ParentGroup.UUID, m_host.ParentGroup.RootPart.OwnerID)) |
11780 | return origID.ToString(); | ||
11781 | |||
11782 | lock(part.TaskInventory) | ||
11370 | { | 11783 | { |
11371 | lock (part.TaskInventory) | 11784 | foreach(KeyValuePair<UUID, TaskInventoryItem> inv in part.TaskInventory) |
11372 | { | 11785 | { |
11373 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in part.TaskInventory) | 11786 | if(inv.Value.InvType == (int)InventoryType.Texture && inv.Value.AssetID == origID) |
11374 | { | 11787 | return origID.ToString(); |
11375 | if (inv.Value.AssetID == origID) | ||
11376 | { | ||
11377 | if(inv.Value.InvType == (int)InventoryType.Texture) | ||
11378 | { | ||
11379 | if(returnInvName) | ||
11380 | return inv.Value.Name; | ||
11381 | else | ||
11382 | return origID.ToString(); | ||
11383 | } | ||
11384 | else | ||
11385 | return UUID.Zero.ToString(); | ||
11386 | } | ||
11387 | } | ||
11388 | } | 11788 | } |
11389 | } | 11789 | } |
11390 | 11790 | ||
11391 | if(World.Permissions.CanEditObject(m_host.ParentGroup.UUID, m_host.ParentGroup.RootPart.OwnerID)) | ||
11392 | return origID.ToString(); | ||
11393 | |||
11394 | return UUID.Zero.ToString(); | 11791 | return UUID.Zero.ToString(); |
11395 | } | 11792 | } |
11396 | */ | 11793 | |
11397 | private void getLSLFaceMaterial(ref LSL_List res, int code, SceneObjectPart part, Primitive.TextureEntryFace texface) | 11794 | private void getLSLFaceMaterial(ref LSL_List res, int code, SceneObjectPart part, Primitive.TextureEntryFace texface) |
11398 | { | 11795 | { |
11399 | UUID matID = texface.MaterialID; | 11796 | UUID matID = UUID.Zero; |
11797 | if(m_materialsModule != null) | ||
11798 | matID = texface.MaterialID; | ||
11799 | |||
11400 | if(matID != UUID.Zero) | 11800 | if(matID != UUID.Zero) |
11401 | { | 11801 | { |
11402 | AssetBase MatAsset = World.AssetService.Get(matID.ToString()); | 11802 | FaceMaterial mat = m_materialsModule.GetMaterial(matID); |
11403 | if(MatAsset != null) | 11803 | if(mat != null) |
11404 | { | 11804 | { |
11405 | Byte[] data = MatAsset.Data; | 11805 | if(code == ScriptBaseClass.PRIM_NORMAL) |
11406 | OSDMap osdmat = (OSDMap)OSDParser.DeserializeLLSDXml(data); | ||
11407 | if(osdmat != null && osdmat.ContainsKey("NormMap")) | ||
11408 | { | 11806 | { |
11409 | string mapIDstr; | 11807 | res.Add(new LSL_String(GetMaterialTextureUUIDbyRights(mat.NormalMapID, part))); |
11410 | FaceMaterial mat = new FaceMaterial(matID, osdmat); | 11808 | res.Add(new LSL_Vector(mat.NormalRepeatX, mat.NormalRepeatY, 0)); |
11411 | if(code == ScriptBaseClass.PRIM_NORMAL) | 11809 | res.Add(new LSL_Vector(mat.NormalOffsetX, mat.NormalOffsetY, 0)); |
11412 | { | 11810 | res.Add(new LSL_Float(mat.NormalRotation)); |
11413 | // mapIDstr = filterTextureUUIDbyRights(mat.NormalMapID, part, true, false); | ||
11414 | mapIDstr = mat.NormalMapID.ToString(); | ||
11415 | res.Add(new LSL_String(mapIDstr)); | ||
11416 | res.Add(new LSL_Vector(mat.NormalRepeatX, mat.NormalRepeatY, 0)); | ||
11417 | res.Add(new LSL_Vector(mat.NormalOffsetX, mat.NormalOffsetY, 0)); | ||
11418 | res.Add(new LSL_Float(mat.NormalRotation)); | ||
11419 | } | ||
11420 | else if(code == ScriptBaseClass.PRIM_SPECULAR ) | ||
11421 | { | ||
11422 | // mapIDstr = filterTextureUUIDbyRights(mat.SpecularMapID, part, true, false); | ||
11423 | const float colorScale = 1.0f/255f; | ||
11424 | mapIDstr = mat.SpecularMapID.ToString(); | ||
11425 | res.Add(new LSL_String(mapIDstr)); | ||
11426 | res.Add(new LSL_Vector(mat.SpecularRepeatX, mat.SpecularRepeatY, 0)); | ||
11427 | res.Add(new LSL_Vector(mat.SpecularOffsetX, mat.SpecularOffsetY, 0)); | ||
11428 | res.Add(new LSL_Float(mat.SpecularRotation)); | ||
11429 | res.Add(new LSL_Vector(mat.SpecularLightColor.R * colorScale, | ||
11430 | mat.SpecularLightColor.G * colorScale, | ||
11431 | mat.SpecularLightColor.B * colorScale)); | ||
11432 | res.Add(new LSL_Integer(mat.SpecularLightExponent)); | ||
11433 | res.Add(new LSL_Integer(mat.EnvironmentIntensity)); | ||
11434 | } | ||
11435 | else if(code == ScriptBaseClass.PRIM_ALPHA_MODE) | ||
11436 | { | ||
11437 | res.Add(new LSL_Integer(mat.DiffuseAlphaMode)); | ||
11438 | res.Add(new LSL_Integer(mat.AlphaMaskCutoff)); | ||
11439 | } | ||
11440 | return; | ||
11441 | } | 11811 | } |
11442 | } | 11812 | else if(code == ScriptBaseClass.PRIM_SPECULAR) |
11443 | matID = UUID.Zero; | ||
11444 | } | ||
11445 | if(matID == UUID.Zero) | ||
11446 | { | ||
11447 | if(code == (int)ScriptBaseClass.PRIM_NORMAL || code == (int)ScriptBaseClass.PRIM_SPECULAR ) | ||
11448 | { | ||
11449 | res.Add(new LSL_String(UUID.Zero.ToString())); | ||
11450 | res.Add(new LSL_Vector(1.0, 1.0, 0)); | ||
11451 | res.Add(new LSL_Vector(0, 0, 0)); | ||
11452 | res.Add(new LSL_Float(0)); | ||
11453 | |||
11454 | if(code == (int)ScriptBaseClass.PRIM_SPECULAR) | ||
11455 | { | 11813 | { |
11456 | res.Add(new LSL_Vector(1.0, 1.0, 1.0)); | 11814 | const float colorScale = 1.0f / 255f; |
11457 | res.Add(new LSL_Integer(51)); | 11815 | res.Add(new LSL_String(GetMaterialTextureUUIDbyRights(mat.SpecularMapID, part))); |
11458 | res.Add(new LSL_Integer(0)); | 11816 | res.Add(new LSL_Vector(mat.SpecularRepeatX, mat.SpecularRepeatY, 0)); |
11817 | res.Add(new LSL_Vector(mat.SpecularOffsetX, mat.SpecularOffsetY, 0)); | ||
11818 | res.Add(new LSL_Float(mat.SpecularRotation)); | ||
11819 | res.Add(new LSL_Vector(mat.SpecularLightColorR * colorScale, | ||
11820 | mat.SpecularLightColorG * colorScale, | ||
11821 | mat.SpecularLightColorB * colorScale)); | ||
11822 | res.Add(new LSL_Integer(mat.SpecularLightExponent)); | ||
11823 | res.Add(new LSL_Integer(mat.EnvironmentIntensity)); | ||
11824 | } | ||
11825 | else if(code == ScriptBaseClass.PRIM_ALPHA_MODE) | ||
11826 | { | ||
11827 | res.Add(new LSL_Integer(mat.DiffuseAlphaMode)); | ||
11828 | res.Add(new LSL_Integer(mat.AlphaMaskCutoff)); | ||
11459 | } | 11829 | } |
11830 | return; | ||
11460 | } | 11831 | } |
11461 | else if(code == (int)ScriptBaseClass.PRIM_ALPHA_MODE) | 11832 | } |
11833 | |||
11834 | // material not found | ||
11835 | if(code == (int)ScriptBaseClass.PRIM_NORMAL || code == (int)ScriptBaseClass.PRIM_SPECULAR) | ||
11836 | { | ||
11837 | res.Add(new LSL_String(UUID.Zero.ToString())); | ||
11838 | res.Add(new LSL_Vector(1.0, 1.0, 0)); | ||
11839 | res.Add(new LSL_Vector(0, 0, 0)); | ||
11840 | res.Add(new LSL_Float(0)); | ||
11841 | |||
11842 | if(code == (int)ScriptBaseClass.PRIM_SPECULAR) | ||
11462 | { | 11843 | { |
11463 | res.Add(new LSL_Integer(1)); | 11844 | res.Add(new LSL_Vector(1.0, 1.0, 1.0)); |
11845 | res.Add(new LSL_Integer(51)); | ||
11464 | res.Add(new LSL_Integer(0)); | 11846 | res.Add(new LSL_Integer(0)); |
11465 | } | 11847 | } |
11466 | } | 11848 | } |
11849 | else if(code == (int)ScriptBaseClass.PRIM_ALPHA_MODE) | ||
11850 | { | ||
11851 | res.Add(new LSL_Integer(1)); | ||
11852 | res.Add(new LSL_Integer(0)); | ||
11853 | } | ||
11467 | } | 11854 | } |
11468 | 11855 | ||
11469 | public LSL_List llGetPrimMediaParams(int face, LSL_List rules) | 11856 | public LSL_List llGetPrimMediaParams(int face, LSL_List rules) |