Blender  V3.3
gpencil_io_base.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. All rights reserved. */
3 #pragma once
4 
9 #include "BLI_float4x4.hh"
10 #include "BLI_math_vec_types.hh"
11 #include "BLI_vector.hh"
12 
13 #include "DNA_space_types.h" /* for FILE_MAX */
14 
15 #include "gpencil_io.h"
16 
17 struct Depsgraph;
18 struct Main;
19 struct Object;
20 struct RegionView3D;
21 struct Scene;
22 
23 struct bGPDlayer;
24 struct bGPDstroke;
25 struct bGPdata;
26 
27 using blender::Vector;
28 
29 namespace blender::io::gpencil {
30 
31 class GpencilIO {
32  public:
33  GpencilIO(const GpencilIOParams *iparams);
34 
35  void frame_number_set(int value);
36  void prepare_camera_params(Scene *scene, const GpencilIOParams *iparams);
37 
38  protected:
40 
41  bool invert_axis_[2];
44 
45  /* Used for sorting objects. */
46  struct ObjectZ {
47  float zdepth;
48  struct Object *ob;
49  };
50 
53 
54  /* Data for easy access. */
56  struct bGPdata *gpd_;
57  struct Main *bmain_;
58  struct Scene *scene_;
60 
61  int winx_, winy_;
65 
67 
68  int cfra_;
69 
70  float stroke_color_[4], fill_color_[4];
71 
72  /* Geometry functions. */
74  bool gpencil_3D_point_to_screen_space(const float3 co, float2 &r_co);
79 
81  float stroke_point_radius_get(struct bGPDlayer *gpl, struct bGPDstroke *gps);
83  void create_object_list();
84 
85  bool is_camera_mode();
86 
88 
89  void prepare_layer_export_matrix(struct Object *ob, struct bGPDlayer *gpl);
90  void prepare_stroke_export_colors(struct Object *ob, struct bGPDstroke *gps);
91 
92  /* Calculate selected strokes boundbox. */
94  void selected_objects_boundbox_get(rctf *boundbox);
99  void filepath_set(const char *filepath);
100 
101  private:
102  float avg_opacity_;
103  bool is_camera_;
104  rctf select_boundbox_;
105 
106  /* Camera matrix. */
107  float persmat_[4][4];
108 };
109 
110 } // namespace blender::io::gpencil
#define FILE_MAX
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
float2 gpencil_3D_point_to_render_space(const float3 co)
void selected_objects_boundbox_get(rctf *boundbox)
void filepath_set(const char *filepath)
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)
bool gpencil_3D_point_to_screen_space(const float3 co, float2 &r_co)
void prepare_layer_export_matrix(struct Object *ob, struct bGPDlayer *gpl)
void prepare_camera_params(Scene *scene, const GpencilIOParams *iparams)
Scene scene
Definition: BKE_main.h:121