Ejemplo n.º 1
0
        public void Update(float dt)
        {
            ViewportUsingKeyboard = Viewport.Update(Window, dt);

            if (_loadingTask != null && _loadingTask.IsCompleted)
            {
                _loadingTask = null;
                if (_renderMesh != null)
                {
                    var box = _renderMesh.GetBounds();
                    Viewport.FrameBox(box);

                    var dim       = box.GetDimensions();
                    var mindim    = Math.Min(dim.X, Math.Min(dim.Y, dim.Z));
                    var maxdim    = Math.Max(dim.X, Math.Max(dim.Y, dim.Z));
                    var basespeed = (float)Math.Sqrt(mindim / 3.0f);
                    Viewport._worldView.CameraMoveSpeed     = basespeed;
                    Viewport._worldView.CameraMoveSpeedSlow = basespeed / 10.0f;
                    Viewport._worldView.CameraMoveSpeedFast = basespeed * 10.0f;

                    Viewport.FarClip  = Math.Max(10.0f, maxdim * 10.0f);
                    Viewport.NearClip = Math.Max(0.001f, maxdim / 10000.0f);
                }

                if (_flverhandle.IsLoaded && _flverhandle.Get() != null)
                {
                    if (_flverhandle.TryLock())
                    {
                        var r = _flverhandle.Get();
                        if (r.Flver != null)
                        {
                            _universe.LoadFlver(r.Flver, _renderMesh, _currentModel);
                        }
                        _flverhandle.Unlock();
                    }
                }
            }
        }