LookAtCameraTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Rendering3D.Tests.Cameras LookAtCameraTests

Namespace: DeltaEngine.Rendering3D.Tests.Cameras
Assembly: DeltaEngine.Rendering3D.Tests (in DeltaEngine.Rendering3D.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class LookAtCameraTests : TestWithMocksOrVisually

The LookAtCameraTests type exposes the following members.

Constructors

  NameDescription
Public methodLookAtCameraTests
Initializes a new instance of the LookAtCameraTests class
Top
Methods

  NameDescription
Public methodActivateShakeEffect
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCenterOfScreenWithLookAtCameraPointsToTarget
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodLookAtEntity3D
Public methodOverZoomTowardTheTarget
Public methodPositionToTargetDistance
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Public methodRenderGrid
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Public methodRotateCamera90DegreesAroundZAxis
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodWorldToScreenPoint
Public methodZoomOutwardTheTarget
Public methodZoomTowardTheTarget
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, ApproveFirstFrameScreenshot]
public void RenderGrid()
{
    CreateLookAtCamera(new Vector3D(0.0f, -5.0f, 5.0f), Vector3D.Zero);
    new Grid3D(new Size(9));
}
[Test, CloseAfterFirstFrame]
public void PositionToTargetDistance()
{
    var camera = CreateLookAtCamera(Vector3D.UnitZ * 5.0f, Vector3D.Zero);
    Assert.AreEqual(5.0f, camera.Position.Length - camera.Target.Length);
}
[Test, CloseAfterFirstFrame]
public void RotateCamera90DegreesAroundZAxis()
{
    var camera = CreateLookAtCamera(Vector3D.UnitY, Vector3D.Zero);
    Assert.AreEqual(Vector3D.Zero, camera.YawPitchRoll);
    camera.YawPitchRoll = new Vector3D(90.0f, 0.0f, 0.0f);
    Assert.IsTrue(camera.Position.IsNearlyEqual(-Vector3D.UnitX));
    Assert.AreEqual(Vector3D.Zero, camera.Target);
}
[Test, CloseAfterFirstFrame]
public void LookAtEntity3D()
{
    var entity = new Entity3D(Vector3D.One * 5.0f, Quaternion.Identity);
    var camera = CreateLookAtCamera(Vector3D.Zero, entity);
    Assert.AreEqual(camera.Target, entity.Position);
}
[Test, CloseAfterFirstFrame]
public void ZoomTowardTheTarget()
{
    var camera = CreateLookAtCamera(Vector3D.UnitX * 2.0f, Vector3D.Zero);
    camera.Zoom(1.0f);
    Assert.AreEqual(Vector3D.UnitX, camera.Position);
}
[Test, CloseAfterFirstFrame]
public void ZoomOutwardTheTarget()
{
    var camera = CreateLookAtCamera(Vector3D.UnitX, Vector3D.Zero);
    camera.Zoom(-1.0f);
    Assert.AreEqual(Vector3D.UnitX * 2.0f, camera.Position);
}
[Test, CloseAfterFirstFrame]
public void OverZoomTowardTheTarget()
{
    var camera = CreateLookAtCamera(Vector3D.UnitX * 3.0f, Vector3D.Zero);
    camera.Zoom(100.0f);
    Assert.IsTrue(camera.Position.IsNearlyEqual(Vector3D.Zero));
}
[Test, CloseAfterFirstFrame]
public void WorldToScreenPoint()
{
    var camera = CreateLookAtCamera(Vector3D.One, Vector3D.Zero);
    var point = camera.WorldToScreenPoint(Vector3D.Zero);
    Assert.AreEqual(Vector2D.Half, point);
}
[Test, CloseAfterFirstFrame]
public void CenterOfScreenWithLookAtCameraPointsToTarget()
{
    VerifyScreenCenterIsTarget(new Vector3D(3.0f, 3.0f, 3.0f), new Vector3D(1.0f, 1.0f, 2.0f));
    VerifyScreenCenterIsTarget(new Vector3D(1.0f, 4.0f, 1.5f), new Vector3D(-2.9f, 0.0f, 2.5f));
    VerifyScreenCenterIsTarget(new Vector3D(-1.0f, -4.0f, 2.5f), new Vector3D(2.9f, -1.0f, 3.5f));
}
[Test]
public void ActivateShakeEffect()
{
    var camera = CreateLookAtCamera(new Vector3D(0.0f, -5.0f, 5.0f), Vector3D.Zero);
    new Grid3D(new Size(10));
    camera.Start<CameraShakingUpdater>();
    new Command(() => { CameraShakingUpdater.isShaking = true; }).Add(new KeyTrigger(Key.Space));
}
See Also