Obtenha-o na Microsoft Store
Documentação
Discórdia
O motor 3D está atualmente num estágio inicial de desenvolvimento e ainda não está equipado com os recursos essenciais necessários para um motor de jogo pronto para produção. No entanto, foi estabelecido um roteiro de desenvolvimento claro e voltado para o futuro, com trabalho ativo sendo feito para implementar sistemas avançados, como geometria virtualizada e cascatas de radiância para iluminação global totalmente dinâmica. À medida que o desenvolvimento avança, pretendo promover uma comunidade a partir do próximo ano, com o objetivo de construir um mecanismo de jogo C# que se integre perfeitamente aos fluxos de trabalho do Unity. Com o seu apoio, podemos criar um mecanismo poderoso e fácil de usar, completo com um editor, que atenda às demandas do desenvolvimento de jogos modernos.
Um projeto de amostra do 3D Engine demonstrando os recursos do 3D Engine. Voxel Sandbox implementa os seguintes recursos:
Todos os componentes são escritos em C#, mostrando como aproveitar as funcionalidades do 3D Engine para construir um aplicativo completo.
Instale o pacote por meio do NuGet Package Manager para integração ao seu projeto.
dotnet new console -n Project
cd Project
dotnet add package 3DEngine
dotnet add package Costura.Fody
./Project.csproj
< Project Sdk = " Microsoft.NET.Sdk " >
< PropertyGroup >
< OutputType >WinExe</ OutputType >
< TargetFramework >net8.0-windows10.0.22621.0</ TargetFramework >
< ImplicitUsings >enable</ ImplicitUsings >
< SatelliteResourceLanguages >en</ SatelliteResourceLanguages >
< PlatformTarget >x64</ PlatformTarget >
< PublishAot >true</ PublishAot >
</ PropertyGroup >
< ItemGroup >
< None Remove = " FodyWeavers.xml " />
</ ItemGroup >
< ItemGroup >
< PackageReference Include = " 3DEngine " Version = " 3.1.0 " />
< PackageReference Include = " Costura.Fody " Version = " 5.7.0 " >
< PrivateAssets >all</ PrivateAssets >
</ PackageReference >
</ ItemGroup >
< ItemGroup >
< Content Update = " $(NuGetPackageRoot) 3DEngine 3.1.0contentFilesanynet8.0-windows10.0.22621AssetsResources*** " >
< CopyToOutputDirectory >PreserveNewest</ CopyToOutputDirectory >
</ Content >
</ ItemGroup >
< ItemGroup >
< None Update = " AssetsGeneratorsFileNamesEnumGenerator.tt " >
< Generator >TextTemplatingFileGenerator</ Generator >
< LastGenOutput >FileNamesEnumGenerator.cs</ LastGenOutput >
</ None >
</ ItemGroup >
< ItemGroup >
< Service Include = " {508349b6-6b84-4df5-91f0-309beebad82d} " />
</ ItemGroup >
< ItemGroup >
< Compile Update = " AssetsGeneratorsFileNamesEnumGenerator.cs " >
< DesignTime >True</ DesignTime >
< AutoGen >True</ AutoGen >
< DependentUpon >FileNamesEnumGenerator.tt</ DependentUpon >
</ Compile >
</ ItemGroup >
</ Project >
Certifique-se de que "PreserveNewest" esteja definido para arquivos na pasta Assets no Visual Studio. Substitua o caminho para o pacote NuGet 3DEngine 3.1.0
class Program
{
[ STAThread ]
private static void Main ( ) =>
new Engine . Program ( ) . Run (
config : Engine . Config . GetDefault (
windowCommand : Engine . WindowCommand . Show ,
presentInterval : Engine . PresentInterval . Immediate ,
multiSample : Engine . MultiSample . x4 ,
resolutionScale : 1 ,
title : "3D Engine" ,
width : 2560 , height : 1440 ,
renderGUI : true , defaultBoot : true ) ,
initialization : ( ) =>
Engine . Kernel . Instance . SystemManager . MainEntityManager . CreateEntity ( ) . AddComponent < GameManager > ( ) ,
frame : ( ) => { } ) ;
}
using System ;
using System . Collections ;
using System . Numerics ;
using Engine ;
using Engine . Buffer ;
using Engine . Components ;
using Engine . DataStructures ;
using Engine . ECS ;
using Engine . Editor ;
using Engine . Framework ;
using Engine . Graphics ;
using Engine . GUI ;
using Engine . Helper ;
using Engine . Runtime ;
using Engine . Utilities ;
public class Example : Component
{
[ ToolTip ( "This is a ToolTip" ) ]
[ Show ]
private string _visibleString = "This field is private" ;
[ Hide ]
public string HiddenString = "This field is public" ;
[ ShowOnly ]
public string ShowOnlyString = "This string is not editable" ;
public int Int ;
public float Float ;
public Vector2 Vector2 ;
public Vector3 Vector3 ;
public Vector4 Vector4 ;
[ Slider ( 1 , 100 ) ]
public float Slider ;
public bool Bool ;
[ If ( "Bool" , "True" ) ]
[ ShowOnly ]
public string IfField = "This field is only visible if the bool is true" ;
[ IfNot ( "Bool" , "True" ) ]
[ ShowOnly ]
public string IfNotField = "This field is only visible if the bool is not true" ;
[ Color ]
public Vector4 Color ;
public Entity ? _Entity ;
[ Space ]
[ Header ( "Header" ) ]
public event Action ? Event ;
// This is the base function of OnRegister.
public override void OnRegister ( ) =>
ScriptSystem . Register ( this ) ;
public override void OnAwake ( ) { }
public override void OnStart ( ) { }
public override void OnUpdate ( ) { }
public override void OnLateUpdate ( ) { }
public override void OnFixedUpdate ( ) { }
public override void OnRender ( ) { }
public override void OnGUI ( ) { }
public override void OnDestroy ( ) { }
}
Engine . Loader . ModelLoader . LoadFile ( Engine . ModelFiles . Model ) ;
Engine . Loader . ModelLoader . LoadFile ( Engine . Utilities . AssetPaths . MESHES + "Model.obj" ) ;
Engine . Loader . ImageLoader . LoadFile ( Engine . TextureFiles . TextureAtlas ) ;
Engine . Loader . ImageLoader . LoadFile ( Engine . Utilities . AssetPaths . TEXTURES + "Texture.png" ) ;
Engine . Kernel . Instance . Context . CreateShader ( Engine . Utilities . AssetPaths . SHADERS + "Shader" ) ;
Engine . Kernel . Instance . Context . CreateComputeShader ( Engine . Utilities . AssetPaths . COMPUTESHADERS + "ComputeShader" ) ;
Entity . AddComponent < Example > ( ) ;
Entity . Manager . CreateEntity ( name : "Controller" ) . AddComponent < PlayerController > ( ) . Initialize ( this ) ;
Entity . Manager . CreateEntity ( name : "Sky" ) . AddComponent < DefaultSky > ( ) . Initialize ( ) ;
var mesh = Entity . Manager . CreateEntity ( ) . AddComponent < Mesh > ( ) ;
mesh . SetMeshData ( ModelFiles . Model ) ;
mesh . SetMeshData ( Assets . Meshes [ "Model.obj" ] ) ;
mesh . SetMeshData ( vertices , indices , positions , new InputLayoutHelper ( ) . AddPosition3D ( ) . AddUV ( ) ) ;
mesh . SetRootSignature ( ) ;
mesh . SetRootSignature ( new RootSignatureHelper ( ) . AddConstantBufferView ( 2 ) . AddShaderResourceViewTable ( ) ) ;
mesh . SetMaterialTextures ( TextureFiles . Texture ) ;
mesh . SetMaterialTextures ( textureEntries : [ new ( "Texture.png" , 0 ) ] ) ;
mesh . SetMaterialPipeline ( ShaderFiles . Shader ) ;
mesh . SetMaterialPipeline ( "Shader" ) ;
Engine . Utilities . Output . Log ( Entity . Transform . Position ) ;
if ( Input . GetKey ( Key . Escape , InputState . Down ) )
{
PAUSED = ! PAUSED ;
if ( PAUSED )
Input . SetMouseLockState ( MouseLockState . Unlocked ) ;
else
Input . SetMouseLockState ( MouseLockState . LockedInvisible , 0.5 , 0.5 ) ;
}
if ( ! PAUSED )
Input . SetCursorIcon ( SystemCursor . IDC_CROSS ) ;
O repositório do 3D Engine inclui:
Você pode construir o 3DEngine (pacote) para o Editor e o Mecanismo como um aplicativo MSIX ou o Mecanismo como um aplicativo Win32 portátil.
Para compilar o mecanismo 3D, certifique-se de ter o Visual Studio 2022 com os seguintes componentes: