Blender V5.3
node_geo_viewport_transform.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
8
10{
11 b.add_output<decl::Matrix>("Projection"_ustr)
12 .description(
13 "Transforms points in view space to region space (\"clip space\" or \"normalized device "
14 "coordinates\")");
15 b.add_output<decl::Matrix>("View"_ustr)
16 .description(
17 "Transforms points from object space to view space using the viewport's location and "
18 "rotation");
19 b.add_output<decl::Bool>("Is Orthographic"_ustr)
20 .description("Whether the viewport is using orthographic projection");
21}
22
24{
25 if (!check_tool_context_and_error(params)) {
26 return;
27 }
28 const Object &self_object = *params.self_object();
30
31 params.set_output("Projection"_ustr, data.viewport_winmat);
32 params.set_output("View"_ustr, data.viewport_viewmat * self_object.object_to_world());
33 params.set_output("Is Orthographic"_ustr, !data.viewport_is_perspective);
34}
35
36static void node_register()
37{
38 static bke::bNodeType ntype;
40 &ntype, "GeometryNodeViewportTransform"_ustr, GEO_NODE_TOOL_VIEWPORT_TRANSFORM);
41 ntype.ui_name = "Viewport Transform";
42 ntype.ui_description = "Retrieve the view direction and location of the 3D viewport";
43 ntype.enum_name_legacy = "VIEWPORT_TRANFORM";
45 ntype.declare = node_declare;
49}
51
52} // namespace blender::nodes::node_geo_viewport_transform_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define GEO_NODE_TOOL_VIEWPORT_TRANSFORM
#define NOD_REGISTER_NODE(REGISTER_FUNC)
GeoNodesUserData * user_data() const
void set_output(const UString identifier, T &&value)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params)
bool check_tool_context_and_error(GeoNodeExecParams &params)
BMesh const char void * data
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
NodeDeclareFunction declare
Definition BKE_node.hh:393