Merged Obj and Engine Restructure
This commit is contained in:
commit
b419849fd4
|
@ -15,14 +15,14 @@ OBJReader::~OBJReader()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBJReader::readOBJFile( wstring fileName )
|
void OBJReader::readOBJFile( std::wstring fileName )
|
||||||
{
|
{
|
||||||
fstream inStream;
|
std::fstream inStream;
|
||||||
string typeOfData = " ";
|
std::string typeOfData = " ";
|
||||||
float vertexData;
|
float vertexData;
|
||||||
string face1, face2, face3;
|
std::string face1, face2, face3;
|
||||||
|
|
||||||
inStream.open( fileName, fstream::in );
|
inStream.open( fileName, std::fstream::in );
|
||||||
|
|
||||||
if( inStream.is_open() )
|
if( inStream.is_open() )
|
||||||
{
|
{
|
||||||
|
@ -94,12 +94,38 @@ void OBJReader::readOBJFile( wstring fileName )
|
||||||
inStream.close();
|
inStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Oyster::Graphics::Render::ModelInfo OBJReader::toModel()
|
||||||
|
{
|
||||||
|
Oyster::Graphics::Buffer b;
|
||||||
|
Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc;
|
||||||
|
Oyster::Graphics::Render::ModelInfo modelInfo;
|
||||||
|
|
||||||
|
desc.ElementSize = sizeof(OBJReader::OBJFormat);
|
||||||
|
desc.InitData = &this->_myOBJ[0];
|
||||||
|
desc.NumElements = (UINT32)this->_myOBJ.size();
|
||||||
|
desc.Type = Oyster::Graphics::Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
|
||||||
|
desc.Usage = Oyster::Graphics::Buffer::BUFFER_USAGE_IMMUTABLE;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
hr = b.Init(desc);
|
||||||
|
if(FAILED(hr))
|
||||||
|
{
|
||||||
|
//Something isn't okay here
|
||||||
|
}
|
||||||
|
modelInfo.Indexed = false;
|
||||||
|
modelInfo.VertexCount = (int)desc.NumElements;
|
||||||
|
modelInfo.Vertices = b;
|
||||||
|
|
||||||
|
|
||||||
|
return modelInfo;
|
||||||
|
}
|
||||||
|
|
||||||
//Private functions
|
//Private functions
|
||||||
void OBJReader::stringSplit( string strToSplit )
|
void OBJReader::stringSplit( std::string strToSplit )
|
||||||
{
|
{
|
||||||
char delim = '/';
|
char delim = '/';
|
||||||
string vPos, vNormal, vTexel;
|
std::string vPos, vNormal, vTexel;
|
||||||
stringstream aStream(strToSplit);
|
std::stringstream aStream(strToSplit);
|
||||||
getline( aStream, vPos, delim );
|
getline( aStream, vPos, delim );
|
||||||
getline( aStream, vTexel, delim );
|
getline( aStream, vTexel, delim );
|
||||||
getline( aStream, vNormal );
|
getline( aStream, vNormal );
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define OBJREADER_H
|
#define OBJREADER_H
|
||||||
#include "..\..\Misc\Utilities.h"
|
#include "..\..\Misc\Utilities.h"
|
||||||
#include "..\..\OysterMath\OysterMath.h"
|
#include "..\..\OysterMath\OysterMath.h"
|
||||||
|
#include "..\Model\ModelInfo.h"
|
||||||
|
|
||||||
//#include <fstream>
|
//#include <fstream>
|
||||||
|
|
||||||
|
@ -19,8 +20,8 @@ class OBJReader
|
||||||
|
|
||||||
struct OBJMaterialData
|
struct OBJMaterialData
|
||||||
{
|
{
|
||||||
string _name;
|
std::string _name;
|
||||||
string _mapKd;
|
std::string _mapKd;
|
||||||
float _kd[3];
|
float _kd[3];
|
||||||
float _ka[3];
|
float _ka[3];
|
||||||
float _tf[3];
|
float _tf[3];
|
||||||
|
@ -35,19 +36,20 @@ class OBJReader
|
||||||
std::vector<OBJFormat> _myOBJ;
|
std::vector<OBJFormat> _myOBJ;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
vector<Oyster::Math::Float3> _mVertexCoord, _mVertexNormal;
|
std::vector<Oyster::Math::Float3> _mVertexCoord, _mVertexNormal;
|
||||||
vector<Oyster::Math::Float2> _mVertexTexture;
|
std::vector<Oyster::Math::Float2> _mVertexTexture;
|
||||||
|
|
||||||
int _mNrOfCoords, _mNrOfNormals, _mNrOfTexels, _mNrOfFaces;
|
int _mNrOfCoords, _mNrOfNormals, _mNrOfTexels, _mNrOfFaces;
|
||||||
int _mPos, _mNormal, _mTexel;
|
int _mPos, _mNormal, _mTexel;
|
||||||
void stringSplit( string strToSplit );
|
void stringSplit( std::string strToSplit );
|
||||||
void addToOBJarray();
|
void addToOBJarray();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OBJReader();
|
OBJReader();
|
||||||
~OBJReader();
|
~OBJReader();
|
||||||
|
|
||||||
void readOBJFile( wstring fileName);
|
void readOBJFile( std::wstring fileName);
|
||||||
|
Oyster::Graphics::Render::ModelInfo toModel();
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -11,7 +11,7 @@
|
||||||
//#include "ICollideable.h"
|
//#include "ICollideable.h"
|
||||||
#include "ModelInfo.h"
|
#include "ModelInfo.h"
|
||||||
|
|
||||||
using namespace Oyster::Math;
|
//using namespace Oyster::Math;
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ namespace Oyster
|
||||||
struct Model
|
struct Model
|
||||||
{
|
{
|
||||||
ModelInfo* info;
|
ModelInfo* info;
|
||||||
Float4x4 *World;
|
Oyster::Math::Float4x4 *World;
|
||||||
bool Visible;
|
bool Visible;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
//#include "OysterMath.h"
|
//#include "OysterMath.h"
|
||||||
//#include "ICollideable.h"
|
//#include "ICollideable.h"
|
||||||
|
|
||||||
using namespace Oyster::Math;
|
//using namespace Oyster::Math;
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue