Exemplo n.º 1
0
        public void LoadClientPlugins()
        {
            LoadGlobalPlugins();

            UIEntityPropertiesDialog.GetInstance();
            Editing3d.GetInstance();
            SelectionController.GetInstance();
            AssignTextureHandler.GetInstance();
            AssignColorHandler.GetInstance();
            WorldPersistToXml.GetInstance();

            ImportExportPrimBlender.GetInstance();

            EntityDelete.GetInstance();


            //SimpleCube.Register();  // SimpleCube and SimpleCone are for testing primarily
            //SimpleCone.Register();

            FractalSplineBox.Register();
            FractalSplinePrism.Register();
            FractalSplineCylinder.Register();
            FractalSplineTube.Register();
            FractalSplineRing.Register();
            FractalSplineTorus.Register();

            //WorldView.GetInstance();

            //plugins.Add(new DrawAxes());
            FrustrumCulling.GetInstance();

            ServerInfo.GetInstance();
            ConnectToServerDialog.GetInstance();

            MainTerrainWindow.GetInstance();
            BrushEffectController.GetInstance().Register(new RaiseLower());
            BrushEffectController.GetInstance().Register(new FixedHeight());
            BrushEffectController.GetInstance().Register(new Flatten());
            BrushEffectController.GetInstance().Register(new PaintTexture());
            BrushShapeController.GetInstance().Register(new RoundBrush());
            BrushShapeController.GetInstance().Register(new SquareBrush());
            EditController.GetInstance();
            plugins.Add(new CurrentEditSpot());

            // add allowed serialization/deserialization types (security measure)
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(Prim));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(Vector3));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(Rot));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(Vector2));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(TerrainModel));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(Color));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(MapTextureStageModel));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(FractalSplineBox));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(FractalSplineCylinder));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(FractalSplinePrim));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(FractalSplinePrism));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(FractalSplineRing));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(FractalSplineTorus));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(FractalSplineTube));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(Avatar));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(EntityGroup));
            OsmpXmlSerializer.GetInstance().RegisterType(typeof(Entity));

            MetaverseClient.GetInstance().worldstorage.terrainmodel.NewMap();

            DumpLogfile.GetInstance();
            HelpAbout.GetInstance();
            KeyHandlerQuit.GetInstance();
        }
Exemplo n.º 2
0
        public void TestGeneralBinaryPackerFunctionality()
        {
            byte[]    bytearray = new byte[1024];
            int       position  = 0;
            TestClass testclass = new TestClass();

            testclass.booleanvaluetrue = true;
            testclass.charvalue        = 'C';
            testclass.doublevalue      = 123.4567890;
            testclass.intvalue         = 1234567890;
            testclass.Country          = "Spain";
            testclass.name             = "Test class name";
            testclass.indexes          = new int[] { 5, 1, 4, 2, 3 };
            testclass.childclass       = new ChildClass();
            testclass.childclass.name  = "name inside child class";

            BinaryPacker bp = new BinaryPacker();

            //Write several objects into the buffer
            bp.WriteValueToBuffer(bytearray, ref position, testclass);
            bp.WriteValueToBuffer(bytearray, ref position, "The quick brown fox.");
            bp.WriteValueToBuffer(bytearray, ref position, "Rain in Spain.");

            bp.PackObjectUsingSpecifiedAttributes(bytearray, ref position, testclass, new Type[] { typeof(AttributePack) });

            byte[] bytearraytowrite = Encoding.UTF8.GetBytes("Hello world");
            bp.WriteValueToBuffer(bytearray, ref position, bytearraytowrite);


            FractalSplineBox box = new FractalSplineBox();

            box.name = "Test box";


            box.pos = new Vector3(1, 123.123, 150.150);

            bp.PackObjectUsingSpecifiedAttributes(bytearray, ref position, box, new Type[] { typeof(Replicate) });

            position = 0;

            //verify all the items we put in
            TestClass outputobject = (TestClass) new BinaryPacker().ReadValueFromBuffer(bytearray, ref position, typeof(TestClass));

            string error = "Trouble unpacking TestClass from BinaryPacker";

            Assert.AreEqual(true, outputobject.booleanvaluetrue, error);
            Assert.AreEqual('C', outputobject.charvalue, error);
            Assert.AreEqual(123.4567890, outputobject.doublevalue, error);
            Assert.AreEqual(1234567890, outputobject.intvalue, error);
            Assert.AreEqual("Spain", outputobject.Country, error);
            Assert.AreEqual("Test class name", outputobject.name, error);
            Assert.AreEqual(5, outputobject.indexes.Length, error);
            Assert.AreEqual(5, outputobject.indexes[0], error);
            Assert.AreEqual(1, outputobject.indexes[1], error);
            Assert.AreEqual(4, outputobject.indexes[2], error);
            Assert.AreEqual(2, outputobject.indexes[3], error);
            Assert.AreEqual(3, outputobject.indexes[4], error);
            Assert.AreEqual("name inside child class", outputobject.childclass.name, error);


            string sout = (string)new BinaryPacker().ReadValueFromBuffer(bytearray, ref position, typeof(string));

            Assert.AreEqual("The quick brown fox.", sout, "Could not unpack string");

            sout = (string)new BinaryPacker().ReadValueFromBuffer(bytearray, ref position, typeof(string));
            Assert.AreEqual("Rain in Spain.", sout, "Could not unpack second string");

            outputobject = new TestClass();
            bp.UnpackIntoObjectUsingSpecifiedAttributes(bytearray, ref position, outputobject, new Type[] { typeof(AttributePack) });
            Assert.AreEqual(null, outputobject.name, "Error in value of unset value in attribute packing");              // should be blank, because name member has a AttributePack attribute
            Assert.AreEqual("Spain", outputobject.Country, "Error in value of set value in attribute packing");          //Country does have an AttributePack attribute

            bytearraytowrite = (byte[])new BinaryPacker().ReadValueFromBuffer(bytearray, ref position, typeof(byte[]));
            Assert.AreEqual("Hello world", Encoding.UTF8.GetString(bytearraytowrite), "Error in unpacking UTF8");
            FractalSplineBox boxobject = new FractalSplineBox();

            new BinaryPacker().UnpackIntoObjectUsingSpecifiedAttributes(bytearray, ref position, boxobject, new Type[] { typeof(Replicate) });
            Assert.AreEqual("Test box", boxobject.name, "Error in unpacking FractelSplineBox name");
            Assert.AreEqual(new Vector3(1, 123.123, 150.150), box.pos, "Error in unpacking FractelSplineBox position");
        }