-
Notifications
You must be signed in to change notification settings - Fork 434
/
Asset.cpp
54 lines (43 loc) · 1.79 KB
/
Asset.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
53
54
// Copyright (c) Meta Platforms, Inc. and its affiliates.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include "Asset.h"
#include <Corrade/Utility/String.h>
#include "esp/geo/CoordinateFrame.h"
namespace esp {
namespace assets {
AssetInfo AssetInfo::fromPath(const std::string& path) {
using Corrade::Utility::String::endsWith;
AssetInfo info{metadata::attributes::AssetType::Unknown, path};
if (endsWith(path, "_semantic.ply")) {
info.type = metadata::attributes::AssetType::InstanceMesh;
} else if (endsWith(path, ".glb")) {
// assumes MP3D glb with gravity = -Z
info.type = metadata::attributes::AssetType::Mp3dMesh;
// Create a coordinate for the mesh by rotating the default ESP
// coordinate frame to -Z gravity
info.frame = geo::CoordinateFrame(geo::ESP_BACK, geo::ESP_UP);
}
return info;
}
bool operator==(const AssetInfo& a, const AssetInfo& b) {
return a.type == b.type && a.filepath == b.filepath && a.frame == b.frame &&
a.shaderTypeToUse == b.shaderTypeToUse &&
a.hasSemanticTextures == b.hasSemanticTextures &&
a.virtualUnitToMeters == b.virtualUnitToMeters &&
a.splitInstanceMesh == b.splitInstanceMesh &&
a.overridePhongMaterial == b.overridePhongMaterial &&
a.forceFlatShading == b.forceFlatShading;
}
bool operator!=(const AssetInfo& a, const AssetInfo& b) {
return !(a == b);
}
bool operator==(const PhongMaterialColor& a, const PhongMaterialColor& b) {
return a.ambientColor == b.ambientColor && a.diffuseColor == b.diffuseColor &&
a.specularColor == b.specularColor;
}
bool operator!=(const PhongMaterialColor& a, const PhongMaterialColor& b) {
return !(a == b);
}
} // namespace assets
} // namespace esp