Rumba C++ SDK
BrushSculpt.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #include "Maquina/AnimCurve.h"
16 #include "Maquina/BVHTriangle.h"
18 
19 MAQUINA_IGNORE_WARNINGS_BEGIN
20 #include <vector>
21 #include <tbb/parallel_for.h>
22 MAQUINA_IGNORE_WARNINGS_END
23 
24 class TransferSculptGeometryUserData;
25 
26 namespace maquina {
27 
29 {
30 public:
31 
32  enum class Operation
33  {
34  pull = 0,
35  inflate,
36  smooth_vertices,
37  smooth_delta,
38  relax,
39  reset,
40  flatten,
41  pinch,
42  grab,
43  mirror,
44  transfer,
45  count
46  };
47 
48  enum class SetBrushAttribute
49  {
50  none = 0,
51  radius,
52  amount,
53  smoothness,
54  flow
55  };
56 
57  BrushSculpt(Node* node);
58 
59  // From ToolPlugin
60  void on_mouse_move( const CameraContext& camera, const InteractionContext& interaction ) final;
61  void on_mouse_press( const CameraContext& camera, const InteractionContext& interaction ) final;
62  void on_mouse_release( const CameraContext& camera, const InteractionContext& interaction ) final;
63  void activate();
64  void deactivate();
65  Array get_help(const char *tool) final;
66  Array get_status(const char *tool) final;
67  bool on_key_press(int32_t key, int32_t modifiers) final;
68  bool on_key_release(int32_t key, int32_t modifiers) final;
69 
70  // From BrushPlugin
71  void stroke_begin(int modifiers);
72  void update_brush_matrix(const CameraContext& camera, const InteractionContext& interaction, bool& visible, Imath::M44f& brush_matrix, bool on_press) final;
73  void update_weights(bool first, const Imath::M44f&) final;
74  float weight(float distance) final;
75  float flow() final;
76 
77  // From BrushSculptPlugin
78  std::shared_ptr<BrushSculptUserData> user_data(
79  const SparseBufferV3f& delta_points,
80  const BrushPlugin::GeometryData& geometry,
81  const BufferConstM33f& vertex_space,
82  const std::shared_ptr<SceneConst>& reference
83  );
84  SceneConst delta_points() const;
85  void set_delta_points(const SceneConst&);
86  SceneConst vertex_space() final;
87  SceneConst reference() final;
88  bool preserve_edges() final;
89 
90  Operation operation(bool* invert=nullptr) const;
91 
92 protected:
93  int _modifiers;
94 
95 private:
96  SetBrushAttribute _attribute_change(int32_t key);
97  Plug _attribute();
98  bool _attribute_exponential();
99 
100  // Some cache to compute the weights
101  float _radius;
102  AnimCurveFloat _profile;
103 
104  // The currently edit attribute
105  SetBrushAttribute __attribute_change = SetBrushAttribute::none;
106  int _attribute_change_init = 0;
107  float _attribute_init = 0.f;
108 
109  // transfer data
110 protected:
111  std::string _input_path;
112  std::string _source_path;
113  Imath::M44d _source_matrix;
114  Imath::M44d _source_matrix_inv;
115  Mesh _source_mesh;
116  BufferV3i _source_topo;
117  std::vector<uint32_t> _source_tri_to_face;
118  SpanSpan<const uint32_t, const uint32_t> _source_topo_face;
119  BVHTriangle _source_bvh_triangle;
121 
122 private:
123  friend class ::TransferSculptGeometryUserData;
124 };
125 
126 }
127 
An animation curve for floating point values. That type of curves contains tangents.
Definition: AnimCurve.h:229
MAQUINA_EXPORT std::vector< uint8_t > inflate(const uint8_t *data, size_t size)
Uncompress a bunch of binary data with zlib.
Definition: ImathFrame.h:43
A mesh value.
Definition: Mesh.h:33
A readonly buffer for basic types like floats, integers, Imath::V3f, Imath::M44f..
Definition: Buffer.h:42
Definition: Plug.h:527
This class provides viewport space conversion services.
Definition: CameraContext.h:23
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
Matrix44< double > M44d
Definition: ImathMatrix.h:812
Operation
Definition: BrushSculpt.h:32
Base class for the sculpt brush plug-ins.
Definition: BrushSculptPlugin.h:32
Definition: BrushPlugin.h:36
MAQUINA_EXPORT Value default_value(const maquina::StringView &type_name)
Return the default value of a type.
none
Definition: BrushID.h:29
An array of values.
Definition: Array.h:26
MAQUINA_EXPORT Node reference(Node &root, const std::wstring &filepath, const std::string &reference_root_name="", const ProgressCallback &progress={})
Reference the content of a file into the project.
#define MAQUINA_EXPORT
Definition: Export.h:31
A node plug.
Definition: Plug.h:59
An immutable scene node value.
Definition: Scene.h:35
Force to match the selection controller&#39;s mirrored channels.
A writable SparseBuffer.
Definition: SparseBuffer.h:55
This interface is passed to the events and is implemented by the application. */. ...
Definition: InteractionContext.h:22
A bounding volume hierarchy to quickly intersect 3d triangles.
Definition: BVHTriangle.h:24
Definition: ImathBox.h:67
Definition: BrushSculpt.h:28
SetBrushAttribute
Definition: BrushSculpt.h:48
A view on a "vector of sub-vectors of values" container.
Definition: SpanSpan.h:31
Base class of all Rumba nodes.
Definition: Node.h:37