* Implemented the 3 functions needed by the Object module:
For Camera and Lamp * Minor updates, NMesh is not finished yet.
This commit is contained in:
parent
1a87f3a4aa
commit
4ca6f542a2
@ -224,5 +224,6 @@ void M_Blender_Init (void)
|
||||
PyDict_SetItemString (dict, "Draw", M_Draw_Init());
|
||||
PyDict_SetItemString (dict, "BGL", M_BGL_Init());
|
||||
PyDict_SetItemString (dict, "Text", M_Text_Init());
|
||||
// PyDict_SetItemString (dict, "Effect", M_Text_Init());
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
/* Function: M_Camera_New */
|
||||
/* Python equivalent: Blender.Camera.New */
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *keywords)
|
||||
static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
|
||||
{
|
||||
char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
|
||||
char *name_str = "CamData";
|
||||
@ -46,7 +46,7 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *keywords
|
||||
|
||||
printf ("In Camera_New()\n");
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywords, "|ss", kwlist,
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwords, "|ss", kwlist,
|
||||
&type_str, &name_str))
|
||||
/* We expected string(s) (or nothing) as argument, but we didn't get that. */
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
@ -155,6 +155,7 @@ static PyObject *M_Camera_Get(PyObject *self, PyObject *args)
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Camera_Init */
|
||||
/*****************************************************************************/
|
||||
/* Needed by the Blender module, to register the Blender.Camera submodule */
|
||||
PyObject *M_Camera_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
@ -166,6 +167,48 @@ PyObject *M_Camera_Init (void)
|
||||
return (submodule);
|
||||
}
|
||||
|
||||
/* Three Python Camera_Type helper functions needed by the Object module: */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Camera_createPyObject */
|
||||
/* Description: This function will create a new C_Camera from an existing */
|
||||
/* Blender camera structure. */
|
||||
/*****************************************************************************/
|
||||
PyObject *Camera_createPyObject (Camera *cam)
|
||||
{
|
||||
C_Camera *pycam;
|
||||
|
||||
pycam = (C_Camera *)PyObject_NEW (C_Camera, &Camera_Type);
|
||||
|
||||
if (!pycam)
|
||||
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
"couldn't create C_Camera object");
|
||||
|
||||
pycam->camera = cam;
|
||||
|
||||
return (PyObject *)pycam;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Camera_checkPyObject */
|
||||
/* Description: This function returns true when the given PyObject is of the */
|
||||
/* type Camera. Otherwise it will return false. */
|
||||
/*****************************************************************************/
|
||||
int Camera_checkPyObject (PyObject *pyobj)
|
||||
{
|
||||
return (pyobj->ob_type == &Camera_Type);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Camera_fromPyObject */
|
||||
/* Description: This function returns the Blender camera from the given */
|
||||
/* PyObject. */
|
||||
/*****************************************************************************/
|
||||
Camera *Camera_fromPyObject (PyObject *pyobj)
|
||||
{
|
||||
return ((C_Camera *)pyobj)->camera;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Camera methods: */
|
||||
/*****************************************************************************/
|
||||
|
@ -43,7 +43,6 @@
|
||||
|
||||
#include "constant.h"
|
||||
#include "gen_utils.h"
|
||||
#include "modules.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Camera defaults: */
|
||||
@ -195,6 +194,15 @@ static int CameraSetAttr (C_Camera *self, char *name, PyObject *v);
|
||||
static PyObject *CameraGetAttr (C_Camera *self, char *name);
|
||||
static PyObject *CameraRepr (C_Camera *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Camera_Type helper functions needed by Blender (the Init function) */
|
||||
/* and Object modules. */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Camera_Init (void);
|
||||
PyObject *CameraCreatePyObject (Camera *cam);
|
||||
Camera *CameraFromPyObject (PyObject *pyobj);
|
||||
int CameraCheckPyObject (PyObject *pyobj);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Camera_Type structure definition: */
|
||||
/*****************************************************************************/
|
||||
|
@ -157,6 +157,7 @@ static PyObject *M_Lamp_Get(PyObject *self, PyObject *args)
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Lamp_Init */
|
||||
/*****************************************************************************/
|
||||
/* Needed by the Blender module, to register the Blender.Lamp submodule */
|
||||
PyObject *M_Lamp_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
@ -168,6 +169,48 @@ PyObject *M_Lamp_Init (void)
|
||||
return (submodule);
|
||||
}
|
||||
|
||||
/* Three Python Lamp_Type helper functions needed by the Object module: */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Lamp_createPyObject */
|
||||
/* Description: This function will create a new C_Lamp from an existing */
|
||||
/* Blender camera structure. */
|
||||
/*****************************************************************************/
|
||||
PyObject *Lamp_createPyObject (Lamp *lamp)
|
||||
{
|
||||
C_Lamp *pylamp;
|
||||
|
||||
pylamp = (C_Lamp *)PyObject_NEW (C_Lamp, &Lamp_Type);
|
||||
|
||||
if (!pylamp)
|
||||
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
"couldn't create C_Lamp object");
|
||||
|
||||
pylamp->lamp = lamp;
|
||||
|
||||
return (PyObject *)pylamp;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Lamp_checkPyObject */
|
||||
/* Description: This function returns true when the given PyObject is of the */
|
||||
/* type Lamp. Otherwise it will return false. */
|
||||
/*****************************************************************************/
|
||||
int Lamp_checkPyObject (PyObject *pyobj)
|
||||
{
|
||||
return (pyobj->ob_type == &Lamp_Type);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Lamp_fromPyObject */
|
||||
/* Description: This function returns the Blender lamp from the given */
|
||||
/* PyObject. */
|
||||
/*****************************************************************************/
|
||||
Lamp *Lamp_fromPyObject (PyObject *pyobj)
|
||||
{
|
||||
return ((C_Lamp *)pyobj)->lamp;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Lamp methods: */
|
||||
/*****************************************************************************/
|
||||
|
@ -49,7 +49,6 @@
|
||||
/*****************************************************************************/
|
||||
/* Python C_Lamp defaults: */
|
||||
/*****************************************************************************/
|
||||
#define EXPP_LAMP_MAX 256
|
||||
|
||||
/* Lamp types */
|
||||
|
||||
@ -294,6 +293,15 @@ static int LampSetAttr (C_Lamp *lamp, char *name, PyObject *v);
|
||||
static PyObject *LampRepr (C_Lamp *lamp);
|
||||
static int LampPrint (C_Lamp *lamp, FILE *fp, int flags);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Lamp_Type helper functions needed by Blender (the Init function) */
|
||||
/* and Object modules. */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Lamp_Init (void);
|
||||
PyObject *LampCreatePyObject (Lamp *lamp);
|
||||
Lamp *LampFromPyObject (PyObject *pyobj);
|
||||
int LampCheckPyObject (PyObject *pyobj);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python TypeLamp structure definition: */
|
||||
/*****************************************************************************/
|
||||
|
@ -259,14 +259,12 @@ static int NMFace_setattr(PyObject *self, char *name, PyObject *v)
|
||||
}
|
||||
else if (!strcmp(name, "mat") || !strcmp(name, "materialIndex")) {
|
||||
PyArg_Parse(v, "h", &ival);
|
||||
|
||||
mf->mat_nr= ival;
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if (strcmp(name, "smooth") == 0) {
|
||||
PyArg_Parse(v, "h", &ival);
|
||||
|
||||
mf->smooth = ival?1:0;
|
||||
|
||||
return 0;
|
||||
@ -566,19 +564,18 @@ static PyObject *NMesh_getSelectedFaces(PyObject *self, PyObject *args)
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|i", &flag))
|
||||
return NULL;
|
||||
|
||||
if (flag) {
|
||||
for (i = 0 ; i < me->totface; i++) {
|
||||
if (tf[i].flag & TF_SELECT ) {
|
||||
if (tf[i].flag & TF_SELECT )
|
||||
PyList_Append(l, PyInt_FromLong(i));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0 ; i < me->totface; i++) {
|
||||
if (tf[i].flag & TF_SELECT ) {
|
||||
if (tf[i].flag & TF_SELECT )
|
||||
PyList_Append(l, PyList_GetItem(nm->faces, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,9 @@
|
||||
|
||||
/* Most of this file comes from opy_nmesh.[ch] in the old bpython dir */
|
||||
|
||||
#ifndef EXPP_NMESH_H
|
||||
#define EXPP_NMESH_H
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -197,8 +200,10 @@ static int convert_NMeshToMesh(Mesh *mesh, C_NMesh *nmesh);
|
||||
void mesh_update(Mesh *mesh);
|
||||
PyObject *new_NMesh(Mesh *oldmesh);
|
||||
Mesh *Mesh_fromNMesh(C_NMesh *nmesh);
|
||||
// XXX change NMesh *ob below to Object, void to Material
|
||||
PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob);
|
||||
Material **nmesh_updateMaterials(C_NMesh *nmesh);
|
||||
Material **newMaterialList_fromPyList (PyObject *list);
|
||||
void mesh_update(Mesh *mesh);
|
||||
|
||||
|
||||
#endif /* EXPP_NMESH_H */
|
||||
|
@ -24,33 +24,74 @@
|
||||
*
|
||||
* This is a new part of Blender.
|
||||
*
|
||||
* Contributor(s): Michel Selten
|
||||
* Contributor(s): Michel Selten, Willian P. Germano
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef EXPP_modules_h
|
||||
#define EXPP_modules_h
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include <DNA_object_types.h>
|
||||
#include <DNA_camera_types.h>
|
||||
#include <DNA_lamp_types.h>
|
||||
#include <DNA_image_types.h>
|
||||
#include <DNA_curve_types.h>
|
||||
#include <DNA_effect_types.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Global variables */
|
||||
/*****************************************************************************/
|
||||
extern PyObject *g_blenderdict;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Module Init functions and Data Object helper functions (used by the */
|
||||
/* Object module to work with its .data field for the various Data objs */
|
||||
/*****************************************************************************/
|
||||
void M_Blender_Init (void);
|
||||
|
||||
/* Object itself */
|
||||
PyObject * M_Object_Init (void);
|
||||
PyObject * M_ObjectCreatePyObject (struct Object *obj);
|
||||
int M_ObjectCheckPyObject (PyObject *py_obj);
|
||||
struct Object * M_ObjectFromPyObject (PyObject *py_obj);
|
||||
|
||||
/* NMesh Data */
|
||||
PyObject * M_NMesh_Init (void);
|
||||
|
||||
/* Camera Data */
|
||||
PyObject * M_Camera_Init (void);
|
||||
PyObject * Camera_createPyObject (struct Camera *cam);
|
||||
Camera * Camera_fromPyObject (PyObject *pyobj);
|
||||
int Camera_checkPyObject (PyObject *pyobj);
|
||||
|
||||
/* Lamp Data */
|
||||
PyObject * M_Lamp_Init (void);
|
||||
PyObject * Lamp_createPyObject (struct Lamp *lamp);
|
||||
Lamp * Lamp_fromPyObject (PyObject *pyobj);
|
||||
int Lamp_checkPyObject (PyObject *pyobj);
|
||||
|
||||
/* Curve Data */
|
||||
PyObject * M_Curve_Init (void);
|
||||
PyObject * M_Image_Init (void);
|
||||
PyObject * CurveCreatePyObject (struct Curve *curve);
|
||||
struct Curve * CurveFromPyObject (PyObject *py_obj);
|
||||
int CurveCheckPyObject (PyObject *py_obj);
|
||||
|
||||
/* Particle Effects Data */
|
||||
/*
|
||||
PyObject * M_Effect_Init (void);
|
||||
PyObject * EffectCreatePyObject (struct Effect *effect);
|
||||
int EffectCheckPyObject (PyObject *py_obj);
|
||||
struct Effect * EffectFromPyObject (PyObject *py_obj);
|
||||
*/
|
||||
|
||||
/* Init functions for other modules */
|
||||
PyObject * M_Window_Init (void);
|
||||
PyObject * M_Image_Init (void);
|
||||
PyObject * M_Draw_Init (void);
|
||||
PyObject * M_BGL_Init (void);
|
||||
PyObject * M_Text_Init (void);
|
||||
|
||||
#endif /* EXPP_modules_h */
|
||||
|
Loading…
Reference in New Issue
Block a user