update for CSM implementation
parent
a92a8de50a
commit
cf2e6d7ce6
2
Kav
2
Kav
|
@ -1 +1 @@
|
|||
Subproject commit 3540e098d55e3b8edc4e78504487576e07537ec8
|
||||
Subproject commit 8cb760171745a7bc75ff56d88f0773dc55e2f2e3
|
|
@ -1,15 +1,20 @@
|
|||
using Encompass;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace KavTest.Components
|
||||
{
|
||||
public struct CameraComponent : IComponent
|
||||
public struct PerspectiveCameraComponent : IComponent
|
||||
{
|
||||
public Matrix Projection { get; }
|
||||
public float FieldOfView { get; }
|
||||
public float AspectRatio { get; }
|
||||
public float NearPlane { get; }
|
||||
public float FarPlane { get; }
|
||||
|
||||
public CameraComponent(Matrix projection)
|
||||
public PerspectiveCameraComponent(float fieldOfView, float aspectRatio, float nearPlane, float farPlane)
|
||||
{
|
||||
Projection = projection;
|
||||
FieldOfView = fieldOfView;
|
||||
AspectRatio = aspectRatio;
|
||||
NearPlane = nearPlane;
|
||||
FarPlane = farPlane;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@ using KavTest.Messages;
|
|||
|
||||
namespace KavTest.Engines
|
||||
{
|
||||
[Reads(typeof(CameraComponent), typeof(ArcballTransformComponent))]
|
||||
[Reads(typeof(PerspectiveCameraComponent), typeof(ArcballTransformComponent))]
|
||||
[Receives(typeof(MoveCameraMessage), typeof(RotateCameraMessage))]
|
||||
[Writes(typeof(ArcballTransformComponent))]
|
||||
public class CameraEngine : Engine
|
||||
{
|
||||
public override void Update(double dt)
|
||||
{
|
||||
if (SomeComponent<CameraComponent>())
|
||||
if (SomeComponent<PerspectiveCameraComponent>())
|
||||
{
|
||||
var cameraEntity = ReadEntity<CameraComponent>();
|
||||
var cameraEntity = ReadEntity<PerspectiveCameraComponent>();
|
||||
var arcballTransformComponent = GetComponent<ArcballTransformComponent>(cameraEntity);
|
||||
|
||||
var transform = arcballTransformComponent.ArcballTransform;
|
||||
|
|
|
@ -6,7 +6,7 @@ using Microsoft.Xna.Framework.Input;
|
|||
|
||||
namespace KavTest.Engines
|
||||
{
|
||||
[Reads(typeof(CameraComponent))]
|
||||
[Reads(typeof(PerspectiveCameraComponent))]
|
||||
[Sends(
|
||||
typeof(MoveCameraMessage),
|
||||
typeof(RotateCameraMessage)
|
||||
|
@ -47,9 +47,9 @@ namespace KavTest.Engines
|
|||
|
||||
if (Game.IsActive)
|
||||
{
|
||||
if (SomeComponent<CameraComponent>())
|
||||
if (SomeComponent<PerspectiveCameraComponent>())
|
||||
{
|
||||
var cameraEntity = ReadEntity<CameraComponent>();
|
||||
var cameraEntity = ReadEntity<PerspectiveCameraComponent>();
|
||||
SendMessage(new RotateCameraMessage(cameraEntity, -mouseState.X, -mouseState.Y));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace KavTest
|
|||
}
|
||||
|
||||
WorldBuilder.SendMessage(new DirectionalLightSpawnMessage(
|
||||
Quaternion.CreateFromAxisAngle(Vector3.Right, Microsoft.Xna.Framework.MathHelper.PiOver2 + 0.1f),
|
||||
Quaternion.CreateFromAxisAngle(Vector3.Right, Microsoft.Xna.Framework.MathHelper.PiOver4),
|
||||
Color.GhostWhite,
|
||||
0.1f
|
||||
));
|
||||
|
@ -132,13 +132,11 @@ namespace KavTest
|
|||
0
|
||||
)
|
||||
));
|
||||
WorldBuilder.SetComponent(cameraEntity, new CameraComponent(
|
||||
Matrix.CreatePerspectiveFieldOfView(
|
||||
Microsoft.Xna.Framework.MathHelper.PiOver4,
|
||||
16f / 9f,
|
||||
0.1f,
|
||||
100f
|
||||
)
|
||||
WorldBuilder.SetComponent(cameraEntity, new PerspectiveCameraComponent(
|
||||
Microsoft.Xna.Framework.MathHelper.PiOver4,
|
||||
16f / 9f,
|
||||
0.01f,
|
||||
100f
|
||||
));
|
||||
|
||||
World = WorldBuilder.Build();
|
||||
|
|
|
@ -75,20 +75,30 @@ namespace KavTest.Renderers
|
|||
|
||||
public SceneRenderer(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
Renderer = new Kav.Renderer(graphicsDevice, graphicsDevice.PresentationParameters.BackBufferWidth, graphicsDevice.PresentationParameters.BackBufferHeight);
|
||||
Renderer = new Kav.Renderer(
|
||||
graphicsDevice,
|
||||
graphicsDevice.PresentationParameters.BackBufferWidth,
|
||||
graphicsDevice.PresentationParameters.BackBufferHeight,
|
||||
3
|
||||
);
|
||||
}
|
||||
|
||||
public override void Render()
|
||||
{
|
||||
if (SomeComponent<CameraComponent>())
|
||||
if (SomeComponent<PerspectiveCameraComponent>())
|
||||
{
|
||||
var cameraEntity = ReadEntity<CameraComponent>();
|
||||
var cameraEntity = ReadEntity<PerspectiveCameraComponent>();
|
||||
var transformComponent = GetComponent<ArcballTransformComponent>(cameraEntity);
|
||||
var cameraComponent = GetComponent<CameraComponent>(cameraEntity);
|
||||
var cameraComponent = GetComponent<PerspectiveCameraComponent>(cameraEntity);
|
||||
|
||||
var camera = new Kav.Camera(
|
||||
transformComponent.ArcballTransform.TransformMatrix,
|
||||
cameraComponent.Projection
|
||||
var camera = new Kav.PerspectiveCamera(
|
||||
transformComponent.ArcballTransform.Position,
|
||||
transformComponent.ArcballTransform.Forward,
|
||||
transformComponent.ArcballTransform.Up,
|
||||
cameraComponent.FieldOfView,
|
||||
cameraComponent.AspectRatio,
|
||||
cameraComponent.NearPlane,
|
||||
cameraComponent.FarPlane
|
||||
);
|
||||
|
||||
// if (SomeComponent<DirectionalLightComponent>())
|
||||
|
|
39
README.md
39
README.md
|
@ -1,38 +1,3 @@
|
|||
# Encompass-FNA-Template
|
||||
# KavTest
|
||||
|
||||
Template (and VSCode build tasks) for developing a cross-platform multi-target .NET Framework and .NET Core game using Encompass and FNA.
|
||||
|
||||
## Features
|
||||
|
||||
- Includes project boilerplate code
|
||||
- Build tasks for both .NET Framework and .NET Core side by side
|
||||
- Press F5 to build and debug in-editor with Core Debugger
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Git](https://git-scm.com/)
|
||||
- [Git for Windows](https://gitforwindows.org/) if on Windows
|
||||
- [Visual Studio Code](https://code.visualstudio.com/)
|
||||
- [VSCode C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp)
|
||||
- [.NET Core SDK](https://dotnet.microsoft.com/download/dotnet-core)
|
||||
- [.NET Framework SDK](https://dotnet.microsoft.com/download/visual-studio-sdks) or [Mono](https://www.mono-project.com/)
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
- Make sure you have Git Bash from Git for Windows if you are on Windows
|
||||
- Download this repository
|
||||
- Run `install.sh`
|
||||
- Move the newly created project directory wherever you want
|
||||
|
||||
## Usage
|
||||
|
||||
- Open the project directory in VSCode
|
||||
- Press Ctrl-Shift-B to open the build tasks menu
|
||||
- `Framework` tasks use .NET Framework or Mono to build and run
|
||||
- `Core` tasks use .NET Core to build and run
|
||||
- Press F5 to build and debug with Core Debugger
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
Thanks to Andrew Russell and Caleb Cornett's FNA templates for a starting point for this template.
|
||||
Test project to develop Kav.
|
||||
|
|
Loading…
Reference in New Issue