Page Menu
Home
Search
Configure Global Search
Log In
Files
F3753
cameraang9.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Juho Vepsalainen (bebraw)
Nov 13 2013, 1:12 PM
Size
9 KB
Subscribers
None
cameraang9.txt
View Options
Index: source/blender/blenkernel/intern/object.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/object.c,v
retrieving revision 1.119
diff -u -p -u -r1.119 object.c
--- source/blender/blenkernel/intern/object.c 30 Nov 2006 15:54:20 -0000 1.119
+++ source/blender/blenkernel/intern/object.c 1 Dec 2006 15:54:40 -0000
@@ -495,6 +495,7 @@ void *add_camera()
cam= alloc_libblock(&G.main->camera, ID_CA, "Camera");
cam->lens= 35.0f;
+ cam->angle= 49.14f;
cam->clipsta= 0.1f;
cam->clipend= 100.0f;
cam->drawsize= 0.5f;
@@ -2051,5 +2052,3 @@ void object_handle_update(Object *ob)
// printf("set proxy pointer for later group stuff %s\n", ob->id.name);
}
}
-
-
Index: source/blender/blenloader/intern/readfile.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/blenloader/intern/readfile.c,v
retrieving revision 1.332
diff -u -p -u -r1.332 readfile.c
--- source/blender/blenloader/intern/readfile.c 30 Nov 2006 21:40:11 -0000 1.332
+++ source/blender/blenloader/intern/readfile.c 1 Dec 2006 15:54:42 -0000
@@ -6253,6 +6253,17 @@ static void do_versions(FileData *fd, Li
}
}
+ if(main->versionfile <= 243) {
+ Camera *cam = main->camera.first;
+
+ while(cam) {
+ if(cam->angle==0.0) {
+ cam->angle= 16 / tan(M_PI*cam->lens/360);
+ }
+ cam= cam->id.next;
+ }
+ }
+
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
Index: source/blender/makesdna/DNA_camera_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_camera_types.h,v
retrieving revision 1.14
diff -u -p -u -r1.14 DNA_camera_types.h
--- source/blender/makesdna/DNA_camera_types.h 6 Nov 2006 15:42:37 -0000 1.14
+++ source/blender/makesdna/DNA_camera_types.h 1 Dec 2006 15:54:42 -0000
@@ -46,8 +46,10 @@ struct Ipo;
typedef struct Camera {
ID id;
- short type, flag;
- float passepartalpha, pad1;
+ short type, flag, angletoggle;
+ short pad1;
+ float angle;
+ float passepartalpha, pad2;
float clipsta, clipend;
float lens, ortho_scale, drawsize;
float shiftx, shifty;
@@ -84,4 +86,3 @@ typedef struct Camera {
#endif
#endif
-
Index: source/blender/python/api2_2x/Camera.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Camera.c,v
retrieving revision 1.38
diff -u -p -u -r1.38 Camera.c
--- source/blender/python/api2_2x/Camera.c 16 Aug 2006 14:06:23 -0000 1.38
+++ source/blender/python/api2_2x/Camera.c 1 Dec 2006 15:54:42 -0000
@@ -97,6 +97,7 @@ struct PyMethodDef M_Camera_methods[] =
/*****************************************************************************/
/* Python BPy_Camera methods declarations: */
/*****************************************************************************/
+static PyObject *Camera_getAngle( BPy_Camera * self);
static PyObject *Camera_getIpo( BPy_Camera * self );
static PyObject *Camera_getName( BPy_Camera * self );
static PyObject *Camera_getType( BPy_Camera * self );
@@ -106,6 +107,7 @@ static PyObject *Camera_getClipStart( BP
static PyObject *Camera_getClipEnd( BPy_Camera * self );
static PyObject *Camera_getDrawSize( BPy_Camera * self );
static PyObject *Camera_getScale( BPy_Camera * self );
+static PyObject *Camera_setAngle( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args );
static PyObject *Camera_clearIpo( BPy_Camera * self );
static PyObject *Camera_setName( BPy_Camera * self, PyObject * args );
@@ -132,6 +134,8 @@ Camera *GetCameraByName( char *name );
/*****************************************************************************/
static PyMethodDef BPy_Camera_methods[] = {
/* name, method, flags, doc */
+ {"getAngle", ( PyCFunction ) Camera_getAngle, METH_NOARGS,
+ "() - Return Camera Data Angle"},
{"getIpo", ( PyCFunction ) Camera_getIpo, METH_NOARGS,
"() - Return Camera Data Ipo"},
{"getName", ( PyCFunction ) Camera_getName, METH_NOARGS,
@@ -151,6 +155,8 @@ static PyMethodDef BPy_Camera_methods[]
"() - Return Camera clip end value"},
{"getDrawSize", ( PyCFunction ) Camera_getDrawSize, METH_NOARGS,
"() - Return Camera draw size value"},
+ {"setAngle", ( PyCFunction ) Camera_setAngle, METH_VARARGS,
+ "(f) - Set Camera Angle"},
{"setIpo", ( PyCFunction ) Camera_setIpo, METH_VARARGS,
"(Blender Ipo) - Set Camera Ipo"},
{"clearIpo", ( PyCFunction ) Camera_clearIpo, METH_NOARGS,
@@ -417,6 +423,17 @@ Camera *GetCameraByName( char *name )
/* Python BPy_Camera methods: */
/*****************************************************************************/
+static PyObject *Camera_getAngle( BPy_Camera * self )
+{
+ PyObject *attr = PyInt_FromLong( self->camera->angle );
+
+ if( attr )
+ return attr;
+
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Camera.angle attribute" );
+}
+
static PyObject *Camera_getIpo( BPy_Camera * self )
{
struct Ipo *ipo = self->camera->ipo;
@@ -523,7 +540,22 @@ static PyObject *Camera_getDrawSize( BPy
"couldn't get Camera.drawSize attribute" );
}
+static PyObject *Camera_setAngle( BPy_Camera * self, PyObject * args )
+{
+ float value;
+
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
+ self->camera->angle = EXPP_ClampFloat( value,
+ EXPP_CAM_LENS_MIN,
+ EXPP_CAM_LENS_MAX );
+ self->camera->lens = 16 / tan(M_PI*self->camera->angle/360);
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args )
{
@@ -706,6 +738,7 @@ static PyObject *Camera_setLens( BPy_Cam
self->camera->lens = EXPP_ClampFloat( value,
EXPP_CAM_LENS_MIN,
EXPP_CAM_LENS_MAX );
+ self->camera->angle = 360 * atan(16/self->camera->lens) / M_PI;
Py_INCREF( Py_None );
return Py_None;
Index: source/blender/src/buttons_editing.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_editing.c,v
retrieving revision 1.305
diff -u -p -u -r1.305 buttons_editing.c
--- source/blender/src/buttons_editing.c 29 Nov 2006 21:59:19 -0000 1.305
+++ source/blender/src/buttons_editing.c 1 Dec 2006 15:54:42 -0000
@@ -2667,12 +2667,38 @@ static void editing_panel_curve_type(Obj
/* *************************** CAMERA ******************************** */
+/* callback to handle angle to lens conversion */
+static void do_angletolensconversion_cb(void *lens1, void *angle1) {
+ float *lens= (float *)lens1;
+ float *angle= (float *)angle1;
+ float anglevalue= *angle;
+
+ if(lens) {
+ *lens= 16 / tan(M_PI*anglevalue/360);
+ }
+
+ allqueue(REDRAWVIEW3D, 0);
+}
+
+/* callback to handle lens to angle conversion */
+static void do_lenstoangleconversion_cb(void *lens1, void *angle1) {
+ float *lens= (float *)lens1;
+ float *angle= (float *)angle1;
+ float lensvalue= *lens;
+
+ if(lens) {
+ *angle= 360 * atan(16/lensvalue) / M_PI;
+ }
+
+ allqueue(REDRAWVIEW3D, 0);
+}
static void editing_panel_camera_type(Object *ob, Camera *cam)
{
uiBlock *block;
+ uiBut *but;
float grid=0.0;
-
+
if(G.vd) grid= G.vd->grid;
if(grid<1.0) grid= 1.0;
@@ -2681,16 +2707,34 @@ static void editing_panel_camera_type(Ob
uiDefBut(block, LABEL, 10, "Lens:", 10, 180, 150, 20, 0, 0.0, 0.0, 0, 0, "");
-if(cam->type==CAM_ORTHO) {
+ if(cam->type==CAM_ORTHO) {
uiDefButF(block, NUM,REDRAWVIEW3D, "Scale:",
10, 160, 150, 20, &cam->ortho_scale, 0.01, 1000.0, 50, 0, "Specify the ortho scaling of the used camera");
} else {
- uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:",
- 10, 160, 150, 20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera");
+ if(cam->angletoggle) {
+ but= uiDefButF(block, NUM, B_NOP, "Lens:",
+ 10, 160, 150, 20, &cam->angle, 1.0, 179.0, 100, 0, "Specify the lens of the camera in degrees");
+ uiButSetFunc(but,do_angletolensconversion_cb,&cam->lens,&cam->angle);
+ }
+ else {
+ but= uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:",
+ 10, 160, 150, 20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera");
+ uiButSetFunc(but,do_lenstoangleconversion_cb,&cam->lens,&cam->angle);
+ }
}
- uiDefButS(block, TOG, REDRAWVIEW3D, "Orthographic",
- 10, 135, 150, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally");
+ uiBlockBeginAlign(block);
+ uiDefButS(block, TOG, REDRAWVIEW3D, "Ortho",
+ 10, 135, 75, 20, &cam->type, 0, 0, 0, 0, "Render orthogonally");
+ but= uiDefButS(block, TOG, REDRAWVIEW3D, "Angle",
+ 85, 135, 75, 20, &cam->angletoggle, 0, 0, 0, 0, "Use angle as normal camera lens value");
+ if(cam->angletoggle) {
+ uiButSetFunc(but,do_lenstoangleconversion_cb,&cam->lens,&cam->angle);
+ }
+ else {
+ uiButSetFunc(but,do_angletolensconversion_cb,&cam->lens,&cam->angle);
+ }
+ uiBlockEndAlign(block);
uiDefBut(block, LABEL, 0, "Clipping:", 10, 110, 150, 20, 0, 0.0, 0.0, 0, 0, "");
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a1/96/efced9ffc1d5cc875fc73bf05c6c
Event Timeline
Log In to Comment