29 b.add_input<
decl::Vector>(
"Center").description(
"Point to rotate around");
35 .description(
"Axis to rotate around");
38 .
description(
"Angle to rotate the input vector by");
43 "The amount of rotation on each axis, around the X, Y, then Z axes in that order");
57 return "node_vector_rotate_axis_angle";
59 return "node_vector_rotate_axis_x";
61 return "node_vector_rotate_axis_y";
63 return "node_vector_rotate_axis_z";
65 return "node_vector_rotate_euler_xyz";
79 if (name !=
nullptr) {
80 float invert = (node->custom2) ? -1.0 : 1.0;
96 return result + center;
111 return result + center;
116 bool invert = node.custom2;
117 const int mode = node.custom1;
122 static auto fn = mf::build::SI4_SO<float3, float3, float3, float, float3>(
129 static auto fn = mf::build::SI4_SO<float3, float3, float3, float, float3>(
139 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
140 "Rotate X-Axis", [=](
const float3 &in,
const float3 ¢er,
float angle) {
145 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
146 "Rotate X-Axis", [=](
const float3 &in,
const float3 ¢er,
float angle) {
154 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
155 "Rotate Y-Axis", [=](
const float3 &in,
const float3 ¢er,
float angle) {
160 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
161 "Rotate Y-Axis", [=](
const float3 &in,
const float3 ¢er,
float angle) {
169 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
170 "Rotate Z-Axis", [=](
const float3 &in,
const float3 ¢er,
float angle) {
175 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
176 "Rotate Z-Axis", [=](
const float3 &in,
const float3 ¢er,
float angle) {
183 static auto fn = mf::build::SI3_SO<float3, float3, float3, float3>(
189 static auto fn = mf::build::SI3_SO<float3, float3, float3, float3>(
223 int mode = node_->custom1;
224 bool invert = node_->custom2;
226 NodeItem
vector = get_input_value(
"Vector", NodeItem::Type::Vector3);
227 NodeItem center = get_input_value(
"Center", NodeItem::Type::Vector3) *
228 val(MaterialX::Vector3(1.0f, 1.0f, -1.0f));
232 NodeItem rotation = get_input_value(
"Rotation", NodeItem::Type::Vector3) *
233 val(MaterialX::Vector3(1.0f, 1.0f, -1.0f) * 180.0f /
M_PI);
238 NodeItem angle = get_input_value(
"Angle", NodeItem::Type::Float) * val(
float(180.0f /
M_PI));
239 NodeItem axis = empty();
242 axis = get_input_value(
"Axis", NodeItem::Type::Vector3) *
243 val(MaterialX::Vector3(1.0f, 1.0f, -1.0f));
246 axis = val(MaterialX::Vector3(1.0f, 0.0f, 0.0f));
249 axis = val(MaterialX::Vector3(0.0f, 1.0f, 0.0f));
252 axis = val(MaterialX::Vector3(0.0f, 0.0f, -1.0f));
258 return vector.rotate(
invert ? -angle : angle, axis) + center;
272 ntype.
declare = file_ns::sh_node_vector_rotate_declare;
273 ntype.
draw_buttons = file_ns::node_shader_buts_vector_rotate;
274 ntype.
gpu_fn = file_ns::gpu_shader_vector_rotate;
275 ntype.
updatefunc = file_ns::node_shader_update_vector_rotate;
#define SH_NODE_VECTOR_ROTATE
#define NODE_CLASS_OP_VECTOR
#define BLI_assert_unreachable()
void mul_m3_v3(const float M[3][3], float r[3])
bool invert_m3(float mat[3][3])
void eul_to_mat3(float mat[3][3], const float eul[3])
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
@ NODE_VECTOR_ROTATE_TYPE_AXIS
@ NODE_VECTOR_ROTATE_TYPE_AXIS_Z
@ NODE_VECTOR_ROTATE_TYPE_AXIS_X
@ NODE_VECTOR_ROTATE_TYPE_EULER_XYZ
@ NODE_VECTOR_ROTATE_TYPE_AXIS_Y
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void set_matching_fn(const mf::MultiFunction *fn)
void make_available(bNode &node) const
local_group_size(16, 16) .push_constant(Type b
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
void node_set_socket_availability(bNodeTree *ntree, bNodeSocket *sock, bool is_available)
void node_register_type(bNodeType *ntype)
bNodeSocket * node_find_socket(bNode *node, eNodeSocketInOut in_out, StringRef identifier)
static float3 sh_node_vector_rotate_around_axis(const float3 &vector, const float3 ¢er, const float3 &axis, const float angle)
static void sh_node_vector_rotate_declare(NodeDeclarationBuilder &b)
static void node_shader_buts_vector_rotate(uiLayout *layout, bContext *, PointerRNA *ptr)
static const mf::MultiFunction * get_multi_function(const bNode &node)
static void sh_node_vector_rotate_build_multi_function(NodeMultiFunctionBuilder &builder)
static float3 sh_node_vector_rotate_euler(const float3 &vector, const float3 ¢er, const float3 &rotation, const bool invert)
static const char * gpu_shader_get_name(int mode)
static int gpu_shader_vector_rotate(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_update_vector_rotate(bNodeTree *ntree, bNode *node)
VecBase< float, 3 > float3
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void sh_fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void register_node_type_sh_vector_rotate()
NodeMaterialXFunction materialx_fn
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void(* updatefunc)(bNodeTree *ntree, bNode *node)