2016-09-28 11:00:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <assimp/Importer.hpp> // C++ importer interface
|
|
|
|
#include <assimp/scene.h> // Output data structure
|
|
|
|
#include <assimp/postprocess.h> // Post processing flags
|
|
|
|
|
|
|
|
#include <epoxy/gl.h>
|
|
|
|
#include <epoxy/glx.h>
|
|
|
|
|
2016-09-29 09:38:26 +00:00
|
|
|
#include "glclasses.hpp"
|
|
|
|
|
|
|
|
// TODO: hide assimp inside
|
|
|
|
// and enable/disable
|
|
|
|
// to use own binary format without assimp for speed/compatibiblity
|
|
|
|
|
|
|
|
// TODO: add lod-options
|
|
|
|
// TODO: add generate from openscad options if models missing
|
2016-09-28 19:26:11 +00:00
|
|
|
namespace endofthejedi {
|
|
|
|
class PolygonModel {
|
|
|
|
public:
|
2016-09-29 09:38:26 +00:00
|
|
|
PolygonModel(const std::string &filename);
|
2016-09-29 06:28:56 +00:00
|
|
|
|
2016-09-29 09:38:26 +00:00
|
|
|
void clear();
|
2016-09-29 06:28:56 +00:00
|
|
|
|
2016-09-29 09:38:26 +00:00
|
|
|
bool import();
|
2016-09-29 06:28:56 +00:00
|
|
|
|
2016-09-29 09:38:26 +00:00
|
|
|
bool uploadToOpenGl();
|
|
|
|
bool bind(Shader &shader);
|
|
|
|
bool render(Shader& shader);
|
2016-09-28 11:00:40 +00:00
|
|
|
|
2016-09-28 19:26:11 +00:00
|
|
|
private:
|
2016-09-29 09:38:26 +00:00
|
|
|
bool copyVertices(const aiScene *scene);
|
2016-09-28 11:00:40 +00:00
|
|
|
|
2016-09-28 19:26:11 +00:00
|
|
|
const std::string &filename() const { return m_filename; }
|
2016-09-28 11:00:40 +00:00
|
|
|
|
2016-09-28 19:26:11 +00:00
|
|
|
private:
|
|
|
|
std::string m_filename;
|
|
|
|
bool m_loaded_from_file;
|
|
|
|
bool m_loaded_to_opengl;
|
|
|
|
bool m_binding_active;
|
2016-09-28 11:00:40 +00:00
|
|
|
|
2016-09-28 19:26:11 +00:00
|
|
|
// both will hold 3 * numVertices floats
|
|
|
|
std::vector<float> m_data_position;
|
|
|
|
std::vector<float> m_data_normal;
|
2016-09-28 11:16:11 +00:00
|
|
|
|
2016-09-28 19:26:11 +00:00
|
|
|
size_t m_numVertices;
|
2016-09-28 11:00:40 +00:00
|
|
|
|
2016-09-28 19:26:11 +00:00
|
|
|
GLuint m_vbo_id_position;
|
|
|
|
GLuint m_vbo_id_normal;
|
|
|
|
};
|
|
|
|
}
|