LesDingeriesDeDjalimSurOpenGL/include/Mesh3D.h
Djalim Simaila 7e36811c91 ♻️ refactor engine to use Mesh3D with transform support
- Add position, rotation and scale fields to `Mesh3D` and expose them publicly.
- Remove the old `Object3D` struct; `Objects3D` now stores `unique_ptr<Mesh3D>`.
- Implement a new `createObject(name,textures,filepath,position,rotation,scale)` overload that sets transforms after loading the mesh.
- Add a `draw(Mesh3D*)` helper that binds the texture, builds a model matrix and issues `glDrawArrays`.
- Update the rendering loop to use `draw()` instead of the old cube routine.
- Simplify `onCreate`: enable depth test, flip textures, create two objects with proper transforms, set clear color.
- Enable window resizing (`GLFW_RESIZABLE`), change default size to 800×600 in `main.cpp`.
- Clean up includes and remove unused `cube.cpp`; refactor OBJ parsing for robustness.

These changes unify object handling, allow per‑object transformations, simplify the rendering pipeline, improve maintainability, and make the window resizable.
2025-10-25 19:46:49 +02:00

33 lines
626 B
C++

#ifndef _MESH3D
#define _MESH3D
#include "Texture2D.h"
#include <glm/ext/vector_float3.hpp>
#include <vector>
#include <string>
namespace djalim {
class Mesh3D {
public:
Mesh3D();
Mesh3D(const std::string& filepath);
void loadOBJFile(const std::string& filepath);
public:
Texture2D texture;
glm::vec3 position = {0.0f, 0.0f, 0.0f};
glm::vec3 rotation = {0.0f, 0.0f, 0.0f};
glm::vec3 scale = {1.0f, 1.0f, 1.0f};
std::vector<float> meshVertices;
int numMeshVertices = 0;
int numFaces = 0;
GLuint VBO;
GLuint VAO;
};
}
#endif // !_MESH3D