diff --git a/Debug/Tester.ilk b/Debug/Tester.ilk index 79981c45..019c0cea 100644 Binary files a/Debug/Tester.ilk and b/Debug/Tester.ilk differ diff --git a/Debug/Tester.pdb b/Debug/Tester.pdb index f2f5e970..5635e396 100644 Binary files a/Debug/Tester.pdb and b/Debug/Tester.pdb differ diff --git a/OysterGraphics/Core/CoreIncludes.h b/OysterGraphics/Core/CoreIncludes.h index 3e1d9306..26b1ce0c 100644 --- a/OysterGraphics/Core/CoreIncludes.h +++ b/OysterGraphics/Core/CoreIncludes.h @@ -6,7 +6,7 @@ // http://lolengine.net/blog/2011/3/4/fuck-you-microsoft-near-far-macros #include #include -#include +#include #pragma comment(lib, "d3d11.lib") #pragma comment(lib, "d3dcompiler.lib") diff --git a/OysterGraphics/Core/ShaderManager.cpp b/OysterGraphics/Core/ShaderManager.cpp index fe40bb84..ca607249 100644 --- a/OysterGraphics/Core/ShaderManager.cpp +++ b/OysterGraphics/Core/ShaderManager.cpp @@ -140,7 +140,7 @@ namespace Oyster case Core::ShaderManager::ShaderType::Pixel: ID3D11PixelShader* pixel; - + if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"ps_5_0",0,0,&Shader,&Error))) { std::string fel = (char*)Error->GetBufferPointer(); @@ -168,7 +168,7 @@ namespace Oyster case Core::ShaderManager::ShaderType::Geometry: ID3D11GeometryShader* geometry; - + if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"gs_5_0",0,0,&Shader,&Error))) { std::string fel = (char*)Error->GetBufferPointer(); diff --git a/OysterGraphics/FileLoader/ObjReader.cpp b/OysterGraphics/FileLoader/ObjReader.cpp index e4d12b91..b5ad5d4e 100644 --- a/OysterGraphics/FileLoader/ObjReader.cpp +++ b/OysterGraphics/FileLoader/ObjReader.cpp @@ -1,268 +1,122 @@ -#include "ObjReader.h" -#include "Utilities.h" -#include "..\Core\Core.h" +#include "OBJReader.h" +#include #include -#include using namespace std; -using namespace Oyster::FileLoaders; -using namespace Oyster; -using namespace Oyster::Math; - -ObjReader *ObjReader::LoadFile(std::string fileName, Oyster::Math::Float4x4 transform) +OBJReader::OBJReader() { - static std::map cache; - - ObjReader *reader = NULL; - - if (cache.count(fileName)) - { - reader = cache[fileName]; - } - else - { - reader = new ObjReader(); - reader->ParseFile(fileName, transform); - - cache[fileName] = reader; - } - - return reader; + _mPos = 0; + _mNormal = 0; + _mTexel = 0; } -ObjReader::ObjReader(void) +OBJReader::~OBJReader() { + } - -ObjReader::~ObjReader(void) +void OBJReader::readOBJFile( wstring fileName ) { -} + fstream inStream; + string typeOfData = " "; + float vertexData; + string face1, face2, face3; -void ObjReader::ParseFile(std::string fileName, Float4x4 transform) -{ - ifstream input; - input.open(fileName.c_str()); - - if(!input.is_open()) + inStream.open( fileName, fstream::in ); + + if( inStream.is_open() ) { - return; - } - - string path; - Utility::String::extractDirPath(path,fileName,'\\'); - - std::vector VertexList; - std::vector vList; - std::vector nList; - std::vector uvList; - Vertex vertex1, vertex2, vertex3; - Float3 face[3]; - Float3 position, normal; - Float2 uv; - string s; - - while(!input.eof()) - { - getline(input,s); - int offset = (int)s.find(' '); - - if(offset!=-1) + while( !inStream.eof() ) { - string c = s.substr(0,offset); + inStream >> typeOfData; - if(c=="v") + if( typeOfData == "v" ) { - position = readVertex(offset,s); - vList.push_back(position); + Oyster::Math::Float3 position; + + inStream >> vertexData; + position.x = vertexData; + + inStream >> vertexData; + position.y = vertexData; + + inStream >> vertexData; + position.z = vertexData; + + _mVertexCoord.push_back( position ); + } - else if(c=="vt") + else if( typeOfData == "vt" ) { - uv = readUV(offset,s); - uvList.push_back(uv); + Oyster::Math::Float2 texel; + inStream >> vertexData; + texel.x = vertexData; + + inStream >> vertexData; + texel.y = 1 - vertexData; + + _mVertexTexture.push_back( texel ); } - else if(c=="vn") + else if( typeOfData == "vn" ) { - normal = readNormal(offset,s); - nList.push_back(normal); + Oyster::Math::Float3 normal; + inStream >> vertexData; + normal.x = vertexData; + + inStream >> vertexData; + normal.y = vertexData; + + inStream >> vertexData; + normal.z = vertexData; + + _mVertexNormal.push_back( normal ); } - else if(c=="f") + else if( typeOfData == "f" ) { - readFace(offset, s, face); + inStream >> face1; + stringSplit( face1 ); + + addToOBJarray(); - vertex1.Position = vList[(int)face[0].x]; - vertex1.UV = uvList[(int)face[0].y]; - vertex1.Normal = nList[(int)face[0].z]; + inStream >> face2; + stringSplit( face2 ); - vertex2.Position = vList[(int)face[1].x]; - vertex2.UV = uvList[(int)face[1].y]; - vertex2.Normal = nList[(int)face[1].z]; + addToOBJarray(); - vertex3.Position = vList[(int)face[2].x]; - vertex3.UV = uvList[(int)face[2].y]; - vertex3.Normal = nList[(int)face[2].z]; + inStream >> face3; + stringSplit( face3 ); - VertexList.push_back(vertex1); - VertexList.push_back(vertex3); - VertexList.push_back(vertex2); - } - else if(c=="mtllib") - { - this->materials = GetMaterials(path+s.substr(offset+1)); + addToOBJarray(); } } } - input.close(); - - this->numVertices = VertexList.size(); - this->vertices = new Vertex[this->numVertices]; - - for(size_t i=0;inumVertices;++i) - { - vertices[i].Position=Math::transformVector(Math::Float4(VertexList[i].Position,1),transform); - vertices[i].Normal=Math::transformVector(Math::Float4(VertexList[i].Normal,0),transform); - vertices[i].UV = VertexList[i].UV; - } + inStream.close(); } -void ObjReader::GetVertexData(Vertex **vertex,int &numVertex, std::map &Textures) +//Private functions +void OBJReader::stringSplit( string strToSplit ) { - numVertex=(int)this->numVertices; - (*vertex)=this->vertices; - Textures = this->materials; + char delim = '/'; + string vPos, vNormal, vTexel; + stringstream aStream(strToSplit); + getline( aStream, vPos, delim ); + getline( aStream, vTexel, delim ); + getline( aStream, vNormal ); + + _mPos = atoi( vPos.c_str() ); + _mNormal = atoi( vNormal.c_str() ); + _mTexel = atoi( vTexel.c_str() ); + } -Float3 ObjReader::extract(std::string d) +void OBJReader::addToOBJarray() { - Float3 data; - int offset=(int)d.find('/'); - data.x=(float)atoi(d.substr(1,offset).c_str())-1; + OBJFormat temp; - int newOffset = (int)d.find('/',offset+1); - string d2=d.substr(offset+1,newOffset-offset-1); - data.y=(float)atoi(d2.c_str())-1; - offset=newOffset; + temp._d3VertexCoord = _mVertexCoord.at( _mPos - 1 ); + temp._d3VertexNormal = _mVertexNormal.at( _mNormal - 1 ); + temp._d3VertexTexture = _mVertexTexture.at( _mTexel - 1 ); - newOffset = (int)d.find('/',offset+1); - string d3=d.substr(offset+1,newOffset-offset-1); - data.z=(float)atoi(d3.c_str())-1; - - return data; -} - -Float3 ObjReader::readVertex(int offset,string s) -{ - int newOffset = (int)s.find(' ',offset+1); - Float3 vertex; - string d = s.substr(offset,newOffset-offset); - vertex.x = (float)atof(d.c_str()); - offset=newOffset; - - newOffset = (int)s.find(' ',offset+1); - vertex.y = (float)atof(s.substr(offset,newOffset-offset).c_str()); - offset=newOffset; - - newOffset = (int)s.find(' ',offset+1); - vertex.z = (float)-atof(s.substr(offset,newOffset-offset).c_str()); - - return vertex; -} - -Float2 ObjReader::readUV(int offset,string s) -{ - int newOffset = (int)s.find(' ',offset+1); - Float2 uv; - string d = s.substr(offset,newOffset-offset); - uv.x =(float)atof(d.c_str()); - offset=newOffset; - - newOffset = (int)s.find(' ',offset+1); - d = s.substr(offset,newOffset-offset); - uv.y =1- (float)atof(d.c_str()); - offset=newOffset; - - return uv; -} - -Float3 ObjReader::readNormal(int offset,string s) -{ - int newOffset = (int)s.find(' ',offset+1); - Float3 vertex; - string d = s.substr(offset,newOffset-offset); - vertex.x = (float)atof(d.c_str()); - offset=newOffset; - - newOffset = (int)s.find(' ',offset+1); - vertex.y = (float)atof(s.substr(offset,newOffset-offset).c_str()); - offset=newOffset; - - newOffset = (int)s.find(' ',offset+1); - vertex.z = (float)-atof(s.substr(offset,newOffset-offset).c_str()); - - return vertex; -} - -void ObjReader::readFace(int offset,string s, Oyster::Math::Float3 face[3]) -{ - int newOffset = (int)s.find(' ',offset+1); - string point1 = s.substr(offset,newOffset-offset); - - offset = newOffset; - newOffset = (int)s.find(' ',offset+1); - string point2 = s.substr(offset,newOffset-offset); - - offset = newOffset; - newOffset = (int)s.find(' ',offset+1); - string point3 = s.substr(offset,newOffset-offset); - - face[0] = extract(point1); - face[1] = extract(point2); - face[2] = extract(point3); -} - -std::map ObjReader::GetMaterials(std::string fileName) -{ - ifstream input; - input.open(fileName.c_str()); - - std::map materials; - ID3D11ShaderResourceView *srv; - string texture; - string s; - string path; - Utility::String::extractDirPath(path,fileName,'\\'); - if(!input.is_open()) - return materials; - - while(!input.eof()) - { - getline(input,s); - int offset = (int)s.find(' '); - if(offset!=-1) - { - string c = s.substr(0,offset); - if(c=="map_Kd") - { - texture = path+s.substr(offset+1); - D3DX11CreateShaderResourceViewFromFile(Oyster::Core::Device,texture.c_str(), NULL, NULL, &srv, NULL); - materials["Diffuse"] = srv; - } - if(c=="map_G") - { - texture = path+s.substr(offset+1); - D3DX11CreateShaderResourceViewFromFile(Oyster::Core::Device,texture.c_str(), NULL, NULL, &srv, NULL); - materials["Glow"] = srv; - } - if(c=="map_Ks") - { - texture = path+s.substr(offset+1); - D3DX11CreateShaderResourceViewFromFile(Oyster::Core::Device,texture.c_str(), NULL, NULL, &srv, NULL); - materials["Specular"] = srv; - } - } - } - input.close(); - - return materials; -} + _myOBJ.push_back( temp ); +} \ No newline at end of file diff --git a/OysterGraphics/FileLoader/ObjReader.h b/OysterGraphics/FileLoader/ObjReader.h index a846181e..562d81fc 100644 --- a/OysterGraphics/FileLoader/ObjReader.h +++ b/OysterGraphics/FileLoader/ObjReader.h @@ -1,42 +1,53 @@ -#pragma once -#include "..\Core\CoreIncludes.h" -#include "..\Math\OysterMath.h" +#ifndef OBJREADER_H +#define OBJREADER_H +#include "..\..\Misc\Utilities.h" +#include "..\..\OysterMath\OysterMath.h" -namespace Oyster +//#include + + + +class OBJReader { - namespace FileLoaders - { - class ObjReader + public: + struct OBJFormat { - public: - struct Vertex - { - Oyster::Math::Float3 Position; - Oyster::Math::Float3 Normal; - Oyster::Math::Float2 UV; - }; - - static ObjReader *LoadFile(std::string fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity); - - ObjReader(void); - ~ObjReader(void); - - void GetVertexData(Vertex **vertex,int &numVertex, std::map &textures); - - private: - Vertex *vertices; - size_t numVertices; - std::map materials; - - void ParseFile(std::string fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity); - - Oyster::Math::Float3 extract(std::string d); - Oyster::Math::Float3 readVertex(int offset,std::string s); - Oyster::Math::Float2 readUV(int offset,std::string s); - Oyster::Math::Float3 readNormal(int offset,std::string s); - void readFace(int offset,std::string s, Oyster::Math::Float3 face[3]); - - std::map GetMaterials(std::string fileName); + Oyster::Math::Float3 _d3VertexCoord; + Oyster::Math::Float2 _d3VertexTexture; + Oyster::Math::Float3 _d3VertexNormal; }; - } -} \ No newline at end of file + + struct OBJMaterialData + { + string _name; + string _mapKd; + float _kd[3]; + float _ka[3]; + float _tf[3]; + float _ni; + + OBJMaterialData() + { + _name = " "; + _mapKd = " "; + } + }; + std::vector _myOBJ; + private: + + vector _mVertexCoord, _mVertexNormal; + vector _mVertexTexture; + + int _mNrOfCoords, _mNrOfNormals, _mNrOfTexels, _mNrOfFaces; + int _mPos, _mNormal, _mTexel; + void stringSplit( string strToSplit ); + void addToOBJarray(); + + public: + OBJReader(); + ~OBJReader(); + + void readOBJFile( wstring fileName); + +}; +#endif \ No newline at end of file diff --git a/OysterGraphics/OysterGraphics.vcxproj b/OysterGraphics/OysterGraphics.vcxproj index 45df7d9d..51fd1bd9 100644 --- a/OysterGraphics/OysterGraphics.vcxproj +++ b/OysterGraphics/OysterGraphics.vcxproj @@ -69,6 +69,9 @@ $(SolutionDir)..\External\Lib\$(ProjectName)\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D + $(WindowsSDK_IncludePath);$(VCInstallDir)atlmfc\include;$(VCInstallDir)include + $(WindowsSDK_LibraryPath_x86);$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib + $(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH) $(SolutionDir)..\External\Lib\$(ProjectName)\ @@ -79,6 +82,10 @@ $(SolutionDir)..\External\Lib\$(ProjectName)\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D + $(WindowsSDK_IncludePath);$(VCInstallDir)atlmfc\include;$(VCInstallDir)include + $(WindowsSDK_LibraryPath_x86);$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib + $(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH) + $(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib $(SolutionDir)..\External\Lib\$(ProjectName)\ @@ -101,7 +108,7 @@ Level3 Disabled true - ..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + ..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) true @@ -142,6 +149,7 @@ + diff --git a/OysterGraphics/OysterGraphics.vcxproj.filters b/OysterGraphics/OysterGraphics.vcxproj.filters index 412e083a..e5f8a058 100644 --- a/OysterGraphics/OysterGraphics.vcxproj.filters +++ b/OysterGraphics/OysterGraphics.vcxproj.filters @@ -45,6 +45,9 @@ Source Files + + Source Files + diff --git a/Tester/Debug/CL.read.1.tlog b/Tester/Debug/CL.read.1.tlog index f673f687..21117297 100644 Binary files a/Tester/Debug/CL.read.1.tlog and b/Tester/Debug/CL.read.1.tlog differ diff --git a/Tester/Debug/CL.write.1.tlog b/Tester/Debug/CL.write.1.tlog index 49f3d35c..18acae38 100644 Binary files a/Tester/Debug/CL.write.1.tlog and b/Tester/Debug/CL.write.1.tlog differ diff --git a/Tester/Debug/MainTest.obj b/Tester/Debug/MainTest.obj index 3fa96e29..704dcbff 100644 Binary files a/Tester/Debug/MainTest.obj and b/Tester/Debug/MainTest.obj differ diff --git a/Tester/Debug/Tester.lastbuildstate b/Tester/Debug/Tester.lastbuildstate index 40d074b4..a9539db7 100644 --- a/Tester/Debug/Tester.lastbuildstate +++ b/Tester/Debug/Tester.lastbuildstate @@ -1,2 +1,2 @@ #v4.0:v110:false -Debug|Win32|C:\DanBias\Danbias\| +Debug|Win32|C:\Users\Tobias\Documents\GitHub\Danbias\| diff --git a/Tester/Debug/Tester.log b/Tester/Debug/Tester.log index 2c2e96b0..c8588202 100644 --- a/Tester/Debug/Tester.log +++ b/Tester/Debug/Tester.log @@ -1,13 +1,17 @@ -Build started 11/15/2013 11:04:26 AM. - 1>Project "C:\DanBias\Danbias\Tester\Tester.vcxproj" on node 3 (Build target(s)). - 1>Link: - C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\DanBias\Danbias\Debug\Tester.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\DanBias\Danbias\Debug\Tester.pdb" /SUBSYSTEM:WINDOWS /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\DanBias\Danbias\Debug\Tester.lib" /MACHINE:X86 Debug\MainTest.obj - C:\DanBias\External\Lib\Misc\Misc_x86D.lib - C:\DanBias\External\Lib\OysterMath\OysterMath_x86D.lib - C:\DanBias\External\Lib\OysterGraphics\OysterGraphics_x86D.lib - Tester.vcxproj -> C:\DanBias\Danbias\Debug\Tester.exe - 1>Done Building Project "C:\DanBias\Danbias\Tester\Tester.vcxproj" (Build target(s)). +Build started 2013-11-19 09:36:20. + 1>Project "C:\Users\Tobias\Documents\GitHub\Danbias\Tester\Tester.vcxproj" on node 2 (Build target(s)). + 1>InitializeBuildStatus: + Creating "Debug\Tester.unsuccessfulbuild" because "AlwaysCreate" was specified. + ClCompile: + All outputs are up-to-date. + Link: + All outputs are up-to-date. + Tester.vcxproj -> C:\Users\Tobias\Documents\GitHub\Danbias\Debug\Tester.exe + FinalizeBuildStatus: + Deleting file "Debug\Tester.unsuccessfulbuild". + Touching "Debug\Tester.lastbuildstate". + 1>Done Building Project "C:\Users\Tobias\Documents\GitHub\Danbias\Tester\Tester.vcxproj" (Build target(s)). Build succeeded. -Time Elapsed 00:00:00.98 +Time Elapsed 00:00:00.30 diff --git a/Tester/Debug/Tester.vcxprojResolveAssemblyReference.cache b/Tester/Debug/Tester.vcxprojResolveAssemblyReference.cache index 7a891077..93520706 100644 Binary files a/Tester/Debug/Tester.vcxprojResolveAssemblyReference.cache and b/Tester/Debug/Tester.vcxprojResolveAssemblyReference.cache differ diff --git a/Tester/Debug/cl.command.1.tlog b/Tester/Debug/cl.command.1.tlog index d459c2da..71127474 100644 Binary files a/Tester/Debug/cl.command.1.tlog and b/Tester/Debug/cl.command.1.tlog differ diff --git a/Tester/Debug/link.command.1.tlog b/Tester/Debug/link.command.1.tlog index e5978dc7..0ee459a7 100644 Binary files a/Tester/Debug/link.command.1.tlog and b/Tester/Debug/link.command.1.tlog differ diff --git a/Tester/Debug/link.read.1.tlog b/Tester/Debug/link.read.1.tlog index a6faf923..ef3fe5fe 100644 Binary files a/Tester/Debug/link.read.1.tlog and b/Tester/Debug/link.read.1.tlog differ diff --git a/Tester/Debug/link.write.1.tlog b/Tester/Debug/link.write.1.tlog index e18501b8..8eef2d0b 100644 Binary files a/Tester/Debug/link.write.1.tlog and b/Tester/Debug/link.write.1.tlog differ diff --git a/Tester/Debug/vc110.idb b/Tester/Debug/vc110.idb index 7790813b..f13513df 100644 Binary files a/Tester/Debug/vc110.idb and b/Tester/Debug/vc110.idb differ diff --git a/Tester/Debug/vc110.pdb b/Tester/Debug/vc110.pdb index 7a8bf47b..686f149c 100644 Binary files a/Tester/Debug/vc110.pdb and b/Tester/Debug/vc110.pdb differ diff --git a/Tester/Tester.vcxproj b/Tester/Tester.vcxproj index ccfb910f..d45cf245 100644 --- a/Tester/Tester.vcxproj +++ b/Tester/Tester.vcxproj @@ -41,6 +41,9 @@ true + $(WindowsSDK_IncludePath);$(VCInstallDir)atlmfc\include;$(VCInstallDir)include + $(WindowsSDK_LibraryPath_x86);$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib + $(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH) false