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.
This commit is contained in:
@@ -149,7 +149,7 @@ void object_camera_matrix(
|
||||
void camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float drawsize, const short do_clip, const float scale[3],
|
||||
float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]);
|
||||
|
||||
void camera_frame(struct Scene *scene, struct Camera *camera, float r_vec[4][3]);
|
||||
void camera_view_frame(struct Scene *scene, struct Camera *camera, float r_vec[4][3]);
|
||||
|
||||
void object_relink(struct Object *ob);
|
||||
|
||||
|
@@ -3122,7 +3122,7 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh
|
||||
r_vec[3][0]= r_shift[0] - facx; r_vec[3][1]= r_shift[1] + facy; r_vec[3][2]= depth;
|
||||
}
|
||||
|
||||
void camera_frame(Scene *scene, Camera *camera, float r_vec[4][3])
|
||||
void camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3])
|
||||
{
|
||||
float dummy_asp[2];
|
||||
float dummy_shift[2];
|
||||
|
@@ -95,6 +95,7 @@ set(APISRC
|
||||
rna_actuator_api.c
|
||||
rna_animation_api.c
|
||||
rna_armature_api.c
|
||||
rna_camera_api.c
|
||||
rna_controller_api.c
|
||||
rna_fcurve_api.c
|
||||
rna_image_api.c
|
||||
|
@@ -2432,7 +2432,7 @@ static RNAProcessItem PROCESS_ITEMS[]= {
|
||||
{"rna_armature.c", "rna_armature_api.c", RNA_def_armature},
|
||||
{"rna_boid.c", NULL, RNA_def_boid},
|
||||
{"rna_brush.c", NULL, RNA_def_brush},
|
||||
{"rna_camera.c", NULL, RNA_def_camera},
|
||||
{"rna_camera.c", "rna_camera_api.c", RNA_def_camera},
|
||||
{"rna_cloth.c", NULL, RNA_def_cloth},
|
||||
{"rna_color.c", NULL, RNA_def_color},
|
||||
{"rna_constraint.c", NULL, RNA_def_constraint},
|
||||
|
@@ -209,6 +209,9 @@ void RNA_def_camera(BlenderRNA *brna)
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "DOF Object", "Use this object to define the depth of field focal point");
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
|
||||
|
||||
/* Camera API */
|
||||
RNA_api_camera(srna);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
88
source/blender/makesrna/intern/rna_camera_api.c
Normal file
88
source/blender/makesrna/intern/rna_camera_api.c
Normal file
@@ -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
|
||||
|
@@ -234,6 +234,7 @@ char *rna_TextureSlot_path(struct PointerRNA *ptr);
|
||||
void RNA_api_action(StructRNA *srna);
|
||||
void RNA_api_armature_edit_bone(StructRNA *srna);
|
||||
void RNA_api_bone(StructRNA *srna);
|
||||
void RNA_api_camera(StructRNA *srna);
|
||||
void RNA_api_drivers(StructRNA *srna);
|
||||
void RNA_api_image(struct StructRNA *srna);
|
||||
void RNA_api_operator(struct StructRNA *srna);
|
||||
|
Reference in New Issue
Block a user