|
Blender
V2.59
|
00001 /* 00002 * $Id: rna_animviz.c 35238 2011-02-27 20:20:01Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * Contributor(s): Blender Foundation (2010), Joshua Leung 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #include <stdlib.h> 00031 00032 #include "RNA_define.h" 00033 00034 #include "rna_internal.h" 00035 00036 #include "DNA_anim_types.h" 00037 #include "DNA_action_types.h" 00038 #include "DNA_scene_types.h" 00039 00040 #include "MEM_guardedalloc.h" 00041 00042 #include "WM_types.h" 00043 00044 #ifdef RNA_RUNTIME 00045 00046 static PointerRNA rna_AnimViz_onion_skinning_get(PointerRNA *ptr) 00047 { 00048 return rna_pointer_inherit_refine(ptr, &RNA_AnimVizOnionSkinning, ptr->data); 00049 } 00050 00051 static PointerRNA rna_AnimViz_motion_paths_get(PointerRNA *ptr) 00052 { 00053 return rna_pointer_inherit_refine(ptr, &RNA_AnimVizMotionPaths, ptr->data); 00054 } 00055 00056 static void rna_AnimViz_ghost_start_frame_set(PointerRNA *ptr, int value) 00057 { 00058 bAnimVizSettings *data= (bAnimVizSettings*)ptr->data; 00059 00060 CLAMP(value, 1, data->ghost_ef); 00061 data->ghost_sf= value; 00062 } 00063 00064 static void rna_AnimViz_ghost_end_frame_set(PointerRNA *ptr, int value) 00065 { 00066 bAnimVizSettings *data= (bAnimVizSettings*)ptr->data; 00067 00068 CLAMP(value, data->ghost_sf, (int)(MAXFRAMEF/2)); 00069 data->ghost_ef= value; 00070 } 00071 00072 static void rna_AnimViz_path_start_frame_set(PointerRNA *ptr, int value) 00073 { 00074 bAnimVizSettings *data= (bAnimVizSettings*)ptr->data; 00075 00076 CLAMP(value, 1, data->path_ef); 00077 data->path_sf= value; 00078 } 00079 00080 static void rna_AnimViz_path_end_frame_set(PointerRNA *ptr, int value) 00081 { 00082 bAnimVizSettings *data= (bAnimVizSettings*)ptr->data; 00083 00084 CLAMP(value, data->path_sf, (int)(MAXFRAMEF/2)); 00085 data->path_ef= value; 00086 } 00087 00088 #else 00089 00090 void rna_def_motionpath_common(StructRNA *srna) 00091 { 00092 PropertyRNA *prop; 00093 00094 prop= RNA_def_property(srna, "motion_path", PROP_POINTER, PROP_NONE); 00095 RNA_def_property_pointer_sdna(prop, NULL, "mpath"); 00096 RNA_def_property_ui_text(prop, "Motion Path", "Motion Path for this element"); 00097 } 00098 00099 static void rna_def_animviz_motionpath_vert(BlenderRNA *brna) 00100 { 00101 StructRNA *srna; 00102 PropertyRNA *prop; 00103 00104 srna= RNA_def_struct(brna, "MotionPathVert", NULL); 00105 RNA_def_struct_sdna(srna, "bMotionPathVert"); 00106 RNA_def_struct_ui_text(srna, "Motion Path Cache Point", "Cached location on path"); 00107 00108 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ); 00109 RNA_def_property_array(prop, 3); 00110 RNA_def_property_ui_text(prop, "Coordinates", ""); 00111 00112 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); 00113 RNA_def_property_boolean_sdna(prop, NULL, "flag", MOTIONPATH_VERT_SEL); 00114 RNA_def_property_ui_text(prop, "Select", "Path point is selected for editing"); 00115 } 00116 00117 static void rna_def_animviz_motion_path(BlenderRNA *brna) 00118 { 00119 StructRNA *srna; 00120 PropertyRNA *prop; 00121 00122 srna= RNA_def_struct(brna, "MotionPath", NULL); 00123 RNA_def_struct_sdna(srna, "bMotionPath"); 00124 RNA_def_struct_ui_text(srna, "Motion Path", "Cache of the worldspace positions of an element over a frame range"); 00125 00126 /* Collections */ 00127 prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); 00128 RNA_def_property_collection_sdna(prop, NULL, "points", "length"); 00129 RNA_def_property_struct_type(prop, "MotionPathVert"); 00130 RNA_def_property_ui_text(prop, "Motion Path Points", "Cached positions per frame"); 00131 00132 /* Playback Ranges */ 00133 prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); 00134 RNA_def_property_int_sdna(prop, NULL, "start_frame"); 00135 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00136 RNA_def_property_ui_text(prop, "Start Frame", "Starting frame of the stored range"); 00137 00138 prop= RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); 00139 RNA_def_property_int_sdna(prop, NULL, "end_frame"); 00140 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00141 RNA_def_property_ui_text(prop, "End Frame", "End frame of the stored range"); 00142 00143 prop= RNA_def_property(srna, "length", PROP_INT, PROP_TIME); 00144 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00145 RNA_def_property_ui_text(prop, "Length", "Number of frames cached"); 00146 00147 /* Settings */ 00148 prop= RNA_def_property(srna, "use_bone_head", PROP_BOOLEAN, PROP_NONE); 00149 RNA_def_property_boolean_sdna(prop, NULL, "flag", MOTIONPATH_FLAG_BHEAD); 00150 RNA_def_property_clear_flag(prop, PROP_EDITABLE); // xxx 00151 RNA_def_property_ui_text(prop, "Use Bone Heads", "For PoseBone paths, use the bone head location when calculating this path"); 00152 00153 prop= RNA_def_property(srna, "is_modified", PROP_BOOLEAN, PROP_NONE); 00154 RNA_def_property_boolean_sdna(prop, NULL, "flag", MOTIONPATH_FLAG_EDIT); 00155 RNA_def_property_ui_text(prop, "Edit Path", "Path is being edited"); 00156 } 00157 00158 /* --- */ 00159 00160 static void rna_def_animviz_ghosts(BlenderRNA *brna) 00161 { 00162 StructRNA *srna; 00163 PropertyRNA *prop; 00164 00165 static const EnumPropertyItem prop_type_items[] = { 00166 {GHOST_TYPE_NONE, "NONE", 0, "No Ghosts", "Do not show any ghosts"}, 00167 {GHOST_TYPE_ACFRA, "CURRENT_FRAME", 0, "Around Current Frame", "Show ghosts from around the current frame"}, 00168 {GHOST_TYPE_RANGE, "RANGE", 0, "In Range", "Show ghosts for the specified frame range"}, 00169 {GHOST_TYPE_KEYS, "KEYS", 0, "On Keyframes", "Show ghosts on keyframes"}, 00170 {0, NULL, 0, NULL, NULL}}; 00171 00172 00173 srna= RNA_def_struct(brna, "AnimVizOnionSkinning", NULL); 00174 RNA_def_struct_sdna(srna, "bAnimVizSettings"); 00175 RNA_def_struct_nested(brna, srna, "AnimViz"); 00176 RNA_def_struct_ui_text(srna, "Onion Skinning Settings", "Onion Skinning settings for animation visualisation"); 00177 00178 /* Enums */ 00179 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); 00180 RNA_def_property_enum_sdna(prop, NULL, "ghost_type"); 00181 RNA_def_property_enum_items(prop, prop_type_items); 00182 RNA_def_property_ui_text(prop, "Type", "Method used for determining what ghosts get drawn"); 00183 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00184 00185 /* Settings */ 00186 prop= RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE); 00187 RNA_def_property_boolean_sdna(prop, NULL, "ghost_flag", GHOST_FLAG_ONLYSEL); 00188 RNA_def_property_ui_text(prop, "On Selected Bones Only", "For Pose-Mode drawing, only draw ghosts for selected bones"); 00189 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00190 00191 prop= RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE); 00192 RNA_def_property_int_sdna(prop, NULL, "ghost_step"); 00193 RNA_def_property_range(prop, 1, 20); 00194 RNA_def_property_ui_text(prop, "Frame Step", "Number of frames between ghosts shown (not for 'On Keyframes' Onion-skinning method)"); 00195 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00196 00197 /* Playback Ranges */ 00198 prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); 00199 RNA_def_property_int_sdna(prop, NULL, "ghost_sf"); 00200 RNA_def_property_int_funcs(prop, NULL, "rna_AnimViz_ghost_start_frame_set", NULL); 00201 RNA_def_property_ui_text(prop, "Start Frame", "Starting frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method)"); 00202 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00203 00204 prop= RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); 00205 RNA_def_property_int_sdna(prop, NULL, "ghost_ef"); 00206 RNA_def_property_int_funcs(prop, NULL, "rna_AnimViz_ghost_end_frame_set", NULL); 00207 RNA_def_property_ui_text(prop, "End Frame", "End frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method)"); 00208 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00209 00210 /* Around Current Ranges */ 00211 prop= RNA_def_property(srna, "frame_before", PROP_INT, PROP_TIME); 00212 RNA_def_property_int_sdna(prop, NULL, "ghost_bc"); 00213 RNA_def_property_range(prop, 0, 30); 00214 RNA_def_property_ui_text(prop, "Before Current", "Number of frames to show before the current frame (only for 'Around Current Frame' Onion-skinning method)"); 00215 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00216 00217 prop= RNA_def_property(srna, "frame_after", PROP_INT, PROP_TIME); 00218 RNA_def_property_int_sdna(prop, NULL, "ghost_ac"); 00219 RNA_def_property_range(prop, 0, 30); 00220 RNA_def_property_ui_text(prop, "After Current", "Number of frames to show after the current frame (only for 'Around Current Frame' Onion-skinning method)"); 00221 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00222 } 00223 00224 static void rna_def_animviz_paths(BlenderRNA *brna) 00225 { 00226 StructRNA *srna; 00227 PropertyRNA *prop; 00228 00229 static const EnumPropertyItem prop_type_items[]= { 00230 {MOTIONPATH_TYPE_ACFRA, "CURRENT_FRAME", 0, "Around Frame", "Display Paths of poses within a fixed number of frames around the current frame"}, 00231 {MOTIONPATH_TYPE_RANGE, "RANGE", 0, "In Range", "Display Paths of poses within specified range"}, 00232 {0, NULL, 0, NULL, NULL}}; 00233 static const EnumPropertyItem prop_location_items[]= { 00234 {MOTIONPATH_BAKE_HEADS, "HEADS", 0, "Heads", "Calculate bone paths from heads"}, 00235 {0, "TAILS", 0, "Tails", "Calculate bone paths from tails"}, 00236 {0, NULL, 0, NULL, NULL}}; 00237 00238 srna= RNA_def_struct(brna, "AnimVizMotionPaths", NULL); 00239 RNA_def_struct_sdna(srna, "bAnimVizSettings"); 00240 RNA_def_struct_nested(brna, srna, "AnimViz"); 00241 RNA_def_struct_ui_text(srna, "Motion Path Settings", "Motion Path settings for animation visualisation"); 00242 00243 /* Enums */ 00244 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); 00245 RNA_def_property_enum_sdna(prop, NULL, "path_type"); 00246 RNA_def_property_enum_items(prop, prop_type_items); 00247 RNA_def_property_ui_text(prop, "Paths Type", "Type of range to show for Motion Paths"); 00248 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00249 00250 prop= RNA_def_property(srna, "bake_location", PROP_ENUM, PROP_NONE); 00251 RNA_def_property_enum_bitflag_sdna(prop, NULL, "path_bakeflag"); 00252 RNA_def_property_enum_items(prop, prop_location_items); 00253 RNA_def_property_ui_text(prop, "Bake Location", "When calculating Bone Paths, use Head or Tips"); 00254 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00255 00256 /* Settings */ 00257 prop= RNA_def_property(srna, "show_frame_numbers", PROP_BOOLEAN, PROP_NONE); 00258 RNA_def_property_boolean_sdna(prop, NULL, "path_viewflag", MOTIONPATH_VIEW_FNUMS); 00259 RNA_def_property_ui_text(prop, "Show Frame Numbers", "Show frame numbers on Motion Paths"); 00260 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00261 00262 prop= RNA_def_property(srna, "show_keyframe_highlight", PROP_BOOLEAN, PROP_NONE); 00263 RNA_def_property_boolean_sdna(prop, NULL, "path_viewflag", MOTIONPATH_VIEW_KFRAS); 00264 RNA_def_property_ui_text(prop, "Highlight Keyframes", "Emphasize position of keyframes on Motion Paths"); 00265 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00266 00267 prop= RNA_def_property(srna, "show_keyframe_numbers", PROP_BOOLEAN, PROP_NONE); 00268 RNA_def_property_boolean_sdna(prop, NULL, "path_viewflag", MOTIONPATH_VIEW_KFNOS); 00269 RNA_def_property_ui_text(prop, "Show Keyframe Numbers", "Show frame numbers of Keyframes on Motion Paths"); 00270 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00271 00272 prop= RNA_def_property(srna, "show_keyframe_action_all", PROP_BOOLEAN, PROP_NONE); 00273 RNA_def_property_boolean_sdna(prop, NULL, "path_viewflag", MOTIONPATH_VIEW_KFACT); 00274 RNA_def_property_ui_text(prop, "All Action Keyframes", "For bone motion paths, search whole Action for keyframes instead of in group with matching name only (is slower)"); 00275 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00276 00277 prop= RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE); 00278 RNA_def_property_int_sdna(prop, NULL, "path_step"); 00279 RNA_def_property_range(prop, 1, 100); 00280 RNA_def_property_ui_text(prop, "Frame Step", "Number of frames between paths shown (not for 'On Keyframes' Onion-skinning method)"); 00281 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00282 00283 00284 /* Playback Ranges */ 00285 prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); 00286 RNA_def_property_int_sdna(prop, NULL, "path_sf"); 00287 RNA_def_property_int_funcs(prop, NULL, "rna_AnimViz_path_start_frame_set", NULL); 00288 RNA_def_property_ui_text(prop, "Start Frame", "Starting frame of range of paths to display/calculate (not for 'Around Current Frame' Onion-skinning method)"); 00289 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00290 00291 prop= RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); 00292 RNA_def_property_int_sdna(prop, NULL, "path_ef"); 00293 RNA_def_property_int_funcs(prop, NULL, "rna_AnimViz_path_end_frame_set", NULL); 00294 RNA_def_property_ui_text(prop, "End Frame", "End frame of range of paths to display/calculate (not for 'Around Current Frame' Onion-skinning method)"); 00295 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00296 00297 /* Around Current Ranges */ 00298 prop= RNA_def_property(srna, "frame_before", PROP_INT, PROP_TIME); 00299 RNA_def_property_int_sdna(prop, NULL, "path_bc"); 00300 RNA_def_property_range(prop, 1, MAXFRAMEF/2); 00301 RNA_def_property_ui_text(prop, "Before Current", "Number of frames to show before the current frame (only for 'Around Current Frame' Onion-skinning method)"); 00302 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00303 00304 prop= RNA_def_property(srna, "frame_after", PROP_INT, PROP_TIME); 00305 RNA_def_property_int_sdna(prop, NULL, "path_ac"); 00306 RNA_def_property_range(prop, 1, MAXFRAMEF/2); 00307 RNA_def_property_ui_text(prop, "After Current", "Number of frames to show after the current frame (only for 'Around Current Frame' Onion-skinning method)"); 00308 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* XXX since this is only for 3d-view drawing */ 00309 } 00310 00311 /* --- */ 00312 00313 void rna_def_animviz_common(StructRNA *srna) 00314 { 00315 PropertyRNA *prop; 00316 00317 prop= RNA_def_property(srna, "animation_visualisation", PROP_POINTER, PROP_NONE); 00318 RNA_def_property_flag(prop, PROP_NEVER_NULL); 00319 RNA_def_property_pointer_sdna(prop, NULL, "avs"); 00320 RNA_def_property_ui_text(prop, "Animation Visualisation", "Animation data for this datablock"); 00321 } 00322 00323 static void rna_def_animviz(BlenderRNA *brna) 00324 { 00325 StructRNA *srna; 00326 PropertyRNA *prop; 00327 00328 srna= RNA_def_struct(brna, "AnimViz", NULL); 00329 RNA_def_struct_sdna(srna, "bAnimVizSettings"); 00330 RNA_def_struct_ui_text(srna, "Animation Visualisation", "Settings for the visualisation of motion"); 00331 00332 /* onion-skinning settings (nested struct) */ 00333 prop= RNA_def_property(srna, "onion_skin_frames", PROP_POINTER, PROP_NONE); 00334 RNA_def_property_flag(prop, PROP_NEVER_NULL); 00335 RNA_def_property_struct_type(prop, "AnimVizOnionSkinning"); 00336 RNA_def_property_pointer_funcs(prop, "rna_AnimViz_onion_skinning_get", NULL, NULL, NULL); 00337 RNA_def_property_ui_text(prop, "Onion Skinning", "Onion Skinning (ghosting) settings for visualisation"); 00338 00339 /* motion path settings (nested struct) */ 00340 prop= RNA_def_property(srna, "motion_path", PROP_POINTER, PROP_NONE); 00341 RNA_def_property_flag(prop, PROP_NEVER_NULL); 00342 RNA_def_property_struct_type(prop, "AnimVizMotionPaths"); 00343 RNA_def_property_pointer_funcs(prop, "rna_AnimViz_motion_paths_get", NULL, NULL, NULL); 00344 RNA_def_property_ui_text(prop, "Motion Paths", "Motion Path settings for visualisation"); 00345 } 00346 00347 /* --- */ 00348 00349 void RNA_def_animviz(BlenderRNA *brna) 00350 { 00351 rna_def_animviz(brna); 00352 rna_def_animviz_ghosts(brna); 00353 rna_def_animviz_paths(brna); 00354 00355 rna_def_animviz_motion_path(brna); 00356 rna_def_animviz_motionpath_vert(brna); 00357 } 00358 00359 #endif