2013-11-19 13:30:46 +01:00
|
|
|
#ifndef OBJREADER_H
|
|
|
|
#define OBJREADER_H
|
|
|
|
#include "..\..\Misc\Utilities.h"
|
|
|
|
#include "..\..\OysterMath\OysterMath.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
|
|
|
|
{
|
|
|
|
string _name;
|
|
|
|
string _mapKd;
|
|
|
|
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:
|
|
|
|
|
|
|
|
vector<Oyster::Math::Float3> _mVertexCoord, _mVertexNormal;
|
|
|
|
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;
|
|
|
|
void stringSplit( string strToSplit );
|
|
|
|
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-19 13:30:46 +01:00
|
|
|
void readOBJFile( wstring fileName);
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-19 13:30:46 +01:00
|
|
|
};
|
|
|
|
#endif
|