1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 /** \file
18  * \ingroup RNA
19  */
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 
25 #include "RNA_define.h"
26 
27 #include "rna_internal.h" /* own include */
28 
29 #ifdef RNA_RUNTIME
30 
31 #  include "DNA_scene_types.h"
32 
33 #  include "BKE_camera.h"
34 #  include "BKE_context.h"
35 #  include "BKE_object.h"
36 
rna_camera_view_frame(struct Camera * camera,struct Scene * scene,float r_vec1[3],float r_vec2[3],float r_vec3[3],float r_vec4[3])37 static void rna_camera_view_frame(struct Camera *camera,
38                                   struct Scene *scene,
39                                   float r_vec1[3],
40                                   float r_vec2[3],
41                                   float r_vec3[3],
42                                   float r_vec4[3])
43 {
44   float vec[4][3];
45 
46   BKE_camera_view_frame(scene, camera, vec);
47 
48   copy_v3_v3(r_vec1, vec[0]);
49   copy_v3_v3(r_vec2, vec[1]);
50   copy_v3_v3(r_vec3, vec[2]);
51   copy_v3_v3(r_vec4, vec[3]);
52 }
53 
54 #else
55 
RNA_api_camera(StructRNA * srna)56 void RNA_api_camera(StructRNA *srna)
57 {
58   FunctionRNA *func;
59   PropertyRNA *parm;
60 
61   func = RNA_def_function(srna, "view_frame", "rna_camera_view_frame");
62   RNA_def_function_ui_description(
63       func, "Return 4 points for the cameras frame (before object transformation)");
64 
65   RNA_def_pointer(func,
66                   "scene",
67                   "Scene",
68                   "",
69                   "Scene to use for aspect calculation, when omitted 1:1 aspect is used");
70 
71   /* return location and normal */
72   parm = RNA_def_float_vector(
73       func, "result_1", 3, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4);
74   RNA_def_property_flag(parm, PROP_THICK_WRAP);
75   RNA_def_function_output(func, parm);
76 
77   parm = RNA_def_float_vector(
78       func, "result_2", 3, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4);
79   RNA_def_property_flag(parm, PROP_THICK_WRAP);
80   RNA_def_function_output(func, parm);
81 
82   parm = RNA_def_float_vector(
83       func, "result_3", 3, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4);
84   RNA_def_property_flag(parm, PROP_THICK_WRAP);
85   RNA_def_function_output(func, parm);
86 
87   parm = RNA_def_float_vector(
88       func, "result_4", 3, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4);
89   RNA_def_property_flag(parm, PROP_THICK_WRAP);
90   RNA_def_function_output(func, parm);
91 }
92 
93 #endif
94