Blender  V3.3
GeometryExporter.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include <set>
10 #include <string>
11 #include <vector>
12 
13 #include "COLLADASWInputList.h"
14 #include "COLLADASWLibraryGeometries.h"
15 #include "COLLADASWStreamWriter.h"
16 
17 #include "DNA_key_types.h"
18 #include "DNA_mesh_types.h"
19 #include "DNA_object_types.h"
20 #include "DNA_scene_types.h"
21 
22 #include "BKE_key.h"
23 #include "BlenderContext.h"
24 #include "ExportSettings.h"
25 #include "collada_utils.h"
26 
27 class Normal {
28  public:
29  float x;
30  float y;
31  float z;
32 
33  friend bool operator<(const Normal &, const Normal &);
34 };
35 
36 bool operator<(const Normal &, const Normal &);
37 
38 /* TODO: optimize UV sets by making indexed list with duplicates removed */
39 class GeometryExporter : COLLADASW::LibraryGeometries {
40  struct Face {
41  unsigned int v1, v2, v3, v4;
42  };
43 
44  public:
45  /* TODO: optimize UV sets by making indexed list with duplicates removed */
46  GeometryExporter(BlenderContext &blender_context,
47  COLLADASW::StreamWriter *sw,
48  BCExportSettings &export_settings)
49  : COLLADASW::LibraryGeometries(sw),
50  blender_context(blender_context),
51  export_settings(export_settings)
52  {
53  }
54 
55  void exportGeom();
56 
57  void operator()(Object *ob);
58 
59  void createLooseEdgeList(Object *ob, Mesh *me, std::string &geom_id);
60 
62  void create_mesh_primitive_list(short material_index,
63  bool has_uvs,
64  bool has_color,
65  Object *ob,
66  Mesh *me,
67  std::string &geom_id,
68  std::vector<BCPolygonNormalsIndices> &norind);
69 
71  void createVertsSource(std::string geom_id, Mesh *me);
72 
73  void createVertexColorSource(std::string geom_id, Mesh *me);
74 
75  std::string makeTexcoordSourceId(std::string &geom_id, int layer_index, bool is_single_layer);
76 
78  void createTexcoordsSource(std::string geom_id, Mesh *me);
79 
81  void createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal> &nor);
82 
83  void create_normals(std::vector<Normal> &nor,
84  std::vector<BCPolygonNormalsIndices> &polygons_normals,
85  Mesh *me);
86 
87  std::string getIdBySemantics(std::string geom_id,
88  COLLADASW::InputSemantic::Semantics type,
89  std::string other_suffix = "");
90  std::string makeVertexColorSourceId(std::string &geom_id, char *layer_name);
91 
92  COLLADASW::URI getUrlBySemantics(std::string geom_id,
93  COLLADASW::InputSemantic::Semantics type,
94  std::string other_suffix = "");
95 
96  COLLADASW::URI makeUrl(std::string id);
97 
98  void export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb);
99 
100  private:
101  std::set<std::string> exportedGeometry;
102  BlenderContext &blender_context;
103  BCExportSettings &export_settings;
104 
105  Mesh *get_mesh(Scene *sce, Object *ob, int apply_modifiers);
106 };
107 
109  /* f should have
110  * void operator()(Object *ob) */
111  template<class Functor>
112  void forEachMeshObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
113  {
114  LinkNode *node;
115  for (node = export_set; node; node = node->next) {
116  Object *ob = (Object *)node->link;
117  if (ob->type == OB_MESH) {
118  f(ob);
119  }
120  }
121  }
122 };
Object is a sort of wrapper for general info.
@ OB_MESH
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
bool operator<(const Normal &, const Normal &)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
GeometryExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, BCExportSettings &export_settings)
void create_normals(std::vector< Normal > &nor, std::vector< BCPolygonNormalsIndices > &polygons_normals, Mesh *me)
COLLADASW::URI getUrlBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix="")
COLLADASW::URI makeUrl(std::string id)
std::string makeTexcoordSourceId(std::string &geom_id, int layer_index, bool is_single_layer)
std::string makeVertexColorSourceId(std::string &geom_id, char *layer_name)
void export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
void operator()(Object *ob)
void create_mesh_primitive_list(short material_index, bool has_uvs, bool has_color, Object *ob, Mesh *me, std::string &geom_id, std::vector< BCPolygonNormalsIndices > &norind)
void createVertexColorSource(std::string geom_id, Mesh *me)
std::string getIdBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix="")
void createLooseEdgeList(Object *ob, Mesh *me, std::string &geom_id)
void createTexcoordsSource(std::string geom_id, Mesh *me)
void createVertsSource(std::string geom_id, Mesh *me)
void createNormalsSource(std::string geom_id, Mesh *me, std::vector< Normal > &nor)
friend bool operator<(const Normal &, const Normal &)
OperationNode * node
uint nor
ccl_gpu_kernel_postfix ccl_global float int int int sw
struct Face Face
void forEachMeshObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)