-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelFormats.cpp
More file actions
76 lines (63 loc) · 2.1 KB
/
Copy pathModelFormats.cpp
File metadata and controls
76 lines (63 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// ===========================================================================
/// <summary>
/// ModelFormats.cpp
/// DirectXIntroduction
/// created by Mehrdad Soleimanimajd on 08.09.2019
/// </summary>
/// <created>ʆϒʅ, 08.09.2019</created>
/// <changed>ʆϒʅ, 04.07.2023</changed>
// ===========================================================================
#include "ModelFormats.h"
#include "Shared.h"
unsigned int VertexTexDiffuseL::read (const char* path, VertexL** vertices)
{
try
{
std::ifstream file (path);
unsigned int count {0};
std::string type {""};
if (file.is_open ())
{
std::string input;
std::stringstream stream;
std::getline (file, input);
stream << input;
stream >> count;
stream >> type;
stream.clear ();
*vertices = new (std::nothrow) VertexL [count];
unsigned int index {0};
for (unsigned int i = 3; i <= count; i += 3)
{
std::getline (file, input);
stream << input;
index = i - 3;
// read one triangle
while (index != i)
{
stream >> (*vertices) [index].position.x >> (*vertices) [index].position.y >> (*vertices) [index].position.z;
stream >> (*vertices) [index].texture.x >> (*vertices) [index].texture.y;
stream >> (*vertices) [index].normal.x >> (*vertices) [index].normal.y >> (*vertices) [index].normal.z;
index++;
}
stream.clear ();
}
}
file.close ();
return count;
} catch (const std::exception& ex)
{
PointerProvider::getFileLogger ()->push (logType::error, std::this_thread::get_id (), L"mainThread",
Converter::strConverter (ex.what ()));
return 0;
}
};
void VertexTexDiffuseL::write (VertexL* data, unsigned int& count)
{
try
{
} catch (const std::exception&)
{
}
};