diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-29 12:23:52 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-29 12:23:52 +0400 |
commit | 4b2b8fe9bdb4b47a414c9315e515706bdb30194a (patch) | |
tree | 7d1fe11a3e1299fb6598c9408704422367d09929 /source/blender/makesrna/intern/rna_camera_api.c | |
parent | 4b325a938e716787bc51b5cb89e704aac1bd012a (diff) |
rna function:
vecs = Camera.view_frame(scene)
returns 4 points for the camera frame, without this its very hard to know if a point is in the camera view or not, without rewriting blenders internal logic in python.
Diffstat (limited to 'source/blender/makesrna/intern/rna_camera_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_camera_api.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_camera_api.c b/source/blender/makesrna/intern/rna_camera_api.c new file mode 100644 index 00000000000..9e92527aef7 --- /dev/null +++ b/source/blender/makesrna/intern/rna_camera_api.c @@ -0,0 +1,88 @@ +/* + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_camera_api.c + * \ingroup RNA + */ + + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + + +#include "RNA_define.h" +#include "BKE_utildefines.h" + +#ifdef RNA_RUNTIME + +#include "DNA_scene_types.h" +#include "BKE_context.h" +#include "BKE_object.h" + +void rna_camera_view_frame(struct Camera *camera, struct Scene *scene, + float vec1_r[3], float vec2_r[3], float vec3_r[3], float vec4_r[3]) +{ + float vec[4][3]; + + camera_view_frame(scene, camera, vec); + + copy_v3_v3(vec1_r, vec[0]); + copy_v3_v3(vec2_r, vec[1]); + copy_v3_v3(vec3_r, vec[2]); + copy_v3_v3(vec4_r, vec[3]); +} + +#else + +void RNA_api_camera(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func= RNA_def_function(srna, "view_frame", "rna_camera_view_frame"); + RNA_def_function_ui_description(func, "Return 4 points for the cameras frame (before object transformation)"); + + RNA_def_pointer(func, "scene", "Scene", "", "Scene to use for aspect calculation, when omitted 1:1 aspect is used"); + + /* return location and normal */ + parm= RNA_def_float_vector(func, "result_1", 3, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4); + RNA_def_property_flag(parm, PROP_THICK_WRAP); + RNA_def_function_output(func, parm); + + parm= RNA_def_float_vector(func, "result_2", 3, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4); + RNA_def_property_flag(parm, PROP_THICK_WRAP); + RNA_def_function_output(func, parm); + + parm= RNA_def_float_vector(func, "result_3", 3, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4); + RNA_def_property_flag(parm, PROP_THICK_WRAP); + RNA_def_function_output(func, parm); + + parm= RNA_def_float_vector(func, "result_4", 3, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4); + RNA_def_property_flag(parm, PROP_THICK_WRAP); + RNA_def_function_output(func, parm); +} + +#endif + |