public void T001_ToFromBinaryTest()
        {
            RenderMaterial mat = new RenderMaterial ();
            RenderMaterials mats = new RenderMaterials ();
            String key = UUID.Random().ToString();
            mats.Materials.Add(key, mat);

            byte[] bytes = mats.ToBytes ();
            RenderMaterials newmats = RenderMaterials.FromBytes(bytes, 0);
            RenderMaterial newmat = newmats.Materials[key];
            Assert.That (mat, Is.EqualTo(newmat));
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (obj.GetType() != typeof(RenderMaterials))
            {
                return(false);
            }

            RenderMaterials other = (RenderMaterials)obj;

            if (this.Materials.Count != other.Materials.Count)
            {
                return(false);
            }

            foreach (var kvp in this.Materials)
            {
                RenderMaterial thisValue = kvp.Value;
                RenderMaterial otherValue;
                if (!other.Materials.TryGetValue(kvp.Key, out otherValue))
                {
                    return(false);
                }
                if (thisValue.Equals(otherValue) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Construct a PrimitiveBaseShape object from a OpenMetaverse.Primitive object
        /// </summary>
        /// <param name="prim"></param>
        public PrimitiveBaseShape(Primitive prim)
        {
//            m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID);

            PCode = (byte)prim.PrimData.PCode;
            ExtraParams = new byte[1];

            State = prim.PrimData.State;
            PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin);
            PathEnd = Primitive.PackEndCut(prim.PrimData.PathEnd);
            PathScaleX = Primitive.PackPathScale(prim.PrimData.PathScaleX);
            PathScaleY = Primitive.PackPathScale(prim.PrimData.PathScaleY);
            PathShearX = (byte)Primitive.PackPathShear(prim.PrimData.PathShearX);
            PathShearY = (byte)Primitive.PackPathShear(prim.PrimData.PathShearY);
            PathSkew = Primitive.PackPathTwist(prim.PrimData.PathSkew);
            ProfileBegin = Primitive.PackBeginCut(prim.PrimData.ProfileBegin);
            ProfileEnd = Primitive.PackEndCut(prim.PrimData.ProfileEnd);
            Scale = prim.Scale;
            PathCurve = (byte)prim.PrimData.PathCurve;
            ProfileCurve = (byte)prim.PrimData.ProfileCurve;
            ProfileHollow = Primitive.PackProfileHollow(prim.PrimData.ProfileHollow);
            PathRadiusOffset = Primitive.PackPathTwist(prim.PrimData.PathRadiusOffset);
            PathRevolutions = Primitive.PackPathRevolutions(prim.PrimData.PathRevolutions);
            PathTaperX = Primitive.PackPathTaper(prim.PrimData.PathTaperX);
            PathTaperY = Primitive.PackPathTaper(prim.PrimData.PathTaperY);
            PathTwist = Primitive.PackPathTwist(prim.PrimData.PathTwist);
            PathTwistBegin = Primitive.PackPathTwist(prim.PrimData.PathTwistBegin);

            Textures = prim.Textures;   // also updates TextureEntry (and TextureEntryBytes)

            if (prim.Sculpt != null)
            {
                SculptEntry = (prim.Sculpt.Type != OpenMetaverse.SculptType.None);
                SculptData = prim.Sculpt.GetBytes();
                SculptTexture = prim.Sculpt.SculptTexture;
                SculptType = (byte)prim.Sculpt.Type;
            }
            else
            {
                SculptType = (byte)OpenMetaverse.SculptType.None;
            }

            RenderMaterials = new RenderMaterials();
        }
        public PrimitiveBaseShape(bool noShape)
        {
            if (noShape)
                return;

            PCode = (byte)PCodeEnum.Primitive;
            ExtraParams = new byte[1];
            Textures = new Primitive.TextureEntry(DEFAULT_TEXTURE_ID);
            RenderMaterials = new RenderMaterials();
        }
 public RenderMaterials Copy()
 {
     return(RenderMaterials.FromBytes(this.ToBytes(), 0));
 }
示例#6
0
 public PrimitiveBaseShape()
 {
     SculptTexture = UUID.Zero;
     SculptData = new byte[0];
     PCode = (byte)PCodeEnum.Primitive;
     ExtraParams = new byte[1];
     Textures = new Primitive.TextureEntry(DEFAULT_TEXTURE_ID);
     RenderMaterials = new RenderMaterials();
 }
        private UUID ExtractMaterial(Guid matId, RenderMaterials mats)
        {
            byte[] osdBlob = m_assetResolver.ResolveAsset(matId);
            if (osdBlob != null)
            {
                OSD osd = OSDParser.DeserializeLLSDXml(osdBlob);
                return mats.AddMaterial(RenderMaterial.FromOSD(osd));
            }

            return UUID.Zero;
        }
        private Tuple<RenderMaterials, byte[]>  ExtractRenderMaterials(dynamic osPart)
        {
            var te = new Primitive.TextureEntry(osPart.Shape.TextureEntry, 0, osPart.Shape.TextureEntry.Length);
            var materialTextureIds = new List<Guid>();
            var mats = new RenderMaterials();

            if (te.DefaultTexture != null)
            {
                te.DefaultTexture.MaterialID = ExtractMaterial(te.DefaultTexture.MaterialID.Guid, mats);
            }

            foreach (Primitive.TextureEntryFace face in te.FaceTextures)
            {
                if (face != null)
                {
                    face.MaterialID = ExtractMaterial(face.MaterialID.Guid, mats);
                }
            }
            
            return new Tuple<RenderMaterials, byte[]>(mats, te.GetBytes());
        }