Blender V5.0
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")
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").description(
16 "Transforms points from object space to view space using the viewport's location and "
17 "rotation");
18 b.add_output<decl::Bool>("Is Orthographic")
19 .description("Whether the viewport is using orthographic projection");
20}
21
23{
25 return;
26 }
27 const Object &self_object = *params.self_object();
28 const GeoNodesOperatorData &data = *params.user_data()->call_data->operator_data;
29
30 params.set_output("Projection", data.viewport_winmat);
31 params.set_output("View", data.viewport_viewmat * self_object.object_to_world());
32 params.set_output("Is Orthographic", !data.viewport_is_perspective);
33}
34
35static void node_register()
36{
37 static blender::bke::bNodeType ntype;
38 geo_node_type_base(&ntype, "GeometryNodeViewportTransform", GEO_NODE_TOOL_VIEWPORT_TRANSFORM);
39 ntype.ui_name = "Viewport Transform";
40 ntype.ui_description = "Retrieve the view direction and location of the 3D viewport";
41 ntype.enum_name_legacy = "VIEWPORT_TRANFORM";
43 ntype.declare = node_declare;
47}
49
50} // namespace blender::nodes::node_geo_viewport_transform_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define GEO_NODE_TOOL_VIEWPORT_TRANSFORM
#define NOD_REGISTER_NODE(REGISTER_FUNC)
BMesh const char void * data
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_declare(NodeDeclarationBuilder &b)
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params)
bool check_tool_context_and_error(GeoNodeExecParams &params)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:378
NodeDeclareFunction declare
Definition BKE_node.hh:362