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.
47 lines
1.3 KiB
47 lines
1.3 KiB
#pragma once
|
|
#include "ggl.h"
|
|
#include "vertexbuffer.h"
|
|
#include "shader.h"
|
|
#include <vector>
|
|
#include "Glm/glm.hpp"
|
|
#include "Glm/ext.hpp"
|
|
|
|
struct VertexIndex
|
|
{
|
|
int position;
|
|
int texcoord;
|
|
int normal;
|
|
};
|
|
|
|
class Model {
|
|
public:
|
|
VertexBuffer* mVertexBuffer;
|
|
Shader* mShader;
|
|
public:
|
|
glm::mat4 mModelMatrix;
|
|
float *mLightViewMatrix, *mLightProjectionMatrix;
|
|
Model();
|
|
void Init(const char *modelPath);
|
|
void Draw(glm::mat4 &viewMatrix, glm::mat4 projectionMatrix, float x, float y, float z);
|
|
void SetPosition(float x, float y, float z);
|
|
void SetAmbientMaterial(float r, float g, float b, float a);
|
|
void SetDiffuseMaterial(float r, float g, float b, float a);
|
|
void SetSpecularMaterial(float r, float g, float b, float a);
|
|
void SetTexture(const char*imagePath);
|
|
private:
|
|
unsigned char* fileContent = nullptr;
|
|
std::vector<glm::float3> position;
|
|
std::vector<glm::float3> texcoord;
|
|
std::vector<glm::float3> normal;
|
|
std::vector<VertexIndex> vertices;
|
|
void parseModel();
|
|
void parseLine(const char* line);
|
|
glm::float3 parseFloat(const char* line);
|
|
VertexIndex parseVertexIndex(std::string pointStr);
|
|
int addVertices(VertexIndex indexes);
|
|
void parseTexcoord(const char* line);
|
|
void parseNormal(const char* line);
|
|
void parsePosition(const char* line);
|
|
void parseFace(const char* line);
|
|
void createVertexBuffer();
|
|
};
|