protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     Effect.World = World;
     Thing.Draw(Effect);
     return true;
 }
Beispiel #2
0
        public ShadowMap(
            VisionContent vContent,
            Camera camera,
            int width,
            int height,
            int nearPlane = 1,
            int farPlane = 200)
        {
            _graphicsDevice = vContent.GraphicsDevice;
            RealCamera = camera;

            ShadowDepthTarget = RenderTarget2D.New(_graphicsDevice, width, height, PixelFormat.R16G16.Float);

            _spriteBatch = new SpriteBatch(_graphicsDevice);
            _shadowBlurEffect = vContent.LoadPlainEffect("ShadowEffects/Blur");
            _shadowBlurTarg = RenderTarget2D.New(_graphicsDevice, width, height, PixelFormat.R16G16.Float);

            ShadowNearPlane = nearPlane;
            ShadowFarPlane = farPlane;
            Camera = new Camera(
                new Vector2(width, height),
                Vector3.Zero,
                Vector3.Up,
                ShadowNearPlane,
                ShadowFarPlane);
            UpdateProjection(50, 50);
        }
Beispiel #3
0
 public virtual void DrawReflection(
     Vector4? clipPlane,
     Camera camera)
 {
     if(Effect!=null)
         Effect.ClipPlane = clipPlane;
     Draw(camera, DrawingReason.ReflectionMap);
     Children.ForEach(cd => cd.DrawReflection(clipPlane, camera));
 }
Beispiel #4
0
 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     if (drawingReason == DrawingReason.ShadowDepthMap)
         return false;
     camera.UpdateEffect(Effect);
     Effect.World = Matrix.Scaling(1, 0.5f, 1)*Matrix.Translation(camera.Position);
     _sphere.Draw(Effect);
     return true;
 }
Beispiel #5
0
 public bool Draw(
     Camera camera,
     DrawingReason drawingReason = DrawingReason.Normal,
     ShadowMap shadowMap = null)
 {
     if (Effect != null)
     {
         Effect.SetTechnique(drawingReason);
         Effect.SetShadowMapping(drawingReason != DrawingReason.ShadowDepthMap ? shadowMap : null);
         var didPaint = draw(camera, drawingReason, shadowMap);
         Effect.SetShadowMapping(null);
         if (!didPaint)
             return false;
     }
     Children.ForEach(cd => cd.Draw(camera, drawingReason, shadowMap));
     return true;
 }
Beispiel #6
0
        private MoveCamera(Camera camera, float totalTime, float unitsPerSecond, Func<Vector3> toLookAt, params Vector3[] followPath)
        {
            _camera = camera;

            var list = followPath.ToList();
            if (Vector3.DistanceSquared(list.First(), _camera.Position) > 0.1f || followPath.Length < 2)
                list.Insert(0, _camera.Position);
            qwerty(list, toLookAt());
            _path = list.ToArray();

            _totalTime = MathUtil.IsZero(unitsPerSecond)
                ? totalTime
                : (0.1f + pathLength())/unitsPerSecond;

            _toLookAt = toLookAt;
            _fromLookAt = camera.Target;
        }
Beispiel #7
0
 protected abstract bool draw(
     Camera camera,
     DrawingReason drawingReason,
     ShadowMap shadowMap);
Beispiel #8
0
 public virtual void Update(Camera camera, GameTime gameTime)
 {
     Children.ForEach(cd => cd.Update(camera, gameTime));
 }
Beispiel #9
0
 public static MoveCamera UnitsPerSecond(Camera camera, float unitsPerSecond, Vector3 toLookAt, params Vector3[] followPath)
 {
     return new MoveCamera(camera, 0, unitsPerSecond, () => toLookAt, followPath);
 }
Beispiel #10
0
 public static MoveCamera TotalTime(Camera camera, float totalTime, Vector3 toLookAt, params Vector3[] followPath)
 {
     return new MoveCamera(camera, totalTime, 0, () => toLookAt, followPath);
 }