Blender  V2.59
rna_armature_api.c
Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version. 
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2009 Blender Foundation.
00019  * All rights reserved.
00020  *
00021  * 
00022  * Contributor(s): Campbell Barton
00023  *
00024  * ***** END GPL LICENSE BLOCK *****
00025  */
00026 
00032 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include <string.h>
00035 #include <time.h>
00036 
00037 #include "RNA_define.h"
00038 
00039 #ifdef RNA_RUNTIME
00040 
00041 #include <stddef.h>
00042 
00043 #include "BLI_blenlib.h"
00044 #include "BKE_armature.h"
00045 
00046 void rna_EditBone_align_roll(EditBone *ebo, float no[3])
00047 {
00048         ebo->roll= ED_rollBoneToVector(ebo, no, FALSE);
00049 }
00050 
00051 float rna_Bone_do_envelope(Bone *bone, float *vec)
00052 {
00053         float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f;
00054         return distfactor_to_bone(vec, bone->arm_head, bone->arm_tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
00055 }
00056 
00057 #else
00058 
00059 void RNA_api_armature_edit_bone(StructRNA *srna)
00060 {
00061         FunctionRNA *func;
00062         PropertyRNA *parm;
00063 
00064         func= RNA_def_function(srna, "align_roll", "rna_EditBone_align_roll");
00065         RNA_def_function_ui_description(func, "Align the bone to a localspace roll so the Z axis points in the direction of the vector given.");
00066         parm= RNA_def_float_vector(func, "vector", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
00067         RNA_def_property_flag(parm, PROP_REQUIRED);
00068 }
00069 
00070 void RNA_api_bone(StructRNA *srna)
00071 {
00072         PropertyRNA *parm;
00073         FunctionRNA *func;
00074 
00075         func= RNA_def_function(srna, "evaluate_envelope", "rna_Bone_do_envelope");
00076         RNA_def_function_ui_description(func, "Calculate bone envelope at given point.");
00077         parm= RNA_def_float_vector_xyz(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "Position in 3d space to evaluate", -FLT_MAX, FLT_MAX);
00078         RNA_def_property_flag(parm, PROP_REQUIRED);
00079         /* return value */
00080         parm= RNA_def_float(func, "factor", 0, -FLT_MAX, FLT_MAX, "Factor", "Envelope factor", -FLT_MAX, FLT_MAX);
00081         RNA_def_function_return(func, parm);
00082 }
00083 
00084 #endif