-
Notifications
You must be signed in to change notification settings - Fork 32
/
extendedTriangleMesh.h
61 lines (46 loc) · 1.67 KB
/
extendedTriangleMesh.h
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
#pragma once
#include <Physics3D/math/linalg/vec.h>
#include <Physics3D/geometry/triangleMesh.h>
#include <Physics3D/datastructures/sharedArray.h>
#include "ecs/components.h"
class Polyhedron;
namespace P3D::Graphics {
struct ExtendedTriangleMesh : public TriangleMesh {
SRef<const Vec3f[]> normals;
SRef<const Vec2f[]> uvs;
SRef<const Vec3f[]> tangents;
SRef<const Vec3f[]> bitangents;
ExtendedTriangleMesh()
: TriangleMesh()
, normals(nullptr)
, uvs(nullptr)
, tangents(nullptr)
, bitangents(nullptr) {}
ExtendedTriangleMesh(const Vec3f* vertices, int vertexCount, const Triangle* triangles, int triangleCount)
: TriangleMesh(vertexCount, triangleCount, vertices, triangles) {
}
explicit ExtendedTriangleMesh(const TriangleMesh& shape) : TriangleMesh(shape) {}
void setNormalBuffer(const SRef<const Vec3f[]>& normals) {
this->normals = normals;
}
void setUVBuffer(const SRef<const Vec2f[]>& uvs) {
this->uvs = uvs;
}
void setTangentBuffer(const SRef<const Vec3f[]>& tangents) {
this->tangents = tangents;
}
void setBitangentBuffer(const SRef<const Vec3f[]>& bitangents) {
this->bitangents = bitangents;
}
Comp::Mesh::Flags getFlags() const {
using namespace Comp;
return Mesh::Flags_None
| (normals != nullptr ? Mesh::Flags_Normal : Mesh::Flags_None)
| (uvs != nullptr ? Mesh::Flags_UV : Mesh::Flags_None)
| (tangents != nullptr ? Mesh::Flags_Tangent : Mesh::Flags_None)
| (bitangents != nullptr ? Mesh::Flags_Bitangent : Mesh::Flags_None);
}
static ExtendedTriangleMesh generateSmoothNormalsShape(const TriangleMesh& underlyingMesh);
static ExtendedTriangleMesh generateSplitNormalsShape(const TriangleMesh& underlyingMesh);
};
};