2013-11-19 13:30:46 +01:00
|
|
|
#ifndef OBJREADER_H
|
|
|
|
#define OBJREADER_H
|
|
|
|
#include "..\..\Misc\Utilities.h"
|
|
|
|
#include "..\..\OysterMath\OysterMath.h"
|
2013-11-21 13:45:11 +01:00
|
|
|
#include "..\Model\ModelInfo.h"
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-19 13:30:46 +01:00
|
|
|
//#include <fstream>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OBJReader
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-11-19 13:30:46 +01:00
|
|
|
public:
|
|
|
|
struct OBJFormat
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-11-19 13:30:46 +01:00
|
|
|
Oyster::Math::Float3 _d3VertexCoord;
|
|
|
|
Oyster::Math::Float2 _d3VertexTexture;
|
|
|
|
Oyster::Math::Float3 _d3VertexNormal;
|
|
|
|
};
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-19 13:30:46 +01:00
|
|
|
struct OBJMaterialData
|
|
|
|
{
|
2013-11-21 12:47:47 +01:00
|
|
|
std::string _name;
|
|
|
|
std::string _mapKd;
|
2013-11-19 13:30:46 +01:00
|
|
|
float _kd[3];
|
|
|
|
float _ka[3];
|
|
|
|
float _tf[3];
|
|
|
|
float _ni;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-19 13:30:46 +01:00
|
|
|
OBJMaterialData()
|
|
|
|
{
|
|
|
|
_name = " ";
|
|
|
|
_mapKd = " ";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
std::vector<OBJFormat> _myOBJ;
|
|
|
|
private:
|
|
|
|
|
2013-11-21 12:47:47 +01:00
|
|
|
std::vector<Oyster::Math::Float3> _mVertexCoord, _mVertexNormal;
|
|
|
|
std::vector<Oyster::Math::Float2> _mVertexTexture;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-19 13:30:46 +01:00
|
|
|
int _mNrOfCoords, _mNrOfNormals, _mNrOfTexels, _mNrOfFaces;
|
|
|
|
int _mPos, _mNormal, _mTexel;
|
2013-11-21 12:47:47 +01:00
|
|
|
void stringSplit( std::string strToSplit );
|
2013-11-19 13:30:46 +01:00
|
|
|
void addToOBJarray();
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-19 13:30:46 +01:00
|
|
|
public:
|
|
|
|
OBJReader();
|
|
|
|
~OBJReader();
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-21 12:47:47 +01:00
|
|
|
void readOBJFile( std::wstring fileName);
|
2013-11-26 09:09:35 +01:00
|
|
|
Oyster::Graphics::Model::ModelInfo* toModel();
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-19 13:30:46 +01:00
|
|
|
};
|
|
|
|
#endif
|