You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

86 lines
3.0 KiB

#ifndef OBJECT_H
#define OBJECT_H
#include "Mesh.h"
#include "ShaderProgram.h"
#include "ExternalLib/glad.h"
#include "ExternalLib/glm/glm.hpp"
#include <string>
#include <vector>
/*******************************************************************
* Object is storing every openGL attributes necessary to send *
* and get informations from the GPU, along its rotation, scale, *
* position, mesh, etc *
* TODO : finish the implementation of the previous Object, *
* Object.h/cpp.BACK for a more versatile class capable *
* of holding different types of meshes, lightpoint, etc *
*******************************************************************/
enum ObjectType // Describe object's type, will add more types as time goes by
{
SimpleMesh,
Mirror,
SkyBox
};
class Object
{
public:
/***** Constructors *****/
Object();
Object(const glm::vec3& position_, const glm::vec3& rotation_, const glm::vec3& scale_, const Mesh& mesh_, const ObjectType objectType_);
/***** Methods *****/
void Draw(const ShaderProgram& sp) const; // Draw the actual Object !! Assume OpenGL context available and ShaderProgram linked to the camera !!
/***** Getters *****/
int getNbVertices() const;
GLuint getVAO() const;
GLuint getVBO() const;
Mesh getMesh() const;
glm::vec3 getPosition() const;
glm::vec3 getRotation() const;
glm::vec3 getScale() const;
glm::mat4 getModel() const;
//setters
void setPosition(glm::vec3 position_);
void setRotation(glm::vec3 rotation_);
void setScale(glm::vec3 scale_);
// Oerators
bool operator==(Object const& rhs) const
{
if (objectType == rhs.objectType &&
// mesh == rhs.mesh && // TODO : implement mesh's operator ==
position == rhs.position &&
rotation == rhs.rotation &&
scale == rhs.scale &&
vao == rhs.vao &&
vbo == rhs.vbo &&
nbVertices == rhs.nbVertices
)
return true;
else
return false;
}
private:
/***** Members *****/
ObjectType objectType; // describes object's type
Mesh mesh; // store object's mesh
glm::vec3 position; // store object's position
glm::vec3 rotation; // store object's rotation
glm::vec3 scale; // store object's scale
glm::mat4 model; // model matrix resulting in the combination of: position, rotation and scale
GLuint vao; // one object per VAO
GLuint vbo; // vertices VBO, MUST HAVE otherwise Model Object is invalid, layout 0 reserved for it
int nbVertices; // number of vertices stored in the Object's Mesh
/***** Methods *****/
void setModel(); // Set Object's Model matrix
};
#endif /* OBJECT_H */