File: BrushInterface.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (108 lines) | stat: -rw-r--r-- 2,426 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"
#include "ibrush.h"

#include "SceneGraphInterface.h"

namespace script 
{

class ScriptFace
{
private:
	IFace* _face;
	static std::string _emptyShader;
	static IWinding _emptyWinding;

public:
	ScriptFace();

	ScriptFace(IFace& face);

	void undoSave();

	const std::string& getShader() const;

	void setShader(const std::string& name);

	void shiftTexdef(float s, float t);

	void scaleTexdef(float s, float t);

	void rotateTexdef(float angle);

	void fitTexture(float s_repeat, float t_repeat);

	void flipTexture(unsigned int flipAxis);

	void normaliseTexture();

	IWinding& getWinding();
};

class ScriptBrushNode :
	public ScriptSceneNode
{
public:
	ScriptBrushNode(const scene::INodePtr& node);

	std::size_t getNumFaces();

	// Get a reference to the face by index in [0..getNumFaces).
	ScriptFace getFace(std::size_t index);

	// Returns true when this brush has no faces
	bool empty() const;

	// Returns true if any face of the brush contributes to the final B-Rep.
	bool hasContributingFaces() const;

	// Removes faces that do not contribute to the brush.
	// This is useful for cleaning up after CSG operations on the brush.
	// Note: removal of empty faces is not performed during direct brush manipulations,
	// because it would make a manipulation irreversible if it created an empty face.
	void removeEmptyFaces();

	// Sets the shader of all faces to the given name
	void setShader(const std::string& newShader);

	// Returns TRUE if any of the faces has the given shader
	bool hasShader(const std::string& name);

	bool hasVisibleMaterial();

	enum DetailFlag
	{
		Structural = 0,
		Detail = 1 << 27,
	};

	DetailFlag getDetailFlag();

	void setDetailFlag(DetailFlag detailFlag);

	// Saves the current state to the undo stack.
	// Call this before manipulating the brush to make your action undo-able.
	void undoSave();

	// Checks if the given SceneNode structure is a BrushNode
	static bool isBrush(const ScriptSceneNode& node);

	// "Cast" service for Python, returns a ScriptBrushNode.
	// The returned node is non-NULL if the cast succeeded
	static ScriptBrushNode getBrush(const ScriptSceneNode& node);
};

class BrushInterface :
	public IScriptInterface
{
public:
	ScriptSceneNode createBrush();

	// IScriptInterface implementation
	void registerInterface(py::module& scope, py::dict& globals) override;
};

} // namespace script