Exemplo n.º 1
0
        void network_NewConnection(NetworkLevel2Connection net2con, ConnectionInfo connectioninfo)
        {
            LogFile.WriteLine("client connected to server");
            waitingforserverconnection = false;

            InitializePlayermovement();

            myavatar = new Avatar();
            worldstorage.AddEntity(myavatar);

            new NetworkInterfaces.WorldControl_ClientProxy(rpc, connectioninfo.Connection)
            .RequestResendWorld();
        }
Exemplo n.º 2
0
        public void Restore(Stream stream, Uri projecturi)
        //public void Restore( StringReader stringreader, Uri projecturi )
        {
            WorldModel worldmodel = MetaverseClient.GetInstance().worldstorage;

            // note to self: should make these types a publisher/subscriber thing
            //XmlSerializer serializer = new XmlSerializer( typeof( World ), new Type[]{
            //  typeof( Avatar ),
//                typeof( FractalSplineCylinder ),
//              typeof( FractalSplineRing ),
//            typeof( FractalSplineBox ),
//          typeof( FractalSplineTorus ),
//        typeof( FractalSplinePrism ),
//      typeof( FractalSplineTube )
            //    } );
            //DialogHelpers.ShowInfoMessage( null, serializer.Deserialize(filestream).GetType().ToString());
            ProjectFileController.GetInstance().SetProjectPath(projecturi);

            StreamReader sr       = new StreamReader(stream);
            string       contents = sr.ReadToEnd();

            sr.Close();
            StringReader stringreader = new StringReader(contents);

            OsmpXmlSerializer.GetInstance().RegisterType(typeof(World));
            World world = (World)OsmpXmlSerializer.GetInstance().Deserialize(stringreader);

            stringreader.Close();
            //World world = (World)serializer.Deserialize( stream );

            worldmodel.Clear();
            foreach (Entity entity in world.Entities)
            {
                if (entity.GetType() != typeof(Avatar))
                {
                    LogFile.WriteLine("WorldPersistToXml, restoring: " + entity);
                    worldmodel.AddEntity(entity);
                }
            }
            if (world.TerrainModel.HeightmapFilename != "")
            {
                HeightMapPersistence.GetInstance().Load(world.TerrainModel.HeightmapFilename);
            }
            worldmodel.terrainmodel.texturestagesarray = world.TerrainModel.texturestagesarray;
            LogFile.WriteLine(worldmodel);
            worldmodel.terrainmodel.MinHeight = world.TerrainModel.MinHeight;
            worldmodel.terrainmodel.MaxHeight = world.TerrainModel.MaxHeight;
            worldmodel.terrainmodel.OnTerrainModified();
        }
Exemplo n.º 3
0
        public int Init( IConfigSource commandlineConfig, IClientControllers controllers )
        {
            Type type = Type.GetType( "OSMP.ObjectReplicationClientToServer" );
            LogFile.WriteLine( "type: [" + type + "] " + type.AssemblyQualifiedName );
            //System.Environment.Exit( 0 );

            Tao.DevIl.Il.ilInit();
               	Tao.DevIl.Ilu.iluInit();

            config = Config.GetInstance();

            string serverip = commandlineConfig.Configs["CommandLineArgs"].GetString( "serverip", config.ServerIPAddress );
            int port = commandlineConfig.Configs["CommandLineArgs"].GetInt( "serverport", config.ServerPort );

            network = new NetworkLevel2Controller();
            network.NewConnection += new Level2NewConnectionHandler(network_NewConnection);

            network.ConnectAsClient(serverip, port);

            rpc = new RpcController(network);
            netreplicationcontroller = new NetReplicationController(rpc);

            renderer = RendererFactory.GetInstance();
            renderer.Tick += new OSMP.TickHandler( MainLoop );
            renderer.Init();

            worldstorage = new WorldModel(netreplicationcontroller);
            worldview = new WorldView( worldstorage );
            playermovement = PlayerMovement.GetInstance();

            InitializePlayermovement();

            myavatar = new Avatar();
            worldstorage.AddEntity(myavatar);

               controllers.Plugin.LoadClientPlugins();
            if (!commandlineConfig.Configs["CommandLineArgs"].Contains("nochat" ))
            {
                LoadChat();
            }

            if( commandlineConfig.Configs["CommandLineArgs"].Contains("url" ) )
            {
            string url = commandlineConfig.Configs["CommandLineArgs"].GetString("url" );
                LogFile.WriteLine( "url: " +  url);

                if (url.StartsWith( "osmp://" ))
                {
                    targettoload = "http://" + url.Substring( "osmp://".Length );
                    LogFile.WriteLine( "target: " + targettoload );
                }
                else
                {
                    targettoload = url;
                }
            }

            renderer.StartMainLoop();

            return 0;
        }
Exemplo n.º 4
0
        public int Init(IConfigSource commandlineConfig, IClientControllers controllers)
        {
            Type type = Type.GetType("OSMP.ObjectReplicationClientToServer");

            LogFile.WriteLine("type: [" + type + "] " + type.AssemblyQualifiedName);
            //System.Environment.Exit( 0 );

            Tao.DevIl.Il.ilInit();
            Tao.DevIl.Ilu.iluInit();

            config = Config.GetInstance();

            string serverip = commandlineConfig.Configs["CommandLineArgs"].GetString("serverip", config.ServerIPAddress);
            int    port     = commandlineConfig.Configs["CommandLineArgs"].GetInt("serverport", config.ServerPort);

            network = new NetworkLevel2Controller();
            network.NewConnection += new Level2NewConnectionHandler(network_NewConnection);

            network.ConnectAsClient(serverip, port);

            rpc = new RpcController(network);
            netreplicationcontroller = new NetReplicationController(rpc);

            renderer       = RendererFactory.GetInstance();
            renderer.Tick += new OSMP.TickHandler(MainLoop);
            renderer.Init();

            worldstorage   = new WorldModel(netreplicationcontroller);
            worldview      = new WorldView(worldstorage);
            playermovement = PlayerMovement.GetInstance();

            InitializePlayermovement();

            myavatar = new Avatar();
            worldstorage.AddEntity(myavatar);


            controllers.Plugin.LoadClientPlugins();
            if (!commandlineConfig.Configs["CommandLineArgs"].Contains("nochat"))
            {
                LoadChat();
            }

            if (commandlineConfig.Configs["CommandLineArgs"].Contains("url"))
            {
                string url = commandlineConfig.Configs["CommandLineArgs"].GetString("url");
                LogFile.WriteLine("url: " + url);

                if (url.StartsWith("osmp://"))
                {
                    targettoload = "http://" + url.Substring("osmp://".Length);
                    LogFile.WriteLine("target: " + targettoload);
                }
                else
                {
                    targettoload = url;
                }
            }

            renderer.StartMainLoop();

            return(0);
        }