-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.hpp
More file actions
95 lines (83 loc) · 3.25 KB
/
utils.hpp
File metadata and controls
95 lines (83 loc) · 3.25 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#pragma once
#include "pch.h"
#include "import_bfm.hpp"
namespace br2proj::utils {
using namespace br2proj::bfm;
auto conv(point_3f pt) {
return vector3{ static_cast<decltype(vector3::x)>(pt.x), static_cast<decltype(vector3::y)>(pt.y),static_cast<decltype(vector3::z)>(pt.z) };
}
auto conv(point_2f pt) {
return vector2{ static_cast<decltype(vector2::x)>(pt.x), static_cast<decltype(vector2::y)>(pt.y) };
}
template <std::size_t TSize>
auto conv(const fstring<TSize>& s) {
return string(s.data());
}
std::ifstream in_bstream(const fs::path& path) {
std::ifstream is(path, std::ios::binary);
is.exceptions(std::ios::eofbit | std::ios::failbit | std::ios::badbit);
return is;
}
template <class T=std::ofstream>
T out_bstream(const fs::path& path) {
T os(path, std::ios::binary);
os.exceptions(std::ios::eofbit | std::ios::failbit | std::ios::badbit);
return os;
}
/*std::ostream& operator<<(std::ostream& os, const vector3& v) {
os << "[" << v.x << " " << v.y <<" " << v.z<< "]";
return os;
}
std::ostream& operator<<(std::ostream& os, const point_3f& v) {
os << "[" << v.x << " " << v.y << " " << v.z<< "]";
return os;
}
std::ostream& operator<<(std::ostream& os, const vector2& v) {
os << "[" << v.x << " " << v.y << "]";
return os;
}
std::ostream& operator<<(std::ostream& os, const point_2f& v) {
os << "[" << v.x << " " << v.y << "]";
return os;
}
std::ostream& operator<<(std::ostream& os, const matrix4x4& v) {
os << "[" << v.a1 << " " << v.a2 << " " << v.a3<<" "<<v.a4 << "\n";
os << v.b1 << " " << v.b2 << " " << v.b3 << " " << v.b4 << "\n";
os << v.c1 << " " << v.c2 << " " << v.c3 << " " << v.c4 << "\n";
os << v.d1 << " " << v.d2 << " " << v.d3 << " " << v.d4 << "]";
return os;
}
std::ostream& operator<<(std::ostream& os, const std::array<float, 9> arr) {
for (int i = 0;i < arr.size();++i) {
os << arr[i]<<' ';
if ((i+1) % 3 == 0)
os << '\n';
}
return os;
}*/
//utils for assimp
template <typename T = ai_real>
constexpr aiVector2t<T> aiconv(vector2 v) {
return aiVector2t<T>(static_cast<T>(v.x), static_cast<T>(v.y));
}
template <typename T = ai_real>
constexpr aiVector3t<T> aiuvconv(vector2 uv, T c = 0) {
return aiVector3t<T>(static_cast<T>(uv.x), static_cast<T>(uv.y), c);
}
template <typename T = ai_real>
constexpr aiVector3t<T> aiconv(vector3 v) {
return aiVector3t<T>(static_cast<T>(v.x), static_cast<T>(v.y), static_cast<T>(v.z));
}
aiFace aiconv(triangle v) {
aiFace r;
using T = std::remove_pointer_t<decltype(r.mIndices)>;
r.mNumIndices = 3;
r.mIndices = new T[]{ static_cast<T>(v.a), static_cast<T>(v.b), static_cast<T>(v.c) };
return r;
}
aiString aiconv(string str) {
//TODO вход¤щ¤¤ строка может содержать символы после \0, возможно стоит искуственно ограничить конвертацию
return aiString(str);
}
//end of utils for assimp
}