2013-12-17 14:49:45 +01:00
|
|
|
#pragma once
|
|
|
|
#include "../Model/ModelInfo.h"
|
2014-02-17 10:38:11 +01:00
|
|
|
#include "OysterMath.h"
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-12-17 14:49:45 +01:00
|
|
|
namespace Oyster
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-12-17 14:49:45 +01:00
|
|
|
namespace FileLoaders
|
|
|
|
{
|
|
|
|
class ObjReader
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-12-17 14:49:45 +01:00
|
|
|
public:
|
|
|
|
struct Vertex
|
|
|
|
{
|
|
|
|
Oyster::Math::Float3 Position;
|
|
|
|
Oyster::Math::Float2 UV;
|
|
|
|
Oyster::Math::Float3 Normal;
|
|
|
|
};
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2014-01-08 07:01:59 +01:00
|
|
|
void LoadFile(std::wstring fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-12-17 14:49:45 +01:00
|
|
|
ObjReader(void);
|
|
|
|
~ObjReader(void);
|
|
|
|
|
|
|
|
void GetVertexData(Vertex **vertex,int &numVertex, std::map<std::string, ID3D11ShaderResourceView *> &textures);
|
|
|
|
void GetVertexData(Vertex **vertex,int &numVertex);
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-12-17 14:49:45 +01:00
|
|
|
private:
|
|
|
|
Vertex *vertices;
|
|
|
|
size_t numVertices;
|
|
|
|
std::map<std::wstring, ID3D11ShaderResourceView *> materials;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-12-17 14:49:45 +01:00
|
|
|
void ParseFile(std::wstring fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-12-17 14:49:45 +01:00
|
|
|
Oyster::Math::Float3 extract(std::string d);
|
|
|
|
Oyster::Math::Float3 readVertex(int offset,std::wstring s);
|
|
|
|
Oyster::Math::Float2 readUV(int offset,std::wstring s);
|
|
|
|
Oyster::Math::Float3 readNormal(int offset,std::wstring s);
|
|
|
|
void readFace(int offset,std::wstring s, Oyster::Math::Float3 face[3]);
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-12-17 14:49:45 +01:00
|
|
|
std::map<std::string, ID3D11ShaderResourceView *> GetMaterials(std::wstring fileName);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|