Programming/D3D12
[책공부] Chap7 연습 문제
Dorasima
2024. 1. 8. 17:54
연습 문제 1
연습 문제 2
연습 문제 3
연습 문제에서 주어진 건
Vertex 개수가 몇개인지, Type이 어떻게 되는지
Index가 몇개인지 알려주고,
{} 안에 공백으로 포멧에 맞게 예쁘게 구분되어 들어었었다.
머... 파일 입출력을 잘 못하기도 하고, 귀찮기도 해서...
오로지 이 예제 텍스트 파일을 위한 읽기 함수를 만들었다.
namespace Prac3
{
void Prac3VerticesNIndicies(const wstring& _Path, vector<VertexSkull>& _outVertices, vector<uint32_t>& _outIndices)
{
ifstream fin;
fin.open(_Path);
string TrashBin;
UINT VertexCount;
UINT IndicesCount;
float px, py, pz, nx, ny, nz;
uint32_t index;
if (fin.is_open())
{
fin >> TrashBin;
fin >> VertexCount;
fin >> TrashBin;
fin >> IndicesCount;
IndicesCount *= 3;
_outVertices.reserve(VertexCount);
_outIndices.reserve(IndicesCount);
getline(fin, TrashBin);
getline(fin, TrashBin);
fin >> TrashBin;
for (UINT i = 0; i < VertexCount; i++)
{
fin >> px >> py >> pz >> nx >> ny >> nz;
XMFLOAT3 pos(px, py, pz);
XMFLOAT3 norm(nx, ny, nz);
VertexSkull skullVert = { pos, norm };
_outVertices.push_back(skullVert);
}
fin >> TrashBin;
fin >> TrashBin;
fin >> TrashBin;
for (UINT i = 0; i < IndicesCount; i++)
{
fin >> index;
_outIndices.push_back(index);
}
fin >> TrashBin;
}
fin.close();
}
}
(ㄹㅇㅋㅋ)
그리고 바뀐 main은
(클릭하면 커집니다.)
더보기
책 : DirectX 12를 이용한 3D 게임 프로그래밍 입문