Geometry Nodes: Add Viewport Transform node #118680

Merged
Hans Goudey merged 22 commits from HooglyBoogly/blender:geometry-nodes-viewport-transform into main 2024-04-26 19:47:31 +02:00
Showing only changes of commit 0c1055438f - Show all commits

View File

@ -12,8 +12,10 @@ namespace blender::nodes::node_geo_viewport_transform_cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Matrix>("Viewport Transform")
.description("The view direction and location of the 3D viewport");
b.add_output<decl::Matrix>("View").description(
"The view direction and location of the 3D viewport");
HooglyBoogly marked this conversation as resolved Outdated

perspective or orthographic?

perspective or orthographic?

Okay I guess it deals with orthographic projection too. I'll change it to perspective or orthographic

Okay I guess it deals with orthographic projection too. I'll change it to `perspective or orthographic`
b.add_output<decl::Matrix>("Projection")
.description("The 3D viewport's perspective projection matrix");
}
static void node_geo_exec(GeoNodeExecParams params)
@ -23,7 +25,8 @@ static void node_geo_exec(GeoNodeExecParams params)
}
const Object &self_object = *params.self_object();
const RegionView3D &rv3d = *params.user_data()->call_data->operator_data->rv3d;
HooglyBoogly marked this conversation as resolved Outdated

Node group operators should work even when there is no 3D view.

Node group operators should work even when there is no 3D view.
params.set_output("Viewport Transform", float4x4(rv3d.persmat) * self_object.object_to_world());
params.set_output("View", float4x4(rv3d.viewmat) * self_object.object_to_world());
params.set_output("Projection", float4x4(rv3d.winmat) * self_object.object_to_world());
}
static void node_register()