SOPObjectMaterial.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System.Drawing;
  28. using OpenMetaverse;
  29. using OpenSim.Region.Framework.Scenes;
  30. namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
  31. {
  32. class SOPObjectMaterial : System.MarshalByRefObject, IObjectMaterial
  33. {
  34. private readonly int m_face;
  35. private readonly SceneObjectPart m_parent;
  36. public SOPObjectMaterial(int m_face, SceneObjectPart m_parent)
  37. {
  38. this.m_face = m_face;
  39. this.m_parent = m_parent;
  40. }
  41. public Color Color
  42. {
  43. get
  44. {
  45. Color4 res = GetTexface().RGBA;
  46. return Color.FromArgb((int) (res.A*255), (int) (res.R*255), (int) (res.G*255), (int) (res.B*255));
  47. }
  48. set
  49. {
  50. Primitive.TextureEntry tex = m_parent.Shape.Textures;
  51. Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
  52. texface.RGBA = new Color4(value.R,value.G,value.B,value.A);
  53. tex.FaceTextures[m_face] = texface;
  54. m_parent.UpdateTextureEntry(tex.GetBytes());
  55. }
  56. }
  57. public UUID Texture
  58. {
  59. get
  60. {
  61. Primitive.TextureEntryFace texface = GetTexface();
  62. return texface.TextureID;
  63. }
  64. set
  65. {
  66. Primitive.TextureEntry tex = m_parent.Shape.Textures;
  67. Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
  68. texface.TextureID = value;
  69. tex.FaceTextures[m_face] = texface;
  70. m_parent.UpdateTextureEntry(tex.GetBytes());
  71. }
  72. }
  73. private Primitive.TextureEntryFace GetTexface()
  74. {
  75. Primitive.TextureEntry tex = m_parent.Shape.Textures;
  76. return tex.GetFace((uint)m_face);
  77. }
  78. public TextureMapping Mapping
  79. {
  80. get { throw new System.NotImplementedException(); }
  81. set { throw new System.NotImplementedException(); }
  82. }
  83. public bool Bright
  84. {
  85. get { return GetTexface().Fullbright; }
  86. set
  87. {
  88. Primitive.TextureEntry tex = m_parent.Shape.Textures;
  89. Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
  90. texface.Fullbright = value;
  91. tex.FaceTextures[m_face] = texface;
  92. m_parent.UpdateTextureEntry(tex.GetBytes());
  93. }
  94. }
  95. public double Bloom
  96. {
  97. get { return GetTexface().Glow; }
  98. set
  99. {
  100. Primitive.TextureEntry tex = m_parent.Shape.Textures;
  101. Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
  102. texface.Glow = (float) value;
  103. tex.FaceTextures[m_face] = texface;
  104. m_parent.UpdateTextureEntry(tex.GetBytes());
  105. }
  106. }
  107. public bool Shiny
  108. {
  109. get { return GetTexface().Shiny != Shininess.None; }
  110. set
  111. {
  112. Primitive.TextureEntry tex = m_parent.Shape.Textures;
  113. Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
  114. texface.Shiny = value ? Shininess.High : Shininess.None;
  115. tex.FaceTextures[m_face] = texface;
  116. m_parent.UpdateTextureEntry(tex.GetBytes());
  117. }
  118. }
  119. public bool BumpMap
  120. {
  121. get { return GetTexface().Bump == Bumpiness.None; }
  122. set { throw new System.NotImplementedException(); }
  123. }
  124. }
  125. }