From 7f3aa1cff755d21d972457b05c140cf465b9fa19 Mon Sep 17 00:00:00 2001 From: DrNuget Date: Wed, 7 Jan 2026 04:58:54 +0200 Subject: some basic 3D rendering and the base for chunk generation etc. --- src/engine/M_object.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/engine/M_object.h (limited to 'src/engine/M_object.h') 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 +#include +#include + +#include +#include +#include +#include + +//#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); -- cgit v1.2.3