3D Repo Bouncer  1.4
repo_node_mesh.h
1 
21 #pragma once
22 #include "repo_node.h"
23 
24 #include "../../../repo_bouncer_global.h"
25 
26 namespace repo {
27  namespace core {
28  namespace model {
29  //------------------------------------------------------------------------------
30  //
31  // Fields specific only to mesh
32  //
33  //------------------------------------------------------------------------------
34 #define REPO_NODE_MESH_LABEL_VERTICES "vertices" //<! vertices array
35 #define REPO_NODE_MESH_LABEL_VERTICES_COUNT "vertices_count" //<! vertices size
36 #define REPO_NODE_MESH_LABEL_VERTICES_BYTE_COUNT "vertices_byte_count"
37  //------------------------------------------------------------------------------
38 #define REPO_NODE_MESH_LABEL_FACES "faces" //<! faces array label
39 #define REPO_NODE_MESH_LABEL_FACES_COUNT "faces_count" //<! number of faces
40 #define REPO_NODE_MESH_LABEL_FACES_BYTE_COUNT "faces_byte_count"
41  //------------------------------------------------------------------------------
42 #define REPO_NODE_MESH_LABEL_NORMALS "normals"
43  //------------------------------------------------------------------------------
44 #define REPO_NODE_MESH_LABEL_OUTLINE "outline"
45 #define REPO_NODE_MESH_LABEL_BOUNDING_BOX "bounding_box"
46  //------------------------------------------------------------------------------
47 #define REPO_NODE_MESH_LABEL_UV_CHANNELS "uv_channels"
48 #define REPO_NODE_MESH_LABEL_UV_CHANNELS_COUNT "uv_channels_count"
49 #define REPO_NODE_MESH_LABEL_UV_CHANNELS_BYTE_COUNT "uv_channels_byte_count"
50 #define REPO_NODE_MESH_LABEL_SHA256 "sha256"
51 #define REPO_NODE_MESH_LABEL_COLORS "colors"
52  //------------------------------------------------------------------------------
53 #define REPO_NODE_MESH_LABEL_MAP_ID "map_id"
54 #define REPO_NODE_MESH_LABEL_VERTEX_FROM "v_from"
55 #define REPO_NODE_MESH_LABEL_VERTEX_TO "v_to"
56 #define REPO_NODE_MESH_LABEL_TRIANGLE_FROM "t_from"
57 #define REPO_NODE_MESH_LABEL_TRIANGLE_TO "t_to"
58 #define REPO_NODE_MESH_LABEL_MATERIAL_ID "mat_id"
59 #define REPO_NODE_MESH_LABEL_MERGE_MAP "m_map"
60  //------------------------------------------------------------------------------
61 
62  class REPO_API_EXPORT MeshNode :public RepoNode
63  {
64  public:
65 
69  MeshNode();
70 
76  MeshNode(RepoBSON bson,
77  const std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>> &binMapping =
78  std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>>()
79  );
80 
84  ~MeshNode();
85 
93  uint32_t getMFormat() const;
94 
99  virtual std::string getType() const
100  {
101  return REPO_NODE_TYPE_MESH;
102  }
103 
108  virtual NodeType getTypeAsEnum() const
109  {
110  return NodeType::MESH;
111  }
112 
122  virtual bool positionDependant() { return true; }
123 
131  virtual bool sEqual(const RepoNode &other) const;
132 
133  /*
134  * ------------- Delusional modifiers --------------
135  * These are like "setters" but not. We are actually
136  * creating a new bson object with the changed field
137  */
138 
146  virtual RepoNode cloneAndApplyTransformation(
147  const std::vector<float> &matrix) const;
148 
153  MeshNode cloneAndUpdateMeshMapping(
154  const std::vector<repo_mesh_mapping_t> &vec,
155  const bool &overwrite = false);
156 
165  std::vector<repo_vector_t> getBoundingBox() const;
166 
167  static std::vector<repo_vector_t> getBoundingBox(RepoBSON &bbArr);
168 
172  std::vector<repo_color4d_t> getColors() const;
173 
177  std::vector<repo_face_t> getFaces() const;
178 
179  std::vector<repo_mesh_mapping_t> getMeshMapping() const;
180 
184  std::vector<repo_vector_t> getNormals() const;
185 
189  std::vector<repo_vector2d_t> getUVChannels() const;
190 
194  std::vector<std::vector<repo_vector2d_t>> getUVChannelsSeparated() const;
195 
199  std::vector<repo_vector_t> getVertices() const;
200 
201  private:
207  RepoBSON meshMappingAsBSON(const repo_mesh_mapping_t &mapping);
208 
212  std::vector<uint32_t> getFacesSerialized() const;
213  };
214  } //namespace model
215  } //namespace core
216 } //namespace repo
Definition: repo_connection_pool_mongo.h:32
Definition: repo_node_utils.h:81
Definition: repo_node_mesh.h:62
Definition: repo_node.h:33
Definition: repo_bson.h:53
virtual NodeType getTypeAsEnum() const
Definition: repo_node_mesh.h:108
virtual std::string getType() const
Definition: repo_node_mesh.h:99
virtual bool positionDependant()
Definition: repo_node_mesh.h:122