diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-01 10:51:15 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-01 10:51:15 +0100 |
| commit | 8bdc4754647c9c6691130fa91d51fee93c5fc88f (patch) | |
| tree | 2cfd7f72a21541c488ea48629eef47a6774fc2c4 /src/3d/object.h | |
| parent | 7905abd9f7ad35231289e729b42e3ad57a943ff5 (diff) | |
feat: Implement 3D system and procedural texture manager
- Extended mini_math.h with mat4 multiplication and affine transforms.
- Implemented TextureManager for runtime procedural texture generation and GPU upload.
- Added 3D system components: Camera, Object, Scene, and Renderer3D.
- Created test_3d_render mini-demo for interactive 3D verification.
- Fixed WebGPU validation errors regarding depthSlice and unimplemented WaitAny.
Diffstat (limited to 'src/3d/object.h')
| -rw-r--r-- | src/3d/object.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/3d/object.h b/src/3d/object.h new file mode 100644 index 0000000..f4215aa --- /dev/null +++ b/src/3d/object.h @@ -0,0 +1,51 @@ +// This file is part of the 64k demo project. +// It defines the base 3D Object structure. +// Handles transforms and bounding volumes for hybrid rendering. + +#pragma once + +#include "util/mini_math.h" + +enum class ObjectType { + CUBE, + SPHERE, + PLANE, + TORUS + // Add more SDF types here +}; + +struct BoundingVolume { + vec3 min; + vec3 max; +}; + +class Object3D { + public: + vec3 position; + quat rotation; + vec3 scale; + + ObjectType type; + // Material parameters could go here (color, roughness, etc.) + vec4 color; + + Object3D(ObjectType t = ObjectType::CUBE) + : position(0, 0, 0), rotation(0, 0, 0, 1), scale(1, 1, 1), type(t), + color(1, 1, 1, 1) { + } + + mat4 get_model_matrix() const { + mat4 T = mat4::translate(position); + mat4 R = rotation.to_mat(); + mat4 S = mat4::scale(scale); + // M = T * R * S + return T * (R * S); + } + + // Returns the local-space AABB of the primitive (before transform) + // Used to generate the proxy geometry for rasterization. + BoundingVolume get_local_bounds() const { + // Simple defaults for unit primitives + return {{-1, -1, -1}, {1, 1, 1}}; + } +}; |
