[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33100] branches/particles-2010/source/ blender: Added basic rotation converter nodes to convert a quaternion to/ from axis-angle or euler rotations.
Lukas Toenne
lukas.toenne at googlemail.com
Tue Nov 16 13:58:39 CET 2010
Revision: 33100
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33100
Author: lukastoenne
Date: 2010-11-16 13:58:38 +0100 (Tue, 16 Nov 2010)
Log Message:
-----------
Added basic rotation converter nodes to convert a quaternion to/from axis-angle or euler rotations.
Modified Paths:
--------------
branches/particles-2010/source/blender/blenkernel/BKE_node.h
branches/particles-2010/source/blender/blenkernel/intern/node.c
branches/particles-2010/source/blender/editors/space_node/drawnode.c
branches/particles-2010/source/blender/editors/space_node/node_header.c
branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
branches/particles-2010/source/blender/nodes/CMakeLists.txt
branches/particles-2010/source/blender/nodes/SIM_node.h
Added Paths:
-----------
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_math_rotation.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_math_vector.c
Removed Paths:
-------------
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_vectormath.c
Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-11-16 12:54:44 UTC (rev 33099)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-11-16 12:58:38 UTC (rev 33100)
@@ -155,24 +155,25 @@
#define NODE_EXEC_SUSPEND 1
/* nodetype->nclass, for add-menu and themes */
-#define NODE_CLASS_INPUT 0
-#define NODE_CLASS_OUTPUT 1
-#define NODE_CLASS_OP_COLOR 3
-#define NODE_CLASS_OP_VECTOR 4
-#define NODE_CLASS_OP_FILTER 5
-#define NODE_CLASS_GROUP 6
-#define NODE_CLASS_FILE 7
-#define NODE_CLASS_CONVERTOR 8
-#define NODE_CLASS_MATTE 9
-#define NODE_CLASS_DISTORT 10
-#define NODE_CLASS_OP_DYNAMIC 11
-#define NODE_CLASS_PATTERN 12
-#define NODE_CLASS_TEXTURE 13
-#define NODE_CLASS_EXECUTION 14
-#define NODE_CLASS_DATA 15
-#define NODE_CLASS_MATH 16
-#define NODE_CLASS_VECTORMATH 17
-#define NODE_CLASS_PARTICLES 18
+#define NODE_CLASS_INPUT 0
+#define NODE_CLASS_OUTPUT 1
+#define NODE_CLASS_OP_COLOR 3
+#define NODE_CLASS_OP_VECTOR 4
+#define NODE_CLASS_OP_FILTER 5
+#define NODE_CLASS_GROUP 6
+#define NODE_CLASS_FILE 7
+#define NODE_CLASS_CONVERTOR 8
+#define NODE_CLASS_MATTE 9
+#define NODE_CLASS_DISTORT 10
+#define NODE_CLASS_OP_DYNAMIC 11
+#define NODE_CLASS_PATTERN 12
+#define NODE_CLASS_TEXTURE 13
+#define NODE_CLASS_EXECUTION 14
+#define NODE_CLASS_DATA 15
+#define NODE_CLASS_MATH 16
+#define NODE_CLASS_MATH_VECTOR 17
+#define NODE_CLASS_MATH_ROTATION 18
+#define NODE_CLASS_PARTICLES 22
typedef void (*bNodeTreeCallback)(void *calldata, struct ID *owner_id, struct bNodeTree *ntree);
typedef struct bNodeTreeTypeInfo
@@ -582,6 +583,10 @@
#define SIM_NODE_DOTPRODUCT 703
#define SIM_NODE_CROSSPRODUCT 704
+/* rotation math */
+#define SIM_NODE_FROMQUATERNION 720
+#define SIM_NODE_TOQUATERNION 721
+
/* data input/output */
#define SIM_NODE_GETDATA 750
#define SIM_NODE_SETDATA 751
@@ -616,6 +621,9 @@
void sim_setdata_type_set(struct bNodeTree *ntree, struct bNode *node, struct StructRNA *type);
void sim_setdata_property_types(struct bNodeSocket *sock, int **types, int *num_types);
+void sim_fromquaternion_update_rotation_mode(struct bNodeTree *ntree, struct bNode *node);
+void sim_toquaternion_update_rotation_mode(struct bNodeTree *ntree, struct bNode *node);
+
/**/
void init_nodesystem(void);
Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-11-16 12:54:44 UTC (rev 33099)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-11-16 12:58:38 UTC (rev 33100)
@@ -2554,6 +2554,9 @@
nodeRegisterSimDotProduct(ntypelist);
nodeRegisterSimCrossProduct(ntypelist);
+ nodeRegisterSimFromQuaternion(ntypelist);
+ nodeRegisterSimToQuaternion(ntypelist);
+
nodeRegisterSimGetData(ntypelist);
nodeRegisterSimSetData(ntypelist);
nodeRegisterSimIndex(ntypelist);
Modified: branches/particles-2010/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/drawnode.c 2010-11-16 12:54:44 UTC (rev 33099)
+++ branches/particles-2010/source/blender/editors/space_node/drawnode.c 2010-11-16 12:58:38 UTC (rev 33100)
@@ -1528,6 +1528,22 @@
uiItemR(col, ptr, "max_iterations", 0, NULL, 0);
}
+static void node_simulation_buts_fromquaternion(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *col;
+
+ col= uiLayoutColumn(layout, 0);
+ uiItemR(col, ptr, "rotation_mode", 0, NULL, 0);
+}
+
+static void node_simulation_buts_toquaternion(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *col;
+
+ col= uiLayoutColumn(layout, 0);
+ uiItemR(col, ptr, "rotation_mode", 0, NULL, 0);
+}
+
/* only once called */
static void node_simulation_set_butfunc(bNodeType *ntype)
{
@@ -1552,6 +1568,12 @@
case SIM_NODE_WHILE:
ntype->uifunc = node_simulation_buts_while;
break;
+ case SIM_NODE_FROMQUATERNION:
+ ntype->uifunc = node_simulation_buts_fromquaternion;
+ break;
+ case SIM_NODE_TOQUATERNION:
+ ntype->uifunc = node_simulation_buts_toquaternion;
+ break;
default:
ntype->uifunc= NULL;
Modified: branches/particles-2010/source/blender/editors/space_node/node_header.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_header.c 2010-11-16 12:54:44 UTC (rev 33099)
+++ branches/particles-2010/source/blender/editors/space_node/node_header.c 2010-11-16 12:58:38 UTC (rev 33100)
@@ -205,7 +205,8 @@
uiItemMenuF(layout, "Data", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DATA));
uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT));
uiItemMenuF(layout, "Math", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATH));
- uiItemMenuF(layout, "Vector Math", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_VECTORMATH));
+ uiItemMenuF(layout, "Vector Math", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATH_VECTOR));
+ uiItemMenuF(layout, "Rotation Math", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATH_ROTATION));
uiItemMenuF(layout, "Particles", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_PARTICLES));
uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP));
}
Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c 2010-11-16 12:54:44 UTC (rev 33099)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c 2010-11-16 12:58:38 UTC (rev 33100)
@@ -533,6 +533,19 @@
sim_setdata_type_set((bNodeTree*)ptr->id.data, (bNode*)ptr->data, RNA_find_struct(value));
}
+static void rna_Node_rotation_mode_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ bNodeTree *ntree= (bNodeTree*)ptr->id.data;
+ bNode *node= (bNode*)ptr->data;
+
+ if (node->type==SIM_NODE_FROMQUATERNION)
+ sim_fromquaternion_update_rotation_mode(ntree, node);
+ else if (node->type==SIM_NODE_TOQUATERNION)
+ sim_toquaternion_update_rotation_mode(ntree, node);
+
+ node_update(bmain, scene, ntree, node);
+}
+
#else
static EnumPropertyItem prop_image_layer_items[] = {
@@ -2322,6 +2335,42 @@
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
}
+/* XXX This is a partial of the Object rotation modes. See rna_object.c
+ * The quaternion mode has been removed, since quaternion-to-quaternion conversion is not needed
+ */
+static EnumPropertyItem prop_rotmode_items[] = {
+ {ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order. Prone to Gimbal Lock. (Default)"},
+ {ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order. Prone to Gimbal Lock"},
+ {ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order. Prone to Gimbal Lock"},
+ {ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order. Prone to Gimbal Lock"},
+ {ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order. Prone to Gimbal Lock"},
+ {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"},
+ {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector"},
+ {-1, NULL, 0, NULL, NULL}
+};
+
+static void def_sim_fromquaternion(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop= RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_enum_items(prop, prop_rotmode_items);
+ RNA_def_property_ui_text(prop, "Rotation Mode", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_rotation_mode_update");
+}
+
+static void def_sim_toquaternion(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop= RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_enum_items(prop, prop_rotmode_items);
+ RNA_def_property_ui_text(prop, "Rotation Mode", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_rotation_mode_update");
+}
+
/* -------------------------------------------------------------------------- */
static EnumPropertyItem shader_node_type_items[MaxNodes];
Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-11-16 12:54:44 UTC (rev 33099)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-11-16 12:58:38 UTC (rev 33100)
@@ -163,6 +163,8 @@
DefNode( SimulationNode, SIM_NODE_VECTORLENGTH, 0, "VECTORLENGTH", VectorLength, "VectorLength", "" )
DefNode( SimulationNode, SIM_NODE_DOTPRODUCT, 0, "DOTPRODUCT", DotProduct, "DotProduct", "" )
DefNode( SimulationNode, SIM_NODE_CROSSPRODUCT, 0, "CROSSPRODUCT", CrossProduct, "CrossProduct", "" )
+DefNode( SimulationNode, SIM_NODE_FROMQUATERNION, def_sim_fromquaternion, "FROMQUATERNION", FromQuaternion, "FromQuaternion", "" )
+DefNode( SimulationNode, SIM_NODE_TOQUATERNION, def_sim_toquaternion, "TOQUATERNION", ToQuaternion, "ToQuaternion", "" )
DefNode( SimulationNode, SIM_NODE_GETDATA, def_sim_getdata, "GETDATA", GetData, "Get Data", "" )
DefNode( SimulationNode, SIM_NODE_SETDATA, def_sim_setdata, "SETDATA", SetData, "Set Data", "" )
DefNode( SimulationNode, SIM_NODE_INDEX, def_sim_index, "INDEX", Index, "Index", "" )
Modified: branches/particles-2010/source/blender/nodes/CMakeLists.txt
===================================================================
--- branches/particles-2010/source/blender/nodes/CMakeLists.txt 2010-11-16 12:54:44 UTC (rev 33099)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list