-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOBJLoader.h
23 lines (19 loc) · 1.08 KB
/
OBJLoader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once
#include <windows.h>
#include <d3d11_1.h>
#include <directxmath.h>
#include <fstream> //For loading in an external file
#include <vector> //For storing the XMFLOAT3/2 variables
#include <map> //For fast searching when re-creating the index buffer
#include "Structures.h"
using namespace DirectX;
namespace OBJLoader
{
//The only method you'll need to call
MeshData Load(char* filename, ID3D11Device* _pd3dDevice, bool invertTexCoords = true);
//Helper methods for the above method
//Searhes to see if a similar vertex already exists in the buffer -- if true, we re-use that index
bool FindSimilarVertex(const SimpleVertex& vertex, std::map<SimpleVertex, unsigned short>& vertToIndexMap, unsigned short& index);
//Re-creates a single index buffer from the 3 given in the OBJ file
void CreateIndices(const std::vector<XMFLOAT3>& inVertices, const std::vector<XMFLOAT2>& inTexCoords, const std::vector<XMFLOAT3>& inNormals, std::vector<unsigned short>& outIndices, std::vector<XMFLOAT3>& outVertices, std::vector<XMFLOAT2>& outTexCoords, std::vector<XMFLOAT3>& outNormals);
};