-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtexture_packer_model_loading.cpp
52 lines (49 loc) · 2.81 KB
/
texture_packer_model_loading.cpp
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
#include "texture_packer_model_loading.hpp"
std::vector<IVPNTPRigged> convert_ivpnt_to_ivpntpr(std::vector<IVPNTRigged> &ivptrs, TexturePacker &texture_packer) {
std::vector<IVPNTPRigged> ivpntprs = {};
for (auto &ivpntr : ivptrs) {
std::vector<glm::vec2> packed_texture_coordinates;
for (auto &tc : ivpntr.texture_coordinates) {
auto ptc = texture_packer.get_packed_texture_coordinate(ivpntr.texture, tc);
packed_texture_coordinates.push_back(ptc);
}
int packed_texture_index = texture_packer.get_packed_texture_index_of_texture(ivpntr.texture);
IVPNTPRigged ivpntpr(ivpntr.indices, ivpntr.xyz_positions, ivpntr.normals, packed_texture_coordinates,
packed_texture_index, ivpntr.texture, ivpntr.bone_data);
ivpntprs.push_back(ivpntpr);
}
return ivpntprs;
}
std::vector<IVPTexturePacked> convert_ivpt_to_ivptp(std::vector<IVPTextured> &ivpts, TexturePacker &texture_packer) {
std::vector<IVPTexturePacked> ivptps = {};
for (auto &ivpt : ivpts) {
std::vector<glm::vec2> packed_texture_coordinates;
for (auto &tc : ivpt.texture_coordinates) {
auto ptc = texture_packer.get_packed_texture_coordinate(ivpt.texture_path, tc);
packed_texture_coordinates.push_back(ptc);
}
int packed_texture_index = texture_packer.get_packed_texture_index_of_texture(ivpt.texture_path);
int texture_bounding_box_index =
texture_packer.get_packed_texture_bounding_box_index_of_texture(ivpt.texture_path);
IVPTexturePacked ivptp(ivpt.indices, ivpt.xyz_positions, ivpt.texture_coordinates, packed_texture_coordinates,
packed_texture_index, texture_bounding_box_index, ivpt.texture_path);
ivptps.push_back(ivptp);
}
return ivptps;
}
std::vector<IVPNTexturePacked> convert_ivpnt_to_ivpntp(std::vector<IVPNTextured> &ivpnts,
TexturePacker &texture_packer) {
std::vector<IVPNTexturePacked> ivpntps = {};
for (auto &ivpnt : ivpnts) {
std::vector<glm::vec2> packed_texture_coordinates =
texture_packer.get_packed_texture_coordinates(ivpnt.texture_path, ivpnt.texture_coordinates);
int packed_texture_index = texture_packer.get_packed_texture_index_of_texture(ivpnt.texture_path);
int texture_bounding_box_index =
texture_packer.get_packed_texture_bounding_box_index_of_texture(ivpnt.texture_path);
IVPNTexturePacked ivpntp(ivpnt.indices, ivpnt.xyz_positions, ivpnt.normals, ivpnt.texture_coordinates,
packed_texture_coordinates, packed_texture_index, texture_bounding_box_index,
ivpnt.texture_path);
ivpntps.push_back(ivpntp);
}
return ivpntps;
}