The source code of the 12th tutorial of the C++ 3D Game Tutorial Series is now available in early access on GitHub!
This update marks a significant architectural evolution for the DX3D engine, transitioning it from a basic object hierarchy toward a more flexible Component-based system. The core goal is to decouple game object logic and properties, allowing features like transforms to be attached dynamically rather than being hardcoded into every instance.
Here is a summary of the key changes:
New Component Architecture: A foundational Component class has been created in Game/Component.h, serving as the base for all future components. Following this, the first concrete implementation, TransformComponent, was added in a new header and source file to handle position, rotation, and scale.
GameObject Refactoring: The GameObject class has been significantly modified to support the new system. It now includes a map to manage internal components and introduces templated methods (createOrGetComponent, getComponent) that allow objects to request specific features dynamically.
Type Safety Enhancements: Several core headers (Common.h, Identifiable.h, Core.h) were updated to include C++ concepts like HasTypeId and IsRegistered. These ensure at compile-time safety that components and game objects are properly registered before they are used or queried.
Optimization Logic: The TransformComponent introduces a "dirty" flag mechanism. When position or rotation changes, the component is marked dirty, and the World updates the associated world matrix only during the game loop update cycle if necessary, reducing unnecessary recalculations.
You can find the full source code on GitHub here: GitHub Link
I hope you enjoy the tutorial, and thank you for all your support!