Debian Codegraph @

plugins/script/interfaces/BrushInterface.h

raw
1 #pragma once
2
3 #include "iscript.h"
4 #include "iscriptinterface.h"
5 #include "ibrush.h"
6
7 #include "SceneGraphInterface.h"
8
9 namespace script
10 {
11
12 class ScriptFace
13 {
14 private:
15 IFace* _face;
16 static std::string _emptyShader;
17 static IWinding _emptyWinding;
18
19 public:
20 ScriptFace();
21
22 ScriptFace(IFace& face);
23
24 void undoSave();
25
26 const std::string& getShader() const;
27
28 void setShader(const std::string& name);
29
30 void shiftTexdef(float s, float t);
31
32 void scaleTexdef(float s, float t);
33
34 void rotateTexdef(float angle);
35
36 void fitTexture(float s_repeat, float t_repeat);
37
38 void flipTexture(unsigned int flipAxis);
39
40 void normaliseTexture();
41
42 IWinding& getWinding();
43 };
44
45 class ScriptBrushNode :
46 public ScriptSceneNode
47 {
48 public:
49 ScriptBrushNode(const scene::INodePtr& node);
50
51 std::size_t getNumFaces();
52
53 // Get a reference to the face by index in [0..getNumFaces).
54 ScriptFace getFace(std::size_t index);
55
56 // Returns true when this brush has no faces
57 bool empty() const;
58
59 // Returns true if any face of the brush contributes to the final B-Rep.
60 bool hasContributingFaces() const;
61
62 // Removes faces that do not contribute to the brush.
63 // This is useful for cleaning up after CSG operations on the brush.
64 // Note: removal of empty faces is not performed during direct brush manipulations,
65 // because it would make a manipulation irreversible if it created an empty face.
66 void removeEmptyFaces();
67
68 // Sets the shader of all faces to the given name
69 void setShader(const std::string& newShader);
70
71 // Returns TRUE if any of the faces has the given shader
72 bool hasShader(const std::string& name);
73
74 bool hasVisibleMaterial();
75
76 enum DetailFlag
77 {
78 Structural = 0,
79 Detail = 1 << 27,
80 };
81
82 DetailFlag getDetailFlag();
83
84 void setDetailFlag(DetailFlag detailFlag);
85
86 // Saves the current state to the undo stack.
87 // Call this before manipulating the brush to make your action undo-able.
88 void undoSave();
89
90 // Checks if the given SceneNode structure is a BrushNode
91 static bool isBrush(const ScriptSceneNode& node);
92
93 // "Cast" service for Python, returns a ScriptBrushNode.
94 // The returned node is non-NULL if the cast succeeded
95 static ScriptBrushNode getBrush(const ScriptSceneNode& node);
96 };
97
98 class BrushInterface :
99 public IScriptInterface
100 {
101 public:
102 ScriptSceneNode createBrush();
103
104 // IScriptInterface implementation
105 void registerInterface(py::module& scope, py::dict& globals) override;
106 };
107
108 } // namespace script