TDME2  1.9.200
FacesEntity.cpp
Go to the documentation of this file.
2 
3 #include <string>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
10 
11 using std::string;
12 using std::vector;
13 
18 
19 FacesEntity::FacesEntity()
20 {
21  this->id = "";
22  this->node = nullptr;
23  this->material = nullptr;
24  this->textureCoordinatesAvailable = false;
25  this->tangentBitangentAvailable = false;
26  this->lod1Distance = 64.0f;
27  this->lod2Distance = 128.0f;
28  this->lod3Distance = 192.0f;
29 }
30 
31 FacesEntity::FacesEntity(Node* node, const string& id)
32 {
33  this->id = id;
34  this->node = node;
35  this->material = nullptr;
36  this->textureCoordinatesAvailable = false;
37  this->tangentBitangentAvailable = false;
38  this->lod1Distance = 64.0f;
39  this->lod2Distance = 128.0f;
40  this->lod3Distance = 192.0f;
41 }
42 
43 void FacesEntity::setFaces(const vector<Face>& faces)
44 {
45  this->faces.clear();
46  this->faces.resize(faces.size());
47  int i = 0;
48  for (auto& face: faces) {
49  this->faces[i++] = face;
50  }
52 }
53 
55 {
58  for (auto& face: faces) {
59  const auto& textureCoordinateIndices = face.getTextureCoordinateIndices();
60  if (textureCoordinateIndices[0] != -1 && textureCoordinateIndices[1] != -1 && textureCoordinateIndices[2] != -1) textureCoordinatesAvailable = true;
61  const auto& tangentIndices = face.getTangentIndices();
62  const auto& biTangentIndices = face.getBitangentIndices();
63  if (tangentIndices[0] != -1 && tangentIndices[1] != -1 && tangentIndices[2] != -1 &&
64  biTangentIndices[0] != -1 && biTangentIndices[1] != -1 && biTangentIndices[2] != -1) tangentBitangentAvailable = true;
65  }
66 }
67 
68 void FacesEntity::setLOD1Indices(const vector<int32_t>& lod1Indices) {
69  this->lod1Indices.resize(lod1Indices.size());
70  auto i = 0;
71  for (auto lod1Index: lod1Indices) {
72  this->lod1Indices[i++] = lod1Index;
73  }
74 }
75 
76 void FacesEntity::setLOD2Indices(const vector<int32_t>& lod2Indices) {
77  this->lod2Indices.resize(lod2Indices.size());
78  auto i = 0;
79  for (auto lod2Index: lod2Indices) {
80  this->lod2Indices[i++] = lod2Index;
81  }
82 }
83 
84 void FacesEntity::setLOD3Indices(const vector<int32_t>& lod3Indices) {
85  this->lod3Indices.resize(lod3Indices.size());
86  auto i = 0;
87  for (auto lod3Index: lod3Indices) {
88  this->lod3Indices[i++] = lod3Index;
89  }
90 }
91 
Represents a model face, consisting of vertex, normal, tangent and bitangent vectors,...
Definition: Face.h:18
Node faces entity A node can have multiple entities containing faces and a applied material.
Definition: FacesEntity.h:23
FacesEntity()
Public constructor.
Definition: FacesEntity.cpp:19
void determineFeatures()
Determine features.
Definition: FacesEntity.cpp:54
vector< int32_t > lod1Indices
Definition: FacesEntity.h:31
vector< int32_t > lod2Indices
Definition: FacesEntity.h:32
vector< int32_t > lod3Indices
Definition: FacesEntity.h:33
void setLOD2Indices(const vector< int32_t > &lod2Indices)
Set LOD2 indices.
Definition: FacesEntity.cpp:76
void setLOD1Indices(const vector< int32_t > &lod1Indices)
Set LOD1 indices.
Definition: FacesEntity.cpp:68
void setLOD3Indices(const vector< int32_t > &lod3Indices)
Set LOD3 indices.
Definition: FacesEntity.cpp:84
void setFaces(const vector< Face > &faces)
Set up entity's faces.
Definition: FacesEntity.cpp:43
Represents a material.
Definition: Material.h:23
Model node.
Definition: Node.h:32