Step 3 for the initial commits for 2.5: removing src/ and python,

adding new windowmanager module, and the first bits of new editors
module.
This commit is contained in:
2007-12-24 18:27:28 +00:00
parent 8a07e665c2
commit a1c8543f2a
481 changed files with 13724 additions and 366053 deletions

View File

@@ -1,136 +0,0 @@
/*
* $Id$
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code was in: source/blender/bpython/include/BPY_extern.h
*
* Contributor(s): Michel Selten, Willian P. Germano, Chris Keith
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef BPY_EXTERN_H
#define BPY_EXTERN_H
extern char bprogname[]; /* holds a copy of argv[0], from creator.c */
struct Text; /* defined in DNA_text_types.h */
struct ID; /* DNA_ID.h */
struct Object; /* DNA_object_types.h */
struct IpoDriver; /* DNA_curve_types.h */
struct ScriptLink; /* DNA_scriptlink_types.h */
struct ListBase; /* DNA_listBase.h */
struct SpaceText; /* DNA_space_types.h */
struct SpaceScript; /* DNA_space_types.h */
struct Script; /* BPI_script.h */
struct ScrArea; /* DNA_screen_types.h */
struct bScreen; /* DNA_screen_types.h */
struct bConstraint; /* DNA_constraint_types.h */
struct bPythonConstraint; /* DNA_constraint_types.h */
struct bConstraintOb; /* DNA_constraint_types.h */
struct bConstraintTarget; /* DNA_constraint_types.h*/
#ifdef __cplusplus
extern "C" {
#endif
/*These two next functions are important for making sure the Draw module
works correctly. Before calling any gui callback using the Draw module,
the following code must be executed:
if (some_drawspace_pylist) {
BPy_Set_DrawButtonsList(some_drawspace_pylist->but_refs);
BPy_Free_DrawButtonsList();
}
some_drawspace_pylist = PyList_New(0);
BPy_Set_DrawButtonsList(some_drawspace_pylist);
Also, BPy_Free_DrawButtonsList() must be called as necassary when a drawspace
with python callbacks is destroyed.
This is necassary to avoid blender buttons storing invalid pointers to freed
python data.*/
void BPy_Set_DrawButtonsList(void *list);
void BPy_Free_DrawButtonsList(void);
void BPY_pyconstraint_eval(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets);
void BPY_pyconstraint_settings(void *arg1, void *arg2);
void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct);
void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con);
int BPY_is_pyconstraint(struct Text *text);
void BPY_start_python( int argc, char **argv );
void BPY_end_python( void );
void BPY_post_start_python( void );
void init_syspath( int first_time );
void syspath_append( char *dir );
int BPY_Err_getLinenumber( void );
const char *BPY_Err_getFilename( void );
int BPY_txt_do_python_Text( struct Text *text );
int BPY_menu_do_python( short menutype, int event );
void BPY_run_python_script( char *filename );
void BPY_free_compiled_text( struct Text *text );
void BPY_clear_bad_scriptlinks( struct Text *byebye );
int BPY_has_onload_script( void );
void BPY_do_all_scripts( short event );
int BPY_check_all_scriptlinks( struct Text *text );
void BPY_do_pyscript( struct ID *id, short event );
void BPY_free_scriptlink( struct ScriptLink *slink );
void BPY_copy_scriptlink( struct ScriptLink *scriptlink );
int BPY_is_spacehandler(struct Text *text, char spacetype);
int BPY_del_spacehandler(struct Text *text, struct ScrArea *sa);
int BPY_add_spacehandler(struct Text *txt, struct ScrArea *sa,char spacetype);
int BPY_has_spacehandler(struct Text *text, struct ScrArea *sa);
void BPY_screen_free_spacehandlers(struct bScreen *sc);
int BPY_do_spacehandlers(struct ScrArea *sa, unsigned short event,
unsigned short space_event);
void BPY_pydriver_update(void);
float BPY_pydriver_eval(struct IpoDriver *driver);
struct Object **BPY_pydriver_get_objects(struct IpoDriver *driver);
int BPY_button_eval(char *expr, double *value);
/* format importer hook */
int BPY_call_importloader( char *name );
void BPY_spacescript_do_pywin_draw( struct SpaceScript *sc );
void BPY_spacescript_do_pywin_event( struct SpaceScript *sc,
unsigned short event, short val, char ascii );
void BPY_clear_script( struct Script *script );
void BPY_free_finished_script( struct Script *script );
/* void BPY_Err_Handle(struct Text *text); */
/* void BPY_clear_bad_scriptlink(struct ID *id, struct Text *byebye); */
/* void BPY_clear_bad_scriptlist(struct ListBase *, struct Text *byebye); */
/* int BPY_spacetext_is_pywin(struct SpaceText *st); */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* BPY_EXTERN_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,128 +0,0 @@
/*
* $Id$
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano, Matt Ebb
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef BPY_MENUS_H
#define BPY_MENUS_H
/* This header exposes BPyMenu related public declarations. The implementation
* adds 'dynamic' menus to Blender, letting scripts register themselves in any
* of a few pre-defined (trivial to upgrade) places in menus. These places or
* slots are called groups here (Import, Export, etc). This is how it works:
* - scripts at dirs user pref U.pythondir and .blender/scripts/ are scanned
* for registration info.
* - this data is also saved to a Bpymenus file at the user's .blender/ dir and
* only re-created when the scripts folder gets modified.
* - on start-up Blender uses this info to fill a table, which is used to
* create the menu entries when they are needed (see header_info.c or
* header_script.c, under source/blender/src/, for examples).
*/
/* These two structs hold py menu/submenu info.
* BPyMenu holds a script's name (as should appear in the menu) and filename,
* plus an optional list of submenus. Each submenu is related to a string
* (arg) that the script can get from the __script__ pydict, to know which
* submenu was chosen. */
typedef struct BPySubMenu {
char *name;
char *arg;
struct BPySubMenu *next;
} BPySubMenu;
typedef struct BPyMenu {
char *name;
char *filename;
char *tooltip;
short version; /* Blender version */
int dir; /* 0: default, 1: U.pythondir */
struct BPySubMenu *submenus;
struct BPyMenu *next;
} BPyMenu;
/* Scripts can be added to only a few pre-defined places in menus, like
* File->Import, File->Export, etc. (for speed and better control).
* To make a new menu 'slot' available for scripts:
* - add an entry to the enum below, before PYMENU_TOTAL, of course;
* - update the bpymenu_group_atoi() and BPyMenu_group_itoa() functions in
* BPY_menus.c;
* - add the necessary code to the header_***.c file in
* source/blender/src/, like done in header_info.c for import/export;
*/
typedef enum {
PYMENU_ADD,/* creates new objects */
PYMENU_ANIMATION,
PYMENU_EXPORT,
PYMENU_IMPORT,
PYMENU_MATERIALS,
PYMENU_MESH,
PYMENU_MISC,
PYMENU_OBJECT,
PYMENU_RENDER,/* exporters to external renderers */
PYMENU_SYSTEM,
PYMENU_THEMES,
PYMENU_UV,/* UV editing tools, to go in UV/Image editor space, 'UV' menu */
PYMENU_IMAGE,/* Image editing tools, to go in UV/Image editor space, 'Image' menu */
PYMENU_WIZARDS,/* complex 'app' scripts */
/* entries put after Wizards don't appear at the Scripts win->Scripts menu;
* see define right below */
PYMENU_FACESELECT,
PYMENU_WEIGHTPAINT,
PYMENU_VERTEXPAINT,
PYMENU_UVCALCULATION,
PYMENU_ARMATURE,
PYMENU_SCRIPTTEMPLATE,
PYMENU_HELP,/*Main Help menu items - prob best to leave for 'official' ones*/
PYMENU_HELPSYSTEM,/* Resources, troubleshooting, system tools */
PYMENU_HELPWEBSITES,/* Help -> Websites submenu */
PYMENU_MESHFACEKEY, /* face key in mesh editmode */
PYMENU_ADDMESH, /* adds mesh */
PYMENU_TOTAL
} PYMENUHOOKS;
#define PYMENU_SCRIPTS_MENU_TOTAL (PYMENU_WIZARDS + 1)
/* BPyMenuTable holds all registered pymenus, as linked lists for each menu
* where they can appear (see PYMENUHOOKS enum above).
*/
extern BPyMenu *BPyMenuTable[]; /* defined in BPY_menus.c */
/* public functions: */
int BPyMenu_Init( int usedir );
void BPyMenu_RemoveAllEntries( void );
void BPyMenu_PrintAllEntries( void );
char *BPyMenu_CreatePupmenuStr( BPyMenu * pym, short group );
char *BPyMenu_group_itoa( short group );
struct BPyMenu *BPyMenu_GetEntry( short group, short pos );
#endif /* BPY_MENUS_H */

View File

@@ -1,57 +0,0 @@
# $Id$
# ***** BEGIN GPL/BL DUAL 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. The Blender
# Foundation also sells licenses for use in proprietary software under
# the Blender License. See http://www.blender.org/BL/ for information
# about this.
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The Original Code is Copyright (C) 2006, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Jacques Beaurain.
#
# ***** END GPL/BL DUAL LICENSE BLOCK *****
FILE(GLOB SRC api2_2x/*.c)
SET(SRC ${SRC}
BPY_interface.c
BPY_menus.c
)
SET(INC
api2_2x ../blenkernel ../blenlib ../blenloader
../render/extern/include ../radiosity/extern/include
../makesdna ../../../intern/guardedalloc ../../../intern/bmfont ../imbuf ../include
${PYTHON_INC}
)
IF(WITH_QUICKTIME)
SET(INC ${INC} ${QUICKTIME_INC})
ADD_DEFINITIONS(-DWITH_QUICKTIME)
ENDIF(WITH_QUICKTIME)
IF(WITH_OPENEXR)
ADD_DEFINITIONS(-DWITH_OPENEXR)
ENDIF(WITH_OPENEXR)
IF(WITH_FFMPEG)
ADD_DEFINITIONS(-DWITH_FFMPEG)
ENDIF(WITH_FFMPEG)
BLENDERLIB_NOLIST(blender_python "${SRC}" "${INC}")
#env.BlenderLib ( libname='blender_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype=['core','game2'], priority = [60,115] )

View File

@@ -1,37 +0,0 @@
#
# $Id$
#
# ***** BEGIN GPL/BL DUAL 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. The Blender
# Foundation also sells licenses for use in proprietary software under
# the Blender License. See http://www.blender.org/BL/ for information
# about this.
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): none yet.
#
# ***** END GPL/BL DUAL LICENSE BLOCK *****
#
# Bounces make to subdirectories.
SOURCEDIR = source/blender/python
DIRS = api2_2x
include nan_subdirs.mk

View File

@@ -1,26 +0,0 @@
#!/usr/bin/python
Import ('env')
sources = Split('BPY_interface.c BPY_menus.c') + env.Glob('api2_2x/*.c')
incs = 'api2_2x ../blenkernel ../blenlib ../blenloader'
incs += ' ../render/extern/include ../radiosity/extern/include'
incs += ' ../makesdna #intern/guardedalloc #intern/bmfont ../imbuf ../include'
incs += ' ' + env['BF_PYTHON_INC']
incs += ' ' + env['BF_OPENGL_INC']
defs = []
if env['OURPLATFORM'] in ('win32-mingw') and env['BF_DEBUG']:
defs.append('Py_TRACE_REFS')
if env['WITH_BF_QUICKTIME']==1:
incs += ' ' + env['BF_QUICKTIME_INC']
defs.append('WITH_QUICKTIME')
if env['WITH_BF_OPENEXR'] == 1:
defs.append('WITH_OPENEXR')
if env['WITH_BF_FFMPEG'] == 1:
defs.append('WITH_FFMPEG')
env.BlenderLib ( libname='blender_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype=['core','game2'], priority = [60,115] )

File diff suppressed because it is too large Load Diff

View File

@@ -1,70 +0,0 @@
/*
* $Id: Armature.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* Contributor(s): Joseph gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_ARMATURE_H
#define EXPP_ARMATURE_H
#include <Python.h>
#include "DNA_armature_types.h"
//-------------------TYPE CHECKS---------------------------------
#define BPy_Armature_Check(v) ((v)->ob_type == &Armature_Type)
#define BPy_BonesDict_Check(v) ((v)->ob_type == &BonesDict_Type)
//-------------------MODULE INIT---------------------------------
PyObject *Armature_Init( void );
//-------------------TYPEOBJECT----------------------------------
extern PyTypeObject Armature_Type;
extern PyTypeObject BonesDict_Type;
//-------------------STRUCT DEFINITION---------------------------
typedef struct {
PyObject_HEAD
PyObject *bonesMap; //wrapper for bones
PyObject *editbonesMap; //wrapper for editbones
ListBase *bones; //pointer to armature->bonebase
ListBase editbones; //allocated list of EditBones
short editmode_flag; //1 = in , 0 = not in
} BPy_BonesDict;
typedef struct {
PyObject_HEAD
struct bArmature * armature;
BPy_BonesDict *Bones; //BPy_BonesDict
PyObject *weaklist;
} BPy_Armature;
//-------------------VISIBLE PROTOTYPES-------------------------
PyObject *Armature_CreatePyObject(struct bArmature *armature);
struct bArmature *PyArmature_AsArmature(BPy_Armature *py_armature);
PyObject * Armature_RebuildEditbones(PyObject *pyarmature);
PyObject *Armature_RebuildBones(PyObject *pyarmature);
struct bArmature *Armature_FromPyObject( PyObject * py_obj );
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,333 +0,0 @@
/*
* $Id: BGL.h 5407 2005-10-02 17:09:11Z zuster $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/* This is the Blender.BGL part of opy_draw.c, from the old bpython/intern
* dir, with minor changes to adapt it to the new Python implementation.
* The BGL submodule "wraps" OpenGL functions and constants, allowing script
* writers to make OpenGL calls in their Python scripts for Blender. The
* more important original comments are marked with an @ symbol. */
#ifndef EXPP_BGL_H
#define EXPP_BGL_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <Python.h>
#include "BIF_gl.h"
/*@ Buffer Object */
/*@ For Python access to OpenGL functions requiring a pointer. */
typedef struct _Buffer {
PyObject_VAR_HEAD
PyObject * parent;
int type; /* GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT */
int ndimensions;
int *dimensions;
union {
char *asbyte;
short *asshort;
int *asint;
float *asfloat;
double *asdouble;
void *asvoid;
} buf;
} Buffer;
/*@ By golly George! It looks like fancy pants macro time!!! */
/*
#define int_str "i"
#define int_var(number) bgl_int##number
#define int_ref(number) &bgl_int##number
#define int_def(number) int int_var(number)
#define float_str "f"
#define float_var(number) bgl_float##number
#define float_ref(number) &bgl_float##number
#define float_def(number) float float_var(number)
*/
/* TYPE_str is the string to pass to Py_ArgParse (for the format) */
/* TYPE_var is the name to pass to the GL function */
/* TYPE_ref is the pointer to pass to Py_ArgParse (to store in) */
/* TYPE_def is the C initialization of the variable */
#define void_str ""
#define void_var(num)
#define void_ref(num) &bgl_var##num
#define void_def(num) char bgl_var##num
#define buffer_str "O!"
#define buffer_var(number) (bgl_buffer##number)->buf.asvoid
#define buffer_ref(number) &buffer_Type, &bgl_buffer##number
#define buffer_def(number) Buffer *bgl_buffer##number
/* GL Pointer fields, handled by buffer type */
/* GLdoubleP, GLfloatP, GLintP, GLuintP, GLshortP */
#define GLbooleanP_str "O!"
#define GLbooleanP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLbooleanP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLbooleanP_def(number) Buffer *bgl_buffer##number
#define GLbyteP_str "O!"
#define GLbyteP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLbyteP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLbyteP_def(number) Buffer *bgl_buffer##number
#define GLubyteP_str "O!"
#define GLubyteP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLubyteP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLubyteP_def(number) Buffer *bgl_buffer##number
#define GLintP_str "O!"
#define GLintP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLintP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLintP_def(number) Buffer *bgl_buffer##number
#define GLuintP_str "O!"
#define GLuintP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLuintP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLuintP_def(number) Buffer *bgl_buffer##number
#define GLshortP_str "O!"
#define GLshortP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLshortP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLshortP_def(number) Buffer *bgl_buffer##number
#define GLushortP_str "O!"
#define GLushortP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLushortP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLushortP_def(number) Buffer *bgl_buffer##number
#define GLfloatP_str "O!"
#define GLfloatP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLfloatP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLfloatP_def(number) Buffer *bgl_buffer##number
#define GLdoubleP_str "O!"
#define GLdoubleP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLdoubleP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLdoubleP_def(number) Buffer *bgl_buffer##number
#define GLclampfP_str "O!"
#define GLclampfP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLclampfP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLclampfP_def(number) Buffer *bgl_buffer##number
#define GLvoidP_str "O!"
#define GLvoidP_var(number) (bgl_buffer##number)->buf.asvoid
#define GLvoidP_ref(number) &buffer_Type, &bgl_buffer##number
#define GLvoidP_def(number) Buffer *bgl_buffer##number
#define buffer_str "O!"
#define buffer_var(number) (bgl_buffer##number)->buf.asvoid
#define buffer_ref(number) &buffer_Type, &bgl_buffer##number
#define buffer_def(number) Buffer *bgl_buffer##number
/*@The standard GL typedefs are used as prototypes, we can't
* use the GL type directly because Py_ArgParse expects normal
* C types.
*
* Py_ArgParse doesn't grok writing into unsigned variables,
* so we use signed everything (even stuff that should be unsigned.
*/
/* typedef unsigned int GLenum; */
#define GLenum_str "i"
#define GLenum_var(num) bgl_var##num
#define GLenum_ref(num) &bgl_var##num
#define GLenum_def(num) /* unsigned */ int GLenum_var(num)
/* typedef unsigned int GLboolean; */
#define GLboolean_str "b"
#define GLboolean_var(num) bgl_var##num
#define GLboolean_ref(num) &bgl_var##num
#define GLboolean_def(num) /* unsigned */ char GLboolean_var(num)
/* typedef unsigned int GLbitfield; */
#define GLbitfield_str "i"
#define GLbitfield_var(num) bgl_var##num
#define GLbitfield_ref(num) &bgl_var##num
#define GLbitfield_def(num) /* unsigned */ int GLbitfield_var(num)
/* typedef signed char GLbyte; */
#define GLbyte_str "b"
#define GLbyte_var(num) bgl_var##num
#define GLbyte_ref(num) &bgl_var##num
#define GLbyte_def(num) signed char GLbyte_var(num)
/* typedef short GLshort; */
#define GLshort_str "h"
#define GLshort_var(num) bgl_var##num
#define GLshort_ref(num) &bgl_var##num
#define GLshort_def(num) short GLshort_var(num)
/* typedef int GLint; */
#define GLint_str "i"
#define GLint_var(num) bgl_var##num
#define GLint_ref(num) &bgl_var##num
#define GLint_def(num) int GLint_var(num)
/* typedef int GLsizei; */
#define GLsizei_str "i"
#define GLsizei_var(num) bgl_var##num
#define GLsizei_ref(num) &bgl_var##num
#define GLsizei_def(num) int GLsizei_var(num)
/* typedef unsigned char GLubyte; */
#define GLubyte_str "b"
#define GLubyte_var(num) bgl_var##num
#define GLubyte_ref(num) &bgl_var##num
#define GLubyte_def(num) /* unsigned */ char GLubyte_var(num)
/* typedef unsigned short GLushort; */
#define GLushort_str "h"
#define GLushort_var(num) bgl_var##num
#define GLushort_ref(num) &bgl_var##num
#define GLushort_def(num) /* unsigned */ short GLushort_var(num)
/* typedef unsigned int GLuint; */
#define GLuint_str "i"
#define GLuint_var(num) bgl_var##num
#define GLuint_ref(num) &bgl_var##num
#define GLuint_def(num) /* unsigned */ int GLuint_var(num)
/* typedef float GLfloat; */
#define GLfloat_str "f"
#define GLfloat_var(num) bgl_var##num
#define GLfloat_ref(num) &bgl_var##num
#define GLfloat_def(num) float GLfloat_var(num)
/* typedef float GLclampf; */
#define GLclampf_str "f"
#define GLclampf_var(num) bgl_var##num
#define GLclampf_ref(num) &bgl_var##num
#define GLclampf_def(num) float GLclampf_var(num)
/* typedef double GLdouble; */
#define GLdouble_str "d"
#define GLdouble_var(num) bgl_var##num
#define GLdouble_ref(num) &bgl_var##num
#define GLdouble_def(num) double GLdouble_var(num)
/* typedef double GLclampd; */
#define GLclampd_str "d"
#define GLclampd_var(num) bgl_var##num
#define GLclampd_ref(num) &bgl_var##num
#define GLclampd_def(num) double GLclampd_var(num)
/* typedef void GLvoid; */
/* #define GLvoid_str "" */
/* #define GLvoid_var(num) bgl_var##num */
/* #define GLvoid_ref(num) &bgl_var##num */
/* #define GLvoid_def(num) char bgl_var##num */
#define arg_def1(a1) a1##_def(1)
#define arg_def2(a1, a2) arg_def1(a1); a2##_def(2)
#define arg_def3(a1, a2, a3) arg_def2(a1, a2); a3##_def(3)
#define arg_def4(a1, a2, a3, a4) arg_def3(a1, a2, a3); a4##_def(4)
#define arg_def5(a1, a2, a3, a4, a5) arg_def4(a1, a2, a3, a4); a5##_def(5)
#define arg_def6(a1, a2, a3, a4, a5, a6)arg_def5(a1, a2, a3, a4, a5); a6##_def(6)
#define arg_def7(a1, a2, a3, a4, a5, a6, a7)arg_def6(a1, a2, a3, a4, a5, a6); a7##_def(7)
#define arg_def8(a1, a2, a3, a4, a5, a6, a7, a8)arg_def7(a1, a2, a3, a4, a5, a6, a7); a8##_def(8)
#define arg_def9(a1, a2, a3, a4, a5, a6, a7, a8, a9)arg_def8(a1, a2, a3, a4, a5, a6, a7, a8); a9##_def(9)
#define arg_def10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)arg_def9(a1, a2, a3, a4, a5, a6, a7, a8, a9); a10##_def(10)
#define arg_var1(a1) a1##_var(1)
#define arg_var2(a1, a2) arg_var1(a1), a2##_var(2)
#define arg_var3(a1, a2, a3) arg_var2(a1, a2), a3##_var(3)
#define arg_var4(a1, a2, a3, a4) arg_var3(a1, a2, a3), a4##_var(4)
#define arg_var5(a1, a2, a3, a4, a5) arg_var4(a1, a2, a3, a4), a5##_var(5)
#define arg_var6(a1, a2, a3, a4, a5, a6)arg_var5(a1, a2, a3, a4, a5), a6##_var(6)
#define arg_var7(a1, a2, a3, a4, a5, a6, a7)arg_var6(a1, a2, a3, a4, a5, a6), a7##_var(7)
#define arg_var8(a1, a2, a3, a4, a5, a6, a7, a8)arg_var7(a1, a2, a3, a4, a5, a6, a7), a8##_var(8)
#define arg_var9(a1, a2, a3, a4, a5, a6, a7, a8, a9)arg_var8(a1, a2, a3, a4, a5, a6, a7, a8), a9##_var(9)
#define arg_var10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)arg_var9(a1, a2, a3, a4, a5, a6, a7, a8, a9), a10##_var(10)
#define arg_ref1(a1) a1##_ref(1)
#define arg_ref2(a1, a2) arg_ref1(a1), a2##_ref(2)
#define arg_ref3(a1, a2, a3) arg_ref2(a1, a2), a3##_ref(3)
#define arg_ref4(a1, a2, a3, a4) arg_ref3(a1, a2, a3), a4##_ref(4)
#define arg_ref5(a1, a2, a3, a4, a5) arg_ref4(a1, a2, a3, a4), a5##_ref(5)
#define arg_ref6(a1, a2, a3, a4, a5, a6)arg_ref5(a1, a2, a3, a4, a5), a6##_ref(6)
#define arg_ref7(a1, a2, a3, a4, a5, a6, a7)arg_ref6(a1, a2, a3, a4, a5, a6), a7##_ref(7)
#define arg_ref8(a1, a2, a3, a4, a5, a6, a7, a8)arg_ref7(a1, a2, a3, a4, a5, a6, a7), a8##_ref(8)
#define arg_ref9(a1, a2, a3, a4, a5, a6, a7, a8, a9)arg_ref8(a1, a2, a3, a4, a5, a6, a7, a8), a9##_ref(9)
#define arg_ref10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)arg_ref9(a1, a2, a3, a4, a5, a6, a7, a8, a9), a10##_ref(10)
#define arg_str1(a1) a1##_str
#define arg_str2(a1, a2) arg_str1(a1) a2##_str
#define arg_str3(a1, a2, a3) arg_str2(a1, a2) a3##_str
#define arg_str4(a1, a2, a3, a4) arg_str3(a1, a2, a3) a4##_str
#define arg_str5(a1, a2, a3, a4, a5) arg_str4(a1, a2, a3, a4) a5##_str
#define arg_str6(a1, a2, a3, a4, a5, a6)arg_str5(a1, a2, a3, a4, a5) a6##_str
#define arg_str7(a1, a2, a3, a4, a5, a6, a7)arg_str6(a1, a2, a3, a4, a5, a6) a7##_str
#define arg_str8(a1, a2, a3, a4, a5, a6, a7, a8)arg_str7(a1, a2, a3, a4, a5, a6, a7) a8##_str
#define arg_str9(a1, a2, a3, a4, a5, a6, a7, a8, a9)arg_str8(a1, a2, a3, a4, a5, a6, a7, a8) a9##_str
#define arg_str10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)arg_str9(a1, a2, a3, a4, a5, a6, a7, a8, a9) a10##_str
#define ret_def_void
#define ret_set_void
#define ret_ret_void return EXPP_incr_ret(Py_None)
#define ret_def_GLint int ret_int
#define ret_set_GLint ret_int=
#define ret_ret_GLint return PyInt_FromLong(ret_int);
#define ret_def_GLuint unsigned int ret_uint
#define ret_set_GLuint ret_uint=
#define ret_ret_GLuint return PyInt_FromLong((long) ret_uint);
#define ret_def_GLenum unsigned int ret_uint
#define ret_set_GLenum ret_uint=
#define ret_ret_GLenum return PyInt_FromLong((long) ret_uint);
#define ret_def_GLboolean unsigned char ret_bool
#define ret_set_GLboolean ret_bool=
#define ret_ret_GLboolean return PyInt_FromLong((long) ret_bool);
#define ret_def_GLstring const unsigned char *ret_str;
#define ret_set_GLstring ret_str=
#define ret_ret_GLstring return PyString_FromString(ret_str);
#endif /* EXPP_BGL_H */

View File

@@ -1,716 +0,0 @@
/*
* $Id: BezTriple.c 11241 2007-07-12 11:51:21Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Jacques Guignot RIP 2005,
* Stephen Swaney, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "BezTriple.h" /*This must come first */
#include "DNA_ipo_types.h"
#include "MEM_guardedalloc.h"
#include "gen_utils.h"
/***************************************************************************
Python API function prototypes for the BezTriple module.
***************************************************************************/
static PyObject *M_BezTriple_New( PyObject * self, PyObject * args );
static PyObject *M_BezTriple_Get( PyObject * self, PyObject * args );
/*************************************
Doc strings for the BezTriple module
*************************************/
static char M_BezTriple_doc[] = "The Blender BezTriple module\n";
/****************************************************************************
Python BPy_BezTriple instance methods declarations:
****************************************************************************/
static PyObject *BezTriple_oldsetPoints( BPy_BezTriple * self, PyObject * args );
static int BezTriple_setPoints( BPy_BezTriple * self, PyObject * args );
static PyObject *BezTriple_getPoints( BPy_BezTriple * self );
static PyObject *BezTriple_getTriple( BPy_BezTriple * self );
/****************************************************************************
Python method structure definition for Blender.BezTriple module:
****************************************************************************/
struct PyMethodDef M_BezTriple_methods[] = {
{"New", ( PyCFunction ) M_BezTriple_New, METH_VARARGS | METH_KEYWORDS,
0},
/* {"New", ( PyCFunction ) M_BezTriple_New, METH_O, 0}, */
{"Get", M_BezTriple_Get, METH_VARARGS, 0},
{"get", M_BezTriple_Get, METH_VARARGS, 0},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_BezTriple methods table: */
/*****************************************************************************/
static PyMethodDef BPy_BezTriple_methods[] = {
/* name, method, flags, doc */
{"setPoints", ( PyCFunction ) BezTriple_oldsetPoints, METH_VARARGS,
"(str) - Change BezTriple point coordinates"},
{"getPoints", ( PyCFunction ) BezTriple_getPoints, METH_NOARGS,
"() - return BezTriple knot point x and y coordinates"},
{"getTriple", ( PyCFunction ) BezTriple_getTriple, METH_NOARGS,
"() - return list of 3 floating point triplets. order is H1, knot, H2"},
{NULL, NULL, 0, NULL}
};
/****************************************************************************
Function: M_BezTriple_New
Python equivalent: Blender.BezTriple.New
****************************************************************************/
static PyObject *M_BezTriple_New( PyObject* self, PyObject * args )
{
float numbuf[9];
PyObject* in_args = NULL;
int length;
/* accept list, tuple, or 3 or 9 args (which better be floats) */
length = PyTuple_Size( args );
if( length == 3 || length == 9 )
in_args = args;
else if( !PyArg_ParseTuple( args, "|O", &in_args) )
goto TypeError;
if( !in_args ) {
numbuf[0] = 0.0f; numbuf[1] = 0.0f; numbuf[2] = 0.0f;
numbuf[3] = 0.0f; numbuf[4] = 0.0f; numbuf[5] = 0.0f;
numbuf[6] = 0.0f; numbuf[7] = 0.0f; numbuf[8] = 0.0f;
} else {
int i, length;
if( !PySequence_Check( in_args ) )
goto TypeError;
length = PySequence_Length( in_args );
if( length != 9 && length != 3 )
goto TypeError;
for( i = 0; i < length; i++ ) {
PyObject *item, *pyfloat;
item = PySequence_ITEM( in_args, i);
if( !item )
goto TypeError;
pyfloat = PyNumber_Float( item );
Py_DECREF( item );
if( !pyfloat )
goto TypeError;
numbuf[i] = ( float )PyFloat_AS_DOUBLE( pyfloat );
Py_DECREF( pyfloat );
}
if( length == 3 ) {
numbuf[3] = numbuf[0]; numbuf[6] = numbuf[0];
numbuf[4] = numbuf[1]; numbuf[7] = numbuf[1];
numbuf[5] = numbuf[2]; numbuf[8] = numbuf[2];
}
}
return newBezTriple( numbuf );
TypeError:
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected sequence of 3 or 9 floats or nothing" );
}
/****************************************************************************
Function: M_BezTriple_Get
Python equivalent: Blender.BezTriple.Get
Description: Receives a string and returns the ipo data obj
whose name matches the string. If no argument is
passed in, a list of all ipo data names in the
current scene is returned.
****************************************************************************/
static PyObject *M_BezTriple_Get( PyObject * self, PyObject * args )
{
return 0;
}
/****************************************************************************
Function: BezTriple_dealloc
Description: This is a callback function for the BPy_BezTriple type. It is
the destructor function.
****************************************************************************/
static void BezTriple_dealloc( BPy_BezTriple * self )
{
if( self->own_memory)
MEM_freeN( self->beztriple );
PyObject_DEL( self );
}
/*
* BezTriple_getTriple
*
* Get the coordinate data for a BezTriple. Returns a list of 3 points.
* List order is handle1, knot, handle2. each point consists of a list
* of x,y,z float values.
*/
static PyObject *BezTriple_getTriple( BPy_BezTriple * self )
{
BezTriple *bezt = self->beztriple;
return Py_BuildValue( "[[fff][fff][fff]]",
bezt->vec[0][0], bezt->vec[0][1], bezt->vec[0][2],
bezt->vec[1][0], bezt->vec[1][1], bezt->vec[1][2],
bezt->vec[2][0], bezt->vec[2][1], bezt->vec[2][2] );
}
/*
* BezTriple_setTriple
*
* Set the cordinate data for a BezTriple. Takes a sequence of 3 points,
* of the same format at BezTriple_getTriple.
*/
static int BezTriple_setTriple( BPy_BezTriple * self, PyObject * args )
{
int i, j;
struct BezTriple *bezt = self->beztriple;
float vec[3][3];
if( !PySequence_Check( args ) || PySequence_Size( args ) != 3 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected three sequences of three floats" );
for( i = 0; i < 3; i++ ) {
PyObject *obj1 = PySequence_ITEM( args, i );
if( !PySequence_Check( obj1 ) || PySequence_Size( obj1 ) != 3 ) {
Py_DECREF( obj1 );
return EXPP_ReturnIntError( PyExc_TypeError,
"expected three sequences of three floats" );
}
for( j = 0; j < 3; j++ ) {
PyObject *obj2 = PySequence_ITEM( obj1, j );
PyObject *num = PyNumber_Float( obj2 );
Py_DECREF( obj2 );
if( !num ) {
Py_DECREF( obj1 );
return EXPP_ReturnIntError( PyExc_ValueError,
"expected float parameter" );
}
vec[i][j] = ( float )PyFloat_AsDouble( num );
Py_DECREF( num );
}
Py_DECREF( obj1 );
}
for( i = 0; i < 3; i++ )
for( j = 0; j < 3; j++ )
bezt->vec[i][j] = vec[i][j];
return 0;
}
/*
* BezTriple_getPoint
*
* Get the coordinate data for a BezTriple. Returns the control point,
* as a list of x,y float values.
*/
static PyObject *BezTriple_getPoints( BPy_BezTriple * self )
{
BezTriple *bezt = self->beztriple;
return Py_BuildValue( "[ff]", bezt->vec[1][0], bezt->vec[1][1] );
}
/*
* BezTriple_setPoint
*
* Set the coordinate data for a BezTriple. Accepts the x,y for the control
* point and builds handle values based on control point.
*/
static int BezTriple_setPoints( BPy_BezTriple * self, PyObject * args )
{
int i;
struct BezTriple *bezt = self->beztriple;
float vec[2];
if( !PySequence_Check( args ) || PySequence_Size( args ) != 2 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected sequence of two floats" );
for( i = 0; i < 2; i++ ) {
PyObject *obj = PySequence_ITEM( args, i );
PyObject *num = PyNumber_Float( obj );
Py_DECREF( obj );
if( !num )
return EXPP_ReturnIntError( PyExc_ValueError,
"expected float parameter" );
vec[i] = ( float )PyFloat_AsDouble( num );
Py_DECREF( num );
}
for( i = 0; i < 2; i++ ) {
bezt->vec[0][i] = vec[i] - 1;
bezt->vec[1][i] = vec[i];
bezt->vec[2][i] = vec[i] + 1;
}
/* experimental fussing with handles - ipo.c: calchandles_ipocurve */
if( bezt->vec[0][0] > bezt->vec[1][0] )
bezt->vec[0][0] = bezt->vec[1][0];
if( bezt->vec[2][0] < bezt->vec[1][0] )
bezt->vec[2][0] = bezt->vec[1][0];
return 0;
}
static PyObject *BezTriple_getTilt( BPy_BezTriple * self )
{
return PyFloat_FromDouble( self->beztriple->alfa );
}
static int BezTriple_setTilt( BPy_BezTriple * self, PyObject *value )
{
PyObject *num = PyNumber_Float( value );
if( !num )
return EXPP_ReturnIntError( PyExc_TypeError, "expected a float" );
self->beztriple->alfa = (float)PyFloat_AsDouble( num );
Py_DECREF( num );
return 0;
}
static PyObject *BezTriple_getWeight( BPy_BezTriple * self )
{
return PyFloat_FromDouble( self->beztriple->weight );
}
static int BezTriple_setWeight( BPy_BezTriple * self, PyObject *value )
{
PyObject *num = PyNumber_Float( value );
if( !num )
return EXPP_ReturnIntError( PyExc_TypeError, "expected a float" );
self->beztriple->weight = (float)PyFloat_AsDouble( num );
Py_DECREF( num );
return 0;
}
static PyObject *BezTriple_getRadius( BPy_BezTriple * self )
{
return PyFloat_FromDouble( self->beztriple->radius );
}
static int BezTriple_setRadius( BPy_BezTriple * self, PyObject *value )
{
PyObject *num = PyNumber_Float( value );
if( !num )
return EXPP_ReturnIntError( PyExc_TypeError, "expected a float" );
self->beztriple->radius = (float)PyFloat_AsDouble( num );
Py_DECREF( num );
return 0;
}
static PyObject *BezTriple_getHide( BPy_BezTriple * self )
{
return PyInt_FromLong( self->beztriple->hide == IPO_BEZ );
}
static int BezTriple_setHide( BPy_BezTriple * self, PyObject *value )
{
int param = PyObject_IsTrue( value );
if( param == -1 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected True/False or 0/1" );
if( param )
self->beztriple->hide = IPO_BEZ;
else
self->beztriple->hide = 0;
return 0;
}
static PyObject *BezTriple_getSelects( BPy_BezTriple * self )
{
BezTriple *bezt = self->beztriple;
return Py_BuildValue( "[iii]", bezt->f1, bezt->f2, bezt->f3 );
}
static int BezTriple_setSelects( BPy_BezTriple * self, PyObject *args )
{
struct BezTriple *bezt = self->beztriple;
PyObject *ob1, *ob2, *ob3;
int param1, param2, param3;
/* only accept a sequence of three booleans */
if( !PySequence_Check( args ) || PySequence_Size( args ) != 3 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected sequence of three integers" );
ob1 = PySequence_ITEM( args, 0 );
ob2 = PySequence_ITEM( args, 1 );
ob3 = PySequence_ITEM( args, 2 );
param1 = PyObject_IsTrue( ob1 );
param2 = PyObject_IsTrue( ob2 );
param3 = PyObject_IsTrue( ob3 );
if (param1==-1 || param2==-1 || param3==-1)
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a sequence of 3 items: True/False or 0/1" );
/* assign the selects */
bezt->f1 = (char)param1;
bezt->f2 = (char)param2;
bezt->f3 = (char)param3;
Py_DECREF( ob1 );
Py_DECREF( ob2 );
Py_DECREF( ob3 );
return 0;
}
static PyObject *BezTriple_getHandles( BPy_BezTriple * self )
{
BezTriple *bezt = self->beztriple;
return Py_BuildValue( "[ii]", bezt->h1, bezt->h2 );
}
static int BezTriple_setHandles( BPy_BezTriple * self, PyObject *args )
{
struct BezTriple *bezt = self->beztriple;
PyObject *ob1, *ob2;
short h1, h2;
/* only accept a sequence of two ints */
if( !PySequence_Check( args ) || PySequence_Size( args ) != 2 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected sequence of two integers" );
ob1 = PySequence_ITEM( args, 0 );
ob2 = PySequence_ITEM( args, 1 );
if( !PyInt_Check( ob1 ) || !PyInt_Check( ob2 ) ) {
Py_DECREF( ob1 );
Py_DECREF( ob2 );
return EXPP_ReturnIntError( PyExc_TypeError,
"expected sequence of two integers" );
}
h1 = ( short ) PyInt_AsLong( ob1 );
h2 = ( short ) PyInt_AsLong( ob2 );
Py_DECREF( ob1 );
Py_DECREF( ob2 );
if( h1 < HD_FREE || h2 < HD_FREE ||
h1 > HD_AUTO_ANIM || h2 > HD_AUTO_ANIM )
return EXPP_ReturnIntError( PyExc_ValueError,
"expected int in range [0,4]" );
/* assign the handles */
bezt->h1 = h1;
bezt->h2 = h2;
return 0;
}
/*
* Python BezTriple attributes get/set structure
*/
static PyGetSetDef BPy_BezTriple_getseters[] = {
{"pt",
(getter)BezTriple_getPoints, (setter)BezTriple_setPoints,
"point knot values",
NULL},
{"vec",
(getter)BezTriple_getTriple, (setter)BezTriple_setTriple,
"point handle and knot values",
NULL},
{"tilt",
(getter)BezTriple_getTilt, (setter)BezTriple_setTilt,
"point tilt",
NULL},
{"hide",
(getter)BezTriple_getHide, (setter)BezTriple_setHide,
"point hide status",
NULL},
{"selects",
(getter)BezTriple_getSelects, (setter)BezTriple_setSelects,
"point select statuses",
NULL},
{"handleTypes",
(getter)BezTriple_getHandles, (setter)BezTriple_setHandles,
"point handle types",
NULL},
{"weight",
(getter)BezTriple_getWeight, (setter)BezTriple_setWeight,
"point weight",
NULL},
{"radius",
(getter)BezTriple_getRadius, (setter)BezTriple_setRadius,
"point radius",
NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
/*****************************************************************************/
/* Function: BezTriple_repr */
/* Description: This is a callback function for the BPy_BezTriple type. It */
/* builds a meaninful string to represent BezTriple objects. */
/*****************************************************************************/
static PyObject *BezTriple_repr( BPy_BezTriple * self )
{
char str[512];
sprintf( str,
"[BezTriple [%.6f, %.6f, %.6f] [%.6f, %.6f, %.6f] [%.6f, %.6f, %.6f]\n",
self->beztriple->vec[0][0], self->beztriple->vec[0][1], self->beztriple->vec[0][2],
self->beztriple->vec[1][0], self->beztriple->vec[1][1], self->beztriple->vec[1][2],
self->beztriple->vec[2][0], self->beztriple->vec[2][1], self->beztriple->vec[2][2]);
return PyString_FromString( str );
}
/************************************************************************
*
* Python BezTriple_Type structure definition
*
************************************************************************/
PyTypeObject BezTriple_Type = {
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"BezTriple", /* char *tp_name; */
sizeof( BPy_BezTriple ), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
( destructor ) BezTriple_dealloc,/* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */
( reprfunc ) BezTriple_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_BezTriple_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_BezTriple_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};
static PyObject *M_BezTriple_HandleDict( void )
{
PyObject *HM = PyConstant_New( );
if( HM ) {
BPy_constant *d = ( BPy_constant * ) HM;
PyConstant_Insert( d, "FREE", PyInt_FromLong( HD_FREE ) );
PyConstant_Insert( d, "AUTO", PyInt_FromLong( HD_AUTO ) );
PyConstant_Insert( d, "VECT", PyInt_FromLong( HD_VECT ) );
PyConstant_Insert( d, "ALIGN", PyInt_FromLong( HD_ALIGN ) );
PyConstant_Insert( d, "AUTOANIM", PyInt_FromLong( HD_AUTO_ANIM ) );
}
return HM;
}
/*
BezTriple_Init
*/
PyObject *BezTriple_Init( void )
{
PyObject *submodule;
PyObject *HandleTypes = M_BezTriple_HandleDict( );
if( PyType_Ready( &BezTriple_Type ) < 0 )
return NULL;
submodule = Py_InitModule3( "Blender.BezTriple",
M_BezTriple_methods,
M_BezTriple_doc );
if( HandleTypes )
PyModule_AddObject( submodule, "HandleTypes", HandleTypes );
return submodule;
}
/* Three Python BezTriple_Type helper functions needed by the Object module: */
/****************************************************************************
Function: BezTriple_CreatePyObject
Description: This function will create a new BPy_BezTriple from an existing
Blender ipo structure.
****************************************************************************/
PyObject *BezTriple_CreatePyObject( BezTriple * bzt )
{
BPy_BezTriple *pybeztriple;
pybeztriple =
( BPy_BezTriple * ) PyObject_NEW( BPy_BezTriple, &BezTriple_Type );
if( !pybeztriple )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create BPy_BezTriple object" );
pybeztriple->beztriple = bzt;
pybeztriple->own_memory = 0;
return ( PyObject * ) pybeztriple;
}
/*****************************************************************************/
/* Function: BezTriple_FromPyObject */
/* Description: This function returns the Blender beztriple from the given */
/* PyObject. */
/*****************************************************************************/
BezTriple *BezTriple_FromPyObject( PyObject * pyobj )
{
return ( ( BPy_BezTriple * ) pyobj )->beztriple;
}
/*
Create a new BezTriple
input args is a sequence - either 3 or 9 floats
*/
PyObject *newBezTriple( float *numbuf )
{
int i, j, num;
PyObject *pyobj = NULL;
BezTriple *bzt = NULL;
/* create our own beztriple data */
bzt = MEM_callocN( sizeof( BezTriple ), "new bpytriple");
/* check malloc */
if( !bzt )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"MEM_callocN failed");
/* copy the data */
num = 0;
for( i = 0; i < 3; i++ ) {
for( j = 0; j < 3; j++) {
bzt->vec[i][j] = numbuf[num++];
}
}
bzt->h1 = HD_ALIGN;
bzt->h2 = HD_ALIGN;
/* wrap it */
pyobj = BezTriple_CreatePyObject( bzt );
/* we own it. must free later */
( ( BPy_BezTriple * )pyobj)->own_memory = 1;
return pyobj;
}
/* #####DEPRECATED###### */
static PyObject *BezTriple_oldsetPoints( BPy_BezTriple * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args,
(setter)BezTriple_setPoints );
}

View File

@@ -1,64 +0,0 @@
/*
* $Id: BezTriple.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Jacques Guignot, Stephen Swaney
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_BEZTRIPLE_H
#define EXPP_BEZTRIPLE_H
#include <Python.h>
#include "DNA_curve_types.h"
extern PyTypeObject BezTriple_Type;
/* type check macro */
#define BPy_BezTriple_Check(o) \
( (o)->ob_type == &BezTriple_Type)
/****************************************************************************
Python BPy_BezTriple structure definition:
****************************************************************************/
typedef struct {
PyObject_HEAD /* required python macro */
BezTriple * beztriple;
int own_memory; /* true == we own this memory and must delete. */
} BPy_BezTriple;
/*
* prototypes
*/
PyObject *BezTriple_CreatePyObject( BezTriple * bzt );
BezTriple *BezTriple_FromPyObject( PyObject * pyobj );
PyObject *newBezTriple( float *args );
PyObject *BezTriple_Init( void );
#endif /* EXPP_BEZTRIPLE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,41 +0,0 @@
/*
* $Id: Blender.h 4803 2005-07-18 03:50:37Z ascotan $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Michel Selten, Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_BLENDER_H
#define EXPP_BLENDER_H
#include <Python.h>
extern PyObject *g_blenderdict;
void M_Blender_Init( void );
#endif /* EXPP_BLENDER_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,76 +0,0 @@
/*
* $Id: Bone.h 12399 2007-10-26 08:19:40Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* Contributor(s): Joseph Gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_BONE_H
#define EXPP_BONE_H
#include <Python.h>
#include "DNA_armature_types.h"
/*-------------------TYPE CHECKS---------------------------------*/
#define BoneObject_Check(v) ((v)->ob_type == &Bone_Type)
#define EditBoneObject_Check(v) ((v)->ob_type == &EditBone_Type)
/*-------------------TYPEOBJECT----------------------------------*/
extern PyTypeObject EditBone_Type;
extern PyTypeObject Bone_Type;
/*-------------------STRUCT DEFINITION----------------------------*/
typedef struct {
PyObject_HEAD
Bone * bone;
} BPy_Bone;
typedef struct {
PyObject_HEAD
struct EditBone *editbone;
struct EditBone *parent;
char name[32];
float roll;
float head[3];
float tail[3];
int flag;
float dist;
float weight;
float xwidth;
float zwidth;
float ease1;
float ease2;
float rad_head;
float rad_tail;
short segments;
short layer;
} BPy_EditBone;
/*-------------------VISIBLE PROTOTYPES-------------------------*/
PyObject *PyBone_FromBone(struct Bone *bone);
struct Bone *PyBone_AsBone(BPy_Bone *py_Bone);
PyObject *PyEditBone_FromBone(Bone *bone);
PyObject *PyEditBone_FromEditBone(struct EditBone *editbone);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,82 +0,0 @@
/*
* $Id: Camera.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_CAMERA_H
#define EXPP_CAMERA_H
#include <Python.h>
#include "DNA_camera_types.h"
extern PyTypeObject Camera_Type;
#define BPy_Camera_Check(v) \
((v)->ob_type == &Camera_Type) /* for type checking */
/* Python BPy_Camera structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
Camera * camera;
} BPy_Camera;
/*****************************************************************************/
/* Python BPy_Camera defaults: */
/*****************************************************************************/
/* Camera types */
#define EXPP_CAM_TYPE_PERSP 0
#define EXPP_CAM_TYPE_ORTHO 1
/* Camera mode flags */
#define EXPP_CAM_MODE_SHOWLIMITS 1
#define EXPP_CAM_MODE_SHOWMIST 2
/* Camera MIN, MAX values */
#define EXPP_CAM_LENS_MIN 1.0
#define EXPP_CAM_LENS_MAX 250.0
#define EXPP_CAM_SCALE_MIN 0.01f
#define EXPP_CAM_SCALE_MAX 1000.0
#define EXPP_CAM_CLIPSTART_MIN 0.0
#define EXPP_CAM_CLIPSTART_MAX 100.0
#define EXPP_CAM_CLIPEND_MIN 1.0
#define EXPP_CAM_CLIPEND_MAX 5000.0
#define EXPP_CAM_DRAWSIZE_MIN 0.1f
#define EXPP_CAM_DRAWSIZE_MAX 10.0
PyObject *Camera_Init( void );
PyObject *Camera_CreatePyObject( Camera * cam );
Camera *Camera_FromPyObject( PyObject * pyobj );
#endif /* EXPP_CAMERA_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,76 +0,0 @@
/*
* $Id: Constraint.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joseph Gilbert, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_CONSTRAINT_H
#define EXPP_CONSTRAINT_H
#include <Python.h>
#include "DNA_object_types.h"
#include "DNA_action_types.h"
#include "DNA_constraint_types.h"
#include "DNA_listBase.h"
/*****************************************************************************/
/* Python BPy_Modifier structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD /* required macro */
Object *obj; /* "parent" object */
bPoseChannel *pchan;/* "parent" pose channel */
/* if con this is null, the constraint has been removed and we need to
* raise an error when its data is accessed */
bConstraint *con;
} BPy_Constraint;
extern PyTypeObject Constraint_Type;
#define BPy_Constraint_Check(v) ((v)->ob_type == &Constraint_Type) /* for type checking */
typedef struct {
PyObject_HEAD /* required macro */
Object *obj; /* "parent" object */
bPoseChannel *pchan;/* "parent" pose channel */
bConstraint *iter;
} BPy_ConstraintSeq;
/*
* prototypes
*/
PyObject *Constraint_Init( void );
PyObject *Constraint_CreatePyObject( bPoseChannel *pchan, Object *obj,
bConstraint *con );
bConstraint *Constraint_FromPyObject( BPy_Constraint * obj );
PyObject *PoseConstraintSeq_CreatePyObject( bPoseChannel *pchan );
PyObject *ObConstraintSeq_CreatePyObject( Object *obj );
#endif /* EXPP_CONSTRAINT_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,70 +0,0 @@
/*
* $Id: CurNurb.h 10269 2007-03-15 01:09:14Z campbellbarton $
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Stephen Swaney
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_NURB_H
#define EXPP_NURB_H
#include <Python.h>
#include "DNA_curve_types.h"
extern PyTypeObject CurNurb_Type;
#define BPy_CurNurb_Check(v) ((v)->ob_type == &CurNurb_Type) /* for type checking */
/* Python BPy_CurNurb structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
Nurb * nurb; /* pointer to Blender data */
/* iterator stuff */
/* internal ptrs to point data. do not free */
BPoint *bp;
BezTriple *bezt;
int atEnd; /* iter exhausted flag */
int nextPoint;
} BPy_CurNurb;
/*
* prototypes
*/
PyObject *CurNurb_Init( void );
PyObject *CurNurb_CreatePyObject( Nurb * bzt );
Nurb *CurNurb_FromPyObject( PyObject * pyobj );
PyObject *CurNurb_getPoint( BPy_CurNurb * self, int index );
PyObject *CurNurb_pointAtIndex( Nurb * nurb, int index );
PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * args );
#endif /* EXPP_NURB_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,78 +0,0 @@
/*
* $Id: Curve.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Jacques Guignot, Stephen Swaney
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_CURVE_H
#define EXPP_CURVE_H
#include <Python.h>
#include "DNA_curve_types.h"
extern PyTypeObject Curve_Type;
#define BPy_Curve_Check(v) ((v)->ob_type==&Curve_Type)
/* Python BPy_Curve structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
Curve * curve; /* libdata must be second */
/* pointer for iterator: does not point to owned memory */
Nurb *iter_pointer;
} BPy_Curve;
/*
* protoypes
*/
PyObject *Curve_Init( void );
PyObject *Curve_CreatePyObject( struct Curve * curve );
struct Curve *Curve_FromPyObject( PyObject * py_obj );
PyObject *Curve_update( BPy_Curve * self );
PyObject *Curve_getName( BPy_Curve * self );
PyObject *Curve_setName( BPy_Curve * self, PyObject * args );
PyObject *Curve_getMode( BPy_Curve * self );
PyObject *Curve_setMode( BPy_Curve * self, PyObject * args );
PyObject *Curve_getBevresol( BPy_Curve * self );
PyObject *Curve_setBevresol( BPy_Curve * self, PyObject * args );
PyObject *Curve_getResolu( BPy_Curve * self );
PyObject *Curve_setResolu( BPy_Curve * self, PyObject * args );
PyObject *Curve_getResolv( BPy_Curve * self );
PyObject *Curve_setResolv( BPy_Curve * self, PyObject * args );
PyObject *Curve_getExt1( BPy_Curve * self );
PyObject *Curve_setExt1( BPy_Curve * self, PyObject * args );
PyObject *Curve_getExt2( BPy_Curve * self );
PyObject *Curve_setExt2( BPy_Curve * self, PyObject * args );
PyObject *Curve_getWidth( BPy_Curve * self );
PyObject *Curve_setWidth( BPy_Curve * self, PyObject * args );
#endif /* EXPP_CURVE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,77 +0,0 @@
/*
* $Id: Draw.h 11387 2007-07-27 06:14:25Z joeedh $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/* The code in Draw.[ch] and BGL.[ch] comes from opy_draw.c in the old
* bpython/intern dir, with minor modifications to suit the current
* implementation. Important original comments are marked with an @ symbol. */
#ifndef EXPP_DRAW_H_
#define EXPP_DRAW_H_
#include <Python.h>
#include "DNA_space_types.h"
#include "DNA_text_types.h"
void initDraw( void );
/*
* Button Object stuct
*/
typedef struct _Button {
PyObject_VAR_HEAD /* required Py Macro */
int type; /*@ 1 == int, 2 == float, 3 == string */
unsigned int slen; /*@ length of string (if type == 3) */
union {
int asint;
float asfloat;
char *asstr;
float asvec[3];
} val;
char tooltip[256];
} Button;
#define BPY_MAX_TOOLTIP 255
#define BINT_TYPE 1
#define BFLOAT_TYPE 2
#define BSTRING_TYPE 3
#define BVECTOR_TYPE 4
/*
* these are declared in ../BPY_extern.h
*/
PyObject *M_Draw_Init( void );
PyObject *Draw_Init( void );
#endif /* EXPP_DRAW_H */

View File

@@ -1,230 +0,0 @@
/*
* $Id: EXPP_interface.c 7338 2006-04-30 16:22:31Z ianwill $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Michel Selten
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include <Python.h>
#include "EXPP_interface.h"
#include "BLI_blenlib.h"
#include "MEM_guardedalloc.h"
#include "BLI_linklist.h" /* linked list: LinkNode struct and functions */
#include "DNA_object_types.h"
#include "DNA_space_types.h" /* for FILE_MAXDIR, FILE_MAXFILE */
#include "Blender.h"
extern char bprogname[]; /* argv[0] from creator.c */
/* this makes sure BLI_gethome() returns a path with '.blender' appended
* Besides, this function now either returns userhome/.blender (if it exists)
* or blenderInstallDir/.blender/ otherwise (can also be cvs dir).
* If append_scriptsdir is non NULL, "scripts/" is appended to the dir, to
* get the path to the scripts folder ("release/scripts/" if cvs dir).
* Finally, if all else fails BLI_gethome() is returned
* (or NULL if append_scriptdir != 0).
*/
char *bpy_gethome(int append_scriptsdir)
{
static char homedir[FILE_MAXDIR];
static char scriptsdir[FILE_MAXDIR];
char tmpdir[FILE_MAXDIR];
char bprogdir[FILE_MAXDIR];
char *s;
int i;
if (append_scriptsdir) {
if (scriptsdir[0] != '\0')
return scriptsdir;
}
else if (homedir[0] != '\0')
return homedir;
/* BLI_gethome() can return NULL if env vars are not set */
s = BLI_gethome();
if( !s ) /* bail if no $HOME */
{
printf("$HOME is NOT set\n");
return NULL;
}
if( strstr( s, ".blender" ) )
PyOS_snprintf( homedir, FILE_MAXDIR, s );
else
BLI_make_file_string( "/", homedir, s, ".blender" );
/* if userhome/.blender/ exists, return it */
if( BLI_exists( homedir ) ) {
if (append_scriptsdir) {
BLI_make_file_string("/", scriptsdir, homedir, "scripts");
if (BLI_exists (scriptsdir)) return scriptsdir;
}
else return homedir;
}
else homedir[0] = '\0';
/* if either:
* no homedir was found or
* append_scriptsdir = 1 but there's no scripts/ inside homedir,
* use argv[0] (bprogname) to get .blender/ in
* Blender's installation dir */
s = BLI_last_slash( bprogname );
i = s - bprogname + 1;
PyOS_snprintf( bprogdir, i, "%s", bprogname );
/* using tmpdir to preserve homedir (if) found above:
* the ideal is to have a home dir with scripts dir inside
* it, but if that isn't available, it's possible to
* have a 'broken' home dir somewhere and a scripts dir in the
* cvs sources */
BLI_make_file_string( "/", tmpdir, bprogdir, ".blender" );
if (BLI_exists(tmpdir)) {
if (append_scriptsdir) {
BLI_make_file_string("/", scriptsdir, tmpdir, "scripts");
if (BLI_exists(scriptsdir)) {
PyOS_snprintf(homedir, FILE_MAXDIR, "%s", tmpdir);
return scriptsdir;
}
else {
homedir[0] = '\0';
scriptsdir[0] = '\0';
}
}
else return homedir;
}
/* last try for scripts dir: blender in cvs dir, scripts/ inside release/: */
if (append_scriptsdir) {
BLI_make_file_string("/", scriptsdir, bprogdir, "release/scripts");
if (BLI_exists(scriptsdir)) return scriptsdir;
else scriptsdir[0] = '\0';
}
return NULL;
}
/* PyDrivers */
/*
* Pydrivers are Blender Ipo Drivers defined by Python expressions.
* We need to tell DAG about objects used in these expressions, so we
* eval each expression to collect the ob refs. in it.
*/
/* these are checked for example in Object.c: M_Object_Get (Object.Get())
* to collect the refs. */
static int pydriver_running = 0;
int bpy_during_pydriver(void)
{
return pydriver_running;
}
void bpy_pydriver_running(int state)
{
pydriver_running = state;
}
/* Obj references are collected in this extern linked list: */
LinkNode *bpy_pydriver_oblist = NULL;
void bpy_pydriver_freeList(void)
{
BLI_linklist_free(bpy_pydriver_oblist, NULL);
bpy_pydriver_oblist = NULL;
}
void bpy_pydriver_appendToList(struct Object *ob)
{
LinkNode *ln = bpy_pydriver_oblist;
/* check that the expression is not referencing its owner object */
/* XXX COMMENTED OUT TO TEST IF WE REALLY NEED TO IMPOSE THIS RESTRICTION
if (ln && ln->link) {
if (ob == (Object *)ln->link) {
PyErr_SetString(PyExc_AttributeError,
"Python driver expression can't reference its own object");
return;
}
else
ln = ln->next;
}
*/
while (ln) { /* is ob already in list? ... */
if (ob == (Object *)ln->link)
break;
ln = ln->next;
}
if (!ln) /* ... not yet, append it */
BLI_linklist_append(&bpy_pydriver_oblist, (void *)ob);
return;
}
/* Get an array from our linked list of objs referenced in the
* current pydriver. The first node in the list is discarded,
* since it is the actual pydriver owner, which shouldn't be
* passed to the depsgraph (no self references). */
struct Object **bpy_pydriver_obArrayFromList(void)
{
Object **obarray = NULL;
if (bpy_pydriver_oblist) {
int i;
short len = BLI_linklist_length(bpy_pydriver_oblist);
if (len > 1) {
obarray = (Object **)MEM_mallocN(sizeof(Object*)*len,
"pydriver array");
if (obarray) {
LinkNode *ln = bpy_pydriver_oblist;
ln = ln->next; /* skip first ob, which is the pydriver owner */
for (i = 0; i < len-1; i++) {
obarray[i] = (Object *)ln->link;
ln = ln->next;
}
obarray[len-1] = NULL; /* NULL-terminated array */
}
}
bpy_pydriver_freeList();
}
return obarray;
}

View File

@@ -1,56 +0,0 @@
/*
* $Id: EXPP_interface.h 7338 2006-04-30 16:22:31Z ianwill $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Michel Selten, Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_INTERFACE_H
#define EXPP_INTERFACE_H
struct Object;
struct Script;
struct LinkNode;
extern struct LinkNode *bpy_pydriver_oblist;
void initBlenderApi2_2x( void );
char *bpy_gethome( int append_scriptsdir );
void discardFromBDict( char *key );
void EXPP_Library_Close( void ); /* in Library.c, used by BPY_end_python */
/* PyDrivers */
void bpy_pydriver_freeList(void);
void bpy_pydriver_appendToList(struct Object *ob);
struct Object **bpy_pydriver_obArrayFromList(void);
int bpy_during_pydriver(void);
void bpy_pydriver_running(int state);
#endif /* EXPP_INTERFACE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,58 +0,0 @@
/*
* $Id: Effect.h 5817 2005-11-17 19:19:05Z khughes $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Jacques Guignot
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_EFFECT_H
#define EXPP_EFFECT_H
#include <Python.h>
#include "DNA_effect_types.h"
#include "DNA_object_types.h"
extern PyTypeObject Effect_Type;
#define BPy_Effect_Check(v) ((v)->ob_type==&Effect_Type)
/* Python BPy_Effect structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
PartEff * effect;
Object * object;
} BPy_Effect;
/*****************************************************************************/
/* Python Effect_Type helpder function prototypes: */
/*****************************************************************************/
PyObject *Effect_Init( void );
int EffectCheckPyObject( PyObject * py_obj );
PyObject *EffectCreatePyObject( Effect * eff, Object * ob );
#endif /* EXPP_EFFECT_H */

View File

@@ -1,403 +0,0 @@
/*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joilnen Leite
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Font.h" /*This must come first*/
#include "DNA_packedFile_types.h"
#include "BKE_packedFile.h"
#include "BKE_global.h"
#include "BKE_library.h" /* for rename_id() */
#include "BLI_blenlib.h"
#include "gen_utils.h"
#include "gen_library.h"
#include "BKE_main.h" /* so we can access G.main->vfont.first */
#include "DNA_space_types.h" /* for FILE_MAXDIR only */
extern PyObject *M_Text3d_LoadFont( PyObject * self, PyObject * args );
/*--------------------Python API function prototypes for the Font module----*/
static PyObject *M_Font_Load( PyObject * self, PyObject * value );
static PyObject *M_Font_Get( PyObject * self, PyObject * args );
/*------------------------Python API Doc strings for the Font module--------*/
char M_Font_doc[] = "The Blender Font module\n\n\
This module provides control over **Font Data** objects in Blender.\n\n\
Example::\n\n\
from Blender import Text3d.Font\n\
l = Text3d.Font.Load('/usr/share/fonts/verdata.ttf')\n";
char M_Font_Get_doc[] = "(name) - return an existing font called 'name'\
when no argument is given it returns a list of blenders fonts.";
char M_Font_Load_doc[] =
"(filename) - return font from file filename as Font Object, \
returns None if not found.\n";
/*----- Python method structure definition for Blender.Text3d.Font module---*/
struct PyMethodDef M_Font_methods[] = {
{"Get", ( PyCFunction ) M_Font_Get, METH_VARARGS, M_Font_Get_doc},
{"Load", ( PyCFunction ) M_Font_Load, METH_O, M_Font_Load_doc},
{NULL, NULL, 0, NULL}
};
/*--------------- Python BPy_Font methods declarations:-------------------*/
static PyObject *Font_pack( BPy_Font * self );
static PyObject *Font_unpack( BPy_Font * self, PyObject * args );
/*--------------- Python BPy_Font methods table:--------------------------*/
static PyMethodDef BPy_Font_methods[] = {
{"pack", ( PyCFunction ) Font_pack, METH_NOARGS,
"() - pack this Font"},
{"unpack", ( PyCFunction ) Font_unpack, METH_O,
"(mode) - unpack this packed font"},
{NULL, NULL, 0, NULL}
};
/*--------------- Python TypeFont callback function prototypes----------*/
static int Font_compare( BPy_Font * a1, BPy_Font * a2 );
static PyObject *Font_repr( BPy_Font * font );
/*--------------- Python Font Module methods------------------------*/
/*--------------- Blender.Text3d.Font.Get()-----------------------*/
static PyObject *M_Font_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
VFont *vfont_iter;
if( !PyArg_ParseTuple( args, "|s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument (or nothing)" ) );
vfont_iter = G.main->vfont.first;
if( name ) { /* (name) - Search font by name */
BPy_Font *wanted_vfont = NULL;
while(vfont_iter) {
if( strcmp( name, vfont_iter->id.name + 2 ) == 0 ) {
wanted_vfont =
( BPy_Font * )
Font_CreatePyObject( vfont_iter );
break;
}
vfont_iter = vfont_iter->id.next;
}
if( wanted_vfont == NULL ) { /* Requested font doesn't exist */
char error_msg[64];
PyOS_snprintf( error_msg, sizeof( error_msg ),
"Font \"%s\" not found", name );
return ( EXPP_ReturnPyObjError
( PyExc_NameError, error_msg ) );
}
return ( PyObject * ) wanted_vfont;
}
else { /* () - return a list of all fonts in the scene */
int index = 0;
PyObject *vfontlist, *pyobj;
vfontlist = PyList_New( BLI_countlist( &( G.main->vfont ) ) );
if( vfontlist == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create font list" ) );
while( vfont_iter ) {
pyobj = Font_CreatePyObject( vfont_iter );
if( !pyobj ) {
Py_DECREF(vfontlist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create Object" ) );
}
PyList_SET_ITEM( vfontlist, index, pyobj );
vfont_iter = vfont_iter->id.next;
index++;
}
return vfontlist;
}
}
/*--------------- Blender.Text3d.Font.New()-----------------------*/
PyObject *M_Font_Load( PyObject * self, PyObject * value )
{
char *filename_str = PyString_AsString(value);
BPy_Font *py_font = NULL; /* for Font Data object wrapper in Python */
if( !value )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected string or empty argument" ) );
/*create python font*/
if( !S_ISDIR(BLI_exist(filename_str)) ) {
py_font= (BPy_Font *) M_Text3d_LoadFont (self, value);
}
else
Py_RETURN_NONE;
return ( PyObject * ) py_font;
}
/*--------------- Python BPy_Font getsetattr funcs ---------------------*/
/*--------------- BPy_Font.filename-------------------------------------*/
static PyObject *Font_getFilename( BPy_Font * self )
{
return PyString_FromString( self->font->name );
}
static int Font_setFilename( BPy_Font * self, PyObject * value )
{
char *name = NULL;
/* max len is FILE_MAXDIR = 160 chars like done in DNA_image_types.h */
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
PyOS_snprintf( self->font->name, FILE_MAXDIR * sizeof( char ), "%s",
name );
return 0;
}
/*--------------- BPy_Font.pack()---------------------------------*/
static PyObject *Font_pack( BPy_Font * self )
{
if( !self->font->packedfile )
self->font->packedfile = newPackedFile(self->font->name);
Py_RETURN_NONE;
}
/*--------------- BPy_Font.unpack()---------------------------------*/
static PyObject *Font_unpack( BPy_Font * self, PyObject * value )
{
int mode= PyInt_AsLong(value);
VFont *font= self->font;
if( mode==-1 )
return ( EXPP_ReturnPyObjError
( PyExc_AttributeError,
"expected int argument from Blender.UnpackModes" ) );
if (font->packedfile)
if (unpackVFont(font, mode) == RET_ERROR)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"error unpacking font" );
Py_RETURN_NONE;
}
/*--------------- BPy_Font.packed---------------------------------*/
static PyObject *Font_getPacked( BPy_Font * self )
{
if (G.fileflags & G_AUTOPACK)
return EXPP_incr_ret_True();
else
return EXPP_incr_ret_False();
}
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Font_getseters[] = {
GENERIC_LIB_GETSETATTR,
{"filename",
(getter)Font_getFilename, (setter)Font_setFilename,
"Font filepath",
NULL},
{"packed",
(getter)Font_getPacked, (setter)NULL,
"Packed status",
NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
/*****************************************************************************/
/* Python TypeFont structure definition: */
/*****************************************************************************/
PyTypeObject Font_Type = {
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"Blender Font", /* char *tp_name; */
sizeof( BPy_Font ), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
NULL, /* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
( cmpfunc ) Font_compare, /* cmpfunc tp_compare; */
( reprfunc ) Font_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
( hashfunc ) GenericLib_hash, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_Font_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_Font_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};
/*--------------- Font Module Init-----------------------------*/
PyObject *Font_Init( void )
{
PyObject *submodule;
if( PyType_Ready( &Font_Type ) < 0 )
return NULL;
submodule = Py_InitModule3( "Blender.Text3d.Font",
M_Font_methods, M_Font_doc );
return ( submodule );
}
/*--------------- Font module internal callbacks-----------------*/
/*---------------BPy_Font internal callbacks/methods-------------*/
/*--------------- repr---------------------------------------------*/
static PyObject *Font_repr( BPy_Font * self )
{
if( self->font )
return PyString_FromFormat( "[Font \"%s\"]",
self->font->id.name+2 );
else
return PyString_FromString( "[Font - no data]" );
}
/*--------------- compare------------------------------------------*/
static int Font_compare( BPy_Font * a, BPy_Font * b )
{
return ( a->font == b->font ) ? 0 : -1;
}
/*--------------- Font_CreatePyObject---------------------------------*/
PyObject *Font_CreatePyObject( struct VFont * font )
{
BPy_Font *blen_font;
blen_font = ( BPy_Font * ) PyObject_NEW( BPy_Font, &Font_Type );
blen_font->font = font;
return ( ( PyObject * ) blen_font );
}
/*--------------- Font_FromPyObject---------------------------------*/
struct VFont *Font_FromPyObject( PyObject * py_obj )
{
BPy_Font *blen_obj;
blen_obj = ( BPy_Font * ) py_obj;
if( !( ( BPy_Font * ) py_obj )->font ) { /*test to see if linked to text3d*/
//use python vars
return NULL;
} else {
return ( blen_obj->font );
}
}

View File

@@ -1,53 +0,0 @@
/*
* $Id: Font.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joilnen Leite
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_FONT_H
#define EXPP_FONT_H
#include <Python.h>
#include "DNA_vfont_types.h"
extern PyTypeObject Font_Type;
typedef struct {
PyObject_HEAD /* required py macro */
VFont * font; /* libdata must be second */
} BPy_Font;
/*------------------------------visible prototypes----------------------*/
PyObject *Font_CreatePyObject( struct VFont * font );
struct VFont *Font_FromPyObject( PyObject * py_obj );
PyObject *Font_Init( void );
#endif

View File

@@ -1,428 +0,0 @@
/*
* $Id: Geometry.c 12867 2007-12-13 15:06:02Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joseph Gilbert, Campbell Barton
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Geometry.h"
/* - Not needed for now though other geometry functions will probably need them
#include "BLI_arithb.h"
#include "BKE_utildefines.h"
*/
/* Used for PolyFill */
#include "BKE_displist.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
/* needed for EXPP_ReturnPyObjError and EXPP_check_sequence_consistency */
#include "gen_utils.h"
#include "BKE_utildefines.h"
#include "BLI_boxpack2d.h"
#include "BLI_arithb.h"
#define SWAP_FLOAT(a,b,tmp) tmp=a; a=b; b=tmp
#define eul 0.000001
/*-- forward declarations -- */
static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq );
static PyObject *M_Geometry_LineIntersect2D( PyObject * self, PyObject * args );
static PyObject *M_Geometry_ClosestPointOnLine( PyObject * self, PyObject * args );
static PyObject *M_Geometry_PointInTriangle2D( PyObject * self, PyObject * args );
static PyObject *M_Geometry_BoxPack2D( PyObject * self, PyObject * args );
/*-------------------------DOC STRINGS ---------------------------*/
static char M_Geometry_doc[] = "The Blender Geometry module\n\n";
static char M_Geometry_PolyFill_doc[] = "(veclist_list) - takes a list of polylines (each point a vector) and returns the point indicies for a polyline filled with triangles";
static char M_Geometry_LineIntersect2D_doc[] = "(lineA_p1, lineA_p2, lineB_p1, lineB_p2) - takes 2 lines (as 4 vectors) and returns a vector for their point of intersection or None";
static char M_Geometry_ClosestPointOnLine_doc[] = "(pt, line_p1, line_p2) - takes a point and a line and returns a (Vector, Bool) for the point on the line, and the bool so you can know if the point was between the 2 points";
static char M_Geometry_PointInTriangle2D_doc[] = "(pt, tri_p1, tri_p2, tri_p3) - takes 4 vectors, one is the point and the next 3 define the triabgle, only the x and y are used from the vectors";
static char M_Geometry_BoxPack2D_doc[] = "";
/*-----------------------METHOD DEFINITIONS ----------------------*/
struct PyMethodDef M_Geometry_methods[] = {
{"PolyFill", ( PyCFunction ) M_Geometry_PolyFill, METH_O, M_Geometry_PolyFill_doc},
{"LineIntersect2D", ( PyCFunction ) M_Geometry_LineIntersect2D, METH_VARARGS, M_Geometry_LineIntersect2D_doc},
{"ClosestPointOnLine", ( PyCFunction ) M_Geometry_ClosestPointOnLine, METH_VARARGS, M_Geometry_ClosestPointOnLine_doc},
{"PointInTriangle2D", ( PyCFunction ) M_Geometry_PointInTriangle2D, METH_VARARGS, M_Geometry_PointInTriangle2D_doc},
{"BoxPack2D", ( PyCFunction ) M_Geometry_BoxPack2D, METH_O, M_Geometry_BoxPack2D_doc},
{NULL, NULL, 0, NULL}
};
/*----------------------------MODULE INIT-------------------------*/
PyObject *Geometry_Init(void)
{
PyObject *submodule;
submodule = Py_InitModule3("Blender.Geometry",
M_Geometry_methods, M_Geometry_doc);
return (submodule);
}
/*----------------------------------Geometry.PolyFill() -------------------*/
/* PolyFill function, uses Blenders scanfill to fill multiple poly lines */
static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq )
{
PyObject *tri_list; /*return this list of tri's */
PyObject *polyLine, *polyVec;
int i, len_polylines, len_polypoints;
/* display listbase */
ListBase dispbase={NULL, NULL};
DispList *dl;
float *fp; /*pointer to the array of malloced dl->verts to set the points from the vectors */
int index, *dl_face, totpoints=0;
dispbase.first= dispbase.last= NULL;
if(!PySequence_Check(polyLineSeq)) {
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a sequence of poly lines" );
}
len_polylines = PySequence_Size( polyLineSeq );
for( i = 0; i < len_polylines; ++i ) {
polyLine= PySequence_GetItem( polyLineSeq, i );
if (!PySequence_Check(polyLine)) {
freedisplist(&dispbase);
Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/
return EXPP_ReturnPyObjError( PyExc_TypeError,
"One or more of the polylines is not a sequence of Mathutils.Vector's" );
}
len_polypoints= PySequence_Size( polyLine );
if (len_polypoints>0) { /* dont bother adding edges as polylines */
if (EXPP_check_sequence_consistency( polyLine, &vector_Type ) != 1) {
freedisplist(&dispbase);
Py_DECREF(polyLine);
return EXPP_ReturnPyObjError( PyExc_TypeError,
"A point in one of the polylines is not a Mathutils.Vector type" );
}
dl= MEM_callocN(sizeof(DispList), "poly disp");
BLI_addtail(&dispbase, dl);
dl->type= DL_INDEX3;
dl->nr= len_polypoints;
dl->type= DL_POLY;
dl->parts= 1; /* no faces, 1 edge loop */
dl->col= 0; /* no material */
dl->verts= fp= MEM_callocN( sizeof(float)*3*len_polypoints, "dl verts");
dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index");
for( index = 0; index<len_polypoints; ++index, fp+=3) {
polyVec= PySequence_GetItem( polyLine, index );
fp[0] = ((VectorObject *)polyVec)->vec[0];
fp[1] = ((VectorObject *)polyVec)->vec[1];
if( ((VectorObject *)polyVec)->size > 2 )
fp[2] = ((VectorObject *)polyVec)->vec[2];
else
fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */
totpoints++;
Py_DECREF(polyVec);
}
}
Py_DECREF(polyLine);
}
if (totpoints) {
/* now make the list to return */
filldisplist(&dispbase, &dispbase);
/* The faces are stored in a new DisplayList
thats added to the head of the listbase */
dl= dispbase.first;
tri_list= PyList_New(dl->parts);
if( !tri_list ) {
freedisplist(&dispbase);
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Geometry.PolyFill failed to make a new list" );
}
index= 0;
dl_face= dl->index;
while(index < dl->parts) {
PyList_SetItem(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2]) );
dl_face+= 3;
index++;
}
freedisplist(&dispbase);
} else {
/* no points, do this so scripts dont barf */
tri_list= PyList_New(0);
}
return tri_list;
}
static PyObject *M_Geometry_LineIntersect2D( PyObject * self, PyObject * args )
{
VectorObject *line_a1, *line_a2, *line_b1, *line_b2;
float a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y, xi, yi, a1,a2,b1,b2, newvec[2];
if( !PyArg_ParseTuple ( args, "O!O!O!O!",
&vector_Type, &line_a1,
&vector_Type, &line_a2,
&vector_Type, &line_b1,
&vector_Type, &line_b2)
)
return ( EXPP_ReturnPyObjError
( PyExc_TypeError, "expected 4 vector types\n" ) );
a1x= line_a1->vec[0];
a1y= line_a1->vec[1];
a2x= line_a2->vec[0];
a2y= line_a2->vec[1];
b1x= line_b1->vec[0];
b1y= line_b1->vec[1];
b2x= line_b2->vec[0];
b2y= line_b2->vec[1];
if((MIN2(a1x, a2x) > MAX2(b1x, b2x)) ||
(MAX2(a1x, a2x) < MIN2(b1x, b2x)) ||
(MIN2(a1y, a2y) > MAX2(b1y, b2y)) ||
(MAX2(a1y, a2y) < MIN2(b1y, b2y)) ) {
Py_RETURN_NONE;
}
/* Make sure the hoz/vert line comes first. */
if (fabs(b1x - b2x) < eul || fabs(b1y - b2y) < eul) {
SWAP_FLOAT(a1x, b1x, xi); /*abuse xi*/
SWAP_FLOAT(a1y, b1y, xi);
SWAP_FLOAT(a2x, b2x, xi);
SWAP_FLOAT(a2y, b2y, xi);
}
if (fabs(a1x-a2x) < eul) { /* verticle line */
if (fabs(b1x-b2x) < eul){ /*verticle second line */
Py_RETURN_NONE; /* 2 verticle lines dont intersect. */
}
else if (fabs(b1y-b2y) < eul) {
/*X of vert, Y of hoz. no calculation needed */
newvec[0]= a1x;
newvec[1]= b1y;
return newVectorObject(newvec, 2, Py_NEW);
}
yi = (float)(((b1y / fabs(b1x - b2x)) * fabs(b2x - a1x)) + ((b2y / fabs(b1x - b2x)) * fabs(b1x - a1x)));
if (yi > MAX2(a1y, a2y)) {/* New point above seg1's vert line */
Py_RETURN_NONE;
} else if (yi < MIN2(a1y, a2y)) { /* New point below seg1's vert line */
Py_RETURN_NONE;
}
newvec[0]= a1x;
newvec[1]= yi;
return newVectorObject(newvec, 2, Py_NEW);
} else if (fabs(a2y-a1y) < eul) { /* hoz line1 */
if (fabs(b2y-b1y) < eul) { /*hoz line2*/
Py_RETURN_NONE; /*2 hoz lines dont intersect*/
}
/* Can skip vert line check for seg 2 since its covered above. */
xi = (float)(((b1x / fabs(b1y - b2y)) * fabs(b2y - a1y)) + ((b2x / fabs(b1y - b2y)) * fabs(b1y - a1y)));
if (xi > MAX2(a1x, a2x)) { /* New point right of hoz line1's */
Py_RETURN_NONE;
} else if (xi < MIN2(a1x, a2x)) { /*New point left of seg1's hoz line */
Py_RETURN_NONE;
}
newvec[0]= xi;
newvec[1]= a1y;
return newVectorObject(newvec, 2, Py_NEW);
}
b1 = (a2y-a1y)/(a2x-a1x);
b2 = (b2y-b1y)/(b2x-b1x);
a1 = a1y-b1*a1x;
a2 = b1y-b2*b1x;
if (b1 - b2 == 0.0) {
Py_RETURN_NONE;
}
xi = - (a1-a2)/(b1-b2);
yi = a1+b1*xi;
if ((a1x-xi)*(xi-a2x) >= 0 && (b1x-xi)*(xi-b2x) >= 0 && (a1y-yi)*(yi-a2y) >= 0 && (b1y-yi)*(yi-b2y)>=0) {
newvec[0]= xi;
newvec[1]= yi;
return newVectorObject(newvec, 2, Py_NEW);
}
Py_RETURN_NONE;
}
static PyObject *M_Geometry_ClosestPointOnLine( PyObject * self, PyObject * args )
{
VectorObject *pt, *line_1, *line_2;
float pt_in[3], pt_out[3], l1[3], l2[3];
float lambda;
PyObject *ret;
if( !PyArg_ParseTuple ( args, "O!O!O!",
&vector_Type, &pt,
&vector_Type, &line_1,
&vector_Type, &line_2)
)
return ( EXPP_ReturnPyObjError
( PyExc_TypeError, "expected 3 vector types\n" ) );
/* accept 2d verts */
if (pt->size==3) { VECCOPY(pt_in, pt->vec);}
else { pt_in[2]=0.0; VECCOPY2D(pt_in, pt->vec) }
if (line_1->size==3) { VECCOPY(l1, line_1->vec);}
else { l1[2]=0.0; VECCOPY2D(l1, line_1->vec) }
if (line_2->size==3) { VECCOPY(l2, line_2->vec);}
else { l2[2]=0.0; VECCOPY2D(l2, line_2->vec) }
/* do the calculation */
lambda = lambda_cp_line_ex(pt_in, l1, l2, pt_out);
ret = PyTuple_New(2);
PyTuple_SET_ITEM( ret, 0, newVectorObject(pt_out, 3, Py_NEW) );
PyTuple_SET_ITEM( ret, 1, PyFloat_FromDouble(lambda) );
return ret;
}
#define SIDE_OF_LINE(pa,pb,pp) ((pa[0]-pp[0])*(pb[1]-pp[1]))-((pb[0]-pp[0])*(pa[1]-pp[1]))
#define POINT_IN_TRI(p0,p1,p2,p3) ((SIDE_OF_LINE(p1,p2,p0)>=0) && (SIDE_OF_LINE(p2,p3,p0)>=0) && (SIDE_OF_LINE(p3,p1,p0)>=0))
static PyObject *M_Geometry_PointInTriangle2D( PyObject * self, PyObject * args )
{
VectorObject *pt_vec, *tri_p1, *tri_p2, *tri_p3;
if( !PyArg_ParseTuple ( args, "O!O!O!O!",
&vector_Type, &pt_vec,
&vector_Type, &tri_p1,
&vector_Type, &tri_p2,
&vector_Type, &tri_p3)
)
return ( EXPP_ReturnPyObjError
( PyExc_TypeError, "expected 4 vector types\n" ) );
if POINT_IN_TRI(pt_vec->vec, tri_p1->vec, tri_p2->vec, tri_p3->vec)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
int boxPack_FromPyObject(PyObject * value, boxPack **boxarray )
{
int len, i;
PyObject *list_item, *item_1, *item_2;
boxPack *box;
/* Error checking must alredy be done */
if( !PyList_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"can only back a list of [x,y,x,w]" );
len = PyList_Size( value );
(*boxarray) = MEM_mallocN( len*sizeof(boxPack), "boxPack box");
for( i = 0; i < len; i++ ) {
list_item = PyList_GET_ITEM( value, i );
if( !PyList_Check( list_item ) || PyList_Size( list_item ) < 4 ) {
MEM_freeN(*boxarray);
return EXPP_ReturnIntError( PyExc_TypeError,
"can only back a list of [x,y,x,w]" );
}
box = (*boxarray)+i;
item_1 = PyList_GET_ITEM(list_item, 2);
item_2 = PyList_GET_ITEM(list_item, 3);
if (!PyNumber_Check(item_1) || !PyNumber_Check(item_2)) {
MEM_freeN(*boxarray);
return EXPP_ReturnIntError( PyExc_TypeError,
"can only back a list of 2d boxes [x,y,x,w]" );
}
box->w = (float)PyFloat_AsDouble( item_1 );
box->h = (float)PyFloat_AsDouble( item_2 );
box->index = i;
/* verts will be added later */
}
return 0;
}
void boxPack_ToPyObject(PyObject * value, boxPack **boxarray)
{
int len, i;
PyObject *list_item;
boxPack *box;
len = PyList_Size( value );
for( i = 0; i < len; i++ ) {
box = (*boxarray)+i;
list_item = PyList_GET_ITEM( value, box->index );
PyList_SET_ITEM( list_item, 0, PyFloat_FromDouble( box->x ));
PyList_SET_ITEM( list_item, 1, PyFloat_FromDouble( box->y ));
}
MEM_freeN(*boxarray);
}
static PyObject *M_Geometry_BoxPack2D( PyObject * self, PyObject * boxlist )
{
boxPack *boxarray;
float tot_width, tot_height;
int len;
int error;
if(!PyList_Check(boxlist))
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a sequence of boxes [[x,y,w,h], ... ]" );
len = PyList_Size( boxlist );
if (!len)
return Py_BuildValue( "ff", 0.0, 0.0);
error = boxPack_FromPyObject(boxlist, &boxarray);
if (error!=0) return NULL;
/* Non Python function */
boxPack2D(boxarray, len, &tot_width, &tot_height);
boxPack_ToPyObject(boxlist, &boxarray);
return Py_BuildValue( "ff", tot_width, tot_height);
}

View File

@@ -1,42 +0,0 @@
/*
* $Id: Geometry.h 10324 2007-03-21 17:06:02Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joseph Gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/*Include this file for access to vector, quat, matrix, euler, etc...*/
#ifndef EXPP_Geometry_H
#define EXPP_Geometry_H
#include <Python.h>
#include "vector.h"
PyObject *Geometry_Init( void );
#endif /* EXPP_Geometry_H */

View File

@@ -1,813 +0,0 @@
/*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Group.h" /* This must come first */
#include "MEM_guardedalloc.h"
#include "DNA_group_types.h"
#include "DNA_scene_types.h" /* for Base */
#include "BKE_mesh.h"
#include "BKE_library.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_scene.h"
#include "BKE_group.h"
#include "BLI_blenlib.h"
#include "blendef.h"
#include "Object.h"
#include "gen_utils.h"
#include "gen_library.h"
/* checks for the group being removed */
#define GROUP_DEL_CHECK_PY(bpy_group) if (!(bpy_group->group)) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "Group has been removed" ) )
#define GROUP_DEL_CHECK_INT(bpy_group) if (!(bpy_group->group)) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "Group has been removed" ) )
/*****************************************************************************/
/* Python API function prototypes for the Blender module. */
/*****************************************************************************/
static PyObject *M_Group_New( PyObject * self, PyObject * args );
PyObject *M_Group_Get( PyObject * self, PyObject * args );
PyObject *M_Group_Unlink( PyObject * self, BPy_Group * pygrp );
/* internal */
static PyObject *GroupObSeq_CreatePyObject( BPy_Group *self, GroupObject *iter );
/*****************************************************************************/
/* Python method structure definition for Blender.Object module: */
/*****************************************************************************/
struct PyMethodDef M_Group_methods[] = {
{"New", ( PyCFunction ) M_Group_New, METH_VARARGS,
"(name) Add a new empty group"},
{"Get", ( PyCFunction ) M_Group_Get, METH_VARARGS,
"(name) - return the group with the name 'name',\
returns None if notfound.\nIf 'name' is not specified, it returns a list of all groups."},
{"Unlink", ( PyCFunction ) M_Group_Unlink, METH_O,
"(group) - Unlink (delete) this group from Blender."},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_Group methods table: */
/*****************************************************************************/
static PyObject *BPy_Group_copy( BPy_Group * self );
static PyMethodDef BPy_Group_methods[] = {
/* name, method, flags, doc */
{"__copy__", ( PyCFunction ) BPy_Group_copy, METH_VARARGS,
"() - Return a copy of the group containing the same objects."},
{"copy", ( PyCFunction ) BPy_Group_copy, METH_VARARGS,
"() - Return a copy of the group containing the same objects."},
{NULL, NULL, 0, NULL}
};
static PyObject *BPy_Group_copy( BPy_Group * self )
{
BPy_Group *py_group; /* for Group Data object wrapper in Python */
struct Group *bl_group;
GroupObject *group_ob, *group_ob_new; /* Group object, copied and added to the groups */
GROUP_DEL_CHECK_PY(self);
bl_group= add_group( self->group->id.name + 2 );
if( bl_group ) /* now create the wrapper grp in Python */
py_group = ( BPy_Group * ) Group_CreatePyObject( bl_group );
else
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Group Data in Blender" ) );
bl_group->id.us = 1;
/* Now add the objects to the group */
group_ob= self->group->gobject.first;
while(group_ob) {
/* save time by not using */
group_ob_new= MEM_callocN(sizeof(GroupObject), "groupobject");
group_ob_new->ob= group_ob->ob;
BLI_addtail( &bl_group->gobject, group_ob_new);
group_ob= group_ob->next;
}
return ( PyObject * ) py_group;
}
/************************************************************************
*
* Python BPy_Object attributes
*
************************************************************************/
static PyObject *Group_getObjects( BPy_Group * self )
{
return GroupObSeq_CreatePyObject(self, NULL);
}
static void add_to_group_wraper(Group *group, Object *ob) {
Base *base;
add_to_group(group, ob);
if (!(ob->flag & OB_FROMGROUP)) { /* do this to avoid a listbase lookup */
ob->flag |= OB_FROMGROUP;
base= object_in_scene(ob, G.scene);
if (base)
base->flag |= OB_FROMGROUP;
}
}
/* only for internal use Blender.Group.Get("MyGroup").objects= []*/
static int Group_setObjects( BPy_Group * self, PyObject * args )
{
int i, list_size;
Group *group;
Object *blen_ob;
group= self->group;
GROUP_DEL_CHECK_INT(self);
if( PyList_Check( args ) ) {
if( EXPP_check_sequence_consistency( args, &Object_Type ) != 1)
return ( EXPP_ReturnIntError( PyExc_TypeError,
"expected a list of objects" ) );
/* remove all from the list and add the new items */
free_group(group); /* unlink all objects from this group, keep the group */
list_size= PyList_Size( args );
for( i = 0; i < list_size; i++ ) {
blen_ob= ((BPy_Object *)PyList_GET_ITEM( args, i ))->object;
add_to_group_wraper(group, blen_ob);
}
} else if (PyIter_Check(args)) {
PyObject *iterator = PyObject_GetIter(args);
PyObject *item;
if (iterator == NULL) {
Py_DECREF(iterator);
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a list of objects, This iterator cannot be used." );
}
free_group(group); /* unlink all objects from this group, keep the group */
item = PyIter_Next(iterator);
while (item) {
if ( PyObject_TypeCheck(item, &Object_Type) ) {
blen_ob= ((BPy_Object *)item)->object;
add_to_group_wraper(group, blen_ob);
}
Py_DECREF(item);
item = PyIter_Next(iterator);
}
Py_DECREF(iterator);
if (PyErr_Occurred()) {
return EXPP_ReturnIntError( PyExc_RuntimeError,
"An unknown error occured while adding iterator objects to the group.\nThe group has been modified." );
}
} else
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a list or sequence of objects" );
return 0;
}
/*****************************************************************************/
/* PythonTypeObject callback function prototypes */
/*****************************************************************************/
static PyObject *Group_repr( BPy_Group * obj );
static int Group_compare( BPy_Group * a, BPy_Group * b );
/*****************************************************************************/
/* Python BPy_Group getsetattr funcs: */
/*****************************************************************************/
static int Group_setLayers( BPy_Group * self, PyObject * value )
{
unsigned int laymask = 0;
GROUP_DEL_CHECK_INT(self);
if( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an integer (bitmask) as argument" );
laymask = ( unsigned int )PyInt_AS_LONG( value );
if( laymask <= 0 )
return EXPP_ReturnIntError( PyExc_ValueError,
"layer value cannot be zero or below" );
self->group->layer= laymask & ((1<<20) - 1);
return 0;
}
static PyObject *Group_getLayers( BPy_Group * self )
{
return PyInt_FromLong( self->group->layer );
}
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Group_getseters[] = {
GENERIC_LIB_GETSETATTR,
{"layers",
(getter)Group_getLayers, (setter)Group_setLayers,
"layer mask for this group",
NULL},
{"objects",
(getter)Group_getObjects, (setter)Group_setObjects,
"objects in this group",
NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
/*****************************************************************************/
/* Python TypeGroup structure definition: */
/*****************************************************************************/
PyTypeObject Group_Type = {
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"Blender Group", /* char *tp_name; */
sizeof( BPy_Group ), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
NULL, /* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
( cmpfunc ) Group_compare, /* cmpfunc tp_compare; */
( reprfunc ) Group_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
( hashfunc ) GenericLib_hash, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_Group_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_Group_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};
/*****************************************************************************/
/* Function: M_Group_New */
/* Python equivalent: Blender.Group.New */
/*****************************************************************************/
PyObject *M_Group_New( PyObject * self, PyObject * args )
{
char *name = "Group";
BPy_Group *py_group; /* for Group Data object wrapper in Python */
struct Group *bl_group;
if( !PyArg_ParseTuple( args, "|s", &name ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"string expected as argument or nothing" );
bl_group= add_group( name );
if( bl_group ) /* now create the wrapper grp in Python */
py_group = ( BPy_Group * ) Group_CreatePyObject( bl_group );
else
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Group Data in Blender" ) );
bl_group->id.us = 1;
return ( PyObject * ) py_group;
}
/*****************************************************************************/
/* Function: M_Group_Get */
/* Python equivalent: Blender.Group.Get */
/*****************************************************************************/
PyObject *M_Group_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
Group *group_iter;
if( !PyArg_ParseTuple( args, "|s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument (or nothing)" ) );
group_iter = G.main->group.first;
if( name ) { /* (name) - Search group by name */
BPy_Group *wanted_group = NULL;
while( ( group_iter ) && ( wanted_group == NULL ) ) {
if( strcmp( name, group_iter->id.name + 2 ) == 0 )
wanted_group =
( BPy_Group * )
Group_CreatePyObject( group_iter );
group_iter = group_iter->id.next;
}
if( wanted_group == NULL ) { /* Requested group doesn't exist */
char error_msg[64];
PyOS_snprintf( error_msg, sizeof( error_msg ),
"Group \"%s\" not found", name );
return ( EXPP_ReturnPyObjError
( PyExc_NameError, error_msg ) );
}
return ( PyObject * ) wanted_group;
}
else { /* () - return a list of all groups in the scene */
int index = 0;
PyObject *grouplist, *pyobj;
grouplist = PyList_New( BLI_countlist( &( G.main->group ) ) );
if( grouplist == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create group list" ) );
while( group_iter ) {
pyobj = Group_CreatePyObject( group_iter );
if( !pyobj ) {
Py_DECREF(grouplist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create Object" ) );
}
PyList_SET_ITEM( grouplist, index, pyobj );
group_iter = group_iter->id.next;
index++;
}
return grouplist;
}
}
/*****************************************************************************/
/* Function: M_Group_Unlink */
/* Python equivalent: Blender.Group.Unlink */
/*****************************************************************************/
PyObject *M_Group_Unlink( PyObject * self, BPy_Group * pygrp )
{
Group *group;
if( !BPy_Group_Check(pygrp) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a group" ) );
GROUP_DEL_CHECK_PY(pygrp);
group= pygrp->group;
pygrp->group= NULL;
free_group(group);
unlink_group(group);
group->id.us= 0;
free_libblock( &G.main->group, group );
Py_RETURN_NONE;
}
/*****************************************************************************/
/* Function: initObject */
/*****************************************************************************/
PyObject *Group_Init( void )
{
PyObject *submodule;
if( PyType_Ready( &Group_Type ) < 0 )
return NULL;
if( PyType_Ready( &GroupObSeq_Type ) < 0 )
return NULL;
submodule = Py_InitModule3( "Blender.Group", M_Group_methods,
"The Blender Group module\n\n\
This module provides access to **Group Data** in Blender.\n" );
/*Add SUBMODULES to the module*/
/*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); //creates a *new* module*/
return submodule;
}
/*****************************************************************************/
/* Function: Group_CreatePyObject */
/* Description: This function will create a new BlenObject from an existing */
/* Object structure. */
/*****************************************************************************/
PyObject *Group_CreatePyObject( struct Group * grp )
{
BPy_Group *pygrp;
if( !grp )
Py_RETURN_NONE;
pygrp =
( BPy_Group * ) PyObject_NEW( BPy_Group, &Group_Type );
if( pygrp == NULL ) {
return ( NULL );
}
pygrp->group = grp;
return ( ( PyObject * ) pygrp );
}
/*****************************************************************************/
/* Function: Group_FromPyObject */
/* Description: This function returns the Blender group from the given */
/* PyObject. */
/*****************************************************************************/
Group *Group_FromPyObject( PyObject * py_grp )
{
BPy_Group *blen_grp;
blen_grp = ( BPy_Group * ) py_grp;
return ( blen_grp->group );
}
/*****************************************************************************/
/* Function: Group_compare */
/* Description: This is a callback function for the BPy_Group type. It */
/* compares two Group_Type objects. Only the "==" and "!=" */
/* comparisons are meaninful. Returns 0 for equality and -1 if */
/* they don't point to the same Blender Object struct. */
/* In Python it becomes 1 if they are equal, 0 otherwise. */
/*****************************************************************************/
static int Group_compare( BPy_Group * a, BPy_Group * b )
{
Group *pa = a->group, *pb = b->group;
return ( pa == pb ) ? 0 : -1;
}
/*****************************************************************************/
/* Function: Group_repr */
/* Description: This is a callback function for the BPy_Group type. It */
/* builds a meaninful string to represent object objects. */
/*****************************************************************************/
static PyObject *Group_repr( BPy_Group * self )
{
if (!self->group)
return PyString_FromString( "[Group - Removed]" );
return PyString_FromFormat( "[Group \"%s\"]",
self->group->id.name + 2 );
}
/************************************************************************
*
* GroupOb sequence
*
************************************************************************/
/*
* create a thin GroupOb object
*/
static PyObject *GroupObSeq_CreatePyObject( BPy_Group *self, GroupObject *iter )
{
BPy_GroupObSeq *seq = PyObject_NEW( BPy_GroupObSeq, &GroupObSeq_Type);
seq->bpygroup = self; Py_INCREF(self);
seq->iter= iter;
return (PyObject *)seq;
}
static int GroupObSeq_len( BPy_GroupObSeq * self )
{
GROUP_DEL_CHECK_INT(self->bpygroup);
return BLI_countlist( &( self->bpygroup->group->gobject ) );
}
/*
* retrive a single GroupOb from somewhere in the GroupObex list
*/
static PyObject *GroupObSeq_item( BPy_GroupObSeq * self, int i )
{
Group *group= self->bpygroup->group;
int index=0;
PyObject *bpy_obj;
GroupObject *gob;
GROUP_DEL_CHECK_PY(self->bpygroup);
for (gob= group->gobject.first; gob && i!=index; gob= gob->next, index++) {}
if (!(gob))
return EXPP_ReturnPyObjError( PyExc_IndexError,
"array index out of range" );
bpy_obj = Object_CreatePyObject( gob->ob );
if( !bpy_obj )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyObject_New() failed" );
return (PyObject *)bpy_obj;
}
static PySequenceMethods GroupObSeq_as_sequence = {
( inquiry ) GroupObSeq_len, /* sq_length */
( binaryfunc ) 0, /* sq_concat */
( intargfunc ) 0, /* sq_repeat */
( intargfunc ) GroupObSeq_item, /* sq_item */
( intintargfunc ) 0, /* sq_slice */
( intobjargproc ) 0, /* sq_ass_item */
( intintobjargproc ) 0, /* sq_ass_slice */
0,0,0,
};
/************************************************************************
*
* Python GroupObSeq_Type iterator (iterates over GroupObjects)
*
************************************************************************/
/*
* Initialize the interator index
*/
static PyObject *GroupObSeq_getIter( BPy_GroupObSeq * self )
{
GROUP_DEL_CHECK_PY(self->bpygroup);
if (!self->iter) {
self->iter = self->bpygroup->group->gobject.first;
return EXPP_incr_ret ( (PyObject *) self );
} else {
return GroupObSeq_CreatePyObject(self->bpygroup, self->bpygroup->group->gobject.first);
}
}
/*
* Return next GroupOb.
*/
static PyObject *GroupObSeq_nextIter( BPy_GroupObSeq * self )
{
PyObject *object;
if( !(self->iter) || !(self->bpygroup->group) ) {
self->iter = NULL; /* so we can add objects again */
return EXPP_ReturnPyObjError( PyExc_StopIteration,
"iterator at end" );
}
object= Object_CreatePyObject( self->iter->ob );
self->iter= self->iter->next;
return object;
}
static PyObject *GroupObSeq_link( BPy_GroupObSeq * self, BPy_Object *value )
{
Object *blen_ob;
GROUP_DEL_CHECK_PY(self->bpygroup);
if( !BPy_Object_Check(value) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a python object as an argument" ) );
/*
if (self->iter != NULL)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Cannot modify group objects while iterating" );
*/
blen_ob = value->object;
add_to_group_wraper(self->bpygroup->group, blen_ob); /* this checks so as not to add the object into the group twice*/
Py_RETURN_NONE;
}
static PyObject *GroupObSeq_unlink( BPy_GroupObSeq * self, BPy_Object *value )
{
Object *blen_ob;
Base *base= NULL;
GROUP_DEL_CHECK_PY(self->bpygroup);
if( !BPy_Object_Check(value) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a python object as an argument" ) );
blen_ob = value->object;
rem_from_group(self->bpygroup->group, blen_ob);
if(find_group(blen_ob)==NULL) {
blen_ob->flag &= ~OB_FROMGROUP;
base= object_in_scene(blen_ob, G.scene);
if (base)
base->flag &= ~OB_FROMGROUP;
}
Py_RETURN_NONE;
}
static struct PyMethodDef BPy_GroupObSeq_methods[] = {
{"link", (PyCFunction)GroupObSeq_link, METH_O,
"make the object a part of this group"},
{"unlink", (PyCFunction)GroupObSeq_unlink, METH_O,
"unlink an object from this group"},
{NULL, NULL, 0, NULL}
};
/************************************************************************
*
* Python GroupObSeq_Type standard operations
*
************************************************************************/
static void GroupObSeq_dealloc( BPy_GroupObSeq * self )
{
Py_DECREF(self->bpygroup);
PyObject_DEL( self );
}
/*****************************************************************************/
/* Python GroupObSeq_Type structure definition: */
/*****************************************************************************/
PyTypeObject GroupObSeq_Type = {
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"Blender GroupObSeq", /* char *tp_name; */
sizeof( BPy_GroupObSeq ), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
( destructor ) GroupObSeq_dealloc,/* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */
NULL, /* reprfunc tp_repr; */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
&GroupObSeq_as_sequence, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
( getiterfunc) GroupObSeq_getIter, /* getiterfunc tp_iter; */
( iternextfunc ) GroupObSeq_nextIter, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_GroupObSeq_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};

View File

@@ -1,66 +0,0 @@
/*
* $Id: Group.h 11864 2007-08-28 10:07:08Z sirdude $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Michel Selten
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_GROUP_H
#define EXPP_GROUP_H
#include <Python.h>
#include "DNA_group_types.h"
/* The Group PyTypeObject defined in Group.c */
extern PyTypeObject Group_Type;
extern PyTypeObject GroupObSeq_Type;
#define BPy_Group_Check(v) ((v)->ob_type == &Group_Type)
#define BPy_GroupObSeq_Check(v) ((v)->ob_type == &GroupObSeq_Type)
/*****************************************************************************/
/* Python BPy_Group structure definition. */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
struct Group *group;
} BPy_Group;
/* Group object sequence, iterate on the groups object listbase*/
typedef struct {
PyObject_VAR_HEAD /* required python macro */
BPy_Group *bpygroup; /* link to the python group so we can know if its been removed */
GroupObject *iter; /* so we can iterate over the objects */
} BPy_GroupObSeq;
PyObject *Group_Init( void );
PyObject *Group_CreatePyObject( struct Group *group );
Group *Group_FromPyObject( PyObject * py_obj );
#endif /* EXPP_GROUP_H */

View File

@@ -1,895 +0,0 @@
/**
* $Id: IDProp.c
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* Contributor(s): Joseph Eagar
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "DNA_ID.h"
#include "BKE_idprop.h"
#include "IDProp.h"
#include "gen_utils.h"
#include "MEM_guardedalloc.h"
#define BSTR_EQ(a, b) (*(a) == *(b) && !strcmp(a, b))
/*** Function to wrap ID properties ***/
PyObject *BPy_Wrap_IDProperty(ID *id, IDProperty *prop, IDProperty *parent);
extern PyTypeObject IDArray_Type;
extern PyTypeObject IDGroup_Iter_Type;
/*********************** ID Property Main Wrapper Stuff ***************/
PyObject *IDGroup_repr( BPy_IDProperty *self )
{
return PyString_FromString( "(ID Property)" );
}
extern PyTypeObject IDGroup_Type;
PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop )
{
switch ( prop->type ) {
case IDP_STRING:
return PyString_FromString( prop->data.pointer );
case IDP_INT:
return PyInt_FromLong( (long)prop->data.val );
case IDP_FLOAT:
return PyFloat_FromDouble( (double)(*(float*)(&prop->data.val)) );
case IDP_GROUP:
/*blegh*/
{
BPy_IDProperty *group = PyObject_New(BPy_IDProperty, &IDGroup_Type);
if (!group)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyObject_New() failed" );
group->id = id;
group->prop = prop;
return (PyObject*) group;
}
case IDP_ARRAY:
{
BPy_IDProperty *array = PyObject_New(BPy_IDProperty, &IDArray_Type);
if (!array)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyObject_New() failed" );
array->id = id;
array->prop = prop;
return (PyObject*) array;
}
}
Py_RETURN_NONE;
}
int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject *value)
{
switch (prop->type) {
case IDP_STRING:
{
char *st;
if (!PyString_Check(value))
return EXPP_ReturnIntError(PyExc_TypeError, "expected a string!");
st = PyString_AsString(value);
IDP_ResizeArray(prop, strlen(st)+1);
strcpy(prop->data.pointer, st);
return 0;
}
case IDP_INT:
{
int ivalue;
if (!PyNumber_Check(value))
return EXPP_ReturnIntError(PyExc_TypeError, "expected an int!");
value = PyNumber_Int(value);
if (!value)
return EXPP_ReturnIntError(PyExc_TypeError, "expected an int!");
ivalue = (int) PyInt_AsLong(value);
prop->data.val = ivalue;
Py_XDECREF(value);
break;
}
case IDP_FLOAT:
{
float fvalue;
if (!PyNumber_Check(value))
return EXPP_ReturnIntError(PyExc_TypeError, "expected a float!");
value = PyNumber_Float(value);
if (!value)
return EXPP_ReturnIntError(PyExc_TypeError, "expected a float!");
fvalue = (float) PyFloat_AsDouble(value);
*(float*)&self->prop->data.val = fvalue;
Py_XDECREF(value);
break;
}
default:
return EXPP_ReturnIntError(PyExc_AttributeError, "attempt to set read-only attribute!");
}
return 0;
}
PyObject *BPy_IDGroup_GetName(BPy_IDProperty *self, void *bleh)
{
return PyString_FromString(self->prop->name);
}
int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *bleh)
{
char *st;
if (!PyString_Check(value))
return EXPP_ReturnIntError(PyExc_TypeError, "expected a string!");
st = PyString_AsString(value);
if (strlen(st) >= MAX_IDPROP_NAME)
return EXPP_ReturnIntError(PyExc_TypeError, "string length cannot exceed 31 characters!");
strcpy(self->prop->name, st);
return 0;
}
PyObject *BPy_IDGroup_GetType(BPy_IDProperty *self)
{
return PyInt_FromLong((long)self->prop->type);
}
static PyGetSetDef BPy_IDGroup_getseters[] = {
{"name",
(getter)BPy_IDGroup_GetName, (setter)BPy_IDGroup_SetName,
"The name of this Group.",
NULL},
{NULL, NULL, NULL, NULL, NULL}
};
int BPy_IDGroup_Map_Len(BPy_IDProperty *self)
{
if (self->prop->type != IDP_GROUP)
return EXPP_ReturnIntError( PyExc_TypeError,
"len() of unsized object");
return self->prop->len;
}
PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item)
{
IDProperty *loop;
char *st;
if (self->prop->type != IDP_GROUP)
return EXPP_ReturnPyObjError( PyExc_TypeError,
"unsubscriptable object");
if (!PyString_Check(item))
return EXPP_ReturnPyObjError( PyExc_TypeError,
"only strings are allowed as keys of ID properties");
st = PyString_AsString(item);
for (loop=self->prop->data.group.first; loop; loop=loop->next) {
if (BSTR_EQ(loop->name, st)) return BPy_IDGroup_WrapData(self->id, loop);
}
return EXPP_ReturnPyObjError( PyExc_KeyError,
"key not in subgroup dict");
}
/*returns NULL on success, error string on failure*/
char *BPy_IDProperty_Map_ValidateAndCreate(char *name, IDProperty *group, PyObject *ob)
{
IDProperty *prop = NULL;
IDPropertyTemplate val = {0};
if (PyFloat_Check(ob)) {
val.f = (float) PyFloat_AsDouble(ob);
prop = IDP_New(IDP_FLOAT, val, name);
} else if (PyInt_Check(ob)) {
val.i = (int) PyInt_AsLong(ob);
prop = IDP_New(IDP_INT, val, name);
} else if (PyString_Check(ob)) {
val.str = PyString_AsString(ob);
prop = IDP_New(IDP_STRING, val, name);
} else if (PySequence_Check(ob)) {
PyObject *item;
int i;
/*validate sequence and derive type.
we assume IDP_INT unless we hit a float
number; then we assume it's */
val.array.type = IDP_INT;
val.array.len = PySequence_Length(ob);
for (i=0; i<val.array.len; i++) {
item = PySequence_GetItem(ob, i);
if (PyFloat_Check(item)) val.array.type = IDP_FLOAT;
else if (!PyInt_Check(item)) return "only floats and ints are allowed in ID property arrays";
Py_XDECREF(item);
}
prop = IDP_New(IDP_ARRAY, val, name);
for (i=0; i<val.array.len; i++) {
item = PySequence_GetItem(ob, i);
if (val.array.type == IDP_INT) {
item = PyNumber_Int(item);
((int*)prop->data.pointer)[i] = (int)PyInt_AsLong(item);
} else {
item = PyNumber_Float(item);
((float*)prop->data.pointer)[i] = (float)PyFloat_AsDouble(item);
}
Py_XDECREF(item);
}
} else if (PyMapping_Check(ob)) {
PyObject *keys, *vals, *key, *pval;
int i, len;
/*yay! we get into recursive stuff now!*/
keys = PyMapping_Keys(ob);
vals = PyMapping_Values(ob);
/*we allocate the group first; if we hit any invalid data,
we can delete it easily enough.*/
prop = IDP_New(IDP_GROUP, val, name);
len = PyMapping_Length(ob);
for (i=0; i<len; i++) {
key = PySequence_GetItem(keys, i);
pval = PySequence_GetItem(vals, i);
if (!PyString_Check(key)) {
IDP_FreeProperty(prop);
MEM_freeN(prop);
Py_XDECREF(keys);
Py_XDECREF(vals);
Py_XDECREF(key);
Py_XDECREF(pval);
return "invalid element in subgroup dict template!";
}
if (BPy_IDProperty_Map_ValidateAndCreate(PyString_AsString(key), prop, pval)) {
IDP_FreeProperty(prop);
MEM_freeN(prop);
Py_XDECREF(keys);
Py_XDECREF(vals);
Py_XDECREF(key);
Py_XDECREF(pval);
return "invalid element in subgroup dict template!";
}
Py_XDECREF(key);
Py_XDECREF(pval);
}
Py_XDECREF(keys);
Py_XDECREF(vals);
} else return "invalid property value";
IDP_ReplaceInGroup(group, prop);
return NULL;
}
int BPy_IDGroup_Map_SetItem(BPy_IDProperty *self, PyObject *key, PyObject *val)
{
char *err;
if (self->prop->type != IDP_GROUP)
return EXPP_ReturnIntError( PyExc_TypeError,
"unsubscriptable object");
if (!PyString_Check(key))
return EXPP_ReturnIntError( PyExc_TypeError,
"only strings are allowed as subgroup keys" );
if (val == NULL) {
IDProperty *pkey = IDP_GetPropertyFromGroup(self->prop, PyString_AsString(key));
if (pkey) {
IDP_RemFromGroup(self->prop, pkey);
IDP_FreeProperty(pkey);
MEM_freeN(pkey);
return 0;
} else return EXPP_ReturnIntError( PyExc_RuntimeError, "property not found in group" );
}
err = BPy_IDProperty_Map_ValidateAndCreate(PyString_AsString(key), self->prop, val);
if (err) return EXPP_ReturnIntError( PyExc_RuntimeError, err );
return 0;
}
PyObject *BPy_IDGroup_SpawnIterator(BPy_IDProperty *self)
{
BPy_IDGroup_Iter *iter = PyObject_New(BPy_IDGroup_Iter, &IDGroup_Iter_Type);
if (!iter)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyObject_New() failed" );
iter->group = self;
iter->mode = IDPROP_ITER_KEYS;
iter->cur = self->prop->data.group.first;
Py_XINCREF(iter);
return (PyObject*) iter;
}
PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
{
switch (prop->type) {
case IDP_STRING:
return PyString_FromString(prop->data.pointer);
break;
case IDP_FLOAT:
return PyFloat_FromDouble(*((float*)&prop->data.val));
break;
case IDP_INT:
return PyInt_FromLong( (long)prop->data.val );
break;
case IDP_ARRAY:
{
PyObject *seq = PyList_New(prop->len);
int i;
if (!seq)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyList_New() failed" );
for (i=0; i<prop->len; i++) {
if (prop->subtype == IDP_FLOAT)
PyList_SetItem(seq, i,
PyFloat_FromDouble(((float*)prop->data.pointer)[i]));
else PyList_SetItem(seq, i,
PyInt_FromLong(((int*)prop->data.pointer)[i]));
}
return seq;
}
case IDP_GROUP:
{
PyObject *dict = PyDict_New(), *wrap;
IDProperty *loop;
if (!dict)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyDict_New() failed" );
for (loop=prop->data.group.first; loop; loop=loop->next) {
wrap = BPy_IDGroup_MapDataToPy(loop);
if (!wrap)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"BPy_IDGroup_MapDataToPy() failed" );
PyDict_SetItemString(dict, loop->name, wrap);
}
return dict;
}
}
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"eek!! a property exists with a bad type code!!!" );
}
PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value)
{
IDProperty *loop;
PyObject *pyform;
char *name = PyString_AsString(value);
if (!name) {
return EXPP_ReturnPyObjError( PyExc_TypeError,
"pop expected at least 1 arguments, got 0" );
}
for (loop=self->prop->data.group.first; loop; loop=loop->next) {
if (BSTR_EQ(loop->name, name)) {
pyform = BPy_IDGroup_MapDataToPy(loop);
if (!pyform)
/*ok something bad happened with the pyobject,
so don't remove the prop from the group. if pyform is
NULL, then it already should have raised an exception.*/
return NULL;
IDP_RemFromGroup(self->prop, loop);
return pyform;
}
}
return EXPP_ReturnPyObjError( PyExc_KeyError,
"item not in group" );
}
PyObject *BPy_IDGroup_IterItems(BPy_IDProperty *self)
{
BPy_IDGroup_Iter *iter = PyObject_New(BPy_IDGroup_Iter, &IDGroup_Iter_Type);
if (!iter)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyObject_New() failed" );
iter->group = self;
iter->mode = IDPROP_ITER_ITEMS;
iter->cur = self->prop->data.group.first;
Py_XINCREF(iter);
return (PyObject*) iter;
}
PyObject *BPy_IDGroup_GetKeys(BPy_IDProperty *self)
{
PyObject *seq = PyList_New(self->prop->len);
IDProperty *loop;
int i;
if (!seq)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyList_New() failed" );
for (i=0, loop=self->prop->data.group.first; loop; loop=loop->next, i++)
PyList_SetItem(seq, i, PyString_FromString(loop->name));
return seq;
}
PyObject *BPy_IDGroup_GetValues(BPy_IDProperty *self)
{
PyObject *seq = PyList_New(self->prop->len);
IDProperty *loop;
int i;
if (!seq)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyList_New() failed" );
for (i=0, loop=self->prop->data.group.first; loop; loop=loop->next, i++) {
PyList_SetItem(seq, i, BPy_IDGroup_WrapData(self->id, loop));
}
return seq;
}
PyObject *BPy_IDGroup_HasKey(BPy_IDProperty *self, PyObject *value)
{
IDProperty *loop;
char *name = PyString_AsString(value);
if (!name)
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a string");
for (loop=self->prop->data.group.first; loop; loop=loop->next) {
if (BSTR_EQ(loop->name, name)) Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
PyObject *BPy_IDGroup_Update(BPy_IDProperty *self, PyObject *vars)
{
PyObject *pyob, *pkey, *pval;
int i=0;
if (PySequence_Size(vars) != 1)
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected an object derived from dict.");
pyob = PyTuple_GET_ITEM(vars, 0);
if (!PyDict_Check(pyob))
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected an object derived from dict.");
while (PyDict_Next(pyob, &i, &pkey, &pval)) {
BPy_IDGroup_Map_SetItem(self, pkey, pval);
if (PyErr_Occurred()) return NULL;
}
Py_RETURN_NONE;
}
PyObject *BPy_IDGroup_ConvertToPy(BPy_IDProperty *self)
{
return BPy_IDGroup_MapDataToPy(self->prop);
}
static struct PyMethodDef BPy_IDGroup_methods[] = {
{"pop", (PyCFunction)BPy_IDGroup_Pop, METH_O,
"pop an item from the group; raises KeyError if the item doesn't exist."},
{"iteritems", (PyCFunction)BPy_IDGroup_IterItems, METH_NOARGS,
"iterate through the items in the dict; behaves like dictionary method iteritems."},
{"keys", (PyCFunction)BPy_IDGroup_GetKeys, METH_NOARGS,
"get the keys associated with this group as a list of strings."},
{"values", (PyCFunction)BPy_IDGroup_GetValues, METH_NOARGS,
"get the values associated with this group."},
{"has_key", (PyCFunction)BPy_IDGroup_HasKey, METH_O,
"returns true if the group contains a key, false if not."},
{"update", (PyCFunction)BPy_IDGroup_Update, METH_VARARGS,
"updates the values in the group with the values of another or a dict."},
{"convert_to_pyobject", (PyCFunction)BPy_IDGroup_ConvertToPy, METH_NOARGS,
"return a purely python version of the group."},
{0, NULL, 0, NULL}
};
PyMappingMethods BPy_IDGroup_Mapping = {
(inquiry)BPy_IDGroup_Map_Len, /*inquiry mp_length */
(binaryfunc)BPy_IDGroup_Map_GetItem, /*binaryfunc mp_subscript */
(objobjargproc)BPy_IDGroup_Map_SetItem, /*objobjargproc mp_ass_subscript */
};
PyTypeObject IDGroup_Type = {
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"Blender IDProperty", /* char *tp_name; */
sizeof( BPy_IDProperty ), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
NULL, /* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */
( reprfunc ) IDGroup_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
&BPy_IDGroup_Mapping, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
(getiterfunc)BPy_IDGroup_SpawnIterator, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_IDGroup_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_IDGroup_getseters, /* struct PyGetSetDef *tp_getset; */
};
/*********** Main external wrapping function *******/
PyObject *BPy_Wrap_IDProperty(ID *id, IDProperty *prop, IDProperty *parent)
{
BPy_IDProperty *wrap = PyObject_New(BPy_IDProperty, &IDGroup_Type);
if (!wrap)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyObject_New() failed" );
wrap->prop = prop;
wrap->parent = parent;
wrap->id = id;
//wrap->destroy = 0;
return (PyObject*) wrap;
}
/********Array Wrapper********/
PyObject *IDArray_repr(BPy_IDArray *self)
{
return PyString_FromString("(ID Array)");
}
PyObject *BPy_IDArray_GetType(BPy_IDArray *self)
{
return PyInt_FromLong( (long)self->prop->subtype );
}
PyObject *BPy_IDArray_GetLen(BPy_IDArray *self)
{
return PyInt_FromLong( (long)self->prop->len );
}
static PyGetSetDef BPy_IDArray_getseters[] = {
{"len",
(getter)BPy_IDArray_GetLen, (setter)NULL,
"The length of the array, can also be gotten with len(array).",
NULL},
{"type",
(getter)BPy_IDArray_GetType, (setter)NULL,
"The type of the data in the array, is an ant.",
NULL},
{NULL, NULL, NULL, NULL, NULL},
};
int BPy_IDArray_Len(BPy_IDArray *self)
{
return self->prop->len;
}
PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, int index)
{
if (index < 0 || index >= self->prop->len)
return EXPP_ReturnPyObjError( PyExc_IndexError,
"index out of range!");
switch (self->prop->subtype) {
case IDP_FLOAT:
return PyFloat_FromDouble( (double)(((float*)self->prop->data.pointer)[index]));
break;
case IDP_INT:
return PyInt_FromLong( (long)((int*)self->prop->data.pointer)[index] );
break;
}
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"invalid/corrupt array type!");
}
int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *val)
{
int i;
float f;
if (index < 0 || index >= self->prop->len)
return EXPP_ReturnIntError( PyExc_RuntimeError,
"index out of range!");
switch (self->prop->subtype) {
case IDP_FLOAT:
if (!PyNumber_Check(val)) return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float");
val = PyNumber_Float(val);
if (!val) return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float");
f = (float) PyFloat_AsDouble(val);
((float*)self->prop->data.pointer)[index] = f;
Py_XDECREF(val);
break;
case IDP_INT:
if (!PyNumber_Check(val)) return EXPP_ReturnIntError( PyExc_TypeError,
"expected an int");
val = PyNumber_Int(val);
if (!val) return EXPP_ReturnIntError( PyExc_TypeError,
"expected an int");
i = (int) PyInt_AsLong(val);
((int*)self->prop->data.pointer)[index] = i;
Py_XDECREF(val);
break;
}
return 0;
}
static PySequenceMethods BPy_IDArray_Seq = {
(inquiry) BPy_IDArray_Len, /* inquiry sq_length */
0, /* binaryfunc sq_concat */
0, /* intargfunc sq_repeat */
(intargfunc)BPy_IDArray_GetItem, /* intargfunc sq_item */
0, /* intintargfunc sq_slice */
(intobjargproc)BPy_IDArray_SetItem, /* intobjargproc sq_ass_item */
0, /* intintobjargproc sq_ass_slice */
0, /* objobjproc sq_contains */
/* Added in release 2.0 */
0, /* binaryfunc sq_inplace_concat */
0, /* intargfunc sq_inplace_repeat */
};
PyTypeObject IDArray_Type = {
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"Blender IDArray", /* char *tp_name; */
sizeof( BPy_IDArray ), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
NULL, /* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */
( reprfunc ) IDArray_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
&BPy_IDArray_Seq, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_IDArray_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};
/*********** ID Property Group iterator ********/
PyObject *IDGroup_Iter_iterself(PyObject *self)
{
Py_XINCREF(self);
return self;
}
PyObject *IDGroup_Iter_repr(BPy_IDGroup_Iter *self)
{
return PyString_FromString("(ID Property Group)");
}
PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self)
{
IDProperty *cur=NULL;
PyObject *tmpval;
PyObject *ret;
if (self->cur) {
cur = self->cur;
self->cur = self->cur->next;
if (self->mode == IDPROP_ITER_ITEMS) {
tmpval = BPy_IDGroup_WrapData(self->group->id, cur);
ret = Py_BuildValue("[s, O]", cur->name, tmpval);
Py_DECREF(tmpval);
return ret;
} else {
return PyString_FromString(cur->name);
}
} else {
return EXPP_ReturnPyObjError( PyExc_StopIteration,
"iterator at end" );
}
}
PyTypeObject IDGroup_Iter_Type = {
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"Blender IDGroup_Iter", /* char *tp_name; */
sizeof( BPy_IDGroup_Iter ), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
NULL, /* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */
( reprfunc ) IDGroup_Iter_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
IDGroup_Iter_iterself, /* getiterfunc tp_iter; */
(iternextfunc) BPy_Group_Iter_Next, /* iternextfunc tp_iternext; */
};
void IDProp_Init_Types(void)
{
PyType_Ready( &IDGroup_Type );
PyType_Ready( &IDGroup_Iter_Type );
PyType_Ready( &IDArray_Type );
}

View File

@@ -1,61 +0,0 @@
/**
* $Id: IDProp.h
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* Contributor(s): Joseph Eagar
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include <Python.h>
struct ID;
struct IDProperty;
struct BPy_IDGroup_Iter;
typedef struct BPy_IDProperty {
PyObject_VAR_HEAD
struct ID *id;
struct IDProperty *prop, *parent;
PyObject *data_wrap;
} BPy_IDProperty;
typedef struct BPy_IDArray {
PyObject_VAR_HEAD
struct ID *id;
struct IDProperty *prop;
} BPy_IDArray;
typedef struct BPy_IDGroup_Iter {
PyObject_VAR_HEAD
BPy_IDProperty *group;
struct IDProperty *cur;
int mode;
} BPy_IDGroup_Iter;
PyObject *BPy_Wrap_IDProperty(struct ID *id, struct IDProperty *prop, struct IDProperty *parent);
void IDProp_Init_Types(void);
#define IDPROP_ITER_KEYS 0
#define IDPROP_ITER_ITEMS 1

File diff suppressed because it is too large Load Diff

View File

@@ -1,60 +0,0 @@
/*
* $Id: Image.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano, Alex Mole
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_IMAGE_H
#define EXPP_IMAGE_H
#include <Python.h>
#include "DNA_image_types.h"
/*****************************************************************************/
/* Python BPy_Image structure definition */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
Image * image; /* libdata must be second */
} BPy_Image;
extern PyTypeObject Image_Type; /* The Image PyType Object */
#define BPy_Image_Check(v) ((v)->ob_type == &Image_Type) /*for type checking */
/*****************************************************************************/
/* Module Blender.Image - public functions */
/*****************************************************************************/
PyObject *Image_Init( void );
PyObject *Image_CreatePyObject( Image * image );
Image *Image_FromPyObject( PyObject * pyobj );
#endif /* EXPP_IMAGE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,63 +0,0 @@
/*
* $Id: Ipo.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Jacques Guignot
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_IPO_H
#define EXPP_IPO_H
#include <Python.h>
#include "DNA_ipo_types.h"
/*****************************************************************************/
/* Python BPy_Ipo structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD /* required macro */
Ipo * ipo; /* libdata must be second */
short iter;
short mtex;
} BPy_Ipo;
extern PyTypeObject Ipo_Type;
#define BPy_Ipo_Check(v) ((v)->ob_type == &Ipo_Type) /* for type checking */
/*
* prototypes
*/
PyObject *Ipo_Init( void );
PyObject *Ipo_CreatePyObject( struct Ipo *ipo );
Ipo *Ipo_FromPyObject( PyObject * py_obj );
#endif /* EXPP_IPO_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,58 +0,0 @@
/*
* $Id: Ipocurve.h 10943 2007-06-16 12:24:41Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Jacques Guignot
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_IPOCURVE_H
#define EXPP_IPOCURVE_H
#include <Python.h>
#include "DNA_curve_types.h" /* declaration of IpoCurve */
/*****************************************************************************/
/* Python C_IpoCurve structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD /* required macro */
IpoCurve * ipocurve;
char wrapped;
} C_IpoCurve;
extern PyTypeObject IpoCurve_Type;
#define BPy_IpoCurve_Check(v) ((v)->ob_type == &IpoCurve_Type) /* for type checking */
PyObject *IpoCurve_Init( void );
PyObject *IpoCurve_CreatePyObject( IpoCurve * ipo );
IpoCurve *IpoCurve_FromPyObject( PyObject * pyobj );
char *getIpoCurveName( IpoCurve * icu );
#endif /* EXPP_IPOCURVE_H */

View File

@@ -1,681 +0,0 @@
/*
* $Id: Key.c 12867 2007-12-13 15:06:02Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Pontus Lidman, Johnny Matthews, Ken Hughes,
* Michael Reimpell
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Key.h" /*This must come first*/
#include "vector.h"
#include "DNA_scene_types.h"
#include <BLI_blenlib.h>
#include <BKE_global.h>
#include <BKE_main.h>
#include <BKE_curve.h>
#include <BKE_library.h>
#include <BKE_utildefines.h>
#include "BIF_space.h"
#include "Ipocurve.h"
#include "NMesh.h" /* we create NMesh.NMVert objects */
#include "Ipo.h"
#include "BezTriple.h"
#include "BSE_editipo.h"
#include "mydevice.h"
#include "BKE_depsgraph.h"
#include "blendef.h"
#include "constant.h"
#include "gen_utils.h"
#include "gen_library.h"
#define KEY_TYPE_MESH 0
#define KEY_TYPE_CURVE 1
#define KEY_TYPE_LATTICE 2
static int Key_compare( BPy_Key * a, BPy_Key * b );
static PyObject *Key_repr( BPy_Key * self );
static void Key_dealloc( BPy_Key * self );
static PyObject *Key_getBlocks( BPy_Key * self );
static PyObject *Key_getType( BPy_Key * self );
static PyObject *Key_getRelative( BPy_Key * self );
static PyObject *Key_getIpo( BPy_Key * self );
static int Key_setIpo( BPy_Key * self, PyObject * args );
static PyObject *Key_getValue( BPy_Key * self );
static int Key_setRelative( BPy_Key * self, PyObject * value );
static struct PyMethodDef Key_methods[] = {
{ "getBlocks", (PyCFunction) Key_getBlocks, METH_NOARGS, "Get key blocks" },
{ "getIpo", (PyCFunction) Key_getIpo, METH_NOARGS, "Get key Ipo" },
{ 0, 0, 0, 0 }
};
static PyGetSetDef BPy_Key_getsetters[] = {
{"type",(getter)Key_getType, (setter)NULL,
"Key Type",NULL},
{"value",(getter)Key_getValue, (setter)NULL,
"Key value",NULL},
{"ipo",(getter)Key_getIpo, (setter)Key_setIpo,
"Ipo linked to key",NULL},
{"blocks",(getter)Key_getBlocks, (setter)NULL,
"Blocks linked to the key",NULL},
{"relative",(getter)Key_getRelative, (setter)Key_setRelative,
"Non-zero is key is relative",NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
static PyObject *KeyBlock_getData( PyObject * self );
static PyObject *KeyBlock_getCurval( BPy_KeyBlock * self );
static PyObject *KeyBlock_getName( BPy_KeyBlock * self );
static PyObject *KeyBlock_getPos( BPy_KeyBlock * self );
static PyObject *KeyBlock_getSlidermin( BPy_KeyBlock * self );
static PyObject *KeyBlock_getSlidermax( BPy_KeyBlock * self );
static PyObject *KeyBlock_getVgroup( BPy_KeyBlock * self );
static int KeyBlock_setName( BPy_KeyBlock *, PyObject * args );
static int KeyBlock_setVgroup( BPy_KeyBlock *, PyObject * args );
static int KeyBlock_setSlidermin( BPy_KeyBlock *, PyObject * args );
static int KeyBlock_setSlidermax( BPy_KeyBlock *, PyObject * args );
static void KeyBlock_dealloc( BPy_KeyBlock * self );
static int KeyBlock_compare( BPy_KeyBlock * a, BPy_KeyBlock * b );
static PyObject *KeyBlock_repr( BPy_KeyBlock * self );
static struct PyMethodDef KeyBlock_methods[] = {
{ "getData", (PyCFunction) KeyBlock_getData, METH_NOARGS,
"Get keyblock data" },
{ 0, 0, 0, 0 }
};
static PyGetSetDef BPy_KeyBlock_getsetters[] = {
{"curval",(getter)KeyBlock_getCurval, (setter)NULL,
"Current value of the corresponding IpoCurve",NULL},
{"name",(getter)KeyBlock_getName, (setter)KeyBlock_setName,
"Keyblock Name",NULL},
{"pos",(getter)KeyBlock_getPos, (setter)NULL,
"Keyblock Pos",NULL},
{"slidermin",(getter)KeyBlock_getSlidermin, (setter)KeyBlock_setSlidermin,
"Keyblock Slider Minimum",NULL},
{"slidermax",(getter)KeyBlock_getSlidermax, (setter)KeyBlock_setSlidermax,
"Keyblock Slider Maximum",NULL},
{"vgroup",(getter)KeyBlock_getVgroup, (setter)KeyBlock_setVgroup,
"Keyblock VGroup",NULL},
{"data",(getter)KeyBlock_getData, (setter)NULL,
"Keyblock VGroup",NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
PyTypeObject Key_Type = {
PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
"Blender Key", /*tp_name */
sizeof( BPy_Key ), /*tp_basicsize */
0, /*tp_itemsize */
/* methods */
( destructor ) Key_dealloc,/* destructor tp_dealloc; */
( printfunc ) 0, /*tp_print */
( getattrfunc ) 0, /*tp_getattr */
( setattrfunc ) 0, /*tp_setattr */
( cmpfunc) Key_compare, /*tp_compare*/
( reprfunc ) Key_repr, /* tp_repr */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
( hashfunc ) GenericLib_hash, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
Key_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_Key_getsetters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};
PyTypeObject KeyBlock_Type = {
PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
"Blender KeyBlock", /*tp_name */
sizeof( BPy_KeyBlock ), /*tp_basicsize */
0, /*tp_itemsize */
/* methods */
( destructor ) KeyBlock_dealloc,/* destructor tp_dealloc; */
( printfunc ) 0, /*tp_print */
( getattrfunc ) 0, /*tp_getattr */
( setattrfunc ) 0, /*tp_setattr */
( cmpfunc) KeyBlock_compare, /*tp_compare*/
( reprfunc ) KeyBlock_repr, /* tp_repr */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
KeyBlock_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_KeyBlock_getsetters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};
PyObject *Key_CreatePyObject( Key * blenkey )
{
BPy_Key *bpykey = PyObject_NEW( BPy_Key, &Key_Type );
/* blenkey may be NULL so be careful */
bpykey->key = blenkey;
return ( PyObject * ) bpykey;
}
static void Key_dealloc( BPy_Key * self )
{
PyObject_DEL( self );
}
static int Key_compare( BPy_Key * a, BPy_Key * b )
{
return ( a->key == b->key ) ? 0 : -1;
}
static PyObject *Key_repr( BPy_Key * self )
{
return PyString_FromFormat( "[Key \"%s\"]", self->key->id.name + 2 );
}
static PyObject *Key_getIpo( BPy_Key * self )
{
if (self->key->ipo)
return Ipo_CreatePyObject( self->key->ipo );
Py_RETURN_NONE;
}
static int Key_setIpo( BPy_Key * self, PyObject * value )
{
return GenericLib_assignData(value, (void **) &self->key->ipo, 0, 1, ID_IP, ID_KE);
}
static PyObject *Key_getRelative( BPy_Key * self )
{
if( self->key->type == KEY_RELATIVE )
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Key_setRelative( BPy_Key * self, PyObject * value )
{
int param = PyObject_IsTrue( value );
if( param == -1 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected True/False or 0/1" );
if( param )
self->key->type = KEY_RELATIVE;
else
self->key->type = KEY_NORMAL;
allqueue(REDRAWIPO, 0);
allspace(REMAKEIPO, 0);
return 0;
}
static PyObject *Key_getType( BPy_Key * self )
{
int idcode;
int type = -1;
idcode = GS( self->key->from->name );
switch( idcode ) {
case ID_ME:
type = KEY_TYPE_MESH;
break;
case ID_CU:
type = KEY_TYPE_CURVE;
break;
case ID_LT:
type = KEY_TYPE_LATTICE;
break;
}
return PyInt_FromLong( type );
}
static PyObject *Key_getBlocks( BPy_Key * self )
{
Key *key = self->key;
KeyBlock *kb;
int i=0;
PyObject *l = PyList_New( BLI_countlist( &(key->block)) );
for (kb = key->block.first; kb; kb = kb->next, i++)
PyList_SET_ITEM( l, i, KeyBlock_CreatePyObject( kb, key ) );
return l;
}
static PyObject *Key_getValue( BPy_Key * self )
{
BPy_Key *k = ( BPy_Key * ) self;
return PyFloat_FromDouble( k->key->curval );
}
/* ------------ Key Block Functions -------------- */
PyObject *KeyBlock_CreatePyObject( KeyBlock * keyblock, Key *parentKey )
{
BPy_KeyBlock *bpykb = PyObject_NEW( BPy_KeyBlock, &KeyBlock_Type );
bpykb->key = parentKey;
bpykb->keyblock = keyblock; /* keyblock maye be NULL, thats ok */
return ( PyObject * ) bpykb;
}
static PyObject *KeyBlock_getCurval( BPy_KeyBlock * self ) {
return PyFloat_FromDouble( self->keyblock->curval );
}
static PyObject *KeyBlock_getName( BPy_KeyBlock * self ) {
return PyString_FromString(self->keyblock->name);
}
static PyObject *KeyBlock_getPos( BPy_KeyBlock * self ){
return PyFloat_FromDouble( self->keyblock->pos );
}
static PyObject *KeyBlock_getSlidermin( BPy_KeyBlock * self ){
return PyFloat_FromDouble( self->keyblock->slidermin );
}
static PyObject *KeyBlock_getSlidermax( BPy_KeyBlock * self ){
return PyFloat_FromDouble( self->keyblock->slidermax );
}
static PyObject *KeyBlock_getVgroup( BPy_KeyBlock * self ){
return PyString_FromString(self->keyblock->vgroup);
}
static int KeyBlock_setName( BPy_KeyBlock * self, PyObject * args ){
char* text = NULL;
text = PyString_AsString ( args );
if( !text )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
strncpy( self->keyblock->name, text , 32);
return 0;
}
static int KeyBlock_setVgroup( BPy_KeyBlock * self, PyObject * args ){
char* text = NULL;
text = PyString_AsString ( args );
if( !text )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
strncpy( self->keyblock->vgroup, text , 32);
return 0;
}
static int KeyBlock_setSlidermin( BPy_KeyBlock * self, PyObject * args ){
return EXPP_setFloatClamped ( args, &self->keyblock->slidermin,
-10.0f,
10.0f );
}
static int KeyBlock_setSlidermax( BPy_KeyBlock * self, PyObject * args ){
return EXPP_setFloatClamped ( args, &self->keyblock->slidermax,
-10.0f,
10.0f );
}
static void KeyBlock_dealloc( BPy_KeyBlock * self )
{
PyObject_DEL( self );
}
static int KeyBlock_compare( BPy_KeyBlock * a, BPy_KeyBlock * b )
{
return ( a->keyblock == b->keyblock ) ? 0 : -1;
}
static PyObject *KeyBlock_repr( BPy_KeyBlock * self )
{
return PyString_FromFormat( "[KeyBlock \"%s\"]", self->keyblock->name );
}
static Curve *find_curve( Key *key )
{
Curve *cu;
if( !key )
return NULL;
for( cu = G.main->curve.first; cu; cu = cu->id.next ) {
if( cu->key == key )
break;
}
return cu;
}
static PyObject *KeyBlock_getData( PyObject * self )
{
/* If this is a mesh key, data is an array of MVert coords.
If lattice, data is an array of BPoint coords
If curve, data is an array of BezTriple or BPoint */
char *datap;
int datasize;
int idcode;
int i;
Curve *cu;
Nurb* nu;
PyObject *l;
BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
Key *key = kb->key;
if( !kb->keyblock->data ) {
Py_RETURN_NONE;
}
l = PyList_New( kb->keyblock->totelem );
if( !l )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"PyList_New() failed" );
idcode = GS( key->from->name );
switch(idcode) {
case ID_ME:
for (i=0, datap = kb->keyblock->data; i<kb->keyblock->totelem; i++) {
PyObject *vec = newVectorObject((float*)datap, 3, Py_WRAP);
if (!vec) return EXPP_ReturnPyObjError( PyExc_MemoryError,
"could not allocate memory for Blender.Mathutils.Vector wrapper!" );
PyList_SetItem(l, i, vec);
datap += kb->key->elemsize;
}
break;
case ID_CU:
cu = find_curve ( key );
if( !cu )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"key is no linked to any curve!" );
datasize = count_curveverts(&cu->nurb);
nu = cu->nurb.first;
if( nu->bezt ) {
datasize /= 3;
Py_DECREF (l);
l = PyList_New( datasize );
for( i = 0, datap = kb->keyblock->data; i < datasize;
i++, datap += sizeof(float)*3*4) {
PyObject *tuple = PyTuple_New(4), *vec;
float *vecs = (float*)datap;
if (!tuple) return EXPP_ReturnPyObjError( PyExc_MemoryError,
"PyTuple_New() failed!" );
vec = newVectorObject(vecs, 3, Py_WRAP);
if (!vec) return EXPP_ReturnPyObjError( PyExc_MemoryError,
"Could not allocate memory for Blender.Mathutils.Vector wrapper!" );
PyTuple_SET_ITEM( tuple, 0, vec);
vecs += 3;
vec = newVectorObject(vecs, 3, Py_WRAP);
if (!vec) return EXPP_ReturnPyObjError( PyExc_MemoryError,
"Could not allocate memory for Blender.Mathutils.Vector wrapper!" );
PyTuple_SET_ITEM( tuple, 1, vec);
vecs += 3;
vec = newVectorObject(vecs, 3, Py_WRAP);
if (!vec) return EXPP_ReturnPyObjError( PyExc_MemoryError,
"Could not allocate memory for Blender.Mathutils.Vector wrapper!" );
PyTuple_SET_ITEM( tuple, 2, vec);
/*tilts*/
vecs += 3;
vec = newVectorObject(vecs, 3, Py_WRAP);
if (!vec) return EXPP_ReturnPyObjError( PyExc_MemoryError,
"Could not allocate memory for Blender.Mathutils.Vector wrapper!" );
PyTuple_SET_ITEM( tuple, 3, vec);
PyList_SetItem( l, i, tuple );
}
} else {
for( i = 0, datap = kb->keyblock->data; i < datasize;
i++, datap += kb->key->elemsize ) {
PyObject *vec = newVectorObject((float*)datap, 4, Py_WRAP);
if (!vec) return EXPP_ReturnPyObjError( PyExc_MemoryError,
"could not allocate memory for Blender.Mathutils.Vector wrapper!" );
PyList_SetItem( l, i, vec );
}
}
break;
case ID_LT:
for( i = 0, datap = kb->keyblock->data; i < kb->keyblock->totelem;
i++, datap += kb->key->elemsize ) {
PyObject *vec = newVectorObject((float*)datap, 3, Py_WRAP);
if (!vec) return EXPP_ReturnPyObjError( PyExc_MemoryError,
"Could not allocate memory for Blender.Mathutils.Vector wrapper!" );
PyList_SetItem( l, i, vec );
}
break;
}
return l;
}
static PyObject *M_Key_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
Key *key_iter;
char error_msg[64];
int i;
if( !PyArg_ParseTuple( args, "|s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument (or nothing)" ) );
if ( name ) {
for (key_iter = G.main->key.first; key_iter;
key_iter=key_iter->id.next) {
if (strcmp ( key_iter->id.name + 2, name ) == 0 ) {
return Key_CreatePyObject( key_iter );
}
}
PyOS_snprintf( error_msg, sizeof( error_msg ),
"Key \"%s\" not found", name );
return EXPP_ReturnPyObjError ( PyExc_NameError, error_msg );
} else {
PyObject *keylist;
keylist = PyList_New( BLI_countlist( &( G.main->key ) ) );
for ( i=0, key_iter = G.main->key.first; key_iter;
key_iter=key_iter->id.next, i++ ) {
PyList_SetItem(keylist, i, Key_CreatePyObject(key_iter));
}
return keylist;
}
}
struct PyMethodDef M_Key_methods[] = {
{"Get", M_Key_Get, METH_VARARGS, "Get a key or all key names"},
{NULL, NULL, 0, NULL}
};
static PyObject *M_Key_TypesDict( void )
{
PyObject *T = PyConstant_New( );
if( T ) {
BPy_constant *d = ( BPy_constant * ) T;
PyConstant_Insert( d, "MESH", PyInt_FromLong( KEY_TYPE_MESH ) );
PyConstant_Insert( d, "CURVE", PyInt_FromLong( KEY_TYPE_CURVE ) );
PyConstant_Insert( d, "LATTICE", PyInt_FromLong( KEY_TYPE_LATTICE ) );
}
return T;
}
PyObject *Key_Init( void )
{
PyObject *submodule;
PyObject *Types = NULL;
if( PyType_Ready( &Key_Type ) < 0 || PyType_Ready( &KeyBlock_Type ) < 0 )
return NULL;
submodule =
Py_InitModule3( "Blender.Key", M_Key_methods, "Key module" );
Types = M_Key_TypesDict( );
if( Types )
PyModule_AddObject( submodule, "Types", Types );
return submodule;
}

View File

@@ -1,68 +0,0 @@
/*
* $Id: Key.h 10783 2007-05-26 12:58:46Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Pontus Lidman
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_KEY_H
#define EXPP_KEY_H
#include "Python.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <DNA_key_types.h>
#include <DNA_curve_types.h>
extern PyTypeObject Key_Type;
extern PyTypeObject KeyBlock_Type;
typedef struct {
PyObject_HEAD /* required python macro */
Key * key; /* libdata must be second */
/* Object *object;*/ /* for vertex grouping info, since it's stored on the object */
/*PyObject *keyBlock;*/
/*PyObject *ipo;*/
} BPy_Key;
typedef struct {
PyObject_HEAD /* required python macro */
Key *key;
KeyBlock * keyblock;
/* Object *object;*/ /* for vertex grouping info, since it's stored on the object */
} BPy_KeyBlock;
PyObject *Key_CreatePyObject( Key * k );
PyObject *KeyBlock_CreatePyObject( KeyBlock * k, Key *parentKey );
PyObject *Key_Init( void );
#endif /* EXPP_KEY_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,61 +0,0 @@
/*
* $Id: Lamp.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano, Nathan Letwory
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_LAMP_H
#define EXPP_LAMP_H
#include <Python.h>
#include "DNA_lamp_types.h"
#include "rgbTuple.h"
extern PyTypeObject Lamp_Type;
#define BPy_Lamp_Check(v) \
((v)->ob_type == &Lamp_Type) /* for type checking */
/* Python BPy_Lamp structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
Lamp * lamp; /* libdata must be second */
BPy_rgbTuple *color;
} BPy_Lamp;
/*
* prototypes
*/
PyObject *Lamp_Init( void );
PyObject *Lamp_CreatePyObject( struct Lamp *lamp );
Lamp *Lamp_FromPyObject( PyObject * pyobj );
#endif /* EXPP_LAMP_H */

View File

@@ -1,813 +0,0 @@
/*
* $Id: Lattice.c 11130 2007-06-30 00:18:10Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joseph Gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Lattice.h" /*This must come first*/
#include "BKE_utildefines.h"
#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_lattice.h"
#include "BLI_blenlib.h"
#include "DNA_object_types.h"
#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_curve_types.h"
#include "DNA_scene_types.h"
#include "BIF_editkey.h"
#include "BIF_editdeform.h"
#include "BIF_space.h"
#include "blendef.h"
#include "gen_utils.h"
#include "gen_library.h"
#include "Key.h"
/*****************************************************************************/
/* Python API function prototypes for the Lattice module. */
/*****************************************************************************/
static PyObject *M_Lattice_New( PyObject * self, PyObject * args );
static PyObject *M_Lattice_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
/* Lattice Module strings */
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Lattice.__doc__ */
/*****************************************************************************/
static char M_Lattice_doc[] = "The Blender Lattice module\n\n";
static char M_Lattice_New_doc[] = "() - return a new Lattice object";
static char M_Lattice_Get_doc[] = "() - get a Lattice from blender";
/*****************************************************************************/
/* Python method structure definition for Blender.Lattice module: */
/*****************************************************************************/
struct PyMethodDef M_Lattice_methods[] = {
{"New", ( PyCFunction ) M_Lattice_New, METH_VARARGS,
M_Lattice_New_doc},
{"Get", ( PyCFunction ) M_Lattice_Get, METH_VARARGS,
M_Lattice_Get_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Lattice Strings */
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Lattice.__doc__ */
/*****************************************************************************/
static char Lattice_getName_doc[] = "() - Return Lattice Object name";
static char Lattice_setName_doc[] = "(str) - Change Lattice Object name";
static char Lattice_setPartitions_doc[] =
"(str) - Set the number of Partitions in x,y,z";
static char Lattice_getPartitions_doc[] =
"(str) - Get the number of Partitions in x,y,z";
static char Lattice_getKey_doc[] =
"() - Get the Key object attached to this Lattice";
static char Lattice_setKeyTypes_doc[] =
"(str) - Set the key types for x,y,z dimensions";
static char Lattice_getKeyTypes_doc[] =
"(str) - Get the key types for x,y,z dimensions";
static char Lattice_setMode_doc[] = "(str) - Make an outside or grid lattice";
static char Lattice_getMode_doc[] = "(str) - Get lattice mode type";
static char Lattice_setPoint_doc[] =
"(str) - Set the coordinates of a point on the lattice";
static char Lattice_getPoint_doc[] =
"(str) - Get the coordinates of a point on the lattice";
static char Lattice_insertKey_doc[] =
"(str) - Set a new key for the lattice at specified frame";
static char Lattice_copy_doc[] =
"() - Return a copy of the lattice.";
//***************************************************************************
// Function: Lattice_CreatePyObject
//***************************************************************************
PyObject *Lattice_CreatePyObject( Lattice * lt )
{
BPy_Lattice *pyLat;
pyLat = ( BPy_Lattice * ) PyObject_NEW( BPy_Lattice, &Lattice_Type );
if( !pyLat )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create BPy_Lattice PyObject" );
pyLat->lattice = lt;
return ( PyObject * ) pyLat;
}
//***************************************************************************
// Function: Lattice_FromPyObject
//***************************************************************************
Lattice *Lattice_FromPyObject( PyObject * pyobj )
{
return ( ( BPy_Lattice * ) pyobj )->lattice;
}
//***************************************************************************
// Function: M_Lattice_New
// Python equivalent: Blender.Lattice.New
//***************************************************************************
static PyObject *M_Lattice_New( PyObject * self, PyObject * args )
{
char *name = NULL;
Lattice *bl_Lattice; // blender Lattice object
PyObject *py_Lattice; // python wrapper
if( !PyArg_ParseTuple( args, "|s", &name ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected string and int arguments (or nothing)" );
bl_Lattice = add_lattice( "Lattice" );
if( bl_Lattice ) {
bl_Lattice->id.us = 0;
py_Lattice = Lattice_CreatePyObject( bl_Lattice );
} else
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Lattice Object in Blender" );
if( !py_Lattice )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create Lattice Object wrapper" );
if( name )
rename_id( &bl_Lattice->id, name );
return py_Lattice;
}
//***************************************************************************
// Function: M_Lattice_Get
// Python equivalent: Blender.Lattice.Get
//***************************************************************************
static PyObject *M_Lattice_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
Lattice *lat_iter;
if( !PyArg_ParseTuple( args, "|s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument (or nothing)" ) );
lat_iter = G.main->latt.first;
if( name ) { /* (name) - Search Lattice by name */
PyObject *wanted_lat = NULL;
while( ( lat_iter ) && ( wanted_lat == NULL ) ) {
if( strcmp( name, lat_iter->id.name + 2 ) == 0 ) {
wanted_lat =
Lattice_CreatePyObject( lat_iter );
}
lat_iter = lat_iter->id.next;
}
if( wanted_lat == NULL ) { /* Requested Lattice doesn't exist */
char error_msg[64];
PyOS_snprintf( error_msg, sizeof( error_msg ),
"Lattice \"%s\" not found", name );
return ( EXPP_ReturnPyObjError
( PyExc_NameError, error_msg ) );
}
return wanted_lat;
}
else { /* () - return a list of all Lattices in the scene */
int index = 0;
PyObject *latlist, *pyobj;
latlist = PyList_New( BLI_countlist( &( G.main->latt ) ) );
if( latlist == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyList" ) );
while( lat_iter ) {
pyobj = Lattice_CreatePyObject( lat_iter );
if( !pyobj ) {
Py_DECREF(latlist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create PyString" ) );
}
PyList_SET_ITEM( latlist, index, pyobj );
lat_iter = lat_iter->id.next;
index++;
}
return ( latlist );
}
}
//***************************************************************************
// Function: Lattice_Init
//***************************************************************************
PyObject *Lattice_Init( void )
{
PyObject *mod;
PyObject *dict;
if( PyType_Ready( &Lattice_Type ) < 0 )
return NULL;
mod = Py_InitModule3( "Blender.Lattice", M_Lattice_methods,
M_Lattice_doc );
dict = PyModule_GetDict( mod );
//Module dictionary
#define EXPP_ADDCONST(x) EXPP_dict_set_item_str(dict, #x, PyInt_FromLong(LT_##x))
EXPP_ADDCONST( GRID );
EXPP_ADDCONST( OUTSIDE );
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(x) EXPP_dict_set_item_str(dict, #x, PyInt_FromLong(KEY_##x))
EXPP_ADDCONST( LINEAR );
EXPP_ADDCONST( CARDINAL );
EXPP_ADDCONST( BSPLINE );
return ( mod );
}
static PyObject *Lattice_setPartitions( BPy_Lattice * self, PyObject * args )
{
int x = 0;
int y = 0;
int z = 0;
Lattice *bl_Lattice;
if( !PyArg_ParseTuple( args, "iii", &x, &y, &z ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int,int,int argument" ) );
bl_Lattice = self->lattice;
if( x < 2 || y < 2 || z < 2 )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"partition values must be 2 or greater" ) );
resizelattice(bl_Lattice, x, y, z, NULL);
Py_RETURN_NONE;
}
static PyObject *Lattice_getPartitions( BPy_Lattice * self )
{
Lattice *bl_Lattice;
bl_Lattice = self->lattice;
return Py_BuildValue( "[i,i,i]", ( int ) bl_Lattice->pntsu,
( int ) bl_Lattice->pntsv,
( int ) bl_Lattice->pntsw );
}
static PyObject *Lattice_getKey( BPy_Lattice * self )
{
Key *key = self->lattice->key;
if (key)
return Key_CreatePyObject(key);
else
Py_RETURN_NONE;
}
static PyObject *Lattice_getKeyTypes( BPy_Lattice * self )
{
Lattice *bl_Lattice;
char *linear = "linear";
char *cardinal = "cardinal";
char *bspline = "bspline";
char *s_x = NULL, *s_y = NULL, *s_z = NULL;
bl_Lattice = self->lattice;
if( ( bl_Lattice->typeu ) == KEY_LINEAR )
s_x = linear;
else if( ( bl_Lattice->typeu ) == KEY_CARDINAL )
s_x = cardinal;
else if( ( bl_Lattice->typeu ) == KEY_BSPLINE )
s_x = bspline;
else
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"bad key type..." );
if( ( bl_Lattice->typev ) == KEY_LINEAR )
s_y = linear;
else if( ( bl_Lattice->typev ) == KEY_CARDINAL )
s_y = cardinal;
else if( ( bl_Lattice->typev ) == KEY_BSPLINE )
s_y = bspline;
else
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"bad key type..." );
if( ( bl_Lattice->typew ) == KEY_LINEAR )
s_z = linear;
else if( ( bl_Lattice->typew ) == KEY_CARDINAL )
s_z = cardinal;
else if( ( bl_Lattice->typew ) == KEY_BSPLINE )
s_z = bspline;
else
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"bad key type..." );
/* we made sure no s_[xyz] is NULL */
return Py_BuildValue( "[s,s,s]", s_x, s_y, s_z );
}
static PyObject *Lattice_setKeyTypes( BPy_Lattice * self, PyObject * args )
{
int x;
int y;
int z;
Lattice *bl_Lattice;
if( !PyArg_ParseTuple( args, "iii", &x, &y, &z ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int,int,int argument" ) );
bl_Lattice = self->lattice;
if( x == KEY_LINEAR )
bl_Lattice->typeu = KEY_LINEAR;
else if( x == KEY_CARDINAL )
bl_Lattice->typeu = KEY_CARDINAL;
else if( x == KEY_BSPLINE )
bl_Lattice->typeu = KEY_BSPLINE;
else
return EXPP_ReturnPyObjError( PyExc_TypeError,
"type must be LINEAR, CARDINAL OR BSPLINE" );
if( y == KEY_LINEAR )
bl_Lattice->typev = KEY_LINEAR;
else if( y == KEY_CARDINAL )
bl_Lattice->typev = KEY_CARDINAL;
else if( y == KEY_BSPLINE )
bl_Lattice->typev = KEY_BSPLINE;
else
return EXPP_ReturnPyObjError( PyExc_TypeError,
"type must be LINEAR, CARDINAL OR BSPLINE" );
if( z == KEY_LINEAR )
bl_Lattice->typew = KEY_LINEAR;
else if( z == KEY_CARDINAL )
bl_Lattice->typew = KEY_CARDINAL;
else if( z == KEY_BSPLINE )
bl_Lattice->typew = KEY_BSPLINE;
else
return EXPP_ReturnPyObjError( PyExc_TypeError,
"type must be LINEAR, CARDINAL OR BSPLINE" );
Py_RETURN_NONE;
}
static PyObject *Lattice_setMode( BPy_Lattice * self, PyObject * args )
{
short type;
Lattice *bl_Lattice;
bl_Lattice = self->lattice;
if( !PyArg_ParseTuple( args, "h", &type ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int argument" ) );
if( type == LT_GRID )
bl_Lattice->flag = LT_GRID;
else if( type == LT_OUTSIDE ) {
bl_Lattice->flag = LT_OUTSIDE + LT_GRID;
outside_lattice( bl_Lattice );
} else
return EXPP_ReturnPyObjError( PyExc_TypeError,
"type must be either GRID or OUTSIDE" );
Py_RETURN_NONE;
}
static PyObject *Lattice_getMode(BPy_Lattice * self)
{
if( self->lattice->flag == 1 )
return PyString_FromString( "Grid" );
else if( self->lattice->flag == 3 )
return PyString_FromString( "Outside" );
Py_RETURN_NONE;
}
static PyObject *Lattice_setPoint( BPy_Lattice * self, PyObject * args )
{
BPoint *bp, *bpoint;
short size;
Lattice *bl_Lattice;
int index, x;
float tempInt;
PyObject *listObject;
if( !PyArg_ParseTuple
( args, "iO!", &index, &PyList_Type, &listObject ) )
return ( EXPP_ReturnPyObjError
( PyExc_TypeError, "expected int & list argument" ) );
if( !PyList_Check( listObject ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"2nd parameter should be a python list" ) );
if( !( PyList_Size( listObject ) == 3 ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"Please pass 3 parameters in the list [x,y,z]" ) );
//init
bp = 0;
bl_Lattice = self->lattice;
//get bpoints
bp = bl_Lattice->def;
if( bp == 0 )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"no lattice points!" ) );
//calculate size of lattice
size = bl_Lattice->pntsu * bl_Lattice->pntsv * bl_Lattice->pntsw;
if( index < 0 || index > size )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"index outside of lattice size!" ) );
//get the bpoint
while( index ) {
index--;
bp++;
}
bpoint = bp;
for( x = 0; x < PyList_Size( listObject ); x++ ) {
if( !
( PyArg_Parse
( ( PyList_GetItem( listObject, x ) ), "f",
&tempInt ) ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"python list integer not parseable" );
bpoint->vec[x] = tempInt;
}
Py_RETURN_NONE;
}
static PyObject *Lattice_getPoint( BPy_Lattice * self, PyObject * args )
{
BPoint *bp, *bpoint;
short size;
Lattice *bl_Lattice;
int index;
if( !PyArg_ParseTuple( args, "i", &index ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int argument" ) );
//init
bp = 0;
bl_Lattice = self->lattice;
//get bpoints
bp = bl_Lattice->def;
if( bp == 0 )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"no lattice points!" ) );
//calculate size of lattice
size = bl_Lattice->pntsu * bl_Lattice->pntsv * bl_Lattice->pntsw;
if( index < 0 || index > size )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"index outside of lattice size!" ) );
//get the bpoint
while( index ) {
index--;
bp++;
}
bpoint = bp;
if( bpoint == 0 )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"bpoint does not exist" ) );
return Py_BuildValue( "[f,f,f]", bp->vec[0], bp->vec[1], bp->vec[2] );
}
static PyObject *Lattice_insertKey( BPy_Lattice * self, PyObject * args )
{
Lattice *lt;
int frame = -1, oldfra = -1;
if( !PyArg_ParseTuple( args, "i", &frame ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int argument" ) );
lt = self->lattice;
//set the current frame
if( frame > 0 ) {
frame = EXPP_ClampInt( frame, 1, MAXFRAME );
oldfra = G.scene->r.cfra;
G.scene->r.cfra = (int)frame;
}
// else just use current frame, then
// return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
// "frame value has to be greater than 0"));
//insert a keybock for the lattice (1=relative)
insert_lattkey( lt , 1);
allspace(REMAKEIPO, 0);
if( frame > 0 )
G.scene->r.cfra = (int)oldfra;
Py_RETURN_NONE;
}
static PyObject *Lattice_copy( BPy_Lattice * self )
{
Lattice *bl_Lattice; // blender Lattice object
PyObject *py_Lattice; // python wrapper
bl_Lattice = copy_lattice( self->lattice );
bl_Lattice->id.us = 0;
if( bl_Lattice )
py_Lattice = Lattice_CreatePyObject( bl_Lattice );
else
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Lattice Object in Blender" );
if( !py_Lattice )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create Lattice Object wrapper" );
return py_Lattice;
}
static int Lattice_compare( BPy_Lattice * a, BPy_Lattice * b )
{
return ( a->lattice == b->lattice ) ? 0 : -1;
}
//***************************************************************************
// Function: Lattice_repr
// Description: This is a callback function for the BPy_Lattice type. It
// builds a meaninful string to represent Lattice objects.
//***************************************************************************
static PyObject *Lattice_repr( BPy_Lattice * self )
{
if( self->lattice )
return PyString_FromFormat( "[Lattice \"%s\"]",
self->lattice->id.name + 2 );
else
return PyString_FromString( "[Lattice <deleted>]" );
}
/*****************************************************************************/
/* Python BPy_Lattice methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Lattice_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
Lattice_getName_doc},
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
Lattice_setName_doc},
{"setPartitions", ( PyCFunction ) Lattice_setPartitions, METH_VARARGS,
Lattice_setPartitions_doc},
{"getPartitions", ( PyCFunction ) Lattice_getPartitions, METH_NOARGS,
Lattice_getPartitions_doc},
{"getKey", ( PyCFunction ) Lattice_getKey, METH_NOARGS,
Lattice_getKey_doc},
{"setKeyTypes", ( PyCFunction ) Lattice_setKeyTypes, METH_VARARGS,
Lattice_setKeyTypes_doc},
{"getKeyTypes", ( PyCFunction ) Lattice_getKeyTypes, METH_NOARGS,
Lattice_getKeyTypes_doc},
{"setMode", ( PyCFunction ) Lattice_setMode, METH_VARARGS,
Lattice_setMode_doc},
{"getMode", ( PyCFunction ) Lattice_getMode, METH_NOARGS,
Lattice_getMode_doc},
{"setPoint", ( PyCFunction ) Lattice_setPoint, METH_VARARGS,
Lattice_setPoint_doc},
{"getPoint", ( PyCFunction ) Lattice_getPoint, METH_VARARGS,
Lattice_getPoint_doc},
{"insertKey", ( PyCFunction ) Lattice_insertKey, METH_VARARGS,
Lattice_insertKey_doc},
{"__copy__", ( PyCFunction ) Lattice_copy, METH_NOARGS,
Lattice_copy_doc},
{"copy", ( PyCFunction ) Lattice_copy, METH_NOARGS,
Lattice_copy_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python attributes get/set functions: */
/*****************************************************************************/
static PyObject *Lattice_getWidth(BPy_Lattice * self)
{
return PyInt_FromLong( self->lattice->pntsu );
}
static PyObject *Lattice_getHeight(BPy_Lattice * self)
{
return PyInt_FromLong( self->lattice->pntsv );
}
static PyObject *Lattice_getDepth(BPy_Lattice * self)
{
return PyInt_FromLong( self->lattice->pntsw );
}
static PyObject *Lattice_getLatSize(BPy_Lattice * self)
{
return PyInt_FromLong(
self->lattice->pntsu * self->lattice->pntsv * self->lattice->pntsw );
}
static PyObject *Lattice_getAxisType(BPy_Lattice * self, void * type)
{
char interp_type = 0;
switch ( (int)type ) {
case 0:
interp_type = self->lattice->typeu;
break;
case 1:
interp_type = self->lattice->typev;
break;
case 2:
interp_type = self->lattice->typew;
break;
}
switch (interp_type) {
case 0:
return PyString_FromString( "Linear" );
case 1:
return PyString_FromString( "Cardinal" );
case 2:
return PyString_FromString( "Bspline" );
}
Py_RETURN_NONE;
}
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Lattice_getseters[] = {
GENERIC_LIB_GETSETATTR,
{"width", (getter)Lattice_getWidth, (setter)NULL,
"lattice U subdivision ", NULL},
{"height", (getter)Lattice_getHeight, (setter)NULL,
"lattice V subdivision", NULL},
{"depth", (getter)Lattice_getDepth, (setter)NULL,
"lattice W subdivision", NULL},
{"latSize", (getter)Lattice_getLatSize, (setter)NULL,
"lattice W subdivision", NULL},
{"widthType", (getter)Lattice_getAxisType, NULL,
"lattice U interpolation type", (void *)0},
{"heightType", (getter)Lattice_getAxisType, NULL,
"lattice V interpolation type", (void *)1},
{"depthType", (getter)Lattice_getAxisType, NULL,
"lattice W interpolation type", (void *)2},
{"key", (getter)Lattice_getKey, NULL,
"lattice key", NULL},
{"mode", (getter)Lattice_getMode, NULL,
"lattice key", NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
/*****************************************************************************/
/* Python Lattice_Type structure definition: */
/*****************************************************************************/
PyTypeObject Lattice_Type = {
PyObject_HEAD_INIT( NULL )
0, /* ob_size */
"Blender Lattice", /* tp_name */
sizeof( BPy_Lattice ), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
NULL, /* tp_dealloc */
0, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
( cmpfunc ) Lattice_compare, /* tp_compare */
( reprfunc ) Lattice_repr, /* tp_repr */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
( hashfunc ) GenericLib_hash, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_Lattice_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_Lattice_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};

View File

@@ -1,60 +0,0 @@
/*
* $Id: Lattice.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joseph Gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_Lattice_H
#define EXPP_Lattice_H
#include <Python.h>
#include "DNA_lattice_types.h"
/* The Group PyTypeObject defined in Lattice.c */
extern PyTypeObject Lattice_Type;
#define BPy_Lattice_Check(v) ((v)->ob_type == &Lattice_Type)
/*****************************************************************************/
/* Python BPy_Lattice structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
Lattice * lattice; /* libdata must be second */
} BPy_Lattice;
/*
* prototypes
*/
PyObject *Lattice_Init( void );
PyObject *Lattice_CreatePyObject( Lattice * lt );
Lattice *Lattice_FromPyObject( PyObject * pyobj );
#endif /* EXPP_LATTICE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,78 +0,0 @@
/*
* $Id: Library.h 10323 2007-03-21 14:25:31Z stiv $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_LIBRARY_H
#define EXPP_LIBRARY_H
#include <Python.h>
#include "DNA_scene_types.h"
#include "BLI_linklist.h"
#include "blendef.h"
/*****************************************************************************/
/* Python BPy_Library structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
char filename[FILE_MAXDIR + FILE_MAXFILE];
} BPy_Library;
typedef struct {
PyObject_HEAD
LinkNode *iter;
int type;
char filename[FILE_MAXDIR + FILE_MAXFILE];
char *name;
enum {
OBJECT_IS_LINK,
OBJECT_IS_APPEND,
OTHER
} kind;
} BPy_LibraryData;
extern PyTypeObject Library_Type;
extern PyTypeObject LibraryData_Type;
#define BPy_LibraryData_Check(v) ((v)->ob_type == &LibraryData_Type)
#define BPy_Library_Check(v) ((v)->ob_type == &Library_Type)
/*****************************************************************************/
/* Module Blender.Library - public functions */
/*****************************************************************************/
PyObject *Library_Init( void );
PyObject *oldLibrary_Init( void );
PyObject *LibraryData_importLibData( BPy_LibraryData *self, char *name,
int mode, Scene *scene );
#endif /* EXPP_LIBRARY_H */

View File

@@ -1,827 +0,0 @@
/*
* $Id: MTex.c 10279 2007-03-16 11:38:02Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Alex Mole, Yehoshua Sapir
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "MTex.h" /*This must come first*/
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "Texture.h"
#include "Object.h"
#include "gen_utils.h"
#include "gen_library.h"
#include <DNA_material_types.h>
/*****************************************************************************/
/* Python BPy_MTex methods declarations: */
/*****************************************************************************/
static PyObject *MTex_setTexMethod( BPy_MTex * self, PyObject * args );
/*****************************************************************************/
/* Python method structure definition for Blender.Texture.MTex module: */
/*****************************************************************************/
struct PyMethodDef M_MTex_methods[] = {
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_MTex methods table: */
/*****************************************************************************/
static PyMethodDef BPy_MTex_methods[] = {
/* name, method, flags, doc */
{"setTex", ( PyCFunction ) MTex_setTexMethod, METH_VARARGS,
"(i) - Set MTex Texture"},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python MTex_Type callback function prototypes: */
/*****************************************************************************/
static int MTex_compare( BPy_MTex * a, BPy_MTex * b );
static PyObject *MTex_repr( BPy_MTex * self );
#define MTEXGET(x) \
static PyObject *MTex_get##x( BPy_MTex *self, void *closure );
#define MTEXSET(x) \
static int MTex_set##x( BPy_MTex *self, PyObject *value, void *closure);
#define MTEXGETSET(x) \
MTEXGET(x) \
MTEXSET(x)
MTEXGETSET(Tex)
MTEXGETSET(TexCo)
MTEXGETSET(Object)
MTEXGETSET(UVLayer)
MTEXGETSET(MapTo)
MTEXGETSET(Col)
MTEXGETSET(DVar)
MTEXGETSET(BlendMode)
MTEXGETSET(ColFac)
MTEXGETSET(NorFac)
MTEXGETSET(VarFac)
MTEXGETSET(DispFac)
MTEXGETSET(WarpFac)
MTEXGETSET(Ofs)
MTEXGETSET(Size)
MTEXGETSET(Mapping)
MTEXGETSET(Flag)
MTEXGETSET(ProjX)
MTEXGETSET(ProjY)
MTEXGETSET(ProjZ)
MTEXGETSET(MapToFlag)
/*****************************************************************************/
/* Python get/set methods table */
/*****************************************************************************/
static PyGetSetDef MTex_getseters[] = {
{ "tex", (getter) MTex_getTex, (setter) MTex_setTex,
"Texture whose mapping this MTex describes", NULL },
{ "texco", (getter) MTex_getTexCo, (setter) MTex_setTexCo,
"Texture coordinate space (UV, Global, etc.)", NULL },
{ "object", (getter) MTex_getObject, (setter) MTex_setObject,
"Object whose space to use when texco is Object", NULL },
{ "uvlayer", (getter) MTex_getUVLayer, (setter) MTex_setUVLayer,
"Name of the UV layer to use", NULL },
{ "mapto", (getter) MTex_getMapTo, (setter) MTex_setMapTo,
"What values the texture affects", NULL },
{ "col", (getter) MTex_getCol, (setter) MTex_setCol,
"Color that the texture blends with", NULL },
{ "dvar", (getter) MTex_getDVar, (setter) MTex_setDVar,
"Value that the texture blends with when not blending colors", NULL },
{ "blendmode", (getter) MTex_getBlendMode, (setter) MTex_setBlendMode,
"Texture blending mode", NULL },
{ "colfac", (getter) MTex_getColFac, (setter) MTex_setColFac,
"Factor by which texture affects color", NULL },
{ "norfac", (getter) MTex_getNorFac, (setter) MTex_setNorFac,
"Factor by which texture affects normal", NULL },
{ "varfac", (getter) MTex_getVarFac, (setter) MTex_setVarFac,
"Factor by which texture affects most variables", NULL },
{ "dispfac", (getter) MTex_getDispFac, (setter) MTex_setDispFac,
"Factor by which texture affects displacement", NULL },
{ "warpfac", (getter) MTex_getWarpFac, (setter) MTex_setWarpFac,
"Factor by which texture affects warp", NULL },
{ "ofs", (getter) MTex_getOfs, (setter) MTex_setOfs,
"Offset to adjust texture space", NULL },
{ "size", (getter) MTex_getSize, (setter) MTex_setSize,
"Size to scale texture space", NULL },
{ "mapping", (getter) MTex_getMapping, (setter) MTex_setMapping,
"Mapping of texture coordinates (flat, cube, etc.)", NULL },
{ "stencil", (getter) MTex_getFlag, (setter) MTex_setFlag,
"Stencil mode", (void*) MTEX_STENCIL },
{ "neg", (getter) MTex_getFlag, (setter) MTex_setFlag,
"Negate texture values mode", (void*) MTEX_NEGATIVE },
{ "noRGB", (getter) MTex_getFlag, (setter) MTex_setFlag,
"Convert texture RGB values to intensity values",
(void*) MTEX_RGBTOINT },
{ "correctNor", (getter) MTex_getFlag, (setter) MTex_setFlag,
"Correct normal mapping for Texture space and Object space",
(void*) MTEX_VIEWSPACE },
{ "xproj", (getter) MTex_getProjX, (setter) MTex_setProjX,
"Projection of X axis to Texture space", NULL },
{ "yproj", (getter) MTex_getProjY, (setter) MTex_setProjY,
"Projection of Y axis to Texture space", NULL },
{ "zproj", (getter) MTex_getProjZ, (setter) MTex_setProjZ,
"Projection of Z axis to Texture space", NULL },
{ "mtCol", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to color", (void*) MAP_COL },
{ "mtNor", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to normals", (void*) MAP_NORM },
{ "mtCsp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to specularity color", (void*) MAP_COLSPEC },
{ "mtCmir", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to mirror color", (void*) MAP_COLMIR },
{ "mtRef", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to reflectivity", (void*) MAP_REF },
{ "mtSpec", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to specularity", (void*) MAP_SPEC },
{ "mtEmit", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to emit value", (void*) MAP_EMIT },
{ "mtAlpha", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to alpha value", (void*) MAP_ALPHA },
{ "mtHard", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to hardness", (void*) MAP_HAR },
{ "mtRayMir", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to RayMir value", (void*) MAP_RAYMIRR },
{ "mtTranslu", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to translucency", (void*) MAP_TRANSLU },
{ "mtAmb", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to ambient value", (void*) MAP_AMB },
{ "mtDisp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to displacement", (void*) MAP_DISPLACE },
{ "mtWarp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to warp", (void*) MAP_WARP },
{ NULL, NULL, NULL, NULL, NULL }
};
/*****************************************************************************/
/* Python MTex_Type structure definition: */
/*****************************************************************************/
PyTypeObject MTex_Type = {
PyObject_HEAD_INIT( NULL )
0, /* ob_size */
"Blender MTex", /* tp_name */
sizeof( BPy_MTex ), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
NULL, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
( cmpfunc ) MTex_compare, /* tp_compare */
( reprfunc ) MTex_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_as_hash */
0, 0, 0, 0, 0,
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
0, /* tp_doc */
0, 0, 0, 0, 0, 0,
BPy_MTex_methods, /* tp_methods */
0, /* tp_members */
MTex_getseters, /* struct PyGetSetDef *tp_getset; */
0, /* struct _typeobject *tp_base; */
0, /* PyObject *tp_dict; */
0, /* descrgetfunc tp_descr_get; */
0, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
0, /* initproc tp_init; */
0, /* allocfunc tp_alloc; */
0, /* newfunc tp_new; */
/* Low-level free-memory routine */
0, /* freefunc tp_free; */
/* For PyObject_IS_GC */
0, /* inquiry tp_is_gc; */
0, /* PyObject *tp_bases; */
/* method resolution order */
0, /* PyObject *tp_mro; */
0, /* PyObject *tp_cache; */
0, /* PyObject *tp_subclasses; */
0, /* PyObject *tp_weaklist; */
0
};
PyObject *MTex_Init( void )
{
PyObject *submodule;
/* PyObject *dict; */
/* call PyType_Ready() to init dictionaries & such */
if( PyType_Ready( &MTex_Type) < 0)
Py_RETURN_NONE;
submodule = Py_InitModule( "Blender.Texture.MTex", M_MTex_methods );
return submodule;
}
PyObject *MTex_CreatePyObject( MTex * mtex )
{
BPy_MTex *pymtex;
pymtex = ( BPy_MTex * ) PyObject_NEW( BPy_MTex, &MTex_Type );
if( !pymtex )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create BPy_MTex PyObject" );
pymtex->mtex = mtex;
return ( PyObject * ) pymtex;
}
MTex *MTex_FromPyObject( PyObject * pyobj )
{
return ( ( BPy_MTex * ) pyobj )->mtex;
}
/*****************************************************************************/
/* Python BPy_MTex methods: */
/*****************************************************************************/
static PyObject *MTex_setTexMethod( BPy_MTex * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)MTex_setTex );
}
static int MTex_compare( BPy_MTex * a, BPy_MTex * b )
{
return ( a->mtex == b->mtex ) ? 0 : -1;
}
static PyObject *MTex_repr( BPy_MTex * self )
{
return PyString_FromFormat( "[MTex]" );
}
/*****************************************************************************/
/* Python BPy_MTex get and set functions: */
/*****************************************************************************/
static PyObject *MTex_getTex( BPy_MTex *self, void *closure )
{
if( self->mtex->tex )
return Texture_CreatePyObject( self->mtex->tex );
else
Py_RETURN_NONE;
}
static int MTex_setTex( BPy_MTex *self, PyObject *value, void *closure)
{
return GenericLib_assignData(value, (void **) &self->mtex->tex, 0, 1, ID_TE, 0);
}
static PyObject *MTex_getTexCo( BPy_MTex *self, void *closure )
{
return PyInt_FromLong( self->mtex->texco );
}
static int MTex_setTexCo( BPy_MTex *self, PyObject *value, void *closure)
{
int texco;
if( !PyInt_Check( value ) ) {
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be a member of Texture.TexCo dictionary" );
}
texco = PyInt_AsLong( value ) ;
if (texco != TEXCO_ORCO && texco != TEXCO_REFL && texco != TEXCO_NORM &&
texco != TEXCO_GLOB && texco != TEXCO_UV && texco != TEXCO_OBJECT &&
texco != TEXCO_STRESS && texco != TEXCO_TANGENT && texco != TEXCO_WINDOW &&
texco != TEXCO_VIEW && texco != TEXCO_STICKY )
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a member of Texture.TexCo dictionary" );
self->mtex->texco = (short)texco;
return 0;
}
static PyObject *MTex_getObject( BPy_MTex *self, void *closure )
{
if( self->mtex->object )
return Object_CreatePyObject( self->mtex->object );
else
Py_RETURN_NONE;
}
static int MTex_setObject( BPy_MTex *self, PyObject *value, void *closure)
{
return GenericLib_assignData(value, (void **) &self->mtex->object, 0, 1, ID_OB, 0);
}
static PyObject *MTex_getUVLayer( BPy_MTex *self, void *closure )
{
return PyString_FromString(self->mtex->uvname);
}
static int MTex_setUVLayer( BPy_MTex *self, PyObject *value, void *closure)
{
if ( !PyString_Check(value) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string value" );
BLI_strncpy(self->mtex->uvname, PyString_AsString(value), 31);
return 0;
}
static PyObject *MTex_getMapTo( BPy_MTex *self, void *closure )
{
return PyInt_FromLong( self->mtex->mapto );
}
static int MTex_setMapTo( BPy_MTex *self, PyObject *value, void *closure)
{
int mapto;
if( !PyInt_Check( value ) ) {
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an int" );
}
mapto = PyInt_AsLong( value );
/* This method is deprecated anyway. */
if ( mapto < 0 || mapto > 16383 ) {
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a sum of values from Texture.MapTo dictionary" );
}
self->mtex->mapto = (short)mapto;
return 0;
}
static PyObject *MTex_getCol( BPy_MTex *self, void *closure )
{
return Py_BuildValue( "(f,f,f)", self->mtex->r, self->mtex->g,
self->mtex->b );
}
static int MTex_setCol( BPy_MTex *self, PyObject *value, void *closure)
{
float rgb[3];
int i;
if( !PyArg_ParseTuple( value, "fff",
&rgb[0], &rgb[1], &rgb[2] ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple of 3 floats" );
for( i = 0; i < 3; ++i )
if( rgb[i] < 0 || rgb[i] > 1 )
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->r = rgb[0];
self->mtex->g = rgb[1];
self->mtex->b = rgb[2];
return 0;
}
static PyObject *MTex_getDVar( BPy_MTex *self, void *closure )
{
return PyFloat_FromDouble(self->mtex->def_var);
}
static int MTex_setDVar( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 1)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->def_var = f;
return 0;
}
static PyObject *MTex_getBlendMode( BPy_MTex *self, void *closure )
{
return PyInt_FromLong(self->mtex->blendtype);
}
static int MTex_setBlendMode( BPy_MTex *self, PyObject *value, void *closure)
{
int n;
if ( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be member of Texture.BlendModes dictionary" );
n = PyInt_AsLong(value);
/* if (n != MTEX_BLEND && n != MTEX_MUL && n != MTEX_ADD &&
n != MTEX_SUB && n != MTEX_DIV && n != MTEX_DARK &&
n != MTEX_DIFF && n != MTEX_LIGHT && n != MTEX_SCREEN)*/
if (n < 0 || n > 8)
{
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be member of Texture.BlendModes dictionary" );
}
self->mtex->blendtype = (short)n;
return 0;
}
static PyObject *MTex_getColFac( BPy_MTex *self, void *closure )
{
return PyFloat_FromDouble(self->mtex->colfac);
}
static int MTex_setColFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 1)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->colfac = f;
return 0;
}
static PyObject *MTex_getNorFac( BPy_MTex *self, void *closure )
{
return PyFloat_FromDouble(self->mtex->norfac);
}
static int MTex_setNorFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 25)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,25]" );
self->mtex->norfac = f;
return 0;
}
static PyObject *MTex_getVarFac( BPy_MTex *self, void *closure )
{
return PyFloat_FromDouble(self->mtex->varfac);
}
static int MTex_setVarFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 1)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->varfac = f;
return 0;
}
static PyObject *MTex_getDispFac( BPy_MTex *self, void *closure )
{
return PyFloat_FromDouble(self->mtex->dispfac);
}
static int MTex_setDispFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 1)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->dispfac = f;
return 0;
}
static PyObject *MTex_getWarpFac( BPy_MTex *self, void *closure )
{
return PyFloat_FromDouble(self->mtex->warpfac);
}
static int MTex_setWarpFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 1)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->warpfac = f;
return 0;
}
static PyObject *MTex_getOfs( BPy_MTex *self, void *closure )
{
return Py_BuildValue( "(f,f,f)", self->mtex->ofs[0], self->mtex->ofs[1],
self->mtex->ofs[2] );
}
static int MTex_setOfs( BPy_MTex *self, PyObject *value, void *closure)
{
float f[3];
int i;
if( !PyArg_ParseTuple( value, "fff", &f[0], &f[1], &f[2] ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple of 3 floats" );
for( i = 0; i < 3; ++i )
if( f[i] < -10 || f[i] > 10 )
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [-10,10]" );
self->mtex->ofs[0] = f[0];
self->mtex->ofs[1] = f[1];
self->mtex->ofs[2] = f[2];
return 0;
}
static PyObject *MTex_getSize( BPy_MTex *self, void *closure )
{
return Py_BuildValue( "(f,f,f)", self->mtex->size[0], self->mtex->size[1],
self->mtex->size[2] );
}
static int MTex_setSize( BPy_MTex *self, PyObject *value, void *closure)
{
float f[3];
int i;
if( !PyArg_ParseTuple( value, "fff", &f[0], &f[1], &f[2] ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple of 3 floats" );
for( i = 0; i < 3; ++i )
if( f[i] < -100 || f[i] > 100 )
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [-100,100]" );
self->mtex->size[0] = f[0];
self->mtex->size[1] = f[1];
self->mtex->size[2] = f[2];
return 0;
}
static PyObject *MTex_getMapping( BPy_MTex *self, void *closure )
{
return PyInt_FromLong( self->mtex->mapping );
}
static int MTex_setMapping( BPy_MTex *self, PyObject *value, void *closure)
{
int n;
if ( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be member of Texture.Mappings dictionary" );
n = PyInt_AsLong(value);
/* if (n != MTEX_FLAT && n != MTEX_TUBE && n != MTEX_CUBE &&
n != MTEX_SPHERE) */
if (n < 0 || n > 3)
{
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be member of Texture.Mappings dictionary" );
}
self->mtex->mapping = (char)n;
return 0;
}
static PyObject *MTex_getFlag( BPy_MTex *self, void *closure )
{
return PyBool_FromLong( self->mtex->texflag & ((int) closure) );
}
static int MTex_setFlag( BPy_MTex *self, PyObject *value, void *closure)
{
if ( !PyBool_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a bool");
if ( value == Py_True )
self->mtex->texflag |= (int)closure;
else
self->mtex->texflag &= ~((int) closure);
return 0;
}
static PyObject *MTex_getProjX( BPy_MTex *self, void *closure )
{
return PyInt_FromLong( self->mtex->projx );
}
static int MTex_setProjX( BPy_MTex *self, PyObject *value, void *closure)
{
int proj;
if( !PyInt_Check( value ) ) {
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be a member of Texture.Proj dictionary" );
}
proj = PyInt_AsLong( value ) ;
/* valid values are from PROJ_N to PROJ_Z = 0 to 3 */
if (proj < 0 || proj > 3)
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a member of Texture.Proj dictionary" );
self->mtex->projx = (char)proj;
return 0;
}
static PyObject *MTex_getProjY( BPy_MTex *self, void *closure )
{
return PyInt_FromLong( self->mtex->projy );
}
static int MTex_setProjY( BPy_MTex *self, PyObject *value, void *closure )
{
int proj;
if( !PyInt_Check( value ) ) {
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be a member of Texture.Proj dictionary" );
}
proj = PyInt_AsLong( value ) ;
/* valid values are from PROJ_N to PROJ_Z = 0 to 3 */
if (proj < 0 || proj > 3)
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a member of Texture.Proj dictionary" );
self->mtex->projy = (char)proj;
return 0;
}
static PyObject *MTex_getProjZ( BPy_MTex *self, void *closure )
{
return PyInt_FromLong( self->mtex->projz );
}
static int MTex_setProjZ( BPy_MTex *self, PyObject *value, void *closure)
{
int proj;
if( !PyInt_Check( value ) ) {
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be a member of Texture.Proj dictionary" );
}
proj = PyInt_AsLong( value ) ;
/* valid values are from PROJ_N to PROJ_Z = 0 to 3 */
if (proj < 0 || proj > 3)
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a member of Texture.Proj dictionary" );
self->mtex->projz = (char)proj;
return 0;
}
static PyObject *MTex_getMapToFlag( BPy_MTex *self, void *closure )
{
int flag = (int) closure;
if ( self->mtex->mapto & flag )
{
return PyInt_FromLong( ( self->mtex->maptoneg & flag ) ? -1 : 1 );
} else {
return PyInt_FromLong( 0 );
}
}
static int MTex_setMapToFlag( BPy_MTex *self, PyObject *value, void *closure)
{
int flag = (int) closure;
int intVal;
if ( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an int");
intVal = PyInt_AsLong( value );
if (flag == MAP_COL || flag == MAP_COLSPEC || flag == MAP_COLMIR ||
flag == MAP_WARP) {
if (intVal < 0 || intVal > 1) {
return EXPP_ReturnIntError( PyExc_ValueError,
"value for that mapping must be 0 or 1" );
}
} else {
if (intVal < -1 || intVal > 1) {
return EXPP_ReturnIntError( PyExc_ValueError,
"value for that mapping must be -1, 0 or 1" );
}
}
switch (intVal)
{
case 0:
self->mtex->mapto &= ~flag;
self->mtex->maptoneg &= ~flag;
break;
case 1:
self->mtex->mapto |= flag;
self->mtex->maptoneg &= ~flag;
break;
case -1:
self->mtex->mapto |= flag;
self->mtex->maptoneg |= flag;
break;
}
return 0;
}

View File

@@ -1,63 +0,0 @@
/*
* $Id: MTex.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Alex Mole
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_MTEX_H
#define EXPP_MTEX_H
#include <Python.h>
#include "DNA_texture_types.h"
/*****************************************************************************/
/* Python BPy_MTex structure definition */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
MTex * mtex;
} BPy_MTex;
extern PyTypeObject MTex_Type;
#define BPy_MTex_Check(v) ((v)->ob_type == &MTex_Type)
/*****************************************************************************/
/* Module Blender.Texture.MTex - public functions */
/*****************************************************************************/
PyObject *MTex_Init( void );
PyObject *MTex_CreatePyObject( struct MTex *obj );
MTex *MTex_FromPyObject( PyObject * py_obj );
#endif /* EXPP_MTEX_H */

View File

@@ -1,64 +0,0 @@
#
# $Id: Makefile 11904 2007-08-31 16:16:33Z sirdude $
#
# ***** BEGIN GPL/BL DUAL 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. The Blender
# Foundation also sells licenses for use in proprietary software under
# the Blender License. See http://www.blender.org/BL/ for information
# about this.
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): none yet.
#
# ***** END GPL/BL DUAL LICENSE BLOCK *****
#
#
LIBNAME = python
DIR = $(OCGDIR)/blender/python
CSRCS ?= $(wildcard *.c) $(wildcard ../*.c)
include nan_compile.mk
CFLAGS += $(LEVEL_1_C_WARNINGS)
ifeq ($(WITH_FFMPEG), true)
CPPFLAGS += -DWITH_FFMPEG
endif
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
CPPFLAGS += -I../../makesdna
CPPFLAGS += -I../../blenkernel
CPPFLAGS += -I../../blenlib
CPPFLAGS += -I../../blenloader
CPPFLAGS += -I../../include
CPPFLAGS += -I../../render/extern/include
CPPFLAGS += -I../../radiosity/extern/include
CPPFLAGS += -I$(NAN_BMFONT)/include
CPPFLAGS += -I../../imbuf
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
# We'll just add a little duct tape to fix things here ...
.PHONY: clean
clean::
@rm -f $(OCGDIR)/blender/BPY_*.o
@rm -f $(OCGDIR)/blender/BPY_*.d

File diff suppressed because it is too large Load Diff

View File

@@ -1,78 +0,0 @@
/*
* $Id: Material.h 10649 2007-05-04 03:23:40Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_MATERIAL_H
#define EXPP_MATERIAL_H
#include <Python.h>
#include "DNA_object_types.h"
#include "DNA_material_types.h"
#include "DNA_texture_types.h" /* colorband */
#include "rgbTuple.h"
/*****************************************************************************/
/* Python BPy_Material structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
Material * material; /* libdata must be second */
BPy_rgbTuple *col, *amb, *spec, *mir, *sss;
} BPy_Material;
extern PyTypeObject Material_Type; /* The Material PyType Object */
#define BPy_Material_Check(v) \
((v)->ob_type == &Material_Type) /* for type checking */
/*****************************************************************************/
/* Module Blender.Material - public functions */
/*****************************************************************************/
PyObject *M_Material_Init( void );
PyObject *Material_Init( void );
PyObject *Material_CreatePyObject( Material * mat );
Material *Material_FromPyObject( PyObject * pyobj );
/* colorband tp_getseters */
PyObject *EXPP_PyList_fromColorband( ColorBand *coba );
int EXPP_Colorband_fromPyList( ColorBand **coba, PyObject * value );
/* Some functions needed by NMesh, Curve and friends */
PyObject *EXPP_PyList_fromMaterialList( Material ** matlist, int len,
int all );
Material **EXPP_newMaterialList_fromPyList( PyObject * list );
Material **EXPP_newMaterialList( int len );
void EXPP_incr_mats_us( Material ** matlist, int len );
int EXPP_synchronizeMaterialLists( Object * object );
int EXPP_releaseMaterialList( Material ** matlist, int len );
#endif /* EXPP_MATERIAL_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,85 +0,0 @@
/*
* $Id: Mathutils.h 10943 2007-06-16 12:24:41Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joseph Gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
//Include this file for access to vector, quat, matrix, euler, etc...
#ifndef EXPP_Mathutils_H
#define EXPP_Mathutils_H
#include <Python.h>
#include "vector.h"
#include "matrix.h"
#include "quat.h"
#include "euler.h"
#include "point.h"
PyObject *Mathutils_Init( void );
PyObject *row_vector_multiplication(VectorObject* vec, MatrixObject * mat);
PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject* vec);
PyObject *row_point_multiplication(PointObject* pt, MatrixObject * mat);
PyObject *column_point_multiplication(MatrixObject * mat, PointObject* pt);
PyObject *quat_rotation(PyObject *arg1, PyObject *arg2);
PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Vector(PyObject * self, PyObject * args);
PyObject *M_Mathutils_CrossVecs(PyObject * self, PyObject * args);
PyObject *M_Mathutils_DotVecs(PyObject * self, PyObject * args);
PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args);
PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args);
PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Matrix(PyObject * self, PyObject * args);
PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args);
PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * value);
PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args);
PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * args);
PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Quaternion(PyObject * self, PyObject * args);
PyObject *M_Mathutils_CrossQuats(PyObject * self, PyObject * args);
PyObject *M_Mathutils_DotQuats(PyObject * self, PyObject * args);
PyObject *M_Mathutils_DifferenceQuats(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Slerp(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Euler(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Intersect( PyObject * self, PyObject * args );
PyObject *M_Mathutils_TriangleArea( PyObject * self, PyObject * args );
PyObject *M_Mathutils_TriangleNormal( PyObject * self, PyObject * args );
PyObject *M_Mathutils_QuadNormal( PyObject * self, PyObject * args );
PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args );
PyObject *M_Mathutils_Point(PyObject * self, PyObject * args);
//DEPRECATED
PyObject *M_Mathutils_CopyMat(PyObject * self, PyObject * args);
PyObject *M_Mathutils_CopyVec(PyObject * self, PyObject * args);
PyObject *M_Mathutils_CopyQuat(PyObject * self, PyObject * args);
PyObject *M_Mathutils_CopyEuler(PyObject * self, PyObject * args);
PyObject *M_Mathutils_RotateEuler(PyObject * self, PyObject * args);
PyObject *M_Mathutils_MatMultVec(PyObject * self, PyObject * args);
PyObject *M_Mathutils_VecMultMat(PyObject * self, PyObject * args);
#endif /* EXPP_Mathutils_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,127 +0,0 @@
/*
* $Id: Mesh.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/* Most of this file comes from opy_nmesh.[ch] in the old bpython dir */
#ifndef EXPP_MESH_H
#define EXPP_MESH_H
#include <Python.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "Material.h"
#include "Image.h"
/* EXPP PyType Objects */
extern PyTypeObject Mesh_Type;
extern PyTypeObject MVert_Type;
extern PyTypeObject PVert_Type;
extern PyTypeObject MVertSeq_Type;
extern PyTypeObject MEdge_Type;
extern PyTypeObject MFace_Type;
extern PyTypeObject MCol_Type;
struct BPy_Object;
/* Type checking for EXPP PyTypes */
#define BPy_Mesh_Check(v) ((v)->ob_type == &Mesh_Type)
#define BPy_MFace_Check(v) ((v)->ob_type == &MFace_Type)
#define BPy_MEdge_Check(v) ((v)->ob_type == &MEdge_Type)
#define BPy_MVert_Check(v) ((v)->ob_type == &MVert_Type)
#define BPy_PVert_Check(v) ((v)->ob_type == &PVert_Type)
#define BPy_MCol_Check(v) ((v)->ob_type == &MCol_Type)
/* Typedefs for the new types */
typedef struct {
PyObject_HEAD /* required python macro */
MCol *color;
} BPy_MCol; /* a Mesh color: [r,g,b,a] */
typedef struct {
PyObject_VAR_HEAD /* required python macro */
void * data; /* points to a Mesh or an MVert */
int index;
} BPy_MVert; /* a Mesh vertex */
typedef struct {
PyObject_VAR_HEAD /* required python macro */
Mesh * mesh;
int iter;
} BPy_MVertSeq; /* a Mesh vertex sequence */
typedef struct {
PyObject_VAR_HEAD /* required python macro */
Mesh *mesh; /* points to a Mesh */
int index;
short iter; /* char because it can only ever be between -1 and 2 */
} BPy_MEdge; /* a Mesh edge */
typedef struct {
PyObject_VAR_HEAD /* required python macro */
Mesh * mesh;
int iter;
} BPy_MEdgeSeq; /* a Mesh edge sequence */
typedef struct {
PyObject_VAR_HEAD /* required python macro */
Mesh * mesh;
int index;
short iter; /* char because it can only ever be between -1 and 4 */
} BPy_MFace; /* a Mesh face */
typedef struct {
PyObject_VAR_HEAD /* required python macro */
Mesh * mesh;
int iter;
} BPy_MFaceSeq; /* a Mesh face sequence */
typedef struct {
PyObject_HEAD /* required python macro */
Mesh *mesh;
Object *object;
char new; /* was mesh created or already existed? */
} BPy_Mesh;
/* PROTOS */
PyObject *Mesh_Init( void );
PyObject *Mesh_CreatePyObject( Mesh * me, Object *obj );
Mesh *Mesh_FromPyObject( PyObject * pyobj, Object *obj );
#endif /* EXPP_MESH_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,81 +0,0 @@
/*
* $Id: Metaball.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Jacques Guignot
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_METABALL_H
#define EXPP_METABALL_H
#include <Python.h>
#include "DNA_meta_types.h"
extern PyTypeObject Metaball_Type;
#define BPy_Metaball_Check(v) ((v)->ob_type==&Metaball_Type)
/* Python BPy_Metaball structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
MetaBall * metaball; /* libdata must be second */
} BPy_Metaball;
extern PyTypeObject Metaelem_Type;
#define BPy_Metaelem_Check(v) ((v)->ob_type==&Metaelem_Type)
/* Python BPy_Metaelem structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
MetaElem * metaelem;
} BPy_Metaelem;
extern PyTypeObject MetaElemSeq_Type;
#define BPy_MetaElemSeq_Check(v) ((v)->ob_type==&MetaElemSeq_Type)
/* Python BPy_MetaElemSeq structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
BPy_Metaball *bpymetaball; /* link to the python group so we can know if its been removed */
MetaElem * iter; /* so we can iterate over the objects */
} BPy_MetaElemSeq;
/*
* prototypes
*/
PyObject *Metaball_Init( void );
PyObject *Metaball_CreatePyObject( MetaBall * mball );
MetaBall *Metaball_FromPyObject( PyObject * py_obj );
#endif /* EXPP_METABALL_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,72 +0,0 @@
/*
* $Id: Modifier.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_MODIFIER_H
#define EXPP_MODIFIER_H
#include <Python.h>
#include "DNA_object_types.h"
#include "DNA_modifier_types.h"
#include "DNA_listBase.h"
/*****************************************************************************/
/* Python BPy_Modifier and BPy_ModSeq structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD /* required macro */
Object *object;
ModifierData *iter;
} BPy_ModSeq;
typedef struct {
PyObject_HEAD /* required macro */
Object *object;
/* if md this is null, the modifier has been removed and we need to raise
an error when its data is accessed */
ModifierData *md;
} BPy_Modifier;
extern PyTypeObject ModSeq_Type;
extern PyTypeObject Modifier_Type;
#define BPy_ModSeq_Check(v) ((v)->ob_type == &ModSeq_Type)
#define BPy_Modifier_Check(v) ((v)->ob_type == &Modifier_Type)
/*
* prototypes
*/
PyObject *Modifier_Init( void );
PyObject *ModSeq_CreatePyObject( Object *obj, ModifierData *iter );
PyObject *Modifier_CreatePyObject( Object *obj, ModifierData *md );
ModifierData *Modifier_FromPyObject( PyObject * py_obj );
#endif /* EXPP_MODIFIER_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,77 +0,0 @@
/*
* $Id: NLA.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joseph Gilbert, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_NLA_H
#define EXPP_NLA_H
#include <Python.h>
#include "DNA_action_types.h"
#include "DNA_nla_types.h"
struct Object;
/** NLA module initialization function. */
PyObject *NLA_Init( void );
extern PyTypeObject Action_Type;
extern PyTypeObject ActionStrip_Type;
extern PyTypeObject ActionStrips_Type;
/** Python BPy_NLA structure definition. */
typedef struct {
PyObject_HEAD
bAction * action; /* libdata must be second */
} BPy_Action;
typedef struct {
PyObject_HEAD
bActionStrip * strip;
} BPy_ActionStrip;
typedef struct {
PyObject_HEAD
struct Object * ob;
struct bActionStrip *iter;
} BPy_ActionStrips;
/* Type checking for EXPP PyTypes */
#define BPy_Action_Check(v) ((v)->ob_type == &Action_Type)
#define BPy_ActionStrip_Check(v) ((v)->ob_type == &ActionStrip_Type)
#define BPy_ActionStrips_Check(v) ((v)->ob_type == &ActionStrips_Type)
PyObject *Action_CreatePyObject( struct bAction *action );
bAction *Action_FromPyObject( PyObject * py_obj );
PyObject *ActionStrip_CreatePyObject( struct bActionStrip *strip );
PyObject *ActionStrips_CreatePyObject( struct Object *ob );
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,157 +0,0 @@
/*
* $Id: NMesh.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano, Jordi Rovira i Bonnet, Joseph Gilbert.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/* 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
#include <config.h>
#endif
#include "DNA_customdata_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "Material.h"
#include "Image.h"
/* EXPP PyType Objects */
extern PyTypeObject NMesh_Type;
extern PyTypeObject NMFace_Type;
extern PyTypeObject NMVert_Type;
extern PyTypeObject NMCol_Type;
extern PyTypeObject NMEdge_Type;
struct BPy_Object;
/* These are from blender/src/editdeform.c, should be declared elsewhere,
* maybe in BIF_editdeform.h, after proper testing of vgrouping methods XXX */
extern void add_vert_defnr( Object * ob, int def_nr, int vertnum, float weight,
int assignmode );
extern void remove_vert_def_nr( Object * ob, int def_nr, int vertnum );
/* Type checking for EXPP PyTypes */
#define BPy_NMesh_Check(v) ((v)->ob_type == &NMesh_Type)
#define BPy_NMFace_Check(v) ((v)->ob_type == &NMFace_Type)
#define BPy_NMVert_Check(v) ((v)->ob_type == &NMVert_Type)
#define BPy_NMCol_Check(v) ((v)->ob_type == &NMCol_Type)
#define BPy_NMEdge_Check(v) ((v)->ob_type == &NMEdge_Type)
/* Typedefs for the new types */
typedef struct {
PyObject_HEAD /* required python macro */
unsigned char r, g, b, a;
} BPy_NMCol; /* an NMesh color: [r,g,b,a] */
typedef struct {
PyObject_VAR_HEAD /* required python macro */
float co[3];
float no[3];
float uvco[3];
int index;
char flag; /* see MVert flag in DNA_meshdata_types */
} BPy_NMVert; /* an NMesh vertex */
typedef struct {
PyObject_HEAD /* required python macro */
PyObject * v;
PyObject *uv;
PyObject *col;
short mode;
short flag; /* tface->flag */
unsigned char transp;
Image *image;
char mat_nr, mf_flag /* was char smooth */;
int orig_index;
} BPy_NMFace; /* an NMesh face */
typedef struct {
PyObject_HEAD /* required python macro */
PyObject *v1;
PyObject *v2;
char crease;
short flag;
} BPy_NMEdge; /* an NMesh edge */
typedef struct {
PyObject_HEAD /* required python macro */
Mesh * mesh; /* libdata must be second */
Object *object; /* for vertex grouping info, since it's stored on the object */
PyObject *name;
PyObject *materials;
PyObject *verts;
PyObject *faces;
PyObject *edges;
int sel_face; /*@ XXX remove */
short smoothresh; /* max AutoSmooth angle */
short subdiv[2]; /* SubDiv Levels: display and rendering */
short mode; /* see the EXPP_NMESH_* defines in the beginning of this file */
char flags;
#define NMESH_HASMCOL (1<<0)
#define NMESH_HASVERTUV (1<<1)
#define NMESH_HASFACEUV (1<<2)
/* stores original data that is not accesible through NMesh, but that we
still want to preserve, indexed by orig_index in NMFace */
CustomData fdata;
int totfdata;
} BPy_NMesh;
/* PROTOS */
PyObject *NMesh_Init( void );
PyObject *NMesh_CreatePyObject( Mesh * me, Object * ob );
Mesh *NMesh_FromPyObject( PyObject * pyobj, Object * ob );
void mesh_update( Mesh * mesh , Object * ob );
PyObject *new_NMesh( Mesh * oldmesh );
Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh );
PyObject *NMesh_assignMaterials_toObject( BPy_NMesh * nmesh, Object * ob );
Material **nmesh_updateMaterials( BPy_NMesh * nmesh );
Material **newMaterialList_fromPyList( PyObject * list );
#endif /* EXPP_NMESH_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,91 +0,0 @@
/*
* $Id: Node.h 10449 2007-04-03 11:24:11Z jesterking $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2006, Blender Foundation
* All rights reserved.
*
* Original code is this file
*
* Contributor(s): Nathan Letwory
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifdef USE_PYNODES /* note: won't work without patch */
#ifndef __NODE_H__
#define __NODE_H__
#include <Python.h>
#include "DNA_node_types.h"
#include "BKE_node.h"
#include "RE_shader_ext.h" /* <- ShadeInput Shaderesult TexResult */
extern PyTypeObject Node_Type;
extern PyTypeObject ShadeInput_Type;
#define BPy_Node_Check(v) \
((v)->ob_type == &Node_Type)
#define BPy_ShadeInput_Check(v) \
((v)->ob_type == &ShadeInput_Type)
typedef struct BPy_ShadeInput {
PyObject_HEAD
ShadeInput *shi;
} BPy_ShadeInput;
typedef struct {
PyObject_VAR_HEAD
bNodeType *typeinfo;
bNodeStack **stack;
} BPy_SockMap;
typedef struct {
PyObject_HEAD
bNode *node;
} BPy_DefinitionMap;
typedef struct BPy_Node {
PyObject_HEAD
bNode *node;
bNodeStack **in;
bNodeStack **out;
ShadeInput *shi;
} BPy_Node;
extern PyObject *Node_Init(void);
extern void InitNode(BPy_Node *self, bNode *node);
extern BPy_Node *Node_CreatePyObject(bNode *node);
extern BPy_DefinitionMap *Node_CreateOutputDefMap(bNode *node);
extern BPy_DefinitionMap *Node_CreateInputDefMap(bNode *node);
extern void Node_SetStack(BPy_Node *self, bNodeStack **stack, int type);
extern void Node_SetShi(BPy_Node *self, ShadeInput *shi);
extern BPy_ShadeInput *ShadeInput_CreatePyObject(ShadeInput *shi);
extern void Node_dealloc(BPy_Node *self);
extern void ShadeInput_dealloc(BPy_ShadeInput *self);
#define NODE_INPUTSTACK 0
#define NODE_OUTPUTSTACK 1
#endif /* __NODE_H__*/
#endif /* USE_PYNODES */

View File

@@ -1,713 +0,0 @@
/**
* $Id: Noise.c 12056 2007-09-17 06:11:06Z aligorith $
*
* Blender.Noise BPython module implementation.
* This submodule has functions to generate noise of various types.
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): eeshlo
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/************************/
/* Blender Noise Module */
/************************/
#include <Python.h>
#include "BLI_blenlib.h"
#include "DNA_texture_types.h"
#include "constant.h"
/*-----------------------------------------*/
/* 'mersenne twister' random number generator */
/*
A C-program for MT19937, with initialization improved 2002/2/10.
Coded by Takuji Nishimura and Makoto Matsumoto.
This is a faster version by taking Shawn Cokus's optimization,
Matthe Bellew's simplification, Isaku Wada's real version.
Before using, initialize the state by using init_genrand(seed)
or init_by_array(init_key, key_length).
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Any feedback is very welcome.
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
*/
/* Period parameters */
#define N 624
#define M 397
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
#define UMASK 0x80000000UL /* most significant w-r bits */
#define LMASK 0x7fffffffUL /* least significant r bits */
#define MIXBITS(u,v) ( ((u) & UMASK) | ((v) & LMASK) )
#define TWIST(u,v) ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL))
static unsigned long state[N]; /* the array for the state vector */
static int left = 1;
static int initf = 0;
static unsigned long *next;
PyObject *Noise_Init(void);
/* initializes state[N] with a seed */
static void init_genrand( unsigned long s )
{
int j;
state[0] = s & 0xffffffffUL;
for( j = 1; j < N; j++ ) {
state[j] =
( 1812433253UL *
( state[j - 1] ^ ( state[j - 1] >> 30 ) ) + j );
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array state[]. */
/* 2002/01/09 modified by Makoto Matsumoto */
state[j] &= 0xffffffffUL; /* for >32 bit machines */
}
left = 1;
initf = 1;
}
static void next_state( void )
{
unsigned long *p = state;
int j;
/* if init_genrand() has not been called, */
/* a default initial seed is used */
if( initf == 0 )
init_genrand( 5489UL );
left = N;
next = state;
for( j = N - M + 1; --j; p++ )
*p = p[M] ^ TWIST( p[0], p[1] );
for( j = M; --j; p++ )
*p = p[M - N] ^ TWIST( p[0], p[1] );
*p = p[M - N] ^ TWIST( p[0], state[0] );
}
/*------------------------------------------------------------*/
static void setRndSeed( int seed )
{
if( seed == 0 )
init_genrand( time( NULL ) );
else
init_genrand( seed );
}
/* float number in range [0, 1) using the mersenne twister rng */
static float frand( )
{
unsigned long y;
if( --left == 0 )
next_state( );
y = *next++;
/* Tempering */
y ^= ( y >> 11 );
y ^= ( y << 7 ) & 0x9d2c5680UL;
y ^= ( y << 15 ) & 0xefc60000UL;
y ^= ( y >> 18 );
return ( float ) y / 4294967296.f;
}
/*------------------------------------------------------------*/
/* returns random unit vector */
static void randuvec( float v[3] )
{
float r;
v[2] = 2.f * frand( ) - 1.f;
if( ( r = 1.f - v[2] * v[2] ) > 0.f ) {
float a = (float)(6.283185307f * frand( ));
r = (float)sqrt( r );
v[0] = (float)(r * cos( a ));
v[1] = (float)(r * sin( a ));
} else
v[2] = 1.f;
}
static PyObject *Noise_random( PyObject * self )
{
return Py_BuildValue( "f", frand( ) );
}
static PyObject *Noise_randuvec( PyObject * self )
{
float v[3] = {0.0f, 0.0f, 0.0f};
randuvec( v );
return Py_BuildValue( "[fff]", v[0], v[1], v[2] );
}
/*---------------------------------------------------------------------*/
/* Random seed init. Only used for MT random() & randuvec() */
static PyObject *Noise_setRandomSeed( PyObject * self, PyObject * args )
{
int s;
if( !PyArg_ParseTuple( args, "i", &s ) )
return NULL;
setRndSeed( s );
Py_INCREF( Py_None );
return Py_None;
}
/*-------------------------------------------------------------------------*/
/* General noise */
static PyObject *Noise_noise( PyObject * self, PyObject * args )
{
float x, y, z;
int nb = 1;
if( !PyArg_ParseTuple( args, "(fff)|i", &x, &y, &z, &nb ) )
return NULL;
return PyFloat_FromDouble(
(double)(2.0 * BLI_gNoise( 1.0, x, y, z, 0, nb ) - 1.0) );
}
/*-------------------------------------------------------------------------*/
/* General Vector noise */
static void vNoise( float x, float y, float z, int nb, float v[3] )
{
/* Simply evaluate noise at 3 different positions */
v[0] = (float)(2.0 * BLI_gNoise( 1.f, x + 9.321f, y - 1.531f, z - 7.951f, 0,
nb ) - 1.0);
v[1] = (float)(2.0 * BLI_gNoise( 1.f, x, y, z, 0, nb ) - 1.0);
v[2] = (float)(2.0 * BLI_gNoise( 1.f, x + 6.327f, y + 0.1671f, z - 2.672f, 0,
nb ) - 1.0);
}
static PyObject *Noise_vNoise( PyObject * self, PyObject * args )
{
float x, y, z, v[3];
int nb = 1;
if( !PyArg_ParseTuple( args, "(fff)|i", &x, &y, &z, &nb ) )
return NULL;
vNoise( x, y, z, nb, v );
return Py_BuildValue( "[fff]", v[0], v[1], v[2] );
}
/*---------------------------------------------------------------------------*/
/* General turbulence */
static float turb( float x, float y, float z, int oct, int hard, int nb,
float ampscale, float freqscale )
{
float amp, out, t;
int i;
amp = 1.f;
out = (float)(2.0 * BLI_gNoise( 1.f, x, y, z, 0, nb ) - 1.0);
if( hard )
out = (float)fabs( out );
for( i = 1; i < oct; i++ ) {
amp *= ampscale;
x *= freqscale;
y *= freqscale;
z *= freqscale;
t = (float)(amp * ( 2.0 * BLI_gNoise( 1.f, x, y, z, 0, nb ) - 1.0 ));
if( hard )
t = (float)fabs( t );
out += t;
}
return out;
}
static PyObject *Noise_turbulence( PyObject * self, PyObject * args )
{
float x, y, z;
int oct, hd, nb = 1;
float as = 0.5, fs = 2.0;
if( !PyArg_ParseTuple
( args, "(fff)ii|iff", &x, &y, &z, &oct, &hd, &nb, &as, &fs ) )
return NULL;
return PyFloat_FromDouble( (double)turb( x, y, z, oct, hd, nb, as, fs ) );
}
/*--------------------------------------------------------------------------*/
/* Turbulence Vector */
static void vTurb( float x, float y, float z, int oct, int hard, int nb,
float ampscale, float freqscale, float v[3] )
{
float amp, t[3];
int i;
amp = 1.f;
vNoise( x, y, z, nb, v );
if( hard ) {
v[0] = (float)fabs( v[0] );
v[1] = (float)fabs( v[1] );
v[2] = (float)fabs( v[2] );
}
for( i = 1; i < oct; i++ ) {
amp *= ampscale;
x *= freqscale;
y *= freqscale;
z *= freqscale;
vNoise( x, y, z, nb, t );
if( hard ) {
t[0] = (float)fabs( t[0] );
t[1] = (float)fabs( t[1] );
t[2] = (float)fabs( t[2] );
}
v[0] += amp * t[0];
v[1] += amp * t[1];
v[2] += amp * t[2];
}
}
static PyObject *Noise_vTurbulence( PyObject * self, PyObject * args )
{
float x, y, z, v[3];
int oct, hd, nb = 1;
float as = 0.5, fs = 2.0;
if( !PyArg_ParseTuple
( args, "(fff)ii|iff", &x, &y, &z, &oct, &hd, &nb, &as, &fs ) )
return NULL;
vTurb( x, y, z, oct, hd, nb, as, fs, v );
return Py_BuildValue( "[fff]", v[0], v[1], v[2] );
}
/*---------------------------------------------------------------------*/
/* F. Kenton Musgrave's fractal functions */
static PyObject *Noise_fBm( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct;
int nb = 1;
if( !PyArg_ParseTuple
( args, "(fff)fff|i", &x, &y, &z, &H, &lac, &oct, &nb ) )
return NULL;
return PyFloat_FromDouble( (double)mg_fBm( x, y, z, H, lac, oct, nb ) );
}
/*------------------------------------------------------------------------*/
static PyObject *Noise_multiFractal( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct;
int nb = 1;
if( !PyArg_ParseTuple
( args, "(fff)fff|i", &x, &y, &z, &H, &lac, &oct, &nb ) )
return NULL;
return PyFloat_FromDouble( (double)mg_MultiFractal( x, y, z, H, lac, oct, nb ) );
}
/*------------------------------------------------------------------------*/
static PyObject *Noise_vlNoise( PyObject * self, PyObject * args )
{
float x, y, z, d;
int nt1 = 1, nt2 = 1;
if( !PyArg_ParseTuple
( args, "(fff)f|ii", &x, &y, &z, &d, &nt1, &nt2 ) )
return NULL;
return PyFloat_FromDouble( (double)mg_VLNoise( x, y, z, d, nt1, nt2 ) );
}
/*-------------------------------------------------------------------------*/
static PyObject *Noise_heteroTerrain( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct, ofs;
int nb = 1;
if( !PyArg_ParseTuple
( args, "(fff)ffff|i", &x, &y, &z, &H, &lac, &oct, &ofs, &nb ) )
return NULL;
return PyFloat_FromDouble(
(double)mg_HeteroTerrain( x, y, z, H, lac, oct, ofs, nb ) );
}
/*-------------------------------------------------------------------------*/
static PyObject *Noise_hybridMFractal( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct, ofs, gn;
int nb = 1;
if( !PyArg_ParseTuple
( args, "(fff)fffff|i", &x, &y, &z, &H, &lac, &oct, &ofs, &gn,
&nb ) )
return NULL;
return PyFloat_FromDouble(
(double)mg_HybridMultiFractal( x, y, z, H, lac, oct, ofs, gn, nb) );
}
/*------------------------------------------------------------------------*/
static PyObject *Noise_ridgedMFractal( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct, ofs, gn;
int nb = 1;
if( !PyArg_ParseTuple
( args, "(fff)fffff|i", &x, &y, &z, &H, &lac, &oct, &ofs, &gn,
&nb ) )
return NULL;
return PyFloat_FromDouble(
(double)mg_RidgedMultiFractal( x, y, z, H, lac, oct, ofs, gn, nb) );
}
/*-------------------------------------------------------------------------*/
static PyObject *Noise_voronoi( PyObject * self, PyObject * args )
{
float x, y, z, da[4], pa[12];
int dtype = 0;
float me = 2.5; /* default minkovsky exponent */
if( !PyArg_ParseTuple( args, "(fff)|if", &x, &y, &z, &dtype, &me ) )
return NULL;
voronoi( x, y, z, da, pa, me, dtype );
return Py_BuildValue( "[[ffff][[fff][fff][fff][fff]]]",
da[0], da[1], da[2], da[3],
pa[0], pa[1], pa[2],
pa[3], pa[4], pa[5],
pa[6], pa[7], pa[8], pa[9], pa[10], pa[11] );
}
/*-------------------------------------------------------------------------*/
static PyObject *Noise_cellNoise( PyObject * self, PyObject * args )
{
float x, y, z;
if( !PyArg_ParseTuple( args, "(fff)", &x, &y, &z ) )
return NULL;
return Py_BuildValue( "f", cellNoise( x, y, z ) );
}
/*--------------------------------------------------------------------------*/
static PyObject *Noise_cellNoiseV( PyObject * self, PyObject * args )
{
float x, y, z, ca[3];
if( !PyArg_ParseTuple( args, "(fff)", &x, &y, &z ) )
return NULL;
cellNoiseV( x, y, z, ca );
return Py_BuildValue( "[fff]", ca[0], ca[1], ca[2] );
}
/*--------------------------------------------------------------------------*/
/* For all other Blender modules, this stuff seems to be put in a header file.
This doesn't seem really appropriate to me, so I just put it here, feel free to change it.
In the original module I actually kept the docs stings with the functions themselves,
but I grouped them here so that it can easily be moved to a header if anyone thinks that is necessary. */
static char random__doc__[] = "() No arguments.\n\n\
Returns a random floating point number in the range [0, 1)";
static char randuvec__doc__[] =
"() No arguments.\n\nReturns a random unit vector (3-float list).";
static char setRandomSeed__doc__[] = "(seed value)\n\n\
Initializes random number generator.\n\
if seed is zero, the current time will be used instead.";
static char noise__doc__[] = "((x,y,z) tuple, [noisetype])\n\n\
Returns general noise of the optional specified type.\n\
Optional argument noisetype determines the type of noise, STDPERLIN by default, see NoiseTypes.";
static char vNoise__doc__[] = "((x,y,z) tuple, [noisetype])\n\n\
Returns noise vector (3-float list) of the optional specified type.\
Optional argument noisetype determines the type of noise, STDPERLIN by default, see NoiseTypes.";
static char turbulence__doc__[] =
"((x,y,z) tuple, octaves, hard, [noisebasis], [ampscale], [freqscale])\n\n\
Returns general turbulence value using the optional specified noisebasis function.\n\
octaves (integer) is the number of noise values added.\n\
hard (bool), when false (0) returns 'soft' noise, when true (1) returns 'hard' noise (returned value always positive).\n\
Optional arguments:\n\
noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.\n\
ampscale sets the amplitude scale value of the noise frequencies added, 0.5 by default.\n\
freqscale sets the frequency scale factor, 2.0 by default.";
static char vTurbulence__doc__[] =
"((x,y,z) tuple, octaves, hard, [noisebasis], [ampscale], [freqscale])\n\n\
Returns general turbulence vector (3-float list) using the optional specified noisebasis function.\n\
octaves (integer) is the number of noise values added.\n\
hard (bool), when false (0) returns 'soft' noise, when true (1) returns 'hard' noise (returned vector always positive).\n\
Optional arguments:\n\
noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.\n\
ampscale sets the amplitude scale value of the noise frequencies added, 0.5 by default.\n\
freqscale sets the frequency scale factor, 2.0 by default.";
static char fBm__doc__[] =
"((x,y,z) tuple, H, lacunarity, octaves, [noisebasis])\n\n\
Returns Fractal Brownian Motion noise value(fBm).\n\
H is the fractal increment parameter.\n\
lacunarity is the gap between successive frequencies.\n\
octaves is the number of frequencies in the fBm.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
static char multiFractal__doc__[] =
"((x,y,z) tuple, H, lacunarity, octaves, [noisebasis])\n\n\
Returns Multifractal noise value.\n\
H determines the highest fractal dimension.\n\
lacunarity is gap between successive frequencies.\n\
octaves is the number of frequencies in the fBm.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
static char vlNoise__doc__[] =
"((x,y,z) tuple, distortion, [noisetype1], [noisetype2])\n\n\
Returns Variable Lacunarity Noise value, a distorted variety of noise.\n\
distortion sets the amount of distortion.\n\
Optional arguments noisetype1 and noisetype2 set the noisetype to distort and the noisetype used for the distortion respectively.\n\
See NoiseTypes, both are STDPERLIN by default.";
static char heteroTerrain__doc__[] =
"((x,y,z) tuple, H, lacunarity, octaves, offset, [noisebasis])\n\n\
returns Heterogeneous Terrain value\n\
H determines the fractal dimension of the roughest areas.\n\
lacunarity is the gap between successive frequencies.\n\
octaves is the number of frequencies in the fBm.\n\
offset raises the terrain from 'sea level'.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
static char hybridMFractal__doc__[] =
"((x,y,z) tuple, H, lacunarity, octaves, offset, gain, [noisebasis])\n\n\
returns Hybrid Multifractal value.\n\
H determines the fractal dimension of the roughest areas.\n\
lacunarity is the gap between successive frequencies.\n\
octaves is the number of frequencies in the fBm.\n\
offset raises the terrain from 'sea level'.\n\
gain scales the values.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
static char ridgedMFractal__doc__[] =
"((x,y,z) tuple, H, lacunarity, octaves, offset, gain [noisebasis])\n\n\
returns Ridged Multifractal value.\n\
H determines the fractal dimension of the roughest areas.\n\
lacunarity is the gap between successive frequencies.\n\
octaves is the number of frequencies in the fBm.\n\
offset raises the terrain from 'sea level'.\n\
gain scales the values.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
static char voronoi__doc__[] =
"((x,y,z) tuple, distance_metric, [exponent])\n\n\
returns a list, containing a list of distances in order of closest feature,\n\
and a list containing the positions of the four closest features\n\
Optional arguments:\n\
distance_metric: see DistanceMetrics, default is DISTANCE\n\
exponent is only used with MINKOVSKY, default is 2.5.";
static char cellNoise__doc__[] = "((x,y,z) tuple)\n\n\
returns cellnoise float value.";
static char cellNoiseV__doc__[] = "((x,y,z) tuple)\n\n\
returns cellnoise vector/point/color (3-float list).";
static char Noise__doc__[] = "Blender Noise and Turbulence Module\n\n\
This module can be used to generate noise of various types.\n\
This can be used for terrain generation, to create textures,\n\
make animations more 'animated', object deformation, etc.\n\
As an example, this code segment when scriptlinked to a framechanged event,\n\
will make the camera sway randomly about, by changing parameters this can\n\
look like anything from an earthquake to a very nervous or maybe even drunk cameraman...\n\
(the camera needs an ipo with at least one Loc & Rot key for this to work!):\n\
\n\
\tfrom Blender import Get, Scene, Noise\n\
\n\
\t####################################################\n\
\t# This controls jitter speed\n\
\tsl = 0.025\n\
\t# This controls the amount of position jitter\n\
\tsp = 0.1\n\
\t# This controls the amount of rotation jitter\n\
\tsr = 0.25\n\
\t####################################################\n\
\n\
\ttime = Get('curtime')\n\
\tob = Scene.GetCurrent().getCurrentCamera()\n\
\tps = (sl*time, sl*time, sl*time)\n\
\t# To add jitter only when the camera moves, use this next line instead\n\
\t#ps = (sl*ob.LocX, sl*ob.LocY, sl*ob.LocZ)\n\
\trv = Noise.vTurbulence(ps, 3, 0, Noise.NoiseTypes.NEWPERLIN)\n\
\tob.dloc = (sp*rv[0], sp*rv[1], sp*rv[2])\n\
\tob.drot = (sr*rv[0], sr*rv[1], sr*rv[2])\n\
\n";
/* Just in case, declarations for a header file */
/*
static PyObject *Noise_random(PyObject *self);
static PyObject *Noise_randuvec(PyObject *self);
static PyObject *Noise_setRandomSeed(PyObject *self, PyObject *args);
static PyObject *Noise_noise(PyObject *self, PyObject *args);
static PyObject *Noise_vNoise(PyObject *self, PyObject *args);
static PyObject *Noise_turbulence(PyObject *self, PyObject *args);
static PyObject *Noise_vTurbulence(PyObject *self, PyObject *args);
static PyObject *Noise_fBm(PyObject *self, PyObject *args);
static PyObject *Noise_multiFractal(PyObject *self, PyObject *args);
static PyObject *Noise_vlNoise(PyObject *self, PyObject *args);
static PyObject *Noise_heteroTerrain(PyObject *self, PyObject *args);
static PyObject *Noise_hybridMFractal(PyObject *self, PyObject *args);
static PyObject *Noise_ridgedMFractal(PyObject *self, PyObject *args);
static PyObject *Noise_voronoi(PyObject *self, PyObject *args);
static PyObject *Noise_cellNoise(PyObject *self, PyObject *args);
static PyObject *Noise_cellNoiseV(PyObject *self, PyObject *args);
*/
static PyMethodDef NoiseMethods[] = {
{"setRandomSeed", ( PyCFunction ) Noise_setRandomSeed, METH_VARARGS,
setRandomSeed__doc__},
{"random", ( PyCFunction ) Noise_random, METH_NOARGS, random__doc__},
{"randuvec", ( PyCFunction ) Noise_randuvec, METH_NOARGS,
randuvec__doc__},
{"noise", ( PyCFunction ) Noise_noise, METH_VARARGS, noise__doc__},
{"vNoise", ( PyCFunction ) Noise_vNoise, METH_VARARGS, vNoise__doc__},
{"turbulence", ( PyCFunction ) Noise_turbulence, METH_VARARGS,
turbulence__doc__},
{"vTurbulence", ( PyCFunction ) Noise_vTurbulence, METH_VARARGS,
vTurbulence__doc__},
{"fBm", ( PyCFunction ) Noise_fBm, METH_VARARGS, fBm__doc__},
{"multiFractal", ( PyCFunction ) Noise_multiFractal, METH_VARARGS,
multiFractal__doc__},
{"vlNoise", ( PyCFunction ) Noise_vlNoise, METH_VARARGS,
vlNoise__doc__},
{"heteroTerrain", ( PyCFunction ) Noise_heteroTerrain, METH_VARARGS,
heteroTerrain__doc__},
{"hybridMFractal", ( PyCFunction ) Noise_hybridMFractal, METH_VARARGS,
hybridMFractal__doc__},
{"ridgedMFractal", ( PyCFunction ) Noise_ridgedMFractal, METH_VARARGS,
ridgedMFractal__doc__},
{"voronoi", ( PyCFunction ) Noise_voronoi, METH_VARARGS,
voronoi__doc__},
{"cellNoise", ( PyCFunction ) Noise_cellNoise, METH_VARARGS,
cellNoise__doc__},
{"cellNoiseV", ( PyCFunction ) Noise_cellNoiseV, METH_VARARGS,
cellNoiseV__doc__},
{NULL, NULL, 0, NULL}
};
/*----------------------------------------------------------------------*/
PyObject *Noise_Init(void)
{
PyObject *NoiseTypes, *DistanceMetrics,
*md =
Py_InitModule3( "Blender.Noise", NoiseMethods, Noise__doc__ );
/* use current time as seed for random number generator by default */
setRndSeed( 0 );
/* Constant noisetype dictionary */
NoiseTypes = PyConstant_New( );
if( NoiseTypes ) {
BPy_constant *nt = ( BPy_constant * ) NoiseTypes;
PyConstant_Insert( nt, "BLENDER",
PyInt_FromLong( TEX_BLENDER ) );
PyConstant_Insert( nt, "STDPERLIN",
PyInt_FromLong( TEX_STDPERLIN ) );
PyConstant_Insert( nt, "NEWPERLIN",
PyInt_FromLong( TEX_NEWPERLIN ) );
PyConstant_Insert( nt, "VORONOI_F1",
PyInt_FromLong( TEX_VORONOI_F1 ) );
PyConstant_Insert( nt, "VORONOI_F2",
PyInt_FromLong( TEX_VORONOI_F2 ) );
PyConstant_Insert( nt, "VORONOI_F3",
PyInt_FromLong( TEX_VORONOI_F3 ) );
PyConstant_Insert( nt, "VORONOI_F4",
PyInt_FromLong( TEX_VORONOI_F4 ) );
PyConstant_Insert( nt, "VORONOI_F2F1",
PyInt_FromLong( TEX_VORONOI_F2F1 ) );
PyConstant_Insert( nt, "VORONOI_CRACKLE",
PyInt_FromLong( TEX_VORONOI_CRACKLE ) );
PyConstant_Insert( nt, "CELLNOISE",
PyInt_FromLong( TEX_CELLNOISE ) );
PyModule_AddObject( md, "NoiseTypes", NoiseTypes );
}
/* Constant distance metric dictionary for voronoi */
DistanceMetrics = PyConstant_New( );
if( DistanceMetrics ) {
BPy_constant *dm = ( BPy_constant * ) DistanceMetrics;
PyConstant_Insert( dm, "DISTANCE",
PyInt_FromLong( TEX_DISTANCE ) );
PyConstant_Insert( dm, "DISTANCE_SQUARED",
PyInt_FromLong( TEX_DISTANCE_SQUARED ) );
PyConstant_Insert( dm, "MANHATTAN",
PyInt_FromLong( TEX_MANHATTAN ) );
PyConstant_Insert( dm, "CHEBYCHEV",
PyInt_FromLong( TEX_CHEBYCHEV ) );
PyConstant_Insert( dm, "MINKOVSKY_HALF",
PyInt_FromLong( TEX_MINKOVSKY_HALF ) );
PyConstant_Insert( dm, "MINKOVSKY_FOUR",
PyInt_FromLong( TEX_MINKOVSKY_FOUR ) );
PyConstant_Insert( dm, "MINKOVSKY",
PyInt_FromLong( TEX_MINKOVSKY ) );
PyModule_AddObject( md, "DistanceMetrics", DistanceMetrics );
}
return md;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,62 +0,0 @@
/*
* $Id: Object.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Michel Selten
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_OBJECT_H
#define EXPP_OBJECT_H
#include <Python.h>
#include "DNA_object_types.h"
/* The Object PyType Object defined in Object.c */
extern PyTypeObject Object_Type;
#define BPy_Object_Check(v) \
((v)->ob_type == &Object_Type) /* for type checking */
/*****************************************************************************/
/* Python BPy_Object structure definition. */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
struct Object *object; /* libdata must be second */
short realtype;
} BPy_Object;
PyObject *Object_Init( void );
PyObject *Object_CreatePyObject( struct Object *obj );
Object *Object_FromPyObject( PyObject * py_obj );
void Object_updateDag( void *data );
int EXPP_add_obdata( struct Object *object );
#endif /* EXPP_OBJECT_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,67 +0,0 @@
/*
* $Id: Particle.h 5702 2005-11-04 20:34:38Z khughes $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Jacques Guignot
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_PARTICLE_H
#define EXPP_PARTICLE_H
#include <Python.h>
#include "DNA_effect_types.h"
extern PyTypeObject Particle_Type;
#define BPy_Particle_Check(v) ((v)->ob_type==&Particle_Type)
/* Python BPy_Particle structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
Effect * particle;
} BPy_Particle;
#include "Effect.h"
/*****************************************************************************/
/* Python Particle_Type callback function prototypes: */
/*****************************************************************************/
#if 0
void ParticleDeAlloc( BPy_Particle * msh );
//int ParticlePrint (BPy_Particle *msh, FILE *fp, int flags);
int ParticleSetAttr( BPy_Particle * msh, char *name, PyObject * v );
PyObject *ParticleGetAttr( BPy_Particle * msh, char *name );
PyObject *ParticleRepr( void );
PyObject *ParticleCreatePyObject( struct Effect *particle );
int ParticleCheckPyObject( PyObject * py_obj );
struct Particle *ParticleFromPyObject( PyObject * py_obj );
#endif
#endif /* EXPP_PARTICLE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,71 +0,0 @@
/*
* $Id:
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* Contributor(s): Joseph Gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_POSE_H
#define EXPP_POSE_H
#include <Python.h>
#include "DNA_action_types.h"
#include "DNA_object_types.h"
//-------------------TYPE CHECKS---------------------------------
#define BPy_Pose_Check(v) ((v)->ob_type == &Pose_Type)
#define BPy_PoseBone_Check(v) ((v)->ob_type == &PoseBone_Type)
#define BPy_PoseBonesDict_Check(v) ((v)->ob_type == &PoseBonesDict_Type)
//-------------------TYPEOBJECT----------------------------------
extern PyTypeObject Pose_Type;
extern PyTypeObject PoseBone_Type;
extern PyTypeObject PoseBonesDict_Type;
//-------------------STRUCT DEFINITION----------------------------
typedef struct {
PyObject_HEAD
PyObject *bonesMap;
ListBase *bones;
} BPy_PoseBonesDict;
typedef struct {
PyObject_HEAD
bPose *pose;
char name[24]; //because poses have not names :(
BPy_PoseBonesDict *Bones;
} BPy_Pose;
typedef struct {
PyObject_HEAD
bPoseChannel *posechannel;
} BPy_PoseBone;
//-------------------VISIBLE PROTOTYPES-------------------------
PyObject *Pose_Init(void);
PyObject *PyPose_FromPose(bPose *pose, char *name);
PyObject *PyPoseBone_FromPosechannel(bPoseChannel *pchan);
Object *Object_FromPoseChannel(bPoseChannel *curr_pchan);
#endif

View File

@@ -1,245 +0,0 @@
/*
* $Id: Registry.c 4803 2005-07-18 03:50:37Z ascotan $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Registry.h" /*This must come first */
#include "BKE_global.h"
#include "gen_utils.h"
/* the Registry dictionary */
PyObject *bpy_registryDict = NULL;
/*****************************************************************************/
/* Python API function prototypes for the Registry module. */
/*****************************************************************************/
static PyObject *M_Registry_Keys( PyObject * self );
static PyObject *M_Registry_GetKey( PyObject * self, PyObject * args );
static PyObject *M_Registry_SetKey( PyObject * self, PyObject * args );
static PyObject *M_Registry_RemoveKey( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Registry.__doc__ */
/*****************************************************************************/
char M_Registry_doc[] =
"The Blender Registry module (persistent data cache)\n\n\
Use this module to store configuration data that a script can reload\n\
when it is executed again.\n";
char M_Registry_Keys_doc[] =
"() - Get all keys in the Registry dictionary.\n\n\
Each key references another dict with saved data from a specific script.\n";
char M_Registry_GetKey_doc[] =
"(name, disk = False) - Get an entry (a dict) from the Registry dictionary\n\
(name) - a string that references a specific script;\n\
(disk = False) - search on the user (if available) or default scripts config\n\
data dir.\n";
char M_Registry_SetKey_doc[] =
"(key, dict, disk = False) - Store an entry in the Registry dictionary.\n\
If an entry with the same 'key' already exists, it is substituted.\n\
(key) - the string to use as a key for the dict being saved.\n\
(dict) - a dictionary with the data to be stored.\n\
(disk = False) - also write data as a config file inside the user (if\n\
available) or default scripts config data dir.\n";
char M_Registry_RemoveKey_doc[] =
"(key, disk = False) - Remove the dict with key 'key' from the Registry.\n\
(key) - the name of the key to delete;\n\
(disk = False) - if True the respective config file is also deleted.\n";
/*****************************************************************************/
/* Python method structure definition for Blender.Registry module: */
/*****************************************************************************/
struct PyMethodDef M_Registry_methods[] = {
{"Keys", ( PyCFunction ) M_Registry_Keys, METH_VARARGS,
M_Registry_Keys_doc},
{"GetKey", M_Registry_GetKey, METH_VARARGS, M_Registry_GetKey_doc},
{"SetKey", M_Registry_SetKey, METH_VARARGS, M_Registry_SetKey_doc},
{"RemoveKey", M_Registry_RemoveKey, METH_VARARGS,
M_Registry_RemoveKey_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Function: M_Registry_Keys */
/* Python equivalent: Blender.Registry.Keys */
/*****************************************************************************/
PyObject *M_Registry_Keys( PyObject * self )
{
PyObject *pydict = NULL;
if( !bpy_registryDict )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"No Registry dictionary found!" );
pydict = PyDict_Keys( bpy_registryDict );
if( !pydict )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Registry_Keys: couldn't get keys" );
return pydict;
}
/*****************************************************************************/
/* Function: M_Registry_GetKey */
/* Python equivalent: Blender.Registry.GetKey */
/*****************************************************************************/
static PyObject *M_Registry_GetKey( PyObject * self, PyObject * args )
{
PyObject *pyentry = NULL;
PyObject *pydict = NULL;
int disk = 0;
if( !bpy_registryDict )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"No Registry dictionary found!" );
if( !PyArg_ParseTuple( args, "O!|i", &PyString_Type, &pyentry, &disk ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected a string and optionally a bool" );
pydict = PyDict_GetItem( bpy_registryDict, pyentry ); /* borrowed ... */
if (!pydict) {
if (disk > 0) {
/* try to get data from disk */
char buf[256];
PyOS_snprintf(buf, sizeof(buf),
"import Blender, BPyRegistry; BPyRegistry.LoadConfigData('%s')",
PyString_AsString(pyentry));
if (!PyRun_SimpleString(buf))
pydict = PyDict_GetItem(bpy_registryDict, pyentry);
else PyErr_Clear();
}
if (!pydict) /* no need to return a KeyError, since without doubt */
pydict = Py_None; /* Py_None means no key (all valid keys are dicts) */
}
return EXPP_incr_ret (pydict); /* ... so we incref it */
}
/*****************************************************************************/
/* Function: M_Registry_SetKey */
/* Python equivalent: Blender.Registry.SetKey */
/*****************************************************************************/
static PyObject *M_Registry_SetKey( PyObject * self, PyObject * args )
{
PyObject *pystr = NULL;
PyObject *pydict = NULL;
int disk = 0;
if( !bpy_registryDict )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"No Registry dictionary found!" );
if( !PyArg_ParseTuple( args, "O!O!|i",
&PyString_Type, &pystr, &PyDict_Type,
&pydict, &disk ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected a string and a dictionary" );
if( PyDict_SetItem( bpy_registryDict, pystr, pydict ) ) /* 0 on success */
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Registry_SetKey: couldn't update the Registry dict" );
if (disk) {
/* try to save data to disk */
char buf[256];
PyOS_snprintf(buf, sizeof(buf),
"import Blender, BPyRegistry; BPyRegistry.SaveConfigData('%s')",
PyString_AsString(pystr));
if (PyRun_SimpleString(buf) != 0) {
PyErr_Clear();
if (G.f & G_DEBUG)
fprintf(stderr, "\nCan't save script configuration data!\n");
}
}
Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
/* Function: M_Registry_RemoveKey */
/* Python equivalent: Blender.Registry.RemoveKey */
/*****************************************************************************/
static PyObject *M_Registry_RemoveKey( PyObject * self, PyObject * args )
{
PyObject *pystr = NULL;
int disk = 0;
if( !bpy_registryDict )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"No Registry dictionary found!" );
if( !PyArg_ParseTuple( args, "O!|i", &PyString_Type, &pystr, &disk ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected a string and optionally a bool" );
if( PyDict_DelItem( bpy_registryDict, pystr ) ) /* returns 0 on success */
return EXPP_ReturnPyObjError( PyExc_KeyError,
"no such key in the Registry" );
else if (disk) {
/* try to delete from disk too */
char buf[256];
PyOS_snprintf(buf, sizeof(buf),
"import Blender, BPyRegistry; BPyRegistry.RemoveConfigData('%s')",
PyString_AsString(pystr));
if (PyRun_SimpleString(buf) != 0) {
PyErr_Clear();
if (G.f & G_DEBUG)
fprintf(stderr, "\nCan't remove script configuration data file!\n");
}
}
Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
/* Function: Registry_Init */
/*****************************************************************************/
PyObject *Registry_Init( void )
{
PyObject *submodule;
submodule = Py_InitModule3( "Blender.Registry", M_Registry_methods,
M_Registry_doc );
return submodule;
}

View File

@@ -1,50 +0,0 @@
/*
* $Id: Registry.h 3209 2004-10-07 19:25:40Z stiv $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/* This submodule was introduced as a way to preserve configured data in
* scripts. A very simple idea: the script writer saves this data in a dict
* and registers this dict in the "Registry" dict. This way we can discard
* the global interpreter dictionary after a script is executed, since the
* data meant to be kept was copied to the Registry elsewhere. The current
* implementation is naive: scripts can deliberately mess with data saved by
* other scripts. This is so new script versions can delete older entries, if
* they need to. XXX Or should we block this? */
#ifndef EXPP_REGISTRY_H
#define EXPP_REGISTRY_H
#include <Python.h>
extern PyObject *bpy_registryDict;
PyObject *Registry_Init( void );
#endif /* EXPP_REGISTRY_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,70 +0,0 @@
/*
* $Id: Scene.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_SCENE_H
#define EXPP_SCENE_H
#include <Python.h>
#include "DNA_scene_types.h"
/* The Scene PyType Object defined in Scene.c */
extern PyTypeObject Scene_Type;
extern PyTypeObject SceneObSeq_Type;
#define BPy_Scene_Check(v) \
((v)->ob_type == &Scene_Type)
#define BPy_SceneObSeq_Check(v) \
((v)->ob_type == &SceneObSeq_Type)
/*---------------------------Python BPy_Scene structure definition----------*/
typedef struct {
PyObject_HEAD
Scene * scene; /* libdata must be second */
} BPy_Scene;
/*---------------------------Python BPy_Scene visible prototypes-----------*/
/* Python Scene_Type helper functions needed by Blender (the Init function) and Object modules. */
/* Scene object sequence, iterate on the scene object listbase*/
typedef struct {
PyObject_VAR_HEAD /* required python macro */
BPy_Scene *bpyscene; /* link to the python scene so we can know if its been removed */
Base *iter; /* so we can iterate over the objects */
int mode; /*0:all objects, 1:selected objects, 2:user context*/
} BPy_SceneObSeq;
PyObject *Scene_Init( void );
PyObject *Scene_CreatePyObject( Scene * scene );
/*Scene *Scene_FromPyObject( PyObject * pyobj );*/ /* not used yet */
#endif /* EXPP_SCENE_H */

View File

@@ -1,607 +0,0 @@
/*
* $Id: Sound.c 11123 2007-06-29 08:59:26Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Chris Keith
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Sound.h" /*This must come first*/
#include "BKE_global.h"
#include "BKE_main.h"
#include "BLI_blenlib.h"
#include "BKE_sound.h"
#include "BKE_library.h"
#include "BIF_editsound.h"
#include "BKE_packedFile.h"
#include "mydevice.h" /* redraw defines */
#include "gen_utils.h"
#include "gen_library.h"
#include "DNA_space_types.h" /* for FILE_MAXDIR only */
/*****************************************************************************/
/* Python BPy_Sound defaults: */
/*****************************************************************************/
#define EXPP_SND_volume_MIN 0.0
#define EXPP_SND_volume_MAX 1.0
#define EXPP_SND_pitch_MIN -12.0
#define EXPP_SND_pitch_MAX 12.0
#define EXPP_SND_attenuation_MIN 0.0
#define EXPP_SND_attenuation_MAX 5.0
/*****************************************************************************/
/* Python API function prototypes for the Sound module. */
/*****************************************************************************/
static PyObject *M_Sound_Get( PyObject * self, PyObject * args );
static PyObject *M_Sound_Load( PyObject * self, PyObject * value );
/************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Sound.__doc__ */
/************************************************************************/
static char M_Sound_doc[] = "The Blender Sound module\n\n";
static char M_Sound_Get_doc[] =
"(name) - return the sound with the name 'name', \
returns None if not found.\n If 'name' is not specified, \
it returns a list of all sounds in the\ncurrent scene.";
static char M_Sound_Load_doc[] =
"(filename) - return sound from file filename as a Sound Object,\n\
returns None if not found.";
/*****************************************************************************/
/* Python method structure definition for Blender.Sound module: */
/*****************************************************************************/
struct PyMethodDef M_Sound_methods[] = {
{"Get", M_Sound_Get, METH_VARARGS, M_Sound_Get_doc},
{"Load", M_Sound_Load, METH_O, M_Sound_Load_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python Sound_Type callback function prototypes: */
/*****************************************************************************/
static int Sound_compare( BPy_Sound * a, BPy_Sound * b );
static PyObject *Sound_repr( BPy_Sound * self );
#define SOUND_FLOAT_METHODS(funcname, varname) \
static PyObject *Sound_get ## funcname(BPy_Sound *self) { \
return PyFloat_FromDouble(self->sound->varname); \
} \
static PyObject *Sound_set ## funcname(BPy_Sound *self, PyObject *args) { \
float f = 0; \
if (!PyArg_ParseTuple(args, "f", &f)) \
return (EXPP_ReturnPyObjError (PyExc_TypeError, \
"expected float argument")); \
self->sound->varname = EXPP_ClampFloat(f, \
EXPP_SND_##varname##_MIN, EXPP_SND_##varname##_MAX); \
Py_RETURN_NONE; \
}
#define SOUND_FLOAT_METHOD_FUNCS(varname) \
{"get"#varname, (PyCFunction)Sound_get ## varname, METH_NOARGS, \
"() - Return Sound object "#varname}, \
{"set"#varname, (PyCFunction)Sound_set ## varname, METH_VARARGS, \
"(float) - Change Sound object "#varname},
/*****************************************************************************/
/* Python BPy_Sound methods declarations: */
/*****************************************************************************/
static PyObject *Sound_getName( BPy_Sound * self );
static PyObject *Sound_getFilename( BPy_Sound * self );
static PyObject *Sound_setName( BPy_Sound * self, PyObject * args );
static int Sound_setFilename( BPy_Sound * self, PyObject * args );
static PyObject *Sound_oldsetFilename( BPy_Sound * self, PyObject * args );
static PyObject *Sound_setCurrent( BPy_Sound * self );
static PyObject *Sound_play( BPy_Sound * self );
static PyObject *Sound_unpack( BPy_Sound * self, PyObject * args);
static PyObject *Sound_pack( BPy_Sound * self );
/*static PyObject *Sound_reload ( BPy_Sound * self );*/
SOUND_FLOAT_METHODS( Volume, volume )
SOUND_FLOAT_METHODS( Attenuation, attenuation )
SOUND_FLOAT_METHODS( Pitch, pitch )
/* these can't be set via interface, removed for now */
/*
SOUND_FLOAT_METHODS( Panning, panning )
SOUND_FLOAT_METHODS( MinGain, min_gain )
SOUND_FLOAT_METHODS( MaxGain, max_gain )
SOUND_FLOAT_METHODS( Distance, distance )
*/
/*****************************************************************************/
/* Python BPy_Sound methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Sound_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) Sound_getName, METH_NOARGS,
"() - Return Sound object name"},
{"getFilename", ( PyCFunction ) Sound_getFilename, METH_NOARGS,
"() - Return Sound object filename"},
{"setName", ( PyCFunction ) Sound_setName, METH_VARARGS,
"(name) - Set Sound object name"},
{"setFilename", ( PyCFunction ) Sound_oldsetFilename, METH_VARARGS,
"(filename) - Set Sound object filename"},
{"setCurrent", ( PyCFunction ) Sound_setCurrent, METH_NOARGS,
"() - make this the active sound in the sound buttons win (also redraws)"},
{"play", ( PyCFunction ) Sound_play, METH_NOARGS,
"() - play this sound"},
{"unpack", ( PyCFunction ) Sound_unpack, METH_VARARGS,
"(int) - Unpack sound. Uses one of the values defined in Blender.UnpackModes."},
{"pack", ( PyCFunction ) Sound_pack, METH_NOARGS,
"() Pack the sound"},
/*
{"reload", ( PyCFunction ) Sound_setCurrent, METH_NOARGS,
"() - reload this Sound object's sample.\n\
This is only useful if the original sound file has changed."},
*/
SOUND_FLOAT_METHOD_FUNCS( Volume )
SOUND_FLOAT_METHOD_FUNCS( Attenuation )
SOUND_FLOAT_METHOD_FUNCS( Pitch )
/*
SOUND_FLOAT_METHOD_FUNCS( Panning )
SOUND_FLOAT_METHOD_FUNCS( MinGain )
SOUND_FLOAT_METHOD_FUNCS( MaxGain )
SOUND_FLOAT_METHOD_FUNCS( Distance )
*/
{NULL, NULL, 0, NULL}
};
/* NOTE: these were copied and modified from image.h. To Be Done TBD:
* macro-ize them, or C++ templates eventually?
*/
/****************************************************************************/
/* Function: M_Sound_Get */
/* Python equivalent: Blender.Sound.Get */
/* Description: Receives a string and returns the Sound object */
/* whose name matches the string. If no argument is */
/* passed in, a list of all Sound names in the */
/* current scene is returned. */
/****************************************************************************/
static PyObject *M_Sound_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
bSound *snd_iter;
if( !PyArg_ParseTuple( args, "|s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument (or nothing)" ) );
snd_iter = G.main->sound.first;
if( name ) { /* (name) - Search Sound by name */
BPy_Sound *wanted_Sound = NULL;
while( ( snd_iter ) && ( wanted_Sound == NULL ) ) {
if( strcmp( name, snd_iter->id.name + 2 ) == 0 ) {
wanted_Sound =
( BPy_Sound * )
PyObject_NEW( BPy_Sound, &Sound_Type );
if( wanted_Sound ) {
wanted_Sound->sound = snd_iter;
break;
}
}
snd_iter = snd_iter->id.next;
}
if( wanted_Sound == NULL ) { /* Requested Sound doesn't exist */
char error_msg[64];
PyOS_snprintf( error_msg, sizeof( error_msg ),
"Sound \"%s\" not found", name );
return ( EXPP_ReturnPyObjError
( PyExc_NameError, error_msg ) );
}
return ( PyObject * ) wanted_Sound;
}
else { /* () - return a list of all Sounds in the scene */
int index = 0;
PyObject *snd_list, *pyobj;
snd_list = PyList_New( BLI_countlist( &( G.main->sound ) ) );
if( snd_list == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyList" ) );
while( snd_iter ) {
pyobj = Sound_CreatePyObject( snd_iter );
if( !pyobj ) {
Py_DECREF(snd_list);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create PyObject" ) );
}
PyList_SET_ITEM( snd_list, index, pyobj );
snd_iter = snd_iter->id.next;
index++;
}
return ( snd_list );
}
}
/*****************************************************************************/
/* Function: M_Sound_Load */
/* Python equivalent: Blender.Sound.Load */
/* Description: Receives a string and returns the Sound object */
/* whose filename matches the string. */
/*****************************************************************************/
static PyObject *M_Sound_Load( PyObject * self, PyObject * value )
{
char *fname = PyString_AsString(value);
bSound *snd_ptr;
BPy_Sound *snd;
if( !fname )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" ) );
snd = ( BPy_Sound * ) PyObject_NEW( BPy_Sound, &Sound_Type );
if( !snd )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyObject Sound_Type" ) );
snd_ptr = sound_new_sound( fname );
if( snd_ptr ) {
if( G.ssound ) {
G.ssound->sound = snd_ptr;
}
}
if( !snd_ptr )
return ( EXPP_ReturnPyObjError( PyExc_IOError,
"not a valid sound sample" ) );
snd->sound = snd_ptr;
return ( PyObject * ) snd;
}
/*****************************************************************************/
/* Function: Sound_Init */
/*****************************************************************************/
PyObject *Sound_Init( void )
{
PyObject *submodule;
if( PyType_Ready( &Sound_Type ) < 0 )
return NULL;
submodule =
Py_InitModule3( "Blender.Sound", M_Sound_methods,
M_Sound_doc );
return ( submodule );
}
/************************/
/*** The Sound PyType ***/
/************************/
/*****************************************************************************/
/* Function: Sound_CreatePyObject */
/* Description: This function will create a new BPy_Sound from an existing */
/* Blender Sound structure. */
/*****************************************************************************/
PyObject *Sound_CreatePyObject( bSound * snd )
{
BPy_Sound *py_snd;
py_snd = ( BPy_Sound * ) PyObject_NEW( BPy_Sound, &Sound_Type );
if( !py_snd )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create BPy_Sound object" );
py_snd->sound = snd;
return ( PyObject * ) py_snd;
}
/*****************************************************************************/
/* Function: Sound_FromPyObject */
/* Description: Returns the Blender Sound associated with this object */
/*****************************************************************************/
bSound *Sound_FromPyObject( PyObject * pyobj )
{
return ( ( BPy_Sound * ) pyobj )->sound;
}
/*****************************************************************************/
/* Python BPy_Sound methods: */
/*****************************************************************************/
static PyObject *Sound_getName( BPy_Sound * self )
{
return PyString_FromString( self->sound->id.name + 2 );
}
static PyObject *Sound_getFilename( BPy_Sound * self )
{
return PyString_FromString( self->sound->name );
}
static PyObject *Sound_getPacked( BPy_Sound * self )
{
if (!sound_sample_is_null(self->sound)) {
bSample *sample = sound_find_sample(self->sound);
if (sample->packedfile)
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
static PyObject *Sound_setName( BPy_Sound * self, PyObject * args )
{
char *name;
if( !PyArg_ParseTuple( args, "s", &name ) ) {
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected a String as argument" ) );
}
rename_id( &self->sound->id, name );
Py_RETURN_NONE;
}
static int Sound_setFilename( BPy_Sound * self, PyObject * value )
{
char *name;
/* max len is FILE_MAXDIR = 160 chars like in DNA_image_types.h */
name = PyString_AsString(value);
if (!name || strlen(name) > FILE_MAXDIR)
return ( EXPP_ReturnIntError( PyExc_ValueError,
"string argument is limited to 160 chars at most" ) );
strcpy( self->sound->name, name );
return 0;
}
static PyObject *Sound_oldsetFilename( BPy_Sound * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Sound_setFilename );
}
static PyObject *Sound_play( BPy_Sound * self )
{
sound_play_sound( self->sound );
Py_RETURN_NONE;
}
static PyObject *Sound_setCurrent( BPy_Sound * self )
{
bSound *snd_ptr = self->sound;
if( snd_ptr ) {
if( G.ssound ) {
G.ssound->sound = snd_ptr;
}
}
EXPP_allqueue( REDRAWSOUND, 0 );
EXPP_allqueue( REDRAWBUTSLOGIC, 0 );
Py_RETURN_NONE;
}
/* unpack sound */
static PyObject *Sound_unpack( BPy_Sound * self, PyObject * args )
{
bSound *sound = self->sound;
int mode;
if( !PyArg_ParseTuple( args, "i", &mode ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected an integer from Blender.UnpackModes" );
if (!sound_sample_is_null(sound)) {
bSample *sample = sound_find_sample(sound);
if (sample->packedfile) {
if (unpackSample(sample, mode) == RET_ERROR)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"error unpacking sound");
}
} else {
return EXPP_ReturnPyObjError( PyExc_RuntimeError, "sound has no samples" );
}
Py_RETURN_NONE;
}
/* pack sound */
static PyObject *Sound_pack( BPy_Sound * self )
{
bSound *sound = self->sound;
if (!sound_sample_is_null(sound))
{
bSample *sample = sound_find_sample(sound);
if (sample->packedfile )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"sound alredy packed" );
sound_set_packedfile(sample, newPackedFile(sample->name));
}
else
{
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"sound has no samples" );
}
Py_RETURN_NONE;
}
/*
static PyObject *Sound_reload( BPy_Sound * self)
{
sound_free_sample();
if (sound->snd_sound) {
SND_RemoveSound(ghSoundScene, sound->snd_sound);
sound->snd_sound = NULL;
}
Py_RETURN_NONE;
}
*/
/*****************************************************************************/
/* Function: Sound_compare */
/* Description: This is a callback function for the BPy_Sound type. It */
/* compares two Sound_Type objects. Only the "==" and "!=" */
/* comparisons are meaninful. Returns 0 for equality and -1 if */
/* they don't point to the same Blender Sound struct. */
/* In Python it becomes 1 if they are equal, 0 otherwise. */
/*****************************************************************************/
static int Sound_compare( BPy_Sound * a, BPy_Sound * b )
{
return ( a->sound == b->sound ) ? 0 : -1;
}
/*****************************************************************************/
/* Function: Sound_repr */
/* Description: This is a callback function for the BPy_Sound type. It */
/* builds a meaninful string to represent Sound objects. */
/*****************************************************************************/
static PyObject *Sound_repr( BPy_Sound * self )
{
return PyString_FromFormat( "[Sound \"%s\"]",
self->sound->id.name + 2 );
}
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Sound_getseters[] = {
GENERIC_LIB_GETSETATTR,
{"filename", (getter)Sound_getFilename, (setter)Sound_setFilename,
"text filename", NULL},
{"packed", (getter)Sound_getPacked, (setter)NULL,
"text filename", NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
/*****************************************************************************/
/* Python Sound_Type structure definition: */
/*****************************************************************************/
PyTypeObject Sound_Type = {
PyObject_HEAD_INIT( NULL )
0, /* ob_size */
"Blender Sound", /* tp_name */
sizeof( BPy_Sound ), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
NULL, /* tp_dealloc */
0, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
( cmpfunc ) Sound_compare, /* tp_compare */
( reprfunc ) Sound_repr, /* tp_repr */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
( hashfunc ) GenericLib_hash, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_Sound_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_Sound_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};

View File

@@ -1,57 +0,0 @@
/*
* $Id: Sound.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Chris Keith
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_SOUND_H
#define EXPP_SOUND_H
#include <Python.h>
#include "DNA_sound_types.h"
#define BPy_Sound_Check(v) ((v)->ob_type == &Sound_Type)
extern PyTypeObject Sound_Type;
/*****************************************************************************/
/* Python BPy_Sound structure definition */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
bSound * sound;
} BPy_Sound;
/*****************************************************************************/
/* Module Blender.Sound - public functions */
/*****************************************************************************/
PyObject *Sound_Init( void );
PyObject *Sound_CreatePyObject( bSound * sound );
bSound *Sound_FromPyObject( PyObject * pyobj );
#endif /* EXPP_SOUND_H */

View File

@@ -1,857 +0,0 @@
/*
* $Id: SurfNurb.c 11400 2007-07-28 09:26:53Z campbellbarton $
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Stephen Swaney
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "SurfNurb.h" /*This must come first */
#include "BKE_curve.h"
#include "BDR_editcurve.h" /* for convertspline */
#include "MEM_guardedalloc.h"
#include "gen_utils.h"
#include "gen_library.h"
#include "BezTriple.h"
/*
* forward declarations go here
*/
static int SurfNurb_setPoint( BPy_SurfNurb * self, int index, PyObject * ob );
static int SurfNurb_length( PyInstanceObject * inst );
static PyObject *SurfNurb_getIter( BPy_SurfNurb * self );
static PyObject *SurfNurb_iterNext( BPy_SurfNurb * self );
PyObject *SurfNurb_append( BPy_SurfNurb * self, PyObject * args );
char M_SurfNurb_doc[] = "SurfNurb";
/*
table of module methods
these are the equivalent of class or static methods.
you do not need an object instance to call one.
*/
static PyMethodDef M_SurfNurb_methods[] = {
/* name, method, flags, doc_string */
/* {"Get", (PyCFunction) M_SurfNurb_method, METH_NOARGS, " () - doc string"}, */
/* {"method", (PyCFunction) M_SurfNurb_method, METH_NOARGS, " () - doc string"}, */
{NULL, NULL, 0, NULL}
};
/*
* method table
* table of instance methods
* these methods are invoked on an instance of the type.
*/
static PyMethodDef BPy_SurfNurb_methods[] = {
# if 0
{"append", ( PyCFunction ) SurfNurb_append, METH_VARARGS,
"( point ) - add a new point. arg is BezTriple or list of x,y,z,w floats"},
#endif
{NULL, NULL, 0, NULL}
};
/*
* SurfNurb_appendPointToNurb
* this is a non-bpy utility func to add a point to a given nurb.
* notice the first arg is Nurb*.
*/
#if 0
static PyObject *SurfNurb_appendPointToNurb( Nurb * nurb, PyObject * args )
{
int i;
int size;
PyObject *pyOb;
int npoints = nurb->pntsu;
/*
do we have a list of four floats or a BezTriple?
*/
if( !PyArg_ParseTuple( args, "O", &pyOb ))
return EXPP_ReturnPyObjError
( PyExc_RuntimeError,
"Internal error parsing arguments" );
/* if curve is empty, adjust type depending on input type */
if (nurb->bezt==NULL && nurb->bp==NULL) {
if (BPy_BezTriple_Check( pyOb ))
nurb->type |= CU_BEZIER;
else if (PySequence_Check( pyOb ))
nurb->type |= CU_NURBS;
else
return( EXPP_ReturnPyObjError( PyExc_TypeError,
"Expected a BezTriple or a Sequence of 4 (or 5) floats" ) );
}
if ((nurb->type & 7)==CU_BEZIER) {
BezTriple *tmp;
if( !BPy_BezTriple_Check( pyOb ) )
return( EXPP_ReturnPyObjError( PyExc_TypeError,
"Expected a BezTriple\n" ) );
/* printf("\ndbg: got a BezTriple\n"); */
tmp = nurb->bezt; /* save old points */
nurb->bezt =
( BezTriple * ) MEM_mallocN( sizeof( BezTriple ) *
( npoints + 1 ),
"SurfNurb_append2" );
if( !nurb->bezt )
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError, "allocation failed" ) );
/* copy old points to new */
if( tmp ) {
memmove( nurb->bezt, tmp, sizeof( BezTriple ) * npoints );
MEM_freeN( tmp );
}
nurb->pntsu++;
/* add new point to end of list */
memcpy( nurb->bezt + npoints,
BezTriple_FromPyObject( pyOb ), sizeof( BezTriple ) );
}
else if( PySequence_Check( pyOb ) ) {
size = PySequence_Size( pyOb );
/* printf("\ndbg: got a sequence of size %d\n", size ); */
if( size == 4 || size == 5 ) {
BPoint *tmp;
tmp = nurb->bp; /* save old pts */
nurb->bp =
( BPoint * ) MEM_mallocN( sizeof( BPoint ) *
( npoints + 1 ),
"SurfNurb_append1" );
if( !nurb->bp )
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"allocation failed" ) );
memmove( nurb->bp, tmp, sizeof( BPoint ) * npoints );
if( tmp )
MEM_freeN( tmp );
++nurb->pntsu;
/* initialize new BPoint from old */
memcpy( nurb->bp + npoints, nurb->bp,
sizeof( BPoint ) );
for( i = 0; i < 4; ++i ) {
PyObject *item = PySequence_GetItem( pyOb, i );
if (item == NULL)
return NULL;
nurb->bp[npoints].vec[i] = ( float ) PyFloat_AsDouble( item );
Py_DECREF( item );
}
if (size == 5) {
PyObject *item = PySequence_GetItem( pyOb, i );
if (item == NULL)
return NULL;
nurb->bp[npoints].alfa = ( float ) PyFloat_AsDouble( item );
Py_DECREF( item );
}
else {
nurb->bp[npoints].alfa = 0.0f;
}
makeknots( nurb, 1, nurb->flagu >> 1 );
} else {
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a sequence of 4 or 5 floats" );
}
} else {
/* bail with error */
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a sequence of 4 or 5 floats" );
}
return ( EXPP_incr_ret( Py_None ) );
}
/*
* SurfNurb_append( point )
* append a new point to a nurb curve.
* arg is BezTriple or list of xyzw floats
*/
PyObject *SurfNurb_append( BPy_SurfNurb * self, PyObject * args )
{
Nurb *nurb = self->nurb;
return SurfNurb_appendPointToNurb( nurb, args );
}
#endif
#if 0
/*
* SurfNurb_getMatIndex
*
* returns index into material list
*/
static PyObject *SurfNurb_getMatIndex( BPy_SurfNurb * self )
{
return PyInt_FromLong( ( long ) self->nurb->mat_nr );
}
/*
* SurfNurb_setMatIndex
*
* set index into material list
*/
static int SurfNurb_setMatIndex( BPy_SurfNurb * self, PyObject * args )
{
args = PyNumber_Int( args );
if( !args )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected integer argument" );
/* fixme: some range checking would be nice! */
/* can't do range checking without knowing the "parent" curve! */
self->nurb->mat_nr = ( short )PyInt_AS_LONG( args );
Py_DECREF( args );
return 0;
}
#endif
/*
* SurfNurb_getPointsU
*
* returns number of control points in U direction
*/
static PyObject *SurfNurb_getPointsU( BPy_SurfNurb * self )
{
return PyInt_FromLong( ( long ) self->nurb->pntsu );
}
/*
* SurfNurb_getPointsV
*
* returns number of control points in V direction
*/
static PyObject *SurfNurb_getPointsV( BPy_SurfNurb * self )
{
return PyInt_FromLong( ( long ) self->nurb->pntsv );
}
/*
* SurfNurb_getFlagU
*
* returns curve's flagu
*/
static PyObject *SurfNurb_getFlagU( BPy_SurfNurb * self )
{
return PyInt_FromLong( ( long ) (self->nurb->flagu >> 1) );
}
/*
* SurfNurb_setFlagU
*
* set curve's flagu and recalculate the knots
*
* Possible values: 0 - uniform, 2 - endpoints, 4 - bezier
* bit 0 controls CU_CYCLIC
*/
static int SurfNurb_setFlagU( BPy_SurfNurb * self, PyObject * args )
{
int flagu;
args = PyNumber_Int( args );
if( !args )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected integer argument" );
flagu = ( int )PyInt_AS_LONG( args );
Py_DECREF( args );
if( flagu < 0 || flagu > 2 )
return EXPP_ReturnIntError( PyExc_AttributeError,
"expected integer argument in range [0,2]" );
flagu = (flagu << 1) | (self->nurb->flagu & CU_CYCLIC);
if( self->nurb->flagu != flagu ) {
self->nurb->flagu = (short)flagu;
makeknots( self->nurb, 1, self->nurb->flagu >> 1 );
}
return 0;
}
/*
* SurfNurb_getFlagV
*
* returns curve's flagu
*/
static PyObject *SurfNurb_getFlagV( BPy_SurfNurb * self )
{
return PyInt_FromLong( ( long ) (self->nurb->flagv >> 1) );
}
/*
* SurfNurb_setFlagV
*
* set curve's flagu and recalculate the knots
*
* Possible values: 0 - uniform, 1 - endpoints, 2 - bezier
*/
static int SurfNurb_setFlagV( BPy_SurfNurb * self, PyObject * args )
{
int flagv;
args = PyNumber_Int( args );
if( !args )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected integer argument" );
flagv = ( int )PyInt_AS_LONG( args );
Py_DECREF( args );
if( flagv < 0 || flagv > 2 )
return EXPP_ReturnIntError( PyExc_AttributeError,
"expected integer argument in range [0,2]" );
flagv = (flagv << 1) | (self->nurb->flagv & CU_CYCLIC);
if( self->nurb->flagv != flagv ) {
self->nurb->flagv = (short)flagv;
makeknots( self->nurb, 2, self->nurb->flagv >> 1 );
}
return 0;
}
/*
* SurfNurb_getOrder
*
* returns curve's order
*/
static PyObject *SurfNurb_getOrderU( BPy_SurfNurb * self )
{
return PyInt_FromLong( ( long ) self->nurb->orderu );
}
static int SurfNurb_setOrderU( BPy_SurfNurb * self, PyObject * args )
{
int order;
args = PyNumber_Int( args );
if( !args )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected integer argument" );
order = ( int )PyInt_AS_LONG( args );
Py_DECREF( args );
if( order < 2 ) order = 2;
else if( order > 6 ) order = 6;
if( self->nurb->pntsu < order )
order = self->nurb->pntsu;
self->nurb->orderu = (short)order;
makeknots( self->nurb, 1, self->nurb->flagu >> 1 );
return 0;
}
static PyObject *SurfNurb_getOrderV( BPy_SurfNurb * self )
{
return PyInt_FromLong( ( long ) self->nurb->orderv );
}
static int SurfNurb_setOrderV( BPy_SurfNurb * self, PyObject * args )
{
int order;
args = PyNumber_Int( args );
if( !args )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected integer argument" );
order = ( int )PyInt_AS_LONG( args );
Py_DECREF( args );
if( order < 2 ) order = 2;
else if( order > 6 ) order = 6;
if( self->nurb->pntsv < order )
order = self->nurb->pntsv;
self->nurb->orderv = (short)order;
makeknots( self->nurb, 2, self->nurb->flagv >> 1 );
return 0;
}
/*
* SurfNurb_getCyclic()
* test whether surface is cyclic (closed) or not (open)
*/
static PyObject *SurfNurb_getCyclicU( BPy_SurfNurb * self )
{
if( self->nurb->flagu & CU_CYCLIC )
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static PyObject *SurfNurb_getCyclicV( BPy_SurfNurb * self )
{
if( self->nurb->flagv & CU_CYCLIC )
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int SurfNurb_setCyclicU( BPy_SurfNurb * self, PyObject * value )
{
int param = PyObject_IsTrue( value );
if( param == -1 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected True/False or 0/1" );
if( param )
self->nurb->flagu |= CU_CYCLIC;
else
self->nurb->flagu &= ~CU_CYCLIC;
makeknots( self->nurb, 1, self->nurb->flagu >> 1 );
return 0;
}
static int SurfNurb_setCyclicV( BPy_SurfNurb * self, PyObject * value )
{
int param = PyObject_IsTrue( value );
if( param == -1 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected True/False or 0/1" );
if( param )
self->nurb->flagv |= CU_CYCLIC;
else
self->nurb->flagv &= ~CU_CYCLIC;
makeknots( self->nurb, 2, self->nurb->flagu >> 1 );
return 0;
}
/*
* SurfNurb_getIter
*
* create an iterator for our SurfNurb.
* this iterator returns the points for this SurfNurb.
*/
static PyObject *SurfNurb_getIter( BPy_SurfNurb * self )
{
self->bp = self->nurb->bp;
self->bezt = self->nurb->bezt;
self->nextPoint = 0;
Py_INCREF( self );
return ( PyObject * ) self;
}
static PyObject *SurfNurb_iterNext( BPy_SurfNurb * self )
{
Nurb *pnurb = self->nurb;
int npoints = pnurb->pntsu * pnurb->pntsv;
if( self->bp && self->nextPoint < npoints )
return SurfNurb_pointAtIndex( self->nurb, self->nextPoint++ );
else
return EXPP_ReturnPyObjError( PyExc_StopIteration,
"iterator at end" );
}
/*
* SurfNurb_length
* returns the number of points in a Nurb
* this is a tp_as_sequence method, not a regular instance method.
*/
static int SurfNurb_length( PyInstanceObject * inst )
{
Nurb *nurb;
if( BPy_SurfNurb_Check( ( PyObject * ) inst ) ) {
nurb = ( ( BPy_SurfNurb * ) inst )->nurb;
return (int)(nurb->pntsu * nurb->pntsu);
}
return EXPP_ReturnIntError( PyExc_RuntimeError,
"arg is not a BPy_SurfNurb" );
}
/*
* SurfNurb_getPoint
* returns the Nth point in a Nurb
* this is one of the tp_as_sequence methods, hence the int N argument.
* it is called via the [] operator, not as a usual instance method.
*/
PyObject *SurfNurb_getPoint( BPy_SurfNurb * self, int index )
{
Nurb *myNurb;
int npoints;
/* for convenince */
myNurb = self->nurb;
npoints = myNurb->pntsu * myNurb->pntsv;
/* bail if no Nurbs in Curve */
if( npoints == 0 )
return ( EXPP_ReturnPyObjError( PyExc_IndexError,
"no points in this SurfNurb" ) );
/* check index limits */
if( index >= npoints || index < 0 )
return ( EXPP_ReturnPyObjError( PyExc_IndexError,
"index out of range" ) );
return SurfNurb_pointAtIndex( myNurb, index );
}
/*
* SurfNurb_setPoint
* modifies the Nth point in a Nurb
* this is one of the tp_as_sequence methods, hence the int N argument.
* it is called via the [] = operator, not as a usual instance method.
*/
static int SurfNurb_setPoint( BPy_SurfNurb * self, int index, PyObject * pyOb )
{
Nurb *nurb = self->nurb;
int size;
/* check index limits */
if( index < 0 || index >= nurb->pntsu * nurb->pntsv )
return EXPP_ReturnIntError( PyExc_IndexError,
"array assignment index out of range\n" );
/* branch by curve type */
#if 0
if ((nurb->type & 7)==CU_BEZIER) { /* BEZIER */
/* check parameter type */
if( !BPy_BezTriple_Check( pyOb ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a BezTriple\n" );
/* copy bezier in array */
memcpy( nurb->bezt + index,
BezTriple_FromPyObject( pyOb ), sizeof( BezTriple ) );
return 0; /* finished correctly */
}
else
#endif
{ /* NURBS or POLY */
int i;
/* check parameter type */
if (!PySequence_Check( pyOb ))
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a list of 4 (or optionaly 5 if the curve is 3D) floats\n" );
size = PySequence_Size( pyOb );
/* check sequence size */
if( size != 4 && size != 5 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a list of 4 (or optionaly 5 if the curve is 3D) floats\n" );
/* copy x, y, z, w */
for( i = 0; i < 4; ++i ) {
PyObject *item = PySequence_GetItem( pyOb, i );
if (item == NULL)
return -1;
nurb->bp[index].vec[i] = ( float ) PyFloat_AsDouble( item );
Py_DECREF( item );
}
if (size == 5) { /* set tilt, if present */
PyObject *item = PySequence_GetItem( pyOb, i );
if (item == NULL)
return -1;
nurb->bp[index].alfa = ( float ) PyFloat_AsDouble( item );
Py_DECREF( item );
}
else { /* if not, set default */
nurb->bp[index].alfa = 0.0f;
}
return 0; /* finished correctly */
}
}
/*
* this is an internal routine. not callable directly from python
*/
PyObject *SurfNurb_pointAtIndex( Nurb * nurb, int index )
{
PyObject *pyo;
if( nurb->bp ) { /* we have a nurb curve */
int i;
/* add Tilt only if curve is 3D */
if (nurb->flag & CU_3D)
pyo = PyList_New( 5 );
else
pyo = PyList_New( 4 );
for( i = 0; i < 4; i++ ) {
PyList_SetItem( pyo, i,
PyFloat_FromDouble( nurb->bp[index].
vec[i] ) );
}
/* add Tilt only if curve is 3D */
if (nurb->flag & CU_3D)
PyList_SetItem( pyo, 4, PyFloat_FromDouble( nurb->bp[index].alfa ) );
return pyo;
} else /* something is horribly wrong */
return EXPP_ReturnPyObjError( PyExc_SystemError,
"non-NURB surface found" );
}
/*
* methods for SurfNurb as sequence
*/
static PySequenceMethods SurfNurb_as_sequence = {
( inquiry ) SurfNurb_length, /* sq_length */
( binaryfunc ) 0, /* sq_concat */
( intargfunc ) 0, /* sq_repeat */
( intargfunc ) SurfNurb_getPoint, /* sq_item */
( intintargfunc ) 0, /* sq_slice */
( intobjargproc ) SurfNurb_setPoint, /* sq_ass_item */
0, /* sq_ass_slice */
( objobjproc ) 0, /* sq_contains */
0,
0
};
static PyGetSetDef BPy_SurfNurb_getseters[] = {
#if 0
{"matIndex",
(getter)SurfNurb_getMatIndex, (setter)SurfNurb_setMatIndex,
"material index", NULL},
#endif
{"pointsU",
(getter)SurfNurb_getPointsU, (setter)NULL,
"number of control points in U direction", NULL},
{"pointsV",
(getter)SurfNurb_getPointsV, (setter)NULL,
"number of control points in V direction", NULL},
{"flagU",
(getter)SurfNurb_getFlagU, (setter)SurfNurb_setFlagU,
"knot flag for U direction", NULL},
{"flagV",
(getter)SurfNurb_getFlagV, (setter)SurfNurb_setFlagV,
"knot flag for V direction", NULL},
{"cyclicU",
(getter)SurfNurb_getCyclicU, (setter)SurfNurb_setCyclicU,
"cyclic setting for U direction", NULL},
{"cyclicV",
(getter)SurfNurb_getCyclicV, (setter)SurfNurb_setCyclicV,
"cyclic setting for V direction", NULL},
{"orderU",
(getter)SurfNurb_getOrderU, (setter)SurfNurb_setOrderU,
"order setting for U direction", NULL},
{"orderV",
(getter)SurfNurb_getOrderV, (setter)SurfNurb_setOrderV,
"order setting for V direction", NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
/*
* compare
* in this case, we consider two SurfNurbs equal, if they point to the same
* blender data.
*/
static int SurfNurb_compare( BPy_SurfNurb * a, BPy_SurfNurb * b )
{
return ( a->nurb == b->nurb ) ? 0 : -1;
}
/*
* SurfNurb_repr
*/
static PyObject *SurfNurb_repr( BPy_SurfNurb * self )
{
return PyString_FromFormat( "[SurfNurb \"%d\"]", self->nurb->type );
}
/*****************************************************************************/
/* Python SurfNurb_Type structure definition: */
/*****************************************************************************/
PyTypeObject SurfNurb_Type = {
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"SurfNurb", /* char *tp_name; */
sizeof( BPy_SurfNurb ), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
NULL, /* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
( cmpfunc ) SurfNurb_compare, /* cmpfunc tp_compare; */
( reprfunc ) SurfNurb_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
&SurfNurb_as_sequence, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
( getiterfunc ) SurfNurb_getIter, /* getiterfunc tp_iter; */
( iternextfunc ) SurfNurb_iterNext, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_SurfNurb_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_SurfNurb_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};
/*
factory method to create a BPy_SurfNurb from a Blender Nurb
*/
PyObject *SurfNurb_CreatePyObject( Nurb * blen_nurb )
{
BPy_SurfNurb *pyNurb;
pyNurb = ( BPy_SurfNurb * ) PyObject_NEW( BPy_SurfNurb, &SurfNurb_Type );
if( !pyNurb )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"could not create BPy_SurfNurb PyObject" );
pyNurb->nurb = blen_nurb;
return ( PyObject * ) pyNurb;
}
PyObject *SurfNurb_Init( void )
{
PyType_Ready( &SurfNurb_Type );
return Py_InitModule3( "Blender.SurfNurb", M_SurfNurb_methods,
M_SurfNurb_doc );
}

View File

@@ -1,68 +0,0 @@
/*
* $Id: SurfNurb.h 10269 2007-03-15 01:09:14Z campbellbarton $
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Stephen Swaney
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_SURFNURB_H
#define EXPP_SURFNURB_H
#include <Python.h>
#include "DNA_curve_types.h"
extern PyTypeObject SurfNurb_Type;
#define BPy_SurfNurb_Check(v) ((v)->ob_type == &SurfNurb_Type) /* for type checking */
/* Python BPy_SurfNurb structure definition */
typedef struct {
PyObject_HEAD
Nurb * nurb;
/* iterator stuff */
/* internal ptrs to point data. do not free */
BPoint *bp;
BezTriple *bezt;
int atEnd; /* iter exhausted flag */
int nextPoint;
} BPy_SurfNurb;
/*
* prototypes
*/
PyObject *SurfNurb_Init( void );
PyObject *SurfNurb_CreatePyObject( Nurb * bzt );
Nurb *SurfNurb_FromPyObject( PyObject * pyobj );
PyObject *SurfNurb_getPoint( BPy_SurfNurb * self, int index );
PyObject *SurfNurb_pointAtIndex( Nurb * nurb, int index );
#endif /* EXPP_SURFNURB_H */

View File

@@ -1,400 +0,0 @@
/*
* $Id: Sys.c 10945 2007-06-16 13:17:41Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano, Campbell Barton
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Sys.h" /*This must come first*/
#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BLI_blenlib.h"
#include "DNA_scene_types.h" /* G.scene-"r.cfra */
#include "PIL_time.h"
#include "gen_utils.h"
#ifdef WIN32
#define DIRSEP '\\'
#define DIRSEP_STR "\\"
#else
#define DIRSEP '/'
#define DIRSEP_STR "/"
#endif
/*****************************************************************************/
/* Python API function prototypes for the sys module. */
/*****************************************************************************/
static PyObject *M_sys_basename( PyObject * self, PyObject * value );
static PyObject *M_sys_dirname( PyObject * self, PyObject * value );
static PyObject *M_sys_join( PyObject * self, PyObject * args );
static PyObject *M_sys_splitext( PyObject * self, PyObject * value );
static PyObject *M_sys_makename( PyObject * self, PyObject * args,
PyObject * kw );
static PyObject *M_sys_exists( PyObject * self, PyObject * value );
static PyObject *M_sys_time( PyObject * self );
static PyObject *M_sys_sleep( PyObject * self, PyObject * args );
static PyObject *M_sys_expandpath( PyObject *self, PyObject *value);
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.sys.__doc__ */
/*****************************************************************************/
static char M_sys_doc[] = "The Blender.sys submodule\n\
\n\
This is a minimal system module to supply simple functionality available\n\
in the default Python module os.";
static char M_sys_basename_doc[] =
"(path) - Split 'path' in dir and filename.\n\
Return the filename.";
static char M_sys_dirname_doc[] =
"(path) - Split 'path' in dir and filename.\n\
Return the dir.";
static char M_sys_join_doc[] =
"(dir, file) - Join dir and file to form a full filename.\n\
Return the filename.";
static char M_sys_splitext_doc[] =
"(path) - Split 'path' in root and extension:\n\
/this/that/file.ext -> ('/this/that/file','.ext').\n\
Return the pair (root, extension).";
static char M_sys_makename_doc[] =
"(path = Blender.Get('filename'), ext = \"\", strip = 0) -\n\
Strip dir and extension from path, leaving only a name, then append 'ext'\n\
to it (if given) and return the resulting string.\n\n\
(path) - string: a pathname -- Blender.Get('filename') if 'path' isn't given;\n\
(ext = \"\") - string: the extension to append.\n\
(strip = 0) - int: strip dirname from 'path' if given and non-zero.\n\
Ex: makename('/path/to/file/myfile.foo','-01.abc') returns 'myfile-01.abc'\n\
Ex: makename(ext='.txt') returns 'untitled.txt' if Blender.Get('filename')\n\
returns a path to the file 'untitled.blend'";
static char M_sys_time_doc[] =
"() - Return a float representing time elapsed in seconds.\n\
Each successive call is garanteed to return values greater than or\n\
equal to the previous call.";
static char M_sys_sleep_doc[] =
"(milliseconds = 10) - Sleep for the specified time.\n\
(milliseconds = 10) - the amount of time in milliseconds to sleep.\n\
This function can be necessary in tight 'get event' loops.";
static char M_sys_exists_doc[] =
"(path) - Check if the given pathname exists.\n\
The return value is as follows:\n\
\t 0: path doesn't exist;\n\
\t 1: path is an existing filename;\n\
\t 2: path is an existing dirname;\n\
\t-1: path exists but is neither a regular file nor a dir.";
static char M_sys_expandpath_doc[] =
"(path) - Expand this Blender internal path to a proper file system path.\n\
(path) - the string path to convert.\n\n\
Note: internally Blender paths can contain two special character sequences:\n\
- '//' (at start) for base path directory (the current .blend's dir path);\n\
- '#' (at ending) for current frame number.\n\n\
This function expands these to their actual content, returning a valid path.\n\
If the special chars are not found in the given path, it is simply returned.";
/*****************************************************************************/
/* Python method structure definition for Blender.sys module: */
/*****************************************************************************/
struct PyMethodDef M_sys_methods[] = {
{"basename", M_sys_basename, METH_O, M_sys_basename_doc},
{"dirname", M_sys_dirname, METH_O, M_sys_dirname_doc},
{"join", M_sys_join, METH_VARARGS, M_sys_join_doc},
{"splitext", M_sys_splitext, METH_O, M_sys_splitext_doc},
{"makename", ( PyCFunction ) M_sys_makename,
METH_VARARGS | METH_KEYWORDS,
M_sys_makename_doc},
{"exists", M_sys_exists, METH_O, M_sys_exists_doc},
{"sleep", M_sys_sleep, METH_VARARGS, M_sys_sleep_doc},
{"time", ( PyCFunction ) M_sys_time, METH_NOARGS, M_sys_time_doc},
{"expandpath", M_sys_expandpath, METH_O, M_sys_expandpath_doc},
{NULL, NULL, 0, NULL}
};
/* Module Functions */
static PyObject *g_sysmodule = NULL; /* pointer to Blender.sys module */
PyObject *sys_Init( void )
{
PyObject *submodule, *dict;
submodule = Py_InitModule3( "Blender.sys", M_sys_methods, M_sys_doc );
g_sysmodule = submodule;
dict = PyModule_GetDict( submodule );
EXPP_dict_set_item_str( dict, "dirsep", PyString_FromString(DIRSEP_STR) );
EXPP_dict_set_item_str( dict, "sep", PyString_FromString(DIRSEP_STR) );
return submodule;
}
static PyObject *M_sys_basename( PyObject * self, PyObject * value )
{
char *name = PyString_AsString(value);
char *p, basename[FILE_MAXDIR + FILE_MAXFILE];
int n, len;
if( !name )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
len = strlen( name );
#ifdef WIN32
p = MAX2(strrchr( name, '/' ), strrchr( name, '\\' ));
#else
p = strrchr( name, DIRSEP );
#endif
if( p ) {
n = name + len - p - 1; /* - 1 because we don't want the sep */
if( n > FILE_MAXDIR + FILE_MAXFILE )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"path too long" );
BLI_strncpy( basename, p + 1, n + 1 );
return PyString_FromString( basename );
}
return PyString_FromString( name );
}
static PyObject *M_sys_dirname( PyObject * self, PyObject * value )
{
char *name = PyString_AsString(value);
char *p, dirname[FILE_MAXDIR + FILE_MAXFILE];
int n;
if( !name )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
#ifdef WIN32
p = MAX2(strrchr( name, '/' ), strrchr( name, '\\' ));
#else
p = strrchr( name, DIRSEP );
#endif
if( p ) {
n = p - name;
if( n > FILE_MAXDIR + FILE_MAXFILE )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"path too long" );
BLI_strncpy( dirname, name, n + 1 );
return PyString_FromString( dirname );
}
return PyString_FromString( "." );
}
static PyObject *M_sys_join( PyObject * self, PyObject * args )
{
char *name = NULL, *path = NULL;
char filename[FILE_MAXDIR + FILE_MAXFILE];
int pathlen = 0, namelen = 0;
if( !PyArg_ParseTuple( args, "ss", &path, &name ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
pathlen = strlen( path ) + 1;
namelen = strlen( name ) + 1; /* + 1 to account for '\0' for BLI_strncpy */
if( pathlen + namelen > FILE_MAXDIR + FILE_MAXFILE - 1 )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"filename is too long." );
BLI_strncpy( filename, path, pathlen );
if( filename[pathlen - 2] != DIRSEP ) {
filename[pathlen - 1] = DIRSEP;
pathlen += 1;
}
BLI_strncpy( filename + pathlen - 1, name, namelen );
return PyString_FromString( filename );
}
static PyObject *M_sys_splitext( PyObject * self, PyObject * value )
{
char *name = PyString_AsString(value);
char *dot, *p, path[FILE_MAXDIR + FILE_MAXFILE], ext[FILE_MAXDIR + FILE_MAXFILE];
int n, len;
if( !name )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
len = strlen( name );
dot = strrchr( name, '.' );
if( !dot )
return Py_BuildValue( "ss", name, "" );
p = strrchr( name, DIRSEP );
if( p ) {
if( p > dot )
return Py_BuildValue( "ss", name, "" );
}
n = name + len - dot;
/* loong extensions are supported -- foolish, but Python's os.path.splitext
* supports them, so ... */
if( n >= FILE_MAXDIR + FILE_MAXFILE || ( len - n ) >= FILE_MAXDIR + FILE_MAXFILE )
return EXPP_ReturnPyObjError( PyExc_RuntimeError, "path too long" );
BLI_strncpy( ext, dot, n + 1 );
BLI_strncpy( path, name, dot - name + 1 );
return Py_BuildValue( "ss", path, ext );
}
static PyObject *M_sys_makename( PyObject * self, PyObject * args,
PyObject * kw )
{
char *path = G.sce, *ext = NULL;
int strip = 0;
static char *kwlist[] = { "path", "ext", "strip", NULL };
char *dot = NULL, *p = NULL, basename[FILE_MAXDIR + FILE_MAXFILE];
int n, len, lenext = 0;
if( !PyArg_ParseTupleAndKeywords( args, kw, "|ssi", kwlist,
&path, &ext, &strip ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected one or two strings and an int (or nothing) as arguments" );
len = strlen( path ) + 1; /* + 1 to consider ending '\0' */
if( ext )
lenext = strlen( ext ) + 1;
if( ( len + lenext ) > FILE_MAXDIR + FILE_MAXFILE )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"path too long" );
p = strrchr( path, DIRSEP );
if( p && strip ) {
n = path + len - p;
BLI_strncpy( basename, p + 1, n ); /* + 1 to skip the sep */
} else
BLI_strncpy( basename, path, len );
dot = strrchr( basename, '.' );
/* now the extension: always remove the one in basename */
if( dot || ext ) {
if( !ext )
basename[dot - basename] = '\0';
else { /* if user gave an ext, append it */
if( dot )
n = dot - basename;
else
n = strlen( basename );
BLI_strncpy( basename + n, ext, lenext );
}
}
return PyString_FromString( basename );
}
static PyObject *M_sys_time( PyObject * self )
{
return PyFloat_FromDouble( PIL_check_seconds_timer( ) );
}
static PyObject *M_sys_sleep( PyObject * self, PyObject * args )
{
int millisecs = 10;
if( !PyArg_ParseTuple( args, "|i", &millisecs ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int argument" );
PIL_sleep_ms( millisecs );
return EXPP_incr_ret( Py_None );
}
static PyObject *M_sys_exists( PyObject * self, PyObject * value )
{
char *fname = PyString_AsString(value);
int mode = 0, i = -1;
if( !fname )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string (pathname) argument" );
mode = BLI_exist(fname);
if( mode == 0 )
i = 0;
else if( S_ISREG( mode ) )
i = 1;
else if( S_ISDIR( mode ) )
i = 2;
/* i stays as -1 if path exists but is neither a regular file nor a dir */
return PyInt_FromLong(i);
}
static PyObject *M_sys_expandpath( PyObject * self, PyObject * value )
{
char *path = PyString_AsString(value);
char expanded[FILE_MAXDIR + FILE_MAXFILE];
if (!path)
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
BLI_strncpy(expanded, path, FILE_MAXDIR + FILE_MAXFILE);
BLI_convertstringcode(expanded, G.sce, G.scene->r.cfra);
return PyString_FromString(expanded);
}

View File

@@ -1,40 +0,0 @@
/*
* $Id: Sys.h 4803 2005-07-18 03:50:37Z ascotan $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_sys_H
#define EXPP_sys_H
#include <Python.h>
PyObject *sys_Init( void );
#endif /* EXPP_sys_H */

View File

@@ -1,576 +0,0 @@
/*
* $Id: Text.c 11123 2007-06-29 08:59:26Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Text.h" /*This must come first*/
#include "BKE_library.h"
#include "BKE_sca.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BIF_drawtext.h"
#include "BKE_text.h"
#include "BLI_blenlib.h"
#include "DNA_space_types.h"
#include "gen_utils.h"
#include "gen_library.h"
#include "../BPY_extern.h"
#define EXPP_TEXT_MODE_FOLLOW TXT_FOLLOW
/*****************************************************************************/
/* Python API function prototypes for the Text module. */
/*****************************************************************************/
static PyObject *M_Text_New( PyObject * self, PyObject * args);
static PyObject *M_Text_Get( PyObject * self, PyObject * args );
static PyObject *M_Text_Load( PyObject * self, PyObject * value );
static PyObject *M_Text_unlink( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Text.__doc__ */
/*****************************************************************************/
static char M_Text_doc[] = "The Blender Text module\n\n";
static char M_Text_New_doc[] = "() - return a new Text object";
static char M_Text_Get_doc[] = "(name) - return the Text with name 'name', \
returns None if not found.\n If 'name' is not specified, \
it returns a list of all Texts in the\ncurrent scene.";
static char M_Text_Load_doc[] =
"(filename) - return text from file filename as a Text Object, \
returns None if not found.\n";
static char M_Text_unlink_doc[] =
"(text) - remove Text object 'text' from Blender";
/*****************************************************************************/
/* Python method structure definition for Blender.Text module: */
/*****************************************************************************/
struct PyMethodDef M_Text_methods[] = {
{"New", M_Text_New, METH_VARARGS, M_Text_New_doc},
{"Get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
{"get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
{"Load", M_Text_Load, METH_O, M_Text_Load_doc},
{"unlink", M_Text_unlink, METH_VARARGS, M_Text_unlink_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_Text methods declarations: */
/*****************************************************************************/
static PyObject *Text_getFilename( BPy_Text * self );
static PyObject *Text_getNLines( BPy_Text * self );
static PyObject *Text_clear( BPy_Text * self );
static PyObject *Text_write( BPy_Text * self, PyObject * value );
static PyObject *Text_set( BPy_Text * self, PyObject * args );
static PyObject *Text_asLines( BPy_Text * self );
/*****************************************************************************/
/* Python BPy_Text methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Text_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - Return Text Object name"},
{"getFilename", ( PyCFunction ) Text_getFilename, METH_VARARGS,
"() - Return Text Object filename"},
{"getNLines", ( PyCFunction ) Text_getNLines, METH_VARARGS,
"() - Return number of lines in text buffer"},
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(str) - Change Text Object name"},
{"clear", ( PyCFunction ) Text_clear, METH_NOARGS,
"() - Clear Text buffer"},
{"write", ( PyCFunction ) Text_write, METH_O,
"(line) - Append string 'str' to Text buffer"},
{"set", ( PyCFunction ) Text_set, METH_VARARGS,
"(name, val) - Set attribute 'name' to value 'val'"},
{"asLines", ( PyCFunction ) Text_asLines, METH_NOARGS,
"() - Return text buffer as a list of lines"},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python Text_Type callback function prototypes: */
/*****************************************************************************/
static int Text_compare( BPy_Text * a, BPy_Text * b );
static PyObject *Text_repr( BPy_Text * self );
/*****************************************************************************/
/* Function: M_Text_New */
/* Python equivalent: Blender.Text.New */
/*****************************************************************************/
static PyObject *M_Text_New( PyObject * self, PyObject * args)
{
char *name = "Text";
int follow = 0;
Text *bl_text; /* blender text object */
PyObject *py_text; /* python wrapper */
if( !PyArg_ParseTuple( args, "|si", &name, &follow ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected string and int arguments (or nothing)" );
bl_text = add_empty_text( name );
if( bl_text ) {
/* do not set user count because Text is already linked */
/* create python wrapper obj */
py_text = Text_CreatePyObject( bl_text );
} else
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Text Object in Blender" );
if( !py_text )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create Text Object wrapper" );
if( follow )
bl_text->flags |= EXPP_TEXT_MODE_FOLLOW;
return py_text;
}
/*****************************************************************************/
/* Function: M_Text_Get */
/* Python equivalent: Blender.Text.Get */
/* Description: Receives a string and returns the text object */
/* whose name matches the string. If no argument is */
/* passed in, a list of all text names in the current */
/* scene is returned. */
/*****************************************************************************/
static PyObject *M_Text_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
Text *txt_iter;
if( !PyArg_ParseTuple( args, "|s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument (or nothing)" ) );
txt_iter = G.main->text.first;
if( name ) { /* (name) - Search text by name */
PyObject *wanted_txt = NULL;
while( ( txt_iter ) && ( wanted_txt == NULL ) ) {
if( strcmp( name, txt_iter->id.name + 2 ) == 0 ) {
wanted_txt = Text_CreatePyObject( txt_iter );
}
txt_iter = txt_iter->id.next;
}
if( wanted_txt == NULL ) { /* Requested text doesn't exist */
char error_msg[64];
PyOS_snprintf( error_msg, sizeof( error_msg ),
"Text \"%s\" not found", name );
return ( EXPP_ReturnPyObjError
( PyExc_NameError, error_msg ) );
}
return wanted_txt;
}
else { /* () - return a list of all texts in the scene */
int index = 0;
PyObject *txtlist, *pyobj;
txtlist = PyList_New( BLI_countlist( &( G.main->text ) ) );
if( txtlist == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyList" ) );
while( txt_iter ) {
pyobj = Text_CreatePyObject( txt_iter );
if( !pyobj ) {
Py_DECREF(txtlist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create PyString" ) );
}
PyList_SET_ITEM( txtlist, index, pyobj );
txt_iter = txt_iter->id.next;
index++;
}
return ( txtlist );
}
}
/*****************************************************************************/
/* Function: M_Text_Load */
/* Python equivalent: Blender.Text.Load */
/* Description: Receives a filename and returns the text object */
/* created from the corresponding file. */
/*****************************************************************************/
static PyObject *M_Text_Load( PyObject * self, PyObject * value )
{
char *fname = PyString_AsString(value);
char fpath[FILE_MAXDIR + FILE_MAXFILE];
Text *txt_ptr = NULL;
unsigned int maxlen = FILE_MAXDIR + FILE_MAXFILE;
if( !fname )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" ) );
if (strlen(fname) > (maxlen - 1))
return EXPP_ReturnPyObjError (PyExc_AttributeError,
"text filename too long");
else if (!BLI_exists(fname))
return EXPP_ReturnPyObjError (PyExc_AttributeError,
"text file not found");
BLI_strncpy(fpath, fname, maxlen);
txt_ptr = add_text( fpath );
if( !txt_ptr )
return EXPP_ReturnPyObjError( PyExc_IOError,
"couldn't load text" );
return Text_CreatePyObject(txt_ptr);
}
/*****************************************************************************/
/* Function: M_Text_unlink */
/* Python equivalent: Blender.Text.unlink */
/* Description: Removes the given Text object from Blender */
/*****************************************************************************/
static PyObject *M_Text_unlink( PyObject * self, PyObject * args )
{
BPy_Text *textobj;
Text *text;
if( !PyArg_ParseTuple( args, "O!", &Text_Type, &textobj ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a Text object as argument" );
text = ( ( BPy_Text * ) textobj )->text;
if( !text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"this text was already unlinked!" );
BPY_clear_bad_scriptlinks( text );
free_text_controllers( text );
unlink_text( text );
free_libblock( &G.main->text, text );
( ( BPy_Text * ) textobj )->text = NULL;
Py_RETURN_NONE;
}
/*****************************************************************************/
/* Function: Text_Init */
/*****************************************************************************/
PyObject *Text_Init( void )
{
PyObject *submodule;
if( PyType_Ready( &Text_Type ) < 0 )
return NULL;
submodule =
Py_InitModule3( "Blender.Text", M_Text_methods, M_Text_doc );
return ( submodule );
}
/*****************************************************************************/
/* Function: Text_CreatePyObject */
/*****************************************************************************/
PyObject *Text_CreatePyObject( Text * txt )
{
BPy_Text *pytxt;
pytxt = ( BPy_Text * ) PyObject_NEW( BPy_Text, &Text_Type );
if( !pytxt )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create BPy_Text PyObject" );
pytxt->text = txt;
return ( PyObject * ) pytxt;
}
/*****************************************************************************/
/* Python BPy_Text methods: */
/*****************************************************************************/
static PyObject *Text_getFilename( BPy_Text * self )
{
if( self->text->name )
return PyString_FromString( self->text->name );
Py_RETURN_NONE;
}
static PyObject *Text_getNLines( BPy_Text * self )
{ /* text->nlines isn't updated in Blender (?) */
int nlines = 0;
TextLine *line;
line = self->text->lines.first;
while( line ) { /* so we have to count them ourselves */
line = line->next;
nlines++;
}
self->text->nlines = nlines; /* and update Blender, too (should we?) */
return PyInt_FromLong( nlines );
}
static PyObject *Text_clear( BPy_Text * self)
{
int oldstate;
if( !self->text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
oldstate = txt_get_undostate( );
txt_set_undostate( 1 );
txt_sel_all( self->text );
txt_cut_sel( self->text );
txt_set_undostate( oldstate );
Py_RETURN_NONE;
}
static PyObject *Text_set( BPy_Text * self, PyObject * args )
{
int ival;
char *attr;
if( !PyArg_ParseTuple( args, "si", &attr, &ival ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a string and an int as arguments" );
if( strcmp( "follow_cursor", attr ) == 0 ) {
if( ival )
self->text->flags |= EXPP_TEXT_MODE_FOLLOW;
else
self->text->flags &= EXPP_TEXT_MODE_FOLLOW;
}
Py_RETURN_NONE;
}
static PyObject *Text_write( BPy_Text * self, PyObject * value )
{
char *str = PyString_AsString(value);
int oldstate;
if( !self->text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
if( !str )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
oldstate = txt_get_undostate( );
txt_insert_buf( self->text, str );
txt_move_eof( self->text, 0 );
txt_set_undostate( oldstate );
Py_RETURN_NONE;
}
static PyObject *Text_asLines( BPy_Text * self )
{
TextLine *line;
PyObject *list, *tmpstr;
if( !self->text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
line = self->text->lines.first;
list = PyList_New( 0 );
if( !list )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyList" );
while( line ) {
tmpstr = PyString_FromString( line->line );
PyList_Append( list, tmpstr );
Py_DECREF(tmpstr);
line = line->next;
}
return list;
}
/*****************************************************************************/
/* Function: Text_compare */
/* Description: This is a callback function for the BPy_Text type. It */
/* compares two Text_Type objects. Only the "==" and "!=" */
/* comparisons are meaninful. Returns 0 for equality and -1 if */
/* they don't point to the same Blender Text struct. */
/* In Python it becomes 1 if they are equal, 0 otherwise. */
/*****************************************************************************/
static int Text_compare( BPy_Text * a, BPy_Text * b )
{
return ( a->text == b->text ) ? 0 : -1;
}
/*****************************************************************************/
/* Function: Text_repr */
/* Description: This is a callback function for the BPy_Text type. It */
/* builds a meaninful string to represent text objects. */
/*****************************************************************************/
static PyObject *Text_repr( BPy_Text * self )
{
if( self->text )
return PyString_FromFormat( "[Text \"%s\"]",
self->text->id.name + 2 );
else
return PyString_FromString( "[Text <deleted>]" );
}
/*****************************************************************************/
/* Python attributes get/set functions: */
/*****************************************************************************/
static PyObject *Text_getMode(BPy_Text * self)
{
return PyInt_FromLong( self->text->flags );
}
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Text_getseters[] = {
GENERIC_LIB_GETSETATTR,
{"filename", (getter)Text_getFilename, (setter)NULL,
"text filename", NULL},
{"mode", (getter)Text_getMode, (setter)NULL,
"text mode flag", NULL},
{"nlines", (getter)Text_getNLines, (setter)NULL,
"number of lines", NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
/*****************************************************************************/
/* Python Text_Type structure definition: */
/*****************************************************************************/
PyTypeObject Text_Type = {
PyObject_HEAD_INIT( NULL )
0, /* ob_size */
"Blender Text", /* tp_name */
sizeof( BPy_Text ), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
NULL, /* tp_dealloc */
NULL, /* tp_print */
NULL, /* tp_getattr */
NULL, /* tp_setattr */
( cmpfunc ) Text_compare, /* tp_compare */
( reprfunc ) Text_repr, /* tp_repr */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
( hashfunc ) GenericLib_hash, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_Text_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_Text_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};

View File

@@ -1,52 +0,0 @@
/*
* $Id: Text.h 10136 2007-02-25 01:07:28Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_TEXT_H
#define EXPP_TEXT_H
#include <Python.h>
#include "DNA_text_types.h"
extern PyTypeObject Text_Type;
/* Type checking for EXPP PyTypes */
#define BPy_Text_Check(v) ((v)->ob_type == &Text_Type)
typedef struct {
PyObject_HEAD
Text * text; /* libdata must be second */
} BPy_Text;
PyObject *Text_Init( void );
PyObject *Text_CreatePyObject( Text * txt );
#endif /* EXPP_TEXT_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,56 +0,0 @@
/*
* $Id: Text3d.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Joilnen Leite
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_TEXT3D_H
#define EXPP_TEXT3D_H
#include <Python.h>
#include "DNA_curve_types.h"
extern PyTypeObject Text3d_Type;
#define BPy_Text3d_Check(v) ((v)->ob_type==&Text3d_Type)
typedef Curve Text3d;
/*prototypes*/
PyObject *Text3d_Init( void );
struct Text3d *Text3d_FromPyObject( PyObject * py_obj );
PyObject *Text3d_CreatePyObject( Text3d* text3d );
/* Python BPy_Text3d structure definition */
typedef struct {
PyObject_HEAD /* required py macro */
Text3d * curve;
} BPy_Text3d;
#endif /* EXPP_TEXT3D_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,64 +0,0 @@
/*
* $Id: Texture.h 10269 2007-03-15 01:09:14Z campbellbarton $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Alex Mole
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/* based on Image.h */
#ifndef EXPP_TEXTURE_H
#define EXPP_TEXTURE_H
#include <Python.h>
#include "DNA_texture_types.h"
/*****************************************************************************/
/* Python BPy_Texture structure definition */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
Tex * texture; /* libdata must be second */
} BPy_Texture;
extern PyTypeObject Texture_Type;
#define BPy_Texture_Check(v) ((v)->ob_type == &Texture_Type)
/*****************************************************************************/
/* Module Blender.Texture - public functions */
/*****************************************************************************/
PyObject *Texture_Init( void );
PyObject *Texture_CreatePyObject( struct Tex *tex );
Tex *Texture_FromPyObject( PyObject * pyobj );
#endif /* EXPP_TEXTURE_H */

View File

@@ -1,262 +0,0 @@
/*
* $Id: Types.c 11713 2007-08-19 19:06:42Z campbellbarton $
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano, Alex Mole, Joseph Gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Types.h"
#include "IDProp.h"
/*
stuff pasted from the old Types.h
is only need here now
*/
extern PyTypeObject IDGroup_Type, IDArray_Type;
extern PyTypeObject Action_Type, Armature_Type;
extern PyTypeObject Pose_Type;
extern PyTypeObject BezTriple_Type, Bone_Type, Button_Type;
extern PyTypeObject Camera_Type;
extern PyTypeObject CurNurb_Type, SurfNurb_Type;
extern PyTypeObject Curve_Type;
extern PyTypeObject Effect_Type, Font_Type;
extern PyTypeObject Image_Type, Ipo_Type, IpoCurve_Type;
extern PyTypeObject Lamp_Type, Lattice_Type;
extern PyTypeObject Material_Type, Metaball_Type, MTex_Type;
extern PyTypeObject NMFace_Type, NMEdge_Type, NMVert_Type, NMCol_Type,
NMesh_Type;
extern PyTypeObject MFace_Type, MVert_Type, PVert_Type, MEdge_Type, MCol_Type,
Mesh_Type;
extern PyTypeObject Object_Type;
extern PyTypeObject Group_Type;
extern PyTypeObject Particle_Type;
extern PyTypeObject Scene_Type, RenderData_Type;
extern PyTypeObject Text_Type, Text3d_Type, Texture_Type;
extern PyTypeObject World_Type;
extern PyTypeObject property_Type;
extern PyTypeObject buffer_Type, constant_Type, euler_Type;
extern PyTypeObject matrix_Type, quaternion_Type, rgbTuple_Type, vector_Type;
extern PyTypeObject point_Type;
extern PyTypeObject Modifier_Type, ModSeq_Type;
extern PyTypeObject EditBone_Type;
extern PyTypeObject ThemeSpace_Type;
extern PyTypeObject ThemeUI_Type;
extern PyTypeObject TimeLine_Type;
char M_Types_doc[] = "The Blender Types module\n\n\
This module is a dictionary of all Blender Python types";
struct PyMethodDef Null_methods[] = { {NULL, NULL, 0, NULL} };
/* The internal types (lowercase first letter, like constant_Type) are only
* set when some object initializes them. But unless we do it early, we get
* some easy and unpredictable (varies with platform, even distro) ways to
* crash Blender. Some modules also need this early up, so let's generalize
* and init all our pytypes here.
*/
void types_InitAll( void )
{
Action_Type.ob_type = &PyType_Type;
Pose_Type.ob_type = &PyType_Type;
Armature_Type.ob_type = &PyType_Type;
BezTriple_Type.ob_type = &PyType_Type;
Bone_Type.ob_type = &PyType_Type;
Button_Type.ob_type = &PyType_Type;
Camera_Type.ob_type = &PyType_Type;
CurNurb_Type.ob_type = &PyType_Type;
Curve_Type.ob_type = &PyType_Type;
Effect_Type.ob_type = &PyType_Type;
Image_Type.ob_type = &PyType_Type;
Ipo_Type.ob_type = &PyType_Type;
IpoCurve_Type.ob_type = &PyType_Type;
Lamp_Type.ob_type = &PyType_Type;
Lattice_Type.ob_type = &PyType_Type;
Material_Type.ob_type = &PyType_Type;
Metaball_Type.ob_type = &PyType_Type;
MTex_Type.ob_type = &PyType_Type;
NMCol_Type.ob_type = &PyType_Type;
NMFace_Type.ob_type = &PyType_Type;
NMEdge_Type.ob_type = &PyType_Type;
NMVert_Type.ob_type = &PyType_Type;
NMesh_Type.ob_type = &PyType_Type;
MFace_Type.ob_type = &PyType_Type;
MVert_Type.ob_type = &PyType_Type;
PVert_Type.ob_type = &PyType_Type;
MEdge_Type.ob_type = &PyType_Type;
MCol_Type.ob_type = &PyType_Type;
Mesh_Type.ob_type = &PyType_Type;
Object_Type.ob_type = &PyType_Type;
Group_Type.ob_type = &PyType_Type;
RenderData_Type.ob_type = &PyType_Type;
Scene_Type.ob_type = &PyType_Type;
SurfNurb_Type.ob_type = &PyType_Type;
Text_Type.ob_type = &PyType_Type;
Text3d_Type.ob_type = &PyType_Type;
Texture_Type.ob_type = &PyType_Type;
//TimeLine_Type.ob_type = &PyType_Type;
World_Type.ob_type = &PyType_Type;
buffer_Type.ob_type = &PyType_Type;
constant_Type.ob_type = &PyType_Type;
euler_Type.ob_type = &PyType_Type;
matrix_Type.ob_type = &PyType_Type;
quaternion_Type.ob_type = &PyType_Type;
PyType_Ready( &rgbTuple_Type );
vector_Type.ob_type = &PyType_Type;
property_Type.ob_type = &PyType_Type;
point_Type.ob_type = &PyType_Type;
PyType_Ready( &Modifier_Type );
PyType_Ready( &ModSeq_Type );
PyType_Ready( &EditBone_Type );
PyType_Ready( &ThemeSpace_Type );
PyType_Ready( &ThemeUI_Type );
IDProp_Init_Types();
}
/*****************************************************************************/
/* Function: Types_Init */
/*****************************************************************************/
PyObject *Types_Init( void )
{
PyObject *submodule, *dict;
submodule =
Py_InitModule3( "Blender.Types", Null_methods, M_Types_doc );
dict = PyModule_GetDict( submodule );
/* The Blender Object Type */
PyDict_SetItemString( dict, "ObjectType",
( PyObject * ) &Object_Type );
/* Blender Object Data Types */
PyDict_SetItemString( dict, "GroupType",
( PyObject * ) &Group_Type );
PyDict_SetItemString( dict, "SceneType", ( PyObject * ) &Scene_Type );
PyDict_SetItemString( dict, "RenderDataType",
( PyObject * ) &RenderData_Type );
PyDict_SetItemString( dict, "NMeshType", ( PyObject * ) &NMesh_Type );
PyDict_SetItemString( dict, "NMFaceType",
( PyObject * ) &NMFace_Type );
PyDict_SetItemString( dict, "NMVertType",
( PyObject * ) &NMVert_Type );
PyDict_SetItemString( dict, "NMEdgeType",
( PyObject * ) &NMEdge_Type );
PyDict_SetItemString( dict, "NMColType", ( PyObject * ) &NMCol_Type );
PyDict_SetItemString( dict, "MeshType", ( PyObject * ) &Mesh_Type );
PyDict_SetItemString( dict, "MFaceType",
( PyObject * ) &MFace_Type );
PyDict_SetItemString( dict, "MEdgeType",
( PyObject * ) &MEdge_Type );
PyDict_SetItemString( dict, "MVertType",
( PyObject * ) &MVert_Type );
PyDict_SetItemString( dict, "PVertType",
( PyObject * ) &PVert_Type );
PyDict_SetItemString( dict, "MColType", ( PyObject * ) &MCol_Type );
PyDict_SetItemString( dict, "ArmatureType",
( PyObject * ) &Armature_Type );
PyDict_SetItemString( dict, "BoneType", ( PyObject * ) &Bone_Type );
PyDict_SetItemString( dict, "CurNurb_Type",
( PyObject * ) &CurNurb_Type );
PyDict_SetItemString( dict, "SurfNurb_Type",
( PyObject * ) &SurfNurb_Type );
PyDict_SetItemString( dict, "CurveType", ( PyObject * ) &Curve_Type );
PyDict_SetItemString( dict, "IpoType", ( PyObject * ) &Ipo_Type );
PyDict_SetItemString( dict, "MetaballType",
( PyObject * ) &Metaball_Type );
PyDict_SetItemString( dict, "CameraType",
( PyObject * ) &Camera_Type );
PyDict_SetItemString( dict, "ImageType", ( PyObject * ) &Image_Type );
PyDict_SetItemString( dict, "LampType", ( PyObject * ) &Lamp_Type );
PyDict_SetItemString( dict, "TextType", ( PyObject * ) &Text_Type );
PyDict_SetItemString( dict, "Text3dType", ( PyObject * ) &Text3d_Type );
PyDict_SetItemString( dict, "MaterialType",
( PyObject * ) &Material_Type );
PyDict_SetItemString( dict, "ButtonType",
( PyObject * ) &Button_Type );
PyDict_SetItemString( dict, "LatticeType",
( PyObject * ) &Lattice_Type );
PyDict_SetItemString( dict, "TextureType",
( PyObject * ) &Texture_Type );
PyDict_SetItemString( dict, "MTexType", ( PyObject * ) &MTex_Type );
/* External helper Types available to the main ones above */
PyDict_SetItemString( dict, "vectorType",
( PyObject * ) &vector_Type );
PyDict_SetItemString( dict, "bufferType",
( PyObject * ) &buffer_Type );
PyDict_SetItemString( dict, "constantType",
( PyObject * ) &constant_Type );
PyDict_SetItemString( dict, "rgbTupleType",
( PyObject * ) &rgbTuple_Type );
PyDict_SetItemString( dict, "matrix_Type",
( PyObject * ) &matrix_Type );
PyDict_SetItemString( dict, "eulerType", ( PyObject * ) &euler_Type );
PyDict_SetItemString( dict, "quaternionType",
( PyObject * ) &quaternion_Type );
PyDict_SetItemString( dict, "BezTripleType",
( PyObject * ) &BezTriple_Type );
PyDict_SetItemString( dict, "ActionType",
( PyObject * ) &Action_Type );
PyDict_SetItemString( dict, "PoseType",
( PyObject * ) &Pose_Type );
PyDict_SetItemString( dict, "propertyType",
( PyObject * ) &property_Type );
PyDict_SetItemString( dict, "pointType",
( PyObject * ) &point_Type );
PyDict_SetItemString( dict, "ModifierType",
( PyObject * ) &Modifier_Type );
PyDict_SetItemString( dict, "ModSeqType",
( PyObject * ) &ModSeq_Type );
PyDict_SetItemString( dict, "EditBoneType",
( PyObject * ) &EditBone_Type);
PyDict_SetItemString( dict, "ThemeSpaceType",
( PyObject * ) &ThemeSpace_Type);
PyDict_SetItemString( dict, "ThemeUI_Type",
( PyObject * ) &ThemeUI_Type);
PyDict_SetItemString( dict, "IDGroupType",
( PyObject * ) &IDGroup_Type);
PyDict_SetItemString( dict, "IDArrayType",
( PyObject * ) &IDArray_Type);
return submodule;
}

View File

@@ -1,41 +0,0 @@
/*
* $Id: Types.h 7266 2006-04-16 15:28:50Z stiv $
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano, Alex Mole
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef EXPP_TYPES_H
#define EXPP_TYPES_H
#include <Python.h>
PyObject *Types_Init( void );
void types_InitAll( void );
#endif /* EXPP_TYPES_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,43 +0,0 @@
/*
* $Id:*
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/* This file is useless now, CAN BE REMOVED. */
#ifndef EXPP_WINDOW_H
#define EXPP_WINDOW_H
#include <Python.h>
PyObject *Window_Init( void );
PyObject *M_Window_Redraw( PyObject * self, PyObject * args );
#endif /* EXPP_WINDOW_H */

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More