Blender  V2.93
BlenderStrokeRenderer.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
23 #include "BLI_map.hh"
24 
25 #include "../stroke/StrokeRenderer.h"
26 #include "../system/FreestyleConfig.h"
27 
28 extern "C" {
29 struct Depsgraph;
30 struct GHash;
31 struct Main;
32 struct Material;
33 struct Object;
34 struct Render;
35 struct Scene;
36 struct bContext;
37 struct bNodeTree;
38 }
39 
40 namespace Freestyle {
41 
43  public:
44  BlenderStrokeRenderer(Render *re, int render_count);
45  virtual ~BlenderStrokeRenderer();
46 
48  virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const;
49  virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const;
50 
51  Object *NewMesh() const;
52 
53  struct StrokeGroup {
54  explicit StrokeGroup() : totvert(0), totedge(0), totpoly(0), totloop(0)
55  {
56  }
57  vector<StrokeRep *> strokes;
59  int totvert;
60  int totedge;
61  int totpoly;
62  int totloop;
63  };
64  vector<StrokeGroup *> strokeGroups, texturedStrokeGroups;
65 
66  int GenerateScene();
67  void GenerateStrokeMesh(StrokeGroup *group, bool hasTex);
68  void FreeStrokeGroups();
69 
70  Render *RenderScene(Render *re, bool render);
71 
72  static Material *GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user);
73 
74  protected:
80  float _width, _height;
81  float _z, _z_delta;
82  unsigned int _mesh_id;
85 
86  static const char *uvNames[];
87 
88  int get_stroke_count() const;
89  float get_stroke_vertex_z(void) const;
90  unsigned int get_stroke_mesh_id(void) const;
91  bool test_triangle_visibility(StrokeVertexRep *svRep[3]) const;
93  int *visible_faces,
94  int *visible_segments) const;
95 
96  vector<StrokeRep *> _strokeReps;
97 
98 #ifdef WITH_CXX_GUARDEDALLOC
99  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BlenderStrokeRenderer")
100 #endif
101 };
102 
103 } /* namespace Freestyle */
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
bool test_triangle_visibility(StrokeVertexRep *svRep[3]) const
vector< StrokeGroup * > texturedStrokeGroups
vector< StrokeGroup * > strokeGroups
Render * RenderScene(Render *re, bool render)
void test_strip_visibility(Strip::vertex_container &strip_vertices, int *visible_faces, int *visible_segments) const
void GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
static Material * GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user)
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const
BlenderStrokeRenderer(Render *re, int render_count)
unsigned int get_stroke_mesh_id(void) const
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
std::vector< StrokeVertexRep * > vertex_container
Definition: StrokeRep.h:139
inherits from class Rep
Definition: AppCanvas.cpp:32
Definition: BKE_main.h:116