97 lines
1.9 KiB
C++
97 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "GL/glew.h"
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "assimp\scene.h"
|
|
#include "assimp\mesh.h"
|
|
#include "../Shader.h"
|
|
#include "../SceneContext.h"
|
|
#include "../Dataset.h"
|
|
|
|
#include "../ModelView.h"
|
|
|
|
enum Transformation
|
|
{
|
|
Rotation,
|
|
Translation,
|
|
Scaling
|
|
};
|
|
|
|
enum CullFace
|
|
{
|
|
NONE = GL_NONE,
|
|
FRONT = GL_FRONT,
|
|
BACK = GL_BACK,
|
|
FRONT_BACK = GL_FRONT_AND_BACK
|
|
};
|
|
|
|
enum RenderType
|
|
{
|
|
OBJ,
|
|
NO_INDEX
|
|
};
|
|
|
|
class Mesh
|
|
{
|
|
public:
|
|
struct MeshEntry {
|
|
enum BUFFERS {
|
|
VERTEX_BUFFER, NORMAL_BUFFER, COLOR_BUFFER, TEXCOORD_BUFFER, INDEX_BUFFER,
|
|
TANGENTS_BUFFER, BITTANGENTS_BUFFER
|
|
};
|
|
GLuint vao;
|
|
GLuint vbo[7];
|
|
|
|
unsigned int elementCount;
|
|
RenderType renderType;
|
|
unsigned int dset_size = 0;
|
|
GLuint ssbo;
|
|
glm::vec3 ssbo_data[3];
|
|
aiColor3D dcolor;
|
|
aiColor3D acolor;
|
|
aiColor3D scolor;
|
|
std::vector<Texture> textures;
|
|
|
|
float shininessStrength;
|
|
MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m);
|
|
MeshEntry(Dataset &set, Mesh *m);
|
|
~MeshEntry();
|
|
Mesh * parent;
|
|
void render(SceneContext &ctx, Shader &shd);
|
|
|
|
};
|
|
|
|
public:
|
|
Mesh(const char *filename, std::string vert_shd, std::string frag_shd);
|
|
Mesh(Dataset &dataset, std::string vert_shd, std::string frag_shd);
|
|
~Mesh(void);
|
|
std::string directory;
|
|
std::vector<MeshEntry*> meshEntries;
|
|
std::map<std::string, Texture> textures;
|
|
|
|
private:
|
|
std::vector<std::pair<glm::vec4, Transformation>> _transformations;
|
|
|
|
public:
|
|
Model model;
|
|
CullFace cullMode = NONE;
|
|
void effectTransformations();
|
|
void addRotation(glm::vec4 vec);
|
|
void addTranslation(glm::vec4 vec);
|
|
void addScaling(glm::vec4 vec);
|
|
|
|
void addStartRotation(glm::vec4 vec);
|
|
void addStartTranslation(glm::vec4 vec);
|
|
void addStartScaling(glm::vec4 vec);
|
|
|
|
glm::vec4 translateToPivot(glm::vec3);
|
|
void removeLastTransformations(int n);
|
|
glm::vec3 getPosition();
|
|
|
|
std::shared_ptr<Shader> shader;
|
|
void draw(SceneContext &ctx);
|
|
|
|
}; |