Beispiel #1
0
        void UpdateCamera()
        {
            PlayerMovement playermovement = PlayerMovement.GetInstance();

            if (bRoamingCameraEnabled)
            {
                camerapos = RoamingCameraPos;
                camerarot = RoamingCameraRot;
            }
            else if (viewpoint == Viewpoint.MouseLook)
            {
                camerapos = playermovement.avatarpos;
                camerarot =
                    mvMath.AxisAngle2Rot(mvMath.ZAxis, playermovement.avatarzrot * Math.PI / 180) *
                    mvMath.AxisAngle2Rot(mvMath.YAxis, playermovement.avataryrot * Math.PI / 180)
                ;
                //cameramatrix.applyRotate(-playermovement.avataryrot, 0f, 1f, 0f);
                //cameramatrix.applyRotate(-playermovement.avatarzrot, 0f, 0f, 1f);
                //cameramatrix.applyTranslate(-playermovement.avatarpos.x, -playermovement.avatarpos.y, -playermovement.avatarpos.z);
            }

            /*
             * else if (viewpoint == Viewpoint.BehindPlayer)
             * {
             * cameramatrix.applyRotate(-18f, 0f, 1f, 0f);
             *
             * // Vector3 V = new Vector3( 0, playermovement.avataryrot * mvMath.PiOver180, playermovement.avatarzrot * mvMath.PiOver180 );
             *
             * cameramatrix.applyTranslate(3.0f, 0.0f, -1.0f);
             *
             * cameramatrix.applyRotate(-(float)playermovement.avataryrot, 0f, 1f, 0f);
             * cameramatrix.applyRotate(-(float)playermovement.avatarzrot, 0f, 0f, 1f);
             *
             * cameramatrix.applyTranslate(-playermovement.avatarpos.x, -playermovement.avatarpos.y, -playermovement.avatarpos.z);
             * }
             * else if (viewpoint == Viewpoint.ThirdParty)
             * {
             * cameramatrix.applyRotate(-18f, 0f, 1f, 0f);
             * cameramatrix.applyRotate(-90f, 0f, 0f, 1f);
             *
             * cameramatrix.applyTranslate(0.0, -fThirdPartyViewZoom, fThirdPartyViewZoom / 3.0);
             * cameramatrix.applyRotate(-fThirdPartyViewRotate, 0f, 0f, 1f);
             * cameramatrix.applyTranslate(-playermovement.avatarpos.x, -playermovement.avatarpos.y, -playermovement.avatarpos.z);
             * }
             */
        }
Beispiel #2
0
        public void ApplyCamera()
        {
            UpdateCamera();

            // rotate so z axis is up, and x axis is forward

            PlayerMovement playermovement = PlayerMovement.GetInstance();

            GraphicsHelperGl g = new GraphicsHelperGl();

            g.Rotate(90, 0, 0, 1);
            g.Rotate(90, 0, 1, 0);

            Rot inversecamerarot = camerarot.Inverse();

            //inversecamerarot.Inverse();
            g.Rotate(inversecamerarot);
            //g.Rotate(camerarot);

            g.Translate(-camerapos);
        }
Beispiel #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);
        }