OverviewFilesCommitsIssuesDocsReleasesPeers

proc-nodes / src / nodes / mesh_primitive_nodes.h

160 lines · c ref:
#ifndef PROC_NODES_MESH_PRIMITIVE_NODES_H
#define PROC_NODES_MESH_PRIMITIVE_NODES_H

#include "../graph/proc_node.h"

namespace godot {

// Mesh Cube — generates a box mesh
class MeshCubeNode : public ProcNode {
	GDCLASS(MeshCubeNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "MeshCube"; }
	String get_node_title() const override { return "Mesh Cube"; }
	String get_node_category() const override { return "Mesh Primitives"; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;

	MeshCubeNode();
};

// Mesh Grid — generates a subdivided plane
class MeshGridNode : public ProcNode {
	GDCLASS(MeshGridNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "MeshGrid"; }
	String get_node_title() const override { return "Mesh Grid"; }
	String get_node_category() const override { return "Mesh Primitives"; }
	bool supports_gpu() const override { return true; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;

	MeshGridNode();
};

// Mesh Circle — generates a circle (polygon or edge ring)
class MeshCircleNode : public ProcNode {
	GDCLASS(MeshCircleNode, ProcNode);

protected:
	static void _bind_methods();

	// Blender carries fill as a PROPERTY (fill_type: NONE / NGON / TRIANGLE_FAN),
	// not a socket. Ours had a Bool socket, which is neither the same shape nor
	// the same set of choices.
	int fill_type = 2; // 0=None, 1=N-gon, 2=Triangle Fan

public:
	StringName get_node_type() const override { return "MeshCircle"; }
	String get_node_title() const override { return "Mesh Circle"; }
	String get_node_category() const override { return "Mesh Primitives"; }

	void set_fill_type(int p_type) { fill_type = p_type; }
	int get_fill_type() const { return fill_type; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;

	MeshCircleNode();
};

// Mesh Cylinder — generates a cylinder
class MeshCylinderNode : public ProcNode {
	GDCLASS(MeshCylinderNode, ProcNode);

protected:
	static void _bind_methods();

	// Blender carries fill as a PROPERTY (fill_type: NONE / NGON / TRIANGLE_FAN),
	// not a socket. Ours had a Bool socket, which is neither the same shape nor
	// the same set of choices.
	int fill_type = 2; // 0=None, 1=N-gon, 2=Triangle Fan

public:
	StringName get_node_type() const override { return "MeshCylinder"; }
	String get_node_title() const override { return "Mesh Cylinder"; }
	String get_node_category() const override { return "Mesh Primitives"; }

	void set_fill_type(int p_type) { fill_type = p_type; }
	int get_fill_type() const { return fill_type; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;

	MeshCylinderNode();
};

// Mesh UV Sphere — generates a UV sphere
class MeshUVSphereNode : public ProcNode {
	GDCLASS(MeshUVSphereNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "MeshUVSphere"; }
	String get_node_title() const override { return "Mesh UV Sphere"; }
	String get_node_category() const override { return "Mesh Primitives"; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;

	MeshUVSphereNode();
};

// Mesh Ico Sphere — generates an icosphere
class MeshIcoSphereNode : public ProcNode {
	GDCLASS(MeshIcoSphereNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "MeshIcoSphere"; }
	String get_node_title() const override { return "Mesh Ico Sphere"; }
	String get_node_category() const override { return "Mesh Primitives"; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;

	MeshIcoSphereNode();
};

// Mesh Line — generates a line of points
class MeshLineNode : public ProcNode {
	GDCLASS(MeshLineNode, ProcNode);

protected:
	static void _bind_methods();

	// Blender's Mesh Line keeps FOUR sockets always -- Count, Resolution,
	// Start Location, Offset -- and two properties decide which are live and how
	// Offset is read. In END_POINTS it is the end of the line; in OFFSET it is
	// the step between points.
	int mode = 0;       // 0=Offset, 1=End Points
	int count_mode = 0; // 0=Total, 1=Resolution

public:
	StringName get_node_type() const override { return "MeshLine"; }
	String get_node_title() const override { return "Mesh Line"; }
	String get_node_category() const override { return "Mesh Primitives"; }
	bool supports_gpu() const override { return true; }

	void set_mode(int p_mode) { mode = p_mode; }
	int get_mode() const { return mode; }
	void set_count_mode(int p_mode) { count_mode = p_mode; }
	int get_count_mode() const { return count_mode; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;

	MeshLineNode();
};

} // namespace godot

#endif // PROC_NODES_MESH_PRIMITIVE_NODES_H