diff options
| author | DrNuget <drnuget@outlook.com> | 2026-01-07 04:58:54 +0200 |
|---|---|---|
| committer | DrNuget <drnuget@outlook.com> | 2026-01-07 04:58:54 +0200 |
| commit | 7f3aa1cff755d21d972457b05c140cf465b9fa19 (patch) | |
| tree | 748b74a65d71ead9d0d7ade533074c5a643076d7 /src/engine/M_object.h | |
| parent | 67592a66dd9bcc4d79d23624a9abfd8f2c6e92ff (diff) | |
| download | mnm-7f3aa1cff755d21d972457b05c140cf465b9fa19.tar.gz | |
some basic 3D rendering and the base for chunk generation etc.
Diffstat (limited to 'src/engine/M_object.h')
| -rw-r--r-- | src/engine/M_object.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/engine/M_object.h b/src/engine/M_object.h new file mode 100644 index 0000000..ca87f0a --- /dev/null +++ b/src/engine/M_object.h @@ -0,0 +1,64 @@ +#pragma once + +#include <cglm/cglm.h> +#include <cglm/mat4.h> +#include <cglm/vec3.h> + +#include <assimp/cimport.h> +#include <assimp/scene.h> +#include <assimp/mesh.h> +#include <assimp/postprocess.h> + +//#include "M_game.h" +#include "M_shader.h" + +//Temporary type for storing M_Object rotation information, +//will get replaced in later revisions. +typedef struct { + float angle; + vec3 direction; +} M_Rotation; + +//Stores information about a 3D model loaded in VRAM +typedef struct { + int num_indices; + + unsigned int VAO, VBO, EBO; +} M_ViewModel; + +//Type meant for handling 3D models in a scene, +//stores additional information like a model's position, size and rotation. +typedef struct { + M_ViewModel *model; + M_ShaderProgram *shader; + + vec3 pos, size; + + M_Rotation rotation; + + mat4 transform; +} M_Object; + +//Creates a M_ViewModel out of vertices and indices manually +void M_createViewModel(M_ViewModel *model, int num_vertices, float *vert, int num_indices, unsigned int *indices); + +//Unloads M_ViewModel from memory when no longer needed +void M_killViewModel(M_ViewModel *model); + +//Loads and creates a M_ViewModel from a 3D object file like .obj +M_ViewModel M_loadViewModel(const char* filename); + +//Creates a M_Object +void M_createObject(M_Object *obj, M_ViewModel *model); + + +//Functions for moving, scaling and rotating M_Object +void M_moveObject(M_Object *obj, vec3 pos); +void M_scaleObject(M_Object *obj, vec3 scale); +void M_rotateObject(M_Object *obj, float angle, vec3 direction); + +//Updates M_Object transform matrix manually +void M_updateObjectTransform(M_Object *obj); + +//Binds M_ViewModel for drawing +void M_bindViewModel(M_ViewModel *model); |
