Skip to content

Rewriting the engine in C++#7

Draft
NicusorN5 wants to merge 627 commits into
3DRadSpace:masterfrom
NicusorN5:master
Draft

Rewriting the engine in C++#7
NicusorN5 wants to merge 627 commits into
3DRadSpace:masterfrom
NicusorN5:master

Conversation

@NicusorN5
Copy link
Copy Markdown
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

  • Binaries in the repo. #1
  • 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
  • SpriteBatch implementation
  • Macro based reflection (reflective programming, not reflection shaders)
  • Fog object
  • Counter object
  • "Legacy" 3D Rad v722 style APIs
  • Audio device handle creation
  • Fog shader
  • Skybox object
  • CI build pipeline using GitHub actions
  • Gizmos
  • Loading sounds
  • Playing sounds
  • SoundEffect object
  • ExitFade object
  • SoundSource object
  • Plugin system (allowing custom objects)
  • Skinmesh mouse picking
  • C# bindings
  • 3D primitives
  • UI Translation/Rotation/Scale buttons similar to 3D Rad v722
  • Visual Studio support
  • Script object (C#)
  • Rigidbody objects
  • FPVCamera object
  • Force object

Tasks that are currently being worked on

  • ⏳ Writing and generating documentation

TO DO Tasks

  • Timer object
  • EOL object
  • EOK object

Tasks list taken from: 3DRadSpace C++ rewrite (0.1.0a)

@NicusorN5 NicusorN5 self-assigned this Jun 8, 2023
@NicusorN5 NicusorN5 added this to the 0.1.0a milestone Jun 8, 2023
@NicusorN5 NicusorN5 marked this pull request as ready for review June 21, 2023 20:29
@NicusorN5 NicusorN5 marked this pull request as draft June 21, 2023 20:29
@NicusorN5 NicusorN5 linked an issue Jun 21, 2023 that may be closed by this pull request
@NicusorN5
Copy link
Copy Markdown
Member Author

NicusorN5 commented Nov 26, 2023

I didn't log the changes here, but I will do for now: As of the latest commit I finished implemented settings (Camera sensitivity + autoupdates checks at startup).

More settings can be added in the future, but that's just the basics, and I consider this to be good enough for now.

@NicusorN5
Copy link
Copy Markdown
Member Author

The physics initialization needs to be tested, otherwise it is done. What follows are implementing physics objects such as rigidbodies, character controller, etc...

@NicusorN5
Copy link
Copy Markdown
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.

@NicusorN5
Copy link
Copy Markdown
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.

@NicusorN5
Copy link
Copy Markdown
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
Copy Markdown
Member Author

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

@NicusorN5
Copy link
Copy Markdown
Member Author

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

@NicusorN5
Copy link
Copy Markdown
Member Author

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

@NicusorN5
Copy link
Copy Markdown
Member Author

For the moment, I will consider the reflection component (without reflecting member functions) and the spritebatch (despite text rendering not being optimised with one single draw call) tasklists complete.

I'm switching the goal to a earlier but more unstable release.

@NicusorN5 NicusorN5 added the urgent Should be fixed ASAP. label Dec 28, 2024
@NicusorN5
Copy link
Copy Markdown
Member Author

Marking #1 as complete, since I won't bother editing the git history.

@NicusorN5
Copy link
Copy Markdown
Member Author

Marking "Audio device handle creation" as complete, by debugging a sample project, by debugging it I seem to have valid audio device and context handles.
image

Debugging:
image

@NicusorN5
Copy link
Copy Markdown
Member Author

image

One draw call for fonts!

@NicusorN5
Copy link
Copy Markdown
Member Author

image
Preview of the CubeMapSkybox primitive using skybox images.

@NicusorN5 NicusorN5 changed the title [DRAFT]Rewriting the engine in C++ Rewriting the engine in C++ May 6, 2025
NicusorN5 added 14 commits April 6, 2026 23:18
- Currently cannot move the character controller
- Sometimes falling trough the static colliders
Also:
- Fixed Font asset serialization/deserialization not being handled
- Fixed heap-use-after-free when creating a new project when an object was selected previously
- ObjectList::Find() fix compile error, swap object, type.
- GraphicsDevice dtor cleanup context state
As far as I understand, the virtual table for any object is not initialized in the ctor, thus _getMass was being called instead of _getPosition, resulting in undefined behiavour.

As a consequence, I have removed the GetSet utility class from the entire codebase.

C++ moment.

Also fixed ObjectList::Find(size_t) returning nullptr.
@NicusorN5
Copy link
Copy Markdown
Member Author

After some polishing(especially the C# scripting part), this could be merged into the main repository.

@NicusorN5 NicusorN5 marked this pull request as ready for review April 20, 2026 22:41
@NicusorN5 NicusorN5 marked this pull request as draft April 20, 2026 22:42
- Fix rendering breaking when approaching pole singularities
- Fill world center gap if cursor3D isn't at (0,0,0)
- Rename "RenderWindow" to "EditorGame"
- IGame::IsEditor()
- Fix Color serialization
- Rename FPCharacter::JumpHeight to JumpPower
- IGraphicsDeviceContext::ToggleFullscreen separated into an getter and setter
-
- Fix double serialization
- Deserialize object hierarchy AFTER all objects were initialized
- Fix Quaternion Z coordinate in editor deserialization
- IObject3D::GetLocalMatrix
- IObject3D::GetModelMatrix accumulates transforms
Credits to David MacDermot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature urgent Should be fixed ASAP.

Projects

Development

Successfully merging this pull request may close these issues.

Binaries in the repo.

1 participant