Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT]Rewriting the engine in C++ #7

Draft
wants to merge 209 commits into
base: master
Choose a base branch
from

Conversation

NicusorN5
Copy link
Member

@NicusorN5 NicusorN5 commented Feb 16, 2022

Rewriting the engine in C++ could allow more control and performance compared to the old Monogame releases. Monogame has limited 3D rendering capabilities, namely the assimp implementation allows a maxiumum of 72 bones, BasicEffect (Blinn-Phong with limited control over the variables), broken UVW mapping, and some cross compatibility issues.

I do realise this will take months, but I think it is worth it.

Currently, it is being written using plain Winapi32 and DirectX11 (native windows technologies, duh). Future implementation could use NVRHI and a cross platform GUI library.


Tasks are placed in the order they are finished.

Complete tasks

  • Initializing Windows API window.
  • Setup main interface
  • Initializing DirectX11 device
  • Keyboard shortcuts
  • Drag and dropping projects
  • Implementing the Camera object
  • Rendering matrices (MVP + SRT transforms)
  • Drawing the center X-Y-Z axis
  • Depth buffer
  • Implement a basic color shader (Vertex position-color) shader with no transform and transforms
  • Object selection interface
  • Implement runtime created dialog box memory templates
  • Textured shader
  • Model loading using Assimp
  • Skinmesh object
  • Content manager
  • Command line arguments parsing
  • Sprite object
  • Autoupdater
  • Mathematical data structures APIs (Matrix, Vector3, et cetera)
  • Settings
  • G-Force object
  • Skinmesh/Model previewer
  • Implement NVidia PhysX as a physics engine
  • Empty object
  • SkyColor object
  • Project I/O
  • Font loading
  • Font rendering
  • TextPrint object

Tasks that are currently being worked on

  • ⏳ SpriteBatch implementation
  • ⏳ Macro based reflection
  • ⏳ Skinmesh mouse picking
  • ⏳ C# bindings
  • ⏳ 3D primitives
  • ⏳ Audio device handle creation
  • ⏳ "Legacy" 3D Rad v722 style APIs
  • ⏳ UI Translation/Rotation/Scale buttons similar to 3D Rad v722

TO DO Tasks

  • Collision editor
  • Loading sounds
  • Playing sounds
  • Writing and generating documentation
  • Gizmos
  • Visual Studio support
  • Fog shader
  • ExitFade object
  • Timer object
  • EOL object
  • EOK object
  • SoundSource object
  • SoundEffect object
  • Skybox object
  • Script object (C#)
  • FPVCamera object
  • Rigidbody object
  • Force object
  • Binaries in the repo. #1

Tasks list taken from: https://github.com/orgs/3DRadSpace/projects/10

Athanatos added 30 commits August 18, 2021 17:30
Not using Monogame anymore, switching to C++ DX11/DirectXTK
Made Shader,VertexBuffer, ShaderInputLayout and ResourceCreationException classes.

Made Vector4 and Vertex[type]Declaration structs

All that code was written in 1 go and it worked for the first time. lmao I'm still amazed
--> I continued to make the code more modular
--> Implemented IObject and Camera

TODO:
--> Implement shader parameters
It looks so broken GAH
Now to fix the axis model...
@NicusorN5
Copy link
Member Author

I tested the physics engine initialization under a separate VS2022 project.

I fixed some strange issue with vertices seeming to be skewed to the side because of a erroneous calculation inside Matrix4x4::CreatePerspectiveProjection() ( https://github.com/NicusorN5/3D_Rad_Space/blob/ecf059cff3bf958df5b9d266093b39584f651cf1/3DRadSpace/Engine3DRadSpace/Math/Matrix4x4.cpp#L152 )

I attempted implementing mesh picking without success.

Including spritebatch, constexpr math API, grid setting, serialization and deserialization for I/O and more stuff I don't remember.,
@NicusorN5
Copy link
Member Author

SpriteBatch is almost finished, I just need to fix the rotation affine transformation. (I'm not including Font in this list). Fonts currently have a major memory bug involving reading the glyps from FreeType.

I have added support for source rectangles (i.e custom UV coordinates) so it is possible to only render a part of a image. I didn't test that feature, but it will be used when I add the translation/rotation/scale buttons.

- AssetReference was renamed to AssetID.
- AssetID is just a templated struct that contains a unsigned integer, so an untyped ID is a plain integer.
- Asset base type for classes that can be loaded using ContentManager::Load<T>.
- Removed Asset<T> and IAsset.

This was necessary, because the types of content being loaded were not identifiable during deserialization.
@NicusorN5
Copy link
Member Author

Project files are in a JSON format. Compiled projects will be generated using a compiler (i.e MSVC), so they won't be used in final projects.

@NicusorN5
Copy link
Member Author

Need to use font atlases and a preallocated vertex buffer for the SpriteBatch implementation.

- Fix loading assets at opening project
- Some nullchecks
- Simplified AssetType registration
- Work on integrating TextPrint object
Also added Texture2D::Texture2D(GraphicsDevice*, std::filesystem::path const &) overload to replace string and wstring overloads.
Kinda works, but all asset previews are broken and save a plain coloured image.
@NicusorN5
Copy link
Member Author

CMake building works with VS2022 on Windows 10. Post build processes are broken at the moment.

Fixed by writing an optimisation in SpriteBatch to not create new VertexBuffers in each Draw() update, but to modify an existing Vertex Buffer with an initial capacity of 1024 and a growth factor of 2.

Fixed VertexBuffer usage variable not being used in the ctor. Thus also fixing
::SetData() throwing exceptions.

Finally, also fixed the post build process.
@NicusorN5
Copy link
Member Author

Currently using a naive font atlas implementation, see results in the picture below:
image

Visual Studio doesn't seem to define NDEBUG when switching to Release-x64, this is so fcking stupid. I'm beginning to hate VS2022. May want to try CLion again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

Binaries in the repo.
1 participant