Loading of a OFF ASCII file

Only supports triangles
Not textured yet
Supports scaling and rotation of the model
This commit is contained in:
trotFunky 2019-09-30 16:52:04 +02:00
parent db0bd97580
commit 94bc1228f1
9 changed files with 31419 additions and 4 deletions

View file

@ -0,0 +1,57 @@
//
// Created by trotfunky on 30/09/2019.
//
#ifndef TESTS_OPENGL_MODEL3D_H
#define TESTS_OPENGL_MODEL3D_H
#include <string>
#include <fstream>
#include <iostream>
#include "GL/glut.h"
#include "../types.h"
#include "Texture.h"
class Model3D {
public:
Model3D();
explicit Model3D(const std::string& file_name);
~Model3D();
/// Loads an ASCII OFF file. Detects if there is texture data. Only triangles are supported.
bool load_ascii_off_file(const std::string& file_name);
void assign_texture(Texture& new_texture);
void set_scaling(float x_scale, float y_scale, float z_scale);
void set_rotation(float angle, float x, float y, float z);
void draw_model();
bool is_textured;
private:
uint32_t vertex_count;
uint32_t face_count;
/// Coordinates of the vertices
Vec3f* vertices{};
/// Indices of the vertices making up each face
Vec3i* faces{};
/// Normals of each face
Vec3f* normals{};
uint32_t texture_count;
/// U,V coordinates inside the texture
Vec2f* texture_coordinates{};
/// Indices of the texture coordinates of each point on a face
Vec3i* face_textures{};
Texture* texture{};
Vec3f scaling{};
Vec3f rotation_axis{};
float rotation_angle{};
};
#endif //TESTS_OPENGL_MODEL3D_H