add serialization (use yaml-cpp), add stencil to render outline for selected entity, add play mode, UUIDS, add orthographic and perspective camera, add editor camera

This commit is contained in:
2025-12-09 16:30:53 +08:00
parent 3ffb4cc449
commit dc53f9517a
49 changed files with 2801 additions and 796 deletions

View File

@ -0,0 +1,36 @@
using Prism;
namespace Example
{
public class BasicController : Entity
{
public float Speed;
public void OnCreate()
{
}
public void OnUpdate(float ts)
{
Mat4 transform = GetTransform();
Vec3 translation = transform.Translation;
float speed = Speed * ts;
if (Input.IsKeyPressed(KeyCode.Up))
translation.Y += speed;
else if (Input.IsKeyPressed(KeyCode.Down))
translation.Y -= speed;
if (Input.IsKeyPressed(KeyCode.Right))
translation.X += speed;
else if (Input.IsKeyPressed(KeyCode.Left))
translation.X -= speed;
transform.Translation = translation;
SetTransform(transform);
}
}
}

View File

@ -10,7 +10,7 @@ namespace Example
{
public class MapGenerator : Entity
{
// TODO: [EditorSlider("MapWidth Custom Name", 2, 0, 1024)]
// [EditorSlider("MapWidth Custom Name", 2, 0, 1024)]
public int MapWidth = 128;
public int MapHeight = 128;
public int Octaves = 4;
@ -20,6 +20,8 @@ namespace Example
public Vec2 Offset = new Vec2(13.4f, 6.26f);
public float NoiseScale = 0.5f;
public float speed = 0.0f;
public void GenerateMap()
{
// float[,] noiseMap = Noise.GenerateNoiseMap(MapWidth, MapHeight, NoiseScale);
@ -76,7 +78,19 @@ namespace Example
void OnUpdate(float ts)
{
Mat4 transform = GetTransform();
Vec3 translation = transform.Translation;
translation.Y += ts * speed;
if (Input.IsKeyPressed(KeyCode.Space))
{
Console.WriteLine("Space Pressed");
translation.Y -= 10.0f;
}
transform.Translation = translation;
SetTransform(transform);
}

View File

@ -6,8 +6,13 @@ namespace Example
{
public class Script : Entity
{
public float VerticalSpeed = 5.0f;
public float Speed = 5.0f;
public float Rotation = 0.0f;
public Vec3 Velocity;
public float SinkRate = 1.0f;
public void OnCreate()
{
Console.WriteLine("Script.OnCreate");
@ -16,11 +21,20 @@ namespace Example
public void OnUpdate(float ts)
{
Rotation += ts;
Mat4 transform = GetTransform();
Vec3 translation = transform.Translation;
float speed = Speed * ts;
translation.X += Velocity.X * ts;
translation.Y += Velocity.Y * ts;
translation.Z += Velocity.Z * ts;
translation.Y -= SinkRate * ts;
/*
if (Input.IsKeyPressed(KeyCode.Up))
translation.Y += speed;
else if (Input.IsKeyPressed(KeyCode.Down))
@ -29,6 +43,7 @@ namespace Example
translation.X += speed;
else if (Input.IsKeyPressed(KeyCode.Left))
translation.X -= speed;
*/
transform.Translation = translation;
SetTransform(transform);

27
ExampleApp/Src/Sink.cs Normal file
View File

@ -0,0 +1,27 @@
using Prism;
namespace Example
{
class Sink : Entity
{
public float SinkSpeed = 1.0f;
void OnCreate()
{
}
void OnUpdate(float ts)
{
Mat4 transform = GetTransform();
Vec3 translation = transform.Translation;
translation.Y -= SinkSpeed * ts;
transform.Translation = translation;
SetTransform(transform);
}
}
}