Пример #1
0
        public void Update(CollisionGrid map, float dt)
        {
            CameraMotionSettings cms = MovementSettings;

            Scroll(camController.ScrollX, camController.ScrollZ, cms, dt);
            Orbit(camController.Yaw, camController.Pitch, cms, dt);
            int z;

            camController.GetZoom(out z);
            Zoom(z, dt);
            camTarget.X = MathHelper.Clamp(camTarget.X, 0, map.size.X);
            camTarget.Z = MathHelper.Clamp(camTarget.Z, 0, map.size.Y);
            //camOrigin.Y = Grey.Vox.Region.HEIGHT * 0.5f; // MathHelper.Clamp(camOrigin.Y, 0, Grey.Vox.Region.HEIGHT);
            camTarget.Y = map.HeightAt(new Vector2(camOrigin.X, camTarget.Z));

            bool reset;

            camController.GetResetDefault(out reset);
            if (reset)
            {
                Yaw       = INITIAL_CAMERA_YAW;
                Pitch     = INITIAL_CAMERA_PITCH;
                ZoomRatio = INITIAL_ZOOM_RATIO;
            }

            camOrigin = Tweens.LINEAR.GetValue(camOrigin, camTarget, TWEEN_FACTOR * dt);
            RecalculateView(map, MathHelper.Lerp(cms.MinDistance, cms.MaxDistance, ZoomRatio));
        }
Пример #2
0
 // Clamp The Geometry To The Heightmap
 public static void CollideHeightmap(ICollidable o, CollisionGrid map)
 {
     if (!o.IsStatic)
     {
         o.Height = map.HeightAt(o.Center);
     }
 }
Пример #3
0
        // View Matrix Recalculation
        public void RecalculateView(CollisionGrid map, float dist)
        {
            Matrix rot =
                Matrix.CreateRotationZ(Pitch) *
                Matrix.CreateRotationY(Yaw);

            Vector3 back = Vector3.TransformNormal(Vector3.UnitX, rot);

            back.Normalize();

            Vector3 eye = CamOrigin + back * dist;

            //if(map != null) {
            //    float h = map.HeightAt(eye.X, eye.Z);
            //    if(eye.Y < h)
            //        eye.Y = h + EYE_HEIGHT_OFFSET;
            //}
            View = Matrix.CreateLookAt(eye, CamOrigin, Vector3.Up);
        }