Blender  V2.93
rna_camera_api.c
Go to the documentation of this file.
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 
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 
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 
57 {
58  FunctionRNA *func;
59  PropertyRNA *parm;
60 
61  func = RNA_def_function(srna, "view_frame", "rna_camera_view_frame");
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);
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);
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);
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);
90  RNA_def_function_output(func, parm);
91 }
92 
93 #endif
Camera data-block and utility functions.
void BKE_camera_view_frame(const struct Scene *scene, const struct Camera *camera, float r_vec[4][3])
General operations, lookup, etc. for blender objects.
MINLINE void copy_v3_v3(float r[3], const float a[3])
@ PROP_THICK_WRAP
Definition: RNA_types.h:270
Scene scene
void RNA_api_camera(StructRNA *srna)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4159
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret)
Definition: rna_define.c:4327
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3851
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512