Beispiel #1
0
        public void TestGroupSerializationDeserialization()
        {
            var sop1 = SceneUtil.RandomSOP("Root", 1);
            var sop2 = SceneUtil.RandomSOP("Child1", 2);
            var sop3 = SceneUtil.RandomSOP("Child2", 3);

            SceneObjectGroup group = new SceneObjectGroup(sop1);

            group.AddPart(sop2);
            group.AddPart(sop3);

            SceneObjectGroup deserGroup = null;
            string           grpBytes   = null;

            Assert.DoesNotThrow(() =>
            {
                grpBytes = SceneObjectSerializer.ToXml2Format(group, true);
            });

            Assert.NotNull(grpBytes);

            Assert.DoesNotThrow(() =>
            {
                deserGroup = SceneObjectSerializer.FromXml2Format(grpBytes);
            });

            CompareObjects comp = new CompareObjects();

            comp.CompareStaticFields     = false;
            comp.CompareStaticProperties = false;
            comp.ElementsToIgnore        = PrimCompareIgnoreList;

            Assert.IsTrue(comp.Compare(group, deserGroup), comp.DifferencesString);
        }
Beispiel #2
0
        public void TestNullMediaEntryIsNotAnError()
        {
            var sop1 = SceneUtil.RandomSOP("Root", 1);
            var sop2 = SceneUtil.RandomSOP("Child1", 2);
            var sop3 = SceneUtil.RandomSOP("Child2", 3);

            sop1.Shape.Media    = new PrimitiveBaseShape.PrimMedia(3);
            sop1.Shape.Media[0] = null;
            sop1.Shape.Media[1] = new MediaEntry();
            sop1.Shape.Media[2] = null;

            SceneObjectGroup group = new SceneObjectGroup(sop1);

            group.AddPart(sop2);
            group.AddPart(sop3);

            SceneObjectGroup deserGroup = null;
            string           grpBytes   = null;

            Assert.DoesNotThrow(() =>
            {
                grpBytes = SceneObjectSerializer.ToXml2Format(group, true);
            });

            Assert.NotNull(grpBytes);

            Assert.DoesNotThrow(() =>
            {
                deserGroup = SceneObjectSerializer.FromXml2Format(grpBytes);
            });
        }
Beispiel #3
0
        public void TestRenderMaterialsSerialization()
        {
            var sop1 = SceneUtil.RandomSOP("Root", 1);
            var sop2 = SceneUtil.RandomSOP("Child1", 2);
            var sop3 = SceneUtil.RandomSOP("Child2", 3);

            var mat1 = new RenderMaterial(UUID.Random(), UUID.Random());
            var mat2 = new RenderMaterial(UUID.Random(), UUID.Random());

            sop1.Shape.RenderMaterials.AddMaterial(mat1);
            sop2.Shape.RenderMaterials.AddMaterial(mat2);

            SceneObjectGroup group = new SceneObjectGroup(sop1);

            group.AddPart(sop2);
            group.AddPart(sop3);

            SceneObjectGroup deserGroup = null;
            string           grpBytes   = null;

            Assert.DoesNotThrow(() =>
            {
                grpBytes = SceneObjectSerializer.ToXml2Format(group, true);
            });

            Assert.NotNull(grpBytes);

            Assert.DoesNotThrow(() =>
            {
                deserGroup = SceneObjectSerializer.FromXml2Format(grpBytes);
            });

            var newsop1 = deserGroup.GetChildPart(1);
            var newsop2 = deserGroup.GetChildPart(2);
            var newsop3 = deserGroup.GetChildPart(3);

            Assert.That(sop1.Shape.RenderMaterials, Is.EqualTo(newsop1.Shape.RenderMaterials));
            Assert.That(sop2.Shape.RenderMaterials, Is.EqualTo(newsop2.Shape.RenderMaterials));
            Assert.That(sop3.Shape.RenderMaterials, Is.EqualTo(newsop3.Shape.RenderMaterials));
        }
Beispiel #4
0
        public void TestPrimitiveBaseShapeDeserialization()
        {
            var shape      = SceneUtil.MockPrmitiveBaseShape();;
            var serializer = new XmlSerializer(shape.GetType());

            Assert.NotNull(serializer);

            string shapeBytes = null;

            Assert.DoesNotThrow(() =>
            {
                using (StringWriter stringwriter = new System.IO.StringWriter())
                {
                    serializer.Serialize(stringwriter, shape);
                    shapeBytes = stringwriter.ToString();
                }
            });

            Assert.NotNull(shapeBytes);

            PrimitiveBaseShape deserShape = null;

            Assert.DoesNotThrow(() =>
            {
                using (StringReader stringReader = new System.IO.StringReader(shapeBytes))
                {
                    deserShape = (PrimitiveBaseShape)serializer.Deserialize(stringReader);
                }
            });

            CompareObjects comp = new CompareObjects();

            comp.CompareStaticFields     = false;
            comp.CompareStaticProperties = false;
            Assert.IsTrue(comp.Compare(shape, deserShape), comp.DifferencesString);
        }
Beispiel #5
0
        public static SceneObjectPart RandomSOP(string name, uint localId)
        {
            OpenSim.Framework.PrimitiveBaseShape shape = MockPrmitiveBaseShape();

            SceneObjectPart part = new SceneObjectPart(UUID.Zero, shape, new Vector3(1, 2, 3), new Quaternion(4, 5, 6, 7), Vector3.Zero, false);

            part.Name                    = name;
            part.Description             = "Desc";
            part.AngularVelocity         = SceneUtil.RandomVector();
            part.BaseMask                = 0x0876;
            part.Category                = 10;
            part.ClickAction             = 5;
            part.CollisionSound          = UUID.Random();
            part.CollisionSoundVolume    = 1.1f;
            part.CreationDate            = OpenSim.Framework.Util.UnixTimeSinceEpoch();
            part.CreatorID               = UUID.Random();
            part.EveryoneMask            = 0x0543;
            part.Flags                   = PrimFlags.CameraSource | PrimFlags.DieAtEdge;
            part.GroupID                 = UUID.Random();
            part.GroupMask               = 0x0210;
            part.LastOwnerID             = UUID.Random();
            part.LinkNum                 = 4;
            part.LocalId                 = localId;
            part.Material                = 0x1;
            part.MediaUrl                = "http://bam";
            part.NextOwnerMask           = 0x0234;
            part.CreatorID               = UUID.Random();
            part.ObjectFlags             = 10101;
            part.OwnerID                 = UUID.Random();
            part.OwnerMask               = 0x0567;
            part.OwnershipCost           = 5;
            part.ParentID                = 0202;
            part.ParticleSystem          = new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, };
            part.PassTouches             = true;
            part.PhysicalAngularVelocity = SceneUtil.RandomVector();
            part.RegionHandle            = 1234567;
            part.RegionID                = UUID.Random();
            part.RotationOffset          = SceneUtil.RandomQuat();
            part.SalePrice               = 42;
            part.SavedAttachmentPoint    = 6;
            part.SavedAttachmentPos      = SceneUtil.RandomVector();
            part.SavedAttachmentRot      = SceneUtil.RandomQuat();
            part.ScriptAccessPin         = 87654;
            part.SerializedPhysicsData   = new byte[] { 0xA, 0xB, 0xC, 0xD, 0xE, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, };
            part.ServerWeight            = 3.0f;
            part.StreamingCost           = 2.0f;
            part.SitName                 = "Sitting";
            part.SitTargetOrientation    = SceneUtil.RandomQuat();
            part.SitTargetPosition       = SceneUtil.RandomVector();
            part.Sound                   = UUID.Random();
            part.SoundGain               = 3.4f;
            part.SoundOptions            = 9;
            part.SoundRadius             = 10.3f;
            part.Text                    = "Test";
            part.TextColor               = System.Drawing.Color.FromArgb(1, 2, 3, 4);
            part.TextureAnimation        = new byte[] { 0xA, 0xB, 0xC, 0xD, 0xE, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD };
            part.TouchName               = "DoIt";
            part.UUID                    = UUID.Random();
            part.Velocity                = SceneUtil.RandomVector();
            part.FromItemID              = UUID.Random();

            return(part);
        }
Beispiel #6
0
        public static OpenSim.Framework.PrimitiveBaseShape MockPrmitiveBaseShape()
        {
            var shape = new OpenSim.Framework.PrimitiveBaseShape();

            shape.ExtraParams    = new byte[] { 0xA, 0x9, 0x8, 0x7, 0x6, 0x5 };
            shape.FlexiDrag      = 0.3f;
            shape.FlexiEntry     = true;
            shape.FlexiForceX    = 1.0f;
            shape.FlexiForceY    = 2.0f;
            shape.FlexiForceZ    = 3.0f;
            shape.FlexiGravity   = 10.0f;
            shape.FlexiSoftness  = 1;
            shape.FlexiTension   = 999.4f;
            shape.FlexiWind      = 9292.33f;
            shape.HollowShape    = OpenSim.Framework.HollowShape.Square;
            shape.LightColorA    = 0.3f;
            shape.LightColorB    = 0.22f;
            shape.LightColorG    = 0.44f;
            shape.LightColorR    = 0.77f;
            shape.LightCutoff    = 0.4f;
            shape.LightEntry     = true;
            shape.LightFalloff   = 7474;
            shape.LightIntensity = 0.0f;
            shape.LightRadius    = 10.0f;
            shape.Media          = new OpenSim.Framework.PrimitiveBaseShape.PrimMedia();
            shape.Media.New(2);
            shape.Media[0] = new MediaEntry
            {
                AutoLoop              = true,
                AutoPlay              = true,
                AutoScale             = true,
                AutoZoom              = true,
                ControlPermissions    = MediaPermission.All,
                Controls              = MediaControls.Standard,
                CurrentURL            = "bam.com",
                EnableAlterntiveImage = true,
                EnableWhiteList       = false,
                Height  = 1,
                HomeURL = "anotherbam.com",
                InteractOnFirstClick = true,
                InteractPermissions  = MediaPermission.Group,
                WhiteList            = new string[] { "yo mamma" },
                Width = 5
            };
            shape.Media[1] = new MediaEntry
            {
                AutoLoop              = true,
                AutoPlay              = true,
                AutoScale             = true,
                AutoZoom              = true,
                ControlPermissions    = MediaPermission.All,
                Controls              = MediaControls.Standard,
                CurrentURL            = "kabam.com",
                EnableAlterntiveImage = true,
                EnableWhiteList       = true,
                Height  = 1,
                HomeURL = "anotherbam.com",
                InteractOnFirstClick = true,
                InteractPermissions  = MediaPermission.Group,
                WhiteList            = new string[] { "ur mamma" },
                Width = 5
            };

            shape.PathBegin             = 3;
            shape.PathCurve             = 127;
            shape.PathEnd               = 10;
            shape.PathRadiusOffset      = 127;
            shape.PathRevolutions       = 2;
            shape.PathScaleX            = 50;
            shape.PathScaleY            = 100;
            shape.PathShearX            = 33;
            shape.PathShearY            = 44;
            shape.PathSkew              = 126;
            shape.PathTaperX            = 110;
            shape.PathTaperY            = 66;
            shape.PathTwist             = 99;
            shape.PathTwistBegin        = 3;
            shape.PCode                 = 3;
            shape.PreferredPhysicsShape = PhysicsShapeType.Prim;
            shape.ProfileBegin          = 77;
            shape.ProfileCurve          = 5;
            shape.ProfileEnd            = 7;
            shape.ProfileHollow         = 9;
            shape.ProfileShape          = OpenSim.Framework.ProfileShape.IsometricTriangle;
            shape.ProjectionAmbiance    = 0.1f;
            shape.ProjectionEntry       = true;
            shape.ProjectionFocus       = 3.4f;
            shape.ProjectionFOV         = 4.0f;
            shape.ProjectionTextureUUID = UUID.Random();
            shape.Scale                 = SceneUtil.RandomVector();
            shape.SculptEntry           = true;
            shape.SculptTexture         = UUID.Random();
            shape.SculptType            = 40;
            shape.VertexCount           = 1;
            shape.HighLODBytes          = 2;
            shape.MidLODBytes           = 3;
            shape.LowLODBytes           = 4;
            shape.LowestLODBytes        = 5;
            return(shape);
        }