Blender  V2.93
gpencil_io_base.hh
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  * The Original Code is Copyright (C) 2020 Blender Foundation
17  * All rights reserved.
18  */
19 #pragma once
20 
25 #include "BLI_float2.hh"
26 #include "BLI_float3.hh"
27 #include "BLI_float4x4.hh"
28 #include "BLI_vector.hh"
29 
30 #include "DNA_space_types.h" /* for FILE_MAX */
31 
32 #include "gpencil_io.h"
33 
34 struct Depsgraph;
35 struct Main;
36 struct Object;
37 struct RegionView3D;
38 struct Scene;
39 
40 struct bGPdata;
41 struct bGPDlayer;
42 struct bGPDstroke;
43 
44 using blender::Vector;
45 
46 namespace blender::io::gpencil {
47 
48 class GpencilIO {
49  public:
50  GpencilIO(const GpencilIOParams *iparams);
51 
52  void frame_number_set(const int value);
53  void prepare_camera_params(const GpencilIOParams *iparams);
54 
55  protected:
57 
58  bool invert_axis_[2];
61 
62  /* Used for sorting objects. */
63  struct ObjectZ {
64  float zdepth;
65  struct Object *ob;
66  };
67 
70 
71  /* Data for easy access. */
73  struct bGPdata *gpd_;
74  struct Main *bmain_;
75  struct Scene *scene_;
77 
82 
84 
85  int cfra_;
86 
87  float stroke_color_[4], fill_color_[4];
88 
89  /* Geometry functions. */
90  bool gpencil_3D_point_to_screen_space(const float3 co, float2 &r_co);
91  float2 gpencil_3D_point_to_render_space(const float3 co, const bool is_ortho);
93 
94  float stroke_point_radius_get(struct bGPDlayer *gpl, struct bGPDstroke *gps);
95  void create_object_list();
96 
97  bool is_camera_mode();
98  bool is_orthographic();
99 
101 
102  void prepare_layer_export_matrix(struct Object *ob, struct bGPDlayer *gpl);
103  void prepare_stroke_export_colors(struct Object *ob, struct bGPDstroke *gps);
104 
106  void selected_objects_boundbox_get(rctf *boundbox);
107  void filename_set(const char *filename);
108 
109  private:
110  float avg_opacity_;
111  bool is_camera_;
112  bool is_ortho_;
113  rctf select_boundbox_;
114 
115  /* Camera matrix. */
116  float persmat_[4][4];
117 };
118 
119 } // namespace blender::io::gpencil
#define FILE_MAX
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
void prepare_camera_params(const GpencilIOParams *iparams)
void selected_objects_boundbox_get(rctf *boundbox)
void frame_number_set(const int value)
float stroke_point_radius_get(struct bGPDlayer *gpl, struct bGPDstroke *gps)
GpencilIO(const GpencilIOParams *iparams)
blender::Vector< ObjectZ > ob_list_
void prepare_stroke_export_colors(struct Object *ob, struct bGPDstroke *gps)
float2 gpencil_3D_point_to_2D(const float3 co)
float2 gpencil_3D_point_to_render_space(const float3 co, const bool is_ortho)
void filename_set(const char *filename)
bool gpencil_3D_point_to_screen_space(const float3 co, float2 &r_co)
void prepare_layer_export_matrix(struct Object *ob, struct bGPDlayer *gpl)
signed short int16_t
Definition: stdint.h:79
Definition: BKE_main.h:116