Tortuga
Tortua is an open source game engine built using C# dot net core 3.0
Prerequisites
- Dot Net Core 3.0
- Vulkan
- GlsLang Tools
- SDL2
- Open AL
- Bullet Physics Library
sudo apt install -y libopenal1 libsdl2-2.0-0 libvulkan1 glslang-tools libgdiplus
Using the package in your project
You can use nuget to install the package TortugaEngine
nuget install TortugaEngine
How to Run
git clone https://github.com/tortuga-foundation/tortuga.git
cd tortuga
dotnet restore tortuga.sln
dotnet build tortuga.sln
./Tortuga.Test/bin/Debug/netcoreapp3.0/Tortuga.Test.dll
Example
Sample Code:
//setup sdl input system
Engine.Instance.AddModule<Input.InputModule>();
//setup vulkan instance
Engine.Instance.AddModule<Graphics.GraphicsModule>();
//setup open al
Engine.Instance.AddModule<Audio.AudioModule>();
//create new scene
var scene = new Core.Scene();
Input.InputModule.OnApplicationClose += () => Engine.Instance.IsRunning = false;
//camera
Graphics.Camera mainCamera;
{
var entity = new Core.Entity();
mainCamera = await entity.AddComponent<Graphics.Camera>();
mainCamera.RenderTarget = Graphics.Camera.TypeOfRenderTarget.DeferredRendering;
scene.AddEntity(entity);
}
//mesh
{
var entity = new Core.Entity();
var transform = entity.GetComponent<Core.Transform>();
transform.Position = new Vector3(0, 0, -5);
var renderer = await entity.AddComponent<Graphics.Renderer>();
renderer.MeshData = await Graphics.Mesh.Load("Assets/Models/Sphere.obj");
renderer.MaterialData = await Graphics.Material.Load("Assets/Materials/Bricks.json");
scene.AddEntity(entity);
}
//light
{
var entity = new Core.Entity();
var light = await entity.AddComponent<Graphics.Light>();
scene.AddEntity(entity);
}
//user interface
{
var win = new UI.UiWindow();
win.Position = new Vector2(100, 100);
win.Scale = new Vector2(500, 500);
scene.AddUserInterface(win);
var windowContent = new UI.UiRenderable();
windowContent.RenderFromCamera = mainCamera;
windowContent.PositionXConstraint = new UI.PercentConstraint(0.0f);
windowContent.PositionYConstraint = new UI.PercentConstraint(0.0f);
windowContent.ScaleXConstraint = new UI.PercentConstraint(1.0f);
windowContent.ScaleYConstraint = new UI.PercentConstraint(1.0f);
win.Content.Add(windowContent);
}
//add systems to the scene
scene.AddSystem<Audio.AudioSystem>();
scene.AddSystem<Graphics.RenderingSystem>();
//load scene
Engine.Instance.LoadScene(scene);
//run main loop
await Engine.Instance.Run();
Material JSON
{
"Type": "Material",
"Value": {
"Pipeline": {
"RenderPass": {
"Count": 4,
"IsDepthEnabled": true
}
},
"Shaders": [
{
"Type": "ShaderFile",
"Value": {
"ShaderType": "Vertex",
"Data": "Assets/Shaders/Default/MRT.vert"
}
},
{
"Type": "ShaderFile",
"Value": {
"ShaderType": "Fragment",
"Data": "Assets/Shaders/Default/MRT.frag"
}
}
],
"DescriptorSets": [
{
"Type": "DescriptorSet",
"Value": {
"Name": "TEXTURES",
"Bindings": [
{
"Type": "DescriptorSetBinding",
"Value": {
"DescriptorType": "CombinedImageSampler",
"Stage": "Fragment",
"Data": {
"Type": "TexturePath",
"Value": "Assets/Images/Bricks/Color.jpg"
}
}
},
{
"Type": "DescriptorSetBinding",
"Value": {
"DescriptorType": "CombinedImageSampler",
"Stage": "Fragment",
"Data": {
"Type": "TexturePath",
"Value": "Assets/Images/Bricks/Normal.jpg"
}
}
},
{
"Type": "DescriptorSetBinding",
"Value": {
"DescriptorType": "CombinedImageSampler",
"Stage": "Fragment",
"Data": {
"Type": "TexturePathChannels",
"Value": {
"R": "Assets/Images/Bricks/Metal.jpg",
"G": "Assets/Images/Bricks/Roughness.jpg",
"B": "Assets/Images/Bricks/AmbientOclusion.jpg"
}
}
}
}
]
}
},
{
"Type": "DescriptorSet",
"Value": {
"Name": "MATERIAL",
"Bindings": [
{
"Type": "DescriptorSetBinding",
"Value": {
"DescriptorType": "UniformBuffer",
"Stage": "Vertex",
"Data": {
"Type": "Int32",
"Value": [
1
]
}
}
}
]
}
}
]
}
}