Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Examples/MinecraftClone/Minecraft.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
using ImGuiNET;

using Microsoft.Extensions.Logging;
using Minecraft.Terrain.Block;
using Minecraft.Terrain.Layers;

using SharpEngine.Core;
using SharpEngine.Core.Entities;
using SharpEngine.Core.Entities.Properties;
using SharpEngine.Core.Entities.UI;
using SharpEngine.Core.Entities.UI.Layouts;
using SharpEngine.Core.Enums;
using SharpEngine.Core.Interfaces;
using SharpEngine.Core.Numerics;
using SharpEngine.Core.Scenes;
using SharpEngine.Core.UI.Entities;
using SharpEngine.Core.UI.Entities.Layouts;
using SharpEngine.Core.Windowing;

using Silk.NET.Input;
using System;

Expand All @@ -32,7 +35,7 @@

private UIElement _uiElem;

private readonly Terrain.TerrainGenerator_New _terrain;

Check failure on line 38 in Examples/MinecraftClone/Minecraft.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unread private field '_terrain' or refactor the code to use its value.

See more on https://sonarcloud.io/project/issues?id=Av3boy_SharpEngine&issues=AaBxYjjA2zUHyXSZnaz9&open=AaBxYjjA2zUHyXSZnaz9&pullRequest=145
private readonly SceneNode _blocksNode;

/// <summary>
Expand Down Expand Up @@ -69,9 +72,19 @@
_input = new Input(Camera);
_inventory.Initialize();

_terrain.InitializeWorld();
// _terrain.InitializeWorld();

Check warning on line 75 in Examples/MinecraftClone/Minecraft.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this commented out code.

See more on https://sonarcloud.io/project/issues?id=Av3boy_SharpEngine&issues=AaBxYjjA2zUHyXSZnaz8&open=AaBxYjjA2zUHyXSZnaz8&pullRequest=145

InitializeUI();

// Test text renderer
var _textElem = new TextElement("text element")
{
Text = "Hello, World!",
Height = 200,
Color = new System.Numerics.Vector4(1, 1, 1, 1),
};

_uiElem.AddChild(_textElem);
}
catch (Exception ex)
{
Expand Down
4 changes: 3 additions & 1 deletion Examples/MinecraftClone/Minecraft.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -9,7 +9,9 @@
<ItemGroup>
<ProjectReference Include="..\..\SharpEngine.Core.DependencyInjection\SharpEngine.Core.DependencyInjection.csproj" />
<ProjectReference Include="..\..\SharpEngine.Core.ObjLoader\SharpEngine.Core.ObjLoader.csproj" />
<ProjectReference Include="..\..\SharpEngine.Core.UI\SharpEngine.Core.UI.csproj" />
<ProjectReference Include="..\..\SharpEngine.Core\SharpEngine.Core.csproj" />
<ProjectReference Include="..\..\SharpEngine.Text\SharpEngine.Core.UI.Text.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions Examples/MinecraftClone/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SharpEngine.Core;

using SharpEngine.Core.DependencyInjection;
using SharpEngine.Core.Entities.Views;
using SharpEngine.Core.Handlers;
using SharpEngine.Core.Interfaces;
using SharpEngine.Core.Renderers;
using SharpEngine.Core.Scenes;
using SharpEngine.Core.Windowing;
using System;
using SharpEngine.Core.UI.Renderers;

namespace Minecraft;

Expand Down
2 changes: 1 addition & 1 deletion Examples/MinecraftClone/Terrain/Block/BlockBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected BlockBase(Vector3 position, string name, string diffuseMapFile, string

private void Initialize(Vector3 position, string name, string diffuseMapFile, string specularMapFile, string vertShaderFile, string fragShaderFile)
{
var cube = PrimitiveFactory.Create(PrimitiveType.Cube, (SharpEngine.Core.Numerics.Vector3)position, diffuseMapFile, specularMapFile, vertShaderFile, fragShaderFile);
var cube = PrimitiveFactory.Create(PrimitiveType.Cube, position, diffuseMapFile, specularMapFile, vertShaderFile, fragShaderFile);
AssignProperties(cube, name);
}

Expand Down
8 changes: 4 additions & 4 deletions Examples/MinecraftClone/Terrain/Block/Dirt.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SharpEngine.Core._Resources;
using SharpEngine.Core.Extensions;
using SharpEngine.Core.Defaults;
using SharpEngine.Core.Numerics;
using SharpEngine.IO.Extensions;

namespace Minecraft.Terrain.Block;

Expand All @@ -16,8 +16,8 @@ internal class Dirt : BlockBase
/// <param name="name">The name of the block to initialize.</param>
public Dirt(Vector3 position, string name) : base(position, name, PathExtensions.GetAssemblyPath("Resources\\grass.jpg"),
PathExtensions.GetAssemblyPath("Resources\\container2_specular.png"),
Default.VertexShader,
Default.FragmentShader) { }
Defaults.VertexShader,
Defaults.FragmentShader) { }

/// <inheritdoc />
public override BlockId BlockId => BlockId.Dirt;
Expand Down
8 changes: 4 additions & 4 deletions Examples/MinecraftClone/Terrain/Block/Grass.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SharpEngine.Core._Resources;
using SharpEngine.Core.Extensions;
using SharpEngine.Core.Defaults;
using SharpEngine.Core.Numerics;
using SharpEngine.IO.Extensions;

namespace Minecraft.Terrain.Block;

Expand All @@ -13,8 +13,8 @@ internal class Grass : BlockBase
/// <param name="name">The name of the block to initialize.</param>
public Grass(Vector3 position, string name) : base(position, name, PathExtensions.GetAssemblyPath("Resources\\grass.jpg"),
PathExtensions.GetAssemblyPath("Resources\\container2_specular.png"),
Default.VertexShader,
Default.FragmentShader) { }
Defaults.VertexShader,
Defaults.FragmentShader) { }

/// <inheritdoc />
public override BlockId BlockId => BlockId.Grass;
Expand Down
6 changes: 3 additions & 3 deletions Examples/MinecraftClone/Terrain/Block/Iron.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using SharpEngine.Core._Resources;
using SharpEngine.Core.Extensions;
using SharpEngine.Core.Defaults;
using SharpEngine.Core.Numerics;
using SharpEngine.IO.Extensions;

namespace Minecraft.Terrain.Block;

internal class Iron : BlockBase
{
public Iron(Vector3 position, string name)
: base(position, name, DiffuseMap(), SpecularMap(), Default.VertexShader, Default.FragmentShader) { }
: base(position, name, DiffuseMap(), SpecularMap(), Defaults.VertexShader, Defaults.FragmentShader) { }

private static string DiffuseMap() => PathExtensions.GetAssemblyPath("Resources\\container2.png");
private static string SpecularMap() => PathExtensions.GetAssemblyPath("Resources\\container2_specular.png");
Expand Down
6 changes: 3 additions & 3 deletions Examples/MinecraftClone/Terrain/Block/Leaf.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using SharpEngine.Core._Resources;
using SharpEngine.Core.Extensions;
using SharpEngine.Core.Defaults;
using SharpEngine.Core.Numerics;
using SharpEngine.IO.Extensions;

namespace Minecraft.Terrain.Block;

internal class Leaf : BlockBase
{
public Leaf(Vector3 position, string name)
: base(position, name, DiffuseMap(), SpecularMap(), Default.VertexShader, Default.FragmentShader) { }
: base(position, name, DiffuseMap(), SpecularMap(), Defaults.VertexShader, Defaults.FragmentShader) { }

private static string DiffuseMap() => PathExtensions.GetAssemblyPath("Resources\\container2.png");
private static string SpecularMap() => PathExtensions.GetAssemblyPath("Resources\\container2_specular.png");
Expand Down
6 changes: 3 additions & 3 deletions Examples/MinecraftClone/Terrain/Block/Stone.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SharpEngine.Core._Resources;
using SharpEngine.Core.Extensions;
using SharpEngine.Core.Defaults;
using SharpEngine.Core.Numerics;
using SharpEngine.IO.Extensions;

namespace Minecraft.Terrain.Block;

Expand All @@ -15,7 +15,7 @@ internal class Stone : BlockBase
/// <param name="position">The position where the block is created.</param>
/// <param name="name">The name of the object in the scene.</param>
public Stone(Vector3 position, string name)
: base(position, name, DiffuseMap(), SpecularMap(), Default.VertexShader, Default.FragmentShader) { }
: base(position, name, DiffuseMap(), SpecularMap(), Defaults.VertexShader, Defaults.FragmentShader) { }

private static string DiffuseMap() => PathExtensions.GetAssemblyPath("Resources\\container2.png");
private static string SpecularMap() => PathExtensions.GetAssemblyPath("Resources\\container2_specular.png");
Expand Down
6 changes: 3 additions & 3 deletions Examples/MinecraftClone/Terrain/Block/Wood.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using SharpEngine.Core._Resources;
using SharpEngine.Core.Extensions;
using SharpEngine.Core.Defaults;
using SharpEngine.Core.Numerics;
using SharpEngine.IO.Extensions;

namespace Minecraft.Terrain.Block;

internal class Wood : BlockBase
{
public Wood(Vector3 position, string name)
: base(position, name, DiffuseMap(), SpecularMap(), Default.VertexShader, Default.FragmentShader) { }
: base(position, name, DiffuseMap(), SpecularMap(), Defaults.VertexShader, Defaults.FragmentShader) { }

private static string DiffuseMap() => PathExtensions.GetAssemblyPath("Resources\\container2.png");
private static string SpecularMap() => PathExtensions.GetAssemblyPath("Resources\\container2_specular.png");
Expand Down
4 changes: 2 additions & 2 deletions Examples/MultipleWindows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ private static void EnqueueWindow()
var window = CreateWindow();

// Prefer the higher-level Window event to avoid wiring low-level input handlers.
window.InputManager.OnButtonMouseDown += (mouse, button) => Mouse_Click(mouse, (MouseButton)button, mouse.Position);
window.InputManager.OnButtonMouseDown += (mouse, button) => Mouse_Click(mouse, button, (SharpEngine.Core.Numerics.Vector2)mouse.Position);

if (window.InputManager.Context is not null)
_inputContexts.Add(window.InputManager.Context);

_windows.Add(window);
}

private static void Mouse_Click(IMouse args1, MouseButton arg2, System.Numerics.Vector2 arg3)
private static void Mouse_Click(IMouse args1, MouseButton arg2, SharpEngine.Core.Numerics.Vector2 arg3)
=> _windowQueue.Enqueue(WindowOptions.Default);
}
6 changes: 3 additions & 3 deletions Examples/Tutorial 4.1 - Model Loading/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using SharpEngine.Core._Resources;
using SharpEngine.Core.Extensions;
using SharpEngine.Core.Components.Properties.Meshes;
using SharpEngine.Core.ObjLoader.Loaders.ObjLoader;
using Shader = SharpEngine.Core.Shaders.Shader;
Expand All @@ -13,6 +11,8 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using SharpEngine.IO.Extensions;
using SharpEngine.Core.Defaults;

namespace Tutorial
{
Expand Down Expand Up @@ -82,7 +82,7 @@ private static void OnLoad()

Gl = GL.GetApi(window);

Shader = new Shader(Gl, PathExtensions.GetAssemblyPath("shader2.vert"), Default.LightShader, "test");
Shader = new Shader(Gl, PathExtensions.GetAssemblyPath("shader2.vert"), Defaults.LightShader, "test");
Texture = new Texture(Gl, "silk.png");

if (ObjLoaderFactory.Load(Gl, "D:\\Untitled2.obj", out var model))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -7,7 +7,6 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\SharpEngine.Core.ObjLoader\SharpEngine.Core.ObjLoader.csproj" />
<ProjectReference Include="..\..\SharpEngine.Core.Components\SharpEngine.Core.Components.csproj" />
<ProjectReference Include="..\..\SharpEngine.Core.ObjLoader\SharpEngine.Core.ObjLoader.csproj" />
<ProjectReference Include="..\..\SharpEngine.Core\SharpEngine.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.IO;
using SharpEngine.Core.Audio.Players;

namespace SharpEngine.Core.Audio;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Silk.NET.OpenAL;
using System;

namespace SharpEngine.Core.Audio;

Expand Down Expand Up @@ -39,5 +38,4 @@ public void LoadData(ReadOnlySpan<byte> data, AudioData wavData)
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using SharpEngine.Core.Scenes;
using Silk.NET.OpenAL;

using System;
using System.IO;

namespace SharpEngine.Core.Audio;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Microsoft.Extensions.Logging;
using System;
using System.Buffers.Binary;
using System.IO;
using NLayer;
using Silk.NET.OpenAL;

namespace SharpEngine.Core.Audio;
namespace SharpEngine.Core.Audio.Players;

internal class Mp3Player : AudioPlayerBase
{
Expand All @@ -14,9 +11,10 @@ internal class Mp3Player : AudioPlayerBase
/// <inheritdoc />
protected override string FileExtension => AudioFileExtensions.Mp3Extension;

public Mp3Player()
{
}
/// <summary>
/// Initializes a new instance of <see cref="Mp3Player" />
/// </summary>
public Mp3Player() { }

/// <inheritdoc />
/// <exception cref="InvalidOperationException">Thrown if the audio data contains more than 2 channels.</exception>
Expand Down Expand Up @@ -45,9 +43,14 @@ public override void Play(string filePath)
float f = floatBuffer[i];
// clamp and convert
int intVal = (int)MathF.Round(f * 32767f);
if (intVal > short.MaxValue) intVal = short.MaxValue;
else if (intVal < short.MinValue) intVal = short.MinValue;
if (intVal > short.MaxValue)
intVal = short.MaxValue;

else if (intVal < short.MinValue)
intVal = short.MinValue;

short s = (short)intVal;

bytes[i * 2] = (byte)(s & 0xFF);
bytes[i * 2 + 1] = (byte)((s >> 8) & 0xFF);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Microsoft.Extensions.Logging;
using Silk.NET.OpenAL;

using System;
using System.Buffers.Binary;
using System.IO;

namespace SharpEngine.Core.Audio;
namespace SharpEngine.Core.Audio.Players;

/// <summary>
/// Represents a player for .wav files.
Expand Down
22 changes: 22 additions & 0 deletions SharpEngine.Core.Audio/SharpEngine.Core.Audio.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<!-- TODO: This required by the AudioDevice class. -->
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Silk.NET.OpenAL" Version="2.23.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SharpEngine.Core\SharpEngine.Core.csproj" />
</ItemGroup>

</Project>
17 changes: 0 additions & 17 deletions SharpEngine.Core.Components/IComponent.cs

This file was deleted.

Loading
Loading