UpdateTexture() public méthode

Update the textures on the part.
public UpdateTexture ( Primitive tex ) : void
tex Primitive
Résultat void
Exemple #1
0
        protected void SetTexture(SceneObjectPart part, string texture, int face)
        {
            UUID textureID=new UUID();
            int ns = GetNumberOfSides(part);

             textureID = InventoryKey(texture, (int)AssetType.Texture);
             if (textureID == UUID.Zero)
             {
                 if (!UUID.TryParse(texture, out textureID))
                     return;
             }

            Primitive.TextureEntry tex = part.Shape.Textures;

            if (face >= 0 && face < ns)
            {
                Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
                texface.TextureID = textureID;
                tex.FaceTextures[face] = texface;
                part.UpdateTexture(tex);
                return;
            }
            else if (face == ScriptBaseClass.ALL_SIDES)
            {
                for (uint i = 0; i < ns; i++)
                {
                    if (tex.FaceTextures[i] != null)
                    {
                        tex.FaceTextures[i].TextureID = textureID;
                    }
                }
                tex.DefaultTexture.TextureID = textureID;
                part.UpdateTexture(tex);
                return;
            }
        }
Exemple #2
0
 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
 {
     Primitive.TextureEntry tex = part.Shape.Textures;
     int ns = GetNumberOfSides(part);
     if (face >= 0 && face < ns)
     {
         Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
         texface.Rotation = (float)rotation;
         tex.FaceTextures[face] = texface;
         part.UpdateTexture(tex);
         return;
     }
     if (face == ScriptBaseClass.ALL_SIDES)
     {
         for (int i = 0; i < ns; i++)
         {
             if (tex.FaceTextures[i] != null)
             {
                 tex.FaceTextures[i].Rotation = (float)rotation;
             }
         }
         tex.DefaultTexture.Rotation = (float)rotation;
         part.UpdateTexture(tex);
         return;
     }
 }
Exemple #3
0
 public void SetFullBright(SceneObjectPart part, int face, bool bright)
 {
      Primitive.TextureEntry tex = part.Shape.Textures;
      if (face >= 0 && face < GetNumberOfSides(part))
      {
          tex.CreateFace((uint) face);
          tex.FaceTextures[face].Fullbright = bright;
          part.UpdateTexture(tex);
          return;
      }
      else if (face == ScriptBaseClass.ALL_SIDES)
      {
          for (uint i = 0; i < GetNumberOfSides(part); i++)
          {
              if (tex.FaceTextures[i] != null)
              {
                  tex.FaceTextures[i].Fullbright = bright;
              }
          }
          tex.DefaultTexture.Fullbright = bright;
          part.UpdateTexture(tex);
          return;
      }
  }
Exemple #4
0
 protected void SetAlpha(SceneObjectPart part, double alpha, int face)
 {
     Primitive.TextureEntry tex = part.Shape.Textures;
     Color4 texcolor;
     if (face >= 0 && face < GetNumberOfSides(part))
     {
         texcolor = tex.CreateFace((uint)face).RGBA;
         texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
         tex.FaceTextures[face].RGBA = texcolor;
         part.UpdateTexture(tex);
     }
     else if (face == ScriptBaseClass.ALL_SIDES)
     {
         for (int i = 0; i < GetNumberOfSides(part); i++)
         {
             if (tex.FaceTextures[i] != null)
             {
                 texcolor = tex.FaceTextures[i].RGBA;
                 texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
                 tex.FaceTextures[i].RGBA = texcolor;
             }
         }
         texcolor = tex.DefaultTexture.RGBA;
         texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
         tex.DefaultTexture.RGBA = texcolor;
         part.UpdateTexture(tex);
     }
     part.ScheduleUpdate(PrimUpdateFlags.FullUpdate);
 }
Exemple #5
0
        public void SetTexGen(SceneObjectPart part, int face,int style)
        {
            Primitive.TextureEntry tex = part.Shape.Textures;
            MappingType textype;
            textype = MappingType.Default;
            if (style == (int)ScriptBaseClass.PRIM_TEXGEN_PLANAR)
                textype = MappingType.Planar;

            if (face >= 0 && face < GetNumberOfSides(part))
            {
                tex.CreateFace((uint) face);
                tex.FaceTextures[face].TexMapType = textype;
                part.UpdateTexture(tex);
                return;
            }
            else if (face == ScriptBaseClass.ALL_SIDES)
            {
                for (uint i = 0; i < GetNumberOfSides(part); i++)
                {
                    if (tex.FaceTextures[i] != null)
                    {
                        tex.FaceTextures[i].TexMapType = textype;
                    }
                    tex.DefaultTexture.TexMapType = textype;
                }
                part.UpdateTexture(tex);
                return;
            }
        }
Exemple #6
0
        public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
        {

            Shininess sval = new Shininess();

            switch (shiny)
            {
            case 0:
                sval = Shininess.None;
                break;
            case 1:
                sval = Shininess.Low;
                break;
            case 2:
                sval = Shininess.Medium;
                break;
            case 3:
                sval = Shininess.High;
                break;
            default:
                sval = Shininess.None;
                break;
            }

            Primitive.TextureEntry tex = part.Shape.Textures;
            if (face >= 0 && face < GetNumberOfSides(part))
            {
                tex.CreateFace((uint) face);
                tex.FaceTextures[face].Shiny = sval;
                tex.FaceTextures[face].Bump = bump;
                part.UpdateTexture(tex);
                return;
            }
            else if (face == ScriptBaseClass.ALL_SIDES)
            {
                for (uint i = 0; i < GetNumberOfSides(part); i++)
                {
                    if (tex.FaceTextures[i] != null)
                    {
                        tex.FaceTextures[i].Shiny = sval;
                        tex.FaceTextures[i].Bump = bump;;
                    }
                    tex.DefaultTexture.Shiny = sval;
                    tex.DefaultTexture.Bump = bump;
                }
                part.UpdateTexture(tex);
                return;
            }
        }
 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
 {
     Primitive.TextureEntry tex = part.Shape.Textures;
     Color4 texcolor;
     if (face >= 0 && face < GetNumberOfSides(part))
     {
         texcolor = tex.CreateFace((uint)face).RGBA;
         texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
         texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
         texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
         tex.FaceTextures[face].RGBA = texcolor;
         part.UpdateTexture(tex);
         return;
     }
     else if (face == ScriptBaseClass.ALL_SIDES)
     {
         for (uint i = 0; i < GetNumberOfSides(part); i++)
         {
             if (tex.FaceTextures[i] != null)
             {
                 texcolor = tex.FaceTextures[i].RGBA;
                 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
                 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
                 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
                 tex.FaceTextures[i].RGBA = texcolor;
             }
             texcolor = tex.DefaultTexture.RGBA;
             texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
             texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
             texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
             tex.DefaultTexture.RGBA = texcolor;
         }
         part.UpdateTexture(tex);
         return;
     }
 }
Exemple #8
0
 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
 {
     Primitive.TextureEntry tex = part.Shape.Textures;
     if (face >= 0 && face < GetNumberOfSides(part))
     {
         Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
         texface.OffsetU = (float)u;
         texface.OffsetV = (float)v;
         tex.FaceTextures[face] = texface;
         part.UpdateTexture(tex);
         return;
     }
     if (face == ScriptBaseClass.ALL_SIDES)
     {
         for (int i = 0; i < GetNumberOfSides(part); i++)
         {
             if (tex.FaceTextures[i] != null)
             {
                 tex.FaceTextures[i].OffsetU = (float)u;
                 tex.FaceTextures[i].OffsetV = (float)v;
             }
         }
         tex.DefaultTexture.OffsetU = (float)u;
         tex.DefaultTexture.OffsetV = (float)v;
         part.UpdateTexture(tex);
         return;
     }
 }
        private void SetTexture(SceneObjectPart part, UUID textureID, int face)
        {
            Primitive.TextureEntry tex = part.Shape.Textures;

            if (face >= 0 && face < MAX_SIDES)
            {
                Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
                texface.TextureID = textureID;
                tex.FaceTextures[face] = texface;
                part.UpdateTexture(tex);
                return;
            }
            else if (face == ALL_SIDES)
            {
                for (uint i = 0; i < MAX_SIDES; i++)
                {
                    if (tex.FaceTextures[i] != null)
                    {
                        tex.FaceTextures[i].TextureID = textureID;
                    }
                }
                tex.DefaultTexture.TextureID = textureID;
                part.UpdateTexture(tex);
                return;
            }
        }
Exemple #10
0
        protected void SetAlpha(SceneObjectPart part, double alpha, int face)
        {
            Primitive.TextureEntry tex = part.Shape.Textures;
            Color4 texcolor;
            if (face >= 0 && face < GetNumberOfSides(part))
            {
                texcolor = tex.CreateFace((uint)face).RGBA;
                texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
                tex.FaceTextures[face].RGBA = texcolor;
                part.UpdateTexture(tex);
                return;
            }
            else if (face == ScriptBaseClass.ALL_SIDES)
            {
                for (int i = 0; i < GetNumberOfSides(part); i++)
                {
                    if (tex.FaceTextures[i] != null)
                    {
                        texcolor = tex.FaceTextures[i].RGBA;
                        texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
                        tex.FaceTextures[i].RGBA = texcolor;
                    }
                }

                // In some cases, the default texture can be null, eg when every face
                // has a unique texture
                if (tex.DefaultTexture != null)
                {
                    texcolor = tex.DefaultTexture.RGBA;
                    texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
                    tex.DefaultTexture.RGBA = texcolor;
                }
                
                part.UpdateTexture(tex);
                return;
            }
        }
 private void SetGlow(SceneObjectPart part, float glow, int face)
 {
     Primitive.TextureEntry tex = part.Shape.Textures;
     if (face >= 0 && face < MAX_SIDES)
     {
         tex.CreateFace((uint)face);
         tex.FaceTextures[face].Glow = glow;
         part.UpdateTexture(tex);
         return;
     }
     else if (face == ALL_SIDES)
     {
         for (uint i = 0; i < MAX_SIDES; i++)
         {
             if (tex.FaceTextures[i] != null)
             {
                 tex.FaceTextures[i].Glow = glow;
             }
             tex.DefaultTexture.Glow = glow;
         }
         part.UpdateTexture(tex);
         return;
     }
 }
 private void SetFullBright(SceneObjectPart part, bool bright, int face)
 {
     Primitive.TextureEntry tex = part.Shape.Textures;
     if (face >= 0 && face < MAX_SIDES)
     {
         tex.CreateFace((uint)face);
         tex.FaceTextures[face].Fullbright = bright;
         part.UpdateTexture(tex);
         return;
     }
     else if (face == ALL_SIDES)
     {
         for (uint i = 0; i < MAX_SIDES; i++)
         {
             if (tex.FaceTextures[i] != null)
             {
                 tex.FaceTextures[i].Fullbright = bright;
             }
         }
         tex.DefaultTexture.Fullbright = bright;
         part.UpdateTexture(tex);
         return;
     }
 }
 private void SetColor(SceneObjectPart part, Vector3 rgb, int face)
 {
     float r = rgb.X;
     float g = rgb.Y;
     float b = rgb.Z;
     Primitive.TextureEntry tex = part.Shape.Textures;
     Color4 texcolor;
     if (face >= 0 && face < MAX_SIDES)
     {
         texcolor = tex.CreateFace((uint)face).RGBA;
         texcolor.R = Util.Clip(r, 0.0f, 1.0f);
         texcolor.G = Util.Clip(g, 0.0f, 1.0f);
         texcolor.B = Util.Clip(b, 0.0f, 1.0f);
         tex.FaceTextures[face].RGBA = texcolor;
         part.UpdateTexture(tex);
         return;
     }
     else if (face == ALL_SIDES)
     {
         for (uint i = 0; i < MAX_SIDES; i++)
         {
             if (tex.FaceTextures[i] != null)
             {
                 texcolor = tex.FaceTextures[i].RGBA;
                 texcolor.R = Util.Clip(r, 0.0f, 1.0f);
                 texcolor.G = Util.Clip(g, 0.0f, 1.0f);
                 texcolor.B = Util.Clip(b, 0.0f, 1.0f);
                 tex.FaceTextures[i].RGBA = texcolor;
             }
             texcolor = tex.DefaultTexture.RGBA;
             texcolor.R = Util.Clip(r, 0.0f, 1.0f);
             texcolor.G = Util.Clip(g, 0.0f, 1.0f);
             texcolor.B = Util.Clip(b, 0.0f, 1.0f);
             tex.DefaultTexture.RGBA = texcolor;
         }
         part.UpdateTexture(tex);
         return;
     }
 }
 private void SetAlpha(SceneObjectPart part, float alpha, int face)
 {
     Primitive.TextureEntry tex = part.Shape.Textures;
     Color4 texcolor;
     if (face >= 0 && face < MAX_SIDES)
     {
         texcolor = tex.CreateFace((uint)face).RGBA;
         texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
         tex.FaceTextures[face].RGBA = texcolor;
         part.UpdateTexture(tex);
         return;
     }
     else if (face == ALL_SIDES)
     {
         for (int i = 0; i < MAX_SIDES; i++)
         {
             if (tex.FaceTextures[i] != null)
             {
                 texcolor = tex.FaceTextures[i].RGBA;
                 texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
                 tex.FaceTextures[i].RGBA = texcolor;
             }
         }
         texcolor = tex.DefaultTexture.RGBA;
         texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
         tex.DefaultTexture.RGBA = texcolor;
         part.UpdateTexture(tex);
         return;
     }
 }
        /// <summary>
        /// Assign a single material value.  Based on the values passed we'll either set (or clear) the materials for a SOP.
        /// </summary>
        /// <param name="sop">The SOP being affected.</param>
        /// <param name="face">The face to assign, or -1 if the default texture is being set.</param>
        /// <param name="id">The ID assigned to this material.  Setting a Zero UUID clears it.</param>
        /// <param name="material">If not null, the material to set.  Otherwise we are clearing.</param>
        private void AssignSingleMaterial(SceneObjectPart sop, int face, OSDMap matData)
        {
            UUID id = UUID.Zero;

            // If there is a material being set, see if we've seen it before.
            // If not we'll add it to the Shape RenderMaterials and the region cache
            if (matData != null)
            {
                RenderMaterial material = RenderMaterial.FromOSD(matData);
                id = sop.Shape.RenderMaterials.AddMaterial(material);
                m_scene.EventManager.TriggerRenderMaterialAddedToPrim(sop, id, material);

                m_log.DebugFormat("[RenderMaterials]: SOP {0}, Face {1}, Adding RenderMaterial {2}", 
                    sop.LocalId, face, material.ToString());
            }

            // If the new material is replacing one lets record it so we can clean up
            UUID oldMaterialID = UUID.Zero;

            /// Get a copy of the texture entry so we can make changes.
            var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);

            // Set the Material ID in the TextureEntry. If face is ALL_SIDES then
            // set the default entry, otherwise fetch the face and set it there.
            if (face < 0)
            {
                oldMaterialID = te.DefaultTexture.MaterialID;
                te.DefaultTexture.MaterialID = id;
            }
            else
            {
                var faceEntry = te.CreateFace((uint)face);
                oldMaterialID = faceEntry.MaterialID;
                faceEntry.MaterialID = id;
            }

            // Update the texture entry which will force an update to connected clients
            sop.UpdateTexture(te);

            // If the material has changed and it wasn't previously Zero 
            // Deallocate the old value if its not in use and signal the change
            if ((oldMaterialID != id) && 
                (oldMaterialID != UUID.Zero))
            {
                var currentMaterialIDs = sop.Shape.GetMaterialIDs();
                if (currentMaterialIDs.Contains(oldMaterialID) == false)
                {
                    if (sop.Shape.RenderMaterials.ContainsMaterial(oldMaterialID) == true)
                        sop.Shape.RenderMaterials.RemoveMaterial(oldMaterialID);

                    m_scene.EventManager.TriggerRenderMaterialRemovedFromPrim(sop, oldMaterialID);
                }
            }
        }