Added more structure, added abstraction to existing parts
This commit is contained in:
+8
-99
@@ -1,101 +1,10 @@
|
||||
#include "Header.h"
|
||||
using namespace std;
|
||||
|
||||
#pragma once
|
||||
class ModelLoader
|
||||
#include "Header.h"
|
||||
|
||||
string replace(string str, string toReplace, string replacement);
|
||||
vector<string> split(string str, string sep);
|
||||
inline string toLower(string data)
|
||||
{
|
||||
public:
|
||||
ModelLoader();
|
||||
~ModelLoader();
|
||||
};
|
||||
|
||||
class Vec3f
|
||||
{
|
||||
public:
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x, y, z;
|
||||
};
|
||||
float v[3];
|
||||
};
|
||||
Vec3f();
|
||||
Vec3f(Vec3f &other);
|
||||
Vec3f(float x, float y, float z);
|
||||
float& operator [](int);
|
||||
};
|
||||
|
||||
class Vec2f
|
||||
{
|
||||
public:
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x, y;
|
||||
};
|
||||
float v[2];
|
||||
};
|
||||
Vec2f();
|
||||
Vec2f(float x, float y);
|
||||
Vec2f(Vec2f &other);
|
||||
float& operator [](int);
|
||||
};
|
||||
|
||||
|
||||
class ObjModel
|
||||
{
|
||||
private:
|
||||
class Vertex
|
||||
{
|
||||
public:
|
||||
int position;
|
||||
int normal;
|
||||
int texcoord;
|
||||
};
|
||||
|
||||
class Face
|
||||
{
|
||||
public:
|
||||
list<Vertex> vertices;
|
||||
};
|
||||
|
||||
class Texture
|
||||
{
|
||||
GLuint index;
|
||||
public:
|
||||
Texture(const std::string &fileName);
|
||||
void bind();
|
||||
};
|
||||
|
||||
class MaterialInfo
|
||||
{
|
||||
public:
|
||||
MaterialInfo();
|
||||
std::string name;
|
||||
Texture* texture;
|
||||
bool hasTexture;
|
||||
};
|
||||
|
||||
class ObjGroup
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
int materialIndex;
|
||||
list<Face> faces;
|
||||
};
|
||||
|
||||
std::vector<Vec3f> vertices;
|
||||
std::vector<Vec3f> normals;
|
||||
std::vector<Vec2f> texcoords;
|
||||
std::vector<ObjGroup*> groups;
|
||||
std::vector<MaterialInfo*> materials;
|
||||
|
||||
void loadMaterialFile(std::string fileName, std::string dirName);
|
||||
public:
|
||||
ObjModel(std::string filename);
|
||||
~ObjModel(void);
|
||||
|
||||
void draw();
|
||||
};
|
||||
std::transform(data.begin(), data.end(), data.begin(), ::tolower);
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user