#ifndef OBJ_MODEL_H
#define OBJ_MODEL_H
#include <vector>
#include <map>
#include <string>
#include <functional>
struct Vertex
{
Vertex(float a, float b, float c) : x(a), y(b), z(c) {}
union { float asArray[3]; struct { float x, y, z; }; };
};
struct UV
{
UV(float a, float b) : u(a), v(b) {}
union { float asArray[2]; struct { float u, v; }; };
};
struct Face
{
struct FaceDetail { union { int asArray[3]; struct { int vertexIndex, uvIndex, normalIndex; }; }; };
std::vector<FaceDetail> indices;
};
typedef Vertex Normal;
typedef Vertex Position;
typedef Vertex Direction;
struct Object
{
std::string objectName;
std::vector<Position> vertices;
std::vector<Normal> normals;
std::vector<UV> uvs;
std::vector<Face> faces;
bool smoothing;
std::string materialName;
};
struct Material
{
std::string materialName;
float Ns; // ?
float Ni; // ?
float Ka[3]; // ambient
float Kd[3]; // diffuse
float Ks[3]; // specular
float d; // ?
int illum; // ?
std::string map_Kd; // diffuse texture map
};
struct ObjScene
{
std::map<std::string,Material> materialLibrary;
std::vector<Object> objects;
std::map<std::string,Object*> objectMap;
};
//using std::vector<uint8_t> ByteArray;
//bool ReadObjFile(Scene& outScene, ByteArray& inData);
bool ReadObjFile(ObjScene& outScene, const char* fileName, std::function<void(bool okay)> callback);
#endif // OBJ_MODEL_H