Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2007-12-24 21:27:28 +0300
committerTon Roosendaal <ton@blender.org>2007-12-24 21:27:28 +0300
commita1c8543f2acd7086d412cb794b32f96794b00659 (patch)
tree449643369b86531dbbd883193efaeee7d1fb4418 /source/blender/python
parent8a07e665c28a94ffd188daa431a4fd0c5a460eba (diff)
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.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/BPY_extern.h136
-rw-r--r--source/blender/python/BPY_interface.c2659
-rw-r--r--source/blender/python/BPY_menus.c1118
-rw-r--r--source/blender/python/BPY_menus.h128
-rw-r--r--source/blender/python/CMakeLists.txt57
-rw-r--r--source/blender/python/Makefile37
-rw-r--r--source/blender/python/SConscript26
-rw-r--r--source/blender/python/api2_2x/Armature.c1490
-rw-r--r--source/blender/python/api2_2x/Armature.h70
-rw-r--r--source/blender/python/api2_2x/BGL.c1590
-rw-r--r--source/blender/python/api2_2x/BGL.h333
-rw-r--r--source/blender/python/api2_2x/BezTriple.c716
-rw-r--r--source/blender/python/api2_2x/BezTriple.h64
-rw-r--r--source/blender/python/api2_2x/Blender.c1004
-rw-r--r--source/blender/python/api2_2x/Blender.h41
-rw-r--r--source/blender/python/api2_2x/Bone.c1425
-rw-r--r--source/blender/python/api2_2x/Bone.h76
-rw-r--r--source/blender/python/api2_2x/Camera.c1057
-rw-r--r--source/blender/python/api2_2x/Camera.h82
-rw-r--r--source/blender/python/api2_2x/Constraint.c2692
-rw-r--r--source/blender/python/api2_2x/Constraint.h76
-rw-r--r--source/blender/python/api2_2x/CurNurb.c1098
-rw-r--r--source/blender/python/api2_2x/CurNurb.h70
-rw-r--r--source/blender/python/api2_2x/Curve.c1696
-rw-r--r--source/blender/python/api2_2x/Curve.h78
-rw-r--r--source/blender/python/api2_2x/Draw.c2197
-rw-r--r--source/blender/python/api2_2x/Draw.h77
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.c230
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.h56
-rw-r--r--source/blender/python/api2_2x/Effect.c1575
-rw-r--r--source/blender/python/api2_2x/Effect.h58
-rw-r--r--source/blender/python/api2_2x/Font.c403
-rw-r--r--source/blender/python/api2_2x/Font.h53
-rw-r--r--source/blender/python/api2_2x/Geometry.c428
-rw-r--r--source/blender/python/api2_2x/Geometry.h42
-rw-r--r--source/blender/python/api2_2x/Group.c813
-rw-r--r--source/blender/python/api2_2x/Group.h66
-rw-r--r--source/blender/python/api2_2x/IDProp.c895
-rw-r--r--source/blender/python/api2_2x/IDProp.h61
-rw-r--r--source/blender/python/api2_2x/Image.c1339
-rw-r--r--source/blender/python/api2_2x/Image.h60
-rw-r--r--source/blender/python/api2_2x/Ipo.c1842
-rw-r--r--source/blender/python/api2_2x/Ipo.h63
-rw-r--r--source/blender/python/api2_2x/Ipocurve.c1080
-rw-r--r--source/blender/python/api2_2x/Ipocurve.h58
-rw-r--r--source/blender/python/api2_2x/Key.c681
-rw-r--r--source/blender/python/api2_2x/Key.h68
-rw-r--r--source/blender/python/api2_2x/Lamp.c1570
-rw-r--r--source/blender/python/api2_2x/Lamp.h61
-rw-r--r--source/blender/python/api2_2x/Lattice.c813
-rw-r--r--source/blender/python/api2_2x/Lattice.h60
-rw-r--r--source/blender/python/api2_2x/Library.c1192
-rw-r--r--source/blender/python/api2_2x/Library.h78
-rw-r--r--source/blender/python/api2_2x/MTex.c827
-rw-r--r--source/blender/python/api2_2x/MTex.h63
-rw-r--r--source/blender/python/api2_2x/Makefile64
-rw-r--r--source/blender/python/api2_2x/Material.c3048
-rw-r--r--source/blender/python/api2_2x/Material.h78
-rw-r--r--source/blender/python/api2_2x/Mathutils.c1804
-rw-r--r--source/blender/python/api2_2x/Mathutils.h85
-rw-r--r--source/blender/python/api2_2x/Mesh.c8677
-rw-r--r--source/blender/python/api2_2x/Mesh.h127
-rw-r--r--source/blender/python/api2_2x/Metaball.c1189
-rw-r--r--source/blender/python/api2_2x/Metaball.h81
-rw-r--r--source/blender/python/api2_2x/Modifier.c1693
-rw-r--r--source/blender/python/api2_2x/Modifier.h72
-rw-r--r--source/blender/python/api2_2x/NLA.c1590
-rw-r--r--source/blender/python/api2_2x/NLA.h77
-rw-r--r--source/blender/python/api2_2x/NMesh.c4164
-rw-r--r--source/blender/python/api2_2x/NMesh.h157
-rw-r--r--source/blender/python/api2_2x/Node.c1213
-rw-r--r--source/blender/python/api2_2x/Node.h91
-rw-r--r--source/blender/python/api2_2x/Noise.c713
-rw-r--r--source/blender/python/api2_2x/Object.c5964
-rw-r--r--source/blender/python/api2_2x/Object.h62
-rw-r--r--source/blender/python/api2_2x/Particle.c1040
-rw-r--r--source/blender/python/api2_2x/Particle.h67
-rw-r--r--source/blender/python/api2_2x/Pose.c1395
-rw-r--r--source/blender/python/api2_2x/Pose.h71
-rw-r--r--source/blender/python/api2_2x/Registry.c245
-rw-r--r--source/blender/python/api2_2x/Registry.h50
-rw-r--r--source/blender/python/api2_2x/Scene.c1868
-rw-r--r--source/blender/python/api2_2x/Scene.h70
-rw-r--r--source/blender/python/api2_2x/Sound.c607
-rw-r--r--source/blender/python/api2_2x/Sound.h57
-rw-r--r--source/blender/python/api2_2x/SurfNurb.c857
-rw-r--r--source/blender/python/api2_2x/SurfNurb.h68
-rw-r--r--source/blender/python/api2_2x/Sys.c400
-rw-r--r--source/blender/python/api2_2x/Sys.h40
-rw-r--r--source/blender/python/api2_2x/Text.c576
-rw-r--r--source/blender/python/api2_2x/Text.h52
-rw-r--r--source/blender/python/api2_2x/Text3d.c1206
-rw-r--r--source/blender/python/api2_2x/Text3d.h56
-rw-r--r--source/blender/python/api2_2x/Texture.c2516
-rw-r--r--source/blender/python/api2_2x/Texture.h64
-rw-r--r--source/blender/python/api2_2x/Types.c262
-rw-r--r--source/blender/python/api2_2x/Types.h41
-rw-r--r--source/blender/python/api2_2x/Window.c1594
-rw-r--r--source/blender/python/api2_2x/Window.h43
-rw-r--r--source/blender/python/api2_2x/World.c1034
-rw-r--r--source/blender/python/api2_2x/World.h58
-rw-r--r--source/blender/python/api2_2x/bpy.c86
-rw-r--r--source/blender/python/api2_2x/bpy.h41
-rw-r--r--source/blender/python/api2_2x/bpy_config.c414
-rw-r--r--source/blender/python/api2_2x/bpy_config.h52
-rw-r--r--source/blender/python/api2_2x/bpy_data.c817
-rw-r--r--source/blender/python/api2_2x/bpy_data.h55
-rw-r--r--source/blender/python/api2_2x/bpy_types.h93
-rw-r--r--source/blender/python/api2_2x/charRGBA.c475
-rw-r--r--source/blender/python/api2_2x/charRGBA.h59
-rw-r--r--source/blender/python/api2_2x/constant.c269
-rw-r--r--source/blender/python/api2_2x/constant.h53
-rw-r--r--source/blender/python/api2_2x/doc/API_intro.py247
-rw-r--r--source/blender/python/api2_2x/doc/API_related.py564
-rw-r--r--source/blender/python/api2_2x/doc/Armature.py368
-rw-r--r--source/blender/python/api2_2x/doc/BGL.py1778
-rw-r--r--source/blender/python/api2_2x/doc/BezTriple.py96
-rw-r--r--source/blender/python/api2_2x/doc/Blender.py240
-rw-r--r--source/blender/python/api2_2x/doc/Blender_API.css44
-rw-r--r--source/blender/python/api2_2x/doc/Bpy.py25
-rw-r--r--source/blender/python/api2_2x/doc/Bpy_config.py38
-rw-r--r--source/blender/python/api2_2x/doc/Bpy_data.py281
-rw-r--r--source/blender/python/api2_2x/doc/Camera.py257
-rw-r--r--source/blender/python/api2_2x/doc/Constraint.py248
-rw-r--r--source/blender/python/api2_2x/doc/Curve.py723
-rw-r--r--source/blender/python/api2_2x/doc/Curvedoc.txt105
-rw-r--r--source/blender/python/api2_2x/doc/Draw.py880
-rw-r--r--source/blender/python/api2_2x/doc/Effect.py590
-rw-r--r--source/blender/python/api2_2x/doc/Effectdoc.txt257
-rw-r--r--source/blender/python/api2_2x/doc/Font.py69
-rw-r--r--source/blender/python/api2_2x/doc/Geometry.py97
-rw-r--r--source/blender/python/api2_2x/doc/Group.py127
-rw-r--r--source/blender/python/api2_2x/doc/IDProp.py130
-rw-r--r--source/blender/python/api2_2x/doc/Image.py374
-rw-r--r--source/blender/python/api2_2x/doc/Ipo.py437
-rw-r--r--source/blender/python/api2_2x/doc/IpoCurve.py226
-rw-r--r--source/blender/python/api2_2x/doc/Ipodoc.txt66
-rw-r--r--source/blender/python/api2_2x/doc/Key.py124
-rw-r--r--source/blender/python/api2_2x/doc/Lamp.py521
-rw-r--r--source/blender/python/api2_2x/doc/Lattice.py209
-rw-r--r--source/blender/python/api2_2x/doc/LibData.py137
-rw-r--r--source/blender/python/api2_2x/doc/Library.py114
-rw-r--r--source/blender/python/api2_2x/doc/Material.py1061
-rw-r--r--source/blender/python/api2_2x/doc/Mathutils.py864
-rw-r--r--source/blender/python/api2_2x/doc/Mesh.py1215
-rw-r--r--source/blender/python/api2_2x/doc/MeshPrimitives.py157
-rw-r--r--source/blender/python/api2_2x/doc/Metaball.py246
-rw-r--r--source/blender/python/api2_2x/doc/Metaballdoc.txt58
-rw-r--r--source/blender/python/api2_2x/doc/Modifier.py226
-rw-r--r--source/blender/python/api2_2x/doc/NLA.py245
-rw-r--r--source/blender/python/api2_2x/doc/NMesh.py823
-rw-r--r--source/blender/python/api2_2x/doc/Noise.py300
-rw-r--r--source/blender/python/api2_2x/doc/Object.py1757
-rw-r--r--source/blender/python/api2_2x/doc/Pose.py245
-rw-r--r--source/blender/python/api2_2x/doc/Radio.py351
-rw-r--r--source/blender/python/api2_2x/doc/Registry.py122
-rw-r--r--source/blender/python/api2_2x/doc/Render.py1192
-rw-r--r--source/blender/python/api2_2x/doc/Scene.py392
-rw-r--r--source/blender/python/api2_2x/doc/Sound.py147
-rw-r--r--source/blender/python/api2_2x/doc/Sys.py167
-rw-r--r--source/blender/python/api2_2x/doc/Text.py129
-rw-r--r--source/blender/python/api2_2x/doc/Text3d.py302
-rw-r--r--source/blender/python/api2_2x/doc/Texture.py557
-rw-r--r--source/blender/python/api2_2x/doc/Theme.py211
-rw-r--r--source/blender/python/api2_2x/doc/TimeLine.py80
-rw-r--r--source/blender/python/api2_2x/doc/Types.py70
-rw-r--r--source/blender/python/api2_2x/doc/Window.py538
-rw-r--r--source/blender/python/api2_2x/doc/World.py351
-rw-r--r--source/blender/python/api2_2x/doc/Worlddoc.txt55
-rw-r--r--source/blender/python/api2_2x/doc/epy_docgen-3.sh12
-rw-r--r--source/blender/python/api2_2x/doc/epy_docgen.sh12
-rw-r--r--source/blender/python/api2_2x/doc/id_generics.py30
-rw-r--r--source/blender/python/api2_2x/doc/testbgl.py45
-rw-r--r--source/blender/python/api2_2x/doc/testcamera.py137
-rw-r--r--source/blender/python/api2_2x/doc/testcurve.py20
-rw-r--r--source/blender/python/api2_2x/doc/testeffect.py65
-rw-r--r--source/blender/python/api2_2x/doc/testipo.py24
-rw-r--r--source/blender/python/api2_2x/doc/testmball.py37
-rw-r--r--source/blender/python/api2_2x/doc/testtext.py29
-rw-r--r--source/blender/python/api2_2x/doc/testworld.py21
-rw-r--r--source/blender/python/api2_2x/euler.c502
-rw-r--r--source/blender/python/api2_2x/euler.h67
-rw-r--r--source/blender/python/api2_2x/gen_library.c332
-rw-r--r--source/blender/python/api2_2x/gen_library.h94
-rw-r--r--source/blender/python/api2_2x/gen_utils.c948
-rw-r--r--source/blender/python/api2_2x/gen_utils.h176
-rw-r--r--source/blender/python/api2_2x/logic.c529
-rw-r--r--source/blender/python/api2_2x/logic.h61
-rw-r--r--source/blender/python/api2_2x/matrix.c975
-rw-r--r--source/blender/python/api2_2x/matrix.h80
-rw-r--r--source/blender/python/api2_2x/meshPrimitive.c279
-rw-r--r--source/blender/python/api2_2x/meshPrimitive.h46
-rw-r--r--source/blender/python/api2_2x/modules.h65
-rw-r--r--source/blender/python/api2_2x/point.c526
-rw-r--r--source/blender/python/api2_2x/point.h67
-rw-r--r--source/blender/python/api2_2x/quat.c668
-rw-r--r--source/blender/python/api2_2x/quat.h73
-rw-r--r--source/blender/python/api2_2x/rgbTuple.c420
-rw-r--r--source/blender/python/api2_2x/rgbTuple.h56
-rw-r--r--source/blender/python/api2_2x/sceneRadio.c893
-rw-r--r--source/blender/python/api2_2x/sceneRadio.h51
-rw-r--r--source/blender/python/api2_2x/sceneRender.c3216
-rw-r--r--source/blender/python/api2_2x/sceneRender.h52
-rw-r--r--source/blender/python/api2_2x/sceneSequence.c1163
-rw-r--r--source/blender/python/api2_2x/sceneSequence.h83
-rw-r--r--source/blender/python/api2_2x/sceneTimeLine.c319
-rw-r--r--source/blender/python/api2_2x/sceneTimeLine.h58
-rw-r--r--source/blender/python/api2_2x/vector.c1264
-rw-r--r--source/blender/python/api2_2x/vector.h61
-rw-r--r--source/blender/python/api2_2x/windowTheme.c828
-rw-r--r--source/blender/python/api2_2x/windowTheme.h60
211 files changed, 0 insertions, 118005 deletions
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
deleted file mode 100644
index e4986727ab1..00000000000
--- a/source/blender/python/BPY_extern.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
deleted file mode 100644
index 770fbf13931..00000000000
--- a/source/blender/python/BPY_interface.c
+++ /dev/null
@@ -1,2659 +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): Michel Selten, Willian P. Germano, Stephen Swaney,
- * Chris Keith, Chris Want, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include <Python.h>
-
-#include "compile.h" /* for the PyCodeObject */
-#include "eval.h" /* for PyEval_EvalCode */
-#include "BLI_blenlib.h" /* for BLI_last_slash() */
-#include "BIF_interface.h" /* for pupmenu() */
-#include "BIF_space.h"
-#include "BIF_screen.h"
-#include "BIF_toolbox.h"
-#include "BKE_action.h" /* for get_pose_channel() */
-#include "BKE_library.h"
-#include "BKE_object.h" /* during_scriptlink() */
-#include "BKE_text.h"
-#include "BKE_constraint.h" /* for bConstraintOb */
-#include "BKE_idprop.h"
-
-#include "DNA_curve_types.h" /* for struct IpoDriver */
-#include "DNA_ID.h" /* ipo driver */
-#include "DNA_object_types.h" /* ipo driver */
-#include "DNA_constraint_types.h" /* for pyconstraint */
-
-#include "DNA_screen_types.h"
-#include "DNA_userdef_types.h" /* for U.pythondir */
-#include "MEM_guardedalloc.h"
-#include "BPY_extern.h"
-#include "BPY_menus.h"
-#include "BPI_script.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_armature.h"
-#include "api2_2x/EXPP_interface.h"
-#include "api2_2x/constant.h"
-#include "api2_2x/gen_utils.h"
-#include "api2_2x/gen_library.h" /* GetPyObjectFromID */
-#include "api2_2x/BGL.h"
-#include "api2_2x/Blender.h"
-#include "api2_2x/Camera.h"
-#include "api2_2x/Draw.h"
-#include "api2_2x/Object.h"
-#include "api2_2x/Registry.h"
-#include "api2_2x/Pose.h"
-#include "api2_2x/bpy.h" /* for the new "bpy" module */
-
-/*these next two are for pyconstraints*/
-#include "api2_2x/IDProp.h"
-#include "api2_2x/matrix.h"
-
-/* for scriptlinks */
-#include "DNA_lamp_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_world_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_material_types.h"
-
-/* bpy_registryDict is declared in api2_2x/Registry.h and defined
- * in api2_2x/Registry.c
- * This Python dictionary will be used to store data that scripts
- * choose to preserve after they are executed, so user changes can be
- * restored next time the script is used. Check the Blender.Registry module.
- */
-/*#include "api2_2x/Registry.h" */
-
-/* for pydrivers (ipo drivers defined by one-line Python expressions) */
-PyObject *bpy_pydriver_Dict = NULL;
-
-/*
- * set up a weakref list for Armatures
- * creates list in __main__ module dict
- */
-
-int setup_armature_weakrefs()
-{
- PyObject *maindict;
- PyObject *main_module;
- char *list_name = ARM_WEAKREF_LIST_NAME;
-
- main_module = PyImport_AddModule( "__main__");
- if(main_module){
- PyObject *weakreflink;
- maindict= PyModule_GetDict(main_module);
-
- /* check if there is already a dict entry for the armature weakrefs,
- * and delete if so before making another one */
-
- weakreflink= PyDict_GetItemString(maindict,list_name);
- if( weakreflink != NULL ) {
- PyDict_DelItemString(maindict,list_name);
- Py_XDECREF( weakreflink );
- }
-
- if (PyDict_SetItemString(maindict,
- list_name,
- PyList_New(0)) == -1){
- printf("Oops - setup_armature_weakrefs()\n");
-
- return 0;
- }
- }
- return 1;
-}
-
-/* Declares the modules and their initialization functions
- * These are TOP-LEVEL modules e.g. import `module` - there is no
- * support for packages here e.g. import `package.module` */
-
-static struct _inittab BPy_Inittab_Modules[] = {
- {"Blender", M_Blender_Init},
- {"bpy", m_bpy_init},
- {NULL, NULL}
-};
-
-/*************************************************************************
-* Structure definitions
-**************************************************************************/
-#define FILENAME_LENGTH 24
-
-typedef struct _ScriptError {
- char filename[FILENAME_LENGTH];
- int lineno;
-} ScriptError;
-
-/****************************************************************************
-* Global variables
-****************************************************************************/
-ScriptError g_script_error;
-
-/***************************************************************************
-* Function prototypes
-***************************************************************************/
-PyObject *RunPython( Text * text, PyObject * globaldict );
-char *GetName( Text * text );
-PyObject *CreateGlobalDictionary( void );
-void ReleaseGlobalDictionary( PyObject * dict );
-void DoAllScriptsFromList( ListBase * list, short event );
-PyObject *importText( char *name );
-void init_ourImport( void );
-void init_ourReload( void );
-PyObject *blender_import( PyObject * self, PyObject * args );
-PyObject *RunPython2( Text * text, PyObject * globaldict, PyObject *localdict );
-
-
-void BPY_Err_Handle( char *script_name );
-PyObject *traceback_getFilename( PyObject * tb );
-
-/****************************************************************************
-* Description: This function will start the interpreter and load all modules
-* as well as search for a python installation.
-****************************************************************************/
-void BPY_start_python( int argc, char **argv )
-{
- static int argc_copy = 0;
- static char **argv_copy = NULL;
- int first_time = argc;
-
- /* we keep a copy of the values of argc and argv so that the game engine
- * can call BPY_start_python(0, NULL) whenever a game ends, without having
- * to know argc and argv there (in source/blender/src/space.c) */
- if( first_time ) {
- argc_copy = argc;
- argv_copy = argv;
- }
-
- //stuff for Registry module
- bpy_registryDict = PyDict_New( );/* check comment at start of this file */
- if( !bpy_registryDict )
- printf( "Error: Couldn't create the Registry Python Dictionary!" );
- Py_SetProgramName( "blender" );
-
- /* Py_Initialize() will attempt to import the site module and
- * print an error if not found. See init_syspath() for the
- * rest of our init msgs.
- */
-
- /* print Python version
- * Py_GetVersion() returns a ptr to a static string "9.9.9 (aaaa..."
- */
- {
- int count = 3; /* a nice default for major.minor. example 2.5 */
- const char *version = Py_GetVersion();
- /* we know a blank is there somewhere! */
- char *blank_ptr = strchr( version, ' ');
- if(blank_ptr)
- count = blank_ptr - version;
-
- printf( "Compiled with Python version %.*s.\n", count, version );
- }
-
-
- //Initialize the TOP-LEVEL modules
- PyImport_ExtendInittab(BPy_Inittab_Modules);
-
- //Start the interpreter
- Py_Initialize( );
- PySys_SetArgv( argc_copy, argv_copy );
-
- //Overrides __import__
- init_ourImport( );
- init_ourReload( );
-
- //init a global dictionary
- g_blenderdict = NULL;
-
- //Look for a python installation
- init_syspath( first_time ); /* not first_time: some msgs are suppressed */
-
- return;
-}
-
-/*****************************************************************************/
-/* Description: This function will terminate the Python interpreter */
-/*****************************************************************************/
-void BPY_end_python( void )
-{
- Script *script = NULL;
-
- if( bpy_registryDict ) {
- Py_DECREF( bpy_registryDict );
- bpy_registryDict = NULL;
- }
-
- if( bpy_pydriver_Dict ) {
- Py_DECREF( bpy_pydriver_Dict );
- bpy_pydriver_Dict = NULL;
- }
-
- /* Freeing all scripts here prevents problems with the order in which
- * Python is finalized and G.main is freed in exit_usiblender() */
- for (script = G.main->script.first; script; script = script->id.next) {
- BPY_clear_script(script);
- free_libblock( &G.main->script, script );
- }
-
- Py_Finalize( );
-
- BPyMenu_RemoveAllEntries( ); /* freeing bpymenu mem */
-
- /* a script might've opened a .blend file but didn't close it, so: */
- EXPP_Library_Close( );
-
- return;
-}
-
-void syspath_append( char *dirname )
-{
- PyObject *mod_sys= NULL, *dict= NULL, *path= NULL, *dir= NULL;
- short ok=1;
- PyErr_Clear( );
-
- dir = Py_BuildValue( "s", dirname );
-
- mod_sys = PyImport_ImportModule( "sys" ); /* new ref */
-
- if (mod_sys) {
- dict = PyModule_GetDict( mod_sys ); /* borrowed ref */
- path = PyDict_GetItemString( dict, "path" ); /* borrowed ref */
- if ( !PyList_Check( path ) ) {
- ok = 0;
- }
- } else {
- /* cant get the sys module */
- ok = 0;
- }
-
- if (ok && PyList_Append( path, dir ) != 0)
- ok = 0; /* append failed */
-
- if( (ok==0) || PyErr_Occurred( ) )
- Py_FatalError( "could import or build sys.path, can't continue" );
-
- Py_XDECREF( mod_sys );
-}
-
-void init_syspath( int first_time )
-{
- PyObject *path;
- PyObject *mod, *d;
- char *progname;
- char execdir[FILE_MAXDIR]; /*defines from DNA_space_types.h */
-
- int n;
-
- path = Py_BuildValue( "s", bprogname );
-
- mod = PyImport_ImportModule( "Blender.sys" );
-
- if( mod ) {
- d = PyModule_GetDict( mod );
- EXPP_dict_set_item_str( d, "progname", path );
- Py_DECREF( mod );
- } else
- printf( "Warning: could not set Blender.sys.progname\n" );
-
- progname = BLI_last_slash( bprogname ); /* looks for the last dir separator */
-
- n = progname - bprogname;
- if( n > 0 ) {
- strncpy( execdir, bprogname, n );
- if( execdir[n - 1] == '.' )
- n--; /*fix for when run as ./blender */
- execdir[n] = '\0';
-
- syspath_append( execdir ); /* append to module search path */
- } else
- printf( "Warning: could not determine argv[0] path\n" );
-
- /*
- attempt to import 'site' module as a check for valid
- python install found.
- */
-
- printf("Checking for installed Python... "); /* appears after msg "Compiled with Python 2.x" */
- mod = PyImport_ImportModule( "site" ); /* new ref */
-
- if( mod ) {
- printf("got it!\n");
- Py_DECREF( mod );
- } else { /* import 'site' failed */
- PyErr_Clear( );
- if( first_time ) {
- printf( "No installed Python found.\n" );
- printf( "Only built-in modules are available. Some scripts may not run.\n" );
- printf( "Continuing happily.\n" );
- }
- }
-
-
- /*
- * initialize the sys module
- * set sys.executable to the Blender exe
- */
-
- mod = PyImport_ImportModule( "sys" ); /* new ref */
-
- if( mod ) {
- d = PyModule_GetDict( mod ); /* borrowed ref */
- EXPP_dict_set_item_str( d, "executable",
- Py_BuildValue( "s", bprogname ) );
- Py_DECREF( mod );
- } else{
- printf("import of sys module failed\n");
- }
-}
-
-/****************************************************************************
-* Description: This function finishes Python initialization in Blender.
-
-Because U.pythondir (user defined dir for scripts) isn't
-initialized when BPY_start_Python needs to be executed, we
-postpone adding U.pythondir to sys.path and also BPyMenus
-(mechanism to register scripts in Blender menus) for when
-that dir info is available.
-****************************************************************************/
-void BPY_post_start_python( void )
-{
- char dirpath[FILE_MAX];
- char *sdir = NULL;
-
- if(U.pythondir[0] != '\0' ) {
- char modpath[FILE_MAX];
- int upyslen = strlen(U.pythondir);
-
- /* check if user pydir ends with a slash and, if so, remove the slash
- * (for eventual implementations of c library's stat function that might
- * not like it) */
- if (upyslen > 2) { /* avoids doing anything if dir == '//' */
- char ending = U.pythondir[upyslen - 1];
-
- if (ending == '/' || ending == '\\')
- U.pythondir[upyslen - 1] = '\0';
- }
-
- BLI_strncpy(dirpath, U.pythondir, FILE_MAX);
- BLI_convertstringcode(dirpath, G.sce, 0);
- syspath_append(dirpath); /* append to module search path */
-
- BLI_make_file_string("/", modpath, dirpath, "bpymodules");
- if (BLI_exists(modpath)) syspath_append(modpath);
- }
-
- sdir = bpy_gethome(1);
- if (sdir) {
-
- syspath_append(sdir);
-
- BLI_make_file_string("/", dirpath, sdir, "bpymodules");
- if (BLI_exists(dirpath)) syspath_append(dirpath);
- }
-
- BPyMenu_Init( 0 ); /* get dynamic menus (registered scripts) data */
-
- return;
-}
-
-/****************************************************************************
-* Description: This function will return the linenumber on which an error
-* has occurred in the Python script.
-****************************************************************************/
-int BPY_Err_getLinenumber( void )
-{
- return g_script_error.lineno;
-}
-
-/*****************************************************************************/
-/* Description: This function will return the filename of the python script. */
-/*****************************************************************************/
-const char *BPY_Err_getFilename( void )
-{
- return g_script_error.filename;
-}
-
-/*****************************************************************************/
-/* Description: Return PyString filename from a traceback object */
-/*****************************************************************************/
-PyObject *traceback_getFilename( PyObject * tb )
-{
- PyObject *v = NULL;
-
-/* co_filename is in f_code, which is in tb_frame, which is in tb */
-
- v = PyObject_GetAttrString( tb, "tb_frame" );
- if (v) {
- Py_DECREF( v );
- v = PyObject_GetAttrString( v, "f_code" );
- if (v) {
- Py_DECREF( v );
- v = PyObject_GetAttrString( v, "co_filename" );
- }
- }
-
- if (v) return v;
- else return PyString_FromString("unknown");
-}
-
-/****************************************************************************
-* Description: Blender Python error handler. This catches the error and
-* stores filename and line number in a global
-*****************************************************************************/
-void BPY_Err_Handle( char *script_name )
-{
- PyObject *exception, *err, *tb, *v;
-
- if( !script_name ) {
- printf( "Error: script has NULL name\n" );
- return;
- }
-
- PyErr_Fetch( &exception, &err, &tb );
-
- if (!script_name) script_name = "untitled";
- //if( !exception && !tb ) {
- // printf( "FATAL: spurious exception\n" );
- // return;
- //}
-
- strcpy( g_script_error.filename, script_name );
-
- if( exception
- && PyErr_GivenExceptionMatches( exception, PyExc_SyntaxError ) ) {
- /* no traceback available when SyntaxError */
- PyErr_Restore( exception, err, tb ); /* takes away reference! */
- PyErr_Print( );
- v = PyObject_GetAttrString( err, "lineno" );
- if( v ) {
- g_script_error.lineno = PyInt_AsLong( v );
- Py_DECREF( v );
- } else {
- g_script_error.lineno = -1;
- }
- /* this avoids an abort in Python 2.3's garbage collecting: */
- PyErr_Clear( );
- return;
- } else {
- PyErr_NormalizeException( &exception, &err, &tb );
- PyErr_Restore( exception, err, tb ); /* takes away reference! */
- PyErr_Print( );
- tb = PySys_GetObject( "last_traceback" );
-
- if( !tb ) {
- printf( "\nCan't get traceback\n" );
- return;
- }
-
- Py_INCREF( tb );
-
-/* From old bpython BPY_main.c:
- * 'check traceback objects and look for last traceback in the
- * same text file. This is used to jump to the line of where the
- * error occured. "If the error occured in another text file or module,
- * the last frame in the current file is adressed."'
- */
-
- for(;;) {
- v = PyObject_GetAttrString( tb, "tb_next" );
-
- if( !v || v == Py_None ||
- strcmp(PyString_AsString(traceback_getFilename(v)), script_name)) {
- break;
- }
-
- Py_DECREF( tb );
- tb = v;
- }
-
- v = PyObject_GetAttrString( tb, "tb_lineno" );
- if (v) {
- g_script_error.lineno = PyInt_AsLong(v);
- Py_DECREF(v);
- }
- v = traceback_getFilename( tb );
- if (v) {
- strncpy( g_script_error.filename, PyString_AsString( v ),
- FILENAME_LENGTH );
- Py_DECREF(v);
- }
- Py_DECREF( tb );
- }
-
- return;
-}
-
-/****************************************************************************
-* Description: This function executes the script passed by st.
-* Notes: It is called by blender/src/drawtext.c when a Blender user
-* presses ALT+PKEY in the script's text window.
-*****************************************************************************/
-int BPY_txt_do_python_Text( struct Text *text )
-{
- PyObject *py_dict, *py_result;
- BPy_constant *info;
- char textname[24];
- Script *script = G.main->script.first;
-
- if( !text )
- return 0;
-
- /* check if this text is already running */
- while( script ) {
- if( !strcmp( script->id.name + 2, text->id.name + 2 ) ) {
- /* if this text is already a running script,
- * just move to it: */
- SpaceScript *sc;
- newspace( curarea, SPACE_SCRIPT );
- sc = curarea->spacedata.first;
- sc->script = script;
- return 1;
- }
- script = script->id.next;
- }
-
- /* Create a new script structure and initialize it: */
- script = alloc_libblock( &G.main->script, ID_SCRIPT, GetName( text ) );
-
- if( !script ) {
- printf( "couldn't allocate memory for Script struct!" );
- return 0;
- }
-
- /* if in the script Blender.Load(blendfile) is not the last command,
- * an error after it will call BPY_Err_Handle below, but the text struct
- * will have been deallocated already, so we need to copy its name here.
- */
- BLI_strncpy( textname, GetName( text ),
- strlen( GetName( text ) ) + 1 );
-
- script->id.us = 1;
- script->flags = SCRIPT_RUNNING;
- script->py_draw = NULL;
- script->py_event = NULL;
- script->py_button = NULL;
- script->py_browsercallback = NULL;
-
- py_dict = CreateGlobalDictionary( );
-
- if( !setup_armature_weakrefs()){
- printf("Oops - weakref dict\n");
- return 0;
- }
-
- script->py_globaldict = py_dict;
-
- info = ( BPy_constant * ) PyConstant_New( );
- if( info ) {
- PyConstant_Insert( info, "name",
- PyString_FromString( script->id.name + 2 ) );
- Py_INCREF( Py_None );
- PyConstant_Insert( info, "arg", Py_None );
- EXPP_dict_set_item_str( py_dict, "__script__",
- ( PyObject * ) info );
- }
-
- py_result = RunPython( text, py_dict ); /* Run the script */
-
- if( !py_result ) { /* Failed execution of the script */
-
- BPY_Err_Handle( textname );
- ReleaseGlobalDictionary( py_dict );
- script->py_globaldict = NULL;
- if( G.main->script.first )
- free_libblock( &G.main->script, script );
-
- return 0;
- } else {
- Py_DECREF( py_result );
- script->flags &= ~SCRIPT_RUNNING;
- if( !script->flags ) {
- ReleaseGlobalDictionary( py_dict );
- script->py_globaldict = NULL;
- free_libblock( &G.main->script, script );
- }
- }
-
- return 1; /* normal return */
-}
-
-/****************************************************************************
-* Description: Called from command line to run a Python script
-* automatically. The script can be a file or a Blender Text in the current
-* .blend.
-****************************************************************************/
-void BPY_run_python_script( char *fn )
-{
- Text *text = NULL;
- int is_blender_text = 0;
-
- if (!BLI_exists(fn)) { /* if there's no such filename ... */
- text = G.main->text.first; /* try an already existing Blender Text */
-
- while (text) {
- if (!strcmp(fn, text->id.name + 2)) break;
- text = text->id.next;
- }
-
- if (text == NULL) {
- printf("\nError: no such file or Blender text -- %s.\n", fn);
- return;
- }
- else is_blender_text = 1; /* fn is already a Blender Text */
- }
-
- else {
- text = add_text(fn);
-
- if (text == NULL) {
- printf("\nError in BPY_run_python_script:\n"
- "couldn't create Blender text from %s\n", fn);
- /* Chris: On Windows if I continue I just get a segmentation
- * violation. To get a baseline file I exit here. */
- exit(2);
- /* return; */
- }
- }
-
- if (BPY_txt_do_python_Text(text) != 1) {
- printf("\nError executing Python script from command-line:\n"
- "%s (at line %d).\n", fn, BPY_Err_getLinenumber());
- }
-
- if (!is_blender_text) {
- /* We can't simply free the text, since the script might have called
- * Blender.Load() to load a new .blend, freeing previous data.
- * So we check if the pointer is still valid. */
- Text *txtptr = G.main->text.first;
- while (txtptr) {
- if (txtptr == text) {
- free_libblock(&G.main->text, text);
- break;
- }
- txtptr = txtptr->id.next;
- }
- }
-}
-
-/****************************************************************************
-* Description: This function executes the script chosen from a menu.
-* Notes: It is called by the ui code in src/header_???.c when a user
-* clicks on a menu entry that refers to a script.
-* Scripts are searched in the BPyMenuTable, using the given
-* menutype and event values to know which one was chosen.
-*****************************************************************************/
-int BPY_menu_do_python( short menutype, int event )
-{
- PyObject *py_dict, *py_res, *pyarg = NULL;
- BPy_constant *info;
- BPyMenu *pym;
- BPySubMenu *pysm;
- FILE *fp = NULL;
- char *buffer, *s;
- char filestr[FILE_MAXDIR + FILE_MAXFILE];
- char scriptname[21];
- Script *script = NULL;
- int len;
-
- pym = BPyMenu_GetEntry( menutype, ( short ) event );
-
- if( !pym )
- return 0;
-
- if( pym->version > G.version )
- notice( "Version mismatch: script was written for Blender %d. "
- "It may fail with yours: %d.", pym->version,
- G.version );
-
-/* if there are submenus, let the user choose one from a pupmenu that we
- * create here.*/
- pysm = pym->submenus;
- if( pysm ) {
- char *pupstr;
- int arg;
-
- pupstr = BPyMenu_CreatePupmenuStr( pym, menutype );
-
- if( pupstr ) {
- arg = pupmenu( pupstr );
- MEM_freeN( pupstr );
-
- if( arg >= 0 ) {
- while( arg-- )
- pysm = pysm->next;
- pyarg = PyString_FromString( pysm->arg );
- } else
- return 0;
- }
- }
-
- if( !pyarg ) { /* no submenus */
- Py_INCREF( Py_None );
- pyarg = Py_None;
- }
-
- if( pym->dir ) { /* script is in U.pythondir */
- char upythondir[FILE_MAXDIR];
-
- /* dirs in Blender can be "//", which has a special meaning */
- BLI_strncpy(upythondir, U.pythondir, FILE_MAXDIR);
- BLI_convertstringcode(upythondir, G.sce, 0); /* if so, this expands it */
- BLI_make_file_string( "/", filestr, upythondir, pym->filename );
- }
- else { /* script is in default scripts dir */
- char *scriptsdir = bpy_gethome(1);
-
- if (!scriptsdir) {
- printf("Error loading script: can't find default scripts dir!");
- return 0;
- }
-
- BLI_make_file_string( "/", filestr, scriptsdir, pym->filename );
- }
-
- fp = fopen( filestr, "rb" );
- if( !fp ) {
- printf( "Error loading script: couldn't open file %s\n",
- filestr );
- return 0;
- }
-
- BLI_strncpy(scriptname, pym->name, 21);
- len = strlen(scriptname) - 1;
- /* by convention, scripts that open the file browser or have submenus
- * display '...'. Here we remove them from the datablock name */
- while ((len > 0) && scriptname[len] == '.') {
- scriptname[len] = '\0';
- len--;
- }
-
- /* Create a new script structure and initialize it: */
- script = alloc_libblock( &G.main->script, ID_SCRIPT, scriptname );
-
- if( !script ) {
- printf( "couldn't allocate memory for Script struct!" );
- fclose( fp );
- return 0;
- }
-
- /* let's find a proper area for an eventual script gui:
- * (still experimenting here, need definition on which win
- * each group will be put to code this properly) */
- switch ( menutype ) {
-
- case PYMENU_IMPORT: /* first 4 were handled in header_info.c */
- case PYMENU_EXPORT:
- case PYMENU_HELP:
- case PYMENU_RENDER:
- case PYMENU_WIZARDS:
- case PYMENU_SCRIPTTEMPLATE:
- case PYMENU_MESHFACEKEY:
- break;
-
- default:
- if( curarea->spacetype != SPACE_SCRIPT ) {
- ScrArea *sa = NULL;
-
- sa = find_biggest_area_of_type( SPACE_BUTS );
- if( sa ) {
- if( ( 1.5 * sa->winx ) < sa->winy )
- sa = NULL; /* too narrow? */
- }
-
- if( !sa )
- sa = find_biggest_area_of_type( SPACE_SCRIPT );
- if( !sa )
- sa = find_biggest_area_of_type( SPACE_TEXT );
- if( !sa )
- sa = find_biggest_area_of_type( SPACE_IMAGE ); /* group UV */
- if( !sa )
- sa = find_biggest_area_of_type( SPACE_VIEW3D );
-
- if( !sa )
- sa = find_biggest_area( );
-
- areawinset( sa->win );
- }
- break;
- }
-
- script->id.us = 1;
- script->flags = SCRIPT_RUNNING;
- script->py_draw = NULL;
- script->py_event = NULL;
- script->py_button = NULL;
- script->py_browsercallback = NULL;
-
- py_dict = CreateGlobalDictionary( );
-
- script->py_globaldict = py_dict;
-
- info = ( BPy_constant * ) PyConstant_New( );
- if( info ) {
- PyConstant_Insert( info, "name",
- PyString_FromString( script->id.name + 2 ) );
- PyConstant_Insert( info, "arg", pyarg );
- EXPP_dict_set_item_str( py_dict, "__script__",
- ( PyObject * ) info );
- }
-
- /* Previously we used PyRun_File to run directly the code on a FILE
- * object, but as written in the Python/C API Ref Manual, chapter 2,
- * 'FILE structs for different C libraries can be different and
- * incompatible'.
- * So now we load the script file data to a buffer */
-
- fseek( fp, 0L, SEEK_END );
- len = ftell( fp );
- fseek( fp, 0L, SEEK_SET );
-
- buffer = MEM_mallocN( len + 2, "pyfilebuf" ); /* len+2 to add '\n\0' */
- len = fread( buffer, 1, len, fp );
-
- buffer[len] = '\n'; /* fix syntax error in files w/o eol */
- buffer[len + 1] = '\0';
-
- /* fast clean-up of dos cr/lf line endings: change '\r' to space */
-
- /* we also have to check for line splitters: '\\' */
- /* to avoid possible syntax errors on dos files on win */
- /**/
- /* but first make sure we won't disturb memory below &buffer[0]: */
- if( *buffer == '\r' )
- *buffer = ' ';
-
- /* now handle the whole buffer */
- for( s = buffer + 1; *s != '\0'; s++ ) {
- if( *s == '\r' ) {
- if( *( s - 1 ) == '\\' ) { /* special case: long lines split with '\': */
- *( s - 1 ) = ' '; /* we write ' \', because '\ ' is a syntax error */
- *s = '\\';
- } else
- *s = ' '; /* not a split line, just replace '\r' with ' ' */
- }
- }
-
- fclose( fp );
-
-
- if( !setup_armature_weakrefs()){
- printf("Oops - weakref dict\n");
- MEM_freeN( buffer );
- return 0;
- }
-
- /* run the string buffer */
-
- py_res = PyRun_String( buffer, Py_file_input, py_dict, py_dict );
-
- MEM_freeN( buffer );
-
- if( !py_res ) { /* Failed execution of the script */
-
- BPY_Err_Handle( script->id.name + 2 );
- ReleaseGlobalDictionary( py_dict );
- script->py_globaldict = NULL;
- if( G.main->script.first )
- free_libblock( &G.main->script, script );
- error( "Python script error: check console" );
-
- return 0;
- } else {
- Py_DECREF( py_res );
- script->flags &= ~SCRIPT_RUNNING;
-
- if( !script->flags ) {
- ReleaseGlobalDictionary( py_dict );
- script->py_globaldict = NULL;
- free_libblock( &G.main->script, script );
-
- /* special case: called from the menu in the Scripts window
- * we have to change sc->script pointer, since it'll be freed here.*/
- if( curarea->spacetype == SPACE_SCRIPT ) {
- SpaceScript *sc = curarea->spacedata.first;
- sc->script = G.main->script.first; /* can be null, which is ok ... */
- /* ... meaning no other script is running right now. */
- }
-
- }
- }
-
- return 1; /* normal return */
-}
-
-/*****************************************************************************
-* Description:
-* Notes:
-*****************************************************************************/
-void BPY_free_compiled_text( struct Text *text )
-{
- if( !text->compiled )
- return;
- Py_DECREF( ( PyObject * ) text->compiled );
- text->compiled = NULL;
-
- return;
-}
-
-/*****************************************************************************
-* Description: This function frees a finished (flags == 0) script.
-*****************************************************************************/
-void BPY_free_finished_script( Script * script )
-{
- if( !script )
- return;
-
- if( PyErr_Occurred( ) ) { /* if script ended after filesel */
- PyErr_Print( ); /* eventual errors are handled now */
- error( "Python script error: check console" );
- }
-
- free_libblock( &G.main->script, script );
- return;
-}
-
-static void unlink_script( Script * script )
-{ /* copied from unlink_text in drawtext.c */
- bScreen *scr;
- ScrArea *area;
- SpaceLink *sl;
-
- for( scr = G.main->screen.first; scr; scr = scr->id.next ) {
- for( area = scr->areabase.first; area; area = area->next ) {
- for( sl = area->spacedata.first; sl; sl = sl->next ) {
- if( sl->spacetype == SPACE_SCRIPT ) {
- SpaceScript *sc = ( SpaceScript * ) sl;
-
- if( sc->script == script ) {
- sc->script = NULL;
-
- if( sc ==
- area->spacedata.first ) {
- scrarea_queue_redraw
- ( area );
- }
- }
- }
- }
- }
- }
-}
-
-void BPY_clear_script( Script * script )
-{
- PyObject *dict;
-
- if( !script )
- return;
-
- if (!Py_IsInitialized()) {
- printf("\nError: trying to free script data after finalizing Python!");
- printf("\nScript name: %s\n", script->id.name+2);
- return;
- }
-
- Py_XDECREF( ( PyObject * ) script->py_draw );
- Py_XDECREF( ( PyObject * ) script->py_event );
- Py_XDECREF( ( PyObject * ) script->py_button );
- Py_XDECREF( ( PyObject * ) script->py_browsercallback );
- script->py_draw = NULL;
- script->py_event = NULL;
- script->py_button = NULL;
- script->py_browsercallback = NULL;
-
- dict = script->py_globaldict;
-
- if( dict ) {
- PyDict_Clear( dict );
- Py_DECREF( dict ); /* Release dictionary. */
- script->py_globaldict = NULL;
- }
-
- unlink_script( script );
-}
-
-/* PyDrivers */
-
-/* PyDrivers are Ipo Drivers governed by expressions written in Python.
- * Expressions here are one-liners that evaluate to a float value. */
-
-/* For faster execution we keep a special dictionary for pydrivers, with
- * the needed modules and aliases. */
-static int bpy_pydriver_create_dict(void)
-{
- PyObject *d, *mod;
-
- if (bpy_pydriver_Dict) return -1;
-
- d = PyDict_New();
- if (!d) return -1;
-
- bpy_pydriver_Dict = d;
-
- /* import some modules: builtins, Blender, math, Blender.noise */
-
- PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins());
-
- mod = PyImport_ImportModule("Blender");
- if (mod) {
- PyDict_SetItemString(d, "Blender", mod);
- PyDict_SetItemString(d, "b", mod);
- Py_DECREF(mod);
- }
-
- mod = PyImport_ImportModule("math");
- if (mod) {
- PyDict_Merge(d, PyModule_GetDict(mod), 0); /* 0 - dont overwrite existing values */
-
- /* Only keep for backwards compat! - just import all math into root, they are standard */
- PyDict_SetItemString(d, "math", mod);
- PyDict_SetItemString(d, "m", mod);
- Py_DECREF(mod);
- }
-
- mod = PyImport_ImportModule("Blender.Noise");
- if (mod) {
- PyDict_SetItemString(d, "noise", mod);
- PyDict_SetItemString(d, "n", mod);
- Py_DECREF(mod);
- }
-
- /* If there's a Blender text called pydrivers.py, import it.
- * Users can add their own functions to this module. */
- mod = importText("pydrivers"); /* can also use PyImport_Import() */
- if (mod) {
- PyDict_SetItemString(d, "pydrivers", mod);
- PyDict_SetItemString(d, "p", mod);
- Py_DECREF(mod);
- }
- else
- PyErr_Clear();
-
- /* short aliases for some Get() functions: */
-
- /* ob(obname) == Blender.Object.Get(obname) */
- mod = PyImport_ImportModule("Blender.Object");
- if (mod) {
- PyObject *fcn = PyObject_GetAttrString(mod, "Get");
- Py_DECREF(mod);
- if (fcn) {
- PyDict_SetItemString(d, "ob", fcn);
- Py_DECREF(fcn);
- }
- }
-
- /* TODO - change these */
- /* me(meshname) == Blender.Mesh.Get(meshname) */
- mod = PyImport_ImportModule("Blender.Mesh");
- if (mod) {
- PyObject *fcn = PyObject_GetAttrString(mod, "Get");
- Py_DECREF(mod);
- if (fcn) {
- PyDict_SetItemString(d, "me", fcn);
- Py_DECREF(fcn);
- }
- }
-
- /* ma(matname) == Blender.Material.Get(matname) */
- mod = PyImport_ImportModule("Blender.Material");
- if (mod) {
- PyObject *fcn = PyObject_GetAttrString(mod, "Get");
- Py_DECREF(mod);
- if (fcn) {
- PyDict_SetItemString(d, "ma", fcn);
- Py_DECREF(fcn);
- }
- }
-
- return 0;
-}
-
-/* error return function for BPY_eval_pydriver */
-static float pydriver_error(IpoDriver *driver) {
-
- if (bpy_pydriver_oblist)
- bpy_pydriver_freeList();
-
- if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */
- PyDict_Clear(bpy_pydriver_Dict);
- Py_DECREF(bpy_pydriver_Dict);
- bpy_pydriver_Dict = NULL;
- }
-
- driver->flag |= IPO_DRIVER_FLAG_INVALID; /* py expression failed */
-
- if (driver->ob)
- fprintf(stderr, "\nError in Ipo Driver: Object %s\nThis is the failed Python expression:\n'%s'\n\n", driver->ob->id.name+2, driver->name);
- else
- fprintf(stderr, "\nError in Ipo Driver: No Object\nThis is the failed Python expression:\n'%s'\n\n", driver->name);
-
- PyErr_Print();
-
- return 0.0f;
-}
-
-
-/********PyConstraints*********/
-
-/* This function checks whether a text-buffer is a PyConstraint candidate.
- * It uses simple text parsing that could be easily confused!
- */
-int BPY_is_pyconstraint(Text *text)
-{
- TextLine *tline = text->lines.first;
-
- if (tline && (tline->len > 10)) {
- char *line = tline->line;
-
- /* Expected format: #BPYCONSTRAINT
- * The actual checks are forgiving, so slight variations also work. */
- if (line && line[0] == '#' && strstr(line, "BPYCONSTRAINT")) return 1;
- }
- return 0;
-}
-
-/* This function is called to update PyConstraint data so that it is compatible with the script.
- * Some of the allocating/freeing of memory for constraint targets occurs here, espcially
- * if the number of targets changes.
- */
-void BPY_pyconstraint_update(Object *owner, bConstraint *con)
-{
- bPythonConstraint *data= con->data;
-
- if (data->text) {
- /* script does exist. it is assumed that this is a valid pyconstraint script */
- PyObject *globals;
- PyObject *retval, *gval;
- int num, i;
-
- /* clear the relevant flags first */
- data->flag = 0;
-
- /* populate globals dictionary */
- globals = CreateGlobalDictionary();
- retval = RunPython(data->text, globals);
-
- if (retval == NULL) {
- BPY_Err_Handle(data->text->id.name);
- ReleaseGlobalDictionary(globals);
- data->flag |= PYCON_SCRIPTERROR;
- return;
- }
-
- Py_XDECREF(retval);
- retval = NULL;
-
- /* try to find NUM_TARGETS */
- gval = PyDict_GetItemString(globals, "NUM_TARGETS");
- if ( (gval) && (num= PyInt_AsLong(gval)) ) {
- /* NUM_TARGETS is defined... and non-zero */
- bConstraintTarget *ct;
-
- /* check if it is valid (just make sure it is not negative)
- * TODO: PyInt_AsLong may return -1 as sign of invalid input...
- */
- num = abs(num);
- data->flag |= PYCON_USETARGETS;
-
- /* check if the number of targets has changed */
- if (num < data->tarnum) {
- /* free a few targets */
- num= data->tarnum - num;
- for (i = 0; i < num; i++, data->tarnum--) {
- ct= data->targets.last;
- BLI_freelinkN(&data->targets, ct);
- }
- }
- else if (num > data->tarnum) {
- /* add a few targets */
- num = num - data->tarnum;
- for (i = 0; i < num; i++, data->tarnum++) {
- ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget");
- BLI_addtail(&data->targets, ct);
- }
- }
-
- /* validate targets */
- con->flag &= ~CONSTRAINT_DISABLE;
- for (ct= data->targets.first; ct; ct= ct->next) {
- if (!exist_object(ct->tar)) {
- ct->tar = NULL;
- con->flag |= CONSTRAINT_DISABLE;
- break;
- }
-
- if ((ct->tar == owner) && (ct->subtarget[0] != 0)) {
- if (get_named_bone(get_armature(owner), ct->subtarget) == NULL) {
- con->flag |= CONSTRAINT_DISABLE;
- break;
- }
- }
- }
-
- /* clear globals */
- ReleaseGlobalDictionary(globals);
- }
- else {
- /* NUM_TARGETS is not defined or equals 0 */
- ReleaseGlobalDictionary(globals);
-
- /* free all targets */
- BLI_freelistN(&data->targets);
- data->tarnum = 0;
- data->flag &= ~PYCON_USETARGETS;
-
- return;
- }
- }
- else {
- /* no script, so clear any settings/data now */
- data->tarnum = 0;
- data->flag = 0;
- con->flag &= ~CONSTRAINT_DISABLE;
-
- BLI_freelistN(&data->targets);
-
- /* supposedly this should still leave the base struct... */
- IDP_FreeProperty(data->prop);
- }
-}
-
-/* PyConstraints Evaluation Function (only called from evaluate_constraint)
- * This function is responsible for modifying the ownermat that it is passed.
- */
-void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase *targets)
-{
- PyObject *srcmat, *tarmat, *tarmats, *idprop;
- PyObject *globals;
- PyObject *gval;
- PyObject *pyargs, *retval;
- bConstraintTarget *ct;
- MatrixObject *retmat;
- int row, col, index;
-
- if (!con->text) return;
- if (con->flag & PYCON_SCRIPTERROR) return;
-
- globals = CreateGlobalDictionary();
-
- /* wrap blender-data as PyObjects for evaluation
- * - we expose the owner's matrix as pymatrix
- * - id-properties are wrapped using the id-properties pyapi
- * - targets are presented as a list of matrices
- */
- srcmat = newMatrixObject((float *)cob->matrix, 4, 4, Py_NEW);
- idprop = BPy_Wrap_IDProperty(NULL, con->prop, NULL);
-
- tarmats= PyList_New(con->tarnum);
- for (ct=targets->first, index=0; ct; ct=ct->next, index++) {
- tarmat = newMatrixObject((float *)ct->matrix, 4, 4, Py_NEW);
- PyList_SET_ITEM(tarmats, index, tarmat);
- }
-
-
-/* since I can't remember what the armature weakrefs do, I'll just leave this here
- commented out. This function was based on pydrivers, and it might still be relevent.
- if( !setup_armature_weakrefs()){
- fprintf( stderr, "Oops - weakref dict setup\n");
- return result;
- }
-*/
-
- retval = RunPython(con->text, globals);
-
- if (retval == NULL) {
- BPY_Err_Handle(con->text->id.name);
- con->flag |= PYCON_SCRIPTERROR;
-
- /* free temp objects */
- Py_XDECREF(idprop);
- Py_XDECREF(srcmat);
- Py_XDECREF(tarmats);
-
- ReleaseGlobalDictionary(globals);
-
- return;
- }
-
- if (retval) {Py_XDECREF( retval );}
- retval = NULL;
-
- gval = PyDict_GetItemString(globals, "doConstraint");
- if (!gval) {
- printf("ERROR: no doConstraint function in constraint!\n");
-
- /* free temp objects */
- Py_XDECREF(idprop);
- Py_XDECREF(srcmat);
- Py_XDECREF(tarmats);
-
- ReleaseGlobalDictionary(globals);
-
- return;
- }
-
- /* Now for the fun part! Try and find the functions we need. */
- if (PyFunction_Check(gval)) {
- pyargs = Py_BuildValue("OOO", srcmat, tarmats, idprop);
- retval = PyObject_CallObject(gval, pyargs);
- Py_XDECREF(pyargs);
- }
- else {
- printf("ERROR: doConstraint is supposed to be a function!\n");
- con->flag |= PYCON_SCRIPTERROR;
-
- Py_XDECREF(idprop);
- Py_XDECREF(srcmat);
- Py_XDECREF(tarmats);
-
- ReleaseGlobalDictionary(globals);
-
- return;
- }
-
- if (!retval) {
- BPY_Err_Handle(con->text->id.name);
- con->flag |= PYCON_SCRIPTERROR;
-
- /* free temp objects */
- Py_XDECREF(idprop);
- Py_XDECREF(srcmat);
- Py_XDECREF(tarmats);
-
- ReleaseGlobalDictionary(globals);
-
- return;
- }
-
-
- if (!PyObject_TypeCheck(retval, &matrix_Type)) {
- printf("Error in PyConstraint - doConstraint: Function not returning a matrix!\n");
- con->flag |= PYCON_SCRIPTERROR;
-
- Py_XDECREF(idprop);
- Py_XDECREF(srcmat);
- Py_XDECREF(tarmats);
- Py_XDECREF(retval);
-
- ReleaseGlobalDictionary(globals);
-
- return;
- }
-
- retmat = (MatrixObject *)retval;
- if (retmat->rowSize != 4 || retmat->colSize != 4) {
- printf("Error in PyConstraint - doConstraint: Matrix returned is the wrong size!\n");
- con->flag |= PYCON_SCRIPTERROR;
-
- Py_XDECREF(idprop);
- Py_XDECREF(srcmat);
- Py_XDECREF(tarmats);
- Py_XDECREF(retval);
-
- ReleaseGlobalDictionary(globals);
-
- return;
- }
-
- /* this is the reverse of code taken from newMatrix() */
- for(row = 0; row < 4; row++) {
- for(col = 0; col < 4; col++) {
- cob->matrix[row][col] = retmat->contigPtr[row*4+col];
- }
- }
-
- /* free temp objects */
- Py_XDECREF(idprop);
- Py_XDECREF(srcmat);
- Py_XDECREF(tarmats);
- Py_XDECREF(retval);
-
- /* clear globals */
- ReleaseGlobalDictionary(globals);
-}
-
-/* This evaluates the target matrix for each target the PyConstraint uses.
- * NOTE: it only does one target at a time!
- */
-void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct)
-{
- PyObject *tar, *subtar;
- PyObject *tarmat, *idprop;
- PyObject *globals;
- PyObject *gval;
- PyObject *pyargs, *retval;
- MatrixObject *retmat;
- int row, col;
-
- if (!con->text) return;
- if (con->flag & PYCON_SCRIPTERROR) return;
- if (!ct) return;
-
- globals = CreateGlobalDictionary();
-
- tar = Object_CreatePyObject(ct->tar);
- if ((ct->tar) && (ct->tar->type==OB_ARMATURE)) {
- bPoseChannel *pchan;
- pchan = get_pose_channel(ct->tar->pose, ct->subtarget);
- subtar = PyPoseBone_FromPosechannel(pchan);
- }
- else
- subtar = PyString_FromString(ct->subtarget);
-
- tarmat = newMatrixObject((float *)ct->matrix, 4, 4, Py_NEW);
- idprop = BPy_Wrap_IDProperty( NULL, con->prop, NULL);
-
-/* since I can't remember what the armature weakrefs do, I'll just leave this here
- commented out. This function was based on pydrivers, and it might still be relevent.
- if( !setup_armature_weakrefs()){
- fprintf( stderr, "Oops - weakref dict setup\n");
- return result;
- }
-*/
- retval = RunPython(con->text, globals);
-
- if (retval == NULL) {
- BPY_Err_Handle(con->text->id.name);
- con->flag |= PYCON_SCRIPTERROR;
-
- /* free temp objects */
- Py_XDECREF(tar);
- Py_XDECREF(subtar);
- Py_XDECREF(idprop);
- Py_XDECREF(tarmat);
-
- ReleaseGlobalDictionary(globals);
-
- return;
- }
-
- Py_XDECREF(retval);
- retval = NULL;
-
- /* try to find doTarget function to set the target matrix */
- gval = PyDict_GetItemString(globals, "doTarget");
- if (!gval) {
- /* free temp objects */
- Py_XDECREF(tar);
- Py_XDECREF(subtar);
- Py_XDECREF(idprop);
- Py_XDECREF(tarmat);
-
- ReleaseGlobalDictionary(globals);
-
- return;
- }
-
- /* Now for the fun part! Try and find the functions we need.*/
- if (PyFunction_Check(gval)) {
- pyargs = Py_BuildValue("OOOO", tar, subtar, tarmat, idprop);
- retval = PyObject_CallObject(gval, pyargs);
- Py_XDECREF(pyargs);
- }
- else {
- printf("ERROR: doTarget is supposed to be a function!\n");
- con->flag |= PYCON_SCRIPTERROR;
-
- Py_XDECREF(tar);
- Py_XDECREF(subtar);
- Py_XDECREF(idprop);
- Py_XDECREF(tarmat);
-
- ReleaseGlobalDictionary(globals);
- return;
- }
-
- if (!retval) {
- BPY_Err_Handle(con->text->id.name);
- con->flag |= PYCON_SCRIPTERROR;
-
-
- /* free temp objects */
- Py_XDECREF(tar);
- Py_XDECREF(subtar);
- Py_XDECREF(idprop);
- Py_XDECREF(tarmat);
-
- ReleaseGlobalDictionary(globals);
- return;
- }
-
- if (!PyObject_TypeCheck(retval, &matrix_Type)) {
- con->flag |= PYCON_SCRIPTERROR;
-
- Py_XDECREF(tar);
- Py_XDECREF(subtar);
- Py_XDECREF(idprop);
- Py_XDECREF(tarmat);
- Py_XDECREF(retval);
-
- ReleaseGlobalDictionary(globals);
- return;
- }
-
- retmat = (MatrixObject *)retval;
- if (retmat->rowSize != 4 || retmat->colSize != 4) {
- printf("Error in PyConstraint - doTarget: Matrix returned is the wrong size!\n");
- con->flag |= PYCON_SCRIPTERROR;
-
- Py_XDECREF(tar);
- Py_XDECREF(subtar);
- Py_XDECREF(idprop);
- Py_XDECREF(tarmat);
- Py_XDECREF(retval);
-
- ReleaseGlobalDictionary(globals);
- return;
- }
-
- /* this is the reverse of code taken from newMatrix() */
- for(row = 0; row < 4; row++) {
- for(col = 0; col < 4; col++) {
- ct->matrix[row][col] = retmat->contigPtr[row*4+col];
- }
- }
-
- /* free temp objects */
- Py_XDECREF(tar);
- Py_XDECREF(subtar);
- Py_XDECREF(idprop);
- Py_XDECREF(tarmat);
- Py_XDECREF(retval);
-
- /* clear globals */
- ReleaseGlobalDictionary(globals);
-}
-
-/* This draws+handles the user-defined interface for editing pyconstraints idprops */
-void BPY_pyconstraint_settings(void *arg1, void *arg2)
-{
- bPythonConstraint *con= (bPythonConstraint *)arg1;
- PyObject *idprop;
- PyObject *globals;
- PyObject *gval;
- PyObject *retval;
-
- if (!con->text) return;
- if (con->flag & PYCON_SCRIPTERROR) return;
-
- globals = CreateGlobalDictionary();
-
- idprop = BPy_Wrap_IDProperty( NULL, con->prop, NULL);
-
- retval = RunPython(con->text, globals);
-
- if (retval == NULL) {
- BPY_Err_Handle(con->text->id.name);
- ReleaseGlobalDictionary(globals);
- con->flag |= PYCON_SCRIPTERROR;
-
- /* free temp objects */
- Py_XDECREF(idprop);
- return;
- }
-
- if (retval) {Py_XDECREF( retval );}
- retval = NULL;
-
- gval = PyDict_GetItemString(globals, "getSettings");
- if (!gval) {
- printf("ERROR: no getSettings function in constraint!\n");
-
- /* free temp objects */
- ReleaseGlobalDictionary( globals );
- Py_XDECREF(idprop);
- return;
- }
-
- /* Now for the fun part! Try and find the functions we need. */
- if (PyFunction_Check(gval)) {
- retval = PyObject_CallFunction(gval, "O", idprop);
- }
- else {
- printf("ERROR: getSettings is supposed to be a function!\n");
- ReleaseGlobalDictionary( globals );
-
- Py_XDECREF(idprop);
- return;
- }
-
- if (!retval) {
- BPY_Err_Handle(con->text->id.name);
- con->flag |= PYCON_SCRIPTERROR;
-
- /* free temp objects */
- ReleaseGlobalDictionary(globals);
- Py_XDECREF(idprop);
- return;
- }
- else {
- /* clear globals */
- ReleaseGlobalDictionary(globals);
-
- /* free temp objects */
- Py_XDECREF(idprop);
- Py_DECREF(retval);
- return;
- }
-}
-
-/* Update function, it gets rid of pydrivers global dictionary, forcing
- * BPY_pydriver_eval to recreate it. This function is used to force
- * reloading the Blender text module "pydrivers.py", if available, so
- * updates in it reach pydriver evaluation. */
-void BPY_pydriver_update(void)
-{
- if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */
- PyDict_Clear(bpy_pydriver_Dict);
- Py_DECREF(bpy_pydriver_Dict);
- bpy_pydriver_Dict = NULL;
- }
-
- return;
-}
-
-/* for depsgraph.c, runs py expr once to collect all refs. made
- * to objects (self refs. to the object that owns the py driver
- * are not allowed). */
-struct Object **BPY_pydriver_get_objects(IpoDriver *driver)
-{
- /*if (!driver || !driver->ob || driver->name[0] == '\0')
- return NULL;*/
-
- /*PyErr_Clear();*/
-
- /* clear the flag that marks invalid python expressions */
- driver->flag &= ~IPO_DRIVER_FLAG_INVALID;
-
- /* tell we're running a pydriver, so Get() functions know they need
- * to add the requested obj to our list */
- bpy_pydriver_running(1);
-
- /* append driver owner object as the 1st ob in the list;
- * we put it there to make sure it is not itself referenced in
- * its pydriver expression */
- bpy_pydriver_appendToList(driver->ob);
-
- /* this will append any other ob referenced in expr (driver->name)
- * or set the driver's error flag if driver's py expression fails */
- BPY_pydriver_eval(driver);
-
- bpy_pydriver_running(0); /* ok, we're done */
-
- return bpy_pydriver_obArrayFromList(); /* NULL if eval failed */
-}
-
-/* This evals py driver expressions, 'expr' is a Python expression that
- * should evaluate to a float number, which is returned. */
-float BPY_pydriver_eval(IpoDriver *driver)
-{
- char *expr = NULL;
- PyObject *retval, *bpy_ob = NULL;
- float result = 0.0f; /* default return */
- int setitem_retval;
-
- if (!driver) return result;
-
- expr = driver->name; /* the py expression to be evaluated */
- if (!expr || expr[0]=='\0') return result;
-
- if (!bpy_pydriver_Dict) {
- if (bpy_pydriver_create_dict() != 0) {
- fprintf(stderr, "Pydriver error: couldn't create Python dictionary");
- return result;
- }
- }
-
- if (driver->ob)
- bpy_ob = Object_CreatePyObject(driver->ob);
-
- if (!bpy_ob) {
- Py_INCREF(Py_None);
- bpy_ob = Py_None;
- }
-
- setitem_retval = EXPP_dict_set_item_str(bpy_pydriver_Dict, "self", bpy_ob);
-
- if( !setup_armature_weakrefs()){
- fprintf( stderr, "Oops - weakref dict setup\n");
- return result;
- }
-
- retval = PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict,
- bpy_pydriver_Dict);
-
- if (retval == NULL) {
- return pydriver_error(driver);
- }
-
- result = ( float )PyFloat_AsDouble( retval );
-
- if (result == -1 && PyErr_Occurred())
- return pydriver_error(driver);
-
- /* remove 'self', since this dict is also used by py buttons */
- if (setitem_retval == 0) PyDict_DelItemString(bpy_pydriver_Dict, "self");
-
- /* all fine, make sure the "invalid expression" flag is cleared */
- driver->flag &= ~IPO_DRIVER_FLAG_INVALID;
-
- return result;
-}
-
-/* Button Python Evaluation */
-
-/* Python evaluation for gui buttons:
- * users can write any valid Python expression (that evals to an int or float)
- * inside Blender's gui number buttons and have them evaluated to their
- * actual int or float value.
- *
- * The global dict used for pydrivers is also used here, so all imported
- * modules for pydrivers (including the pydrivers.py Blender text) are
- * available for button py eval, too. */
-
-static int bpy_button_eval_error(char *expr) {
-
- if (bpy_pydriver_oblist)
- bpy_pydriver_freeList();
-
- if (bpy_pydriver_Dict) { /* free the persistent global dict */
- /* it's the same dict used by pydrivers */
- PyDict_Clear(bpy_pydriver_Dict);
- Py_DECREF(bpy_pydriver_Dict);
- bpy_pydriver_Dict = NULL;
- }
-
- fprintf(stderr, "\nError in button evaluation:\nThis is the failed Python expression:\n'%s'\n\n", expr);
-
- PyErr_Print();
-
- return -1;
-}
-
-int BPY_button_eval(char *expr, double *value)
-{
- PyObject *retval, *floatval;
-
- if (!value || !expr || expr[0]=='\0') return -1;
-
- *value = 0.0; /* default value */
-
- if (!bpy_pydriver_Dict) {
- if (bpy_pydriver_create_dict() != 0) {
- fprintf(stderr,
- "Button Python Eval error: couldn't create Python dictionary");
- return -1;
- }
- }
-
-
- if( !setup_armature_weakrefs()){
- fprintf(stderr, "Oops - weakref dict\n");
- return -1;
- }
-
- retval = PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict,
- bpy_pydriver_Dict);
-
- if (retval == NULL) {
- return bpy_button_eval_error(expr);
- }
- else {
- floatval = PyNumber_Float(retval);
- Py_DECREF(retval);
- }
-
- if (floatval == NULL)
- return bpy_button_eval_error(expr);
- else {
- *value = (float)PyFloat_AsDouble(floatval);
- Py_DECREF(floatval);
- }
-
- return 0; /* successful exit */
-}
-
-
-/*****************************************************************************/
-/* ScriptLinks */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* Description: */
-/* Notes: Not implemented yet */
-/*****************************************************************************/
-void BPY_clear_bad_scriptlinks( struct Text *byebye )
-{
-/*
- BPY_clear_bad_scriptlist(getObjectList(), byebye);
- BPY_clear_bad_scriptlist(getLampList(), byebye);
- BPY_clear_bad_scriptlist(getCameraList(), byebye);
- BPY_clear_bad_scriptlist(getMaterialList(), byebye);
- BPY_clear_bad_scriptlist(getWorldList(), byebye);
- BPY_clear_bad_scriptlink(&scene_getCurrent()->id, byebye);
-
- allqueue(REDRAWBUTSSCRIPT, 0);
-*/
- return;
-}
-
-/*****************************************************************************
-* Description: Loop through all scripts of a list of object types, and
-* execute these scripts.
-* For the scene, only the current active scene the scripts are
-* executed (if any).
-*****************************************************************************/
-void BPY_do_all_scripts( short event )
-{
- DoAllScriptsFromList( &( G.main->object ), event );
- DoAllScriptsFromList( &( G.main->lamp ), event );
- DoAllScriptsFromList( &( G.main->camera ), event );
- DoAllScriptsFromList( &( G.main->mat ), event );
- DoAllScriptsFromList( &( G.main->world ), event );
-
- BPY_do_pyscript( &( G.scene->id ), event );
-
- return;
-}
-
-/*****************************************************************************
-* Description: Execute a Python script when an event occurs. The following
-* events are possible: frame changed, load script and redraw.
-* Only events happening to one of the following object types
-* are handled: Object, Lamp, Camera, Material, World and
-* Scene.
-*****************************************************************************/
-
-static ScriptLink *ID_getScriptlink( ID * id )
-{
- switch ( MAKE_ID2( id->name[0], id->name[1] ) ) {
- case ID_OB:
- return &( ( Object * ) id )->scriptlink;
- case ID_LA:
- return &( ( Lamp * ) id )->scriptlink;
- case ID_CA:
- return &( ( Camera * ) id )->scriptlink;
- case ID_MA:
- return &( ( Material * ) id )->scriptlink;
- case ID_WO:
- return &( ( World * ) id )->scriptlink;
- case ID_SCE:
- return &( ( Scene * ) id )->scriptlink;
- default:
- return NULL;
- }
-}
-
-int BPY_has_onload_script( void )
-{
- ScriptLink *slink = &G.scene->scriptlink;
- int i;
-
- if( !slink || !slink->totscript )
- return 0;
-
- for( i = 0; i < slink->totscript; i++ ) {
- if( ( slink->flag[i] == SCRIPT_ONLOAD )
- && ( slink->scripts[i] != NULL ) )
- return 1;
- }
-
- return 0;
-}
-
-void BPY_do_pyscript( ID * id, short event )
-{
- ScriptLink *scriptlink;
-
- if( !id ) return;
-
- scriptlink = ID_getScriptlink( id );
-
- if( scriptlink && scriptlink->totscript ) {
- PyObject *value;
- PyObject *dict;
- PyObject *ret;
- int index, during_slink = during_scriptlink( );
-
- /* invalid scriptlinks (new .blend was just loaded), return */
- if( during_slink < 0 )
- return;
-
- if( !setup_armature_weakrefs()){
- printf("Oops - weakref dict, this is a bug\n");
- return;
- }
-
- value = GetPyObjectFromID( id );
- if( !value){
- printf("Oops - could not get a valid python object for Blender.link, this is a bug\n");
- return;
- }
-
- /* tell we're running a scriptlink. The sum also tells if this script
- * is running nested inside another. Blender.Load needs this info to
- * avoid trouble with invalid slink pointers. */
- during_slink++;
- disable_where_scriptlink( (short)during_slink );
-
- /* set globals in Blender module to identify scriptlink */
- PyDict_SetItemString( g_blenderdict, "bylink", Py_True);
- EXPP_dict_set_item_str( g_blenderdict, "link", value );
- EXPP_dict_set_item_str( g_blenderdict, "event",
- PyString_FromString( event_to_name
- ( event ) ) );
- if (event == SCRIPT_POSTRENDER) event = SCRIPT_RENDER;
-
- for( index = 0; index < scriptlink->totscript; index++ ) {
- if( ( scriptlink->flag[index] == event ) &&
- ( scriptlink->scripts[index] != NULL ) ) {
- dict = CreateGlobalDictionary( );
- ret = RunPython( ( Text * ) scriptlink->
- scripts[index], dict );
- ReleaseGlobalDictionary( dict );
-
- if( !ret ) {
- /* Failed execution of the script */
- BPY_Err_Handle( scriptlink->
- scripts[index]->name +
- 2 );
- //BPY_end_python ();
- //BPY_start_python ();
- } else {
- Py_DECREF( ret );
- }
- /* If a scriptlink has just loaded a new .blend file, the
- * scriptlink pointer became invalid (see api2_2x/Blender.c),
- * so we stop here. */
- if( during_scriptlink( ) == -1 ) {
- during_slink = 1;
- break;
- }
- }
- }
-
- disable_where_scriptlink( (short)(during_slink - 1) );
-
- /* cleanup bylink flag and clear link so PyObject
- * can be released
- */
- PyDict_SetItemString(g_blenderdict, "bylink", Py_False);
- PyDict_SetItemString( g_blenderdict, "link", Py_None );
- EXPP_dict_set_item_str( g_blenderdict, "event", PyString_FromString( "" ) );
- }
-}
-
-
-/* SPACE HANDLERS */
-
-/* These are special script links that can be assigned to ScrArea's to
- * (EVENT type) receive events sent to a given space (and use or ignore them) or
- * (DRAW type) be called after the space is drawn, to draw anything on top of
- * the space area. */
-
-/* How to add space handlers to other spaces:
- * - add the space event defines to DNA_scriptlink_types.h, as done for
- * 3d view: SPACEHANDLER_VIEW3D_EVENT, for example;
- * - add the new defines to Blender.SpaceHandler dictionary in Blender.c;
- * - check space.c for how to call the event handlers;
- * - check drawview.c for how to call the draw handlers;
- * - check header_view3d.c for how to add the "Space Handler Scripts" menu.
- * Note: DRAW handlers should be called with 'event = 0', chech drawview.c */
-
-int BPY_has_spacehandler(Text *text, ScrArea *sa)
-{
- ScriptLink *slink;
- int index;
-
- if (!sa || !text) return 0;
-
- slink = &sa->scriptlink;
-
- for (index = 0; index < slink->totscript; index++) {
- if (slink->scripts[index] && (slink->scripts[index] == (ID *)text))
- return 1;
- }
-
- return 0;
-}
-
-int BPY_is_spacehandler(Text *text, char spacetype)
-{
- TextLine *tline = text->lines.first;
- unsigned short type = 0;
-
- if (tline && (tline->len > 10)) {
- char *line = tline->line;
-
- /* Expected format: # SPACEHANDLER.SPACE.TYPE
- * Ex: # SPACEHANDLER.VIEW3D.DRAW
- * The actual checks are forgiving, so slight variations also work. */
- if (line && line[0] == '#' && strstr(line, "HANDLER")) {
- line++; /* skip '#' */
-
- /* only done for 3D View right now, trivial to add for others: */
- switch (spacetype) {
- case SPACE_VIEW3D:
- if (strstr(line, "3D")) { /* VIEW3D, 3DVIEW */
- if (strstr(line, "DRAW")) type = SPACEHANDLER_VIEW3D_DRAW;
- else if (strstr(line, "EVENT")) type = SPACEHANDLER_VIEW3D_EVENT;
- }
- break;
- }
- }
- }
- return type; /* 0 if not a space handler */
-}
-
-int BPY_del_spacehandler(Text *text, ScrArea *sa)
-{
- ScriptLink *slink;
- int i, j;
-
- if (!sa || !text) return -1;
-
- slink = &sa->scriptlink;
- if (slink->totscript < 1) return -1;
-
- for (i = 0; i < slink->totscript; i++) {
- if (text == (Text *)slink->scripts[i]) {
-
- for (j = i; j < slink->totscript - 1; j++) {
- slink->flag[j] = slink->flag[j+1];
- slink->scripts[j] = slink->scripts[j+1];
- }
- slink->totscript--;
- /* like done in buttons_script.c we just free memory
- * if all slinks have been removed -- less fragmentation,
- * these should be quite small arrays */
- if (slink->totscript == 0) {
- if (slink->scripts) MEM_freeN(slink->scripts);
- if (slink->flag) MEM_freeN(slink->flag);
- break;
- }
- }
- }
- return 0;
-}
-
-int BPY_add_spacehandler(Text *text, ScrArea *sa, char spacetype)
-{
- unsigned short handlertype;
-
- if (!sa || !text) return -1;
-
- handlertype = (unsigned short)BPY_is_spacehandler(text, spacetype);
-
- if (handlertype) {
- ScriptLink *slink = &sa->scriptlink;
- void *stmp, *ftmp;
- unsigned short space_event = SPACEHANDLER_VIEW3D_EVENT;
-
- /* extend slink */
-
- stmp= slink->scripts;
- slink->scripts= MEM_mallocN(sizeof(ID*)*(slink->totscript+1),
- "spacehandlerscripts");
-
- ftmp= slink->flag;
- slink->flag= MEM_mallocN(sizeof(short*)*(slink->totscript+1),
- "spacehandlerflags");
-
- if (slink->totscript) {
- memcpy(slink->scripts, stmp, sizeof(ID*)*(slink->totscript));
- MEM_freeN(stmp);
-
- memcpy(slink->flag, ftmp, sizeof(short)*(slink->totscript));
- MEM_freeN(ftmp);
- }
-
- switch (spacetype) {
- case SPACE_VIEW3D:
- if (handlertype == 1) space_event = SPACEHANDLER_VIEW3D_EVENT;
- else space_event = SPACEHANDLER_VIEW3D_DRAW;
- break;
- default:
- break;
- }
-
- slink->scripts[slink->totscript] = (ID *)text;
- slink->flag[slink->totscript]= space_event;
-
- slink->totscript++;
- slink->actscript = slink->totscript;
-
- }
- return 0;
-}
-
-int BPY_do_spacehandlers( ScrArea *sa, unsigned short event,
- unsigned short space_event )
-{
- ScriptLink *scriptlink;
- int retval = 0;
-
- if (!sa || !(G.f & G_DOSCRIPTLINKS)) return 0;
-
- scriptlink = &sa->scriptlink;
-
- if (scriptlink->totscript > 0) {
- PyObject *dict;
- PyObject *ret;
- int index, during_slink = during_scriptlink();
-
- /* invalid scriptlinks (new .blend was just loaded), return */
- if (during_slink < 0) return 0;
-
- /* tell we're running a scriptlink. The sum also tells if this script
- * is running nested inside another. Blender.Load needs this info to
- * avoid trouble with invalid slink pointers.
- * Update (test): allow EVENT space handlers to call file/image selectors,
- * still disabled for DRAW space handlers: */
- if (event == 0) { /* event = 0: DRAW space handler */
- during_slink++;
- disable_where_scriptlink( (short)during_slink );
- }
-
- if( !setup_armature_weakrefs()){
- printf("Oops - weakref dict, this is a bug\n");
- return 0;
- }
-
- /* set globals in Blender module to identify space handler scriptlink */
- PyDict_SetItemString(g_blenderdict, "bylink", Py_True);
- /* unlike normal scriptlinks, here Blender.link is int (space event type) */
- EXPP_dict_set_item_str(g_blenderdict, "link", PyInt_FromLong(space_event));
- /* note: DRAW space_events set event to 0 */
- EXPP_dict_set_item_str(g_blenderdict, "event", PyInt_FromLong(event));
- /* now run all assigned space handlers for this space and space_event */
- for( index = 0; index < scriptlink->totscript; index++ ) {
-
- /* for DRAW handlers: */
- if (event == 0) {
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- }
-
- if( ( scriptlink->flag[index] == space_event ) &&
- ( scriptlink->scripts[index] != NULL ) ) {
- dict = CreateGlobalDictionary();
- ret = RunPython( ( Text * ) scriptlink->scripts[index], dict );
- ReleaseGlobalDictionary( dict );
-
- if (!ret) { /* Failed execution of the script */
- BPY_Err_Handle( scriptlink->scripts[index]->name+2 );
- } else {
- Py_DECREF(ret);
-
- /* an EVENT type (event != 0) script can either accept an event or
- * ignore it:
- * if the script sets Blender.event to None it accepted it;
- * otherwise the space's event handling callback that called us
- * can go on processing the event */
- if (event && (PyDict_GetItemString(g_blenderdict,"event") == Py_None))
- retval = 1; /* event was swallowed */
- }
-
- /* If a scriptlink has just loaded a new .blend file, the
- * scriptlink pointer became invalid (see api2_2x/Blender.c),
- * so we stop here. */
- if( during_scriptlink( ) == -1 ) {
- during_slink = 1;
- if (event == 0) glPopAttrib();
- break;
- }
- }
-
- /* for DRAW handlers: */
- if (event == 0) {
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glPopAttrib();
- disable_where_scriptlink( (short)(during_slink - 1) );
- }
-
- }
-
- PyDict_SetItemString(g_blenderdict, "bylink", Py_False);
- PyDict_SetItemString(g_blenderdict, "link", Py_None );
- EXPP_dict_set_item_str(g_blenderdict, "event", PyString_FromString(""));
- }
-
- /* retval:
- * space_event is of type EVENT:
- * 0 - event was returned,
- * 1 - event was processed;
- * space_event is of type DRAW:
- * 0 always */
-
- return retval;
-}
-
-/*****************************************************************************
-* Description:
-* Notes:
-*****************************************************************************/
-void BPY_free_scriptlink( struct ScriptLink *slink )
-{
- if( slink->totscript ) {
- if( slink->flag ) {
- MEM_freeN( slink->flag );
- slink->flag= NULL;
- }
- if( slink->scripts ) {
- MEM_freeN( slink->scripts );
- slink->scripts= NULL;
- }
- }
-
- return;
-}
-
-static int CheckAllSpaceHandlers(Text *text)
-{
- bScreen *screen;
- ScrArea *sa;
- ScriptLink *slink;
- int fixed = 0;
-
- for (screen = G.main->screen.first; screen; screen = screen->id.next) {
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- slink = &sa->scriptlink;
- if (!slink->totscript) continue;
- if (BPY_del_spacehandler(text, sa) == 0) fixed++;
- }
- }
- return fixed;
-}
-
-static int CheckAllScriptsFromList( ListBase * list, Text * text )
-{
- ID *id;
- ScriptLink *scriptlink;
- int index;
- int fixed = 0;
-
- id = list->first;
-
- while( id != NULL ) {
- scriptlink = ID_getScriptlink( id );
- if( scriptlink && scriptlink->totscript ) {
- for( index = 0; index < scriptlink->totscript; index++) {
- if ((Text *)scriptlink->scripts[index] == text) {
- scriptlink->scripts[index] = NULL;
- fixed++;
- }
- }
- }
- id = id->next;
- }
-
- return fixed;
-}
-
-/* When a Text is deleted, we need to unlink it from eventual scriptlinks */
-int BPY_check_all_scriptlinks( Text * text )
-{
- int fixed = 0;
- fixed += CheckAllScriptsFromList( &( G.main->object ), text );
- fixed += CheckAllScriptsFromList( &( G.main->lamp ), text );
- fixed += CheckAllScriptsFromList( &( G.main->camera ), text );
- fixed += CheckAllScriptsFromList( &( G.main->mat ), text );
- fixed += CheckAllScriptsFromList( &( G.main->world ), text );
- fixed += CheckAllScriptsFromList( &( G.main->scene ), text );
- fixed += CheckAllSpaceHandlers(text);
-
- return fixed;
-}
-
-/*****************************************************************************
-* Description:
-* Notes:
-*****************************************************************************/
-void BPY_copy_scriptlink( struct ScriptLink *scriptlink )
-{
- void *tmp;
-
- if( scriptlink->totscript ) {
-
- tmp = scriptlink->scripts;
- scriptlink->scripts =
- MEM_mallocN( sizeof( ID * ) * scriptlink->totscript,
- "scriptlistL" );
- memcpy( scriptlink->scripts, tmp,
- sizeof( ID * ) * scriptlink->totscript );
-
- tmp = scriptlink->flag;
- scriptlink->flag =
- MEM_mallocN( sizeof( short ) * scriptlink->totscript,
- "scriptlistF" );
- memcpy( scriptlink->flag, tmp,
- sizeof( short ) * scriptlink->totscript );
- }
-
- return;
-}
-
-/****************************************************************************
-* Description:
-* Notes: Not implemented yet
-*****************************************************************************/
-int BPY_call_importloader( char *name )
-{ /* XXX Should this function go away from Blender? */
- printf( "In BPY_call_importloader(name=%s)\n", name );
- return ( 0 );
-}
-
-/*****************************************************************************
-* Private functions
-*****************************************************************************/
-
-/*****************************************************************************
-* Description: This function executes the python script passed by text.
-* The Python dictionary containing global variables needs to
-* be passed in globaldict.
-*****************************************************************************/
-PyObject *RunPython( Text * text, PyObject * globaldict )
-{
- char *buf = NULL;
-
-/* The script text is compiled to Python bytecode and saved at text->compiled
- * to speed-up execution if the user executes the script multiple times */
-
- if( !text->compiled ) { /* if it wasn't already compiled, do it now */
- buf = txt_to_buf( text );
-
- text->compiled =
- Py_CompileString( buf, GetName( text ),
- Py_file_input );
-
- MEM_freeN( buf );
-
- if( PyErr_Occurred( ) ) {
- BPY_free_compiled_text( text );
- return NULL;
- }
-
- }
-
- return PyEval_EvalCode( text->compiled, globaldict, globaldict );
-}
-
-/*****************************************************************************
-* Description: This function returns the value of the name field of the
-* given Text struct.
-*****************************************************************************/
-char *GetName( Text * text )
-{
- return ( text->id.name + 2 );
-}
-
-/*****************************************************************************
-* Description: This function creates a new Python dictionary object.
-*****************************************************************************/
-PyObject *CreateGlobalDictionary( void )
-{
- PyObject *dict = PyDict_New( );
-
- PyDict_SetItemString( dict, "__builtins__", PyEval_GetBuiltins( ) );
- EXPP_dict_set_item_str( dict, "__name__",
- PyString_FromString( "__main__" ) );
-
- return dict;
-}
-
-/*****************************************************************************
-* Description: This function deletes a given Python dictionary object.
-*****************************************************************************/
-void ReleaseGlobalDictionary( PyObject * dict )
-{
- PyDict_Clear( dict );
- Py_DECREF( dict ); /* Release dictionary. */
-
- return;
-}
-
-/***************************************************************************
-* Description: This function runs all scripts (if any) present in the
-* list argument. The event by which the function has been
-* called, is passed in the event argument.
-*****************************************************************************/
-void DoAllScriptsFromList( ListBase * list, short event )
-{
- ID *id;
-
- id = list->first;
-
- while( id != NULL ) {
- BPY_do_pyscript( id, event );
- id = id->next;
- }
-
- return;
-}
-
-PyObject *importText( char *name )
-{
- Text *text;
- char *txtname;
- char *buf = NULL;
- int namelen = strlen( name );
-
- txtname = malloc( namelen + 3 + 1 );
- if( !txtname )
- return NULL;
-
- memcpy( txtname, name, namelen );
- memcpy( &txtname[namelen], ".py", 4 );
-
- text = ( Text * ) & ( G.main->text.first );
-
- while( text ) {
- if( !strcmp( txtname, GetName( text ) ) )
- break;
- text = text->id.next;
- }
-
- if( !text ) {
- free( txtname );
- return NULL;
- }
-
- if( !text->compiled ) {
- buf = txt_to_buf( text );
- text->compiled =
- Py_CompileString( buf, GetName( text ),
- Py_file_input );
- MEM_freeN( buf );
-
- if( PyErr_Occurred( ) ) {
- PyErr_Print( );
- BPY_free_compiled_text( text );
- free( txtname );
- return NULL;
- }
- }
-
- free( txtname );
- return PyImport_ExecCodeModule( name, text->compiled );
-}
-
-static PyMethodDef bimport[] = {
- {"blimport", blender_import, METH_VARARGS, "our own import"}
-};
-
-PyObject *blender_import( PyObject * self, PyObject * args )
-{
- PyObject *exception, *err, *tb;
- char *name;
- PyObject *globals = NULL, *locals = NULL, *fromlist = NULL;
- PyObject *m;
-
- if( !PyArg_ParseTuple( args, "s|OOO:bimport",
- &name, &globals, &locals, &fromlist ) )
- return NULL;
-
- m = PyImport_ImportModuleEx( name, globals, locals, fromlist );
-
- if( m )
- return m;
- else
- PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */
-
- m = importText( name );
- if( m ) { /* found module, ignore above exception */
- PyErr_Clear( );
- Py_XDECREF( exception );
- Py_XDECREF( err );
- Py_XDECREF( tb );
- printf( "imported from text buffer...\n" );
- } else {
- PyErr_Restore( exception, err, tb );
- }
- return m;
-}
-
-void init_ourImport( void )
-{
- PyObject *m, *d;
- PyObject *import = PyCFunction_New( bimport, NULL );
-
- m = PyImport_AddModule( "__builtin__" );
- d = PyModule_GetDict( m );
-
- EXPP_dict_set_item_str( d, "__import__", import );
-}
-
-/*
- * find in-memory module and recompile
- */
-
-static PyObject *reimportText( PyObject *module )
-{
- Text *text;
- char *txtname;
- char *name;
- char *buf = NULL;
-
- /* get name, filename from the module itself */
-
- txtname = PyModule_GetFilename( module );
- name = PyModule_GetName( module );
- if( !txtname || !name)
- return NULL;
-
- /* look up the text object */
- text = ( Text * ) & ( G.main->text.first );
- while( text ) {
- if( !strcmp( txtname, GetName( text ) ) )
- break;
- text = text->id.next;
- }
-
- /* uh-oh.... didn't find it */
- if( !text )
- return NULL;
-
- /* if previously compiled, free the object */
- /* (can't see how could be NULL, but check just in case) */
- if( text->compiled ){
- Py_DECREF( (PyObject *)text->compiled );
- }
-
- /* compile the buffer */
- buf = txt_to_buf( text );
- text->compiled = Py_CompileString( buf, GetName( text ),
- Py_file_input );
- MEM_freeN( buf );
-
- /* if compile failed.... return this error */
- if( PyErr_Occurred( ) ) {
- PyErr_Print( );
- BPY_free_compiled_text( text );
- return NULL;
- }
-
- /* make into a module */
- return PyImport_ExecCodeModule( name, text->compiled );
-}
-
-/*
- * our reload() module, to handle reloading in-memory scripts
- */
-
-static PyObject *blender_reload( PyObject * self, PyObject * args )
-{
- PyObject *exception, *err, *tb;
- PyObject *module = NULL;
- PyObject *newmodule = NULL;
-
- /* check for a module arg */
- if( !PyArg_ParseTuple( args, "O:breload", &module ) )
- return NULL;
-
- /* try reimporting from file */
- newmodule = PyImport_ReloadModule( module );
- if( newmodule )
- return newmodule;
-
- /* no file, try importing from memory */
- PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */
-
- newmodule = reimportText( module );
- if( newmodule ) { /* found module, ignore above exception */
- PyErr_Clear( );
- Py_XDECREF( exception );
- Py_XDECREF( err );
- Py_XDECREF( tb );
- } else
- PyErr_Restore( exception, err, tb );
-
- return newmodule;
-}
-
-static PyMethodDef breload[] = {
- {"blreload", blender_reload, METH_VARARGS, "our own reload"}
-};
-
-void init_ourReload( void )
-{
- PyObject *m, *d;
- PyObject *reload = PyCFunction_New( breload, NULL );
-
- m = PyImport_AddModule( "__builtin__" );
- d = PyModule_GetDict( m );
- EXPP_dict_set_item_str( d, "reload", reload );
-}
diff --git a/source/blender/python/BPY_menus.c b/source/blender/python/BPY_menus.c
deleted file mode 100644
index 5f16aa0241b..00000000000
--- a/source/blender/python/BPY_menus.c
+++ /dev/null
@@ -1,1118 +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, Michael Reimpell
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-/*
- *This is the main file responsible for having bpython scripts accessible
- * from Blender menus. To know more, please start with its header file.
- */
-
-#include "BPY_menus.h"
-
-#include <Python.h>
-#ifndef WIN32
- #include <dirent.h>
-#else
- #include "BLI_winstuff.h"
-#endif
-#include "BKE_global.h"
-#include "BKE_utildefines.h"
-#include "BLI_blenlib.h"
-#include "MEM_guardedalloc.h"
-#include "DNA_userdef_types.h" /* for U.pythondir */
-#include "api2_2x/EXPP_interface.h" /* for bpy_gethome() */
-
-#define BPYMENU_DATAFILE "Bpymenus"
-#define MAX_DIR_DEPTH 4 /* max depth for traversing scripts dirs */
-#define MAX_DIR_NUMBER 30 /* max number of dirs in scripts dirs trees */
-
-static int DEBUG;
-static int Dir_Depth;
-static int Dirs_Number;
-
-/* BPyMenuTable holds all registered pymenus, as linked lists for each menu
- * where they can appear (see PYMENUHOOKS enum in BPY_menus.h).
-*/
-BPyMenu *BPyMenuTable[PYMENU_TOTAL];
-
-static int bpymenu_group_atoi( char *str )
-{
- if( !strcmp( str, "Export" ) )
- return PYMENU_EXPORT;
- else if( !strcmp( str, "Import" ) )
- return PYMENU_IMPORT;
- else if( !strcmp( str, "Help" ) )
- return PYMENU_HELP;
- else if( !strcmp( str, "HelpWebsites" ) )
- return PYMENU_HELPWEBSITES;
- else if( !strcmp( str, "HelpSystem" ) )
- return PYMENU_HELPSYSTEM;
- else if( !strcmp( str, "Render" ) )
- return PYMENU_RENDER;
- else if( !strcmp( str, "System" ) )
- return PYMENU_SYSTEM;
- else if( !strcmp( str, "Object" ) )
- return PYMENU_OBJECT;
- else if( !strcmp( str, "Mesh" ) )
- return PYMENU_MESH;
- else if( !strncmp( str, "Theme", 5 ) )
- return PYMENU_THEMES;
- else if( !strcmp( str, "Add" ) )
- return PYMENU_ADD;
- else if( !strcmp( str, "Wizards" ) )
- return PYMENU_WIZARDS;
- else if( !strcmp( str, "Animation" ) )
- return PYMENU_ANIMATION;
- else if( !strcmp( str, "Materials" ) )
- return PYMENU_MATERIALS;
- else if( !strcmp( str, "UV" ) )
- return PYMENU_UV;
- else if( !strcmp( str, "Image" ) )
- return PYMENU_IMAGE;
- else if( !strcmp( str, "FaceSelect" ) )
- return PYMENU_FACESELECT;
- else if( !strcmp( str, "WeightPaint" ) )
- return PYMENU_WEIGHTPAINT;
- else if( !strcmp( str, "VertexPaint" ) )
- return PYMENU_VERTEXPAINT;
- else if( !strcmp( str, "UVCalculation" ) )
- return PYMENU_UVCALCULATION;
- else if( !strcmp( str, "Armature" ) )
- return PYMENU_ARMATURE;
- else if( !strcmp( str, "ScriptTemplate" ) )
- return PYMENU_SCRIPTTEMPLATE;
- else if( !strcmp( str, "MeshFaceKey" ) )
- return PYMENU_MESHFACEKEY;
- else if( !strcmp( str, "AddMesh" ) )
- return PYMENU_ADDMESH;
- /* "Misc" or an inexistent group name: use misc */
- else
- return PYMENU_MISC;
-}
-
-char *BPyMenu_group_itoa( short menugroup )
-{
- switch ( menugroup ) {
- case PYMENU_EXPORT:
- return "Export";
- break;
- case PYMENU_IMPORT:
- return "Import";
- break;
- case PYMENU_ADD:
- return "Add";
- break;
- case PYMENU_HELP:
- return "Help";
- break;
- case PYMENU_HELPWEBSITES:
- return "HelpWebsites";
- break;
- case PYMENU_HELPSYSTEM:
- return "HelpSystem";
- break;
- case PYMENU_RENDER:
- return "Render";
- break;
- case PYMENU_SYSTEM:
- return "System";
- break;
- case PYMENU_OBJECT:
- return "Object";
- break;
- case PYMENU_MESH:
- return "Mesh";
- break;
- case PYMENU_THEMES:
- return "Themes";
- break;
- case PYMENU_WIZARDS:
- return "Wizards";
- break;
- case PYMENU_ANIMATION:
- return "Animation";
- break;
- case PYMENU_MATERIALS:
- return "Materials";
- break;
- case PYMENU_UV:
- return "UV";
- break;
- case PYMENU_IMAGE:
- return "Image";
- break;
- case PYMENU_FACESELECT:
- return "FaceSelect";
- break;
- case PYMENU_WEIGHTPAINT:
- return "WeightPaint";
- break;
- case PYMENU_VERTEXPAINT:
- return "VertexPaint";
- break;
- case PYMENU_UVCALCULATION:
- return "UVCalculation";
- break;
- case PYMENU_ARMATURE:
- return "Armature";
- break;
- case PYMENU_SCRIPTTEMPLATE:
- return "ScriptTemplate";
- break;
- case PYMENU_MESHFACEKEY:
- return "MeshFaceKey";
- break;
- case PYMENU_ADDMESH:
- return "AddMesh";
- break;
- case PYMENU_MISC:
- return "Misc";
- break;
- }
- return NULL;
-}
-
-/* BPyMenu_CreatePupmenuStr:
- * build and return a meaninful string to be used by pupmenu(). The
- * string is made of a bpymenu name as title and its submenus as possible
- * choices for the user.
-*/
-char *BPyMenu_CreatePupmenuStr( BPyMenu * pym, short menugroup )
-{
- BPySubMenu *pysm = pym->submenus;
- char str[1024], str2[100];
- int i = 0, rlen;
-
- if( !pym || !pysm )
- return NULL;
-
- str[0] = '\0';
-
- PyOS_snprintf( str2, sizeof( str2 ), "%s: %s%%t",
- BPyMenu_group_itoa( menugroup ), pym->name );
- strcat( str, str2 );
-
- while( pysm ) {
- PyOS_snprintf( str2, sizeof( str2 ), "|%s%%x%d", pysm->name,
- i );
- rlen = sizeof( str ) - strlen( str );
- strncat( str, str2, rlen );
- i++;
- pysm = pysm->next;
- }
-
- return BLI_strdup( str );
-}
-
-static void bpymenu_RemoveAllSubEntries( BPySubMenu * smenu )
-{
- BPySubMenu *tmp;
-
- while( smenu ) {
- tmp = smenu->next;
- if( smenu->name )
- MEM_freeN( smenu->name );
- if( smenu->arg )
- MEM_freeN( smenu->arg );
- MEM_freeN( smenu );
- smenu = tmp;
- }
- return;
-}
-
-void BPyMenu_RemoveAllEntries( void )
-{
- BPyMenu *tmp, *pymenu;
- int i;
-
- for( i = 0; i < PYMENU_TOTAL; i++ ) {
- pymenu = BPyMenuTable[i];
- while( pymenu ) {
- tmp = pymenu->next;
- if( pymenu->name )
- MEM_freeN( pymenu->name );
- if( pymenu->filename )
- MEM_freeN( pymenu->filename );
- if( pymenu->tooltip )
- MEM_freeN( pymenu->tooltip );
- if( pymenu->submenus )
- bpymenu_RemoveAllSubEntries( pymenu->
- submenus );
- MEM_freeN( pymenu );
- pymenu = tmp;
- }
- BPyMenuTable[i] = NULL;
- }
-
- Dirs_Number = 0;
- Dir_Depth = 0;
-
- return;
-}
-
-static BPyMenu *bpymenu_FindEntry( short group, char *name )
-{
- BPyMenu *pymenu;
-
- if( ( group < 0 ) || ( group >= PYMENU_TOTAL ) )
- return NULL;
-
- pymenu = BPyMenuTable[group];
-
- while( pymenu ) {
- if( !strcmp( pymenu->name, name ) )
- return pymenu;
- pymenu = pymenu->next;
- }
-
- return NULL;
-}
-
-/* BPyMenu_GetEntry:
- * given a group and a position, return the entry in that position from
- * that group.
-*/
-BPyMenu *BPyMenu_GetEntry( short group, short pos )
-{
- BPyMenu *pym = NULL;
-
- if( ( group < 0 ) || ( group >= PYMENU_TOTAL ) )
- return NULL;
-
- pym = BPyMenuTable[group];
-
- while( pos-- ) {
- if( pym )
- pym = pym->next;
- else
- break;
- }
-
- return pym; /* found entry or NULL */
-}
-
-static void bpymenu_set_tooltip( BPyMenu * pymenu, char *tip )
-{
- if( !pymenu )
- return;
-
- if( pymenu->tooltip )
- MEM_freeN( pymenu->tooltip );
- pymenu->tooltip = BLI_strdup( tip );
-
- return;
-}
-
-/* bpymenu_AddEntry:
- * try to find an existing pymenu entry with the given type and name;
- * if found, update it with new info, otherwise create a new one and fill it.
- */
-static BPyMenu *bpymenu_AddEntry( short group, short version, char *name,
- char *fname, int is_userdir, char *tooltip )
-{
- BPyMenu *menu, *next = NULL, **iter;
- int nameclash = 0;
-
- if( ( group < 0 ) || ( group >= PYMENU_TOTAL ) )
- return NULL;
- if( !name || !fname )
- return NULL;
-
- menu = bpymenu_FindEntry( group, name ); /* already exists? */
-
- /* if a menu with this name already exists in the same group:
- * - if one script is in the default dir and the other in U.pythondir,
- * accept and let the new one override the other.
- * - otherwise, report the error and return NULL. */
- if( menu ) {
- if( menu->dir < is_userdir ) { /* new one is in U.pythondir */
- nameclash = 1;
- if( menu->name )
- MEM_freeN( menu->name );
- if( menu->filename )
- MEM_freeN( menu->filename );
- if( menu->tooltip )
- MEM_freeN( menu->tooltip );
- if( menu->submenus )
- bpymenu_RemoveAllSubEntries( menu->submenus );
- next = menu->next;
- } else { /* they are in the same dir */
- if (DEBUG) {
- fprintf(stderr, "\n\
-Warning: script %s's menu name is already in use.\n\
-Edit the script and change its \n\
-Name: '%s'\n\
-field, please.\n\
-Note: if you really want to have two scripts for the same menu with\n\
-the same name, keep one in the default dir and the other in\n\
-the user defined dir (only the later will be registered).\n", fname, name);
- }
- return NULL;
- }
- } else
- menu = MEM_mallocN( sizeof( BPyMenu ), "pymenu" );
-
- if( !menu )
- return NULL;
-
- menu->name = BLI_strdup( name );
- menu->version = version;
- menu->filename = BLI_strdup( fname );
- menu->tooltip = NULL;
- if( tooltip )
- menu->tooltip = BLI_strdup( tooltip );
- menu->dir = is_userdir;
- menu->submenus = NULL;
- menu->next = next; /* non-NULL if menu already existed */
-
- if( nameclash )
- return menu; /* no need to place it, it's already at the list */
- else { /* insert the new entry in its correct position at the table */
- BPyMenu *prev = NULL;
- char *s = NULL;
-
- iter = &BPyMenuTable[group];
- while( *iter ) {
- s = ( *iter )->name;
- if( s )
- if( strcmp( menu->name, s ) < 0 )
- break; /* sort by names */
- prev = *iter;
- iter = &( ( *iter )->next );
- }
-
- if( *iter ) { /* prepend */
- menu->next = *iter;
- if( prev )
- prev->next = menu;
- else
- BPyMenuTable[group] = menu; /* is first entry */
- } else
- *iter = menu; /* append */
- }
-
- return menu;
-}
-
-/* bpymenu_AddSubEntry:
- * add a submenu to an existing python menu.
- */
-static int bpymenu_AddSubEntry( BPyMenu * mentry, char *name, char *arg )
-{
- BPySubMenu *smenu, **iter;
-
- smenu = MEM_mallocN( sizeof( BPySubMenu ), "pysubmenu" );
- if( !smenu )
- return -1;
-
- smenu->name = BLI_strdup( name );
- smenu->arg = BLI_strdup( arg );
- smenu->next = NULL;
-
- if( !smenu->name || !smenu->arg )
- return -1;
-
- iter = &( mentry->submenus );
- while( *iter )
- iter = &( ( *iter )->next );
-
- *iter = smenu;
-
- return 0;
-}
-
-/* bpymenu_CreateFromFile:
- * parse the bpymenus data file where Python menu data is stored;
- * based on this data, create and fill the pymenu structs.
- */
-static int bpymenu_CreateFromFile( void )
-{
- FILE *fp;
- char line[255], w1[255], w2[255], tooltip[255], *tip;
- char *homedir = NULL;
- int parsing, version, is_userdir;
- short group;
- BPyMenu *pymenu = NULL;
-
- /* init global bpymenu table (it is a list of pointers to struct BPyMenus
- * for each available cathegory: import, export, etc.) */
- for( group = 0; group < PYMENU_TOTAL; group++ )
- BPyMenuTable[group] = NULL;
-
- /* let's try to open the file with bpymenu data */
- homedir = bpy_gethome(0);
- if (!homedir) {
- if( DEBUG )
- fprintf(stderr,
- "BPyMenus error: couldn't open config file Bpymenus: no home dir.\n");
- return -1;
- }
-
- BLI_make_file_string( "/", line, homedir, BPYMENU_DATAFILE );
-
- fp = fopen( line, "rb" );
-
- if( !fp ) {
- if( DEBUG )
- fprintf(stderr, "BPyMenus error: couldn't open config file %s.\n", line );
- return -1;
- }
-
- fgets( line, 255, fp ); /* header */
-
- /* check if the U.pythondir we saved at the file is different from the
- * current one. If so, return to force updating from dirs */
- w1[0] = '\0';
- fscanf( fp, "# User defined scripts dir: %[^\n]\n", w1 );
- if( w1 ) {
- char upythondir[FILE_MAXDIR];
-
- BLI_strncpy(upythondir, U.pythondir, FILE_MAXDIR);
- BLI_convertstringcode(upythondir, G.sce, 0);
- if( strcmp( w1, upythondir ) != 0 )
- return -1;
- w1[0] = '\0';
- }
-
- while( fgets( line, 255, fp ) ) { /* parsing file lines */
-
- switch ( line[0] ) { /* check first char */
- case '#': /* comment */
- continue;
- break;
- case '\n':
- continue;
- break;
- default:
- parsing = sscanf( line, "%s {\n", w1 ); /* menu group */
- break;
- }
-
- if( parsing == 1 ) { /* got menu group string */
- group = (short)bpymenu_group_atoi( w1 );
- if( group < 0 && DEBUG ) { /* invalid type */
- fprintf(stderr,
- "BPyMenus error parsing config file: wrong group: %s,\n\
-will use 'Misc'.\n", w1 );
- }
- } else
- continue;
-
- for(;;) {
- tip = NULL; /* optional tooltip */
- fgets( line, 255, fp );
- if( line[0] == '}' )
- break;
- else if( line[0] == '\n' )
- continue;
- else if( line[0] == '\'' ) { /* menu entry */
- parsing =
- sscanf( line,
- "'%[^']' %d %s %d '%[^']'\n",
- w1, &version, w2, &is_userdir,
- tooltip );
-
- if( parsing <= 0 ) { /* invalid line, get rid of it */
- fgets( line, 255, fp );
- } else if( parsing == 5 )
- tip = tooltip; /* has tooltip */
-
- pymenu = bpymenu_AddEntry( group,
- ( short ) version,
- w1, w2, is_userdir,
- tip );
- if( !pymenu ) {
- puts( "BPyMenus error: couldn't create bpymenu entry.\n" );
- fclose( fp );
- return -1;
- }
- } else if( line[0] == '|' && line[1] == '_' ) { /* menu sub-entry */
- if( !pymenu )
- continue; /* no menu yet, skip this line */
- sscanf( line, "|_%[^:]: %s\n", w1, w2 );
- bpymenu_AddSubEntry( pymenu, w1, w2 );
- }
- }
- }
-
- fclose( fp );
- return 0;
-}
-
-/* bpymenu_WriteDataFile:
- * writes the registered scripts info to the user's home dir, for faster
- * access when the scripts dir hasn't changed.
-*/
-static void bpymenu_WriteDataFile( void )
-{
- BPyMenu *pymenu;
- BPySubMenu *smenu;
- FILE *fp;
- char fname[FILE_MAXDIR], *homedir;
- int i;
-
- homedir = bpy_gethome(0);
-
- if (!homedir) {
- if( DEBUG )
- fprintf(stderr,
- "BPyMenus error: couldn't write Bpymenus file: no home dir.\n\n");
- return;
- }
-
- BLI_make_file_string( "/", fname, homedir, BPYMENU_DATAFILE );
-
- fp = fopen( fname, "w" );
- if( !fp ) {
- if( DEBUG )
- fprintf(stderr, "BPyMenus error: couldn't write %s file.\n\n",
- fname );
- return;
- }
-
- fprintf( fp,
- "# Blender: registered menu entries for bpython scripts\n" );
-
- if (U.pythondir[0] != '\0' &&
- strcmp(U.pythondir, "/") != 0 && strcmp(U.pythondir, "//") != 0)
- {
- char upythondir[FILE_MAXDIR];
-
- BLI_strncpy(upythondir, U.pythondir, FILE_MAXDIR);
- BLI_convertstringcode(upythondir, G.sce, 0);
- fprintf( fp, "# User defined scripts dir: %s\n", upythondir );
- }
-
- for( i = 0; i < PYMENU_TOTAL; i++ ) {
- pymenu = BPyMenuTable[i];
- if( !pymenu )
- continue;
- fprintf( fp, "\n%s {\n", BPyMenu_group_itoa( (short)i ) );
- while( pymenu ) {
- fprintf( fp, "'%s' %d %s %d", pymenu->name,
- pymenu->version, pymenu->filename,
- pymenu->dir );
- if( pymenu->tooltip )
- fprintf( fp, " '%s'\n", pymenu->tooltip );
- else
- fprintf( fp, "\n" );
- smenu = pymenu->submenus;
- while( smenu ) {
- fprintf( fp, "|_%s: %s\n", smenu->name,
- smenu->arg );
- smenu = smenu->next;
- }
- pymenu = pymenu->next;
- }
- fprintf( fp, "}\n" );
- }
-
- fclose( fp );
- return;
-}
-
-/* BPyMenu_PrintAllEntries:
- * useful for debugging.
- */
-void BPyMenu_PrintAllEntries( void )
-{
- BPyMenu *pymenu;
- BPySubMenu *smenu;
- int i;
-
- printf( "# Blender: registered menu entries for bpython scripts\n" );
-
- for( i = 0; i < PYMENU_TOTAL; i++ ) {
- pymenu = BPyMenuTable[i];
- printf( "\n%s {\n", BPyMenu_group_itoa( (short)i ) );
- while( pymenu ) {
- printf( "'%s' %d %s %d", pymenu->name, pymenu->version,
- pymenu->filename, pymenu->dir );
- if( pymenu->tooltip )
- printf( " '%s'\n", pymenu->tooltip );
- else
- printf( "\n" );
- smenu = pymenu->submenus;
- while( smenu ) {
- printf( "|_%s: %s\n", smenu->name,
- smenu->arg );
- smenu = smenu->next;
- }
- pymenu = pymenu->next;
- }
- printf( "}\n" );
- }
-}
-
-/* bpymenu_ParseFile:
- * recursively scans folders looking for scripts to register.
- *
- * This function scans the scripts directory looking for .py files with the
- * right header and menu info, using that to fill the bpymenu structs.
- * is_userdir defines if the script is in the default scripts dir or the
- * user defined one (U.pythondir: is_userdir == 1).
- * Speed is important.
- *
- * The first line of the script must be '#!BPY'.
- * The header registration lines must appear between the first pair of
- * '\"\"\"' and follow this order (the single-quotes are part of
- * the format):
- *
- * # \"\"\"<br>
- * # Name: 'script name for the menu'
- * # Blender: <code>short int</code> (minimal Blender version)
- * # Group: 'group name' (defines menu)
- * # Submenu: 'submenu name' related_1word_arg
- * # Tooltip: 'tooltip for the menu'
- * # \"\"\"
- *
- * Notes:
- *
- * - Commenting out header lines with "#" is optional, but recommended.
- * - There may be more than one submenu line, or none:
- * submenus and the tooltip are optional;
- * - The Blender version is the same number reported by
- * Blender.Get('version') in BPython or G.version in C;
- * - Line length must be less than 99.
- */
-static int bpymenu_ParseFile(FILE *file, char *fname, int is_userdir)
-{
- char line[100];
- char head[100];
- char middle[100];
- char tail[100];
- int matches;
- int parser_state;
-
- char script_name[100];
- int script_version = 1;
- int script_group;
-
- BPyMenu *scriptMenu = NULL;
-
- if (file != NULL) {
- parser_state = 1; /* state of parser, 0 to terminate */
-
- while ((parser_state != 0) && (fgets(line, 100, file) != NULL)) {
-
- switch (parser_state) {
-
- case 1: /* !BPY */
- if (strncmp(line, "#!BPY", 5) == 0) {
- parser_state++;
- } else {
- parser_state = 0;
- }
- break;
-
- case 2: /* \"\"\" */
- if ((strstr(line, "\"\"\""))) {
- parser_state++;
- }
- break;
-
- case 3: /* Name: 'script name for the menu' */
- matches = sscanf(line, "%[^']'%[^']'%c", head, script_name, tail);
- if ((matches == 3) && (strstr(head, "Name:") != NULL)) {
- parser_state++;
- } else {
- if (DEBUG)
- fprintf(stderr, "BPyMenus error: Wrong 'Name' line: %s\n", fname);
- parser_state = 0;
- }
- break;
-
- case 4: /* Blender: <short int> */
- matches = sscanf(line, "%[^1234567890]%i%c", head, &script_version,
- tail);
- if (matches == 3) {
- parser_state++;
- } else {
- if (DEBUG)
- fprintf(stderr,"BPyMenus error: Wrong 'Blender' line: %s\n",fname);
- parser_state = 0;
- }
- break;
-
- case 5: /* Group: 'group name' */
- matches = sscanf(line, "%[^']'%[^']'%c", head, middle, tail);
- if ((matches == 3) && (strstr(head, "Group:") != NULL)) {
- script_group = bpymenu_group_atoi(middle);
- if (script_group < 0) {
- if (DEBUG)
- fprintf(stderr, "BPyMenus error: Unknown group \"%s\": %s\n",
- middle, fname);
- parser_state = 0;
- }
-
- else { /* register script */
- scriptMenu = bpymenu_AddEntry((short)script_group,
- (short int)script_version, script_name, fname, is_userdir,NULL);
- if (scriptMenu == NULL) {
- if (DEBUG)
- fprintf(stderr,
- "BPyMenus error: Couldn't create entry for: %s\n", fname);
- parser_state = 0;
- } else {
- parser_state++;
- }
- }
-
- } else {
- if (DEBUG)
- fprintf(stderr, "BPyMenus error: Wrong 'Group' line: %s\n",fname);
- parser_state = 0;
- }
- break;
-
- case 6: /* optional elements */
- /* Submenu: 'submenu name' related_1word_arg */
- matches = sscanf(line, "%[^']'%[^']'%s\n", head, middle, tail);
- if ((matches == 3) && (strstr(head, "Submenu:") != NULL)) {
- bpymenu_AddSubEntry(scriptMenu, middle, tail);
- } else {
- /* Tooltip: 'tooltip for the menu */
- matches = sscanf(line, "%[^']'%[^']'%c", head, middle, tail);
- if ((matches == 3) && ((strstr(head, "Tooltip:") != NULL) ||
- (strstr(head, "Tip:") != NULL))) {
- bpymenu_set_tooltip(scriptMenu, middle);
- }
- parser_state = 0;
- }
- break;
-
- default:
- parser_state = 0;
- break;
- }
- }
- }
-
- else { /* shouldn't happen, it's checked in bpymenus_ParseDir */
- if (DEBUG)
- fprintf(stderr, "BPyMenus error: Couldn't open %s.\n", fname);
- return -1;
- }
-
- return 0;
-}
-
-/* bpymenu_ParseDir:
- * recursively scans folders looking for scripts to register.
- *
- * This function scans the scripts directory looking for .py files with the
- * right header and menu info.
- * - is_userdir defines if the script is in the default scripts dir or the
- * user defined one (U.pythondir: is_userdir == 1);
- * - parentdir is the parent dir name to store as part of the script filename,
- * if we're down a subdir.
- * Speed is important.
- */
-static int bpymenu_ParseDir(char *dirname, char *parentdir, int is_userdir )
-{
- DIR *dir;
- FILE *file = NULL;
- struct dirent *de;
- struct stat status;
- char *file_extension;
- char path[FILE_MAX];
- char subdir[FILE_MAX];
- char *s = NULL;
-
- dir = opendir(dirname);
-
- if (dir != NULL) {
- while ((de = readdir(dir)) != NULL) {
-
- /* skip files and dirs starting with '.' or 'bpy' */
- if ((de->d_name[0] == '.') || !strncmp(de->d_name, "bpy", 3)) {
- continue;
- }
-
- BLI_make_file_string("/", path, dirname, de->d_name);
-
- if (stat(path, &status) != 0) {
- if (DEBUG)
- fprintf(stderr, "stat %s failed: %s\n", path, strerror(errno));
- }
-
- if (S_ISREG(status.st_mode)) { /* is file */
-
- file_extension = strstr(de->d_name, ".py");
-
- if (file_extension && *(file_extension + 3) == '\0') {
- file = fopen(path, "rb");
-
- if (file) {
- s = de->d_name;
- if (parentdir) {
- /* Join parentdir and de->d_name */
- BLI_join_dirfile(subdir, parentdir, de->d_name);
-
- s = subdir;
- }
- bpymenu_ParseFile(file, s, is_userdir);
- fclose(file);
- }
-
- else {
- if (DEBUG)
- fprintf(stderr, "BPyMenus error: Couldn't open %s.\n", path);
- }
- }
- }
-
- else if (S_ISDIR(status.st_mode)) { /* is subdir */
- Dirs_Number++;
- Dir_Depth++;
- if (Dirs_Number > MAX_DIR_NUMBER) {
- if (DEBUG) {
- fprintf(stderr, "BPyMenus error: too many subdirs.\n");
- }
- closedir(dir);
- return -1;
- }
- else if (Dir_Depth > MAX_DIR_DEPTH) {
- if (DEBUG)
- fprintf(stderr,
- "BPyMenus error: max depth reached traversing dir tree.\n");
- closedir(dir);
- return -1;
- }
- s = de->d_name;
- if (parentdir) {
- /* Join parentdir and de->d_name */
- BLI_join_dirfile(subdir, parentdir, de->d_name);
- s = subdir;
- }
- if (bpymenu_ParseDir(path, s, is_userdir) == -1) {
- closedir(dir);
- return -1;
- }
- Dir_Depth--;
- }
-
- }
- closedir(dir);
- }
-
- else { /* open directory stream failed */
- if (DEBUG)
- fprintf(stderr, "opendir %s failed: %s\n", dirname, strerror(errno));
- return -1;
- }
-
- return 0;
-}
-
-static int bpymenu_GetStatMTime( char *name, int is_file, time_t * mtime )
-{
- struct stat st;
- int result;
-
- result = stat( name, &st );
-
- if( result == -1 )
- return -1;
-
- if( is_file ) {
- if( !S_ISREG( st.st_mode ) )
- return -2;
- } else if( !S_ISDIR( st.st_mode ) )
- return -2;
-
- *mtime = st.st_mtime;
-
- return 0;
-}
-
-/* BPyMenu_Init:
- * import the bpython menus data to Blender, either from:
- * - the BPYMENU_DATAFILE file (?/.blender/Bpymenus) or
- * - the scripts dir(s), case newer than the datafile (then update the file).
- * then fill the bpymenu table with this data.
- * if param usedir != 0, then the data is recreated from the dir(s) anyway.
-*/
-int BPyMenu_Init( int usedir )
-{
- char fname[FILE_MAXDIR];
- char dirname[FILE_MAXDIR];
- char upythondir[FILE_MAXDIR];
- char *upydir = U.pythondir, *sdir = NULL;
- time_t time_dir1 = 0, time_dir2 = 0, time_file = 0;
- int stat_dir1 = 0, stat_dir2 = 0, stat_file = 0;
- int i;
-
- DEBUG = G.f & G_DEBUG; /* is Blender in debug mode (started with -d) ? */
-
- /* init global bpymenu table (it is a list of pointers to struct BPyMenus
- * for each available group: import, export, etc.) */
- for( i = 0; i < PYMENU_TOTAL; i++ )
- BPyMenuTable[i] = NULL;
-
- if( DEBUG )
- fprintf(stdout, "\nRegistering scripts in Blender menus ...\n\n" );
-
- if( U.pythondir[0] == '\0') {
- upydir = NULL;
- }
- else if (strcmp(U.pythondir, "/") == 0 || strcmp(U.pythondir, "//") == 0) {
- /* these are not accepted to prevent possible slight slowdowns on startup;
- * they should not be used as user defined scripts dir, anyway, also from
- * speed considerations, since they'd not be dedicated scripts dirs */
- if (DEBUG) fprintf(stderr,
- "BPyMenus: invalid user defined Python scripts dir: \"/\" or \"//\".\n");
- upydir = NULL;
- }
- else {
- BLI_strncpy(upythondir, upydir, FILE_MAXDIR);
- BLI_convertstringcode(upythondir, G.sce, 0);
- }
-
- sdir = bpy_gethome(1);
-
- if (sdir) {
- BLI_strncpy(dirname, sdir, FILE_MAXDIR);
- stat_dir1 = bpymenu_GetStatMTime( dirname, 0, &time_dir1 );
-
- if( stat_dir1 < 0 ) {
- time_dir1 = 0;
- if( DEBUG ) {
- fprintf(stderr,
- "\nDefault scripts dir: %s:\n%s\n", dirname, strerror(errno));
- if( upydir )
- fprintf(stdout,
- "Getting scripts menu data from user defined dir: %s.\n",
- upythondir );
- }
- }
- }
- else stat_dir1 = -1;
-
- if( upydir ) {
- stat_dir2 = bpymenu_GetStatMTime( upythondir, 0, &time_dir2 );
-
- if( stat_dir2 < 0 ) {
- time_dir2 = 0;
- upydir = NULL;
- if( DEBUG )
- fprintf(stderr, "\nUser defined scripts dir: %s:\n%s.\n",
- upythondir, strerror( errno ) );
- if( stat_dir1 < 0 ) {
- if( DEBUG )
- fprintf(stderr, "\
-To have scripts in menus, please add them to the default scripts dir:\n\
-%s\n\
-and / or go to 'Info window -> File Paths tab' and set a valid path for\n\
-the user defined Python scripts dir.\n", dirname );
- return -1;
- }
- }
- }
- else stat_dir2 = -1;
-
- if( ( stat_dir1 < 0 ) && ( stat_dir2 < 0 ) ) {
- if( DEBUG ) {
- fprintf(stderr, "\nCannot register scripts in menus, no scripts dir"
- " available.\nExpected default dir at: %s \n", dirname );
- }
- return -1;
- }
-
- if (usedir) stat_file = -1;
- else { /* if we're not forced to use the dir */
- char *homedir = bpy_gethome(0);
-
- if (homedir) {
- BLI_make_file_string( "/", fname, homedir, BPYMENU_DATAFILE );
- stat_file = bpymenu_GetStatMTime( fname, 1, &time_file );
- if( stat_file < 0 )
- time_file = 0;
-
- /* comparing dates */
-
- if((stat_file == 0)
- && (time_file > time_dir1) && (time_file > time_dir2))
- { /* file is newer */
- stat_file = bpymenu_CreateFromFile( ); /* -1 if an error occurred */
- if( !stat_file && DEBUG )
- fprintf(stdout,
- "Getting menu data for scripts from file:\n%s\n\n", fname );
- }
- else stat_file = -1;
- }
- else stat_file = -1; /* -1 to use dirs: didn't use file or it was corrupted */
- }
-
- if( stat_file == -1 ) { /* use dirs */
- if( DEBUG ) {
- fprintf(stdout,
- "Getting menu data for scripts from dir(s):\ndefault: %s\n", dirname );
- if( upydir )
- fprintf(stdout, "user defined: %s\n", upythondir );
- fprintf(stdout, "\n");
- }
- if( stat_dir1 == 0 ) {
- i = bpymenu_ParseDir( dirname, NULL, 0 );
- if (i == -1 && DEBUG)
- fprintf(stderr, "Default scripts dir does not seem valid.\n\n");
- }
- if( stat_dir2 == 0 ) {
- BLI_strncpy(dirname, U.pythondir, FILE_MAXDIR);
- BLI_convertstringcode(dirname, G.sce, 0);
- i = bpymenu_ParseDir( dirname, NULL, 1 );
- if (i == -1 && DEBUG)
- fprintf(stderr, "User defined scripts dir does not seem valid.\n\n");
- }
-
- /* check if we got any data */
- for( i = 0; i < PYMENU_TOTAL; i++ )
- if( BPyMenuTable[i] )
- break;
-
- /* if we got, recreate the file */
- if( i < PYMENU_TOTAL )
- bpymenu_WriteDataFile( );
- else if( DEBUG ) {
- fprintf(stderr, "\n\
-Warning: Registering scripts in menus -- no info found.\n\
-Either your scripts dirs have no .py scripts or the scripts\n\
-don't have a header with registration data.\n\
-Default scripts dir is:\n\
-%s\n", dirname );
- if( upydir )
- fprintf(stderr, "User defined scripts dir is: %s\n",
- upythondir );
- }
- }
-
- return 0;
-}
diff --git a/source/blender/python/BPY_menus.h b/source/blender/python/BPY_menus.h
deleted file mode 100644
index 89491ce3ef2..00000000000
--- a/source/blender/python/BPY_menus.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/CMakeLists.txt b/source/blender/python/CMakeLists.txt
deleted file mode 100644
index 7df1f8a02d5..00000000000
--- a/source/blender/python/CMakeLists.txt
+++ /dev/null
@@ -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] )
diff --git a/source/blender/python/Makefile b/source/blender/python/Makefile
deleted file mode 100644
index 149e40092f3..00000000000
--- a/source/blender/python/Makefile
+++ /dev/null
@@ -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
diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript
deleted file mode 100644
index 9cd245394b0..00000000000
--- a/source/blender/python/SConscript
+++ /dev/null
@@ -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] )
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
deleted file mode 100644
index f1fb3812625..00000000000
--- a/source/blender/python/api2_2x/Armature.c
+++ /dev/null
@@ -1,1490 +0,0 @@
-/*
- * $Id: Armature.c 12813 2007-12-07 09:51: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.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include <stddef.h>
-
-#include "Armature.h" //This must come first
-
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_armature.h"
-#include "BKE_library.h"
-#include "BKE_depsgraph.h"
-#include "BKE_utildefines.h"
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "MEM_guardedalloc.h"
-#include "Bone.h"
-#include "NLA.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-#include "DNA_object_types.h" //This must come before BIF_editarmature.h...
-#include "BIF_editarmature.h"
-
-//------------------EXTERNAL PROTOTYPES--------------------
-extern void make_boneList(ListBase* list, ListBase *bones, EditBone *parent);
-extern void editbones_to_armature (ListBase *list, Object *ob);
-
-//------------------------ERROR CODES---------------------------------
-//This is here just to make me happy and to have more consistant error strings :)
-static const char sBoneDictError[] = "ArmatureType.bones - Error: ";
-static const char sBoneDictBadArgs[] = "ArmatureType.bones - Bad Arguments: ";
-static const char sArmatureError[] = "ArmatureType - Error: ";
-static const char sArmatureBadArgs[] = "ArmatureType - Bad Arguments: ";
-static const char sModuleError[] = "Blender.Armature - Error: ";
-static const char sModuleBadArgs[] = "Blender.Armature - Bad Arguments: ";
-
-PyObject * arm_weakref_callback_weakref_dealloc(PyObject *self, PyObject *weakref);
-/* python callable */
-PyObject * arm_weakref_callback_weakref_dealloc__pyfunc;
-
-//################## BonesDict_Type (internal) ########################
-/*This is an internal psuedo-dictionary type that allows for manipulation
-* of bones inside of an armature. It is a subobject of armature.
-* i.e. Armature.bones['key']*/
-//#####################################################################
-
-//------------------METHOD IMPLEMENTATIONS-----------------------------
-//------------------------Armature.bones.items()
-//Returns a list of key:value pairs like dict.items()
-static PyObject* BonesDict_items(BPy_BonesDict *self)
-{
- if (self->editmode_flag){
- return PyDict_Items(self->editbonesMap);
- }else{
- return PyDict_Items(self->bonesMap);
- }
-}
-//------------------------Armature.bones.keys()
-//Returns a list of keys like dict.keys()
-static PyObject* BonesDict_keys(BPy_BonesDict *self)
-{
- if (self->editmode_flag){
- return PyDict_Keys(self->editbonesMap);
- }else{
- return PyDict_Keys(self->bonesMap);
- }
-}
-//------------------------Armature.bones.values()
-//Returns a list of values like dict.values()
-static PyObject* BonesDict_values(BPy_BonesDict *self)
-{
- if (self->editmode_flag){
- return PyDict_Values(self->editbonesMap);
- }else{
- return PyDict_Values(self->bonesMap);
- }
-}
-//------------------ATTRIBUTE IMPLEMENTATION---------------------------
-//------------------TYPE_OBECT IMPLEMENTATION-----------------------
-//------------------------tp_doc
-//The __doc__ string for this object
-static char BPy_BonesDict_doc[] = "This is an internal subobject of armature\
-designed to act as a Py_Bone dictionary.";
-
-//------------------------tp_methods
-//This contains a list of all methods the object contains
-static PyMethodDef BPy_BonesDict_methods[] = {
- {"items", (PyCFunction) BonesDict_items, METH_NOARGS,
- "() - Returns the key:value pairs from the dictionary"},
- {"keys", (PyCFunction) BonesDict_keys, METH_NOARGS,
- "() - Returns the keys the dictionary"},
- {"values", (PyCFunction) BonesDict_values, METH_NOARGS,
- "() - Returns the values from the dictionary"},
- {NULL, NULL, 0, NULL}
-};
-//-----------------(internal)
-static int BoneMapping_Init(PyObject *dictionary, ListBase *bones){
- Bone *bone = NULL;
- PyObject *py_bone = NULL;
-
- for (bone = bones->first; bone; bone = bone->next){
- py_bone = PyBone_FromBone(bone);
- if (!py_bone)
- return -1;
-
- if(PyDict_SetItemString(dictionary, bone->name, py_bone) == -1) {
- /* unlikely but possible */
- Py_DECREF(py_bone);
- return -1;
- }
-
- Py_DECREF(py_bone);
- if (bone->childbase.first)
- BoneMapping_Init(dictionary, &bone->childbase);
- }
- return 0;
-}
-//-----------------(internal)
-static int EditBoneMapping_Init(PyObject *dictionary, ListBase *editbones){
- EditBone *editbone = NULL;
- PyObject *py_editbone = NULL;
-
- for (editbone = editbones->first; editbone; editbone = editbone->next){
- py_editbone = PyEditBone_FromEditBone(editbone);
- if (!py_editbone)
- return -1;
-
- if(PyDict_SetItemString(dictionary, editbone->name, py_editbone) == -1) {
- Py_DECREF(py_editbone);
- return -1;
- }
- Py_DECREF(py_editbone);
- }
- return 0;
-}
-//----------------- BonesDict_InitBones
-static int BonesDict_InitBones(BPy_BonesDict *self)
-{
- PyDict_Clear(self->bonesMap);
- if (BoneMapping_Init(self->bonesMap, self->bones) == -1)
- return 0;
- return 1;
-}
-//----------------- BonesDict_InitEditBones
-static int BonesDict_InitEditBones(BPy_BonesDict *self)
-{
- PyDict_Clear(self->editbonesMap);
- if (EditBoneMapping_Init(self->editbonesMap, &self->editbones) == -1)
- return 0;
- return 1;
-}
-//------------------------tp_repr
-//This is the string representation of the object
-static PyObject *BonesDict_repr(BPy_BonesDict *self)
-{
- char str[2048];
- PyObject *key, *value;
- int pos = 0;
- char *p = str;
- char *keys, *vals;
-
- p += sprintf(str, "[Bone Dict: {");
-
- if (self->editmode_flag){
- while (PyDict_Next(self->editbonesMap, &pos, &key, &value)) {
- keys = PyString_AsString(key);
- vals = PyString_AsString(value->ob_type->tp_repr(value));
- if( strlen(str) + strlen(keys) + strlen(vals) < sizeof(str)-20 )
- p += sprintf(p, "%s : %s, ", keys, vals );
- else {
- p += sprintf(p, "...." );
- break;
- }
- }
- }else{
- while (PyDict_Next(self->bonesMap, &pos, &key, &value)) {
- keys = PyString_AsString(key);
- vals = PyString_AsString(value->ob_type->tp_repr(value));
- if( strlen(str) + strlen(keys) + strlen(vals) < sizeof(str)-20 )
- p += sprintf(p, "%s : %s, ", keys, vals );
- else {
- p += sprintf(p, "...." );
- break;
- }
- }
- }
- sprintf(p, "}]");
- return PyString_FromString(str);
-}
-
-//------------------------tp_dealloc
-//This tells how to 'tear-down' our object when ref count hits 0
-static void BonesDict_dealloc(BPy_BonesDict * self)
-{
- Py_DECREF(self->bonesMap);
- Py_DECREF(self->editbonesMap);
- BLI_freelistN(&self->editbones);
- PyObject_DEL( self );
- return;
-}
-//------------------------mp_length
-//This gets the size of the dictionary
-static int BonesDict_len(BPy_BonesDict *self)
-{
- if (self->editmode_flag){
- return BLI_countlist(&self->editbones);
- }else{
- return BLI_countlist(self->bones);
- }
-}
-//-----------------------mp_subscript
-//This defines getting a bone from the dictionary - x = Bones['key']
-static PyObject *BonesDict_GetItem(BPy_BonesDict *self, PyObject* key)
-{
- PyObject *value = NULL;
-
- if (self->editmode_flag){
- value = PyDict_GetItem(self->editbonesMap, key);
- }else{
- value = PyDict_GetItem(self->bonesMap, key);
- }
- if(value == NULL){ /* item not found in dict. throw exception */
- char* key_str = PyString_AsString( key );
- if (key_str) {
- return EXPP_ReturnPyObjError(PyExc_KeyError, "bone key must be a string" );
- } else {
- char buffer[128];
- PyOS_snprintf( buffer, sizeof(buffer), "bone %s not found", key_str);
- return EXPP_ReturnPyObjError(PyExc_KeyError, buffer );
- }
- }
- return EXPP_incr_ret(value);
-}
-//-----------------------mp_ass_subscript
-//This does dict assignment - Bones['key'] = value
-static int BonesDict_SetItem(BPy_BonesDict *self, PyObject *key, PyObject *value)
-{
- BPy_EditBone *editbone_for_deletion;
- struct EditBone *editbone = NULL;
- char *key_str = PyString_AsString(key);
-
- if (!self->editmode_flag)
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sBoneDictBadArgs, "You must call makeEditable() first");
-
- if (!key_str)
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sBoneDictBadArgs, "The key must be the name of an editbone");
-
- if (value && !EditBoneObject_Check(value))
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sBoneDictBadArgs, "Can only assign editbones as values");
-
- //parse value for assignment
- if (value){ /* we know this must be an editbone from the above check */
- //create a new editbone
- editbone = MEM_callocN(sizeof(EditBone), "eBone");
- BLI_strncpy(editbone->name, key_str, 32);
- unique_editbone_name(NULL, editbone->name);
- editbone->dist = ((BPy_EditBone*)value)->dist;
- editbone->ease1 = ((BPy_EditBone*)value)->ease1;
- editbone->ease2 = ((BPy_EditBone*)value)->ease2;
- editbone->flag = ((BPy_EditBone*)value)->flag;
- editbone->parent = ((BPy_EditBone*)value)->parent;
- editbone->rad_head = ((BPy_EditBone*)value)->rad_head;
- editbone->rad_tail = ((BPy_EditBone*)value)->rad_tail;
- editbone->roll = ((BPy_EditBone*)value)->roll;
- editbone->segments = ((BPy_EditBone*)value)->segments;
- editbone->weight = ((BPy_EditBone*)value)->weight;
- editbone->xwidth = ((BPy_EditBone*)value)->xwidth;
- editbone->zwidth = ((BPy_EditBone*)value)->zwidth;
- VECCOPY(editbone->head, ((BPy_EditBone*)value)->head);
- VECCOPY(editbone->tail, ((BPy_EditBone*)value)->tail);
- editbone->layer= ((BPy_EditBone*)value)->layer;
-
- //set object pointer
- ((BPy_EditBone*)value)->editbone = editbone;
-
- //fix the bone's head position if flags indicate that it is 'connected'
- if (editbone->flag & BONE_CONNECTED){
- if(!editbone->parent){
- ((BPy_EditBone*)value)->editbone = NULL;
- MEM_freeN(editbone);
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sBoneDictBadArgs, "The 'connected' flag is set but the bone has no parent!");
- }else{
- VECCOPY(editbone->head, editbone->parent->tail);
- }
- }
-
- //set in editbonelist
- BLI_addtail(&self->editbones, editbone);
-
- //set the new editbone in the mapping
- if(PyDict_SetItemString(self->editbonesMap, key_str, value) == -1){
- ((BPy_EditBone*)value)->editbone = NULL;
- BLI_freelinkN(&self->editbones, editbone);
- return EXPP_intError(PyExc_RuntimeError, "%s%s",
- sBoneDictError, "Unable to access dictionary!");
- }
- }else {
- //they are trying to delete the bone using 'del'
- editbone_for_deletion = (BPy_EditBone*)PyDict_GetItem(self->editbonesMap, key);
-
- if (!editbone_for_deletion)
- return EXPP_intError(PyExc_KeyError, "%s%s%s%s",
- sBoneDictError, "The key: ", key_str, " is not present in this dictionary!");
-
- /*first kill the datastruct then remove the item from the dict
- and wait for GC to pick it up.
- We have to delete the datastruct here because the tp_dealloc
- doesn't handle it*/
-
- /*this is ugly but you have to set the parent to NULL for else
- editbones_to_armature will crash looking for this bone*/
- for (editbone = self->editbones.first; editbone; editbone = editbone->next){
- if (editbone->parent == editbone_for_deletion->editbone) {
- editbone->parent = NULL;
- /* remove the connected flag or else the 'root' ball
- * doesn't get drawn */
- editbone->flag &= ~BONE_CONNECTED;
- }
- }
- BLI_freelinkN(&self->editbones, editbone_for_deletion->editbone);
- if(PyDict_DelItem(self->editbonesMap, key) == -1)
- return EXPP_intError(PyExc_RuntimeError, "%s%s",
- sBoneDictError, "Unable to access dictionary!");
- }
- return 0;
-}
-//------------------TYPE_OBJECT DEFINITION--------------------------
-//Mapping Protocol
-static PyMappingMethods BonesDict_MapMethods = {
- (inquiry) BonesDict_len, //mp_length
- (binaryfunc)BonesDict_GetItem, //mp_subscript
- (objobjargproc)BonesDict_SetItem, //mp_ass_subscript
-};
-//BonesDict TypeObject
-PyTypeObject BonesDict_Type = {
- PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "BonesDict", //tp_name
- sizeof(BPy_BonesDict), //tp_basicsize
- 0, //tp_itemsize
- (destructor)BonesDict_dealloc, //tp_dealloc
- 0, //tp_print
- 0, //tp_getattr
- 0, //tp_setattr
- 0, //tp_compare
- (reprfunc) BonesDict_repr, //tp_repr
- 0, //tp_as_number
- 0, //tp_as_sequence
- &BonesDict_MapMethods, //tp_as_mapping
- 0, //tp_hash
- 0, //tp_call
- 0, //tp_str
- 0, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
- BPy_BonesDict_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- 0, //tp_richcompare
- 0, //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- BPy_BonesDict_methods, //tp_methods
- 0, //tp_members
- 0, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- 0, //tp_init
- 0, //tp_alloc
- 0, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-//-----------------------PyBonesDict_FromPyArmature
-static PyObject *PyBonesDict_FromPyArmature(BPy_Armature *py_armature)
-{
- BPy_BonesDict *py_BonesDict = (BPy_BonesDict *)PyObject_NEW( BPy_BonesDict, &BonesDict_Type );
- if (!py_BonesDict)
- goto RuntimeError;
-
- py_BonesDict->bones = NULL;
- py_BonesDict->editbones.first = py_BonesDict->editbones.last = NULL;
-
- //create internal dictionaries
- py_BonesDict->bonesMap = PyDict_New();
- py_BonesDict->editbonesMap = PyDict_New();
- if (!py_BonesDict->bonesMap || !py_BonesDict->editbonesMap)
- goto RuntimeError;
-
- //set listbase pointer
- py_BonesDict->bones = &py_armature->armature->bonebase;
-
- //now that everything is setup - init the mappings
- if (!BonesDict_InitBones(py_BonesDict))
- goto RuntimeError;
- if (!BonesDict_InitEditBones(py_BonesDict))
- goto RuntimeError;
-
- //set editmode flag
- py_BonesDict->editmode_flag = 0;
-
- return (PyObject*)py_BonesDict;
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s",
- sBoneDictError, "Failed to create class");
-}
-
-//######################### Armature_Type #############################
-/*This type represents a thin wrapper around bArmature data types
-* internal to blender. It contains the psuedo-dictionary BonesDict
-* as an assistant in manipulating it's own bone collection*/
-//#################################################################
-
-//------------------METHOD IMPLEMENTATION------------------------------
-//------------------------Armature.makeEditable()
-static PyObject *Armature_makeEditable(BPy_Armature *self)
-{
- if (self->armature->flag & ARM_EDITMODE)
- goto AttributeError;
-
- make_boneList(&self->Bones->editbones, self->Bones->bones, NULL);
- if (!BonesDict_InitEditBones(self->Bones))
- return NULL;
- self->Bones->editmode_flag = 1;
- return EXPP_incr_ret(Py_None);
-
-AttributeError:
- return EXPP_objError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "The armature cannot be placed manually in editmode before you call makeEditable()!");
-}
-
-//------------------------Armature.update()
-//This is a bit ugly because you need an object link to do this
-static PyObject *Armature_update(BPy_Armature *self)
-{
- Object *obj = NULL;
-
- for (obj = G.main->object.first; obj; obj = obj->id.next){
- if (obj->data == self->armature)
- break;
- }
- if (obj){
- editbones_to_armature (&self->Bones->editbones, obj);
- if (!BonesDict_InitBones(self->Bones))
- return NULL;
- self->Bones->editmode_flag = 0;
- BLI_freelistN(&self->Bones->editbones);
- }else{
- goto AttributeError;
-
- }
- return EXPP_incr_ret(Py_None);
-
-AttributeError:
- return EXPP_objError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "The armature must be linked to an object before you can save changes!");
-}
-
-//------------------------Armature.__copy__()
-static PyObject *Armature_copy(BPy_Armature *self)
-{
- PyObject *py_armature = NULL;
- bArmature *bl_armature;
- bl_armature= copy_armature(self->armature);
- bl_armature->id.us= 0;
- py_armature= Armature_CreatePyObject( bl_armature );
- return py_armature;
-}
-
-//------------------ATTRIBUTE IMPLEMENTATION---------------------------
-//------------------------Armature.autoIK (getter)
-static PyObject *Armature_getAutoIK(BPy_Armature *self, void *closure)
-{
- if (self->armature->flag & ARM_AUTO_IK)
- return EXPP_incr_ret(Py_True);
- else
- return EXPP_incr_ret(Py_False);
-}
-//------------------------Armature.autoIK (setter)
-static int Armature_setAutoIK(BPy_Armature *self, PyObject *value, void *closure)
-{
- if(value){
- if(PyBool_Check(value)){
- if (value == Py_True){
- self->armature->flag |= ARM_AUTO_IK;
- return 0;
- }else if (value == Py_False){
- self->armature->flag &= ~ARM_AUTO_IK;
- return 0;
- }
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects True or False");
-}
-//------------------------Armature.layers (getter)
-static PyObject *Armature_getLayers(BPy_Armature *self, void *closure)
-{
- int layers, bit = 0, val = 0;
- PyObject *item = NULL, *laylist = PyList_New( 0 );
-
- if( !laylist )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create pylist!" );
-
- layers = self->armature->layer;
-
- while( bit < 20 ) {
- val = 1 << bit;
- if( layers & val ) {
- item = Py_BuildValue( "i", bit + 1 );
- PyList_Append( laylist, item );
- Py_DECREF( item );
- }
- bit++;
- }
- return laylist;
-}
-//------------------------Armature.layer (setter)
-static int Armature_setLayers(BPy_Armature *self, PyObject *value, void *closure)
-{
- if(value){
- if(PyList_Check(value)){
- int layers = 0, len_list = 0;
- int val;
- PyObject *item = NULL;
-
- len_list = PyList_Size(value);
-
- if( len_list == 0 )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "list can't be empty, at least one layer must be set" );
-
- while( len_list ) {
- --len_list;
- item = PyList_GetItem( value, len_list );
- if( !PyInt_Check( item ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "list must contain only integer numbers" );
-
- val = ( int ) PyInt_AsLong( item );
- if( val < 1 || val > 20 )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "layer values must be in the range [1, 20]" );
-
- layers |= 1 << ( val - 1 );
- }
-
- /* update any bases pointing to our object */
- self->armature->layer = (short)layers;
-
- return 0;
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list of integers" );
-}
-
-//------------------------Armature.mirrorEdit (getter)
-static PyObject *Armature_getMirrorEdit(BPy_Armature *self, void *closure)
-{
- if (self->armature->flag & ARM_MIRROR_EDIT)
- return EXPP_incr_ret(Py_True);
- else
- return EXPP_incr_ret(Py_False);
-}
-//------------------------Armature.mirrorEdit (setter)
-static int Armature_setMirrorEdit(BPy_Armature *self, PyObject *value, void *closure)
-{
- if(value){
- if(PyBool_Check(value)){
- if (value == Py_True){
- self->armature->flag |= ARM_MIRROR_EDIT;
- return 0;
- }else if (value == Py_False){
- self->armature->flag &= ~ARM_MIRROR_EDIT;
- return 0;
- }
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects True or False");
-}
-//------------------------Armature.drawType (getter)
-static PyObject *Armature_getDrawType(BPy_Armature *self, void *closure)
-{
- if (self->armature->drawtype == ARM_OCTA){
- return EXPP_GetModuleConstant("Blender.Armature", "OCTAHEDRON") ;
- }else if (self->armature->drawtype == ARM_LINE){
- return EXPP_GetModuleConstant("Blender.Armature", "STICK") ;
- }else if (self->armature->drawtype == ARM_B_BONE){
- return EXPP_GetModuleConstant("Blender.Armature", "BBONE") ;
- }else if (self->armature->drawtype == ARM_ENVELOPE){
- return EXPP_GetModuleConstant("Blender.Armature", "ENVELOPE") ;
- }else{
- goto RuntimeError;
- }
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sArmatureError, "drawType: ", "Internal failure!");
-}
-//------------------------Armature.drawType (setter)
-static int Armature_setDrawType(BPy_Armature *self, PyObject *value, void *closure)
-{
- PyObject *val = NULL, *name = NULL;
- long numeric_value;
-
- if(value){
- if(BPy_Constant_Check(value)){
- name = PyDict_GetItemString(((BPy_constant*)value)->dict, "name");
- if (!STREQ2(PyString_AsString(name), "OCTAHEDRON", "STICK") &&
- !STREQ2(PyString_AsString(name), "BBONE", "ENVELOPE"))
- goto ValueError;
- val = PyDict_GetItemString(((BPy_constant*)value)->dict, "value");
- if (PyInt_Check(val)){
- numeric_value = PyInt_AS_LONG(val);
- self->armature->drawtype = (int)numeric_value;
- return 0;
- }
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects module constant");
-
-ValueError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Argument must be the constant OCTAHEDRON, STICK, BBONE, or ENVELOPE");
-}
-//------------------------Armature.ghostStep (getter)
-static PyObject *Armature_getStep(BPy_Armature *self, void *closure)
-{
- return PyInt_FromLong((long)self->armature->ghostsize);
-}
-//------------------------Armature.ghostStep (setter)
-static int Armature_setStep(BPy_Armature *self, PyObject *value, void *closure)
-{
- long numerical_value;
-
- if(value){
- if(PyInt_Check(value)){
- numerical_value = PyInt_AS_LONG(value);
- if (numerical_value > 20.0f || numerical_value < 1.0f)
- goto ValueError;
- self->armature->ghostsize = (short)numerical_value;
- return 0;
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects Integer");
-
-ValueError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Argument must fall within 1-20");
-}
-//------------------------Armature.ghost (getter)
-static PyObject *Armature_getGhost(BPy_Armature *self, void *closure)
-{
- return PyInt_FromLong((long)self->armature->ghostep);
-}
-//------------------------Armature.ghost (setter)
-static int Armature_setGhost(BPy_Armature *self, PyObject *value, void *closure)
-{
- long numerical_value;
-
- if(value){
- if(PyInt_Check(value)){
- numerical_value = PyInt_AS_LONG(value);
- if (numerical_value > 30.0f || numerical_value < 0.0f)
- goto ValueError;
- self->armature->ghostep = (short)numerical_value;
- return 0;
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects Integer");
-
-ValueError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Argument must fall within 0-30");
-}
-//------------------------Armature.drawNames (getter)
-static PyObject *Armature_getDrawNames(BPy_Armature *self, void *closure)
-{
- if (self->armature->flag & ARM_DRAWNAMES)
- return EXPP_incr_ret(Py_True);
- else
- return EXPP_incr_ret(Py_False);
-}
-//------------------------Armature.drawNames (setter)
-static int Armature_setDrawNames(BPy_Armature *self, PyObject *value, void *closure)
-{
- if(value){
- if(PyBool_Check(value)){
- if (value == Py_True){
- self->armature->flag |= ARM_DRAWNAMES;
- return 0;
- }else if (value == Py_False){
- self->armature->flag &= ~ARM_DRAWNAMES;
- return 0;
- }
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects True or False");
-}
-//------------------------Armature.drawAxes (getter)
-static PyObject *Armature_getDrawAxes(BPy_Armature *self, void *closure)
-{
- if (self->armature->flag & ARM_DRAWAXES)
- return EXPP_incr_ret(Py_True);
- else
- return EXPP_incr_ret(Py_False);
-}
-//------------------------Armature.drawAxes (setter)
-static int Armature_setDrawAxes(BPy_Armature *self, PyObject *value, void *closure)
-{
- if(value){
- if(PyBool_Check(value)){
- if (value == Py_True){
- self->armature->flag |= ARM_DRAWAXES;
- return 0;
- }else if (value == Py_False){
- self->armature->flag &= ~ARM_DRAWAXES;
- return 0;
- }
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects True or False");
-}
-//------------------------Armature.delayDeform (getter)
-static PyObject *Armature_getDelayDeform(BPy_Armature *self, void *closure)
-{
- if (self->armature->flag & ARM_DELAYDEFORM)
- return EXPP_incr_ret(Py_True);
- else
- return EXPP_incr_ret(Py_False);
-}
-//------------------------Armature.delayDeform (setter)
-static int Armature_setDelayDeform(BPy_Armature *self, PyObject *value, void *closure)
-{
- if(value){
- if(PyBool_Check(value)){
- if (value == Py_True){
- self->armature->flag |= ARM_DELAYDEFORM;
- return 0;
- }else if (value == Py_False){
- self->armature->flag &= ~ARM_DELAYDEFORM;
- return 0;
- }
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects True or False");
-}
-//------------------------Armature.restPosition (getter)
-static PyObject *Armature_getRestPosition(BPy_Armature *self, void *closure)
-{
- if (self->armature->flag & ARM_RESTPOS)
- return EXPP_incr_ret(Py_True);
- else
- return EXPP_incr_ret(Py_False);
-}
-//------------------------Armature.restPosition (setter)
-static int Armature_setRestPosition(BPy_Armature *self, PyObject *value, void *closure)
-{
- if(value){
- if(PyBool_Check(value)){
- if (value == Py_True){
- self->armature->flag |= ARM_RESTPOS;
- return 0;
- }else if (value == Py_False){
- self->armature->flag &= ~ARM_RESTPOS;
- return 0;
- }
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects True or False");
-}
-//------------------------Armature.envelopes (getter)
-static PyObject *Armature_getEnvelopes(BPy_Armature *self, void *closure)
-{
- if (self->armature->deformflag & ARM_DEF_ENVELOPE)
- return EXPP_incr_ret(Py_True);
- else
- return EXPP_incr_ret(Py_False);
-}
-//------------------------Armature.envelopes (setter)
-static int Armature_setEnvelopes(BPy_Armature *self, PyObject *value, void *closure)
-{
- if(value){
- if(PyBool_Check(value)){
- if (value == Py_True){
- self->armature->deformflag |= ARM_DEF_ENVELOPE;
- return 0;
- }else if (value == Py_False){
- self->armature->deformflag &= ~ARM_DEF_ENVELOPE;
- return 0;
- }
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects True or False");
-}
-//------------------------Armature.vertexGroups (getter)
-static PyObject *Armature_getVertexGroups(BPy_Armature *self, void *closure)
-{
- if (self->armature->deformflag & ARM_DEF_VGROUP)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-//------------------------Armature.vertexGroups (setter)
-static int Armature_setVertexGroups(BPy_Armature *self, PyObject *value, void *closure)
-{
- if(value){
- if(PyBool_Check(value)){
- if (value == Py_True){
- self->armature->deformflag |= ARM_DEF_VGROUP;
- return 0;
- }else if (value == Py_False){
- self->armature->deformflag &= ~ARM_DEF_VGROUP;
- return 0;
- }
- }
- }
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureBadArgs, "Expects True or False");
-}
-
-//------------------------Armature.bones (getter)
-//Gets the name of the armature
-static PyObject *Armature_getBoneDict(BPy_Armature *self, void *closure)
-{
- return EXPP_incr_ret((PyObject*)self->Bones);
-}
-//------------------------Armature.bones (setter)
-//Sets the name of the armature
-/*TODO*/
-/*Copy Bones through x = y*/
-static int Armature_setBoneDict(BPy_Armature *self, PyObject *value, void *closure)
-{
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sArmatureError, "You are not allowed to change the .Bones attribute");
-}
-
-//------------------------Bone.layerMask (get)
-static PyObject *Armature_getLayerMask(BPy_Armature *self)
-{
- /* do this extra stuff because the short's bits can be negative values */
- unsigned short laymask = 0;
- laymask |= self->armature->layer;
- return PyInt_FromLong((int)laymask);
-}
-//------------------------Bone.layerMask (set)
-static int Armature_setLayerMask(BPy_Armature *self, PyObject *value)
-{
- int laymask;
- if (!PyInt_Check(value)) {
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected an integer (bitmask) as argument" );
- }
-
- laymask = PyInt_AsLong(value);
-
- if (laymask <= 0 || laymask > (1<<16) - 1)
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "bitmask must have from 1 up to 16 bits set");
-
- self->armature->layer = 0;
- self->armature->layer |= laymask;
-
- return 0;
-}
-
-//------------------TYPE_OBECT IMPLEMENTATION--------------------------
-//------------------------tp_doc
-//The __doc__ string for this object
-static char BPy_Armature_doc[] = "This object wraps a Blender Armature object.";
-//------------------------tp_methods
-//This contains a list of all methods the object contains
-static PyMethodDef BPy_Armature_methods[] = {
- {"makeEditable", (PyCFunction) Armature_makeEditable, METH_NOARGS,
- "() - Unlocks the ability to modify armature bones"},
- {"update", (PyCFunction) Armature_update, METH_NOARGS,
- "() - Rebuilds the armature based on changes to bones since the last call to makeEditable"},
- {"__copy__", (PyCFunction) Armature_copy, METH_NOARGS,
- "() - Return a copy of the armature."},
- {"copy", (PyCFunction) Armature_copy, METH_NOARGS,
- "() - Return a copy of the armature."},
- {NULL, NULL, 0, NULL}
-};
-//------------------------tp_getset
-//This contains methods for attributes that require checking
-static PyGetSetDef BPy_Armature_getset[] = {
- GENERIC_LIB_GETSETATTR,
- {"bones", (getter)Armature_getBoneDict, (setter)Armature_setBoneDict,
- "The armature's Bone dictionary", NULL},
- {"vertexGroups", (getter)Armature_getVertexGroups, (setter)Armature_setVertexGroups,
- "Enable/Disable vertex group defined deformation", NULL},
- {"envelopes", (getter)Armature_getEnvelopes, (setter)Armature_setEnvelopes,
- "Enable/Disable bone envelope defined deformation", NULL},
- {"restPosition", (getter)Armature_getRestPosition, (setter)Armature_setRestPosition,
- "Show armature rest position - disables posing", NULL},
- {"delayDeform", (getter)Armature_getDelayDeform, (setter)Armature_setDelayDeform,
- "Don't deform children when manipulating bones in pose mode", NULL},
- {"drawAxes", (getter)Armature_getDrawAxes, (setter)Armature_setDrawAxes,
- "Enable/Disable drawing the bone axes", NULL},
- {"drawNames", (getter)Armature_getDrawNames, (setter)Armature_setDrawNames,
- "Enable/Disable drawing the bone names", NULL},
- {"ghost", (getter)Armature_getGhost, (setter)Armature_setGhost,
- "Draw a number of ghosts around the current frame for current Action", NULL},
- {"ghostStep", (getter)Armature_getStep, (setter)Armature_setStep,
- "The number of frames between ghost instances", NULL},
- {"drawType", (getter)Armature_getDrawType, (setter)Armature_setDrawType,
- "The type of drawing currently applied to the armature", NULL},
- {"mirrorEdit", (getter)Armature_getMirrorEdit, (setter)Armature_setMirrorEdit,
- "Enable/Disable X-axis mirrored editing", NULL},
- {"autoIK", (getter)Armature_getAutoIK, (setter)Armature_setAutoIK,
- "Adds temporal IK chains while grabbing bones", NULL},
- {"layers", (getter)Armature_getLayers, (setter)Armature_setLayers,
- "List of layers for the armature", NULL},
- {"layerMask", (getter)Armature_getLayerMask, (setter)Armature_setLayerMask,
- "Layer bitmask", NULL },
- {NULL, NULL, NULL, NULL, NULL}
-};
-//------------------------tp_new
-//This methods creates a new object (note it does not initialize it - only the building)
-//This can be called through python by myObject.__new__() however, tp_init is not called
-static PyObject *Armature_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- BPy_Armature *py_armature = NULL;
- bArmature *bl_armature;
-
- bl_armature = add_armature("Armature");
- if(bl_armature) {
- bl_armature->id.us = 0; // return count to 0 - add_armature() inc'd it
-
- py_armature = (BPy_Armature*)type->tp_alloc(type, 0); //*new*
- if (py_armature == NULL)
- goto RuntimeError;
-
- py_armature->armature = bl_armature;
-
- //create armature.bones
- py_armature->Bones = (BPy_BonesDict*)PyBonesDict_FromPyArmature(py_armature);
- if (!py_armature->Bones)
- goto RuntimeError;
-
- } else {
- goto RuntimeError;
- }
- return (PyObject*)py_armature;
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sArmatureError, " __new__: ", "couldn't create Armature Data in Blender");
-}
-//------------------------tp_init
-//This methods does initialization of the new object
-//This method will get called in python by 'myObject(argument, keyword=value)'
-//tp_new will be automatically called before this
-static int Armature_init(BPy_Armature *self, PyObject *args, PyObject *kwds)
-{
- char buf[21];
- char *name = "myArmature";
- static char *kwlist[] = {"name", NULL};
-
- if(!PyArg_ParseTupleAndKeywords(args, kwds, "|s", kwlist, &name)){
- goto AttributeError;
- }
-
- //rename the armature if a name is supplied
- if(!BLI_streq(name, "myArmature")){
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
- rename_id(&self->armature->id, buf);
- }
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sArmatureBadArgs, " __init__: ", "Expects string(name)");
-}
-
-
-/*****************************************************************************/
-/* Function: Armature_compare */
-/* Description: This is a callback function for the BPy_Armature type. It */
-/* compares two Armature_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 Armature_compare( BPy_Armature * a, BPy_Armature * b )
-{
- return ( a->armature == b->armature ) ? 0 : -1;
-}
-
-//------------------------tp_repr
-//This is the string representation of the object
-static PyObject *Armature_repr(BPy_Armature *self)
-{
- return PyString_FromFormat( "[Armature: \"%s\"]", self->armature->id.name + 2 ); //*new*
-}
-//------------------------tp_dealloc
-//This tells how to 'tear-down' our object when ref count hits 0
-///tp_dealloc
-static void Armature_dealloc(BPy_Armature * self)
-{
- if (self->weaklist != NULL)
- PyObject_ClearWeakRefs((PyObject *) self); /* this causes the weakref dealloc func to be called */
-
- Py_DECREF(self->Bones);
- PyObject_DEL( self );
-}
-//------------------TYPE_OBECT DEFINITION--------------------------
-PyTypeObject Armature_Type = {
- PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "Armature", //tp_name
- sizeof(BPy_Armature), //tp_basicsize
- 0, //tp_itemsize
- (destructor)Armature_dealloc, //tp_dealloc
- 0, //tp_print
- 0, //tp_getattr
- 0, //tp_setattr
- (cmpfunc) Armature_compare, //tp_compare
- (reprfunc) Armature_repr, //tp_repr
- 0, //tp_as_number
- 0, //tp_as_sequence
- 0, //tp_as_mapping
- ( hashfunc ) GenericLib_hash, //tp_hash
- 0, //tp_call
- 0, //tp_str
- 0, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT| Py_TPFLAGS_HAVE_WEAKREFS, //tp_flags
- BPy_Armature_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- 0, //tp_richcompare
- offsetof(BPy_Armature, weaklist), //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- BPy_Armature_methods, //tp_methods
- 0, //tp_members
- BPy_Armature_getset, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- (initproc)Armature_init, //tp_init
- 0, //tp_alloc
- (newfunc)Armature_new, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-
-//-------------------MODULE METHODS IMPLEMENTATION------------------------
-//----------------Blender.Armature.Get()
-/* This function will return a Py_Armature when a single string is passed
-* or else it will return a {key:value} dictionary when mutliple strings are passed
-* or it will return a {key:value} dictionary of all armatures when nothing is passed */
-static PyObject *M_Armature_Get(PyObject * self, PyObject * args)
-{
- PyObject *seq = NULL, *item = NULL, *dict = NULL, *py_armature = NULL;
- char *name = "", buffer[24];
- int size = 0, i;
- void *data;
-
- //GET ARGUMENTS - () ('s') ('s',..) (['s',..]) are exceptable
- size = PySequence_Length(args);
- if (size == 1) {
- seq = PySequence_GetItem(args, 0); //*new*
- if (!seq)
- goto RuntimeError;
- if(!PyString_Check(seq)){
- if (PySequence_Check(seq)) {
- size = PySequence_Length(seq);
- } else {
- Py_DECREF(seq);
- goto AttributeError;
- }
- }
- } else {
- seq = EXPP_incr_ret(args); //*take ownership*
- }
- //'seq' should be a list, empty tuple or string - check list for strings
- if(!PyString_Check(seq)){
- for(i = 0; i < size; i++){
- item = PySequence_GetItem(seq, i); //*new*
- if (!item) {
- Py_DECREF(seq);
- goto RuntimeError;
- }
- if(!PyString_Check(item)){
- EXPP_decr2(item, seq);
- goto AttributeError;
- }
- Py_DECREF(item);
- }
- }
-
- //GET ARMATURES
- if(size != 1){
- dict = PyDict_New(); //*new*
- if(!dict){
- Py_DECREF(seq);
- goto RuntimeError;
- }
- if(size == 0){ //GET ALL ARMATURES
- data = G.main->armature.first; //get the first data ID from the armature library
- while (data){
- py_armature = Armature_CreatePyObject(data); //*new*
- if (!py_armature) {
- EXPP_decr2(seq, dict);
- return NULL; /* error is set from Armature_CreatePyObject */
- }
- sprintf(buffer, "%s", ((bArmature*)data)->id.name +2);
- if(PyDict_SetItemString(dict, buffer, py_armature) == -1){ //add to dictionary
- EXPP_decr3(seq, dict, py_armature);
- goto RuntimeError;
- }
- Py_DECREF(py_armature);
- data = ((ID*)data)->next;
- }
- Py_DECREF(seq);
- }else{ //GET ARMATURE LIST
- for (i = 0; i < size; i++) {
- item = PySequence_GetItem(seq, i); //*new*
- name = PyString_AsString(item);
- Py_DECREF(item);
- data = find_id("AR", name); //get data from library
- if (data != NULL){
- py_armature = Armature_CreatePyObject(data); //*new*
- if (!py_armature) {
- EXPP_decr2(seq, dict);
- return NULL; /* error is set from Armature_CreatePyObject */
- }
-
- if(PyDict_SetItemString(dict, name, py_armature) == -1){ //add to dictionary
- EXPP_decr3(seq, dict, py_armature);
- goto RuntimeError;
- }
- Py_DECREF(py_armature);
- }else{
- if(PyDict_SetItemString(dict, name, Py_None) == -1){ //add to dictionary
- EXPP_decr2(seq, dict);
- goto RuntimeError;
- }
- Py_DECREF(Py_None);
- }
- }
- Py_DECREF(seq);
- }
- return dict;
- }else{ //GET SINGLE ARMATURE
- if(!PyString_Check(seq)){ //This handles the bizarre case where (['s']) is passed
- item = PySequence_GetItem(seq, 0); //*new*
- name = PyString_AsString(item);
- Py_DECREF(item);
- }else{
- name = PyString_AsString(seq);
- }
- Py_DECREF(seq);
- data = find_id("AR", name); //get data from library
- if (data != NULL){
- return Armature_CreatePyObject(data); //*new*
- }else{
- char buffer[128];
- PyOS_snprintf( buffer, sizeof(buffer),
- "Armature \"%s\" not found", name);
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- buffer );
- }
- }
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sModuleError, "Get(): ", "Internal Error Ocurred");
-
-AttributeError:
- return EXPP_objError(PyExc_AttributeError, "%s%s%s",
- sModuleBadArgs, "Get(): ", "- Expects (optional) string sequence");
-}
-
-
-//----------------Blender.Armature.New()
-static PyObject *M_Armature_New(PyObject * self, PyObject * args)
-{
- char *name = "Armature";
- struct bArmature *armature;
- BPy_Armature *obj;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or a string as argument" );
-
- armature= add_armature(name);
- armature->id.us = 0;
- obj = (BPy_Armature *)Armature_CreatePyObject(armature); /*new*/
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyObject_New() failed" );
-
- obj->armature = armature;
- return (PyObject *)obj;
-}
-
-
-//-------------------MODULE METHODS DEFINITION-----------------------------
-
-static char M_Armature_Get_doc[] = "(name) - return the armature with the name 'name', \
- returns None if not found.\n If 'name' is not specified, it returns a list of all \
- armatures in the\ncurrent scene.";
-
-static char M_Armature_New_doc[] = "(name) - return a new armature object.";
-
-struct PyMethodDef M_Armature_methods[] = {
- {"Get", M_Armature_Get, METH_VARARGS, M_Armature_Get_doc},
- {"New", M_Armature_New, METH_VARARGS, M_Armature_New_doc},
- {NULL, NULL, 0, NULL}
-};
-//------------------VISIBLE PROTOTYPE IMPLEMENTATION-----------------------
-//------------------------Armature_RebuildEditbones (internal)
-PyObject * Armature_RebuildEditbones(PyObject *pyarmature)
-{
- return Armature_makeEditable((BPy_Armature*)pyarmature);
-}
-
-//------------------------Armature_RebuildBones (internal)
-PyObject *Armature_RebuildBones(PyObject *pyarmature)
-{
- return Armature_update((BPy_Armature*)pyarmature);
-}
-
-/* internal func to remove weakref from weakref list */
-PyObject * arm_weakref_callback_weakref_dealloc(PyObject *self, PyObject *weakref)
-{
- char *list_name = ARM_WEAKREF_LIST_NAME;
- PyObject *maindict = NULL, *armlist = NULL;
- int i;
-
- maindict= PyModule_GetDict(PyImport_AddModule( "__main__"));
- armlist = PyDict_GetItemString(maindict, list_name);
- if( !armlist){
- printf("Oops - update_armature_weakrefs()\n");
- Py_RETURN_NONE;
- }
-
- i = PySequence_Index(armlist, weakref);
- if (i==-1) {
- printf("callback weakref internal error, weakref not in list\n\tthis should never happen.\n");
- Py_RETURN_NONE;
- }
- PySequence_DelItem(armlist, i);
- Py_RETURN_NONE;
-}
-
-/*-----------------(internal)
- * Converts a bArmature to a PyArmature */
-
-PyObject *Armature_CreatePyObject(struct bArmature *armature)
-{
- BPy_Armature *py_armature = NULL;
- PyObject *maindict = NULL, *weakref = NULL;
- PyObject *armlist = NULL; /* list of armature weak refs */
- char *list_name = ARM_WEAKREF_LIST_NAME;
- int i;
-
- //put a weakreference in __main__
- maindict= PyModule_GetDict(PyImport_AddModule( "__main__"));
-
- armlist = PyDict_GetItemString(maindict, list_name);
- if(!armlist) {
- printf("Oops - can't get the armature weakref list\n");
- goto RuntimeError;
- }
-
- /* see if we alredy have it */
- for (i=0; i< PyList_Size(armlist); i++) {
- py_armature = (BPy_Armature *)PyWeakref_GetObject(PyList_GET_ITEM(armlist, i));
- if (BPy_Armature_Check(py_armature) && py_armature->armature == armature) {
- Py_INCREF(py_armature);
- /*printf("reusing armature\n");*/
- return (PyObject *)py_armature;
- }
- }
-
-
- /*create armature type*/
- py_armature = PyObject_NEW( BPy_Armature, &Armature_Type );
-
- if (!py_armature){
- printf("Oops - can't create py armature\n");
- goto RuntimeError;
- }
-
- py_armature->armature = armature;
- py_armature->weaklist = NULL; //init the weaklist
-
- //create armature.bones
- py_armature->Bones = (BPy_BonesDict*)PyBonesDict_FromPyArmature(py_armature);
- if (!py_armature->Bones){
- printf("Oops - creating armature.bones\n");
- goto RuntimeError;
- }
-
- weakref = PyWeakref_NewRef((PyObject*)py_armature, arm_weakref_callback_weakref_dealloc__pyfunc);
- if (PyList_Append(armlist, weakref) == -1){
- printf("Oops - list-append failed\n");
- goto RuntimeError;
- }
- Py_DECREF(weakref);
-
- return (PyObject *) py_armature;
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sModuleError, "Armature_CreatePyObject: ", "Internal Error Ocurred");
-}
-//-----------------(internal)
-//Converts a PyArmature to a bArmature
-struct bArmature *PyArmature_AsArmature(BPy_Armature *py_armature)
-{
- return (py_armature->armature);
-}
-
-struct bArmature *Armature_FromPyObject( PyObject * py_obj )
-{
- return PyArmature_AsArmature((BPy_Armature*)py_obj);
-}
-
-/* internal use only */
-static PyMethodDef bpy_arm_weakref_callback_weakref_dealloc[] = {
- {"arm_weakref_callback_weakref_dealloc", arm_weakref_callback_weakref_dealloc, METH_O, ""}
-};
-
-//-------------------MODULE INITIALIZATION--------------------------------
-PyObject *Armature_Init(void)
-{
- PyObject *module, *dict;
-
- //Initializes TypeObject.ob_type
- if (PyType_Ready(&Armature_Type) < 0 || PyType_Ready(&BonesDict_Type) < 0 ||
- PyType_Ready(&EditBone_Type) < 0 || PyType_Ready(&Bone_Type) < 0) {
- return EXPP_incr_ret(Py_None);
- }
-
- /* Weakref management - used for callbacks so we can
- * tell when a callback has been removed that a UI button referenced */
- arm_weakref_callback_weakref_dealloc__pyfunc = PyCFunction_New(bpy_arm_weakref_callback_weakref_dealloc, NULL);
-
-
- //Register the module
- module = Py_InitModule3("Blender.Armature", M_Armature_methods,
- "The Blender Armature module");
-
- //Add TYPEOBJECTS to the module
- PyModule_AddObject(module, "Armature",
- EXPP_incr_ret((PyObject *)&Armature_Type)); //*steals*
- PyModule_AddObject(module, "Bone",
- EXPP_incr_ret((PyObject *)&Bone_Type)); //*steals*
- PyModule_AddObject(module, "Editbone",
- EXPP_incr_ret((PyObject *)&EditBone_Type)); //*steals*
-
- //Add CONSTANTS to the module
- PyModule_AddObject(module, "CONNECTED",
- PyConstant_NewInt("CONNECTED", BONE_CONNECTED));
- PyModule_AddObject(module, "HINGE",
- PyConstant_NewInt("HINGE", BONE_HINGE));
- PyModule_AddObject(module, "NO_DEFORM",
- PyConstant_NewInt("NO_DEFORM", BONE_NO_DEFORM));
- PyModule_AddObject(module, "MULTIPLY",
- PyConstant_NewInt("MULTIPLY", BONE_MULT_VG_ENV));
- PyModule_AddObject(module, "HIDDEN_EDIT",
- PyConstant_NewInt("HIDDEN_EDIT", BONE_HIDDEN_A));
- PyModule_AddObject(module, "ROOT_SELECTED",
- PyConstant_NewInt("ROOT_SELECTED", BONE_ROOTSEL));
- PyModule_AddObject(module, "BONE_SELECTED",
- PyConstant_NewInt("BONE_SELECTED", BONE_SELECTED));
- PyModule_AddObject(module, "TIP_SELECTED",
- PyConstant_NewInt("TIP_SELECTED", BONE_TIPSEL));
-
- PyModule_AddObject(module, "OCTAHEDRON",
- PyConstant_NewInt("OCTAHEDRON", ARM_OCTA));
- PyModule_AddObject(module, "STICK",
- PyConstant_NewInt("STICK", ARM_LINE));
- PyModule_AddObject(module, "BBONE",
- PyConstant_NewInt("BBONE", ARM_B_BONE));
- PyModule_AddObject(module, "ENVELOPE",
- PyConstant_NewInt("ENVELOPE", ARM_ENVELOPE));
-
- //Add SUBMODULES to the module
- dict = PyModule_GetDict( module ); //borrowed
- PyDict_SetItemString(dict, "NLA", NLA_Init()); //creates a *new* module
-
- return module;
-}
diff --git a/source/blender/python/api2_2x/Armature.h b/source/blender/python/api2_2x/Armature.h
deleted file mode 100644
index bafd49772b0..00000000000
--- a/source/blender/python/api2_2x/Armature.h
+++ /dev/null
@@ -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
diff --git a/source/blender/python/api2_2x/BGL.c b/source/blender/python/api2_2x/BGL.c
deleted file mode 100644
index 5d78fd09e2d..00000000000
--- a/source/blender/python/api2_2x/BGL.c
+++ /dev/null
@@ -1,1590 +0,0 @@
-/*
- * $Id: BGL.c 12267 2007-10-17 09:51:13Z 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 *****
-*/
-
-/* This file 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. */
-
-#include "BGL.h" /*This must come first */
-
-#include "MEM_guardedalloc.h"
-#include "gen_utils.h"
-
-static int type_size( int type );
-static Buffer *make_buffer( int type, int ndimensions, int *dimensions );
-
-static char Method_Buffer_doc[] =
- "(type, dimensions, [template]) - Create a new Buffer object\n\n\
-(type) - The format to store data in\n\
-(dimensions) - An int or sequence specifying the dimensions of the buffer\n\
-[template] - A sequence of matching dimensions to the buffer to be created\n\
- which will be used to initialize the Buffer.\n\n\
-If a template is not passed in all fields will be initialized to 0.\n\n\
-The type should be one of GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT, or GL_DOUBLE.\n\
-If the dimensions are specified as an int a linear buffer will be\n\
-created. If a sequence is passed for the dimensions the buffer\n\
-will have len(sequence) dimensions, where the size for each dimension\n\
-is determined by the value in the sequence at that index.\n\n\
-For example, passing [100, 100] will create a 2 dimensional\n\
-square buffer. Passing [16, 16, 32] will create a 3 dimensional\n\
-buffer which is twice as deep as it is wide or high.";
-
-static PyObject *Method_Buffer( PyObject * self, PyObject * args );
-
-/* Buffer sequence methods */
-
-static int Buffer_len( PyObject * self );
-static PyObject *Buffer_item( PyObject * self, int i );
-static PyObject *Buffer_slice( PyObject * self, int begin, int end );
-static int Buffer_ass_item( PyObject * self, int i, PyObject * v );
-static int Buffer_ass_slice( PyObject * self, int begin, int end,
- PyObject * seq );
-
-static PySequenceMethods Buffer_SeqMethods = {
- ( inquiry ) Buffer_len, /*sq_length */
- ( binaryfunc ) 0, /*sq_concat */
- ( intargfunc ) 0, /*sq_repeat */
- ( intargfunc ) Buffer_item, /*sq_item */
- ( intintargfunc ) Buffer_slice, /*sq_slice */
- ( intobjargproc ) Buffer_ass_item, /*sq_ass_item */
- ( intintobjargproc ) Buffer_ass_slice, /*sq_ass_slice */
-};
-
-static void Buffer_dealloc( PyObject * self );
-static PyObject *Buffer_tolist( PyObject * self );
-static PyObject *Buffer_dimensions( PyObject * self );
-static PyObject *Buffer_getattr( PyObject * self, char *name );
-static PyObject *Buffer_repr( PyObject * self );
-
-PyTypeObject buffer_Type = {
- PyObject_HEAD_INIT( NULL ) /* required python macro */
- 0, /*ob_size */
- "buffer", /*tp_name */
- sizeof( Buffer ), /*tp_basicsize */
- 0, /*tp_itemsize */
- ( destructor ) Buffer_dealloc, /*tp_dealloc */
- ( printfunc ) 0, /*tp_print */
- ( getattrfunc ) Buffer_getattr, /*tp_getattr */
- ( setattrfunc ) 0, /*tp_setattr */
- ( cmpfunc ) 0, /*tp_compare */
- ( reprfunc ) Buffer_repr, /*tp_repr */
- 0, /*tp_as_number */
- &Buffer_SeqMethods, /*tp_as_sequence */
-};
-
-/* #ifndef __APPLE__ */
-
-#define BGL_Wrap(nargs, funcname, ret, arg_list) \
-static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\
- arg_def##nargs arg_list; \
- ret_def_##ret; \
- if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
- ret_set_##ret gl##funcname (arg_var##nargs arg_list);\
- ret_ret_##ret; \
-}
-
-#define BGLU_Wrap(nargs, funcname, ret, arg_list) \
-static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\
- arg_def##nargs arg_list; \
- ret_def_##ret; \
- if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
- ret_set_##ret glu##funcname (arg_var##nargs arg_list);\
- ret_ret_##ret; \
-}
-
-/* #endif */
-
-PyObject *BGL_Init( void );
-
-/********/
-static int type_size(int type)
-{
- switch (type) {
- case GL_BYTE:
- return sizeof(char);
- case GL_SHORT:
- return sizeof(short);
- case GL_INT:
- return sizeof(int);
- case GL_FLOAT:
- return sizeof(float);
- case GL_DOUBLE:
- return sizeof(double);
- }
- return -1;
-}
-
-static Buffer *make_buffer(int type, int ndimensions, int *dimensions)
-{
- Buffer *buffer;
- void *buf= NULL;
- int i, size, length;
-
- length= 1;
- for (i=0; i<ndimensions; i++)
- length*= dimensions[i];
-
- size= type_size(type);
-
- buf= MEM_mallocN(length*size, "Buffer buffer");
-
- buffer= (Buffer *) PyObject_NEW(Buffer, &buffer_Type);
- buffer->parent= NULL;
- buffer->ndimensions= ndimensions;
- buffer->dimensions= dimensions;
- buffer->type= type;
- buffer->buf.asvoid= buf;
-
- for (i= 0; i<length; i++) {
- if (type==GL_BYTE)
- buffer->buf.asbyte[i]= 0;
- else if (type==GL_SHORT)
- buffer->buf.asshort[i]= 0;
- else if (type==GL_INT)
- buffer->buf.asint[i]= 0;
- else if (type==GL_FLOAT)
- buffer->buf.asfloat[i]= 0.0f;
- else if (type==GL_DOUBLE)
- buffer->buf.asdouble[i]= 0.0;
- }
- return buffer;
-}
-
-static PyObject *Method_Buffer (PyObject *self, PyObject *args)
-{
- PyObject *length_ob= NULL, *template= NULL;
- Buffer *buffer;
-
- int i, type;
- int *dimensions = 0, ndimensions = 0;
-
- if (!PyArg_ParseTuple(args, "iO|O", &type, &length_ob, &template))
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "expected an int and one or two PyObjects");
-
- if (type!=GL_BYTE && type!=GL_SHORT && type!=GL_INT && type!=GL_FLOAT && type!=GL_DOUBLE) {
- PyErr_SetString(PyExc_AttributeError, "type");
- return NULL;
- }
-
- if (PyNumber_Check(length_ob)) {
- ndimensions= 1;
- dimensions= MEM_mallocN(ndimensions*sizeof(int), "Buffer dimensions");
- dimensions[0]= PyInt_AsLong(length_ob);
- } else if (PySequence_Check(length_ob)) {
- ndimensions= PySequence_Length(length_ob);
- dimensions= MEM_mallocN(ndimensions*sizeof(int), "Buffer dimensions");
- for (i=0; i<ndimensions; i++) {
- PyObject *ob= PySequence_GetItem(length_ob, i);
-
- if (!PyNumber_Check(ob)) dimensions[i]= 1;
- else dimensions[i]= PyInt_AsLong(ob);
- Py_DECREF(ob);
- }
- }
-
- buffer= make_buffer(type, ndimensions, dimensions);
- if (template && ndimensions) {
- if (Buffer_ass_slice((PyObject *) buffer, 0, dimensions[0], template)) {
- Py_DECREF(buffer);
- return NULL;
- }
- }
-
- return (PyObject *) buffer;
-}
-
-/*@ Buffer sequence methods */
-
-static int Buffer_len(PyObject *self)
-{
- Buffer *buf= (Buffer *) self;
- return buf->dimensions[0];
-}
-
-static PyObject *Buffer_item(PyObject *self, int i)
-{
- Buffer *buf= (Buffer *) self;
-
- if (i >= buf->dimensions[0]) {
- PyErr_SetString(PyExc_IndexError, "array index out of range");
- return NULL;
- }
-
- if (buf->ndimensions==1) {
- switch (buf->type) {
- case GL_BYTE: return Py_BuildValue("b", buf->buf.asbyte[i]);
- case GL_SHORT: return Py_BuildValue("h", buf->buf.asshort[i]);
- case GL_INT: return Py_BuildValue("i", buf->buf.asint[i]);
- case GL_FLOAT: return PyFloat_FromDouble(buf->buf.asfloat[i]);
- case GL_DOUBLE: return Py_BuildValue("d", buf->buf.asdouble[i]);
- }
- } else {
- Buffer *newbuf;
- int j, length, size;
-
- length= 1;
- for (j=1; j<buf->ndimensions; j++) {
- length*= buf->dimensions[j];
- }
- size= type_size(buf->type);
-
- newbuf= (Buffer *) PyObject_NEW(Buffer, &buffer_Type);
-
- Py_INCREF(self);
- newbuf->parent= self;
-
- newbuf->ndimensions= buf->ndimensions-1;
- newbuf->type= buf->type;
- newbuf->buf.asvoid= buf->buf.asbyte + i*length*size;
- newbuf->dimensions= MEM_mallocN(newbuf->ndimensions*sizeof(int),
- "Buffer dimensions");
- memcpy(newbuf->dimensions, buf->dimensions+1,
- newbuf->ndimensions*sizeof(int));
-
- return (PyObject *) newbuf;
- }
-
- return NULL;
-}
-
-static PyObject *Buffer_slice(PyObject *self, int begin, int end)
-{
- Buffer *buf= (Buffer *) self;
- PyObject *list;
- int count;
-
- if (begin<0) begin= 0;
- if (end>buf->dimensions[0])
- end= buf->dimensions[0];
- if (begin>end) begin= end;
-
- list= PyList_New(end-begin);
-
- for (count= begin; count<end; count++)
- PyList_SetItem(list, count-begin, Buffer_item(self, count));
-
- return list;
-}
-
-static int Buffer_ass_item(PyObject *self, int i, PyObject *v)
-{
- Buffer *buf= (Buffer *) self;
-
- if (i >= buf->dimensions[0]) {
- PyErr_SetString(PyExc_IndexError, "array assignment index out of range");
- return -1;
- }
-
- if (buf->ndimensions!=1) {
- PyObject *row= Buffer_item(self, i);
- int ret;
-
- if (!row) return -1;
- ret= Buffer_ass_slice(row, 0, buf->dimensions[1], v);
- Py_DECREF(row);
- return ret;
- }
-
- if (buf->type==GL_BYTE) {
- if (!PyArg_Parse(v, "b;Coordinates must be ints", &buf->buf.asbyte[i]))
- return -1;
- } else if (buf->type==GL_SHORT) {
- if (!PyArg_Parse(v, "h;Coordinates must be ints", &buf->buf.asshort[i]))
- return -1;
-
- } else if (buf->type==GL_INT) {
- if (!PyArg_Parse(v, "i;Coordinates must be ints", &buf->buf.asint[i]))
- return -1;
- } else if (buf->type==GL_FLOAT) {
- if (!PyArg_Parse(v, "f;Coordinates must be floats", &buf->buf.asfloat[i]))
- return -1;
- } else if (buf->type==GL_DOUBLE) {
- if (!PyArg_Parse(v, "d;Coordinates must be floats", &buf->buf.asdouble[i]))
- return -1;
- }
- return 0;
-}
-
-static int Buffer_ass_slice(PyObject *self, int begin, int end, PyObject *seq)
-{
- Buffer *buf= (Buffer *) self;
- PyObject *item;
- int count, err=0;
-
- if (begin<0) begin= 0;
- if (end>buf->dimensions[0]) end= buf->dimensions[0];
- if (begin>end) begin= end;
-
- if (!PySequence_Check(seq)) {
- PyErr_SetString(PyExc_TypeError,
- "illegal argument type for built-in operation");
- return -1;
- }
-
- if (PySequence_Length(seq)!=(end-begin)) {
- PyErr_SetString(PyExc_TypeError, "size mismatch in assignment");
- return -1;
- }
-
- for (count= begin; count<end; count++) {
- item= PySequence_GetItem(seq, count-begin);
- err= Buffer_ass_item(self, count, item);
- Py_DECREF(item);
- if (err) break;
- }
- return err;
-}
-
-static void Buffer_dealloc(PyObject *self)
-{
- Buffer *buf = (Buffer *)self;
-
- if (buf->parent) Py_DECREF (buf->parent);
- else MEM_freeN (buf->buf.asvoid);
-
- MEM_freeN (buf->dimensions);
-
- PyObject_DEL (self);
-}
-
-static PyObject *Buffer_tolist(PyObject *self)
-{
- int i, len= ((Buffer *)self)->dimensions[0];
- PyObject *list= PyList_New(len);
-
- for (i=0; i<len; i++) {
- PyList_SetItem(list, i, Buffer_item(self, i));
- }
-
- return list;
-}
-
-static PyObject *Buffer_dimensions(PyObject *self)
-{
- Buffer *buffer= (Buffer *) self;
- PyObject *list= PyList_New(buffer->ndimensions);
- int i;
-
- for (i= 0; i<buffer->ndimensions; i++) {
- PyList_SetItem(list, i, PyInt_FromLong(buffer->dimensions[i]));
- }
-
- return list;
-}
-
-static PyObject *Buffer_getattr(PyObject *self, char *name)
-{
- if (strcmp(name, "list")==0) return Buffer_tolist(self);
- else if (strcmp(name, "dimensions")==0) return Buffer_dimensions(self);
-
- PyErr_SetString(PyExc_AttributeError, name);
- return NULL;
-}
-
-static PyObject *Buffer_repr(PyObject *self)
-{
- PyObject *list= Buffer_tolist(self);
- PyObject *repr= PyObject_Repr(list);
- Py_DECREF(list);
-
- return repr;
-}
-
-
-BGL_Wrap(2, Accum, void, (GLenum, GLfloat))
-BGL_Wrap(2, AlphaFunc, void, (GLenum, GLclampf))
-BGL_Wrap(3, AreTexturesResident, GLboolean, (GLsizei, GLuintP, GLbooleanP))
-BGL_Wrap(1, Begin, void, (GLenum))
-BGL_Wrap(2, BindTexture, void, (GLenum, GLuint))
-BGL_Wrap(7, Bitmap, void, (GLsizei, GLsizei, GLfloat,
- GLfloat, GLfloat, GLfloat, GLubyteP))
-BGL_Wrap(2, BlendFunc, void, (GLenum, GLenum))
-BGL_Wrap(1, CallList, void, (GLuint))
-BGL_Wrap(3, CallLists, void, (GLsizei, GLenum, GLvoidP))
-BGL_Wrap(1, Clear, void, (GLbitfield))
-BGL_Wrap(4, ClearAccum, void, (GLfloat, GLfloat, GLfloat, GLfloat))
-BGL_Wrap(4, ClearColor, void, (GLclampf, GLclampf, GLclampf, GLclampf))
-BGL_Wrap(1, ClearDepth, void, (GLclampd))
-BGL_Wrap(1, ClearIndex, void, (GLfloat))
-BGL_Wrap(1, ClearStencil, void, (GLint))
-BGL_Wrap(2, ClipPlane, void, (GLenum, GLdoubleP))
-BGL_Wrap(3, Color3b, void, (GLbyte, GLbyte, GLbyte))
-BGL_Wrap(1, Color3bv, void, (GLbyteP))
-BGL_Wrap(3, Color3d, void, (GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, Color3dv, void, (GLdoubleP))
-BGL_Wrap(3, Color3f, void, (GLfloat, GLfloat, GLfloat))
-BGL_Wrap(1, Color3fv, void, (GLfloatP))
-BGL_Wrap(3, Color3i, void, (GLint, GLint, GLint))
-BGL_Wrap(1, Color3iv, void, (GLintP))
-BGL_Wrap(3, Color3s, void, (GLshort, GLshort, GLshort))
-BGL_Wrap(1, Color3sv, void, (GLshortP))
-BGL_Wrap(3, Color3ub, void, (GLubyte, GLubyte, GLubyte))
-BGL_Wrap(1, Color3ubv, void, (GLubyteP))
-BGL_Wrap(3, Color3ui, void, (GLuint, GLuint, GLuint))
-BGL_Wrap(1, Color3uiv, void, (GLuintP))
-BGL_Wrap(3, Color3us, void, (GLushort, GLushort, GLushort))
-BGL_Wrap(1, Color3usv, void, (GLushortP))
-BGL_Wrap(4, Color4b, void, (GLbyte, GLbyte, GLbyte, GLbyte))
-BGL_Wrap(1, Color4bv, void, (GLbyteP))
-BGL_Wrap(4, Color4d, void, (GLdouble, GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, Color4dv, void, (GLdoubleP))
-BGL_Wrap(4, Color4f, void, (GLfloat, GLfloat, GLfloat, GLfloat))
-BGL_Wrap(1, Color4fv, void, (GLfloatP))
-BGL_Wrap(4, Color4i, void, (GLint, GLint, GLint, GLint))
-BGL_Wrap(1, Color4iv, void, (GLintP))
-BGL_Wrap(4, Color4s, void, (GLshort, GLshort, GLshort, GLshort))
-BGL_Wrap(1, Color4sv, void, (GLshortP))
-BGL_Wrap(4, Color4ub, void, (GLubyte, GLubyte, GLubyte, GLubyte))
-BGL_Wrap(1, Color4ubv, void, (GLubyteP))
-BGL_Wrap(4, Color4ui, void, (GLuint, GLuint, GLuint, GLuint))
-BGL_Wrap(1, Color4uiv, void, (GLuintP))
-BGL_Wrap(4, Color4us, void, (GLushort, GLushort, GLushort, GLushort))
-BGL_Wrap(1, Color4usv, void, (GLushortP))
-BGL_Wrap(4, ColorMask, void, (GLboolean, GLboolean, GLboolean, GLboolean))
-BGL_Wrap(2, ColorMaterial, void, (GLenum, GLenum))
-BGL_Wrap(5, CopyPixels, void, (GLint, GLint, GLsizei, GLsizei, GLenum))
-BGL_Wrap(1, CullFace, void, (GLenum))
-BGL_Wrap(2, DeleteLists, void, (GLuint, GLsizei))
-BGL_Wrap(2, DeleteTextures, void, (GLsizei, GLuintP))
-BGL_Wrap(1, DepthFunc, void, (GLenum))
-BGL_Wrap(1, DepthMask, void, (GLboolean))
-BGL_Wrap(2, DepthRange, void, (GLclampd, GLclampd))
-BGL_Wrap(1, Disable, void, (GLenum))
-BGL_Wrap(1, DrawBuffer, void, (GLenum))
-BGL_Wrap(5, DrawPixels, void, (GLsizei, GLsizei, GLenum, GLenum, GLvoidP))
-BGL_Wrap(1, EdgeFlag, void, (GLboolean))
-BGL_Wrap(1, EdgeFlagv, void, (GLbooleanP))
-BGL_Wrap(1, Enable, void, (GLenum))
-BGL_Wrap(1, End, void, (void))
-BGL_Wrap(1, EndList, void, (void))
-BGL_Wrap(1, EvalCoord1d, void, (GLdouble))
-BGL_Wrap(1, EvalCoord1dv, void, (GLdoubleP))
-BGL_Wrap(1, EvalCoord1f, void, (GLfloat))
-BGL_Wrap(1, EvalCoord1fv, void, (GLfloatP))
-BGL_Wrap(2, EvalCoord2d, void, (GLdouble, GLdouble))
-BGL_Wrap(1, EvalCoord2dv, void, (GLdoubleP))
-BGL_Wrap(2, EvalCoord2f, void, (GLfloat, GLfloat))
-BGL_Wrap(1, EvalCoord2fv, void, (GLfloatP))
-BGL_Wrap(3, EvalMesh1, void, (GLenum, GLint, GLint))
-BGL_Wrap(5, EvalMesh2, void, (GLenum, GLint, GLint, GLint, GLint))
-BGL_Wrap(1, EvalPoint1, void, (GLint))
-BGL_Wrap(2, EvalPoint2, void, (GLint, GLint))
-BGL_Wrap(3, FeedbackBuffer, void, (GLsizei, GLenum, GLfloatP))
-BGL_Wrap(1, Finish, void, (void))
-BGL_Wrap(1, Flush, void, (void))
-BGL_Wrap(2, Fogf, void, (GLenum, GLfloat))
-BGL_Wrap(2, Fogfv, void, (GLenum, GLfloatP))
-BGL_Wrap(2, Fogi, void, (GLenum, GLint))
-BGL_Wrap(2, Fogiv, void, (GLenum, GLintP))
-BGL_Wrap(1, FrontFace, void, (GLenum))
-BGL_Wrap(6, Frustum, void, (GLdouble, GLdouble,
- GLdouble, GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, GenLists, GLuint, (GLsizei))
-BGL_Wrap(2, GenTextures, void, (GLsizei, GLuintP))
-BGL_Wrap(2, GetBooleanv, void, (GLenum, GLbooleanP))
-BGL_Wrap(2, GetClipPlane, void, (GLenum, GLdoubleP))
-BGL_Wrap(2, GetDoublev, void, (GLenum, GLdoubleP))
-BGL_Wrap(1, GetError, GLenum, (void))
-BGL_Wrap(2, GetFloatv, void, (GLenum, GLfloatP))
-BGL_Wrap(2, GetIntegerv, void, (GLenum, GLintP))
-BGL_Wrap(3, GetLightfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, GetLightiv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(3, GetMapdv, void, (GLenum, GLenum, GLdoubleP))
-BGL_Wrap(3, GetMapfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, GetMapiv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(3, GetMaterialfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, GetMaterialiv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(2, GetPixelMapfv, void, (GLenum, GLfloatP))
-BGL_Wrap(2, GetPixelMapuiv, void, (GLenum, GLuintP))
-BGL_Wrap(2, GetPixelMapusv, void, (GLenum, GLushortP))
-BGL_Wrap(1, GetPolygonStipple,void, (GLubyteP))
-BGL_Wrap(1, GetString, GLstring, (GLenum))
-BGL_Wrap(3, GetTexEnvfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, GetTexEnviv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(3, GetTexGendv, void, (GLenum, GLenum, GLdoubleP))
-BGL_Wrap(3, GetTexGenfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, GetTexGeniv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(5, GetTexImage, void, (GLenum, GLint, GLenum, GLenum, GLvoidP))
-BGL_Wrap(4, GetTexLevelParameterfv, void, (GLenum, GLint, GLenum, GLfloatP))
-BGL_Wrap(4, GetTexLevelParameteriv, void, (GLenum, GLint, GLenum, GLintP))
-BGL_Wrap(3, GetTexParameterfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, GetTexParameteriv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(2, Hint, void, (GLenum, GLenum))
-BGL_Wrap(1, IndexMask, void, (GLuint))
-BGL_Wrap(1, Indexd, void, (GLdouble))
-BGL_Wrap(1, Indexdv, void, (GLdoubleP))
-BGL_Wrap(1, Indexf, void, (GLfloat))
-BGL_Wrap(1, Indexfv, void, (GLfloatP))
-BGL_Wrap(1, Indexi, void, (GLint))
-BGL_Wrap(1, Indexiv, void, (GLintP))
-BGL_Wrap(1, Indexs, void, (GLshort))
-BGL_Wrap(1, Indexsv, void, (GLshortP))
-BGL_Wrap(1, InitNames, void, (void))
-BGL_Wrap(1, IsEnabled, GLboolean, (GLenum))
-BGL_Wrap(1, IsList, GLboolean, (GLuint))
-BGL_Wrap(1, IsTexture, GLboolean, (GLuint))
-BGL_Wrap(2, LightModelf, void, (GLenum, GLfloat))
-BGL_Wrap(2, LightModelfv, void, (GLenum, GLfloatP))
-BGL_Wrap(2, LightModeli, void, (GLenum, GLint))
-BGL_Wrap(2, LightModeliv, void, (GLenum, GLintP))
-BGL_Wrap(3, Lightf, void, (GLenum, GLenum, GLfloat))
-BGL_Wrap(3, Lightfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, Lighti, void, (GLenum, GLenum, GLint))
-BGL_Wrap(3, Lightiv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(2, LineStipple, void, (GLint, GLushort))
-BGL_Wrap(1, LineWidth, void, (GLfloat))
-BGL_Wrap(1, ListBase, void, (GLuint))
-BGL_Wrap(1, LoadIdentity, void, (void))
-BGL_Wrap(1, LoadMatrixd, void, (GLdoubleP))
-BGL_Wrap(1, LoadMatrixf, void, (GLfloatP))
-BGL_Wrap(1, LoadName, void, (GLuint))
-BGL_Wrap(1, LogicOp, void, (GLenum))
-BGL_Wrap(6, Map1d, void, (GLenum, GLdouble, GLdouble,
- GLint, GLint, GLdoubleP))
-BGL_Wrap(6, Map1f, void, (GLenum, GLfloat, GLfloat,
- GLint, GLint, GLfloatP))
-BGL_Wrap(10, Map2d, void, (GLenum, GLdouble, GLdouble,
- GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdoubleP))
-BGL_Wrap(10, Map2f, void, (GLenum, GLfloat, GLfloat,
- GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloatP))
-BGL_Wrap(3, MapGrid1d, void, (GLint, GLdouble, GLdouble))
-BGL_Wrap(3, MapGrid1f, void, (GLint, GLfloat, GLfloat))
-BGL_Wrap(6, MapGrid2d, void, (GLint, GLdouble, GLdouble,
- GLint, GLdouble, GLdouble))
-BGL_Wrap(6, MapGrid2f, void, (GLint, GLfloat, GLfloat,
- GLint, GLfloat, GLfloat))
-BGL_Wrap(3, Materialf, void, (GLenum, GLenum, GLfloat))
-BGL_Wrap(3, Materialfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, Materiali, void, (GLenum, GLenum, GLint))
-BGL_Wrap(3, Materialiv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(1, MatrixMode, void, (GLenum))
-BGL_Wrap(1, MultMatrixd, void, (GLdoubleP))
-BGL_Wrap(1, MultMatrixf, void, (GLfloatP))
-BGL_Wrap(2, NewList, void, (GLuint, GLenum))
-BGL_Wrap(3, Normal3b, void, (GLbyte, GLbyte, GLbyte))
-BGL_Wrap(1, Normal3bv, void, (GLbyteP))
-BGL_Wrap(3, Normal3d, void, (GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, Normal3dv, void, (GLdoubleP))
-BGL_Wrap(3, Normal3f, void, (GLfloat, GLfloat, GLfloat))
-BGL_Wrap(1, Normal3fv, void, (GLfloatP))
-BGL_Wrap(3, Normal3i, void, (GLint, GLint, GLint))
-BGL_Wrap(1, Normal3iv, void, (GLintP))
-BGL_Wrap(3, Normal3s, void, (GLshort, GLshort, GLshort))
-BGL_Wrap(1, Normal3sv, void, (GLshortP))
-BGL_Wrap(6, Ortho, void, (GLdouble, GLdouble,
- GLdouble, GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, PassThrough, void, (GLfloat))
-BGL_Wrap(3, PixelMapfv, void, (GLenum, GLint, GLfloatP))
-BGL_Wrap(3, PixelMapuiv, void, (GLenum, GLint, GLuintP))
-BGL_Wrap(3, PixelMapusv, void, (GLenum, GLint, GLushortP))
-BGL_Wrap(2, PixelStoref, void, (GLenum, GLfloat))
-BGL_Wrap(2, PixelStorei, void, (GLenum, GLint))
-BGL_Wrap(2, PixelTransferf, void, (GLenum, GLfloat))
-BGL_Wrap(2, PixelTransferi, void, (GLenum, GLint))
-BGL_Wrap(2, PixelZoom, void, (GLfloat, GLfloat))
-BGL_Wrap(1, PointSize, void, (GLfloat))
-BGL_Wrap(2, PolygonMode, void, (GLenum, GLenum))
-BGL_Wrap(2, PolygonOffset, void, (GLfloat, GLfloat))
-BGL_Wrap(1, PolygonStipple, void, (GLubyteP))
-BGL_Wrap(1, PopAttrib, void, (void))
-BGL_Wrap(1, PopClientAttrib, void, (void))
-BGL_Wrap(1, PopMatrix, void, (void))
-BGL_Wrap(1, PopName, void, (void))
-BGL_Wrap(3, PrioritizeTextures, void, (GLsizei, GLuintP, GLclampfP))
-BGL_Wrap(1, PushAttrib, void, (GLbitfield))
-BGL_Wrap(1, PushClientAttrib, void, (GLbitfield))
-BGL_Wrap(1, PushMatrix, void, (void))
-BGL_Wrap(1, PushName, void, (GLuint))
-BGL_Wrap(2, RasterPos2d, void, (GLdouble, GLdouble))
-BGL_Wrap(1, RasterPos2dv, void, (GLdoubleP))
-BGL_Wrap(2, RasterPos2f, void, (GLfloat, GLfloat))
-BGL_Wrap(1, RasterPos2fv, void, (GLfloatP))
-BGL_Wrap(2, RasterPos2i, void, (GLint, GLint))
-BGL_Wrap(1, RasterPos2iv, void, (GLintP))
-BGL_Wrap(2, RasterPos2s, void, (GLshort, GLshort))
-BGL_Wrap(1, RasterPos2sv, void, (GLshortP))
-BGL_Wrap(3, RasterPos3d, void, (GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, RasterPos3dv, void, (GLdoubleP))
-BGL_Wrap(3, RasterPos3f, void, (GLfloat, GLfloat, GLfloat))
-BGL_Wrap(1, RasterPos3fv, void, (GLfloatP))
-BGL_Wrap(3, RasterPos3i, void, (GLint, GLint, GLint))
-BGL_Wrap(1, RasterPos3iv, void, (GLintP))
-BGL_Wrap(3, RasterPos3s, void, (GLshort, GLshort, GLshort))
-BGL_Wrap(1, RasterPos3sv, void, (GLshortP))
-BGL_Wrap(4, RasterPos4d, void, (GLdouble, GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, RasterPos4dv, void, (GLdoubleP))
-BGL_Wrap(4, RasterPos4f, void, (GLfloat, GLfloat, GLfloat, GLfloat))
-BGL_Wrap(1, RasterPos4fv, void, (GLfloatP))
-BGL_Wrap(4, RasterPos4i, void, (GLint, GLint, GLint, GLint))
-BGL_Wrap(1, RasterPos4iv, void, (GLintP))
-BGL_Wrap(4, RasterPos4s, void, (GLshort, GLshort, GLshort, GLshort))
-BGL_Wrap(1, RasterPos4sv, void, (GLshortP))
-BGL_Wrap(1, ReadBuffer, void, (GLenum))
-BGL_Wrap(7, ReadPixels, void, (GLint, GLint, GLsizei,
- GLsizei, GLenum, GLenum, GLvoidP))
-BGL_Wrap(4, Rectd, void, (GLdouble, GLdouble, GLdouble, GLdouble))
-BGL_Wrap(2, Rectdv, void, (GLdoubleP, GLdoubleP))
-BGL_Wrap(4, Rectf, void, (GLfloat, GLfloat, GLfloat, GLfloat))
-BGL_Wrap(2, Rectfv, void, (GLfloatP, GLfloatP))
-BGL_Wrap(4, Recti, void, (GLint, GLint, GLint, GLint))
-BGL_Wrap(2, Rectiv, void, (GLintP, GLintP))
-BGL_Wrap(4, Rects, void, (GLshort, GLshort, GLshort, GLshort))
-BGL_Wrap(2, Rectsv, void, (GLshortP, GLshortP))
-BGL_Wrap(1, RenderMode, GLint, (GLenum))
-BGL_Wrap(4, Rotated, void, (GLdouble, GLdouble, GLdouble, GLdouble))
-BGL_Wrap(4, Rotatef, void, (GLfloat, GLfloat, GLfloat, GLfloat))
-BGL_Wrap(3, Scaled, void, (GLdouble, GLdouble, GLdouble))
-BGL_Wrap(3, Scalef, void, (GLfloat, GLfloat, GLfloat))
-BGL_Wrap(4, Scissor, void, (GLint, GLint, GLsizei, GLsizei))
-BGL_Wrap(2, SelectBuffer, void, (GLsizei, GLuintP))
-BGL_Wrap(1, ShadeModel, void, (GLenum))
-BGL_Wrap(3, StencilFunc, void, (GLenum, GLint, GLuint))
-BGL_Wrap(1, StencilMask, void, (GLuint))
-BGL_Wrap(3, StencilOp, void, (GLenum, GLenum, GLenum))
-BGL_Wrap(1, TexCoord1d, void, (GLdouble))
-BGL_Wrap(1, TexCoord1dv, void, (GLdoubleP))
-BGL_Wrap(1, TexCoord1f, void, (GLfloat))
-BGL_Wrap(1, TexCoord1fv, void, (GLfloatP))
-BGL_Wrap(1, TexCoord1i, void, (GLint))
-BGL_Wrap(1, TexCoord1iv, void, (GLintP))
-BGL_Wrap(1, TexCoord1s, void, (GLshort))
-BGL_Wrap(1, TexCoord1sv, void, (GLshortP))
-BGL_Wrap(2, TexCoord2d, void, (GLdouble, GLdouble))
-BGL_Wrap(1, TexCoord2dv, void, (GLdoubleP))
-BGL_Wrap(2, TexCoord2f, void, (GLfloat, GLfloat))
-BGL_Wrap(1, TexCoord2fv, void, (GLfloatP))
-BGL_Wrap(2, TexCoord2i, void, (GLint, GLint))
-BGL_Wrap(1, TexCoord2iv, void, (GLintP))
-BGL_Wrap(2, TexCoord2s, void, (GLshort, GLshort))
-BGL_Wrap(1, TexCoord2sv, void, (GLshortP))
-BGL_Wrap(3, TexCoord3d, void, (GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, TexCoord3dv, void, (GLdoubleP))
-BGL_Wrap(3, TexCoord3f, void, (GLfloat, GLfloat, GLfloat))
-BGL_Wrap(1, TexCoord3fv, void, (GLfloatP))
-BGL_Wrap(3, TexCoord3i, void, (GLint, GLint, GLint))
-BGL_Wrap(1, TexCoord3iv, void, (GLintP))
-BGL_Wrap(3, TexCoord3s, void, (GLshort, GLshort, GLshort))
-BGL_Wrap(1, TexCoord3sv, void, (GLshortP))
-BGL_Wrap(4, TexCoord4d, void, (GLdouble, GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, TexCoord4dv, void, (GLdoubleP))
-BGL_Wrap(4, TexCoord4f, void, (GLfloat, GLfloat, GLfloat, GLfloat))
-BGL_Wrap(1, TexCoord4fv, void, (GLfloatP))
-BGL_Wrap(4, TexCoord4i, void, (GLint, GLint, GLint, GLint))
-BGL_Wrap(1, TexCoord4iv, void, (GLintP))
-BGL_Wrap(4, TexCoord4s, void, (GLshort, GLshort, GLshort, GLshort))
-BGL_Wrap(1, TexCoord4sv, void, (GLshortP))
-BGL_Wrap(3, TexEnvf, void, (GLenum, GLenum, GLfloat))
-BGL_Wrap(3, TexEnvfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, TexEnvi, void, (GLenum, GLenum, GLint))
-BGL_Wrap(3, TexEnviv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(3, TexGend, void, (GLenum, GLenum, GLdouble))
-BGL_Wrap(3, TexGendv, void, (GLenum, GLenum, GLdoubleP))
-BGL_Wrap(3, TexGenf, void, (GLenum, GLenum, GLfloat))
-BGL_Wrap(3, TexGenfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, TexGeni, void, (GLenum, GLenum, GLint))
-BGL_Wrap(3, TexGeniv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(8, TexImage1D, void, (GLenum, GLint, GLint,
- GLsizei, GLint, GLenum, GLenum, GLvoidP))
-BGL_Wrap(9, TexImage2D, void, (GLenum, GLint, GLint,
- GLsizei, GLsizei, GLint, GLenum, GLenum, GLvoidP))
-BGL_Wrap(3, TexParameterf, void, (GLenum, GLenum, GLfloat))
-BGL_Wrap(3, TexParameterfv, void, (GLenum, GLenum, GLfloatP))
-BGL_Wrap(3, TexParameteri, void, (GLenum, GLenum, GLint))
-BGL_Wrap(3, TexParameteriv, void, (GLenum, GLenum, GLintP))
-BGL_Wrap(3, Translated, void, (GLdouble, GLdouble, GLdouble))
-BGL_Wrap(3, Translatef, void, (GLfloat, GLfloat, GLfloat))
-BGL_Wrap(2, Vertex2d, void, (GLdouble, GLdouble))
-BGL_Wrap(1, Vertex2dv, void, (GLdoubleP))
-BGL_Wrap(2, Vertex2f, void, (GLfloat, GLfloat))
-BGL_Wrap(1, Vertex2fv, void, (GLfloatP))
-BGL_Wrap(2, Vertex2i, void, (GLint, GLint))
-BGL_Wrap(1, Vertex2iv, void, (GLintP))
-BGL_Wrap(2, Vertex2s, void, (GLshort, GLshort))
-BGL_Wrap(1, Vertex2sv, void, (GLshortP))
-BGL_Wrap(3, Vertex3d, void, (GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, Vertex3dv, void, (GLdoubleP))
-BGL_Wrap(3, Vertex3f, void, (GLfloat, GLfloat, GLfloat))
-BGL_Wrap(1, Vertex3fv, void, (GLfloatP))
-BGL_Wrap(3, Vertex3i, void, (GLint, GLint, GLint))
-BGL_Wrap(1, Vertex3iv, void, (GLintP))
-BGL_Wrap(3, Vertex3s, void, (GLshort, GLshort, GLshort))
-BGL_Wrap(1, Vertex3sv, void, (GLshortP))
-BGL_Wrap(4, Vertex4d, void, (GLdouble, GLdouble, GLdouble, GLdouble))
-BGL_Wrap(1, Vertex4dv, void, (GLdoubleP))
-BGL_Wrap(4, Vertex4f, void, (GLfloat, GLfloat, GLfloat, GLfloat))
-BGL_Wrap(1, Vertex4fv, void, (GLfloatP))
-BGL_Wrap(4, Vertex4i, void, (GLint, GLint, GLint, GLint))
-BGL_Wrap(1, Vertex4iv, void, (GLintP))
-BGL_Wrap(4, Vertex4s, void, (GLshort, GLshort, GLshort, GLshort))
-BGL_Wrap(1, Vertex4sv, void, (GLshortP))
-BGL_Wrap(4, Viewport, void, (GLint, GLint, GLsizei, GLsizei))
-BGLU_Wrap(4, Perspective, void, (GLdouble, GLdouble, GLdouble, GLdouble))
-BGLU_Wrap(9, LookAt, void, (GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble))
-BGLU_Wrap(4, Ortho2D, void, (GLdouble, GLdouble, GLdouble, GLdouble))
-BGLU_Wrap(5, PickMatrix, void, (GLdouble, GLdouble, GLdouble, GLdouble, GLintP))
-BGLU_Wrap(9, Project, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP))
-BGLU_Wrap(9, UnProject, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP))
-
-#undef MethodDef
-#define MethodDef(func) {"gl"#func, Method_##func, METH_VARARGS, "no string"}
-#define MethodDefu(func) {"glu"#func, Method_##func, METH_VARARGS, "no string"}
-/* So that MethodDef(Accum) becomes:
- * {"glAccum", Method_Accumfunc, METH_VARARGS} */
-
-static struct PyMethodDef BGL_methods[] = {
- {"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc},
-
-/* #ifndef __APPLE__ */
- MethodDef(Accum),
- MethodDef(AlphaFunc),
- MethodDef(AreTexturesResident),
- MethodDef(Begin),
- MethodDef(BindTexture),
- MethodDef(Bitmap),
- MethodDef(BlendFunc),
- MethodDef(CallList),
- MethodDef(CallLists),
- MethodDef(Clear),
- MethodDef(ClearAccum),
- MethodDef(ClearColor),
- MethodDef(ClearDepth),
- MethodDef(ClearIndex),
- MethodDef(ClearStencil),
- MethodDef(ClipPlane),
- MethodDef(Color3b),
- MethodDef(Color3bv),
- MethodDef(Color3d),
- MethodDef(Color3dv),
- MethodDef(Color3f),
- MethodDef(Color3fv),
- MethodDef(Color3i),
- MethodDef(Color3iv),
- MethodDef(Color3s),
- MethodDef(Color3sv),
- MethodDef(Color3ub),
- MethodDef(Color3ubv),
- MethodDef(Color3ui),
- MethodDef(Color3uiv),
- MethodDef(Color3us),
- MethodDef(Color3usv),
- MethodDef(Color4b),
- MethodDef(Color4bv),
- MethodDef(Color4d),
- MethodDef(Color4dv),
- MethodDef(Color4f),
- MethodDef(Color4fv),
- MethodDef(Color4i),
- MethodDef(Color4iv),
- MethodDef(Color4s),
- MethodDef(Color4sv),
- MethodDef(Color4ub),
- MethodDef(Color4ubv),
- MethodDef(Color4ui),
- MethodDef(Color4uiv),
- MethodDef(Color4us),
- MethodDef(Color4usv),
- MethodDef(ColorMask),
- MethodDef(ColorMaterial),
- MethodDef(CopyPixels),
- MethodDef(CullFace),
- MethodDef(DeleteLists),
- MethodDef(DeleteTextures),
- MethodDef(DepthFunc),
- MethodDef(DepthMask),
- MethodDef(DepthRange),
- MethodDef(Disable),
- MethodDef(DrawBuffer),
- MethodDef(DrawPixels),
- MethodDef(EdgeFlag),
- MethodDef(EdgeFlagv),
- MethodDef(Enable),
- MethodDef(End),
- MethodDef(EndList),
- MethodDef(EvalCoord1d),
- MethodDef(EvalCoord1dv),
- MethodDef(EvalCoord1f),
- MethodDef(EvalCoord1fv),
- MethodDef(EvalCoord2d),
- MethodDef(EvalCoord2dv),
- MethodDef(EvalCoord2f),
- MethodDef(EvalCoord2fv),
- MethodDef(EvalMesh1),
- MethodDef(EvalMesh2),
- MethodDef(EvalPoint1),
- MethodDef(EvalPoint2),
- MethodDef(FeedbackBuffer),
- MethodDef(Finish),
- MethodDef(Flush),
- MethodDef(Fogf),
- MethodDef(Fogfv),
- MethodDef(Fogi),
- MethodDef(Fogiv),
- MethodDef(FrontFace),
- MethodDef(Frustum),
- MethodDef(GenLists),
- MethodDef(GenTextures),
- MethodDef(GetBooleanv),
- MethodDef(GetClipPlane),
- MethodDef(GetDoublev),
- MethodDef(GetError),
- MethodDef(GetFloatv),
- MethodDef(GetIntegerv),
- MethodDef(GetLightfv),
- MethodDef(GetLightiv),
- MethodDef(GetMapdv),
- MethodDef(GetMapfv),
- MethodDef(GetMapiv),
- MethodDef(GetMaterialfv),
- MethodDef(GetMaterialiv),
- MethodDef(GetPixelMapfv),
- MethodDef(GetPixelMapuiv),
- MethodDef(GetPixelMapusv),
- MethodDef(GetPolygonStipple),
- MethodDef(GetString),
- MethodDef(GetTexEnvfv),
- MethodDef(GetTexEnviv),
- MethodDef(GetTexGendv),
- MethodDef(GetTexGenfv),
- MethodDef(GetTexGeniv),
- MethodDef(GetTexImage),
- MethodDef(GetTexLevelParameterfv),
- MethodDef(GetTexLevelParameteriv),
- MethodDef(GetTexParameterfv),
- MethodDef(GetTexParameteriv),
- MethodDef(Hint),
- MethodDef(IndexMask),
- MethodDef(Indexd),
- MethodDef(Indexdv),
- MethodDef(Indexf),
- MethodDef(Indexfv),
- MethodDef(Indexi),
- MethodDef(Indexiv),
- MethodDef(Indexs),
- MethodDef(Indexsv),
- MethodDef(InitNames),
- MethodDef(IsEnabled),
- MethodDef(IsList),
- MethodDef(IsTexture),
- MethodDef(LightModelf),
- MethodDef(LightModelfv),
- MethodDef(LightModeli),
- MethodDef(LightModeliv),
- MethodDef(Lightf),
- MethodDef(Lightfv),
- MethodDef(Lighti),
- MethodDef(Lightiv),
- MethodDef(LineStipple),
- MethodDef(LineWidth),
- MethodDef(ListBase),
- MethodDef(LoadIdentity),
- MethodDef(LoadMatrixd),
- MethodDef(LoadMatrixf),
- MethodDef(LoadName),
- MethodDef(LogicOp),
- MethodDef(Map1d),
- MethodDef(Map1f),
- MethodDef(Map2d),
- MethodDef(Map2f),
- MethodDef(MapGrid1d),
- MethodDef(MapGrid1f),
- MethodDef(MapGrid2d),
- MethodDef(MapGrid2f),
- MethodDef(Materialf),
- MethodDef(Materialfv),
- MethodDef(Materiali),
- MethodDef(Materialiv),
- MethodDef(MatrixMode),
- MethodDef(MultMatrixd),
- MethodDef(MultMatrixf),
- MethodDef(NewList),
- MethodDef(Normal3b),
- MethodDef(Normal3bv),
- MethodDef(Normal3d),
- MethodDef(Normal3dv),
- MethodDef(Normal3f),
- MethodDef(Normal3fv),
- MethodDef(Normal3i),
- MethodDef(Normal3iv),
- MethodDef(Normal3s),
- MethodDef(Normal3sv),
- MethodDef(Ortho),
- MethodDef(PassThrough),
- MethodDef(PixelMapfv),
- MethodDef(PixelMapuiv),
- MethodDef(PixelMapusv),
- MethodDef(PixelStoref),
- MethodDef(PixelStorei),
- MethodDef(PixelTransferf),
- MethodDef(PixelTransferi),
- MethodDef(PixelZoom),
- MethodDef(PointSize),
- MethodDef(PolygonMode),
- MethodDef(PolygonOffset),
- MethodDef(PolygonStipple),
- MethodDef(PopAttrib),
- MethodDef(PopClientAttrib),
- MethodDef(PopMatrix),
- MethodDef(PopName),
- MethodDef(PrioritizeTextures),
- MethodDef(PushAttrib),
- MethodDef(PushClientAttrib),
- MethodDef(PushMatrix),
- MethodDef(PushName),
- MethodDef(RasterPos2d),
- MethodDef(RasterPos2dv),
- MethodDef(RasterPos2f),
- MethodDef(RasterPos2fv),
- MethodDef(RasterPos2i),
- MethodDef(RasterPos2iv),
- MethodDef(RasterPos2s),
- MethodDef(RasterPos2sv),
- MethodDef(RasterPos3d),
- MethodDef(RasterPos3dv),
- MethodDef(RasterPos3f),
- MethodDef(RasterPos3fv),
- MethodDef(RasterPos3i),
- MethodDef(RasterPos3iv),
- MethodDef(RasterPos3s),
- MethodDef(RasterPos3sv),
- MethodDef(RasterPos4d),
- MethodDef(RasterPos4dv),
- MethodDef(RasterPos4f),
- MethodDef(RasterPos4fv),
- MethodDef(RasterPos4i),
- MethodDef(RasterPos4iv),
- MethodDef(RasterPos4s),
- MethodDef(RasterPos4sv),
- MethodDef(ReadBuffer),
- MethodDef(ReadPixels),
- MethodDef(Rectd),
- MethodDef(Rectdv),
- MethodDef(Rectf),
- MethodDef(Rectfv),
- MethodDef(Recti),
- MethodDef(Rectiv),
- MethodDef(Rects),
- MethodDef(Rectsv),
- MethodDef(RenderMode),
- MethodDef(Rotated),
- MethodDef(Rotatef),
- MethodDef(Scaled),
- MethodDef(Scalef),
- MethodDef(Scissor),
- MethodDef(SelectBuffer),
- MethodDef(ShadeModel),
- MethodDef(StencilFunc),
- MethodDef(StencilMask),
- MethodDef(StencilOp),
- MethodDef(TexCoord1d),
- MethodDef(TexCoord1dv),
- MethodDef(TexCoord1f),
- MethodDef(TexCoord1fv),
- MethodDef(TexCoord1i),
- MethodDef(TexCoord1iv),
- MethodDef(TexCoord1s),
- MethodDef(TexCoord1sv),
- MethodDef(TexCoord2d),
- MethodDef(TexCoord2dv),
- MethodDef(TexCoord2f),
- MethodDef(TexCoord2fv),
- MethodDef(TexCoord2i),
- MethodDef(TexCoord2iv),
- MethodDef(TexCoord2s),
- MethodDef(TexCoord2sv),
- MethodDef(TexCoord3d),
- MethodDef(TexCoord3dv),
- MethodDef(TexCoord3f),
- MethodDef(TexCoord3fv),
- MethodDef(TexCoord3i),
- MethodDef(TexCoord3iv),
- MethodDef(TexCoord3s),
- MethodDef(TexCoord3sv),
- MethodDef(TexCoord4d),
- MethodDef(TexCoord4dv),
- MethodDef(TexCoord4f),
- MethodDef(TexCoord4fv),
- MethodDef(TexCoord4i),
- MethodDef(TexCoord4iv),
- MethodDef(TexCoord4s),
- MethodDef(TexCoord4sv),
- MethodDef(TexEnvf),
- MethodDef(TexEnvfv),
- MethodDef(TexEnvi),
- MethodDef(TexEnviv),
- MethodDef(TexGend),
- MethodDef(TexGendv),
- MethodDef(TexGenf),
- MethodDef(TexGenfv),
- MethodDef(TexGeni),
- MethodDef(TexGeniv),
- MethodDef(TexImage1D),
- MethodDef(TexImage2D),
- MethodDef(TexParameterf),
- MethodDef(TexParameterfv),
- MethodDef(TexParameteri),
- MethodDef(TexParameteriv),
- MethodDef(Translated),
- MethodDef(Translatef),
- MethodDef(Vertex2d),
- MethodDef(Vertex2dv),
- MethodDef(Vertex2f),
- MethodDef(Vertex2fv),
- MethodDef(Vertex2i),
- MethodDef(Vertex2iv),
- MethodDef(Vertex2s),
- MethodDef(Vertex2sv),
- MethodDef(Vertex3d),
- MethodDef(Vertex3dv),
- MethodDef(Vertex3f),
- MethodDef(Vertex3fv),
- MethodDef(Vertex3i),
- MethodDef(Vertex3iv),
- MethodDef(Vertex3s),
- MethodDef(Vertex3sv),
- MethodDef(Vertex4d),
- MethodDef(Vertex4dv),
- MethodDef(Vertex4f),
- MethodDef(Vertex4fv),
- MethodDef(Vertex4i),
- MethodDef(Vertex4iv),
- MethodDef(Vertex4s),
- MethodDef(Vertex4sv),
- MethodDef(Viewport),
- MethodDefu(Perspective),
- MethodDefu(LookAt),
- MethodDefu(Ortho2D),
- MethodDefu(PickMatrix),
- MethodDefu(Project),
- MethodDefu(UnProject),
-/* #endif */
- {NULL, NULL, 0, NULL}
-};
-
-PyObject *BGL_Init(void)
-{
- PyObject *mod= Py_InitModule("Blender.BGL", BGL_methods);
- PyObject *dict= PyModule_GetDict(mod);
-
- if( PyType_Ready( &buffer_Type) < 0)
- Py_RETURN_NONE;
-
-#define EXPP_ADDCONST(x) EXPP_dict_set_item_str(dict, #x, PyInt_FromLong(x))
-
-/* So, for example:
- * EXPP_ADDCONST(GL_CURRENT_BIT) becomes
- * EXPP_dict_set_item_str(dict, "GL_CURRENT_BIT", PyInt_FromLong(GL_CURRENT_BIT)) */
-
- EXPP_ADDCONST(GL_CURRENT_BIT);
- EXPP_ADDCONST(GL_POINT_BIT);
- EXPP_ADDCONST(GL_LINE_BIT);
- EXPP_ADDCONST(GL_POLYGON_BIT);
- EXPP_ADDCONST(GL_POLYGON_STIPPLE_BIT);
- EXPP_ADDCONST(GL_PIXEL_MODE_BIT);
- EXPP_ADDCONST(GL_LIGHTING_BIT);
- EXPP_ADDCONST(GL_FOG_BIT);
- EXPP_ADDCONST(GL_DEPTH_BUFFER_BIT);
- EXPP_ADDCONST(GL_ACCUM_BUFFER_BIT);
- EXPP_ADDCONST(GL_STENCIL_BUFFER_BIT);
- EXPP_ADDCONST(GL_VIEWPORT_BIT);
- EXPP_ADDCONST(GL_TRANSFORM_BIT);
- EXPP_ADDCONST(GL_ENABLE_BIT);
- EXPP_ADDCONST(GL_COLOR_BUFFER_BIT);
- EXPP_ADDCONST(GL_HINT_BIT);
- EXPP_ADDCONST(GL_EVAL_BIT);
- EXPP_ADDCONST(GL_LIST_BIT);
- EXPP_ADDCONST(GL_TEXTURE_BIT);
- EXPP_ADDCONST(GL_SCISSOR_BIT);
- EXPP_ADDCONST(GL_ALL_ATTRIB_BITS);
-
- EXPP_ADDCONST(GL_FALSE);
- EXPP_ADDCONST(GL_TRUE);
-
- EXPP_ADDCONST(GL_POINTS);
- EXPP_ADDCONST(GL_LINES);
- EXPP_ADDCONST(GL_LINE_LOOP);
- EXPP_ADDCONST(GL_LINE_STRIP);
- EXPP_ADDCONST(GL_TRIANGLES);
- EXPP_ADDCONST(GL_TRIANGLE_STRIP);
- EXPP_ADDCONST(GL_TRIANGLE_FAN);
- EXPP_ADDCONST(GL_QUADS);
- EXPP_ADDCONST(GL_QUAD_STRIP);
- EXPP_ADDCONST(GL_POLYGON);
-
- EXPP_ADDCONST(GL_ACCUM);
- EXPP_ADDCONST(GL_LOAD);
- EXPP_ADDCONST(GL_RETURN);
- EXPP_ADDCONST(GL_MULT);
- EXPP_ADDCONST(GL_ADD);
-
- EXPP_ADDCONST(GL_NEVER);
- EXPP_ADDCONST(GL_LESS);
- EXPP_ADDCONST(GL_EQUAL);
- EXPP_ADDCONST(GL_LEQUAL);
- EXPP_ADDCONST(GL_GREATER);
- EXPP_ADDCONST(GL_NOTEQUAL);
- EXPP_ADDCONST(GL_GEQUAL);
- EXPP_ADDCONST(GL_ALWAYS);
-
- EXPP_ADDCONST(GL_ZERO);
- EXPP_ADDCONST(GL_ONE);
- EXPP_ADDCONST(GL_SRC_COLOR);
- EXPP_ADDCONST(GL_ONE_MINUS_SRC_COLOR);
- EXPP_ADDCONST(GL_SRC_ALPHA);
- EXPP_ADDCONST(GL_ONE_MINUS_SRC_ALPHA);
- EXPP_ADDCONST(GL_DST_ALPHA);
- EXPP_ADDCONST(GL_ONE_MINUS_DST_ALPHA);
-
- EXPP_ADDCONST(GL_DST_COLOR);
- EXPP_ADDCONST(GL_ONE_MINUS_DST_COLOR);
- EXPP_ADDCONST(GL_SRC_ALPHA_SATURATE);
-
- EXPP_ADDCONST(GL_NONE);
- EXPP_ADDCONST(GL_FRONT_LEFT);
- EXPP_ADDCONST(GL_FRONT_RIGHT);
- EXPP_ADDCONST(GL_BACK_LEFT);
- EXPP_ADDCONST(GL_BACK_RIGHT);
- EXPP_ADDCONST(GL_FRONT);
- EXPP_ADDCONST(GL_BACK);
- EXPP_ADDCONST(GL_LEFT);
- EXPP_ADDCONST(GL_RIGHT);
- EXPP_ADDCONST(GL_FRONT_AND_BACK);
- EXPP_ADDCONST(GL_AUX0);
- EXPP_ADDCONST(GL_AUX1);
- EXPP_ADDCONST(GL_AUX2);
- EXPP_ADDCONST(GL_AUX3);
-
- EXPP_ADDCONST(GL_NO_ERROR);
- EXPP_ADDCONST(GL_INVALID_ENUM);
- EXPP_ADDCONST(GL_INVALID_VALUE);
- EXPP_ADDCONST(GL_INVALID_OPERATION);
- EXPP_ADDCONST(GL_STACK_OVERFLOW);
- EXPP_ADDCONST(GL_STACK_UNDERFLOW);
- EXPP_ADDCONST(GL_OUT_OF_MEMORY);
-
- EXPP_ADDCONST(GL_2D);
- EXPP_ADDCONST(GL_3D);
- EXPP_ADDCONST(GL_3D_COLOR);
- EXPP_ADDCONST(GL_3D_COLOR_TEXTURE);
- EXPP_ADDCONST(GL_4D_COLOR_TEXTURE);
-
- EXPP_ADDCONST(GL_PASS_THROUGH_TOKEN);
- EXPP_ADDCONST(GL_POINT_TOKEN);
- EXPP_ADDCONST(GL_LINE_TOKEN);
- EXPP_ADDCONST(GL_POLYGON_TOKEN);
- EXPP_ADDCONST(GL_BITMAP_TOKEN);
- EXPP_ADDCONST(GL_DRAW_PIXEL_TOKEN);
- EXPP_ADDCONST(GL_COPY_PIXEL_TOKEN);
- EXPP_ADDCONST(GL_LINE_RESET_TOKEN);
-
- EXPP_ADDCONST(GL_EXP);
- EXPP_ADDCONST(GL_EXP2);
-
- EXPP_ADDCONST(GL_CW);
- EXPP_ADDCONST(GL_CCW);
-
- EXPP_ADDCONST(GL_COEFF);
- EXPP_ADDCONST(GL_ORDER);
- EXPP_ADDCONST(GL_DOMAIN);
-
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_I);
- EXPP_ADDCONST(GL_PIXEL_MAP_S_TO_S);
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_R);
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_G);
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_B);
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_A);
- EXPP_ADDCONST(GL_PIXEL_MAP_R_TO_R);
- EXPP_ADDCONST(GL_PIXEL_MAP_G_TO_G);
- EXPP_ADDCONST(GL_PIXEL_MAP_B_TO_B);
- EXPP_ADDCONST(GL_PIXEL_MAP_A_TO_A);
-
- EXPP_ADDCONST(GL_CURRENT_COLOR);
- EXPP_ADDCONST(GL_CURRENT_INDEX);
- EXPP_ADDCONST(GL_CURRENT_NORMAL);
- EXPP_ADDCONST(GL_CURRENT_TEXTURE_COORDS);
- EXPP_ADDCONST(GL_CURRENT_RASTER_COLOR);
- EXPP_ADDCONST(GL_CURRENT_RASTER_INDEX);
- EXPP_ADDCONST(GL_CURRENT_RASTER_TEXTURE_COORDS);
- EXPP_ADDCONST(GL_CURRENT_RASTER_POSITION);
- EXPP_ADDCONST(GL_CURRENT_RASTER_POSITION_VALID);
- EXPP_ADDCONST(GL_CURRENT_RASTER_DISTANCE);
- EXPP_ADDCONST(GL_POINT_SMOOTH);
- EXPP_ADDCONST(GL_POINT_SIZE);
- EXPP_ADDCONST(GL_POINT_SIZE_RANGE);
- EXPP_ADDCONST(GL_POINT_SIZE_GRANULARITY);
- EXPP_ADDCONST(GL_LINE_SMOOTH);
- EXPP_ADDCONST(GL_LINE_WIDTH);
- EXPP_ADDCONST(GL_LINE_WIDTH_RANGE);
- EXPP_ADDCONST(GL_LINE_WIDTH_GRANULARITY);
- EXPP_ADDCONST(GL_LINE_STIPPLE);
- EXPP_ADDCONST(GL_LINE_STIPPLE_PATTERN);
- EXPP_ADDCONST(GL_LINE_STIPPLE_REPEAT);
- EXPP_ADDCONST(GL_LIST_MODE);
- EXPP_ADDCONST(GL_MAX_LIST_NESTING);
- EXPP_ADDCONST(GL_LIST_BASE);
- EXPP_ADDCONST(GL_LIST_INDEX);
- EXPP_ADDCONST(GL_POLYGON_MODE);
- EXPP_ADDCONST(GL_POLYGON_SMOOTH);
- EXPP_ADDCONST(GL_POLYGON_STIPPLE);
- EXPP_ADDCONST(GL_EDGE_FLAG);
- EXPP_ADDCONST(GL_CULL_FACE);
- EXPP_ADDCONST(GL_CULL_FACE_MODE);
- EXPP_ADDCONST(GL_FRONT_FACE);
- EXPP_ADDCONST(GL_LIGHTING);
- EXPP_ADDCONST(GL_LIGHT_MODEL_LOCAL_VIEWER);
- EXPP_ADDCONST(GL_LIGHT_MODEL_TWO_SIDE);
- EXPP_ADDCONST(GL_LIGHT_MODEL_AMBIENT);
- EXPP_ADDCONST(GL_SHADE_MODEL);
- EXPP_ADDCONST(GL_COLOR_MATERIAL_FACE);
- EXPP_ADDCONST(GL_COLOR_MATERIAL_PARAMETER);
- EXPP_ADDCONST(GL_COLOR_MATERIAL);
- EXPP_ADDCONST(GL_FOG);
- EXPP_ADDCONST(GL_FOG_INDEX);
- EXPP_ADDCONST(GL_FOG_DENSITY);
- EXPP_ADDCONST(GL_FOG_START);
- EXPP_ADDCONST(GL_FOG_END);
- EXPP_ADDCONST(GL_FOG_MODE);
- EXPP_ADDCONST(GL_FOG_COLOR);
- EXPP_ADDCONST(GL_DEPTH_RANGE);
- EXPP_ADDCONST(GL_DEPTH_TEST);
- EXPP_ADDCONST(GL_DEPTH_WRITEMASK);
- EXPP_ADDCONST(GL_DEPTH_CLEAR_VALUE);
- EXPP_ADDCONST(GL_DEPTH_FUNC);
- EXPP_ADDCONST(GL_ACCUM_CLEAR_VALUE);
- EXPP_ADDCONST(GL_STENCIL_TEST);
- EXPP_ADDCONST(GL_STENCIL_CLEAR_VALUE);
- EXPP_ADDCONST(GL_STENCIL_FUNC);
- EXPP_ADDCONST(GL_STENCIL_VALUE_MASK);
- EXPP_ADDCONST(GL_STENCIL_FAIL);
- EXPP_ADDCONST(GL_STENCIL_PASS_DEPTH_FAIL);
- EXPP_ADDCONST(GL_STENCIL_PASS_DEPTH_PASS);
- EXPP_ADDCONST(GL_STENCIL_REF);
- EXPP_ADDCONST(GL_STENCIL_WRITEMASK);
- EXPP_ADDCONST(GL_MATRIX_MODE);
- EXPP_ADDCONST(GL_NORMALIZE);
- EXPP_ADDCONST(GL_VIEWPORT);
- EXPP_ADDCONST(GL_MODELVIEW_STACK_DEPTH);
- EXPP_ADDCONST(GL_PROJECTION_STACK_DEPTH);
- EXPP_ADDCONST(GL_TEXTURE_STACK_DEPTH);
- EXPP_ADDCONST(GL_MODELVIEW_MATRIX);
- EXPP_ADDCONST(GL_PROJECTION_MATRIX);
- EXPP_ADDCONST(GL_TEXTURE_MATRIX);
- EXPP_ADDCONST(GL_ATTRIB_STACK_DEPTH);
- EXPP_ADDCONST(GL_ALPHA_TEST);
- EXPP_ADDCONST(GL_ALPHA_TEST_FUNC);
- EXPP_ADDCONST(GL_ALPHA_TEST_REF);
- EXPP_ADDCONST(GL_DITHER);
- EXPP_ADDCONST(GL_BLEND_DST);
- EXPP_ADDCONST(GL_BLEND_SRC);
- EXPP_ADDCONST(GL_BLEND);
- EXPP_ADDCONST(GL_LOGIC_OP_MODE);
- EXPP_ADDCONST(GL_LOGIC_OP);
- EXPP_ADDCONST(GL_AUX_BUFFERS);
- EXPP_ADDCONST(GL_DRAW_BUFFER);
- EXPP_ADDCONST(GL_READ_BUFFER);
- EXPP_ADDCONST(GL_SCISSOR_BOX);
- EXPP_ADDCONST(GL_SCISSOR_TEST);
- EXPP_ADDCONST(GL_INDEX_CLEAR_VALUE);
- EXPP_ADDCONST(GL_INDEX_WRITEMASK);
- EXPP_ADDCONST(GL_COLOR_CLEAR_VALUE);
- EXPP_ADDCONST(GL_COLOR_WRITEMASK);
- EXPP_ADDCONST(GL_INDEX_MODE);
- EXPP_ADDCONST(GL_RGBA_MODE);
- EXPP_ADDCONST(GL_DOUBLEBUFFER);
- EXPP_ADDCONST(GL_STEREO);
- EXPP_ADDCONST(GL_RENDER_MODE);
- EXPP_ADDCONST(GL_PERSPECTIVE_CORRECTION_HINT);
- EXPP_ADDCONST(GL_POINT_SMOOTH_HINT);
- EXPP_ADDCONST(GL_LINE_SMOOTH_HINT);
- EXPP_ADDCONST(GL_POLYGON_SMOOTH_HINT);
- EXPP_ADDCONST(GL_FOG_HINT);
- EXPP_ADDCONST(GL_TEXTURE_GEN_S);
- EXPP_ADDCONST(GL_TEXTURE_GEN_T);
- EXPP_ADDCONST(GL_TEXTURE_GEN_R);
- EXPP_ADDCONST(GL_TEXTURE_GEN_Q);
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_I_SIZE);
- EXPP_ADDCONST(GL_PIXEL_MAP_S_TO_S_SIZE);
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_R_SIZE);
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_G_SIZE);
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_B_SIZE);
- EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_A_SIZE);
- EXPP_ADDCONST(GL_PIXEL_MAP_R_TO_R_SIZE);
- EXPP_ADDCONST(GL_PIXEL_MAP_G_TO_G_SIZE);
- EXPP_ADDCONST(GL_PIXEL_MAP_B_TO_B_SIZE);
- EXPP_ADDCONST(GL_PIXEL_MAP_A_TO_A_SIZE);
- EXPP_ADDCONST(GL_UNPACK_SWAP_BYTES);
- EXPP_ADDCONST(GL_UNPACK_LSB_FIRST);
- EXPP_ADDCONST(GL_UNPACK_ROW_LENGTH);
- EXPP_ADDCONST(GL_UNPACK_SKIP_ROWS);
- EXPP_ADDCONST(GL_UNPACK_SKIP_PIXELS);
- EXPP_ADDCONST(GL_UNPACK_ALIGNMENT);
- EXPP_ADDCONST(GL_PACK_SWAP_BYTES);
- EXPP_ADDCONST(GL_PACK_LSB_FIRST);
- EXPP_ADDCONST(GL_PACK_ROW_LENGTH);
- EXPP_ADDCONST(GL_PACK_SKIP_ROWS);
- EXPP_ADDCONST(GL_PACK_SKIP_PIXELS);
- EXPP_ADDCONST(GL_PACK_ALIGNMENT);
- EXPP_ADDCONST(GL_MAP_COLOR);
- EXPP_ADDCONST(GL_MAP_STENCIL);
- EXPP_ADDCONST(GL_INDEX_SHIFT);
- EXPP_ADDCONST(GL_INDEX_OFFSET);
- EXPP_ADDCONST(GL_RED_SCALE);
- EXPP_ADDCONST(GL_RED_BIAS);
- EXPP_ADDCONST(GL_ZOOM_X);
- EXPP_ADDCONST(GL_ZOOM_Y);
- EXPP_ADDCONST(GL_GREEN_SCALE);
- EXPP_ADDCONST(GL_GREEN_BIAS);
- EXPP_ADDCONST(GL_BLUE_SCALE);
- EXPP_ADDCONST(GL_BLUE_BIAS);
- EXPP_ADDCONST(GL_ALPHA_SCALE);
- EXPP_ADDCONST(GL_ALPHA_BIAS);
- EXPP_ADDCONST(GL_DEPTH_SCALE);
- EXPP_ADDCONST(GL_DEPTH_BIAS);
- EXPP_ADDCONST(GL_MAX_EVAL_ORDER);
- EXPP_ADDCONST(GL_MAX_LIGHTS);
- EXPP_ADDCONST(GL_MAX_CLIP_PLANES);
- EXPP_ADDCONST(GL_MAX_TEXTURE_SIZE);
- EXPP_ADDCONST(GL_MAX_PIXEL_MAP_TABLE);
- EXPP_ADDCONST(GL_MAX_ATTRIB_STACK_DEPTH);
- EXPP_ADDCONST(GL_MAX_MODELVIEW_STACK_DEPTH);
- EXPP_ADDCONST(GL_MAX_NAME_STACK_DEPTH);
- EXPP_ADDCONST(GL_MAX_PROJECTION_STACK_DEPTH);
- EXPP_ADDCONST(GL_MAX_TEXTURE_STACK_DEPTH);
- EXPP_ADDCONST(GL_MAX_VIEWPORT_DIMS);
- EXPP_ADDCONST(GL_SUBPIXEL_BITS);
- EXPP_ADDCONST(GL_INDEX_BITS);
- EXPP_ADDCONST(GL_RED_BITS);
- EXPP_ADDCONST(GL_GREEN_BITS);
- EXPP_ADDCONST(GL_BLUE_BITS);
- EXPP_ADDCONST(GL_ALPHA_BITS);
- EXPP_ADDCONST(GL_DEPTH_BITS);
- EXPP_ADDCONST(GL_STENCIL_BITS);
- EXPP_ADDCONST(GL_ACCUM_RED_BITS);
- EXPP_ADDCONST(GL_ACCUM_GREEN_BITS);
- EXPP_ADDCONST(GL_ACCUM_BLUE_BITS);
- EXPP_ADDCONST(GL_ACCUM_ALPHA_BITS);
- EXPP_ADDCONST(GL_NAME_STACK_DEPTH);
- EXPP_ADDCONST(GL_AUTO_NORMAL);
- EXPP_ADDCONST(GL_MAP1_COLOR_4);
- EXPP_ADDCONST(GL_MAP1_INDEX);
- EXPP_ADDCONST(GL_MAP1_NORMAL);
- EXPP_ADDCONST(GL_MAP1_TEXTURE_COORD_1);
- EXPP_ADDCONST(GL_MAP1_TEXTURE_COORD_2);
- EXPP_ADDCONST(GL_MAP1_TEXTURE_COORD_3);
- EXPP_ADDCONST(GL_MAP1_TEXTURE_COORD_4);
- EXPP_ADDCONST(GL_MAP1_VERTEX_3);
- EXPP_ADDCONST(GL_MAP1_VERTEX_4);
- EXPP_ADDCONST(GL_MAP2_COLOR_4);
- EXPP_ADDCONST(GL_MAP2_INDEX);
- EXPP_ADDCONST(GL_MAP2_NORMAL);
- EXPP_ADDCONST(GL_MAP2_TEXTURE_COORD_1);
- EXPP_ADDCONST(GL_MAP2_TEXTURE_COORD_2);
- EXPP_ADDCONST(GL_MAP2_TEXTURE_COORD_3);
- EXPP_ADDCONST(GL_MAP2_TEXTURE_COORD_4);
- EXPP_ADDCONST(GL_MAP2_VERTEX_3);
- EXPP_ADDCONST(GL_MAP2_VERTEX_4);
- EXPP_ADDCONST(GL_MAP1_GRID_DOMAIN);
- EXPP_ADDCONST(GL_MAP1_GRID_SEGMENTS);
- EXPP_ADDCONST(GL_MAP2_GRID_DOMAIN);
- EXPP_ADDCONST(GL_MAP2_GRID_SEGMENTS);
- EXPP_ADDCONST(GL_TEXTURE_1D);
- EXPP_ADDCONST(GL_TEXTURE_2D);
-
- EXPP_ADDCONST(GL_TEXTURE_WIDTH);
- EXPP_ADDCONST(GL_TEXTURE_HEIGHT);
- EXPP_ADDCONST(GL_TEXTURE_COMPONENTS);
- EXPP_ADDCONST(GL_TEXTURE_BORDER_COLOR);
- EXPP_ADDCONST(GL_TEXTURE_BORDER);
-
- EXPP_ADDCONST(GL_DONT_CARE);
- EXPP_ADDCONST(GL_FASTEST);
- EXPP_ADDCONST(GL_NICEST);
-
- EXPP_ADDCONST(GL_AMBIENT);
- EXPP_ADDCONST(GL_DIFFUSE);
- EXPP_ADDCONST(GL_SPECULAR);
- EXPP_ADDCONST(GL_POSITION);
- EXPP_ADDCONST(GL_SPOT_DIRECTION);
- EXPP_ADDCONST(GL_SPOT_EXPONENT);
- EXPP_ADDCONST(GL_SPOT_CUTOFF);
- EXPP_ADDCONST(GL_CONSTANT_ATTENUATION);
- EXPP_ADDCONST(GL_LINEAR_ATTENUATION);
- EXPP_ADDCONST(GL_QUADRATIC_ATTENUATION);
-
- EXPP_ADDCONST(GL_COMPILE);
- EXPP_ADDCONST(GL_COMPILE_AND_EXECUTE);
-
- EXPP_ADDCONST(GL_BYTE);
- EXPP_ADDCONST(GL_UNSIGNED_BYTE);
- EXPP_ADDCONST(GL_SHORT);
- EXPP_ADDCONST(GL_UNSIGNED_SHORT);
- EXPP_ADDCONST(GL_INT);
- EXPP_ADDCONST(GL_UNSIGNED_INT);
- EXPP_ADDCONST(GL_FLOAT);
- EXPP_ADDCONST(GL_DOUBLE);
- EXPP_ADDCONST(GL_2_BYTES);
- EXPP_ADDCONST(GL_3_BYTES);
- EXPP_ADDCONST(GL_4_BYTES);
-
- EXPP_ADDCONST(GL_CLEAR);
- EXPP_ADDCONST(GL_AND);
- EXPP_ADDCONST(GL_AND_REVERSE);
- EXPP_ADDCONST(GL_COPY);
- EXPP_ADDCONST(GL_AND_INVERTED);
- EXPP_ADDCONST(GL_NOOP);
- EXPP_ADDCONST(GL_XOR);
- EXPP_ADDCONST(GL_OR);
- EXPP_ADDCONST(GL_NOR);
- EXPP_ADDCONST(GL_EQUIV);
- EXPP_ADDCONST(GL_INVERT);
- EXPP_ADDCONST(GL_OR_REVERSE);
- EXPP_ADDCONST(GL_COPY_INVERTED);
- EXPP_ADDCONST(GL_OR_INVERTED);
- EXPP_ADDCONST(GL_NAND);
- EXPP_ADDCONST(GL_SET);
-
- EXPP_ADDCONST(GL_EMISSION);
- EXPP_ADDCONST(GL_SHININESS);
- EXPP_ADDCONST(GL_AMBIENT_AND_DIFFUSE);
- EXPP_ADDCONST(GL_COLOR_INDEXES);
-
- EXPP_ADDCONST(GL_MODELVIEW);
- EXPP_ADDCONST(GL_PROJECTION);
- EXPP_ADDCONST(GL_TEXTURE);
-
- EXPP_ADDCONST(GL_COLOR);
- EXPP_ADDCONST(GL_DEPTH);
- EXPP_ADDCONST(GL_STENCIL);
-
- EXPP_ADDCONST(GL_COLOR_INDEX);
- EXPP_ADDCONST(GL_STENCIL_INDEX);
- EXPP_ADDCONST(GL_DEPTH_COMPONENT);
- EXPP_ADDCONST(GL_RED);
- EXPP_ADDCONST(GL_GREEN);
- EXPP_ADDCONST(GL_BLUE);
- EXPP_ADDCONST(GL_ALPHA);
- EXPP_ADDCONST(GL_RGB);
- EXPP_ADDCONST(GL_RGBA);
- EXPP_ADDCONST(GL_LUMINANCE);
- EXPP_ADDCONST(GL_LUMINANCE_ALPHA);
-
- EXPP_ADDCONST(GL_BITMAP);
-
- EXPP_ADDCONST(GL_POINT);
- EXPP_ADDCONST(GL_LINE);
- EXPP_ADDCONST(GL_FILL);
-
- EXPP_ADDCONST(GL_RENDER);
- EXPP_ADDCONST(GL_FEEDBACK);
- EXPP_ADDCONST(GL_SELECT);
-
- EXPP_ADDCONST(GL_FLAT);
- EXPP_ADDCONST(GL_SMOOTH);
-
- EXPP_ADDCONST(GL_KEEP);
- EXPP_ADDCONST(GL_REPLACE);
- EXPP_ADDCONST(GL_INCR);
- EXPP_ADDCONST(GL_DECR);
-
- EXPP_ADDCONST(GL_VENDOR);
- EXPP_ADDCONST(GL_RENDERER);
- EXPP_ADDCONST(GL_VERSION);
- EXPP_ADDCONST(GL_EXTENSIONS);
-
- EXPP_ADDCONST(GL_S);
- EXPP_ADDCONST(GL_T);
- EXPP_ADDCONST(GL_R);
- EXPP_ADDCONST(GL_Q);
-
- EXPP_ADDCONST(GL_MODULATE);
- EXPP_ADDCONST(GL_DECAL);
-
- EXPP_ADDCONST(GL_TEXTURE_ENV_MODE);
- EXPP_ADDCONST(GL_TEXTURE_ENV_COLOR);
-
- EXPP_ADDCONST(GL_TEXTURE_ENV);
-
- EXPP_ADDCONST(GL_EYE_LINEAR);
- EXPP_ADDCONST(GL_OBJECT_LINEAR);
- EXPP_ADDCONST(GL_SPHERE_MAP);
-
- EXPP_ADDCONST(GL_TEXTURE_GEN_MODE);
- EXPP_ADDCONST(GL_OBJECT_PLANE);
- EXPP_ADDCONST(GL_EYE_PLANE);
-
- EXPP_ADDCONST(GL_NEAREST);
- EXPP_ADDCONST(GL_LINEAR);
-
- EXPP_ADDCONST(GL_NEAREST_MIPMAP_NEAREST);
- EXPP_ADDCONST(GL_LINEAR_MIPMAP_NEAREST);
- EXPP_ADDCONST(GL_NEAREST_MIPMAP_LINEAR);
- EXPP_ADDCONST(GL_LINEAR_MIPMAP_LINEAR);
-
- EXPP_ADDCONST(GL_TEXTURE_MAG_FILTER);
- EXPP_ADDCONST(GL_TEXTURE_MIN_FILTER);
- EXPP_ADDCONST(GL_TEXTURE_WRAP_S);
- EXPP_ADDCONST(GL_TEXTURE_WRAP_T);
-
- EXPP_ADDCONST(GL_CLAMP);
- EXPP_ADDCONST(GL_REPEAT);
-
- EXPP_ADDCONST(GL_CLIP_PLANE0);
- EXPP_ADDCONST(GL_CLIP_PLANE1);
- EXPP_ADDCONST(GL_CLIP_PLANE2);
- EXPP_ADDCONST(GL_CLIP_PLANE3);
- EXPP_ADDCONST(GL_CLIP_PLANE4);
- EXPP_ADDCONST(GL_CLIP_PLANE5);
-
- EXPP_ADDCONST(GL_LIGHT0);
- EXPP_ADDCONST(GL_LIGHT1);
- EXPP_ADDCONST(GL_LIGHT2);
- EXPP_ADDCONST(GL_LIGHT3);
- EXPP_ADDCONST(GL_LIGHT4);
- EXPP_ADDCONST(GL_LIGHT5);
- EXPP_ADDCONST(GL_LIGHT6);
- EXPP_ADDCONST(GL_LIGHT7);
-
- EXPP_ADDCONST(GL_POLYGON_OFFSET_UNITS);
- EXPP_ADDCONST(GL_POLYGON_OFFSET_POINT);
- EXPP_ADDCONST(GL_POLYGON_OFFSET_LINE);
- EXPP_ADDCONST(GL_POLYGON_OFFSET_FILL);
- EXPP_ADDCONST(GL_POLYGON_OFFSET_FACTOR);
-
- EXPP_ADDCONST(GL_TEXTURE_PRIORITY);
- EXPP_ADDCONST(GL_TEXTURE_RESIDENT);
- EXPP_ADDCONST(GL_TEXTURE_BINDING_1D);
- EXPP_ADDCONST(GL_TEXTURE_BINDING_2D);
-
- return mod;
-}
-
diff --git a/source/blender/python/api2_2x/BGL.h b/source/blender/python/api2_2x/BGL.h
deleted file mode 100644
index f8dea726d73..00000000000
--- a/source/blender/python/api2_2x/BGL.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/BezTriple.c b/source/blender/python/api2_2x/BezTriple.c
deleted file mode 100644
index e4a872c52c0..00000000000
--- a/source/blender/python/api2_2x/BezTriple.c
+++ /dev/null
@@ -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 );
-}
diff --git a/source/blender/python/api2_2x/BezTriple.h b/source/blender/python/api2_2x/BezTriple.h
deleted file mode 100644
index 38c9b88e185..00000000000
--- a/source/blender/python/api2_2x/BezTriple.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
deleted file mode 100644
index 05eb82802b8..00000000000
--- a/source/blender/python/api2_2x/Blender.c
+++ /dev/null
@@ -1,1004 +0,0 @@
-/*
- * $Id: Blender.c 12702 2007-11-27 23:15:51Z 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, Willian P. Germano, Joseph Gilbert,
- * Campbell Barton
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-struct ID; /*keep me up here */
-
-#include "Blender.h" /*This must come first */
-
-/* for open, close in Blender_Load */
-#include <fcntl.h>
-#include "BDR_editobject.h" /* exit_editmode() */
-#include "BIF_usiblender.h"
-#include "BLI_blenlib.h"
-#include "BLO_writefile.h"
-#include "BKE_blender.h"
-#include "BKE_exotic.h"
-#include "BKE_global.h"
-#include "BKE_packedFile.h"
-#include "BKE_utildefines.h"
-#include "BKE_object.h"
-#include "BKE_scene.h"
-#include "BKE_text.h"
-#include "BKE_ipo.h"
-#include "BKE_library.h"
-#include "BKE_main.h"
-#include "BPI_script.h"
-#include "BSE_headerbuttons.h"
-#include "DNA_screen_types.h" /* for SPACE_VIEW3D */
-#include "DNA_userdef_types.h"
-#include "DNA_packedFile_types.h"
-#include "EXPP_interface.h" /* for bpy_gethome() */
-#include "gen_utils.h"
-#include "modules.h"
-#include "constant.h"
-#include "../BPY_extern.h" /* BPY_txt_do_python_Text */
-#include "../BPY_menus.h" /* to update menus */
-#include "Armature.h"
-#include "BezTriple.h"
-#include "Camera.h"
-#include "Constraint.h"
-#include "Curve.h"
-#include "CurNurb.h"
-#include "Draw.h"
-#include "Effect.h"
-#include "Ipo.h"
-#include "Ipocurve.h"
-#include "IDProp.h"
-#include "Key.h"
-#include "Lamp.h"
-#include "Lattice.h"
-#include "Library.h"
-#include "Mathutils.h"
-#include "Geometry.h"
-#include "Mesh.h"
-#include "Metaball.h"
-#include "Modifier.h"
-#include "NMesh.h"
-#include "Object.h"
-#include "Group.h"
-#include "Registry.h"
-#include "Scene.h"
-#include "Sound.h"
-#include "SurfNurb.h"
-#include "Sys.h"
-#include "Text.h"
-#include "Texture.h"
-#include "Window.h"
-#include "World.h"
-#include "Types.h"
-
-/**********************************************************/
-/* Python API function prototypes for the Blender module. */
-/**********************************************************/
-static PyObject *Blender_Set( PyObject * self, PyObject * args );
-static PyObject *Blender_Get( PyObject * self, PyObject * value );
-static PyObject *Blender_Redraw( PyObject * self, PyObject * args );
-static PyObject *Blender_Quit( PyObject * self );
-static PyObject *Blender_Load( PyObject * self, PyObject * args );
-static PyObject *Blender_Save( PyObject * self, PyObject * args );
-static PyObject *Blender_Run( PyObject * self, PyObject * value );
-static PyObject *Blender_ShowHelp( PyObject * self, PyObject * script );
-static PyObject *Blender_UpdateMenus( PyObject * self);
-static PyObject *Blender_PackAll( PyObject * self);
-static PyObject *Blender_UnpackAll( PyObject * self, PyObject * value);
-static PyObject *Blender_CountPackedFiles( PyObject * self );
-
-extern PyObject *Text3d_Init( void ); /* missing in some include */
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.__doc__ */
-/*****************************************************************************/
-static char Blender_Set_doc[] =
- "(request, data) - Update settings in Blender\n\
-\n\
-(request) A string identifying the setting to change\n\
- 'curframe' - Sets the current frame using the number in data";
-
-static char Blender_Get_doc[] = "(request) - Retrieve settings from Blender\n\
-\n\
-(request) A string indentifying the data to be returned\n\
- 'curframe' - Returns the current animation frame\n\
- 'curtime' - Returns the current animation time\n\
- 'staframe' - Returns the start frame of the animation\n\
- 'endframe' - Returns the end frame of the animation\n\
- 'filename' - Returns the name of the last file read or written\n\
- 'homedir' - Returns Blender's home dir\n\
- 'datadir' - Returns the dir where scripts can save their data, if available\n\
- 'scriptsdir' - Returns the main dir where scripts are kept, if available\n\
- 'uscriptsdir' - Returns the user defined dir for scripts, if available\n\
- 'version' - Returns the Blender version number";
-
-static char Blender_Redraw_doc[] = "() - Redraw all 3D windows";
-
-static char Blender_Quit_doc[] =
- "() - Quit Blender. The current data is saved as 'quit.blend' before leaving.";
-
-static char Blender_Load_doc[] = "(filename) - Load the given file.\n\
-Supported formats:\n\
-Blender, DXF, Inventor 1.0 ASCII, VRML 1.0 asc, STL, Videoscape, radiogour.\n\
-\n\
-Notes:\n\
-1 - () - an empty argument loads the default .B.blend file;\n\
-2 - if the substring '.B.blend' occurs inside 'filename', the default\n\
-.B.blend file is loaded;\n\
-3 - If a Blender file is loaded the script ends immediately.\n\
-4 - The current data is always preserved as an autosave file, for safety;\n\
-5 - This function only works if the script where it's executed is the\n\
-only one running at the moment.";
-
-static char Blender_Save_doc[] =
- "(filename) - Save data to a file based on the filename's extension.\n\
-Supported are: Blender's .blend and the builtin exporters:\n\
-VRML 1.0 (.wrl), Videoscape (.obj), DXF (.dxf) and STL (.stl)\n\
-(filename) - A filename with one of the supported extensions.\n\
-Note 1: 'filename' should not contain the substring \".B.blend\" in it.\n\
-Note 2: only .blend raises an error if file wasn't saved.\n\
-\tYou can use Blender.sys.exists(filename) to make sure the file was saved\n\
-\twhen writing to one of the other formats.";
-
-static char Blender_Run_doc[] =
- "(script) - Run the given Python script.\n\
-(script) - the path to a file or the name of an available Blender Text.";
-
-static char Blender_ShowHelp_doc[] =
-"(script) - Show help for the given Python script.\n\
- This will try to open the 'Scripts Help Browser' script, so to have\n\
-any help displayed the passed 'script' must be properly documented\n\
-with the expected strings (check API ref docs or any bundled script\n\
-for examples).\n\n\
-(script) - the filename of a script in the default or user defined\n\
- scripts dir (no need to supply the full path name).";
-
-static char Blender_UpdateMenus_doc[] =
- "() - Update the menus where scripts are registered. Only needed for\n\
-scripts that save other new scripts in the default or user defined folders.";
-
-static char Blender_PackAll_doc[] =
-"() - Pack all files.\n\
-All files will packed into the blend file.";
-static char Blender_UnpackAll_doc[] =
-"(mode) - Unpack files.\n\
-All files will be unpacked using specified mode.\n\n\
-(mode) - the unpack mode.";
-
-static char Blender_CountPackedFiles_doc[] =
-"() - Returns the number of packed files.";
-
-/*****************************************************************************/
-/* Python method structure definition. */
-/*****************************************************************************/
-static struct PyMethodDef Blender_methods[] = {
- {"Set", Blender_Set, METH_VARARGS, Blender_Set_doc},
- {"Get", Blender_Get, METH_O, Blender_Get_doc},
- {"Redraw", Blender_Redraw, METH_VARARGS, Blender_Redraw_doc},
- {"Quit", ( PyCFunction ) Blender_Quit, METH_NOARGS, Blender_Quit_doc},
- {"Load", Blender_Load, METH_VARARGS, Blender_Load_doc},
- {"Save", Blender_Save, METH_VARARGS, Blender_Save_doc},
- {"Run", Blender_Run, METH_O, Blender_Run_doc},
- {"ShowHelp", Blender_ShowHelp, METH_O, Blender_ShowHelp_doc},
- {"CountPackedFiles", ( PyCFunction ) Blender_CountPackedFiles, METH_NOARGS, Blender_CountPackedFiles_doc},
- {"PackAll", ( PyCFunction ) Blender_PackAll, METH_NOARGS, Blender_PackAll_doc},
- {"UnpackAll", Blender_UnpackAll, METH_O, Blender_UnpackAll_doc},
- {"UpdateMenus", ( PyCFunction ) Blender_UpdateMenus, METH_NOARGS,
- Blender_UpdateMenus_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Global variables */
-/*****************************************************************************/
-PyObject *g_blenderdict;
-
-/*****************************************************************************/
-/* Function: Blender_Set */
-/* Python equivalent: Blender.Set */
-/*****************************************************************************/
-static PyObject *Blender_Set( PyObject * self, PyObject * args )
-{
- char *name, *dir = NULL;
- PyObject *arg;
-
- if( !PyArg_ParseTuple( args, "sO", &name, &arg ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected 2 args, where the first is always a string" );
-
- if( StringEqual( name, "curframe" ) ) {
- if( !PyInt_Check( arg ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected an integer" );
-
- G.scene->r.cfra = (short)PyInt_AsLong( arg ) ;
-
- /* update all objects, so python scripts can export all objects
- in a scene without worrying about the view layers */
- scene_update_for_newframe(G.scene, (1<<20) - 1);
-
- } else if (StringEqual( name , "uscriptsdir" ) ) {
- if ( !PyArg_Parse( arg , "s" , &dir ))
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
- BLI_strncpy(U.pythondir, dir, FILE_MAXDIR);
- } else if (StringEqual( name , "yfexportdir" ) ) {
- if ( !PyArg_Parse( arg , "s" , &dir ))
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
- BLI_strncpy(U.yfexportdir, dir, FILE_MAXDIR);
- } else if (StringEqual( name , "fontsdir" ) ) {
- if ( !PyArg_Parse( arg , "s" , &dir ))
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
- BLI_strncpy(U.fontdir, dir, FILE_MAXDIR);
- } else if (StringEqual( name , "texturesdir" ) ) {
- if ( !PyArg_Parse( arg , "s" , &dir ))
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
- BLI_strncpy(U.textudir, dir, FILE_MAXDIR);
- } else if (StringEqual( name , "texpluginsdir" ) ) {
- if ( !PyArg_Parse( arg , "s" , &dir ))
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
- BLI_strncpy(U.plugtexdir, dir, FILE_MAXDIR);
- } else if (StringEqual( name , "seqpluginsdir" ) ) {
- if ( !PyArg_Parse( arg , "s" , &dir ))
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
- BLI_strncpy(U.plugseqdir, dir, FILE_MAXDIR);
- } else if (StringEqual( name , "renderdir" ) ) {
- if ( !PyArg_Parse( arg , "s" , &dir ))
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
- BLI_strncpy(U.renderdir, dir, FILE_MAXDIR);
- } else if (StringEqual( name , "soundsdir" ) ) {
- if ( !PyArg_Parse( arg , "s" , &dir ))
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
- BLI_strncpy(U.sounddir, dir, FILE_MAXDIR);
- } else if (StringEqual( name , "tempdir" ) ) {
- if ( !PyArg_Parse( arg , "s" , &dir ))
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
- BLI_strncpy(U.tempdir, dir, FILE_MAXDIR);
- } else if (StringEqual( name , "compressfile" ) ) {
- int value = PyObject_IsTrue( arg );
-
- if (value==-1)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected an integer" );
-
- if (value)
- U.flag |= USER_FILECOMPRESS;
- else
- U.flag &= ~USER_FILECOMPRESS;
-
- }else
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "value given is not a blender setting" ) );
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: Blender_Get */
-/* Python equivalent: Blender.Get */
-/*****************************************************************************/
-static PyObject *Blender_Get( PyObject * self, PyObject * value )
-{
- PyObject *ret = NULL;
- char *str = PyString_AsString(value);
-
- if( !str )
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
-
- if( StringEqual( str, "curframe" ) )
- ret = PyInt_FromLong( G.scene->r.cfra );
- else if( StringEqual( str, "curtime" ) )
- ret = PyFloat_FromDouble( frame_to_float( G.scene->r.cfra ) );
- else if( StringEqual( str, "rt" ) )
- ret = PyInt_FromLong( (long)frame_to_float( G.rt ) );
- else if( StringEqual( str, "staframe" ) )
- ret = PyInt_FromLong( G.scene->r.sfra );
- else if( StringEqual( str, "endframe" ) )
- ret = PyInt_FromLong( G.scene->r.efra );
- else if( StringEqual( str, "filename" ) ) {
- if ( strstr(G.main->name, ".B.blend") != 0)
- ret = PyString_FromString("");
- else
- ret = PyString_FromString(G.main->name);
- }
- else if( StringEqual( str, "homedir" ) ) {
- char *hdir = bpy_gethome(0);
- if( hdir && BLI_exists( hdir ))
- ret = PyString_FromString( hdir );
- else
- ret = EXPP_incr_ret( Py_None );
- }
- else if( StringEqual( str, "datadir" ) ) {
- char datadir[FILE_MAXDIR];
- char *sdir = bpy_gethome(1);
-
- if (sdir) {
- BLI_make_file_string( "/", datadir, sdir, "bpydata" );
- if( BLI_exists( datadir ) )
- ret = PyString_FromString( datadir );
- }
- if (!ret) ret = EXPP_incr_ret( Py_None );
- }
- else if(StringEqual(str, "udatadir")) {
- if (U.pythondir[0] != '\0') {
- char upydir[FILE_MAXDIR];
-
- BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR);
- BLI_convertstringcode(upydir, G.sce, 0);
-
- if (BLI_exists(upydir)) {
- char udatadir[FILE_MAXDIR];
-
- BLI_make_file_string("/", udatadir, upydir, "bpydata");
-
- if (BLI_exists(udatadir))
- ret = PyString_FromString(udatadir);
- }
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- else if( StringEqual( str, "scriptsdir" ) ) {
- char *sdir = bpy_gethome(1);
-
- if (sdir)
- ret = PyString_FromString(sdir);
- else
- ret = EXPP_incr_ret( Py_None );
- }
- else if( StringEqual( str, "uscriptsdir" ) ) {
- if (U.pythondir[0] != '\0') {
- char upydir[FILE_MAXDIR];
-
- BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR);
- BLI_convertstringcode(upydir, G.sce, 0);
-
- if( BLI_exists( upydir ) )
- ret = PyString_FromString( upydir );
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* USER PREFS: */
- else if( StringEqual( str, "yfexportdir" ) ) {
- if (U.yfexportdir[0] != '\0') {
- char yfexportdir[FILE_MAXDIR];
-
- BLI_strncpy(yfexportdir, U.yfexportdir, FILE_MAXDIR);
- BLI_convertstringcode(yfexportdir, G.sce, 0);
-
- if( BLI_exists( yfexportdir ) )
- ret = PyString_FromString( yfexportdir );
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* fontsdir */
- else if( StringEqual( str, "fontsdir" ) ) {
- if (U.fontdir[0] != '\0') {
- char fontdir[FILE_MAXDIR];
-
- BLI_strncpy(fontdir, U.fontdir, FILE_MAXDIR);
- BLI_convertstringcode(fontdir, G.sce, 0);
-
- if( BLI_exists( fontdir ) )
- ret = PyString_FromString( fontdir );
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* texturesdir */
- else if( StringEqual( str, "texturesdir" ) ) {
- if (U.textudir[0] != '\0') {
- char textudir[FILE_MAXDIR];
-
- BLI_strncpy(textudir, U.textudir, FILE_MAXDIR);
- BLI_convertstringcode(textudir, G.sce, 0);
-
- if( BLI_exists( textudir ) )
- ret = PyString_FromString( textudir );
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* texpluginsdir */
- else if( StringEqual( str, "texpluginsdir" ) ) {
- if (U.plugtexdir[0] != '\0') {
- char plugtexdir[FILE_MAXDIR];
-
- BLI_strncpy(plugtexdir, U.plugtexdir, FILE_MAXDIR);
- BLI_convertstringcode(plugtexdir, G.sce, 0);
-
- if( BLI_exists( plugtexdir ) )
- ret = PyString_FromString( plugtexdir );
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* seqpluginsdir */
- else if( StringEqual( str, "seqpluginsdir" ) ) {
- if (U.plugseqdir[0] != '\0') {
- char plugseqdir[FILE_MAXDIR];
-
- BLI_strncpy(plugseqdir, U.plugseqdir, FILE_MAXDIR);
- BLI_convertstringcode(plugseqdir, G.sce, 0);
-
- if( BLI_exists( plugseqdir ) )
- ret = PyString_FromString( plugseqdir );
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* renderdir */
- else if( StringEqual( str, "renderdir" ) ) {
- if (U.renderdir[0] != '\0') {
- char renderdir[FILE_MAXDIR];
-
- BLI_strncpy(renderdir, U.renderdir, FILE_MAXDIR);
- BLI_convertstringcode(renderdir, G.sce, 0);
-
- if( BLI_exists( renderdir ) )
- ret = PyString_FromString( renderdir );
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* soundsdir */
- else if( StringEqual( str, "soundsdir" ) ) {
- if (U.sounddir[0] != '\0') {
- char sounddir[FILE_MAXDIR];
-
- BLI_strncpy(sounddir, U.sounddir, FILE_MAXDIR);
- BLI_convertstringcode(sounddir, G.sce, 0);
-
- if( BLI_exists( sounddir ) )
- ret = PyString_FromString( sounddir );
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* tempdir */
- else if( StringEqual( str, "tempdir" ) ) {
- if (U.tempdir[0] != '\0') {
- char tempdir[FILE_MAXDIR];
-
- BLI_strncpy(tempdir, U.tempdir, FILE_MAXDIR);
- BLI_convertstringcode(tempdir, G.sce, 0);
-
- if( BLI_exists( tempdir ) )
- ret = PyString_FromString( tempdir );
- }
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* icondir */
- else if( StringEqual( str, "icondir" ) ) {
-
- char icondirstr[FILE_MAXDIR];
-
- #ifdef WIN32
- BLI_make_file_string("/", icondirstr, BLI_gethome(), "icons");
- #else
- BLI_make_file_string("/", icondirstr, BLI_gethome(), ".blender/icons");
- #endif
-
- if( BLI_exists( icondirstr ) )
- ret = PyString_FromString( icondirstr );
-
- if (!ret) ret = EXPP_incr_ret(Py_None);
- }
- /* According to the old file (opy_blender.c), the following if
- statement is a quick hack and needs some clean up. */
- else if( StringEqual( str, "vrmloptions" ) ) {
- ret = PyDict_New( );
-
- EXPP_dict_set_item_str( ret, "twoside",
- PyInt_FromLong( U.vrmlflag & USER_VRML_TWOSIDED ) );
-
- EXPP_dict_set_item_str( ret, "layers",
- PyInt_FromLong( U.vrmlflag & USER_VRML_LAYERS ) );
-
- EXPP_dict_set_item_str( ret, "autoscale",
- PyInt_FromLong( U.vrmlflag & USER_VRML_AUTOSCALE ) );
-
- } /* End 'quick hack' part. */
- else if(StringEqual( str, "version" ))
- ret = PyInt_FromLong( G.version );
-
- else if(StringEqual( str, "compressfile" ))
- ret = PyInt_FromLong( (U.flag & USER_FILECOMPRESS) >> 15 );
-
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError, "unknown attribute" );
-
- if (ret) return ret;
- else
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "could not create pystring!");
-}
-
-/*****************************************************************************/
-/* Function: Blender_Redraw */
-/* Python equivalent: Blender.Redraw */
-/*****************************************************************************/
-static PyObject *Blender_Redraw( PyObject * self, PyObject * args )
-{
- return M_Window_Redraw( self, args );
-}
-
-/*****************************************************************************/
-/* Function: Blender_Quit */
-/* Python equivalent: Blender.Quit */
-/*****************************************************************************/
-static PyObject *Blender_Quit( PyObject * self )
-{
- BIF_write_autosave( ); /* save the current data first */
-
- exit_usiblender( ); /* renames last autosave to quit.blend */
-
- Py_RETURN_NONE;
-}
-
-/**
- * Blender.Load
- * loads Blender's .blend, DXF, radiogour(?), STL, Videoscape,
- * Inventor 1.0 ASCII, VRML 1.0 asc.
- */
-static PyObject *Blender_Load( PyObject * self, PyObject * args )
-{
- char *fname = NULL;
- int keep_oldfname = 0;
- Script *script = NULL;
- char str[32], name[FILE_MAXDIR];
- int file, is_blend_file = 0;
-
- if( !PyArg_ParseTuple( args, "|si", &fname, &keep_oldfname ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected filename and optional int or nothing as arguments" );
-
- if( fname ) {
- if( strlen( fname ) > FILE_MAXDIR ) /* G.main->name's max length */
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "filename too long!" );
- else if( !BLI_exists( fname ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "requested file doesn't exist!" );
-
- if( keep_oldfname )
- BLI_strncpy( name, G.sce, FILE_MAXDIR );
- }
-
- /* We won't let a new .blend file be loaded if there are still other
- * scripts running, since loading a new file will close and remove them. */
-
- if( G.main->script.first != G.main->script.last )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "there are other scripts running at the Scripts win, close them first!" );
-
- if( fname ) {
- file = open( fname, O_BINARY | O_RDONLY );
-
- if( file <= 0 ) {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot open file!" );
- } else {
- read( file, str, 31 );
- close( file );
-
- if( strncmp( str, "BLEN", 4 ) == 0 )
- is_blend_file = 1;
- }
- } else
- is_blend_file = 1; /* no arg given means default: .B.blend */
-
- if( is_blend_file ) {
-
- int during_slink = during_scriptlink( );
-
- /* when loading a .blend file from a scriptlink, the scriptlink pointer
- * in BPY_do_pyscript becomes invalid during a loop. Inform it here.
- * Also do not allow a nested scriptlink (called from inside another)
- * to load .blend files, to avoid nasty problems. */
- if( during_slink >= 1 ) {
- if( during_slink == 1 )
- disable_where_scriptlink( -1 );
- else {
- return EXPP_ReturnPyObjError
- ( PyExc_EnvironmentError,
- "Blender.Load: cannot load .blend files from a nested scriptlink." );
- }
- }
-
- /* trick: mark the script so that its script struct won't be freed after
- * the script is executed (to avoid a double free warning on exit): */
- script = G.main->script.first;
- if( script )
- script->flags |= SCRIPT_GUI;
-
- BIF_write_autosave( ); /* for safety let's preserve the current data */
- }
-
- if( G.obedit )
- exit_editmode(EM_FREEDATA);
-
- if (G.background) { /* background mode */
- if (is_blend_file)
- BKE_read_file(fname, NULL);
- else {
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "only .blend files can be loaded from command line,\n\
- other file types require interactive mode.");
- }
- }
- else { /* interactive mode */
- /* for safety, any filename with .B.blend is considered the default one.
- * It doesn't seem necessary to compare file attributes (like st_ino and
- * st_dev, according to the glibc info pages) to find out if the given
- * filename, that may have been given with a twisted misgiving path, is the
- * default one for sure. Taking any .B.blend file as the default is good
- * enough here. Note: the default file requires extra clean-up done by
- * BIF_read_homefile: freeing the user theme data. */
- if( !fname || ( strstr( fname, ".B.blend" ) && is_blend_file ) )
- BIF_read_homefile(0);
- else
- BIF_read_file( fname );
-
- if( fname && keep_oldfname ) {
- /*BLI_strncpy(G.main->name, name, FILE_MAXDIR); */
- BLI_strncpy( G.sce, name, FILE_MAXDIR );
- }
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Blender_Save( PyObject * self, PyObject * args )
-{
- char *fname = NULL;
- int overwrite = 0, len = 0;
- char *error = NULL;
- Library *li;
-
- if( !PyArg_ParseTuple( args, "s|i", &fname, &overwrite ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected filename and optional int (overwrite flag) as arguments" );
-
- for( li = G.main->library.first; li; li = li->id.next ) {
- if( BLI_streq( li->name, fname ) ) {
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "cannot overwrite used library" );
- }
- }
-
- /* for safety, any filename with .B.blend is considered the default one
- * and not accepted here. */
- if( strstr( fname, ".B.blend" ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "filename can't contain the substring \".B.blend\" in it." );
-
- len = strlen( fname );
-
- if( len > FILE_MAXDIR + FILE_MAXFILE )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "filename is too long!" );
- else if( BLI_exists( fname ) && !overwrite )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "file already exists and overwrite flag was not given." );
-
- disable_where_script( 1 ); /* to avoid error popups in the write_* functions */
-
- if( BLI_testextensie( fname, ".blend" ) ) {
- int writeflags;
- if( G.fileflags & G_AUTOPACK )
- packAll( );
-
- writeflags= G.fileflags & ~G_FILE_COMPRESS;
- if(U.flag & USER_FILECOMPRESS)
- writeflags |= G_FILE_COMPRESS;
-
- if( !BLO_write_file( fname, writeflags, &error ) ) {
- disable_where_script( 0 );
- return EXPP_ReturnPyObjError( PyExc_SystemError,
- error );
- }
- } else if( BLI_testextensie( fname, ".dxf" ) )
- write_dxf( fname );
- else if( BLI_testextensie( fname, ".stl" ) )
- write_stl( fname );
- else if( BLI_testextensie( fname, ".wrl" ) )
- write_vrml( fname );
- else if( BLI_testextensie( fname, ".obj" ) )
- write_videoscape( fname );
- else {
- disable_where_script( 0 );
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown file extension." );
- }
-
- disable_where_script( 0 );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Blender_ShowHelp(PyObject *self, PyObject *script)
-{
- char hspath[FILE_MAXDIR + FILE_MAXFILE]; /* path to help_browser.py */
- char *sdir = bpy_gethome(1);
- PyObject *rkeyd = NULL, *arglist = NULL;
-
- if (!PyString_Check(script))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expected a script filename as argument");
-
- /* first we try to find the help_browser script */
-
- if (sdir) BLI_make_file_string("/", hspath, sdir, "help_browser.py");
-
- if (!sdir || (!BLI_exists(hspath) && (U.pythondir[0] != '\0'))) {
- char upydir[FILE_MAXDIR];
-
- BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR);
- BLI_convertstringcode(upydir, G.sce, 0);
- BLI_make_file_string("/", hspath, upydir, "help_browser.py");
-
- if (!BLI_exists(hspath))
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "can't find script help_browser.py");
- }
-
- /* now we store the passed script in the registry dict and call the
- * help_browser to show help info for it */
- rkeyd = PyDict_New();
- if (!rkeyd)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "can't create py dictionary!");
-
- /* note: don't use EXPP_dict_set_item_str for 'script', which is an
- * argument to the function we're in and so shouldn't be decref'ed: */
- PyDict_SetItemString(rkeyd, "script", script);
-
- EXPP_dict_set_item_str(bpy_registryDict, "__help_browser", rkeyd);
-
- arglist = Py_BuildValue("(s)", hspath);
- Blender_Run(self, arglist);
- Py_DECREF(arglist);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Blender_Run(PyObject *self, PyObject *value)
-{
- char *fname = PyString_AsString(value);
- Text *text = NULL;
- int is_blender_text = 0;
- Script *script = NULL;
-
- if (!fname)
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expected a filename or a Blender Text name as argument");
-
- if (!BLI_exists(fname)) { /* if there's no such filename ... */
- text = G.main->text.first; /* try an already existing Blender Text */
-
- while (text) {
- if (!strcmp(fname, text->id.name + 2)) break;
- text = text->id.next;
- }
-
- if (!text) {
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "no such file or Blender text");
- }
- else is_blender_text = 1; /* fn is already a Blender Text */
- }
-
- else {
- text = add_text(fname);
-
- if (!text) {
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "couldn't create Blender Text from given file");
- }
- }
-
- /* (this is messy, check Draw.c's Method_Register and Window.c's file
- * selector for more info)
- * - caller script is the one that called this Blender_Run function;
- * - called script is the argument to this function: fname;
- * To mark scripts whose global dicts can't be freed right after
- * the script execution (or better, 'first pass', since these scripts
- * leave callbacks for gui or file/image selectors) we flag them. But to
- * get a pointer to them we need to check which one is currently
- * running (if none we're already at a spacescript). To make sure only
- * the called script will have the SCRIPT_RUNNING flag on, we unset it
- * for the caller script here: */
- script = G.main->script.first;
- while (script) {
- if (script->flags & SCRIPT_RUNNING) break;
- script = script->id.next;
- }
-
- if (script) script->flags &= ~SCRIPT_RUNNING; /* unset */
-
- BPY_txt_do_python_Text(text); /* call new script */
-
- if (script) script->flags |= SCRIPT_RUNNING; /* set */
-
- if (!is_blender_text) free_libblock(&G.main->text, text);
-
- Py_RETURN_NONE;
-}
-
-static PyObject * Blender_UpdateMenus( PyObject * self )
-{
-
- BPyMenu_RemoveAllEntries();
-
- if (BPyMenu_Init(1) == -1)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "invalid scripts dir");
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: Blender_PackAll */
-/* Python equivalent: Blender.PackAll */
-/*****************************************************************************/
-static PyObject *Blender_PackAll( PyObject * self)
-{
- packAll();
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: Blender_UnpackAll */
-/* Python equivalent: Blender.UnpackAll */
-/*****************************************************************************/
-static PyObject *Blender_UnpackAll( PyObject * self, PyObject *value)
-{
- int mode = PyInt_AsLong(value);
-
- if (mode==-1)
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected an int Blender.UnpackModes");
- unpackAll(mode);
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: Blender_CountPackedFiles */
-/* Python equivalent: Blender.CountPackedFiles */
-/*****************************************************************************/
-static PyObject *Blender_CountPackedFiles( PyObject * self )
-{
- int nfiles = countPackedFiles();
- return PyInt_FromLong( nfiles );
-}
-static PyObject *Blender_UnpackModesDict( void )
-{
- PyObject *UnpackModes = PyConstant_New( );
- if( UnpackModes ) {
- BPy_constant *d = ( BPy_constant * ) UnpackModes;
- PyConstant_Insert( d, "EQUAL", PyInt_FromLong((long)PF_EQUAL) );
- PyConstant_Insert( d, "DIFFERS",PyInt_FromLong((long)PF_DIFFERS) );
- PyConstant_Insert( d, "NOFILE", PyInt_FromLong((long)PF_NOFILE) );
- PyConstant_Insert( d, "WRITE_ORIGINAL", PyInt_FromLong((long)PF_WRITE_ORIGINAL) );
- PyConstant_Insert( d, "WRITE_LOCAL", PyInt_FromLong((long)PF_WRITE_LOCAL) );
- PyConstant_Insert( d, "USE_LOCAL", PyInt_FromLong((long)PF_USE_LOCAL) );
- PyConstant_Insert( d, "USE_ORIGINAL", PyInt_FromLong((long)PF_USE_ORIGINAL) );
- PyConstant_Insert( d, "KEEP", PyInt_FromLong((long)PF_KEEP) );
- PyConstant_Insert( d, "NOOP", PyInt_FromLong((long)PF_NOOP) );
- PyConstant_Insert( d, "ASK", PyInt_FromLong((long)PF_EQUAL) );
- }
- return UnpackModes;
-}
-
-/*****************************************************************************/
-/* Function: initBlender */
-/*****************************************************************************/
-
-void M_Blender_Init(void)
-{
- PyObject *module;
- PyObject *dict, *smode, *SpaceHandlers, *UnpackModes;
-
- /* G.scene should only aver be NULL if blender is executed in
- background mode, not loading a blend file and executing a python script eg.
- blender -P somescript.py -b
- The if below solves the segfaults that happen when python runs and
- G.scene is NULL */
- if(G.background && G.main->scene.first==NULL) {
- Scene *sce= add_scene("1");
- /*set_scene(sce);*/ /* causes a crash */
- G.scene= sce;
- }
-
- module = Py_InitModule3("Blender", Blender_methods,
- "The main Blender module");
-
- types_InitAll(); /* set all our pytypes to &PyType_Type */
-
- /* constants for packed files*/
- UnpackModes = Blender_UnpackModesDict( );
- if( UnpackModes )
- PyModule_AddObject( module, "UnpackModes", UnpackModes );
-
- SpaceHandlers = PyConstant_New();
- if (SpaceHandlers) {
- BPy_constant *d = (BPy_constant *)SpaceHandlers;
-
- PyConstant_Insert(d,"VIEW3D_EVENT",PyInt_FromLong(SPACEHANDLER_VIEW3D_EVENT));
- PyConstant_Insert(d,"VIEW3D_DRAW", PyInt_FromLong(SPACEHANDLER_VIEW3D_DRAW));
-
- PyModule_AddObject(module, "SpaceHandlers", SpaceHandlers);
- }
-
- if (G.background)
- smode = PyString_FromString("background");
- else
- smode = PyString_FromString("interactive");
-
- dict = PyModule_GetDict(module);
- g_blenderdict = dict;
-
- PyModule_AddIntConstant(module, "TRUE", 1);
- PyModule_AddIntConstant( module, "FALSE", 0 );
-
- EXPP_dict_set_item_str(dict, "bylink", EXPP_incr_ret_False());
- PyDict_SetItemString(dict, "link", Py_None);
- EXPP_dict_set_item_str(dict, "event", PyString_FromString(""));
- EXPP_dict_set_item_str(dict, "mode", smode);
-
- PyDict_SetItemString(dict, "Armature", Armature_Init());
- PyDict_SetItemString(dict, "BezTriple", BezTriple_Init());
- PyDict_SetItemString(dict, "BGL", BGL_Init());
- PyDict_SetItemString(dict, "CurNurb", CurNurb_Init());
- PyDict_SetItemString(dict, "Constraint", Constraint_Init());
- PyDict_SetItemString(dict, "Curve", Curve_Init());
- PyDict_SetItemString(dict, "Camera", Camera_Init());
- PyDict_SetItemString(dict, "Draw", Draw_Init());
- PyDict_SetItemString(dict, "Effect", Effect_Init());
- PyDict_SetItemString(dict, "Ipo", Ipo_Init());
- PyDict_SetItemString(dict, "IpoCurve", IpoCurve_Init());
- PyDict_SetItemString(dict, "Image", Image_Init());
- PyDict_SetItemString(dict, "Key", Key_Init());
- PyDict_SetItemString(dict, "Lamp", Lamp_Init());
- PyDict_SetItemString(dict, "Lattice", Lattice_Init());
- PyDict_SetItemString(dict, "Library", oldLibrary_Init());
- PyDict_SetItemString(dict, "Material", Material_Init());
- PyDict_SetItemString(dict, "Mesh", Mesh_Init());
- PyDict_SetItemString(dict, "Metaball", Metaball_Init());
- PyDict_SetItemString(dict, "Mathutils", Mathutils_Init());
- PyDict_SetItemString(dict, "Geometry", Geometry_Init());
- PyDict_SetItemString(dict, "Modifier", Modifier_Init());
- PyDict_SetItemString(dict, "NMesh", NMesh_Init());
- PyDict_SetItemString(dict, "Noise", Noise_Init());
- PyDict_SetItemString(dict, "Object", Object_Init());
- PyDict_SetItemString(dict, "Group", Group_Init());
- PyDict_SetItemString(dict, "Registry", Registry_Init());
- PyDict_SetItemString(dict, "Scene", Scene_Init());
- PyDict_SetItemString(dict, "Sound", Sound_Init());
- PyDict_SetItemString(dict, "SurfNurb", SurfNurb_Init());
- PyDict_SetItemString(dict, "sys", sys_Init());
- PyDict_SetItemString(dict, "Types", Types_Init());
- PyDict_SetItemString(dict, "Text", Text_Init());
- PyDict_SetItemString(dict, "Text3d", Text3d_Init());
- PyDict_SetItemString(dict, "Texture", Texture_Init());
- PyDict_SetItemString(dict, "Window", Window_Init());
- PyDict_SetItemString(dict, "World", World_Init());
-
-}
diff --git a/source/blender/python/api2_2x/Blender.h b/source/blender/python/api2_2x/Blender.h
deleted file mode 100644
index 77f21ed333c..00000000000
--- a/source/blender/python/api2_2x/Blender.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c
deleted file mode 100644
index 704fe20d6db..00000000000
--- a/source/blender/python/api2_2x/Bone.c
+++ /dev/null
@@ -1,1425 +0,0 @@
-/*
- * $Id: Bone.c 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 *****
-*/
-
-#include "Bone.h"
-#include "vector.h"
-#include "matrix.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BKE_utildefines.h"
-#include "gen_utils.h"
-#include "BKE_armature.h"
-#include "Mathutils.h"
-#include "BKE_library.h"
-
-//these must come in this order
-#include "DNA_object_types.h" //1
-#include "BIF_editarmature.h" //2
-
-//------------------------ERROR CODES---------------------------------
-//This is here just to make me happy and to have more consistant error strings :)
-static const char sEditBoneError[] = "EditBone - Error: ";
-// static const char sEditBoneBadArgs[] = "EditBone - Bad Arguments: ";
-static const char sBoneError[] = "Bone - Error: ";
-// static const char sBoneBadArgs[] = "Bone - Bad Arguments: ";
-
-//----------------------(internal)
-//gets the bone->roll (which is a localspace roll) and puts it in parentspace
-//(which is the 'roll' value the user sees)
-static double boneRoll_ToArmatureSpace(struct Bone *bone)
-{
- float head[3], tail[3], delta[3];
- float premat[3][3], postmat[3][3];
- float imat[3][3], difmat[3][3];
- double roll = 0.0f;
-
- VECCOPY(head, bone->arm_head);
- VECCOPY(tail, bone->arm_tail);
- VECSUB (delta, tail, head);
- vec_roll_to_mat3(delta, 0.0f, postmat);
- Mat3CpyMat4(premat, bone->arm_mat);
- Mat3Inv(imat, postmat);
- Mat3MulMat3(difmat, imat, premat);
-
- roll = atan2(difmat[2][0], difmat[2][2]);
- if (difmat[0][0] < 0.0){
- roll += M_PI;
- }
- return roll; //result is in radians
-}
-
-//################## EditBone_Type ########################
-/*This type is a wrapper for a tempory bone. This is an 'unparented' bone
-*object. The armature->bonebase will be calculated from these temporary
-*python tracked objects.*/
-//####################################################
-
-//------------------METHOD IMPLEMENTATIONS-----------------------------
-//-------------------------EditBone.hasParent()
-static PyObject *EditBone_hasParent(BPy_EditBone *self)
-{
- if (self->editbone){
- if (self->editbone->parent)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
- }else{
- goto AttributeError;
- }
-
-AttributeError:
- return EXPP_objError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".hasParent: ", "EditBone must be added to the armature first");
-}
-//-------------------------EditBone.clearParent()
-static PyObject *EditBone_clearParent(BPy_EditBone *self)
-{
- if (self->editbone){
- if (self->editbone->parent)
- self->editbone->parent = NULL;
- Py_RETURN_NONE;
- }else{
- goto AttributeError;
- }
-
-AttributeError:
- return EXPP_objError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".clearParent: ", "EditBone must be added to the armature first");
-}
-//------------------ATTRIBUTE IMPLEMENTATION---------------------------
-//------------------------EditBone.name (get)
-static PyObject *EditBone_getName(BPy_EditBone *self, void *closure)
-{
- if (self->editbone)
- return PyString_FromString(self->editbone->name);
- else
- return PyString_FromString(self->name);
-}
-//------------------------EditBone.name (set)
-//check for char[] overflow here...
-static int EditBone_setName(BPy_EditBone *self, PyObject *value, void *closure)
-{
- char *name = "";
-
- if (!PyArg_Parse(value, "s", &name))
- goto AttributeError;
-
- if (self->editbone)
- BLI_strncpy(self->editbone->name, name, 32);
- else
- BLI_strncpy(self->name, name, 32);
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".name: ", "expects a string");
-}
-//------------------------EditBone.roll (get)
-static PyObject *EditBone_getRoll(BPy_EditBone *self, void *closure)
-{
- if (self->editbone){
- return PyFloat_FromDouble((self->editbone->roll * (180/Py_PI)));
- }else{
- return PyFloat_FromDouble((self->roll * (180/Py_PI)));
- }
-}
-//------------------------EditBone.roll (set)
-static int EditBone_setRoll(BPy_EditBone *self, PyObject *value, void *closure)
-{
- float roll = 0.0f;
-
- if (!PyArg_Parse(value, "f", &roll))
- goto AttributeError;
-
- if (self->editbone){
- self->editbone->roll = (float)(roll * (Py_PI/180));
- }else{
- self->roll = (float)(roll * (Py_PI/180));
- }
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".roll: ", "expects a float");
-}
-//------------------------EditBone.head (get)
-static PyObject *EditBone_getHead(BPy_EditBone *self, void *closure)
-{
- if (self->editbone){
- return newVectorObject(self->editbone->head, 3, Py_WRAP);
- }else{
- return newVectorObject(self->head, 3, Py_NEW);
- }
-}
-//------------------------EditBone.head (set)
-static int EditBone_setHead(BPy_EditBone *self, PyObject *value, void *closure)
-{
- VectorObject *vec = NULL;
- int x;
-
- if (!PyArg_Parse(value, "O!", &vector_Type, &vec))
- goto AttributeError;
- if (vec->size != 3)
- goto AttributeError2;
-
- if (self->editbone){
- for (x = 0; x < 3; x++){
- self->editbone->head[x] = vec->vec[x];
- }
- }else{
- for (x = 0; x < 3; x++){
- self->head[x] = vec->vec[x];
- }
- }
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".head: ", "expects a Vector Object");
-
-AttributeError2:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".head: ", "Vector Object needs to be (x,y,z)");
-}
-//------------------------EditBone.tail (get)
-static PyObject *EditBone_getTail(BPy_EditBone *self, void *closure)
-{
- if (self->editbone){
- return newVectorObject(self->editbone->tail, 3, Py_WRAP);
- }else{
- return newVectorObject(self->tail, 3, Py_NEW);
- }
-}
-//------------------------EditBone.tail (set)
-static int EditBone_setTail(BPy_EditBone *self, PyObject *value, void *closure)
-{
- VectorObject *vec = NULL;
- int x;
-
- if (!PyArg_Parse(value, "O!", &vector_Type, &vec))
- goto AttributeError;
- if (vec->size != 3)
- goto AttributeError2;
-
- if (self->editbone){
- for (x = 0; x < 3; x++){
- self->editbone->tail[x] = vec->vec[x];
- }
- }else{
- for (x = 0; x < 3; x++){
- self->tail[x] = vec->vec[x];
- }
- }
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".tail: ", "expects a Vector Object");
-
-AttributeError2:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".tail: ", "Vector Object needs to be (x,y,z)");
-}
-//------------------------EditBone.weight (get)
-static PyObject *EditBone_getWeight(BPy_EditBone *self, void *closure)
-{
- if (self->editbone)
- return PyFloat_FromDouble(self->editbone->weight);
- else
- return PyFloat_FromDouble(self->weight);
-}
-//------------------------EditBone.weight (set)
-static int EditBone_setWeight(BPy_EditBone *self, PyObject *value, void *closure)
-{
- float weight;
-
- if (!PyArg_Parse(value, "f", &weight))
- goto AttributeError;
- CLAMP(weight, 0.0f, 1000.0f);
-
- if (self->editbone)
- self->editbone->weight = weight;
- else
- self->weight = weight;
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".weight: ", "expects a float");
-}
-//------------------------EditBone.deform_dist (get)
-static PyObject *EditBone_getDeform_dist(BPy_EditBone *self, void *closure)
-{
- if (self->editbone)
- return PyFloat_FromDouble(self->editbone->dist);
- else
- return PyFloat_FromDouble(self->dist);
-}
-//------------------------EditBone.deform_dist (set)
-static int EditBone_setDeform_dist(BPy_EditBone *self, PyObject *value, void *closure)
-{
- float deform;
-
- if (!PyArg_Parse(value, "f", &deform))
- goto AttributeError;
- CLAMP(deform, 0.0f, 1000.0f);
-
- if (self->editbone)
- self->editbone->dist = deform;
- else
- self->dist = deform;
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".deform_dist: ", "expects a float");
-}
-//------------------------EditBone.subdivisions (get)
-static PyObject *EditBone_getSubdivisions(BPy_EditBone *self, void *closure)
-{
- if (self->editbone)
- return PyInt_FromLong(self->editbone->segments);
- else
- return PyInt_FromLong(self->segments);
-}
-//------------------------EditBone.subdivisions (set)
-static int EditBone_setSubdivisions(BPy_EditBone *self, PyObject *value, void *closure)
-{
- int segs;
-
- if (!PyArg_Parse(value, "i", &segs))
- goto AttributeError;
- CLAMP(segs, 1, 32);
-
- if (self->editbone)
- self->editbone->segments = (short)segs;
- else
- self->segments = (short)segs;
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".subdivisions: ", "expects a integer");
-}
-//------------------------EditBone.options (get)
-static PyObject *EditBone_getOptions(BPy_EditBone *self, void *closure)
-{
- PyObject *list = NULL;
-
- list = PyList_New(0);
- if (!list)
- goto RuntimeError;
-
- if(self->editbone){
- if(self->editbone->flag & BONE_CONNECTED)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "CONNECTED")) == -1)
- goto RuntimeError;
- if(self->editbone->flag & BONE_HINGE)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "HINGE")) == -1)
- goto RuntimeError;
- if(self->editbone->flag & BONE_NO_DEFORM)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "NO_DEFORM")) == -1)
- goto RuntimeError;
- if(self->editbone->flag & BONE_MULT_VG_ENV)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "MULTIPLY")) == -1)
- goto RuntimeError;
- if(self->editbone->flag & BONE_HIDDEN_A)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "HIDDEN_EDIT")) == -1)
- goto RuntimeError;
- if(self->editbone->flag & BONE_ROOTSEL)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "ROOT_SELECTED")) == -1)
- goto RuntimeError;
- if(self->editbone->flag & BONE_SELECTED)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "BONE_SELECTED")) == -1)
- goto RuntimeError;
- if(self->editbone->flag & BONE_TIPSEL)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "TIP_SELECTED")) == -1)
- goto RuntimeError;
- }else{
- if(self->flag & BONE_CONNECTED)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "CONNECTED")) == -1)
- goto RuntimeError;
- if(self->flag & BONE_HINGE)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "HINGE")) == -1)
- goto RuntimeError;
- if(self->flag & BONE_NO_DEFORM)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "NO_DEFORM")) == -1)
- goto RuntimeError;
- if(self->flag & BONE_MULT_VG_ENV)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "MULTIPLY")) == -1)
- goto RuntimeError;
- if(self->flag & BONE_HIDDEN_A)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "HIDDEN_EDIT")) == -1)
- goto RuntimeError;
- if(self->flag & BONE_ROOTSEL)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "ROOT_SELECTED")) == -1)
- goto RuntimeError;
- if(self->flag & BONE_SELECTED)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "BONE_SELECTED")) == -1)
- goto RuntimeError;
- if(self->flag & BONE_TIPSEL)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "TIP_SELECTED")) == -1)
- goto RuntimeError;
- }
-
- return list;
-
-RuntimeError:
- Py_XDECREF( list );
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sEditBoneError, ".options: ", "Internal failure!");
-}
-//----------------------(internal) EditBone_CheckValidConstant
-static int EditBone_CheckValidConstant(PyObject *constant)
-{
- PyObject *name = NULL;
-
- if (constant){
- if (BPy_Constant_Check(constant)){
- name = PyDict_GetItemString(((BPy_constant*)constant)->dict, "name");
- if (!name)
- return 0;
- if (!STREQ3(PyString_AsString(name), "CONNECTED", "HINGE", "NO_DEFORM") &&
- !STREQ3(PyString_AsString(name), "ROOT_SELECTED", "BONE_SELECTED", "TIP_SELECTED") &&
- !STREQ2(PyString_AsString(name), "MULTIPLY", "HIDDEN_EDIT"))
- return 0;
- else
- return 1;
- }else{
- return 0;
- }
- }else{
- return 0;
- }
-}
-
-//------------------------EditBone.options (set)
-static int EditBone_setOptions(BPy_EditBone *self, PyObject *value, void *closure)
-{
- int length, numeric_value, new_flag = 0, x;
- PyObject *val = NULL, *index = NULL;
-
- if (PyList_Check(value)){
- length = PyList_Size(value);
- for (x = 0; x < length; x++){
- index = PyList_GetItem(value, x);
- if (!EditBone_CheckValidConstant(index))
- goto AttributeError2;
- val = PyDict_GetItemString(((BPy_constant*)index)->dict, "value");
- if (PyInt_Check(val)){
- numeric_value = (int)PyInt_AS_LONG(val);
- new_flag |= numeric_value;
- }else{
- goto AttributeError2;
- }
- }
-
- //set the options
- if(self->editbone){
- //make sure the 'connected' property is set up correctly
- if (new_flag & BONE_CONNECTED) {
- if(!self->editbone->parent)
- goto AttributeError3;
- else
- VECCOPY(self->editbone->head, self->editbone->parent->tail);
- }
- self->editbone->flag = new_flag;
- }else{
- self->flag = new_flag;
- }
- return 0;
- }else if (BPy_Constant_Check(value)){
- if (!EditBone_CheckValidConstant(value))
- goto AttributeError2;
- val = PyDict_GetItemString(((BPy_constant*)value)->dict, "value");
- if (PyInt_Check(val)){
- numeric_value = (int)PyInt_AS_LONG(val);
-
- if(self->editbone){
- //make sure the 'connected' property is set up correctly
- if (numeric_value & BONE_CONNECTED) {
- if(!self->editbone->parent)
- goto AttributeError3;
- else
- VECCOPY(self->editbone->head, self->editbone->parent->tail);
- }
- self->editbone->flag = numeric_value;
- }else{
- self->flag = numeric_value;
- }
- return 0;
- }else{
- goto AttributeError2;
- }
- }else{
- goto AttributeError1;
- }
-
-AttributeError1:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".options: ", "Expects a constant or list of constants");
-AttributeError2:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".options: ", "Please use a constant defined in the Armature module");
-AttributeError3:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".options: ", "You can't connect to parent because no parent is set");
-}
-//------------------------EditBone.parent (get)
-static PyObject *EditBone_getParent(BPy_EditBone *self, void *closure)
-{
- if (self->editbone){
- if (self->editbone->parent)
- return PyEditBone_FromEditBone(self->editbone->parent);
- else
- Py_RETURN_NONE;
- }else{
- Py_RETURN_NONE; //not in the list yet can't have a parent
- }
-}
-//------------------------EditBone.parent (set)
-static int EditBone_setParent(BPy_EditBone *self, PyObject *value, void *closure)
-{
- BPy_EditBone *parent = NULL;
-
- if (!PyArg_Parse(value, "O!", &EditBone_Type, &parent))
- goto AttributeError;
-
- if (!parent->editbone)
- goto AttributeError2;
-
- if (self->editbone){
- self->editbone->parent = parent->editbone;
- }else{
- self->parent = parent->editbone;
- }
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".parent: ", "expects a EditBone Object");
-AttributeError2:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".parent: ", "This object is not in the armature's bone list!");
-}
-//------------------------EditBone.matrix (get)
-static PyObject *EditBone_getMatrix(BPy_EditBone *self, void *closure)
-{
- float boneMatrix[3][3];
- float axis[3];
-
- if (self->editbone){
- VECSUB(axis, self->editbone->tail, self->editbone->head);
- vec_roll_to_mat3(axis, self->editbone->roll, boneMatrix);
- }else{
- VECSUB(axis, self->tail, self->head);
- vec_roll_to_mat3(axis, self->roll, boneMatrix);
- }
-
- return newMatrixObject((float*)boneMatrix, 3, 3, Py_NEW);
-}
-//------------------------EditBone.matrix (set)
-static int EditBone_setMatrix(BPy_EditBone *self, PyObject *value, void *closure)
-{
- PyObject *matrix;
- float roll, length, vec[3], axis[3], mat3[3][3];
-
- if (!PyArg_Parse(value, "O!", &matrix_Type, &matrix))
- goto AttributeError;
-
- //make sure we have the right sizes
- if (((MatrixObject*)matrix)->rowSize != 3 && ((MatrixObject*)matrix)->colSize != 3){
- if(((MatrixObject*)matrix)->rowSize != 4 && ((MatrixObject*)matrix)->colSize != 4){
- goto AttributeError;
- }
- }
-
- /*vec will be a normalized directional vector
- * together with the length of the old bone vec*length = the new vector*/
- /*The default rotation is 0,1,0 on the Y axis (see mat3_to_vec_roll)*/
- if (((MatrixObject*)matrix)->rowSize == 4){
- Mat3CpyMat4(mat3, ((float (*)[4])*((MatrixObject*)matrix)->matrix));
- }else{
- Mat3CpyMat3(mat3, ((float (*)[3])*((MatrixObject*)matrix)->matrix));
- }
- mat3_to_vec_roll(mat3, vec, &roll);
-
- //if a 4x4 matrix was passed we'll translate the vector otherwise not
- if (self->editbone){
- self->editbone->roll = roll;
- VecSubf(axis, self->editbone->tail, self->editbone->head);
- length = VecLength(axis);
- VecMulf(vec, length);
- if (((MatrixObject*)matrix)->rowSize == 4)
- VecCopyf(self->editbone->head, ((MatrixObject*)matrix)->matrix[3]);
- VecAddf(self->editbone->tail, self->editbone->head, vec);
- return 0;
- }else{
- self->roll = roll;
- VecSubf(axis, self->tail, self->head);
- length = VecLength(axis);
- VecMulf(vec, length);
- if (((MatrixObject*)matrix)->rowSize == 4)
- VecCopyf(self->head, ((MatrixObject*)matrix)->matrix[3]);
- VecAddf(self->tail, self->head, vec);
- return 0;
- }
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".matrix: ", "expects a 3x3 or 4x4 Matrix Object");
-}
-//------------------------Bone.length (get)
-static PyObject *EditBone_getLength(BPy_EditBone *self, void *closure)
-{
- float delta[3];
- double dot = 0.0f;
- int x;
-
- if (self->editbone){
- VECSUB(delta, self->editbone->tail, self->editbone->head);
- for(x = 0; x < 3; x++){
- dot += (delta[x] * delta[x]);
- }
- return PyFloat_FromDouble(sqrt(dot));
- }else{
- VECSUB(delta, self->tail, self->head);
- for(x = 0; x < 3; x++){
- dot += (delta[x] * delta[x]);
- }
- return PyFloat_FromDouble(sqrt(dot));
- }
-}
-//------------------------Bone.length (set)
-static int EditBone_setLength(BPy_EditBone *self, PyObject *value, void *closure)
-{
- printf("Sorry this isn't implemented yet.... :/");
- return 1;
-}
-
-
-//------------------------Bone.headRadius (get)
-static PyObject *EditBone_getHeadRadius(BPy_EditBone *self, void *closure)
-{
- if (self->editbone)
- if (self->editbone->parent && self->editbone->flag & BONE_CONNECTED)
- return PyFloat_FromDouble(self->editbone->parent->rad_tail);
- else
- return PyFloat_FromDouble(self->editbone->rad_head);
- else
- if (self->parent && self->flag & BONE_CONNECTED)
- return PyFloat_FromDouble(self->parent->rad_tail);
- else
- return PyFloat_FromDouble(self->rad_head);
-}
-//------------------------Bone.headRadius (set)
-static int EditBone_setHeadRadius(BPy_EditBone *self, PyObject *value, void *closure)
-{
- float radius;
- if (!PyArg_Parse(value, "f", &radius))
- goto AttributeError;
- CLAMP(radius, 0.0f, 10000.0f);
-
- if (self->editbone)
- if (self->editbone->parent && self->editbone->flag & BONE_CONNECTED)
- self->editbone->parent->rad_tail= radius;
- else
- self->editbone->rad_head= radius;
- else
- if (self->parent && self->flag & BONE_CONNECTED)
- self->parent->rad_tail= radius;
- else
- self->rad_head= radius;
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".headRadius: ", "expects a float");
-}
-
-
-//------------------------Bone.tailRadius (get)
-static PyObject *EditBone_getTailRadius(BPy_EditBone *self, void *closure)
-{
- if (self->editbone)
- return PyFloat_FromDouble(self->editbone->rad_tail);
- else
- return PyFloat_FromDouble(self->rad_tail);
-}
-//------------------------Bone.tailRadius (set)
-static int EditBone_setTailRadius(BPy_EditBone *self, PyObject *value, void *closure)
-{
- float radius;
- if (!PyArg_Parse(value, "f", &radius))
- goto AttributeError;
- CLAMP(radius, 0.0f, 10000.0f);
-
- if (self->editbone)
- self->editbone->rad_tail = radius;
- else
- self->rad_tail = radius;
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".tailRadius: ", "expects a float");
-}
-
-//------------------------Bone.layerMask (get)
-static PyObject *EditBone_getLayerMask(BPy_EditBone *self)
-{
- /* do this extra stuff because the short's bits can be negative values */
- unsigned short laymask = 0;
- if (self->editbone) laymask |= self->editbone->layer;
- else laymask |= self->layer;
- return PyInt_FromLong((int)laymask);
-}
-//------------------------Bone.layerMask (set)
-static int EditBone_setLayerMask(BPy_EditBone *self, PyObject *value)
-{
- int laymask;
- if (!PyInt_Check(value)) {
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected an integer (bitmask) as argument" );
- }
-
- laymask = PyInt_AsLong(value);
-
- if (laymask <= 0 || laymask > (1<<16) - 1)
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "bitmask must have from 1 up to 16 bits set");
-
- if (self->editbone) {
- self->editbone->layer = 0;
- self->editbone->layer |= laymask;
- } else {
- self->layer = 0;
- self->layer |= laymask;
- }
-
- return 0;
-}
-
-//------------------TYPE_OBECT IMPLEMENTATION--------------------------
-//------------------------tp_methods
-//This contains a list of all methods the object contains
-static PyMethodDef BPy_EditBone_methods[] = {
- {"hasParent", (PyCFunction) EditBone_hasParent, METH_NOARGS,
- "() - True/False - Bone has a parent"},
- {"clearParent", (PyCFunction) EditBone_clearParent, METH_NOARGS,
- "() - sets the parent to None"},
- {NULL, NULL, 0, NULL}
-};
-///------------------------tp_getset
-//This contains methods for attributes that require checking
-static PyGetSetDef BPy_EditBone_getset[] = {
- {"name", (getter)EditBone_getName, (setter)EditBone_setName,
- "The name of the bone", NULL},
- {"roll", (getter)EditBone_getRoll, (setter)EditBone_setRoll,
- "The roll (or rotation around the axis) of the bone", NULL},
- {"head", (getter)EditBone_getHead, (setter)EditBone_setHead,
- "The start point of the bone", NULL},
- {"tail", (getter)EditBone_getTail, (setter)EditBone_setTail,
- "The end point of the bone", NULL},
- {"matrix", (getter)EditBone_getMatrix, (setter)EditBone_setMatrix,
- "The matrix of the bone", NULL},
- {"weight", (getter)EditBone_getWeight, (setter)EditBone_setWeight,
- "The weight of the bone in relation to a parented mesh", NULL},
- {"deformDist", (getter)EditBone_getDeform_dist, (setter)EditBone_setDeform_dist,
- "The distance at which deformation has effect", NULL},
- {"subdivisions", (getter)EditBone_getSubdivisions, (setter)EditBone_setSubdivisions,
- "The number of subdivisions (for B-Bones)", NULL},
- {"options", (getter)EditBone_getOptions, (setter)EditBone_setOptions,
- "The options effective on this bone", NULL},
- {"parent", (getter)EditBone_getParent, (setter)EditBone_setParent,
- "The parent bone of this bone", NULL},
- {"length", (getter)EditBone_getLength, (setter)EditBone_setLength,
- "The length of this bone", NULL},
- {"tailRadius", (getter)EditBone_getTailRadius, (setter)EditBone_setTailRadius,
- "Set the radius of this bones tip", NULL},
- {"headRadius", (getter)EditBone_getHeadRadius, (setter)EditBone_setHeadRadius,
- "Set the radius of this bones head", NULL},
- {"layerMask", (getter)EditBone_getLayerMask, (setter)EditBone_setLayerMask,
- "Layer bitmask", NULL },
- {NULL, NULL, NULL, NULL,NULL}
-};
-
-//------------------------tp_repr
-//This is the string representation of the object
-static PyObject *EditBone_repr(BPy_EditBone *self)
-{
- if (self->editbone)
- return PyString_FromFormat( "[EditBone \"%s\"]", self->editbone->name );
- else
- return PyString_FromFormat( "[EditBone \"%s\"]", self->name );
-}
-
-static int EditBone_compare( BPy_EditBone * a, BPy_EditBone * b )
-{
- /* if they are not wrapped, then they cant be the same */
- if (a->editbone==NULL && b->editbone==NULL) return -1;
- return ( a->editbone == b->editbone ) ? 0 : -1;
-}
-
-
-//------------------------tp_doc
-//The __doc__ string for this object
-static char BPy_EditBone_doc[] = "This is an internal subobject of armature\
-designed to act as a wrapper for an 'edit bone'.";
-
-//------------------------tp_new
-//This methods creates a new object (note it does not initialize it - only the building)
-static PyObject *EditBone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- char *name = "myEditBone";
- BPy_EditBone *py_editBone = NULL;
- float head[3], tail[3];
-
- py_editBone = (BPy_EditBone*)type->tp_alloc(type, 0); //new
- if (py_editBone == NULL)
- goto RuntimeError;
-
- //this pointer will be set when this bone is placed in ListBase
- //otherwise this will act as a py_object
- py_editBone->editbone = NULL;
-
- unique_editbone_name(NULL, name);
- BLI_strncpy(py_editBone->name, name, 32);
- py_editBone->parent = NULL;
- py_editBone->weight= 1.0f;
- py_editBone->dist= 0.25f;
- py_editBone->xwidth= 0.1f;
- py_editBone->zwidth= 0.1f;
- py_editBone->ease1= 1.0f;
- py_editBone->ease2= 1.0f;
- py_editBone->rad_head= 0.10f;
- py_editBone->rad_tail= 0.05f;
- py_editBone->segments= 1;
- py_editBone->layer= 1;
- py_editBone->flag = 0;
- py_editBone->roll = 0.0f;
-
- head[0] = head[1] = head[2] = 0.0f;
- tail[1] = tail[2] = 0.0f;
- tail[0] = 1.0f;
- VECCOPY(py_editBone->head, head);
- VECCOPY(py_editBone->tail, tail);
-
- return (PyObject*)py_editBone;
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sEditBoneError, " __new__: ", "Internal Error");
-}
-//------------------------tp_dealloc
-//This tells how to 'tear-down' our object when ref count hits 0
-//the struct EditBone pointer will be handled by the BPy_BonesDict class
-static void EditBone_dealloc(BPy_EditBone * self)
-{
- EditBone_Type.tp_free(self);
- return;
-}
-//------------------TYPE_OBECT DEFINITION--------------------------
-PyTypeObject EditBone_Type = {
- PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "EditBone", //tp_name
- sizeof(BPy_EditBone), //tp_basicsize
- 0, //tp_itemsize
- (destructor)EditBone_dealloc, //tp_dealloc
- 0, //tp_print
- 0, //tp_getattr
- 0, //tp_setattr
- (cmpfunc)EditBone_compare, //tp_compare
- (reprfunc)EditBone_repr, //tp_repr
- 0, //tp_as_number
- 0, //tp_as_sequence
- 0, //tp_as_mapping
- 0, //tp_hash
- 0, //tp_call
- 0, //tp_str
- 0, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
- BPy_EditBone_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- 0, //tp_richcompare
- 0, //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- BPy_EditBone_methods, //tp_methods
- 0, //tp_members
- BPy_EditBone_getset, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- 0, //tp_init
- 0, //tp_alloc
- (newfunc)EditBone_new, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-
-//------------------METHOD IMPLEMENTATIONS--------------------------------
-//------------------------(internal) PyBone_ChildrenAsList
-static int PyBone_ChildrenAsList(PyObject *list, ListBase *bones){
- Bone *bone = NULL;
- PyObject *py_bone = NULL;
-
- for (bone = bones->first; bone; bone = bone->next){
- py_bone = PyBone_FromBone(bone);
- if (py_bone == NULL)
- return 0;
-
- if(PyList_Append(list, py_bone) == -1){
- return 0;
- }
- Py_DECREF(py_bone);
- if (bone->childbase.first)
- if (!PyBone_ChildrenAsList(list, &bone->childbase))
- return 0;
- }
- return 1;
-}
-//-------------------------Bone.hasParent()
-static PyObject *Bone_hasParent(BPy_Bone *self)
-{
- if (self->bone->parent)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-//-------------------------Bone.hasChildren()
-static PyObject *Bone_hasChildren(BPy_Bone *self)
-{
- if (self->bone->childbase.first)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-//-------------------------Bone.getAllChildren()
-static PyObject *Bone_getAllChildren(BPy_Bone *self)
-{
- PyObject *list = PyList_New(0);
- if (!self->bone->childbase.first) {
- /* do nothing */
- } else if (!PyBone_ChildrenAsList(list, &self->bone->childbase)) {
- Py_XDECREF(list);
- EXPP_objError(PyExc_RuntimeError, "%s%s",
- sBoneError, "Internal error trying to wrap blender bones!");
- }
- return list;
-}
-
-//------------------ATTRIBUTE IMPLEMENTATIONS-----------------------------
-//------------------------Bone.name (get)
-static PyObject *Bone_getName(BPy_Bone *self, void *closure)
-{
- return PyString_FromString(self->bone->name);
-}
-//------------------------Bone.name (set)
-//check for char[] overflow here...
-static int Bone_setName(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.roll (get)
-static PyObject *Bone_getRoll(BPy_Bone *self, void *closure)
-{
- return Py_BuildValue("{s:f, s:f}",
- "BONESPACE", self->bone->roll * (180/Py_PI),
- "ARMATURESPACE", boneRoll_ToArmatureSpace(self->bone) * (180/Py_PI));
-}
-//------------------------Bone.roll (set)
-static int Bone_setRoll(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.head (get)
-static PyObject *Bone_getHead(BPy_Bone *self, void *closure)
-{
- PyObject *val1 = newVectorObject(self->bone->head, 3, Py_WRAP);
- PyObject *val2 = newVectorObject(self->bone->arm_head, 3, Py_WRAP);
- PyObject *ret = Py_BuildValue(
- "{s:O, s:O}", "BONESPACE", val1, "ARMATURESPACE", val2);
-
- Py_DECREF(val1);
- Py_DECREF(val2);
- return ret;
-}
-//------------------------Bone.head (set)
-static int Bone_setHead(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.tail (get)
-static PyObject *Bone_getTail(BPy_Bone *self, void *closure)
-{
- PyObject *val1 = newVectorObject(self->bone->tail, 3, Py_WRAP);
- PyObject *val2 = newVectorObject(self->bone->arm_tail, 3, Py_WRAP);
- PyObject *ret = Py_BuildValue("{s:O, s:O}",
- "BONESPACE", val1, "ARMATURESPACE", val2);
-
- Py_DECREF(val1);
- Py_DECREF(val2);
- return ret;
-}
-//------------------------Bone.tail (set)
-static int Bone_setTail(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.weight (get)
-static PyObject *Bone_getWeight(BPy_Bone *self, void *closure)
-{
- return PyFloat_FromDouble(self->bone->weight);
-}
-//------------------------Bone.weight (set)
-static int Bone_setWeight(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.deform_dist (get)
-static PyObject *Bone_getDeform_dist(BPy_Bone *self, void *closure)
-{
- return PyFloat_FromDouble(self->bone->dist);
-}
-//------------------------Bone.deform_dist (set)
-static int Bone_setDeform_dist(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.subdivisions (get)
-static PyObject *Bone_getSubdivisions(BPy_Bone *self, void *closure)
-{
- return PyInt_FromLong(self->bone->segments);
-}
-//------------------------Bone.subdivisions (set)
-static int Bone_setSubdivisions(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.connected (get)
-static PyObject *Bone_getOptions(BPy_Bone *self, void *closure)
-{
- PyObject *list = NULL;
-
- list = PyList_New(0);
- if (list == NULL)
- goto RuntimeError;
-
- if(self->bone->flag & BONE_CONNECTED)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "CONNECTED")) == -1)
- goto RuntimeError;
- if(self->bone->flag & BONE_HINGE)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "HINGE")) == -1)
- goto RuntimeError;
- if(self->bone->flag & BONE_NO_DEFORM)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "NO_DEFORM")) == -1)
- goto RuntimeError;
- if(self->bone->flag & BONE_MULT_VG_ENV)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "MULTIPLY")) == -1)
- goto RuntimeError;
- if(self->bone->flag & BONE_HIDDEN_A)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "HIDDEN_EDIT")) == -1)
- goto RuntimeError;
- if(self->bone->flag & BONE_ROOTSEL)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "ROOT_SELECTED")) == -1)
- goto RuntimeError;
- if(self->bone->flag & BONE_SELECTED)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "BONE_SELECTED")) == -1)
- goto RuntimeError;
- if(self->bone->flag & BONE_TIPSEL)
- if (PyList_Append(list,
- EXPP_GetModuleConstant("Blender.Armature", "TIP_SELECTED")) == -1)
- goto RuntimeError;
-
- return list;
-
-RuntimeError:
- Py_XDECREF(list);
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sBoneError, "getOptions(): ", "Internal failure!");
-}
-//------------------------Bone.connected (set)
-static int Bone_setOptions(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.parent (get)
-static PyObject *Bone_getParent(BPy_Bone *self, void *closure)
-{
- if (self->bone->parent)
- return PyBone_FromBone(self->bone->parent);
- else
- Py_RETURN_NONE;
-}
-//------------------------Bone.parent (set)
-static int Bone_setParent(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.children (get)
-static PyObject *Bone_getChildren(BPy_Bone *self, void *closure)
-{
- PyObject *list = PyList_New(0);
- Bone *bone = NULL;
- PyObject *py_bone = NULL;
-
- if (self->bone->childbase.first){
- for (bone = self->bone->childbase.first; bone; bone = bone->next){
- py_bone = PyBone_FromBone(bone);
- if (py_bone == NULL)
- goto RuntimeError;
- if (PyList_Append(list, py_bone) == -1)
- goto RuntimeError;
- Py_DECREF(py_bone);
- }
- }
- return list;
-
-RuntimeError:
- Py_XDECREF(list);
- Py_XDECREF(py_bone);
- return EXPP_objError(PyExc_RuntimeError, "%s%s",
- sBoneError, "Internal error trying to wrap blender bones!");
-}
-//------------------------Bone.children (set)
-static int Bone_setChildren(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.matrix (get)
-static PyObject *Bone_getMatrix(BPy_Bone *self, void *closure)
-{
- PyObject *val1 = newMatrixObject((float*)self->bone->bone_mat, 3,3, Py_WRAP);
- PyObject *val2 = newMatrixObject((float*)self->bone->arm_mat, 4,4, Py_WRAP);
- PyObject *ret = Py_BuildValue("{s:O, s:O}",
- "BONESPACE", val1, "ARMATURESPACE", val2);
- Py_DECREF(val1);
- Py_DECREF(val2);
- return ret;
-
-
-}
-//------------------------Bone.matrix (set)
-static int Bone_setMatrix(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-//------------------------Bone.length (get)
-static PyObject *Bone_getLength(BPy_Bone *self, void *closure)
-{
- return PyFloat_FromDouble(self->bone->length);
-}
-//------------------------Bone.length (set)
-static int Bone_setLength(BPy_Bone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_ValueError, "%s%s",
- sBoneError, "You must first call .makeEditable() to edit the armature");
-}
-
-//------------------------Bone.headRadius (get)
-static PyObject *Bone_getHeadRadius(BPy_Bone *self, void *closure)
-{
-
- if (self->bone->parent && self->bone->flag & BONE_CONNECTED)
- return PyFloat_FromDouble(self->bone->parent->rad_tail);
- else
- return PyFloat_FromDouble(self->bone->rad_head);
-}
-//------------------------Bone.headRadius (set)
-static int Bone_setHeadRadius(BPy_Bone *self, PyObject *value, void *closure)
-{
- float radius;
- if (!PyArg_Parse(value, "f", &radius))
- goto AttributeError;
- CLAMP(radius, 0.0f, 10000.0f);
-
- if (self->bone->parent && self->bone->flag & BONE_CONNECTED)
- self->bone->parent->rad_tail= radius;
- else
- self->bone->rad_head= radius;
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".headRadius: ", "expects a float");
-}
-
-//------------------------Bone.tailRadius (get)
-static PyObject *Bone_getTailRadius(BPy_Bone *self, void *closure)
-{
- return PyFloat_FromDouble(self->bone->rad_tail);
-}
-
-//------------------------Bone.headRadius (set)
-static int Bone_setTailRadius(BPy_Bone *self, PyObject *value, void *closure)
-{
- float radius;
- if (!PyArg_Parse(value, "f", &radius))
- goto AttributeError;
- CLAMP(radius, 0.0f, 10000.0f);
- self->bone->rad_tail= radius;
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sEditBoneError, ".headRadius: ", "expects a float");
-}
-
-//------------------------Bone.layerMask (get)
-static PyObject *Bone_getLayerMask(BPy_Bone *self)
-{
- /* do this extra stuff because the short's bits can be negative values */
- unsigned short laymask = 0;
- laymask |= self->bone->layer;
- return PyInt_FromLong((int)laymask);
-}
-//------------------------Bone.layerMask (set)
-static int Bone_setLayerMask(BPy_Bone *self, PyObject *value)
-{
- int laymask;
- if (!PyInt_Check(value)) {
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected an integer (bitmask) as argument" );
- }
-
- laymask = PyInt_AsLong(value);
-
- if (laymask <= 0 || laymask > (1<<16) - 1)
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "bitmask must have from 1 up to 16 bits set");
-
- self->bone->layer = 0;
- self->bone->layer |= laymask;
-
- return 0;
-}
-
-//------------------TYPE_OBECT IMPLEMENTATION--------------------------
-//------------------------tp_methods
-//This contains a list of all methods the object contains
-static PyMethodDef BPy_Bone_methods[] = {
- {"hasParent", (PyCFunction) Bone_hasParent, METH_NOARGS,
- "() - True/False - Bone has a parent"},
- {"hasChildren", (PyCFunction) Bone_hasChildren, METH_NOARGS,
- "() - True/False - Bone has 1 or more children"},
- {"getAllChildren", (PyCFunction) Bone_getAllChildren, METH_NOARGS,
- "() - All the children for this bone - including children's children"},
- {NULL, NULL, 0, NULL}
-};
-//------------------------tp_getset
-//This contains methods for attributes that require checking
-static PyGetSetDef BPy_Bone_getset[] = {
- {"name", (getter)Bone_getName, (setter)Bone_setName,
- "The name of the bone", NULL},
- {"roll", (getter)Bone_getRoll, (setter)Bone_setRoll,
- "The roll (or rotation around the axis) of the bone", NULL},
- {"head", (getter)Bone_getHead, (setter)Bone_setHead,
- "The start point of the bone", NULL},
- {"tail", (getter)Bone_getTail, (setter)Bone_setTail,
- "The end point of the bone", NULL},
- {"matrix", (getter)Bone_getMatrix, (setter)Bone_setMatrix,
- "The matrix of the bone", NULL},
- {"weight", (getter)Bone_getWeight, (setter)Bone_setWeight,
- "The weight of the bone in relation to a parented mesh", NULL},
- {"deform_dist", (getter)Bone_getDeform_dist, (setter)Bone_setDeform_dist,
- "The distance at which deformation has effect", NULL},
- {"subdivisions", (getter)Bone_getSubdivisions, (setter)Bone_setSubdivisions,
- "The number of subdivisions (for B-Bones)", NULL},
- {"options", (getter)Bone_getOptions, (setter)Bone_setOptions,
- "The options effective on this bone", NULL},
- {"parent", (getter)Bone_getParent, (setter)Bone_setParent,
- "The parent bone of this bone", NULL},
- {"children", (getter)Bone_getChildren, (setter)Bone_setChildren,
- "The child bones of this bone", NULL},
- {"length", (getter)Bone_getLength, (setter)Bone_setLength,
- "The length of this bone", NULL},
- {"tailRadius", (getter)Bone_getTailRadius, (setter)Bone_setTailRadius,
- "Set the radius of this bones tip", NULL},
- {"headRadius", (getter)Bone_getHeadRadius, (setter)Bone_setHeadRadius,
- "Set the radius of this bones head", NULL},
- {"layerMask", (getter)Bone_getLayerMask, (setter)Bone_setLayerMask,
- "Layer bitmask", NULL },
- {NULL, NULL, NULL, NULL,NULL}
-};
-//------------------------tp_repr
-//This is the string representation of the object
-static PyObject *Bone_repr(BPy_Bone *self)
-{
- return PyString_FromFormat( "[Bone \"%s\"]", self->bone->name );
-}
-static int Bone_compare( BPy_Bone * a, BPy_Bone * b )
-{
- return ( a->bone == b->bone ) ? 0 : -1;
-}
-//------------------------tp_dealloc
-//This tells how to 'tear-down' our object when ref count hits 0
-static void Bone_dealloc(BPy_Bone * self)
-{
- Bone_Type.tp_free(self);
- return;
-}
-//------------------------tp_doc
-//The __doc__ string for this object
-static char BPy_Bone_doc[] = "This object wraps a Blender Boneobject.\n\
- This object is a subobject of the Armature object.";
-
-//------------------TYPE_OBECT DEFINITION--------------------------
-PyTypeObject Bone_Type = {
- PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "Bone", //tp_name
- sizeof(BPy_Bone), //tp_basicsize
- 0, //tp_itemsize
- (destructor)Bone_dealloc, //tp_dealloc
- 0, //tp_print
- 0, //tp_getattr
- 0, //tp_setattr
- (cmpfunc) Bone_compare, //tp_compare
- (reprfunc) Bone_repr, //tp_repr
- 0, //tp_as_number
- 0, //tp_as_sequence
- 0, //tp_as_mapping
- 0, //tp_hash
- 0, //tp_call
- 0, //tp_str
- 0, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
- BPy_Bone_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- 0, //tp_richcompare
- 0, //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- BPy_Bone_methods, //tp_methods
- 0, //tp_members
- BPy_Bone_getset, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- 0, //tp_init
- 0, //tp_alloc
- 0, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-//------------------VISIBLE PROTOTYPE IMPLEMENTATION-----------------------
-//-----------------(internal)
-//Converts a struct EditBone to a BPy_EditBone
-PyObject *PyEditBone_FromEditBone(struct EditBone *editbone)
-{
- BPy_EditBone *py_editbone = NULL;
-
- py_editbone = (BPy_EditBone*)EditBone_Type.tp_alloc(&EditBone_Type, 0); //*new*
- if (!py_editbone)
- goto RuntimeError;
-
- py_editbone->editbone = editbone;
-
- return (PyObject *) py_editbone;
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sEditBoneError, "PyEditBone_FromEditBone: ", "Internal Error Ocurred");
-}
-//-----------------(internal)
-//Converts a struct Bone to a BPy_Bone
-PyObject *PyBone_FromBone(struct Bone *bone)
-{
- BPy_Bone *py_Bone = ( BPy_Bone * ) PyObject_NEW( BPy_Bone, &Bone_Type );
-
- py_Bone->bone = bone;
-
- return (PyObject *) py_Bone;
-}
-//-----------------(internal)
-//Converts a PyBone to a bBone
-struct Bone *PyBone_AsBone(BPy_Bone *py_Bone)
-{
- return (py_Bone->bone);
-}
diff --git a/source/blender/python/api2_2x/Bone.h b/source/blender/python/api2_2x/Bone.h
deleted file mode 100644
index da7efe27931..00000000000
--- a/source/blender/python/api2_2x/Bone.h
+++ /dev/null
@@ -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
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c
deleted file mode 100644
index bd1e7932f5c..00000000000
--- a/source/blender/python/api2_2x/Camera.c
+++ /dev/null
@@ -1,1057 +0,0 @@
-/*
- * $Id: Camera.c 12078 2007-09-18 06:41:29Z 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, Johnny Matthews, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include "Camera.h" /*This must come first */
-
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_object.h"
-#include "BKE_library.h"
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h" /* for M_PI */
-#include "BSE_editipo.h"
-#include "BIF_space.h"
-#include "mydevice.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-#include "Ipo.h"
-
-
-#define IPOKEY_LENS 0
-#define IPOKEY_CLIPPING 1
-
-
-
-enum cam_consts {
- EXPP_CAM_ATTR_LENS = 0,
- EXPP_CAM_ATTR_ANGLE,
- EXPP_CAM_ATTR_DOFDIST,
- EXPP_CAM_ATTR_CLIPEND,
- EXPP_CAM_ATTR_CLIPSTART,
- EXPP_CAM_ATTR_SCALE,
- EXPP_CAM_ATTR_DRAWSIZE,
- EXPP_CAM_ATTR_SHIFTX,
- EXPP_CAM_ATTR_SHIFTY,
- EXPP_CAM_ATTR_ALPHA,
-};
-
-/*****************************************************************************/
-/* Python API function prototypes for the Camera module. */
-/*****************************************************************************/
-static PyObject *M_Camera_New( PyObject * self, PyObject * args,
- PyObject * keywords );
-static PyObject *M_Camera_Get( 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.Camera.__doc__ */
-/*****************************************************************************/
-static char M_Camera_doc[] = "The Blender Camera module\n\
-\n\
-This module provides access to **Camera Data** objects in Blender\n\
-\n\
-Example::\n\
-\n\
- from Blender import Camera, Object, Scene\n\
- c = Camera.New('ortho') # create new ortho camera data\n\
- c.scale = 6.0 # set scale value\n\
- scn = Scene.GetCurrent() # get current Scene\n\
- ob = scn.objects.new(c) # Make an object from this data in the scene\n\
- cur.setCurrentCamera(ob) # make this camera the active";
-
-static char M_Camera_New_doc[] =
- "Camera.New (type = 'persp', name = 'CamData'):\n\
- Return a new Camera Data object with the given type and name.";
-
-static char M_Camera_Get_doc[] = "Camera.Get (name = None):\n\
- Return the camera data with the given 'name', None if not found, or\n\
- Return a list with all Camera Data objects in the current scene,\n\
- if no argument was given.";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Camera module: */
-/*****************************************************************************/
-struct PyMethodDef M_Camera_methods[] = {
- {"New", ( PyCFunction ) M_Camera_New, METH_VARARGS | METH_KEYWORDS,
- M_Camera_New_doc},
- {"Get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
- {"get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Camera methods declarations: */
-/*****************************************************************************/
-static PyObject *Camera_oldgetType( BPy_Camera * self );
-static PyObject *Camera_oldgetMode( BPy_Camera * self );
-static PyObject *Camera_oldgetLens( BPy_Camera * self );
-static PyObject *Camera_oldgetClipStart( BPy_Camera * self );
-static PyObject *Camera_oldgetClipEnd( BPy_Camera * self );
-static PyObject *Camera_oldgetDrawSize( BPy_Camera * self );
-static PyObject *Camera_oldgetScale( BPy_Camera * self );
-static PyObject *Camera_getIpo( BPy_Camera * self );
-static int Camera_setIpo( BPy_Camera * self, PyObject * value );
-static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetMode( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetLens( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetClipStart( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetClipEnd( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetDrawSize( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetScale( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * value );
-static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldclearIpo( BPy_Camera * self );
-static PyObject *Camera_clearScriptLinks( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_copy( BPy_Camera * self );
-
-
-/*****************************************************************************/
-/* Python BPy_Camera methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Camera_methods[] = {
- /* name, method, flags, doc */
- {"getIpo", ( PyCFunction ) Camera_getIpo, METH_NOARGS,
- "() - Return Camera Data Ipo"},
- {"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
- "() - Return Camera Data name"},
- {"getType", ( PyCFunction ) Camera_oldgetType, METH_NOARGS,
- "() - Return Camera type - 'persp':0, 'ortho':1"},
- {"getMode", ( PyCFunction ) Camera_oldgetMode, METH_NOARGS,
- "() - Return Camera mode flags (or'ed value) -\n"
- " 'showLimits':1, 'showMist':2"},
- {"getLens", ( PyCFunction ) Camera_oldgetLens, METH_NOARGS,
- "() - Return *perspective* Camera lens value"},
- {"getScale", ( PyCFunction ) Camera_oldgetScale, METH_NOARGS,
- "() - Return *ortho* Camera scale value"},
- {"getClipStart", ( PyCFunction ) Camera_oldgetClipStart, METH_NOARGS,
- "() - Return Camera clip start value"},
- {"getClipEnd", ( PyCFunction ) Camera_oldgetClipEnd, METH_NOARGS,
- "() - Return Camera clip end value"},
- {"getDrawSize", ( PyCFunction ) Camera_oldgetDrawSize, METH_NOARGS,
- "() - Return Camera draw size value"},
- {"setIpo", ( PyCFunction ) Camera_oldsetIpo, METH_VARARGS,
- "(Blender Ipo) - Set Camera Ipo"},
- {"clearIpo", ( PyCFunction ) Camera_oldclearIpo, METH_NOARGS,
- "() - Unlink Ipo from this Camera."},
- {"insertIpoKey", ( PyCFunction ) Camera_insertIpoKey, METH_VARARGS,
- "( Camera IPO type ) - Inserts a key into IPO"},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "(s) - Set Camera Data name"},
- {"setType", ( PyCFunction ) Camera_oldsetType, METH_O,
- "(s) - Set Camera type, which can be 'persp' or 'ortho'"},
- {"setMode", ( PyCFunction ) Camera_oldsetMode, METH_VARARGS,
- "(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"},
- {"setLens", ( PyCFunction ) Camera_oldsetLens, METH_O,
- "(f) - Set *perpective* Camera lens value"},
- {"setScale", ( PyCFunction ) Camera_oldsetScale, METH_O,
- "(f) - Set *ortho* Camera scale value"},
- {"setClipStart", ( PyCFunction ) Camera_oldsetClipStart, METH_O,
- "(f) - Set Camera clip start value"},
- {"setClipEnd", ( PyCFunction ) Camera_oldsetClipEnd, METH_O,
- "(f) - Set Camera clip end value"},
- {"setDrawSize", ( PyCFunction ) Camera_oldsetDrawSize, METH_O,
- "(f) - Set Camera draw size value"},
- {"getScriptLinks", ( PyCFunction ) Camera_oldgetScriptLinks, METH_O,
- "(eventname) - Get a list of this camera's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged, Redraw or Render."},
- {"addScriptLink", ( PyCFunction ) Camera_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new camera scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged, Redraw or Render."},
- {"clearScriptLinks", ( PyCFunction ) Camera_clearScriptLinks,
- METH_NOARGS,
- "() - Delete all scriptlinks from this camera.\n"
- "([s1<,s2,s3...>]) - Delete specified scriptlinks from this camera."},
- {"__copy__", ( PyCFunction ) Camera_copy, METH_NOARGS,
- "() - Return a copy of the camera."},
- {"copy", ( PyCFunction ) Camera_copy, METH_NOARGS,
- "() - Return a copy of the camera."},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python Camera_Type callback function prototypes: */
-/*****************************************************************************/
-static int Camera_compare( BPy_Camera * a, BPy_Camera * b );
-static PyObject *Camera_repr( BPy_Camera * self );
-
-static PyObject *M_Camera_New( PyObject * self, PyObject * args,
- PyObject * kwords )
-{
- char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
- char *name_str = "Camera";
- static char *kwlist[] = { "type_str", "name_str", NULL };
- PyObject *pycam; /* for Camera Data object wrapper in Python */
- Camera *blcam; /* for actual Camera Data we create in Blender */
-
- /* Parse the arguments passed in by the Python interpreter */
- if( !PyArg_ParseTupleAndKeywords( args, kwords, "|ss", kwlist,
- &type_str, &name_str ) )
- /* We expected string(s) (or nothing) as argument, but we didn't get that. */
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected zero, one or two strings as arguments" );
-
- blcam = add_camera( name_str ); /* first create the Camera Data in Blender */
-
- if( blcam ) /* now create the wrapper obj in Python */
- pycam = Camera_CreatePyObject( blcam );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Camera Data in Blender" );
-
- /* let's return user count to zero, because ... */
- blcam->id.us = 0; /* ... add_camera() incref'ed it */
- /* XXX XXX Do this in other modules, too */
-
- if( pycam == NULL )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create Camera PyObject" );
-
- if( strcmp( type_str, "persp" ) == 0 )
- /* default, no need to set, so */
- /*blcam->type = (short)EXPP_CAM_TYPE_PERSP */
- ;
- /* we comment this line */
- else if( strcmp( type_str, "ortho" ) == 0 )
- blcam->type = ( short ) EXPP_CAM_TYPE_ORTHO;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown camera type" );
-
- return pycam;
-}
-
-static PyObject *M_Camera_Get( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- Camera *cam_iter;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" );
-
- cam_iter = G.main->camera.first;
-
- if( name ) { /* (name) - Search camera by name */
-
- PyObject *wanted_cam = NULL;
-
- while( cam_iter && !wanted_cam ) {
-
- if( strcmp( name, cam_iter->id.name + 2 ) == 0 ) {
- wanted_cam = Camera_CreatePyObject( cam_iter );
- break;
- }
-
- cam_iter = cam_iter->id.next;
- }
-
- if( !wanted_cam ) { /* Requested camera doesn't exist */
- char error_msg[64];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Camera \"%s\" not found", name );
- return EXPP_ReturnPyObjError( PyExc_NameError,
- error_msg );
- }
-
- return wanted_cam;
- }
-
- else { /* () - return a list of wrappers for all cameras in the scene */
- int index = 0;
- PyObject *cam_pylist, *pyobj;
-
- cam_pylist =
- PyList_New( BLI_countlist( &( G.main->camera ) ) );
-
- if( !cam_pylist )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" );
-
- while( cam_iter ) {
- pyobj = Camera_CreatePyObject( cam_iter );
-
- if( !pyobj ) {
- Py_DECREF(cam_pylist);
- return EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create Camera PyObject" );
- }
- PyList_SET_ITEM( cam_pylist, index, pyobj );
-
- cam_iter = cam_iter->id.next;
- index++;
- }
-
- return cam_pylist;
- }
-}
-
-PyObject *Camera_Init( void )
-{
- PyObject *submodule;
-
- if( PyType_Ready( &Camera_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Camera",
- M_Camera_methods, M_Camera_doc );
-
- PyModule_AddIntConstant( submodule, "LENS", IPOKEY_LENS );
- PyModule_AddIntConstant( submodule, "CLIPPING", IPOKEY_CLIPPING );
-
- return submodule;
-}
-
-/* Three Python Camera_Type helper functions needed by the Object module: */
-
-PyObject *Camera_CreatePyObject( Camera * cam )
-{
- BPy_Camera *pycam;
-
- pycam = ( BPy_Camera * ) PyObject_NEW( BPy_Camera, &Camera_Type );
-
- if( !pycam )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Camera PyObject" );
-
- pycam->camera = cam;
- return ( PyObject * ) pycam;
-}
-
-Camera *Camera_FromPyObject( PyObject * pyobj )
-{
- return ( ( BPy_Camera * ) pyobj )->camera;
-}
-
-/*****************************************************************************/
-/* Python BPy_Camera methods: */
-/*****************************************************************************/
-
-static PyObject *Camera_oldgetType( BPy_Camera * self )
-{
- return PyInt_FromLong( self->camera->type );
-}
-
-static PyObject *Camera_oldgetMode( BPy_Camera * self )
-{
- return PyInt_FromLong( self->camera->flag );
-}
-
-static PyObject *Camera_oldgetLens( BPy_Camera * self )
-{
- return PyFloat_FromDouble( self->camera->lens );
-}
-
-static PyObject *Camera_oldgetScale( BPy_Camera * self )
-{
- return PyFloat_FromDouble( self->camera->ortho_scale );
-}
-
-static PyObject *Camera_oldgetClipStart( BPy_Camera * self )
-{
- return PyFloat_FromDouble( self->camera->clipsta );
-}
-
-static PyObject *Camera_oldgetClipEnd( BPy_Camera * self )
-{
- return PyFloat_FromDouble( self->camera->clipend );
-}
-
-static PyObject *Camera_oldgetDrawSize( BPy_Camera * self )
-{
- return PyFloat_FromDouble( self->camera->drawsize );
-}
-
-
-
-static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Camera_setIpo );
-}
-
-static PyObject *Camera_oldclearIpo( BPy_Camera * self )
-{
- Camera *cam = self->camera;
- Ipo *ipo = ( Ipo * ) cam->ipo;
-
- if( ipo ) {
- ID *id = &ipo->id;
- if( id->us > 0 )
- id->us--;
- cam->ipo = NULL;
-
- return EXPP_incr_ret_True();
- }
-
- return EXPP_incr_ret_False(); /* no ipo found */
-}
-
-static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * value )
-{
- char *type = PyString_AsString(value);
-
- if(!value)
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if( strcmp( type, "persp" ) == 0 )
- self->camera->type = ( short ) EXPP_CAM_TYPE_PERSP;
- else if( strcmp( type, "ortho" ) == 0 )
- self->camera->type = ( short ) EXPP_CAM_TYPE_ORTHO;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown camera type" );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Camera_oldsetMode( BPy_Camera * self, PyObject * args )
-{
- char *mode_str1 = NULL, *mode_str2 = NULL;
- short flag = 0;
-
- if( !PyArg_ParseTuple( args, "|ss", &mode_str1, &mode_str2 ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected one or two strings as arguments" );
-
- if( mode_str1 != NULL ) {
- if( strcmp( mode_str1, "showLimits" ) == 0 )
- flag |= ( short ) EXPP_CAM_MODE_SHOWLIMITS;
- else if( strcmp( mode_str1, "showMist" ) == 0 )
- flag |= ( short ) EXPP_CAM_MODE_SHOWMIST;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "first argument is an unknown camera flag" );
-
- if( mode_str2 != NULL ) {
- if( strcmp( mode_str2, "showLimits" ) == 0 )
- flag |= ( short ) EXPP_CAM_MODE_SHOWLIMITS;
- else if( strcmp( mode_str2, "showMist" ) == 0 )
- flag |= ( short ) EXPP_CAM_MODE_SHOWMIST;
- else
- return EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "second argument is an unknown camera flag" );
- }
- }
-
- self->camera->flag = flag;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Camera_oldsetLens( BPy_Camera * self, PyObject * value )
-{
- float param = PyFloat_AsDouble(value);
-
- if( !PyFloat_Check(value) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->camera->lens = EXPP_ClampFloat( param,
- EXPP_CAM_LENS_MIN,
- EXPP_CAM_LENS_MAX );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Camera_oldsetScale( BPy_Camera * self, PyObject * value )
-{
- float param = PyFloat_AsDouble(value);
-
- if( !PyFloat_Check(value) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->camera->ortho_scale = EXPP_ClampFloat( param,
- EXPP_CAM_SCALE_MIN,
- EXPP_CAM_SCALE_MAX );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Camera_oldsetClipStart( BPy_Camera * self, PyObject * value )
-{
- float param = PyFloat_AsDouble(value);
-
- if( !PyFloat_Check(value) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->camera->clipsta = EXPP_ClampFloat( param,
- EXPP_CAM_CLIPSTART_MIN,
- EXPP_CAM_CLIPSTART_MAX );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Camera_oldsetClipEnd( BPy_Camera * self, PyObject * value )
-{
- float param = PyFloat_AsDouble(value);
-
- if( !PyFloat_Check(value) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->camera->clipend = EXPP_ClampFloat( param,
- EXPP_CAM_CLIPEND_MIN,
- EXPP_CAM_CLIPEND_MAX );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Camera_oldsetDrawSize( BPy_Camera * self, PyObject * value )
-{
- float param = PyFloat_AsDouble(value);
-
- if( !PyFloat_Check(value) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->camera->drawsize = EXPP_ClampFloat( param,
- EXPP_CAM_DRAWSIZE_MIN,
- EXPP_CAM_DRAWSIZE_MAX );
-
- Py_RETURN_NONE;
-}
-
-/* cam.addScriptLink */
-static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args )
-{
- Camera *cam = self->camera;
- ScriptLink *slink = NULL;
-
- slink = &( cam )->scriptlink;
-
- return EXPP_addScriptLink( slink, args, 0 );
-}
-
-/* cam.clearScriptLinks */
-static PyObject *Camera_clearScriptLinks( BPy_Camera * self, PyObject * args )
-{
- Camera *cam = self->camera;
- ScriptLink *slink = NULL;
-
- slink = &( cam )->scriptlink;
-
- return EXPP_clearScriptLinks( slink, args );
-}
-
-/* cam.getScriptLinks */
-static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * value )
-{
- Camera *cam = self->camera;
- ScriptLink *slink = NULL;
- PyObject *ret = NULL;
-
- slink = &( cam )->scriptlink;
-
- ret = EXPP_getScriptLinks( slink, value, 0 );
-
- if( ret )
- return ret;
- else
- return NULL;
-}
-
-/* cam.__copy__ */
-static PyObject *Camera_copy( BPy_Camera * self )
-{
- PyObject *pycam; /* for Camera Data object wrapper in Python */
- Camera *blcam; /* for actual Camera Data we create in Blender */
-
- blcam = copy_camera( self->camera ); /* first create the Camera Data in Blender */
-
- if( blcam ) /* now create the wrapper obj in Python */
- pycam = Camera_CreatePyObject( blcam );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Camera Data in Blender" );
-
- /* let's return user count to zero, because ... */
- blcam->id.us = 0; /* ... copy_camera() incref'ed it */
- /* XXX XXX Do this in other modules, too */
-
- if( pycam == NULL )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create Camera PyObject" );
-
- return pycam;
-}
-
-static PyObject *Camera_getType( BPy_Camera * self )
-{
- if (self->camera->type == EXPP_CAM_TYPE_PERSP)
- return PyString_FromString("persp");
- else /* must be EXPP_CAM_TYPE_ORTHO */
- return PyString_FromString("ortho");
-}
-
-static int Camera_setType( BPy_Camera * self, PyObject * value )
-{
- char *type = NULL;
- type = PyString_AsString(value);
-
- if (!type)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected a string" );
- if (strcmp("persp", type)==0) {
- self->camera->type = EXPP_CAM_TYPE_PERSP;
- return 0;
- } else if (strcmp("ortho", type)==0) {
- self->camera->type = EXPP_CAM_TYPE_ORTHO;
- return 0;
- }
-
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected a string \"ortho\" or \"persp\"" );
-}
-
-
-
-static PyObject *Camera_getMode( BPy_Camera * self )
-{
- return PyInt_FromLong(self->camera->flag);
-}
-
-static int Camera_setMode( BPy_Camera * self, PyObject * value )
-{
- unsigned int flag = 0;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an integer (bitmask) as argument" );
-
- flag = ( unsigned int )PyInt_AS_LONG( value );
-
- self->camera->flag = flag;
- return 0;
-}
-
-static PyObject *Camera_getIpo( BPy_Camera * self )
-{
- struct Ipo *ipo = self->camera->ipo;
-
- if( ipo )
- return Ipo_CreatePyObject( ipo );
- Py_RETURN_NONE;
-}
-
-static int Camera_setIpo( BPy_Camera * self, PyObject * value )
-{
- return GenericLib_assignData(value, (void **) &self->camera->ipo, 0, 1, ID_IP, ID_CA);
-}
-
-/*
- * get floating point attributes
- */
-
-static PyObject *getFloatAttr( BPy_Camera *self, void *type )
-{
- float param;
- struct Camera *cam= self->camera;
-
- switch( (int)type ) {
- case EXPP_CAM_ATTR_LENS:
- param = cam->lens;
- break;
- case EXPP_CAM_ATTR_ANGLE:
- param = 360.0f * atan(16.0f/cam->lens) / M_PI;
- break;
- case EXPP_CAM_ATTR_DOFDIST:
- param = cam->YF_dofdist;
- break;
- case EXPP_CAM_ATTR_CLIPSTART:
- param = cam->clipsta;
- break;
- case EXPP_CAM_ATTR_CLIPEND:
- param = cam->clipend;
- break;
- case EXPP_CAM_ATTR_DRAWSIZE:
- param = cam->drawsize;
- break;
- case EXPP_CAM_ATTR_SCALE:
- param = cam->ortho_scale;
- break;
- case EXPP_CAM_ATTR_ALPHA:
- param = cam->passepartalpha;
- break;
- case EXPP_CAM_ATTR_SHIFTX:
- param = cam->shiftx;
- break;
- case EXPP_CAM_ATTR_SHIFTY:
- param = cam->shifty;
- break;
-
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type in getFloatAttr" );
- }
-
- return PyFloat_FromDouble( param );
-}
-
-
-
-/*
- * set floating point attributes which require clamping
- */
-
-static int setFloatAttrClamp( BPy_Camera *self, PyObject *value, void *type )
-{
- float *param;
- struct Camera *cam = self->camera;
- float min, max;
- int ret;
-
- switch( (int)type ) {
- case EXPP_CAM_ATTR_LENS:
- min = 1.0;
- max = 250.0;
- param = &cam->lens;
- break;
- case EXPP_CAM_ATTR_ANGLE:
- min = 7.323871;
- max = 172.847331;
- param = &cam->lens;
- break;
- case EXPP_CAM_ATTR_DOFDIST:
- min = 0.0;
- max = 5000.0;
- param = &cam->YF_dofdist;
- break;
- case EXPP_CAM_ATTR_CLIPSTART:
- min = 0.0;
- max = 100.0;
- param = &cam->clipsta;
- break;
- case EXPP_CAM_ATTR_CLIPEND:
- min = 1.0;
- max = 5000.0;
- param = &cam->clipend;
- break;
- case EXPP_CAM_ATTR_DRAWSIZE:
- min = 0.1f;
- max = 10.0;
- param = &cam->drawsize;
- break;
- case EXPP_CAM_ATTR_SCALE:
- min = 0.01f;
- max = 1000.0;
- param = &cam->ortho_scale;
- break;
- case EXPP_CAM_ATTR_ALPHA:
- min = 0.0;
- max = 1.0;
- param = &cam->passepartalpha;
- break;
- case EXPP_CAM_ATTR_SHIFTX:
- min = -2.0;
- max = 2.0;
- param = &cam->shiftx;
- break;
- case EXPP_CAM_ATTR_SHIFTY:
- min = -2.0;
- max = 2.0;
- param = &cam->shifty;
- break;
-
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setFloatAttrClamp" );
- }
-
- ret = EXPP_setFloatClamped( value, param, min, max );
-
- if (ret==0) {
- if ((int)type == EXPP_CAM_ATTR_ANGLE) {
- cam->lens = 16.0f / tan(M_PI*cam->lens/360.0f);
- }
- }
- return ret;
-}
-
-
-/*
- * get floating point attributes
- */
-
-static PyObject *getFlagAttr( BPy_Camera *self, void *type )
-{
- if (self->camera->flag & (int)type)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-/*
- * set floating point attributes which require clamping
- */
-
-static int setFlagAttr( BPy_Camera *self, PyObject *value, void *type )
-{
- int param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if (param)
- self->camera->flag |= (int)type;
- else
- self->camera->flag &= ~(int)type;
- return 0;
-}
-
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Camera_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"type",
- (getter)Camera_getType, (setter)Camera_setType,
- "camera type \"persp\" or \"ortho\"",
- NULL},
- {"mode",
- (getter)Camera_getMode, (setter)Camera_setMode,
- "Cameras mode",
- NULL},
- {"ipo",
- (getter)Camera_getIpo, (setter)Camera_setIpo,
- "Cameras ipo",
- NULL},
-
- /* float settings */
- {"lens",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "lens angle for perspective cameras",
- (void *)EXPP_CAM_ATTR_LENS},
- {"angle",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "lens angle for perspective cameras",
- (void *)EXPP_CAM_ATTR_ANGLE},
-
- {"scale",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "scale for ortho cameras",
- (void *)EXPP_CAM_ATTR_SCALE},
- {"clipStart",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "the cameras clip start",
- (void *)EXPP_CAM_ATTR_CLIPSTART},
- {"clipEnd",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "the cameras clip end",
- (void *)EXPP_CAM_ATTR_CLIPEND},
- {"shiftX",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "the cameras X perspective shift",
- (void *)EXPP_CAM_ATTR_SHIFTX},
- {"shiftY",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "the cameras Y perspective shift",
- (void *)EXPP_CAM_ATTR_SHIFTY},
- {"dofDist",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "cameras dof distance",
- (void *)EXPP_CAM_ATTR_DOFDIST},
- {"drawSize",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "the cameras display size",
- (void *)EXPP_CAM_ATTR_DRAWSIZE},
- {"alpha",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "passepart alpha value for display",
- (void *)EXPP_CAM_ATTR_ALPHA},
-
- /* flags - use flags as defined in DNA_camera_types.h */
- {"drawLimits",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "toggle the draw limits display flag",
- (void *)CAM_SHOWLIMITS},
- {"drawMist",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "toggle the draw mist display flag",
- (void *)CAM_SHOWMIST},
- {"drawName",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "toggle the draw name display flag",
- (void *)CAM_SHOWNAME},
- {"drawTileSafe",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "toggle the tile safe display flag",
- (void *)CAM_SHOWTITLESAFE},
- {"drawPassepartout",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "toggle the passPartOut display flag",
- (void *)CAM_SHOWPASSEPARTOUT},
- {"angleToggle",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "toggle the camera input unit flag",
- (void *)CAM_ANGLETOGGLE},
- {NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-/*****************************************************************************/
-/* Python Camera_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Camera_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Camera", /* char *tp_name; */
- sizeof( BPy_Camera ), /* 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 ) Camera_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Camera_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_Camera_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Camera_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 int Camera_compare( BPy_Camera * a, BPy_Camera * b )
-{
- Camera *pa = a->camera, *pb = b->camera;
- return ( pa == pb ) ? 0 : -1;
-}
-
-static PyObject *Camera_repr( BPy_Camera * self )
-{
- return PyString_FromFormat( "[Camera \"%s\"]",
- self->camera->id.name + 2 );
-}
-
-/*
- * Camera_insertIpoKey()
- * inserts Camera IPO key for LENS and CLIPPING
- */
-
-static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args )
-{
- int key = 0;
-
- if( !PyArg_ParseTuple( args, "i", &( key ) ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
-
- if (key == IPOKEY_LENS){
- insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_LENS, 0);
- }
- else if (key == IPOKEY_CLIPPING){
- insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_STA, 0);
- insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_END, 0);
- }
-
- allspace(REMAKEIPO, 0);
- EXPP_allqueue(REDRAWIPO, 0);
- EXPP_allqueue(REDRAWVIEW3D, 0);
- EXPP_allqueue(REDRAWACTION, 0);
- EXPP_allqueue(REDRAWNLA, 0);
-
- Py_RETURN_NONE;
-}
diff --git a/source/blender/python/api2_2x/Camera.h b/source/blender/python/api2_2x/Camera.h
deleted file mode 100644
index bb751a8849a..00000000000
--- a/source/blender/python/api2_2x/Camera.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Constraint.c b/source/blender/python/api2_2x/Constraint.c
deleted file mode 100644
index 51dbe6a85f9..00000000000
--- a/source/blender/python/api2_2x/Constraint.c
+++ /dev/null
@@ -1,2692 +0,0 @@
-/*
- * $Id: Constraint.c 12705 2007-11-28 12:42:36Z ton $
- *
- * ***** 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, Joshua Leung
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Constraint.h" /*This must come first*/
-
-#include "DNA_object_types.h"
-#include "DNA_effect_types.h"
-#include "DNA_vec_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_text_types.h"
-
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_action.h"
-#include "BKE_armature.h"
-#include "BKE_constraint.h"
-#include "BLI_blenlib.h"
-#include "BIF_editconstraint.h"
-#include "BSE_editipo.h"
-#include "MEM_guardedalloc.h"
-#include "butspace.h"
-#include "blendef.h"
-#include "mydevice.h"
-
-#include "IDProp.h"
-#include "Object.h"
-#include "NLA.h"
-#include "Text.h"
-#include "gen_utils.h"
-
-enum constraint_constants {
- EXPP_CONSTR_XROT = 0,
- EXPP_CONSTR_YROT = 1,
- EXPP_CONSTR_ZROT = 2,
- EXPP_CONSTR_XSIZE = 10,
- EXPP_CONSTR_YSIZE = 11,
- EXPP_CONSTR_ZSIZE = 12,
- EXPP_CONSTR_XLOC = 20,
- EXPP_CONSTR_YLOC = 21,
- EXPP_CONSTR_ZLOC = 22,
-
- EXPP_CONSTR_MAXX = TRACK_X,
- EXPP_CONSTR_MAXY = TRACK_Y,
- EXPP_CONSTR_MAXZ = TRACK_Z,
- EXPP_CONSTR_MINX = TRACK_nX,
- EXPP_CONSTR_MINY = TRACK_nY,
- EXPP_CONSTR_MINZ = TRACK_nZ,
-
- EXPP_CONSTR_TARGET = 100,
- EXPP_CONSTR_STRETCH,
- EXPP_CONSTR_ITERATIONS,
- EXPP_CONSTR_BONE,
- EXPP_CONSTR_CHAINLEN,
- EXPP_CONSTR_POSWEIGHT,
- EXPP_CONSTR_ROTWEIGHT,
- EXPP_CONSTR_ROTATE,
- EXPP_CONSTR_USETIP,
-
- EXPP_CONSTR_ACTION,
- EXPP_CONSTR_START,
- EXPP_CONSTR_END,
- EXPP_CONSTR_MIN,
- EXPP_CONSTR_MAX,
- EXPP_CONSTR_KEYON,
-
- EXPP_CONSTR_TRACK,
- EXPP_CONSTR_UP,
-
- EXPP_CONSTR_RESTLENGTH,
- EXPP_CONSTR_VOLVARIATION,
- EXPP_CONSTR_VOLUMEMODE,
- EXPP_CONSTR_PLANE,
-
- EXPP_CONSTR_FOLLOW,
- EXPP_CONSTR_OFFSET,
- EXPP_CONSTR_FORWARD,
-
- EXPP_CONSTR_LOCK,
-
- EXPP_CONSTR_MINMAX,
- EXPP_CONSTR_STICKY,
-
- EXPP_CONSTR_COPY,
- EXPP_CONSTR_LIMIT,
- EXPP_CONSTR_CLAMP,
-
- EXPP_CONSTR_LIMXMIN = LIMIT_XMIN,
- EXPP_CONSTR_LIMXMAX = LIMIT_XMAX,
- EXPP_CONSTR_LIMYMIN = LIMIT_YMIN,
- EXPP_CONSTR_LIMYMAX = LIMIT_YMAX,
- EXPP_CONSTR_LIMZMIN = LIMIT_ZMIN,
- EXPP_CONSTR_LIMZMAX = LIMIT_ZMAX,
-
- EXPP_CONSTR_LIMXROT = LIMIT_XROT,
- EXPP_CONSTR_LIMYROT = LIMIT_YROT,
- EXPP_CONSTR_LIMZROT = LIMIT_ZROT,
-
- EXPP_CONSTR_CLAMPCYCLIC,
-
- EXPP_CONSTR_XMIN,
- EXPP_CONSTR_XMAX,
- EXPP_CONSTR_YMIN,
- EXPP_CONSTR_YMAX,
- EXPP_CONSTR_ZMIN,
- EXPP_CONSTR_ZMAX,
-
- EXPP_CONSTR_SCRIPT,
- EXPP_CONSTR_PROPS,
-
- EXPP_CONSTR_FROM,
- EXPP_CONSTR_TO,
- EXPP_CONSTR_EXPO,
- EXPP_CONSTR_FROMMINX,
- EXPP_CONSTR_FROMMAXX,
- EXPP_CONSTR_FROMMINY,
- EXPP_CONSTR_FROMMAXY,
- EXPP_CONSTR_FROMMINZ,
- EXPP_CONSTR_FROMMAXZ,
- EXPP_CONSTR_TOMINX,
- EXPP_CONSTR_TOMAXX,
- EXPP_CONSTR_TOMINY,
- EXPP_CONSTR_TOMAXY,
- EXPP_CONSTR_TOMINZ,
- EXPP_CONSTR_TOMAXZ,
- EXPP_CONSTR_MAPX,
- EXPP_CONSTR_MAPY,
- EXPP_CONSTR_MAPZ,
-
- EXPP_CONSTR_OWNSPACE,
- EXPP_CONSTR_TARSPACE,
-
- EXPP_CONSTR_RB_TYPE,
- EXPP_CONSTR_RB_BALL,
- EXPP_CONSTR_RB_HINGE,
- EXPP_CONSTR_RB_GENERIC6DOF,
- EXPP_CONSTR_RB_VEHICLE,
- EXPP_CONSTR_RB_PIVX,
- EXPP_CONSTR_RB_PIVY,
- EXPP_CONSTR_RB_PIVZ,
- EXPP_CONSTR_RB_AXX,
- EXPP_CONSTR_RB_AXY,
- EXPP_CONSTR_RB_AXZ,
- EXPP_CONSTR_RB_MINLIMIT0,
- EXPP_CONSTR_RB_MINLIMIT1,
- EXPP_CONSTR_RB_MINLIMIT2,
- EXPP_CONSTR_RB_MINLIMIT3,
- EXPP_CONSTR_RB_MINLIMIT4,
- EXPP_CONSTR_RB_MINLIMIT5,
- EXPP_CONSTR_RB_MAXLIMIT0,
- EXPP_CONSTR_RB_MAXLIMIT1,
- EXPP_CONSTR_RB_MAXLIMIT2,
- EXPP_CONSTR_RB_MAXLIMIT3,
- EXPP_CONSTR_RB_MAXLIMIT4,
- EXPP_CONSTR_RB_MAXLIMIT5,
- EXPP_CONSTR_RB_EXTRAFZ,
- EXPP_CONSTR_RB_FLAG,
-
-};
-
-/*****************************************************************************/
-/* Python BPy_Constraint methods declarations: */
-/*****************************************************************************/
-static PyObject *Constraint_getName( BPy_Constraint * self );
-static int Constraint_setName( BPy_Constraint * self, PyObject *arg );
-static PyObject *Constraint_getType( BPy_Constraint * self );
-static PyObject *Constraint_getInfluence( BPy_Constraint * self );
-static int Constraint_setInfluence( BPy_Constraint * self, PyObject * arg );
-
-static PyObject *Constraint_insertKey( BPy_Constraint * self, PyObject * arg );
-
-static PyObject *Constraint_getData( BPy_Constraint * self, PyObject * key );
-static int Constraint_setData( BPy_Constraint * self, PyObject * key,
- PyObject * value );
-
-/*****************************************************************************/
-/* Python BPy_Constraint methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Constraint_methods[] = {
- /* name, method, flags, doc */
- {"insertKey", ( PyCFunction ) Constraint_insertKey, METH_O,
- "Insert influence keyframe for constraint"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Constraint attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Constraint_getseters[] = {
- {"name",
- (getter)Constraint_getName, (setter)Constraint_setName,
- "Constraint name", NULL},
- {"type",
- (getter)Constraint_getType, (setter)NULL,
- "Constraint type (read only)", NULL},
- {"influence",
- (getter)Constraint_getInfluence, (setter)Constraint_setInfluence,
- "Constraint influence", NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python Constraint_Type Mapping Methods table: */
-/*****************************************************************************/
-static PyMappingMethods Constraint_as_mapping = {
- NULL, /* mp_length */
- ( binaryfunc ) Constraint_getData, /* mp_subscript */
- ( objobjargproc ) Constraint_setData, /* mp_ass_subscript */
-};
-
-/*****************************************************************************/
-/* Python Constraint_Type callback function prototypes: */
-/*****************************************************************************/
-static PyObject *Constraint_repr( BPy_Constraint * self );
-static int Constraint_compare( BPy_Constraint * a, BPy_Constraint * b );
-
-/*****************************************************************************/
-/* Python Constraint_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Constraint_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Constraint", /* char *tp_name; */
- sizeof( BPy_Constraint ), /* 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 ) Constraint_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Constraint_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- NULL, /* PySequenceMethods *tp_as_sequence; */
- &Constraint_as_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 */
- NULL, /* getiterfunc tp_iter; */
- NULL, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_Constraint_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Constraint_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
-};
-
-/*****************************************************************************/
-/* Python BPy_Constraint methods: */
-/*****************************************************************************/
-
-/*
- * return the name of this constraint
- */
-
-static PyObject *Constraint_getName( BPy_Constraint * self )
-{
- if( !self->con )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This constraint has been removed!" );
-
- return PyString_FromString( self->con->name );
-}
-
-/*
- * set the name of this constraint
- */
-
-static int Constraint_setName( BPy_Constraint * self, PyObject * attr )
-{
- char *name = PyString_AsString( attr );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected string arg" );
-
- if( !self->con )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This constraint has been removed!" );
-
- BLI_strncpy( self->con->name, name, sizeof( self->con->name ) );
-
- return 0;
-}
-
-/*
- * return the influence of this constraint
- */
-
-static PyObject *Constraint_getInfluence( BPy_Constraint * self )
-{
- if( !self->con )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This constraint has been removed!" );
-
- return PyFloat_FromDouble( (double)self->con->enforce );
-}
-
-/*
- * set the influence of this constraint
- */
-
-static int Constraint_setInfluence( BPy_Constraint * self, PyObject * value )
-{
- if( !self->con )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This constraint has been removed!" );
-
- return EXPP_setFloatClamped( value, &self->con->enforce, 0.0, 1.0 );
-}
-
-/*
- * return the type of this constraint
- */
-
-static PyObject *Constraint_getType( BPy_Constraint * self )
-{
- if( !self->con )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This constraint has been removed!" );
-
- return PyInt_FromLong( self->con->type );
-}
-
-/*
- * add keyframe for influence
- base on code in add_influence_key_to_constraint_func()
- */
-static PyObject *Constraint_insertKey( BPy_Constraint * self, PyObject * value )
-{
- bConstraint *con = self->con;
- Object *ob = self->obj;
- bPoseChannel *pchan = self->pchan;
- IpoCurve *icu;
- float cfra = (float)PyFloat_AsDouble(value);
- char actname[32] = "";
-
- if( !self->con )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This constraint has been removed!" );
-
- /* get frame for inserting key */
- if( PyFloat_Check(value) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float argument" );
-
- /* find actname for locating that action-channel that a constraint channel should be added to */
- if (ob) {
- if (pchan) {
- /* actname is the name of the pchan that this constraint belongs to */
- BLI_strncpy(actname, pchan->name, 32);
- }
- else {
- /* hardcoded achan name -> "Object" (this may change in future) */
- strcpy(actname, "Object");
- }
- }
- else {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "constraint doesn't belong to anything" );
- }
- icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, NULL, CO_ENFORCE);
-
- if (!icu)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot get a curve from this IPO, may be using libdata" );
-
- if( ob->action )
- insert_vert_icu( icu, get_action_frame(ob, cfra), con->enforce, 0);
- else
- insert_vert_icu( icu, cfra, con->enforce, 0);
-
- Py_RETURN_NONE;
-}
-
-/******************************************************************************/
-/* Constraint Space Conversion get/set procedures */
-/* - These are called before/instead of individual constraint */
-/* get/set procedures when OWNERSPACE or TARGETSPACE are chosen */
-/* - They are only called from Constraint_g/setData */
-/******************************************************************************/
-
-static PyObject *constspace_getter( BPy_Constraint * self, int type )
-{
- bConstraint *con= (bConstraint *)(self->con);
-
- /* depends on type being asked for
- * NOTE: not all constraints support all space types
- */
- if (type == EXPP_CONSTR_OWNSPACE) {
- switch (con->type) {
- /* all of these support this... */
- case CONSTRAINT_TYPE_PYTHON:
- case CONSTRAINT_TYPE_LOCLIKE:
- case CONSTRAINT_TYPE_ROTLIKE:
- case CONSTRAINT_TYPE_SIZELIKE:
- case CONSTRAINT_TYPE_TRACKTO:
- case CONSTRAINT_TYPE_LOCLIMIT:
- case CONSTRAINT_TYPE_ROTLIMIT:
- case CONSTRAINT_TYPE_SIZELIMIT:
- case CONSTRAINT_TYPE_TRANSFORM:
- return PyInt_FromLong( (long)con->ownspace );
- }
- }
- else if (type == EXPP_CONSTR_TARSPACE) {
- switch (con->type) {
- /* all of these support this... */
- case CONSTRAINT_TYPE_PYTHON:
- case CONSTRAINT_TYPE_ACTION:
- case CONSTRAINT_TYPE_LOCLIKE:
- case CONSTRAINT_TYPE_ROTLIKE:
- case CONSTRAINT_TYPE_SIZELIKE:
- case CONSTRAINT_TYPE_TRACKTO:
- case CONSTRAINT_TYPE_TRANSFORM:
- return PyInt_FromLong( (long)con->tarspace );
- }
- }
-
- /* raise error if failed */
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
-}
-
-static int constspace_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bConstraint *con= (bConstraint *)(self->con);
-
- /* depends on type being asked for
- * NOTE: not all constraints support all space types
- */
- if (type == EXPP_CONSTR_OWNSPACE) {
- switch (con->type) {
- /* all of these support this... */
- case CONSTRAINT_TYPE_PYTHON:
- case CONSTRAINT_TYPE_LOCLIKE:
- case CONSTRAINT_TYPE_ROTLIKE:
- case CONSTRAINT_TYPE_SIZELIKE:
- case CONSTRAINT_TYPE_TRACKTO:
- case CONSTRAINT_TYPE_LOCLIMIT:
- case CONSTRAINT_TYPE_ROTLIMIT:
- case CONSTRAINT_TYPE_SIZELIMIT:
- case CONSTRAINT_TYPE_TRANSFORM:
- {
- /* only copy depending on ownertype */
- if (self->pchan) {
- return EXPP_setIValueClamped( value, &con->ownspace,
- CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_PARLOCAL, 'h' );
- }
- else {
- return EXPP_setIValueClamped( value, &con->ownspace,
- CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, 'h' );
- }
- }
- break;
- }
- }
- else if (type == EXPP_CONSTR_TARSPACE) {
- switch (con->type) {
- /* all of these support this... */
- case CONSTRAINT_TYPE_PYTHON:
- case CONSTRAINT_TYPE_ACTION:
- case CONSTRAINT_TYPE_LOCLIKE:
- case CONSTRAINT_TYPE_ROTLIKE:
- case CONSTRAINT_TYPE_SIZELIKE:
- case CONSTRAINT_TYPE_TRACKTO:
- case CONSTRAINT_TYPE_TRANSFORM:
- {
- Object *tar;
- char *subtarget;
-
- // FIXME!!!
- //tar= get_constraint_target(con, &subtarget);
- tar = NULL;
- subtarget = NULL;
-
- /* only copy depending on target-type */
- if (tar && subtarget[0]) {
- return EXPP_setIValueClamped( value, &con->tarspace,
- CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_PARLOCAL, 'h' );
- }
- else if (tar) {
- return EXPP_setIValueClamped( value, &con->tarspace,
- CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, 'h' );
- }
- }
- break;
- }
- }
-
- /* raise error if failed */
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
-}
-
-/*****************************************************************************/
-/* Specific constraint get/set procedures */
-/*****************************************************************************/
-
-static PyObject *kinematic_getter( BPy_Constraint * self, int type )
-{
- bKinematicConstraint *con = (bKinematicConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_STRETCH:
- return PyBool_FromLong( (long)( con->flag & CONSTRAINT_IK_STRETCH ) ) ;
- case EXPP_CONSTR_ITERATIONS:
- return PyInt_FromLong( (long)con->iterations );
- case EXPP_CONSTR_CHAINLEN:
- return PyInt_FromLong( (long)con->rootbone );
- case EXPP_CONSTR_POSWEIGHT:
- return PyFloat_FromDouble( (double)con->weight );
- case EXPP_CONSTR_ROTWEIGHT:
- return PyFloat_FromDouble( (double)con->orientweight );
- case EXPP_CONSTR_ROTATE:
- return PyBool_FromLong( (long)( con->flag & CONSTRAINT_IK_ROT ) ) ;
- case EXPP_CONSTR_USETIP:
- return PyBool_FromLong( (long)( con->flag & CONSTRAINT_IK_TIP ) ) ;
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int kinematic_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bKinematicConstraint *con = (bKinematicConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_STRETCH:
- return EXPP_setBitfield( value, &con->flag, CONSTRAINT_IK_STRETCH, 'h' );
- case EXPP_CONSTR_ITERATIONS:
- return EXPP_setIValueClamped( value, &con->iterations, 1, 10000, 'h' );
- case EXPP_CONSTR_CHAINLEN:
- return EXPP_setIValueClamped( value, &con->rootbone, 0, 255, 'i' );
- case EXPP_CONSTR_POSWEIGHT:
- return EXPP_setFloatClamped( value, &con->weight, 0.01f, 1.0 );
- case EXPP_CONSTR_ROTWEIGHT:
- return EXPP_setFloatClamped( value, &con->orientweight, 0.01f, 1.0 );
- case EXPP_CONSTR_ROTATE:
- return EXPP_setBitfield( value, &con->flag, CONSTRAINT_IK_ROT, 'h' );
- case EXPP_CONSTR_USETIP:
- return EXPP_setBitfield( value, &con->flag, CONSTRAINT_IK_TIP, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *action_getter( BPy_Constraint * self, int type )
-{
- bActionConstraint *con = (bActionConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_ACTION:
- return Action_CreatePyObject( con->act );
- case EXPP_CONSTR_START:
- return PyInt_FromLong( (long)con->start );
- case EXPP_CONSTR_END:
- return PyInt_FromLong( (long)con->end );
- case EXPP_CONSTR_MIN:
- return PyFloat_FromDouble( (double)con->min );
- case EXPP_CONSTR_MAX:
- return PyFloat_FromDouble( (double)con->max );
- case EXPP_CONSTR_KEYON:
- return PyInt_FromLong( (long)con->type );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int action_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bActionConstraint *con = (bActionConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_ACTION: {
- bAction *act = (( BPy_Action * )value)->action;
- if( !BPy_Action_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy action argument" );
- con->act = act;
- return 0;
- }
- case EXPP_CONSTR_START:
- return EXPP_setIValueClamped( value, &con->start, 1, MAXFRAME, 'h' );
- case EXPP_CONSTR_END:
- return EXPP_setIValueClamped( value, &con->end, 1, MAXFRAME, 'h' );
- case EXPP_CONSTR_MIN:
- if (con->type < 10)
- return EXPP_setFloatClamped( value, &con->min, -180.0, 180.0 );
- else if (con->type < 20)
- return EXPP_setFloatClamped( value, &con->min, 0.0001, 1000.0 );
- else
- return EXPP_setFloatClamped( value, &con->min, -1000.0, 1000.0 );
- case EXPP_CONSTR_MAX:
- if (con->type < 10)
- return EXPP_setFloatClamped( value, &con->max, -180.0, 180.0 );
- else if (con->type < 20)
- return EXPP_setFloatClamped( value, &con->max, 0.0001, 1000.0 );
- else
- return EXPP_setFloatClamped( value, &con->max, -1000.0, 1000.0 );
- case EXPP_CONSTR_KEYON:
- return EXPP_setIValueRange( value, &con->type,
- EXPP_CONSTR_XROT, EXPP_CONSTR_ZLOC, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *trackto_getter( BPy_Constraint * self, int type )
-{
- bTrackToConstraint *con = (bTrackToConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_TRACK:
- return PyInt_FromLong( (long)con->reserved1 );
- case EXPP_CONSTR_UP:
- return PyInt_FromLong( (long)con->reserved2 );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int trackto_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bTrackToConstraint *con = (bTrackToConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_TRACK:
- return EXPP_setIValueRange( value, &con->reserved1,
- TRACK_X, TRACK_nZ, 'i' );
- case EXPP_CONSTR_UP:
- return EXPP_setIValueRange( value, &con->reserved2,
- UP_X, UP_Z, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *stretchto_getter( BPy_Constraint * self, int type )
-{
- bStretchToConstraint *con = (bStretchToConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_RESTLENGTH:
- return PyFloat_FromDouble( (double)con->orglength );
- case EXPP_CONSTR_VOLVARIATION:
- return PyFloat_FromDouble( (double)con->bulge );
- case EXPP_CONSTR_VOLUMEMODE:
- return PyInt_FromLong( (long)con->volmode );
- case EXPP_CONSTR_PLANE:
- return PyInt_FromLong( (long)con->plane );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int stretchto_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bStretchToConstraint *con = (bStretchToConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_RESTLENGTH:
- return EXPP_setFloatClamped( value, &con->orglength, 0.0, 100.0 );
- case EXPP_CONSTR_VOLVARIATION:
- return EXPP_setFloatClamped( value, &con->bulge, 0.0, 100.0 );
- case EXPP_CONSTR_VOLUMEMODE:
- return EXPP_setIValueRange( value, &con->volmode,
- VOLUME_XZ, NO_VOLUME, 'h' );
- case EXPP_CONSTR_PLANE: {
- int status, oldcode = con->plane;
- status = EXPP_setIValueRange( value, &con->plane,
- PLANE_X, PLANE_Z, 'h' );
- if( !status && con->plane == PLANE_Y ) {
- con->plane = oldcode;
- return EXPP_ReturnIntError( PyExc_ValueError,
- "value must be either PLANEX or PLANEZ" );
- }
- return status;
- }
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *followpath_getter( BPy_Constraint * self, int type )
-{
- bFollowPathConstraint *con = (bFollowPathConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_FOLLOW:
- return PyBool_FromLong( (long)( con->followflag & SELECT ) );
- case EXPP_CONSTR_OFFSET:
- return PyFloat_FromDouble( (double)con->offset );
- case EXPP_CONSTR_FORWARD:
- return PyInt_FromLong( (long)con->trackflag );
- case EXPP_CONSTR_UP:
- return PyInt_FromLong( (long)con->upflag );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int followpath_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bFollowPathConstraint *con = (bFollowPathConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_FOLLOW:
- return EXPP_setBitfield( value, &con->followflag, SELECT, 'i' );
- case EXPP_CONSTR_OFFSET:
- return EXPP_setFloatClamped( value, &con->offset,
- -MAXFRAMEF, MAXFRAMEF );
- case EXPP_CONSTR_FORWARD:
- return EXPP_setIValueRange( value, &con->trackflag,
- TRACK_X, TRACK_nZ, 'i' );
- case EXPP_CONSTR_UP:
- return EXPP_setIValueRange( value, &con->upflag,
- UP_X, UP_Z, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *clampto_getter( BPy_Constraint * self, int type )
-{
- bClampToConstraint *con = (bClampToConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_CLAMP:
- return PyInt_FromLong( (long)con->flag );
- case EXPP_CONSTR_CLAMPCYCLIC:
- return PyBool_FromLong( (long)(con->flag2 & CLAMPTO_CYCLIC) );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int clampto_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bClampToConstraint *con = (bClampToConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_CLAMP:
- return EXPP_setIValueRange( value, &con->flag,
- CLAMPTO_AUTO, CLAMPTO_Z, 'i' );
- case EXPP_CONSTR_CLAMPCYCLIC:
- return EXPP_setBitfield( value, &con->flag2, CLAMPTO_CYCLIC, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-static PyObject *locktrack_getter( BPy_Constraint * self, int type )
-{
- bLockTrackConstraint *con = (bLockTrackConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_TRACK:
- return PyInt_FromLong( (long)con->trackflag );
- case EXPP_CONSTR_LOCK:
- return PyInt_FromLong( (long)con->lockflag );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int locktrack_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bLockTrackConstraint *con = (bLockTrackConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_TRACK:
- return EXPP_setIValueRange( value, &con->trackflag,
- TRACK_X, TRACK_nZ, 'i' );
- case EXPP_CONSTR_LOCK:
- return EXPP_setIValueRange( value, &con->lockflag,
- LOCK_X, LOCK_Z, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *floor_getter( BPy_Constraint * self, int type )
-{
- bMinMaxConstraint *con = (bMinMaxConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_MINMAX:
- return PyInt_FromLong( (long)con->minmaxflag );
- case EXPP_CONSTR_OFFSET:
- return PyFloat_FromDouble( (double)con->offset );
- case EXPP_CONSTR_STICKY:
- return PyBool_FromLong( (long)( con->flag & MINMAX_STICKY ) ) ;
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int floor_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bMinMaxConstraint *con = (bMinMaxConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_MINMAX:
- return EXPP_setIValueRange( value, &con->minmaxflag,
- EXPP_CONSTR_MAXX, EXPP_CONSTR_MINZ, 'i' );
- case EXPP_CONSTR_OFFSET:
- return EXPP_setFloatClamped( value, &con->offset, -100.0, 100.0 );
- case EXPP_CONSTR_STICKY:
- return EXPP_setBitfield( value, &con->flag, MINMAX_STICKY, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *locatelike_getter( BPy_Constraint * self, int type )
-{
- bLocateLikeConstraint *con = (bLocateLikeConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_COPY:
- return PyInt_FromLong( (long)con->flag );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int locatelike_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bLocateLikeConstraint *con = (bLocateLikeConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_COPY:
- return EXPP_setIValueRange( value, &con->flag,
- 0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z | LOCLIKE_X_INVERT | LOCLIKE_Y_INVERT | LOCLIKE_Z_INVERT, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *rotatelike_getter( BPy_Constraint * self, int type )
-{
- bRotateLikeConstraint *con = (bRotateLikeConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_COPY:
- return PyInt_FromLong( (long)con->flag );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int rotatelike_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bRotateLikeConstraint *con = (bRotateLikeConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_COPY:
- return EXPP_setIValueRange( value, &con->flag,
- 0, ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z | ROTLIKE_X_INVERT | ROTLIKE_Y_INVERT | ROTLIKE_Z_INVERT, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *sizelike_getter( BPy_Constraint * self, int type )
-{
- bSizeLikeConstraint *con = (bSizeLikeConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_COPY:
- return PyInt_FromLong( (long)con->flag );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int sizelike_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bSizeLikeConstraint *con = (bSizeLikeConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_COPY:
- return EXPP_setIValueRange( value, &con->flag,
- 0, SIZELIKE_X | SIZELIKE_Y | SIZELIKE_Z, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *loclimit_getter( BPy_Constraint * self, int type)
-{
- bLocLimitConstraint *con = (bLocLimitConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_LIMIT:
- return PyInt_FromLong( (long)con->flag );
- case EXPP_CONSTR_XMIN:
- return PyFloat_FromDouble( (double)con->xmin );
- case EXPP_CONSTR_XMAX:
- return PyFloat_FromDouble( (double)con->xmax );
- case EXPP_CONSTR_YMIN:
- return PyFloat_FromDouble( (double)con->ymin );
- case EXPP_CONSTR_YMAX:
- return PyFloat_FromDouble( (double)con->ymax );
- case EXPP_CONSTR_ZMIN:
- return PyFloat_FromDouble( (double)con->zmin );
- case EXPP_CONSTR_ZMAX:
- return PyFloat_FromDouble( (double)con->zmax );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int loclimit_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bLocLimitConstraint *con = (bLocLimitConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_LIMIT:
- return EXPP_setIValueRange( value, &con->flag, 0,
- LIMIT_XMIN | LIMIT_XMAX | LIMIT_YMIN | LIMIT_YMAX | LIMIT_ZMIN | LIMIT_ZMAX , 'i' );
- case EXPP_CONSTR_XMIN:
- return EXPP_setFloatClamped( value, &con->xmin, -1000.0, 1000.0 );
- case EXPP_CONSTR_XMAX:
- return EXPP_setFloatClamped( value, &con->xmax, -1000.0, 1000.0 );
- case EXPP_CONSTR_YMIN:
- return EXPP_setFloatClamped( value, &con->ymin, -1000.0, 1000.0 );
- case EXPP_CONSTR_YMAX:
- return EXPP_setFloatClamped( value, &con->ymax, -1000.0, 1000.0 );
- case EXPP_CONSTR_ZMIN:
- return EXPP_setFloatClamped( value, &con->zmin, -1000.0, 1000.0 );
- case EXPP_CONSTR_ZMAX:
- return EXPP_setFloatClamped( value, &con->zmax, -1000.0, 1000.0 );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *rotlimit_getter( BPy_Constraint * self, int type )
-{
- bRotLimitConstraint *con = (bRotLimitConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_LIMIT:
- return PyInt_FromLong( (long)con->flag );
- case EXPP_CONSTR_XMIN:
- return PyFloat_FromDouble( (double)con->xmin );
- case EXPP_CONSTR_XMAX:
- return PyFloat_FromDouble( (double)con->xmax );
- case EXPP_CONSTR_YMIN:
- return PyFloat_FromDouble( (double)con->ymin );
- case EXPP_CONSTR_YMAX:
- return PyFloat_FromDouble( (double)con->ymax );
- case EXPP_CONSTR_ZMIN:
- return PyFloat_FromDouble( (double)con->zmin );
- case EXPP_CONSTR_ZMAX:
- return PyFloat_FromDouble( (double)con->zmax );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int rotlimit_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bRotLimitConstraint *con = (bRotLimitConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_LIMIT:
- return EXPP_setIValueRange( value, &con->flag, 0,
- LIMIT_XROT | LIMIT_YROT | LIMIT_ZROT, 'i' );
- case EXPP_CONSTR_XMIN:
- return EXPP_setFloatClamped( value, &con->xmin, -360.0, 360.0 );
- case EXPP_CONSTR_XMAX:
- return EXPP_setFloatClamped( value, &con->xmax, -360.0, 360.0 );
- case EXPP_CONSTR_YMIN:
- return EXPP_setFloatClamped( value, &con->ymin, -360.0, 360.0 );
- case EXPP_CONSTR_YMAX:
- return EXPP_setFloatClamped( value, &con->ymax, -360.0, 360.0 );
- case EXPP_CONSTR_ZMIN:
- return EXPP_setFloatClamped( value, &con->zmin, -360.0, 360.0 );
- case EXPP_CONSTR_ZMAX:
- return EXPP_setFloatClamped( value, &con->zmax, -360.0, 360.0 );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *sizelimit_getter( BPy_Constraint * self, int type)
-{
- bSizeLimitConstraint *con = (bSizeLimitConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_LIMIT:
- return PyInt_FromLong( (long)con->flag );
- case EXPP_CONSTR_XMIN:
- return PyFloat_FromDouble( (double)con->xmin );
- case EXPP_CONSTR_XMAX:
- return PyFloat_FromDouble( (double)con->xmax );
- case EXPP_CONSTR_YMIN:
- return PyFloat_FromDouble( (double)con->ymin );
- case EXPP_CONSTR_YMAX:
- return PyFloat_FromDouble( (double)con->ymax );
- case EXPP_CONSTR_ZMIN:
- return PyFloat_FromDouble( (double)con->zmin );
- case EXPP_CONSTR_ZMAX:
- return PyFloat_FromDouble( (double)con->zmax );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int sizelimit_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bSizeLimitConstraint *con = (bSizeLimitConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_LIMIT:
- return EXPP_setIValueRange( value, &con->flag, 0,
- LIMIT_XMIN | LIMIT_XMAX | LIMIT_YMIN | LIMIT_YMAX | LIMIT_ZMIN | LIMIT_ZMAX, 'i' );
- case EXPP_CONSTR_XMIN:
- return EXPP_setFloatClamped( value, &con->xmin, -1000.0, 1000.0 );
- case EXPP_CONSTR_XMAX:
- return EXPP_setFloatClamped( value, &con->xmax, -1000.0, 1000.0 );
- case EXPP_CONSTR_YMIN:
- return EXPP_setFloatClamped( value, &con->ymin, -1000.0, 1000.0 );
- case EXPP_CONSTR_YMAX:
- return EXPP_setFloatClamped( value, &con->ymax, -1000.0, 1000.0 );
- case EXPP_CONSTR_ZMIN:
- return EXPP_setFloatClamped( value, &con->zmin, -1000.0, 1000.0 );
- case EXPP_CONSTR_ZMAX:
- return EXPP_setFloatClamped( value, &con->zmax, -1000.0, 1000.0 );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *script_getter( BPy_Constraint * self, int type )
-{
- bPythonConstraint *con = (bPythonConstraint *)(self->con->data);
-
- switch( type ) {
- // FIXME!!!
- //case EXPP_CONSTR_TARGET:
- // return Object_CreatePyObject( con->tar );
- //case EXPP_CONSTR_BONE:
- // return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_SCRIPT:
- return Text_CreatePyObject( con->text );
- case EXPP_CONSTR_PROPS:
- return BPy_Wrap_IDProperty( NULL, con->prop, NULL);
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int script_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bPythonConstraint *con = (bPythonConstraint *)(self->con->data);
-
- switch( type ) {
- // FIXME!!!
- //case EXPP_CONSTR_TARGET: {
- // Object *obj = (( BPy_Object * )value)->object;
- // if( !BPy_Object_Check( value ) )
- // return EXPP_ReturnIntError( PyExc_TypeError,
- // "expected BPy object argument" );
- // con->tar = obj;
- // return 0;
- // }
- //case EXPP_CONSTR_BONE: {
- // char *name = PyString_AsString( value );
- // if( !name )
- // return EXPP_ReturnIntError( PyExc_TypeError,
- // "expected string arg" );
- //
- // BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
- //
- // return 0;
- // }
- case EXPP_CONSTR_SCRIPT: {
- Text *text = (( BPy_Text * )value)->text;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy text argument" );
- con->text = text;
- return 0;
- }
- case EXPP_CONSTR_PROPS:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "setting ID-Properties of PyConstraints this way is not supported" );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-
-static PyObject *rigidbody_getter( BPy_Constraint * self, int type)
-{
- bRigidBodyJointConstraint *con = (bRigidBodyJointConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_RB_PIVX:
- return PyFloat_FromDouble( (double)con->pivX );
- case EXPP_CONSTR_RB_PIVY:
- return PyFloat_FromDouble( (double)con->pivY );
- case EXPP_CONSTR_RB_PIVZ:
- return PyFloat_FromDouble( (double)con->pivZ );
- case EXPP_CONSTR_RB_AXX:
- return PyFloat_FromDouble( (double)con->axX );
- case EXPP_CONSTR_RB_AXY:
- return PyFloat_FromDouble( (double)con->axY );
- case EXPP_CONSTR_RB_AXZ:
- return PyFloat_FromDouble( (double)con->axZ );
- case EXPP_CONSTR_RB_MINLIMIT0:
- return PyFloat_FromDouble( (double)con->minLimit[0] );
- case EXPP_CONSTR_RB_MINLIMIT1:
- return PyFloat_FromDouble( (double)con->minLimit[1] );
- case EXPP_CONSTR_RB_MINLIMIT2:
- return PyFloat_FromDouble( (double)con->minLimit[2] );
- case EXPP_CONSTR_RB_MINLIMIT3:
- return PyFloat_FromDouble( (double)con->minLimit[3] );
- case EXPP_CONSTR_RB_MINLIMIT4:
- return PyFloat_FromDouble( (double)con->minLimit[4] );
- case EXPP_CONSTR_RB_MINLIMIT5:
- return PyFloat_FromDouble( (double)con->minLimit[5] );
- case EXPP_CONSTR_RB_MAXLIMIT0:
- return PyFloat_FromDouble( (double)con->maxLimit[0] );
- case EXPP_CONSTR_RB_MAXLIMIT1:
- return PyFloat_FromDouble( (double)con->maxLimit[1] );
- case EXPP_CONSTR_RB_MAXLIMIT2:
- return PyFloat_FromDouble( (double)con->maxLimit[2] );
- case EXPP_CONSTR_RB_MAXLIMIT3:
- return PyFloat_FromDouble( (double)con->maxLimit[3] );
- case EXPP_CONSTR_RB_MAXLIMIT4:
- return PyFloat_FromDouble( (double)con->maxLimit[4] );
- case EXPP_CONSTR_RB_MAXLIMIT5:
- return PyFloat_FromDouble( (double)con->maxLimit[5] );
- case EXPP_CONSTR_RB_EXTRAFZ:
- return PyFloat_FromDouble( (double)con->extraFz );
- case EXPP_CONSTR_LIMIT:
- return PyInt_FromLong( (int)con->flag );
-
- case EXPP_CONSTR_RB_TYPE:
- return PyInt_FromLong( (int)con->type );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-
-static int rigidbody_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bRigidBodyJointConstraint *con = (bRigidBodyJointConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_RB_PIVX:
- return EXPP_setFloatClamped( value, &con->pivX , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_PIVY:
- return EXPP_setFloatClamped( value, &con->pivY , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_PIVZ:
- return EXPP_setFloatClamped( value, &con->pivZ , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_AXX:
- return EXPP_setFloatClamped( value, &con->axX , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_AXY:
- return EXPP_setFloatClamped( value, &con->axY , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_AXZ:
- return EXPP_setFloatClamped( value, &con->axZ , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MINLIMIT0:
- return EXPP_setFloatClamped( value, &con->minLimit[0] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MINLIMIT1:
- return EXPP_setFloatClamped( value, &con->minLimit[1] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MINLIMIT2:
- return EXPP_setFloatClamped( value, &con->minLimit[2] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MINLIMIT3:
- return EXPP_setFloatClamped( value, &con->minLimit[3] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MINLIMIT4:
- return EXPP_setFloatClamped( value, &con->minLimit[4] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MINLIMIT5:
- return EXPP_setFloatClamped( value, &con->minLimit[5] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MAXLIMIT0:
- return EXPP_setFloatClamped( value, &con->maxLimit[0] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MAXLIMIT1:
- return EXPP_setFloatClamped( value, &con->maxLimit[1] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MAXLIMIT2:
- return EXPP_setFloatClamped( value, &con->maxLimit[2] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MAXLIMIT3:
- return EXPP_setFloatClamped( value, &con->maxLimit[3] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MAXLIMIT4:
- return EXPP_setFloatClamped( value, &con->maxLimit[4] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_MAXLIMIT5:
- return EXPP_setFloatClamped( value, &con->maxLimit[5] , -1000.0, 1000.0 );
- case EXPP_CONSTR_RB_EXTRAFZ:
- return EXPP_setFloatClamped( value, &con->extraFz , -1000.0, 1000.0 );
- case EXPP_CONSTR_LIMIT:
- return EXPP_setIValueRange( value, &con->flag, 0,
- LIMIT_XMIN | LIMIT_XMAX | LIMIT_YMIN | LIMIT_YMAX | LIMIT_ZMIN | LIMIT_ZMAX, 'i' );
- case EXPP_CONSTR_RB_TYPE:
- return EXPP_setIValueRange( value, &con->type, 0,
- EXPP_CONSTR_RB_BALL | EXPP_CONSTR_RB_HINGE | EXPP_CONSTR_RB_GENERIC6DOF | EXPP_CONSTR_RB_VEHICLE, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *childof_getter( BPy_Constraint * self, int type )
-{
- bChildOfConstraint *con = (bChildOfConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_COPY:
- return PyInt_FromLong( (long)con->flag );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int childof_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bChildOfConstraint *con = (bChildOfConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_COPY:
- return EXPP_setIValueRange( value, &con->flag,
- 0, CHILDOF_LOCX| CHILDOF_LOCY | CHILDOF_LOCZ | CHILDOF_ROTX | CHILDOF_ROTY | CHILDOF_ROTZ |
- CHILDOF_SIZEX |CHILDOF_SIZEY| CHILDOF_SIZEZ, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *transf_getter( BPy_Constraint * self, int type )
-{
- bTransformConstraint *con = (bTransformConstraint *)(self->con->data);
-
- switch( type ) {
- case EXPP_CONSTR_TARGET:
- return Object_CreatePyObject( con->tar );
- case EXPP_CONSTR_BONE:
- return PyString_FromString( con->subtarget );
- case EXPP_CONSTR_FROM:
- return PyInt_FromLong( (long)con->from );
- case EXPP_CONSTR_TO:
- return PyInt_FromLong( (long)con->to );
- case EXPP_CONSTR_MAPX:
- return PyInt_FromLong( (long)con->map[0] );
- case EXPP_CONSTR_MAPY:
- return PyInt_FromLong( (long)con->map[1] );
- case EXPP_CONSTR_MAPZ:
- return PyInt_FromLong( (long)con->map[2] );
- case EXPP_CONSTR_FROMMINX:
- return PyFloat_FromDouble( (double)con->from_min[0] );
- case EXPP_CONSTR_FROMMAXX:
- return PyFloat_FromDouble( (double)con->from_max[0] );
- case EXPP_CONSTR_FROMMINY:
- return PyFloat_FromDouble( (double)con->from_min[1] );
- case EXPP_CONSTR_FROMMAXY:
- return PyFloat_FromDouble( (double)con->from_max[1] );
- case EXPP_CONSTR_FROMMINZ:
- return PyFloat_FromDouble( (double)con->from_min[2] );
- case EXPP_CONSTR_FROMMAXZ:
- return PyFloat_FromDouble( (double)con->from_max[2] );
- case EXPP_CONSTR_TOMINX:
- return PyFloat_FromDouble( (double)con->to_min[0] );
- case EXPP_CONSTR_TOMAXX:
- return PyFloat_FromDouble( (double)con->to_max[0] );
- case EXPP_CONSTR_TOMINY:
- return PyFloat_FromDouble( (double)con->to_min[1] );
- case EXPP_CONSTR_TOMAXY:
- return PyFloat_FromDouble( (double)con->to_max[1] );
- case EXPP_CONSTR_TOMINZ:
- return PyFloat_FromDouble( (double)con->to_min[2] );
- case EXPP_CONSTR_TOMAXZ:
- return PyFloat_FromDouble( (double)con->to_max[2] );
- case EXPP_CONSTR_EXPO:
- return PyBool_FromLong( (long)con->expo );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int transf_setter( BPy_Constraint *self, int type, PyObject *value )
-{
- bTransformConstraint *con = (bTransformConstraint *)(self->con->data);
- float fmin, fmax, tmin, tmax;
-
- if (con->from == 2) {
- fmin = 0.0001;
- fmax = 1000.0;
- }
- else if (con->from == 1) {
- fmin = -360.0;
- fmax = 360.0;
- }
- else {
- fmin = -1000.0;
- fmax = 1000.0;
- }
-
- if (con->to == 2) {
- tmin = 0.0001;
- tmax = 1000.0;
- }
- else if (con->to == 1) {
- tmin = -360.0;
- tmax = 360.0;
- }
- else {
- tmin = -1000.0;
- tmax = 1000.0;
- }
-
- switch( type ) {
- case EXPP_CONSTR_TARGET: {
- Object *obj = (( BPy_Object * )value)->object;
- if( !BPy_Object_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected BPy object argument" );
- con->tar = obj;
- return 0;
- }
- case EXPP_CONSTR_BONE: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
-
- BLI_strncpy( con->subtarget, name, sizeof( con->subtarget ) );
-
- return 0;
- }
- case EXPP_CONSTR_FROM:
- return EXPP_setIValueClamped( value, &con->from, 0, 3, 'h' );
- case EXPP_CONSTR_TO:
- return EXPP_setIValueClamped( value, &con->to, 0, 3, 'h' );
- case EXPP_CONSTR_MAPX:
- return EXPP_setIValueClamped( value, &con->map[0], 0, 3, 'h' );
- case EXPP_CONSTR_MAPY:
- return EXPP_setIValueClamped( value, &con->map[1], 0, 3, 'h' );
- case EXPP_CONSTR_MAPZ:
- return EXPP_setIValueClamped( value, &con->map[2], 0, 3, 'h' );
- case EXPP_CONSTR_FROMMINX:
- return EXPP_setFloatClamped( value, &con->from_min[0], fmin, fmax );
- case EXPP_CONSTR_FROMMAXX:
- return EXPP_setFloatClamped( value, &con->from_max[0], fmin, fmax );
- case EXPP_CONSTR_FROMMINY:
- return EXPP_setFloatClamped( value, &con->from_min[1], fmin, fmax );
- case EXPP_CONSTR_FROMMAXY:
- return EXPP_setFloatClamped( value, &con->from_max[1], fmin, fmax );
- case EXPP_CONSTR_FROMMINZ:
- return EXPP_setFloatClamped( value, &con->from_min[2], fmin, fmax );
- case EXPP_CONSTR_FROMMAXZ:
- return EXPP_setFloatClamped( value, &con->from_max[2], fmin, fmax );
- case EXPP_CONSTR_TOMINX:
- return EXPP_setFloatClamped( value, &con->to_min[0], tmin, tmax );
- case EXPP_CONSTR_TOMAXX:
- return EXPP_setFloatClamped( value, &con->to_max[0], tmin, tmax );
- case EXPP_CONSTR_TOMINY:
- return EXPP_setFloatClamped( value, &con->to_min[1], tmin, tmax );
- case EXPP_CONSTR_TOMAXY:
- return EXPP_setFloatClamped( value, &con->to_max[1], tmin, tmax );
- case EXPP_CONSTR_TOMINZ:
- return EXPP_setFloatClamped( value, &con->to_min[2], tmin, tmax );
- case EXPP_CONSTR_TOMAXZ:
- return EXPP_setFloatClamped( value, &con->to_max[2], tmin, tmax );
- case EXPP_CONSTR_EXPO:
- return EXPP_setBitfield( value, &con->expo, 1, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-/*
- * get data from a constraint
- */
-
-static PyObject *Constraint_getData( BPy_Constraint * self, PyObject * key )
-{
- int setting;
-
- if( !PyInt_Check( key ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int arg" );
-
- if( !self->con )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This constraint has been removed!" );
-
- setting = PyInt_AsLong( key );
-
- /* bypass doing settings of individual constraints, if we're just doing
- * constraint space access-stuff
- */
- if ((setting==EXPP_CONSTR_OWNSPACE) || (setting==EXPP_CONSTR_TARSPACE)) {
- return constspace_getter( self, setting );
- }
- switch( self->con->type ) {
- case CONSTRAINT_TYPE_NULL:
- Py_RETURN_NONE;
- case CONSTRAINT_TYPE_TRACKTO:
- return trackto_getter( self, setting );
- case CONSTRAINT_TYPE_KINEMATIC:
- return kinematic_getter( self, setting );
- case CONSTRAINT_TYPE_FOLLOWPATH:
- return followpath_getter( self, setting );
- case CONSTRAINT_TYPE_ACTION:
- return action_getter( self, setting );
- case CONSTRAINT_TYPE_LOCKTRACK:
- return locktrack_getter( self, setting );
- case CONSTRAINT_TYPE_STRETCHTO:
- return stretchto_getter( self, setting );
- case CONSTRAINT_TYPE_MINMAX:
- return floor_getter( self, setting );
- case CONSTRAINT_TYPE_LOCLIKE:
- return locatelike_getter( self, setting );
- case CONSTRAINT_TYPE_ROTLIKE:
- return rotatelike_getter( self, setting );
- case CONSTRAINT_TYPE_SIZELIKE:
- return sizelike_getter( self, setting );
- case CONSTRAINT_TYPE_ROTLIMIT:
- return rotlimit_getter( self, setting );
- case CONSTRAINT_TYPE_LOCLIMIT:
- return loclimit_getter( self, setting );
- case CONSTRAINT_TYPE_SIZELIMIT:
- return sizelimit_getter( self, setting );
- case CONSTRAINT_TYPE_RIGIDBODYJOINT:
- return rigidbody_getter( self, setting );
- case CONSTRAINT_TYPE_CLAMPTO:
- return clampto_getter( self, setting );
- case CONSTRAINT_TYPE_PYTHON:
- return script_getter( self, setting );
- case CONSTRAINT_TYPE_CHILDOF:
- return childof_getter( self, setting );
- case CONSTRAINT_TYPE_TRANSFORM:
- return transf_getter( self, setting );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError,
- "unknown constraint type" );
- }
-}
-
-static int Constraint_setData( BPy_Constraint * self, PyObject * key,
- PyObject * arg )
-{
- int key_int, result;
-
- if( !PyNumber_Check( key ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an int arg" );
- if( !self->con )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This constraint has been removed!" );
-
- key_int = PyInt_AsLong( key );
-
- /* bypass doing settings of individual constraints, if we're just doing
- * constraint space access-stuff
- */
- if ((key_int==EXPP_CONSTR_OWNSPACE) || (key_int==EXPP_CONSTR_TARSPACE)) {
- result = constspace_setter( self, key_int, arg );
- }
- else {
- switch( self->con->type ) {
- case CONSTRAINT_TYPE_KINEMATIC:
- result = kinematic_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_ACTION:
- result = action_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_TRACKTO:
- result = trackto_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_STRETCHTO:
- result = stretchto_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_FOLLOWPATH:
- result = followpath_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_LOCKTRACK:
- result = locktrack_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_MINMAX:
- result = floor_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_LOCLIKE:
- result = locatelike_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_ROTLIKE:
- result = rotatelike_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_SIZELIKE:
- result = sizelike_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_ROTLIMIT:
- result = rotlimit_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_LOCLIMIT:
- result = loclimit_setter( self, key_int, arg );
- break;
- case CONSTRAINT_TYPE_SIZELIMIT:
- result = sizelimit_setter( self, key_int, arg);
- break;
- case CONSTRAINT_TYPE_RIGIDBODYJOINT:
- result = rigidbody_setter( self, key_int, arg);
- break;
- case CONSTRAINT_TYPE_CLAMPTO:
- result = clampto_setter( self, key_int, arg);
- break;
- case CONSTRAINT_TYPE_PYTHON:
- result = script_setter( self, key_int, arg);
- break;
- case CONSTRAINT_TYPE_CHILDOF:
- result = childof_setter( self, key_int, arg);
- break;
- case CONSTRAINT_TYPE_TRANSFORM:
- result = transf_setter( self, key_int, arg);
- break;
- case CONSTRAINT_TYPE_NULL:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "unsupported constraint setting" );
- }
- }
- if( !result && self->pchan )
- update_pose_constraint_flags( self->obj->pose );
- return result;
-}
-
-/*****************************************************************************/
-/* Function: Constraint_compare */
-/* Description: This compares 2 constraint python types, == or != only. */
-/*****************************************************************************/
-static int Constraint_compare( BPy_Constraint * a, BPy_Constraint * b )
-{
- return ( a->con == b->con ) ? 0 : -1;
-}
-
-/*****************************************************************************/
-/* Function: Constraint_repr */
-/* Description: This is a callback function for the BPy_Constraint type. It */
-/* builds a meaningful string to represent constraint objects. */
-/*****************************************************************************/
-
-static PyObject *Constraint_repr( BPy_Constraint * self )
-{
- bConstraintTypeInfo *cti;
-
- if (!self->con)
- return PyString_FromString("[Constraint - Removed]");
- else
- cti= constraint_get_typeinfo(self->con);
-
- if (cti) {
- return PyString_FromFormat("[Constraint \"%s\", Type \"%s\"]",
- self->con->name, cti->name);
- }
- else {
- return PyString_FromString("[Constraint \"%s\", Type \"Unknown\"]");
- }
-}
-
-/* Three Python Constraint_Type helper functions needed by the Object module: */
-
-/*****************************************************************************/
-/* Function: Constraint_CreatePyObject */
-/* Description: This function will create a new BPy_Constraint from an */
-/* existing Blender constraint structure. */
-/*****************************************************************************/
-PyObject *Constraint_CreatePyObject( bPoseChannel *pchan, Object *obj,
- bConstraint *con )
-{
- BPy_Constraint *pycon;
- pycon = ( BPy_Constraint * ) PyObject_NEW( BPy_Constraint,
- &Constraint_Type );
- if( !pycon )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Constraint object" );
-
- pycon->con = con;
-
- /* one of these two will be NULL */
- pycon->obj = obj;
- pycon->pchan = pchan;
- return ( PyObject * ) pycon;
-}
-
-/*****************************************************************************/
-/* Function: Constraint_FromPyObject */
-/* Description: This function returns the Blender constraint from the given */
-/* PyObject. */
-/*****************************************************************************/
-bConstraint *Constraint_FromPyObject( BPy_Constraint * self )
-{
- return self->con;
-}
-
-/*****************************************************************************/
-/* Constraint Sequence wrapper */
-/*****************************************************************************/
-
-/*
- * Initialize the interator
- */
-
-static PyObject *ConstraintSeq_getIter( BPy_ConstraintSeq * self )
-{
- if( self->pchan )
- self->iter = (bConstraint *)self->pchan->constraints.first;
- else
- self->iter = (bConstraint *)self->obj->constraints.first;
- return EXPP_incr_ret ( (PyObject *) self );
-}
-
-/*
- * Get the next Constraint
- */
-
-static PyObject *ConstraintSeq_nextIter( BPy_ConstraintSeq * self )
-{
- bConstraint *this = self->iter;
- if( this ) {
- self->iter = this->next;
- return Constraint_CreatePyObject( self->pchan, self->obj, this );
- }
-
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
-}
-
-/* return the number of constraints */
-
-static int ConstraintSeq_length( BPy_ConstraintSeq * self )
-{
- return BLI_countlist( self->pchan ?
- &self->pchan->constraints : &self->obj->constraints );
-}
-
-/* return a constraint */
-
-static PyObject *ConstraintSeq_item( BPy_ConstraintSeq * self, int i )
-{
- bConstraint *con = NULL;
-
- /* if index is negative, start counting from the end of the list */
- if( i < 0 )
- i += ConstraintSeq_length( self );
-
- /* skip through the list until we get the constraint or end of list */
-
- if( self->pchan )
- con = self->pchan->constraints.first;
- else
- con = self->obj->constraints.first;
-
- while( i && con ) {
- --i;
- con = con->next;
- }
-
- if( con )
- return Constraint_CreatePyObject( self->pchan, self->obj, con );
- else
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-}
-
-/*****************************************************************************/
-/* Python BPy_ConstraintSeq sequence table: */
-/*****************************************************************************/
-static PySequenceMethods ConstraintSeq_as_sequence = {
- ( inquiry ) ConstraintSeq_length, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) ConstraintSeq_item, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- ( objobjproc ) 0, /* sq_contains */
- ( binaryfunc ) 0, /* sq_inplace_concat */
- ( intargfunc ) 0, /* sq_inplace_repeat */
-};
-
-/*
- * helper function to check for a valid constraint argument
- */
-
-static bConstraint *locate_constr( BPy_ConstraintSeq *self, BPy_Constraint * value )
-{
- bConstraint *con;
-
- /* check that argument is a modifier */
- if (!BPy_Constraint_Check(value))
- return (bConstraint *)EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a constraint as an argument" );
-
- /* check whether constraint has been removed */
- if( !value->con )
- return (bConstraint *)EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This constraint has been removed!" );
-
- /* verify the constraint is still exists in the stack */
- if( self->pchan )
- con = self->pchan->constraints.first;
- else
- con = self->obj->constraints.first;
- while( con && con != value->con )
- con = con->next;
-
- /* if we didn't find it, exception */
- if( !con )
- return (bConstraint *)EXPP_ReturnPyObjError( PyExc_AttributeError,
- "This constraint is no longer in the object's stack" );
-
- return con;
-}
-
-
-/* create a new constraint at the end of the list */
-
-static PyObject *ConstraintSeq_append( BPy_ConstraintSeq *self, PyObject *value )
-{
- int type = (int)PyInt_AsLong(value);
- bConstraint *con;
-
- /* type 0 is CONSTRAINT_TYPE_NULL, should we be able to add one of these?
- * if the value is not an int it will be -1 */
- if( type < CONSTRAINT_TYPE_NULL || type > CONSTRAINT_TYPE_RIGIDBODYJOINT )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "arg not in int or out of range" );
-
- con = add_new_constraint( type );
- if( self->pchan ) {
- BLI_addtail( &self->pchan->constraints, con );
- update_pose_constraint_flags( self->obj->pose );
- }
- else
- BLI_addtail( &self->obj->constraints, con );
-
- return Constraint_CreatePyObject( self->pchan, self->obj, con );
-}
-
-/* move the constraint up in the stack */
-
-static PyObject *ConstraintSeq_moveUp( BPy_ConstraintSeq *self, BPy_Constraint *value )
-{
- bConstraint *con = locate_constr( self, value );
-
- /* if we can't locate the constraint, return (exception already set) */
- if( !con )
- return (PyObject *)NULL;
-
- const_moveUp( self->obj, con );
- Py_RETURN_NONE;
-}
-
-/* move the constraint down in the stack */
-
-static PyObject *ConstraintSeq_moveDown( BPy_ConstraintSeq *self, BPy_Constraint *value )
-{
- bConstraint *con = locate_constr( self, value );
-
- /* if we can't locate the constraint, return (exception already set) */
- if( !con )
- return (PyObject *)NULL;
-
- const_moveDown( self->obj, con );
- Py_RETURN_NONE;
-}
-
-/* remove an existing constraint */
-
-static PyObject *ConstraintSeq_remove( BPy_ConstraintSeq *self, BPy_Constraint *value )
-{
- bConstraint *con = locate_constr( self, value );
-
- /* if we can't locate the constraint, return (exception already set) */
- if( !con )
- return (PyObject *)NULL;
-
- /* do the actual removal */
- if( self->pchan )
- BLI_remlink( &self->pchan->constraints, con );
- else
- BLI_remlink( &self->obj->constraints, con);
- del_constr_func( self->obj, con );
-
- /* erase the link to the constraint */
- value->con = NULL;
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: ConstraintSeq_dealloc */
-/* Description: This is a callback function for the BPy_ConstraintSeq type. */
-/* It destroys data when the object is deleted. */
-/*****************************************************************************/
-static void ConstraintSeq_dealloc( BPy_Constraint * self )
-{
- PyObject_DEL( self );
-}
-
-/*****************************************************************************/
-/* Python BPy_ConstraintSeq methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_ConstraintSeq_methods[] = {
- /* name, method, flags, doc */
- {"append", ( PyCFunction ) ConstraintSeq_append, METH_O,
- "(type) - add a new constraint, where type is the constraint type"},
- {"remove", ( PyCFunction ) ConstraintSeq_remove, METH_O,
- "(con) - remove an existing constraint, where con is a constraint from this object."},
- {"moveUp", ( PyCFunction ) ConstraintSeq_moveUp, METH_O,
- "(con) - Move constraint up in stack"},
- {"moveDown", ( PyCFunction ) ConstraintSeq_moveDown, METH_O,
- "(con) - Move constraint down in stack"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python ConstraintSeq_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject ConstraintSeq_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.Constraints", /* char *tp_name; */
- sizeof( BPy_ConstraintSeq ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) ConstraintSeq_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- NULL, /* cmpfunc tp_compare; */
- ( reprfunc ) NULL, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &ConstraintSeq_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 )ConstraintSeq_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc )ConstraintSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_ConstraintSeq_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
-};
-
-/*****************************************************************************/
-/* Function: PoseConstraintSeq_CreatePyObject */
-/* Description: This function will create a new BPy_ConstraintSeq from an */
-/* existing ListBase structure. */
-/*****************************************************************************/
-PyObject *PoseConstraintSeq_CreatePyObject( bPoseChannel *pchan )
-{
- BPy_ConstraintSeq *pyseq;
- Object *ob;
-
- for( ob = G.main->object.first; ob; ob = ob->id.next ) {
- if( ob->type == OB_ARMATURE ) {
- bPoseChannel *p = ob->pose->chanbase.first;
- while( p ) {
- if( p == pchan ) {
- pyseq = ( BPy_ConstraintSeq * ) PyObject_NEW(
- BPy_ConstraintSeq, &ConstraintSeq_Type );
- if( !pyseq )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_ConstraintSeq object" );
- pyseq->pchan = pchan;
- pyseq->obj = ob;
- return ( PyObject * ) pyseq;
- } else
- p = p->next;
- }
- }
- }
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't find ANY armature with the pose!" );
-
-}
-
-/*****************************************************************************/
-/* Function: ObConstraintSeq_CreatePyObject */
-/* Description: This function will create a new BPy_ConstraintSeq from an */
-/* existing ListBase structure. */
-/*****************************************************************************/
-PyObject *ObConstraintSeq_CreatePyObject( Object *obj )
-{
- BPy_ConstraintSeq *pyseq;
- pyseq = ( BPy_ConstraintSeq * ) PyObject_NEW( BPy_ConstraintSeq,
- &ConstraintSeq_Type );
- if( !pyseq )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_ConstraintSeq object" );
- pyseq->obj = obj;
- pyseq->pchan = NULL;
- return ( PyObject * ) pyseq;
-}
-
-static PyObject *M_Constraint_TypeDict( void )
-{
- PyObject *S = PyConstant_New( );
-
- if( S ) {
- BPy_constant *d = ( BPy_constant * ) S;
- PyConstant_Insert( d, "NULL",
- PyInt_FromLong( CONSTRAINT_TYPE_NULL ) );
- PyConstant_Insert( d, "TRACKTO",
- PyInt_FromLong( CONSTRAINT_TYPE_TRACKTO ) );
- PyConstant_Insert( d, "IKSOLVER",
- PyInt_FromLong( CONSTRAINT_TYPE_KINEMATIC ) );
- PyConstant_Insert( d, "FOLLOWPATH",
- PyInt_FromLong( CONSTRAINT_TYPE_FOLLOWPATH ) );
- PyConstant_Insert( d, "COPYROT",
- PyInt_FromLong( CONSTRAINT_TYPE_ROTLIKE ) );
- PyConstant_Insert( d, "COPYLOC",
- PyInt_FromLong( CONSTRAINT_TYPE_LOCLIKE ) );
- PyConstant_Insert( d, "COPYSIZE",
- PyInt_FromLong( CONSTRAINT_TYPE_SIZELIKE ) );
- PyConstant_Insert( d, "ACTION",
- PyInt_FromLong( CONSTRAINT_TYPE_ACTION ) );
- PyConstant_Insert( d, "LOCKTRACK",
- PyInt_FromLong( CONSTRAINT_TYPE_LOCKTRACK ) );
- PyConstant_Insert( d, "STRETCHTO",
- PyInt_FromLong( CONSTRAINT_TYPE_STRETCHTO ) );
- PyConstant_Insert( d, "FLOOR",
- PyInt_FromLong( CONSTRAINT_TYPE_MINMAX ) );
- PyConstant_Insert( d, "LIMITLOC",
- PyInt_FromLong( CONSTRAINT_TYPE_LOCLIMIT ) );
- PyConstant_Insert( d, "LIMITROT",
- PyInt_FromLong( CONSTRAINT_TYPE_ROTLIMIT ) );
- PyConstant_Insert( d, "LIMITSIZE",
- PyInt_FromLong( CONSTRAINT_TYPE_SIZELIMIT ) );
- PyConstant_Insert( d, "RIGIDBODYJOINT",
- PyInt_FromLong( CONSTRAINT_TYPE_RIGIDBODYJOINT ) );
- PyConstant_Insert( d, "CLAMPTO",
- PyInt_FromLong( CONSTRAINT_TYPE_CLAMPTO ) );
- PyConstant_Insert( d, "PYTHON",
- PyInt_FromLong( CONSTRAINT_TYPE_PYTHON ) );
- PyConstant_Insert( d, "CHILDOF",
- PyInt_FromLong( CONSTRAINT_TYPE_CHILDOF ) );
- PyConstant_Insert( d, "TRANSFORM",
- PyInt_FromLong( CONSTRAINT_TYPE_TRANSFORM ) );
- }
- return S;
-}
-
-static PyObject *M_Constraint_SettingsDict( void )
-{
- PyObject *S = PyConstant_New( );
-
- if( S ) {
- BPy_constant *d = ( BPy_constant * ) S;
- PyConstant_Insert( d, "XROT",
- PyInt_FromLong( EXPP_CONSTR_XROT ) );
- PyConstant_Insert( d, "YROT",
- PyInt_FromLong( EXPP_CONSTR_YROT ) );
- PyConstant_Insert( d, "ZROT",
- PyInt_FromLong( EXPP_CONSTR_ZROT ) );
- PyConstant_Insert( d, "XSIZE",
- PyInt_FromLong( EXPP_CONSTR_XSIZE ) );
- PyConstant_Insert( d, "YSIZE",
- PyInt_FromLong( EXPP_CONSTR_YSIZE ) );
- PyConstant_Insert( d, "ZSIZE",
- PyInt_FromLong( EXPP_CONSTR_ZSIZE ) );
- PyConstant_Insert( d, "XLOC",
- PyInt_FromLong( EXPP_CONSTR_XLOC ) );
- PyConstant_Insert( d, "YLOC",
- PyInt_FromLong( EXPP_CONSTR_YLOC ) );
- PyConstant_Insert( d, "ZLOC",
- PyInt_FromLong( EXPP_CONSTR_ZLOC ) );
-
- PyConstant_Insert( d, "UPX",
- PyInt_FromLong( UP_X ) );
- PyConstant_Insert( d, "UPY",
- PyInt_FromLong( UP_Y ) );
- PyConstant_Insert( d, "UPZ",
- PyInt_FromLong( UP_Z ) );
-
- PyConstant_Insert( d, "TRACKX",
- PyInt_FromLong( TRACK_X ) );
- PyConstant_Insert( d, "TRACKY",
- PyInt_FromLong( TRACK_Y ) );
- PyConstant_Insert( d, "TRACKZ",
- PyInt_FromLong( TRACK_Z ) );
- PyConstant_Insert( d, "TRACKNEGX",
- PyInt_FromLong( TRACK_nX ) );
- PyConstant_Insert( d, "TRACKNEGY",
- PyInt_FromLong( TRACK_nY ) );
- PyConstant_Insert( d, "TRACKNEGZ",
- PyInt_FromLong( TRACK_nZ ) );
-
- PyConstant_Insert( d, "VOLUMEXZ",
- PyInt_FromLong( VOLUME_XZ ) );
- PyConstant_Insert( d, "VOLUMEX",
- PyInt_FromLong( VOLUME_X ) );
- PyConstant_Insert( d, "VOLUMEZ",
- PyInt_FromLong( VOLUME_Z ) );
- PyConstant_Insert( d, "VOLUMENONE",
- PyInt_FromLong( NO_VOLUME ) );
-
- PyConstant_Insert( d, "PLANEX",
- PyInt_FromLong( PLANE_X ) );
- PyConstant_Insert( d, "PLANEY",
- PyInt_FromLong( PLANE_Y ) );
- PyConstant_Insert( d, "PLANEZ",
- PyInt_FromLong( PLANE_Z ) );
-
- PyConstant_Insert( d, "LOCKX",
- PyInt_FromLong( LOCK_X ) );
- PyConstant_Insert( d, "LOCKY",
- PyInt_FromLong( LOCK_Y ) );
- PyConstant_Insert( d, "LOCKZ",
- PyInt_FromLong( LOCK_Z ) );
-
- PyConstant_Insert( d, "MAXX",
- PyInt_FromLong( EXPP_CONSTR_MAXX ) );
- PyConstant_Insert( d, "MAXY",
- PyInt_FromLong( EXPP_CONSTR_MAXY ) );
- PyConstant_Insert( d, "MAXZ",
- PyInt_FromLong( EXPP_CONSTR_MAXZ ) );
- PyConstant_Insert( d, "MINX",
- PyInt_FromLong( EXPP_CONSTR_MINX ) );
- PyConstant_Insert( d, "MINY",
- PyInt_FromLong( EXPP_CONSTR_MINY ) );
- PyConstant_Insert( d, "MINZ",
- PyInt_FromLong( EXPP_CONSTR_MINZ ) );
-
- PyConstant_Insert( d, "COPYX",
- PyInt_FromLong( LOCLIKE_X ) );
- PyConstant_Insert( d, "COPYY",
- PyInt_FromLong( LOCLIKE_Y ) );
- PyConstant_Insert( d, "COPYZ",
- PyInt_FromLong( LOCLIKE_Z ) );
- PyConstant_Insert( d, "COPYXINVERT",
- PyInt_FromLong( LOCLIKE_X_INVERT ) );
- PyConstant_Insert( d, "COPYYINVERT",
- PyInt_FromLong( LOCLIKE_Y_INVERT ) );
- PyConstant_Insert( d, "COPYZINVERT",
- PyInt_FromLong( LOCLIKE_Z_INVERT ) );
-
- PyConstant_Insert( d, "PARLOCX",
- PyInt_FromLong( CHILDOF_LOCX ) );
- PyConstant_Insert( d, "PARLOCY",
- PyInt_FromLong( CHILDOF_LOCY ) );
- PyConstant_Insert( d, "PARLOCZ",
- PyInt_FromLong( CHILDOF_LOCZ ) );
- PyConstant_Insert( d, "PARROTX",
- PyInt_FromLong( CHILDOF_ROTX ) );
- PyConstant_Insert( d, "PARROTY",
- PyInt_FromLong( CHILDOF_ROTY ) );
- PyConstant_Insert( d, "PARROTZ",
- PyInt_FromLong( CHILDOF_ROTZ ) );
- PyConstant_Insert( d, "PARSIZEX",
- PyInt_FromLong( CHILDOF_LOCX ) );
- PyConstant_Insert( d, "PARSIZEY",
- PyInt_FromLong( CHILDOF_SIZEY ) );
- PyConstant_Insert( d, "PARSIZEZ",
- PyInt_FromLong( CHILDOF_SIZEZ ) );
-
- PyConstant_Insert( d, "CLAMPAUTO",
- PyInt_FromLong( CLAMPTO_AUTO ) );
- PyConstant_Insert( d, "CLAMPX",
- PyInt_FromLong( CLAMPTO_X ) );
- PyConstant_Insert( d, "CLAMPY",
- PyInt_FromLong( CLAMPTO_Y ) );
- PyConstant_Insert( d, "CLAMPZ",
- PyInt_FromLong( CLAMPTO_Z ) );
- PyConstant_Insert( d, "CLAMPCYCLIC",
- PyInt_FromLong( EXPP_CONSTR_CLAMPCYCLIC ));
-
- PyConstant_Insert( d, "TARGET",
- PyInt_FromLong( EXPP_CONSTR_TARGET ) );
- PyConstant_Insert( d, "STRETCH",
- PyInt_FromLong( EXPP_CONSTR_STRETCH ) );
- PyConstant_Insert( d, "ITERATIONS",
- PyInt_FromLong( EXPP_CONSTR_ITERATIONS ) );
- PyConstant_Insert( d, "BONE",
- PyInt_FromLong( EXPP_CONSTR_BONE ) );
- PyConstant_Insert( d, "CHAINLEN",
- PyInt_FromLong( EXPP_CONSTR_CHAINLEN ) );
- PyConstant_Insert( d, "POSWEIGHT",
- PyInt_FromLong( EXPP_CONSTR_POSWEIGHT ) );
- PyConstant_Insert( d, "ROTWEIGHT",
- PyInt_FromLong( EXPP_CONSTR_ROTWEIGHT ) );
- PyConstant_Insert( d, "ROTATE",
- PyInt_FromLong( EXPP_CONSTR_ROTATE ) );
- PyConstant_Insert( d, "USETIP",
- PyInt_FromLong( EXPP_CONSTR_USETIP ) );
-
- PyConstant_Insert( d, "ACTION",
- PyInt_FromLong( EXPP_CONSTR_ACTION ) );
- PyConstant_Insert( d, "START",
- PyInt_FromLong( EXPP_CONSTR_START ) );
- PyConstant_Insert( d, "END",
- PyInt_FromLong( EXPP_CONSTR_END ) );
- PyConstant_Insert( d, "MIN",
- PyInt_FromLong( EXPP_CONSTR_MIN ) );
- PyConstant_Insert( d, "MAX",
- PyInt_FromLong( EXPP_CONSTR_MAX ) );
- PyConstant_Insert( d, "KEYON",
- PyInt_FromLong( EXPP_CONSTR_KEYON ) );
-
- PyConstant_Insert( d, "TRACK",
- PyInt_FromLong( EXPP_CONSTR_TRACK ) );
- PyConstant_Insert( d, "UP",
- PyInt_FromLong( EXPP_CONSTR_UP ) );
-
- PyConstant_Insert( d, "RESTLENGTH",
- PyInt_FromLong( EXPP_CONSTR_RESTLENGTH ) );
- PyConstant_Insert( d, "VOLVARIATION",
- PyInt_FromLong( EXPP_CONSTR_VOLVARIATION ) );
- PyConstant_Insert( d, "VOLUMEMODE",
- PyInt_FromLong( EXPP_CONSTR_VOLUMEMODE ) );
- PyConstant_Insert( d, "PLANE",
- PyInt_FromLong( EXPP_CONSTR_PLANE ) );
-
- PyConstant_Insert( d, "FOLLOW",
- PyInt_FromLong( EXPP_CONSTR_FOLLOW ) );
- PyConstant_Insert( d, "OFFSET",
- PyInt_FromLong( EXPP_CONSTR_OFFSET ) );
- PyConstant_Insert( d, "FORWARD",
- PyInt_FromLong( EXPP_CONSTR_FORWARD ) );
-
- PyConstant_Insert( d, "LOCK",
- PyInt_FromLong( EXPP_CONSTR_LOCK ) );
-
- PyConstant_Insert( d, "COPY",
- PyInt_FromLong( EXPP_CONSTR_COPY ) );
- PyConstant_Insert( d, "LIMIT",
- PyInt_FromLong( EXPP_CONSTR_LIMIT ) );
- PyConstant_Insert( d, "CLAMP",
- PyInt_FromLong( EXPP_CONSTR_CLAMP ) );
-
- PyConstant_Insert( d, "LIMIT_XMIN",
- PyInt_FromLong( EXPP_CONSTR_LIMXMIN ) );
- PyConstant_Insert( d, "LIMIT_XMAX",
- PyInt_FromLong( EXPP_CONSTR_LIMXMAX ) );
- PyConstant_Insert( d, "LIMIT_YMIN",
- PyInt_FromLong( EXPP_CONSTR_LIMYMIN ) );
- PyConstant_Insert( d, "LIMIT_YMAX",
- PyInt_FromLong( EXPP_CONSTR_LIMYMAX ) );
- PyConstant_Insert( d, "LIMIT_ZMIN",
- PyInt_FromLong( EXPP_CONSTR_LIMZMIN ) );
- PyConstant_Insert( d, "LIMIT_ZMAX",
- PyInt_FromLong( EXPP_CONSTR_LIMZMAX ) );
-
- PyConstant_Insert( d, "LIMIT_XROT",
- PyInt_FromLong( EXPP_CONSTR_LIMXROT ) );
- PyConstant_Insert( d, "LIMIT_YROT",
- PyInt_FromLong( EXPP_CONSTR_LIMYROT ) );
- PyConstant_Insert( d, "LIMIT_ZROT",
- PyInt_FromLong( EXPP_CONSTR_LIMZROT ) );
-
- PyConstant_Insert( d, "XMIN",
- PyInt_FromLong( EXPP_CONSTR_XMIN ) );
- PyConstant_Insert( d, "XMAX",
- PyInt_FromLong( EXPP_CONSTR_XMAX ) );
- PyConstant_Insert( d, "YMIN",
- PyInt_FromLong( EXPP_CONSTR_YMIN ) );
- PyConstant_Insert( d, "YMAX",
- PyInt_FromLong( EXPP_CONSTR_YMAX ) );
- PyConstant_Insert( d, "ZMIN",
- PyInt_FromLong( EXPP_CONSTR_ZMIN ) );
- PyConstant_Insert( d, "ZMAX",
- PyInt_FromLong( EXPP_CONSTR_ZMAX ) );
-
- PyConstant_Insert( d, "SCRIPT",
- PyInt_FromLong( EXPP_CONSTR_SCRIPT ) );
- PyConstant_Insert( d, "PROPERTIES",
- PyInt_FromLong( EXPP_CONSTR_PROPS ) );
-
- PyConstant_Insert( d, "FROM",
- PyInt_FromLong( EXPP_CONSTR_FROM ) );
- PyConstant_Insert( d, "TO",
- PyInt_FromLong( EXPP_CONSTR_TO ) );
- PyConstant_Insert( d, "EXTRAPOLATE",
- PyInt_FromLong( EXPP_CONSTR_EXPO ) );
- PyConstant_Insert( d, "MAPX",
- PyInt_FromLong( EXPP_CONSTR_MAPX ) );
- PyConstant_Insert( d, "MAPY",
- PyInt_FromLong( EXPP_CONSTR_MAPY ) );
- PyConstant_Insert( d, "MAPZ",
- PyInt_FromLong( EXPP_CONSTR_MAPZ ) );
- PyConstant_Insert( d, "FROM_MINX",
- PyInt_FromLong( EXPP_CONSTR_FROMMINX ) );
- PyConstant_Insert( d, "FROM_MAXX",
- PyInt_FromLong( EXPP_CONSTR_FROMMAXX ) );
- PyConstant_Insert( d, "FROM_MINY",
- PyInt_FromLong( EXPP_CONSTR_FROMMINY ) );
- PyConstant_Insert( d, "FROM_MAXY",
- PyInt_FromLong( EXPP_CONSTR_FROMMAXY ) );
- PyConstant_Insert( d, "FROM_MINZ",
- PyInt_FromLong( EXPP_CONSTR_FROMMINZ ) );
- PyConstant_Insert( d, "FROM_MAXZ",
- PyInt_FromLong( EXPP_CONSTR_FROMMAXZ ) );
- PyConstant_Insert( d, "TO_MINX",
- PyInt_FromLong( EXPP_CONSTR_TOMINX ) );
- PyConstant_Insert( d, "TO_MAXX",
- PyInt_FromLong( EXPP_CONSTR_TOMAXX ) );
- PyConstant_Insert( d, "TO_MINY",
- PyInt_FromLong( EXPP_CONSTR_TOMINY ) );
- PyConstant_Insert( d, "TO_MAXY",
- PyInt_FromLong( EXPP_CONSTR_TOMAXY ) );
- PyConstant_Insert( d, "TO_MINZ",
- PyInt_FromLong( EXPP_CONSTR_TOMINZ ) );
- PyConstant_Insert( d, "TO_MAXZ",
- PyInt_FromLong( EXPP_CONSTR_TOMAXZ ) );
-
- PyConstant_Insert( d, "LOC",
- PyInt_FromLong( 0 ) );
- PyConstant_Insert( d, "ROT",
- PyInt_FromLong( 1 ) );
- PyConstant_Insert( d, "SCALE",
- PyInt_FromLong( 2 ) );
-
- PyConstant_Insert( d, "CONSTR_RB_TYPE",
- PyInt_FromLong( EXPP_CONSTR_RB_TYPE ) );
- PyConstant_Insert( d, "CONSTR_RB_BALL",
- PyInt_FromLong( EXPP_CONSTR_RB_BALL ) );
- PyConstant_Insert( d, "CONSTR_RB_HINGE",
- PyInt_FromLong( EXPP_CONSTR_RB_HINGE ) );
- PyConstant_Insert( d, "CONSTR_RB_GENERIC6DOF",
- PyInt_FromLong( EXPP_CONSTR_RB_GENERIC6DOF ) );
- PyConstant_Insert( d, "CONSTR_RB_VEHICLE",
- PyInt_FromLong( EXPP_CONSTR_RB_VEHICLE ) );
- PyConstant_Insert( d, "CONSTR_RB_PIVX",
- PyInt_FromLong( EXPP_CONSTR_RB_PIVX ) );
- PyConstant_Insert( d, "CONSTR_RB_PIVY",
- PyInt_FromLong( EXPP_CONSTR_RB_PIVY ) );
- PyConstant_Insert( d, "CONSTR_RB_PIVZ",
- PyInt_FromLong( EXPP_CONSTR_RB_PIVZ ) );
- PyConstant_Insert( d, "CONSTR_RB_AXX",
- PyInt_FromLong( EXPP_CONSTR_RB_AXX ) );
- PyConstant_Insert( d, "CONSTR_RB_AXY",
- PyInt_FromLong( EXPP_CONSTR_RB_AXY ) );
- PyConstant_Insert( d, "CONSTR_RB_AXZ",
- PyInt_FromLong( EXPP_CONSTR_RB_AXZ ) );
- PyConstant_Insert( d, "CONSTR_RB_MINLIMIT0",
- PyInt_FromLong( EXPP_CONSTR_RB_MINLIMIT0 ) );
- PyConstant_Insert( d, "CONSTR_RB_MINLIMIT1",
- PyInt_FromLong( EXPP_CONSTR_RB_MINLIMIT1 ) );
- PyConstant_Insert( d, "CONSTR_RB_MINLIMIT2",
- PyInt_FromLong( EXPP_CONSTR_RB_MINLIMIT2 ) );
- PyConstant_Insert( d, "CONSTR_RB_MINLIMIT3",
- PyInt_FromLong( EXPP_CONSTR_RB_MINLIMIT3 ) );
- PyConstant_Insert( d, "CONSTR_RB_MINLIMIT4",
- PyInt_FromLong( EXPP_CONSTR_RB_MINLIMIT4 ) );
- PyConstant_Insert( d, "CONSTR_RB_MINLIMIT5",
- PyInt_FromLong( EXPP_CONSTR_RB_MINLIMIT5 ) );
- PyConstant_Insert( d, "CONSTR_RB_MAXLIMIT0",
- PyInt_FromLong( EXPP_CONSTR_RB_MAXLIMIT0 ) );
- PyConstant_Insert( d, "CONSTR_RB_MAXLIMIT1",
- PyInt_FromLong( EXPP_CONSTR_RB_MAXLIMIT1 ) );
- PyConstant_Insert( d, "CONSTR_RB_MAXLIMIT2",
- PyInt_FromLong( EXPP_CONSTR_RB_MAXLIMIT2 ) );
- PyConstant_Insert( d, "CONSTR_RB_MAXLIMIT3",
- PyInt_FromLong( EXPP_CONSTR_RB_MAXLIMIT3 ) );
- PyConstant_Insert( d, "CONSTR_RB_MAXLIMIT4",
- PyInt_FromLong( EXPP_CONSTR_RB_MAXLIMIT4 ) );
- PyConstant_Insert( d, "CONSTR_RB_MAXLIMIT5",
- PyInt_FromLong( EXPP_CONSTR_RB_MAXLIMIT5 ) );
- PyConstant_Insert( d, "CONSTR_RB_EXTRAFZ",
- PyInt_FromLong( EXPP_CONSTR_RB_EXTRAFZ ) );
- PyConstant_Insert( d, "CONSTR_RB_FLAG",
- PyInt_FromLong( EXPP_CONSTR_RB_FLAG ) );
-
-
- PyConstant_Insert( d, "OWNERSPACE",
- PyInt_FromLong( EXPP_CONSTR_OWNSPACE ) );
- PyConstant_Insert( d, "TARGETSPACE",
- PyInt_FromLong( EXPP_CONSTR_TARSPACE ) );
-
- PyConstant_Insert( d, "SPACE_WORLD",
- PyInt_FromLong( CONSTRAINT_SPACE_WORLD) );
- PyConstant_Insert( d, "SPACE_LOCAL",
- PyInt_FromLong( CONSTRAINT_SPACE_LOCAL ) );
- PyConstant_Insert( d, "SPACE_POSE",
- PyInt_FromLong( CONSTRAINT_SPACE_POSE) );
- PyConstant_Insert( d, "SPACE_PARLOCAL",
- PyInt_FromLong( CONSTRAINT_SPACE_PARLOCAL ) );
- }
- return S;
-}
-
-/*****************************************************************************/
-/* Function: Constraint_Init */
-/*****************************************************************************/
-PyObject *Constraint_Init( void )
-{
- PyObject *submodule;
- PyObject *TypeDict = M_Constraint_TypeDict( );
- PyObject *SettingsDict = M_Constraint_SettingsDict( );
-
- if( PyType_Ready( &ConstraintSeq_Type ) < 0
- || PyType_Ready( &Constraint_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Constraint", NULL,
- "Constraint module for accessing and creating constraint data" );
-
- if( TypeDict )
- PyModule_AddObject( submodule, "Type", TypeDict );
-
- if( SettingsDict )
- PyModule_AddObject( submodule, "Settings", SettingsDict );
-
- return submodule;
-}
diff --git a/source/blender/python/api2_2x/Constraint.h b/source/blender/python/api2_2x/Constraint.h
deleted file mode 100644
index a9b983fadb4..00000000000
--- a/source/blender/python/api2_2x/Constraint.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c
deleted file mode 100644
index fc79296e952..00000000000
--- a/source/blender/python/api2_2x/CurNurb.c
+++ /dev/null
@@ -1,1098 +0,0 @@
-/*
- * $Id: CurNurb.c 12813 2007-12-07 09:51: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): Stephen Swaney, Campbell Barton, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "CurNurb.h" /*This must come first */
-
-#include "BKE_curve.h"
-#include "BDR_editcurve.h" /* for convertspline */
-#include "MEM_guardedalloc.h"
-#include "gen_utils.h"
-#include "BezTriple.h"
-
-/* Only for ME_SMOOTH */
-#include "DNA_meshdata_types.h"
-
-/*
- * forward declarations go here
- */
-
-static PyObject *M_CurNurb_New( PyObject * self, PyObject * args );
-static PyObject *CurNurb_oldsetMatIndex( BPy_CurNurb * self, PyObject * args );
-static int CurNurb_setMatIndex( BPy_CurNurb * self, PyObject * args );
-static PyObject *CurNurb_getMatIndex( BPy_CurNurb * self );
-static PyObject *CurNurb_getFlagU( BPy_CurNurb * self );
-static PyObject *CurNurb_oldsetFlagU( BPy_CurNurb * self, PyObject * args );
-static int CurNurb_setFlagU( BPy_CurNurb * self, PyObject * args );
-static PyObject *CurNurb_getFlagV( BPy_CurNurb * self );
-static PyObject *CurNurb_oldsetFlagV( BPy_CurNurb * self, PyObject * args );
-static int CurNurb_setFlagV( BPy_CurNurb * self, PyObject * args );
-static PyObject *CurNurb_getType( BPy_CurNurb * self );
-static PyObject *CurNurb_oldsetType( BPy_CurNurb * self, PyObject * args );
-static int CurNurb_setType( BPy_CurNurb * self, PyObject * args );
-static PyObject *CurNurb_getKnotsU( BPy_CurNurb * self );
-static PyObject *CurNurb_getKnotsV( BPy_CurNurb * self );
-static PyObject *CurNurb_getPoints( BPy_CurNurb * self );
-/* static PyObject* CurNurb_setXXX( BPy_CurNurb* self, PyObject* args ); */
-static int CurNurb_setPoint( BPy_CurNurb * self, int index, PyObject * ob );
-static int CurNurb_length( PyInstanceObject * inst );
-static PyObject *CurNurb_getIter( BPy_CurNurb * self );
-static PyObject *CurNurb_iterNext( BPy_CurNurb * self );
-PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * value );
-
-static PyObject *CurNurb_isNurb( BPy_CurNurb * self );
-static PyObject *CurNurb_isCyclic( BPy_CurNurb * self );
-static PyObject *CurNurb_dump( BPy_CurNurb * self );
-static PyObject *CurNurb_switchDirection( BPy_CurNurb * self );
-static PyObject *CurNurb_recalc( BPy_CurNurb * self );
-static PyObject *CurNurb_getFlagBits( BPy_CurNurb * self, void *type );
-static int CurNurb_setFlagBits( BPy_CurNurb * self, PyObject *value, void *type );
-char M_CurNurb_doc[] = "CurNurb";
-
-
-/*
- CurNurb_Type callback function prototypes:
-*/
-
-static int CurNurb_compare( BPy_CurNurb * a, BPy_CurNurb * b );
-static PyObject *CurNurb_repr( BPy_CurNurb * self );
-
-/*
- 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_CurNurb_methods[] = {
-/* name, method, flags, doc_string */
- {"New", ( PyCFunction ) M_CurNurb_New, METH_VARARGS | METH_KEYWORDS,
- " () - doc string"},
-/* {"Get", (PyCFunction) M_CurNurb_method, METH_NOARGS, " () - doc string"}, */
-/* {"method", (PyCFunction) M_CurNurb_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_CurNurb_methods[] = {
-/* name, method, flags, doc */
-/* {"method", (PyCFunction) CurNurb_method, METH_NOARGS, " () - doc string"} */
- {"setMatIndex", ( PyCFunction ) CurNurb_oldsetMatIndex, METH_VARARGS,
- "( index ) - set index into materials list"},
- {"getMatIndex", ( PyCFunction ) CurNurb_getMatIndex, METH_NOARGS,
- "( ) - get current material index"},
- {"setFlagU", ( PyCFunction ) CurNurb_oldsetFlagU, METH_VARARGS,
- "( index ) - set flagU and recalculate the knots (0: uniform, 1: endpoints, 2: bezier)"},
- {"getFlagU", ( PyCFunction ) CurNurb_getFlagU, METH_NOARGS,
- "( ) - get flagU of the knots"},
- {"setFlagV", ( PyCFunction ) CurNurb_oldsetFlagV, METH_VARARGS,
- "( index ) - set flagV and recalculate the knots (0: uniform, 1: endpoints, 2: bezier)"},
- {"getFlagV", ( PyCFunction ) CurNurb_getFlagV, METH_NOARGS,
- "( ) - get flagV of the knots"},
- {"setType", ( PyCFunction ) CurNurb_oldsetType, METH_VARARGS,
- "( type ) - change the type of the curve (Poly: 0, Bezier: 1, NURBS: 4)"},
- {"getType", ( PyCFunction ) CurNurb_getType, METH_NOARGS,
- "( ) - get the type of the curve (Poly: 0, Bezier: 1, NURBS: 4)"},
- {"append", ( PyCFunction ) CurNurb_append, METH_O,
- "( point ) - add a new point. arg is BezTriple or list of x,y,z,w floats"},
- {"isNurb", ( PyCFunction ) CurNurb_isNurb, METH_NOARGS,
- "( ) - boolean function tests if this spline is type nurb or bezier"},
- {"isCyclic", ( PyCFunction ) CurNurb_isCyclic, METH_NOARGS,
- "( ) - boolean function tests if this spline is cyclic (closed) or not (open)"},
- {"dump", ( PyCFunction ) CurNurb_dump, METH_NOARGS,
- "( ) - dumps Nurb data)"},
- {"switchDirection", ( PyCFunction ) CurNurb_switchDirection, METH_NOARGS,
- "( ) - swaps curve beginning and end)"},
- {"recalc", ( PyCFunction ) CurNurb_recalc, METH_NOARGS,
- "( ) - recalc Nurb data)"},
- {NULL, NULL, 0, NULL}
-};
-
-/*
- * methods for CurNurb as sequece
- */
-
-static PySequenceMethods CurNurb_as_sequence = {
- ( inquiry ) CurNurb_length, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) CurNurb_getPoint, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) CurNurb_setPoint, /* sq_ass_item */
- 0, /* sq_ass_slice */
- ( objobjproc ) 0, /* sq_contains */
- 0,
- 0
-};
-
-static PyGetSetDef BPy_CurNurb_getseters[] = {
- {"mat_index",
- (getter)CurNurb_getMatIndex, (setter)CurNurb_setMatIndex,
- "CurNurb's material index",
- NULL},
- {"points",
- (getter)CurNurb_getPoints, (setter)NULL,
- "The number of curve points",
- NULL},
- {"flagU",
- (getter)CurNurb_getFlagU, (setter)CurNurb_setFlagU,
- "The knot type in the U direction",
- NULL},
- {"flagV",
- (getter)CurNurb_getFlagV, (setter)CurNurb_setFlagV,
- "The knot type in the V direction",
- NULL},
- {"type",
- (getter)CurNurb_getType, (setter)CurNurb_setType,
- "The curve type (poly: bezier, or NURBS)",
- NULL},
- {"knotsU",
- (getter)CurNurb_getKnotsU, (setter)NULL,
- "The The knot vector in the U direction",
- NULL},
- {"knotsV",
- (getter)CurNurb_getKnotsV, (setter)NULL,
- "The The knot vector in the V direction",
- NULL},
- {"smooth",
- (getter)CurNurb_getFlagBits, (setter)CurNurb_setFlagBits,
- "The smooth bool setting",
- (void *)ME_SMOOTH},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*
- Object Type definition
- full blown 2.3 struct
- if you are having trouble building with an earlier version of python,
- this is why.
-*/
-
-PyTypeObject CurNurb_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "CurNurb", /* char *tp_name; */
- sizeof( CurNurb_Type ), /* 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 ) CurNurb_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) CurNurb_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- 0, /* PyNumberMethods *tp_as_number; */
- &CurNurb_as_sequence, /* PySequenceMethods *tp_as_sequence; */
- 0, /* PyMappingMethods *tp_as_mapping; */
-
- /* More standard operations (here for binary compatibility) */
-
- 0, /* hashfunc tp_hash; */
- 0, /* ternaryfunc tp_call; */
- 0, /* reprfunc tp_str; */
- 0, /* getattrofunc tp_getattro; */
- 0, /* setattrofunc tp_setattro; */
-
- /* Functions to access object as input/output buffer */
- 0, /* PyBufferProcs *tp_as_buffer; */
-
- /*** Flags to define presence of optional/expanded features ***/
- Py_TPFLAGS_DEFAULT, /* long tp_flags; */
-
- 0, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
- /* call function for all accessible objects */
- 0, /* traverseproc tp_traverse; */
-
- /* delete references to contained objects */
- 0, /* inquiry tp_clear; */
-
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
- 0, /* richcmpfunc tp_richcompare; */
-
- /*** weak reference enabler ***/
- 0, /* long tp_weaklistoffset; */
-
- /*** Added in release 2.2 ***/
- /* Iterators */
- ( getiterfunc ) CurNurb_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) CurNurb_iterNext, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_CurNurb_methods, /* struct PyMethodDef *tp_methods; */
- 0, /* struct PyMemberDef *tp_members; */
- BPy_CurNurb_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
-};
-
-/*
- compare
- in this case, we consider two CurNurbs equal, if they point to the same
- blender data.
-*/
-
-static int CurNurb_compare( BPy_CurNurb * a, BPy_CurNurb * b )
-{
- Nurb *pa = a->nurb;
- Nurb *pb = b->nurb;
-
- return ( pa == pb ) ? 0 : -1;
-}
-
-
-/*
- factory method to create a BPy_CurNurb from a Blender Nurb
-*/
-
-PyObject *CurNurb_CreatePyObject( Nurb * blen_nurb )
-{
- BPy_CurNurb *pyNurb;
-
- pyNurb = ( BPy_CurNurb * ) PyObject_NEW( BPy_CurNurb, &CurNurb_Type );
-
- if( !pyNurb )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "could not create BPy_CurNurb PyObject" );
-
- pyNurb->nurb = blen_nurb;
- return ( PyObject * ) pyNurb;
-}
-
-
-/*
- * CurNurb_repr
- */
-static PyObject *CurNurb_repr( BPy_CurNurb * self )
-{ /* used by 'repr' */
-
- return PyString_FromFormat( "[CurNurb \"%d\"]", self->nurb->type );
-}
-
-/* XXX Can't this be simply removed? */
-static PyObject *M_CurNurb_New( PyObject * self, PyObject * args )
-{
- return ( PyObject * ) 0;
-
-}
-
-/*
- * Curve.getType
- */
-static PyObject *CurNurb_getType( BPy_CurNurb * self )
-{
- /* type is on 3 first bits only */
- return PyInt_FromLong( self->nurb->type & 7 );
-}
-
-/*
- * Curve.setType
- *
- * Convert the curve using Blender's convertspline fonction
- */
-static int CurNurb_setType( BPy_CurNurb * self, PyObject * args )
-{
- PyObject* integer = PyNumber_Int( args );
- short value;
-
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- value = ( short )PyInt_AS_LONG( integer );
- Py_DECREF( integer );
-
- /* parameter value checking */
- if (value != CU_POLY && value != CU_BEZIER && value != CU_NURBS)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected integer argument" );
-
- /* convert and raise error if impossible */
- if (convertspline(value, self->nurb))
- return EXPP_ReturnIntError( PyExc_ValueError,
- "Conversion Impossible" );
-
- return 0;
-}
-
-/*
- * CurNurb_getKnotsU
- *
- * returns curve's knotsU in a tuple. Empty tuple is returned if curve
- * isn't Nurbs or it doesn't have knots in U
- */
-
-static PyObject *CurNurb_getKnotsU( BPy_CurNurb * self )
-{
- if(self->nurb->knotsu) {
- int len = KNOTSU(self->nurb);
- int i;
- PyObject *knotsu = PyTuple_New(len);
- if( !knotsu )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not get CurNurb.knotsU attribute" );
-
- for(i = 0; i < len; ++i)
- PyTuple_SetItem(knotsu, i,
- PyFloat_FromDouble(self->nurb->knotsu[i]));
-
- return knotsu;
- }
- return PyTuple_New(0);
-}
-
-/*
- * CurNurb_getKnotsV
- *
- * returns curve's knotsV in a tuple. Empty tuple is returned if curve doesn't have knots in V
- */
-
-static PyObject *CurNurb_getKnotsV( BPy_CurNurb * self )
-{
- if(self->nurb->knotsv) {
- int len = KNOTSV(self->nurb);
- int i;
- PyObject *knotsv = PyTuple_New(len);
- if( !knotsv )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not get CurNurb.knotsV index" );
-
- for(i = 0; i < len; ++i)
- PyTuple_SetItem(knotsv, i,
- PyFloat_FromDouble(self->nurb->knotsv[i] ));
-
- return knotsv;
- }
- return PyTuple_New(0);
-}
-
-static PyObject *CurNurb_getPoints( BPy_CurNurb * self )
-{
- return PyInt_FromLong( ( long ) self->nurb->pntsu );
-}
-
-static PyObject *CurNurb_getFlagBits( BPy_CurNurb * self, void *type )
-{
- return EXPP_getBitfield( (void *)&self->nurb->flag,
- (int)type, 'h' );
-}
-
-static int CurNurb_setFlagBits( BPy_CurNurb * self, PyObject *value,
- void *type )
-{
- return EXPP_setBitfield( value, (void *)&self->nurb->flag,
- (int)type, 'h' );
-}
-
-/*
- * CurNurb_append( point )
- * append a new point to a nurb curve.
- * arg is BezTriple or list of xyzw floats
- */
-
-PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * value )
-{
- return CurNurb_appendPointToNurb( self->nurb, value );
-}
-
-
-/*
- * CurNurb_appendPointToNurb
- * this is a non-bpy utility func to add a point to a given nurb.
- * notice the first arg is Nurb*.
- */
-
-PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * value )
-{
-
- int i;
- int size;
- int npoints = nurb->pntsu;
-
- /*
- do we have a list of four floats or a BezTriple?
- */
-
- /* if curve is empty, adjust type depending on input type */
- if (nurb->bezt==NULL && nurb->bp==NULL) {
- if (BPy_BezTriple_Check( value ))
- nurb->type |= CU_BEZIER;
- else if (PySequence_Check( value ))
- 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( value ) )
- 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 ),
- "CurNurb_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( value ), sizeof( BezTriple ) );
-
- }
- else if( PySequence_Check( value ) ) {
- size = PySequence_Size( value );
-/* 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 ),
- "CurNurb_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( value, 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( value, 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" );
-
- }
-
- Py_RETURN_NONE;
-}
-
-
-/*
- * CurNurb_setMatIndex
- *
- * set index into material list
- */
-
-static int CurNurb_setMatIndex( BPy_CurNurb * self, PyObject * args )
-{
- printf ("%d\n", self->nurb->mat_nr);
- return EXPP_setIValueRange( args, &self->nurb->mat_nr, 0, 15, 'h' );
-}
-
-/*
- * CurNurb_getMatIndex
- *
- * returns index into material list
- */
-
-static PyObject *CurNurb_getMatIndex( BPy_CurNurb * self )
-{
- PyObject *index = PyInt_FromLong( ( long ) self->nurb->mat_nr );
-
- if( index )
- return index;
-
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not get material index" );
-}
-
-/*
- * CurNurb_getFlagU
- *
- * returns curve's flagu
- */
-
-static PyObject *CurNurb_getFlagU( BPy_CurNurb * self )
-{
- PyObject *flagu = PyInt_FromLong( ( long ) self->nurb->flagu );
-
- if( flagu )
- return flagu;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not get CurNurb.flagu index" ) );
-}
-
-/*
- * CurNurb_setFlagU
- *
- * set curve's flagu and recalculate the knots
- *
- * Possible values: 0 - uniform, 2 - endpoints, 4 - bezier
- * bit 0 controls CU_CYCLIC
- */
-
-static int CurNurb_setFlagU( BPy_CurNurb * self, PyObject * args )
-{
- PyObject* integer = PyNumber_Int( args );
- short value;
-
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- value = ( short )PyInt_AS_LONG( integer );
- Py_DECREF( integer );
-
- if( value < 0 || value > 5 )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected integer argument in range [0,5]" );
-
- if( self->nurb->flagu != value ) {
- self->nurb->flagu = (short)value;
- makeknots( self->nurb, 1, self->nurb->flagu >> 1 );
- }
-
- return 0;
-}
-
-/*
- * CurNurb_getFlagV
- *
- * returns curve's flagu
- */
-
-static PyObject *CurNurb_getFlagV( BPy_CurNurb * self )
-{
- PyObject *flagv = PyInt_FromLong( ( long ) self->nurb->flagv );
-
- if( flagv )
- return flagv;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not get CurNurb.flagv" ) );
-}
-
-/*
- * CurNurb_setFlagV
- *
- * set curve's flagu and recalculate the knots
- *
- * Possible values: 0 - uniform, 1 - endpoints, 2 - bezier
- */
-
-static int CurNurb_setFlagV( BPy_CurNurb * self, PyObject * args )
-{
- PyObject* integer = PyNumber_Int( args );
- short value;
-
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- value = ( short )PyInt_AS_LONG( integer );
- Py_DECREF( integer );
-
- if( value < 0 || value > 5 )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected integer argument in range [0,5]" );
-
- if( self->nurb->flagv != value ) {
- self->nurb->flagv = (short)value;
- makeknots( self->nurb, 2, self->nurb->flagv >> 1 );
- }
-
- return 0;
-}
-
-/*
- * CurNurb_getIter
- *
- * create an iterator for our CurNurb.
- * this iterator returns the points for this CurNurb.
- */
-
-static PyObject *CurNurb_getIter( BPy_CurNurb * self )
-{
- self->bp = self->nurb->bp;
- self->bezt = self->nurb->bezt;
- self->atEnd = 0;
- self->nextPoint = 0;
-
- /* set exhausted flag if both bp and bezt are zero */
- if( ( !self->bp ) && ( !self->bezt ) )
- self->atEnd = 1;
-
- Py_INCREF( self );
- return ( PyObject * ) self;
-}
-
-
-static PyObject *CurNurb_iterNext( BPy_CurNurb * self )
-{
- PyObject *po; /* return value */
- Nurb *pnurb = self->nurb;
- int npoints = pnurb->pntsu;
-
- /* are we at end already? */
- if( self->atEnd )
- return ( EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" ) );
-
- if( self->nextPoint < npoints ) {
-
- po = CurNurb_pointAtIndex( self->nurb, self->nextPoint );
- self->nextPoint++;
-
- return po;
-
- } else {
- self->atEnd = 1; /* set flag true */
- }
-
- return ( EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" ) );
-}
-
-
-
-/*
- * CurNurb_isNurb()
- * test whether spline nurb or bezier
- */
-
-static PyObject *CurNurb_isNurb( BPy_CurNurb * self )
-{
- /* NOTE: a Nurb has bp and bezt pointers
- * depending on type.
- * It is possible both are NULL if no points exist.
- * in that case, we return False
- */
-
- if( self->nurb->bp ) {
- Py_RETURN_TRUE;
- } else {
- Py_RETURN_FALSE;
- }
-}
-
-/*
- * CurNurb_isCyclic()
- * test whether spline cyclic (closed) or not (open)
- */
-
-static PyObject *CurNurb_isCyclic( BPy_CurNurb * self )
-{
- /* supposing that the flagu is always set */
-
- if( self->nurb->flagu & CU_CYCLIC ) {
- Py_RETURN_TRUE;
- } else {
- Py_RETURN_FALSE;
- }
-}
-
-/*
- * CurNurb_length
- * returns the number of points in a Nurb
- * this is a tp_as_sequence method, not a regular instance method.
- */
-
-static int CurNurb_length( PyInstanceObject * inst )
-{
- Nurb *nurb;
- int len;
-
- if( BPy_CurNurb_Check( ( PyObject * ) inst ) ) {
- nurb = ( ( BPy_CurNurb * ) inst )->nurb;
- len = nurb->pntsu;
- return len;
- }
-
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "arg is not a BPy_CurNurb" );
-}
-
-/*
- * CurNurb_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 *CurNurb_getPoint( BPy_CurNurb * self, int index )
-{
- Nurb *myNurb;
-
- int npoints;
-
- /* for convenince */
- myNurb = self->nurb;
- npoints = myNurb->pntsu;
-
- /* DELETED: bail if index < 0 */
- /* actually, this check is not needed since python treats */
- /* negative indices as starting from the right end of a sequence */
- /*
- THAT IS WRONG, when passing a negative index, python adjusts it to be positive
- BUT it can still overflow in the negatives if the index is too small.
- For example, list[-6] when list contains 5 items means index = -1 in here.
- (theeth)
- */
-
- /* bail if no Nurbs in Curve */
- if( npoints == 0 )
- return ( EXPP_ReturnPyObjError( PyExc_IndexError,
- "no points in this CurNurb" ) );
-
- /* check index limits */
- if( index >= npoints || index < 0 )
- return ( EXPP_ReturnPyObjError( PyExc_IndexError,
- "index out of range" ) );
-
- return CurNurb_pointAtIndex( myNurb, index );
-}
-
-/*
- * CurNurb_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 CurNurb_setPoint( BPy_CurNurb * self, int index, PyObject * pyOb )
-{
- Nurb *nurb = self->nurb;
- int size;
-
- /* check index limits */
- if( index < 0 || index >= nurb->pntsu )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "array assignment index out of range" );
-
-
- /* branch by curve type */
- if ((nurb->type & 7)==CU_BEZIER) { /* BEZIER */
- /* check parameter type */
- if( !BPy_BezTriple_Check( pyOb ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a BezTriple" );
-
- /* copy bezier in array */
- memcpy( nurb->bezt + index,
- BezTriple_FromPyObject( pyOb ), sizeof( BezTriple ) );
-
- return 0; /* finished correctly */
- }
- else { /* NURBS or POLY */
- int i;
-
- /* check parameter type */
- if (!PySequence_Check( pyOb ))
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list of 4 (or optionally 5 if the curve is 3D) floats" );
-
- size = PySequence_Size( pyOb );
-
- /* check sequence size */
- if( size != 4 && size != 5 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list of 4 (or optionally 5 if the curve is 3D) floats" );
-
- /* 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 *CurNurb_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 ) );
-
- } else if( nurb->bezt ) { /* we have a bezier */
- /* if an error occurs, we just pass it on */
- pyo = BezTriple_CreatePyObject( &( nurb->bezt[index] ) );
-
- } else /* something is horribly wrong */
- /* neither bp or bezt is set && pntsu != 0 */
- return EXPP_ReturnPyObjError( PyExc_SystemError,
- "inconsistant structure found" );
-
- return pyo;
-}
-
-/*
- dump nurb
-*/
-
-PyObject *CurNurb_dump( BPy_CurNurb * self )
-{
- BPoint *bp = NULL;
- BezTriple *bezt = NULL;
- Nurb *nurb = self->nurb;
- int npoints = 0;
-
- if( !self->nurb )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "no Nurb in this CurNurb");
-
- printf(" type: %d, mat_nr: %d hide: %d flag: %d",
- nurb->type, nurb->mat_nr, nurb->hide, nurb->flag);
- printf("\n pntsu: %d, pntsv: %d, resolu: %d resolv: %d",
- nurb->pntsu, nurb->pntsv, nurb->resolu, nurb->resolv );
- printf("\n orderu: %d orderv: %d", nurb->orderu, nurb->orderv );
- printf("\n flagu: %d flagv: %d",
- nurb->flagu, nurb->flagv );
-
- npoints = nurb->pntsu;
-
- if( nurb->bp ) { /* we have a BPoint */
- int n;
- for( n = 0, bp = nurb->bp;
- n < npoints;
- n++, bp++ )
- {
- /* vec[4] */
- printf( "\ncoords[%d]: ", n);
- {
- int i;
- for( i = 0; i < 4; i++){
- printf("%10.3f ", bp->vec[i] );
- }
- }
-
- /* alfa, s[2] */
- printf("\n alpha: %5.2f", bp->alfa);
- /* f1, hide */
- printf(" f1 %d hide %d", bp->f1, bp->hide );
- printf("\n");
- }
- }
- else { /* we have a BezTriple */
- int n;
- for( n = 0, bezt = nurb->bezt;
- n < npoints;
- n++, bezt++ )
- {
- int i, j;
- printf("\npoint %d: ", n);
- for( i = 0; i < 3; i++ ) {
- printf("\nvec[%i] ",i );
- for( j = 0; j < 3; j++ ) {
- printf(" %5.2f ", bezt->vec[i][j] );
- }
- }
-
-
- }
- printf("\n");
- }
-
- Py_RETURN_NONE;
-}
-
-/*
- recalc nurb
-*/
-
-static PyObject *CurNurb_recalc( BPy_CurNurb * self )
-{
- calchandlesNurb ( self->nurb );
- Py_RETURN_NONE;
-}
-
-PyObject *CurNurb_switchDirection( BPy_CurNurb * self )
-{
- if( !self->nurb )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "no Nurb in this CurNurb");
-
- switchdirectionNurb( self->nurb );
-
- Py_RETURN_NONE;
-}
-
-PyObject *CurNurb_Init( void )
-{
- if( PyType_Ready( &CurNurb_Type ) < 0)
- return NULL;
-
- return Py_InitModule3( "Blender.CurNurb", M_CurNurb_methods,
- M_CurNurb_doc );
-}
-
-/* #####DEPRECATED###### */
-
-static PyObject *CurNurb_oldsetType( BPy_CurNurb * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)CurNurb_setType );
-}
-
-static PyObject *CurNurb_oldsetMatIndex( BPy_CurNurb * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)CurNurb_setMatIndex );
-}
-
-static PyObject *CurNurb_oldsetFlagU( BPy_CurNurb * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)CurNurb_setFlagU );
-}
-
-static PyObject *CurNurb_oldsetFlagV( BPy_CurNurb * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)CurNurb_setFlagV );
-}
diff --git a/source/blender/python/api2_2x/CurNurb.h b/source/blender/python/api2_2x/CurNurb.h
deleted file mode 100644
index f7c50c41bb9..00000000000
--- a/source/blender/python/api2_2x/CurNurb.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c
deleted file mode 100644
index e96e25c25d8..00000000000
--- a/source/blender/python/api2_2x/Curve.c
+++ /dev/null
@@ -1,1696 +0,0 @@
-/*
- * $Id: Curve.c 12752 2007-12-01 23:25:00Z 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 *****
- */
-
-#include "Curve.h" /*This must come first*/
-
-#include "BLI_blenlib.h"
-#include "BKE_main.h"
-#include "BKE_displist.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_curve.h"
-#include "BKE_material.h"
-#include "MEM_guardedalloc.h" /* because we wil be mallocing memory */
-#include "CurNurb.h"
-#include "SurfNurb.h"
-#include "Material.h"
-#include "Object.h"
-#include "Key.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-#include "mydevice.h"
-
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Curve.__doc__ */
-/*****************************************************************************/
-
-char M_Curve_doc[] = "The Blender Curve module\n\n\
-This module provides access to **Curve Data** in Blender.\n\
-Functions :\n\
- New(opt name) : creates a new curve object with the given name (optional)\n\
- Get(name) : retreives a curve with the given name (mandatory)\n\
- get(name) : same as Get. Kept for compatibility reasons";
-char M_Curve_New_doc[] = "";
-char M_Curve_Get_doc[] = "xxx";
-
-
-
-/*****************************************************************************/
-/* Python API function prototypes for the Curve module. */
-/*****************************************************************************/
-static PyObject *M_Curve_New( PyObject * self, PyObject * args );
-static PyObject *M_Curve_Get( PyObject * self, PyObject * args );
-
-
-/*****************************************************************************/
-/* Python BPy_Curve instance methods declarations: */
-/*****************************************************************************/
-
-static PyObject *Curve_getPathLen( BPy_Curve * self );
-static PyObject *Curve_setPathLen( BPy_Curve * self, PyObject * args );
-static PyObject *Curve_getTotcol( BPy_Curve * self );
-static PyObject *Curve_setTotcol( BPy_Curve * self, PyObject * args );
-#if 0
-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_getWidth( BPy_Curve * self );
-PyObject *Curve_setWidth( 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 );
-#endif
-static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args );
-static PyObject *Curve_setControlPoint( BPy_Curve * self, PyObject * args );
-static PyObject *Curve_getLoc( BPy_Curve * self );
-static PyObject *Curve_setLoc( BPy_Curve * self, PyObject * args );
-static PyObject *Curve_getRot( BPy_Curve * self );
-static PyObject *Curve_setRot( BPy_Curve * self, PyObject * args );
-static PyObject *Curve_getSize( BPy_Curve * self );
-static PyObject *Curve_setSize( BPy_Curve * self, PyObject * args );
-static PyObject *Curve_getNumCurves( BPy_Curve * self );
-static PyObject *Curve_getKey( BPy_Curve * self );
-static PyObject *Curve_isNurb( BPy_Curve * self, PyObject * args );
-static PyObject *Curve_isCyclic( BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getNumPoints( BPy_Curve * self, PyObject * args );
-
-static PyObject *Curve_appendPoint( BPy_Curve * self, PyObject * args );
-static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * args );
-
-static PyObject *Curve_getMaterials( BPy_Curve * self );
-
-static PyObject *Curve_getBevOb( BPy_Curve * self );
-static PyObject *Curve_setBevOb( BPy_Curve * self, PyObject * args );
-
-static PyObject *Curve_getTaperOb( BPy_Curve * self );
-static PyObject *Curve_setTaperOb( BPy_Curve * self, PyObject * args );
-static PyObject *Curve_copy( BPy_Curve * self );
-
-static PyObject *Curve_getIter( BPy_Curve * self );
-static PyObject *Curve_iterNext( BPy_Curve * self );
-
-PyObject *Curve_getNurb( BPy_Curve * self, int n );
-static int Curve_setNurb( BPy_Curve * self, int n, PyObject * value );
-static int Curve_length( PyInstanceObject * inst );
-
-
-struct chartrans *text_to_curve( Object * ob, int mode );
-/*****************************************************************************/
-/* Python BPy_Curve methods: */
-/* gives access to */
-/* name, pathlen totcol flag bevresol */
-/* resolu resolv width ext1 ext2 */
-/* controlpoint loc rot size */
-/* numpts */
-/*****************************************************************************/
-
-
-PyObject *Curve_getName( BPy_Curve * self )
-{
- return PyString_FromString( self->curve->id.name + 2 );
-}
-
-static int Curve_newsetName( BPy_Curve * self, PyObject * args )
-{
- char *name;
-
- name = PyString_AsString( args );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string argument" );
-
- rename_id( &self->curve->id, name ); /* proper way in Blender */
- Curve_update( self );
-
- return 0;
-}
-
-static PyObject *Curve_getPathLen( BPy_Curve * self )
-{
- return PyInt_FromLong( ( long ) self->curve->pathlen );
-}
-
-
-static int Curve_newsetPathLen( BPy_Curve * self, PyObject * args )
-{
- PyObject *num;
-
- if( !PyNumber_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- num = PyNumber_Int( args );
- self->curve->pathlen = (short)PyInt_AS_LONG( num );
- Py_DECREF( num );
-
- return 0;
-}
-
-static PyObject *Curve_getTotcol( BPy_Curve * self )
-{
- return PyInt_FromLong( ( long ) self->curve->totcol );
-}
-
-
-PyObject *Curve_getMode( BPy_Curve * self )
-{
- return PyInt_FromLong( ( long ) self->curve->flag );
-}
-
-
-static int Curve_newsetMode( BPy_Curve * self, PyObject * args )
-{
- PyObject *num;
-
- if( !PyNumber_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- num = PyNumber_Int( args );
- self->curve->flag = (short)PyInt_AS_LONG( num );
- Py_DECREF( num );
-
- return 0;
-}
-
-PyObject *Curve_getBevresol( BPy_Curve * self )
-{
- return PyInt_FromLong( ( long ) self->curve->bevresol );
-}
-
-static int Curve_newsetBevresol( BPy_Curve * self, PyObject * args )
-{
- short value;
- PyObject *num;
-
- if( !PyNumber_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- num = PyNumber_Int( args );
- value = (short)PyInt_AS_LONG( num );
- Py_DECREF( num );
-
- if( value > 10 || value < 0 )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "acceptable values are between 0 and 10" );
-
- self->curve->bevresol = value;
- return 0;
-}
-
-
-PyObject *Curve_getResolu( BPy_Curve * self )
-{
- return PyInt_FromLong( ( long ) self->curve->resolu );
-}
-
-
-static int Curve_newsetResolu( BPy_Curve * self, PyObject * args )
-{
- short value;
- Nurb *nu;
- PyObject *num;
-
- if( !PyNumber_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- num = PyNumber_Int( args );
- value = (short)PyInt_AS_LONG( num );
- Py_DECREF( num );
-
- if( value > 128 || value < 1 )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "acceptable values are between 1 and 128" );
-
- self->curve->resolu = value;
- /* propagate the change through all the curves */
- for( nu = self->curve->nurb.first; nu; nu = nu->next )
- nu->resolu = value;
-
- return 0;
-}
-
-PyObject *Curve_getResolv( BPy_Curve * self )
-{
- return PyInt_FromLong( ( long ) self->curve->resolv );
-}
-
-static int Curve_newsetResolv( BPy_Curve * self, PyObject * args )
-{
- short value;
- PyObject *num;
-
- if( !PyNumber_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- num = PyNumber_Int( args );
- value = (short)PyInt_AS_LONG( num );
- Py_DECREF( num );
-
- if(value > 128 || value < 1)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "acceptable values are between 1 and 128" );
- self->curve->resolv = value;
-
- return 0;
-}
-
-PyObject *Curve_getWidth( BPy_Curve * self )
-{
- return PyFloat_FromDouble( ( double ) self->curve->width );
-}
-
-
-static int Curve_newsetWidth( BPy_Curve * self, PyObject * args )
-{
- float value;
- PyObject *num;
-
- if( !PyNumber_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
-
- num = PyNumber_Float( args );
- value = (float)PyFloat_AS_DOUBLE( num );
- Py_DECREF( num );
-
- if(value > 2.0f || value < 0.0f)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "acceptable values are between 2.0 and 0.0" );
- self->curve->width = value;
-
- return 0;
-}
-
-
-PyObject *Curve_getExt1( BPy_Curve * self )
-{
- return PyFloat_FromDouble( ( double ) self->curve->ext1 );
-}
-
-
-static int Curve_newsetExt1( BPy_Curve * self, PyObject * args )
-{
- float value;
- PyObject *num;
-
- if( !PyNumber_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
-
- num = PyNumber_Float( args );
- value = (float)PyFloat_AS_DOUBLE( num );
- Py_DECREF( num );
-
- if(value > 100.0f || value < 0.0f)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "acceptable values are between 0.0 and 100.0" );
- self->curve->ext1 = value;
-
- return 0;
-}
-
-PyObject *Curve_getExt2( BPy_Curve * self )
-{
- return PyFloat_FromDouble( ( double ) self->curve->ext2 );
-}
-
-
-static int Curve_newsetExt2( BPy_Curve * self, PyObject * args )
-{
- float value;
- PyObject *num;
-
- if( !PyNumber_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
-
- num = PyNumber_Float( args );
- value = (float)PyFloat_AS_DOUBLE( num );
- Py_DECREF( num );
-
- if(value > 2.0f || value < 0.0f)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "acceptable values are between 0.0 and 2.0" );
- self->curve->ext2 = value;
-
- return 0;
-}
-
-/*
- * Curve_setControlPoint
- * this function sets an EXISTING control point.
- * it does NOT add a new one.
- */
-
-static PyObject *Curve_setControlPoint( BPy_Curve * self, PyObject * args )
-{
- PyObject *listargs = 0;
- Nurb *ptrnurb = self->curve->nurb.first;
- int numcourbe = 0, numpoint = 0, i, j;
-
- if( !ptrnurb )
- Py_RETURN_NONE;
-
- if( ptrnurb->bp )
- if( !PyArg_ParseTuple
- ( args, "iiO", &numcourbe, &numpoint, &listargs ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected int, int, list arguments" ) );
- if( ptrnurb->bezt )
- if( !PyArg_ParseTuple
- ( args, "iiO", &numcourbe, &numpoint, &listargs ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected int, int, list arguments" ) );
-
- for( i = 0; i < numcourbe; i++ )
- ptrnurb = ptrnurb->next;
-
- if( ptrnurb->bp )
- for( i = 0; i < 4; i++ )
- ptrnurb->bp[numpoint].vec[i] =
- (float)PyFloat_AsDouble( PyList_GetItem ( listargs, i ) );
-
- if( ptrnurb->bezt )
- for( i = 0; i < 3; i++ )
- for( j = 0; j < 3; j++ )
- ptrnurb->bezt[numpoint].vec[i][j] =
- (float)PyFloat_AsDouble( PyList_GetItem
- ( listargs,
- i * 3 + j ) );
-
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args )
-{
- PyObject *liste;
- PyObject *item;
-
- Nurb *ptrnurb;
- int i, j;
- /* input args: requested curve and point number on curve */
- int numcourbe, numpoint;
-
- if( !PyArg_ParseTuple( args, "ii", &numcourbe, &numpoint ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int int arguments" ) );
- if( ( numcourbe < 0 ) || ( numpoint < 0 ) )
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "arguments must be non-negative" ) );
-
- /* if no nurbs in this curve obj */
- if( !self->curve->nurb.first )
- return PyList_New( 0 );
-
- /* walk the list of nurbs to find requested numcourbe */
- ptrnurb = self->curve->nurb.first;
- for( i = 0; i < numcourbe; i++ ) {
- ptrnurb = ptrnurb->next;
- if( !ptrnurb ) /* if zero, we ran just ran out of curves */
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "curve index out of range" ) );
- }
-
- /* check numpoint param against pntsu */
- if( numpoint >= ptrnurb->pntsu )
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "point index out of range" ) );
-
- liste = PyList_New( 0 );
- if( ptrnurb->bp ) { /* if we are a nurb curve, you get 4 values */
- for( i = 0; i < 4; i++ ) {
- item = PyFloat_FromDouble( ptrnurb->bp[numpoint].vec[i] );
- PyList_Append( liste, item );
- Py_DECREF(item);
- }
- } else if( ptrnurb->bezt ) { /* if we are a bezier, you get 9 values */
- for( i = 0; i < 3; i++ )
- for( j = 0; j < 3; j++ ) {
- item = PyFloat_FromDouble( ptrnurb->bezt[numpoint].vec[i][j] );
- PyList_Append( liste, item );
- Py_DECREF(item);
- }
- }
-
- return liste;
-}
-
-static PyObject *Curve_getLoc( BPy_Curve * self )
-{
- return Py_BuildValue( "[f,f,f]", self->curve->loc[0],
- self->curve->loc[1], self->curve->loc[2] );
-}
-
-static int Curve_newsetLoc( BPy_Curve * self, PyObject * args )
-{
- float loc[3];
- int i;
-
- if( ( !PyList_Check( args ) && !PyTuple_Check( args ) ) ||
- PySequence_Size( args ) != 3 ) {
-TypeError:
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a sequence of three floats" );
- }
-
- for( i = 0; i < 3; i++ ) {
- PyObject *item = PySequence_GetItem( args, i );
- PyObject *num = PyNumber_Float( item );
- Py_DECREF( item );
- if( !num )
- goto TypeError;
- loc[i] = PyFloat_AS_DOUBLE( num );
- Py_DECREF( num );
- }
- memcpy( self->curve->loc, loc, sizeof( loc ) );
-
- return 0;
-}
-
-static PyObject *Curve_getRot( BPy_Curve * self )
-{
- return Py_BuildValue( "[f,f,f]", self->curve->rot[0],
- self->curve->rot[1], self->curve->rot[2] );
-}
-
-static int Curve_newsetRot( BPy_Curve * self, PyObject * args )
-{
- float rot[3];
- int i;
-
- if( ( !PyList_Check( args ) && !PyTuple_Check( args ) ) ||
- PySequence_Size( args ) != 3 ) {
-TypeError:
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a sequence of three floats" );
- }
-
- for( i = 0; i < 3; i++ ) {
- PyObject *item = PySequence_GetItem( args, i );
- PyObject *num = PyNumber_Float( item );
- Py_DECREF( item );
- if( !num )
- goto TypeError;
- rot[i] = PyFloat_AS_DOUBLE( num );
- Py_DECREF( num );
- }
- memcpy( self->curve->rot, rot, sizeof( rot ) );
-
- return 0;
-}
-
-static PyObject *Curve_getSize( BPy_Curve * self )
-{
- return Py_BuildValue( "[f,f,f]", self->curve->size[0],
- self->curve->size[1], self->curve->size[2] );
-}
-
-static int Curve_newsetSize( BPy_Curve * self, PyObject * args )
-{
- float size[3];
- int i;
-
- if( ( !PyList_Check( args ) && !PyTuple_Check( args ) ) ||
- PySequence_Size( args ) != 3 ) {
-TypeError:
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a sequence of three floats" );
- }
-
- for( i = 0; i < 3; i++ ) {
- PyObject *item = PySequence_GetItem( args, i );
- PyObject *num = PyNumber_Float( item );
- Py_DECREF( item );
- if( !num )
- goto TypeError;
- size[i] = PyFloat_AS_DOUBLE( num );
- Py_DECREF( num );
- }
- memcpy( self->curve->size, size, sizeof( size ) );
-
- return 0;
-}
-
-/*
- * Count the number of splines in a Curve Object
- * int getNumCurves()
- */
-
-static PyObject *Curve_getNumCurves( BPy_Curve * self )
-{
- Nurb *ptrnurb;
- PyObject *ret_val;
- int num_curves = 0; /* start with no splines */
-
- /* get curve */
- ptrnurb = self->curve->nurb.first;
- if( ptrnurb ) { /* we have some nurbs in this curve */
- for(;;) {
- ++num_curves;
- ptrnurb = ptrnurb->next;
- if( !ptrnurb ) /* no more curves */
- break;
- }
- }
-
- ret_val = PyInt_FromLong( ( long ) num_curves );
-
- if( ret_val )
- return ret_val;
-
- /* oops! */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get number of curves" );
-}
-
-/*
- * get the key object linked to this curve
- */
-
-static PyObject *Curve_getKey( BPy_Curve * self )
-{
- PyObject *keyObj;
-
- if (self->curve->key)
- keyObj = Key_CreatePyObject(self->curve->key);
- else keyObj = EXPP_incr_ret(Py_None);
-
- return keyObj;
-}
-
-/*
- * count the number of points in a given spline
- * int getNumPoints( curve_num=0 )
- *
- */
-
-static PyObject *Curve_getNumPoints( BPy_Curve * self, PyObject * args )
-{
- Nurb *ptrnurb;
- PyObject *ret_val;
- int curve_num = 0; /* default spline number */
- int i;
-
- /* parse input arg */
- if( !PyArg_ParseTuple( args, "|i", &curve_num ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" ) );
-
- /* check arg - must be non-negative */
- if( curve_num < 0 )
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "argument must be non-negative" ) );
-
-
- /* walk the list of curves looking for our curve */
- ptrnurb = self->curve->nurb.first;
- if( !ptrnurb ) { /* no splines in this Curve */
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no splines in this Curve" ) );
- }
-
- for( i = 0; i < curve_num; i++ ) {
- ptrnurb = ptrnurb->next;
- if( !ptrnurb ) /* if zero, we ran just ran out of curves */
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "curve index out of range" ) );
- }
-
- /* pntsu is the number of points in curve */
- ret_val = PyInt_FromLong( ( long ) ptrnurb->pntsu );
-
- if( ret_val )
- return ret_val;
-
- /* oops! */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get number of points for curve" );
-}
-
-/*
- * Test whether a given spline of a Curve is a nurb
- * as opposed to a bezier
- * int isNurb( curve_num=0 )
- */
-
-static PyObject *Curve_isNurb( BPy_Curve * self, PyObject * args )
-{
- int curve_num = 0; /* default value */
- int is_nurb;
- Nurb *ptrnurb;
- PyObject *ret_val;
- int i;
-
- /* parse and check input args */
- if( !PyArg_ParseTuple( args, "|i", &curve_num ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" ) );
- }
- if( curve_num < 0 ) {
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "curve number must be non-negative" ) );
- }
-
- ptrnurb = self->curve->nurb.first;
-
- if( !ptrnurb ) /* no splines in this curve */
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no splines in this Curve" ) );
-
- for( i = 0; i < curve_num; i++ ) {
- ptrnurb = ptrnurb->next;
- if( !ptrnurb ) /* if zero, we ran just ran out of curves */
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "curve index out of range" ) );
- }
-
- /* right now, there are only two curve types, nurb and bezier. */
- is_nurb = ptrnurb->bp ? 1 : 0;
-
- ret_val = PyInt_FromLong( ( long ) is_nurb );
- if( ret_val )
- return ret_val;
-
- /* oops */
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get curve type" ) );
-}
-
-/* trying to make a check for closedness (cyclic), following on isNurb (above)
- copy-pasting done by antont@kyperjokki.fi */
-
-static PyObject *Curve_isCyclic( BPy_Curve * self, PyObject * args )
-{
- int curve_num = 0; /* default value */
- /* unused:*/
- /* int is_cyclic;
- * PyObject *ret_val;*/
- Nurb *ptrnurb;
- int i;
-
- /* parse and check input args */
- if( !PyArg_ParseTuple( args, "|i", &curve_num ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" ) );
- }
- if( curve_num < 0 ) {
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "curve number must be non-negative" ) );
- }
-
- ptrnurb = self->curve->nurb.first;
-
- if( !ptrnurb ) /* no splines in this curve */
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no splines in this Curve" ) );
-
- for( i = 0; i < curve_num; i++ ) {
- ptrnurb = ptrnurb->next;
- if( !ptrnurb ) /* if zero, we ran just ran out of curves */
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "curve index out of range" ) );
- }
-
- if( ptrnurb->flagu & CU_CYCLIC ){
- return EXPP_incr_ret_True();
- } else {
- return EXPP_incr_ret_False();
- }
-}
-
-
-/*
- * Curve_appendPoint( numcurve, new_point )
- * append a new point to indicated spline
- */
-
-static PyObject *Curve_appendPoint( BPy_Curve * self, PyObject * args )
-{
- int i;
- int nurb_num; /* index of curve we append to */
- PyObject *coord_args; /* coords for new point */
- Nurb *nurb = self->curve->nurb.first; /* first nurb in Curve */
-
-/* fixme - need to malloc new Nurb */
- if( !nurb )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError, "no nurbs in this Curve" ) );
-
- if( !PyArg_ParseTuple( args, "iO", &nurb_num, &coord_args ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected int, coords as arguments" ) );
-
- /*
- chase down the list of Nurbs looking for our curve.
- */
- for( i = 0; i < nurb_num; i++ ) {
- nurb = nurb->next;
- if( !nurb ) /* we ran off end of list */
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "curve index out of range" );
- }
- return CurNurb_appendPointToNurb( nurb, coord_args );
-}
-
-
-/****
- appendNurb( new_point )
- create a new nurb in the Curve and add the point param to it.
- returns a refernce to the newly created nurb.
-*****/
-
-static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * value )
-{
- Nurb *new_nurb;
- /* malloc new nurb */
- new_nurb = ( Nurb * ) MEM_callocN( sizeof( Nurb ), "appendNurb" );
- if( !new_nurb )
- return EXPP_ReturnPyObjError
- ( PyExc_MemoryError, "unable to malloc Nurb" );
-
- if( CurNurb_appendPointToNurb( new_nurb, value ) ) {
- new_nurb->resolu = self->curve->resolu;
- new_nurb->resolv = self->curve->resolv;
- new_nurb->hide = 0;
- new_nurb->flag = 1;
-
-
- if( new_nurb->bezt ) { /* do setup for bezt */
- new_nurb->type = CU_BEZIER;
- new_nurb->bezt->h1 = HD_ALIGN;
- new_nurb->bezt->h2 = HD_ALIGN;
- new_nurb->bezt->f1 = SELECT;
- new_nurb->bezt->f2 = SELECT;
- new_nurb->bezt->f3 = SELECT;
- new_nurb->bezt->hide = 0;
- /* calchandlesNurb( new_nurb ); */
- } else { /* set up bp */
- new_nurb->pntsv = 1;
- new_nurb->type = CU_NURBS;
- new_nurb->orderu = 4;
- new_nurb->flagu = 0;
- new_nurb->flagv = 0;
- new_nurb->bp->f1 = 0;
- new_nurb->bp->hide = 0;
- new_nurb->knotsu = 0;
- /*makenots( new_nurb, 1, new_nurb->flagu >> 1); */
- }
- BLI_addtail( &self->curve->nurb, new_nurb);
-
- } else {
- freeNurb( new_nurb );
- return NULL; /* with PyErr already set */
- }
-
- return CurNurb_CreatePyObject( new_nurb );
-}
-
-
-/*
- * Curve_update( )
- * method to update display list for a Curve.
- * used. after messing with control points
- */
-
-PyObject *Curve_update( BPy_Curve * self )
-{
- Nurb *nu = self->curve->nurb.first;
-
- /* recalculate handles for each curve: calchandlesNurb() will make
- * sure curves are bezier first */
- while( nu ) {
- calchandlesNurb ( nu );
- nu = nu->next;
- }
-
- Object_updateDag( (void*) self->curve );
-
- Py_RETURN_NONE;
-}
-
-/*
- * Curve_getMaterials
- *
- */
-
-static PyObject *Curve_getMaterials( BPy_Curve * self )
-{
- return EXPP_PyList_fromMaterialList( self->curve->mat,
- self->curve->totcol, 1 );
-}
-
-static int Curve_setMaterials( BPy_Curve *self, PyObject * value )
-{
- Material **matlist;
- int len;
-
- if( !PySequence_Check( value ) ||
- !EXPP_check_sequence_consistency( value, &Material_Type ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "sequence should only contain materials or None)" );
-
- len = PySequence_Size( value );
- if( len > 16 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "list can't have more than 16 materials" );
-
- /* free old material list (if it exists) and adjust user counts */
- if( self->curve->mat ) {
- Curve *cur = self->curve;
- int i;
- for( i = cur->totcol; i-- > 0; )
- if( cur->mat[i] )
- cur->mat[i]->id.us--;
- MEM_freeN( cur->mat );
- }
-
- /* build the new material list, increment user count, store it */
-
- matlist = EXPP_newMaterialList_fromPyList( value );
- EXPP_incr_mats_us( matlist, len );
- self->curve->mat = matlist;
- self->curve->totcol = (short)len;
-
-/**@ This is another ugly fix due to the weird material handling of blender.
- * it makes sure that object material lists get updated (by their length)
- * according to their data material lists, otherwise blender crashes.
- * It just stupidly runs through all objects...BAD BAD BAD.
- */
-
- test_object_materials( ( ID * ) self->curve );
-
- return 0;
-}
-
-/*****************************************************************************/
-/* Function: Curve_getBevOb */
-/* Description: Get the bevel object assign to the curve. */
-/*****************************************************************************/
-static PyObject *Curve_getBevOb( BPy_Curve * self)
-{
- if( self->curve->bevobj ) {
- return Object_CreatePyObject( self->curve->bevobj );
- }
-
- return EXPP_incr_ret( Py_None );
-}
-
-/*****************************************************************************/
-/* Function: Curve_newsetBevOb */
-/* Description: Assign a bevel object to the curve. */
-/*****************************************************************************/
-static int Curve_newsetBevOb( BPy_Curve * self, PyObject * args )
-{
-
- if (BPy_Object_Check( args ) && ((BPy_Object *)args)->object->data == self->curve )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "Can't bevel an object to itself" );
-
- return GenericLib_assignData(args, (void **) &self->curve->bevobj, 0, 0, ID_OB, OB_CURVE);
-}
-
-/*****************************************************************************/
-/* Function: Curve_getTaperOb */
-/* Description: Get the taper object assign to the curve. */
-/*****************************************************************************/
-
-static PyObject *Curve_getTaperOb( BPy_Curve * self)
-{
- if( self->curve->taperobj )
- return Object_CreatePyObject( self->curve->taperobj );
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: Curve_newsetTaperOb */
-/* Description: Assign a taper object to the curve. */
-/*****************************************************************************/
-
-static int Curve_newsetTaperOb( BPy_Curve * self, PyObject * args )
-{
- if (BPy_Object_Check( args ) && ((BPy_Object *)args)->object->data == self->curve )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "Can't taper an object to itself" );
-
- return GenericLib_assignData(args, (void **) &self->curve->taperobj, 0, 0, ID_OB, OB_CURVE);
-}
-
-/*****************************************************************************/
-/* Function: Curve_copy */
-/* Description: Return a copy of this curve data. */
-/*****************************************************************************/
-
-PyObject *Curve_copy( BPy_Curve * self )
-{
- BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */
- Curve *blcurve = 0; /* for actual Curve Data we create in Blender */
-
- /* copies the data */
- blcurve = copy_curve( self->curve ); /* first create the Curve Data in Blender */
-
- if( blcurve == NULL ) /* bail out if add_curve() failed */
- return ( EXPP_ReturnPyObjError
- ( PyExc_RuntimeError,
- "couldn't create Curve Data in Blender" ) );
-
- /* return user count to zero because add_curve() inc'd it */
- blcurve->id.us = 0;
-
- /* create python wrapper obj */
- pycurve = ( BPy_Curve * ) PyObject_NEW( BPy_Curve, &Curve_Type );
-
- if( pycurve == NULL )
- return ( EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create Curve Data object" ) );
-
- pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */
- return ( PyObject * ) pycurve;
-}
-
-
-/*
- * Curve_getIter
- *
- * create an iterator for our Curve.
- * this iterator returns the Nurbs for this Curve.
- * the iter_pointer always points to the next available item or null
- */
-
-static PyObject *Curve_getIter( BPy_Curve * self )
-{
- self->iter_pointer = self->curve->nurb.first;
-
- Py_INCREF( self );
- return ( PyObject * ) self;
-
-}
-
-
-/*
- * Curve_iterNext
- * get the next item.
- * iter_pointer always points to the next available element
- * or NULL if at the end of the list.
- */
-
-static PyObject *Curve_iterNext( BPy_Curve * self )
-{
- Nurb *pnurb;
-
- if( self->iter_pointer ) {
- pnurb = self->iter_pointer;
- self->iter_pointer = pnurb->next; /* advance iterator */
- if( (pnurb->type & 7) == CU_BEZIER || pnurb->pntsv <= 1 )
- return CurNurb_CreatePyObject( pnurb ); /* make a bpy_curnurb */
- else
- return SurfNurb_CreatePyObject( pnurb ); /* make a bpy_surfnurb */
- }
-
- /* if iter_pointer was null, we are at end */
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
-}
-
-/* tp_sequence methods */
-
-/*
- * Curve_length
- * returns the number of curves in a Curve
- * this is a tp_as_sequence method, not a regular instance method.
- */
-
-static int Curve_length( PyInstanceObject * inst )
-{
- if( BPy_Curve_Check( ( PyObject * ) inst ) )
- return ( ( int ) PyInt_AsLong
- ( Curve_getNumCurves( ( BPy_Curve * ) inst ) ) );
-
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "arg is not a BPy_Curve" );
-
-}
-
-/*
- * Curve_getNurb
- * returns the Nth nurb in a Curve.
- * 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 *Curve_getNurb( BPy_Curve * self, int n )
-{
- Nurb *pNurb;
- int i;
-
- /* bail if index < 0 */
- if( n < 0 )
- return ( EXPP_ReturnPyObjError( PyExc_IndexError,
- "index less than 0" ) );
- /* bail if no Nurbs in Curve */
- if( self->curve->nurb.first == 0 )
- return ( EXPP_ReturnPyObjError( PyExc_IndexError,
- "no Nurbs in this Curve" ) );
- /* set pointer to nth Nurb */
- for( pNurb = self->curve->nurb.first, i = 0;
- pNurb != 0 && i < n; pNurb = pNurb->next, ++i )
- /**/;
-
- if( !pNurb ) /* we came to the end of the list */
- return ( EXPP_ReturnPyObjError( PyExc_IndexError,
- "index out of range" ) );
-
- /* until there is a Surface BPyType, distinquish between a curve and a
- * surface based on whether it's a Bezier and the v size */
- if( (pNurb->type & 7) == CU_BEZIER || pNurb->pntsv <= 1 )
- return CurNurb_CreatePyObject( pNurb ); /* make a bpy_curnurb */
- else
- return SurfNurb_CreatePyObject( pNurb ); /* make a bpy_surfnurb */
-
-}
-
-/*
- * Curve_setNurb
- * In this case only remove the item, we could allow adding later.
- */
-static int Curve_setNurb( BPy_Curve * self, int n, PyObject * value )
-{
- Nurb *pNurb;
- int i;
-
- /* bail if index < 0 */
- if( n < 0 )
- return ( EXPP_ReturnIntError( PyExc_IndexError,
- "index less than 0" ) );
- /* bail if no Nurbs in Curve */
- if( self->curve->nurb.first == 0 )
- return ( EXPP_ReturnIntError( PyExc_IndexError,
- "no Nurbs in this Curve" ) );
- /* set pointer to nth Nurb */
- for( pNurb = self->curve->nurb.first, i = 0;
- pNurb != 0 && i < n; pNurb = pNurb->next, ++i )
- /**/;
-
- if( !pNurb ) /* we came to the end of the list */
- return ( EXPP_ReturnIntError( PyExc_IndexError,
- "index out of range" ) );
-
- if (value) {
- return ( EXPP_ReturnIntError( PyExc_RuntimeError,
- "assigning curves is not yet supported" ) );
- } else {
- BLI_remlink(&self->curve->nurb, pNurb);
- freeNurb(pNurb);
- }
- return 0;
-}
-
-/*****************************************************************************/
-/* Function: Curve_compare */
-/* Description: This compares 2 curve python types, == or != only. */
-/*****************************************************************************/
-static int Curve_compare( BPy_Curve * a, BPy_Curve * b )
-{
- return ( a->curve == b->curve ) ? 0 : -1;
-}
-
-/*****************************************************************************/
-/* Function: Curve_repr */
-/* Description: This is a callback function for the BPy_Curve type. It */
-/* builds a meaninful string to represent curve objects. */
-/*****************************************************************************/
-static PyObject *Curve_repr( BPy_Curve * self )
-{ /* used by 'repr' */
-
- return PyString_FromFormat( "[Curve \"%s\"]",
- self->curve->id.name + 2 );
-}
-
-/* attributes for curves */
-
-static PyGetSetDef Curve_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"pathlen",
- (getter)Curve_getPathLen, (setter)Curve_newsetPathLen,
- "The path length, used to set the number of frames for an animation (not the physical length)",
- NULL},
- {"totcol",
- (getter)Curve_getTotcol, (setter)NULL,
- "The maximum number of linked materials",
- NULL},
- {"flag",
- (getter)Curve_getMode, (setter)Curve_newsetMode,
- "The flag bitmask",
- NULL},
- {"bevresol",
- (getter)Curve_getBevresol, (setter)Curve_newsetBevresol,
- "The bevel resolution",
- NULL},
- {"resolu",
- (getter)Curve_getResolu, (setter)Curve_newsetResolu,
- "The resolution in U direction",
- NULL},
- {"resolv",
- (getter)Curve_getResolv, (setter)Curve_newsetResolv,
- "The resolution in V direction",
- NULL},
- {"width",
- (getter)Curve_getWidth, (setter)Curve_newsetWidth,
- "The curve width",
- NULL},
- {"ext1",
- (getter)Curve_getExt1, (setter)Curve_newsetExt1,
- "The extent1 value (for bevels)",
- NULL},
- {"ext2",
- (getter)Curve_getExt2, (setter)Curve_newsetExt2,
- "The extent2 value (for bevels)",
- NULL},
- {"loc",
- (getter)Curve_getLoc, (setter)Curve_newsetLoc,
- "The data location (from the center)",
- NULL},
- {"rot",
- (getter)Curve_getRot, (setter)Curve_newsetRot,
- "The data rotation (from the center)",
- NULL},
- {"size",
- (getter)Curve_getSize, (setter)Curve_newsetSize,
- "The data size (from the center)",
- NULL},
- {"bevob",
- (getter)Curve_getBevOb, (setter)Curve_newsetBevOb,
- "The bevel object",
- NULL},
- {"taperob",
- (getter)Curve_getTaperOb, (setter)Curve_newsetTaperOb,
- "The taper object",
- NULL},
- {"key",
- (getter)Curve_getKey, (setter)NULL,
- "The shape key for the curve (if any)",
- NULL},
- {"materials",
- (getter)Curve_getMaterials, (setter)Curve_setMaterials,
- "The materials associated with the curve",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-
-};
-
-/*****************************************************************************/
-/* Function: M_Curve_New */
-/* Python equivalent: Blender.Curve.New */
-/*****************************************************************************/
-static PyObject *M_Curve_New( PyObject * self, PyObject * args )
-{
- char *name = "Curve";
- BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */
- Curve *blcurve = 0; /* for actual Curve Data we create in Blender */
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected string argument or no argument" ) );
-
- blcurve = add_curve( name, OB_CURVE ); /* first create the Curve Data in Blender */
-
- if( blcurve == NULL ) /* bail out if add_curve() failed */
- return ( EXPP_ReturnPyObjError
- ( PyExc_RuntimeError,
- "couldn't create Curve Data in Blender" ) );
-
- /* return user count to zero because add_curve() inc'd it */
- blcurve->id.us = 0;
- /* create python wrapper obj */
- pycurve = ( BPy_Curve * ) PyObject_NEW( BPy_Curve, &Curve_Type );
-
- if( pycurve == NULL )
- return ( EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create Curve Data object" ) );
-
- pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */
-
- return ( PyObject * ) pycurve;
-}
-
-/*****************************************************************************/
-/* Function: M_Curve_Get */
-/* Python equivalent: Blender.Curve.Get */
-/*****************************************************************************/
-static PyObject *M_Curve_Get( PyObject * self, PyObject * args )
-{
-
- char *name = NULL;
- Curve *curv_iter;
- BPy_Curve *wanted_curv;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) ) /* expects nothing or a string */
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" ) );
- if( name ) { /*a name has been given */
- /* Use the name to search for the curve requested */
- wanted_curv = NULL;
- curv_iter = G.main->curve.first;
-
- while( ( curv_iter ) && ( wanted_curv == NULL ) ) {
-
- if( strcmp( name, curv_iter->id.name + 2 ) == 0 ) {
- wanted_curv = ( BPy_Curve * )
- PyObject_NEW( BPy_Curve, &Curve_Type );
- if( wanted_curv )
- wanted_curv->curve = curv_iter;
- }
-
- curv_iter = curv_iter->id.next;
- }
-
- if( wanted_curv == NULL ) { /* Requested curve doesn't exist */
- char error_msg[64];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Curve \"%s\" not found", name );
- return ( EXPP_ReturnPyObjError
- ( PyExc_NameError, error_msg ) );
- }
-
-
- return ( PyObject * ) wanted_curv;
- } /* end of if(name) */
- else {
- /* no name has been given; return a list of all curves by name. */
- PyObject *curvlist;
-
- curv_iter = G.main->curve.first;
- curvlist = PyList_New( 0 );
-
- if( curvlist == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" ) );
-
- while( curv_iter ) {
- BPy_Curve *found_cur =
- ( BPy_Curve * ) PyObject_NEW( BPy_Curve,
- &Curve_Type );
- found_cur->curve = curv_iter;
- PyList_Append( curvlist, ( PyObject * ) found_cur );
- Py_DECREF(found_cur);
- curv_iter = curv_iter->id.next;
- }
-
- return ( curvlist );
- } /* end of else */
-}
-
-/*****************************************************************************/
-/* Python method definitions for Blender.Curve module: */
-/*****************************************************************************/
-struct PyMethodDef M_Curve_methods[] = {
- {"New", ( PyCFunction ) M_Curve_New, METH_VARARGS, M_Curve_New_doc},
- {"Get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc},
- {"get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-
-/*****************************************************************************/
-/* Python BPy_Curve instance methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Curve_methods[] = {
- {"getName", ( PyCFunction ) Curve_getName,
- METH_NOARGS, "() - Return Curve Data name"},
- {"setName", ( PyCFunction ) Curve_setName,
- METH_VARARGS, "() - Sets Curve Data name"},
- {"getPathLen", ( PyCFunction ) Curve_getPathLen,
- METH_NOARGS, "() - Return Curve path length"},
- {"setPathLen", ( PyCFunction ) Curve_setPathLen,
- METH_VARARGS, "(int) - Sets Curve path length"},
- {"getTotcol", ( PyCFunction ) Curve_getTotcol,
- METH_NOARGS, "() - Return the number of materials of the curve"},
- {"setTotcol", ( PyCFunction ) Curve_setTotcol,
- METH_VARARGS, "(int) - Sets the number of materials of the curve"},
- {"getFlag", ( PyCFunction ) Curve_getMode,
- METH_NOARGS, "() - Return flag (see the doc for semantic)"},
- {"setFlag", ( PyCFunction ) Curve_setMode,
- METH_VARARGS, "(int) - Sets flag (see the doc for semantic)"},
- {"getBevresol", ( PyCFunction ) Curve_getBevresol,
- METH_NOARGS, "() - Return bevel resolution"},
- {"setBevresol", ( PyCFunction ) Curve_setBevresol,
- METH_VARARGS, "(int) - Sets bevel resolution"},
- {"getResolu", ( PyCFunction ) Curve_getResolu,
- METH_NOARGS, "() - Return U resolution"},
- {"setResolu", ( PyCFunction ) Curve_setResolu,
- METH_VARARGS, "(int) - Sets U resolution"},
- {"getResolv", ( PyCFunction ) Curve_getResolv,
- METH_NOARGS, "() - Return V resolution"},
- {"setResolv", ( PyCFunction ) Curve_setResolv,
- METH_VARARGS, "(int) - Sets V resolution"},
- {"getWidth", ( PyCFunction ) Curve_getWidth,
- METH_NOARGS, "() - Return curve width"},
- {"setWidth", ( PyCFunction ) Curve_setWidth,
- METH_VARARGS, "(int) - Sets curve width"},
- {"getExt1", ( PyCFunction ) Curve_getExt1,
- METH_NOARGS, "() - Returns extent 1 of the bevel"},
- {"setExt1", ( PyCFunction ) Curve_setExt1,
- METH_VARARGS, "(int) - Sets extent 1 of the bevel"},
- {"getExt2", ( PyCFunction ) Curve_getExt2,
- METH_NOARGS, "() - Return extent 2 of the bevel "},
- {"setExt2", ( PyCFunction ) Curve_setExt2,
- METH_VARARGS, "(int) - Sets extent 2 of the bevel "},
- {"getControlPoint", ( PyCFunction ) Curve_getControlPoint,
- METH_VARARGS, "(int numcurve,int numpoint) -\
-Gets a control point.Depending upon the curve type, returne a list of 4 or 9 floats"},
- {"setControlPoint", ( PyCFunction ) Curve_setControlPoint,
- METH_VARARGS, "(int numcurve,int numpoint,float x,float y,float z,\
-float w)(nurbs) or (int numcurve,int numpoint,float x1,...,x9(bezier)\
-Sets a control point "},
- {"getLoc", ( PyCFunction ) Curve_getLoc,
- METH_NOARGS, "() - Gets Location of the curve (a 3-tuple) "},
- {"setLoc", ( PyCFunction ) Curve_setLoc,
- METH_VARARGS, "(3-tuple) - Sets Location "},
- {"getRot", ( PyCFunction ) Curve_getRot,
- METH_NOARGS, "() - Gets curve rotation"},
- {"setRot", ( PyCFunction ) Curve_setRot,
- METH_VARARGS, "(3-tuple) - Sets curve rotation"},
- {"getSize", ( PyCFunction ) Curve_getSize,
- METH_NOARGS, "() - Gets curve size"},
- {"setSize", ( PyCFunction ) Curve_setSize,
- METH_VARARGS, "(3-tuple) - Sets curve size"},
- {"getNumCurves", ( PyCFunction ) Curve_getNumCurves,
- METH_NOARGS, "() - Gets number of curves in Curve"},
- {"getKey", ( PyCFunction ) Curve_getKey,
- METH_NOARGS, "() - Gets curve key"},
- {"isNurb", ( PyCFunction ) Curve_isNurb,
- METH_VARARGS,
- "(nothing or integer) - returns 1 if curve is type Nurb, O otherwise."},
- {"isCyclic", ( PyCFunction ) Curve_isCyclic,
- METH_VARARGS, "( nothing or integer ) - returns true if curve is cyclic (closed), false otherwise."},
- {"getNumPoints", ( PyCFunction ) Curve_getNumPoints,
- METH_VARARGS,
- "(nothing or integer) - returns the number of points of the specified curve"},
- {"appendPoint", ( PyCFunction ) Curve_appendPoint, METH_VARARGS,
- "( int numcurve, list of coordinates) - adds a new point to end of curve"},
- {"appendNurb", ( PyCFunction ) Curve_appendNurb, METH_O,
- "( new_nurb ) - adds a new nurb to the Curve"},
- {"update", ( PyCFunction ) Curve_update, METH_NOARGS,
- "( ) - updates display lists after changes to Curve"},
- {"getMaterials", ( PyCFunction ) Curve_getMaterials, METH_NOARGS,
- "() - returns list of materials assigned to this Curve"},
- {"getBevOb", ( PyCFunction ) Curve_getBevOb, METH_NOARGS,
- "() - returns Bevel Object assigned to this Curve"},
- {"setBevOb", ( PyCFunction ) Curve_setBevOb, METH_VARARGS,
- "() - assign a Bevel Object to this Curve"},
- {"getTaperOb", ( PyCFunction ) Curve_getTaperOb, METH_NOARGS,
- "() - returns Taper Object assigned to this Curve"},
- {"setTaperOb", ( PyCFunction ) Curve_setTaperOb, METH_VARARGS,
- "() - assign a Taper Object to this Curve"},
- {"__copy__", ( PyCFunction ) Curve_copy, METH_NOARGS,
- "() - make a copy of this curve data"},
- {"copy", ( PyCFunction ) Curve_copy, METH_NOARGS,
- "() - make a copy of this curve data"},
- {NULL, NULL, 0, NULL}
-};
-
-
-/*****************************************************************************/
-/* Python Curve_Type callback function prototypes: */
-/*****************************************************************************/
-static int Curve_compare( BPy_Curve * a, BPy_Curve * b );
-static PyObject *Curve_repr( BPy_Curve * msh );
-
-static PySequenceMethods Curve_as_sequence = {
- ( inquiry ) Curve_length, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) Curve_getNurb, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) Curve_setNurb, /* sq_ass_item - only so you can do del curve[i] */
- 0, /* sq_ass_slice */
- ( objobjproc ) 0, /* sq_contains */
- 0,
- 0
-};
-
-/*****************************************************************************/
-/* Python Curve_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Curve_Type = {
- PyObject_HEAD_INIT( NULL ) /* required macro */
- 0, /* ob_size */
- "Curve", /* tp_name */
- sizeof( BPy_Curve ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- NULL, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) NULL, /* tp_getattr */
- ( setattrfunc ) NULL, /* tp_setattr */
- ( cmpfunc ) Curve_compare, /* tp_compare */
- ( reprfunc ) Curve_repr, /* tp_repr */
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &Curve_as_sequence, /* 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; */
- /*** 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 ) Curve_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) Curve_iterNext, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_Curve_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- Curve_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: Curve_Init */
-/*****************************************************************************/
-PyObject *Curve_Init( void )
-{
- PyObject *submodule;
-
- if( PyType_Ready( &Curve_Type) < 0) /* set exception. -1 is failure */
- return NULL;
-
- submodule =
- Py_InitModule3( "Blender.Curve", M_Curve_methods,
- M_Curve_doc );
- return ( submodule );
-}
-
-
-/*
- * Curve_CreatePyObject
- * constructor to build a py object from blender data
- */
-
-PyObject *Curve_CreatePyObject( struct Curve * curve )
-{
- BPy_Curve *blen_object;
-
- blen_object = ( BPy_Curve * ) PyObject_NEW( BPy_Curve, &Curve_Type );
-
- if( blen_object == NULL ) {
- return ( NULL );
- }
- blen_object->curve = curve;
- return ( ( PyObject * ) blen_object );
-
-}
-
-struct Curve *Curve_FromPyObject( PyObject * py_obj )
-{
- BPy_Curve *blen_obj;
-
- blen_obj = ( BPy_Curve * ) py_obj;
- return ( blen_obj->curve );
-
-}
-
-/* #####DEPRECATED###### */
-
-PyObject *Curve_setName( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Curve_newsetName );
-}
-
-static PyObject *Curve_setPathLen( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetPathLen );
-}
-
-static PyObject *Curve_setTotcol( BPy_Curve * self, PyObject * args )
-{
- if( !PyArg_ParseTuple( args, "i", &( self->curve->totcol ) ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
- Py_RETURN_NONE;
-}
-
-PyObject *Curve_setMode( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetMode );
-}
-
-PyObject *Curve_setBevresol( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetBevresol);
-}
-
-PyObject *Curve_setResolu( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetResolu );
-}
-
-PyObject *Curve_setResolv( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetResolv );
-}
-
-PyObject *Curve_setWidth( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetWidth );
-}
-
-PyObject *Curve_setExt1( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetExt1 );
-}
-
-PyObject *Curve_setExt2( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetExt2 );
-}
-
-static PyObject *Curve_setLoc( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetLoc );
-}
-
-static PyObject *Curve_setRot( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetRot );
-}
-
-static PyObject *Curve_setSize( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetSize );
-}
-
-PyObject *Curve_setBevOb( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetBevOb );
-}
-
-PyObject *Curve_setTaperOb( BPy_Curve * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Curve_newsetTaperOb );
-}
-
diff --git a/source/blender/python/api2_2x/Curve.h b/source/blender/python/api2_2x/Curve.h
deleted file mode 100644
index b6c80058b77..00000000000
--- a/source/blender/python/api2_2x/Curve.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
deleted file mode 100644
index 621c72efc2a..00000000000
--- a/source/blender/python/api2_2x/Draw.c
+++ /dev/null
@@ -1,2197 +0,0 @@
-/*
- * $Id: Draw.c 12893 2007-12-15 18:24:16Z 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, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-/* This file is the Blender.Draw part of opy_draw.c, from the old
- * bpython/intern dir, with minor changes to adapt it to the new Python
- * implementation. Non-trivial original comments are marked with an
- * @ symbol at their beginning. */
-
-#include "Draw.h" /*This must come first*/
-
-#include "BLI_blenlib.h"
-#include "MEM_guardedalloc.h"
-#include "BMF_Api.h"
-#include "DNA_screen_types.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_object.h"
-#include "BKE_main.h"
-#include "BKE_utildefines.h"
-#include "BIF_gl.h"
-#include "BIF_mywindow.h"
-#include "BIF_screen.h"
-#include "BIF_space.h"
-#include "BIF_interface.h"
-#include "BIF_toolbox.h"
-#include "BPI_script.h" /* script struct */
-#include "Image.h" /* for accessing Blender.Image objects */
-#include "IMB_imbuf_types.h" /* for the IB_rect define */
-#include "interface.h"
-#include "mydevice.h" /*@ for all the event constants */
-#include "gen_utils.h"
-#include "Window.h"
-#include "../BPY_extern.h"
-
-/* used so we can get G.scene->r.cfra for getting the
-current image frame, some images change frame if they are a sequence */
-#include "DNA_scene_types.h"
-
-/* these delimit the free range for button events */
-#define EXPP_BUTTON_EVENTS_OFFSET 1001
-#define EXPP_BUTTON_EVENTS_MIN 0
-#define EXPP_BUTTON_EVENTS_MAX 15382 /* 16384 - 1 - OFFSET */
-
-#define ButtonObject_Check(v) ((v)->ob_type == &Button_Type)
-
-#define UI_METHOD_ERRORCHECK \
- if (check_button_event(&event) == -1)\
- return EXPP_ReturnPyObjError( PyExc_AttributeError,\
- "button event argument must be in the range [0, 16382]");\
- if (callback && !PyCallable_Check(callback))\
- return EXPP_ReturnPyObjError( PyExc_ValueError,\
- "callback is not a python function");\
-
-/* pointer to main dictionary defined in Blender.c */
-extern PyObject *g_blenderdict;
-
-/*@ hack to flag that window redraw has happened inside slider callback: */
-int EXPP_disable_force_draw = 0;
-
-/* forward declarations for internal functions */
-static void Button_dealloc( PyObject * self );
-static PyObject *Button_getattr( PyObject * self, char *name );
-static PyObject *Button_repr( PyObject * self );
-static PyObject *Button_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type);
-static int Button_setattr( PyObject * self, char *name, PyObject * v );
-
-static Button *newbutton( void );
-
-/* GUI interface routines */
-
-static void exit_pydraw( SpaceScript * sc, short error );
-static void exec_callback( SpaceScript * sc, PyObject * callback,
- PyObject * args );
-static void spacescript_do_pywin_buttons( SpaceScript * sc,
- unsigned short event );
-
-static PyObject *Method_Exit( PyObject * self );
-static PyObject *Method_Register( PyObject * self, PyObject * args );
-static PyObject *Method_Redraw( PyObject * self, PyObject * args );
-static PyObject *Method_Draw( PyObject * self );
-static PyObject *Method_Create( PyObject * self, PyObject * args );
-static PyObject *Method_UIBlock( PyObject * self, PyObject * args );
-
-static PyObject *Method_Button( PyObject * self, PyObject * args );
-static PyObject *Method_Menu( PyObject * self, PyObject * args );
-static PyObject *Method_Toggle( PyObject * self, PyObject * args );
-static PyObject *Method_Slider( PyObject * self, PyObject * args );
-static PyObject *Method_Scrollbar( PyObject * self, PyObject * args );
-static PyObject *Method_ColorPicker( PyObject * self, PyObject * args );
-static PyObject *Method_Normal( PyObject * self, PyObject * args );
-static PyObject *Method_Number( PyObject * self, PyObject * args );
-static PyObject *Method_String( PyObject * self, PyObject * args );
-static PyObject *Method_GetStringWidth( PyObject * self, PyObject * args );
-static PyObject *Method_Text( PyObject * self, PyObject * args );
-static PyObject *Method_Label( PyObject * self, PyObject * args );
-/* by Campbell: */
-static PyObject *Method_PupMenu( PyObject * self, PyObject * args );
-static PyObject *Method_PupIntInput( PyObject * self, PyObject * args );
-static PyObject *Method_PupFloatInput( PyObject * self, PyObject * args );
-static PyObject *Method_PupStrInput( PyObject * self, PyObject * args );
-static PyObject *Method_BeginAlign( PyObject * self, PyObject * args );
-static PyObject *Method_EndAlign( PyObject * self, PyObject * args );
-/* next by Jonathan Merritt (lancelet): */
-static PyObject *Method_Image( PyObject * self, PyObject * args);
-/* CLEVER NUMBUT */
-static PyObject *Method_PupBlock( PyObject * self, PyObject * args );
-
-static uiBlock *Get_uiBlock( void );
-
-static void py_slider_update( void *butv, void *data2_unused );
-
-/* hack to get 1 block for the UIBlock, only ever 1 at a time */
-static uiBlock *uiblock=NULL;
-
-static char Draw_doc[] = "The Blender.Draw submodule";
-
-static char Method_UIBlock_doc[] = "(drawfunc, x,y) - Popup dialog where buttons can be drawn (expemental)";
-
-static char Method_Register_doc[] =
- "(draw, event, button) - Register callbacks for windowing\n\n\
-(draw) A function to draw the screen, taking no arguments\n\
-(event) A function to handle events, taking 2 arguments (evt, val)\n\
- (evt) The event number\n\
- (val) The value modifier (for key and mouse press/release)\n\
-(button) A function to handle button events, taking 1 argument (evt)\n\
- (evt) The button number\n\n\
-A None object can be passed if a callback is unused.";
-
-
-static char Method_Redraw_doc[] = "([after]) - Queue a redraw event\n\n\
-[after=0] Determines whether the redraw is processed before\n\
-or after other input events.\n\n\
-Redraw events are buffered so that regardless of how many events\n\
-are queued the window only receives one redraw event.";
-
-static char Method_Draw_doc[] = "() - Force an immediate redraw\n\n\
-Forced redraws are not buffered, in other words the window is redrawn\n\
-exactly once for everytime this function is called.";
-
-
-static char Method_Create_doc[] =
- "(value) - Create a default Button object\n\n\
- (value) - The value to store in the button\n\n\
- Valid values are ints, floats, and strings";
-
-static char Method_Button_doc[] =
- "(name, event, x, y, width, height, [tooltip]) - Create a new Button \
-(push) button\n\n\
-(name) A string to display on the button\n\
-(event) The event number to pass to the button event function when activated\n\
-(x, y) The lower left coordinate of the button\n\
-(width, height) The button width and height\n\
-[tooltip=] The button's tooltip\n\n\
-This function can be called as Button() or PushButton().";
-
-static char Method_BeginAlign_doc[] =
- "Buttons after this function will draw aligned (button layout only)";
-
-static char Method_EndAlign_doc[] =
- "Use after BeginAlign() to stop aligning the buttons (button layout only).";
-
-static char Method_Menu_doc[] =
- "(name, event, x, y, width, height, default, [tooltip]) - Create a new Menu \
-button\n\n\
-(name) A string to display on the button\n\
-(event) The event number to pass to the button event function when activated\n\
-(x, y) The lower left coordinate of the button\n\
-(width, height) The button width and height\n\
-(default) The number of the option to be selected by default\n\
-[tooltip=" "] The button's tooltip\n\n\
-The menu options are specified through the name of the\n\
-button. Options are followed by a format code and separated\n\
-by the '|' (pipe) character.\n\
-Valid format codes are\n\
- %t - The option should be used as the title\n\
- %xN - The option should set the integer N in the button value.";
-
-static char Method_Toggle_doc[] =
- "(name, event, x, y, width, height, default, [tooltip]) - Create a new Toggle \
-button\n\n\
-(name) A string to display on the button\n\
-(event) The event number to pass to the button event function when activated\n\
-(x, y) The lower left coordinate of the button\n\
-(width, height) The button width and height\n\
-(default) An integer (0 or 1) specifying the default state\n\
-[tooltip=] The button's tooltip";
-
-
-static char Method_Slider_doc[] =
- "(name, event, x, y, width, height, initial, min, max, [update, tooltip]) - \
-Create a new Slider button\n\n\
-(name) A string to display on the button\n\
-(event) The event number to pass to the button event function when activated\n\
-(x, y) The lower left coordinate of the button\n\
-(width, height) The button width and height\n\
-(initial, min, max) Three values (int or float) specifying the initial \
- and limit values.\n\
-[update=1] A value controlling whether the slider will emit events as it \
-is edited.\n\
- A non-zero value (default) enables the events. A zero value supresses them.\n\
-[tooltip=] The button's tooltip";
-
-
-static char Method_Scrollbar_doc[] =
- "(event, x, y, width, height, initial, min, max, [update, tooltip]) - Create a \
-new Scrollbar\n\n\
-(event) The event number to pass to the button event function when activated\n\
-(x, y) The lower left coordinate of the button\n\
-(width, height) The button width and height\n\
-(initial, min, max) Three values (int or float) specifying the initial and limit values.\n\
-[update=1] A value controlling whether the slider will emit events as it is edited.\n\
- A non-zero value (default) enables the events. A zero value supresses them.\n\
-[tooltip=] The button's tooltip";
-
-static char Method_ColorPicker_doc[] =
- "(event, x, y, width, height, initial, [tooltip]) - Create a new Button \
-Color picker button\n\n\
-(event) The event number to pass to the button event function when the color changes\n\
-(x, y) The lower left coordinate of the button\n\
-(width, height) The button width and height\n\
-(initial) 3-Float tuple of the color (values between 0 and 1)\
-[tooltip=] The button's tooltip";
-
-static char Method_Normal_doc[] =
- "(event, x, y, width, height, initial, [tooltip]) - Create a new Button \
-Normal button (a sphere that you can roll to change the normal)\n\n\
-(event) The event number to pass to the button event function when the color changes\n\
-(x, y) The lower left coordinate of the button\n\
-(width, height) The button width and height - non square will gave odd results\n\
-(initial) 3-Float tuple of the normal vector (values between -1 and 1)\
-[tooltip=] The button's tooltip";
-
-static char Method_Number_doc[] =
- "(name, event, x, y, width, height, initial, min, max, [tooltip]) - Create a \
-new Number button\n\n\
-(name) A string to display on the button\n\
-(event) The event number to pass to the button event function when activated\n\
-(x, y) The lower left coordinate of the button\n\
-(width, height) The button width and height\n\
-(initial, min, max) Three values (int or float) specifying the initial and \
-limit values.\n\
-[tooltip=] The button's tooltip";
-
-static char Method_String_doc[] =
- "(name, event, x, y, width, height, initial, length, [tooltip]) - Create a \
-new String button\n\n\
-(name) A string to display on the button\n\
-(event) The event number to pass to the button event function when activated\n\
-(x, y) The lower left coordinate of the button\n\
-(width, height) The button width and height\n\
-(initial) The string to display initially\n\
-(length) The maximum input length\n\
-[tooltip=] The button's tooltip";
-
-static char Method_GetStringWidth_doc[] =
- "(text, font = 'normal') - Return the width in pixels of the given string\n\
-(font) The font size: 'normal' (default), 'small' or 'tiny'.";
-
-static char Method_Text_doc[] =
- "(text, font = 'normal') - Draw text onscreen\n\n\
-(text) The text to draw\n\
-(font) The font size: 'normal' (default), 'small' or 'tiny'.\n\n\
-This function returns the width of the drawn string.";
-
-static char Method_Label_doc[] =
- "(text, x, y) - Draw a text label onscreen\n\n\
-(text) The text to draw\n\
-(x, y) The lower left coordinate of the lable";
-
-static char Method_PupMenu_doc[] =
- "(string, maxrow = None) - Display a pop-up menu at the screen.\n\
-The contents of the pop-up are specified through the 'string' argument,\n\
-like with Draw.Menu.\n\
-'maxrow' is an optional int to control how many rows the pop-up should have.\n\
-Options are followed by a format code and separated\n\
-by the '|' (pipe) character.\n\
-Valid format codes are\n\
- %t - The option should be used as the title\n\
- %xN - The option should set the integer N in the button value.\n\n\
-Ex: Draw.PupMenu('OK?%t|QUIT BLENDER') # should be familiar ...";
-
-static char Method_PupIntInput_doc[] =
- "(text, default, min, max) - Display an int pop-up input.\n\
-(text) - text string to display on the button;\n\
-(default, min, max) - the default, min and max int values for the button;\n\
-Return the user input value or None on user exit";
-
-static char Method_PupFloatInput_doc[] =
- "(text, default, min, max, clickStep, floatLen) - Display a float pop-up input.\n\
-(text) - text string to display on the button;\n\
-(default, min, max) - the default, min and max float values for the button;\n\
-(clickStep) - float increment/decrement for each click on the button arrows;\n\
-(floatLen) - an integer defining the precision (number of decimal places) of \n\
-the float value show.\n\
-Return the user input value or None on user exit";
-
-static char Method_Image_doc[] =
- "(image, x, y, zoomx = 1.0, zoomy = 1.0, [clipx, clipy, clipw, cliph])) \n\
- - Draw an image.\n\
-(image) - Blender.Image to draw.\n\
-(x, y) - floats specifying the location of the image.\n\
-(zoomx, zoomy) - float zoom factors in horizontal and vertical directions.\n\
-(clipx, clipy, clipw, cliph) - integers specifying a clipping rectangle within the original image.";
-
-static char Method_PupStrInput_doc[] =
- "(text, default, max = 20) - Display a float pop-up input.\n\
-(text) - text string to display on the button;\n\
-(default) - the initial string to display (truncated to 'max' chars);\n\
-(max = 20) - The maximum number of chars the user can input;\n\
-Return the user input value or None on user exit";
-
-static char Method_PupBlock_doc[] =
- "(title, sequence) - Display a pop-up block.\n\
-(title) - The title of the block.\n\
-(sequence) - A sequence defining what the block contains. \
-The order of the list is the order of appearance, from top down.\n\
-Possible format for sequence items:\n\
-[value is an object created with Create]\n\
-\ttext: Defines a label in the block\n\
-\t(text, value, tooltip = ''): Defines a toggle button \n\
-\t(text, value, min, max, tooltip = ''): Defines a num or string button \n\
-\t\t\tdepending on the value.\n\
-\t\tFor string, max is the maximum length of the text and min is unused.\n\
-Return 1 if the pop-up is confirmed, 0 otherwise. \n\
-Warning: On cancel, the value objects are brought back to there previous values, \
-\texcept for string values which will still contain the modified values.\n";
-
-static char Method_Exit_doc[] = "() - Exit the windowing interface";
-
-/*This is needed for button callbacks. Any button that uses a callback gets added to this list.
- On the C side of drawing begin, this list should be cleared.
- Each entry is a tuple of the form (button, callback py object)
-*/
-PyObject *M_Button_List = NULL;
-
-static struct PyMethodDef Draw_methods[] = {
- {"Create", (PyCFunction)Method_Create, METH_VARARGS, Method_Create_doc},
- {"UIBlock", (PyCFunction)Method_UIBlock, METH_VARARGS, Method_UIBlock_doc},
- {"Button", (PyCFunction)Method_Button, METH_VARARGS, Method_Button_doc},
- {"Toggle", (PyCFunction)Method_Toggle, METH_VARARGS, Method_Toggle_doc},
- {"Menu", (PyCFunction)Method_Menu, METH_VARARGS, Method_Menu_doc},
- {"Slider", (PyCFunction)Method_Slider, METH_VARARGS, Method_Slider_doc},
- {"Scrollbar", (PyCFunction)Method_Scrollbar, METH_VARARGS, Method_Scrollbar_doc},
- {"ColorPicker", (PyCFunction)Method_ColorPicker, METH_VARARGS, Method_ColorPicker_doc},
- {"Normal", (PyCFunction)Method_Normal, METH_VARARGS, Method_Normal_doc},
- {"Number", (PyCFunction)Method_Number, METH_VARARGS, Method_Number_doc},
- {"String", (PyCFunction)Method_String, METH_VARARGS, Method_String_doc},
- {"GetStringWidth", (PyCFunction)Method_GetStringWidth, METH_VARARGS, Method_GetStringWidth_doc},
- {"Text", (PyCFunction)Method_Text, METH_VARARGS, Method_Text_doc},
- {"Label", (PyCFunction)Method_Label, METH_VARARGS, Method_Label_doc},
- {"PupMenu", (PyCFunction)Method_PupMenu, METH_VARARGS, Method_PupMenu_doc},
- {"PupIntInput", (PyCFunction)Method_PupIntInput, METH_VARARGS, Method_PupIntInput_doc},
- {"PupFloatInput", (PyCFunction)Method_PupFloatInput, METH_VARARGS, Method_PupFloatInput_doc},
- {"PupStrInput", (PyCFunction)Method_PupStrInput, METH_VARARGS, Method_PupStrInput_doc},
- {"PupBlock", (PyCFunction)Method_PupBlock, METH_VARARGS, Method_PupBlock_doc},
- {"Image", (PyCFunction)Method_Image, METH_VARARGS, Method_Image_doc},
- {"Exit", (PyCFunction)Method_Exit, METH_NOARGS, Method_Exit_doc},
- {"Redraw", (PyCFunction)Method_Redraw, METH_VARARGS, Method_Redraw_doc},
- {"Draw", (PyCFunction)Method_Draw, METH_NOARGS, Method_Draw_doc},
- {"Register", (PyCFunction)Method_Register, METH_VARARGS, Method_Register_doc},
- {"PushButton", (PyCFunction)Method_Button, METH_VARARGS, Method_Button_doc},
- {"BeginAlign", (PyCFunction)Method_BeginAlign, METH_VARARGS, Method_BeginAlign_doc},
- {"EndAlign", (PyCFunction)Method_EndAlign, METH_VARARGS, Method_EndAlign_doc},
- {NULL, NULL, 0, NULL}
-};
-
-PyTypeObject Button_Type = {
- PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
- "Button", /*tp_name */
- sizeof( Button ), /*tp_basicsize */
- 0, /*tp_itemsize */
- ( destructor ) Button_dealloc, /*tp_dealloc */
- ( printfunc ) 0, /*tp_print */
- ( getattrfunc ) Button_getattr, /*tp_getattr */
- ( setattrfunc ) Button_setattr, /*tp_setattr */
- NULL, /*tp_cmp */
- ( reprfunc ) Button_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 ***/
- (richcmpfunc)Button_richcmpr, /* 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; */
- 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
-};
-
-static void Button_dealloc( PyObject * self )
-{
- Button *but = ( Button * ) self;
-
- if( but->type == BSTRING_TYPE ) {
- if( but->val.asstr )
- MEM_freeN( but->val.asstr );
- }
-
- PyObject_DEL( self );
-}
-
-static PyObject *Button_getattr( PyObject * self, char *name )
-{
- Button *but = ( Button * ) self;
-
- if( strcmp( name, "val" ) == 0 ) {
- if( but->type == BINT_TYPE )
- return PyInt_FromLong( but->val.asint );
- else if( but->type == BFLOAT_TYPE )
- return PyFloat_FromDouble( but->val.asfloat );
- else if( but->type == BSTRING_TYPE )
- return PyString_FromString( but->val.asstr );
- else if( but->type == BVECTOR_TYPE )
- return Py_BuildValue( "fff", but->val.asvec[0], but->val.asvec[1], but->val.asvec[2] );
- }
-
- PyErr_SetString( PyExc_AttributeError, name );
- return NULL;
-}
-
-static int Button_setattr( PyObject * self, char *name, PyObject * v )
-{
- Button *but = ( Button * ) self;
-
- if( strcmp( name, "val" ) == 0 ) {
- if( but->type == BINT_TYPE && PyNumber_Check(v) ) {
- PyObject *pyVal = PyNumber_Int( v );
- if (pyVal) {
- but->val.asint = (int)PyInt_AS_LONG( pyVal );
- Py_DECREF(pyVal);
- return 0;
- }
- }
- else if( but->type == BFLOAT_TYPE && PyNumber_Check(v) ) {
- PyObject *pyVal = PyNumber_Float( v );
- if (pyVal) {
- but->val.asfloat = (float)PyFloat_AS_DOUBLE( pyVal );
- Py_DECREF(pyVal);
- return 0;
- }
- }
- else if( but->type == BVECTOR_TYPE ) {
- if ( PyArg_ParseTuple( v, "fff", but->val.asvec, but->val.asvec+1, but->val.asvec+2 ) )
- return 0;
- }
- else if( but->type == BSTRING_TYPE && PyString_Check(v) ) {
- char *newstr;
- unsigned int newlen;
-
- PyString_AsStringAndSize( v, &newstr, (int *)&newlen );
-
- if (newlen+1> UI_MAX_DRAW_STR)
- return EXPP_ReturnIntError( PyExc_ValueError, "Error: button string length exceeded max limit (399 chars).");
-
- /* if the length of the new string is the same as */
- /* the old one, just copy, else delete and realloc. */
- if( but->slen == newlen ) {
- BLI_strncpy( but->val.asstr, newstr,
- but->slen + 1 );
-
- return 0;
-
- } else {
- MEM_freeN( but->val.asstr );
- but->slen = newlen;
- but->val.asstr =
- MEM_mallocN( but->slen + 1,
- "button setattr" );
- BLI_strncpy( but->val.asstr, newstr,
- but->slen + 1 );
-
- return 0;
- }
- }
- } else {
- /*
- * Accessing the wrong attribute.
- */
- return EXPP_ReturnIntError( PyExc_AttributeError, name );
- }
-
- /*
- * Correct attribute but value is incompatible with current button value.
- */
- return EXPP_ReturnIntError( PyExc_ValueError, "value incompatible with current button type" );
-}
-
-static PyObject *Button_repr( PyObject * self )
-{
- return PyObject_Repr( Button_getattr( self, "val" ) );
-}
-
-static PyObject *Button_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type)
-{
- PyObject *ret, *valA=NULL, *valB=NULL;
- if (ButtonObject_Check(objectA))
- objectA = valA = Button_getattr( objectA, "val" );
- if (ButtonObject_Check(objectB))
- objectB = valB = Button_getattr( objectB, "val" );
- ret = PyObject_RichCompare(objectA, objectB, comparison_type);
- Py_XDECREF(valA); /* Button_getattr created with 1 ref, we dont care about them now */
- Py_XDECREF(valB);
- return ret;
-}
-
-
-static Button *newbutton( void )
-{
- Button *but = NULL;
-
- but = ( Button * ) PyObject_NEW( Button, &Button_Type );
- but->tooltip[0] = 0; /*NULL-terminate tooltip string*/
- but->tooltip[255] = 0; /*necassary to insure we always have a NULL-terminated string, as
- according to the docs strncpy doesn't do this for us.*/
- return but;
-}
-
-/* GUI interface routines */
-
-static void exit_pydraw( SpaceScript * sc, short err )
-{
- Script *script = NULL;
-
- if( !sc || !sc->script )
- return;
-
- script = sc->script;
-
- if( err ) {
- PyErr_Print( );
- script->flags = 0; /* mark script struct for deletion */
- error( "Python script error: check console" );
- scrarea_queue_redraw( sc->area );
- }
-
- BPy_Set_DrawButtonsList(sc->but_refs);
- BPy_Free_DrawButtonsList(); /*clear all temp button references*/
- sc->but_refs = NULL;
-
- Py_XDECREF( ( PyObject * ) script->py_draw );
- Py_XDECREF( ( PyObject * ) script->py_event );
- Py_XDECREF( ( PyObject * ) script->py_button );
-
- script->py_draw = script->py_event = script->py_button = NULL;
-}
-
-static void exec_callback( SpaceScript * sc, PyObject * callback,
- PyObject * args )
-{
- PyObject *result = PyObject_CallObject( callback, args );
-
- if( result == NULL && sc->script ) { /* errors in the script */
-
- if( sc->script->lastspace == SPACE_TEXT ) { /*if it can be an ALT+P script */
- Text *text = G.main->text.first;
-
- while( text ) { /* find it and free its compiled code */
-
- if( !strcmp
- ( text->id.name + 2,
- sc->script->id.name + 2 ) ) {
- BPY_free_compiled_text( text );
- break;
- }
-
- text = text->id.next;
- }
- }
- exit_pydraw( sc, 1 );
- }
-
- Py_XDECREF( result );
- Py_DECREF( args );
-}
-
-/* BPY_spacescript_do_pywin_draw, the static spacescript_do_pywin_buttons and
- * BPY_spacescript_do_pywin_event are the three functions responsible for
- * calling the draw, buttons and event callbacks registered with Draw.Register
- * (see Method_Register below). They are called (only the two BPY_ ones)
- * from blender/src/drawscript.c */
-
-void BPY_spacescript_do_pywin_draw( SpaceScript * sc )
-{
- uiBlock *block;
- char butblock[20];
- Script *script = sc->script;
-
- sprintf( butblock, "win %d", curarea->win );
- block = uiNewBlock( &curarea->uiblocks, butblock, UI_EMBOSSX,
- UI_HELV, curarea->win );
-
- if( script->py_draw ) {
- if (sc->but_refs) {
- BPy_Set_DrawButtonsList(sc->but_refs);
- BPy_Free_DrawButtonsList(); /*clear all temp button references*/
- }
- sc->but_refs = PyList_New(0);
- BPy_Set_DrawButtonsList(sc->but_refs);
-
- glPushAttrib( GL_ALL_ATTRIB_BITS );
- exec_callback( sc, script->py_draw, Py_BuildValue( "()" ) );
- glPopAttrib( );
- } else {
- glClearColor( 0.4375, 0.4375, 0.4375, 0.0 );
- glClear( GL_COLOR_BUFFER_BIT );
- }
-
- uiDrawBlock( block );
-
- curarea->win_swap = WIN_BACK_OK;
-}
-
-static void spacescript_do_pywin_buttons( SpaceScript * sc,
- unsigned short event )
-{
- if( sc->script->py_button )
- exec_callback( sc, sc->script->py_button,
- Py_BuildValue( "(i)", event ) );
-}
-
-void BPY_spacescript_do_pywin_event( SpaceScript * sc, unsigned short event,
- short val, char ascii )
-{
- if( event == QKEY && G.qual & ( LR_ALTKEY | LR_CTRLKEY ) ) {
- /* finish script: user pressed ALT+Q or CONTROL+Q */
- Script *script = sc->script;
-
- exit_pydraw( sc, 0 );
-
- script->flags &= ~SCRIPT_GUI; /* we're done with this script */
-
- return;
- }
-
- if (val) {
-
- if (uiDoBlocks( &curarea->uiblocks, event, 1 ) != UI_NOTHING) event = 0;
-
- if (event == UI_BUT_EVENT) {
- /* check that event is in free range for script button events;
- * read the comment before check_button_event() below to understand */
- if (val >= EXPP_BUTTON_EVENTS_OFFSET && val < 0x4000)
- spacescript_do_pywin_buttons(sc, val - EXPP_BUTTON_EVENTS_OFFSET);
- return;
- }
- }
-
- /* We use the "event" main module var, used by scriptlinks, to pass the ascii
- * value to event callbacks (gui/event/button callbacks are not allowed
- * inside scriptlinks, so this is ok) */
- if( sc->script->py_event ) {
- int pass_ascii = 0;
- if (ascii > 31 && ascii != 127) {
- pass_ascii = 1;
- EXPP_dict_set_item_str(g_blenderdict, "event",
- PyInt_FromLong((long)ascii));
- }
- exec_callback( sc, sc->script->py_event,
- Py_BuildValue( "(ii)", event, val ) );
- if (pass_ascii)
- EXPP_dict_set_item_str(g_blenderdict, "event",
- PyString_FromString(""));
- }
-}
-
-static void exec_but_callback(void *pyobj, void *data)
-{
- PyObject *result;
- PyObject *pyvalue = NULL;
- uiBut *but = (uiBut *)data;
- PyObject *arg;
- PyObject *callback = (PyObject *)pyobj;
-
- double value = ui_get_but_val(but);
-
- if (callback==NULL || callback == Py_None)
- return;
-
- /* Button types support
- case MENU:
- case TEX:
- case TOG:
- case NUMSLI:
- case NUM:
- case COL:
- case BUT_NORMAL:
- case BUT */
- switch (but->type) {
- case TEX:
- /*printf("TEX\n");*/
- pyvalue = PyString_FromString( (char *)but->poin );
- break;
- case NUM:
- case NUMSLI:
- case TOG:
- case MENU:
- if (but->pointype==FLO) {
- /*printf("FLO\n");*/
- pyvalue = PyFloat_FromDouble( (float)value );
- } else if (but->pointype==INT) {
- /*printf("INT\n");*/
- pyvalue = PyInt_FromLong( (int)value );
- } else if (but->pointype==SHO) {
- /*printf("SHO\n");*/
- pyvalue = PyInt_FromLong( (short)value );
- }
- break;
- case COL:
- case BUT_NORMAL:
- {
- float vec[3];
- VECCOPY(vec, (float *)but->poin);
- pyvalue = Py_BuildValue("(fff)", vec[0], vec[1], vec[2]);
- break;
- }
- case BUT:
- pyvalue = Py_None;
- Py_INCREF(pyvalue);
- break;
- default:
- pyvalue = Py_None;
- Py_INCREF(pyvalue);
- printf("Error, no button type matched.");
- }
-
- arg = PyTuple_New( 2 );
- if (uiblock==NULL)
- PyTuple_SetItem( arg, 0, PyInt_FromLong(but->retval - EXPP_BUTTON_EVENTS_OFFSET) );
- else
- PyTuple_SetItem( arg, 0, PyInt_FromLong(but->retval) );
-
- PyTuple_SetItem( arg, 1, pyvalue );
-
- result = PyObject_CallObject( callback, arg );
- Py_DECREF(arg);
-
- if (!result) {
- Py_DECREF(pyvalue);
- PyErr_Print( );
- error( "Python script error: check console" );
- }
- Py_XDECREF( result );
-}
-
-/*note that this function populates the drawbutton ref lists.*/
-static void set_pycallback(uiBut *ubut, PyObject *callback, Button *but)
-{
- PyObject *tuple;
- if (!callback || !PyCallable_Check(callback)) {
- if (M_Button_List && but) {
- PyList_Append(M_Button_List, (PyObject*)but);
- }
- return;
- }
-
- if (M_Button_List) {
- if (but) tuple = PyTuple_New(2);
- else tuple = PyTuple_New(1);
-
- /*the tuple API mandates this*/
- Py_XINCREF(callback);
- Py_XINCREF(but); /*this checks for NULL*/
-
- PyTuple_SET_ITEM(tuple, 0, callback);
- if (but) PyTuple_SET_ITEM(tuple, 1, (PyObject*)but);
-
- PyList_Append(M_Button_List, tuple);
- Py_DECREF(tuple); /*we have to do this to aovid double references.*/
-
- uiButSetFunc(ubut, exec_but_callback, callback, ubut);
- }
-}
-
-void BPy_Set_DrawButtonsList(void *list)
-{
- M_Button_List = list;
-}
-
-/*this MUST be called after doing UI stuff.*/
-void BPy_Free_DrawButtonsList(void)
-{
- /*Clear the list.*/
- if (M_Button_List) {
- PyList_SetSlice(M_Button_List, 0, PyList_Size(M_Button_List), NULL);
- Py_DECREF(M_Button_List);
- M_Button_List = NULL;
- }
-}
-
-static PyObject *Method_Exit( PyObject * self )
-{
- SpaceScript *sc;
- Script *script;
-
- /* if users call Draw.Exit when we are already out of the SPACE_SCRIPT, we
- * simply return, for compatibility */
- if( curarea->spacetype == SPACE_SCRIPT )
- sc = curarea->spacedata.first;
- else
- Py_RETURN_NONE;
-
- exit_pydraw( sc, 0 );
-
- script = sc->script;
-
- /* remove our lock to the current namespace */
- script->flags &= ~SCRIPT_GUI;
-
- Py_RETURN_NONE;
-}
-
-/* Method_Register (Draw.Register) registers callbacks for drawing, events
- * and gui button events, so a script can continue executing after the
- * interpreter reached its end and returned control to Blender. Everytime
- * the SPACE_SCRIPT window with this script is redrawn, the registered
- * callbacks are executed. */
-static PyObject *Method_Register( PyObject * self, PyObject * args )
-{
- PyObject *newdrawc = NULL, *neweventc = NULL, *newbuttonc = NULL;
- SpaceScript *sc;
- Script *script;
- int startspace = 0;
-
- if( !PyArg_ParseTuple
- ( args, "O|OO", &newdrawc, &neweventc, &newbuttonc ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected one or three PyObjects" );
-
- if( !PyCallable_Check( newdrawc ) )
- newdrawc = NULL;
- if( !PyCallable_Check( neweventc ) )
- neweventc = NULL;
- if( !PyCallable_Check( newbuttonc ) )
- newbuttonc = NULL;
-
- if( !( newdrawc || neweventc || newbuttonc ) )
- Py_RETURN_NONE;
-
- startspace = curarea->spacetype;
-
- /* first make sure the current area is of type SPACE_SCRIPT */
- if( startspace != SPACE_SCRIPT )
- newspace( curarea, SPACE_SCRIPT );
-
- sc = curarea->spacedata.first;
-
- /* There are two kinds of scripts:
- * a) those that simply run, finish and return control to Blender;
- * b) those that do like 'a)' above but leave callbacks for drawing,
- * events and button events, with this Method_Register (Draw.Register
- * in Python). These callbacks are called by scriptspaces (Scripts windows).
- *
- * We need to flag scripts that leave callbacks so their namespaces are
- * not deleted when they 'finish' execution, because the callbacks will
- * still need the namespace.
- */
-
- /* Let's see if this is a new script */
- script = G.main->script.first;
- while (script) {
- if (script->flags & SCRIPT_RUNNING) break;
- script = script->id.next;
- }
-
- if( !script ) {
- /* not new, it's a left callback calling Register again */
- script = sc->script;
- if( !script ) {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Draw.Register can't be used inside script links" );
- }
- }
- else sc->script = script;
-
- /* Now we have the right script and can set a lock so its namespace can't be
- * deleted for as long as we need it */
- script->flags |= SCRIPT_GUI;
-
- /* save the last space so we can go back to it upon finishing */
- if( !script->lastspace )
- script->lastspace = startspace;
-
- /* clean the old callbacks */
- exit_pydraw( sc, 0 );
-
- /* prepare the new ones and insert them */
- Py_XINCREF( newdrawc );
- Py_XINCREF( neweventc );
- Py_XINCREF( newbuttonc );
-
- script->py_draw = newdrawc;
- script->py_event = neweventc;
- script->py_button = newbuttonc;
-
- scrarea_queue_redraw( sc->area );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Method_Redraw( PyObject * self, PyObject * args )
-{
- int after = 0;
-
- if( !PyArg_ParseTuple( args, "|i", &after ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument (or nothing)" );
-
- if( after )
- addafterqueue( curarea->win, REDRAW, 1 );
- else
- scrarea_queue_winredraw( curarea );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Method_Draw( PyObject * self )
-{
- /*@ If forced drawing is disable queue a redraw event instead */
- if( EXPP_disable_force_draw ) {
- scrarea_queue_winredraw( curarea );
- Py_RETURN_NONE;
- }
-
- scrarea_do_windraw( curarea );
-
- screen_swapbuffers( );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Method_Create( PyObject * self, PyObject * args )
-{
- Button *but = NULL;
- PyObject *val;
- char *newstr;
-
- but = newbutton();
- /* If this function dosnt sucseed this will need to be deallocated,
- * make sure the type is NOT BSTRING_TYPE before deallocing -1 is ok.
- * so we dont dealloc with an uninitialized value wich would be bad! */
- if ( PyArg_ParseTuple( args, "fff", but->val.asvec, but->val.asvec+1, but->val.asvec+2 ) ) {
- but->type = BVECTOR_TYPE;
-
- } else if ( PyArg_ParseTuple( args, "O!", &PyFloat_Type, &val ) ) {
- but->val.asfloat = (float)PyFloat_AS_DOUBLE(val);
- but->type = BFLOAT_TYPE;
-
- } else if ( PyArg_ParseTuple( args, "O!", &PyInt_Type, &val ) ) {
- but->val.asint = (int)PyInt_AS_LONG(val);
- but->type = BINT_TYPE;
-
- } else if ( PyArg_ParseTuple( args, "s#", &newstr, &but->slen ) ) {
- if (but->slen + 1 > UI_MAX_DRAW_STR) {
- but->type = -1;
- Py_DECREF((PyObject *)but); /* will remove */
- but = NULL;
- PyErr_SetString( PyExc_TypeError, "string is longer then 399 chars");
- } else {
- but->type = BSTRING_TYPE;
- but->val.asstr = MEM_mallocN( but->slen + 1, "button string" );
- BLI_strncpy( but->val.asstr, newstr, but->slen+1 );
- }
-
- } else {
- but->type = -1;
- Py_DECREF((PyObject *)but); /* will remove */
- but = NULL;
- PyErr_SetString( PyExc_TypeError, "expected string, float, int or 3-float tuple argument" );
- }
-
- if (but != NULL) {
- PyErr_Clear();
- }
-
- return (PyObject*) but;
-}
-
-
-static PyObject *Method_UIBlock( PyObject * self, PyObject * args )
-{
- PyObject *val = NULL;
- PyObject *result = NULL;
- ListBase listb= {NULL, NULL};
-
- if ( !PyArg_ParseTuple( args, "O", &val ) || !PyCallable_Check( val ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected 1 python function and 2 ints" );
-
- if (uiblock)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot run more then 1 UIBlock at a time" );
-
- BPy_Set_DrawButtonsList(PyList_New(0));
-
- mywinset(G.curscreen->mainwin);
- uiblock= uiNewBlock(&listb, "numbuts", UI_EMBOSS, UI_HELV, G.curscreen->mainwin);
-
- uiBlockSetFlag(uiblock, UI_BLOCK_LOOP|UI_BLOCK_REDRAW);
- result = PyObject_CallObject( val, Py_BuildValue( "()" ) );
-
- if (!result) {
- PyErr_Print( );
- error( "Python script error: check console" );
- } else {
- /* copied from do_clever_numbuts in toolbox.c */
-
- /* Clear all events so tooltips work, this is not ideal and
- only needed because calls from the menu still have some events
- left over when do_clever_numbuts is called.
- Calls from keyshortcuts do not have this problem.*/
- ScrArea *sa;
- BWinEvent temp_bevt;
- for (sa= G.curscreen->areabase.first; sa; sa= sa->next) {
- if(sa->win) {
- while( bwin_qread( sa->win, &temp_bevt ) ) {}
- }
- if(sa->headwin) {
- while( bwin_qread( sa->headwin, &temp_bevt ) ) {}
- }
- }
- /* Done clearing events */
-
- uiBoundsBlock(uiblock, 5);
- uiDoBlocks(&listb, 0, 1);
- }
- uiFreeBlocks(&listb);
- uiblock = NULL;
- BPy_Free_DrawButtonsList(); /*clear all temp button references*/
-
- Py_XDECREF( result );
- Py_RETURN_NONE;
-}
-
-void Set_uiBlock(uiBlock *block)
-{
- uiblock = block;
-}
-
-static uiBlock *Get_uiBlock( void )
-{
- char butblock[32];
- /* Global, used now for UIBlock */
- if (uiblock) {
- return uiblock;
- }
- /* Local */
- sprintf( butblock, "win %d", curarea->win );
-
- return uiGetBlock( butblock, curarea );
-}
-
-
-/* We restrict the acceptable event numbers to a proper "free" range
- * according to other spaces in Blender.
- * winqread***space() (space events callbacks) use short for events
- * (called 'val' there) and we also translate by EXPP_BUTTON_EVENTS_OFFSET
- * to get rid of unwanted events (check BPY_do_pywin_events above for
- * explanation). This function takes care of that and proper checking: */
-static int check_button_event(int *event) {
- if ((*event < EXPP_BUTTON_EVENTS_MIN) ||
- (*event > EXPP_BUTTON_EVENTS_MAX)) {
- return -1;
- }
- if (uiblock==NULL) /* For UIBlock we need non offset UI elements */
- *event += EXPP_BUTTON_EVENTS_OFFSET;
- return 0;
-}
-
-static PyObject *Method_BeginAlign( PyObject * self, PyObject * args )
-{
- uiBlock *block = Get_uiBlock( );
-
- if (block)
- uiBlockBeginAlign(block);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Method_EndAlign( PyObject * self, PyObject * args )
-{
- uiBlock *block = Get_uiBlock( );
-
- if (block)
- uiBlockEndAlign(block);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Method_Button( PyObject * self, PyObject * args )
-{
- uiBlock *block;
- char *name, *tip = NULL;
- int event;
- int x, y, w, h;
- PyObject *callback=NULL;
-
- if( !PyArg_ParseTuple( args, "siiiii|sO", &name, &event,
- &x, &y, &w, &h, &tip, &callback ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string, five ints and optionally string and callback arguments" );
-
- UI_METHOD_ERRORCHECK;
-
- block = Get_uiBlock( );
- if( block ) {
- uiBut *ubut = uiDefBut( block, BUT, event, name, (short)x, (short)y, (short)w, (short)h, 0, 0, 0, 0, 0, tip );
- set_pycallback(ubut, callback, NULL);
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *Method_Menu( PyObject * self, PyObject * args )
-{
- uiBlock *block;
- char *name, *tip = NULL;
- int event, def;
- int x, y, w, h;
- Button *but;
- PyObject *callback=NULL;
-
- if( !PyArg_ParseTuple( args, "siiiiii|sO", &name, &event,
- &x, &y, &w, &h, &def, &tip, &callback ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string, six ints and optionally string and callback arguments" );
-
- UI_METHOD_ERRORCHECK;
-
- but = newbutton( );
- but->type = BINT_TYPE;
- but->val.asint = def;
- if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP);
-
- block = Get_uiBlock( );
- if( block ) {
- uiBut *ubut = uiDefButI( block, MENU, event, name, (short)x, (short)y, (short)w, (short)h,
- &but->val.asint, 0, 0, 0, 0, but->tooltip );
- set_pycallback(ubut, callback, but);
- }
- return ( PyObject * ) but;
-}
-
-static PyObject *Method_Toggle( PyObject * self, PyObject * args )
-{
- uiBlock *block;
- char *name, *tip = NULL;
- int event;
- int x, y, w, h, def;
- Button *but;
- PyObject *callback=NULL;
-
- if( !PyArg_ParseTuple( args, "siiiiii|sO", &name, &event,
- &x, &y, &w, &h, &def, &tip, &callback ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string, six ints and optionally string and callback arguments" );
-
- UI_METHOD_ERRORCHECK;
-
- but = newbutton( );
- but->type = BINT_TYPE;
- but->val.asint = def;
- if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP);
-
- block = Get_uiBlock( );
- if( block ) {
- uiBut *ubut = uiDefButI( block, TOG, event, name, (short)x, (short)y, (short)w, (short)h,
- &but->val.asint, 0, 0, 0, 0, but->tooltip );
- set_pycallback(ubut, callback, but);
- }
- return ( PyObject * ) but;
-}
-
-/*@DO NOT TOUCH THIS FUNCTION !
- Redrawing a slider inside its own callback routine is actually forbidden
- with the current toolkit architecture (button routines are not reentrant).
- But it works anyway.
- XXX This is condemned to be dinosource in future - it's a hack.
- */
-
-static void py_slider_update( void *butv, void *data2_unused )
-{
- uiBut *but = butv;
- PyObject *ref = Py_BuildValue( "(i)", SPACE_VIEW3D );
- PyObject *ret = NULL;
-
- EXPP_disable_force_draw = 1;
- /*@ Disable forced drawing, otherwise the button object which
- * is still being used might be deleted */
-
- curarea->win_swap = WIN_BACK_OK;
- /* removed global uiFrontBuf (contact ton when this goes wrong here) */
-
- disable_where_script( 1 );
-
- spacescript_do_pywin_buttons( curarea->spacedata.first,
- (unsigned short)uiButGetRetVal( but ) - EXPP_BUTTON_EVENTS_OFFSET );
-
- /* XXX useless right now, investigate better before a bcon 5 */
- ret = M_Window_Redraw( 0, ref );
-
- Py_XDECREF(ref);
- Py_XDECREF(ret);
-
- disable_where_script( 0 );
-
- EXPP_disable_force_draw = 0;
-}
-
-static PyObject *Method_Slider( PyObject * self, PyObject * args )
-{
- uiBlock *block;
- char *name, *tip = NULL;
- int event;
- int x, y, w, h, realtime = 1;
- Button *but;
- PyObject *mino, *maxo, *inio;
- PyObject *callback=NULL;
-
- if( !PyArg_ParseTuple( args, "siiiiiOOO|isO", &name, &event,
- &x, &y, &w, &h, &inio, &mino, &maxo, &realtime,
- &tip, &callback ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string, five ints, three PyObjects\n\
- and optionally int, string and callback arguments" );
-
- if(realtime && uiblock)
- realtime = 0; /* realtime dosnt work with UIBlock */
-
- UI_METHOD_ERRORCHECK;
-
- but = newbutton( );
-
- if( PyFloat_Check( inio ) ) {
- float ini, min, max;
-
- ini = (float)PyFloat_AsDouble( inio );
- min = (float)PyFloat_AsDouble( mino );
- max = (float)PyFloat_AsDouble( maxo );
-
- but->type = BFLOAT_TYPE;
- but->val.asfloat = ini;
- if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP);
-
- block = Get_uiBlock( );
- if( block ) {
- uiBut *ubut;
- ubut = uiDefButF( block, NUMSLI, event, name, (short)x, (short)y, (short)w,
- (short)h, &but->val.asfloat, min, max, 0, 0,
- but->tooltip );
- if( realtime )
- uiButSetFunc( ubut, py_slider_update, ubut, NULL );
- else
- set_pycallback(ubut, callback, but);
- }
- } else {
- int ini, min, max;
-
- ini = PyInt_AsLong( inio );
- min = PyInt_AsLong( mino );
- max = PyInt_AsLong( maxo );
-
- but->type = BINT_TYPE;
- but->val.asint = ini;
- if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP);
-
- block = Get_uiBlock( );
- if( block ) {
- uiBut *ubut;
- ubut = uiDefButI( block, NUMSLI, event, name, (short)x, (short)y, (short)w,
- (short)h, &but->val.asint, (float)min, (float)max, 0, 0,
- but->tooltip );
- if( realtime )
- uiButSetFunc( ubut, py_slider_update, ubut, NULL );
- else
- set_pycallback(ubut, callback, but);
- }
- }
- return ( PyObject * ) but;
-}
-
-static PyObject *Method_Scrollbar( PyObject * self, PyObject * args )
-{
- char *tip = NULL;
- uiBlock *block;
- int event;
- int x, y, w, h, realtime = 1;
- Button *but;
- PyObject *mino, *maxo, *inio;
- float ini, min, max;
- uiBut *ubut;
-
- if( !PyArg_ParseTuple( args, "iiiiiOOO|isO", &event, &x, &y, &w, &h,
- &inio, &mino, &maxo, &realtime, &tip ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected five ints, three PyObjects and optionally\n\
-another int and string as arguments" );
-
- if( !PyNumber_Check( inio ) || !PyNumber_Check( inio )
- || !PyNumber_Check( inio ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected numbers for initial, min, and max" );
-
- if (check_button_event(&event) == -1)
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "button event argument must be in the range [0, 16382]");
-
- but = newbutton( );
- if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP);
-
- if( PyFloat_Check( inio ) )
- but->type = BFLOAT_TYPE;
- else
- but->type = BINT_TYPE;
-
- ini = (float)PyFloat_AsDouble( inio );
- min = (float)PyFloat_AsDouble( mino );
- max = (float)PyFloat_AsDouble( maxo );
-
- block = Get_uiBlock( );
-
- if( block ) {
- if( but->type == BFLOAT_TYPE ) {
- but->val.asfloat = ini;
- ubut = uiDefButF( block, SCROLL, event, "", (short)x, (short)y, (short)w, (short)h,
- &but->val.asfloat, min, max, 0, 0, but->tooltip );
- if( realtime )
- uiButSetFunc( ubut, py_slider_update, ubut, NULL );
- } else {
- but->val.asint = (int)ini;
- ubut = uiDefButI( block, SCROLL, event, "", (short)x, (short)y, (short)w, (short)h,
- &but->val.asint, min, max, 0, 0, but->tooltip );
- if( realtime )
- uiButSetFunc( ubut, py_slider_update, ubut, NULL );
- }
- }
- return ( PyObject * ) but;
-}
-
-static PyObject *Method_ColorPicker( PyObject * self, PyObject * args )
-{
- char USAGE_ERROR[] = "expected a 3-float tuple of values between 0 and 1";
- Button *but;
- PyObject *inio;
- uiBlock *block;
- char *tip = NULL;
- float col[3];
- int event;
- short x, y, w, h;
- PyObject *callback=NULL;
-
- if( !PyArg_ParseTuple( args, "ihhhhO!|sO", &event,
- &x, &y, &w, &h, &PyTuple_Type, &inio, &tip, &callback ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected five ints, one tuple and optionally string and callback arguments" );
-
- UI_METHOD_ERRORCHECK;
-
- if ( !PyArg_ParseTuple( inio, "fff", col, col+1, col+2 ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError, USAGE_ERROR);
-
- if ( col[0] < 0 || col[0] > 1
- || col[1] < 0 || col[1] > 1
- || col[2] < 0 || col[2] > 1 )
- return EXPP_ReturnPyObjError( PyExc_ValueError, USAGE_ERROR);
-
- if ( EXPP_check_sequence_consistency( inio, &PyFloat_Type ) != 1 )
- return EXPP_ReturnPyObjError( PyExc_ValueError, USAGE_ERROR);
-
- but = newbutton();
-
- but->type = BVECTOR_TYPE;
- but->val.asvec[0] = col[0];
- but->val.asvec[1] = col[1];
- but->val.asvec[2] = col[2];
- if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP);
-
- block = Get_uiBlock( );
- if( block ) {
- uiBut *ubut;
- ubut = uiDefButF( block, COL, event, "", x, y, w, h, but->val.asvec, 0, 0, 0, 0, but->tooltip);
- set_pycallback(ubut, callback, but);
- }
-
- return ( PyObject * ) but;
-}
-
-
-
-static PyObject *Method_Normal( PyObject * self, PyObject * args )
-{
- char USAGE_ERROR[] = "expected a 3-float tuple of values between -1 and 1";
- Button *but;
- PyObject *inio;
- uiBlock *block;
- char *tip = NULL;
- float nor[3];
- int event;
- short x, y, w, h;
- PyObject *callback=NULL;
-
- if( !PyArg_ParseTuple( args, "ihhhhO!|sO", &event,
- &x, &y, &w, &h, &PyTuple_Type, &inio, &tip, &callback ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected five ints, one tuple and optionally string and callback arguments" );
-
- UI_METHOD_ERRORCHECK;
-
- if ( !PyArg_ParseTuple( inio, "fff", nor, nor+1, nor+2 ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError, USAGE_ERROR);
-
- if ( EXPP_check_sequence_consistency( inio, &PyFloat_Type ) != 1 )
- return EXPP_ReturnPyObjError( PyExc_ValueError, USAGE_ERROR);
-
- but = newbutton();
- if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP);
-
- but->type = BVECTOR_TYPE;
- but->val.asvec[0] = nor[0];
- but->val.asvec[1] = nor[1];
- but->val.asvec[2] = nor[2];
-
- block = Get_uiBlock( );
- if( block ) {
- uiBut *ubut;
- ubut = uiDefButF( block, BUT_NORMAL, event, "", x, y, w, h, but->val.asvec, 0.0f, 1.0f, 0, 0, but->tooltip);
- set_pycallback(ubut, callback, but);
- }
-
- return ( PyObject * ) but;
-}
-
-static PyObject *Method_Number( PyObject * self, PyObject * args )
-{
- uiBlock *block;
- char *name, *tip = NULL;
- int event;
- int x, y, w, h;
- Button *but;
- PyObject *mino, *maxo, *inio;
- PyObject *callback=NULL;
- uiBut *ubut= NULL;
-
- if( !PyArg_ParseTuple( args, "siiiiiOOO|sO", &name, &event,
- &x, &y, &w, &h, &inio, &mino, &maxo, &tip, &callback ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string, five ints, three PyObjects and\n\
- optionally string and callback arguments" );
-
- UI_METHOD_ERRORCHECK;
-
- but = newbutton( );
- if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP);
- block = Get_uiBlock( );
-
- if( PyFloat_Check( inio ) ) {
- float ini, min, max, range, precission=0;
-
- ini = (float)PyFloat_AsDouble( inio );
- min = (float)PyFloat_AsDouble( mino );
- max = (float)PyFloat_AsDouble( maxo );
-
- range= (float)fabs(max-min); /* Click step will be a 10th of the range. */
- if (!range) range= 1.0f; /* avoid any odd errors */
-
- /* set the precission to display*/
- if (range>=1000.0f) precission=1.0f;
- else if (range>=100.0f) precission=2.0f;
- else if (range>=10.0f) precission=3.0f;
- else precission=4.0f;
-
- but->type = BFLOAT_TYPE;
- but->val.asfloat = ini;
-
-
- if( block )
- ubut= uiDefButF( block, NUM, event, name, (short)x, (short)y, (short)w, (short)h,
- &but->val.asfloat, min, max, 10*range, precission, but->tooltip );
- } else {
- int ini, min, max;
-
- ini = PyInt_AsLong( inio );
- min = PyInt_AsLong( mino );
- max = PyInt_AsLong( maxo );
-
- but->type = BINT_TYPE;
- but->val.asint = ini;
-
- if( block )
- ubut= uiDefButI( block, NUM, event, name, (short)x, (short)y, (short)w, (short)h,
- &but->val.asint, (float)min, (float)max, 0, 0, but->tooltip );
- }
-
- if (ubut) set_pycallback(ubut, callback, but);
-
- return ( PyObject * ) but;
-}
-
-static PyObject *Method_String( PyObject * self, PyObject * args )
-{
- uiBlock *block;
- char *info_arg = NULL, *tip = NULL, *newstr = NULL;
- char *info_str = NULL, *info_str0 = " ";
- int event;
- int x, y, w, h, len, real_len = 0;
- Button *but;
- PyObject *callback=NULL;
-
- if( !PyArg_ParseTuple( args, "siiiiisi|sO", &info_arg, &event,
- &x, &y, &w, &h, &newstr, &len, &tip, &callback ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string, five ints, a string, an int and\n\
- optionally string and callback arguments" );
-
- UI_METHOD_ERRORCHECK;
-
- if (len > (UI_MAX_DRAW_STR - 1))
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "The maximum length of a string is 399, your value is too high.");
-
- real_len = strlen(newstr);
- if (real_len > len) real_len = len;
-
- but = newbutton( );
- but->type = BSTRING_TYPE;
- but->slen = len;
- but->val.asstr = MEM_mallocN( len + 1, "pybutton str" );
- if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP);
-
- BLI_strncpy( but->val.asstr, newstr, len + 1); /* adds '\0' */
- but->val.asstr[real_len] = '\0';
-
- if (info_arg[0] == '\0') info_str = info_str0;
- else info_str = info_arg;
-
- block = Get_uiBlock( );
- if( block ) {
- uiBut *ubut = uiDefBut( block, TEX, event, info_str, (short)x, (short)y, (short)w, (short)h,
- but->val.asstr, 0, (float)len, 0, 0, but->tooltip );
- set_pycallback(ubut, callback, but);
- }
- return ( PyObject * ) but;
-}
-
-static PyObject *Method_GetStringWidth( PyObject * self, PyObject * args )
-{
- char *text;
- char *font_str = "normal";
- struct BMF_Font *font;
- PyObject *width;
-
- if( !PyArg_ParseTuple( args, "s|s", &text, &font_str ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected one or two string arguments" );
-
- if( !strcmp( font_str, "normal" ) )
- font = ( &G )->font;
- else if( !strcmp( font_str, "large" ) )
- font = BMF_GetFont(BMF_kScreen15);
- else if( !strcmp( font_str, "small" ) )
- font = ( &G )->fonts;
- else if( !strcmp( font_str, "tiny" ) )
- font = ( &G )->fontss;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "\"font\" must be: 'large', 'normal' (default), 'small' or 'tiny'." );
-
- width = PyInt_FromLong( BMF_GetStringWidth( font, text ) );
-
- if( !width )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyInt" );
-
- return width;
-}
-
-static PyObject *Method_Text( PyObject * self, PyObject * args )
-{
- char *text;
- char *font_str = NULL;
- struct BMF_Font *font;
-
- if( !PyArg_ParseTuple( args, "s|s", &text, &font_str ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected one or two string arguments" );
-
- if( !font_str )
- font = ( &G )->font;
- else if( !strcmp( font_str, "large" ) )
- font = BMF_GetFont(BMF_kScreen15);
- else if( !strcmp( font_str, "normal" ) )
- font = ( &G )->font;
- else if( !strcmp( font_str, "small" ) )
- font = ( &G )->fonts;
- else if( !strcmp( font_str, "tiny" ) )
- font = ( &G )->fontss;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "\"font\" must be: 'normal' (default), 'large', 'small' or 'tiny'." );
-
- BMF_DrawString( font, text );
-
- return PyInt_FromLong( BMF_GetStringWidth( font, text ) );
-}
-
-static PyObject *Method_Label( PyObject * self, PyObject * args )
-{
- uiBlock *block;
- char *text;
- int x, y, w, h;
-
- if( !PyArg_ParseTuple( args, "siiii", &text, &x, &y, &w, &h ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string and four ints" );
-
- block = Get_uiBlock( );
- uiDefBut(block, LABEL, 0, text, x, y, w, h, 0, 0, 0, 0, 0, "");
-
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Method_PupMenu( PyObject * self, PyObject * args )
-{
- char *text;
- int maxrow = -1;
- PyObject *ret;
-
- if( !PyArg_ParseTuple( args, "s|i", &text, &maxrow ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string and optionally an int as arguments" );
-
- if( maxrow >= 0 )
- ret = PyInt_FromLong( pupmenu_col( text, maxrow ) );
- else
- ret = PyInt_FromLong( pupmenu( text ) );
-
- if( ret )
- return ret;
-
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create a PyInt" );
-}
-
-static PyObject *Method_PupIntInput( PyObject * self, PyObject * args )
-{
- char *text = NULL;
- int min = 0, max = 1;
- short var = 0;
- PyObject *ret = NULL;
-
- if( !PyArg_ParseTuple( args, "s|hii", &text, &var, &min, &max ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 1 string and 3 int arguments" );
-
- if( button( &var, (short)min, (short)max, text ) == 0 ) {
- Py_INCREF( Py_None );
- return Py_None;
- }
- ret = PyInt_FromLong( var );
- if( ret )
- return ret;
-
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create a PyInt" );
-}
-
-static PyObject *Method_PupFloatInput( PyObject * self, PyObject * args )
-{
- char *text = NULL;
- float min = 0, max = 1, var = 0, a1 = 10, a2 = 2;
- PyObject *ret = NULL;
-
- if( !PyArg_ParseTuple
- ( args, "s|fffff", &text, &var, &min, &max, &a1, &a2 ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 1 string and 5 float arguments" );
-
- if( fbutton( &var, min, max, a1, a2, text ) == 0 ) {
- Py_INCREF( Py_None );
- return Py_None;
- }
- ret = PyFloat_FromDouble( var );
- if( ret )
- return ret;
-
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create a PyFloat" );
-}
-
-static PyObject *Method_PupStrInput( PyObject * self, PyObject * args )
-{
- char *text = NULL, *textMsg = NULL;
- char tmp[101];
- char max = 20;
- PyObject *ret = NULL;
-
- if( !PyArg_ParseTuple( args, "ss|b", &textMsg, &text, &max ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 2 strings and 1 int" );
-
- if( ( max <= 0 ) || ( max > 100 ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "max string length value must be in the range [1, 100]." );
-
- /* copying the text string handles both cases:
- * max < strlen(text) (by truncating) and
- * max > strlen(text) (by expanding to strlen(tmp)) */
- BLI_strncpy( tmp, text, max + 1 );
-
- if( sbutton( tmp, 0, max, textMsg ) == 0 ) {
- Py_INCREF( Py_None );
- return Py_None;
- }
-
- ret = PyString_FromString( tmp );
-
- if( ret )
- return ret;
-
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create a PyString" );
-}
-
-static PyObject *Method_PupBlock( PyObject * self, PyObject * args )
-{
- PyObject *pyList, *pyItem;
- float min, max;
- int len, i;
- char *title;
-
- if (!PyArg_ParseTuple( args, "sO", &title, &pyList ) || !PySequence_Check( pyList ))
- return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string and a sequence" );
-
-
- len = PySequence_Length(pyList);
-
- if (len == 0)
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string and a non-empty sequence." );
-
- if (len > 120) /* LIMIT DEFINED IN toolbox.c */
- return EXPP_ReturnPyObjError( PyExc_ValueError, "sequence cannot have more than 120 elements" );
-
- for ( i=0 ; i<len ; i++ ) {
- PyObject *pyMin = NULL, *pyMax = NULL;
- PyObject *f1, *f2;
- Button *but = NULL;
- int tlen;
- char *text, *tip = NULL;
-
- pyItem = PySequence_GetItem( pyList, i );
- if (!pyItem)
- return NULL;
-
- if (PyString_Check( pyItem )) {
- tlen = -2; /* single string for label, giving it a special len for later */
- }
- else if (PyTuple_Check( pyItem )) {
- /* tuple for other button, get the length for later */
- tlen = PyTuple_Size( pyItem );
- }
- else {
- /* Neither a string or a tuple, error */
- Py_DECREF( pyItem );
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string or a tuple containing 2 to 5 values." );
- }
-
- switch (tlen) {
- case -2: /* LABEL */
- text = PyString_AsString( pyItem );
- add_numbut(i, LABEL, text, 0, 0, NULL, NULL);
- break;
- case 2: /* TOGGLE (no tooltip) */
- case 3: /* TOGGLE */
- if (!PyArg_ParseTuple( pyItem, "sO!|s", &text, &Button_Type, &but, &tip )) {
- Py_DECREF( pyItem );
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a tuple containing a string, a Button object and optionally a string for toggles" );
- }
-
- if (but->type != BINT_TYPE) {
- Py_DECREF( pyItem );
- return EXPP_ReturnPyObjError( PyExc_ValueError, "Button object for toggles should hold an integer" );
- }
-
- add_numbut(i, TOG|INT, text, 0, 0, &but->val.asint, tip);
- break;
- case 4: /* TEX and NUM (no tooltip) */
- case 5: /* TEX and NUM */
- if (!PyArg_ParseTuple( pyItem, "sO!OO|s", &text, &Button_Type, &but, &pyMin, &pyMax, &tip )) {
- Py_DECREF( pyItem );
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a tuple containing a string, a Button object, two numerical values and optionally a string for Text and Num buttons" );
- }
-
- f1 = PyNumber_Float(pyMin);
- f2 = PyNumber_Float(pyMax);
-
- if (!f1 || !f2) {
- Py_DECREF( pyItem );
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a tuple containing a string, a Button object, two numerical values and optionally a string for Text and Num buttons" );
- }
-
- min = (float)PyFloat_AS_DOUBLE(f1);
- max = (float)PyFloat_AS_DOUBLE(f2);
- Py_DECREF( f1 );
- Py_DECREF( f2 );
-
- switch ( but->type ) {
- case BINT_TYPE:
- add_numbut(i, NUM|INT, text, min, max, &but->val.asint, tip);
- break;
- case BFLOAT_TYPE:
- add_numbut(i, NUM|FLO, text, min, max, &but->val.asfloat, tip);
- break;
- case BSTRING_TYPE:
- if (max+1>UI_MAX_DRAW_STR) {
- Py_DECREF( pyItem );
- return EXPP_ReturnPyObjError( PyExc_ValueError, "length of a string buttons must be less then 400" );
- }
- max = (float)floor(max);
-
- if (max > but->slen) {
- int old_len = but->slen;
- char *old_str = but->val.asstr;
- but->slen = (int)max;
- but->val.asstr = MEM_callocN( but->slen + 1, "button pupblock");
- BLI_strncpy( but->val.asstr, old_str, old_len + 1 );
- MEM_freeN(old_str);
- }
-
- add_numbut(i, TEX, text, 0.0f, max, but->val.asstr, tip);
- }
-
- break;
- default:
- Py_DECREF( pyItem );
- return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string or a tuple containing 2 to 5 values." );
- }
- Py_DECREF( pyItem );
- }
-
- if (do_clever_numbuts(title, len, REDRAW))
- return EXPP_incr_ret_True();
- else
- return EXPP_incr_ret_False();
-}
-
-
-/*****************************************************************************
- * Function: Method_Image *
- * Python equivalent: Blender.Draw.Image *
- * *
- * @author Jonathan Merritt <j.merritt@pgrad.unimelb.edu.au> *
- ****************************************************************************/
-static PyObject *Method_Image( PyObject * self, PyObject * args )
-{
- PyObject *pyObjImage;
- BPy_Image *py_img;
- Image *image;
- ImBuf *ibuf;
- float originX, originY;
- float zoomX = 1.0, zoomY = 1.0;
- int clipX = 0, clipY = 0, clipW = -1, clipH = -1;
- /*GLfloat scissorBox[4];*/
-
- /* parse the arguments passed-in from Python */
- if( !PyArg_ParseTuple( args, "Off|ffiiii", &pyObjImage,
- &originX, &originY, &zoomX, &zoomY,
- &clipX, &clipY, &clipW, &clipH ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a Blender.Image and 2 floats, and " \
- "optionally 2 floats and 4 ints as arguments" );
- /* check that the first PyObject is actually a Blender.Image */
- if( !BPy_Image_Check( pyObjImage ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a Blender.Image and 2 floats, and " \
- "optionally 2 floats and 4 ints as arguments" );
- /* check that the zoom factors are valid */
- if( ( zoomX <= 0.0 ) || ( zoomY <= 0.0 ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "invalid zoom factors - they must be >= 0.0" );
-
- /* fetch a C Image pointer from the passed-in Python object */
- py_img = ( BPy_Image * ) pyObjImage;
- image = py_img->image;
- ibuf = BKE_image_get_ibuf( image, NULL );
-
- if( !ibuf ) /* if failed to load the image */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
- if( !ibuf->rect ) /* no float yet */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Image has no byte rect" );
-
- /* Update the time tag of the image */
- tag_image_time(image);
-
- /* set up a valid clipping rectangle. if no clip rectangle was
- * given, this results in inclusion of the entire image. otherwise,
- * the clipping is just checked against the bounds of the image.
- * if clipW or clipH are less than zero then they include as much of
- * the image as they can. */
- clipX = EXPP_ClampInt( clipX, 0, ibuf->x );
- clipY = EXPP_ClampInt( clipY, 0, ibuf->y );
- if( ( clipW < 0 ) || ( clipW > ( ibuf->x - clipW ) ) )
- clipW = ibuf->x - clipX;
- if( ( clipH < 0 ) || ( clipH > ( ibuf->y - clipH ) ) )
- clipH = ibuf->y - clipY;
-
- /* -- we are "Go" to Draw! -- */
-
- /* set the raster position.
- *
- * If the raster position is negative, then using glRasterPos2i()
- * directly would cause it to be clipped. Instead, we first establish
- * a valid raster position within the clipping rectangle of the
- * window and then use glBitmap() with a NULL image pointer to offset
- * it to the true position we require. To pick an initial valid
- * raster position within the viewport, we query the clipping rectangle
- * and use its lower-left pixel.
- *
- * This particular technique is documented in the glRasterPos() man
- * page, although I haven't seen it used elsewhere in Blender.
- */
-
- /* update (W): to fix a bug where images wouldn't get drawn if the bottom
- * left corner of the Scripts win were above a given height or to the right
- * of a given width, the code below is being commented out. It should not
- * be needed anyway, because spaces in Blender are projected to lie inside
- * their areas, see src/drawscript.c for example. Note: the
- * glaRasterPosSafe2i function in src/glutil.c does use the commented out
- * technique, but with 0,0 instead of scissorBox. This function can be
- * a little optimized, based on glaDrawPixelsSafe in that same fine, but
- * we're too close to release 2.37 right now. */
- /*
- glGetFloatv( GL_SCISSOR_BOX, scissorBox );
- glRasterPos2i( scissorBox[0], scissorBox[1] );
- glBitmap( 0, 0, 0.0, 0.0,
- originX-scissorBox[0], originY-scissorBox[1], NULL );
- */
-
- /* update (cont.): using these two lines instead:
- * (based on glaRasterPosSafe2i, but Ken Hughes deserves credit
- * for suggesting this exact fix in the bug tracker) */
- glRasterPos2i(0, 0);
- glBitmap( 0, 0, 0.0, 0.0, originX, originY, NULL );
-
- /* set the zoom */
- glPixelZoom( zoomX, zoomY );
-
- /* set the width of the image (ROW_LENGTH), and the offset to the
- * clip origin within the image in x (SKIP_PIXELS) and
- * y (SKIP_ROWS) */
- glPixelStorei( GL_UNPACK_ROW_LENGTH, ibuf->x );
- glPixelStorei( GL_UNPACK_SKIP_PIXELS, clipX );
- glPixelStorei( GL_UNPACK_SKIP_ROWS, clipY );
-
- /* draw the image */
- glDrawPixels( clipW, clipH, GL_RGBA, GL_UNSIGNED_BYTE,
- ibuf->rect );
-
- /* restore the defaults for some parameters (we could also use a
- * glPushClientAttrib() and glPopClientAttrib() pair). */
- glPixelZoom( 1.0, 1.0 );
- glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
- glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
- glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
-
- Py_INCREF( Py_None );
- return Py_None;
-
-}
-
-PyObject *Draw_Init( void )
-{
- PyObject *submodule, *dict;
-
- if( PyType_Ready( &Button_Type) < 0)
- Py_RETURN_NONE;
-
- submodule = Py_InitModule3( "Blender.Draw", Draw_methods, Draw_doc );
-
- dict = PyModule_GetDict( submodule );
-
-#define EXPP_ADDCONST(x) \
- EXPP_dict_set_item_str(dict, #x, PyInt_FromLong(x))
-
- /* So, for example:
- * EXPP_ADDCONST(LEFTMOUSE) becomes
- * EXPP_dict_set_item_str(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE))
- */
-
- EXPP_ADDCONST( LEFTMOUSE );
- EXPP_ADDCONST( MIDDLEMOUSE );
- EXPP_ADDCONST( RIGHTMOUSE );
- EXPP_ADDCONST( WHEELUPMOUSE );
- EXPP_ADDCONST( WHEELDOWNMOUSE );
- EXPP_ADDCONST( MOUSEX );
- EXPP_ADDCONST( MOUSEY );
- EXPP_ADDCONST( TIMER0 );
- EXPP_ADDCONST( TIMER1 );
- EXPP_ADDCONST( TIMER2 );
- EXPP_ADDCONST( TIMER3 );
- EXPP_ADDCONST( KEYBD );
- EXPP_ADDCONST( RAWKEYBD );
- EXPP_ADDCONST( REDRAW );
- EXPP_ADDCONST( INPUTCHANGE );
- EXPP_ADDCONST( QFULL );
- EXPP_ADDCONST( WINFREEZE );
- EXPP_ADDCONST( WINTHAW );
- EXPP_ADDCONST( WINCLOSE );
- EXPP_ADDCONST( WINQUIT );
-#ifndef IRISGL
- EXPP_ADDCONST( Q_FIRSTTIME );
-#endif
- EXPP_ADDCONST( AKEY );
- EXPP_ADDCONST( BKEY );
- EXPP_ADDCONST( CKEY );
- EXPP_ADDCONST( DKEY );
- EXPP_ADDCONST( EKEY );
- EXPP_ADDCONST( FKEY );
- EXPP_ADDCONST( GKEY );
- EXPP_ADDCONST( HKEY );
- EXPP_ADDCONST( IKEY );
- EXPP_ADDCONST( JKEY );
- EXPP_ADDCONST( KKEY );
- EXPP_ADDCONST( LKEY );
- EXPP_ADDCONST( MKEY );
- EXPP_ADDCONST( NKEY );
- EXPP_ADDCONST( OKEY );
- EXPP_ADDCONST( PKEY );
- EXPP_ADDCONST( QKEY );
- EXPP_ADDCONST( RKEY );
- EXPP_ADDCONST( SKEY );
- EXPP_ADDCONST( TKEY );
- EXPP_ADDCONST( UKEY );
- EXPP_ADDCONST( VKEY );
- EXPP_ADDCONST( WKEY );
- EXPP_ADDCONST( XKEY );
- EXPP_ADDCONST( YKEY );
- EXPP_ADDCONST( ZKEY );
- EXPP_ADDCONST( ZEROKEY );
- EXPP_ADDCONST( ONEKEY );
- EXPP_ADDCONST( TWOKEY );
- EXPP_ADDCONST( THREEKEY );
- EXPP_ADDCONST( FOURKEY );
- EXPP_ADDCONST( FIVEKEY );
- EXPP_ADDCONST( SIXKEY );
- EXPP_ADDCONST( SEVENKEY );
- EXPP_ADDCONST( EIGHTKEY );
- EXPP_ADDCONST( NINEKEY );
- EXPP_ADDCONST( CAPSLOCKKEY );
- EXPP_ADDCONST( LEFTCTRLKEY );
- EXPP_ADDCONST( LEFTALTKEY );
- EXPP_ADDCONST( RIGHTALTKEY );
- EXPP_ADDCONST( RIGHTCTRLKEY );
- EXPP_ADDCONST( RIGHTSHIFTKEY );
- EXPP_ADDCONST( LEFTSHIFTKEY );
- EXPP_ADDCONST( ESCKEY );
- EXPP_ADDCONST( TABKEY );
- EXPP_ADDCONST( RETKEY );
- EXPP_ADDCONST( SPACEKEY );
- EXPP_ADDCONST( LINEFEEDKEY );
- EXPP_ADDCONST( BACKSPACEKEY );
- EXPP_ADDCONST( DELKEY );
- EXPP_ADDCONST( SEMICOLONKEY );
- EXPP_ADDCONST( PERIODKEY );
- EXPP_ADDCONST( COMMAKEY );
- EXPP_ADDCONST( QUOTEKEY );
- EXPP_ADDCONST( ACCENTGRAVEKEY );
- EXPP_ADDCONST( MINUSKEY );
- EXPP_ADDCONST( SLASHKEY );
- EXPP_ADDCONST( BACKSLASHKEY );
- EXPP_ADDCONST( EQUALKEY );
- EXPP_ADDCONST( LEFTBRACKETKEY );
- EXPP_ADDCONST( RIGHTBRACKETKEY );
- EXPP_ADDCONST( LEFTARROWKEY );
- EXPP_ADDCONST( DOWNARROWKEY );
- EXPP_ADDCONST( RIGHTARROWKEY );
- EXPP_ADDCONST( UPARROWKEY );
- EXPP_ADDCONST( PAD2 );
- EXPP_ADDCONST( PAD4 );
- EXPP_ADDCONST( PAD6 );
- EXPP_ADDCONST( PAD8 );
- EXPP_ADDCONST( PAD1 );
- EXPP_ADDCONST( PAD3 );
- EXPP_ADDCONST( PAD5 );
- EXPP_ADDCONST( PAD7 );
- EXPP_ADDCONST( PAD9 );
- EXPP_ADDCONST( PADPERIOD );
- EXPP_ADDCONST( PADSLASHKEY );
- EXPP_ADDCONST( PADASTERKEY );
- EXPP_ADDCONST( PAD0 );
- EXPP_ADDCONST( PADMINUS );
- EXPP_ADDCONST( PADENTER );
- EXPP_ADDCONST( PADPLUSKEY );
- EXPP_ADDCONST( F1KEY );
- EXPP_ADDCONST( F2KEY );
- EXPP_ADDCONST( F3KEY );
- EXPP_ADDCONST( F4KEY );
- EXPP_ADDCONST( F5KEY );
- EXPP_ADDCONST( F6KEY );
- EXPP_ADDCONST( F7KEY );
- EXPP_ADDCONST( F8KEY );
- EXPP_ADDCONST( F9KEY );
- EXPP_ADDCONST( F10KEY );
- EXPP_ADDCONST( F11KEY );
- EXPP_ADDCONST( F12KEY );
- EXPP_ADDCONST( PAUSEKEY );
- EXPP_ADDCONST( INSERTKEY );
- EXPP_ADDCONST( HOMEKEY );
- EXPP_ADDCONST( PAGEUPKEY );
- EXPP_ADDCONST( PAGEDOWNKEY );
- EXPP_ADDCONST( ENDKEY );
-
- return submodule;
-}
diff --git a/source/blender/python/api2_2x/Draw.h b/source/blender/python/api2_2x/Draw.h
deleted file mode 100644
index a78b19b0ebd..00000000000
--- a/source/blender/python/api2_2x/Draw.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/EXPP_interface.c b/source/blender/python/api2_2x/EXPP_interface.c
deleted file mode 100644
index 9d49746ff41..00000000000
--- a/source/blender/python/api2_2x/EXPP_interface.c
+++ /dev/null
@@ -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;
-}
-
diff --git a/source/blender/python/api2_2x/EXPP_interface.h b/source/blender/python/api2_2x/EXPP_interface.h
deleted file mode 100644
index 8ed0836820d..00000000000
--- a/source/blender/python/api2_2x/EXPP_interface.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Effect.c b/source/blender/python/api2_2x/Effect.c
deleted file mode 100644
index 1dcc2279ee2..00000000000
--- a/source/blender/python/api2_2x/Effect.c
+++ /dev/null
@@ -1,1575 +0,0 @@
-/*
- * $Id: Effect.c 11485 2007-08-05 09:21:29Z aligorith $
- *
- * ***** 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, Jean-Michel Soler, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-#include "Effect.h" /*This must come first */
-
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h" /* for G.scene->r.cfra */
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_effect.h"
-#include "BKE_object.h"
-#include "BKE_deform.h"
-#include "BKE_scene.h" /* for G.scene->r.cfra */
-#include "BKE_ipo.h" /* frame_to_float() */
-#include "BLI_blenlib.h"
-#include "gen_utils.h"
-#include "blendef.h"
-#include "vector.h"
-#include "MTC_matrixops.h"
-
-#define EXPP_EFFECT_STA_MIN -250.0f
-#define EXPP_EFFECT_END_MIN 1.0f
-#define EXPP_EFFECT_LIFETIME_MIN 1.0f
-#define EXPP_EFFECT_NORMFAC_MIN -2.0f
-#define EXPP_EFFECT_NORMFAC_MAX 2.0f
-#define EXPP_EFFECT_OBFAC_MIN -1.0f
-#define EXPP_EFFECT_OBFAC_MAX 1.0f
-#define EXPP_EFFECT_RANDFAC_MIN 0.0f
-#define EXPP_EFFECT_RANDFAC_MAX 2.0f
-#define EXPP_EFFECT_TEXFAC_MIN 0.0f
-#define EXPP_EFFECT_TEXFAC_MAX 2.0f
-#define EXPP_EFFECT_RANDLIFE_MIN 0.0f
-#define EXPP_EFFECT_RANDLIFE_MAX 2.0f
-#define EXPP_EFFECT_NABLA_MIN 0.0001f
-#define EXPP_EFFECT_NABLA_MAX 1.0f
-#define EXPP_EFFECT_VECTSIZE_MIN 0.0f
-#define EXPP_EFFECT_VECTSIZE_MAX 1.0f
-#define EXPP_EFFECT_TOTPART_MIN 1.0f
-#define EXPP_EFFECT_TOTPART_MAX 100000.0f
-#define EXPP_EFFECT_FORCE_MIN -1.0f
-#define EXPP_EFFECT_FORCE_MAX 1.0f
-#define EXPP_EFFECT_MULT_MIN 0.0f
-#define EXPP_EFFECT_MULT_MAX 1.0f
-#define EXPP_EFFECT_LIFE_MIN 1.0f
-#define EXPP_EFFECT_DEFVEC_MIN -1.0f
-#define EXPP_EFFECT_DEFVEC_MAX 1.0f
-#define EXPP_EFFECT_DAMP_MIN 0.0f
-#define EXPP_EFFECT_DAMP_MAX 1.0f
-
-#define EXPP_EFFECT_TOTKEY_MIN 1
-#define EXPP_EFFECT_TOTKEY_MAX 100
-#define EXPP_EFFECT_SEED_MIN 0
-#define EXPP_EFFECT_SEED_MAX 255
-#define EXPP_EFFECT_CHILD_MIN 1
-#define EXPP_EFFECT_CHILD_MAX 600
-#define EXPP_EFFECT_CHILDMAT_MIN 1
-#define EXPP_EFFECT_CHILDMAT_MAX 16
-#define EXPP_EFFECT_JITTER_MIN 0
-#define EXPP_EFFECT_JITTER_MAX 200
-#define EXPP_EFFECT_DISPMAT_MIN 1
-#define EXPP_EFFECT_DISPMAT_MAX 16
-#define EXPP_EFFECT_TIMETEX_MIN 1
-#define EXPP_EFFECT_TIMETEX_MAX 10
-#define EXPP_EFFECT_SPEEDTEX_MIN 1
-#define EXPP_EFFECT_SPEEDTEX_MAX 10
-#define EXPP_EFFECT_TEXMAP_MIN 1
-#define EXPP_EFFECT_TEXMAP_MAX 3
-
-#define EXPP_EFFECT_SPEEDTYPE_INTENSITY 0
-#define EXPP_EFFECT_SPEEDTYPE_RGB 1
-#define EXPP_EFFECT_SPEEDTYPE_GRADIENT 2
-
-#define EXPP_EFFECT_STATICSTEP_MIN 1
-#define EXPP_EFFECT_STATICSTEP_MAX 100
-#define EXPP_EFFECT_DISP_MIN 0
-#define EXPP_EFFECT_DISP_MAX 100
-
-/*****************************************************************************/
-/* Python API function prototypes for the Blender module. */
-/*****************************************************************************/
-static PyObject *M_Effect_New( PyObject * self, PyObject * args );
-static PyObject *M_Effect_Get( PyObject * self, PyObject * args );
-
-/*****************************************************************************/
-/* Python BPy_Effect methods declarations: */
-/*****************************************************************************/
-static PyObject *Effect_getType( BPy_Effect * self );
-static int Effect_setType( void );
-static PyObject *Effect_getStype( BPy_Effect * self );
-static int Effect_setStype( BPy_Effect * self, PyObject * args );
-static PyObject *Effect_getFlag( BPy_Effect * self );
-static int Effect_setFlag( BPy_Effect * self, PyObject * args );
-static PyObject *Effect_getSta( BPy_Effect * self );
-static int Effect_setSta( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getEnd( BPy_Effect * self );
-static int Effect_setEnd( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getLifetime( BPy_Effect * self );
-static int Effect_setLifetime( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getNormfac( BPy_Effect * self );
-static int Effect_setNormfac( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getObfac( BPy_Effect * self );
-static int Effect_setObfac( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getRandfac( BPy_Effect * self );
-static int Effect_setRandfac( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getTexfac( BPy_Effect * self );
-static int Effect_setTexfac( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getRandlife( BPy_Effect * self );
-static int Effect_setRandlife( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getNabla( BPy_Effect * self );
-static int Effect_setNabla( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getVectsize( BPy_Effect * self );
-static int Effect_setVectsize( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getTotpart( BPy_Effect * self );
-static int Effect_setTotpart( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getTotkey( BPy_Effect * self );
-static int Effect_setTotkey( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getSeed( BPy_Effect * self );
-static int Effect_setSeed( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getForce( BPy_Effect * self );
-static int Effect_setForce( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getMult( BPy_Effect * self );
-static int Effect_setMult( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getLife( BPy_Effect * self );
-static int Effect_setLife( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getChildMat( BPy_Effect * self );
-static int Effect_setChildMat( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getChild( BPy_Effect * self );
-static int Effect_setChild( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getDefvec( BPy_Effect * self );
-static int Effect_setDefvec( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getJitter( BPy_Effect * self );
-static int Effect_setJitter( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getDispMat( BPy_Effect * self );
-static int Effect_setDispMat( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getEmissionTex( BPy_Effect * self );
-static int Effect_setEmissionTex( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getForceTex( BPy_Effect * self );
-static int Effect_setForceTex( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getDamping( BPy_Effect * self );
-static int Effect_setDamping( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getSpeedType( BPy_Effect * self );
-static int Effect_setSpeedType( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getVertGroup( BPy_Effect * self );
-static int Effect_setVertGroup( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getSpeedVertGroup( BPy_Effect * self );
-static int Effect_setSpeedVertGroup( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_getStaticStep( BPy_Effect * self );
-static int Effect_setStaticStep( BPy_Effect * self , PyObject * a);
-static PyObject *Effect_getDisp( BPy_Effect * self );
-static int Effect_setDisp( BPy_Effect * self , PyObject * a);
-static PyObject *Effect_getParticlesLoc( BPy_Effect * self );
-
-static PyObject *Effect_oldsetType( void );
-static PyObject *Effect_oldsetStype( BPy_Effect * self, PyObject * args );
-static PyObject *Effect_oldsetFlag( BPy_Effect * self, PyObject * args );
-static PyObject *Effect_oldsetSta( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetEnd( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetLifetime( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetNormfac( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetObfac( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetRandfac( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetTexfac( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetRandlife( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetNabla( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetVectsize( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetTotpart( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetTotkey( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetSeed( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetForce( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetMult( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetLife( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetMat( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetChild( BPy_Effect * self, PyObject * a );
-static PyObject *Effect_oldsetDefvec( BPy_Effect * self, PyObject * a );
-
-/*****************************************************************************/
-/* Python Effect_Type callback function prototypes: */
-/*****************************************************************************/
-static PyObject *Effect_repr( void );
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Particle.__doc__ */
-/*****************************************************************************/
-static char M_Particle_doc[] = "The Blender Effect module\n\n\
-This module provides access to **Object Data** in Blender.\n\
-Functions :\n\
- New(name) : creates a new part object and adds it to the given mesh object \n\
- Get(name) : retreives a particle with the given name (mandatory)\n\
- get(name) : same as Get. Kept for compatibility reasons.\n";
-static char M_Effect_New_doc[] = "New(name) : creates a new part object and adds it to the given mesh object\n";
-static char M_Effect_Get_doc[] = "xxx";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Particle module: */
-/*****************************************************************************/
-static struct PyMethodDef M_Particle_methods[] = {
- {"New", ( PyCFunction ) M_Effect_New, METH_VARARGS, M_Effect_New_doc},
- {"Get", M_Effect_Get, METH_VARARGS, M_Effect_Get_doc},
- {"get", M_Effect_Get, METH_VARARGS, M_Effect_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Effect methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Effect_methods[] = {
- {"getType", ( PyCFunction ) Effect_getType,
- METH_NOARGS, "() - Return Effect type"},
- {"setType", ( PyCFunction ) Effect_oldsetType,
- METH_VARARGS, "() - Set Effect type"},
- {"getStype", ( PyCFunction ) Effect_getStype,
- METH_NOARGS, "() - Return Effect stype"},
- {"setStype", ( PyCFunction ) Effect_oldsetStype,
- METH_VARARGS, "() - Set Effect stype"},
- {"getFlag", ( PyCFunction ) Effect_getFlag,
- METH_NOARGS, "() - Return Effect flag"},
- {"setFlag", ( PyCFunction ) Effect_oldsetFlag,
- METH_VARARGS, "() - Set Effect flag"},
- {"getStartTime", ( PyCFunction ) Effect_getSta,
- METH_NOARGS, "()-Return particle start time"},
- {"setStartTime", ( PyCFunction ) Effect_oldsetSta, METH_VARARGS,
- "()- Sets particle start time"},
- {"getEndTime", ( PyCFunction ) Effect_getEnd,
- METH_NOARGS, "()-Return particle end time"},
- {"setEndTime", ( PyCFunction ) Effect_oldsetEnd, METH_VARARGS,
- "()- Sets particle end time"},
- {"getLifetime", ( PyCFunction ) Effect_getLifetime,
- METH_NOARGS, "()-Return particle life time"},
- {"setLifetime", ( PyCFunction ) Effect_oldsetLifetime, METH_VARARGS,
- "()- Sets particle life time "},
- {"getNormfac", ( PyCFunction ) Effect_getNormfac,
- METH_NOARGS, "()-Return particle life time"},
- {"setNormfac", ( PyCFunction ) Effect_oldsetNormfac, METH_VARARGS,
- "()- Sets particle life time "},
- {"getObfac", ( PyCFunction ) Effect_getObfac,
- METH_NOARGS, "()-Return particle life time"},
- {"setObfac", ( PyCFunction ) Effect_oldsetObfac, METH_VARARGS,
- "()- Sets particle life time "},
- {"getRandfac", ( PyCFunction ) Effect_getRandfac,
- METH_NOARGS, "()-Return particle life time"},
- {"setRandfac", ( PyCFunction ) Effect_oldsetRandfac, METH_VARARGS,
- "()- Sets particle life time "},
- {"getTexfac", ( PyCFunction ) Effect_getTexfac,
- METH_NOARGS, "()-Return particle life time"},
- {"setTexfac", ( PyCFunction ) Effect_oldsetTexfac, METH_VARARGS,
- "()- Sets particle life time "},
- {"getRandlife", ( PyCFunction ) Effect_getRandlife,
- METH_NOARGS, "()-Return particle life time"},
- {"setRandlife", ( PyCFunction ) Effect_oldsetRandlife, METH_VARARGS,
- "()- Sets particle life time "},
- {"getNabla", ( PyCFunction ) Effect_getNabla,
- METH_NOARGS, "()-Return particle life time"},
- {"setNabla", ( PyCFunction ) Effect_oldsetNabla, METH_VARARGS,
- "()- Sets particle life time "},
- {"getVectsize", ( PyCFunction ) Effect_getVectsize,
- METH_NOARGS, "()-Return particle life time"},
- {"setVectsize", ( PyCFunction ) Effect_oldsetVectsize, METH_VARARGS,
- "()- Sets particle life time "},
- {"getTotpart", ( PyCFunction ) Effect_getTotpart,
- METH_NOARGS, "()-Return particle life time"},
- {"setTotpart", ( PyCFunction ) Effect_oldsetTotpart, METH_VARARGS,
- "()- Sets particle life time "},
- {"getTotkey", ( PyCFunction ) Effect_getTotkey,
- METH_NOARGS, "()-Return the number of key positions."},
- {"setTotkey", ( PyCFunction ) Effect_oldsetTotkey, METH_VARARGS,
- "()-Set the number of key positions. "},
- {"getSeed", ( PyCFunction ) Effect_getSeed,
- METH_NOARGS, "()-Return particle life time"},
- {"setSeed", ( PyCFunction ) Effect_oldsetSeed, METH_VARARGS,
- "()- Sets particle life time "},
- {"getForce", ( PyCFunction ) Effect_getForce,
- METH_NOARGS, "()-Return particle life time"},
- {"setForce", ( PyCFunction ) Effect_oldsetForce, METH_VARARGS,
- "()- Sets particle life time "},
- {"getMult", ( PyCFunction ) Effect_getMult,
- METH_NOARGS, "()-Return particle life time"},
- {"setMult", ( PyCFunction ) Effect_oldsetMult, METH_VARARGS,
- "()- Sets particle life time "},
- {"getLife", ( PyCFunction ) Effect_getLife,
- METH_NOARGS, "()-Return particle life time"},
- {"setLife", ( PyCFunction ) Effect_oldsetLife, METH_VARARGS,
- "()- Sets particle life time "},
- {"getMat", ( PyCFunction ) Effect_getChildMat,
- METH_NOARGS, "()-Return particle life time"},
- {"setMat", ( PyCFunction ) Effect_oldsetMat, METH_VARARGS,
- "()- Sets particle life time "},
- {"getChild", ( PyCFunction ) Effect_getChild,
- METH_NOARGS, "()-Return particle life time"},
- {"setChild", ( PyCFunction ) Effect_oldsetChild, METH_VARARGS,
- "()- Sets particle life time "},
- {"getDefvec", ( PyCFunction ) Effect_getDefvec,
- METH_NOARGS, "()-Return particle life time"},
- {"setDefvec", ( PyCFunction ) Effect_oldsetDefvec, METH_VARARGS,
- "()- Sets particle life time "},
- {"getParticlesLoc", ( PyCFunction ) Effect_getParticlesLoc, METH_NOARGS,
- "()- Sets particle life time "},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Effect attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Effect_getseters[] = {
- {"flag",
- (getter)Effect_getFlag, (setter)Effect_setFlag,
- "The particle flag bitfield",
- NULL},
- {"stype",
- (getter)Effect_getStype, (setter)Effect_setStype,
- "The particle stype bitfield",
- NULL},
- {"disp",
- (getter)Effect_getDisp, (setter)Effect_setDisp,
- "The particle display value",
- NULL},
- {"staticStep",
- (getter)Effect_getStaticStep, (setter)Effect_setStaticStep,
- "The particle static step value",
- NULL},
- {"type",
- (getter)Effect_getType, (setter)Effect_setType,
- "The effect's type (deprecated)",
- NULL},
- {"child",
- (getter)Effect_getChild, (setter)Effect_setChild,
- "The number of children of a particle that multiply itself",
- NULL},
- {"childMat",
- (getter)Effect_getChildMat, (setter)Effect_setChildMat,
- "Specify the material used for the particles",
- NULL},
- {"damping",
- (getter)Effect_getDamping, (setter)Effect_setDamping,
- "The damping factor",
- NULL},
- {"defvec",
- (getter)Effect_getDefvec, (setter)Effect_setDefvec,
- "The axes of a force, determined by the texture",
- NULL},
- {"dispMat",
- (getter)Effect_getDispMat, (setter)Effect_setDispMat,
- "The material used for the particles",
- NULL},
- {"emissionTex",
- (getter)Effect_getEmissionTex, (setter)Effect_setEmissionTex,
- "The texture used for texture emission",
- NULL},
- {"end",
- (getter)Effect_getEnd, (setter)Effect_setEnd,
- "The endframe for the effect",
- NULL},
- {"force",
- (getter)Effect_getForce, (setter)Effect_setForce,
- "The axes of a continues force",
- NULL},
- {"forceTex",
- (getter)Effect_getForceTex, (setter)Effect_setForceTex,
- "The texture used for force",
- NULL},
- {"jitter",
- (getter)Effect_getJitter, (setter)Effect_setJitter,
- "Jitter table distribution: maximum particles per face",
- NULL},
- {"life",
- (getter)Effect_getLife, (setter)Effect_setLife,
- "The life span of the next generation of particles",
- NULL},
- {"lifetime",
- (getter)Effect_getLifetime, (setter)Effect_setLifetime,
- "The life span of the particles",
- NULL},
- {"mult",
- (getter)Effect_getMult, (setter)Effect_setMult,
- "The probabilities that a \"dying\" particle spawns a new one",
- NULL},
- {"nabla",
- (getter)Effect_getNabla, (setter)Effect_setNabla,
- "The dimension of the area for gradient calculation",
- NULL},
- {"normfac",
- (getter)Effect_getNormfac, (setter)Effect_setNormfac,
- "Particle's starting speed (from the mesh)",
- NULL},
- {"obfac",
- (getter)Effect_getObfac, (setter)Effect_setObfac,
- "Particle's starting speed (from the object)",
- NULL},
- {"randfac",
- (getter)Effect_getRandfac, (setter)Effect_setRandfac,
- "The random variation for the starting speed",
- NULL},
- {"randlife",
- (getter)Effect_getRandlife, (setter)Effect_setRandlife,
- "The random variation for a particle's life",
- NULL},
- {"seed",
- (getter)Effect_getSeed, (setter)Effect_setSeed,
- "The seed for random variations",
- NULL},
- {"speedType",
- (getter)Effect_getSpeedType, (setter)Effect_setSpeedType,
- "Controls which texture property affects particle speeds",
- NULL},
- {"speedVGroup",
- (getter)Effect_getSpeedVertGroup, (setter)Effect_setSpeedVertGroup,
- "Vertex group for speed control",
- NULL},
- {"sta",
- (getter)Effect_getSta, (setter)Effect_setSta,
- "The startframe for the effect",
- NULL},
- {"texfac",
- (getter)Effect_getTexfac, (setter)Effect_setTexfac,
- "Particle's starting speed (from the texture)",
- NULL},
- {"totpart",
- (getter)Effect_getTotpart, (setter)Effect_setTotpart,
- "The total number of particles",
- NULL},
- {"totkey",
- (getter)Effect_getTotkey, (setter)Effect_setTotkey,
- "The total number of key positions",
- NULL},
- {"vectsize",
- (getter)Effect_getVectsize, (setter)Effect_setVectsize,
- "The speed for particle's rotation direction",
- NULL},
- {"vGroup",
- (getter)Effect_getVertGroup, (setter)Effect_setVertGroup,
- "Vertex group for emitted particles",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python Effect_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Effect_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Effect", /* char *tp_name; */
- sizeof( BPy_Effect ), /* 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 ) Effect_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_Effect_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Effect_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
-};
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Effect module: */
-/*****************************************************************************/
-
-struct PyMethodDef M_Effect_methods[] = {
- {"New", ( PyCFunction ) M_Effect_New, METH_VARARGS, NULL},
- {"Get", M_Effect_Get, METH_VARARGS, NULL},
- {"get", M_Effect_Get, METH_VARARGS, NULL},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Function: M_Effect_New */
-/* Python equivalent: Blender.Effect.New */
-/*****************************************************************************/
-PyObject *M_Effect_New( PyObject * self, PyObject * args )
-{
- Effect *bleffect = 0;
- Object *ob;
- char *name = NULL;
-
- if( !PyArg_ParseTuple( args, "s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- for( ob = G.main->object.first; ob; ob = ob->id.next )
- if( !strcmp( name, ob->id.name + 2 ) )
- break;
-
- if( !ob )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object does not exist" );
-
- if( ob->type != OB_MESH )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object is not a mesh" );
-
- bleffect = add_effect( EFF_PARTICLE );
- if( !bleffect )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Effect Data in Blender" );
-
- BLI_addtail( &ob->effect, bleffect );
-
- return EffectCreatePyObject( bleffect, ob );
-}
-
-/*****************************************************************************/
-/* Function: M_Effect_Get */
-/* Python equivalent: Blender.Effect.Get */
-/*****************************************************************************/
-PyObject *M_Effect_Get( PyObject * self, PyObject * args )
-{
- /*arguments : string object name
- int : position of effect in the obj's effect list */
- char *name = NULL;
- Object *object_iter;
- Effect *eff;
- int num = -1, i;
-
- if( !PyArg_ParseTuple( args, "|si", &name, &num ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected string int argument" ) );
-
- object_iter = G.main->object.first;
-
- if( !object_iter )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Scene contains no object" ) );
-
- if( name ) { /* (name, num = -1) - try to find the given object */
-
- while( object_iter ) {
-
- if( !strcmp( name, object_iter->id.name + 2 ) ) {
-
- eff = object_iter->effect.first; /*can be NULL: None will be returned*/
-
- if (num >= 0) { /* return effect in given num position if available */
-
- for( i = 0; i < num; i++ ) {
- if (!eff) break;
- eff = eff->next;
- }
-
- if (eff) {
- return EffectCreatePyObject( eff, object_iter );
- } else { /* didn't find any effect in the given position */
- Py_RETURN_NONE;
- }
- }
-
- else {/*return a list with all effects linked to the given object*/
- /* this was pointed by Stephen Swaney */
- PyObject *effectlist = PyList_New( 0 );
-
- while (eff) {
- PyObject *found_eff = EffectCreatePyObject( eff,
- object_iter );
- PyList_Append( effectlist, found_eff );
- Py_DECREF( found_eff ); /* PyList_Append incref'ed it */
- eff = eff->next;
- }
- return effectlist;
- }
- }
-
- object_iter = object_iter->id.next;
- }
-
- if (!object_iter)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no such object");
- }
-
- else { /* () - return a list with all effects currently in Blender */
- PyObject *effectlist = PyList_New( 0 );
-
- while( object_iter ) {
- if( object_iter->effect.first != NULL ) {
- eff = object_iter->effect.first;
- while( eff ) {
- PyObject *found_eff = EffectCreatePyObject( eff,
- object_iter );
- PyList_Append( effectlist, found_eff );
- Py_DECREF( found_eff );
- eff = eff->next;
- }
- }
- object_iter = object_iter->id.next;
- }
- return effectlist;
- }
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-/* create the Blender.Effect.Flags constant dict */
-
-static PyObject *Effect_FlagsDict( void )
-{
- PyObject *Flags = PyConstant_New( );
-
- if( Flags ) {
- BPy_constant *c = ( BPy_constant * ) Flags;
-
- PyConstant_Insert( c, "SELECTED",
- PyInt_FromLong( EFF_SELECT ) );
- PyConstant_Insert( c, "BSPLINE",
- PyInt_FromLong( PAF_BSPLINE ) );
- PyConstant_Insert( c, "STATIC",
- PyInt_FromLong( PAF_STATIC ) );
- PyConstant_Insert( c, "FACES",
- PyInt_FromLong( PAF_FACE ) );
- PyConstant_Insert( c, "ANIMATED",
- PyInt_FromLong( PAF_ANIMATED ) );
- PyConstant_Insert( c, "UNBORN",
- PyInt_FromLong( PAF_UNBORN ) );
- PyConstant_Insert( c, "VERTS",
- PyInt_FromLong( PAF_OFACE ) );
- PyConstant_Insert( c, "EMESH",
- PyInt_FromLong( PAF_SHOWE ) );
- PyConstant_Insert( c, "TRUERAND",
- PyInt_FromLong( PAF_TRAND ) );
- PyConstant_Insert( c, "EVENDIST",
- PyInt_FromLong( PAF_EDISTR ) );
- PyConstant_Insert( c, "DIED",
- PyInt_FromLong( PAF_DIED ) );
- }
- return Flags;
-}
-
-static PyObject *Effect_SpeedTypeDict( void )
-{
- PyObject *Type = PyConstant_New( );
-
- if( Type ) {
- BPy_constant *c = ( BPy_constant * ) Type;
-
- PyConstant_Insert( c, "INTENSITY",
- PyInt_FromLong( EXPP_EFFECT_SPEEDTYPE_INTENSITY ) );
- PyConstant_Insert( c, "RGB",
- PyInt_FromLong( EXPP_EFFECT_SPEEDTYPE_RGB ) );
- PyConstant_Insert( c, "GRADIENT",
- PyInt_FromLong( EXPP_EFFECT_SPEEDTYPE_GRADIENT ) );
- }
- return Type;
-}
-
-/*****************************************************************************/
-/* Function: Effect_Init */
-/*****************************************************************************/
-
-PyObject *Effect_Init( void )
-{
- PyObject *submodule, *dict;
- PyObject *particle;
- PyObject *Flags;
- PyObject *Types;
-
- if( PyType_Ready( &Effect_Type ) < 0)
- return NULL;
-
- Flags = Effect_FlagsDict( );
- Types = Effect_SpeedTypeDict( );
-
- submodule = Py_InitModule3( "Blender.Effect", M_Effect_methods, 0 );
- if( Flags )
- PyModule_AddObject( submodule, "Flags", Flags );
- if( Types )
- PyModule_AddObject( submodule, "SpeedTypes", Types );
-
- particle = Py_InitModule3( "Blender.Particle", M_Particle_methods,
- M_Particle_doc );
-
- dict = PyModule_GetDict( submodule );
-
- PyDict_SetItemString( dict, "Particle", particle );
- return ( submodule );
-}
-
-/*****************************************************************************/
-/* Python BPy_Effect methods: */
-/*****************************************************************************/
-
-static PyObject *Effect_getType( BPy_Effect * self )
-{
- return PyInt_FromLong( ( long ) self->effect->type );
-}
-
-/* does nothing since there is only one type of effect */
-
-static int Effect_setType( void )
-{
- return 0;
-}
-
-static int Effect_setStype( BPy_Effect * self, PyObject * args )
-{
- short param;
- if( !PyArg_Parse( args, "h", &param ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an int as argument" );
- self->effect->stype = param;
- return 0;
-}
-
-static PyObject *Effect_getStype( BPy_Effect * self )
-{
- return PyInt_FromLong( (long)( self->effect->stype ) );
-}
-
-static PyObject *Effect_getFlag( BPy_Effect * self )
-{
- return PyInt_FromLong( (long)( self->effect->flag ^ PAF_OFACE ) );
-}
-
-static int Effect_setFlag( BPy_Effect * self, PyObject * args )
-{
- short param;
- static short bitmask = PAF_BSPLINE | PAF_STATIC | PAF_FACE | PAF_ANIMATED |
- PAF_UNBORN | PAF_OFACE | PAF_SHOWE | PAF_TRAND | PAF_EDISTR | PAF_DIED;
-
- if( !PyArg_Parse( args, "h", &param ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an int as argument" );
-
- /* we don't allow users to change the select bit at this time */
- param &= ~EFF_SELECT;
-
- if ( ( param & bitmask ) != param )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid bit(s) set in mask" );
-
- /* the sense of "Verts" is inverted (clear is enabled) */
- param ^= PAF_OFACE;
-
- /* leave select bit alone, and add in the others */
- self->effect->flag &= EFF_SELECT;
- self->effect->flag |= param;
- return 0;
-}
-
-static PyObject *Effect_getSta( BPy_Effect * self )
-{
- return PyFloat_FromDouble( self->effect->sta );
-}
-
-static int Effect_setSta( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->sta,
- EXPP_EFFECT_STA_MIN, MAXFRAMEF );
-}
-
-static PyObject *Effect_getEnd( BPy_Effect * self )
-{
- return PyFloat_FromDouble( ((PartEff *) self->effect)->end );
-}
-
-static int Effect_setEnd( BPy_Effect * self, PyObject * args )
-{
- float val;
-
- if( !PyArg_Parse( args, "f", &val ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected float argument" );
-
- self->effect->end = EXPP_ClampFloat( val,
- EXPP_EFFECT_END_MIN, MAXFRAMEF );
- return 0;
-}
-
-static PyObject *Effect_getLifetime( BPy_Effect * self )
-{
- return PyFloat_FromDouble( self->effect->lifetime );
-}
-
-static int Effect_setLifetime( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->lifetime,
- EXPP_EFFECT_LIFETIME_MIN, MAXFRAMEF );
-}
-
-static PyObject *Effect_getNormfac( BPy_Effect * self )
-{
- return PyFloat_FromDouble( self->effect->normfac );
-}
-
-static int Effect_setNormfac( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->normfac,
- EXPP_EFFECT_NORMFAC_MIN, EXPP_EFFECT_NORMFAC_MAX );
-}
-
-static PyObject *Effect_getObfac( BPy_Effect * self )
-{
- return PyFloat_FromDouble( self->effect->obfac );
-}
-
-static int Effect_setObfac( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->obfac,
- EXPP_EFFECT_OBFAC_MIN, EXPP_EFFECT_OBFAC_MAX );
-}
-
-static PyObject *Effect_getRandfac( BPy_Effect * self )
-{
- return PyFloat_FromDouble( self->effect->randfac );
-}
-
-static int Effect_setRandfac( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->randfac,
- EXPP_EFFECT_RANDFAC_MIN, EXPP_EFFECT_RANDFAC_MAX );
-}
-
-static PyObject *Effect_getTexfac( BPy_Effect * self )
-{
- return PyFloat_FromDouble( self->effect->texfac );
-}
-
-static int Effect_setTexfac( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->texfac,
- EXPP_EFFECT_TEXFAC_MIN, EXPP_EFFECT_TEXFAC_MAX );
-}
-
-static PyObject *Effect_getRandlife( BPy_Effect * self )
-{
- return PyFloat_FromDouble( self->effect->randlife );
-}
-
-static int Effect_setRandlife( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->randlife,
- EXPP_EFFECT_RANDLIFE_MIN, EXPP_EFFECT_RANDLIFE_MAX );
-}
-
-static PyObject *Effect_getNabla( BPy_Effect * self )
-{
- return PyFloat_FromDouble( self->effect->nabla );
-}
-
-static int Effect_setNabla( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->nabla,
- EXPP_EFFECT_NABLA_MIN, EXPP_EFFECT_NABLA_MAX );
-}
-
-static PyObject *Effect_getVectsize( BPy_Effect * self )
-{
- return PyFloat_FromDouble( self->effect->vectsize );
-}
-
-static int Effect_setVectsize( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->vectsize,
- EXPP_EFFECT_VECTSIZE_MIN, EXPP_EFFECT_VECTSIZE_MAX );
-}
-
-static PyObject *Effect_getTotpart( BPy_Effect * self )
-{
- return PyInt_FromLong( self->effect->totpart );
-}
-
-static int Effect_setTotpart( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setIValueClamped( args, &self->effect->totpart,
- (int)EXPP_EFFECT_TOTPART_MIN, (int)EXPP_EFFECT_TOTPART_MAX, 'i' );
-}
-
-static PyObject *Effect_getTotkey( BPy_Effect * self )
-{
- return PyInt_FromLong( self->effect->totkey );
-}
-
-static int Effect_setTotkey( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setIValueClamped( args, &self->effect->totkey,
- EXPP_EFFECT_TOTKEY_MIN, EXPP_EFFECT_TOTKEY_MAX, 'i' );
-}
-
-static PyObject *Effect_getSeed( BPy_Effect * self )
-{
- return PyInt_FromLong( self->effect->seed );
-}
-
-static int Effect_setSeed( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setIValueClamped( args, &self->effect->seed,
- EXPP_EFFECT_SEED_MIN, EXPP_EFFECT_SEED_MAX, 'i' );
-}
-
-static PyObject *Effect_getForce( BPy_Effect * self )
-{
- return Py_BuildValue( "(f,f,f)", self->effect->force[0],
- self->effect->force[1], self->effect->force[2] );
-}
-
-static int Effect_setForce( BPy_Effect * self, PyObject * args )
-{
- float val[3];
- int i;
-
- if( PyTuple_Check( args ) && PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
-
- if( !PyArg_ParseTuple( args, "fff", &val[0], &val[1], &val[2] ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected a tuple of three float arguments" );
- for( i = 0; i < 3; ++i )
- self->effect->force[i] = EXPP_ClampFloat( val[i],
- EXPP_EFFECT_FORCE_MIN, EXPP_EFFECT_FORCE_MAX );
- return 0;
-}
-
-static PyObject *Effect_getMult( BPy_Effect * self )
-{
- return Py_BuildValue( "(f,f,f,f)", self->effect->mult[0],
- self->effect->mult[1], self->effect->mult[2],
- self->effect->mult[3] );
-}
-
-static int Effect_setMult( BPy_Effect * self, PyObject * args )
-{
- float val[4];
- int i;
-
- if( PyTuple_Check( args ) && PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
-
- if( !PyArg_ParseTuple( args, "ffff", &val[0], &val[1], &val[2], &val[3] ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected a tuple of four float arguments" );
- for( i = 0; i < 4; ++i )
- self->effect->mult[i] = EXPP_ClampFloat( val[i],
- EXPP_EFFECT_MULT_MIN, EXPP_EFFECT_MULT_MAX );
- return 0;
-}
-
-static PyObject *Effect_getLife( BPy_Effect * self )
-{
- return Py_BuildValue( "(f,f,f,f)", self->effect->life[0],
- self->effect->life[1], self->effect->life[2],
- self->effect->life[3] );
-}
-
-static int Effect_setLife( BPy_Effect * self, PyObject * args )
-{
- float val[4];
- int i;
-
- if( PyTuple_Check( args ) && PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
-
- if( !PyArg_ParseTuple( args, "ffff", &val[0], &val[1], &val[2], &val[3] ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected a tuple of four float arguments" );
- for( i = 0; i < 4; ++i )
- self->effect->life[i] = EXPP_ClampFloat( val[i],
- EXPP_EFFECT_LIFE_MIN, MAXFRAMEF );
- return 0;
-}
-
-static PyObject *Effect_getChild( BPy_Effect * self )
-{
- return Py_BuildValue( "(h,h,h,h)", self->effect->child[0],
- self->effect->child[1], self->effect->child[2],
- self->effect->child[3] );
-}
-
-
-static int Effect_setChild( BPy_Effect * self, PyObject * args )
-{
- short val[4];
- int i;
-
- if( PyTuple_Check( args ) && PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
-
- if( !PyArg_ParseTuple( args, "hhhh", &val[0], &val[1], &val[2], &val[3] ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected a tuple of four int argument" );
- for( i = 0; i < 4; ++i )
- self->effect->child[i] = (short)EXPP_ClampInt( val[i],
- EXPP_EFFECT_CHILD_MIN, EXPP_EFFECT_CHILD_MAX );
- return 0;
-}
-
-static PyObject *Effect_getChildMat( BPy_Effect * self )
-{
- return Py_BuildValue( "(h,h,h,h)", self->effect->mat[0],
- self->effect->mat[1], self->effect->mat[2],
- self->effect->mat[3] );
-}
-
-static int Effect_setChildMat( BPy_Effect * self, PyObject * args )
-{
- short val[4];
- int i;
-
- if( PyTuple_Check( args ) && PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
-
- if( !PyArg_ParseTuple( args, "hhhh", &val[0], &val[1], &val[2], &val[3] ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected a tuple of four int argument" );
- for( i = 0; i < 4; ++i )
- self->effect->mat[i] = (short)EXPP_ClampInt( val[i],
- EXPP_EFFECT_CHILDMAT_MIN, EXPP_EFFECT_CHILDMAT_MAX );
- return 0;
-}
-
-static PyObject *Effect_getDefvec( BPy_Effect * self )
-{
- return Py_BuildValue( "(f,f,f)", self->effect->defvec[0],
- self->effect->defvec[1], self->effect->defvec[2] );
-}
-
-static int Effect_setDefvec( BPy_Effect * self, PyObject * args )
-{
- float val[3];
- int i;
-
- if( PyTuple_Check( args ) && PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
-
- if( !PyArg_ParseTuple( args, "fff", &val[0], &val[1], &val[2] ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected a tuple of three float arguments" );
-
- for( i = 0; i < 3; ++i )
- self->effect->defvec[i] = EXPP_ClampFloat( val[i],
- EXPP_EFFECT_DEFVEC_MIN, EXPP_EFFECT_DEFVEC_MAX );
- return 0;
-}
-
-static PyObject *Effect_getJitter( BPy_Effect * self )
-{
- return PyInt_FromLong( ( long )self->effect->userjit );
-}
-
-static int Effect_setJitter( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setIValueClamped( args, &self->effect->userjit,
- EXPP_EFFECT_JITTER_MIN, EXPP_EFFECT_JITTER_MAX, 'h' );
-}
-
-static PyObject *Effect_getDispMat( BPy_Effect * self )
-{
- return PyInt_FromLong( ( long )self->effect->omat );
-}
-
-static int Effect_setDispMat( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setIValueClamped( args, &self->effect->omat,
- EXPP_EFFECT_DISPMAT_MIN, EXPP_EFFECT_DISPMAT_MAX, 'h' );
-}
-
-static PyObject *Effect_getEmissionTex( BPy_Effect * self )
-{
- return PyInt_FromLong( ( long )self->effect->timetex );
-}
-
-static int Effect_setEmissionTex( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setIValueClamped( args, &self->effect->timetex,
- EXPP_EFFECT_TIMETEX_MIN, EXPP_EFFECT_TIMETEX_MAX, 'h' );
-}
-
-static PyObject *Effect_getForceTex( BPy_Effect * self )
-{
- return PyInt_FromLong( ( long )self->effect->speedtex );
-}
-
-static int Effect_setForceTex( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setIValueClamped( args, &self->effect->speedtex,
- EXPP_EFFECT_SPEEDTEX_MIN, EXPP_EFFECT_SPEEDTEX_MAX, 'h' );
-}
-
-static PyObject *Effect_getSpeedType( BPy_Effect * self )
-{
- return PyInt_FromLong( ( long )self->effect->texmap );
-}
-
-static int Effect_setSpeedType( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setIValueRange( args, &self->effect->texmap,
- EXPP_EFFECT_SPEEDTYPE_INTENSITY, EXPP_EFFECT_SPEEDTYPE_GRADIENT,
- 'h' );
-}
-
-static PyObject *Effect_getDamping( BPy_Effect * self )
-{
- return PyFloat_FromDouble( ( double )self->effect->damp );
-}
-
-static int Effect_setDamping( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setFloatClamped( args, &self->effect->damp,
- EXPP_EFFECT_DAMP_MIN, EXPP_EFFECT_DAMP_MAX );
-}
-
-static PyObject *Effect_getVertGroup( BPy_Effect * self )
-{
- return PyString_FromString( self->effect->vgroupname );
-}
-
-
-static int Effect_setVertGroup( BPy_Effect * self, PyObject * value )
-{
- char *name;
- bDeformGroup *dg;
-
- name = PyString_AsString ( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string argument" );
-
- PyOS_snprintf( self->effect->vgroupname,
- sizeof( self->effect->vgroupname )-1, "%s", name );
-
- dg = get_named_vertexgroup( self->object, self->effect->vgroupname );
- if( dg )
- self->effect->vertgroup = (short)get_defgroup_num( self->object, dg )+1;
- else
- self->effect->vertgroup = 0;
-
- return 0;
-}
-
-static PyObject *Effect_getSpeedVertGroup( BPy_Effect * self )
-{
- return PyString_FromString( self->effect->vgroupname_v );
-}
-
-static int Effect_setSpeedVertGroup( BPy_Effect * self, PyObject * value )
-{
- char *name;
- bDeformGroup *dg;
-
- name = PyString_AsString ( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string argument" );
-
- PyOS_snprintf( self->effect->vgroupname_v,
- sizeof( self->effect->vgroupname_v )-1, "%s", name );
-
- dg = get_named_vertexgroup( self->object, self->effect->vgroupname_v );
- if( dg )
- self->effect->vertgroup_v = (short)get_defgroup_num( self->object, dg )+1;
- else
- self->effect->vertgroup_v = 0;
-
- return 0;
-}
-
-/*****************************************************************************/
-/* attribute: getDisp */
-/* Description: the current value of the display number button */
-/* Data: self effect */
-/* Return: integer value between 0 and 100 */
-/*****************************************************************************/
-static PyObject *Effect_getDisp( BPy_Effect * self )
-{
- return PyInt_FromLong( ( long )self->effect->disp );
-}
-
-static int Effect_setDisp( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setIValueRange( args, &self->effect->disp,
- EXPP_EFFECT_DISP_MIN, EXPP_EFFECT_DISP_MAX, 'h' );
-}
-
-/*****************************************************************************/
-/* attribute: getStep */
-/* Description: the current value of the Step number button */
-/* Data: self effect */
-/* Return: integer value between 1 and 100 */
-/*****************************************************************************/
-static PyObject *Effect_getStaticStep( BPy_Effect * self )
-{
- return PyInt_FromLong( ( long )self->effect->staticstep );
-}
-
-static int Effect_setStaticStep( BPy_Effect * self , PyObject * args )
-{
- return EXPP_setIValueRange( args, &self->effect->staticstep,
- EXPP_EFFECT_STATICSTEP_MIN, EXPP_EFFECT_STATICSTEP_MAX,
- 'h' );
-}
-
-/*****************************************************************************/
-/* Method: getParticlesLoc */
-/* Python equivalent: effect.getParticlesLoc */
-/* Description: Get the current location of each particle */
-/* and return a list of 3D vectors */
-/* or a list of ists of two 3D vectors */
-/* if effect.vect has any sense */
-/* Data: notihng get the current time from G.scene */
-/* Return: One python list of 3D vector */
-/*****************************************************************************/
-static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
-{
- Object *ob;
- Effect *eff;
- PartEff *paf;
- Particle *pa=0;
- PyObject *list, *strand_list, *pyvec, *pyvec2;
- float p_time, c_time, vec[3], vec1[3], cfra, m_time, s_time;
- int a;
- short disp=100 ;
-
- cfra=frame_to_float( G.scene->r.cfra );
-
- /* as we need to update the particles system we try to retrieve
- the object to which the effect is connected */
- eff =(Effect *) self->effect;
-
- ob= self->object;
- if(!ob)
- return ( EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Effect has no object" ) );
- /*get the particles data */
- paf= (PartEff *)eff;
-
- /* particles->disp reduce the display number of particles */
- /* as we want the complete list ... we backup the disp value and restore later */
- if (paf->disp<100)
- disp= paf->disp; paf->disp=100;
-
-
- build_particle_system(ob);
- pa= paf->keys;
-
- if(!pa)
- return ( EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Particles Location : no Keys" ) );
-
- /* if object is in motion */
- if( ob->ipoflag & OB_OFFS_PARTICLE )
- p_time= ob->sf;
- else
- p_time= 0.0;
-
- list = PyList_New( 0 );
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_MemoryError, "PyList() failed" );
-
- c_time= bsystem_time( ob, cfra, p_time );
-
- for( a=0; a < paf->totpart; a++, pa += paf->totkey ) {
-
- if(paf->flag & PAF_STATIC ) {
- strand_list = PyList_New( 0 );
- m_time= pa->time+pa->lifetime+paf->staticstep-1;
- for(c_time= pa->time; c_time<m_time; c_time+=paf->staticstep) {
- where_is_particle(paf, pa, c_time, vec);
- MTC_Mat4MulVecfl(ob->obmat, vec); /* make worldspace like the others */
- pyvec = newVectorObject(vec, 3, Py_NEW);
- if( PyList_Append( strand_list, pyvec) < 0 ) {
- Py_DECREF( list );
- Py_DECREF( strand_list );
- Py_XDECREF( pyvec );
-
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Couldn't append item to PyList" );
- }
- Py_DECREF( pyvec );
-
- }
-
- if( PyList_Append( list, strand_list) < 0 ) {
- Py_DECREF( list );
- Py_DECREF( strand_list );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Couldn't append item to PyList" );
- }
- Py_DECREF( strand_list );
- } else {
- if(c_time > pa->time && c_time < pa->time+pa->lifetime ) {
- /* vector particles are a tuple of 2 vectors */
- if( paf->stype==PAF_VECT ) {
- s_time= c_time;
- p_time= c_time+1.0f;
- if(c_time < pa->time) {
- if(paf->flag & PAF_UNBORN)
- p_time= pa->time+1.0f;
- else
- continue;
- }
- if(c_time > pa->time+pa->lifetime) {
- if(paf->flag & PAF_DIED)
- s_time= pa->time+pa->lifetime-1.0f;
- else
- continue;
- }
- where_is_particle(paf, pa, s_time, vec);
- where_is_particle(paf, pa, p_time, vec1);
- pyvec = newVectorObject(vec, 3, Py_NEW);
- pyvec2 = newVectorObject(vec1, 3, Py_NEW);
- if( PyList_Append( list, Py_BuildValue("[OO]", pyvec, pyvec2)) < 0 ) {
- Py_DECREF( list );
- Py_XDECREF( pyvec );
- Py_XDECREF( pyvec2 );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Couldn't append item to PyList" );
- }
- Py_DECREF( pyvec );
- Py_DECREF( pyvec2 );
- } else { /* not a vector */
- where_is_particle(paf, pa, c_time, vec);
- pyvec = newVectorObject(vec, 3, Py_NEW);
- if( PyList_Append( list, pyvec) < 0 ) {
- Py_DECREF( list );
- Py_XDECREF( pyvec );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Couldn't append item to PyList" );
- }
- Py_DECREF( pyvec );
- }
- }
- }
- }
-
- /* restore the real disp value */
- if (disp<100){
- paf->disp=disp;
- build_particle_system(ob);
- }
-
- return list;
-}
-
-/*****************************************************************************/
-/* Function: Effect_repr */
-/* Description: This is a callback function for the BPy_Effect type. It */
-/* builds a meaninful string to represent effcte objects. */
-/*****************************************************************************/
-
-static PyObject *Effect_repr( void )
-{
- return PyString_FromString( "Particle" );
-}
-
-/*****************************************************************************/
-/* These are needed by Object.c */
-/*****************************************************************************/
-PyObject *EffectCreatePyObject( Effect * effect, Object *ob )
-{
- BPy_Effect *blen_object;
-
- blen_object =
- ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
-
- if( blen_object )
- blen_object->effect = (PartEff *)effect;
- blen_object->object = ob;
-
- return ( PyObject * ) blen_object;
-}
-
-int EffectCheckPyObject( PyObject * py_obj )
-{
- return ( py_obj->ob_type == &Effect_Type );
-}
-
-/* #####DEPRECATED###### */
-
-static PyObject *Effect_oldsetChild( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Effect_setChild );
-}
-
-static PyObject *Effect_oldsetDefvec( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Effect_setDefvec );
-}
-
-static PyObject *Effect_oldsetForce( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Effect_setForce );
-}
-
-static PyObject *Effect_oldsetMat( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Effect_setChildMat );
-}
-
-static PyObject *Effect_oldsetEnd( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setEnd );
-}
-
-static PyObject *Effect_oldsetLife( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Effect_setLife );
-}
-
-static PyObject *Effect_oldsetLifetime( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setLifetime );
-}
-
-static PyObject *Effect_oldsetMult( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Effect_setMult );
-}
-
-static PyObject *Effect_oldsetNabla( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setNabla );
-}
-
-static PyObject *Effect_oldsetNormfac( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setNormfac );
-}
-
-static PyObject *Effect_oldsetObfac( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setObfac );
-}
-
-static PyObject *Effect_oldsetRandfac( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setRandfac );
-}
-
-static PyObject *Effect_oldsetRandlife( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setRandlife );
-}
-
-static PyObject *Effect_oldsetSeed( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setSeed );
-}
-
-static PyObject *Effect_oldsetSta( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setSta );
-}
-
-static PyObject *Effect_oldsetTexfac( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setTexfac );
-}
-
-static PyObject *Effect_oldsetTotkey( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setTotkey );
-}
-
-static PyObject *Effect_oldsetTotpart( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setTotpart );
-}
-
-static PyObject *Effect_oldsetVectsize( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setVectsize );
-}
-
-static PyObject *Effect_oldsetFlag( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setFlag );
-}
-
-static PyObject *Effect_oldsetStype( BPy_Effect * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setStype );
-}
-
-static PyObject *Effect_oldsetType( void )
-{
- return EXPP_incr_ret( Py_None );
-}
diff --git a/source/blender/python/api2_2x/Effect.h b/source/blender/python/api2_2x/Effect.h
deleted file mode 100644
index 86996b9f8a6..00000000000
--- a/source/blender/python/api2_2x/Effect.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Font.c b/source/blender/python/api2_2x/Font.c
deleted file mode 100644
index 61edac2841a..00000000000
--- a/source/blender/python/api2_2x/Font.c
+++ /dev/null
@@ -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 );
- }
-}
-
-
-
diff --git a/source/blender/python/api2_2x/Font.h b/source/blender/python/api2_2x/Font.h
deleted file mode 100644
index 75867c5b6e7..00000000000
--- a/source/blender/python/api2_2x/Font.h
+++ /dev/null
@@ -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
-
-
diff --git a/source/blender/python/api2_2x/Geometry.c b/source/blender/python/api2_2x/Geometry.c
deleted file mode 100644
index 909e6e449cb..00000000000
--- a/source/blender/python/api2_2x/Geometry.c
+++ /dev/null
@@ -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);
-}
diff --git a/source/blender/python/api2_2x/Geometry.h b/source/blender/python/api2_2x/Geometry.h
deleted file mode 100644
index a9a1c7cf818..00000000000
--- a/source/blender/python/api2_2x/Geometry.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Group.c b/source/blender/python/api2_2x/Group.c
deleted file mode 100644
index 26e5edd0733..00000000000
--- a/source/blender/python/api2_2x/Group.c
+++ /dev/null
@@ -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
-};
diff --git a/source/blender/python/api2_2x/Group.h b/source/blender/python/api2_2x/Group.h
deleted file mode 100644
index 68b6ce3eb17..00000000000
--- a/source/blender/python/api2_2x/Group.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/IDProp.c b/source/blender/python/api2_2x/IDProp.c
deleted file mode 100644
index 4f2fa82b21e..00000000000
--- a/source/blender/python/api2_2x/IDProp.c
+++ /dev/null
@@ -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 );
-}
diff --git a/source/blender/python/api2_2x/IDProp.h b/source/blender/python/api2_2x/IDProp.h
deleted file mode 100644
index 5fcf4f6e1b7..00000000000
--- a/source/blender/python/api2_2x/IDProp.h
+++ /dev/null
@@ -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
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
deleted file mode 100644
index f68cb2d8eeb..00000000000
--- a/source/blender/python/api2_2x/Image.c
+++ /dev/null
@@ -1,1339 +0,0 @@
-/*
- * $Id: Image.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): Willian P. Germano, Campbell Barton, Joilnen B. Leite,
- * Austin Benesh
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-#include "Image.h" /*This must come first */
-
-#include "BDR_drawmesh.h" /* free_realtime_image */
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_image.h"
-#include "BKE_idprop.h"
-#include "BIF_drawimage.h"
-#include "BLI_blenlib.h"
-#include "DNA_space_types.h" /* FILE_MAXDIR = 160 */
-#include "IMB_imbuf_types.h" /* for the IB_rect define */
-#include "BIF_gl.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-#include "BKE_packedFile.h"
-#include "DNA_packedFile_types.h"
-#include "BKE_icons.h"
-#include "IMB_imbuf.h"
-#include "IDProp.h"
-
-/* used so we can get G.scene->r.cfra for getting the
-current image frame, some images change frame if they are a sequence */
-#include "DNA_scene_types.h"
-
-/*****************************************************************************/
-/* Python BPy_Image defaults: */
-/*****************************************************************************/
-#define EXPP_IMAGE_REP 1
-#define EXPP_IMAGE_REP_MIN 1
-#define EXPP_IMAGE_REP_MAX 16
-
-
-enum img_consts {
- EXPP_IMAGE_ATTR_XREP = 0,
- EXPP_IMAGE_ATTR_YREP,
- EXPP_IMAGE_ATTR_START,
- EXPP_IMAGE_ATTR_END,
- EXPP_IMAGE_ATTR_SPEED,
- EXPP_IMAGE_ATTR_BINDCODE,
- EXPP_IMAGE_ATTR_SOURCE,
-};
-
-/************************/
-/*** The Image Module ***/
-/************************/
-
-/*****************************************************************************/
-/* Python API function prototypes for the Image module. */
-/*****************************************************************************/
-static PyObject *M_Image_New( PyObject * self, PyObject * args );
-static PyObject *M_Image_Get( PyObject * self, PyObject * args );
-static PyObject *M_Image_GetCurrent( PyObject * self );
-static PyObject *M_Image_Load( PyObject * self, PyObject * value );
-
-
-/*****************************************************************************/
-/* Python BPy_Image methods declarations: */
-/*****************************************************************************/
-static PyObject *Image_getFilename( BPy_Image * self );
-static PyObject *Image_getSize( BPy_Image * self );
-static PyObject *Image_getDepth( BPy_Image * self );
-static PyObject *Image_getXRep( BPy_Image * self );
-static PyObject *Image_getYRep( BPy_Image * self );
-static PyObject *Image_getBindCode( BPy_Image * self );
-static PyObject *Image_getStart( BPy_Image * self );
-static PyObject *Image_getEnd( BPy_Image * self );
-static PyObject *Image_getSpeed( BPy_Image * self );
-static int Image_setFilename( BPy_Image * self, PyObject * args );
-static PyObject *Image_oldsetFilename( BPy_Image * self, PyObject * args );
-static PyObject *Image_setXRep( BPy_Image * self, PyObject * value );
-static PyObject *Image_setYRep( BPy_Image * self, PyObject * value );
-static PyObject *Image_setStart( BPy_Image * self, PyObject * args );
-static PyObject *Image_setEnd( BPy_Image * self, PyObject * args );
-static PyObject *Image_setSpeed( BPy_Image * self, PyObject * args );
-static PyObject *Image_reload( BPy_Image * self );
-static PyObject *Image_glLoad( BPy_Image * self );
-static PyObject *Image_glFree( BPy_Image * self );
-static PyObject *Image_getPixelF( BPy_Image * self, PyObject * args );
-static PyObject *Image_getPixelI( BPy_Image * self, PyObject * args );
-static PyObject *Image_setPixelF( BPy_Image * self, PyObject * args );
-static PyObject *Image_setPixelI( BPy_Image * self, PyObject * args );
-static PyObject *Image_getMaxXY( BPy_Image * self );
-static PyObject *Image_getMinXY( BPy_Image * self );
-static PyObject *Image_save( BPy_Image * self );
-static PyObject *Image_unpack( BPy_Image * self, PyObject * value );
-static PyObject *Image_pack( BPy_Image * self );
-static PyObject *Image_makeCurrent( BPy_Image * self );
-
-
-/*****************************************************************************/
-/* Python BPy_Image methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Image_methods[] = {
- /* name, method, flags, doc */
- {"getPixelF", ( PyCFunction ) Image_getPixelF, METH_VARARGS,
- "(int, int) - Get pixel color as floats 0.0-1.0 returns [r,g,b,a]"},
- {"getPixelI", ( PyCFunction ) Image_getPixelI, METH_VARARGS,
- "(int, int) - Get pixel color as ints 0-255 returns [r,g,b,a]"},
- {"setPixelF", ( PyCFunction ) Image_setPixelF, METH_VARARGS,
- "(int, int, [f r,f g,f b,f a]) - Set pixel color using floats 0.0-1.0"},
- {"setPixelI", ( PyCFunction ) Image_setPixelI, METH_VARARGS,
- "(int, int, [i r, i g, i b, i a]) - Set pixel color using ints 0-255"},
- {"getMaxXY", ( PyCFunction ) Image_getMaxXY, METH_NOARGS,
- "() - Get maximum x & y coordinates of current image as [x, y]"},
- {"getMinXY", ( PyCFunction ) Image_getMinXY, METH_NOARGS,
- "() - Get minimun x & y coordinates of image as [x, y]"},
- {"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
- "() - Return Image object name"},
- {"getFilename", ( PyCFunction ) Image_getFilename, METH_NOARGS,
- "() - Return Image object filename"},
- {"getSize", ( PyCFunction ) Image_getSize, METH_NOARGS,
- "() - Return Image object [width, height] dimension in pixels"},
- {"getDepth", ( PyCFunction ) Image_getDepth, METH_NOARGS,
- "() - Return Image object pixel depth"},
- {"getXRep", ( PyCFunction ) Image_getXRep, METH_NOARGS,
- "() - Return Image object x repetition value"},
- {"getYRep", ( PyCFunction ) Image_getYRep, METH_NOARGS,
- "() - Return Image object y repetition value"},
- {"getStart", ( PyCFunction ) Image_getStart, METH_NOARGS,
- "() - Return Image object start frame."},
- {"getEnd", ( PyCFunction ) Image_getEnd, METH_NOARGS,
- "() - Return Image object end frame."},
- {"getSpeed", ( PyCFunction ) Image_getSpeed, METH_NOARGS,
- "() - Return Image object speed (fps)."},
- {"getBindCode", ( PyCFunction ) Image_getBindCode, METH_NOARGS,
- "() - Return Image object's bind code value"},
- {"reload", ( PyCFunction ) Image_reload, METH_NOARGS,
- "() - Reload the image from the filesystem"},
- {"glLoad", ( PyCFunction ) Image_glLoad, METH_NOARGS,
- "() - Load the image data in OpenGL texture memory.\n\
- The bindcode (int) is returned."},
- {"glFree", ( PyCFunction ) Image_glFree, METH_NOARGS,
- "() - Free the image data from OpenGL texture memory only,\n\
- see also image.glLoad()."},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "(str) - Change Image object name"},
- {"setFilename", ( PyCFunction ) Image_oldsetFilename, METH_VARARGS,
- "(str) - Change Image file name"},
- {"setXRep", ( PyCFunction ) Image_setXRep, METH_O,
- "(int) - Change Image object x repetition value"},
- {"setYRep", ( PyCFunction ) Image_setYRep, METH_O,
- "(int) - Change Image object y repetition value"},
- {"setStart", ( PyCFunction ) Image_setStart, METH_VARARGS,
- "(int) - Change Image object animation start value"},
- {"setEnd", ( PyCFunction ) Image_setEnd, METH_VARARGS,
- "(int) - Change Image object animation end value"},
- {"setSpeed", ( PyCFunction ) Image_setSpeed, METH_VARARGS,
- "(int) - Change Image object animation speed (fps)"},
- {"save", ( PyCFunction ) Image_save, METH_NOARGS,
- "() - Write image buffer to file"},
- {"unpack", ( PyCFunction ) Image_unpack, METH_VARARGS,
- "(int) - Unpack image. Uses the values defined in Blender.UnpackModes."},
- {"pack", ( PyCFunction ) Image_pack, METH_NOARGS,
- "() - Pack the image"},
- {"makeCurrent", ( PyCFunction ) Image_makeCurrent, METH_NOARGS,
- "() - Make this the currently displayed image"},
- {NULL, NULL, 0, NULL}
-};
-
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Image.__doc__ */
-/*****************************************************************************/
-static char M_Image_doc[] = "The Blender Image module\n\n";
-
-static char M_Image_New_doc[] =
- "() - return a new Image object";
-
-static char M_Image_Get_doc[] =
- "(name) - return the image with the name 'name', \
-returns None if not found.\n If 'name' is not specified, \
-it returns a list of all images in the\ncurrent scene.";
-
-static char M_Image_GetCurrent_doc[] =
- "() - return the current image, from last active the uv/image view, \
-returns None no image is in the view.\n";
-
-static char M_Image_Load_doc[] =
- "(filename) - return image from file filename as Image Object, \
-returns None if not found.\n";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Image module: */
-/*****************************************************************************/
-struct PyMethodDef M_Image_methods[] = {
- {"New", M_Image_New, METH_VARARGS, M_Image_New_doc},
- {"Get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
- {"GetCurrent", ( PyCFunction ) M_Image_GetCurrent, METH_NOARGS, M_Image_GetCurrent_doc},
- {"get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
- {"Load", M_Image_Load, METH_O, M_Image_Load_doc},
- {NULL, NULL, 0, NULL}
-};
-
-
-/*****************************************************************************/
-/* Function: M_Image_New */
-/* Python equivalent: Blender.Image.New */
-/*****************************************************************************/
-static PyObject *M_Image_New( PyObject * self, PyObject * args)
-{
- int width, height, depth;
- char *name;
- float color[] = {0, 0, 0, 1};
- Image *image;
- if( !PyArg_ParseTuple( args, "siii", &name, &width, &height, &depth ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 1 string and 3 ints" ) );
- if (width > 5000 || height > 5000 || width < 1 || height < 1)
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "Image width and height must be between 1 and 5000" ) );
- image = BKE_add_image_size(width, height, name, 0, color);
- if( !image )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyObject Image_Type" ) );
-
- /* reset usage count, since BKE_add_image_size() incremented it */
- /* image->id.us--; */
- /* Strange, new images have a user count of one???, otherwise it messes up */
-
- return Image_CreatePyObject( image );
-}
-
-
-
-/*****************************************************************************/
-/* Function: M_Image_Get */
-/* Python equivalent: Blender.Image.Get */
-/* Description: Receives a string and returns the image object */
-/* whose name matches the string. If no argument is */
-/* passed in, a list of all image names in the */
-/* current scene is returned. */
-/*****************************************************************************/
-static PyObject *M_Image_Get( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- Image *img_iter;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" ) );
-
- img_iter = G.main->image.first;
-
- if( name ) { /* (name) - Search image by name */
-
- BPy_Image *wanted_image = NULL;
-
- while( ( img_iter ) && ( wanted_image == NULL ) ) {
- if( strcmp( name, img_iter->id.name + 2 ) == 0 ) {
- wanted_image = ( BPy_Image * )
- PyObject_NEW( BPy_Image, &Image_Type );
- if( wanted_image )
- wanted_image->image = img_iter;
- }
- img_iter = img_iter->id.next;
- }
-
- if( wanted_image == NULL ) { /* Requested image doesn't exist */
- char error_msg[64];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Image \"%s\" not found", name );
- return ( EXPP_ReturnPyObjError
- ( PyExc_NameError, error_msg ) );
- }
-
- return ( PyObject * ) wanted_image;
- }
-
- else { /* () - return a list of all images in the scene */
- int index = 0;
- PyObject *img_list, *pyobj;
-
- img_list = PyList_New( BLI_countlist( &( G.main->image ) ) );
-
- if( img_list == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" ) );
-
- while( img_iter ) {
- pyobj = Image_CreatePyObject( img_iter );
-
- PyList_SET_ITEM( img_list, index, pyobj );
-
- img_iter = img_iter->id.next;
- index++;
- }
-
- return ( img_list );
- }
-}
-
-
-
-/*****************************************************************************/
-/* Function: M_Image_GetCurrent*/
-/* Python equivalent: Blender.Image.GetCurrent */
-/* Description: Returns the active current (G.sima) */
-/* This will be the image last under the mouse cursor */
-/* None if there is no Image. */
-/*****************************************************************************/
-static PyObject *M_Image_GetCurrent( PyObject * self )
-{
- if (!G.sima || !G.sima->image) {
- Py_RETURN_NONE;
- }
- what_image( G.sima ); /* make sure image data exists */
- return Image_CreatePyObject( G.sima->image );
-}
-
-
-/*****************************************************************************/
-/* Function: M_Image_Load */
-/* Python equivalent: Blender.Image.Load */
-/* Description: Receives a string and returns the image object */
-/* whose filename matches the string. */
-/*****************************************************************************/
-static PyObject *M_Image_Load( PyObject * self, PyObject * value )
-{
- char *fname = PyString_AsString(value);
- Image *img_ptr;
- BPy_Image *image;
-
- if( !value )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" ) );
-
- image = ( BPy_Image * ) PyObject_NEW( BPy_Image, &Image_Type );
-
- if( !image )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyObject Image_Type" ) );
-
- img_ptr = BKE_add_image_file( fname );
- if( !img_ptr )
- return ( EXPP_ReturnPyObjError( PyExc_IOError,
- "couldn't load image" ) );
-
- /* force a load the image buffers*/
- BKE_image_get_ibuf(img_ptr, NULL);
-
- image->image = img_ptr;
-
- return ( PyObject * ) image;
-}
-
-
-/**
- * getPixelF( x, y )
- * returns float list of pixel colors in rgba order.
- * returned values are floats normalized to 0.0 - 1.0.
- * blender images are all 4x8 bit at the moment apr-2005
- */
-
-static PyObject *Image_getPixelF( BPy_Image * self, PyObject * args )
-{
-
- PyObject *attr;
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
- char *pixel; /* image data */
- int index; /* offset into image data */
- int x = 0;
- int y = 0;
- int pixel_size = 4; /* each pixel is 4 x 8-bits packed in unsigned int */
- int i;
-
- if( !PyArg_ParseTuple( args, "ii", &x, &y ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 2 integers" );
-
- if( !ibuf || !ibuf->rect ) /* loading didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- if( ibuf->type == 1 ) /* bitplane image */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "unsupported bitplane image format" );
-
- if( x > ( ibuf->x - 1 )
- || y > ( ibuf->y - 1 )
- || x < ibuf->xorig || y < ibuf->yorig )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "x or y is out of range" );
-
- /*
- assumption: from looking at source, skipx is often not set,
- so we calc ourselves
- */
-
- attr = PyList_New(4);
-
- if (!attr)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't allocate memory for color list" );
-
- index = ( x + y * ibuf->x ) * pixel_size;
-
- pixel = ( char * ) ibuf->rect;
- for (i=0; i<4; i++) {
- PyList_SetItem( attr, i, PyFloat_FromDouble( ( ( double ) pixel[index+i] ) / 255.0 ));
- }
- return attr;
-}
-
-
-/**
- * getPixelI( x, y )
- * returns integer list of pixel colors in rgba order.
- * returned values are ints normalized to 0-255.
- * blender images are all 4x8 bit at the moment apr-2005
- */
-
-static PyObject *Image_getPixelI( BPy_Image * self, PyObject * args )
-{
- PyObject *attr = PyList_New(4);
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
- char *pixel; /* image data */
- int index; /* offset into image data */
- int x = 0;
- int y = 0;
- int pixel_size = 4; /* each pixel is 4 x 8-bits packed in unsigned int */
- int i;
-
- if (!attr)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't allocate memory for color list" );
-
- if( !PyArg_ParseTuple( args, "ii", &x, &y ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 2 integers" );
-
- if( !ibuf || !ibuf->rect ) /* didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- if( ibuf->type == 1 ) /* bitplane image */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "unsupported bitplane image format" );
-
- if( x > ( ibuf->x - 1 )
- || y > ( ibuf->y - 1 )
- || x < ibuf->xorig || y < ibuf->yorig )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "x or y is out of range" );
-
- /*
- assumption: from looking at source, skipx is often not set,
- so we calc ourselves
- */
-
- index = ( x + y * ibuf->x ) * pixel_size;
- pixel = ( char * ) ibuf->rect;
-
- for (i=0; i<4; i++) {
- PyList_SetItem( attr, i, PyInt_FromLong( pixel[index+i] ));
- }
- return attr;
-}
-
-
-/* set pixel as floats */
-
-static PyObject *Image_setPixelF( BPy_Image * self, PyObject * args )
-{
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
- char *pixel; /* image data */
- int index; /* offset into image data */
- int x = 0;
- int y = 0;
- int a = 0;
- int pixel_size = 4; /* each pixel is 4 x 8-bits packed in unsigned int */
- float p[4];
-
- if( !PyArg_ParseTuple
- ( args, "ii(ffff)", &x, &y, &p[0], &p[1], &p[2], &p[3] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 2 integers and an array of 4 floats" );
-
- if( !ibuf || !ibuf->rect ) /* didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- if( ibuf->type == 1 ) /* bitplane image */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "unsupported bitplane image format" );
-
- if( x > ( ibuf->x - 1 )
- || y > ( ibuf->y - 1 )
- || x < ibuf->xorig || y < ibuf->yorig )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "x or y is out of ruange" );
-
- for( a = 0; a < 4; a++ ) {
- if( p[a] > 1.0 || p[a] < 0.0 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "r, g, b, or a is out of range" );
- }
-
-
- /*
- assumption: from looking at source, skipx is often not set,
- so we calc ourselves
- */
-
- index = ( x + y * ibuf->x ) * pixel_size;
-
- pixel = ( char * ) ibuf->rect;
-
- pixel[index] = ( char ) ( p[0] * 255.0 );
- pixel[index + 1] = ( char ) ( p[1] * 255.0 );
- pixel[index + 2] = ( char ) ( p[2] * 255.0 );
- pixel[index + 3] = ( char ) ( p[3] * 255.0 );
-
- ibuf->userflags |= IB_BITMAPDIRTY;
- Py_RETURN_NONE;
-}
-
-
-/* set pixel as ints */
-
-static PyObject *Image_setPixelI( BPy_Image * self, PyObject * args )
-{
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
- char *pixel; /* image data */
- int index; /* offset into image data */
- int x = 0;
- int y = 0;
- int a = 0;
- int pixel_size = 4; /* each pixel is 4 x 8-bits packed in unsigned int */
- int p[4];
-
- if( !PyArg_ParseTuple
- ( args, "ii(iiii)", &x, &y, &p[0], &p[1], &p[2], &p[3] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 2 integers and an list of 4 ints" );
-
- if( !ibuf || !ibuf->rect ) /* didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- if( ibuf->type == 1 ) /* bitplane image */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "unsupported bitplane image format" );
-
- if( x > ( ibuf->x - 1 )
- || y > ( ibuf->y - 1 )
- || x < ibuf->xorig || y < ibuf->yorig )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "x or y is out of range" );
-
- for( a = 0; a < 4; a++ ) {
- if( p[a] > 255 || p[a] < 0 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "r, g, b, or a is out of range" );
- }
-
- /*
- assumption: from looking at source, skipx is often not set,
- so we calc ourselves
- */
-
- index = ( x + y * ibuf->x ) * pixel_size;
-
- pixel = ( char * ) ibuf->rect;
-
- pixel[index] = ( char ) p[0];
- pixel[index + 1] = ( char ) p[1];
- pixel[index + 2] = ( char ) p[2];
- pixel[index + 3] = ( char ) p[3];
-
- ibuf->userflags |= IB_BITMAPDIRTY;
- Py_RETURN_NONE;
-}
-
-
-/* get max extent of image */
-
-static PyObject *Image_getMaxXY( BPy_Image * self )
-{
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
-
- if( !ibuf || !ibuf->rect ) /* didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- return Py_BuildValue( "[i,i]", ibuf->x, ibuf->y );
-}
-
-
-/* get min extent of image */
-
-static PyObject *Image_getMinXY( BPy_Image * self )
-{
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
-
- if( !ibuf || !ibuf->rect ) /* didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- return Py_BuildValue( "[i,i]", ibuf->xorig, ibuf->yorig );
-}
-
-/* unpack image */
-
-static PyObject *Image_unpack( BPy_Image * self, PyObject * value )
-{
- Image *image = self->image;
- int mode = (int)PyInt_AsLong(value);
-
- /*get the absolute path */
- if( mode==-1 )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 1 integer from Blender.UnpackModes" );
-
- if (image->packedfile==NULL)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "image not packed" );
-
- if (unpackImage(image, mode) == RET_ERROR)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "error unpacking image" );
- Py_RETURN_NONE;
-}
-
-/* pack image */
-
-static PyObject *Image_pack( BPy_Image * self )
-{
- Image *image = self->image;
- ImBuf *ibuf = BKE_image_get_ibuf(image, NULL);
-
- if( !ibuf || !ibuf->rect ) /* didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- if (image->packedfile ) { /* RePack? */
- if (ibuf->userflags & IB_BITMAPDIRTY)
- BKE_image_memorypack(image);
- } else { /* Pack for the first time */
- if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
- BKE_image_memorypack(image);
- else
- image->packedfile = newPackedFile(image->name);
- }
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Image_makeCurrent( BPy_Image * self )
-{
-#if 0 /* add back in when bpy becomes "official" */
- static char warning = 1;
- if( warning ) {
- printf("image.makeCurrent() deprecated!\n\t use 'bpy.images.active = image instead'\n");
- --warning;
- }
-#endif
-
- if (!G.sima)
- Py_RETURN_FALSE;
-
- G.sima->image= self->image;
- Py_RETURN_TRUE;
-}
-
-
-/* save image to file */
-
-static PyObject *Image_save( BPy_Image * self )
-{
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
-
- if(!ibuf)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not save image (no image buffer)" );
-
- /* If this is a packed file, write using writePackedFile
- * because IMB_saveiff wont save to a file */
- if (self->image->packedfile) {
- if (writePackedFile(self->image->name, self->image->packedfile, 0) != RET_OK) {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not save image (writing image from packedfile failed)" );
- }
- } else if (!IMB_saveiff( ibuf, self->image->name, ibuf->flags))
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not save image (writing the image buffer failed)" );
-
- Py_RETURN_NONE; /* normal return, image saved */
-}
-
-static PyObject *M_Image_SourceDict( void )
-{
- PyObject *Dict = PyConstant_New( );
- if( Dict ) {
- BPy_constant *d = ( BPy_constant * ) Dict;
- PyConstant_Insert(d, "STILL", PyInt_FromLong(IMA_SRC_FILE));
- PyConstant_Insert(d, "MOVIE", PyInt_FromLong(IMA_SRC_MOVIE));
- PyConstant_Insert(d, "SEQUENCE", PyInt_FromLong(IMA_SRC_SEQUENCE));
- PyConstant_Insert(d, "GENERATED", PyInt_FromLong(IMA_SRC_GENERATED));
- }
- return Dict;
-}
-
-/*****************************************************************************/
-/* Function: Image_Init */
-/*****************************************************************************/
-PyObject *Image_Init( void )
-{
- PyObject *submodule;
- PyObject *Sources = M_Image_SourceDict( );
-
- if( PyType_Ready( &Image_Type ) < 0 )
- return NULL;
-
- submodule =
- Py_InitModule3( "Blender.Image", M_Image_methods,
- M_Image_doc );
-
- if( Sources )
- PyModule_AddObject( submodule, "Sources", Sources );
-
- return submodule;
-}
-
-/*****************************************************************************/
-/* Python Image_Type callback function prototypes: */
-/*****************************************************************************/
-static int Image_compare( BPy_Image * a, BPy_Image * b );
-static PyObject *Image_repr( BPy_Image * self );
-
-/*****************************************************************************/
-/* Function: Image_CreatePyObject */
-/* Description: This function will create a new BPy_Image from an existing */
-/* Blender image structure. */
-/*****************************************************************************/
-PyObject *Image_CreatePyObject( Image * image )
-{
- BPy_Image *py_img;
- py_img = ( BPy_Image * ) PyObject_NEW( BPy_Image, &Image_Type );
-
- if( !py_img )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Image object" );
-
- py_img->image = image;
- return ( PyObject * ) py_img;
-}
-
-/*****************************************************************************/
-/* Function: Image_FromPyObject */
-/* Description: Returns the Blender Image associated with this object */
-/*****************************************************************************/
-Image *Image_FromPyObject( PyObject * pyobj )
-{
- return ( ( BPy_Image * ) pyobj )->image;
-}
-
-static PyObject *Image_getFilename( BPy_Image * self )
-{
- return PyString_FromString( self->image->name );
-}
-
-static PyObject *Image_getSize( BPy_Image * self )
-{
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
- PyObject *attr;
-
- if( !ibuf ) /* didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- attr = PyList_New(2);
-
- if( !attr )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Image.size attribute" );
-
- PyList_SetItem( attr, 0, PyInt_FromLong(ibuf->x));
- PyList_SetItem( attr, 1, PyInt_FromLong(ibuf->y));
- return attr;
-}
-
-static PyObject *Image_getDepth( BPy_Image * self )
-{
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
-
- if( !ibuf ) /* didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- return PyInt_FromLong( (long)ibuf->depth );
-}
-
-
-static PyObject *Image_getXRep( BPy_Image * self )
-{
- return PyInt_FromLong( self->image->xrep );
-}
-
-static PyObject *Image_getYRep( BPy_Image * self )
-{
- return PyInt_FromLong( self->image->yrep );
-}
-
-static PyObject *Image_getStart( BPy_Image * self )
-{
- return PyInt_FromLong( self->image->twsta );
-}
-
-static PyObject *Image_getEnd( BPy_Image * self )
-{
- return PyInt_FromLong( self->image->twend );
-}
-
-static PyObject *Image_getSpeed( BPy_Image * self )
-{
- return PyInt_FromLong( self->image->animspeed );
-}
-
-static PyObject *Image_getBindCode( BPy_Image * self )
-{
- return PyLong_FromUnsignedLong( self->image->bindcode );
-}
-
-static PyObject *Image_reload( BPy_Image * self )
-{
- Image *image = self->image;
-
- BKE_image_signal(image, NULL, IMA_SIGNAL_RELOAD);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Image_glFree( BPy_Image * self )
-{
- Image *image = self->image;
-
- free_realtime_image( image );
- /* remove the nocollect flag, image is available for garbage collection again */
- image->flag &= ~IMA_NOCOLLECT;
- Py_RETURN_NONE;
-}
-
-static PyObject *Image_glLoad( BPy_Image * self )
-{
- Image *image = self->image;
- unsigned int *bind = &image->bindcode;
-
- if( *bind == 0 ) {
- ImBuf *ibuf= BKE_image_get_ibuf(self->image, NULL);
-
- if( !ibuf ) /* didn't work */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't load image data in Blender" );
-
- glGenTextures( 1, ( GLuint * ) bind );
- glBindTexture( GL_TEXTURE_2D, *bind );
-
- gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, ibuf->x,
- ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE,
- ibuf->rect );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
- GL_LINEAR );
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, ibuf->x,
- ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE,
- ibuf->rect );
-
- /* raise the nocollect flag,
- image is not available for garbage collection
- (python GL might use it directly)
- */
- image->flag |= IMA_NOCOLLECT;
- }
-
- return PyLong_FromUnsignedLong( image->bindcode );
-}
-
-static int Image_setFilename( BPy_Image * self, PyObject * value )
-{
- char *name;
-
- name = PyString_AsString(value);
-
- if( !name )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "expected a string argument" ) );
-
- /* max len is FILE_MAXDIR == 160, FILE_MAXFILE == 80 chars like done in DNA_image_types.h */
- if( strlen(name) >= FILE_MAXDIR + FILE_MAXFILE )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "string argument is limited to 240 chars at most" ) );
-
- strcpy( self->image->name, name );
- return 0;
-}
-
-static PyObject *Image_oldsetFilename( BPy_Image * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Image_setFilename );
-}
-
-static PyObject *Image_setXRep( BPy_Image * self, PyObject * value )
-{
- short param = (short)PyInt_AsLong(value);
-
- if( param !=-1 && param >= EXPP_IMAGE_REP_MIN && param <= EXPP_IMAGE_REP_MAX)
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument in [1,16]" ) );
-
- self->image->xrep = param;
- Py_RETURN_NONE;
-}
-
-static PyObject *Image_setYRep( BPy_Image * self, PyObject * value )
-{
- short param = (short)PyInt_AsLong(value);
-
- if( param !=-1 && param >= EXPP_IMAGE_REP_MIN && param <= EXPP_IMAGE_REP_MAX)
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument in [1,16]" ) );
-
- self->image->yrep = param;
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Image_setStart( BPy_Image * self, PyObject * args )
-{
- short value;
-
- if( !PyArg_ParseTuple( args, "h", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument in [0,128]" ) );
-
- if( value >= 0 && value <= 128 )
- self->image->twsta = value;
- else
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected int argument in [0,128]" ) );
-
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Image_setEnd( BPy_Image * self, PyObject * args )
-{
- short value;
-
- if( !PyArg_ParseTuple( args, "h", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument in [0,128]" ) );
-
- if( value >= 0 && value <= 128 )
- self->image->twend = value;
- else
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected int argument in [0,128]" ) );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Image_setSpeed( BPy_Image * self, PyObject * args )
-{
- short value;
-
- if( !PyArg_ParseTuple( args, "h", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument in [0,128]" ) );
-
- if( value >= 1 && value <= 100 )
- self->image->animspeed = value;
- else
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected int argument in [0,128]" ) );
-
- Py_RETURN_NONE;
-}
-
-
-/*****************************************************************************/
-/* Function: Image_compare */
-/* Description: This is a callback function for the BPy_Image type. It */
-/* compares two Image_Type objects. Only the "==" and "!=" */
-/* comparisons are meaninful. Returns 0 for equality and -1 if */
-/* they don't point to the same Blender Image struct. */
-/* In Python it becomes 1 if they are equal, 0 otherwise. */
-/*****************************************************************************/
-static int Image_compare( BPy_Image * a, BPy_Image * b )
-{
- return ( a->image == b->image ) ? 0 : -1;
-}
-
-/*****************************************************************************/
-/* Function: Image_repr */
-/* Description: This is a callback function for the BPy_Image type. It */
-/* builds a meaninful string to represent image objects. */
-/*****************************************************************************/
-static PyObject *Image_repr( BPy_Image * self )
-{
- return PyString_FromFormat( "[Image \"%s\"]",
- self->image->id.name + 2 );
-}
-
-static PyObject *Image_getPacked(BPy_Image *self, void *closure)
-{
- if (self->image->packedfile)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static PyObject *Image_hasData(BPy_Image *self, void *closure)
-{
- if (self->image->ibufs.first)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static PyObject *Image_getFlag(BPy_Image *self, void *flag)
-{
- if (self->image->flag & (int)flag)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-
-}
-
-static PyObject *Image_getFlagTpage(BPy_Image *self, void *flag)
-{
- if (self->image->tpageflag & (int)flag)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-
-}
-
-static int Image_setSource( BPy_Image *self, PyObject *args)
-{
- PyObject* integer = PyNumber_Int( args );
- short value;
-
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- value = ( short )PyInt_AS_LONG( integer );
- Py_DECREF( integer );
-
- if( value < IMA_SRC_FILE || value > IMA_SRC_GENERATED )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected integer argument in range 1-4" );
-
- self->image->source = value;
- return 0;
-}
-
-static int Image_setFlag(BPy_Image *self, PyObject *value, void *flag)
-{
- int param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if ( param )
- self->image->flag |= (int)flag;
- else
- self->image->flag &= ~(int)flag;
- return 0;
-}
-
-static int Image_setFlagTpage(BPy_Image *self, PyObject *value, void *flag)
-{
- int param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if ( param )
- self->image->tpageflag |= (int)flag;
- else
- self->image->tpageflag &= ~(int)flag;
- return 0;
-}
-
-/*
- * get integer attributes
- */
-static PyObject *getIntAttr( BPy_Image *self, void *type )
-{
- int param;
- struct Image *image = self->image;
-
- switch( (int)type ) {
- case EXPP_IMAGE_ATTR_XREP:
- param = image->xrep;
- break;
- case EXPP_IMAGE_ATTR_YREP:
- param = image->xrep;
- break;
- case EXPP_IMAGE_ATTR_START:
- param = image->twsta;
- break;
- case EXPP_IMAGE_ATTR_END:
- param = image->twend;
- break;
- case EXPP_IMAGE_ATTR_SPEED:
- param = image->animspeed;
- break;
- case EXPP_IMAGE_ATTR_BINDCODE:
- param = image->bindcode;
- break;
- case EXPP_IMAGE_ATTR_SOURCE:
- param = image->source;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type in getIntAttr" );
- }
-
- return PyInt_FromLong( param );
-}
-
-
-/*
- * set integer attributes which require clamping
- */
-
-static int setIntAttrClamp( BPy_Image *self, PyObject *value, void *type )
-{
- void *param;
- struct Image *image = self->image;
- int min, max, size;
-
- switch( (int)type ) {
- case EXPP_IMAGE_ATTR_XREP:
- min = EXPP_IMAGE_REP_MIN;
- max = EXPP_IMAGE_REP_MAX;
- size = 'h';
- param = (void *)&image->xrep;
- break;
- case EXPP_IMAGE_ATTR_YREP:
- min = EXPP_IMAGE_REP_MIN;
- max = EXPP_IMAGE_REP_MAX;
- size = 'h';
- param = (void *)&image->yrep;
- break;
- case EXPP_IMAGE_ATTR_START:
- min = 0;
- max = 128;
- size = 'h';
- param = (void *)&image->twsta;
- break;
- case EXPP_IMAGE_ATTR_END:
- min = 0;
- max = 128;
- size = 'h';
- param = (void *)&image->twend;
- break;
- case EXPP_IMAGE_ATTR_SPEED:
- min = 0;
- max = 100;
- size = 'h';
- param = (void *)&image->animspeed;
- break;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setIntAttrClamp");
- }
- return EXPP_setIValueClamped( value, param, min, max, size );
-}
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Image_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"filename", (getter)Image_getFilename, (setter)Image_setFilename,
- "image path", NULL},
- /* readonly */
- {"depth", (getter)Image_getDepth, (setter)NULL,
- "image depth", NULL},
- {"size", (getter)Image_getSize, (setter)NULL,
- "image size", NULL},
- {"packed", (getter)Image_getPacked, (setter)NULL,
- "image packed state", NULL },
- {"has_data", (getter)Image_hasData, (setter)NULL,
- "is image data loaded", NULL },
- /* ints */
- {"xrep", (getter)getIntAttr, (setter)setIntAttrClamp,
- "image xrep", (void *)EXPP_IMAGE_ATTR_XREP },
- {"yrep", (getter)getIntAttr, (setter)setIntAttrClamp,
- "image yrep", (void *)EXPP_IMAGE_ATTR_YREP },
- {"start", (getter)getIntAttr, (setter)setIntAttrClamp,
- "image start frame", (void *)EXPP_IMAGE_ATTR_START },
- {"end", (getter)getIntAttr, (setter)setIntAttrClamp,
- "image end frame", (void *)EXPP_IMAGE_ATTR_END },
- {"speed", (getter)getIntAttr, (setter)setIntAttrClamp,
- "image end frame", (void *)EXPP_IMAGE_ATTR_SPEED },
- {"bindcode", (getter)getIntAttr, (setter)NULL,
- "openGL bindcode", (void *)EXPP_IMAGE_ATTR_BINDCODE },
- {"source", (getter)getIntAttr, (setter)Image_setSource,
- "image source type", (void *)EXPP_IMAGE_ATTR_SOURCE },
- /* flags */
- {"fields", (getter)Image_getFlag, (setter)Image_setFlag,
- "image fields toggle", (void *)IMA_FIELDS },
- {"fields_odd", (getter)Image_getFlag, (setter)Image_setFlag,
- "image odd fields toggle", (void *)IMA_STD_FIELD },
- {"antialias", (getter)Image_getFlag, (setter)Image_setFlag,
- "image antialiasing toggle", (void *)IMA_ANTIALI },
- {"reflect", (getter)Image_getFlag, (setter)Image_setFlag,
- "image reflect toggle", (void *)IMA_REFLECT },
- {"clampX", (getter)Image_getFlagTpage, (setter)Image_setFlagTpage,
- "disable tiling on the X axis", (void *)IMA_CLAMP_U },
- {"clampY", (getter)Image_getFlagTpage, (setter)Image_setFlagTpage,
- "disable tiling on the Y axis", (void *)IMA_CLAMP_V },
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-/*****************************************************************************/
-/* Python Image_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Image_Type = {
- PyObject_HEAD_INIT( NULL ) /* required macro. ( no comma needed ) */
- 0, /* ob_size */
- "Blender Image", /* tp_name */
- sizeof( BPy_Image ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- NULL, /* tp_dealloc */
- 0, /* tp_print */
- NULL, /* tp_getattr */
- NULL, /* tp_setattr */
- ( cmpfunc ) Image_compare, /* tp_compare */
- ( reprfunc ) Image_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_Image_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Image_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
-};
diff --git a/source/blender/python/api2_2x/Image.h b/source/blender/python/api2_2x/Image.h
deleted file mode 100644
index a2fb22563bb..00000000000
--- a/source/blender/python/api2_2x/Image.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c
deleted file mode 100644
index e150a10259c..00000000000
--- a/source/blender/python/api2_2x/Ipo.c
+++ /dev/null
@@ -1,1842 +0,0 @@
-/*
- * $Id: Ipo.c 12078 2007-09-18 06:41:29Z 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, Nathan Letwory,
- * Stephen Swaney, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Ipo.h" /*This must come first*/
-
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_object.h"
-#include "BKE_ipo.h"
-#include "BLI_blenlib.h"
-#include "BIF_space.h"
-#include "BSE_editipo.h"
-#include "MEM_guardedalloc.h"
-#include "DNA_key_types.h"
-#include "mydevice.h"
-#include "Ipocurve.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-extern int ob_ar[];
-extern int la_ar[];
-extern int ma_ar[];
-extern int ac_ar[];
-extern int cam_ar[];
-extern int co_ar[];
-extern int cu_ar[];
-extern int seq_ar[];
-extern int te_ar[];
-extern int wo_ar[];
-
-PyObject *submodule;
-
-/*****************************************************************************/
-/* Python API function prototypes for the Ipo module. */
-/*****************************************************************************/
-static PyObject *M_Ipo_New( PyObject * self, PyObject * args );
-static PyObject *M_Ipo_Get( PyObject * self, PyObject * args );
-static PyObject *M_Ipo_Recalc( 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.Ipo.__doc__ */
-/*****************************************************************************/
-char M_Ipo_doc[] = "";
-char M_Ipo_New_doc[] = "";
-char M_Ipo_Get_doc[] = "";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Ipo module: */
-/*****************************************************************************/
-
-struct PyMethodDef M_Ipo_methods[] = {
- {"New", ( PyCFunction ) M_Ipo_New, METH_VARARGS | METH_KEYWORDS,
- M_Ipo_New_doc},
- {"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
- {"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
- {"Recalc", M_Ipo_Recalc, METH_O, M_Ipo_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Ipo methods declarations: */
-/*****************************************************************************/
-static PyObject *Ipo_getBlocktype( BPy_Ipo * self );
-static PyObject *Ipo_oldsetBlocktype( BPy_Ipo * self, PyObject * args );
-static int Ipo_setBlocktype( BPy_Ipo * self, PyObject * args );
-static PyObject *Ipo_getRctf( BPy_Ipo * self );
-static PyObject *Ipo_oldsetRctf( BPy_Ipo * self, PyObject * args );
-static int Ipo_setRctf( BPy_Ipo * self, PyObject * args );
-
-static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args );
-static PyObject *Ipo_getCurves( BPy_Ipo * self );
-static PyObject *Ipo_getCurveNames( BPy_Ipo * self );
-static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * value );
-static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args );
-static PyObject *Ipo_getNcurves( BPy_Ipo * self );
-static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args );
-static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args );
-static PyObject *Ipo_getCurveBP( BPy_Ipo * self, PyObject * args );
-static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args );
-static PyObject *Ipo_EvaluateCurveOn( BPy_Ipo * self, PyObject * args );
-
-static PyObject *Ipo_setCurveBeztriple( BPy_Ipo * self, PyObject * args );
-static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args );
-
-static PyObject *Ipo_getChannel( BPy_Ipo * self );
-static PyObject *Ipo_copy( BPy_Ipo * self );
-static int Ipo_setChannel( BPy_Ipo * self, PyObject * args );
-
-static int Ipo_length( BPy_Ipo * inst );
-static PyObject *Ipo_getIpoCurveByName( BPy_Ipo * self, PyObject * key );
-static int Ipo_setIpoCurveByName( BPy_Ipo * self, PyObject * key,
- PyObject * value );
-static int Ipo_contains( BPy_Ipo * self, PyObject * key );
-
-/*****************************************************************************/
-/* Python BPy_Ipo methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Ipo_methods[] = {
- /* name, method, flags, doc */
- {"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
- "() - Return Ipo Data name"},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "(str) - Change Ipo Data name"},
- {"getBlocktype", ( PyCFunction ) Ipo_getBlocktype, METH_NOARGS,
- "() - Return Ipo blocktype"},
- {"setBlocktype", ( PyCFunction ) Ipo_oldsetBlocktype, METH_VARARGS,
- "(str) - Change Ipo blocktype"},
- {"getRctf", ( PyCFunction ) Ipo_getRctf, METH_NOARGS,
- "() - Return Ipo rctf"},
- {"setRctf", ( PyCFunction ) Ipo_oldsetRctf, METH_VARARGS,
- "(flt,flt,flt,flt) - Change Ipo rctf"},
- {"addCurve", ( PyCFunction ) Ipo_addCurve, METH_O,
- "() - Add a curve to Ipo"},
- {"delCurve", ( PyCFunction ) Ipo_delCurve, METH_VARARGS,
- "(str) - Delete curve from Ipo"},
- {"getNcurves", ( PyCFunction ) Ipo_getNcurves, METH_NOARGS,
- "() - Return number of Ipo curves"},
- {"getCurves", ( PyCFunction ) Ipo_getCurves, METH_NOARGS,
- "() - Return list of all defined Ipo curves"},
- {"getCurve", ( PyCFunction ) Ipo_getCurve, METH_VARARGS,
- "(str|int) - Returns specified Ipo curve"},
- {"getNBezPoints", ( PyCFunction ) Ipo_getNBezPoints, METH_VARARGS,
- "(int) - Return number of Bez points on an Ipo curve"},
- {"delBezPoint", ( PyCFunction ) Ipo_DeleteBezPoints, METH_VARARGS,
- "(int) - deprecated: use ipocurve.delBezier()"},
- {"getCurveBP", ( PyCFunction ) Ipo_getCurveBP, METH_VARARGS,
- "() - unsupported"},
- {"EvaluateCurveOn", ( PyCFunction ) Ipo_EvaluateCurveOn, METH_VARARGS,
- "(int,flt) - deprecated: see ipocurve.evaluate()"},
- {"getCurveCurval", ( PyCFunction ) Ipo_getCurvecurval, METH_VARARGS,
- "(int) - deprecated: see ipocurve.evaluate()"},
- {"getCurveBeztriple", ( PyCFunction ) Ipo_getCurveBeztriple, METH_VARARGS,
- "(int,int) - deprecated: see ipocurve.bezierPoints[]"},
- {"setCurveBeztriple", ( PyCFunction ) Ipo_setCurveBeztriple, METH_VARARGS,
- "(int,int,list) - set a BezTriple"},
-
- {"__copy__", ( PyCFunction ) Ipo_copy, METH_NOARGS,
- "() - copy the ipo"},
- {"copy", ( PyCFunction ) Ipo_copy, METH_NOARGS,
- "() - copy the ipo"},
-
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Ipo attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Ipo_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"curves",
- (getter)Ipo_getCurves, (setter)NULL,
- "Ipo curves",
- NULL},
- {"curveConsts",
- (getter)Ipo_getCurveNames, (setter)NULL,
- "Ipo curve constants (values depend on Ipo type)",
- NULL},
- {"channel",
- (getter)Ipo_getChannel, (setter)Ipo_setChannel,
- "Ipo texture channel (world, lamp, material Ipos only)",
- NULL},
-
- {"blocktype",
- (getter)Ipo_getBlocktype, (setter)NULL,
- "Ipo block type",
- NULL},
- {"rctf",
- (getter)Ipo_getRctf, (setter)Ipo_setRctf,
- "Ipo type",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python Ipo_Type Mapping Methods table: */
-/*****************************************************************************/
-static PyMappingMethods Ipo_as_mapping = {
- ( inquiry ) Ipo_length, /* mp_length */
- ( binaryfunc ) Ipo_getIpoCurveByName, /* mp_subscript */
- ( objobjargproc ) Ipo_setIpoCurveByName, /* mp_ass_subscript */
-};
-
-static PySequenceMethods Ipo_as_sequence = {
- ( inquiry ) 0, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) 0, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- ( objobjproc ) Ipo_contains, /* sq_contains */
- ( binaryfunc ) 0, /* sq_inplace_concat */
- ( intargfunc ) 0, /* sq_inplace_repeat */
-};
-
-/*****************************************************************************/
-/* Python Ipo_Type callback function prototypes: */
-/*****************************************************************************/
-/*static int IpoPrint (BPy_Ipo *self, FILE *fp, int flags);*/
-static int Ipo_compare( BPy_Ipo * a, BPy_Ipo * b );
-static PyObject *Ipo_repr( BPy_Ipo * self );
-static PyObject *Ipo_getIter( BPy_Ipo * self );
-static PyObject *Ipo_nextIter( BPy_Ipo * self );
-
-/* #define CURVEATTRS */ /* uncomment to enable curves as Ipo attributes */
-
-#ifdef CURVEATTRS
-static PyGetSetDef BPy_Ipocurve_getseter = {
- "noname",
- (getter)NULL, (setter)NULL,
- "Ipo curve name",
- NULL
-};
-
-void generate_curveattrs( PyObject* dict, int blocktype )
-{
- typedef char * (*namefunc)(int, ... );
- namefunc lookup_name;
- int size;
- int *vals = NULL;
- char name[32];
- PyObject*desc;
-
- switch ( blocktype ) {
- case ID_OB:
- lookup_name = (namefunc)getname_ob_ei;
- vals = ob_ar;
- size = OB_TOTIPO;
- break;
- case ID_MA:
- lookup_name = (namefunc)getname_mat_ei;
- vals = ma_ar;
- size = MA_TOTIPO;
- break;
- case ID_CA:
- lookup_name = (namefunc)getname_cam_ei;
- vals = cam_ar;
- size = CAM_TOTIPO;
- break;
- case ID_LA:
- lookup_name = (namefunc)getname_la_ei;
- vals = la_ar;
- size = LA_TOTIPO;
- break;
- case ID_TE:
- lookup_name = (namefunc)getname_tex_ei;
- vals = te_ar;
- size = TE_TOTIPO;
- break;
- case ID_WO:
- lookup_name = (namefunc)getname_world_ei;
- vals = wo_ar;
- size = WO_TOTIPO;
- break;
- case ID_PO:
- lookup_name = (namefunc)getname_ac_ei;
- vals = ac_ar;
- size = AC_TOTIPO;
- break;
- case ID_CO:
- lookup_name = (namefunc)getname_co_ei;
- vals = co_ar;
- size = CO_TOTIPO;
- break;
- case ID_CU:
- lookup_name = (namefunc)getname_cu_ei;
- vals = cu_ar;
- size = CU_TOTIPO;
- break;
- case ID_SEQ:
- lookup_name = (namefunc)getname_seq_ei;
- vals = seq_ar;
- size = SEQ_TOTIPO;
- break;
- }
-
- desc = PyDescr_NewGetSet( &Ipo_Type, &BPy_Ipocurve_getseter );
- while( size-- ) {
- strcpy( name, lookup_name( *vals ) );
- *name = tolower( *name );
- PyDict_SetItemString( dict, name, desc );
- ++vals;
- }
- Py_DECREF( desc );
-}
-
-static short lookup_curve_name( char *, int , int );
-
-static PyObject *getattro( PyObject *self, PyObject *value )
-{
- char *name = PyString_AS_STRING( value );
- Ipo *ipo = ((BPy_Ipo *)self)->ipo;
- int adrcode;
- IpoCurve *icu;
-
- if( !strcmp(name, "__class__") )
- return PyObject_GenericGetAttr( self, value );
-
- if( !strcmp(name, "__dict__") ) /* no effect */
- {
- PyObject *dict;
- dict = PyDict_Copy( self->ob_type->tp_dict );
- generate_curveattrs( dict, ipo->blocktype );
- return dict;
- }
-
- adrcode = lookup_curve_name( name, ipo->blocktype,
- ((BPy_Ipo *)self)->mtex );
-
- if( adrcode != -1 ) {
- for( icu = ipo->curve.first; icu; icu = icu->next )
- if( icu->adrcode == adrcode )
- return IpoCurve_CreatePyObject( icu );
- Py_RETURN_NONE;
- }
-
- return PyObject_GenericGetAttr( self, value );
-}
-#endif
-
-/*****************************************************************************/
-/* Python Ipo_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Ipo_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Ipo", /* char *tp_name; */
- sizeof( BPy_Ipo ), /* 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 ) Ipo_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Ipo_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &Ipo_as_sequence, /* PySequenceMethods *tp_as_sequence; */
- &Ipo_as_mapping, /* 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; */
-#ifdef CURVEATTRS
- (getattrofunc)getattro,
-#else
- NULL, /* getattrofunc tp_getattro; */
-#endif
- 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) Ipo_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) Ipo_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_Ipo_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Ipo_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
-};
-
-/*****************************************************************************/
-/* internal utility routines */
-/*****************************************************************************/
-
-/*
- * Search through list of known Ipocurves for a particular name.
- *
- * str: name of curve we are searching for
- * blocktype: type of Ipo
- * channel: texture channel number, for World/Lamp/Material curves
- *
- * returns the adrcode for the named curve if it exists, -1 otherwise
- */
-
-/* this is needed since getname_ob_ei() is different from the rest */
-
-typedef char * (*namefunc)(int, ... );
-
-static short lookup_curve_name( char *str, int blocktype, int channel )
-{
- namefunc lookup_name;
- int *adrcodes = NULL;
- int size = 0;
-
- /* make sure channel type is ignored when it should be */
- if( blocktype != ID_WO && blocktype != ID_LA && blocktype != ID_MA )
- channel = -1;
-
- switch ( blocktype ) {
- case ID_OB:
- lookup_name = (namefunc)getname_ob_ei;
- adrcodes = ob_ar;
- size = OB_TOTIPO;
- break;
- case ID_MA:
- lookup_name = (namefunc)getname_mat_ei;
- adrcodes = ma_ar;
- size = MA_TOTIPO;
- break;
- case ID_CA:
- lookup_name = (namefunc)getname_cam_ei;
- adrcodes = cam_ar;
- size = CAM_TOTIPO;
- break;
- case ID_LA:
- lookup_name = (namefunc)getname_la_ei;
- adrcodes = la_ar;
- size = LA_TOTIPO;
- break;
- case ID_TE:
- lookup_name = (namefunc)getname_tex_ei;
- adrcodes = te_ar;
- size = TE_TOTIPO;
- break;
- case ID_WO:
- lookup_name = (namefunc)getname_world_ei;
- adrcodes = wo_ar;
- size = WO_TOTIPO;
- break;
- case ID_PO:
- lookup_name = (namefunc)getname_ac_ei;
- adrcodes = ac_ar;
- size = AC_TOTIPO;
- break;
- case ID_CO:
- lookup_name = (namefunc)getname_co_ei;
- adrcodes = co_ar;
- size = CO_TOTIPO;
- break;
- case ID_CU:
- lookup_name = (namefunc)getname_cu_ei;
- adrcodes = cu_ar;
- size = CU_TOTIPO;
- break;
- case ID_SEQ:
- lookup_name = (namefunc)getname_seq_ei;
- adrcodes = seq_ar;
- size = SEQ_TOTIPO;
- break;
- case ID_KE: /* shouldn't happen */
- default:
- return -1;
- }
-
- while ( size-- ) {
- char *name = lookup_name ( *adrcodes );
-
- /* if not a texture channel, just return the adrcode */
- if( !strcmp( str, name ) ) {
- if( channel == -1 || *adrcodes < MA_MAP1 )
- return (short)*adrcodes;
-
- /* otherwise adjust adrcode to include current channel */
- else {
- int param = (short)*adrcodes & ~MA_MAP1;
- param |= texchannel_to_adrcode( channel );
- return (short)param;
- }
- }
- ++adrcodes;
- }
- return -1;
-}
-
-static short lookup_curve_key( char *str, Ipo *ipo )
-{
- Key *keyiter;
-
- /* find the ipo in the keylist */
- for( keyiter = G.main->key.first; keyiter; keyiter = keyiter->id.next ) {
- if( keyiter->ipo == ipo ) {
- KeyBlock *block = keyiter->block.first;
-
- /* look for a matching string, get the adrcode */
- for( block = keyiter->block.first; block; block = block->next )
- if( !strcmp( str, block->name ) )
- return block->adrcode;
-
- /* no match; no addr code */
- return -1;
- }
- }
-
- /* error if the ipo isn't in the list */
- return -2;
-}
-
-/*
- * Search through list of known Ipocurves for a particular adrcode.
- *
- * code: adrcode of curve we are searching for
- * blocktype: type of Ipo
- * channel: texture channel number, for World/Lamp/Material curves
- *
- * returns the adrcode for the named curve if it exists, -1 otherwise
- */
-
-static short lookup_curve_adrcode( int code, int blocktype, int channel )
-{
- int *adrcodes = NULL;
- int size = 0;
-
- switch ( blocktype ) {
- case ID_OB:
- adrcodes = ob_ar;
- size = OB_TOTIPO;
- break;
- case ID_MA:
- adrcodes = ma_ar;
- size = MA_TOTIPO;
- break;
- case ID_CA:
- adrcodes = cam_ar;
- size = CAM_TOTIPO;
- break;
- case ID_LA:
- adrcodes = la_ar;
- size = LA_TOTIPO;
- break;
- case ID_TE:
- adrcodes = te_ar;
- size = TE_TOTIPO;
- break;
- case ID_WO:
- adrcodes = wo_ar;
- size = WO_TOTIPO;
- break;
- case ID_PO:
- adrcodes = ac_ar;
- size = AC_TOTIPO;
- break;
- case ID_CO:
- adrcodes = co_ar;
- size = CO_TOTIPO;
- break;
- case ID_CU:
- adrcodes = cu_ar;
- size = CU_TOTIPO;
- break;
- case ID_SEQ:
- adrcodes = seq_ar;
- size = SEQ_TOTIPO;
- break;
- case ID_KE:
- default:
- return -1;
- }
-
- while ( size-- ) {
- if( *adrcodes == code ) {
-
- /* if not a texture channel, just return the adrcode */
- if( channel == -1 || *adrcodes < MA_MAP1 )
- return (short)*adrcodes;
-
- /* otherwise adjust adrcode to include current channel */
- else {
- int param = *adrcodes & ~MA_MAP1;
- param |= texchannel_to_adrcode( channel );
- return (short)param;
- }
- }
- ++adrcodes;
- }
- return -1;
-}
-
-/*
- * Delete an IpoCurve from an Ipo
- */
-
-static void del_ipocurve( Ipo * ipo, IpoCurve * icu ) {
- BLI_remlink( &( ipo->curve ), icu );
- if( icu->bezt )
- MEM_freeN( icu->bezt );
- if( icu->driver )
- MEM_freeN( icu->driver );
- MEM_freeN( icu );
-
- /* have to do this to avoid crashes in the IPO window */
- allspace( REMAKEIPO, 0 );
- EXPP_allqueue( REDRAWIPO, 0 );
-}
-
-/*****************************************************************************/
-/* Python BPy_Ipo functions: */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* Function: M_Ipo_New */
-/* Python equivalent: Blender.Ipo.New */
-/*****************************************************************************/
-
-static PyObject *M_Ipo_New( PyObject * self_unused, PyObject * args )
-{
- char *name = NULL, *code = NULL;
- int idcode = -1;
- Ipo *blipo;
-
- if( !PyArg_ParseTuple( args, "ss", &code, &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected two string arguments" );
-
- if( !strcmp( code, "Object" ) )
- idcode = ID_OB;
- else if( !strcmp( code, "Camera" ) )
- idcode = ID_CA;
- else if( !strcmp( code, "World" ) )
- idcode = ID_WO;
- else if( !strcmp( code, "Material" ) )
- idcode = ID_MA;
- else if( !strcmp( code, "Texture" ) )
- idcode = ID_TE;
- else if( !strcmp( code, "Lamp" ) )
- idcode = ID_LA;
- else if( !strcmp( code, "Action" ) )
- idcode = ID_PO;
- else if( !strcmp( code, "Constraint" ) )
- idcode = ID_CO;
- else if( !strcmp( code, "Sequence" ) )
- idcode = ID_SEQ;
- else if( !strcmp( code, "Curve" ) )
- idcode = ID_CU;
- else if( !strcmp( code, "Key" ) )
- idcode = ID_KE;
- else return EXPP_ReturnPyObjError( PyExc_ValueError,
- "unknown Ipo code" );
-
- blipo = add_ipo( name, idcode );
-
- if( blipo ) {
- /* return user count to zero because add_ipo() inc'd it */
- blipo->id.us = 0;
- /* create python wrapper obj */
- return Ipo_CreatePyObject( blipo );
- } else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Ipo Data in Blender" );
-}
-
-/*****************************************************************************/
-/* Function: M_Ipo_Get */
-/* Python equivalent: Blender.Ipo.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_Ipo_Get( PyObject * self_unused, PyObject * args )
-{
- char *name = NULL;
- Ipo *ipo_iter;
- PyObject *ipolist, *pyobj;
- char error_msg[64];
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" ) );
-
- ipo_iter = G.main->ipo.first;
-
- if( name ) { /* (name) - Search ipo by name */
- while( ipo_iter ) {
- if( !strcmp( name, ipo_iter->id.name + 2 ) ) {
- return Ipo_CreatePyObject( ipo_iter );
- }
- ipo_iter = ipo_iter->id.next;
- }
-
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Ipo \"%s\" not found", name );
- return EXPP_ReturnPyObjError( PyExc_NameError, error_msg );
- }
-
- else { /* () - return a list with all ipos in the scene */
- int index = 0;
-
- ipolist = PyList_New( BLI_countlist( &( G.main->ipo ) ) );
-
- if( !ipolist )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" );
-
- while( ipo_iter ) {
- pyobj = Ipo_CreatePyObject( ipo_iter );
-
- if( !pyobj )
- return NULL;
-
- PyList_SET_ITEM( ipolist, index, pyobj );
-
- ipo_iter = ipo_iter->id.next;
- index++;
- }
-
- return ipolist;
- }
-}
-
-/*
- * This should probably be deprecated too? Or else documented in epydocs.
- * Seems very similar to Ipocurve.recalc().
- */
-
-/*****************************************************************************/
-/* Function: M_Ipo_Recalc */
-/* Python equivalent: Blender.Ipo.Recalc */
-/* Description: Receives (presumably) an IpoCurve object and */
-/* updates the curve after changes to control points. */
-/*****************************************************************************/
-static PyObject *M_Ipo_Recalc( PyObject * self_unused, PyObject * value )
-{
- if( !BPy_IpoCurve_Check(value) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Ipo curve argument" );
-
- testhandles_ipocurve( IpoCurve_FromPyObject( value ) );
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Python BPy_Ipo methods: */
-/*****************************************************************************/
-static PyObject *Ipo_getBlocktype( BPy_Ipo * self )
-{
- return PyInt_FromLong( self->ipo->blocktype );
-}
-
-static int Ipo_setBlocktype( BPy_Ipo * self, PyObject * args )
-{
- if( !PyInt_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- self->ipo->blocktype = (short)PyInt_AS_LONG( args );
-
- return 0;
-}
-
-static PyObject *Ipo_getRctf( BPy_Ipo * self )
-{
- PyObject *l = PyList_New( 4 );
- PyList_SET_ITEM( l, 0, PyFloat_FromDouble( self->ipo->cur.xmin ) );
- PyList_SET_ITEM( l, 1, PyFloat_FromDouble( self->ipo->cur.xmax ) );
- PyList_SET_ITEM( l, 2, PyFloat_FromDouble( self->ipo->cur.ymin ) );
- PyList_SET_ITEM( l, 3, PyFloat_FromDouble( self->ipo->cur.ymax ) );
- return l;
-}
-
-static int Ipo_setRctf( BPy_Ipo * self, PyObject * args )
-{
- float v[4];
-
- if( !PyArg_ParseTuple( args, "ffff", v, v + 1, v + 2, v + 3 ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a tuple of 4 floats" );
-
- self->ipo->cur.xmin = v[0];
- self->ipo->cur.xmax = v[1];
- self->ipo->cur.ymin = v[2];
- self->ipo->cur.ymax = v[3];
-
- return 0;
-}
-
-/*
- * Get total number of Ipo curves for this Ipo. NOTE: this function
- * returns all curves for Ipos which have texture channels, unlike
- * Ipo_length().
- */
-
-static PyObject *Ipo_getNcurves( BPy_Ipo * self )
-{
- IpoCurve *icu;
- int i = 0;
-
- for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
- i++;
- }
-
- return PyInt_FromLong( (long)i );
-}
-
-/*
- Function: Ipo_addCurve
- Bpy: Blender.Ipo.addCurve( 'curname')
-
- add a new curve to an existing IPO.
- example:
- ipo = Blender.Ipo.New('Object','ObIpo')
- cu = ipo.addCurve('LocX')
-*/
-
-static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * value )
-{
- short param; /* numeric curve name constant */
- char *cur_name = PyString_AsString(value); /* input arg: curve name */
- Ipo *ipo = 0;
- IpoCurve *icu = 0;
- Link *link;
-
- if( !cur_name )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected string argument" ) );
-
-
- /* chase down the ipo list looking for ours */
- link = G.main->ipo.first;
-
- while( link ) {
- ipo = ( Ipo * ) link;
- if( ipo == self->ipo )
- break;
- link = link->next;
- }
-
- if( !link )
- return EXPP_ReturnPyObjError
- ( PyExc_RuntimeError, "Ipo not found" );
-
- /*
- * Check if the input arg curve name is valid depending on the block
- * type, and set param to numeric value. Invalid names will return
- * param = -1.
- */
-
- if( ipo->blocktype != ID_KE ) {
- param = lookup_curve_name( cur_name, ipo->blocktype, self->mtex );
- } else {
- param = lookup_curve_key( cur_name, ipo );
- if( param == -2 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unable to find matching key data for Ipo" );
- }
-
- if( param == -1 )
- return EXPP_ReturnPyObjError( PyExc_NameError,
- "curve name is not valid" );
-
- /* see if the curve already exists */
- for( icu = ipo->curve.first; icu; icu = icu->next )
- if( icu->adrcode == param )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Ipo curve already exists" );
-
- /* create the new ipo curve */
- icu = MEM_callocN( sizeof(IpoCurve), "Python added ipocurve");
- icu->blocktype = ipo->blocktype;
- icu->adrcode = param;
- icu->flag |= IPO_VISIBLE|IPO_AUTO_HORIZ;
- set_icu_vars( icu );
- BLI_addtail( &(ipo->curve), icu);
-
- allspace( REMAKEIPO, 0 );
- EXPP_allqueue( REDRAWIPO, 0 );
-
- /* create a bpy wrapper for the new ipo curve */
- return IpoCurve_CreatePyObject( icu );
-}
-
-/*
- Function: Ipo_delCurve
- Bpy: Blender.Ipo.delCurve(curtype)
-
- delete an existing curve from IPO.
- example:
- ipo = Blender.Ipo.New('Object','ObIpo')
- cu = ipo.delCurve('LocX')
-*/
-
-static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * value )
-{
- IpoCurve *icu;
- char *strname = PyString_AsString(value);
-
- if( !strname )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
- if( !strcmp( strname, getIpoCurveName( icu ) ) ) {
- del_ipocurve( self->ipo, icu );
- Py_RETURN_NONE;
- }
- }
-
- return EXPP_ReturnPyObjError( PyExc_ValueError, "IpoCurve not found" );
-}
-/*
- */
-
-static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args )
-{
- IpoCurve *icu = NULL;
- short adrcode;
- PyObject *value = NULL;
-
- if( !PyArg_ParseTuple( args, "|O", &value ) )
- goto typeError;
-
- /* if no name give, get all the Ipocurves */
- if( !value )
- return Ipo_getCurves( self );
-
- /* if arg is a string or int, look up the adrcode */
- if( PyString_Check( value ) ) {
- char *str = PyString_AsString( value );
- for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
- if( !strcmp( str, getIpoCurveName( icu ) ) )
- return IpoCurve_CreatePyObject( icu );
- }
- Py_RETURN_NONE;
- }
- else if( PyInt_Check( value ) ) {
- adrcode = ( short )PyInt_AsLong( value );
- for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
- if( icu->adrcode == adrcode )
- return IpoCurve_CreatePyObject( icu );
- }
- Py_RETURN_NONE;
- }
-
-typeError:
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expected string or int argument" );
-}
-
-static PyObject *Ipo_getCurves( BPy_Ipo * self )
-{
- PyObject *attr = PyList_New( 0 ), *pyipo;
- IpoCurve *icu;
-
- for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
- pyipo = IpoCurve_CreatePyObject( icu );
- PyList_Append( attr, pyipo );
- Py_DECREF(pyipo);
- }
- return attr;
-}
-
-/*
- * return a list of valid curve name constants for the Ipo
- */
-
-static PyObject *Ipo_getCurveNames( BPy_Ipo * self )
-{
- namefunc lookup_name;
- int size;
- PyObject *dict;
- int *vals = NULL;
- char name[32];
- PyObject *attr = Py_None;
-
- /* determine what type of Ipo we are */
-
- switch ( self->ipo->blocktype ) {
- case ID_OB:
- lookup_name = (namefunc)getname_ob_ei;
- vals = ob_ar;
- size = OB_TOTIPO;
- strcpy( name, "OB_" );
- break;
- case ID_MA:
- lookup_name = (namefunc)getname_mat_ei;
- vals = ma_ar;
- size = MA_TOTIPO;
- strcpy( name, "MA_" );
- break;
- case ID_CA:
- lookup_name = (namefunc)getname_cam_ei;
- vals = cam_ar;
- size = CAM_TOTIPO;
- strcpy( name, "CA_" );
- break;
- case ID_LA:
- lookup_name = (namefunc)getname_la_ei;
- vals = la_ar;
- size = LA_TOTIPO;
- strcpy( name, "LA_" );
- break;
- case ID_TE:
- lookup_name = (namefunc)getname_tex_ei;
- vals = te_ar;
- size = TE_TOTIPO;
- strcpy( name, "TE_" );
- break;
- case ID_WO:
- lookup_name = (namefunc)getname_world_ei;
- vals = wo_ar;
- size = WO_TOTIPO;
- strcpy( name, "WO_" );
- break;
- case ID_PO:
- lookup_name = (namefunc)getname_ac_ei;
- vals = ac_ar;
- size = AC_TOTIPO;
- strcpy( name, "PO_" );
- break;
- case ID_CO:
- lookup_name = (namefunc)getname_co_ei;
- vals = co_ar;
- size = CO_TOTIPO;
- strcpy( name, "CO_" );
- break;
- case ID_CU:
- lookup_name = (namefunc)getname_cu_ei;
- vals = cu_ar;
- size = CU_TOTIPO;
- strcpy( name, "CU_" );
- break;
- case ID_SEQ:
- lookup_name = (namefunc)getname_seq_ei;
- vals = seq_ar;
- size = SEQ_TOTIPO;
- strcpy( name, "SQ_" );
- break;
- case ID_KE:
- {
- Key *key;
-
- /* find the ipo in the keylist */
- for( key = G.main->key.first; key; key = key->id.next ) {
- if( key->ipo == self->ipo ) {
- PyObject *tmpstr;
- KeyBlock *block = key->block.first;
- attr = PyList_New( 0 );
-
- /* add each name to the list */
- for( block = key->block.first; block; block = block->next ) {
- tmpstr = PyString_FromString( block->name );
- PyList_Append( attr, tmpstr);
- Py_DECREF(tmpstr);
- }
- return attr;
- }
- }
-
- /* error if the ipo isn't in the list */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unable to find matching key data for Ipo" );
- }
- default:
- Py_DECREF( attr );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unknown Ipo type" );
- }
-
- /*
- * go through the list of adrcodes to find names, then add to dictionary
- * with string as key and adrcode as value
- */
-
- dict = PyModule_GetDict( submodule );
- attr = PyConstant_New();
-
- while( size-- ) {
- char *ptr = name+3;
- strcpy( name+3, lookup_name( *vals ) );
- while( *ptr ) {
- *ptr = (char)toupper( *ptr );
- ++ptr;
- }
- PyConstant_Insert( (BPy_constant *)attr, name,
- PyInt_FromLong( *vals ) );
- ++vals;
- }
- return attr;
-}
-
-void generate_curveconsts( PyObject* module )
-{
- namefunc lookup_name = NULL;
- int size = 0;
- int *vals = NULL;
- char name[32];
-
- unsigned int i = 0;
- static short curvelist[] = {
- ID_OB, ID_MA, ID_CA, ID_LA, ID_TE, ID_WO, ID_PO, ID_CO, ID_CU, ID_SEQ
- };
-
- for( i = 0; i < sizeof(curvelist)/sizeof(short); ++i ) {
- switch ( curvelist[i] ) {
- case ID_OB:
- lookup_name = (namefunc)getname_ob_ei;
- vals = ob_ar;
- size = OB_TOTIPO;
- strcpy( name, "OB_" );
- break;
- case ID_MA:
- lookup_name = (namefunc)getname_mat_ei;
- vals = ma_ar;
- size = MA_TOTIPO;
- strcpy( name, "MA_" );
- break;
- case ID_CA:
- lookup_name = (namefunc)getname_cam_ei;
- vals = cam_ar;
- size = CAM_TOTIPO;
- strcpy( name, "CA_" );
- break;
- case ID_LA:
- lookup_name = (namefunc)getname_la_ei;
- vals = la_ar;
- size = LA_TOTIPO;
- strcpy( name, "LA_" );
- break;
- case ID_TE:
- lookup_name = (namefunc)getname_tex_ei;
- vals = te_ar;
- size = TE_TOTIPO;
- strcpy( name, "TE_" );
- break;
- case ID_WO:
- lookup_name = (namefunc)getname_world_ei;
- vals = wo_ar;
- size = WO_TOTIPO;
- strcpy( name, "WO_" );
- break;
- case ID_PO:
- lookup_name = (namefunc)getname_ac_ei;
- vals = ac_ar;
- size = AC_TOTIPO;
- strcpy( name, "PO_" );
- break;
- case ID_CO:
- lookup_name = (namefunc)getname_co_ei;
- vals = co_ar;
- size = CO_TOTIPO;
- strcpy( name, "CO_" );
- break;
- case ID_CU:
- lookup_name = (namefunc)getname_cu_ei;
- vals = cu_ar;
- size = CU_TOTIPO;
- strcpy( name, "CU_" );
- break;
- case ID_SEQ:
- lookup_name = (namefunc)getname_seq_ei;
- vals = seq_ar;
- size = SEQ_TOTIPO;
- strcpy( name, "SQ_" );
- break;
- }
-
- while( size-- ) {
- char *ptr = name+3;
- strcpy( name+3, lookup_name( *vals ) );
- while( *ptr ) {
- *ptr = (char)toupper( *ptr );
- ++ptr;
- }
- PyModule_AddIntConstant( module, name, *vals );
- ++vals;
- }
- }
-}
-
-
-/*
- * get the current texture channel number, if defined
- */
-
-static PyObject *Ipo_getChannel( BPy_Ipo * self )
-{
- if( self->mtex != -1 )
- return PyInt_FromLong( (long)self->mtex );
- Py_RETURN_NONE;
-}
-
-/*
- * set the current texture channel number, if defined
- */
-
-static int Ipo_setChannel( BPy_Ipo * self, PyObject * value )
-{
- if( self->mtex != -1 )
- return EXPP_setIValueRange( value, &self->mtex, 0, 9, 'h' );
- return 0;
-}
-
-/*****************************************************************************/
-/* Function: Ipo_compare */
-/* Description: This compares 2 ipo python types, == or != only. */
-/*****************************************************************************/
-static int Ipo_compare( BPy_Ipo * a, BPy_Ipo * b )
-{
- return ( a->ipo == b->ipo ) ? 0 : -1;
-}
-
-/*****************************************************************************/
-/* Function: Ipo_repr */
-/* Description: This is a callback function for the BPy_Ipo type. It */
-/* builds a meaningful string to represent ipo objects. */
-/*****************************************************************************/
-static PyObject *Ipo_repr( BPy_Ipo * self )
-{
- char *param;
-
- switch ( self->ipo->blocktype ) {
- case ID_OB:
- param = "Object"; break;
- case ID_CA:
- param = "Camera"; break;
- case ID_LA:
- param = "Lamp"; break;
- case ID_TE:
- param = "Texture"; break;
- case ID_WO:
- param = "World"; break;
- case ID_MA:
- param = "Material"; break;
- case ID_PO:
- param = "Action"; break;
- case ID_CO:
- param = "Constriant"; break;
- case ID_CU:
- param = "Curve"; break;
- case ID_SEQ:
- param = "Sequence"; break;
- case ID_KE:
- param = "Key"; break;
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unknown Ipo type" );
- }
- return PyString_FromFormat( "[Ipo \"%s\" (%s)]", self->ipo->id.name + 2,
- param );
-}
-
-/* Three Python Ipo_Type helper functions needed by the Object module: */
-
-/*****************************************************************************/
-/* Function: Ipo_CreatePyObject */
-/* Description: This function will create a new BPy_Ipo from an existing */
-/* Blender ipo structure. */
-/*****************************************************************************/
-PyObject *Ipo_CreatePyObject( Ipo * ipo )
-{
- BPy_Ipo *pyipo;
- pyipo = ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo, &Ipo_Type );
- if( !pyipo )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Ipo object" );
- pyipo->ipo = ipo;
- pyipo->iter = 0;
- if( pyipo->ipo->blocktype == ID_WO || pyipo->ipo->blocktype == ID_LA ||
- pyipo->ipo->blocktype == ID_MA )
- pyipo->mtex = 0;
- else
- pyipo->mtex = -1;
- return ( PyObject * ) pyipo;
-}
-
-/*****************************************************************************/
-/* Function: Ipo_FromPyObject */
-/* Description: This function returns the Blender ipo from the given */
-/* PyObject. */
-/*****************************************************************************/
-Ipo *Ipo_FromPyObject( PyObject * pyobj )
-{
- return ( ( BPy_Ipo * ) pyobj )->ipo;
-}
-
-/*****************************************************************************/
-/* Function: Ipo_length */
-/* Description: This function counts the number of curves accessible for the */
-/* PyObject. */
-/*****************************************************************************/
-static int Ipo_length( BPy_Ipo * self )
-{
- IpoCurve *icu;
- int len = 0;
-
- for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
- if( self->mtex == -1 || icu->adrcode < MA_MAP1 ||
- icu->adrcode & texchannel_to_adrcode( self->mtex ) )
- ++len;
- }
- return len;
-}
-
-/*
- * "mapping" operator getter: return an IpoCurve it we can find it
- */
-
-static PyObject *Ipo_getIpoCurveByName( BPy_Ipo * self, PyObject * key )
-{
- IpoCurve *icu = NULL;
- int adrcode;
-
- /* if Ipo is not ShapeKey and arg is an int, look up the adrcode */
- if( self->ipo->blocktype != ID_KE && PyNumber_Check( key ) )
- adrcode = lookup_curve_adrcode( PyInt_AsLong( key ),
- self->ipo->blocktype, self->mtex );
- /* if Ipo is ShapeKey and arg is string, look up the adrcode */
- else if( self->ipo->blocktype == ID_KE && PyString_Check( key ) ) {
- adrcode = lookup_curve_key( PyString_AS_STRING( key ), self->ipo );
- if( adrcode == -2 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unable to find matching key data for Ipo" );
- }
- else
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int or string key" );
-
- /* if no adrcode found, value error */
- if( adrcode == -1 )
- return EXPP_ReturnPyObjError( PyExc_KeyError, "invalid curve key" );
-
- /* search for a matching adrcode */
- for( icu = self->ipo->curve.first; icu; icu = icu->next )
- if( icu->adrcode == adrcode )
- return IpoCurve_CreatePyObject( icu );
-
- /* no curve found */
- Py_RETURN_NONE;
-}
-
-/*
- * "mapping" operator setter: create or delete an IpoCurve it we can find it
- */
-
-static int Ipo_setIpoCurveByName( BPy_Ipo * self, PyObject * key,
- PyObject * arg )
-{
- IpoCurve *icu;
- Ipo *ipo = self->ipo;
- short adrcode;
-
- /* "del ipo[const]" will send NULL here; give an error */
- if( !arg )
- return EXPP_ReturnIntError( PyExc_NotImplementedError,
- "del operator not supported" );
-
- /* "del ipo[const]" will send NULL here; give an error */
- if( self->ipo->blocktype == ID_KE )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "creation or deletion of Shape Keys not supported" );
-
- /* check for int argument */
- if( !PyNumber_Check( key ) )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected int key" );
-
- /* look up the key, return error if not found */
- adrcode = lookup_curve_adrcode( PyInt_AsLong( key ),
- self->ipo->blocktype, self->mtex );
-
- if( adrcode == -1 )
- return EXPP_ReturnIntError( PyExc_KeyError,
- "invalid curve specified" );
-
- /* if arg is None, delete the curve */
- if( arg == Py_None ) {
- for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
- if( icu->adrcode == adrcode ) {
- del_ipocurve( ipo, icu );
- return 0;
- }
- }
-
- return EXPP_ReturnIntError( PyExc_ValueError, "IpoCurve not found" );
- } else {
-
- /* create the new ipo curve */
- float time, curval;
- PyObject *tmp, *flt=NULL, *val=NULL;
-
- /* error if not a sequence or sequence with other than 2 values */
- if( PySequence_Size( arg ) != 2 )
- goto AttrError;
-
- /* get the time and curval */
- tmp = PySequence_ITEM( arg, 0 );
- flt = PyNumber_Float( tmp );
- Py_DECREF( tmp );
- tmp = PySequence_ITEM( arg, 1 );
- val = PyNumber_Float( tmp );
- Py_DECREF( tmp );
-
- if( !flt || !val )
- goto AttrError;
-
- time = (float)PyFloat_AS_DOUBLE( flt );
- curval = (float)PyFloat_AS_DOUBLE( val );
- Py_DECREF( flt );
- Py_DECREF( val );
-
- /* if curve already exist, delete the original */
- for( icu = ipo->curve.first; icu; icu = icu->next )
- if( icu->adrcode == adrcode ) {
- del_ipocurve( ipo, icu );
- break;
- }
-
- /* create the new curve, then add the key */
- icu = MEM_callocN( sizeof(IpoCurve), "Python added ipocurve");
- icu->blocktype = ipo->blocktype;
- icu->adrcode = adrcode;
- icu->flag |= IPO_VISIBLE|IPO_AUTO_HORIZ;
- set_icu_vars( icu );
- BLI_addtail( &(ipo->curve), icu);
- insert_vert_icu( icu, time, curval, 0);
-
- allspace( REMAKEIPO, 0 );
- EXPP_allqueue( REDRAWIPO, 0 );
-
- return 0;
-
-AttrError:
- Py_XDECREF( val );
- Py_XDECREF( flt );
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected sequence of two floats" );
- }
-}
-
-/*
- * sequence __contains__ method (implements "x in ipo")
- */
-
-static int Ipo_contains( BPy_Ipo *self, PyObject *key )
-{
- IpoCurve *icu = NULL;
- int adrcode;
-
- /* take a Ipo curve name: key must be a int */
-
- if( self->ipo->blocktype != ID_KE && PyNumber_Check( key ) ) {
- adrcode = lookup_curve_adrcode( PyInt_AsLong( key ),
- self->ipo->blocktype, self->mtex );
-
- /* if we found an adrcode for the key, search the ipo's curve */
- if( adrcode != -1 ) {
- for( icu = self->ipo->curve.first; icu; icu = icu->next )
- if( icu->adrcode == adrcode )
- return 1;
- }
- } else if( self->ipo->blocktype == ID_KE && PyString_Check( key ) ) {
- adrcode = lookup_curve_key( PyString_AS_STRING( key ), self->ipo );
-
- /* if we found an adrcode for the key, search the ipo's curve */
- if( adrcode >= 0 ) {
- for( icu = self->ipo->curve.first; icu; icu = icu->next )
- if( icu->adrcode == adrcode )
- return 1;
- }
- }
-
- /* no curve found */
- return 0;
-}
-
-/*
- * Initialize the interator index
- */
-
-static PyObject *Ipo_getIter( BPy_Ipo * self )
-{
- /* return a new IPO object if we are looping on the existing one
- This allows nested loops */
- if (self->iter==0) {
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- return Ipo_CreatePyObject(self->ipo);
- }
-}
-
-/*
- * Get the next Ipo curve
- */
-
-static PyObject *Ipo_nextIter( BPy_Ipo * self )
-{
- int i;
- IpoCurve *icu = self->ipo->curve.first;
-
- ++self->iter;
-
- /*
- * count curves only if
- * (a) Ipo has no texture channels
- * (b) Ipo has texture channels, but curve is not that type
- * (c) Ipo has texture channels, and curve is that type, and it is
- * in the active texture channel
- */
- for( i = 0; icu; icu = icu->next ) {
- if( self->mtex == -1 || icu->adrcode < MA_MAP1 ||
- icu->adrcode & texchannel_to_adrcode( self->mtex ) ) {
- ++i;
-
- /* if indices match, return the curve */
- if( i == self->iter )
- return IpoCurve_CreatePyObject( icu );
- }
- }
-
- self->iter = 0; /* allow iter use again */
- /* ran out of curves */
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
-}
-
-/*****************************************************************************/
-/* Function: Ipo_Init */
-/*****************************************************************************/
-PyObject *Ipo_Init( void )
-{
- /* PyObject *submodule; */
-
- if( PyType_Ready( &Ipo_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Ipo", M_Ipo_methods, M_Ipo_doc );
- generate_curveconsts( submodule );
-
- return submodule;
-}
-
-/*
- * The following methods should be deprecated when there are equivalent
- * methods in Ipocurve (if there aren't already).
- */
-
-static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args )
-{
- int num = 0;
- IpoCurve *icu = NULL;
-
- if( !PyArg_ParseTuple( args, "i", &num ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
-
- icu = self->ipo->curve.first;
- while( icu && num > 0 ) {
- icu = icu->next;
- --num;
- }
-
- if( num < 0 || !icu )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "index out of range" );
-
- return PyInt_FromLong( icu->totvert );
-}
-
-static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args )
-{
- int num = 0, i = 0;
- IpoCurve *icu = 0;
- if( !PyArg_ParseTuple( args, "i", &num ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected int argument" ) );
- icu = self->ipo->curve.first;
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "No IPO curve" ) );
- for( i = 0; i < num; i++ ) {
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "Bad curve number" ) );
- icu = icu->next;
-
- }
- icu->totvert--;
- return ( PyInt_FromLong( icu->totvert ) );
-}
-
-/*
- * Ipo_getCurveBP()
- * this method is UNSUPPORTED.
- * Calling this method throws a TypeError Exception.
- *
- * it looks like the original intent was to return the first point
- * of a BPoint Ipo curve. However, BPoint ipos are not currently
- * implemented.
- */
-
-static PyObject *Ipo_getCurveBP( BPy_Ipo * self_unused, PyObject * args_unused )
-{
- return EXPP_ReturnPyObjError( PyExc_NotImplementedError,
- "bpoint ipos are not supported" );
-}
-
-static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args )
-{
- struct BezTriple *ptrbt;
- int num = 0, pos, i, j;
- IpoCurve *icu;
- PyObject *l, *pyfloat;
-
- if( !PyArg_ParseTuple( args, "ii", &num, &pos ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected int argument" ) );
- icu = self->ipo->curve.first;
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "No IPO curve" ) );
- for( i = 0; i < num; i++ ) {
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "Bad ipo number" ) );
- icu = icu->next;
- }
- if( pos >= icu->totvert )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Bad bezt number" );
-
- ptrbt = icu->bezt + pos;
- if( !ptrbt )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "No bez triple" );
-
- l = PyList_New( 0 );
- for( i = 0; i < 3; i++ ) {
- for( j = 0; j < 3; j++ ) {
- pyfloat = PyFloat_FromDouble( ptrbt->vec[i][j] );
- PyList_Append( l, pyfloat );
- Py_DECREF(pyfloat);
- }
- }
- return l;
-}
-
-static PyObject *Ipo_setCurveBeztriple( BPy_Ipo * self, PyObject * args )
-{
- struct BezTriple *ptrbt;
- int num = 0, pos, i;
- IpoCurve *icu;
- PyObject *listargs = 0;
-
- if( !PyArg_ParseTuple( args, "iiO", &num, &pos, &listargs ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected int int object argument" ) );
- if( !PyTuple_Check( listargs ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "3rd arg should be a tuple" ) );
- icu = self->ipo->curve.first;
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "No IPO curve" ) );
- for( i = 0; i < num; i++ ) {
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "Bad ipo number" ) );
- icu = icu->next;
- }
- if( pos >= icu->totvert )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Bad bezt number" );
-
- ptrbt = icu->bezt + pos;
- if( !ptrbt )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "No bez triple" );
-
- for( i = 0; i < 9; i++ ) {
- PyObject *xx = PyTuple_GetItem( listargs, i );
- ptrbt->vec[i / 3][i % 3] = (float)PyFloat_AsDouble( xx );
- }
-
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-/* Ipo.__copy__ */
-static PyObject *Ipo_copy( BPy_Ipo * self )
-{
- Ipo *ipo = copy_ipo(self->ipo );
- ipo->id.us = 0;
- return Ipo_CreatePyObject(ipo);
-}
-
-static PyObject *Ipo_EvaluateCurveOn( BPy_Ipo * self, PyObject * args )
-{
- int num = 0, i;
- IpoCurve *icu;
- float time = 0;
-
- if( !PyArg_ParseTuple( args, "if", &num, &time ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected int argument" ) );
-
- icu = self->ipo->curve.first;
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "No IPO curve" ) );
-
- for( i = 0; i < num; i++ ) {
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "Bad ipo number" ) );
- icu = icu->next;
-
- }
- return PyFloat_FromDouble( eval_icu( icu, time ) );
-}
-
-static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args )
-{
- int numcurve = 0, i;
- IpoCurve *icu;
- char *stringname = 0, *str1 = 0;
-
- icu = self->ipo->curve.first;
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "No IPO curve" ) );
-
- if( PyNumber_Check( PyTuple_GetItem( args, 0 ) ) ) /* args is an integer */
- {
- if( !PyArg_ParseTuple( args, "i", &numcurve ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected int or string argument" ) );
- for( i = 0; i < numcurve; i++ ) {
- if( !icu )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "Bad ipo number" ) );
- icu = icu->next;
- }
- }
-
- else /* args is a string */
- {
- if( !PyArg_ParseTuple( args, "s", &stringname ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected int or string argument" ) );
- while( icu ) {
- str1 = getIpoCurveName( icu );
- if( !strcmp( str1, stringname ) )
- break;
- icu = icu->next;
- }
- }
-
- if( icu )
- return PyFloat_FromDouble( icu->curval );
- Py_RETURN_NONE;
-}
-
-/*
- * The following methods should be deprecated when methods are pruned out.
- */
-
-static PyObject *Ipo_oldsetRctf( BPy_Ipo * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Ipo_setRctf );
-}
-
-static PyObject *Ipo_oldsetBlocktype( BPy_Ipo * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Ipo_setBlocktype );
-}
diff --git a/source/blender/python/api2_2x/Ipo.h b/source/blender/python/api2_2x/Ipo.h
deleted file mode 100644
index 35893015a79..00000000000
--- a/source/blender/python/api2_2x/Ipo.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c
deleted file mode 100644
index cc4cb066fe7..00000000000
--- a/source/blender/python/api2_2x/Ipocurve.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/*
- * $Id: Ipocurve.c 12078 2007-09-18 06:41:29Z 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, Nathan Letwory, Ken Hughes, Johnny Matthews
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Ipocurve.h" /*This must come first*/
-
-#include "Object.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_depsgraph.h"
-#include "BKE_ipo.h"
-#include "BIF_space.h"
-#include "BSE_editipo.h"
-#include "MEM_guardedalloc.h"
-#include "DNA_ipo_types.h"
-#include "DNA_key_types.h"
-#include "BezTriple.h"
-#include "gen_utils.h"
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.IpoCurve.__doc__ */
-/*****************************************************************************/
-char M_IpoCurve_doc[] = "";
-char M_IpoCurve_New_doc[] = "";
-char M_IpoCurve_Get_doc[] = "";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.IpoCurve module: */
-/*****************************************************************************/
-
-struct PyMethodDef M_IpoCurve_methods[] = {
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python C_IpoCurve methods declarations: */
-/*****************************************************************************/
-static PyObject *IpoCurve_getName( C_IpoCurve * self );
-static PyObject *IpoCurve_Recalc( C_IpoCurve * self );
-static PyObject *IpoCurve_append( C_IpoCurve * self, PyObject * value );
-static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * value );
-static PyObject *IpoCurve_delBezier( C_IpoCurve * self, PyObject * args );
-static PyObject *IpoCurve_setInterpolation( C_IpoCurve * self,
- PyObject * value );
-static PyObject *IpoCurve_getInterpolation( C_IpoCurve * self );
-static PyObject *IpoCurve_newgetInterp( C_IpoCurve * self );
-static int IpoCurve_newsetInterp( C_IpoCurve * self, PyObject * args );
-static PyObject *IpoCurve_setExtrapolation( C_IpoCurve * self,
- PyObject * value );
-static PyObject *IpoCurve_getExtrapolation( C_IpoCurve * self );
-static PyObject *IpoCurve_newgetExtend( C_IpoCurve * self );
-static int IpoCurve_newsetExtend( C_IpoCurve * self, PyObject * args );
-static PyObject *IpoCurve_getPoints( C_IpoCurve * self );
-static PyObject *IpoCurve_evaluate( C_IpoCurve * self, PyObject * args );
-static PyObject *IpoCurve_getDriver( C_IpoCurve * self );
-static int IpoCurve_setDriver( C_IpoCurve * self, PyObject * args );
-static PyObject *IpoCurve_getDriverObject( C_IpoCurve * self);
-static int IpoCurve_setDriverObject( C_IpoCurve * self, PyObject * args );
-static PyObject *IpoCurve_getDriverChannel( C_IpoCurve * self);
-static int IpoCurve_setDriverChannel( C_IpoCurve * self, PyObject * args );
-static PyObject *IpoCurve_getDriverExpression( C_IpoCurve * self);
-static PyObject *IpoCurve_getFlag( C_IpoCurve * self, void *type);
-static int IpoCurve_setFlag( C_IpoCurve * self, PyObject *value, void *type);
-
-static int IpoCurve_setDriverExpression( C_IpoCurve * self, PyObject * args );
-static PyObject *IpoCurve_getCurval( C_IpoCurve * self, PyObject * args );
-static int IpoCurve_setCurval( C_IpoCurve * self, PyObject * key,
- PyObject * value );
-
-/*****************************************************************************/
-/* Python C_IpoCurve methods table: */
-/*****************************************************************************/
-static PyMethodDef C_IpoCurve_methods[] = {
- /* name, method, flags, doc */
- {"getName", ( PyCFunction ) IpoCurve_getName, METH_NOARGS,
- "() - Return IpoCurve name"},
- {"Recalc", ( PyCFunction ) IpoCurve_Recalc, METH_NOARGS,
- "() - deprecated method. use recalc() instead"},
- {"recalc", ( PyCFunction ) IpoCurve_Recalc, METH_NOARGS,
- "() - Recomputes the curve after changes"},
- {"update", ( PyCFunction ) IpoCurve_Recalc, METH_NOARGS,
- "() - deprecated method: use recalc method instead."},
- {"append", ( PyCFunction ) IpoCurve_append, METH_O,
- "(coordlist) - Adds a Bezier point to a curve"},
- {"addBezier", ( PyCFunction ) IpoCurve_addBezier, METH_O,
- "() - deprecated method. use append() instead"},
- {"delBezier", ( PyCFunction ) IpoCurve_delBezier, METH_VARARGS,
- "() - deprecated method. use \"del icu[index]\" instead"},
- {"setInterpolation", ( PyCFunction ) IpoCurve_setInterpolation,
- METH_O, "(str) - Sets the interpolation type of the curve"},
- {"getInterpolation", ( PyCFunction ) IpoCurve_getInterpolation,
- METH_NOARGS, "() - Gets the interpolation type of the curve"},
- {"setExtrapolation", ( PyCFunction ) IpoCurve_setExtrapolation,
- METH_O, "(str) - Sets the extend mode of the curve"},
- {"getExtrapolation", ( PyCFunction ) IpoCurve_getExtrapolation,
- METH_NOARGS, "() - Gets the extend mode of the curve"},
- {"getPoints", ( PyCFunction ) IpoCurve_getPoints, METH_NOARGS,
- "() - Returns list of all bezTriples of the curve"},
- {"evaluate", ( PyCFunction ) IpoCurve_evaluate, METH_VARARGS,
- "(float) - Evaluate curve at given time"},
- {NULL, NULL, 0, NULL}
-};
-
-/*
- * IpoCurve methods
- */
-
-static PyGetSetDef C_IpoCurve_getseters[] = {
- {"name",
- (getter)IpoCurve_getName, (setter)NULL,
- "the IpoCurve name",
- NULL},
- {"bezierPoints",
- (getter)IpoCurve_getPoints, (setter)NULL,
- "list of all bezTriples of the curve",
- NULL},
- {"driver",
- (getter)IpoCurve_getDriver, (setter)IpoCurve_setDriver,
- "The status of the driver 1-object, 2-py expression, 0-off",
- NULL},
- {"driverObject",
- (getter)IpoCurve_getDriverObject, (setter)IpoCurve_setDriverObject,
- "The object used to drive the IpoCurve",
- NULL},
- {"driverChannel",
- (getter)IpoCurve_getDriverChannel, (setter)IpoCurve_setDriverChannel,
- "The channel on the driver object used to drive the IpoCurve",
- NULL},
- {"driverExpression",
- (getter)IpoCurve_getDriverExpression, (setter)IpoCurve_setDriverExpression,
- "The python expression on the driver used to drive the IpoCurve",
- NULL},
- {"interpolation",
- (getter)IpoCurve_newgetInterp, (setter)IpoCurve_newsetInterp,
- "The interpolation mode of the curve",
- NULL},
- {"extend",
- (getter)IpoCurve_newgetExtend, (setter)IpoCurve_newsetExtend,
- "The extend mode of the curve",
- NULL},
-
- {"sel",
- (getter)IpoCurve_getFlag, (setter)IpoCurve_setFlag,
- "the selection state of the curve",
- (void *)IPO_SELECT},
-
- {NULL,NULL,NULL,NULL,NULL}
-};
-
-/*****************************************************************************/
-/* Python IpoCurve_Type Mapping Methods table: */
-/*****************************************************************************/
-
-static PyMappingMethods IpoCurve_as_mapping = {
- ( inquiry ) 0, /* mp_length */
- ( binaryfunc ) IpoCurve_getCurval, /* mp_subscript */
- ( objobjargproc ) IpoCurve_setCurval, /* mp_ass_subscript */
-};
-
-/*****************************************************************************/
-/* Python IpoCurve_Type callback function prototypes: */
-/*****************************************************************************/
-static int IpoCurve_compare( C_IpoCurve * a, C_IpoCurve * b );
-static PyObject *IpoCurve_repr( C_IpoCurve * self );
-
-/*****************************************************************************/
-/* Python IpoCurve_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject IpoCurve_Type = {
- PyObject_HEAD_INIT( NULL ) /* required macro */
- 0, /* ob_size */
- "IpoCurve", /* tp_name */
- sizeof( C_IpoCurve ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- NULL, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) NULL, /* tp_getattr */
- ( setattrfunc ) NULL, /* tp_setattr */
- ( cmpfunc ) IpoCurve_compare, /* tp_compare */
- ( reprfunc ) IpoCurve_repr, /* tp_repr */
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- NULL, /* PySequenceMethods *tp_as_sequence; */
- &IpoCurve_as_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; */
- /*** 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 ***/
- C_IpoCurve_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- C_IpoCurve_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
-};
-
-/*****************************************************************************/
-/* local utility functions */
-/*****************************************************************************/
-
-/*
- * Keys are handled differently than other Ipos, so go through contortions
- * to find their names.
- */
-
-static char *get_key_curvename( IpoCurve *ipocurve )
-{
- Key *key_iter;
- char *empty = "";
-
- /* search for keys with an Ipo */
-
- for( key_iter = G.main->key.first; key_iter; key_iter=key_iter->id.next) {
- if( key_iter->ipo ) {
- IpoCurve *icu = key_iter->ipo->curve.first;
- /* search curves for a match */
- while( icu ) {
- if( icu == ipocurve ) {
- KeyBlock *block = key_iter->block.first;
- /* search for matching adrcode */
- while( block ) {
- if( block->adrcode == ipocurve->adrcode )
- return block->name;
- block = block->next;
- }
- }
- icu = icu->next;
- }
- }
- }
-
- /* shouldn't get here unless deleted in UI while BPy object alive */
- return empty;
-}
-
-/*
- * internal bpy func to get Ipo Curve Name, used by Ipo.c and
- * KX_BlenderSceneConverter.cpp.
- *
- * We are returning a pointer to string constants so there are
- * no issues with who owns pointers.
- */
-
-char *getIpoCurveName( IpoCurve * icu )
-{
- switch ( icu->blocktype ) {
- case ID_MA:
- return getname_mat_ei( icu->adrcode );
- case ID_WO:
- return getname_world_ei( icu->adrcode );
- case ID_CA:
- return getname_cam_ei( icu->adrcode );
- case ID_OB:
- return getname_ob_ei( icu->adrcode, 1 );
- /* solve: what if EffX/Y/Z are wanted? */
- case ID_TE:
- return getname_tex_ei( icu->adrcode );
- case ID_LA:
- return getname_la_ei( icu->adrcode );
- case ID_PO:
- return getname_ac_ei( icu->adrcode );
- case ID_CU:
- return getname_cu_ei( icu->adrcode );
- case ID_KE:
- /* return "Key"; */
- /* ipo curves have no names... that was only meant for drawing the buttons... (ton) */
- return get_key_curvename( icu );
- case ID_SEQ:
- return getname_seq_ei( icu->adrcode );
- case ID_CO:
- return getname_co_ei( icu->adrcode );
- }
- return NULL;
-}
-
-/*
- * delete a bezTriple from a curve
- */
-
-static void del_beztriple( IpoCurve *icu, int index )
-{
- int npoints = icu->totvert - 1;
- BezTriple * tmp = icu->bezt;
-
- /*
- * if delete empties list, then delete it, otherwise copy the remaining
- * points to a new list
- */
-
- if( !npoints ) {
- icu->bezt = NULL;
- } else {
- icu->bezt =
- MEM_mallocN( sizeof( BezTriple ) * npoints, "bezt" );
- if( index > 0 )
- memmove( icu->bezt, tmp, index * sizeof( BezTriple ) );
- if( index < npoints )
- memmove( icu->bezt + index, tmp + index + 1,
- ( npoints - index ) * sizeof( BezTriple ) );
- }
-
- /* free old list, adjust vertex count */
- MEM_freeN( tmp );
- icu->totvert--;
-
- /* call calchandles_* instead of testhandles_* */
- /* I'm not sure this is a complete solution but since we do not */
- /* deal with curve handles right now, it seems ok */
- calchandles_ipocurve( icu );
-}
-
-/*****************************************************************************/
-/* Python C_IpoCurve methods: */
-/*****************************************************************************/
-
-static PyObject *IpoCurve_setInterpolation( C_IpoCurve * self,
- PyObject * value )
-{
- char *interpolationtype = PyString_AsString(value);
- short id;
-
- if( !interpolationtype )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if( !strcmp( interpolationtype, "Bezier" ) )
- id = IPO_BEZ;
- else if( !strcmp( interpolationtype, "Constant" ) )
- id = IPO_CONST;
- else if( !strcmp( interpolationtype, "Linear" ) )
- id = IPO_LIN;
- else
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "bad interpolation type" );
-
- self->ipocurve->ipo = id;
- Py_RETURN_NONE;
-}
-
-static PyObject *IpoCurve_getInterpolation( C_IpoCurve * self )
-{
- char *str = 0;
- IpoCurve *icu = self->ipocurve;
-
- switch( icu->ipo ) {
- case IPO_BEZ:
- str = "Bezier";
- break;
- case IPO_CONST:
- str = "Constant";
- break;
- case IPO_LIN:
- str = "Linear";
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "unknown interpolation type" );
- }
-
- return PyString_FromString( str );
-}
-
-static PyObject * IpoCurve_setExtrapolation( C_IpoCurve * self,
- PyObject * value )
-{
- char *extrapolationtype = PyString_AsString(value);
- short id;
-
- if( !extrapolationtype )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if( !strcmp( extrapolationtype, "Constant" ) )
- id = 0;
- else if( !strcmp( extrapolationtype, "Extrapolation" ) )
- id = 1;
- else if( !strcmp( extrapolationtype, "Cyclic" ) )
- id = 2;
- else if( !strcmp( extrapolationtype, "Cyclic_extrapolation" ) )
- id = 3;
- else
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "bad interpolation type" );
-
- self->ipocurve->extrap = id;
- Py_RETURN_NONE;
-}
-
-static PyObject *IpoCurve_getExtrapolation( C_IpoCurve * self )
-{
- char *str;
- IpoCurve *icu = self->ipocurve;
-
- switch( icu->extrap ) {
- case 0:
- str = "Constant";
- break;
- case 1:
- str = "Extrapolation";
- break;
- case 2:
- str = "Cyclic";
- break;
- case 3:
- str = "Cyclic_extrapolation";
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "bad extrapolation type" );
- }
-
- return PyString_FromString( str );
-}
-
-/*
- * append a new BezTriple to curve
- */
-
-static PyObject *IpoCurve_append( C_IpoCurve * self, PyObject * value )
-{
- float x, y;
- IpoCurve *icu = self->ipocurve;
-
- /* if args is a already a beztriple, tack onto end of list */
- if( BPy_BezTriple_Check ( value ) ) {
- BPy_BezTriple *bobj = (BPy_BezTriple *)value;
-
- BezTriple *newb = MEM_callocN( (icu->totvert+1)*sizeof(BezTriple),
- "BPyBeztriple" );
- if( icu->bezt ) {
- memcpy( newb, icu->bezt, ( icu->totvert )*sizeof( BezTriple ) );
- MEM_freeN( icu->bezt );
- }
- icu->bezt = newb;
- memcpy( &icu->bezt[icu->totvert], bobj->beztriple,
- sizeof( BezTriple ) );
- icu->totvert++;
- calchandles_ipocurve( icu );
-
- /* otherwise try to get two floats and add to list */
- } else {
- PyObject *xobj, *yobj;
- xobj = PyNumber_Float( PyTuple_GetItem( value, 0 ) );
- yobj = PyNumber_Float( PyTuple_GetItem( value, 1 ) );
-
- if( !xobj || !yobj )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected tuple of floats" );
-
- x = (float)PyFloat_AsDouble( xobj );
- Py_DECREF( xobj );
- y = (float)PyFloat_AsDouble( yobj );
- Py_DECREF( yobj );
- insert_vert_icu( icu, x, y, 0);
- }
-
- Py_RETURN_NONE;
-}
-
-/*
- Function: IpoCurve_delBezier
- Bpy: Blender.Ipocurve.delBezier(0)
-
- Delete an BezTriple from an IPO curve.
- example:
- ipo = Blender.Ipo.Get('ObIpo')
- cu = ipo.getCurve('LocX')
- cu.delBezier(0)
-*/
-
-static PyObject *IpoCurve_delBezier( C_IpoCurve * self, PyObject * args )
-{
- int index;
-
- if( !PyArg_ParseTuple( args, "i", &index ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
-
- /* if index is negative, count from end of list */
- if( index < 0 )
- index += self->ipocurve->totvert;
- /* check range of index */
- if( index < 0 || index > self->ipocurve->totvert - 1 )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "index outside of list" );
-
- del_beztriple( self->ipocurve, index );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *IpoCurve_Recalc( C_IpoCurve * self )
-{
- IpoCurve *icu = self->ipocurve;
-
- /* testhandles_ipocurve (icu); */
- /* call calchandles_* instead of testhandles_* */
- /* I'm not sure this is a complete solution but since we do not */
- /* deal with curve handles right now, it seems ok */
- calchandles_ipocurve( icu );
- sort_time_ipocurve( icu );
-
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-static PyObject *IpoCurve_getName( C_IpoCurve * self )
-{
- switch ( self->ipocurve->blocktype ) {
- case ID_OB:
- return PyString_FromString( getname_ob_ei( self->ipocurve->adrcode, 1 ) ); /* solve: what if EffX/Y/Z are wanted? */
- case ID_TE:
- return PyString_FromString( getname_tex_ei
- ( self->ipocurve->adrcode ) );
- case ID_LA:
- return PyString_FromString( getname_la_ei
- ( self->ipocurve->adrcode ) );
- case ID_MA:
- return PyString_FromString( getname_mat_ei
- ( self->ipocurve->adrcode ) );
- case ID_CA:
- return PyString_FromString( getname_cam_ei
- ( self->ipocurve->adrcode ) );
- case ID_WO:
- return PyString_FromString( getname_world_ei
- ( self->ipocurve->adrcode ) );
- case ID_PO:
- return PyString_FromString( getname_ac_ei
- ( self->ipocurve->adrcode ) );
- case ID_CU:
- return PyString_FromString( getname_cu_ei
- ( self->ipocurve->adrcode ) );
- case ID_KE:
- return PyString_FromString( get_key_curvename( self->ipocurve ) );
- case ID_SEQ:
- return PyString_FromString( getname_seq_ei
- ( self->ipocurve->adrcode ) );
- case ID_CO:
- return PyString_FromString( getname_co_ei
- ( self->ipocurve->adrcode ) );
- default:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "This function doesn't support this ipocurve type yet" );
- }
-}
-
-static PyObject *IpoCurve_getPoints( C_IpoCurve * self )
-{
- BezTriple *bezt;
- PyObject *po;
- int i;
- PyObject *list = PyList_New( self->ipocurve->totvert );
-
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "PyList_New() failed" );
-
- for( bezt = self->ipocurve->bezt, i = 0;
- i < self->ipocurve->totvert; i++, bezt++ ) {
- po = BezTriple_CreatePyObject( bezt );
- if( !po ) {
- Py_DECREF( list );
- return NULL; /* This is okay since the error is alredy set */
- }
- PyList_SET_ITEM( list, i, po );
- }
- return list;
-}
-
-/*****************************************************************************/
-/* Function: IpoCurve_compare */
-/* Description: This compares 2 python types, == or != only. */
-/*****************************************************************************/
-static int IpoCurve_compare( C_IpoCurve * a, C_IpoCurve * b )
-{
- return ( a->ipocurve == b->ipocurve ) ? 0 : -1;
-}
-
-/*****************************************************************************/
-/* Function: IpoCurve_repr */
-/* Description: This is a callback function for the C_IpoCurve type. It */
-/* builds a meaningful string to represent ipocurve objects. */
-/*****************************************************************************/
-static PyObject *IpoCurve_repr( C_IpoCurve * self )
-{
- return PyString_FromFormat( "[IpoCurve \"%s\"]",
- getIpoCurveName( self->ipocurve ) );
-}
-
-/* Three Python IpoCurve_Type helper functions needed by the Object module: */
-
-/*****************************************************************************/
-/* Function: IpoCurve_CreatePyObject */
-/* Description: This function will create a new C_IpoCurve from an existing */
-/* Blender ipo structure. */
-/*****************************************************************************/
-PyObject *IpoCurve_CreatePyObject( IpoCurve * icu )
-{
- C_IpoCurve *pyipo;
-
- pyipo = ( C_IpoCurve * ) PyObject_NEW( C_IpoCurve, &IpoCurve_Type );
-
- if( !pyipo )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create C_IpoCurve object" );
-
- pyipo->ipocurve = icu;
-
- return ( PyObject * ) pyipo;
-}
-
-/*****************************************************************************/
-/* Function: IpoCurve_FromPyObject */
-/* Description: This function returns the Blender ipo from the given */
-/* PyObject. */
-/*****************************************************************************/
-IpoCurve *IpoCurve_FromPyObject( PyObject * pyobj )
-{
- return ( ( C_IpoCurve * ) pyobj )->ipocurve;
-}
-
-/*
- * get the value of an Ipocurve at a particular time
- */
-
-static PyObject *IpoCurve_getCurval( C_IpoCurve * self, PyObject * args )
-{
- float time;
- PyObject *pyfloat = PyNumber_Float( args );
-
- if( !pyfloat )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
- time = ( float )PyFloat_AS_DOUBLE( pyfloat );
- Py_DECREF( pyfloat );
-
- return PyFloat_FromDouble( ( double ) eval_icu( self->ipocurve, time ) );
-}
-
-/*
- * set the value of an Ipocurve at a particular time
- */
-
-static int IpoCurve_setCurval( C_IpoCurve * self, PyObject * key,
- PyObject * value )
-{
- float time, curval;
- PyObject *pyfloat;
-
- /* make sure time, curval are both floats */
-
- pyfloat = PyNumber_Float( key );
- if( !pyfloat )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float key" );
- time = ( float )PyFloat_AS_DOUBLE( pyfloat );
- Py_DECREF( pyfloat );
-
- pyfloat = PyNumber_Float( value );
- if( !pyfloat )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
- curval = ( float )PyFloat_AS_DOUBLE( pyfloat );
- Py_DECREF( pyfloat );
-
- /* insert a key at the specified time */
-
- insert_vert_icu( self->ipocurve, time, curval, 0);
- allspace(REMAKEIPO, 0);
- return 0;
-}
-
-/***************************************************************************/
-/* Function: IpoCurve_evaluate( time ) */
-/* Description: Evaluates IPO curve at the given time. */
-/***************************************************************************/
-
-static PyObject *IpoCurve_evaluate( C_IpoCurve * self, PyObject * args )
-{
- float time = 0;
- double eval = 0;
-
- /* expecting float */
- if( !PyArg_ParseTuple( args, "f", &time ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected float argument" ) );
-
- eval = ( double ) eval_icu( self->ipocurve, time );
-
- return PyFloat_FromDouble( eval );
-
-}
-
-static PyObject *IpoCurve_getDriver( C_IpoCurve * self )
-{
- if( !self->ipocurve->driver )
- return PyInt_FromLong( 0 );
- else {
- if (self->ipocurve->driver->type == IPO_DRIVER_TYPE_NORMAL)
- return PyInt_FromLong( 1 );
- if (self->ipocurve->driver->type == IPO_DRIVER_TYPE_PYTHON)
- return PyInt_FromLong( 2 );
- }
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unknown driver type, internal error" );
-
-}
-
-/*
- sets the driver to
- 0: disabled
- 1: enabled (object)
- 2: enabled (python expression)
-*/
-static int IpoCurve_setDriver( C_IpoCurve * self, PyObject * args )
-{
- IpoCurve *ipo = self->ipocurve;
- int type;
- if( !PyInt_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument 0 or 1 " );
-
- type = PyInt_AS_LONG( args );
-
- if (type < 0 || type > 2)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected int argument 0, 1 or 2" );
-
- if (type==0) { /* disable driver */
- if( ipo->driver ) {
- MEM_freeN( ipo->driver );
- ipo->driver = NULL;
- }
- } else {
- if( !ipo->driver ) { /*add driver if its not there */
- ipo->driver = MEM_callocN( sizeof(IpoDriver), "ipo driver" );
- ipo->driver->blocktype = ID_OB;
- ipo->driver->adrcode = OB_LOC_X;
- }
-
- if (type==1 && ipo->driver->type != IPO_DRIVER_TYPE_NORMAL) {
- ipo->driver->type = IPO_DRIVER_TYPE_NORMAL;
- ipo->driver->ob = NULL;
- ipo->driver->flag &= ~IPO_DRIVER_FLAG_INVALID;
-
- } else if (type==2 && ipo->driver->type != IPO_DRIVER_TYPE_PYTHON) {
- ipo->driver->type = IPO_DRIVER_TYPE_PYTHON;
- /* we should probably set ipo->driver->ob, but theres no way to do it properly */
- ipo->driver->ob = NULL;
- }
- }
-
- return 0;
-}
-
-static PyObject *IpoCurve_getDriverObject( C_IpoCurve * self )
-{
- IpoCurve *ipo = self->ipocurve;
-
- if( ipo->driver )
- return Object_CreatePyObject( ipo->driver->ob );
-
- Py_RETURN_NONE;
-}
-
-static int IpoCurve_setDriverObject( C_IpoCurve * self, PyObject * arg )
-{
- IpoCurve *ipo = self->ipocurve;
-
- if( !ipo->driver )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This IpoCurve does not have an active driver" );
-
- if(!BPy_Object_Check(arg) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "expected an object argument" );
- ipo->driver->ob = ((BPy_Object *)arg)->object;
-
- DAG_scene_sort(G.scene);
-
- return 0;
-}
-
-static PyObject *IpoCurve_getDriverChannel( C_IpoCurve * self )
-{
- if( !self->ipocurve->driver )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This IpoCurve does not have an active driver" );
-
- return PyInt_FromLong( self->ipocurve->driver->adrcode );
-}
-
-static int IpoCurve_setDriverChannel( C_IpoCurve * self, PyObject * args )
-{
- IpoCurve *ipo = self->ipocurve;
- short param;
-
- if( !ipo->driver )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This IpoCurve does not have an active driver" );
-
- if( !PyInt_Check( args ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- param = (short)PyInt_AS_LONG ( args );
- if( ( param >= OB_LOC_X && param <= OB_LOC_Z )
- || ( param >= OB_ROT_X && param <= OB_ROT_Z )
- || ( param >= OB_SIZE_X && param <= OB_SIZE_Z ) ) {
- ipo->driver->adrcode = (short)PyInt_AS_LONG ( args );
- return 0;
- }
-
- return EXPP_ReturnIntError( PyExc_ValueError, "invalid int argument" );
-}
-
-static PyObject *IpoCurve_getDriverExpression( C_IpoCurve * self )
-{
- IpoCurve *ipo = self->ipocurve;
-
- if( ipo->driver && ipo->driver->type == IPO_DRIVER_TYPE_PYTHON )
- return PyString_FromString( ipo->driver->name );
-
- Py_RETURN_NONE;
-}
-
-static int IpoCurve_setDriverExpression( C_IpoCurve * self, PyObject * arg )
-{
- IpoCurve *ipo = self->ipocurve;
- char *exp; /* python expression */
-
- if( !ipo->driver )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This IpoCurve does not have an active driver" );
-
- if (ipo->driver->type != IPO_DRIVER_TYPE_PYTHON)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This IpoCurve is not a python expression set the driver attribute to 2" );
-
- if(!PyString_Check(arg) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "expected a string argument" );
-
- exp = PyString_AsString(arg);
- if (strlen(exp)>127)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "string is too long, use 127 characters or less" );
-
- strcpy(ipo->driver->name, exp);
- return 0;
-}
-
-static PyObject *M_IpoCurve_ExtendDict( void )
-{
- PyObject *EM = PyConstant_New( );
-
- if( EM ) {
- BPy_constant *d = ( BPy_constant * ) EM;
-
- PyConstant_Insert( d, "CONST", PyInt_FromLong( IPO_HORIZ ) );
- PyConstant_Insert( d, "EXTRAP", PyInt_FromLong( IPO_DIR ) );
- PyConstant_Insert( d, "CYCLIC", PyInt_FromLong( IPO_CYCL ) );
- PyConstant_Insert( d, "CYCLIC_EXTRAP", PyInt_FromLong( IPO_CYCLX ) );
- }
- return EM;
-}
-
-static PyObject *M_IpoCurve_InterpDict( void )
-{
- PyObject *IM = PyConstant_New( );
-
- if( IM ) {
- BPy_constant *d = ( BPy_constant * ) IM;
-
- PyConstant_Insert( d, "CONST", PyInt_FromLong( IPO_CONST ) );
- PyConstant_Insert( d, "LINEAR", PyInt_FromLong( IPO_LIN ) );
- PyConstant_Insert( d, "BEZIER", PyInt_FromLong( IPO_BEZ ) );
- }
- return IM;
-}
-
-/*****************************************************************************/
-/* Function: IpoCurve_Init */
-/*****************************************************************************/
-PyObject *IpoCurve_Init( void )
-{
- PyObject *submodule;
- PyObject *ExtendTypes = M_IpoCurve_ExtendDict( );
- PyObject *InterpTypes = M_IpoCurve_InterpDict( );
-
- if( PyType_Ready( &IpoCurve_Type ) < 0)
- return NULL;
-
- submodule =
- Py_InitModule3( "Blender.IpoCurve", M_IpoCurve_methods,
- M_IpoCurve_doc );
-
- PyModule_AddIntConstant( submodule, "LOC_X", OB_LOC_X );
- PyModule_AddIntConstant( submodule, "LOC_Y", OB_LOC_Y );
- PyModule_AddIntConstant( submodule, "LOC_Z", OB_LOC_Z );
- PyModule_AddIntConstant( submodule, "ROT_X", OB_ROT_X );
- PyModule_AddIntConstant( submodule, "ROT_Y", OB_ROT_Y );
- PyModule_AddIntConstant( submodule, "ROT_Z", OB_ROT_Z );
- PyModule_AddIntConstant( submodule, "SIZE_X", OB_SIZE_X );
- PyModule_AddIntConstant( submodule, "SIZE_Y", OB_SIZE_Y );
- PyModule_AddIntConstant( submodule, "SIZE_Z", OB_SIZE_Z );
-
- if( ExtendTypes )
- PyModule_AddObject( submodule, "ExtendTypes", ExtendTypes );
- if( InterpTypes )
- PyModule_AddObject( submodule, "InterpTypes", InterpTypes );
-
- return submodule;
-}
-
-/*
- */
-
-static PyObject *IpoCurve_newgetInterp( C_IpoCurve * self )
-{
- return PyInt_FromLong( self->ipocurve->ipo );
-}
-
-static int IpoCurve_newsetInterp( C_IpoCurve * self, PyObject * value )
-{
- return EXPP_setIValueRange( value, &self->ipocurve->ipo,
- IPO_CONST, IPO_BEZ, 'h' );
-}
-
-static PyObject *IpoCurve_newgetExtend( C_IpoCurve * self )
-{
- return PyInt_FromLong( self->ipocurve->extrap );
-}
-
-static int IpoCurve_newsetExtend( C_IpoCurve * self, PyObject * value )
-{
- return EXPP_setIValueRange( value, &self->ipocurve->extrap,
- IPO_HORIZ, IPO_CYCLX, 'h' );
-}
-
-static PyObject *IpoCurve_getFlag( C_IpoCurve * self, void *type )
-{
- if (self->ipocurve->flag & (int)type)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static int IpoCurve_setFlag( C_IpoCurve * self, PyObject *value, void *type )
-{
- int param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if (param)
- self->ipocurve->flag |= (int)type;
- else
- self->ipocurve->flag &= ~(int)type;
-
- return 0;
-}
-
-
-/* #####DEPRECATED###### */
-
-static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * value )
-{
- float x, y;
- int npoints;
- IpoCurve *icu;
- BezTriple *bzt, *tmp;
- static char name[10] = "mlml";
- if( !PyArg_ParseTuple( value, "ff", &x, &y ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected a tuple of 2 floats" ) );
-
- icu = self->ipocurve;
- npoints = icu->totvert;
- tmp = icu->bezt;
- icu->bezt = MEM_mallocN( sizeof( BezTriple ) * ( npoints + 1 ), name );
- if( tmp ) {
- memmove( icu->bezt, tmp, sizeof( BezTriple ) * npoints );
- MEM_freeN( tmp );
- }
- memmove( icu->bezt + npoints, icu->bezt, sizeof( BezTriple ) );
- icu->totvert++;
- bzt = icu->bezt + npoints;
- bzt->vec[0][0] = x - 1;
- bzt->vec[1][0] = x;
- bzt->vec[2][0] = x + 1;
- bzt->vec[0][1] = y - 1;
- bzt->vec[1][1] = y;
- bzt->vec[2][1] = y + 1;
- /* set handle type to Auto */
- bzt->h1 = HD_AUTO;
- bzt->h2 = HD_AUTO;
-
- Py_RETURN_NONE;
-}
diff --git a/source/blender/python/api2_2x/Ipocurve.h b/source/blender/python/api2_2x/Ipocurve.h
deleted file mode 100644
index 6c4216fa4bd..00000000000
--- a/source/blender/python/api2_2x/Ipocurve.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Key.c b/source/blender/python/api2_2x/Key.c
deleted file mode 100644
index b223a382818..00000000000
--- a/source/blender/python/api2_2x/Key.c
+++ /dev/null
@@ -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;
-}
-
diff --git a/source/blender/python/api2_2x/Key.h b/source/blender/python/api2_2x/Key.h
deleted file mode 100644
index 35e92fc5fea..00000000000
--- a/source/blender/python/api2_2x/Key.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c
deleted file mode 100644
index 8112d1372c6..00000000000
--- a/source/blender/python/api2_2x/Lamp.c
+++ /dev/null
@@ -1,1570 +0,0 @@
-/*
- * $Id: Lamp.c 12810 2007-12-06 20:15:03Z 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): Willian P. Germano, Nathan Letwory, Stephen Swaney,
- * Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include "Lamp.h" /*This must come first*/
-
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_object.h"
-#include "BKE_library.h"
-#include "BLI_blenlib.h"
-#include "BIF_space.h"
-#include "BSE_editipo.h"
-#include "mydevice.h"
-#include "Ipo.h"
-#include "constant.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-/*****************************************************************************/
-/* Python BPy_Lamp defaults: */
-/*****************************************************************************/
-
-/* Lamp types */
-
-/* NOTE:
- these are the same values as LA_* from DNA_lamp_types.h
- is there some reason we are not simply using those #defines?
- s. swaney 8-oct-2004
-*/
-
-#define EXPP_LAMP_TYPE_LAMP 0
-#define EXPP_LAMP_TYPE_SUN 1
-#define EXPP_LAMP_TYPE_SPOT 2
-#define EXPP_LAMP_TYPE_HEMI 3
-#define EXPP_LAMP_TYPE_AREA 4
-#define EXPP_LAMP_TYPE_YF_PHOTON 5
-/*
- define a constant to keep magic numbers out of the code
- this value should be equal to the last EXPP_LAMP_TYPE_*
-*/
-#define EXPP_LAMP_TYPE_MAX 5
-
-/* Lamp mode flags */
-
-#define EXPP_LAMP_MODE_SHADOWS 1
-#define EXPP_LAMP_MODE_HALO 2
-#define EXPP_LAMP_MODE_LAYER 4
-#define EXPP_LAMP_MODE_QUAD 8
-#define EXPP_LAMP_MODE_NEGATIVE 16
-#define EXPP_LAMP_MODE_ONLYSHADOW 32
-#define EXPP_LAMP_MODE_SPHERE 64
-#define EXPP_LAMP_MODE_SQUARE 128
-#define EXPP_LAMP_MODE_TEXTURE 256
-#define EXPP_LAMP_MODE_OSATEX 512
-#define EXPP_LAMP_MODE_DEEPSHADOW 1024
-#define EXPP_LAMP_MODE_NODIFFUSE 2048
-#define EXPP_LAMP_MODE_NOSPECULAR 4096
-#define EXPP_LAMP_MODE_SHAD_RAY 8192
-/* Lamp MIN, MAX values */
-
-#define EXPP_LAMP_SAMPLES_MIN 1
-#define EXPP_LAMP_SAMPLES_MAX 16
-#define EXPP_LAMP_BUFFERSIZE_MIN 512
-#define EXPP_LAMP_BUFFERSIZE_MAX 5120
-#define EXPP_LAMP_ENERGY_MIN 0.0
-#define EXPP_LAMP_ENERGY_MAX 10.0
-#define EXPP_LAMP_DIST_MIN 0.1f
-#define EXPP_LAMP_DIST_MAX 5000.0
-#define EXPP_LAMP_SPOTSIZE_MIN 1.0
-#define EXPP_LAMP_SPOTSIZE_MAX 180.0
-#define EXPP_LAMP_SPOTBLEND_MIN 0.00
-#define EXPP_LAMP_SPOTBLEND_MAX 1.00
-#define EXPP_LAMP_CLIPSTART_MIN 0.1f
-#define EXPP_LAMP_CLIPSTART_MAX 1000.0
-#define EXPP_LAMP_CLIPEND_MIN 1.0
-#define EXPP_LAMP_CLIPEND_MAX 5000.0
-#define EXPP_LAMP_BIAS_MIN 0.01f
-#define EXPP_LAMP_BIAS_MAX 5.00
-#define EXPP_LAMP_SOFTNESS_MIN 1.0
-#define EXPP_LAMP_SOFTNESS_MAX 100.0
-#define EXPP_LAMP_HALOINT_MIN 0.0
-#define EXPP_LAMP_HALOINT_MAX 5.0
-#define EXPP_LAMP_HALOSTEP_MIN 0
-#define EXPP_LAMP_HALOSTEP_MAX 12
-#define EXPP_LAMP_QUAD1_MIN 0.0
-#define EXPP_LAMP_QUAD1_MAX 1.0
-#define EXPP_LAMP_QUAD2_MIN 0.0
-#define EXPP_LAMP_QUAD2_MAX 1.0
-#define EXPP_LAMP_COL_MIN 0.0
-#define EXPP_LAMP_COL_MAX 1.0
-
-/* Raytracing settings */
-#define EXPP_LAMP_RAYSAMPLES_MIN 1
-#define EXPP_LAMP_RAYSAMPLES_MAX 16
-#define EXPP_LAMP_AREASIZE_MIN 0.01f
-#define EXPP_LAMP_AREASIZE_MAX 100.0f
-
-/* Lamp_setComponent() keys for which color to get/set */
-#define EXPP_LAMP_COMP_R 0x00
-#define EXPP_LAMP_COMP_G 0x01
-#define EXPP_LAMP_COMP_B 0x02
-
-#define IPOKEY_RGB 0
-#define IPOKEY_ENERGY 1
-#define IPOKEY_SPOTSIZE 2
-#define IPOKEY_OFFSET 3
-#define IPOKEY_SIZE 4
-
-/*****************************************************************************/
-/* Python API function prototypes for the Lamp module. */
-/*****************************************************************************/
-static PyObject *M_Lamp_New( PyObject * self, PyObject * args,
- PyObject * keywords );
-static PyObject *M_Lamp_Get( 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.Lamp.__doc__ */
-/*****************************************************************************/
-static char M_Lamp_doc[] = "The Blender Lamp module\n\n\
-This module provides control over **Lamp Data** objects in Blender.\n\n\
-Example::\n\n\
- from Blender import Lamp\n\
- l = Lamp.New('Spot') # create new 'Spot' lamp data\n\
- l.setMode('square', 'shadow') # set these two lamp mode flags\n\
- ob = Object.New('Lamp') # create new lamp object\n\
- ob.link(l) # link lamp obj with lamp data\n";
-
-static char M_Lamp_New_doc[] = "Lamp.New (type = 'Lamp', name = 'LampData'):\n\
- Return a new Lamp Data object with the given type and name.";
-
-static char M_Lamp_Get_doc[] = "Lamp.Get (name = None):\n\
- Return the Lamp Data with the given name, None if not found, or\n\
- Return a list with all Lamp Data objects in the current scene,\n\
- if no argument was given.";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Lamp module: */
-/*****************************************************************************/
-struct PyMethodDef M_Lamp_methods[] = {
- {"New", ( PyCFunction ) M_Lamp_New, METH_VARARGS | METH_KEYWORDS,
- M_Lamp_New_doc},
- {"Get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
- {"get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Lamp methods declarations: */
-/*****************************************************************************/
-static PyObject *Lamp_getType( BPy_Lamp * self );
-static PyObject *Lamp_getTypesConst( void );
-static PyObject *Lamp_getMode( BPy_Lamp * self );
-static PyObject *Lamp_getModesConst( void );
-static PyObject *Lamp_getSamples( BPy_Lamp * self );
-static PyObject *Lamp_getRaySamplesX( BPy_Lamp * self );
-static PyObject *Lamp_getRaySamplesY( BPy_Lamp * self );
-static PyObject *Lamp_getAreaSizeX( BPy_Lamp * self );
-static PyObject *Lamp_getAreaSizeY( BPy_Lamp * self );
-static PyObject *Lamp_getBufferSize( BPy_Lamp * self );
-static PyObject *Lamp_getHaloStep( BPy_Lamp * self );
-static PyObject *Lamp_getEnergy( BPy_Lamp * self );
-static PyObject *Lamp_getDist( BPy_Lamp * self );
-static PyObject *Lamp_getSpotSize( BPy_Lamp * self );
-static PyObject *Lamp_getSpotBlend( BPy_Lamp * self );
-static PyObject *Lamp_getClipStart( BPy_Lamp * self );
-static PyObject *Lamp_getClipEnd( BPy_Lamp * self );
-static PyObject *Lamp_getBias( BPy_Lamp * self );
-static PyObject *Lamp_getSoftness( BPy_Lamp * self );
-static PyObject *Lamp_getHaloInt( BPy_Lamp * self );
-static PyObject *Lamp_getQuad1( BPy_Lamp * self );
-static PyObject *Lamp_getQuad2( BPy_Lamp * self );
-static PyObject *Lamp_getCol( BPy_Lamp * self );
-static PyObject *Lamp_getIpo( BPy_Lamp * self );
-static PyObject *Lamp_getComponent( BPy_Lamp * self, void * closure );
-static PyObject *Lamp_clearIpo( BPy_Lamp * self );
-static PyObject *Lamp_insertIpoKey( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetIpo( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * value );
-static PyObject *Lamp_oldsetMode( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetSamples( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetRaySamplesX( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetRaySamplesY( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetAreaSizeX( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetAreaSizeY( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetBufferSize( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetHaloStep( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetEnergy( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetDist( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetSpotSize( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetSpotBlend( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetClipStart( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetClipEnd( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetBias( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetSoftness( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetHaloInt( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetQuad1( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetQuad2( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_oldsetCol( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_copy( BPy_Lamp * self );
-static int Lamp_setIpo( BPy_Lamp * self, PyObject * args );
-static int Lamp_setType( BPy_Lamp * self, PyObject * args );
-static int Lamp_setMode( BPy_Lamp * self, PyObject * args );
-static int Lamp_setSamples( BPy_Lamp * self, PyObject * args );
-static int Lamp_setRaySamplesX( BPy_Lamp * self, PyObject * args );
-static int Lamp_setRaySamplesY( BPy_Lamp * self, PyObject * args );
-static int Lamp_setAreaSizeX( BPy_Lamp * self, PyObject * args );
-static int Lamp_setAreaSizeY( BPy_Lamp * self, PyObject * args );
-static int Lamp_setBufferSize( BPy_Lamp * self, PyObject * args );
-static int Lamp_setHaloStep( BPy_Lamp * self, PyObject * args );
-static int Lamp_setEnergy( BPy_Lamp * self, PyObject * args );
-static int Lamp_setDist( BPy_Lamp * self, PyObject * args );
-static int Lamp_setSpotSize( BPy_Lamp * self, PyObject * args );
-static int Lamp_setSpotBlend( BPy_Lamp * self, PyObject * args );
-static int Lamp_setClipStart( BPy_Lamp * self, PyObject * args );
-static int Lamp_setClipEnd( BPy_Lamp * self, PyObject * args );
-static int Lamp_setBias( BPy_Lamp * self, PyObject * args );
-static int Lamp_setSoftness( BPy_Lamp * self, PyObject * args );
-static int Lamp_setHaloInt( BPy_Lamp * self, PyObject * args );
-static int Lamp_setQuad1( BPy_Lamp * self, PyObject * args );
-static int Lamp_setQuad2( BPy_Lamp * self, PyObject * args );
-static int Lamp_setCol( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * value );
-static PyObject *Lamp_addScriptLink( BPy_Lamp * self, PyObject * args );
-static PyObject *Lamp_clearScriptLinks( BPy_Lamp * self, PyObject * args );
-static int Lamp_setComponent( BPy_Lamp * self, PyObject * value, void * closure );
-
-/*****************************************************************************/
-/* Python BPy_Lamp methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Lamp_methods[] = {
- /* name, method, flags, doc */
-
- {"getType", ( PyCFunction ) Lamp_getType, METH_NOARGS,
- "() - return Lamp type - 'Lamp':0, 'Sun':1, 'Spot':2, 'Hemi':3, 'Area':4, 'Photon':5"},
- {"getMode", ( PyCFunction ) Lamp_getMode, METH_NOARGS,
- "() - return Lamp mode flags (or'ed value)"},
- {"getSamples", ( PyCFunction ) Lamp_getSamples, METH_NOARGS,
- "() - return Lamp samples value"},
- {"getRaySamplesX", ( PyCFunction ) Lamp_getRaySamplesX, METH_NOARGS,
- "() - return Lamp raytracing samples on the X axis"},
- {"getRaySamplesY", ( PyCFunction ) Lamp_getRaySamplesY, METH_NOARGS,
- "() - return Lamp raytracing samples on the Y axis"},
- {"getAreaSizeX", ( PyCFunction ) Lamp_getAreaSizeX, METH_NOARGS,
- "() - return Lamp area size on the X axis"},
- {"getAreaSizeY", ( PyCFunction ) Lamp_getAreaSizeY, METH_NOARGS,
- "() - return Lamp area size on the Y axis"},
- {"getBufferSize", ( PyCFunction ) Lamp_getBufferSize, METH_NOARGS,
- "() - return Lamp buffer size value"},
- {"getHaloStep", ( PyCFunction ) Lamp_getHaloStep, METH_NOARGS,
- "() - return Lamp halo step value"},
- {"getEnergy", ( PyCFunction ) Lamp_getEnergy, METH_NOARGS,
- "() - return Lamp energy value"},
- {"getDist", ( PyCFunction ) Lamp_getDist, METH_NOARGS,
- "() - return Lamp clipping distance value"},
- {"getSpotSize", ( PyCFunction ) Lamp_getSpotSize, METH_NOARGS,
- "() - return Lamp spot size value"},
- {"getSpotBlend", ( PyCFunction ) Lamp_getSpotBlend, METH_NOARGS,
- "() - return Lamp spot blend value"},
- {"getClipStart", ( PyCFunction ) Lamp_getClipStart, METH_NOARGS,
- "() - return Lamp clip start value"},
- {"getClipEnd", ( PyCFunction ) Lamp_getClipEnd, METH_NOARGS,
- "() - return Lamp clip end value"},
- {"getBias", ( PyCFunction ) Lamp_getBias, METH_NOARGS,
- "() - return Lamp bias value"},
- {"getSoftness", ( PyCFunction ) Lamp_getSoftness, METH_NOARGS,
- "() - return Lamp softness value"},
- {"getHaloInt", ( PyCFunction ) Lamp_getHaloInt, METH_NOARGS,
- "() - return Lamp halo intensity value"},
- {"getQuad1", ( PyCFunction ) Lamp_getQuad1, METH_NOARGS,
- "() - return light intensity value #1 for a Quad Lamp"},
- {"getQuad2", ( PyCFunction ) Lamp_getQuad2, METH_NOARGS,
- "() - return light intensity value #2 for a Quad Lamp"},
- {"getCol", ( PyCFunction ) Lamp_getCol, METH_NOARGS,
- "() - return light rgb color triplet"},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "(str) - rename Lamp"},
- {"setType", ( PyCFunction ) Lamp_oldsetType, METH_O,
- "(str) - change Lamp type, which can be 'Lamp', 'Sun', 'Spot', 'Hemi', 'Area', 'Photon'"},
- {"setMode", ( PyCFunction ) Lamp_oldsetMode, METH_VARARGS,
- "([up to eight str's]) - Set Lamp mode flag(s)"},
- {"setSamples", ( PyCFunction ) Lamp_oldsetSamples, METH_VARARGS,
- "(int) - change Lamp samples value"},
- {"setRaySamplesX", ( PyCFunction ) Lamp_oldsetRaySamplesX, METH_VARARGS,
- "(int) - change Lamp ray X samples value in [1,16]"},
- {"setRaySamplesY", ( PyCFunction ) Lamp_oldsetRaySamplesY, METH_VARARGS,
- "(int) - change Lamp ray Y samples value in [1,16]"},
- {"setAreaSizeX", ( PyCFunction ) Lamp_oldsetAreaSizeX, METH_VARARGS,
- "(float) - change Lamp ray X size for area lamps, value in [0.01, 100.0]"},
- {"setAreaSizeY", ( PyCFunction ) Lamp_oldsetAreaSizeY, METH_VARARGS,
- "(float) - change Lamp ray Y size for area lamps, value in [0.01, 100.0]"},
- {"setBufferSize", ( PyCFunction ) Lamp_oldsetBufferSize, METH_VARARGS,
- "(int) - change Lamp buffer size value"},
- {"setHaloStep", ( PyCFunction ) Lamp_oldsetHaloStep, METH_VARARGS,
- "(int) - change Lamp halo step value"},
- {"setEnergy", ( PyCFunction ) Lamp_oldsetEnergy, METH_VARARGS,
- "(float) - change Lamp energy value"},
- {"setDist", ( PyCFunction ) Lamp_oldsetDist, METH_VARARGS,
- "(float) - change Lamp clipping distance value"},
- {"setSpotSize", ( PyCFunction ) Lamp_oldsetSpotSize, METH_VARARGS,
- "(float) - change Lamp spot size value"},
- {"setSpotBlend", ( PyCFunction ) Lamp_oldsetSpotBlend, METH_VARARGS,
- "(float) - change Lamp spot blend value"},
- {"setClipStart", ( PyCFunction ) Lamp_oldsetClipStart, METH_VARARGS,
- "(float) - change Lamp clip start value"},
- {"setClipEnd", ( PyCFunction ) Lamp_oldsetClipEnd, METH_VARARGS,
- "(float) - change Lamp clip end value"},
- {"setBias", ( PyCFunction ) Lamp_oldsetBias, METH_VARARGS,
- "(float) - change Lamp draw size value"},
- {"setSoftness", ( PyCFunction ) Lamp_oldsetSoftness, METH_VARARGS,
- "(float) - change Lamp softness value"},
- {"setHaloInt", ( PyCFunction ) Lamp_oldsetHaloInt, METH_VARARGS,
- "(float) - change Lamp halo intensity value"},
- {"setQuad1", ( PyCFunction ) Lamp_oldsetQuad1, METH_VARARGS,
- "(float) - change light intensity value #1 for a Quad Lamp"},
- {"setQuad2", ( PyCFunction ) Lamp_oldsetQuad2, METH_VARARGS,
- "(float) - change light intensity value #2 for a Quad Lamp"},
- {"setCol", ( PyCFunction ) Lamp_oldsetCol, METH_VARARGS,
- "(f,f,f) or ([f,f,f]) - change light's rgb color triplet"},
- {"getScriptLinks", ( PyCFunction ) Lamp_getScriptLinks, METH_O,
- "(eventname) - Get a list of this lamp's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged, Redraw or Render."},
- {"addScriptLink", ( PyCFunction ) Lamp_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new lamp scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged, Redraw or Render."},
- {"clearScriptLinks", ( PyCFunction ) Lamp_clearScriptLinks,
- METH_VARARGS,
- "() - Delete all scriptlinks from this lamp.\n"
- "([s1<,s2,s3...>]) - Delete specified scriptlinks from this lamp."},
- {"getIpo", ( PyCFunction ) Lamp_getIpo, METH_NOARGS,
- "() - get IPO for this lamp"},
- {"clearIpo", ( PyCFunction ) Lamp_clearIpo, METH_NOARGS,
- "() - unlink the IPO for this lamp"},
- {"setIpo", ( PyCFunction ) Lamp_oldsetIpo, METH_VARARGS,
- "( lamp-ipo ) - link an IPO to this lamp"},
- {"insertIpoKey", ( PyCFunction ) Lamp_insertIpoKey, METH_VARARGS,
- "( Lamp IPO type ) - Inserts a key into IPO"},
- {"__copy__", ( PyCFunction ) Lamp_copy, METH_NOARGS,
- "() - Makes a copy of this lamp."},
- {"copy", ( PyCFunction ) Lamp_copy, METH_NOARGS,
- "() - Makes a copy of this lamp."},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Lamp_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"bias",
- (getter)Lamp_getBias, (setter)Lamp_setBias,
- "Lamp shadow map sampling bias",
- NULL},
- {"bufferSize",
- (getter)Lamp_getBufferSize, (setter)Lamp_setBufferSize,
- "Lamp shadow buffer size",
- NULL},
- {"clipEnd",
- (getter)Lamp_getClipEnd, (setter)Lamp_setClipEnd,
- "Lamp shadow map clip end",
- NULL},
- {"clipStart",
- (getter)Lamp_getClipStart, (setter)Lamp_setClipStart,
- "Lamp shadow map clip start",
- NULL},
- {"col",
- (getter)Lamp_getCol, (setter)Lamp_setCol,
- "Lamp RGB color triplet",
- NULL},
- {"dist",
- (getter)Lamp_getDist, (setter)Lamp_setDist,
- "Lamp clipping distance",
- NULL},
- {"energy",
- (getter)Lamp_getEnergy, (setter)Lamp_setEnergy,
- "Lamp light intensity",
- NULL},
- {"haloInt",
- (getter)Lamp_getHaloInt, (setter)Lamp_setHaloInt,
- "Lamp spotlight halo intensity",
- NULL},
- {"haloStep",
- (getter)Lamp_getHaloStep, (setter)Lamp_setHaloStep,
- "Lamp volumetric halo sampling frequency",
- NULL},
- {"ipo",
- (getter)Lamp_getIpo, (setter)Lamp_setIpo,
- "Lamp Ipo",
- NULL},
- {"mode",
- (getter)Lamp_getMode, (setter)Lamp_setMode,
- "Lamp mode bitmask",
- NULL},
- {"quad1",
- (getter)Lamp_getQuad1, (setter)Lamp_setQuad1,
- "Quad lamp linear distance attenuation",
- NULL},
- {"quad2",
- (getter)Lamp_getQuad2, (setter)Lamp_setQuad2,
- "Quad lamp quadratic distance attenuation",
- NULL},
- {"samples",
- (getter)Lamp_getSamples, (setter)Lamp_setSamples,
- "Lamp shadow map samples",
- NULL},
- {"raySamplesX",
- (getter)Lamp_getRaySamplesX, (setter)Lamp_setRaySamplesX,
- "Lamp raytracing samples on the X axis",
- NULL},
- {"raySamplesY",
- (getter)Lamp_getRaySamplesY, (setter)Lamp_setRaySamplesY,
- "Lamp raytracing samples on the Y axis",
- NULL},
- {"areaSizeX",
- (getter)Lamp_getAreaSizeX, (setter)Lamp_setAreaSizeX,
- "Lamp X size for an arealamp",
- NULL},
- {"areaSizeY",
- (getter)Lamp_getAreaSizeY, (setter)Lamp_setAreaSizeY,
- "Lamp Y size for an arealamp",
- NULL},
- {"softness",
- (getter)Lamp_getSoftness, (setter)Lamp_setSoftness,
- "Lamp shadow sample area size",
- NULL},
- {"spotBlend",
- (getter)Lamp_getSpotBlend, (setter)Lamp_setSpotBlend,
- "Lamp spotlight edge softness",
- NULL},
- {"spotSize",
- (getter)Lamp_getSpotSize, (setter)Lamp_setSpotSize,
- "Lamp spotlight beam angle (in degrees)",
- NULL},
- {"type",
- (getter)Lamp_getType, (setter)Lamp_setType,
- "Lamp type",
- NULL},
- {"R",
- (getter)Lamp_getComponent, (setter)Lamp_setComponent,
- "Lamp color red component",
- (void *)EXPP_LAMP_COMP_R},
- {"r",
- (getter)Lamp_getComponent, (setter)Lamp_setComponent,
- "Lamp color red component",
- (void *)EXPP_LAMP_COMP_R},
- {"G",
- (getter)Lamp_getComponent, (setter)Lamp_setComponent,
- "Lamp color green component",
- (void *)EXPP_LAMP_COMP_G},
- {"g",
- (getter)Lamp_getComponent, (setter)Lamp_setComponent,
- "Lamp color green component",
- (void *)EXPP_LAMP_COMP_G},
- {"B",
- (getter)Lamp_getComponent, (setter)Lamp_setComponent,
- "Lamp color blue component",
- (void *)EXPP_LAMP_COMP_B},
- {"b",
- (getter)Lamp_getComponent, (setter)Lamp_setComponent,
- "Lamp color blue component",
- (void *)EXPP_LAMP_COMP_B},
- {"Modes",
- (getter)Lamp_getModesConst, (setter)NULL,
- "Dictionary of values for 'mode' attribute",
- NULL},
- {"Types",
- (getter)Lamp_getTypesConst, (setter)NULL,
- "Dictionary of values for 'type' attribute",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python TypeLamp callback function prototypes: */
-/*****************************************************************************/
-static void Lamp_dealloc( BPy_Lamp * lamp );
-static int Lamp_compare( BPy_Lamp * a, BPy_Lamp * b );
-static PyObject *Lamp_repr( BPy_Lamp * lamp );
-
-/*****************************************************************************/
-/* Python TypeLamp structure definition: */
-/*****************************************************************************/
-PyTypeObject Lamp_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Lamp", /* char *tp_name; */
- sizeof( BPy_Lamp ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) Lamp_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) Lamp_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Lamp_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_Lamp_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Lamp_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_Lamp_New */
-/* Python equivalent: Blender.Lamp.New */
-/*****************************************************************************/
-static PyObject *M_Lamp_New( PyObject * self, PyObject * args,
- PyObject * keywords )
-{
- char *type_str = "Lamp";
- char *name_str = "Lamp";
- static char *kwlist[] = { "type_str", "name_str", NULL };
- BPy_Lamp *py_lamp; /* for Lamp Data object wrapper in Python */
- Lamp *bl_lamp; /* for actual Lamp Data we create in Blender */
-
- if( !PyArg_ParseTupleAndKeywords( args, keywords, "|ss", kwlist,
- &type_str, &name_str ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected string(s) or empty argument" ) );
-
- bl_lamp = add_lamp( name_str ); /* first create in Blender */
-
- if( bl_lamp ) /* now create the wrapper obj in Python */
- py_lamp = ( BPy_Lamp * ) Lamp_CreatePyObject( bl_lamp );
- else
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Lamp Data in Blender" ) );
-
- /* let's return user count to zero, because ... */
- bl_lamp->id.us = 0; /* ... add_lamp() incref'ed it */
-
- if( py_lamp == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create Lamp Data object" ) );
-
- if( strcmp( type_str, "Lamp" ) == 0 )
- bl_lamp->type = ( short ) EXPP_LAMP_TYPE_LAMP;
- else if( strcmp( type_str, "Sun" ) == 0 )
- bl_lamp->type = ( short ) EXPP_LAMP_TYPE_SUN;
- else if( strcmp( type_str, "Spot" ) == 0 )
- bl_lamp->type = ( short ) EXPP_LAMP_TYPE_SPOT;
- else if( strcmp( type_str, "Hemi" ) == 0 )
- bl_lamp->type = ( short ) EXPP_LAMP_TYPE_HEMI;
- else if( strcmp( type_str, "Area" ) == 0 )
- bl_lamp->type = ( short ) EXPP_LAMP_TYPE_AREA;
- else if( strcmp( type_str, "Photon" ) == 0 )
- bl_lamp->type = ( short ) EXPP_LAMP_TYPE_YF_PHOTON;
- else
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown lamp type" ) );
-
- return ( PyObject * ) py_lamp;
-}
-
-/*****************************************************************************/
-/* Function: M_Lamp_Get */
-/* Python equivalent: Blender.Lamp.Get */
-/* Description: Receives a string and returns the lamp data obj */
-/* whose name matches the string. If no argument is */
-/* passed in, a list of all lamp data names in the */
-/* current scene is returned. */
-/*****************************************************************************/
-static PyObject *M_Lamp_Get( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- Lamp *lamp_iter;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" ) );
-
- lamp_iter = G.main->lamp.first;
-
- if( name ) { /* (name) - Search lamp by name */
-
- BPy_Lamp *wanted_lamp = NULL;
-
- while( ( lamp_iter ) && ( wanted_lamp == NULL ) ) {
-
- if( strcmp( name, lamp_iter->id.name + 2 ) == 0 )
- wanted_lamp =
- ( BPy_Lamp * )
- Lamp_CreatePyObject( lamp_iter );
-
- lamp_iter = lamp_iter->id.next;
- }
-
- if( wanted_lamp == NULL ) { /* Requested lamp doesn't exist */
- char error_msg[64];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Lamp \"%s\" not found", name );
- return ( EXPP_ReturnPyObjError
- ( PyExc_NameError, error_msg ) );
- }
-
- return ( PyObject * ) wanted_lamp;
- }
-
- else { /* () - return a list of all lamps in the scene */
- int index = 0;
- PyObject *lamplist, *pyobj;
-
- lamplist = PyList_New( BLI_countlist( &( G.main->lamp ) ) );
-
- if( lamplist == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" ) );
-
- while( lamp_iter ) {
- pyobj = Lamp_CreatePyObject( lamp_iter );
-
- if( !pyobj ) {
- Py_DECREF(lamplist);
- return ( EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create PyLamp" ) );
- }
-
- PyList_SET_ITEM( lamplist, index, pyobj );
-
- lamp_iter = lamp_iter->id.next;
- index++;
- }
-
- return lamplist;
- }
-}
-
-static PyObject *Lamp_TypesDict( void )
-{ /* create the Blender.Lamp.Types constant dict */
- PyObject *Types = PyConstant_New( );
-
- if( Types ) {
- BPy_constant *c = ( BPy_constant * ) Types;
-
- PyConstant_Insert( c, "Lamp",
- PyInt_FromLong( EXPP_LAMP_TYPE_LAMP ) );
- PyConstant_Insert( c, "Sun",
- PyInt_FromLong( EXPP_LAMP_TYPE_SUN ) );
- PyConstant_Insert( c, "Spot",
- PyInt_FromLong( EXPP_LAMP_TYPE_SPOT ) );
- PyConstant_Insert( c, "Hemi",
- PyInt_FromLong( EXPP_LAMP_TYPE_HEMI ) );
- PyConstant_Insert( c, "Area",
- PyInt_FromLong( EXPP_LAMP_TYPE_AREA ) );
- PyConstant_Insert( c, "Photon",
- PyInt_FromLong( EXPP_LAMP_TYPE_YF_PHOTON ) );
- }
-
- return Types;
-}
-
-static PyObject *Lamp_ModesDict( void )
-{ /* create the Blender.Lamp.Modes constant dict */
- PyObject *Modes = PyConstant_New( );
-
- if( Modes ) {
- BPy_constant *c = ( BPy_constant * ) Modes;
-
- PyConstant_Insert( c, "Shadows",
- PyInt_FromLong( EXPP_LAMP_MODE_SHADOWS ) );
- PyConstant_Insert( c, "Halo",
- PyInt_FromLong( EXPP_LAMP_MODE_HALO ) );
- PyConstant_Insert( c, "Layer",
- PyInt_FromLong( EXPP_LAMP_MODE_LAYER ) );
- PyConstant_Insert( c, "Quad",
- PyInt_FromLong( EXPP_LAMP_MODE_QUAD ) );
- PyConstant_Insert( c, "Negative",
- PyInt_FromLong( EXPP_LAMP_MODE_NEGATIVE ) );
- PyConstant_Insert( c, "Sphere",
- PyInt_FromLong( EXPP_LAMP_MODE_SPHERE ) );
- PyConstant_Insert( c, "Square",
- PyInt_FromLong( EXPP_LAMP_MODE_SQUARE ) );
- PyConstant_Insert( c, "OnlyShadow",
- PyInt_FromLong( EXPP_LAMP_MODE_ONLYSHADOW ) );
- PyConstant_Insert( c, "NoDiffuse",
- PyInt_FromLong( EXPP_LAMP_MODE_NODIFFUSE ) );
- PyConstant_Insert( c, "NoSpecular",
- PyInt_FromLong( EXPP_LAMP_MODE_NOSPECULAR ) );
- PyConstant_Insert( c, "RayShadow",
- PyInt_FromLong( EXPP_LAMP_MODE_SHAD_RAY ) );
- }
-
- return Modes;
-}
-
-/*****************************************************************************/
-/* Function: Lamp_Init */
-/*****************************************************************************/
-/* Needed by the Blender module, to register the Blender.Lamp submodule */
-PyObject *Lamp_Init( void )
-{
- PyObject *submodule, *Types, *Modes;
-
- if( PyType_Ready( &Lamp_Type ) < 0)
- return NULL;
-
- Types = Lamp_TypesDict( );
- Modes = Lamp_ModesDict( );
-
- submodule =
- Py_InitModule3( "Blender.Lamp", M_Lamp_methods, M_Lamp_doc );
-
- if( Types )
- PyModule_AddObject( submodule, "Types", Types );
- if( Modes )
- PyModule_AddObject( submodule, "Modes", Modes );
-
- PyModule_AddIntConstant( submodule, "RGB", IPOKEY_RGB );
- PyModule_AddIntConstant( submodule, "ENERGY", IPOKEY_ENERGY );
- PyModule_AddIntConstant( submodule, "SPOTSIZE", IPOKEY_SPOTSIZE );
- PyModule_AddIntConstant( submodule, "OFFSET", IPOKEY_OFFSET );
- PyModule_AddIntConstant( submodule, "SIZE", IPOKEY_SIZE );
-
- return submodule;
-}
-
-/* Three Python Lamp_Type helper functions needed by the Object module: */
-
-/*****************************************************************************/
-/* Function: Lamp_CreatePyObject */
-/* Description: This function will create a new BPy_Lamp from an existing */
-/* Blender lamp structure. */
-/*****************************************************************************/
-PyObject *Lamp_CreatePyObject( Lamp * lamp )
-{
- BPy_Lamp *pylamp;
- float *rgb[3];
-
- pylamp = ( BPy_Lamp * ) PyObject_NEW( BPy_Lamp, &Lamp_Type );
-
- if( !pylamp )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Lamp object" );
-
- pylamp->lamp = lamp;
-
- rgb[0] = &lamp->r;
- rgb[1] = &lamp->g;
- rgb[2] = &lamp->b;
-
- pylamp->color = ( BPy_rgbTuple * ) rgbTuple_New( rgb );
- Py_INCREF(pylamp->color);
-
- return ( PyObject * ) pylamp;
-}
-
-/*****************************************************************************/
-/* Function: Lamp_FromPyObject */
-/* Description: This function returns the Blender lamp from the given */
-/* PyObject. */
-/*****************************************************************************/
-Lamp *Lamp_FromPyObject( PyObject * pyobj )
-{
- return ( ( BPy_Lamp * ) pyobj )->lamp;
-}
-
-/*****************************************************************************/
-/* Python BPy_Lamp methods: */
-/*****************************************************************************/
-
-/* Lamp.__copy__ */
-static PyObject *Lamp_copy( BPy_Lamp * self )
-{
- Lamp *lamp = copy_lamp(self->lamp );
- lamp->id.us = 0;
- return Lamp_CreatePyObject(lamp);
-}
-
-static PyObject *Lamp_getType( BPy_Lamp * self )
-{
- return PyInt_FromLong( self->lamp->type );
-}
-
-static PyObject *Lamp_getMode( BPy_Lamp * self )
-{
- return PyInt_FromLong( self->lamp->mode );
-}
-
-static PyObject *Lamp_getSamples( BPy_Lamp * self )
-{
- return PyInt_FromLong( self->lamp->samp );
-}
-
-static PyObject *Lamp_getRaySamplesX( BPy_Lamp * self )
-{
- return PyInt_FromLong( self->lamp->ray_samp );
-}
-
-static PyObject *Lamp_getRaySamplesY( BPy_Lamp * self )
-{
- return PyInt_FromLong( self->lamp->ray_sampy );
-}
-
-static PyObject *Lamp_getAreaSizeX( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->area_size );
-}
-
-static PyObject *Lamp_getAreaSizeY( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->area_sizey );
-}
-
-static PyObject *Lamp_getBufferSize( BPy_Lamp * self )
-{
- return PyInt_FromLong( self->lamp->bufsize );
-}
-
-static PyObject *Lamp_getHaloStep( BPy_Lamp * self )
-{
- return PyInt_FromLong( self->lamp->shadhalostep );
-}
-
-static PyObject *Lamp_getEnergy( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->energy );
-}
-
-static PyObject *Lamp_getDist( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->dist );
-}
-
-static PyObject *Lamp_getSpotSize( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->spotsize );
-}
-
-static PyObject *Lamp_getSpotBlend( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->spotblend );
-}
-
-static PyObject *Lamp_getClipStart( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->clipsta );
-}
-
-static PyObject *Lamp_getClipEnd( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->clipend );
-}
-
-static PyObject *Lamp_getBias( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->bias );
-}
-
-static PyObject *Lamp_getSoftness( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->soft );
-}
-
-static PyObject *Lamp_getHaloInt( BPy_Lamp * self )
-{
- return PyFloat_FromDouble( self->lamp->haint );
-}
-
-static PyObject *Lamp_getQuad1( BPy_Lamp * self )
-{ /* should we complain if Lamp is not of type Quad? */
- return PyFloat_FromDouble( self->lamp->att1 );
-}
-
-static PyObject *Lamp_getQuad2( BPy_Lamp * self )
-{ /* should we complain if Lamp is not of type Quad? */
- return PyFloat_FromDouble( self->lamp->att2 );
-}
-
-static PyObject *Lamp_getCol( BPy_Lamp * self )
-{
- return rgbTuple_getCol( self->color );
-}
-
-static int Lamp_setType( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setIValueRange ( value, &self->lamp->type,
- 0, EXPP_LAMP_TYPE_MAX, 'h' );
-}
-
-static int Lamp_setMode( BPy_Lamp * self, PyObject * value )
-{
- short param;
- static short bitmask = EXPP_LAMP_MODE_SHADOWS
- | EXPP_LAMP_MODE_HALO
- | EXPP_LAMP_MODE_LAYER
- | EXPP_LAMP_MODE_QUAD
- | EXPP_LAMP_MODE_NEGATIVE
- | EXPP_LAMP_MODE_ONLYSHADOW
- | EXPP_LAMP_MODE_SPHERE
- | EXPP_LAMP_MODE_SQUARE
- | EXPP_LAMP_MODE_NODIFFUSE
- | EXPP_LAMP_MODE_NOSPECULAR
- | EXPP_LAMP_MODE_SHAD_RAY;
-
- if( !PyInt_Check ( value ) ) {
- char errstr[128];
- sprintf ( errstr , "expected int bitmask of 0x%04x", bitmask );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
- param = (short)PyInt_AS_LONG ( value );
-
- if ( ( param & bitmask ) != param )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid bit(s) set in mask" );
-
- self->lamp->mode = param;
-
- return 0;
-}
-
-static int Lamp_setSamples( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->lamp->samp,
- EXPP_LAMP_SAMPLES_MIN,
- EXPP_LAMP_SAMPLES_MAX, 'h' );
-}
-
-
-static int Lamp_setRaySamplesX( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->lamp->ray_samp,
- EXPP_LAMP_RAYSAMPLES_MIN,
- EXPP_LAMP_RAYSAMPLES_MAX, 'h' );
-}
-
-static int Lamp_setRaySamplesY( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->lamp->ray_sampy,
- EXPP_LAMP_RAYSAMPLES_MIN,
- EXPP_LAMP_RAYSAMPLES_MAX, 'h' );
-}
-
-static int Lamp_setAreaSizeX( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->area_size,
- EXPP_LAMP_AREASIZE_MIN,
- EXPP_LAMP_AREASIZE_MAX );
-}
-
-static int Lamp_setAreaSizeY( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->area_sizey,
- EXPP_LAMP_AREASIZE_MIN,
- EXPP_LAMP_AREASIZE_MAX );
-}
-
-static int Lamp_setBufferSize( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->lamp->bufsize,
- EXPP_LAMP_BUFFERSIZE_MIN,
- EXPP_LAMP_BUFFERSIZE_MAX, 'h' );
-}
-
-static int Lamp_setHaloStep( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->lamp->shadhalostep,
- EXPP_LAMP_HALOSTEP_MIN,
- EXPP_LAMP_HALOSTEP_MAX, 'h' );
-}
-
-static int Lamp_setEnergy( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->energy,
- EXPP_LAMP_ENERGY_MIN,
- EXPP_LAMP_ENERGY_MAX );
-}
-
-static int Lamp_setDist( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->dist,
- EXPP_LAMP_DIST_MIN,
- EXPP_LAMP_DIST_MAX );
-}
-
-static int Lamp_setSpotSize( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->spotsize,
- EXPP_LAMP_SPOTSIZE_MIN,
- EXPP_LAMP_SPOTSIZE_MAX );
-}
-
-static int Lamp_setSpotBlend( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->spotblend,
- EXPP_LAMP_SPOTBLEND_MIN,
- EXPP_LAMP_SPOTBLEND_MAX );
-}
-
-static int Lamp_setClipStart( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->clipsta,
- EXPP_LAMP_CLIPSTART_MIN,
- EXPP_LAMP_CLIPSTART_MAX );
-}
-
-static int Lamp_setClipEnd( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->clipend,
- EXPP_LAMP_CLIPEND_MIN,
- EXPP_LAMP_CLIPEND_MAX );
-}
-
-static int Lamp_setBias( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->bias,
- EXPP_LAMP_BIAS_MIN,
- EXPP_LAMP_BIAS_MAX );
-}
-
-static int Lamp_setSoftness( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->soft,
- EXPP_LAMP_SOFTNESS_MIN,
- EXPP_LAMP_SOFTNESS_MAX );
-}
-
-static int Lamp_setHaloInt( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->haint,
- EXPP_LAMP_HALOINT_MIN,
- EXPP_LAMP_HALOINT_MAX );
-}
-
-static int Lamp_setQuad1( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->att1,
- EXPP_LAMP_QUAD1_MIN,
- EXPP_LAMP_QUAD1_MAX );
-}
-
-static int Lamp_setQuad2( BPy_Lamp * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->lamp->att2,
- EXPP_LAMP_QUAD2_MIN,
- EXPP_LAMP_QUAD2_MAX );
-}
-
-static PyObject *Lamp_getComponent( BPy_Lamp * self, void * closure )
-{
- switch ( (int)closure ) {
- case EXPP_LAMP_COMP_R:
- return PyFloat_FromDouble( self->lamp->r );
- case EXPP_LAMP_COMP_G:
- return PyFloat_FromDouble( self->lamp->g );
- case EXPP_LAMP_COMP_B:
- return PyFloat_FromDouble( self->lamp->b );
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unknown color component specified" );
- }
-}
-
-static int Lamp_setComponent( BPy_Lamp * self, PyObject * value,
- void * closure )
-{
- float color;
-
- if( !PyNumber_Check ( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument in [0.0,1.0]" );
-
- color = (float)PyFloat_AsDouble( value );
- color = EXPP_ClampFloat( color, EXPP_LAMP_COL_MIN, EXPP_LAMP_COL_MAX );
-
- switch ( (int)closure ) {
- case EXPP_LAMP_COMP_R:
- self->lamp->r = color;
- return 0;
- case EXPP_LAMP_COMP_G:
- self->lamp->g = color;
- return 0;
- case EXPP_LAMP_COMP_B:
- self->lamp->b = color;
- return 0;
- }
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "unknown color component specified" );
-}
-
-static int Lamp_setCol( BPy_Lamp * self, PyObject * args )
-{
- return rgbTuple_setCol( self->color, args );
-}
-
-/* lamp.addScriptLink */
-static PyObject *Lamp_addScriptLink( BPy_Lamp * self, PyObject * args )
-{
- Lamp *lamp = self->lamp;
- ScriptLink *slink = NULL;
-
- slink = &( lamp )->scriptlink;
-
- return EXPP_addScriptLink( slink, args, 0 );
-}
-
-/* lamp.clearScriptLinks */
-static PyObject *Lamp_clearScriptLinks( BPy_Lamp * self, PyObject * args )
-{
- Lamp *lamp = self->lamp;
- ScriptLink *slink = NULL;
-
- slink = &( lamp )->scriptlink;
-
- return EXPP_clearScriptLinks( slink, args );
-}
-
-/* mat.getScriptLinks */
-static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * value )
-{
- Lamp *lamp = self->lamp;
- ScriptLink *slink = NULL;
- PyObject *ret = NULL;
-
- slink = &( lamp )->scriptlink;
-
- ret = EXPP_getScriptLinks( slink, value, 0 );
-
- if( ret )
- return ret;
- else
- return NULL;
-}
-
-/*****************************************************************************/
-/* Function: Lamp_dealloc */
-/* Description: This is a callback function for the BPy_Lamp type. It is */
-/* the destructor function. */
-/*****************************************************************************/
-static void Lamp_dealloc( BPy_Lamp * self )
-{
- Py_DECREF( self->color );
- PyObject_DEL( self );
-}
-
-/*****************************************************************************/
-/* Function: Lamp_compare */
-/* Description: This is a callback function for the BPy_Lamp type. It */
-/* compares two Lamp_Type objects. Only the "==" and "!=" */
-/* comparisons are meaningful. Returns 0 for equality and -1 */
-/* if they don't point to the same Blender Lamp struct. */
-/* In Python it becomes 1 if they are equal, 0 otherwise. */
-/*****************************************************************************/
-static int Lamp_compare( BPy_Lamp * a, BPy_Lamp * b )
-{
- return ( a->lamp == b->lamp ) ? 0 : -1;
-}
-
-/*****************************************************************************/
-/* Function: Lamp_repr */
-/* Description: This is a callback function for the BPy_Lamp type. It */
-/* builds a meaninful string to represent lamp objects. */
-/*****************************************************************************/
-static PyObject *Lamp_repr( BPy_Lamp * self )
-{
- return PyString_FromFormat( "[Lamp \"%s\"]", self->lamp->id.name + 2 );
-}
-
-static PyObject *Lamp_getIpo( BPy_Lamp * self )
-{
- struct Ipo *ipo = self->lamp->ipo;
-
- if( !ipo )
- Py_RETURN_NONE;
-
- return Ipo_CreatePyObject( ipo );
-}
-
-/*
- * this should accept a Py_None argument and just delete the Ipo link
- * (as Lamp_clearIpo() does)
- */
-
-static int Lamp_setIpo( BPy_Lamp * self, PyObject * value )
-{
- return GenericLib_assignData(value, (void **) &self->lamp->ipo, 0, 1, ID_IP, ID_LA);
-}
-
-/*
- * Lamp_insertIpoKey()
- * inserts Lamp IPO key for RGB,ENERGY,SPOTSIZE,OFFSET,SIZE
- */
-
-static PyObject *Lamp_insertIpoKey( BPy_Lamp * self, PyObject * args )
-{
- int key = 0, map;
-
- if( !PyArg_ParseTuple( args, "i", &( key ) ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
-
- map = texchannel_to_adrcode(self->lamp->texact);
-
- if (key == IPOKEY_RGB ) {
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL, LA_COL_R, 0);
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_G, 0);
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_B, 0);
- }
- if (key == IPOKEY_ENERGY ) {
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_ENERGY, 0);
- }
- if (key == IPOKEY_SPOTSIZE ) {
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_SPOTSI, 0);
- }
- if (key == IPOKEY_OFFSET ) {
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_X, 0);
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Y, 0);
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Z, 0);
- }
- if (key == IPOKEY_SIZE ) {
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_X, 0);
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Y, 0);
- insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Z, 0);
- }
-
- allspace(REMAKEIPO, 0);
- EXPP_allqueue(REDRAWIPO, 0);
- EXPP_allqueue(REDRAWVIEW3D, 0);
- EXPP_allqueue(REDRAWACTION, 0);
- EXPP_allqueue(REDRAWNLA, 0);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Lamp_getModesConst( void )
-{
- return Py_BuildValue
- ( "{s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h}",
- "Shadows", EXPP_LAMP_MODE_SHADOWS, "Halo",
- EXPP_LAMP_MODE_HALO, "Layer", EXPP_LAMP_MODE_LAYER,
- "Quad", EXPP_LAMP_MODE_QUAD, "Negative",
- EXPP_LAMP_MODE_NEGATIVE, "OnlyShadow",
- EXPP_LAMP_MODE_ONLYSHADOW, "Sphere",
- EXPP_LAMP_MODE_SPHERE, "Square",
- EXPP_LAMP_MODE_SQUARE, "NoDiffuse",
- EXPP_LAMP_MODE_NODIFFUSE, "NoSpecular",
- EXPP_LAMP_MODE_NOSPECULAR, "RayShadow",
- EXPP_LAMP_MODE_SHAD_RAY);
-}
-
-static PyObject *Lamp_getTypesConst( void )
-{
- return Py_BuildValue( "{s:h,s:h,s:h,s:h,s:h,s:h}",
- "Lamp", EXPP_LAMP_TYPE_LAMP,
- "Sun", EXPP_LAMP_TYPE_SUN,
- "Spot", EXPP_LAMP_TYPE_SPOT,
- "Hemi", EXPP_LAMP_TYPE_HEMI,
- "Area", EXPP_LAMP_TYPE_AREA,
- "Photon", EXPP_LAMP_TYPE_YF_PHOTON );
-}
-
-/* #####DEPRECATED###### */
-
-static PyObject *Lamp_oldsetSamples( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setSamples );
-}
-
-static PyObject *Lamp_oldsetRaySamplesX( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setRaySamplesX );
-}
-
-static PyObject *Lamp_oldsetRaySamplesY( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setRaySamplesY );
-}
-
-static PyObject *Lamp_oldsetAreaSizeX( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setAreaSizeX );
-}
-
-static PyObject *Lamp_oldsetAreaSizeY( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setAreaSizeY );
-}
-
-static PyObject *Lamp_oldsetBufferSize( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setBufferSize );
-}
-
-static PyObject *Lamp_oldsetHaloStep( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setHaloStep );
-}
-
-static PyObject *Lamp_oldsetEnergy( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setEnergy );
-}
-
-static PyObject *Lamp_oldsetDist( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setDist );
-}
-
-static PyObject *Lamp_oldsetSpotSize( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setSpotSize );
-}
-
-static PyObject *Lamp_oldsetSpotBlend( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setSpotBlend );
-}
-
-static PyObject *Lamp_oldsetClipStart( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setClipStart );
-}
-
-static PyObject *Lamp_oldsetClipEnd( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setClipEnd );
-}
-
-static PyObject *Lamp_oldsetBias( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setBias );
-}
-
-static PyObject *Lamp_oldsetSoftness( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setSoftness );
-}
-
-static PyObject *Lamp_oldsetHaloInt( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setHaloInt );
-}
-
-static PyObject *Lamp_oldsetQuad1( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setQuad1 );
-}
-
-static PyObject *Lamp_oldsetQuad2( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setQuad2 );
-}
-
-static PyObject *Lamp_oldsetIpo( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setIpo );
-}
-
-static PyObject *Lamp_oldsetCol( BPy_Lamp * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setCol );
-}
-
-/*
- * the "not-well-behaved" methods which require more processing than
- * just the simple wrapper
- */
-
-/*
- * clearIpo() returns True/False depending on whether lamp has an Ipo
- */
-
-static PyObject *Lamp_clearIpo( BPy_Lamp * self )
-{
- /* if Ipo defined, delete it and return true */
-
- if( self->lamp->ipo ) {
- PyObject *value = Py_BuildValue( "(O)", Py_None );
- EXPP_setterWrapper ( (void *)self, value, (setter)Lamp_setIpo );
- Py_DECREF ( value );
- return EXPP_incr_ret_True();
- }
- return EXPP_incr_ret_False(); /* no ipo found */
-}
-
-/*
- * setType() accepts a string while mode setter takes an integer
- */
-
-static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * value )
-{
- char *type = PyString_AsString(value);
- PyObject *arg, *error;
-
- /* parse string argument */
-
- if( !value )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" ) );
-
- /* check for valid arguments, set type accordingly */
-
- if( !strcmp( type, "Lamp" ) )
- self->lamp->type = ( short ) EXPP_LAMP_TYPE_LAMP;
- else if( !strcmp( type, "Sun" ) )
- self->lamp->type = ( short ) EXPP_LAMP_TYPE_SUN;
- else if( !strcmp( type, "Spot" ) )
- self->lamp->type = ( short ) EXPP_LAMP_TYPE_SPOT;
- else if( !strcmp( type, "Hemi" ) )
- self->lamp->type = ( short ) EXPP_LAMP_TYPE_HEMI;
- else if( !strcmp( type, "Area" ) )
- self->lamp->type = ( short ) EXPP_LAMP_TYPE_AREA;
- else if( !strcmp( type, "Photon" ) )
- self->lamp->type = ( short ) EXPP_LAMP_TYPE_YF_PHOTON;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown lamp type" );
-
- /* build tuple, call wrapper */
-
- arg = Py_BuildValue( "(i)", type );
- error = EXPP_setterWrapper ( (void *)self, arg, (setter)Lamp_setType );
- Py_DECREF ( arg );
- return error;
-}
-
-/*
- * setMode() accepts up to ten strings while mode setter takes an integer
- */
-
-static PyObject *Lamp_oldsetMode( BPy_Lamp * self, PyObject * args )
-{
- short i, flag = 0;
- PyObject *error, *value;
- char *name;
-
- /* check that we're passed a tuple of no more than 10 args*/
-
- if ( !PyTuple_Check( args ) || PyTuple_Size( args ) > 10 )
- return EXPP_ReturnPyObjError ( PyExc_AttributeError,
- "expected up to 10 string arguments" );
-
- /* check each argument for type, find its value */
-
- for ( i = (short)PyTuple_Size( args ); i-- ; ) {
- name = PyString_AsString ( PyTuple_GET_ITEM( args, i ) );
- if( !name )
- return EXPP_ReturnPyObjError ( PyExc_AttributeError,
- "expected string argument" );
-
- if( !strcmp( name, "Shadows" ) )
- flag |= ( short ) EXPP_LAMP_MODE_SHADOWS;
- else if( !strcmp( name, "Halo" ) )
- flag |= ( short ) EXPP_LAMP_MODE_HALO;
- else if( !strcmp( name, "Layer" ) )
- flag |= ( short ) EXPP_LAMP_MODE_LAYER;
- else if( !strcmp( name, "Quad" ) )
- flag |= ( short ) EXPP_LAMP_MODE_QUAD;
- else if( !strcmp( name, "Negative" ) )
- flag |= ( short ) EXPP_LAMP_MODE_NEGATIVE;
- else if( !strcmp( name, "OnlyShadow" ) )
- flag |= ( short ) EXPP_LAMP_MODE_ONLYSHADOW;
- else if( !strcmp( name, "Sphere" ) )
- flag |= ( short ) EXPP_LAMP_MODE_SPHERE;
- else if( !strcmp( name, "Square" ) )
- flag |= ( short ) EXPP_LAMP_MODE_SQUARE;
- else if( !strcmp( name, "NoDiffuse" ) )
- flag |= ( short ) EXPP_LAMP_MODE_NODIFFUSE;
- else if( !strcmp( name, "NoSpecular" ) )
- flag |= ( short ) EXPP_LAMP_MODE_NOSPECULAR;
- else if( !strcmp( name, "RayShadow" ) )
- flag |= ( short ) EXPP_LAMP_MODE_SHAD_RAY;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown lamp flag argument" );
- }
-
- /* build tuple, call wrapper */
-
- value = Py_BuildValue( "(i)", flag );
- error = EXPP_setterWrapper ( (void *)self, value, (setter)Lamp_setMode );
- Py_DECREF ( value );
- return error;
-}
-
diff --git a/source/blender/python/api2_2x/Lamp.h b/source/blender/python/api2_2x/Lamp.h
deleted file mode 100644
index 01c80e0006b..00000000000
--- a/source/blender/python/api2_2x/Lamp.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Lattice.c b/source/blender/python/api2_2x/Lattice.c
deleted file mode 100644
index 6a9f3891e52..00000000000
--- a/source/blender/python/api2_2x/Lattice.c
+++ /dev/null
@@ -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
-};
diff --git a/source/blender/python/api2_2x/Lattice.h b/source/blender/python/api2_2x/Lattice.h
deleted file mode 100644
index dd141f1b8dd..00000000000
--- a/source/blender/python/api2_2x/Lattice.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Library.c b/source/blender/python/api2_2x/Library.c
deleted file mode 100644
index 412daf24bd2..00000000000
--- a/source/blender/python/api2_2x/Library.c
+++ /dev/null
@@ -1,1192 +0,0 @@
-/**
- * $Id: Library.c 10943 2007-06-16 12:24:41Z campbellbarton $
- *
- * Blender.Library BPython module implementation.
- * This submodule has functions to append data from .blend files.
- *
- * ***** 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, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-/************************************************************/
-/* Original library module code */
-/************************************************************/
-
-#include <Python.h>
-
-#include "DNA_curve_types.h"
-#include "DNA_object_types.h"
-#include "DNA_space_types.h" /* for line linked */
-#include "BKE_library.h" /* for all_local */
-#include "BKE_font.h" /* for text_to_curve */
-#include "BKE_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BLI_blenlib.h"
-#include "BLO_readfile.h"
-#include "BLI_linklist.h"
-#include "MEM_guardedalloc.h"
-#include "gen_utils.h"
-
-/**
- * Global variables.
- */
-static BlendHandle *bpy_openlib = NULL; /* ptr to the open .blend file */
-static char *bpy_openlibname = NULL; /* its pathname */
-static int bpy_relative= 0;
-
-/**
- * Function prototypes for the Library submodule.
- */
-static PyObject *M_Library_Open( PyObject * self, PyObject * args );
-static PyObject *M_Library_Close( PyObject * self );
-static PyObject *M_Library_GetName( PyObject * self );
-static PyObject *M_Library_Update( PyObject * self );
-static PyObject *M_Library_Datablocks( PyObject * self, PyObject * value );
-static PyObject *oldM_Library_Load( PyObject * self, PyObject * args );
-static PyObject *M_Library_LinkableGroups( PyObject * self );
-static PyObject *M_Library_LinkedLibs( PyObject * self );
-
-PyObject *Library_Init( void );
-void EXPP_Library_Close( void );
-
-/**
- * Module doc strings.
- */
-static char M_Library_doc[] = "The Blender.Library submodule:\n\n\
-This module gives access to .blend files, using them as libraries of\n\
-data that can be loaded into the current scene in Blender.";
-
-static char Library_Open_doc[] =
- "(filename) - Open the given .blend file for access to its objects.\n\
-If another library file is still open, it's closed automatically.";
-
-static char Library_Close_doc[] =
- "() - Close the currently open library file, if any.";
-
-static char Library_GetName_doc[] =
- "() - Get the filename of the currently open library file, if any.";
-
-static char Library_Datablocks_doc[] =
- "(datablock) - List all datablocks of the given type in the currently\n\
-open library file.\n\
-(datablock) - datablock name as a string: Object, Mesh, etc.";
-
-static char Library_Load_doc[] =
- "(name, datablock [,update = 1]) - Append object 'name' of type 'datablock'\n\
-from the open library file to the current scene.\n\
-(name) - (str) the name of the object.\n\
-(datablock) - (str) the datablock of the object.\n\
-(update = 1) - (int) if non-zero, all display lists are recalculated and the\n\
-links are updated. This is slow, set it to zero if you have more than one\n\
-object to load, then call Library.Update() after loading them all.";
-
-static char Library_Update_doc[] =
- "() - Update the current scene, linking all loaded library objects and\n\
-remaking all display lists. This is slow, call it only once after loading\n\
-all objects (load each of them with update = 0:\n\
-Library.Load(name, datablock, 0), or the update will be automatic, repeated\n\
-for each loaded object.";
-
-static char Library_LinkableGroups_doc[] =
- "() - Get all linkable groups from the open .blend library file.";
-
-static char Library_LinkedLibs_doc[] =
- "() - Get all libs used in the the open .blend file.";
-
-/**
- * Python method structure definition for Blender.Library submodule.
- */
-struct PyMethodDef oldM_Library_methods[] = {
- {"Open", M_Library_Open, METH_O, Library_Open_doc},
- {"Close", ( PyCFunction ) M_Library_Close, METH_NOARGS,
- Library_Close_doc},
- {"GetName", ( PyCFunction ) M_Library_GetName, METH_NOARGS,
- Library_GetName_doc},
- {"Update", ( PyCFunction ) M_Library_Update, METH_NOARGS,
- Library_Update_doc},
- {"Datablocks", M_Library_Datablocks, METH_O,
- Library_Datablocks_doc},
- {"Load", oldM_Library_Load, METH_VARARGS, Library_Load_doc},
- {"LinkableGroups", ( PyCFunction ) M_Library_LinkableGroups,
- METH_NOARGS, Library_LinkableGroups_doc},
- {"LinkedLibs", ( PyCFunction ) M_Library_LinkedLibs,
- METH_NOARGS, Library_LinkedLibs_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/* Submodule Python functions: */
-
-/**
- * Open a new .blend file.
- * Only one can be open at a time, so this function also closes
- * the previously opened file, if any.
- */
-static PyObject *M_Library_Open( PyObject * self, PyObject * value )
-{
- char *fname = PyString_AsString(value);
- char filename[FILE_MAXDIR+FILE_MAXFILE];
- char fname1[FILE_MAXDIR+FILE_MAXFILE];
-
- int len = 0;
-
- bpy_relative= 0; /* assume non relative each time we load */
-
- if( !fname ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a .blend filename" );
- }
-
- if( bpy_openlib ) {
- M_Library_Close( self );
- Py_DECREF( Py_None ); /* incref'ed by above function */
- }
-
- /* copy the name to make it absolute so BLO_blendhandle_from_file doesn't complain */
- BLI_strncpy(fname1, fname, sizeof(fname1));
- BLI_convertstringcode(fname1, G.sce, 0); /* make absolute */
-
- /* G.sce = last file loaded, save for UI and restore after opening file */
- BLI_strncpy(filename, G.sce, sizeof(filename));
- bpy_openlib = BLO_blendhandle_from_file( fname1 );
- BLI_strncpy(G.sce, filename, sizeof(filename));
-
- if( !bpy_openlib )
- return EXPP_ReturnPyObjError( PyExc_IOError, "file not found" );
-
- /* "//someblend.blend" enables relative paths */
- if (sizeof(fname) > 2 && fname[0] == '/' && fname[1] == '/')
- bpy_relative= 1; /* global that makes the library relative on loading */
-
- len = strlen( fname1 ) + 1; /* +1 for terminating '\0' */
-
- bpy_openlibname = MEM_mallocN( len, "bpy_openlibname" );
-
- if( bpy_openlibname )
- PyOS_snprintf( bpy_openlibname, len, "%s", fname1 );
-
- Py_RETURN_TRUE;
-}
-
-/**
- * Close the current .blend file, if any.
- */
-static PyObject *M_Library_Close( PyObject * self )
-{
- if( bpy_openlib ) {
- BLO_blendhandle_close( bpy_openlib );
- bpy_openlib = NULL;
- }
-
- if( bpy_openlibname ) {
- MEM_freeN( bpy_openlibname );
- bpy_openlibname = NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-/**
- * helper function for 'atexit' clean-ups, used by BPY_end_python,
- * declared in EXPP_interface.h.
- */
-void EXPP_Library_Close( void )
-{
- if( bpy_openlib ) {
- BLO_blendhandle_close( bpy_openlib );
- bpy_openlib = NULL;
- }
-
- if( bpy_openlibname ) {
- MEM_freeN( bpy_openlibname );
- bpy_openlibname = NULL;
- }
-}
-
-/**
- * Get the filename of the currently open library file, if any.
- */
-static PyObject *M_Library_GetName( PyObject * self )
-{
- if( bpy_openlib && bpy_openlibname )
- return Py_BuildValue( "s", bpy_openlibname );
-
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-/**
- * Return a list with all items of a given datablock type
- * (like 'Object', 'Mesh', etc.) in the open library file.
- */
-static PyObject *M_Library_Datablocks( PyObject * self, PyObject * value )
-{
- char *name = PyString_AsString(value);
- int blocktype = 0;
- LinkNode *l = NULL, *names = NULL;
- PyObject *list = NULL;
-
- if( !bpy_openlib ) {
- return EXPP_ReturnPyObjError( PyExc_IOError,
- "no library file: open one first with Blender.Lib_Open(filename)" );
- }
-
- if( !name ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string (datablock type) as argument." );
- }
-
- blocktype = ( int ) BLO_idcode_from_name( name );
-
- if( !blocktype ) {
- return EXPP_ReturnPyObjError( PyExc_NameError,
- "no such Blender datablock type" );
- }
-
- names = BLO_blendhandle_get_datablock_names( bpy_openlib, blocktype );
-
- if( names ) {
- int counter = 0;
- list = PyList_New( BLI_linklist_length( names ) );
- for( l = names; l; l = l->next ) {
- PyList_SET_ITEM( list, counter,
- PyString_FromString( ( char * ) l->link ) );
- counter++;
- }
- BLI_linklist_free( names, free ); /* free linklist *and* each node's data */
- return list;
- }
-
- Py_RETURN_NONE;
-}
-
-/**
- * Return a list with the names of all linkable groups in the
- * open library file.
- */
-static PyObject *M_Library_LinkableGroups( PyObject * self )
-{
- LinkNode *l = NULL, *names = NULL;
- PyObject *list = NULL;
-
- if( !bpy_openlib ) {
- return EXPP_ReturnPyObjError( PyExc_IOError,
- "no library file: open one first with Blender.Lib_Open(filename)" );
- }
-
- names = BLO_blendhandle_get_linkable_groups( bpy_openlib );
- list = PyList_New( BLI_linklist_length( names ) );
-
- if( names ) {
- int counter = 0;
-
- for( l = names; l; l = l->next ) {
- PyList_SET_ITEM( list, counter, PyString_FromString( ( char * ) l->link ) );
- counter++;
- }
- BLI_linklist_free( names, free ); /* free linklist *and* each node's data */
- return list;
- }
- return list;
-}
-
-/**
- * Return a list with the names of all externally linked libs used in the current Blend file
- */
-static PyObject *M_Library_LinkedLibs( PyObject * self )
-{
- int counter = 0;
- Library *li;
- PyObject *list;
-
- list = PyList_New( BLI_countlist( &( G.main->library ) ) );
- for (li= G.main->library.first; li; li= li->id.next) {
- PyList_SET_ITEM( list, counter, PyString_FromString( li->name ));
- counter++;
- }
- return list;
-}
-
-/**
- * Load (append) a given datablock of a given datablock type
- * to the current scene.
- */
-static PyObject *oldM_Library_Load( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- char *base = NULL;
- int update = 1;
- int blocktype = 0;
- int linked = 0;
-
- if( !bpy_openlib ) {
- return EXPP_ReturnPyObjError( PyExc_IOError,
- "no library file: you need to open one, first." );
- }
-
- if( !PyArg_ParseTuple( args, "ss|ii", &name, &base, &update, &linked ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected two strings as arguments." );
- }
-
- blocktype = ( int ) BLO_idcode_from_name( base );
-
- if( !blocktype )
- return EXPP_ReturnPyObjError( PyExc_NameError,
- "no such Blender datablock type" );
-
- if (linked)
- BLO_script_library_append( bpy_openlib, bpy_openlibname, name, blocktype, FILE_LINK, G.scene);
- else
- BLO_script_library_append( bpy_openlib, bpy_openlibname, name, blocktype, 0, G.scene);
-
- if( update ) {
- M_Library_Update( self );
- Py_DECREF( Py_None ); /* incref'ed by above function */
- }
-
- if( bpy_relative ) {
- /* and now find the latest append lib file */
- Library *lib = G.main->library.first;
- while( lib ) {
- if( strcmp( bpy_openlibname, lib->name ) == 0 ) {
-
- /* use the full path, this could have been read by other library even */
- BLI_strncpy(lib->name, lib->filename, sizeof(lib->name));
-
- /* uses current .blend file as reference */
- BLI_makestringcode(G.sce, lib->name);
- break;
- }
- lib = lib->id.next;
- }
-
- }
-
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-/**
- * Update all links and remake displists.
- */
-static PyObject *M_Library_Update( PyObject * self )
-{ /* code adapted from do_library_append in src/filesel.c: */
- Library *lib = NULL;
-
- /* Displist code that was here is obsolete... depending on what
- * this function is supposed to do (it should technically be unnecessary)
- * can be replaced with depgraph calls - zr
- */
-
- if( bpy_openlibname ) {
- strcpy( G.lib, bpy_openlibname );
-
- /* and now find the latest append lib file */
- lib = G.main->library.first;
- while( lib ) {
- if( strcmp( bpy_openlibname, lib->name ) == 0 )
- break;
- lib = lib->id.next;
- }
- all_local( lib, 0 );
- }
-
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-/**
- * Initialize the Blender.Library submodule.
- * Called by Blender_Init in Blender.c .
- * @return the registered submodule.
- */
-PyObject *oldLibrary_Init( void )
-{
- PyObject *submod;
-
- submod = Py_InitModule3( "Blender.Library", oldM_Library_methods,
- M_Library_doc );
-
- return submod;
-}
-
-/************************************************************/
-/* New library (LibData) module code */
-/************************************************************/
-
-#include "Library.h"
-
-/* if this module supercedes the old library module, include these instead */
-#if 0
-#include "BLI_blenlib.h"
-#include "MEM_guardedalloc.h"
-
-#include "DNA_curve_types.h"
-#include "DNA_object_types.h"
-#include "DNA_space_types.h" /* for line linked */
-#include "BKE_library.h" /* for all_local */
-#include "BKE_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BLO_readfile.h"
-#include "BLI_linklist.h"
-
-#include "Object.h"
-#include "gen_utils.h"
-#endif
-
-#include "gen_library.h"
-
-/* Helper function */
-
-/*
- * Try to open a library, set Python exceptions as necessary if not
- * successful. On success, return a valid handle; othewise return NULL.
- */
-
-static BlendHandle *open_library( char *filename, char *longFilename )
-{
- char globalFilename[FILE_MAX];
- BlendHandle *openlib = NULL;
-
- /* get complete file name if necessary */
- BLI_strncpy( longFilename, filename, FILE_MAX );
- BLI_convertstringcode( longFilename, G.sce, 0 );
-
- /* throw exceptions for wrong file type, cyclic reference */
- if( !BLO_has_bfile_extension(longFilename) ) {
- PyErr_SetString( PyExc_ValueError, "file not a library" );
- return NULL;
- }
- if( BLI_streq(G.main->name, longFilename) ) {
- PyErr_SetString( PyExc_ValueError,
- "cannot use current file as library" );
- return NULL;
- }
-
- /* G.sce = last file loaded, save for UI and restore after opening file */
- BLI_strncpy(globalFilename, G.sce, sizeof(globalFilename));
- openlib = BLO_blendhandle_from_file( longFilename );
- BLI_strncpy(G.sce, globalFilename, sizeof(globalFilename));
-
- /* if failed, set that exception code too */
- if( !openlib )
- PyErr_SetString( PyExc_IOError, "library not found" );
-
- return openlib;
-}
-
-/*
- * Create a specific type of LibraryData object. These are used for
- * .append() and .link() access, for iterators, and (for Blender Objects)
- * for defining "pseudo objects" for scene linking.
- */
-
-static PyObject *CreatePyObject_LibData( int idtype, int kind,
- void *name, void *iter, char *filename )
-{
- BPy_LibraryData *seq = PyObject_NEW( BPy_LibraryData, &LibraryData_Type);
- seq->iter = iter; /* the name list (for iterators) */
- seq->type = idtype; /* the Blender ID type */
- seq->kind = kind; /* used by Blender Objects */
- seq->name = name; /* object name, iterator name list, or NULL */
- /* save the library name */
- BLI_strncpy( seq->filename, filename, strlen(filename)+1 );
- return (PyObject *)seq;
-}
-
-/*
- * Link/append data to the current .blend file, or create a pseudo object
- * which can be linked/appended to a scene.
- */
-
-static PyObject *lib_link_or_append( BPy_LibraryData *self, PyObject * value,
- int mode )
-{
- char *name = PyString_AsString(value);
-
- /* get the name of the data used wants to append */
- if( !name )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string" );
-
- /*
- * For everything except objects, just add to Blender's DB. For objects,
- * create an APPEND or LINK "pseudo object" for the Scene module.
- */
- if( self->type != ID_OB )
- return LibraryData_importLibData( self, name, 0, NULL );
- else {
- /*
- * If this is already a pseudo object, throw an exception: re-linking
- * or re-appending is not allowed
- */
- if( self->kind != OTHER )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "object has already been marked for append or link" );
-
- /* otherwise, create a pseudo object ready for appending or linking */
-
- return CreatePyObject_LibData( ID_OB, mode,
- BLI_strdupn( name, strlen( name ) ), NULL, self->filename );
- }
-}
-
-/*
- * Perform the actual link or append operation. This procedure is also
- * called externally from the Scene module using a "pseudo Object" so we
- * can be sure objects get linked to a scene.
- */
-
-PyObject *LibraryData_importLibData( BPy_LibraryData *self, char *name,
- int mode, Scene *scene )
-{
- char longFilename[FILE_MAX];
- BlendHandle *openlib;
- Library *lib;
- LinkNode *names, *ptr;
- ID *id;
- ListBase *lb;
- char newName[32];
-
- /* try to open the library */
- openlib = open_library( self->filename, longFilename );
- if( !openlib )
- return NULL;
-
- /* find all datablocks for the specified type */
- names = BLO_blendhandle_get_datablock_names ( openlib, self->type );
-
- /* now check for a match to the user-specified name */
- for( ptr = names; ptr; ptr = ptr->next )
- if( strcmp( ptr->link, name ) == 0 ) break;
- BLI_linklist_free( names, free );
-
- /* if no match, throw exception */
- if( !ptr ) {
- BLO_blendhandle_close( openlib );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "library does not contain specified item" );
- }
-
- /*
- * Figure out what the datablock will be named after it's imported. If
- * it's a link, nothing to do. If it's an append, find what it might
- * be renamed to.
- */
-
- if( mode != FILE_LINK ) {
- flag_all_listbases_ids(LIB_APPEND_TAG, 1);
-
- /* see what new block will be called */
- strncpy( newName, name, strlen(name)+1 );
- check_for_dupid( wich_libbase(G.main, self->type), NULL, newName );
- }
-
- /* import from the libary */
- BLO_script_library_append( openlib, longFilename, name, self->type, mode,
- scene );
-
- /*
- * locate the library. If this is an append, make the data local. If it
- * is link, we need the library for later
- */
- for( lib = G.main->library.first; lib; lib = lib->id.next )
- if( strcmp( longFilename, lib->name ) == 0 ) {
- if( mode != FILE_LINK ) {
- all_local( lib, 1 );
- /* important we unset, otherwise these object wont
- * link into other scenes from this blend file */
- flag_all_listbases_ids(LIB_APPEND_TAG, 0);
- }
- break;
- }
-
- /* done with library; close it */
- BLO_blendhandle_close( openlib );
-
- /* this should not happen, but just in case */
- if( !lib )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not library" );
-
- /* find the base for this type */
- lb = wich_libbase( G.main, self->type );
-
- /*
- * Check for linked data matching the name first. Even if we are trying
- * to append, if the data has already been linked we need to return it
- * (it won't be appended from the library).
- */
- for( id = lb->first; id; id = id->next ) {
- if( id->lib == lib && id->name[2]==name[0] &&
- strcmp(id->name+2, name)==0 )
- return GetPyObjectFromID( id );
- }
-
- /*
- * If we didn't find it, and we're appending, then try searching for the
- * new datablock, possibly under a new name.
- */
- if( mode != FILE_LINK )
- for( id = lb->first; id; id = id->next ) {
- if( id->lib == NULL && id->name[2]==newName[0] &&
- strcmp(id->name+2, newName)==0 )
- return GetPyObjectFromID( id );
- }
-
- /* if we get here, something's really wrong */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not find data after reading from library" );
-}
-
-/************************************************************
- * Python LibraryData_Type getseters
- ************************************************************/
-
-/* .append(): make a local copy of the library's data (except for objects) */
-
-static PyObject *LibraryData_getAppend( BPy_LibraryData *self, PyObject * value)
-{
- return lib_link_or_append( self, value, OBJECT_IS_APPEND );
-}
-
-/* .link(): make a link to the library's data (except for objects) */
-
-static PyObject *LibraryData_getLink( BPy_LibraryData *self, PyObject * value)
-{
- return lib_link_or_append( self, value, OBJECT_IS_LINK );
-}
-
-/************************************************************************
- * Python LibraryData_Type iterator
- ************************************************************************/
-
-/* Create and initialize the interator indices */
-
-static PyObject *LibraryData_getIter( BPy_LibraryData * self )
-{
- char longFilename[FILE_MAX];
- BlendHandle *openlib;
- LinkNode *names;
-
- /* try to open library */
- openlib = open_library( self->filename, longFilename );
-
- /* if failed, return exception */
- if( !openlib )
- return NULL;
-
- /* find all datablocks for the specified type */
- names = BLO_blendhandle_get_datablock_names ( openlib, self->type );
-
- /* close library*/
- BLO_blendhandle_close( openlib );
-
- /* build an iterator object for the name list */
- return CreatePyObject_LibData( self->type, OTHER, names,
- names, self->filename );
-}
-
-/* Return next name. */
-
-static PyObject *LibraryData_nextIter( BPy_LibraryData * self )
-{
- LinkNode *ptr = (LinkNode *)self->iter;
- PyObject *ob;
-
- /* if at the end of list, clean up */
- if( !ptr ) {
- /* If name list is still allocated, free storage. This check is
- * necessary since iter.next() can technically be called repeatedly */
- if( self->name ) {
- BLI_linklist_free( (LinkNode *)self->name, free );
- self->name = NULL;
- }
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- /* otherwise, return the next name in the list */
- ob = PyString_FromString( ptr->link );
- ptr = ptr->next;
- self->iter = ptr;
- return ob;
-}
-
-/************************************************************************
- * Python LibraryData_type methods structure
- ************************************************************************/
-
-static struct PyMethodDef BPy_LibraryData_methods[] = {
- {"append", (PyCFunction)LibraryData_getAppend, METH_O,
- "(str) - create new data from library"},
- {"link", (PyCFunction)LibraryData_getLink, METH_O,
- "(str) - link data from library"},
- {NULL, NULL, 0, NULL}
-};
-
-/* Deallocate object and its data */
-
-static void LibraryData_dealloc( BPy_LibraryData * self )
-{
- if( self->name )
- MEM_freeN( self->name );
-
- PyObject_DEL( self );
-}
-
-/* Display representation of what Library Data is wrapping */
-
-static PyObject *LibraryData_repr( BPy_LibraryData * self )
-{
- char *linkstate = "";
- char *str;
-
- switch (self->type) {
- case ID_OB:
- /* objects can be lib data or pseudo objects */
- switch( self->kind ) {
- case OBJECT_IS_APPEND :
- linkstate = ", appended";
- break;
- case OBJECT_IS_LINK :
- linkstate = ", linked";
- break;
- default:
- break;
- }
- str = "Object";
- break;
- case ID_SCE:
- str = "Scene";
- break;
- case ID_ME:
- str = "Mesh";
- break;
- case ID_CU:
- str = "Curve";
- break;
- case ID_MB:
- str = "Metaball";
- break;
- case ID_MA:
- str = "Material";
- break;
- case ID_TE:
- str = "Texture";
- break;
- case ID_IM:
- str = "Image";
- break;
- case ID_LT:
- str = "Lattice";
- break;
- case ID_LA:
- str = "Lamp";
- break;
- case ID_CA:
- str = "Camera";
- break;
- case ID_IP:
- str = "Ipo";
- break;
- case ID_WO:
- str = "World";
- break;
- case ID_VF:
- str = "Font";
- break;
- case ID_TXT:
- str = "Text";
- break;
- case ID_SO:
- str = "Sound";
- break;
- case ID_GR:
- str = "Group";
- break;
- case ID_AR:
- str = "Armature";
- break;
- case ID_AC:
- str = "Action";
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unsupported ID type" );
- }
-
- return PyString_FromFormat( "[Library Data (%s%s)]", str, linkstate );
-}
-
-PyTypeObject LibraryData_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender LibData", /* char *tp_name; */
- sizeof( BPy_LibraryData ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) LibraryData_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) NULL, /* cmpfunc tp_compare; */
- ( reprfunc ) LibraryData_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 */
- (getiterfunc)LibraryData_getIter, /* getiterfunc tp_iter; */
- (iternextfunc)LibraryData_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_LibraryData_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
-};
-
-/*
- * Create a LibraryData object for a specific type of Blender Group (ID_OB,
- * ID_MA, etc). These can then be used to link or append the data.
- */
-
-static PyObject *LibraryData_CreatePyObject( BPy_Library *self, void *mode )
-{
- return CreatePyObject_LibData( (int)mode, OTHER, NULL, NULL,
- self->filename );
-}
-
-/************************************************************
- * Python Library_Type getseters
- ************************************************************/
-
-/*
- * Return the library's filename.
- */
-
-static PyObject *Library_getFilename( BPy_Library * self )
-{
- return PyString_FromString( self->filename );
-}
-
-/*
- * Set/change the library's filename.
- */
-
-static int Library_setFilename( BPy_Library * self, PyObject * args )
-{
- char *filename = PyString_AsString( args );
- if( !filename )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected a string" );
-
- BLI_strncpy( self->filename, filename, sizeof(self->filename) );
- return 0;
-}
-
-/************************************************************************
- * Python Library_type attributes get/set structure
- ************************************************************************/
-
-static PyGetSetDef Library_getseters[] = {
- {"filename",
- (getter)Library_getFilename, (setter)Library_setFilename,
- "library filename",
- NULL},
- {"objects",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "objects from the library",
- (void *)ID_OB},
- {"scenes",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "scenes from the library",
- (void *)ID_SCE},
- {"meshes",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "meshes from the library",
- (void *)ID_ME},
- {"curves",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "curves from the library",
- (void *)ID_CU},
- {"metaballs",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "metaballs from the library",
- (void *)ID_MB},
- {"lattices",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "lattices from the library",
- (void *)ID_LT},
- {"lamps",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "lamps from the library",
- (void *)ID_LA},
- {"cameras",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "cameras from the library",
- (void *)ID_CA},
- {"materials",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "objects from the library",
- (void *)ID_MA},
- {"textures",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "textures from the library",
- (void *)ID_TE},
- {"images",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "images from the library",
- (void *)ID_IM},
- {"ipos",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "ipos from the library",
- (void *)ID_IP},
- {"worlds",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "worlds from the library",
- (void *)ID_WO},
- {"fonts",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "fonts from the library",
- (void *)ID_VF},
- {"texts",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "texts from the library",
- (void *)ID_TXT},
- {"groups",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "groups from the library",
- (void *)ID_GR},
- {"sounds",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "sounds from the library",
- (void *)ID_SO},
- {"actions",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "actions from the library",
- (void *)ID_AC},
- {"armatures",
- (getter)LibraryData_CreatePyObject, (setter)NULL,
- "armatures from the library",
- (void *)ID_AR},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*
- * Define a new library and create a library object. We don't actually test
- * if the library is valid here since we have to do it when the file is
- * actually accessed later.
- */
-
-static PyObject *M_Library_Load(PyObject *self, PyObject * value)
-{
- char *filename = PyString_AsString(value);
- BPy_Library *lib;
-
- if( !filename )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string" );
-
- /* try to create a new object */
- lib = (BPy_Library *)PyObject_NEW( BPy_Library, &Library_Type );
- if( !lib )
- return NULL;
-
- /* assign the library filename for future use, then return */
- BLI_strncpy( lib->filename, filename, sizeof(lib->filename) );
-
- return (PyObject *)lib;
-}
-
-static struct PyMethodDef M_Library_methods[] = {
- {"load", (PyCFunction)M_Library_Load, METH_O,
- "(string) - declare a .blend file for use as a library"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python Library_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Library_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Library", /* char *tp_name; */
- sizeof( BPy_Library ), /* 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 ) NULL, /* cmpfunc tp_compare; */
- ( reprfunc ) NULL, /* 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 ***/
- NULL, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- Library_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
-};
-
-/*
- * Library module initialization
- */
-
-static char M_newLibrary_doc[] = "The Blender.lib submodule";
-
-PyObject *Library_Init( void )
-{
- PyObject *submodule;
-
- if( PyType_Ready( &Library_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &LibraryData_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.lib", M_Library_methods,
- M_newLibrary_doc );
- return submodule;
-}
diff --git a/source/blender/python/api2_2x/Library.h b/source/blender/python/api2_2x/Library.h
deleted file mode 100644
index 1ddc138ea57..00000000000
--- a/source/blender/python/api2_2x/Library.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/MTex.c b/source/blender/python/api2_2x/MTex.c
deleted file mode 100644
index 61d809411a1..00000000000
--- a/source/blender/python/api2_2x/MTex.c
+++ /dev/null
@@ -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;
-}
diff --git a/source/blender/python/api2_2x/MTex.h b/source/blender/python/api2_2x/MTex.h
deleted file mode 100644
index 36cfa1c477a..00000000000
--- a/source/blender/python/api2_2x/MTex.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Makefile b/source/blender/python/api2_2x/Makefile
deleted file mode 100644
index 4ea06a324f5..00000000000
--- a/source/blender/python/api2_2x/Makefile
+++ /dev/null
@@ -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
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
deleted file mode 100644
index 8ec1a8fab06..00000000000
--- a/source/blender/python/api2_2x/Material.c
+++ /dev/null
@@ -1,3048 +0,0 @@
-/*
- * $Id: Material.c 12078 2007-09-18 06:41:29Z 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, Michel Selten, Alex Mole,
- * Alexander Szakaly, Campbell Barton, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include "Material.h" /*This must come first*/
-
-#include "DNA_space_types.h"
-#include "DNA_material_types.h"
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_material.h"
-#include "BKE_texture.h"
-#include "BKE_idprop.h"
-#include "BKE_utildefines.h" /* for CLAMP */
-#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
-#include "BSE_editipo.h"
-#include "BIF_space.h"
-#include "mydevice.h"
-#include "constant.h"
-#include "MTex.h"
-#include "Texture.h"
-#include "Ipo.h"
-#include "Group.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-#include "IDProp.h"
-
-/*****************************************************************************/
-/* Python BPy_Material defaults: */
-/*****************************************************************************/
-/* Material MIN, MAX values */
-#define EXPP_MAT_ADD_MIN 0.0f
-#define EXPP_MAT_ADD_MAX 1.0f
-#define EXPP_MAT_ALPHA_MIN 0.0f
-#define EXPP_MAT_ALPHA_MAX 1.0f
-#define EXPP_MAT_AMB_MIN 0.0f
-#define EXPP_MAT_AMB_MAX 1.0f
-#define EXPP_MAT_COL_MIN 0.0f /* min/max for all ... */
-#define EXPP_MAT_COL_MAX 1.0f /* ... color triplets */
-#define EXPP_MAT_EMIT_MIN 0.0f
-#define EXPP_MAT_EMIT_MAX 1.0f
-#define EXPP_MAT_REF_MIN 0.0f
-#define EXPP_MAT_REF_MAX 1.0f
-#define EXPP_MAT_SPEC_MIN 0.0f
-#define EXPP_MAT_SPEC_MAX 2.0f
-#define EXPP_MAT_SPECTRA_MIN 0.0f
-#define EXPP_MAT_SPECTRA_MAX 1.0f
-
-/* Shader specific settings */
-
-#define EXPP_MAT_ROUGHNESS_MIN 0.0f
-#define EXPP_MAT_ROUGHNESS_MAX 3.140f
-#define EXPP_MAT_SPECSIZE_MIN 0.0f
-#define EXPP_MAT_SPECSIZE_MAX 1.530f
-#define EXPP_MAT_DIFFUSESIZE_MIN 0.0f
-#define EXPP_MAT_DIFFUSESIZE_MAX 3.140f
-#define EXPP_MAT_SPECSMOOTH_MIN 0.0f
-#define EXPP_MAT_SPECSMOOTH_MAX 1.0f
-#define EXPP_MAT_DIFFUSESMOOTH_MIN 0.0f
-#define EXPP_MAT_DIFFUSESMOOTH_MAX 1.0f
-#define EXPP_MAT_DIFFUSE_DARKNESS_MIN 0.0f
-#define EXPP_MAT_DIFFUSE_DARKNESS_MAX 2.0f
-#define EXPP_MAT_REFRACINDEX_MIN 1.0f
-#define EXPP_MAT_REFRACINDEX_MAX 10.0f
-#define EXPP_MAT_RMS_MIN 0.0f
-#define EXPP_MAT_RMS_MAX 0.4f
-/* End shader settings */
-
-#define EXPP_MAT_ZOFFS_MIN 0.0
-#define EXPP_MAT_ZOFFS_MAX 10.0
-#define EXPP_MAT_HALOSIZE_MIN 0.0
-#define EXPP_MAT_HALOSIZE_MAX 100.0
-#define EXPP_MAT_FLARESIZE_MIN 0.1f
-#define EXPP_MAT_FLARESIZE_MAX 25.0
-#define EXPP_MAT_FLAREBOOST_MIN 0.1f
-#define EXPP_MAT_FLAREBOOST_MAX 10.0
-#define EXPP_MAT_SUBSIZE_MIN 0.1f
-#define EXPP_MAT_SUBSIZE_MAX 25.0
-
-#define EXPP_MAT_HARD_MIN 1
-#define EXPP_MAT_HARD_MAX 255 /* 127 with MODE HALO ON */
-#define EXPP_MAT_HALOSEED_MIN 0
-#define EXPP_MAT_HALOSEED_MAX 255
-#define EXPP_MAT_NFLARES_MIN 1
-#define EXPP_MAT_NFLARES_MAX 32
-#define EXPP_MAT_FLARESEED_MIN 0
-#define EXPP_MAT_FLARESEED_MAX 255
-#define EXPP_MAT_NSTARS_MIN 3
-#define EXPP_MAT_NSTARS_MAX 50
-#define EXPP_MAT_NLINES_MIN 0
-#define EXPP_MAT_NLINES_MAX 250
-#define EXPP_MAT_NRINGS_MIN 0
-#define EXPP_MAT_NRINGS_MAX 24
-
-#define EXPP_MAT_RAYMIRR_MIN 0.0
-#define EXPP_MAT_RAYMIRR_MAX 1.0
-#define EXPP_MAT_MIRRDEPTH_MIN 0
-#define EXPP_MAT_MIRRDEPTH_MAX 10
-#define EXPP_MAT_FRESNELMIRR_MIN 0.0
-#define EXPP_MAT_FRESNELMIRR_MAX 5.0
-#define EXPP_MAT_FRESNELMIRRFAC_MIN 1.0
-#define EXPP_MAT_FRESNELMIRRFAC_MAX 5.0
-#define EXPP_MAT_FILTER_MIN 0.0
-#define EXPP_MAT_FILTER_MAX 1.0
-#define EXPP_MAT_TRANSLUCENCY_MIN 0.0
-#define EXPP_MAT_TRANSLUCENCY_MAX 1.0
-#define EXPP_MAT_ZOFFS_MIN 0.0
-#define EXPP_MAT_ZOFFS_MAX 10.0
-#define EXPP_MAT_IOR_MIN 1.0
-#define EXPP_MAT_IOR_MAX 3.0
-#define EXPP_MAT_TRANSDEPTH_MIN 0
-#define EXPP_MAT_TRANSDEPTH_MAX 10
-#define EXPP_MAT_FRESNELTRANS_MIN 0.0
-#define EXPP_MAT_FRESNELTRANS_MAX 5.0
-#define EXPP_MAT_FRESNELTRANSFAC_MIN 1.0
-#define EXPP_MAT_FRESNELTRANSFAC_MAX 5.0
-#define EXPP_MAT_SPECTRANS_MIN 0.0
-#define EXPP_MAT_SPECTRANS_MAX 1.0
-#define EXPP_MAT_MIRRTRANSADD_MIN 0.0
-#define EXPP_MAT_MIRRTRANSADD_MAX 1.0
-
-/* closure values for getColorComponent()/setColorComponent() */
-
-#define EXPP_MAT_COMP_R 0
-#define EXPP_MAT_COMP_G 1
-#define EXPP_MAT_COMP_B 2
-#define EXPP_MAT_COMP_SPECR 3
-#define EXPP_MAT_COMP_SPECG 4
-#define EXPP_MAT_COMP_SPECB 5
-#define EXPP_MAT_COMP_MIRR 6
-#define EXPP_MAT_COMP_MIRG 7
-#define EXPP_MAT_COMP_MIRB 8
-#define EXPP_MAT_COMP_SSSR 9
-#define EXPP_MAT_COMP_SSSG 10
-#define EXPP_MAT_COMP_SSSB 11
-
-
-#define IPOKEY_RGB 0
-#define IPOKEY_ALPHA 1
-#define IPOKEY_HALOSIZE 2
-#define IPOKEY_MODE 3
-#define IPOKEY_ALLCOLOR 10
-#define IPOKEY_ALLMIRROR 14
-#define IPOKEY_OFS 12
-#define IPOKEY_SIZE 13
-#define IPOKEY_ALLMAPPING 11
-
-/* SSS Settings */
-#define EXPP_MAT_SSS_SCALE_MIN 0.001
-#define EXPP_MAT_SSS_SCALE_MAX 1000.0
-#define EXPP_MAT_SSS_RADIUS_MIN 0.0
-#define EXPP_MAT_SSS_RADIUS_MAX 10000.0
-#define EXPP_MAT_SSS_IOR_MIN 0.1
-#define EXPP_MAT_SSS_IOR_MAX 2.0
-#define EXPP_MAT_SSS_ERROR_MIN 0.0
-#define EXPP_MAT_SSS_ERROR_MAX 1.0
-#define EXPP_MAT_SSS_FRONT_MIN 0.0
-#define EXPP_MAT_SSS_FRONT_MAX 2.0
-#define EXPP_MAT_SSS_BACK_MIN 0.0
-#define EXPP_MAT_SSS_BACK_MAX 10.0
-
-
-/*****************************************************************************/
-/* Python API function prototypes for the Material module. */
-/*****************************************************************************/
-static PyObject *M_Material_New( PyObject * self, PyObject * args,
- PyObject * keywords );
-static PyObject *M_Material_Get( 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.Material.__doc__ */
-/*****************************************************************************/
-static char M_Material_doc[] = "The Blender Material module";
-
-static char M_Material_New_doc[] =
- "(name) - return a new material called 'name'\n\
-() - return a new material called 'Mat'";
-
-static char M_Material_Get_doc[] =
- "(name) - return the material called 'name', None if not found.\n\
-() - return a list of all materials in the current scene.";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Material module: */
-/*****************************************************************************/
-struct PyMethodDef M_Material_methods[] = {
- {"New", ( PyCFunction ) M_Material_New, METH_VARARGS | METH_KEYWORDS,
- M_Material_New_doc},
- {"Get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
- {"get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Function: M_Material_New */
-/* Python equivalent: Blender.Material.New */
-/*****************************************************************************/
-static PyObject *M_Material_New( PyObject * self, PyObject * args,
- PyObject * keywords )
-{
- char *name = "Mat";
- static char *kwlist[] = { "name", NULL };
- BPy_Material *pymat; /* for Material Data object wrapper in Python */
- Material *blmat; /* for actual Material Data we create in Blender */
- char buf[21];
-
- if( !PyArg_ParseTupleAndKeywords
- ( args, keywords, "|s", kwlist, &name ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected string or nothing as argument" ) );
-
- if( strcmp( name, "Mat" ) != 0 ) /* use gave us a name ? */
- PyOS_snprintf( buf, sizeof( buf ), "%s", name );
-
- blmat = add_material( name ); /* first create the Material Data in Blender */
-
- if( blmat ) /* now create the wrapper obj in Python */
- pymat = ( BPy_Material * ) Material_CreatePyObject( blmat );
- else
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Material Data in Blender" ) );
-
- blmat->id.us = 0; /* was incref'ed by add_material() above */
-
- if( pymat == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create Material Data object" ) );
-
- return ( PyObject * ) pymat;
-}
-
-/*****************************************************************************/
-/* Function: M_Material_Get */
-/* Python equivalent: Blender.Material.Get */
-/* Description: Receives a string and returns the material whose */
-/* name matches the string. If no argument is */
-/* passed in, a list with all materials in the */
-/* current scene is returned. */
-/*****************************************************************************/
-static PyObject *M_Material_Get( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- Material *mat_iter;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" ) );
-
- if( name ) { /* (name) - Search material by name */
-
- mat_iter = ( Material * ) GetIdFromList( &( G.main->mat ), name );
-
- if( mat_iter == NULL ) { /* Requested material doesn't exist */
- char error_msg[64];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Material \"%s\" not found", name );
- return EXPP_ReturnPyObjError( PyExc_NameError,
- error_msg );
- }
-
- return Material_CreatePyObject( mat_iter );
- }
-
- else { /* () - return a list with all materials in the scene */
- int index = 0;
- PyObject *matlist, *pyobj;
-
- matlist = PyList_New( BLI_countlist( &( G.main->mat ) ) );
-
- if( !matlist )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" ) );
-
- mat_iter = G.main->mat.first;
- while( mat_iter ) {
- pyobj = Material_CreatePyObject( mat_iter );
-
- if( !pyobj ) {
- Py_DECREF(matlist);
- return ( EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create PyObject" ) );
- }
- PyList_SET_ITEM( matlist, index, pyobj );
-
- mat_iter = mat_iter->id.next;
- index++;
- }
-
- return matlist;
- }
-}
-
-static PyObject *Material_ModesDict( void )
-{
- PyObject *Modes = PyConstant_New( );
-
- if( Modes ) {
- BPy_constant *c = ( BPy_constant * ) Modes;
-
- PyConstant_Insert(c, "TRACEABLE", PyInt_FromLong(MA_TRACEBLE));
- PyConstant_Insert(c, "SHADOW", PyInt_FromLong(MA_SHADOW));
- PyConstant_Insert(c, "SHADOWBUF", PyInt_FromLong(MA_SHADBUF));
- PyConstant_Insert(c, "TANGENTSTR", PyInt_FromLong(MA_TANGENT_STR));
- PyConstant_Insert(c, "FULLOSA", PyInt_FromLong(MA_FULL_OSA));
- PyConstant_Insert(c, "RAYBIAS", PyInt_FromLong(MA_RAYBIAS));
- PyConstant_Insert(c, "TRANSPSHADOW", PyInt_FromLong(MA_SHADOW_TRA));
- PyConstant_Insert(c, "RAMPCOL", PyInt_FromLong(MA_RAMP_COL));
- PyConstant_Insert(c, "RAMPSPEC", PyInt_FromLong(MA_RAMP_SPEC));
- PyConstant_Insert(c, "SHADELESS", PyInt_FromLong(MA_SHLESS));
- PyConstant_Insert(c, "WIRE", PyInt_FromLong(MA_WIRE));
- PyConstant_Insert(c, "VCOL_LIGHT", PyInt_FromLong(MA_VERTEXCOL));
- PyConstant_Insert(c, "HALO", PyInt_FromLong(MA_HALO));
- PyConstant_Insert(c, "ZTRANSP", PyInt_FromLong(MA_ZTRA));
- PyConstant_Insert(c, "VCOL_PAINT", PyInt_FromLong(MA_VERTEXCOLP));
- PyConstant_Insert(c, "ZINVERT", PyInt_FromLong(MA_ZINV));
- PyConstant_Insert(c, "HALORINGS", PyInt_FromLong(MA_HALO_RINGS));
- PyConstant_Insert(c, "ENV", PyInt_FromLong(MA_ENV));
- PyConstant_Insert(c, "HALOLINES", PyInt_FromLong(MA_HALO_LINES));
- PyConstant_Insert(c, "ONLYSHADOW", PyInt_FromLong(MA_ONLYSHADOW));
- PyConstant_Insert(c, "HALOXALPHA", PyInt_FromLong(MA_HALO_XALPHA));
- PyConstant_Insert(c, "HALOSTAR", PyInt_FromLong(MA_STAR));
- PyConstant_Insert(c, "TEXFACE", PyInt_FromLong(MA_FACETEXTURE));
- PyConstant_Insert(c, "HALOTEX", PyInt_FromLong(MA_HALOTEX));
- PyConstant_Insert(c, "HALOPUNO", PyInt_FromLong(MA_HALOPUNO));
- PyConstant_Insert(c, "NOMIST", PyInt_FromLong(MA_NOMIST));
- PyConstant_Insert(c, "HALOSHADE", PyInt_FromLong(MA_HALO_SHADE));
- PyConstant_Insert(c, "HALOFLARE", PyInt_FromLong(MA_HALO_FLARE));
- PyConstant_Insert(c, "RADIO", PyInt_FromLong(MA_RADIO));
- PyConstant_Insert(c, "RAYMIRROR", PyInt_FromLong(MA_RAYMIRROR));
- PyConstant_Insert(c, "ZTRA", PyInt_FromLong(MA_ZTRA));
- PyConstant_Insert(c, "RAYTRANSP", PyInt_FromLong(MA_RAYTRANSP));
- PyConstant_Insert(c, "TANGENT_V", PyInt_FromLong(MA_TANGENT_V));
- PyConstant_Insert(c, "NMAP_TS", PyInt_FromLong(MA_NORMAP_TANG));
- PyConstant_Insert(c, "GROUP_EXCLUSIVE", PyInt_FromLong(MA_GROUP_NOLAY));
- }
-
- return Modes;
-}
-
-
-static PyObject *Material_ShadersDict( void )
-{
- PyObject *Shaders = PyConstant_New( );
-
- if( Shaders ) {
- BPy_constant *c = ( BPy_constant * ) Shaders;
-
- PyConstant_Insert(c, "DIFFUSE_LAMBERT", PyInt_FromLong(MA_DIFF_LAMBERT));
- PyConstant_Insert(c, "DIFFUSE_ORENNAYAR", PyInt_FromLong(MA_DIFF_ORENNAYAR));
- PyConstant_Insert(c, "DIFFUSE_TOON", PyInt_FromLong(MA_DIFF_TOON));
- PyConstant_Insert(c, "DIFFUSE_MINNAERT", PyInt_FromLong(MA_DIFF_MINNAERT));
- PyConstant_Insert(c, "SPEC_COOKTORR", PyInt_FromLong(MA_SPEC_COOKTORR));
- PyConstant_Insert(c, "SPEC_PHONG", PyInt_FromLong(MA_SPEC_PHONG));
- PyConstant_Insert(c, "SPEC_BLINN", PyInt_FromLong(MA_SPEC_BLINN));
- PyConstant_Insert(c, "SPEC_TOON", PyInt_FromLong(MA_SPEC_TOON));
- PyConstant_Insert(c, "SPEC_WARDISO", PyInt_FromLong(MA_SPEC_WARDISO));
-
- }
-
- return Shaders;
-}
-
-
-/*****************************************************************************/
-/* Function: Material_Init */
-/*****************************************************************************/
-PyObject *Material_Init( void )
-{
- PyObject *submodule, *Modes, *Shaders;
-
- if( PyType_Ready( &Material_Type ) < 0)
- return NULL;
-
- Modes = Material_ModesDict( );
- Shaders = Material_ShadersDict( );
-
- submodule = Py_InitModule3( "Blender.Material",
- M_Material_methods, M_Material_doc );
-
- if( Modes )
- PyModule_AddObject( submodule, "Modes", Modes );
- if( Shaders )
- PyModule_AddObject( submodule, "Shaders", Shaders );
-
- PyModule_AddIntConstant( submodule, "RGB", IPOKEY_RGB );
- PyModule_AddIntConstant( submodule, "ALPHA", IPOKEY_ALPHA );
- PyModule_AddIntConstant( submodule, "HALOSIZE", IPOKEY_HALOSIZE );
- PyModule_AddIntConstant( submodule, "MODE", IPOKEY_MODE );
- PyModule_AddIntConstant( submodule, "ALLCOLOR", IPOKEY_ALLCOLOR );
- PyModule_AddIntConstant( submodule, "ALLMIRROR", IPOKEY_ALLMIRROR );
- PyModule_AddIntConstant( submodule, "OFS", IPOKEY_OFS );
- PyModule_AddIntConstant( submodule, "SIZE", IPOKEY_SIZE );
- PyModule_AddIntConstant( submodule, "ALLMAPPING", IPOKEY_ALLMAPPING );
-
- return ( submodule );
-}
-
-/***************************/
-/*** The Material PyType ***/
-/***************************/
-
-static PyObject *Matr_oldsetAdd( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetAlpha( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetAmb( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetEmit( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetFilter( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetFlareBoost( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetFlareSeed( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetFlareSize( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetFresnelMirr( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetFresnelMirrFac( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetFresnelTrans( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetFresnelTransFac( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetHaloSeed( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetHaloSize( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetHardness( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetIOR( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetNFlares( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetNLines( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetNRings( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetNStars( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetRayMirr( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetMirrDepth( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetRef( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetSpec( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetSpecTransp( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetSubSize( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetTransDepth( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetZOffset( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetMode( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetIpo( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetRGBCol( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetSpecCol( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetSpecShader( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetMirCol( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetDiffuseShader( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetRoughness( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetSpecSize( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetDiffuseSize( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetSpecSmooth( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetDiffuseSmooth( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetDiffuseDarkness( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetRefracIndex( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetRms( BPy_Material * self, PyObject * args );
-static PyObject *Matr_oldsetTranslucency( BPy_Material * self, PyObject * args );
-
-static int Material_setIpo( BPy_Material * self, PyObject * value );
-
-static int Material_setMode( BPy_Material * self, PyObject * value );
-static int Material_setRGBCol( BPy_Material * self, PyObject * value );
-static int Material_setSpecCol( BPy_Material * self, PyObject * value );
-static int Material_setMirCol( BPy_Material * self, PyObject * value );
-static int Material_setSssCol( BPy_Material * self, PyObject * value );
-static int Material_setColorComponent( BPy_Material * self, PyObject * value,
- void * closure );
-static int Material_setAmb( BPy_Material * self, PyObject * value );
-static int Material_setEmit( BPy_Material * self, PyObject * value );
-static int Material_setSpecTransp( BPy_Material * self, PyObject * value );
-static int Material_setAlpha( BPy_Material * self, PyObject * value );
-static int Material_setShadAlpha( BPy_Material * self, PyObject * value );
-static int Material_setRef( BPy_Material * self, PyObject * value );
-static int Material_setSpec( BPy_Material * self, PyObject * value );
-static int Material_setZOffset( BPy_Material * self, PyObject * value );
-static int Material_setLightGroup( BPy_Material * self, PyObject * value );
-static int Material_setAdd( BPy_Material * self, PyObject * value );
-static int Material_setHaloSize( BPy_Material * self, PyObject * value );
-static int Material_setFlareSize( BPy_Material * self, PyObject * value );
-static int Material_setFlareBoost( BPy_Material * self, PyObject * value );
-static int Material_setSubSize( BPy_Material * self, PyObject * value );
-static int Material_setHaloSeed( BPy_Material * self, PyObject * value );
-static int Material_setFlareSeed( BPy_Material * self, PyObject * value );
-static int Material_setHardness( BPy_Material * self, PyObject * value );
-static int Material_setNFlares( BPy_Material * self, PyObject * value );
-static int Material_setNStars( BPy_Material * self, PyObject * value );
-static int Material_setNLines( BPy_Material * self, PyObject * value );
-static int Material_setNRings( BPy_Material * self, PyObject * value );
-static int Material_setRayMirr( BPy_Material * self, PyObject * value );
-static int Material_setMirrDepth( BPy_Material * self, PyObject * value );
-static int Material_setFresnelMirr( BPy_Material * self, PyObject * value );
-static int Material_setFresnelMirrFac( BPy_Material * self, PyObject * value );
-static int Material_setIOR( BPy_Material * self, PyObject * value );
-static int Material_setTransDepth( BPy_Material * self, PyObject * value );
-static int Material_setFresnelTrans( BPy_Material * self, PyObject * value );
-static int Material_setFresnelTransFac( BPy_Material * self, PyObject * value );
-static int Material_setRigidBodyFriction( BPy_Material * self, PyObject * value );
-static int Material_setRigidBodyRestitution( BPy_Material * self, PyObject * value );
-
-static int Material_setSpecShader( BPy_Material * self, PyObject * value );
-static int Material_setDiffuseShader( BPy_Material * self, PyObject * value );
-static int Material_setRoughness( BPy_Material * self, PyObject * value );
-static int Material_setSpecSize( BPy_Material * self, PyObject * value );
-static int Material_setDiffuseSize( BPy_Material * self, PyObject * value );
-static int Material_setSpecSmooth( BPy_Material * self, PyObject * value );
-static int Material_setDiffuseSmooth( BPy_Material * self, PyObject * value );
-static int Material_setDiffuseDarkness( BPy_Material * self, PyObject * value );
-static int Material_setRefracIndex( BPy_Material * self, PyObject * value );
-static int Material_setRms( BPy_Material * self, PyObject * value );
-static int Material_setFilter( BPy_Material * self, PyObject * value );
-static int Material_setTranslucency( BPy_Material * self, PyObject * value );
-
-static int Material_setSssEnable( BPy_Material * self, PyObject * value );
-static int Material_setSssScale( BPy_Material * self, PyObject * value );
-static int Material_setSssRadius( BPy_Material * self, PyObject * value, void * type );
-static int Material_setSssIOR( BPy_Material * self, PyObject * value );
-static int Material_setSssError( BPy_Material * self, PyObject * value );
-static int Material_setSssColorBlend( BPy_Material * self, PyObject * value );
-static int Material_setSssTexScatter( BPy_Material * self, PyObject * value );
-static int Material_setSssFront( BPy_Material * self, PyObject * value );
-static int Material_setSssBack( BPy_Material * self, PyObject * value );
-static int Material_setSssBack( BPy_Material * self, PyObject * value );
-
-static PyObject *Material_getColorComponent( BPy_Material * self,
- void * closure );
-
-/*static int Material_setSeptex( BPy_Material * self, PyObject * value );
- static PyObject *Material_getSeptex( BPy_Material * self );*/
-
-/*****************************************************************************/
-/* Python BPy_Material methods declarations: */
-/*****************************************************************************/
-static PyObject *Material_getIpo( BPy_Material * self );
-static PyObject *Material_getMode( BPy_Material * self );
-static PyObject *Material_getRGBCol( BPy_Material * self );
-/*static PyObject *Material_getAmbCol(BPy_Material *self);*/
-static PyObject *Material_getSpecCol( BPy_Material * self );
-static PyObject *Material_getMirCol( BPy_Material * self );
-static PyObject *Material_getSssCol( BPy_Material * self );
-static PyObject *Material_getAmb( BPy_Material * self );
-static PyObject *Material_getEmit( BPy_Material * self );
-static PyObject *Material_getAlpha( BPy_Material * self );
-static PyObject *Material_getShadAlpha( BPy_Material * self );
-static PyObject *Material_getRef( BPy_Material * self );
-static PyObject *Material_getSpec( BPy_Material * self );
-static PyObject *Material_getSpecTransp( BPy_Material * self );
-static PyObject *Material_getAdd( BPy_Material * self );
-static PyObject *Material_getZOffset( BPy_Material * self );
-static PyObject *Material_getLightGroup( BPy_Material * self );
-static PyObject *Material_getHaloSize( BPy_Material * self );
-static PyObject *Material_getHaloSeed( BPy_Material * self );
-static PyObject *Material_getFlareSize( BPy_Material * self );
-static PyObject *Material_getFlareSeed( BPy_Material * self );
-static PyObject *Material_getFlareBoost( BPy_Material * self );
-static PyObject *Material_getSubSize( BPy_Material * self );
-static PyObject *Material_getHardness( BPy_Material * self );
-static PyObject *Material_getNFlares( BPy_Material * self );
-static PyObject *Material_getNStars( BPy_Material * self );
-static PyObject *Material_getNLines( BPy_Material * self );
-static PyObject *Material_getNRings( BPy_Material * self );
-/* Shader settings */
-static PyObject *Material_getSpecShader( BPy_Material * self );
-static PyObject *Material_getDiffuseShader( BPy_Material * self );
-static PyObject *Material_getRoughness( BPy_Material * self );
-static PyObject *Material_getSpecSize( BPy_Material * self );
-static PyObject *Material_getDiffuseSize( BPy_Material * self );
-static PyObject *Material_getSpecSmooth( BPy_Material * self );
-static PyObject *Material_getDiffuseSmooth( BPy_Material * self );
-static PyObject *Material_getDiffuseDarkness( BPy_Material * self );
-static PyObject *Material_getRefracIndex( BPy_Material * self );
-static PyObject *Material_getRms( BPy_Material * self );
-
-static PyObject *Material_getRayMirr( BPy_Material * self );
-static PyObject *Material_getMirrDepth( BPy_Material * self );
-static PyObject *Material_getFresnelMirr( BPy_Material * self );
-static PyObject *Material_getFresnelMirrFac( BPy_Material * self );
-static PyObject *Material_getIOR( BPy_Material * self );
-static PyObject *Material_getTransDepth( BPy_Material * self );
-static PyObject *Material_getFresnelTrans( BPy_Material * self );
-static PyObject *Material_getFresnelTransFac( BPy_Material * self );
-static PyObject *Material_getRigidBodyFriction( BPy_Material * self );
-static PyObject *Material_getRigidBodyRestitution( BPy_Material * self );
-
-static PyObject *Material_getSssEnable( BPy_Material * self );
-static PyObject *Material_getSssScale( BPy_Material * self );
-static PyObject *Material_getSssRadius( BPy_Material * self, void * type );
-static PyObject *Material_getSssIOR( BPy_Material * self );
-static PyObject *Material_getSssError( BPy_Material * self );
-static PyObject *Material_getSssColorBlend( BPy_Material * self );
-static PyObject *Material_getSssTexScatter( BPy_Material * self );
-static PyObject *Material_getSssFront( BPy_Material * self );
-static PyObject *Material_getSssBack( BPy_Material * self );
-static PyObject *Material_getSssBack( BPy_Material * self );
-
-static PyObject *Material_getFilter( BPy_Material * self );
-static PyObject *Material_getTranslucency( BPy_Material * self );
-static PyObject *Material_getTextures( BPy_Material * self );
-static PyObject *Material_clearIpo( BPy_Material * self );
-
-static PyObject *Material_setTexture( BPy_Material * self, PyObject * args );
-static PyObject *Material_clearTexture( BPy_Material * self, PyObject * value );
-
-static PyObject *Material_getScriptLinks(BPy_Material *self, PyObject * value );
-static PyObject *Material_addScriptLink(BPy_Material * self, PyObject * args );
-static PyObject *Material_clearScriptLinks(BPy_Material *self, PyObject *args);
-
-static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args );
-static PyObject *Material_getColorband( BPy_Material * self, void * type);
-int Material_setColorband( BPy_Material * self, PyObject * value, void * type);
-static PyObject *Material_copy( BPy_Material * self );
-
-
-/*****************************************************************************/
-/* Python BPy_Material methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Material_methods[] = {
- /* name, method, flags, doc */
- {"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
- "() - Return Material's name"},
- {"getIpo", ( PyCFunction ) Material_getIpo, METH_NOARGS,
- "() - Return Material's ipo or None if not found"},
- {"getMode", ( PyCFunction ) Material_getMode, METH_NOARGS,
- "() - Return Material's mode flags"},
- {"getRGBCol", ( PyCFunction ) Material_getRGBCol, METH_NOARGS,
- "() - Return Material's rgb color triplet"},
-/* {"getAmbCol", (PyCFunction)Material_getAmbCol, METH_NOARGS,
- "() - Return Material's ambient color"},*/
- {"getSpecCol", ( PyCFunction ) Material_getSpecCol, METH_NOARGS,
- "() - Return Material's specular color"},
- {"getMirCol", ( PyCFunction ) Material_getMirCol, METH_NOARGS,
- "() - Return Material's mirror color"},
- {"getAmb", ( PyCFunction ) Material_getAmb, METH_NOARGS,
- "() - Return Material's ambient color blend factor"},
- {"getEmit", ( PyCFunction ) Material_getEmit, METH_NOARGS,
- "() - Return Material's emitting light intensity"},
- {"getAlpha", ( PyCFunction ) Material_getAlpha, METH_NOARGS,
- "() - Return Material's alpha (transparency) value"},
- {"getRef", ( PyCFunction ) Material_getRef, METH_NOARGS,
- "() - Return Material's reflectivity"},
- {"getSpec", ( PyCFunction ) Material_getSpec, METH_NOARGS,
- "() - Return Material's specularity"},
- /* Shader specific settings */
- {"getSpecShader", ( PyCFunction ) Material_getSpecShader, METH_NOARGS,
- "() - Returns Material's specular shader" },
- {"getDiffuseShader", ( PyCFunction ) Material_getDiffuseShader, METH_NOARGS,
- "() - Returns Material's diffuse shader" },
- {"getRoughness", ( PyCFunction ) Material_getRoughness, METH_NOARGS,
- "() - Returns Material's Roughness (applies to the \"Oren Nayar\" Diffuse Shader only)" },
- {"getSpecSize", ( PyCFunction ) Material_getSpecSize, METH_NOARGS,
- "() - Returns Material's size of specular area (applies to the \"Toon\" Specular Shader only)" },
- {"getDiffuseSize", ( PyCFunction ) Material_getDiffuseSize, METH_NOARGS,
- "() - Returns Material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
- {"getSpecSmooth", ( PyCFunction ) Material_getSpecSmooth, METH_NOARGS,
- "() - Returns Material's smoothing of specular area (applies to the \"Toon\" Diffuse Shader only)" },
- {"getDiffuseSmooth", ( PyCFunction ) Material_getDiffuseSmooth, METH_NOARGS,
- "() - Returns Material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
- {"getDiffuseDarkness", ( PyCFunction ) Material_getDiffuseDarkness, METH_NOARGS,
- "() - Returns Material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)" },
- {"getRefracIndex", ( PyCFunction ) Material_getRefracIndex, METH_NOARGS,
- "() - Returns Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)" },
- {"getRms", ( PyCFunction ) Material_getRms, METH_NOARGS,
- "() - Returns Material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)" },
- /* End shader settings */
- {"getSpecTransp", ( PyCFunction ) Material_getSpecTransp, METH_NOARGS,
- "() - Return Material's specular transparency"},
- {"getAdd", ( PyCFunction ) Material_getAdd, METH_NOARGS,
- "() - Return Material's glow factor"},
- {"getZOffset", ( PyCFunction ) Material_getZOffset, METH_NOARGS,
- "() - Return Material's artificial offset for faces"},
- {"getHaloSize", ( PyCFunction ) Material_getHaloSize, METH_NOARGS,
- "() - Return Material's halo size"},
- {"getHaloSeed", ( PyCFunction ) Material_getHaloSeed, METH_NOARGS,
- "() - Return Material's seed for random ring dimension and line "
- "location in halos"},
- {"getFlareSize", ( PyCFunction ) Material_getFlareSize, METH_NOARGS,
- "() - Return Material's (flare size)/(halo size) factor"},
- {"getFlareSeed", ( PyCFunction ) Material_getFlareSeed, METH_NOARGS,
- "() - Return Material's flare offset in the seed table"},
- {"getFlareBoost", ( PyCFunction ) Material_getFlareBoost, METH_NOARGS,
- "() - Return Material's flare boost"},
- {"getSubSize", ( PyCFunction ) Material_getSubSize, METH_NOARGS,
- "() - Return Material's dimension of subflare, dots and circles"},
- {"getHardness", ( PyCFunction ) Material_getHardness, METH_NOARGS,
- "() - Return Material's specular hardness"},
- {"getNFlares", ( PyCFunction ) Material_getNFlares, METH_NOARGS,
- "() - Return Material's number of flares in halo"},
- {"getNStars", ( PyCFunction ) Material_getNStars, METH_NOARGS,
- "() - Return Material's number of points in the halo stars"},
- {"getNLines", ( PyCFunction ) Material_getNLines, METH_NOARGS,
- "() - Return Material's number of lines in halo"},
- {"getNRings", ( PyCFunction ) Material_getNRings, METH_NOARGS,
- "() - Return Material's number of rings in halo"},
- {"getRayMirr", ( PyCFunction ) Material_getRayMirr, METH_NOARGS,
- "() - Return mount mirror"},
- {"getMirrDepth", ( PyCFunction ) Material_getMirrDepth, METH_NOARGS,
- "() - Return amount mirror depth"},
- {"getFresnelMirr", ( PyCFunction ) Material_getFresnelMirr, METH_NOARGS,
- "() - Return fresnel power for refractions"},
- {"getFresnelMirrFac", ( PyCFunction ) Material_getFresnelMirrFac, METH_NOARGS,
- "() - Return fresnel power for refractions factor"},
- {"getFilter", ( PyCFunction ) Material_getFilter, METH_NOARGS,
- "() - Return the amount of filtering when transparent raytrace is enabled"},
- {"getTranslucency", ( PyCFunction ) Material_getTranslucency, METH_NOARGS,
- "() - Return the Translucency, the amount of diffuse shading of the back side"},
- {"getIOR", ( PyCFunction ) Material_getIOR, METH_NOARGS,
- "() - Return IOR"},
- {"getTransDepth", ( PyCFunction ) Material_getTransDepth, METH_NOARGS,
- "() - Return amount inter-refractions"},
- {"getFresnelTrans", ( PyCFunction ) Material_getFresnelTrans, METH_NOARGS,
- "() - Return fresnel power for refractions"},
- {"getFresnelTransFac", ( PyCFunction ) Material_getFresnelTransFac, METH_NOARGS,
- "() - Return fresnel power for refractions factor"},
-
- {"getTextures", ( PyCFunction ) Material_getTextures, METH_NOARGS,
- "() - Return Material's texture list as a tuple"},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "(s) - Change Material's name"},
- {"setIpo", ( PyCFunction ) Matr_oldsetIpo, METH_VARARGS,
- "(Blender Ipo) - Change Material's Ipo"},
- {"clearIpo", ( PyCFunction ) Material_clearIpo, METH_NOARGS,
- "(Blender Ipo) - Unlink Ipo from this Material"},
- {"insertIpoKey", ( PyCFunction ) Material_insertIpoKey, METH_VARARGS,
- "(Material Ipo Constant) - Insert IPO Key at current frame"},
- {"setMode", ( PyCFunction ) Matr_oldsetMode, METH_VARARGS,
- "([s[,s]]) - Set Material's mode flag(s)"},
- {"setRGBCol", ( PyCFunction ) Matr_oldsetRGBCol, METH_VARARGS,
- "(f,f,f or [f,f,f]) - Set Material's rgb color triplet"},
-/* {"setAmbCol", (PyCFunction)Matr_oldsetAmbCol, METH_VARARGS,
- "(f,f,f or [f,f,f]) - Set Material's ambient color"},*/
- {"setSpecCol", ( PyCFunction ) Matr_oldsetSpecCol, METH_VARARGS,
- "(f,f,f or [f,f,f]) - Set Material's specular color"},
-
- /* Shader spesific settings */
- {"setSpecShader", ( PyCFunction ) Matr_oldsetSpecShader, METH_VARARGS,
- "(i) - Set the Material's specular shader" },
- {"setDiffuseShader", ( PyCFunction ) Matr_oldsetDiffuseShader, METH_VARARGS,
- "(i) - Set the Material's diffuse shader" },
- {"setRoughness", ( PyCFunction ) Matr_oldsetRoughness, METH_VARARGS,
- "(f) - Set the Material's Roughness (applies to the \"Oren Nayar\" Diffuse Shader only)" },
- {"setSpecSize", ( PyCFunction ) Matr_oldsetSpecSize, METH_VARARGS,
- "(f) - Set the Material's size of specular area (applies to the \"Toon\" Specular Shader only)" },
- {"setDiffuseSize", ( PyCFunction ) Matr_oldsetDiffuseSize, METH_VARARGS,
- "(f) - Set the Material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
- {"setSpecSmooth", ( PyCFunction ) Matr_oldsetSpecSmooth, METH_VARARGS,
- "(f) - Set the Material's smoothing of specular area (applies to the \"Toon\" Specular Shader only)" },
- {"setDiffuseSmooth", ( PyCFunction ) Matr_oldsetDiffuseSmooth, METH_VARARGS,
- "(f) - Set the Material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
- {"setDiffuseDarkness", ( PyCFunction ) Matr_oldsetDiffuseDarkness, METH_VARARGS,
- "(f) - Set the Material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)" },
- {"setRefracIndex", ( PyCFunction ) Matr_oldsetRefracIndex, METH_VARARGS,
- "(f) - Set the Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)" },
- {"setRms", ( PyCFunction ) Matr_oldsetRms, METH_VARARGS,
- "(f) - Set the Material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)" },
- /* End shader settings */
-
- {"setMirCol", ( PyCFunction ) Matr_oldsetMirCol, METH_VARARGS,
- "(f,f,f or [f,f,f]) - Set Material's mirror color"},
- {"setAmb", ( PyCFunction ) Matr_oldsetAmb, METH_VARARGS,
- "(f) - Set how much the Material's color is affected"
- " by \nthe global ambient colors - [0.0, 1.0]"},
- {"setEmit", ( PyCFunction ) Matr_oldsetEmit, METH_VARARGS,
- "(f) - Set Material's emitting light intensity - [0.0, 1.0]"},
- {"setAlpha", ( PyCFunction ) Matr_oldsetAlpha, METH_VARARGS,
- "(f) - Set Material's alpha (transparency) - [0.0, 1.0]"},
- {"setRef", ( PyCFunction ) Matr_oldsetRef, METH_VARARGS,
- "(f) - Set Material's reflectivity - [0.0, 1.0]"},
- {"setSpec", ( PyCFunction ) Matr_oldsetSpec, METH_VARARGS,
- "(f) - Set Material's specularity - [0.0, 2.0]"},
- {"setSpecTransp", ( PyCFunction ) Matr_oldsetSpecTransp, METH_VARARGS,
- "(f) - Set Material's specular transparency - [0.0, 1.0]"},
- {"setAdd", ( PyCFunction ) Matr_oldsetAdd, METH_VARARGS,
- "(f) - Set Material's glow factor - [0.0, 1.0]"},
- {"setZOffset", ( PyCFunction ) Matr_oldsetZOffset, METH_VARARGS,
- "(f) - Set Material's artificial offset - [0.0, 10.0]"},
- {"setHaloSize", ( PyCFunction ) Matr_oldsetHaloSize, METH_VARARGS,
- "(f) - Set Material's halo size - [0.0, 100.0]"},
- {"setHaloSeed", ( PyCFunction ) Matr_oldsetHaloSeed, METH_VARARGS,
- "(i) - Set Material's halo seed - [0, 255]"},
- {"setFlareSize", ( PyCFunction ) Matr_oldsetFlareSize, METH_VARARGS,
- "(f) - Set Material's factor: (flare size)/(halo size) - [0.1, 25.0]"},
- {"setFlareSeed", ( PyCFunction ) Matr_oldsetFlareSeed, METH_VARARGS,
- "(i) - Set Material's flare seed - [0, 255]"},
- {"setFlareBoost", ( PyCFunction ) Matr_oldsetFlareBoost, METH_VARARGS,
- "(f) - Set Material's flare boost - [0.1, 10.0]"},
- {"setSubSize", ( PyCFunction ) Matr_oldsetSubSize, METH_VARARGS,
- "(f) - Set Material's dimension of subflare,"
- " dots and circles - [0.1, 25.0]"},
- {"setHardness", ( PyCFunction ) Matr_oldsetHardness, METH_VARARGS,
- "(i) - Set Material's hardness - [1, 255 (127 if halo mode is ON)]"},
- {"setNFlares", ( PyCFunction ) Matr_oldsetNFlares, METH_VARARGS,
- "(i) - Set Material's number of flares in halo - [1, 32]"},
- {"setNStars", ( PyCFunction ) Matr_oldsetNStars, METH_VARARGS,
- "(i) - Set Material's number of stars in halo - [3, 50]"},
- {"setNLines", ( PyCFunction ) Matr_oldsetNLines, METH_VARARGS,
- "(i) - Set Material's number of lines in halo - [0, 250]"},
- {"setNRings", ( PyCFunction ) Matr_oldsetNRings, METH_VARARGS,
- "(i) - Set Material's number of rings in halo - [0, 24]"},
- {"setRayMirr", ( PyCFunction ) Matr_oldsetRayMirr, METH_VARARGS,
- "(f) - Set amount mirror - [0.0, 1.0]"},
- {"setMirrDepth", ( PyCFunction ) Matr_oldsetMirrDepth, METH_VARARGS,
- "(i) - Set amount inter-reflections - [0, 10]"},
- {"setFresnelMirr", ( PyCFunction ) Matr_oldsetFresnelMirr, METH_VARARGS,
- "(f) - Set fresnel power for mirror - [0.0, 5.0]"},
- {"setFresnelMirrFac", ( PyCFunction ) Matr_oldsetFresnelMirrFac, METH_VARARGS,
- "(f) - Set blend fac for mirror fresnel - [1.0, 5.0]"},
- {"setFilter", ( PyCFunction ) Matr_oldsetFilter, METH_VARARGS,
- "(f) - Set the amount of filtering when transparent raytrace is enabled"},
- {"setTranslucency", ( PyCFunction ) Matr_oldsetTranslucency, METH_VARARGS,
- "(f) - Set the Translucency, the amount of diffuse shading of the back side"},
- {"setIOR", ( PyCFunction ) Matr_oldsetIOR, METH_VARARGS,
- "(f) - Set IOR - [1.0, 3.0]"},
- {"setTransDepth", ( PyCFunction ) Matr_oldsetTransDepth, METH_VARARGS,
- "(i) - Set amount inter-refractions - [0, 10]"},
- {"setFresnelTrans", ( PyCFunction ) Matr_oldsetFresnelTrans, METH_VARARGS,
- "(f) - Set fresnel power for refractions - [0.0, 5.0]"},
- {"setFresnelTransFac", ( PyCFunction ) Matr_oldsetFresnelTransFac, METH_VARARGS,
- "(f) - Set fresnel power for refractions factor- [0.0, 5.0]"},
- {"setTexture", ( PyCFunction ) Material_setTexture, METH_VARARGS,
- "(n,tex,texco=0,mapto=0) - Set numbered texture to tex"},
- {"clearTexture", ( PyCFunction ) Material_clearTexture, METH_O,
- "(n) - Remove texture from numbered slot"},
- {"getScriptLinks", ( PyCFunction ) Material_getScriptLinks, METH_O,
- "(eventname) - Get a list of this material's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged, Redraw or Render."},
- {"addScriptLink", ( PyCFunction ) Material_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new material scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged, Redraw or Render."},
- {"clearScriptLinks", ( PyCFunction ) Material_clearScriptLinks, METH_VARARGS,
- "() - Delete all scriptlinks from this material.\n"
- "([s1<,s2,s3...>]) - Delete specified scriptlinks from this material."},
- {"__copy__", ( PyCFunction ) Material_copy, METH_NOARGS,
- "() - Return a copy of the material."},
- {"copy", ( PyCFunction ) Material_copy, METH_NOARGS,
- "() - Return a copy of the material."},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-
-static PyGetSetDef BPy_Material_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"add",
- (getter)Material_getAdd, (setter)Material_setAdd,
- "Strength of the add effect",
- NULL},
- {"alpha",
- (getter)Material_getAlpha, (setter)Material_setAlpha,
- "Alpha setting ",
- NULL},
- {"shadAlpha",
- (getter)Material_getShadAlpha, (setter)Material_setShadAlpha,
- "Shadow Alpha setting",
- NULL},
- {"amb",
- (getter)Material_getAmb, (setter)Material_setAmb,
- "Amount of global ambient color material receives",
- NULL},
- {"diffuseDarkness",
- (getter)Material_getDiffuseDarkness, (setter)Material_setDiffuseDarkness,
- "Material's diffuse darkness (\"Minnaert\" diffuse shader only)",
- NULL},
- {"diffuseShader",
- (getter)Material_getDiffuseShader, (setter)Material_setDiffuseShader,
- "Diffuse shader type",
- NULL},
- {"diffuseSize",
- (getter)Material_getDiffuseSize, (setter)Material_setDiffuseSize,
- "Material's diffuse area size (\"Toon\" diffuse shader only)",
- NULL},
- {"diffuseSmooth",
- (getter)Material_getDiffuseSmooth, (setter)Material_setDiffuseSmooth,
- "Material's diffuse area smoothing (\"Toon\" diffuse shader only)",
- NULL},
- {"emit",
- (getter)Material_getEmit, (setter)Material_setEmit,
- "Amount of light the material emits",
- NULL},
- {"filter",
- (getter)Material_getFilter, (setter)Material_setFilter,
- "Amount of filtering when transparent raytrace is enabled",
- NULL},
- {"flareBoost",
- (getter)Material_getFlareBoost, (setter)Material_setFlareBoost,
- "Flare's extra strength",
- NULL},
- {"flareSeed",
- (getter)Material_getFlareSeed, (setter)Material_setFlareSeed,
- "Offset in the flare seed table",
- NULL},
- {"flareSize",
- (getter)Material_getFlareSize, (setter)Material_setFlareSize,
- "Ratio of flare size to halo size",
- NULL},
- {"fresnelDepth",
- (getter)Material_getFresnelMirr, (setter)Material_setFresnelMirr,
- "Power of Fresnel for mirror reflection",
- NULL},
- {"fresnelDepthFac",
- (getter)Material_getFresnelMirrFac, (setter)Material_setFresnelMirrFac,
- "Blending factor for Fresnel mirror",
- NULL},
- {"fresnelTrans",
- (getter)Material_getFresnelTrans, (setter)Material_setFresnelTrans,
- "Power of Fresnel for transparency",
- NULL},
- {"fresnelTransFac",
- (getter)Material_getFresnelTransFac, (setter)Material_setFresnelTransFac,
- "Blending factor for Fresnel transparency",
- NULL},
- {"rbFriction",
- (getter)Material_getRigidBodyFriction, (setter)Material_setRigidBodyFriction,
- "Rigid Body Friction coefficient",
- NULL},
- {"rbRestitution",
- (getter)Material_getRigidBodyRestitution, (setter)Material_setRigidBodyRestitution,
- "Rigid Body Restitution coefficient",
- NULL},
-
- {"haloSeed",
- (getter)Material_getHaloSeed, (setter)Material_setHaloSeed,
- "Randomizes halo ring dimension and line location",
- NULL},
- {"haloSize",
- (getter)Material_getHaloSize, (setter)Material_setHaloSize,
- "Dimension of the halo",
- NULL},
- {"hard",
- (getter)Material_getHardness, (setter)Material_setHardness,
- "Specularity hardness",
- NULL},
- {"IOR",
- (getter)Material_getIOR, (setter)Material_setIOR,
- "Angular index of refraction for raytrace",
- NULL},
- {"ipo",
- (getter)Material_getIpo, (setter)Material_setIpo,
- "Material Ipo data",
- NULL},
- {"mirCol",
- (getter)Material_getMirCol, (setter)Material_setMirCol,
- "Mirror RGB color triplet",
- NULL},
- {"mirR",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "Mirror color red component",
- (void *) EXPP_MAT_COMP_MIRR },
- {"mirG",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "Mirror color green component",
- (void *) EXPP_MAT_COMP_MIRG },
- {"mirB",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "Mirror color blue component",
- (void *) EXPP_MAT_COMP_MIRB },
- {"sssCol",
- (getter)Material_getSssCol, (setter)Material_setSssCol,
- "Sss RGB color triplet",
- NULL},
- {"sssR",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "SSS color red component",
- (void *) EXPP_MAT_COMP_SSSR },
- {"sssG",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "SSS color green component",
- (void *) EXPP_MAT_COMP_SSSG },
- {"sssB",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "SSS color blue component",
- (void *) EXPP_MAT_COMP_SSSB },
- {"mode",
- (getter)Material_getMode, (setter)Material_setMode,
- "Material mode bitmask",
- NULL},
- {"nFlares",
- (getter)Material_getNFlares, (setter)Material_setNFlares,
- "Number of subflares with halo",
- NULL},
- {"nLines",
- (getter)Material_getNLines, (setter)Material_setNLines,
- "Number of star-shaped lines with halo",
- NULL},
- {"nRings",
- (getter)Material_getNRings, (setter)Material_setNRings,
- "Number of rings with halo",
- NULL},
- {"nStars",
- (getter)Material_getNStars, (setter)Material_setNStars,
- "Number of star points with halo",
- NULL},
- {"rayMirr",
- (getter)Material_getRayMirr, (setter)Material_setRayMirr,
- "Mirror reflection amount for raytrace",
- NULL},
- {"rayMirrDepth",
- (getter)Material_getMirrDepth, (setter)Material_setMirrDepth,
- "Amount of raytrace inter-reflections",
- NULL},
- {"ref",
- (getter)Material_getRef, (setter)Material_setRef,
- "Amount of reflections (for shader)",
- NULL},
- {"refracIndex",
- (getter)Material_getRefracIndex, (setter)Material_setRefracIndex,
- "Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only",
- NULL},
- {"rgbCol",
- (getter)Material_getRGBCol, (setter)Material_setRGBCol,
- "Diffuse RGB color triplet",
- NULL},
- {"rms",
- (getter)Material_getRms, (setter)Material_setRms,
- "Material's surface slope standard deviation (\"WardIso\" specular shader only)",
- NULL},
- {"roughness",
- (getter)Material_getRoughness, (setter)Material_setRoughness,
- "Material's roughness (\"Oren Nayar\" diffuse shader only)",
- NULL},
- {"spec",
- (getter)Material_getSpec, (setter)Material_setSpec,
- "Degree of specularity",
- NULL},
- {"specCol",
- (getter)Material_getSpecCol, (setter)Material_setSpecCol,
- "Specular RGB color triplet",
- NULL},
- {"specR",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "Specular color red component",
- (void *) EXPP_MAT_COMP_SPECR },
- {"specG",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "Specular color green component",
- (void *) EXPP_MAT_COMP_SPECG },
- {"specB",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "Specular color blue component",
- (void *) EXPP_MAT_COMP_SPECB },
- {"specTransp",
- (getter)Material_getSpecTransp, (setter)Material_setSpecTransp,
- "Makes specular areas opaque on transparent materials",
- NULL},
- {"specShader",
- (getter)Material_getSpecShader, (setter)Material_setSpecShader,
- "Specular shader type",
- NULL},
- {"specSize",
- (getter)Material_getSpecSize, (setter)Material_setSpecSize,
- "Material's specular area size (\"Toon\" specular shader only)",
- NULL},
- {"specSmooth",
- (getter)Material_getSpecSmooth, (setter)Material_setSpecSmooth,
- "Sets the smoothness of specular toon area",
- NULL},
- {"subSize",
- (getter)Material_getSubSize, (setter)Material_setSubSize,
- "Dimension of subflares, dots and circles",
- NULL},
- {"transDepth",
- (getter)Material_getTransDepth, (setter)Material_setTransDepth,
- "Amount of refractions for raytrace",
- NULL},
- {"translucency",
- (getter)Material_getTranslucency, (setter)Material_setTranslucency,
- "Amount of diffuse shading of the back side",
- NULL},
- {"zOffset",
- (getter)Material_getZOffset, (setter)Material_setZOffset,
- "Artificial offset in the Z buffer (for Ztransp option)",
- NULL},
- {"lightGroup",
- (getter)Material_getLightGroup, (setter)Material_setLightGroup,
- "Set the light group for this material",
- NULL},
- {"R",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "Diffuse color red component",
- (void *) EXPP_MAT_COMP_R },
- {"G",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "Diffuse color green component",
- (void *) EXPP_MAT_COMP_G },
- {"B",
- (getter)Material_getColorComponent, (setter)Material_setColorComponent,
- "Diffuse color blue component",
- (void *) EXPP_MAT_COMP_B },
- {"colorbandDiffuse",
- (getter)Material_getColorband, (setter)Material_setColorband,
- "The diffuse colorband for this material",
- (void *) 0},
- {"colorbandSpecular",
- (getter)Material_getColorband, (setter)Material_setColorband,
- "The specular colorband for this material",
- (void *) 1},
-
- /* SSS settings */
- {"enableSSS",
- (getter)Material_getSssEnable, (setter)Material_setSssEnable,
- "if true, SSS will be rendered for this material",
- NULL},
- {"sssScale",
- (getter)Material_getSssScale, (setter)Material_setSssScale,
- "object scale for sss",
- NULL},
- {"sssRadiusRed",
- (getter)Material_getSssRadius, (setter)Material_setSssRadius,
- "Mean red scattering path length",
- (void *) 0},
- {"sssRadiusGreen",
- (getter)Material_getSssRadius, (setter)Material_setSssRadius,
- "Mean red scattering path length",
- (void *) 1},
- {"sssRadiusBlue",
- (getter)Material_getSssRadius, (setter)Material_setSssRadius,
- "Mean red scattering path length",
- (void *) 0},
- {"sssIOR",
- (getter)Material_getSssIOR, (setter)Material_setSssIOR,
- "index of refraction",
- NULL},
- {"sssError",
- (getter)Material_getSssError, (setter)Material_setSssError,
- "Error",
- NULL},
- {"sssColorBlend",
- (getter)Material_getSssColorBlend, (setter)Material_setSssColorBlend,
- "Blend factor for SSS Colors",
- NULL},
- {"sssTextureScatter",
- (getter)Material_getSssTexScatter, (setter)Material_setSssTexScatter,
- "Texture scattering factor",
- NULL},
- {"sssFont",
- (getter)Material_getSssFront, (setter)Material_setSssFront,
- "Front scattering weight",
- NULL},
- {"sssBack",
- (getter)Material_getSssBack, (setter)Material_setSssBack,
- "Back scattering weight",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python Material_Type callback function prototypes: */
-/*****************************************************************************/
-static void Material_dealloc( BPy_Material * self );
-static int Material_compare( BPy_Material * a, BPy_Material * b);
-static PyObject *Material_repr( BPy_Material * self );
-
-/*****************************************************************************/
-/* Python Material_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Material_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Material", /* char *tp_name; */
- sizeof( BPy_Material ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) Material_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) Material_compare,/* cmpfunc tp_compare; */
- ( reprfunc ) Material_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_Material_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Material_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: Material_dealloc */
-/* Description: This is a callback function for the BPy_Material type. It is */
-/* the destructor function. */
-/*****************************************************************************/
-static void Material_dealloc( BPy_Material * self )
-{
- Py_DECREF( self->col );
- Py_DECREF( self->amb );
- Py_DECREF( self->spec );
- Py_DECREF( self->mir );
- Py_DECREF( self->sss );
- PyObject_DEL( self );
-}
-
-/*****************************************************************************/
-/* Function: Material_CreatePyObject */
-/* Description: Create a new BPy_Material from an existing */
-/* Blender material structure. */
-/*****************************************************************************/
-PyObject *Material_CreatePyObject( struct Material *mat )
-{
- BPy_Material *pymat;
- float *col[3], *amb[3], *spec[3], *mir[3], *sss[3];
-
- pymat = ( BPy_Material * ) PyObject_NEW( BPy_Material,
- &Material_Type );
-
- if( !pymat )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Material object" );
-
- pymat->material = mat;
-
- col[0] = &mat->r;
- col[1] = &mat->g;
- col[2] = &mat->b;
-
- amb[0] = &mat->ambr;
- amb[1] = &mat->ambg;
- amb[2] = &mat->ambb;
-
- spec[0] = &mat->specr;
- spec[1] = &mat->specg;
- spec[2] = &mat->specb;
-
- mir[0] = &mat->mirr;
- mir[1] = &mat->mirg;
- mir[2] = &mat->mirb;
-
- sss[0] = &mat->sss_col[0];
- sss[1] = &mat->sss_col[1];
- sss[2] = &mat->sss_col[2];
-
- pymat->col = ( BPy_rgbTuple * ) rgbTuple_New( col );
- pymat->amb = ( BPy_rgbTuple * ) rgbTuple_New( amb );
- pymat->spec = ( BPy_rgbTuple * ) rgbTuple_New( spec );
- pymat->mir = ( BPy_rgbTuple * ) rgbTuple_New( mir );
- pymat->sss = ( BPy_rgbTuple * ) rgbTuple_New( sss );
-
- return ( PyObject * ) pymat;
-}
-
-/*****************************************************************************/
-/* Function: Material_FromPyObject */
-/* Description: This function returns the Blender material from the given */
-/* PyObject. */
-/*****************************************************************************/
-Material *Material_FromPyObject( PyObject * pyobj )
-{
- return ( ( BPy_Material * ) pyobj )->material;
-}
-
-static PyObject *Material_getIpo( BPy_Material * self )
-{
- Ipo *ipo = self->material->ipo;
-
- if( !ipo )
- Py_RETURN_NONE;
-
- return Ipo_CreatePyObject( ipo );
-}
-
-static PyObject *Material_getMode( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->mode );
-}
-
-static PyObject *Material_getRGBCol( BPy_Material * self )
-{
- return rgbTuple_getCol( self->col );
-}
-
-/*
-static PyObject *Material_getAmbCol(BPy_Material *self)
-{
- return rgbTuple_getCol(self->amb);
-}
-*/
-static PyObject *Material_getSpecCol( BPy_Material * self )
-{
- return rgbTuple_getCol( self->spec );
-}
-
-static PyObject *Material_getMirCol( BPy_Material * self )
-{
- return rgbTuple_getCol( self->mir );
-}
-
-static PyObject *Material_getSssCol( BPy_Material * self )
-{
- return rgbTuple_getCol( self->sss );
-}
-
-static PyObject *Material_getSpecShader( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->spec_shader );
-}
-
-static PyObject *Material_getDiffuseShader( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->diff_shader );
-}
-
-static PyObject *Material_getRoughness( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->roughness );
-}
-
-static PyObject *Material_getSpecSize( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->param[2] );
-}
-
-static PyObject *Material_getDiffuseSize( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->param[0] );
-}
-
-static PyObject *Material_getSpecSmooth( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->param[3] );
-}
-
-static PyObject *Material_getDiffuseSmooth( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->param[1] );
-}
-
-static PyObject *Material_getDiffuseDarkness( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->darkness );
-}
-
-static PyObject *Material_getRefracIndex( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->refrac );
-}
-
-static PyObject *Material_getRms( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->rms );
-}
-
-static PyObject *Material_getAmb( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->amb );
-}
-
-static PyObject *Material_getEmit( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->emit );
-}
-
-static PyObject *Material_getAlpha( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->alpha );
-}
-
-static PyObject *Material_getShadAlpha( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->shad_alpha );
-}
-
-static PyObject *Material_getRef( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->ref );
-}
-
-static PyObject *Material_getSpec( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->spec );
-}
-
-static PyObject *Material_getSpecTransp( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->spectra );
-}
-
-static PyObject *Material_getAdd( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->add );
-}
-
-static PyObject *Material_getZOffset( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->zoffs );
-}
-
-static PyObject *Material_getLightGroup( BPy_Material * self )
-{
- return Group_CreatePyObject( self->material->group );
-}
-
-static PyObject *Material_getHaloSize( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->hasize );
-}
-
-static PyObject *Material_getFlareSize( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->flaresize );
-}
-
-static PyObject *Material_getFlareBoost( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->flareboost );
-}
-
-static PyObject *Material_getSubSize( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->subsize );
-}
-
-static PyObject *Material_getHaloSeed( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->seed1 );
-}
-
-static PyObject *Material_getFlareSeed( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->seed2 );
-}
-
-static PyObject *Material_getHardness( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->har );
-}
-
-static PyObject *Material_getNFlares( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->flarec );
-}
-
-static PyObject *Material_getNStars( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->starc );
-}
-
-static PyObject *Material_getNLines( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->linec );
-}
-
-static PyObject *Material_getNRings( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->ringc );
-}
-
-static PyObject *Material_getRayMirr( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->ray_mirror );
-}
-
-static PyObject *Material_getMirrDepth( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->ray_depth );
-}
-
-static PyObject *Material_getFresnelMirr( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->fresnel_mir );
-}
-
-static PyObject *Material_getFresnelMirrFac( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->fresnel_mir_i );
-}
-
-static PyObject *Material_getFilter( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->filter );
-}
-
-static PyObject *Material_getTranslucency( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->translucency );
-}
-
-static PyObject *Material_getIOR( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->ang );
-}
-
-static PyObject *Material_getTransDepth( BPy_Material * self )
-{
- return PyInt_FromLong( ( long ) self->material->ray_depth_tra );
-}
-
-static PyObject *Material_getFresnelTrans( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->fresnel_tra );
-}
-
-static PyObject *Material_getFresnelTransFac( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->fresnel_tra_i );
-}
-
-static PyObject* Material_getRigidBodyFriction( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->friction );
-}
-
-static PyObject* Material_getRigidBodyRestitution( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->reflect );
-}
-
-/* SSS */
-static PyObject* Material_getSssEnable( BPy_Material * self )
-{
- return EXPP_getBitfield( &self->material->sss_flag, MA_DIFF_SSS, 'h' );
-}
-
-static PyObject* Material_getSssScale( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->sss_scale );
-}
-
-static PyObject* Material_getSssRadius( BPy_Material * self, void * type )
-{
- return PyFloat_FromDouble( ( double ) (self->material->sss_radius[(int)type]) );
-}
-
-static PyObject* Material_getSssIOR( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->sss_ior);
-}
-
-static PyObject* Material_getSssError( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->sss_error);
-}
-
-static PyObject* Material_getSssColorBlend( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->sss_colfac);
-}
-
-static PyObject* Material_getSssTexScatter( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->sss_texfac);
-}
-
-static PyObject* Material_getSssFront( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->sss_front);
-}
-
-static PyObject* Material_getSssBack( BPy_Material * self )
-{
- return PyFloat_FromDouble( ( double ) self->material->sss_back);
-}
-
-static PyObject *Material_getTextures( BPy_Material * self )
-{
- int i;
- struct MTex *mtex;
- PyObject *t[MAX_MTEX];
- PyObject *tuple;
-
- /* build a texture list */
- for( i = 0; i < MAX_MTEX; ++i ) {
- mtex = self->material->mtex[i];
-
- if( mtex ) {
- t[i] = MTex_CreatePyObject( mtex );
- } else {
- Py_INCREF( Py_None );
- t[i] = Py_None;
- }
- }
-
- /* turn the array into a tuple */
- tuple = Py_BuildValue( "NNNNNNNNNN", t[0], t[1], t[2], t[3],
- t[4], t[5], t[6], t[7], t[8], t[9] );
- if( !tuple )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "Material_getTextures: couldn't create PyTuple" );
-
- return tuple;
-}
-
-/*
- * this should accept a Py_None argument and just delete the Ipo link
- * (as Lamp_clearIpo() does)
- */
-
-static int Material_setIpo( BPy_Material * self, PyObject * value )
-{
- return GenericLib_assignData(value, (void **) &self->material->ipo, 0, 1, ID_IP, ID_MA);
-}
-
-
-/*
- * Material_insertIpoKey( key )
- * inserts Material IPO key at current frame
- */
-
-static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args )
-{
- int key = 0, map;
-
- if( !PyArg_ParseTuple( args, "i", &( key ) ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
-
- map = texchannel_to_adrcode(self->material->texact);
-
- if(key==IPOKEY_RGB || key==IPOKEY_ALLCOLOR) {
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_R, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_G, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_B, 0);
- }
- if(key==IPOKEY_ALPHA || key==IPOKEY_ALLCOLOR) {
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ALPHA, 0);
- }
- if(key==IPOKEY_HALOSIZE || key==IPOKEY_ALLCOLOR) {
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HASIZE, 0);
- }
- if(key==IPOKEY_MODE || key==IPOKEY_ALLCOLOR) {
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, 0);
- }
- if(key==IPOKEY_ALLCOLOR) {
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_R, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_G, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_B, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_REF, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_EMIT, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_AMB, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HARD, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_TRANSLU, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ADD, 0);
- }
- if(key==IPOKEY_ALLMIRROR) {
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_RAYM, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIR, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIRI, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRA, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRAI, 0);
- }
- if(key==IPOKEY_OFS || key==IPOKEY_ALLMAPPING) {
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_X, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Y, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Z, 0);
- }
- if(key==IPOKEY_SIZE || key==IPOKEY_ALLMAPPING) {
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_X, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Y, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Z, 0);
- }
- if(key==IPOKEY_ALLMAPPING) {
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_R, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_G, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_B, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DVAR, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_COLF, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_NORF, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_VARF, 0);
- insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DISP, 0);
- }
-
- allspace(REMAKEIPO, 0);
- EXPP_allqueue(REDRAWIPO, 0);
- EXPP_allqueue(REDRAWVIEW3D, 0);
- EXPP_allqueue(REDRAWACTION, 0);
- EXPP_allqueue(REDRAWNLA, 0);
-
- Py_RETURN_NONE;
-}
-
-static int Material_setMode( BPy_Material * self, PyObject * value )
-{
- int param;
-
- if( !PyInt_Check( value ) ) {
- char errstr[128];
- sprintf ( errstr , "expected int bitmask of 0x%08x", MA_MODE_MASK );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
- param = PyInt_AS_LONG ( value );
-
- if ( ( param & MA_MODE_MASK ) != param )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid bit(s) set in mask" );
-
- self->material->mode &= ( MA_RAMP_COL | MA_RAMP_SPEC );
- self->material->mode |= param & ~( MA_RAMP_COL | MA_RAMP_SPEC );
-
- return 0;
-}
-
-static int Material_setRGBCol( BPy_Material * self, PyObject * value )
-{
- return rgbTuple_setCol( self->col, value );
-}
-
-/*
-static PyObject *Material_setAmbCol (BPy_Material *self, PyObject * value )
-{
- return rgbTuple_setCol(self->amb, value);
-}
-*/
-
-static int Material_setSpecCol( BPy_Material * self, PyObject * value )
-{
- return rgbTuple_setCol( self->spec, value );
-}
-
-static int Material_setMirCol( BPy_Material * self, PyObject * value )
-{
- return rgbTuple_setCol( self->mir, value );
-}
-
-static int Material_setSssCol( BPy_Material * self, PyObject * value )
-{
- return rgbTuple_setCol( self->sss, value );
-}
-
-static int Material_setColorComponent( BPy_Material * self, PyObject * value,
- void * closure )
-{
- float param;
-
- if( !PyNumber_Check ( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument in [0.0,1.0]" );
-
- param = (float)PyFloat_AsDouble( value );
- param = EXPP_ClampFloat( param, EXPP_MAT_COL_MIN, EXPP_MAT_COL_MAX );
-
- switch ( (int)closure ) {
- case EXPP_MAT_COMP_R:
- self->material->r = param;
- return 0;
- case EXPP_MAT_COMP_G:
- self->material->g = param;
- return 0;
- case EXPP_MAT_COMP_B:
- self->material->b = param;
- return 0;
- case EXPP_MAT_COMP_SPECR:
- self->material->specr = param;
- return 0;
- case EXPP_MAT_COMP_SPECG:
- self->material->specg = param;
- return 0;
- case EXPP_MAT_COMP_SPECB:
- self->material->specb = param;
- return 0;
- case EXPP_MAT_COMP_MIRR:
- self->material->mirr = param;
- return 0;
- case EXPP_MAT_COMP_MIRG:
- self->material->mirg = param;
- return 0;
- case EXPP_MAT_COMP_MIRB:
- self->material->mirb = param;
- return 0;
- case EXPP_MAT_COMP_SSSR:
- self->material->sss_col[0] = param;
- return 0;
- case EXPP_MAT_COMP_SSSG:
- self->material->sss_col[1] = param;
- return 0;
- case EXPP_MAT_COMP_SSSB:
- self->material->sss_col[2] = param;
- return 0;
- }
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "unknown color component specified" );
-}
-
-/*#define setFloatWrapper(val, min, max) {return EXPP_setFloatClamped ( value, &self->material->#val, #min, #max}*/
-
-static int Material_setAmb( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->amb,
- EXPP_MAT_AMB_MIN,
- EXPP_MAT_AMB_MAX );
-}
-
-static int Material_setEmit( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->emit,
- EXPP_MAT_EMIT_MIN,
- EXPP_MAT_EMIT_MAX );
-}
-
-static int Material_setSpecTransp( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->spectra,
- EXPP_MAT_SPECTRA_MIN,
- EXPP_MAT_SPECTRA_MAX );
-}
-
-static int Material_setAlpha( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->alpha,
- EXPP_MAT_ALPHA_MIN,
- EXPP_MAT_ALPHA_MAX );
-}
-
-static int Material_setShadAlpha( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->shad_alpha,
- EXPP_MAT_ALPHA_MIN,
- EXPP_MAT_ALPHA_MAX );
-}
-
-static int Material_setRef( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->ref,
- EXPP_MAT_REF_MIN,
- EXPP_MAT_REF_MAX );
-}
-
-static int Material_setSpec( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->spec,
- EXPP_MAT_SPEC_MIN,
- EXPP_MAT_SPEC_MAX );
-}
-
-static int Material_setZOffset( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->zoffs,
- EXPP_MAT_ZOFFS_MIN,
- EXPP_MAT_ZOFFS_MAX );
-}
-
-static int Material_setLightGroup( BPy_Material * self, PyObject * value )
-{
- return GenericLib_assignData(value, (void **) &self->material->group, NULL, 1, ID_GR, 0);
-}
-
-static int Material_setAdd( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->add,
- EXPP_MAT_ADD_MIN,
- EXPP_MAT_ADD_MAX );
-}
-
-static int Material_setHaloSize( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->hasize,
- EXPP_MAT_HALOSIZE_MIN,
- EXPP_MAT_HALOSIZE_MAX );
-}
-
-static int Material_setFlareSize( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->flaresize,
- EXPP_MAT_FLARESIZE_MIN,
- EXPP_MAT_FLARESIZE_MAX );
-}
-
-static int Material_setFlareBoost( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->flareboost,
- EXPP_MAT_FLAREBOOST_MIN,
- EXPP_MAT_FLAREBOOST_MAX );
-}
-
-static int Material_setSubSize( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->subsize,
- EXPP_MAT_SUBSIZE_MIN,
- EXPP_MAT_SUBSIZE_MAX );
-}
-
-static int Material_setHaloSeed( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->material->seed1,
- EXPP_MAT_HALOSEED_MIN,
- EXPP_MAT_HALOSEED_MAX, 'b' );
-}
-
-static int Material_setFlareSeed( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->material->seed2,
- EXPP_MAT_FLARESEED_MIN,
- EXPP_MAT_FLARESEED_MAX, 'b' );
-}
-
-static int Material_setHardness( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->material->har,
- EXPP_MAT_HARD_MIN,
- EXPP_MAT_HARD_MAX, 'h' );
-}
-
-static int Material_setNFlares( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->material->flarec,
- EXPP_MAT_NFLARES_MIN,
- EXPP_MAT_NFLARES_MAX, 'h' );
-}
-
-static int Material_setNStars( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->material->starc,
- EXPP_MAT_NSTARS_MIN,
- EXPP_MAT_NSTARS_MAX, 'h' );
-}
-
-static int Material_setNLines( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->material->linec,
- EXPP_MAT_NLINES_MIN,
- EXPP_MAT_NLINES_MAX, 'h' );
-}
-
-static int Material_setNRings( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->material->ringc,
- EXPP_MAT_NRINGS_MIN,
- EXPP_MAT_NRINGS_MAX, 'h' );
-}
-
-static int Material_setRayMirr( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->ray_mirror,
- EXPP_MAT_RAYMIRR_MIN,
- EXPP_MAT_RAYMIRR_MAX );
-}
-
-static int Material_setMirrDepth( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->material->ray_depth,
- EXPP_MAT_MIRRDEPTH_MIN,
- EXPP_MAT_MIRRDEPTH_MAX, 'h' );
-}
-
-static int Material_setFresnelMirr( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->fresnel_mir,
- EXPP_MAT_FRESNELMIRR_MIN,
- EXPP_MAT_FRESNELMIRR_MAX );
-}
-
-static int Material_setFresnelMirrFac( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->fresnel_mir_i,
- EXPP_MAT_FRESNELMIRRFAC_MIN,
- EXPP_MAT_FRESNELMIRRFAC_MAX );
-}
-
-static int Material_setIOR( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->ang,
- EXPP_MAT_IOR_MIN,
- EXPP_MAT_IOR_MAX );
-}
-
-static int Material_setTransDepth( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->material->ray_depth_tra,
- EXPP_MAT_TRANSDEPTH_MIN,
- EXPP_MAT_TRANSDEPTH_MAX, 'h' );
-}
-
-static int Material_setFresnelTrans( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->fresnel_tra,
- EXPP_MAT_FRESNELTRANS_MIN,
- EXPP_MAT_FRESNELTRANS_MAX );
-}
-
-static int Material_setFresnelTransFac( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->fresnel_tra_i,
- EXPP_MAT_FRESNELTRANSFAC_MIN,
- EXPP_MAT_FRESNELTRANSFAC_MAX );
-}
-
-static int Material_setRigidBodyFriction( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->friction,
- 0.f,
- 100.f );
-}
-
-static int Material_setRigidBodyRestitution( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->reflect,
- 0.f,
- 1.f );
-}
-
-
-
-
-static int Material_setSpecShader( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueRange( value, &self->material->spec_shader,
- MA_SPEC_COOKTORR,
- MA_SPEC_WARDISO, 'h' );
-}
-
-static int Material_setDiffuseShader( BPy_Material * self, PyObject * value )
-{
- return EXPP_setIValueRange( value, &self->material->diff_shader,
- MA_DIFF_LAMBERT,
- MA_DIFF_MINNAERT, 'h' );
-}
-
-static int Material_setRoughness( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->roughness,
- EXPP_MAT_ROUGHNESS_MIN,
- EXPP_MAT_ROUGHNESS_MAX );
-}
-
-static int Material_setSpecSize( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->param[2],
- EXPP_MAT_SPECSIZE_MIN,
- EXPP_MAT_SPECSIZE_MAX );
-}
-
-static int Material_setDiffuseSize( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->param[0],
- EXPP_MAT_DIFFUSESIZE_MIN,
- EXPP_MAT_DIFFUSESIZE_MAX );
-}
-
-static int Material_setSpecSmooth( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->param[3],
- EXPP_MAT_SPECSMOOTH_MIN,
- EXPP_MAT_SPECSMOOTH_MAX );
-}
-
-static int Material_setDiffuseSmooth( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->param[1],
- EXPP_MAT_DIFFUSESMOOTH_MIN,
- EXPP_MAT_DIFFUSESMOOTH_MAX );
-}
-
-static int Material_setDiffuseDarkness( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->darkness,
- EXPP_MAT_DIFFUSE_DARKNESS_MIN,
- EXPP_MAT_DIFFUSE_DARKNESS_MAX );
-}
-
-static int Material_setRefracIndex( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->refrac,
- EXPP_MAT_REFRACINDEX_MIN,
- EXPP_MAT_REFRACINDEX_MAX );
-}
-
-static int Material_setRms( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->rms,
- EXPP_MAT_RMS_MIN,
- EXPP_MAT_RMS_MAX );
-}
-
-static int Material_setFilter( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->filter,
- EXPP_MAT_FILTER_MIN,
- EXPP_MAT_FILTER_MAX );
-}
-
-static int Material_setTranslucency( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->translucency,
- EXPP_MAT_TRANSLUCENCY_MIN,
- EXPP_MAT_TRANSLUCENCY_MAX );
-}
-
-/* SSS */
-static int Material_setSssEnable( BPy_Material * self, PyObject * value )
-{
- return EXPP_setBitfield( value, &self->material->sss_flag, MA_DIFF_SSS, 'h' );
-}
-
-static int Material_setSssScale( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->sss_scale,
- EXPP_MAT_SSS_SCALE_MIN,
- EXPP_MAT_SSS_SCALE_MAX);
-}
-
-static int Material_setSssRadius( BPy_Material * self, PyObject * value, void *type )
-{
- return EXPP_setFloatClamped ( value, &self->material->sss_radius[(int)type],
- EXPP_MAT_SSS_RADIUS_MIN,
- EXPP_MAT_SSS_RADIUS_MAX);
-}
-
-static int Material_setSssIOR( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->sss_ior,
- EXPP_MAT_SSS_IOR_MIN,
- EXPP_MAT_SSS_IOR_MAX);
-}
-
-static int Material_setSssError( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->sss_error,
- EXPP_MAT_SSS_IOR_MIN,
- EXPP_MAT_SSS_IOR_MAX);
-}
-
-static int Material_setSssColorBlend( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->sss_colfac,
- 0.0,
- 1.0);
-}
-
-static int Material_setSssTexScatter( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->sss_texfac,
- 0.0,
- 1.0);
-}
-
-static int Material_setSssFront( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->sss_front,
- EXPP_MAT_SSS_FRONT_MIN,
- EXPP_MAT_SSS_FRONT_MAX);
-}
-
-static int Material_setSssBack( BPy_Material * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->material->sss_back,
- EXPP_MAT_SSS_BACK_MIN,
- EXPP_MAT_SSS_BACK_MAX);
-}
-
-
-
-
-static PyObject *Material_setTexture( BPy_Material * self, PyObject * args )
-{
- int texnum;
- PyObject *pytex;
- Tex *bltex;
- int texco = TEXCO_ORCO, mapto = MAP_COL;
-
- if( !PyArg_ParseTuple( args, "iO!|ii", &texnum, &Texture_Type, &pytex,
- &texco, &mapto ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int in [0,9] and Texture" );
- if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int in [0,9] and Texture" );
-
- bltex = Texture_FromPyObject( pytex );
-
- if( !self->material->mtex[texnum] ) {
- /* there isn't an mtex for this slot so we need to make one */
- self->material->mtex[texnum] = add_mtex( );
- } else {
- /* we already had a texture here so deal with the old one first */
- self->material->mtex[texnum]->tex->id.us--;
- }
-
- self->material->mtex[texnum]->tex = bltex;
- id_us_plus( &bltex->id );
- self->material->mtex[texnum]->texco = (short)texco;
- self->material->mtex[texnum]->mapto = (short)mapto;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Material_clearTexture( BPy_Material * self, PyObject * value )
-{
- int texnum = (int)PyInt_AsLong(value);
- struct MTex *mtex;
- /* non ints will be -1 */
- if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int in [0,9]" );
-
- mtex = self->material->mtex[texnum];
- if( mtex ) {
- if( mtex->tex )
- mtex->tex->id.us--;
- MEM_freeN( mtex );
- self->material->mtex[texnum] = NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-/* mat.addScriptLink */
-static PyObject *Material_addScriptLink( BPy_Material * self, PyObject * args )
-{
- Material *mat = self->material;
- ScriptLink *slink = NULL;
-
- slink = &( mat )->scriptlink;
-
- return EXPP_addScriptLink( slink, args, 0 );
-}
-
-/* mat.clearScriptLinks */
-static PyObject *Material_clearScriptLinks(BPy_Material *self, PyObject *args )
-{
- Material *mat = self->material;
- ScriptLink *slink = NULL;
-
- slink = &( mat )->scriptlink;
-
- return EXPP_clearScriptLinks( slink, args );
-}
-
-/* mat.getScriptLinks */
-static PyObject *Material_getScriptLinks( BPy_Material * self,
- PyObject * value )
-{
- Material *mat = self->material;
- ScriptLink *slink = NULL;
- PyObject *ret = NULL;
-
- slink = &( mat )->scriptlink;
-
- /* can't this just return? EXP_getScriptLinks() returns a PyObject*
- * or NULL anyway */
-
- ret = EXPP_getScriptLinks( slink, value, 0 );
-
- if( ret )
- return ret;
- else
- return NULL;
-}
-
-/* mat.__copy__ */
-static PyObject *Material_copy( BPy_Material * self )
-{
- BPy_Material *pymat; /* for Material Data object wrapper in Python */
- Material *blmat; /* for actual Material Data we create in Blender */
-
- blmat = copy_material( self->material ); /* first copy the Material Data in Blender */
-
- if( blmat ) /* now create the wrapper obj in Python */
- pymat = ( BPy_Material * ) Material_CreatePyObject( blmat );
- else
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Material Data in Blender" ) );
-
- blmat->id.us = 0; /* was incref'ed by add_material() above */
-
- if( pymat == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create Material Data object" ) );
-
- return ( PyObject * ) pymat;
-}
-
-/* mat_a==mat_b or mat_a!=mat_b*/
-static int Material_compare( BPy_Material * a, BPy_Material * b )
-{
- return ( a->material == b->material) ? 0 : -1;
-}
-
-/*****************************************************************************/
-/* Function: Material_repr */
-/* Description: This is a callback function for the BPy_Material type. It */
-/* builds a meaninful string to represent material objects. */
-/*****************************************************************************/
-static PyObject *Material_repr( BPy_Material * self )
-{
- return PyString_FromFormat( "[Material \"%s\"]",
- self->material->id.name + 2 );
-}
-
-/*****************************************************************************/
-/* These functions are used here and in in Texture.c */
-/*****************************************************************************/
-PyObject *EXPP_PyList_fromColorband( ColorBand *coba )
-{
- short i;
- PyObject *cbls;
- PyObject *colls;
-
- if (!coba)
- return PyList_New( 0 );
-
- cbls = PyList_New( coba->tot );
-
- for (i=0; i < coba->tot; i++) {
- colls = PyList_New( 5 );
- PyList_SET_ITEM( colls, 0, PyFloat_FromDouble(coba->data[i].r) );
- PyList_SET_ITEM( colls, 1, PyFloat_FromDouble(coba->data[i].g) );
- PyList_SET_ITEM( colls, 2, PyFloat_FromDouble(coba->data[i].b) );
- PyList_SET_ITEM( colls, 3, PyFloat_FromDouble(coba->data[i].a) );
- PyList_SET_ITEM( colls, 4, PyFloat_FromDouble(coba->data[i].pos) );
- PyList_SET_ITEM(cbls, i, colls);
- }
- return cbls;
-}
-
-/* make sure you coba is not none before calling this */
-int EXPP_Colorband_fromPyList( ColorBand **coba, PyObject * value )
-{
- short totcol, i;
- PyObject *colseq;
- PyObject *pyflt;
- float f;
-
- if ( !PySequence_Check( value ) )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "Colorband must be a sequence" ) );
-
- totcol = PySequence_Size(value);
- if ( totcol > 31)
- return ( EXPP_ReturnIntError( PyExc_ValueError,
- "Colorband must be between 1 and 31 in length" ) );
-
- if (totcol==0) {
- MEM_freeN(*coba);
- *coba = NULL;
- return 0;
- }
-
- if (!*coba)
- *coba = MEM_callocN( sizeof(ColorBand), "colorband");
-
- for (i=0; i<totcol; i++) {
- colseq = PySequence_GetItem( value, i );
- if ( !PySequence_Check( colseq ) || PySequence_Size( colseq ) != 5) {
- Py_DECREF ( colseq );
- return ( EXPP_ReturnIntError( PyExc_ValueError,
- "Colorband colors must be sequences of 5 floats" ) );
- }
- for (i=0; i<5; i++) {
- pyflt = PySequence_GetItem( colseq, i );
- if (!PyNumber_Check(pyflt)) {
- return ( EXPP_ReturnIntError( PyExc_ValueError,
- "Colorband colors must be sequences of 5 floats" ) );
- Py_DECREF ( pyflt );
- Py_DECREF ( colseq );
- }
- Py_DECREF ( pyflt );
- }
- Py_DECREF ( colseq );
- }
-
- /* ok, continue - should check for 5 floats, will ignore non floats for now */
- (*coba)->tot = totcol;
- for (i=0; i<totcol; i++) {
- colseq = PySequence_GetItem( value, i );
-
- pyflt = PySequence_GetItem( colseq, 0 );
- f = (float)PyFloat_AsDouble( pyflt );
- CLAMP(f, 0.0, 1.0);
- (*coba)->data[i].r = f;
- Py_DECREF ( pyflt );
-
- pyflt = PySequence_GetItem( colseq, 1 );
- f = (float)PyFloat_AsDouble( pyflt );
- CLAMP(f, 0.0, 1.0);
- (*coba)->data[i].g = f;
- Py_DECREF ( pyflt );
-
- pyflt = PySequence_GetItem( colseq, 2 );
- f = (float)PyFloat_AsDouble( pyflt );
- CLAMP(f, 0.0, 1.0);
- (*coba)->data[i].b = f;
- Py_DECREF ( pyflt );
-
- pyflt = PySequence_GetItem( colseq, 3 );
- f = (float)PyFloat_AsDouble( pyflt );
- CLAMP(f, 0.0, 1.0);
- (*coba)->data[i].a = f;
- Py_DECREF ( pyflt );
-
- pyflt = PySequence_GetItem( colseq, 4 );
- f = (float)PyFloat_AsDouble( pyflt );
- CLAMP(f, 0.0, 1.0);
- (*coba)->data[i].pos = f;
- Py_DECREF ( pyflt );
-
- Py_DECREF ( colseq );
- }
- return 0;
-}
-
-
-/*****************************************************************************/
-/* These functions are used in NMesh.c and Object.c */
-/*****************************************************************************/
-PyObject *EXPP_PyList_fromMaterialList( Material ** matlist, int len, int all )
-{
- PyObject *list;
- int i;
-
- list = PyList_New( 0 );
- if( !matlist )
- return list;
-
- for( i = 0; i < len; i++ ) {
- Material *mat = matlist[i];
- PyObject *ob;
-
- if( mat ) {
- ob = Material_CreatePyObject( mat );
- PyList_Append( list, ob );
- Py_DECREF( ob ); /* because Append increfs */
- } else if( all ) { /* return NULL mats (empty slots) as Py_None */
- PyList_Append( list, Py_None );
- }
- }
-
- return list;
-}
-
-Material **EXPP_newMaterialList_fromPyList( PyObject * list )
-{
- int i, len;
- BPy_Material *pymat = 0;
- Material *mat;
- Material **matlist;
-
- len = PySequence_Length( list );
- if( len > 16 )
- len = 16;
- else if( len <= 0 )
- return NULL;
-
- matlist = EXPP_newMaterialList( len );
-
- for( i = 0; i < len; i++ ) {
-
- pymat = ( BPy_Material * ) PySequence_GetItem( list, i );
-
- if( BPy_Material_Check( ( PyObject * ) pymat ) ) {
- mat = pymat->material;
- matlist[i] = mat;
- } else if( ( PyObject * ) pymat == Py_None ) {
- matlist[i] = NULL;
- } else { /* error; illegal type in material list */
- Py_DECREF( pymat );
- MEM_freeN( matlist );
- return NULL;
- }
-
- Py_DECREF( pymat );
- }
-
- return matlist;
-}
-
-Material **EXPP_newMaterialList( int len )
-{
- Material **matlist =
- ( Material ** ) MEM_mallocN( len * sizeof( Material * ),
- "MaterialList" );
-
- return matlist;
-}
-
-int EXPP_releaseMaterialList( Material ** matlist, int len )
-{
- int i;
- Material *mat;
-
- if( ( len < 0 ) || ( len > MAXMAT ) ) {
- printf( "illegal matindex!\n" );
- return 0;
- }
-
- for( i = 0; i < len; i++ ) {
- mat = matlist[i];
- if( mat ) {
- if( ( ( ID * ) mat )->us > 0 )
- ( ( ID * ) mat )->us--;
- else
- printf( "FATAL: material usage=0: %s",
- ( ( ID * ) mat )->name );
- }
- }
- MEM_freeN( matlist );
-
- return 1;
-}
-
-/** expands pointer array of length 'oldsize' to length 'newsize'.
- * A pointer to the (void *) array must be passed as first argument
- * The array pointer content can be NULL, in this case a new array of length
- * 'newsize' is created.
- */
-
-static int expandPtrArray( void **p, int oldsize, int newsize )
-{
- void *newarray;
-
- if( newsize < oldsize ) {
- return 0;
- }
- newarray = MEM_callocN( sizeof( void * ) * newsize, "PtrArray" );
- if( *p ) {
- memcpy( newarray, *p, sizeof( void * ) * oldsize );
- MEM_freeN( *p );
- }
- *p = newarray;
- return 1;
-}
-
-int EXPP_synchronizeMaterialLists( Object * object )
-{
- Material ***p_dataMaterials = give_matarar( object );
- short *nmaterials = give_totcolp( object );
- int result = 0;
-
- if( object->totcol > *nmaterials ) {
- /* More object mats than data mats */
- result = expandPtrArray( ( void * ) p_dataMaterials,
- *nmaterials, object->totcol );
- *nmaterials = object->totcol;
- } else {
- if( object->totcol < *nmaterials ) {
- /* More data mats than object mats */
- result = expandPtrArray( ( void * ) &object->mat,
- object->totcol, *nmaterials );
- object->totcol = (char)*nmaterials;
- }
- } /* else no synchronization needed, they are of equal length */
-
- return result; /* 1 if changed, 0 otherwise */
-}
-
-void EXPP_incr_mats_us( Material ** matlist, int len )
-{
- int i;
- Material *mat;
-
- if( len <= 0 )
- return;
-
- for( i = 0; i < len; i++ ) {
- mat = matlist[i];
- if( mat )
- mat->id.us++;
- }
-
- return;
-}
-
-static PyObject *Material_getColorComponent( BPy_Material * self,
- void * closure )
-{
- switch ( (int)closure ) {
- case EXPP_MAT_COMP_R:
- return PyFloat_FromDouble( ( double ) self->material->r );
- case EXPP_MAT_COMP_G:
- return PyFloat_FromDouble( ( double ) self->material->g );
- case EXPP_MAT_COMP_B:
- return PyFloat_FromDouble( ( double ) self->material->b );
- case EXPP_MAT_COMP_SPECR:
- return PyFloat_FromDouble( ( double ) self->material->specr );
- case EXPP_MAT_COMP_SPECG:
- return PyFloat_FromDouble( ( double ) self->material->specg );
- case EXPP_MAT_COMP_SPECB:
- return PyFloat_FromDouble( ( double ) self->material->specb );
- case EXPP_MAT_COMP_MIRR:
- return PyFloat_FromDouble( ( double ) self->material->mirr );
- case EXPP_MAT_COMP_MIRG:
- return PyFloat_FromDouble( ( double ) self->material->mirg );
- case EXPP_MAT_COMP_MIRB:
- return PyFloat_FromDouble( ( double ) self->material->mirb );
- case EXPP_MAT_COMP_SSSR:
- return PyFloat_FromDouble( ( double ) self->material->sss_col[0] );
- case EXPP_MAT_COMP_SSSG:
- return PyFloat_FromDouble( ( double ) self->material->sss_col[1] );
- case EXPP_MAT_COMP_SSSB:
- return PyFloat_FromDouble( ( double ) self->material->sss_col[2] );
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unknown color component specified" );
- }
-}
-
-static PyObject *Material_getColorband( BPy_Material * self, void * type)
-{
- switch( (long)type ) {
- case 0: /* these are backwards, but that how it works */
- return EXPP_PyList_fromColorband( self->material->ramp_col );
- case 1:
- return EXPP_PyList_fromColorband( self->material->ramp_spec );
- }
- Py_RETURN_NONE;
-}
-
-int Material_setColorband( BPy_Material * self, PyObject * value, void * type)
-{
- switch( (long)type ) {
- case 0: /* these are backwards, but that how it works */
- return EXPP_Colorband_fromPyList( &self->material->ramp_col, value );
- case 1:
- return EXPP_Colorband_fromPyList( &self->material->ramp_spec, value );
- }
- return 0;
-}
-
-/* #####DEPRECATED###### */
-
-static PyObject *Matr_oldsetAdd( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setAdd );
-}
-
-static PyObject *Matr_oldsetAlpha( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setAlpha );
-}
-
-static PyObject *Matr_oldsetAmb( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setAmb );
-}
-
-static PyObject *Matr_oldsetDiffuseDarkness( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setDiffuseDarkness );
-}
-
-static PyObject *Matr_oldsetDiffuseShader( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setDiffuseShader );
-}
-
-static PyObject *Matr_oldsetDiffuseSize( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setDiffuseSize );
-}
-
-static PyObject *Matr_oldsetDiffuseSmooth( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setDiffuseSmooth );
-}
-
-static PyObject *Matr_oldsetEmit( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setEmit );
-}
-
-static PyObject *Matr_oldsetFilter( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFilter );
-}
-
-static PyObject *Matr_oldsetFlareBoost( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFlareBoost );
-}
-
-static PyObject *Matr_oldsetFlareSeed( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFlareSeed );
-}
-
-static PyObject *Matr_oldsetFlareSize( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFlareSize );
-}
-
-static PyObject *Matr_oldsetFresnelMirr( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFresnelMirr );
-}
-
-static PyObject *Matr_oldsetFresnelMirrFac( BPy_Material * self,
- PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFresnelMirrFac );
-}
-
-static PyObject *Matr_oldsetFresnelTrans( BPy_Material * self,
- PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFresnelTrans );
-}
-
-static PyObject *Matr_oldsetFresnelTransFac( BPy_Material * self,
- PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFresnelTransFac );
-}
-
-static PyObject *Matr_oldsetHaloSeed( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setHaloSeed );
-}
-
-static PyObject *Matr_oldsetHaloSize( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setHaloSize );
-}
-
-static PyObject *Matr_oldsetHardness( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setHardness );
-}
-
-static PyObject *Matr_oldsetIOR( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setIOR );
-}
-
-static PyObject *Matr_oldsetNFlares( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setNFlares );
-}
-
-static PyObject *Matr_oldsetNLines( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setNLines );
-}
-
-static PyObject *Matr_oldsetNRings( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setNRings );
-}
-
-static PyObject *Matr_oldsetNStars( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setNStars );
-}
-
-static PyObject *Matr_oldsetRayMirr( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRayMirr );
-}
-
-static PyObject *Matr_oldsetRoughness( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRoughness );
-}
-
-static PyObject *Matr_oldsetMirrDepth( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setMirrDepth );
-}
-
-static PyObject *Matr_oldsetRef( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRef );
-}
-
-static PyObject *Matr_oldsetRefracIndex( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRefracIndex );
-}
-
-static PyObject *Matr_oldsetRms( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRms );
-}
-
-static PyObject *Matr_oldsetSpec( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpec );
-}
-
-static PyObject *Matr_oldsetSpecShader( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpecShader );
-}
-
-static PyObject *Matr_oldsetSpecSize( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpecSize );
-}
-
-static PyObject *Matr_oldsetSpecSmooth( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpecSmooth );
-}
-
-static PyObject *Matr_oldsetSpecTransp( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpecTransp );
-}
-
-static PyObject *Matr_oldsetSubSize( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSubSize );
-}
-
-static PyObject *Matr_oldsetTranslucency( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setTranslucency );
-}
-
-static PyObject *Matr_oldsetTransDepth( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setTransDepth );
-}
-
-static PyObject *Matr_oldsetZOffset( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setZOffset );
-}
-
-static PyObject *Matr_oldsetRGBCol( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Material_setRGBCol );
-}
-
-static PyObject *Matr_oldsetSpecCol( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Material_setSpecCol );
-}
-
-static PyObject *Matr_oldsetMirCol( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Material_setMirCol );
-}
-
-
-/* Possible modes are traceable, shadow, shadeless, wire, vcolLight,
- * vcolPaint, halo, ztransp, zinvert, haloRings, env, haloLines,
- * onlyShadow, xalpha, star, faceTexture, haloTex, haloPuno, noMist,
- * haloShaded, haloFlare */
-
-static PyObject *Matr_oldsetMode( BPy_Material * self, PyObject * args )
-{
- unsigned int i, flag = 0, ok = 0;
- PyObject *value, *error;
- char *m[28] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL
- };
-
- /*
- * check for a single integer argument; do a quick check for now
- * that the value is not larger than double the highest flag bit
- */
-
- if ( (PySequence_Size( args ) == 1)
- && PyInt_Check ( PyTuple_GET_ITEM ( args , 0 ) )
- && PyArg_ParseTuple( args, "i", &flag )
- && (flag & MA_MODE_MASK ) == flag ) {
- ok = 1;
-
- /*
- * check for either an empty argument list, or up to 28 strings
- */
-
- } else if( PyArg_ParseTuple( args, "|ssssssssssssssssssssssssssss",
- &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6],
- &m[7], &m[8], &m[9], &m[10], &m[11], &m[12],
- &m[13], &m[14], &m[15], &m[16], &m[17], &m[18],
- &m[19], &m[20], &m[21], &m[22], &m[23], &m[24],
- &m[25], &m[26], &m[27] ) ) {
- for( i = 0; i < 28; i++ ) {
- if( m[i] == NULL )
- break;
- if( strcmp( m[i], "Traceable" ) == 0 )
- flag |= MA_TRACEBLE;
- else if( strcmp( m[i], "Shadow" ) == 0 )
- flag |= MA_SHADOW;
- else if( strcmp( m[i], "Shadeless" ) == 0 )
- flag |= MA_SHLESS;
- else if( strcmp( m[i], "Wire" ) == 0 )
- flag |= MA_WIRE;
- else if( strcmp( m[i], "VColLight" ) == 0 )
- flag |= MA_VERTEXCOL;
- else if( strcmp( m[i], "VColPaint" ) == 0 )
- flag |= MA_VERTEXCOLP;
- else if( strcmp( m[i], "Halo" ) == 0 )
- flag |= MA_HALO;
- else if( strcmp( m[i], "ZTransp" ) == 0 )
- flag |= MA_ZTRA;
- else if( strcmp( m[i], "ZInvert" ) == 0 )
- flag |= MA_ZINV;
- else if( strcmp( m[i], "HaloRings" ) == 0 )
- flag |= MA_HALO_RINGS;
- else if( strcmp( m[i], "HaloLines" ) == 0 )
- flag |= MA_HALO_LINES;
- else if( strcmp( m[i], "OnlyShadow" ) == 0 )
- flag |= MA_ONLYSHADOW;
- else if( strcmp( m[i], "HaloXAlpha" ) == 0 )
- flag |= MA_HALO_XALPHA;
- else if( strcmp( m[i], "HaloStar" ) == 0 )
- flag |= MA_STAR;
- else if( strcmp( m[i], "TexFace" ) == 0 )
- flag |= MA_FACETEXTURE;
- else if( strcmp( m[i], "HaloTex" ) == 0 )
- flag |= MA_HALOTEX;
- else if( strcmp( m[i], "HaloPuno" ) == 0 )
- flag |= MA_HALOPUNO;
- else if( strcmp( m[i], "NoMist" ) == 0 )
- flag |= MA_NOMIST;
- else if( strcmp( m[i], "HaloShaded" ) == 0 )
- flag |= MA_HALO_SHADE;
- else if( strcmp( m[i], "HaloFlare" ) == 0 )
- flag |= MA_HALO_FLARE;
- else if( strcmp( m[i], "Radio" ) == 0 )
- flag |= MA_RADIO;
- /* ** Mirror ** */
- else if( strcmp( m[i], "RayMirr" ) == 0 )
- flag |= MA_RAYMIRROR;
- else if( strcmp( m[i], "ZTransp" ) == 0 )
- flag |= MA_ZTRA;
- else if( strcmp( m[i], "RayTransp" ) == 0 )
- flag |= MA_RAYTRANSP;
- else if( strcmp( m[i], "OnlyShadow" ) == 0 )
- flag |= MA_ONLYSHADOW;
- else if( strcmp( m[i], "NoMist" ) == 0 )
- flag |= MA_NOMIST;
- else if( strcmp( m[i], "Env" ) == 0 )
- flag |= MA_ENV;
- else
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown Material mode argument" ) );
- }
- ok = 1;
- }
-
- /* if neither input method worked, then throw an exception */
-
- if ( ok == 0 )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected nothing, an integer or up to 22 string argument(s)" ) );
- /* build tuple, call wrapper */
-
- value = Py_BuildValue("(i)", flag);
- error = EXPP_setterWrapper( (void *)self, value, (setter)Material_setMode );
- Py_DECREF ( value );
- return error;
-}
-
-static PyObject *Matr_oldsetIpo( BPy_Material * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Material_setIpo );
-}
-
-/*
- * clearIpo() returns True/False depending on whether material has an Ipo
- */
-
-static PyObject *Material_clearIpo( BPy_Material * self )
-{
- /* if Ipo defined, delete it and return true */
-
- if( self->material->ipo ) {
- PyObject *value = Py_BuildValue( "(O)", Py_None );
- EXPP_setterWrapper( (void *)self, value, (setter)Material_setIpo );
- Py_DECREF ( value );
- return EXPP_incr_ret_True();
- }
- return EXPP_incr_ret_False(); /* no ipo found */
-}
-
diff --git a/source/blender/python/api2_2x/Material.h b/source/blender/python/api2_2x/Material.h
deleted file mode 100644
index 18fc87ee803..00000000000
--- a/source/blender/python/api2_2x/Material.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c
deleted file mode 100644
index cf79b3071f7..00000000000
--- a/source/blender/python/api2_2x/Mathutils.c
+++ /dev/null
@@ -1,1804 +0,0 @@
-/*
- * $Id: Mathutils.c 11502 2007-08-06 14:27:08Z 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): Joseph Gilbert, Campbell Barton
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Mathutils.h"
-
-#include "BLI_arithb.h"
-#include "PIL_time.h"
-#include "BLI_rand.h"
-#include "BKE_utildefines.h"
-
-#include "gen_utils.h"
-
-//-------------------------DOC STRINGS ---------------------------
-static char M_Mathutils_doc[] = "The Blender Mathutils module\n\n";
-static char M_Mathutils_Vector_doc[] = "() - create a new vector object from a list of floats";
-static char M_Mathutils_Matrix_doc[] = "() - create a new matrix object from a list of floats";
-static char M_Mathutils_Quaternion_doc[] = "() - create a quaternion from a list or an axis of rotation and an angle";
-static char M_Mathutils_Euler_doc[] = "() - create and return a new euler object";
-static char M_Mathutils_Rand_doc[] = "() - return a random number";
-static char M_Mathutils_CrossVecs_doc[] = "() - returns a vector perpedicular to the 2 vectors crossed";
-static char M_Mathutils_CopyVec_doc[] = "() - create a copy of vector";
-static char M_Mathutils_DotVecs_doc[] = "() - return the dot product of two vectors";
-static char M_Mathutils_AngleBetweenVecs_doc[] = "() - returns the angle between two vectors in degrees";
-static char M_Mathutils_MidpointVecs_doc[] = "() - return the vector to the midpoint between two vectors";
-static char M_Mathutils_MatMultVec_doc[] = "() - multiplies a matrix by a column vector";
-static char M_Mathutils_VecMultMat_doc[] = "() - multiplies a row vector by a matrix";
-static char M_Mathutils_ProjectVecs_doc[] = "() - returns the projection vector from the projection of vecA onto vecB";
-static char M_Mathutils_RotationMatrix_doc[] = "() - construct a rotation matrix from an angle and axis of rotation";
-static char M_Mathutils_ScaleMatrix_doc[] = "() - construct a scaling matrix from a scaling factor";
-static char M_Mathutils_OrthoProjectionMatrix_doc[] = "() - construct a orthographic projection matrix from a selected plane";
-static char M_Mathutils_ShearMatrix_doc[] = "() - construct a shearing matrix from a plane of shear and a shear factor";
-static char M_Mathutils_CopyMat_doc[] = "() - create a copy of a matrix";
-static char M_Mathutils_TranslationMatrix_doc[] = "(vec) - create a translation matrix from a vector";
-static char M_Mathutils_CopyQuat_doc[] = "() - copy quatB to quatA";
-static char M_Mathutils_CopyEuler_doc[] = "() - copy eulB to eultA";
-static char M_Mathutils_CrossQuats_doc[] = "() - return the mutliplication of two quaternions";
-static char M_Mathutils_DotQuats_doc[] = "() - return the dot product of two quaternions";
-static char M_Mathutils_Slerp_doc[] = "() - returns the interpolation between two quaternions";
-static char M_Mathutils_DifferenceQuats_doc[] = "() - return the angular displacment difference between two quats";
-static char M_Mathutils_RotateEuler_doc[] = "() - rotate euler by an axis and angle";
-static char M_Mathutils_Intersect_doc[] = "(v1, v2, v3, ray, orig, clip=1) - returns the intersection between a ray and a triangle, if possible, returns None otherwise";
-static char M_Mathutils_TriangleArea_doc[] = "(v1, v2, v3) - returns the area size of the 2D or 3D triangle defined";
-static char M_Mathutils_TriangleNormal_doc[] = "(v1, v2, v3) - returns the normal of the 3D triangle defined";
-static char M_Mathutils_QuadNormal_doc[] = "(v1, v2, v3, v4) - returns the normal of the 3D quad defined";
-static char M_Mathutils_LineIntersect_doc[] = "(v1, v2, v3, v4) - returns a tuple with the points on each line respectively closest to the other";
-static char M_Mathutils_Point_doc[] = "Creates a 2d or 3d point object";
-//-----------------------METHOD DEFINITIONS ----------------------
-struct PyMethodDef M_Mathutils_methods[] = {
- {"Rand", (PyCFunction) M_Mathutils_Rand, METH_VARARGS, M_Mathutils_Rand_doc},
- {"Vector", (PyCFunction) M_Mathutils_Vector, METH_VARARGS, M_Mathutils_Vector_doc},
- {"CrossVecs", (PyCFunction) M_Mathutils_CrossVecs, METH_VARARGS, M_Mathutils_CrossVecs_doc},
- {"DotVecs", (PyCFunction) M_Mathutils_DotVecs, METH_VARARGS, M_Mathutils_DotVecs_doc},
- {"AngleBetweenVecs", (PyCFunction) M_Mathutils_AngleBetweenVecs, METH_VARARGS, M_Mathutils_AngleBetweenVecs_doc},
- {"MidpointVecs", (PyCFunction) M_Mathutils_MidpointVecs, METH_VARARGS, M_Mathutils_MidpointVecs_doc},
- {"VecMultMat", (PyCFunction) M_Mathutils_VecMultMat, METH_VARARGS, M_Mathutils_VecMultMat_doc},
- {"ProjectVecs", (PyCFunction) M_Mathutils_ProjectVecs, METH_VARARGS, M_Mathutils_ProjectVecs_doc},
- {"CopyVec", (PyCFunction) M_Mathutils_CopyVec, METH_VARARGS, M_Mathutils_CopyVec_doc},
- {"Matrix", (PyCFunction) M_Mathutils_Matrix, METH_VARARGS, M_Mathutils_Matrix_doc},
- {"RotationMatrix", (PyCFunction) M_Mathutils_RotationMatrix, METH_VARARGS, M_Mathutils_RotationMatrix_doc},
- {"ScaleMatrix", (PyCFunction) M_Mathutils_ScaleMatrix, METH_VARARGS, M_Mathutils_ScaleMatrix_doc},
- {"ShearMatrix", (PyCFunction) M_Mathutils_ShearMatrix, METH_VARARGS, M_Mathutils_ShearMatrix_doc},
- {"TranslationMatrix", (PyCFunction) M_Mathutils_TranslationMatrix, METH_O, M_Mathutils_TranslationMatrix_doc},
- {"CopyMat", (PyCFunction) M_Mathutils_CopyMat, METH_VARARGS, M_Mathutils_CopyMat_doc},
- {"OrthoProjectionMatrix", (PyCFunction) M_Mathutils_OrthoProjectionMatrix, METH_VARARGS, M_Mathutils_OrthoProjectionMatrix_doc},
- {"MatMultVec", (PyCFunction) M_Mathutils_MatMultVec, METH_VARARGS, M_Mathutils_MatMultVec_doc},
- {"Quaternion", (PyCFunction) M_Mathutils_Quaternion, METH_VARARGS, M_Mathutils_Quaternion_doc},
- {"CopyQuat", (PyCFunction) M_Mathutils_CopyQuat, METH_VARARGS, M_Mathutils_CopyQuat_doc},
- {"CrossQuats", (PyCFunction) M_Mathutils_CrossQuats, METH_VARARGS, M_Mathutils_CrossQuats_doc},
- {"DotQuats", (PyCFunction) M_Mathutils_DotQuats, METH_VARARGS, M_Mathutils_DotQuats_doc},
- {"DifferenceQuats", (PyCFunction) M_Mathutils_DifferenceQuats, METH_VARARGS,M_Mathutils_DifferenceQuats_doc},
- {"Slerp", (PyCFunction) M_Mathutils_Slerp, METH_VARARGS, M_Mathutils_Slerp_doc},
- {"Euler", (PyCFunction) M_Mathutils_Euler, METH_VARARGS, M_Mathutils_Euler_doc},
- {"CopyEuler", (PyCFunction) M_Mathutils_CopyEuler, METH_VARARGS, M_Mathutils_CopyEuler_doc},
- {"RotateEuler", (PyCFunction) M_Mathutils_RotateEuler, METH_VARARGS, M_Mathutils_RotateEuler_doc},
- {"Intersect", ( PyCFunction ) M_Mathutils_Intersect, METH_VARARGS, M_Mathutils_Intersect_doc},
- {"TriangleArea", ( PyCFunction ) M_Mathutils_TriangleArea, METH_VARARGS, M_Mathutils_TriangleArea_doc},
- {"TriangleNormal", ( PyCFunction ) M_Mathutils_TriangleNormal, METH_VARARGS, M_Mathutils_TriangleNormal_doc},
- {"QuadNormal", ( PyCFunction ) M_Mathutils_QuadNormal, METH_VARARGS, M_Mathutils_QuadNormal_doc},
- {"LineIntersect", ( PyCFunction ) M_Mathutils_LineIntersect, METH_VARARGS, M_Mathutils_LineIntersect_doc},
- {"Point", (PyCFunction) M_Mathutils_Point, METH_VARARGS, M_Mathutils_Point_doc},
- {NULL, NULL, 0, NULL}
-};
-//----------------------------MODULE INIT-------------------------
-PyObject *Mathutils_Init(void)
-{
- PyObject *submodule;
-
- //seed the generator for the rand function
- BLI_srand((unsigned int) (PIL_check_seconds_timer() *
- 0x7FFFFFFF));
-
- /* needed for getseters */
- if( PyType_Ready( &vector_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &matrix_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &euler_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &quaternion_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3("Blender.Mathutils",
- M_Mathutils_methods, M_Mathutils_doc);
- return (submodule);
-}
-//-----------------------------METHODS----------------------------
-//----------------column_vector_multiplication (internal)---------
-//COLUMN VECTOR Multiplication (Matrix X Vector)
-// [1][2][3] [a]
-// [4][5][6] * [b]
-// [7][8][9] [c]
-//vector/matrix multiplication IS NOT COMMUTATIVE!!!!
-PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject* vec)
-{
- float vecNew[4], vecCopy[4];
- double dot = 0.0f;
- int x, y, z = 0;
-
- if(mat->rowSize != vec->size){
- if(mat->rowSize == 4 && vec->size != 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "matrix * vector: matrix row size and vector size must be the same");
- }else{
- vecCopy[3] = 1.0f;
- }
- }
-
- for(x = 0; x < vec->size; x++){
- vecCopy[x] = vec->vec[x];
- }
-
- for(x = 0; x < mat->rowSize; x++) {
- for(y = 0; y < mat->colSize; y++) {
- dot += mat->matrix[x][y] * vecCopy[y];
- }
- vecNew[z++] = (float)dot;
- dot = 0.0f;
- }
- return newVectorObject(vecNew, vec->size, Py_NEW);
-}
-//This is a helper for point/matrix translation
-
-PyObject *column_point_multiplication(MatrixObject * mat, PointObject* pt)
-{
- float ptNew[4], ptCopy[4];
- double dot = 0.0f;
- int x, y, z = 0;
-
- if(mat->rowSize != pt->size){
- if(mat->rowSize == 4 && pt->size != 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "matrix * point: matrix row size and point size must be the same\n");
- }else{
- ptCopy[3] = 0.0f;
- }
- }
-
- for(x = 0; x < pt->size; x++){
- ptCopy[x] = pt->coord[x];
- }
-
- for(x = 0; x < mat->rowSize; x++) {
- for(y = 0; y < mat->colSize; y++) {
- dot += mat->matrix[x][y] * ptCopy[y];
- }
- ptNew[z++] = (float)dot;
- dot = 0.0f;
- }
- return newPointObject(ptNew, pt->size, Py_NEW);
-}
-//-----------------row_vector_multiplication (internal)-----------
-//ROW VECTOR Multiplication - Vector X Matrix
-//[x][y][z] * [1][2][3]
-// [4][5][6]
-// [7][8][9]
-//vector/matrix multiplication IS NOT COMMUTATIVE!!!!
-PyObject *row_vector_multiplication(VectorObject* vec, MatrixObject * mat)
-{
- float vecNew[4], vecCopy[4];
- double dot = 0.0f;
- int x, y, z = 0, vec_size = vec->size;
-
- if(mat->colSize != vec_size){
- if(mat->rowSize == 4 && vec_size != 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "vector * matrix: matrix column size and the vector size must be the same");
- }else{
- vecCopy[3] = 1.0f;
- }
- }
-
- for(x = 0; x < vec_size; x++){
- vecCopy[x] = vec->vec[x];
- }
-
- //muliplication
- for(x = 0; x < mat->colSize; x++) {
- for(y = 0; y < mat->rowSize; y++) {
- dot += mat->matrix[y][x] * vecCopy[y];
- }
- vecNew[z++] = (float)dot;
- dot = 0.0f;
- }
- return newVectorObject(vecNew, vec_size, Py_NEW);
-}
-//This is a helper for the point class
-PyObject *row_point_multiplication(PointObject* pt, MatrixObject * mat)
-{
- float ptNew[4], ptCopy[4];
- double dot = 0.0f;
- int x, y, z = 0, size;
-
- if(mat->colSize != pt->size){
- if(mat->rowSize == 4 && pt->size != 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "point * matrix: matrix column size and the point size must be the same\n");
- }else{
- ptCopy[3] = 0.0f;
- }
- }
- size = pt->size;
- for(x = 0; x < pt->size; x++){
- ptCopy[x] = pt->coord[x];
- }
-
- //muliplication
- for(x = 0; x < mat->colSize; x++) {
- for(y = 0; y < mat->rowSize; y++) {
- dot += mat->matrix[y][x] * ptCopy[y];
- }
- ptNew[z++] = (float)dot;
- dot = 0.0f;
- }
- return newPointObject(ptNew, size, Py_NEW);
-}
-//-----------------quat_rotation (internal)-----------
-//This function multiplies a vector/point * quat or vice versa
-//to rotate the point/vector by the quaternion
-//arguments should all be 3D
-PyObject *quat_rotation(PyObject *arg1, PyObject *arg2)
-{
- float rot[3];
- QuaternionObject *quat = NULL;
- VectorObject *vec = NULL;
- PointObject *pt = NULL;
-
- if(QuaternionObject_Check(arg1)){
- quat = (QuaternionObject*)arg1;
- if(VectorObject_Check(arg2)){
- vec = (VectorObject*)arg2;
- rot[0] = quat->quat[0]*quat->quat[0]*vec->vec[0] + 2*quat->quat[2]*quat->quat[0]*vec->vec[2] -
- 2*quat->quat[3]*quat->quat[0]*vec->vec[1] + quat->quat[1]*quat->quat[1]*vec->vec[0] +
- 2*quat->quat[2]*quat->quat[1]*vec->vec[1] + 2*quat->quat[3]*quat->quat[1]*vec->vec[2] -
- quat->quat[3]*quat->quat[3]*vec->vec[0] - quat->quat[2]*quat->quat[2]*vec->vec[0];
- rot[1] = 2*quat->quat[1]*quat->quat[2]*vec->vec[0] + quat->quat[2]*quat->quat[2]*vec->vec[1] +
- 2*quat->quat[3]*quat->quat[2]*vec->vec[2] + 2*quat->quat[0]*quat->quat[3]*vec->vec[0] -
- quat->quat[3]*quat->quat[3]*vec->vec[1] + quat->quat[0]*quat->quat[0]*vec->vec[1] -
- 2*quat->quat[1]*quat->quat[0]*vec->vec[2] - quat->quat[1]*quat->quat[1]*vec->vec[1];
- rot[2] = 2*quat->quat[1]*quat->quat[3]*vec->vec[0] + 2*quat->quat[2]*quat->quat[3]*vec->vec[1] +
- quat->quat[3]*quat->quat[3]*vec->vec[2] - 2*quat->quat[0]*quat->quat[2]*vec->vec[0] -
- quat->quat[2]*quat->quat[2]*vec->vec[2] + 2*quat->quat[0]*quat->quat[1]*vec->vec[1] -
- quat->quat[1]*quat->quat[1]*vec->vec[2] + quat->quat[0]*quat->quat[0]*vec->vec[2];
- return newVectorObject(rot, 3, Py_NEW);
- }else if(PointObject_Check(arg2)){
- pt = (PointObject*)arg2;
- rot[0] = quat->quat[0]*quat->quat[0]*pt->coord[0] + 2*quat->quat[2]*quat->quat[0]*pt->coord[2] -
- 2*quat->quat[3]*quat->quat[0]*pt->coord[1] + quat->quat[1]*quat->quat[1]*pt->coord[0] +
- 2*quat->quat[2]*quat->quat[1]*pt->coord[1] + 2*quat->quat[3]*quat->quat[1]*pt->coord[2] -
- quat->quat[3]*quat->quat[3]*pt->coord[0] - quat->quat[2]*quat->quat[2]*pt->coord[0];
- rot[1] = 2*quat->quat[1]*quat->quat[2]*pt->coord[0] + quat->quat[2]*quat->quat[2]*pt->coord[1] +
- 2*quat->quat[3]*quat->quat[2]*pt->coord[2] + 2*quat->quat[0]*quat->quat[3]*pt->coord[0] -
- quat->quat[3]*quat->quat[3]*pt->coord[1] + quat->quat[0]*quat->quat[0]*pt->coord[1] -
- 2*quat->quat[1]*quat->quat[0]*pt->coord[2] - quat->quat[1]*quat->quat[1]*pt->coord[1];
- rot[2] = 2*quat->quat[1]*quat->quat[3]*pt->coord[0] + 2*quat->quat[2]*quat->quat[3]*pt->coord[1] +
- quat->quat[3]*quat->quat[3]*pt->coord[2] - 2*quat->quat[0]*quat->quat[2]*pt->coord[0] -
- quat->quat[2]*quat->quat[2]*pt->coord[2] + 2*quat->quat[0]*quat->quat[1]*pt->coord[1] -
- quat->quat[1]*quat->quat[1]*pt->coord[2] + quat->quat[0]*quat->quat[0]*pt->coord[2];
- return newPointObject(rot, 3, Py_NEW);
- }
- }else if(VectorObject_Check(arg1)){
- vec = (VectorObject*)arg1;
- if(QuaternionObject_Check(arg2)){
- quat = (QuaternionObject*)arg2;
- rot[0] = quat->quat[0]*quat->quat[0]*vec->vec[0] + 2*quat->quat[2]*quat->quat[0]*vec->vec[2] -
- 2*quat->quat[3]*quat->quat[0]*vec->vec[1] + quat->quat[1]*quat->quat[1]*vec->vec[0] +
- 2*quat->quat[2]*quat->quat[1]*vec->vec[1] + 2*quat->quat[3]*quat->quat[1]*vec->vec[2] -
- quat->quat[3]*quat->quat[3]*vec->vec[0] - quat->quat[2]*quat->quat[2]*vec->vec[0];
- rot[1] = 2*quat->quat[1]*quat->quat[2]*vec->vec[0] + quat->quat[2]*quat->quat[2]*vec->vec[1] +
- 2*quat->quat[3]*quat->quat[2]*vec->vec[2] + 2*quat->quat[0]*quat->quat[3]*vec->vec[0] -
- quat->quat[3]*quat->quat[3]*vec->vec[1] + quat->quat[0]*quat->quat[0]*vec->vec[1] -
- 2*quat->quat[1]*quat->quat[0]*vec->vec[2] - quat->quat[1]*quat->quat[1]*vec->vec[1];
- rot[2] = 2*quat->quat[1]*quat->quat[3]*vec->vec[0] + 2*quat->quat[2]*quat->quat[3]*vec->vec[1] +
- quat->quat[3]*quat->quat[3]*vec->vec[2] - 2*quat->quat[0]*quat->quat[2]*vec->vec[0] -
- quat->quat[2]*quat->quat[2]*vec->vec[2] + 2*quat->quat[0]*quat->quat[1]*vec->vec[1] -
- quat->quat[1]*quat->quat[1]*vec->vec[2] + quat->quat[0]*quat->quat[0]*vec->vec[2];
- return newVectorObject(rot, 3, Py_NEW);
- }
- }else if(PointObject_Check(arg1)){
- pt = (PointObject*)arg1;
- if(QuaternionObject_Check(arg2)){
- quat = (QuaternionObject*)arg2;
- rot[0] = quat->quat[0]*quat->quat[0]*pt->coord[0] + 2*quat->quat[2]*quat->quat[0]*pt->coord[2] -
- 2*quat->quat[3]*quat->quat[0]*pt->coord[1] + quat->quat[1]*quat->quat[1]*pt->coord[0] +
- 2*quat->quat[2]*quat->quat[1]*pt->coord[1] + 2*quat->quat[3]*quat->quat[1]*pt->coord[2] -
- quat->quat[3]*quat->quat[3]*pt->coord[0] - quat->quat[2]*quat->quat[2]*pt->coord[0];
- rot[1] = 2*quat->quat[1]*quat->quat[2]*pt->coord[0] + quat->quat[2]*quat->quat[2]*pt->coord[1] +
- 2*quat->quat[3]*quat->quat[2]*pt->coord[2] + 2*quat->quat[0]*quat->quat[3]*pt->coord[0] -
- quat->quat[3]*quat->quat[3]*pt->coord[1] + quat->quat[0]*quat->quat[0]*pt->coord[1] -
- 2*quat->quat[1]*quat->quat[0]*pt->coord[2] - quat->quat[1]*quat->quat[1]*pt->coord[1];
- rot[2] = 2*quat->quat[1]*quat->quat[3]*pt->coord[0] + 2*quat->quat[2]*quat->quat[3]*pt->coord[1] +
- quat->quat[3]*quat->quat[3]*pt->coord[2] - 2*quat->quat[0]*quat->quat[2]*pt->coord[0] -
- quat->quat[2]*quat->quat[2]*pt->coord[2] + 2*quat->quat[0]*quat->quat[1]*pt->coord[1] -
- quat->quat[1]*quat->quat[1]*pt->coord[2] + quat->quat[0]*quat->quat[0]*pt->coord[2];
- return newPointObject(rot, 3, Py_NEW);
- }
- }
-
- return (EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "quat_rotation(internal): internal problem rotating vector/point\n"));
-}
-
-//----------------------------------Mathutils.Rand() --------------------
-//returns a random number between a high and low value
-PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args)
-{
- float high, low, range;
- double rand;
- //initializers
- high = 1.0;
- low = 0.0;
-
- if(!PyArg_ParseTuple(args, "|ff", &low, &high))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Rand(): expected nothing or optional (float, float)\n"));
-
- if((high < low) || (high < 0 && low > 0))
- return (EXPP_ReturnPyObjError(PyExc_ValueError,
- "Mathutils.Rand(): high value should be larger than low value\n"));
-
- //get the random number 0 - 1
- rand = BLI_drand();
-
- //set it to range
- range = high - low;
- rand = rand * range;
- rand = rand + low;
-
- return PyFloat_FromDouble(rand);
-}
-//----------------------------------VECTOR FUNCTIONS---------------------
-//----------------------------------Mathutils.Vector() ------------------
-// Supports 2D, 3D, and 4D vector objects both int and float values
-// accepted. Mixed float and int values accepted. Ints are parsed to float
-PyObject *M_Mathutils_Vector(PyObject * self, PyObject * args)
-{
- PyObject *listObject = NULL;
- int size, i;
- float vec[4];
- PyObject *v, *f;
-
- size = PySequence_Length(args);
- if (size == 1) {
- listObject = PySequence_GetItem(args, 0);
- if (PySequence_Check(listObject)) {
- size = PySequence_Length(listObject);
- } else { // Single argument was not a sequence
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
- }
- } else if (size == 0) {
- //returns a new empty 3d vector
- return newVectorObject(NULL, 3, Py_NEW);
- } else {
- listObject = EXPP_incr_ret(args);
- }
-
- if (size<2 || size>4) { // Invalid vector size
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
- }
-
- for (i=0; i<size; i++) {
- v=PySequence_GetItem(listObject, i);
- if (v==NULL) { // Failed to read sequence
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
- }
-
- f=PyNumber_Float(v);
- if(f==NULL) { // parsed item not a number
- Py_DECREF(v);
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
- }
-
- vec[i]=(float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(f,v);
- }
- Py_DECREF(listObject);
- return newVectorObject(vec, size, Py_NEW);
-}
-//----------------------------------Mathutils.CrossVecs() ---------------
-//finds perpendicular vector - only 3D is supported
-PyObject *M_Mathutils_CrossVecs(PyObject * self, PyObject * args)
-{
- PyObject *vecCross = NULL;
- VectorObject *vec1 = NULL, *vec2 = NULL;
-
- if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.CrossVecs(): expects (2) 3D vector objects\n");
- if(vec1->size != 3 || vec2->size != 3)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.CrossVecs(): expects (2) 3D vector objects\n");
-
- vecCross = newVectorObject(NULL, 3, Py_NEW);
- Crossf(((VectorObject*)vecCross)->vec, vec1->vec, vec2->vec);
- return vecCross;
-}
-//----------------------------------Mathutils.DotVec() -------------------
-//calculates the dot product of two vectors
-PyObject *M_Mathutils_DotVecs(PyObject * self, PyObject * args)
-{
- VectorObject *vec1 = NULL, *vec2 = NULL;
- double dot = 0.0f;
- int x;
-
- if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.DotVecs(): expects (2) vector objects of the same size\n");
- if(vec1->size != vec2->size)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.DotVecs(): expects (2) vector objects of the same size\n");
-
- for(x = 0; x < vec1->size; x++) {
- dot += vec1->vec[x] * vec2->vec[x];
- }
- return PyFloat_FromDouble(dot);
-}
-//----------------------------------Mathutils.AngleBetweenVecs() ---------
-//calculates the angle between 2 vectors
-PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args)
-{
- VectorObject *vec1 = NULL, *vec2 = NULL;
- double dot = 0.0f, angleRads, test_v1 = 0.0f, test_v2 = 0.0f;
- int x, size;
-
- if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- goto AttributeError1; //not vectors
- if(vec1->size != vec2->size)
- goto AttributeError1; //bad sizes
-
- //since size is the same....
- size = vec1->size;
-
- for(x = 0; x < size; x++) {
- test_v1 += vec1->vec[x] * vec1->vec[x];
- test_v2 += vec2->vec[x] * vec2->vec[x];
- }
- if (!test_v1 || !test_v2){
- goto AttributeError2; //zero-length vector
- }
-
- //dot product
- for(x = 0; x < size; x++) {
- dot += vec1->vec[x] * vec2->vec[x];
- }
- dot /= (sqrt(test_v1) * sqrt(test_v2));
-
- if (dot < -1.0f || dot > 1.0f) {
- CLAMP(dot,-1.0f,1.0f);
- }
- angleRads = (double)acos(dot);
-
- return PyFloat_FromDouble(angleRads * (180/ Py_PI));
-
-AttributeError1:
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.AngleBetweenVecs(): expects (2) VECTOR objects of the same size\n");
-
-AttributeError2:
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.AngleBetweenVecs(): zero length vectors are not acceptable arguments\n");
-}
-//----------------------------------Mathutils.MidpointVecs() -------------
-//calculates the midpoint between 2 vectors
-PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args)
-{
- VectorObject *vec1 = NULL, *vec2 = NULL;
- float vec[4];
- int x;
-
- if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.MidpointVecs(): expects (2) vector objects of the same size\n");
- if(vec1->size != vec2->size)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.MidpointVecs(): expects (2) vector objects of the same size\n");
-
- for(x = 0; x < vec1->size; x++) {
- vec[x] = 0.5f * (vec1->vec[x] + vec2->vec[x]);
- }
- return newVectorObject(vec, vec1->size, Py_NEW);
-}
-//----------------------------------Mathutils.ProjectVecs() -------------
-//projects vector 1 onto vector 2
-PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args)
-{
- VectorObject *vec1 = NULL, *vec2 = NULL;
- float vec[4];
- double dot = 0.0f, dot2 = 0.0f;
- int x, size;
-
- if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.ProjectVecs(): expects (2) vector objects of the same size\n");
- if(vec1->size != vec2->size)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.ProjectVecs(): expects (2) vector objects of the same size\n");
-
- //since they are the same size...
- size = vec1->size;
-
- //get dot products
- for(x = 0; x < size; x++) {
- dot += vec1->vec[x] * vec2->vec[x];
- dot2 += vec2->vec[x] * vec2->vec[x];
- }
- //projection
- dot /= dot2;
- for(x = 0; x < size; x++) {
- vec[x] = (float)(dot * vec2->vec[x]);
- }
- return newVectorObject(vec, size, Py_NEW);
-}
-//----------------------------------MATRIX FUNCTIONS--------------------
-//----------------------------------Mathutils.Matrix() -----------------
-//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
-//create a new matrix type
-PyObject *M_Mathutils_Matrix(PyObject * self, PyObject * args)
-{
- PyObject *listObject = NULL;
- PyObject *argObject, *m, *s, *f;
- MatrixObject *mat;
- int argSize, seqSize = 0, i, j;
- float matrix[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
-
- argSize = PySequence_Length(args);
- if(argSize > 4){ //bad arg nums
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
- } else if (argSize == 0) { //return empty 4D matrix
- return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW);
- }else if (argSize == 1){
- //copy constructor for matrix objects
- argObject = PySequence_GetItem(args, 0);
- if(MatrixObject_Check(argObject)){
- mat = (MatrixObject*)argObject;
-
- argSize = mat->rowSize; //rows
- seqSize = mat->colSize; //col
- for(i = 0; i < (seqSize * argSize); i++){
- matrix[i] = mat->contigPtr[i];
- }
- }
- Py_DECREF(argObject);
- }else{ //2-4 arguments (all seqs? all same size?)
- for(i =0; i < argSize; i++){
- argObject = PySequence_GetItem(args, i);
- if (PySequence_Check(argObject)) { //seq?
- if(seqSize){ //0 at first
- if(PySequence_Length(argObject) != seqSize){ //seq size not same
- Py_DECREF(argObject);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
- }
- }
- seqSize = PySequence_Length(argObject);
- }else{ //arg not a sequence
- Py_XDECREF(argObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
- }
- Py_DECREF(argObject);
- }
- //all is well... let's continue parsing
- listObject = args;
- for (i = 0; i < argSize; i++){
- m = PySequence_GetItem(listObject, i);
- if (m == NULL) { // Failed to read sequence
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "Mathutils.Matrix(): failed to parse arguments...\n");
- }
-
- for (j = 0; j < seqSize; j++) {
- s = PySequence_GetItem(m, j);
- if (s == NULL) { // Failed to read sequence
- Py_DECREF(m);
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "Mathutils.Matrix(): failed to parse arguments...\n");
- }
-
- f = PyNumber_Float(s);
- if(f == NULL) { // parsed item is not a number
- EXPP_decr2(m,s);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
- }
-
- matrix[(seqSize*i)+j]=(float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(f,s);
- }
- Py_DECREF(m);
- }
- }
- return newMatrixObject(matrix, argSize, seqSize, Py_NEW);
-}
-//----------------------------------Mathutils.RotationMatrix() ----------
-//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
-//creates a rotation matrix
-PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args)
-{
- VectorObject *vec = NULL;
- char *axis = NULL;
- int matSize;
- float angle = 0.0f, norm = 0.0f, cosAngle = 0.0f, sinAngle = 0.0f;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
-
- if(!PyArg_ParseTuple
- (args, "fi|sO!", &angle, &matSize, &axis, &vector_Type, &vec)) {
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "Mathutils.RotationMatrix(): expected float int and optional string and vector\n");
- }
-
- /* Clamp to -360:360 */
- while (angle<-360.0f)
- angle+=360.0;
- while (angle>360.0f)
- angle-=360.0;
-
- if(matSize != 2 && matSize != 3 && matSize != 4)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
- if(matSize == 2 && (axis != NULL || vec != NULL))
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.RotationMatrix(): cannot create a 2x2 rotation matrix around arbitrary axis\n");
- if((matSize == 3 || matSize == 4) && axis == NULL)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.RotationMatrix(): please choose an axis of rotation for 3d and 4d matrices\n");
- if(axis) {
- if(((strcmp(axis, "r") == 0) ||
- (strcmp(axis, "R") == 0)) && vec == NULL)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.RotationMatrix(): please define the arbitrary axis of rotation\n");
- }
- if(vec) {
- if(vec->size != 3)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.RotationMatrix(): the arbitrary axis must be a 3D vector\n");
- }
- //convert to radians
- angle = angle * (float) (Py_PI / 180);
- if(axis == NULL && matSize == 2) {
- //2D rotation matrix
- mat[0] = (float) cos (angle);
- mat[1] = (float) sin (angle);
- mat[2] = -((float) sin(angle));
- mat[3] = (float) cos(angle);
- } else if((strcmp(axis, "x") == 0) || (strcmp(axis, "X") == 0)) {
- //rotation around X
- mat[0] = 1.0f;
- mat[4] = (float) cos(angle);
- mat[5] = (float) sin(angle);
- mat[7] = -((float) sin(angle));
- mat[8] = (float) cos(angle);
- } else if((strcmp(axis, "y") == 0) || (strcmp(axis, "Y") == 0)) {
- //rotation around Y
- mat[0] = (float) cos(angle);
- mat[2] = -((float) sin(angle));
- mat[4] = 1.0f;
- mat[6] = (float) sin(angle);
- mat[8] = (float) cos(angle);
- } else if((strcmp(axis, "z") == 0) || (strcmp(axis, "Z") == 0)) {
- //rotation around Z
- mat[0] = (float) cos(angle);
- mat[1] = (float) sin(angle);
- mat[3] = -((float) sin(angle));
- mat[4] = (float) cos(angle);
- mat[8] = 1.0f;
- } else if((strcmp(axis, "r") == 0) || (strcmp(axis, "R") == 0)) {
- //arbitrary rotation
- //normalize arbitrary axis
- norm = (float) sqrt(vec->vec[0] * vec->vec[0] +
- vec->vec[1] * vec->vec[1] +
- vec->vec[2] * vec->vec[2]);
- vec->vec[0] /= norm;
- vec->vec[1] /= norm;
- vec->vec[2] /= norm;
-
- //create matrix
- cosAngle = (float) cos(angle);
- sinAngle = (float) sin(angle);
- mat[0] = ((vec->vec[0] * vec->vec[0]) * (1 - cosAngle)) +
- cosAngle;
- mat[1] = ((vec->vec[0] * vec->vec[1]) * (1 - cosAngle)) +
- (vec->vec[2] * sinAngle);
- mat[2] = ((vec->vec[0] * vec->vec[2]) * (1 - cosAngle)) -
- (vec->vec[1] * sinAngle);
- mat[3] = ((vec->vec[0] * vec->vec[1]) * (1 - cosAngle)) -
- (vec->vec[2] * sinAngle);
- mat[4] = ((vec->vec[1] * vec->vec[1]) * (1 - cosAngle)) +
- cosAngle;
- mat[5] = ((vec->vec[1] * vec->vec[2]) * (1 - cosAngle)) +
- (vec->vec[0] * sinAngle);
- mat[6] = ((vec->vec[0] * vec->vec[2]) * (1 - cosAngle)) +
- (vec->vec[1] * sinAngle);
- mat[7] = ((vec->vec[1] * vec->vec[2]) * (1 - cosAngle)) -
- (vec->vec[0] * sinAngle);
- mat[8] = ((vec->vec[2] * vec->vec[2]) * (1 - cosAngle)) +
- cosAngle;
- } else {
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.RotationMatrix(): unrecognizable axis of rotation type - expected x,y,z or r\n");
- }
- if(matSize == 4) {
- //resize matrix
- mat[10] = mat[8];
- mat[9] = mat[7];
- mat[8] = mat[6];
- mat[7] = 0.0f;
- mat[6] = mat[5];
- mat[5] = mat[4];
- mat[4] = mat[3];
- mat[3] = 0.0f;
- }
- //pass to matrix creation
- return newMatrixObject(mat, matSize, matSize, Py_NEW);
-}
-//----------------------------------Mathutils.TranslationMatrix() -------
-//creates a translation matrix
-PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * vec)
-{
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
-
- if(!VectorObject_Check(vec)) {
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.TranslationMatrix(): expected vector\n");
- }
- if(vec->size != 3 && vec->size != 4) {
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.TranslationMatrix(): vector must be 3D or 4D\n");
- }
- //create a identity matrix and add translation
- Mat4One((float(*)[4]) mat);
- mat[12] = vec->vec[0];
- mat[13] = vec->vec[1];
- mat[14] = vec->vec[2];
-
- return newMatrixObject(mat, 4, 4, Py_NEW);
-}
-//----------------------------------Mathutils.ScaleMatrix() -------------
-//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
-//creates a scaling matrix
-PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args)
-{
- VectorObject *vec = NULL;
- float norm = 0.0f, factor;
- int matSize, x;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
-
- if(!PyArg_ParseTuple
- (args, "fi|O!", &factor, &matSize, &vector_Type, &vec)) {
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.ScaleMatrix(): expected float int and optional vector\n");
- }
- if(matSize != 2 && matSize != 3 && matSize != 4)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.ScaleMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
- if(vec) {
- if(vec->size > 2 && matSize == 2)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.ScaleMatrix(): please use 2D vectors when scaling in 2D\n");
- }
- if(vec == NULL) { //scaling along axis
- if(matSize == 2) {
- mat[0] = factor;
- mat[3] = factor;
- } else {
- mat[0] = factor;
- mat[4] = factor;
- mat[8] = factor;
- }
- } else { //scaling in arbitrary direction
- //normalize arbitrary axis
- for(x = 0; x < vec->size; x++) {
- norm += vec->vec[x] * vec->vec[x];
- }
- norm = (float) sqrt(norm);
- for(x = 0; x < vec->size; x++) {
- vec->vec[x] /= norm;
- }
- if(matSize == 2) {
- mat[0] = 1 +((factor - 1) *(vec->vec[0] * vec->vec[0]));
- mat[1] =((factor - 1) *(vec->vec[0] * vec->vec[1]));
- mat[2] =((factor - 1) *(vec->vec[0] * vec->vec[1]));
- mat[3] = 1 + ((factor - 1) *(vec->vec[1] * vec->vec[1]));
- } else {
- mat[0] = 1 + ((factor - 1) *(vec->vec[0] * vec->vec[0]));
- mat[1] =((factor - 1) *(vec->vec[0] * vec->vec[1]));
- mat[2] =((factor - 1) *(vec->vec[0] * vec->vec[2]));
- mat[3] =((factor - 1) *(vec->vec[0] * vec->vec[1]));
- mat[4] = 1 + ((factor - 1) *(vec->vec[1] * vec->vec[1]));
- mat[5] =((factor - 1) *(vec->vec[1] * vec->vec[2]));
- mat[6] =((factor - 1) *(vec->vec[0] * vec->vec[2]));
- mat[7] =((factor - 1) *(vec->vec[1] * vec->vec[2]));
- mat[8] = 1 + ((factor - 1) *(vec->vec[2] * vec->vec[2]));
- }
- }
- if(matSize == 4) {
- //resize matrix
- mat[10] = mat[8];
- mat[9] = mat[7];
- mat[8] = mat[6];
- mat[7] = 0.0f;
- mat[6] = mat[5];
- mat[5] = mat[4];
- mat[4] = mat[3];
- mat[3] = 0.0f;
- }
- //pass to matrix creation
- return newMatrixObject(mat, matSize, matSize, Py_NEW);
-}
-//----------------------------------Mathutils.OrthoProjectionMatrix() ---
-//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
-//creates an ortho projection matrix
-PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * args)
-{
- VectorObject *vec = NULL;
- char *plane;
- int matSize, x;
- float norm = 0.0f;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
-
- if(!PyArg_ParseTuple
- (args, "si|O!", &plane, &matSize, &vector_Type, &vec)) {
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.OrthoProjectionMatrix(): expected string and int and optional vector\n");
- }
- if(matSize != 2 && matSize != 3 && matSize != 4)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.OrthoProjectionMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
- if(vec) {
- if(vec->size > 2 && matSize == 2)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.OrthoProjectionMatrix(): please use 2D vectors when scaling in 2D\n");
- }
- if(vec == NULL) { //ortho projection onto cardinal plane
- if(((strcmp(plane, "x") == 0)
- || (strcmp(plane, "X") == 0)) && matSize == 2) {
- mat[0] = 1.0f;
- } else if(((strcmp(plane, "y") == 0)
- || (strcmp(plane, "Y") == 0))
- && matSize == 2) {
- mat[3] = 1.0f;
- } else if(((strcmp(plane, "xy") == 0)
- || (strcmp(plane, "XY") == 0))
- && matSize > 2) {
- mat[0] = 1.0f;
- mat[4] = 1.0f;
- } else if(((strcmp(plane, "xz") == 0)
- || (strcmp(plane, "XZ") == 0))
- && matSize > 2) {
- mat[0] = 1.0f;
- mat[8] = 1.0f;
- } else if(((strcmp(plane, "yz") == 0)
- || (strcmp(plane, "YZ") == 0))
- && matSize > 2) {
- mat[4] = 1.0f;
- mat[8] = 1.0f;
- } else {
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.OrthoProjectionMatrix(): unknown plane - expected: x, y, xy, xz, yz\n");
- }
- } else { //arbitrary plane
- //normalize arbitrary axis
- for(x = 0; x < vec->size; x++) {
- norm += vec->vec[x] * vec->vec[x];
- }
- norm = (float) sqrt(norm);
- for(x = 0; x < vec->size; x++) {
- vec->vec[x] /= norm;
- }
- if(((strcmp(plane, "r") == 0)
- || (strcmp(plane, "R") == 0)) && matSize == 2) {
- mat[0] = 1 - (vec->vec[0] * vec->vec[0]);
- mat[1] = -(vec->vec[0] * vec->vec[1]);
- mat[2] = -(vec->vec[0] * vec->vec[1]);
- mat[3] = 1 - (vec->vec[1] * vec->vec[1]);
- } else if(((strcmp(plane, "r") == 0)
- || (strcmp(plane, "R") == 0))
- && matSize > 2) {
- mat[0] = 1 - (vec->vec[0] * vec->vec[0]);
- mat[1] = -(vec->vec[0] * vec->vec[1]);
- mat[2] = -(vec->vec[0] * vec->vec[2]);
- mat[3] = -(vec->vec[0] * vec->vec[1]);
- mat[4] = 1 - (vec->vec[1] * vec->vec[1]);
- mat[5] = -(vec->vec[1] * vec->vec[2]);
- mat[6] = -(vec->vec[0] * vec->vec[2]);
- mat[7] = -(vec->vec[1] * vec->vec[2]);
- mat[8] = 1 - (vec->vec[2] * vec->vec[2]);
- } else {
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.OrthoProjectionMatrix(): unknown plane - expected: 'r' expected for axis designation\n");
- }
- }
- if(matSize == 4) {
- //resize matrix
- mat[10] = mat[8];
- mat[9] = mat[7];
- mat[8] = mat[6];
- mat[7] = 0.0f;
- mat[6] = mat[5];
- mat[5] = mat[4];
- mat[4] = mat[3];
- mat[3] = 0.0f;
- }
- //pass to matrix creation
- return newMatrixObject(mat, matSize, matSize, Py_NEW);
-}
-//----------------------------------Mathutils.ShearMatrix() -------------
-//creates a shear matrix
-PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args)
-{
- int matSize;
- char *plane;
- float factor;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
-
- if(!PyArg_ParseTuple(args, "sfi", &plane, &factor, &matSize)) {
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.ShearMatrix(): expected string float and int\n");
- }
- if(matSize != 2 && matSize != 3 && matSize != 4)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.ShearMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
-
- if(((strcmp(plane, "x") == 0) || (strcmp(plane, "X") == 0))
- && matSize == 2) {
- mat[0] = 1.0f;
- mat[2] = factor;
- mat[3] = 1.0f;
- } else if(((strcmp(plane, "y") == 0)
- || (strcmp(plane, "Y") == 0)) && matSize == 2) {
- mat[0] = 1.0f;
- mat[1] = factor;
- mat[3] = 1.0f;
- } else if(((strcmp(plane, "xy") == 0)
- || (strcmp(plane, "XY") == 0)) && matSize > 2) {
- mat[0] = 1.0f;
- mat[4] = 1.0f;
- mat[6] = factor;
- mat[7] = factor;
- } else if(((strcmp(plane, "xz") == 0)
- || (strcmp(plane, "XZ") == 0)) && matSize > 2) {
- mat[0] = 1.0f;
- mat[3] = factor;
- mat[4] = 1.0f;
- mat[5] = factor;
- mat[8] = 1.0f;
- } else if(((strcmp(plane, "yz") == 0)
- || (strcmp(plane, "YZ") == 0)) && matSize > 2) {
- mat[0] = 1.0f;
- mat[1] = factor;
- mat[2] = factor;
- mat[4] = 1.0f;
- mat[8] = 1.0f;
- } else {
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.ShearMatrix(): expected: x, y, xy, xz, yz or wrong matrix size for shearing plane\n");
- }
- if(matSize == 4) {
- //resize matrix
- mat[10] = mat[8];
- mat[9] = mat[7];
- mat[8] = mat[6];
- mat[7] = 0.0f;
- mat[6] = mat[5];
- mat[5] = mat[4];
- mat[4] = mat[3];
- mat[3] = 0.0f;
- }
- //pass to matrix creation
- return newMatrixObject(mat, matSize, matSize, Py_NEW);
-}
-//----------------------------------QUATERNION FUNCTIONS-----------------
-//----------------------------------Mathutils.Quaternion() --------------
-PyObject *M_Mathutils_Quaternion(PyObject * self, PyObject * args)
-{
- PyObject *listObject = NULL, *n, *q, *f;
- int size, i;
- float quat[4];
- double norm = 0.0f, angle = 0.0f;
-
- size = PySequence_Length(args);
- if (size == 1 || size == 2) { //seq?
- listObject = PySequence_GetItem(args, 0);
- if (PySequence_Check(listObject)) {
- size = PySequence_Length(listObject);
- if ((size == 4 && PySequence_Length(args) !=1) ||
- (size == 3 && PySequence_Length(args) !=2) || (size >4 || size < 3)) {
- // invalid args/size
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
- }
- if(size == 3){ //get angle in axis/angle
- n = PyNumber_Float(PySequence_GetItem(args, 1));
- if(n == NULL) { // parsed item not a number or getItem fail
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
- }
- angle = PyFloat_AS_DOUBLE(n);
- Py_DECREF(n);
- }
- }else{
- listObject = PySequence_GetItem(args, 1);
- if (size>1 && PySequence_Check(listObject)) {
- size = PySequence_Length(listObject);
- if (size != 3) {
- // invalid args/size
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
- }
- n = PyNumber_Float(PySequence_GetItem(args, 0));
- if(n == NULL) { // parsed item not a number or getItem fail
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
- }
- angle = PyFloat_AS_DOUBLE(n);
- Py_DECREF(n);
- } else { // argument was not a sequence
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
- }
- }
- } else if (size == 0) { //returns a new empty quat
- return newQuaternionObject(NULL, Py_NEW);
- } else {
- listObject = EXPP_incr_ret(args);
- }
-
- if (size == 3) { // invalid quat size
- if(PySequence_Length(args) != 2){
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
- }
- }else{
- if(size != 4){
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
- }
- }
-
- for (i=0; i<size; i++) { //parse
- q = PySequence_GetItem(listObject, i);
- if (q == NULL) { // Failed to read sequence
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
- }
-
- f = PyNumber_Float(q);
- if(f == NULL) { // parsed item not a number
- EXPP_decr2(q, listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
- }
-
- quat[i] = (float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(f, q);
- }
- if(size == 3){ //calculate the quat based on axis/angle
- norm = sqrt(quat[0] * quat[0] + quat[1] * quat[1] + quat[2] * quat[2]);
- quat[0] /= (float)norm;
- quat[1] /= (float)norm;
- quat[2] /= (float)norm;
-
- angle = angle * (Py_PI / 180);
- quat[3] =(float) (sin(angle/ 2.0f)) * quat[2];
- quat[2] =(float) (sin(angle/ 2.0f)) * quat[1];
- quat[1] =(float) (sin(angle/ 2.0f)) * quat[0];
- quat[0] =(float) (cos(angle/ 2.0f));
- }
-
- Py_DECREF(listObject);
- return newQuaternionObject(quat, Py_NEW);
-}
-//----------------------------------Mathutils.CrossQuats() ----------------
-//quaternion multiplication - associate not commutative
-PyObject *M_Mathutils_CrossQuats(PyObject * self, PyObject * args)
-{
- QuaternionObject *quatU = NULL, *quatV = NULL;
- float quat[4];
-
- if(!PyArg_ParseTuple(args, "O!O!", &quaternion_Type, &quatU,
- &quaternion_Type, &quatV))
- return EXPP_ReturnPyObjError(PyExc_TypeError,"Mathutils.CrossQuats(): expected Quaternion types");
- QuatMul(quat, quatU->quat, quatV->quat);
-
- return newQuaternionObject(quat, Py_NEW);
-}
-//----------------------------------Mathutils.DotQuats() ----------------
-//returns the dot product of 2 quaternions
-PyObject *M_Mathutils_DotQuats(PyObject * self, PyObject * args)
-{
- QuaternionObject *quatU = NULL, *quatV = NULL;
- double dot = 0.0f;
- int x;
-
- if(!PyArg_ParseTuple(args, "O!O!", &quaternion_Type, &quatU,
- &quaternion_Type, &quatV))
- return EXPP_ReturnPyObjError(PyExc_TypeError, "Mathutils.DotQuats(): expected Quaternion types");
-
- for(x = 0; x < 4; x++) {
- dot += quatU->quat[x] * quatV->quat[x];
- }
- return PyFloat_FromDouble(dot);
-}
-//----------------------------------Mathutils.DifferenceQuats() ---------
-//returns the difference between 2 quaternions
-PyObject *M_Mathutils_DifferenceQuats(PyObject * self, PyObject * args)
-{
- QuaternionObject *quatU = NULL, *quatV = NULL;
- float quat[4], tempQuat[4];
- double dot = 0.0f;
- int x;
-
- if(!PyArg_ParseTuple(args, "O!O!", &quaternion_Type,
- &quatU, &quaternion_Type, &quatV))
- return EXPP_ReturnPyObjError(PyExc_TypeError, "Mathutils.DifferenceQuats(): expected Quaternion types");
-
- tempQuat[0] = quatU->quat[0];
- tempQuat[1] = -quatU->quat[1];
- tempQuat[2] = -quatU->quat[2];
- tempQuat[3] = -quatU->quat[3];
-
- dot = sqrt(tempQuat[0] * tempQuat[0] + tempQuat[1] * tempQuat[1] +
- tempQuat[2] * tempQuat[2] + tempQuat[3] * tempQuat[3]);
-
- for(x = 0; x < 4; x++) {
- tempQuat[x] /= (float)(dot * dot);
- }
- QuatMul(quat, tempQuat, quatV->quat);
- return newQuaternionObject(quat, Py_NEW);
-}
-//----------------------------------Mathutils.Slerp() ------------------
-//attemps to interpolate 2 quaternions and return the result
-PyObject *M_Mathutils_Slerp(PyObject * self, PyObject * args)
-{
- QuaternionObject *quatU = NULL, *quatV = NULL;
- float quat[4], quat_u[4], quat_v[4], param;
- double x, y, dot, sinT, angle, IsinT;
- int z;
-
- if(!PyArg_ParseTuple(args, "O!O!f", &quaternion_Type,
- &quatU, &quaternion_Type, &quatV, &param))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Slerp(): expected Quaternion types and float");
-
- if(param > 1.0f || param < 0.0f)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Slerp(): interpolation factor must be between 0.0 and 1.0");
-
- //copy quats
- for(z = 0; z < 4; z++){
- quat_u[z] = quatU->quat[z];
- quat_v[z] = quatV->quat[z];
- }
-
- //dot product
- dot = quat_u[0] * quat_v[0] + quat_u[1] * quat_v[1] +
- quat_u[2] * quat_v[2] + quat_u[3] * quat_v[3];
-
- //if negative negate a quat (shortest arc)
- if(dot < 0.0f) {
- quat_v[0] = -quat_v[0];
- quat_v[1] = -quat_v[1];
- quat_v[2] = -quat_v[2];
- quat_v[3] = -quat_v[3];
- dot = -dot;
- }
- if(dot > .99999f) { //very close
- x = 1.0f - param;
- y = param;
- } else {
- //calculate sin of angle
- sinT = sqrt(1.0f - (dot * dot));
- //calculate angle
- angle = atan2(sinT, dot);
- //caluculate inverse of sin(theta)
- IsinT = 1.0f / sinT;
- x = sin((1.0f - param) * angle) * IsinT;
- y = sin(param * angle) * IsinT;
- }
- //interpolate
- quat[0] = (float)(quat_u[0] * x + quat_v[0] * y);
- quat[1] = (float)(quat_u[1] * x + quat_v[1] * y);
- quat[2] = (float)(quat_u[2] * x + quat_v[2] * y);
- quat[3] = (float)(quat_u[3] * x + quat_v[3] * y);
-
- return newQuaternionObject(quat, Py_NEW);
-}
-//----------------------------------EULER FUNCTIONS----------------------
-//----------------------------------Mathutils.Euler() -------------------
-//makes a new euler for you to play with
-PyObject *M_Mathutils_Euler(PyObject * self, PyObject * args)
-{
-
- PyObject *listObject = NULL;
- int size, i;
- float eul[3];
- PyObject *e, *f;
-
- size = PySequence_Length(args);
- if (size == 1) {
- listObject = PySequence_GetItem(args, 0);
- if (PySequence_Check(listObject)) {
- size = PySequence_Length(listObject);
- } else { // Single argument was not a sequence
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Euler(): 3d numeric sequence expected\n");
- }
- } else if (size == 0) {
- //returns a new empty 3d euler
- return newEulerObject(NULL, Py_NEW);
- } else {
- listObject = EXPP_incr_ret(args);
- }
-
- if (size != 3) { // Invalid euler size
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Euler(): 3d numeric sequence expected\n");
- }
-
- for (i=0; i<size; i++) {
- e = PySequence_GetItem(listObject, i);
- if (e == NULL) { // Failed to read sequence
- Py_DECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "Mathutils.Euler(): 3d numeric sequence expected\n");
- }
-
- f = PyNumber_Float(e);
- if(f == NULL) { // parsed item not a number
- EXPP_decr2(e, listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Euler(): 3d numeric sequence expected\n");
- }
-
- eul[i]=(float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(f,e);
- }
- Py_DECREF(listObject);
- return newEulerObject(eul, Py_NEW);
-}
-//----------------------------------POINT FUNCTIONS---------------------
-//----------------------------------Mathutils.Point() ------------------
-PyObject *M_Mathutils_Point(PyObject * self, PyObject * args)
-{
- PyObject *listObject = NULL;
- int size, i;
- float point[3];
- PyObject *v, *f;
-
- size = PySequence_Length(args);
- if (size == 1) {
- listObject = PySequence_GetItem(args, 0);
- if (PySequence_Check(listObject)) {
- size = PySequence_Length(listObject);
- } else { // Single argument was not a sequence
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Point(): 2-3 floats or ints expected (optionally in a sequence)\n");
- }
- } else if (size == 0) {
- //returns a new empty 3d point
- return newPointObject(NULL, 3, Py_NEW);
- } else {
- listObject = EXPP_incr_ret(args);
- }
-
- if (size<2 || size>3) { // Invalid vector size
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mathutils.Point(): 2-3 floats or ints expected (optionally in a sequence)\n");
- }
-
- for (i=0; i<size; i++) {
- v=PySequence_GetItem(listObject, i);
- if (v==NULL) { // Failed to read sequence
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "Mathutils.Point(): 2-3 floats or ints expected (optionally in a sequence)\n");
- }
-
- f=PyNumber_Float(v);
- if(f==NULL) { // parsed item not a number
- Py_DECREF(v);
- Py_XDECREF(listObject);
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.Point(): 2-3 floats or ints expected (optionally in a sequence)\n");
- }
-
- point[i]=(float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(f,v);
- }
- Py_DECREF(listObject);
- return newPointObject(point, size, Py_NEW);
-}
-//---------------------------------INTERSECTION FUNCTIONS--------------------
-//----------------------------------Mathutils.Intersect() -------------------
-PyObject *M_Mathutils_Intersect( PyObject * self, PyObject * args )
-{
- VectorObject *ray, *ray_off, *vec1, *vec2, *vec3;
- float dir[3], orig[3], v1[3], v2[3], v3[3], e1[3], e2[3], pvec[3], tvec[3], qvec[3];
- float det, inv_det, u, v, t;
- int clip = 1;
-
- if( !PyArg_ParseTuple
- ( args, "O!O!O!O!O!|i", &vector_Type, &vec1, &vector_Type, &vec2
- , &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected 5 vector types\n" ) );
- if( vec1->size != 3 || vec2->size != 3 || vec3->size != 3 ||
- ray->size != 3 || ray_off->size != 3)
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "only 3D vectors for all parameters\n" ) );
-
- VECCOPY(v1, vec1->vec);
- VECCOPY(v2, vec2->vec);
- VECCOPY(v3, vec3->vec);
-
- VECCOPY(dir, ray->vec);
- Normalize(dir);
-
- VECCOPY(orig, ray_off->vec);
-
- /* find vectors for two edges sharing v1 */
- VecSubf(e1, v2, v1);
- VecSubf(e2, v3, v1);
-
- /* begin calculating determinant - also used to calculated U parameter */
- Crossf(pvec, dir, e2);
-
- /* if determinant is near zero, ray lies in plane of triangle */
- det = Inpf(e1, pvec);
-
- if (det > -0.000001 && det < 0.000001) {
- return EXPP_incr_ret( Py_None );
- }
-
- inv_det = 1.0f / det;
-
- /* calculate distance from v1 to ray origin */
- VecSubf(tvec, orig, v1);
-
- /* calculate U parameter and test bounds */
- u = Inpf(tvec, pvec) * inv_det;
- if (clip && (u < 0.0f || u > 1.0f)) {
- return EXPP_incr_ret( Py_None );
- }
-
- /* prepare to test the V parameter */
- Crossf(qvec, tvec, e1);
-
- /* calculate V parameter and test bounds */
- v = Inpf(dir, qvec) * inv_det;
-
- if (clip && (v < 0.0f || u + v > 1.0f)) {
- return EXPP_incr_ret( Py_None );
- }
-
- /* calculate t, ray intersects triangle */
- t = Inpf(e2, qvec) * inv_det;
-
- VecMulf(dir, t);
- VecAddf(pvec, orig, dir);
-
- return newVectorObject(pvec, 3, Py_NEW);
-}
-//----------------------------------Mathutils.LineIntersect() -------------------
-/* Line-Line intersection using algorithm from mathworld.wolfram.com */
-PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args )
-{
- PyObject * tuple;
- VectorObject *vec1, *vec2, *vec3, *vec4;
- float v1[3], v2[3], v3[3], v4[3], i1[3], i2[3];
-
- if( !PyArg_ParseTuple
- ( args, "O!O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2
- , &vector_Type, &vec3, &vector_Type, &vec4 ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected 4 vector types\n" ) );
- if( vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec2->size)
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "vectors must be of the same size\n" ) );
-
- if( vec1->size == 3 || vec1->size == 2) {
- float a[3], b[3], c[3], ab[3], cb[3], dir1[3], dir2[3];
- float d;
- if (vec1->size == 3) {
- VECCOPY(v1, vec1->vec);
- VECCOPY(v2, vec2->vec);
- VECCOPY(v3, vec3->vec);
- VECCOPY(v4, vec4->vec);
- }
- else {
- v1[0] = vec1->vec[0];
- v1[1] = vec1->vec[1];
- v1[2] = 0.0f;
-
- v2[0] = vec2->vec[0];
- v2[1] = vec2->vec[1];
- v2[2] = 0.0f;
-
- v3[0] = vec3->vec[0];
- v3[1] = vec3->vec[1];
- v3[2] = 0.0f;
-
- v4[0] = vec4->vec[0];
- v4[1] = vec4->vec[1];
- v4[2] = 0.0f;
- }
-
- VecSubf(c, v3, v1);
- VecSubf(a, v2, v1);
- VecSubf(b, v4, v3);
-
- VECCOPY(dir1, a);
- Normalize(dir1);
- VECCOPY(dir2, b);
- Normalize(dir2);
- d = Inpf(dir1, dir2);
- if (d == 1.0f || d == -1.0f) {
- /* colinear */
- return EXPP_incr_ret( Py_None );
- }
-
- Crossf(ab, a, b);
- d = Inpf(c, ab);
-
- /* test if the two lines are coplanar */
- if (d > -0.000001f && d < 0.000001f) {
- Crossf(cb, c, b);
-
- VecMulf(a, Inpf(cb, ab) / Inpf(ab, ab));
- VecAddf(i1, v1, a);
- VECCOPY(i2, i1);
- }
- /* if not */
- else {
- float n[3], t[3];
- VecSubf(t, v1, v3);
-
- /* offset between both plane where the lines lies */
- Crossf(n, a, b);
- Projf(t, t, n);
-
- /* for the first line, offset the second line until it is coplanar */
- VecAddf(v3, v3, t);
- VecAddf(v4, v4, t);
-
- VecSubf(c, v3, v1);
- VecSubf(a, v2, v1);
- VecSubf(b, v4, v3);
-
- Crossf(ab, a, b);
- Crossf(cb, c, b);
-
- VecMulf(a, Inpf(cb, ab) / Inpf(ab, ab));
- VecAddf(i1, v1, a);
-
- /* for the second line, just substract the offset from the first intersection point */
- VecSubf(i2, i1, t);
- }
-
- tuple = PyTuple_New( 2 );
- PyTuple_SetItem( tuple, 0, newVectorObject(i1, vec1->size, Py_NEW) );
- PyTuple_SetItem( tuple, 1, newVectorObject(i2, vec1->size, Py_NEW) );
- return tuple;
- }
- else {
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "2D/3D vectors only\n" ) );
- }
-}
-
-
-
-//---------------------------------NORMALS FUNCTIONS--------------------
-//----------------------------------Mathutils.QuadNormal() -------------------
-PyObject *M_Mathutils_QuadNormal( PyObject * self, PyObject * args )
-{
- VectorObject *vec1;
- VectorObject *vec2;
- VectorObject *vec3;
- VectorObject *vec4;
- float v1[3], v2[3], v3[3], v4[3], e1[3], e2[3], n1[3], n2[3];
-
- if( !PyArg_ParseTuple
- ( args, "O!O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2
- , &vector_Type, &vec3, &vector_Type, &vec4 ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected 4 vector types\n" ) );
- if( vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec4->size)
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "vectors must be of the same size\n" ) );
- if( vec1->size != 3 )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "only 3D vectors\n" ) );
-
- VECCOPY(v1, vec1->vec);
- VECCOPY(v2, vec2->vec);
- VECCOPY(v3, vec3->vec);
- VECCOPY(v4, vec4->vec);
-
- /* find vectors for two edges sharing v2 */
- VecSubf(e1, v1, v2);
- VecSubf(e2, v3, v2);
-
- Crossf(n1, e2, e1);
- Normalize(n1);
-
- /* find vectors for two edges sharing v4 */
- VecSubf(e1, v3, v4);
- VecSubf(e2, v1, v4);
-
- Crossf(n2, e2, e1);
- Normalize(n2);
-
- /* adding and averaging the normals of both triangles */
- VecAddf(n1, n2, n1);
- Normalize(n1);
-
- return newVectorObject(n1, 3, Py_NEW);
-}
-
-//----------------------------Mathutils.TriangleNormal() -------------------
-PyObject *M_Mathutils_TriangleNormal( PyObject * self, PyObject * args )
-{
- VectorObject *vec1, *vec2, *vec3;
- float v1[3], v2[3], v3[3], e1[3], e2[3], n[3];
-
- if( !PyArg_ParseTuple
- ( args, "O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2
- , &vector_Type, &vec3 ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected 3 vector types\n" ) );
- if( vec1->size != vec2->size || vec1->size != vec3->size )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "vectors must be of the same size\n" ) );
- if( vec1->size != 3 )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "only 3D vectors\n" ) );
-
- VECCOPY(v1, vec1->vec);
- VECCOPY(v2, vec2->vec);
- VECCOPY(v3, vec3->vec);
-
- /* find vectors for two edges sharing v2 */
- VecSubf(e1, v1, v2);
- VecSubf(e2, v3, v2);
-
- Crossf(n, e2, e1);
- Normalize(n);
-
- return newVectorObject(n, 3, Py_NEW);
-}
-
-//--------------------------------- AREA FUNCTIONS--------------------
-//----------------------------------Mathutils.TriangleArea() -------------------
-PyObject *M_Mathutils_TriangleArea( PyObject * self, PyObject * args )
-{
- VectorObject *vec1, *vec2, *vec3;
- float v1[3], v2[3], v3[3];
-
- if( !PyArg_ParseTuple
- ( args, "O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2
- , &vector_Type, &vec3 ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected 3 vector types\n" ) );
- if( vec1->size != vec2->size || vec1->size != vec3->size )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "vectors must be of the same size\n" ) );
-
- if (vec1->size == 3) {
- VECCOPY(v1, vec1->vec);
- VECCOPY(v2, vec2->vec);
- VECCOPY(v3, vec3->vec);
-
- return PyFloat_FromDouble( AreaT3Dfl(v1, v2, v3) );
- }
- else if (vec1->size == 2) {
- v1[0] = vec1->vec[0];
- v1[1] = vec1->vec[1];
-
- v2[0] = vec2->vec[0];
- v2[1] = vec2->vec[1];
-
- v3[0] = vec3->vec[0];
- v3[1] = vec3->vec[1];
-
- return PyFloat_FromDouble( AreaF2Dfl(v1, v2, v3) );
- }
- else {
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "only 2D,3D vectors are supported\n" ) );
- }
-}
-//#############################DEPRECATED################################
-//#######################################################################
-//----------------------------------Mathutils.CopyMat() -----------------
-//copies a matrix into a new matrix
-PyObject *M_Mathutils_CopyMat(PyObject * self, PyObject * args)
-{
- PyObject *matrix = NULL;
- static char warning = 1;
-
- if( warning ) {
- printf("Mathutils.CopyMat(): deprecated :use Mathutils.Matrix() to copy matrices\n");
- --warning;
- }
-
- matrix = M_Mathutils_Matrix(self, args);
- if(matrix == NULL)
- return NULL; //error string already set if we get here
- else
- return matrix;
-}
-//----------------------------------Mathutils.CopyVec() -----------------
-//makes a new vector that is a copy of the input
-PyObject *M_Mathutils_CopyVec(PyObject * self, PyObject * args)
-{
- PyObject *vec = NULL;
- static char warning = 1;
-
- if( warning ) {
- printf("Mathutils.CopyVec(): Deprecated: use Mathutils.Vector() to copy vectors\n");
- --warning;
- }
-
- vec = M_Mathutils_Vector(self, args);
- if(vec == NULL)
- return NULL; //error string already set if we get here
- else
- return vec;
-}
-//----------------------------------Mathutils.CopyQuat() --------------
-//Copies a quaternion to a new quat
-PyObject *M_Mathutils_CopyQuat(PyObject * self, PyObject * args)
-{
- PyObject *quat = NULL;
- static char warning = 1;
-
- if( warning ) {
- printf("Mathutils.CopyQuat(): Deprecated: use Mathutils.Quaternion() to copy vectors\n");
- --warning;
- }
-
- quat = M_Mathutils_Quaternion(self, args);
- if(quat == NULL)
- return NULL; //error string already set if we get here
- else
- return quat;
-}
-//----------------------------------Mathutils.CopyEuler() ---------------
-//copies a euler to a new euler
-PyObject *M_Mathutils_CopyEuler(PyObject * self, PyObject * args)
-{
- PyObject *eul = NULL;
- static char warning = 1;
-
- if( warning ) {
- printf("Mathutils.CopyEuler(): deprecated:use Mathutils.Euler() to copy vectors\n");
- --warning;
- }
-
- eul = M_Mathutils_Euler(self, args);
- if(eul == NULL)
- return NULL; //error string already set if we get here
- else
- return eul;
-}
-//----------------------------------Mathutils.RotateEuler() ------------
-//rotates a euler a certain amount and returns the result
-//should return a unique euler rotation (i.e. no 720 degree pitches :)
-PyObject *M_Mathutils_RotateEuler(PyObject * self, PyObject * args)
-{
- EulerObject *Eul = NULL;
- float angle;
- char *axis;
- static char warning = 1;
-
- if( warning ) {
- printf("Mathutils.RotateEuler(): Deprecated:use Euler.rotate() to rotate a euler\n");
- --warning;
- }
-
- if(!PyArg_ParseTuple(args, "O!fs", &euler_Type, &Eul, &angle, &axis))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.RotateEuler(): expected euler type & float & string");
-
- Euler_Rotate(Eul, Py_BuildValue("fs", angle, axis));
- Py_RETURN_NONE;
-}
-//----------------------------------Mathutils.MatMultVec() --------------
-//COLUMN VECTOR Multiplication (Matrix X Vector)
-PyObject *M_Mathutils_MatMultVec(PyObject * self, PyObject * args)
-{
- MatrixObject *mat = NULL;
- VectorObject *vec = NULL;
- static char warning = 1;
-
- if( warning ) {
- printf("Mathutils.MatMultVec(): Deprecated: use matrix * vec to perform column vector multiplication\n");
- --warning;
- }
-
- //get pyObjects
- if(!PyArg_ParseTuple(args, "O!O!", &matrix_Type, &mat, &vector_Type, &vec))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.MatMultVec(): MatMultVec() expects a matrix and a vector object - in that order\n");
-
- return column_vector_multiplication(mat, vec);
-}
-//----------------------------------Mathutils.VecMultMat() ---------------
-//ROW VECTOR Multiplication - Vector X Matrix
-PyObject *M_Mathutils_VecMultMat(PyObject * self, PyObject * args)
-{
- MatrixObject *mat = NULL;
- VectorObject *vec = NULL;
- static char warning = 1;
-
- if( warning ) {
- printf("Mathutils.VecMultMat(): Deprecated: use vec * matrix to perform row vector multiplication\n");
- --warning;
- }
-
- //get pyObjects
- if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec, &matrix_Type, &mat))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Mathutils.VecMultMat(): VecMultMat() expects a vector and matrix object - in that order\n");
-
- return row_vector_multiplication(vec, mat);
-}
-//#######################################################################
-//#############################DEPRECATED################################
diff --git a/source/blender/python/api2_2x/Mathutils.h b/source/blender/python/api2_2x/Mathutils.h
deleted file mode 100644
index 56d96d8f281..00000000000
--- a/source/blender/python/api2_2x/Mathutils.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c
deleted file mode 100644
index 4424fd08ffd..00000000000
--- a/source/blender/python/api2_2x/Mesh.c
+++ /dev/null
@@ -1,8677 +0,0 @@
-/*
- * $Id: Mesh.c 12892 2007-12-15 17:41:13Z 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, partially based on NMesh.c API.
- *
- * Contributor(s): Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Mesh.h" /*This must come first*/
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_key_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_oops_types.h"
-#include "DNA_space_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_meta_types.h"
-#include "DNA_modifier_types.h"
-
-#include "BDR_editface.h" /* make_tfaces */
-#include "BDR_vpaint.h"
-#include "BDR_editobject.h"
-
-#include "BIF_editdeform.h"
-#include "BIF_editkey.h" /* insert_meshkey */
-#include "BIF_space.h" /* REMAKEIPO - insert_meshkey */
-#include "BIF_editview.h"
-#include "BIF_editmesh.h"
-#include "BIF_meshtools.h"
-
-#include "BKE_customdata.h"
-#include "BKE_deform.h"
-#include "BKE_displist.h"
-#include "BKE_mesh.h"
-#include "BKE_material.h"
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_object.h"
-#include "BKE_mball.h"
-#include "BKE_utildefines.h"
-#include "BKE_depsgraph.h"
-#include "BSE_edit.h" /* for countall(); */
-#include "BKE_curve.h" /* for copy_curve(); */
-#include "BKE_modifier.h" /* for modifier_new(), modifier_copyData(); */
-#include "BKE_idprop.h"
-
-#include "BLI_arithb.h"
-#include "BLI_blenlib.h"
-
-#include "blendef.h"
-#include "mydevice.h"
-#include "butspace.h" /* for mesh tools */
-#include "Object.h"
-#include "Key.h"
-#include "Image.h"
-#include "Material.h"
-#include "Mathutils.h"
-#include "IDProp.h"
-#include "meshPrimitive.h"
-#include "constant.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-#include "multires.h"
-
-/* EXPP Mesh defines */
-
-#define MESH_SMOOTHRESH 30
-#define MESH_SMOOTHRESH_MIN 1
-#define MESH_SMOOTHRESH_MAX 80
-#define MESH_SUBDIV 1
-#define MESH_SUBDIV_MIN 0
-#define MESH_SUBDIV_MAX 6
-
-#define MESH_HASFACEUV 0
-#define MESH_HASMCOL 1
-#define MESH_HASVERTUV 2
-#define MESH_HASMULTIRES 3
-
-#define MESH_MULTIRES_LEVEL 0
-#define MESH_MULTIRES_EDGE 1
-#define MESH_MULTIRES_PIN 2
-#define MESH_MULTIRES_RENDER 3
-
-#define MESH_TOOL_TOSPHERE 0
-#define MESH_TOOL_VERTEXSMOOTH 1
-#define MESH_TOOL_FLIPNORM 2
-#define MESH_TOOL_SUBDIV 3
-#define MESH_TOOL_REMDOUB 4
-#define MESH_TOOL_FILL 5
-#define MESH_TOOL_RECALCNORM 6
-#define MESH_TOOL_TRI2QUAD 7
-#define MESH_TOOL_QUAD2TRI 8
-
-static PyObject *MVertSeq_CreatePyObject( Mesh * mesh );
-static PyObject *MFaceSeq_CreatePyObject( Mesh * mesh );
-static PyObject *MEdgeSeq_CreatePyObject( Mesh * mesh );
-static PyObject *MFace_CreatePyObject( Mesh * mesh, int i );
-static PyObject *MEdge_CreatePyObject( Mesh * mesh, int i );
-
-#define MFACE_VERT_BADRANGE_CHECK(me, face) ((int)face->v1 >= me->totvert || (int)face->v2 >= me->totvert || (int)face->v3 >= me->totvert || (int)face->v4 >= me->totvert)
-#define MEDGE_VERT_BADRANGE_CHECK(me, edge) ((int)edge->v1 >= me->totvert || (int)edge->v2 >= me->totvert)
-
-/************************************************************************
- *
- * internal utilities
- *
- ************************************************************************/
-
-/*
- * internal structures used for sorting edges and faces
- */
-
-typedef struct SrchEdges {
- unsigned int v[2]; /* indices for verts */
- unsigned char swap; /* non-zero if verts swapped */
- unsigned int index; /* index in original param list of this edge */
- /* (will be used by findEdges) */
-} SrchEdges;
-
-typedef struct SrchFaces {
- unsigned int v[4]; /* indices for verts */
- unsigned int index; /* index in original param list of this edge */
- unsigned char order; /* order of original verts, bitpacked */
-} SrchFaces;
-
-typedef struct FaceEdges {
- unsigned int v[2]; /* search key (vert indices) */
- unsigned int index; /* location in edge list */
- unsigned char sel; /* selection state */
-} FaceEdges;
-
-/*
- * compare edges by vertex indices
- */
-
-int medge_comp( const void *va, const void *vb )
-{
- const unsigned int *a = ((SrchEdges *)va)->v;
- const unsigned int *b = ((SrchEdges *)vb)->v;
-
- /* compare first index for differences */
-
- if (a[0] < b[0]) return -1;
- else if (a[0] > b[0]) return 1;
-
- /* if first indices equal, compare second index for differences */
-
- else if (a[1] < b[1]) return -1;
- else return (a[1] > b[1]);
-}
-
-/*
- * compare edges by insert list indices
- */
-
-int medge_index_comp( const void *va, const void *vb )
-{
- const SrchEdges *a = (SrchEdges *)va;
- const SrchEdges *b = (SrchEdges *)vb;
-
- /* compare list indices for differences */
-
- if (a->index < b->index) return -1;
- else return (a->index > b->index);
-}
-
-
-/*
- * compare faces by vertex indices
- */
-
-int mface_comp( const void *va, const void *vb )
-{
- const SrchFaces *a = va;
- const SrchFaces *b = vb;
- int i;
-
- /* compare indices, first to last, for differences */
- for( i = 0; i < 4; ++i ) {
- if( a->v[i] < b->v[i] )
- return -1;
- if( a->v[i] > b->v[i] )
- return 1;
- }
-
- /*
- * don't think this needs be done; if order is different then either
- * (a) the face is good, just reversed or has a different starting
- * vertex, or (b) face is bad (for 4 verts) and there's a "twist"
- */
-
-#if 0
- /* if all the same verts, compare their order */
- if( a->order < b->order )
- return -1;
- if( a->order > b->order )
- return 1;
-#endif
-
- return 0;
-}
-
-/*
- * compare faces by insert list indices
- */
-
-int mface_index_comp( const void *va, const void *vb )
-{
- const SrchFaces *a = va;
- const SrchFaces *b = vb;
-
- /* compare indices, first to last, for differences */
- if( a->index < b->index )
- return -1;
- if( a->index > b->index )
- return 1;
- return 0;
-}
-
-/*
- * compare edges by vertex indices
- */
-
-int faceedge_comp( const void *va, const void *vb )
-{
- const unsigned int *a = ((FaceEdges *)va)->v;
- const unsigned int *b = ((FaceEdges *)vb)->v;
-
- /* compare first index for differences */
-
- if (a[0] < b[0]) return -1;
- else if (a[0] > b[0]) return 1;
-
- /* if first indices equal, compare second index for differences */
-
- else if (a[1] < b[1]) return -1;
- else return (a[1] > b[1]);
-}
-
-/*
- * update the DAG for all objects linked to this mesh
- */
-
-static void mesh_update( Mesh * mesh )
-{
- Object_updateDag( (void *) mesh );
-}
-
-/*
- * delete vertices from mesh, then delete edges/keys/faces which used those
- * vertices
- *
- * Deletion is done by "smart compaction"; groups of verts/edges/faces which
- * remain in the list are copied to new list instead of one at a time. Since
- * Blender has no realloc we would have to copy things anyway, so there's no
- * point trying to fill empty entries with data from the end of the lists.
- *
- * vert_table is a lookup table for mapping old verts to new verts (after the
- * vextex list has deleted vertices removed). Each entry contains the
- * vertex's new index.
- */
-
-static void delete_verts( Mesh *mesh, unsigned int *vert_table, int to_delete )
-{
- /*
- * (1) allocate vertex table (initialize contents to 0)
- * (2) mark each vertex being deleted in vertex table (= UINT_MAX)
- * (3) update remaining table entries with "new" vertex index (after
- * compaction)
- * (4) allocate new vertex list
- * (5) do "smart copy" of vertices from old to new
- * * each moved vertex is entered into vertex table: if vertex i is
- * moving to index j in new list
- * vert_table[i] = j;
- * (6) if keys, do "smart copy" of keys
- * (7) process edge list
- * update vert index
- * delete edges which delete verts
- * (7) allocate new edge list
- * (8) do "smart copy" of edges
- * (9) allocate new face list
- * (10) do "smart copy" of face
- */
-
- unsigned int *tmpvert;
- CustomData vdata;
- int i, count, state, dstindex, totvert;
-
- totvert = mesh->totvert - to_delete;
- CustomData_copy( &mesh->vdata, &vdata, CD_MASK_MESH, CD_CALLOC, totvert );
-
- /*
- * do "smart compaction" of the table; find and copy groups of vertices
- * which are not being deleted
- */
-
- dstindex = 0;
- tmpvert = vert_table;
- count = 0;
- state = 1;
- for( i = 0; i < mesh->totvert; ++i, ++tmpvert ) {
- switch( state ) {
- case 0: /* skipping verts */
- if( *tmpvert == UINT_MAX ) {
- ++count;
- } else {
- count = 1;
- state = 1;
- }
- break;
- case 1: /* gathering verts */
- if( *tmpvert != UINT_MAX ) {
- ++count;
- } else {
- if( count ) {
- CustomData_copy_data( &mesh->vdata, &vdata, i-count,
- dstindex, count );
- dstindex += count;
- }
- count = 1;
- state = 0;
- }
- }
- }
-
- /* if we were gathering verts at the end of the loop, copy those */
- if( state && count )
- CustomData_copy_data( &mesh->vdata, &vdata, i-count, dstindex, count );
-
- /* delete old vertex list, install the new one, update vertex count */
- CustomData_free( &mesh->vdata, mesh->totvert );
- mesh->vdata = vdata;
- mesh->totvert = totvert;
- mesh_update_customdata_pointers( mesh );
-}
-
-static void delete_edges( Mesh *mesh, unsigned int *vert_table, int to_delete )
-{
- int i;
- MEdge *tmpedge;
-
- /* if not given, then mark and count edges to be deleted */
- if( !to_delete ) {
- tmpedge = mesh->medge;
- for( i = mesh->totedge; i-- ; ++tmpedge )
- if( vert_table[tmpedge->v1] == UINT_MAX ||
- vert_table[tmpedge->v2] == UINT_MAX ) {
- tmpedge->v1 = UINT_MAX;
- ++to_delete;
- }
- }
-
- /* if there are edges to delete, handle it */
- if( to_delete ) {
- CustomData edata;
- int count, state, dstindex, totedge;
-
- /* allocate new edge list and populate */
- totedge = mesh->totedge - to_delete;
- CustomData_copy( &mesh->edata, &edata, CD_MASK_MESH, CD_CALLOC, totedge);
-
- /*
- * do "smart compaction" of the edges; find and copy groups of edges
- * which are not being deleted
- */
-
- dstindex = 0;
- tmpedge = mesh->medge;
- count = 0;
- state = 1;
- for( i = 0; i < mesh->totedge; ++i, ++tmpedge ) {
- switch( state ) {
- case 0: /* skipping edges */
- if( tmpedge->v1 == UINT_MAX ) {
- ++count;
- } else {
- count = 1;
- state = 1;
- }
- break;
- case 1: /* gathering edges */
- if( tmpedge->v1 != UINT_MAX ) {
- ++count;
- } else {
- if( count ) {
- CustomData_copy_data( &mesh->edata, &edata, i-count,
- dstindex, count );
- dstindex += count;
- }
- count = 1;
- state = 0;
- }
- }
- /* if edge is good, update vertex indices */
- }
-
- /* copy any pending good edges */
- if( state && count )
- CustomData_copy_data( &mesh->edata, &edata, i-count, dstindex,
- count );
-
- /* delete old edge list, install the new one, update vertex count */
- CustomData_free( &mesh->edata, mesh->totedge );
- mesh->edata = edata;
- mesh->totedge = totedge;
- mesh_update_customdata_pointers( mesh );
- }
-
- /* if vertices were deleted, update edge's vertices */
- if( vert_table ) {
- tmpedge = mesh->medge;
- for( i = mesh->totedge; i--; ++tmpedge ) {
- tmpedge->v1 = vert_table[tmpedge->v1];
- tmpedge->v2 = vert_table[tmpedge->v2];
- }
- }
-}
-
-/*
-* Since all faces must have 3 or 4 verts, we can't have v3 or v4 be zero.
-* If that happens during the deletion, we have to shuffle the vertices
-* around; otherwise it can cause an Eeekadoodle or worse. If there are
-* texture faces as well, they have to be shuffled as well.
-*
-* (code borrowed from test_index_face() in mesh.c, but since we know the
-* faces already have correct number of vertices, this is a little faster)
-*/
-
-static void eeek_fix( MFace *mface, int len4 )
-{
- /* if 4 verts, then neither v3 nor v4 can be zero */
- if( len4 ) {
- if( !mface->v3 || !mface->v4 ) {
- SWAP( int, mface->v1, mface->v3 );
- SWAP( int, mface->v2, mface->v4 );
- }
- } else if( !mface->v3 ) {
- /* if 2 verts, then just v3 cannot be zero (v4 MUST be zero) */
- SWAP( int, mface->v1, mface->v2 );
- SWAP( int, mface->v2, mface->v3 );
- }
-}
-
-static void delete_faces( Mesh *mesh, unsigned int *vert_table, int to_delete )
-{
- int i;
- MFace *tmpface;
-
- /* if there are faces to delete, handle it */
- if( to_delete ) {
- CustomData fdata;
- int count, state, dstindex, totface;
-
- totface = mesh->totface - to_delete;
- CustomData_copy( &mesh->fdata, &fdata, CD_MASK_MESH, CD_CALLOC, totface );
-
- /*
- * do "smart compaction" of the faces; find and copy groups of faces
- * which are not being deleted
- */
-
- dstindex = 0;
- tmpface = mesh->mface;
-
- count = 0;
- state = 1;
- for( i = 0; i < mesh->totface; ++i ) {
- switch( state ) {
- case 0: /* skipping faces */
- if( tmpface->v1 == UINT_MAX ) {
- ++count;
- } else {
- count = 1;
- state = 1;
- }
- break;
- case 1: /* gathering faces */
- if( tmpface->v1 != UINT_MAX ) {
- ++count;
- } else {
- if( count ) {
- CustomData_copy_data( &mesh->fdata, &fdata, i-count,
- dstindex, count );
- dstindex += count;
- }
- count = 1;
- state = 0;
- }
- }
- ++tmpface;
- }
-
- /* if we were gathering faces at the end of the loop, copy those */
- if ( state && count )
- CustomData_copy_data( &mesh->fdata, &fdata, i-count, dstindex,
- count );
-
- /* delete old face list, install the new one, update face count */
-
- CustomData_free( &mesh->fdata, mesh->totface );
- mesh->fdata = fdata;
- mesh->totface = totface;
- mesh_update_customdata_pointers( mesh );
- }
-
- /* if vertices were deleted, update face's vertices */
- if( vert_table ) {
- tmpface = mesh->mface;
-
- for( i = 0; i<mesh->totface; ++i, ++tmpface ) {
- int len4 = tmpface->v4;
- tmpface->v1 = vert_table[tmpface->v1];
- tmpface->v2 = vert_table[tmpface->v2];
- tmpface->v3 = vert_table[tmpface->v3];
- if(len4)
- tmpface->v4 = vert_table[tmpface->v4];
- else
- tmpface->v4 = 0;
-
- test_index_face( tmpface, &mesh->fdata, i, len4? 4: 3);
- }
- }
-}
-
-/*
- * fill up vertex lookup table with old-to-new mappings
- *
- * returns the number of vertices marked for deletion
- */
-
-static unsigned int make_vertex_table( unsigned int *vert_table, int count )
-{
- int i;
- unsigned int *tmpvert = vert_table;
- unsigned int to_delete = 0;
- unsigned int new_index = 0;
-
- /* fill the lookup table with old->new index mappings */
- for( i = count; i; --i, ++tmpvert ) {
- if( *tmpvert == UINT_MAX ) {
- ++to_delete;
- } else {
- *tmpvert = new_index;
- ++new_index;
- }
- }
- return to_delete;
-}
-
-
-/************************************************************************
- *
- * Color attributes
- *
- ************************************************************************/
-
-/*
- * get a color attribute
- */
-
-static PyObject *MCol_getAttr( BPy_MCol * self, void *type )
-{
- unsigned char param;
-
- switch( (long)type ) {
- case 'R': /* these are backwards, but that how it works */
- param = self->color->b;
- break;
- case 'G':
- param = self->color->g;
- break;
- case 'B': /* these are backwards, but that how it works */
- param = self->color->r;
- break;
- case 'A':
- param = self->color->a;
- break;
- default:
- {
- char errstr[1024];
- sprintf( errstr, "undefined type '%d' in MCol_getAttr",
- (int)((long)type & 0xff));
- return EXPP_ReturnPyObjError( PyExc_RuntimeError, errstr );
- }
- }
-
- return PyInt_FromLong( param );
-}
-
-/*
- * set a color attribute
- */
-
-static int MCol_setAttr( BPy_MCol * self, PyObject * value, void * type )
-{
- unsigned char *param;
-
- switch( (long)type ) {
- case 'R': /* these are backwards, but that how it works */
- param = (unsigned char *)&self->color->b;
- break;
- case 'G':
- param = (unsigned char *)&self->color->g;
- break;
- case 'B': /* these are backwards, but that how it works */
- param = (unsigned char *)&self->color->r;
- break;
- case 'A':
- param = (unsigned char *)&self->color->a;
- break;
- default:
- {
- char errstr[1024];
- sprintf( errstr, "undefined type '%d' in MCol_setAttr",
- (int)((long)type & 0xff));
- return EXPP_ReturnIntError( PyExc_RuntimeError, errstr );
- }
- }
-
- return EXPP_setIValueClamped( value, param, 0, 255, 'b' );
-}
-
-/************************************************************************
- *
- * Python MCol_Type attributes get/set structure
- *
- ************************************************************************/
-
-static PyGetSetDef BPy_MCol_getseters[] = {
- {"r",
- (getter)MCol_getAttr, (setter)MCol_setAttr,
- "red component",
- (void *)'R'},
- {"g",
- (getter)MCol_getAttr, (setter)MCol_setAttr,
- "green component",
- (void *)'G'},
- {"b",
- (getter)MCol_getAttr, (setter)MCol_setAttr,
- "blue component",
- (void *)'B'},
- {"a",
- (getter)MCol_getAttr, (setter)MCol_setAttr,
- "alpha component",
- (void *)'A'},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-/*----------------------------object[]---------------------------
- sequence accessor (get)*/
-static PyObject *MCol_item(BPy_MCol * self, int i)
-{
- unsigned char param;
- switch (i) {
- case 0:
- param = self->color->b;
- break;
- case 1:
- param = self->color->g;
- break;
- case 2:
- param = self->color->r;
- break;
- case 3:
- param = self->color->a;
- break;
- default:
- return EXPP_ReturnPyObjError(PyExc_IndexError,
- "vector[index] = x: assignment index out of range\n");
- }
-
- return PyInt_FromLong( param );
-}
-
-/*----------------------------object[]-------------------------
- sequence accessor (set)*/
-static int MCol_ass_item(BPy_MCol * self, int i, PyObject * value)
-{
- unsigned char *param;
-
- switch (i) {
- case 0:
- param = (unsigned char *)&self->color->b; /* reversed? why */
- break;
- case 1:
- param = (unsigned char *)&self->color->g;
- break;
- case 2:
- param = (unsigned char *)&self->color->r; /* reversed? why */
- break;
- case 3:
- param = (unsigned char *)&self->color->a;
- break;
- default:
- {
- return EXPP_ReturnIntError( PyExc_RuntimeError, "Index out of range" );
- }
- }
- return EXPP_setIValueClamped( value, param, 0, 255, 'b' );
-}
-
-/************************************************************************
- *
- * Python MCol_Type methods
- *
- ************************************************************************/
-
-static PyObject *MCol_repr( BPy_MCol * self )
-{
- return PyString_FromFormat( "[MCol %d %d %d %d]",
- (int)self->color->b, (int)self->color->g,
- (int)self->color->r, (int)self->color->a );
-}
-
-/*-----------------PROTCOL DECLARATIONS--------------------------*/
-static PySequenceMethods MCol_SeqMethods = {
- (inquiry) NULL, /* sq_length */
- (binaryfunc) NULL, /* sq_concat */
- (intargfunc) NULL, /* sq_repeat */
- (intargfunc) MCol_item, /* sq_item */
- (intintargfunc) NULL, /* sq_slice */
- (intobjargproc) MCol_ass_item, /* sq_ass_item */
- (intintobjargproc) NULL, /* sq_ass_slice */
-};
-
-/************************************************************************
- *
- * Python MCol_Type structure definition
- *
- ************************************************************************/
-
-PyTypeObject MCol_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender MCol", /* char *tp_name; */
- sizeof( BPy_MCol ), /* 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 ) MCol_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &MCol_SeqMethods, /* 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_MCol_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 *MCol_CreatePyObject( MCol * color )
-{
- BPy_MCol *obj = PyObject_NEW( BPy_MCol, &MCol_Type );
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyObject_New() failed" );
-
- obj->color = color;
- return (PyObject *)obj;
-}
-
-/************************************************************************
- *
- * BPy_MVert attributes
- *
- ************************************************************************/
-
-static MVert * MVert_get_pointer( BPy_MVert * self )
-{
- if( BPy_MVert_Check( self ) ) {
- if( self->index >= ((Mesh *)self->data)->totvert )
- return (MVert *)EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "MVert is no longer valid" );
- return &((Mesh *)self->data)->mvert[self->index];
- }
- else
- return (MVert *)self->data;
-}
-
-/*
- * get a vertex's coordinate
- */
-
-static PyObject *MVert_getCoord( BPy_MVert * self )
-{
- MVert *v;
-
- v = MVert_get_pointer( self );
- if( !v )
- return NULL;
-
- return newVectorObject( v->co, 3, Py_WRAP );
-}
-
-/*
- * set a vertex's coordinate
- */
-
-static int MVert_setCoord( BPy_MVert * self, VectorObject * value )
-{
- int i;
- MVert *v;
-
- v = MVert_get_pointer( self );
- if( !v )
- return -1;
-
- if( !VectorObject_Check( value ) || value->size != 3 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected vector argument of size 3" );
-
- for( i=0; i<3 ; ++i)
- v->co[i] = value->vec[i];
-
- return 0;
-}
-
-/*
- * get a vertex's index
- */
-
-static PyObject *MVert_getIndex( BPy_MVert * self )
-{
- if( self->index >= ((Mesh *)self->data)->totvert )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "MVert is no longer valid" );
-
- return PyInt_FromLong( self->index );
-}
-
-
-/*
- * get a verts's hidden state
- */
-
-static PyObject *MVert_getMFlagBits( BPy_MVert * self, void * type )
-{
- MVert *v;
-
- v = MVert_get_pointer( self );
- if (!v)
- return NULL; /* error is set */
-
- return EXPP_getBitfield( &v->flag, (int)((long)type & 0xff), 'b' );
-}
-
-
-/*
- * set a verts's hidden state
- */
-
-static int MVert_setMFlagBits( BPy_MVert * self, PyObject * value,
- void * type )
-{
- MVert *v;
-
- v = MVert_get_pointer( self );
-
- if (!v)
- return -1; /* error is set */
-
- return EXPP_setBitfield( value, &v->flag,
- (int)((long)type & 0xff), 'b' );
-}
-
-
-/*
- * get a vertex's normal
- */
-
-static PyObject *MVert_getNormal( BPy_MVert * self )
-{
- float no[3];
- int i;
- MVert *v;
-
- v = MVert_get_pointer( self );
- if( !v )
- return NULL; /* error set */
-
- for( i = 0; i < 3; ++i )
- no[i] = (float)(v->no[i] / 32767.0);
- return newVectorObject( no, 3, Py_NEW );
-}
-
-/*
- * set a vertex's normal
- */
-
-static int MVert_setNormal( BPy_MVert * self, VectorObject * value )
-{
- int i;
- MVert *v;
- float normal[3];
-
- v = MVert_get_pointer( self );
- if( !v )
- return -1; /* error set */
-
- if( !VectorObject_Check( value ) || value->size != 3 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected vector argument of size 3" );
-
-
- for( i=0; i<3 ; ++i)
- normal[i] = value->vec[i];
-
- Normalize(normal);
-
- for( i=0; i<3 ; ++i)
- v->no[i] = (short)(normal[i]*32767.0);
-
- return 0;
-}
-
-
-/*
- * get a vertex's select status
- */
-
-static PyObject *MVert_getSel( BPy_MVert *self )
-{
- MVert *v;
-
- v = MVert_get_pointer( self );
- if( !v )
- return NULL; /* error is set */
-
- return EXPP_getBitfield( &v->flag, SELECT, 'b' );
-}
-
-/*
- * set a vertex's select status
- */
-
-static int MVert_setSel( BPy_MVert *self, PyObject *value )
-{
- MVert *v = MVert_get_pointer( self );
- Mesh *me = (Mesh *)self->data;
- if (!v)
- return -1; /* error is set */
-
- /*
- * if vertex exists and setting status is OK, delete select storage
- * of the edges and faces as well
- */
-
- if( v && !EXPP_setBitfield( value, &v->flag, SELECT, 'b' ) ) {
- if( me && me->mselect ) {
- MEM_freeN( me->mselect );
- me->mselect = NULL;
- }
- return 0;
- }
- return -1;
-}
-
-/*
- * get a vertex's UV coordinates
- */
-
-static PyObject *MVert_getUVco( BPy_MVert *self )
-{
- Mesh *me = (Mesh *)self->data;
-
- if( !me->msticky )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh has no 'sticky' coordinates" );
-
- if( self->index >= ((Mesh *)self->data)->totvert )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "MVert is no longer valid" );
-
- return newVectorObject( me->msticky[self->index].co, 2, Py_WRAP );
-}
-
-/*
- * set a vertex's UV coordinates
- */
-
-static int MVert_setUVco( BPy_MVert *self, PyObject *value )
-{
- float uvco[3] = {0.0, 0.0};
- Mesh *me = (Mesh *)self->data;
- struct MSticky *v;
- int i;
-
- /*
- * at least for now, don't allow creation of sticky coordinates if they
- * don't already exist
- */
-
- if( !me->msticky )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "mesh has no 'sticky' coordinates" );
-
- if( self->index >= ((Mesh *)self->data)->totvert )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "MVert is no longer valid" );
-
- if( VectorObject_Check( value ) ) {
- VectorObject *vect = (VectorObject *)value;
- if( vect->size != 2 )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected 2D vector" );
- for( i = 0; i < vect->size; ++i )
- uvco[i] = vect->vec[i];
- } else if( !PyArg_ParseTuple( value, "ff",
- &uvco[0], &uvco[1] ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected 2D vector" );
-
- v = &me->msticky[self->index];
-
- for( i = 0; i < 2; ++i )
- v->co[i] = uvco[i];
-
- return 0;
-}
-
-/************************************************************************
- *
- * Python MVert_Type attributes get/set structure
- *
- ************************************************************************/
-
-static PyGetSetDef BPy_MVert_getseters[] = {
- {"co",
- (getter)MVert_getCoord, (setter)MVert_setCoord,
- "vertex's coordinate",
- NULL},
- {"index",
- (getter)MVert_getIndex, (setter)NULL,
- "vertex's index",
- NULL},
- {"no",
- (getter)MVert_getNormal, (setter)MVert_setNormal,
- "vertex's normal",
- NULL},
- {"sel",
- (getter)MVert_getSel, (setter)MVert_setSel,
- "vertex's select status",
- NULL},
- {"hide",
- (getter)MVert_getMFlagBits, (setter)MVert_setMFlagBits,
- "vert hidden in edit mode",
- (void *)ME_HIDE},
- {"uvco",
- (getter)MVert_getUVco, (setter)MVert_setUVco,
- "vertex's UV coordinates",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-static PyGetSetDef BPy_PVert_getseters[] = {
- {"co",
- (getter)MVert_getCoord, (setter)MVert_setCoord,
- "vertex's coordinate",
- NULL},
- {"no",
- (getter)MVert_getNormal, (setter)MVert_setNormal,
- "vertex's normal",
- NULL},
- {"sel",
- (getter)MVert_getSel, (setter)MVert_setSel,
- "vertex's select status",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/************************************************************************
- *
- * Python MVert_Type standard operations
- *
- ************************************************************************/
-
-static void MVert_dealloc( BPy_MVert * self )
-{
- if( BPy_PVert_Check( self ) ) /* free memory of thick objects */
- MEM_freeN ( self->data );
-
- PyObject_DEL( self );
-}
-
-static int MVert_compare( BPy_MVert * a, BPy_MVert * b )
-{
- return( a->data == b->data && a->index == b->index ) ? 0 : -1;
-}
-
-static PyObject *MVert_repr( BPy_MVert * self )
-{
- char format[512];
- char index[24];
- MVert *v;
-
- v = MVert_get_pointer( self );
- if( !v )
- return NULL;
-
- if( BPy_MVert_Check( self ) )
- sprintf( index, "%d", self->index );
- else
- BLI_strncpy( index, "(None)", 24 );
-
- sprintf( format, "[MVert (%f %f %f) (%f %f %f) %s]",
- v->co[0], v->co[1], v->co[2], (float)(v->no[0] / 32767.0),
- (float)(v->no[1] / 32767.0), (float)(v->no[2] / 32767.0),
- index );
-
- return PyString_FromString( format );
-}
-
-static long MVert_hash( BPy_MVert *self )
-{
- return (long)self->index;
-}
-
-static PyObject *Mesh_addPropLayer_internal(Mesh *mesh, CustomData *data, int tot, PyObject *args)
-{
- char *name=NULL;
- int type = -1;
-
- if( !PyArg_ParseTuple( args, "si", &name, &type) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string and an int" );
- if (strlen(name)>31)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, maximum name length is 31");
- if((type != CD_PROP_FLT) && (type != CD_PROP_INT) && (type != CD_PROP_STR))
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, unknown layer type");
- if (name)
- CustomData_add_layer_named(data, type, CD_DEFAULT, NULL,tot,name);
-
- mesh_update_customdata_pointers(mesh);
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_removePropLayer_internal(Mesh *mesh, CustomData *data, int tot,PyObject *value)
-{
- CustomDataLayer *layer;
- char *name=PyString_AsString(value);
- int i;
-
- if( !name )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if (strlen(name)>31)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, maximum name length is 31" );
-
- i = CustomData_get_named_layer_index(data, CD_PROP_FLT, name);
- if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_INT, name);
- if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_STR, name);
- if (i==-1)
- return EXPP_ReturnPyObjError(PyExc_ValueError,
- "No matching layers to remove" );
- layer = &data->layers[i];
- CustomData_free_layer(data, layer->type, tot, i);
- mesh_update_customdata_pointers(mesh);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_renamePropLayer_internal(Mesh *mesh, CustomData *data, PyObject *args)
-{
- CustomDataLayer *layer;
- int i;
- char *name_from, *name_to;
-
- if( !PyArg_ParseTuple( args, "ss", &name_from, &name_to ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 2 strings" );
-
- if (strlen(name_from)>31 || strlen(name_to)>31)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, maximum name length is 31" );
-
- i = CustomData_get_named_layer_index(data, CD_PROP_FLT, name_from);
- if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_INT, name_from);
- if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_STR, name_from);
- if(i == -1)
- return EXPP_ReturnPyObjError(PyExc_ValueError,
- "No matching layers to rename" );
-
- layer = &data->layers[i];
-
- strcpy(layer->name, name_to); /* we alredy know the string sizes are under 32 */
- CustomData_set_layer_unique_name(data, i);
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_propList_internal(CustomData *data)
-{
- CustomDataLayer *layer;
- PyObject *list = PyList_New( 0 ), *item;
- int i;
- for(i=0; i<data->totlayer; i++) {
- layer = &data->layers[i];
- if( (layer->type == CD_PROP_FLT) || (layer->type == CD_PROP_INT) || (layer->type == CD_PROP_STR)) {
- item = PyString_FromString(layer->name);
- PyList_Append( list, item );
- Py_DECREF(item);
- }
- }
- return list;
-}
-
-static PyObject *Mesh_getProperty_internal(CustomData *data, int eindex, PyObject *value)
-{
- CustomDataLayer *layer;
- char *name=PyString_AsString(value);
- int i;
- MFloatProperty *pf;
- MIntProperty *pi;
- MStringProperty *ps;
-
- if(!name)
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an string argument" );
-
- if (strlen(name)>31)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, maximum name length is 31" );
-
- i = CustomData_get_named_layer_index(data, CD_PROP_FLT, name);
- if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_INT, name);
- if(i == -1) i = CustomData_get_named_layer_index(data, CD_PROP_STR, name);
- if(i == -1)
- return EXPP_ReturnPyObjError(PyExc_ValueError,
- "No matching layers" );
-
- layer = &data->layers[i];
-
- if(layer->type == CD_PROP_FLT){
- pf = layer->data;
- return PyFloat_FromDouble(pf[eindex].f);
- }
- else if(layer->type == CD_PROP_INT){
- pi = layer->data;
- return PyInt_FromLong(pi[eindex].i);
-
- }
- else if(layer->type == CD_PROP_STR){
- ps = layer->data;
- return PyString_FromString(ps[eindex].s);
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_setProperty_internal(CustomData *data, int eindex, PyObject *args)
-{
- CustomDataLayer *layer;
- int i = 0, index, type = -1;
- float f = 0.0f;
- char *s=NULL, *name=NULL;
- MFloatProperty *pf;
- MIntProperty *pi;
- MStringProperty *ps;
- PyObject *val;
-
- if(PyArg_ParseTuple(args, "sO", &name, &val)){
- if (strlen(name)>31)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, maximum name length is 31" );
-
- if(PyInt_Check(val)){
- type = CD_PROP_INT;
- i = (int)PyInt_AS_LONG(val);
- }
- else if(PyFloat_Check(val)){
- type = CD_PROP_FLT;
- f = (float)PyFloat_AsDouble(val);
- }
- else if(PyString_Check(val)){
- type = CD_PROP_STR;
- s = PyString_AsString(val);
- }
- else
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an name plus either float/int/string" );
-
- }
-
- index = CustomData_get_named_layer_index(data, type, name);
- if(index == -1)
- return EXPP_ReturnPyObjError(PyExc_ValueError,
- "No matching layers or type mismatch" );
-
- layer = &data->layers[index];
-
- if(type==CD_PROP_STR){
- if (strlen(s)>255){
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, maximum string length is 255");
- }
- else{
- ps = layer->data;
- strcpy(ps[eindex].s,s);
- }
- }
- else if(type==CD_PROP_FLT){
- pf = layer->data;
- pf[eindex].f = f;
- }
- else{
- pi = layer->data;
- pi[eindex].i = i;
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *MVert_getProp( BPy_MVert *self, PyObject *args)
-{
- if( BPy_MVert_Check( self ) ){
- Mesh *me = (Mesh *)self->data;
- if(self->index >= me->totvert)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, MVert is no longer valid part of mesh!");
- else
- return Mesh_getProperty_internal(&(me->vdata), self->index, args);
- }
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, Vertex not part of a mesh!");
-}
-
-static PyObject *MVert_setProp( BPy_MVert *self, PyObject *args)
-{
- if( BPy_MVert_Check( self ) ){
- Mesh *me = (Mesh *)self->data;
- if(self->index >= me->totvert)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, MVert is no longer valid part of mesh!");
- else
- return Mesh_setProperty_internal(&(me->vdata), self->index, args);
- }
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, Vertex not part of a mesh!");
-}
-
-static struct PyMethodDef BPy_MVert_methods[] = {
- {"getProperty", (PyCFunction)MVert_getProp, METH_O,
- "get property indicated by name"},
- {"setProperty", (PyCFunction)MVert_setProp, METH_VARARGS,
- "set property indicated by name"},
- {NULL, NULL, 0, NULL}
-};
-
-
-/************************************************************************
- *
- * Python MVert_Type structure definition
- *
- ************************************************************************/
-
-PyTypeObject MVert_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender MVert", /* char *tp_name; */
- sizeof( BPy_MVert ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) MVert_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) MVert_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) MVert_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 ) MVert_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_MVert_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_MVert_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
-};
-
-/************************************************************************
- *
- * Python PVert_Type standard operations
- *
- ************************************************************************/
-
-static int PVert_compare( BPy_MVert * a, BPy_MVert * b )
-{
- return( a->data == b->data ) ? 0 : -1;
-}
-
-/************************************************************************
- *
- * Python PVert_Type structure definition
- *
- ************************************************************************/
-
-PyTypeObject PVert_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender PVert", /* char *tp_name; */
- sizeof( BPy_MVert ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) MVert_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) PVert_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) MVert_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 ) MVert_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 ***/
- NULL, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_PVert_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
-};
-
-/*
- * create 'thin' or 'thick' MVert objects
- *
- * there are two types of objects; thin (wrappers for mesh vertex) and thick
- * (not contains in mesh). Thin objects are MVert_Type and thick are
- * PVert_Type. For thin objects, data is a pointer to a Mesh and index
- * is the vertex's index in mesh->mvert. For thick objects, data is a
- * pointer to an MVert; index is unused.
- */
-
-/*
- * create a thin MVert object
- */
-
-static PyObject *MVert_CreatePyObject( Mesh *mesh, int i )
-{
- BPy_MVert *obj = (BPy_MVert *)PyObject_NEW( BPy_MVert, &MVert_Type );
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyObject_New() failed" );
-
- obj->index = i;
- obj->data = mesh;
- return (PyObject *)obj;
-}
-
-/*
- * create a thick MVert object
- */
-
-static PyObject *PVert_CreatePyObject( MVert *vert )
-{
- MVert *newvert;
- BPy_MVert *obj = (BPy_MVert *)PyObject_NEW( BPy_MVert, &PVert_Type );
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyObject_New() failed" );
-
- newvert = (MVert *)MEM_callocN( sizeof( MVert ), "MVert" );
- if( !newvert )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "MEM_callocN() failed" );
-
- memcpy( newvert, vert, sizeof( MVert ) );
- obj->data = newvert;
- return (PyObject *)obj;
-}
-
-/************************************************************************
- *
- * Vertex sequence
- *
- ************************************************************************/
-
-static int MVertSeq_len( BPy_MVertSeq * self )
-{
- return self->mesh->totvert;
-}
-
-/*
- * retrive a single MVert from somewhere in the vertex list
- */
-
-static PyObject *MVertSeq_item( BPy_MVertSeq * self, int i )
-{
- if( i < 0 || i >= self->mesh->totvert )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-
- return MVert_CreatePyObject( self->mesh, i );
-}
-
-/*
- * retrieve a slice of the vertex list (as a Python list)
- *
- * Python is nice enough to handle negative indices for us: if the user
- * specifies -1, Python will pass us len()-1. So we can just check for
- * indices in the range 0:len()-1. Of course, we should never actually
- * return the high index, but up to one less.
- */
-
-static PyObject *MVertSeq_slice( BPy_MVertSeq *self, int low, int high )
-{
- PyObject *list;
- int i;
-
- /*
- * Python list slice operator returns empty list when asked for a slice
- * outside the list, or if indices are reversed (low > high). Clamp
- * our input to do the same.
- */
-
- if( low < 0 ) low = 0;
- if( high > self->mesh->totvert ) high = self->mesh->totvert;
- if( low > high ) low = high;
-
- list = PyList_New( high-low );
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyList_New() failed" );
-
- /*
- * return Py_NEW copies of requested vertices
- */
-
- for( i = low; i < high; ++i )
- PyList_SET_ITEM( list, i-low,
- PVert_CreatePyObject( (void *)&self->mesh->mvert[i] ) );
- return list;
-}
-
-/*
- * assign a single MVert to somewhere in the vertex list
- */
-
-static int MVertSeq_assign_item( BPy_MVertSeq * self, int i,
- BPy_MVert *v )
-{
- MVert *dst = &self->mesh->mvert[i];
- MVert *src;
-
- if( !v )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "del() not supported" );
-
- if( i < 0 || i >= self->mesh->totvert )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "array index out of range" );
-
- if( BPy_MVert_Check( v ) )
- src = &((Mesh *)v->data)->mvert[v->index];
- else
- src = (MVert *)v->data;
-
- memcpy( dst, src, sizeof(MVert) );
- /* mesh_update( self->mesh );*/
- return 0;
-}
-
-static int MVertSeq_assign_slice( BPy_MVertSeq *self, int low, int high,
- PyObject *args )
-{
- int len, i;
-
- if( !PyList_Check( args ) )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "can only assign lists of MVerts" );
-
- len = PyList_Size( args );
-
- /*
- * Python list slice assign operator allows for changing the size of the
- * destination list, by replacement and appending....
- *
- * >>> l=[1,2,3,4]
- * >>> m=[11,12,13,14]
- * >>> l[5:7]=m
- * >>> print l
- * [1, 2, 3, 4, 11, 12, 13, 14]
- * >>> l=[1,2,3,4]
- * >>> l[2:3]=m
- * >>> print l
- * [1, 2, 11, 12, 13, 14, 4]
- *
- * We don't want the size of the list to change (at least not at time
- * point in development) so we are a little more strict:
- * - low and high indices must be in range [0:len()]
- * - high-low == PyList_Size(v)
- */
-
- if( low < 0 || high > self->mesh->totvert || low > high )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "invalid slice range" );
-
- if( high-low != len )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "slice range and input list sizes must be equal" );
-
- for( i = low; i < high; ++i )
- {
- BPy_MVert *v = (BPy_MVert *)PyList_GET_ITEM( args, i-low );
- MVert *dst = &self->mesh->mvert[i];
- MVert *src;
-
- if( BPy_MVert_Check( v ) )
- src = &((Mesh *)v->data)->mvert[v->index];
- else
- src = (MVert *)v->data;
-
- memcpy( dst, src, sizeof(MVert) );
- }
- /* mesh_update( self->mesh );*/
- return 0;
-}
-
-static PySequenceMethods MVertSeq_as_sequence = {
- ( inquiry ) MVertSeq_len, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) MVertSeq_item, /* sq_item */
- ( intintargfunc ) MVertSeq_slice, /* sq_slice */
- ( intobjargproc ) MVertSeq_assign_item, /* sq_ass_item */
- ( intintobjargproc ) MVertSeq_assign_slice, /* sq_ass_slice */
- 0,0,0,
-};
-
-/************************************************************************
- *
- * Python MVertSeq_Type iterator (iterates over vertices)
- *
- ************************************************************************/
-
-/*
- * Initialize the interator index
- */
-
-static PyObject *MVertSeq_getIter( BPy_MVertSeq * self )
-{
- if (self->iter==-1) { /* iteration for this pyobject is not yet used, just return self */
- self->iter = 0;
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- /* were alredy using this as an iterator, make a copy to loop on */
- BPy_MVertSeq *seq = (BPy_MVertSeq *)MVertSeq_CreatePyObject(self->mesh);
- seq->iter = 0;
- return (PyObject *)seq;
- }
-}
-
-/*
- * Return next MVert.
- */
-
-static PyObject *MVertSeq_nextIter( BPy_MVertSeq * self )
-{
- if( self->iter == self->mesh->totvert ) {
- self->iter= -1; /* allow it to be used as an iterator again without creating a new BPy_MVertSeq */
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- return MVert_CreatePyObject( self->mesh, self->iter++ );
-}
-
-/************************************************************************
- *
- * Python MVertSeq_Type methods
- *
- ************************************************************************/
-
-static PyObject *MVertSeq_extend( BPy_MVertSeq * self, PyObject *args )
-{
- int len, newlen;
- int i,j;
- PyObject *tmp;
- MVert *newvert, *tmpvert;
- Mesh *mesh = self->mesh;
- CustomData vdata;
- /* make sure we get a sequence of tuples of something */
-
- switch( PySequence_Size( args ) ) {
- case 1: /* better be a list or a tuple */
- tmp = PyTuple_GET_ITEM( args, 0 );
- if( !VectorObject_Check ( tmp ) ) {
- if( !PySequence_Check ( tmp ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of sequence triplets" );
- else if( !PySequence_Size ( tmp ) ) {
- Py_RETURN_NONE;
- }
- args = tmp;
- }
- Py_INCREF( args ); /* so we can safely DECREF later */
- break;
- case 3:
- tmp = PyTuple_GET_ITEM( args, 0 );
- /* if first item is not a number, it's wrong */
- if( !PyNumber_Check( tmp ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of sequence triplets" );
-
- /* otherwise, put into a new tuple */
- args = Py_BuildValue( "((OOO))", tmp,
- PyTuple_GET_ITEM( args, 1 ), PyTuple_GET_ITEM( args, 2 ) );
- if( !args )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Py_BuildValue() failed" );
- break;
-
- default: /* anything else is definitely wrong */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of sequence triplets" );
- }
-
- /* if no verts given, return quietly */
- len = PySequence_Size( args );
- if( len == 0 ) {
- Py_DECREF ( args );
- Py_RETURN_NONE;
- }
-
- /* create custom vertex data arrays and copy existing vertices into it */
-
- newlen = mesh->totvert + len;
- CustomData_copy( &mesh->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, newlen );
- CustomData_copy_data( &mesh->vdata, &vdata, 0, 0, mesh->totvert );
-
- if ( !CustomData_has_layer( &vdata, CD_MVERT ) )
- CustomData_add_layer( &vdata, CD_MVERT, CD_CALLOC, NULL, newlen );
-
- newvert = CustomData_get_layer( &vdata, CD_MVERT );
-
- /* scan the input list and insert the new vertices */
-
- tmpvert = &newvert[mesh->totvert];
- for( i = 0; i < len; ++i ) {
- float co[3];
- tmp = PySequence_GetItem( args, i );
- if( VectorObject_Check( tmp ) ) {
- if( ((VectorObject *)tmp)->size != 3 ) {
- CustomData_free( &vdata, newlen );
- Py_DECREF ( tmp );
- Py_DECREF ( args );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected vector of size 3" );
- }
- for( j = 0; j < 3; ++j )
- co[j] = ((VectorObject *)tmp)->vec[j];
- } else if( PySequence_Check( tmp ) ) {
- int ok=1;
- PyObject *flt;
- if( PySequence_Size( tmp ) != 3 )
- ok = 0;
- else
- for( j = 0; ok && j < 3; ++j ) {
- flt = PySequence_ITEM( tmp, j );
- if( !PyNumber_Check ( flt ) )
- ok = 0;
- else
- co[j] = (float)PyFloat_AsDouble( flt );
- Py_DECREF( flt );
- }
-
- if( !ok ) {
- CustomData_free( &vdata, newlen );
- Py_DECREF ( args );
- Py_DECREF ( tmp );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected sequence triplet of floats" );
- }
- } else {
- CustomData_free( &vdata, newlen );
- Py_DECREF ( args );
- Py_DECREF ( tmp );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected sequence triplet of floats" );
- }
-
- Py_DECREF ( tmp );
-
- /* add the coordinate to the new list */
- memcpy( tmpvert->co, co, sizeof(co) );
-
- tmpvert->flag |= SELECT;
- /* TODO: anything else which needs to be done when we add a vert? */
- /* probably not: NMesh's newvert() doesn't */
- ++tmpvert;
- }
-
- CustomData_free( &mesh->vdata, mesh->totvert );
- mesh->vdata = vdata;
- mesh_update_customdata_pointers( mesh );
-
- /*
- * if there are keys, have to fix those lists up
- */
-
- if( mesh->key ) {
- KeyBlock *currkey = mesh->key->block.first;
- float *fp, *newkey;
-
- while( currkey ) {
-
- /* create key list, copy existing data if any */
- newkey = MEM_callocN(mesh->key->elemsize*newlen, "keydata");
- if( currkey->data ) {
- memcpy( newkey, currkey->data,
- mesh->totvert*mesh->key->elemsize );
- MEM_freeN( currkey->data );
- currkey->data = newkey;
- }
-
- /* add data for new vertices */
- fp = (float *)((char *)currkey->data +
- (mesh->key->elemsize*mesh->totvert));
- tmpvert = mesh->mvert + mesh->totvert;
- for( i = newlen - mesh->totvert; i > 0; --i ) {
- VECCOPY(fp, tmpvert->co);
- fp += 3;
- tmpvert++;
- }
- currkey->totelem = newlen;
- currkey = currkey->next;
- }
- }
-
- /* set final vertex list size */
- mesh->totvert = newlen;
-
- mesh_update( mesh );
-
- Py_DECREF ( args );
- Py_RETURN_NONE;
-}
-
-static PyObject *MVertSeq_delete( BPy_MVertSeq * self, PyObject *args )
-{
- unsigned int *vert_table;
- int vert_delete, face_count;
- int i;
- Mesh *mesh = self->mesh;
- MFace *tmpface;
-
- /*
- * if input tuple contains a single sequence, use it as input instead;
- * otherwise use the sequence as-is and check later that it contains
- * one or more integers or MVerts
- */
- if( PySequence_Size( args ) == 1 ) {
- PyObject *tmp = PyTuple_GET_ITEM( args, 0 );
- if( PySequence_Check( tmp ) )
- args = tmp;
- }
-
- /* if sequence is empty, do nothing */
- if( PySequence_Size( args ) == 0 ) {
- Py_RETURN_NONE;
- }
-
- /* allocate vertex lookup table */
- vert_table = (unsigned int *)MEM_callocN(
- mesh->totvert*sizeof( unsigned int ), "vert_table" );
-
- /* get the indices of vertices to be removed */
- for( i = PySequence_Size( args ); i--; ) {
- PyObject *tmp = PySequence_GetItem( args, i );
- int index;
- if( BPy_MVert_Check( tmp ) ) {
- if( (void *)self->mesh != ((BPy_MVert*)tmp)->data ) {
- MEM_freeN( vert_table );
- Py_DECREF( tmp );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "MVert belongs to a different mesh" );
- }
- index = ((BPy_MVert*)tmp)->index;
- } else if( PyInt_Check( tmp ) ) {
- index = PyInt_AsLong ( tmp );
- } else {
- MEM_freeN( vert_table );
- Py_DECREF( tmp );
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of ints or MVerts" );
- }
- Py_DECREF( tmp );
- if( index < 0 || index >= mesh->totvert ) {
- MEM_freeN( vert_table );
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
- }
- vert_table[index] = UINT_MAX;
- }
-
- /* delete things, then clean up and return */
-
- vert_delete = make_vertex_table( vert_table, mesh->totvert );
- if( vert_delete )
- delete_verts( mesh, vert_table, vert_delete );
-
- /* calculate edges to delete, fix vertex indices */
- delete_edges( mesh, vert_table, 0 );
-
- /*
- * find number of faces which contain any of the deleted vertices,
- * and mark them, then delete them
- */
- tmpface = mesh->mface;
- face_count=0;
- for( i = mesh->totface; i--; ++tmpface ) {
- if( vert_table[tmpface->v1] == UINT_MAX ||
- vert_table[tmpface->v2] == UINT_MAX ||
- vert_table[tmpface->v3] == UINT_MAX ||
- ( tmpface->v4 && vert_table[tmpface->v4] == UINT_MAX ) ) {
- tmpface->v1 = UINT_MAX;
- ++face_count;
- }
- }
- delete_faces( mesh, vert_table, face_count );
-
- /* clean up and exit */
- MEM_freeN( vert_table );
- mesh_update ( mesh );
- Py_RETURN_NONE;
-}
-
-static PyObject *MVertSeq_selected( BPy_MVertSeq * self )
-{
- int i, count;
- Mesh *mesh = self->mesh;
- MVert *tmpvert;
- PyObject *list;
-
- /* first count selected edges (quicker than appending to PyList?) */
- count = 0;
- tmpvert = mesh->mvert;
- for( i = 0; i < mesh->totvert; ++i, ++tmpvert )
- if( tmpvert->flag & SELECT )
- ++count;
-
- list = PyList_New( count );
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyList_New() failed" );
-
- /* next, insert selected edges into list */
- count = 0;
- tmpvert = mesh->mvert;
- for( i = 0; i < mesh->totvert; ++i, ++tmpvert ) {
- if( tmpvert->flag & SELECT ) {
- PyObject *tmp = PyInt_FromLong( i );
- if( !tmp ) {
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyInt_FromLong() failed" );
- }
- PyList_SET_ITEM( list, count, tmp );
- ++count;
- }
- }
- return list;
-}
-static PyObject *MVertSeq_add_layertype(BPy_MVertSeq *self, PyObject *args)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_addPropLayer_internal(me, &(me->vdata), me->totvert, args);
-}
-static PyObject *MVertSeq_del_layertype(BPy_MVertSeq *self, PyObject *value)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_removePropLayer_internal(me, &(me->vdata), me->totvert, value);
-}
-static PyObject *MVertSeq_rename_layertype(BPy_MVertSeq *self, PyObject *args)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_renamePropLayer_internal(me,&(me->vdata),args);
-}
-static PyObject *MVertSeq_PropertyList(BPy_MVertSeq *self)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_propList_internal(&(me->vdata));
-}
-static PyObject *M_Mesh_PropertiesTypeDict(void)
-{
- PyObject *Types = PyConstant_New( );
- if(Types) {
- BPy_constant *d = (BPy_constant *) Types;
- PyConstant_Insert(d, "FLOAT", PyInt_FromLong(CD_PROP_FLT));
- PyConstant_Insert(d, "INT" , PyInt_FromLong(CD_PROP_INT));
- PyConstant_Insert(d, "STRING", PyInt_FromLong(CD_PROP_STR));
- }
- return Types;
-}
-
-static struct PyMethodDef BPy_MVertSeq_methods[] = {
- {"extend", (PyCFunction)MVertSeq_extend, METH_VARARGS,
- "add vertices to mesh"},
- {"delete", (PyCFunction)MVertSeq_delete, METH_VARARGS,
- "delete vertices from mesh"},
- {"selected", (PyCFunction)MVertSeq_selected, METH_NOARGS,
- "returns a list containing indices of selected vertices"},
- {"addPropertyLayer",(PyCFunction)MVertSeq_add_layertype, METH_VARARGS,
- "add a new property layer"},
- {"removePropertyLayer",(PyCFunction)MVertSeq_del_layertype, METH_O,
- "removes a property layer"},
- {"renamePropertyLayer",(PyCFunction)MVertSeq_rename_layertype, METH_VARARGS,
- "renames an existing property layer"},
- {NULL, NULL, 0, NULL}
-};
-
-static PyGetSetDef BPy_MVertSeq_getseters[] = {
- {"properties",
- (getter)MVertSeq_PropertyList, (setter)NULL,
- "vertex property layers, read only",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-
-/************************************************************************
- *
- * Python MVertSeq_Type standard operations
- *
- ************************************************************************/
-
-/*****************************************************************************/
-/* Python MVertSeq_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject MVertSeq_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender MVertSeq", /* char *tp_name; */
- sizeof( BPy_MVertSeq ), /* 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; */
- NULL, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &MVertSeq_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) MVertSeq_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) MVertSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_MVertSeq_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_MVertSeq_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
-};
-
-/************************************************************************
- *
- * Edge attributes
- *
- ************************************************************************/
-
-static MEdge * MEdge_get_pointer( BPy_MEdge * self )
-{
- if( self->index >= self->mesh->totedge )
- return (MEdge *)EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "MEdge is no longer valid" );
- return &self->mesh->medge[self->index];
-}
-
-/*
- * get an edge's crease value
- */
-
-static PyObject *MEdge_getCrease( BPy_MEdge * self )
-{
- MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return NULL;
-
- return PyInt_FromLong( edge->crease );
-}
-
-/*
- * set an edge's crease value
- */
-
-static int MEdge_setCrease( BPy_MEdge * self, PyObject * value )
-{
- MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return -1;
-
- return EXPP_setIValueClamped( value, &edge->crease, 0, 255, 'b' );
-}
-
-/*
- * get an edge's flag
- */
-
-static PyObject *MEdge_getFlag( BPy_MEdge * self )
-{
- MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return NULL;
-
- return PyInt_FromLong( edge->flag );
-}
-
-/*
- * set an edge's flag
- */
-
-static int MEdge_setFlag( BPy_MEdge * self, PyObject * value )
-{
- short param;
- static short bitmask = SELECT
- | ME_EDGEDRAW
- | ME_SEAM
- | ME_FGON
- | ME_HIDE
- | ME_EDGERENDER
- | ME_LOOSEEDGE
- | ME_SEAM_LAST
- | ME_SHARP;
- MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return -1;
-
- if( !PyInt_Check ( value ) ) {
- char errstr[128];
- sprintf ( errstr , "expected int bitmask of 0x%04x", bitmask );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
- param = (short)PyInt_AS_LONG ( value );
-
- if ( ( param & bitmask ) != param )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid bit(s) set in mask" );
-
- edge->flag = param;
-
- return 0;
-}
-
-/*
- * get an edge's first vertex
- */
-
-static PyObject *MEdge_getV1( BPy_MEdge * self )
-{
- MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return NULL;
-
- return MVert_CreatePyObject( self->mesh, edge->v1 );
-}
-
-/*
- * set an edge's first vertex
- */
-
-static int MEdge_setV1( BPy_MEdge * self, BPy_MVert * value )
-{
- MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return -1;
- if( !BPy_MVert_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected an MVert" );
-
- edge->v1 = value->index;
- return 0;
-}
-
-/*
- * get an edge's second vertex
- */
-
-static PyObject *MEdge_getV2( BPy_MEdge * self )
-{
- MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return NULL; /* error is set */
- /* if v2 is out of range, the python mvert will complain, no need to check here */
- return MVert_CreatePyObject( self->mesh, edge->v2 );
-}
-
-/*
- * set an edge's second vertex
- */
-
-static int MEdge_setV2( BPy_MEdge * self, BPy_MVert * value )
-{
- MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return -1; /* error is set */
- if( !BPy_MVert_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected an MVert" );
-
- if ( edge->v1 == value->index )
- return EXPP_ReturnIntError( PyExc_ValueError, "an edge cant use the same vertex for each end" );
-
- edge->v2 = value->index;
- return 0;
-}
-
-/*
- * get an edge's index
- */
-
-static PyObject *MEdge_getIndex( BPy_MEdge * self )
-{
- if( !MEdge_get_pointer( self ) )
- return NULL; /* error is set */
-
- return PyInt_FromLong( self->index );
-}
-
-/*
- * get an edge's flag
- */
-
-static PyObject *MEdge_getMFlagBits( BPy_MEdge * self, void * type )
-{
- MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return NULL; /* error is set */
-
- return EXPP_getBitfield( &edge->flag, (int)((long)type & 0xff), 'b' );
-}
-
-/*
- * get an edge's length
- */
-
-static PyObject *MEdge_getLength( BPy_MEdge * self )
-{
- MEdge *edge = MEdge_get_pointer( self );
- double dot = 0.0f;
- float tmpf;
- int i;
- float *v1, *v2;
-
- if (!edge)
- return NULL; /* error is set */
-
- if MEDGE_VERT_BADRANGE_CHECK(self->mesh, edge)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError, "This edge uses removed vert(s)" );
-
- /* get the 2 edges vert locations */
- v1= (&((Mesh *)self->mesh)->mvert[edge->v1])->co;
- v2= (&((Mesh *)self->mesh)->mvert[edge->v2])->co;
-
- if( !edge )
- return NULL;
-
- for( i = 0; i < 3; i++ ) {
- tmpf = v1[i] - v2[i];
- dot += tmpf*tmpf;
- }
- return PyFloat_FromDouble( sqrt( dot ) );
-}
-
-/*
- * get an key for using in a dictionary or set key
- */
-
-static PyObject *MEdge_getKey( BPy_MEdge * self )
-{
- PyObject *attr;
- MEdge *edge = MEdge_get_pointer( self );
- if (!edge)
- return NULL; /* error is set */
-
- attr = PyTuple_New( 2 );
- if (edge->v1 > edge->v2) {
- PyTuple_SET_ITEM( attr, 0, PyInt_FromLong(edge->v2) );
- PyTuple_SET_ITEM( attr, 1, PyInt_FromLong(edge->v1) );
- } else {
- PyTuple_SET_ITEM( attr, 0, PyInt_FromLong(edge->v1) );
- PyTuple_SET_ITEM( attr, 1, PyInt_FromLong(edge->v2) );
- }
- return attr;
-}
-
-/*
- * set an edge's select state
- */
-
-static int MEdge_setSel( BPy_MEdge * self,PyObject * value,
- void * type_unused )
-{
- MEdge *edge = MEdge_get_pointer( self );
- int param = PyObject_IsTrue( value );
- Mesh *me = self->mesh;
-
- if( !edge )
- return -1;
-
- if MEDGE_VERT_BADRANGE_CHECK(me, edge)
- return EXPP_ReturnIntError( PyExc_RuntimeError, "This edge uses removed vert(s)" );
-
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if( param ) {
- edge->flag |= SELECT;
- me->mvert[edge->v1].flag |= SELECT;
- me->mvert[edge->v2].flag |= SELECT;
- }
- else {
- edge->flag &= ~SELECT;
- me->mvert[edge->v1].flag &= ~SELECT;
- me->mvert[edge->v2].flag &= ~SELECT;
- }
-
- if( self->mesh->mselect ) {
- MEM_freeN( self->mesh->mselect );
- self->mesh->mselect = NULL;
- }
-
- return 0;
-}
-
-/************************************************************************
- *
- * Python MEdge_Type attributes get/set structure
- *
- ************************************************************************/
-
-static PyGetSetDef BPy_MEdge_getseters[] = {
- {"crease",
- (getter)MEdge_getCrease, (setter)MEdge_setCrease,
- "edge's crease value",
- NULL},
- {"flag",
- (getter)MEdge_getFlag, (setter)MEdge_setFlag,
- "edge's flags",
- NULL},
- {"v1",
- (getter)MEdge_getV1, (setter)MEdge_setV1,
- "edge's first vertex",
- NULL},
- {"v2",
- (getter)MEdge_getV2, (setter)MEdge_setV2,
- "edge's second vertex",
- NULL},
- {"index",
- (getter)MEdge_getIndex, (setter)NULL,
- "edge's index",
- NULL},
- {"sel",
- (getter)MEdge_getMFlagBits, (setter)MEdge_setSel,
- "edge selected in edit mode",
- (void *)SELECT},
- {"length",
- (getter)MEdge_getLength, (setter)NULL,
- "edge's length, read only",
- NULL},
- {"key",
- (getter)MEdge_getKey, (setter)NULL,
- "edge's key for using with sets or dictionaries, read only",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/************************************************************************
- *
- * Python MEdge_Type iterator (iterates over vertices)
- *
- ************************************************************************/
-
-/*
- * Initialize the interator index
- */
-
-static PyObject *MEdge_getIter( BPy_MEdge * self )
-{
- if (self->iter==-1) { /* not alredy used to iterator on, just use self */
- self->iter = 0;
- return EXPP_incr_ret ( (PyObject *) self );
- } else { /* alredy being iterated on, return a copy */
- BPy_MEdge *seq = (BPy_MEdge *)MEdge_CreatePyObject(self->mesh, self->index);
- seq->iter = 0;
- return (PyObject *)seq;
- }
-}
-
-/*
- * Return next MVert. Throw an exception after the second vertex.
- */
-
-static PyObject *MEdge_nextIter( BPy_MEdge * self )
-{
- if( self->iter == 2 ) {
- self->iter = -1;
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- self->iter++;
- if( self->iter == 1 )
- return MEdge_getV1( self );
- else
- return MEdge_getV2( self );
-}
-
-/************************************************************************
- *
- * Python MEdge_Type standard operations
- *
- ************************************************************************/
-
-static int MEdge_compare( BPy_MEdge * a, BPy_MEdge * b )
-{
- return( a->mesh == b->mesh && a->index == b->index ) ? 0 : -1;
-}
-
-static PyObject *MEdge_repr( BPy_MEdge * self )
-{
- struct MEdge *edge = MEdge_get_pointer( self );
-
- if( !edge )
- return NULL;
-
- return PyString_FromFormat( "[MEdge (%d %d) %d %d]",
- (int)edge->v1, (int)edge->v2, (int)edge->crease,
- (int)self->index );
-}
-
-static long MEdge_hash( BPy_MEdge *self )
-{
- return (long)self->index;
-}
-static PyObject *MEdge_getProp( BPy_MEdge *self, PyObject *args)
-{
- Mesh *me = (Mesh *)self->mesh;
- return Mesh_getProperty_internal(&(me->edata), self->index, args);
-}
-
-static PyObject *MEdge_setProp( BPy_MEdge *self, PyObject *args)
-{
- Mesh *me = (Mesh *)self->mesh;
- return Mesh_setProperty_internal(&(me->edata), self->index, args);
-}
-
-static struct PyMethodDef BPy_MEdge_methods[] = {
- {"getProperty", (PyCFunction)MEdge_getProp, METH_O,
- "get property indicated by name"},
- {"setProperty", (PyCFunction)MEdge_setProp, METH_VARARGS,
- "set property indicated by name"},
- {NULL, NULL, 0, NULL}
-};
-/************************************************************************
- *
- * Python MEdge_Type structure definition
- *
- ************************************************************************/
-
-PyTypeObject MEdge_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender MEdge", /* char *tp_name; */
- sizeof( BPy_MEdge ), /* 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 ) MEdge_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) MEdge_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 ) MEdge_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 */
- ( getiterfunc) MEdge_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) MEdge_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_MEdge_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_MEdge_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 *MEdge_CreatePyObject( Mesh * mesh, int i )
-{
- BPy_MEdge *obj = PyObject_NEW( BPy_MEdge, &MEdge_Type );
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyObject_New() failed" );
-
- obj->mesh = mesh;
- obj->index = i;
- obj->iter = -1;
- return (PyObject *)obj;
-}
-
-/************************************************************************
- *
- * Edge sequence
- *
- ************************************************************************/
-
-static int MEdgeSeq_len( BPy_MEdgeSeq * self )
-{
- return self->mesh->totedge;
-}
-
-static PyObject *MEdgeSeq_item( BPy_MEdgeSeq * self, int i )
-{
- if( i < 0 || i >= self->mesh->totedge )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-
- return MEdge_CreatePyObject( self->mesh, i );
-}
-
-
-static PySequenceMethods MEdgeSeq_as_sequence = {
- ( inquiry ) MEdgeSeq_len, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) MEdgeSeq_item, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- 0,0,0,
-};
-
-/************************************************************************
- *
- * Python MEdgeSeq_Type iterator (iterates over edges)
- *
- ************************************************************************/
-
-/*
- * Initialize the interator index
- */
-
-static PyObject *MEdgeSeq_getIter( BPy_MEdgeSeq * self )
-{
- if (self->iter==-1) { /* iteration for this pyobject is not yet used, just return self */
- self->iter = 0;
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- BPy_MEdgeSeq *seq = (BPy_MEdgeSeq *)MEdgeSeq_CreatePyObject(self->mesh);
- seq->iter = 0;
- return (PyObject *)seq;
- }
-}
-
-/*
- * Return next MEdge.
- */
-
-static PyObject *MEdgeSeq_nextIter( BPy_MEdgeSeq * self )
-{
- if( self->iter == self->mesh->totedge ) {
- self->iter= -1;
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- return MEdge_CreatePyObject( self->mesh, self->iter++ );
-}
-
-/************************************************************************
- *
- * Python MEdgeSeq_Type methods
- *
- ************************************************************************/
-
-/*
- * Create edges from tuples of vertices. Duplicate new edges, or
- * edges which already exist,
- */
-
-static PyObject *MEdgeSeq_extend( BPy_MEdgeSeq * self, PyObject *args )
-{
- int len, nverts;
- int i, j, ok;
- int new_edge_count, good_edges;
- SrchEdges *oldpair, *newpair, *tmppair, *tmppair2;
- PyObject *tmp;
- BPy_MVert *e[4];
- MEdge *tmpedge;
- Mesh *mesh = self->mesh;
-
- /* make sure we get a tuple of sequences of something */
- switch( PySequence_Size( args ) ) {
- case 1:
- /* if a sequence... */
- tmp = PyTuple_GET_ITEM( args, 0 );
- if( PySequence_Check( tmp ) ) {
- PyObject *tmp2;
-
- /* ignore empty sequences */
- if( !PySequence_Size( tmp ) ) {
- Py_RETURN_NONE;
- }
-
- /* if another sequence, use it */
- tmp2 = PySequence_ITEM( tmp, 0 );
- if( PySequence_Check( tmp2 ) )
- args = tmp;
- Py_INCREF( args );
- Py_DECREF( tmp2 );
- } else
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of sequence pairs" );
- break;
- case 2:
- case 3:
- case 4: /* two to four args may be individual verts */
- tmp = PyTuple_GET_ITEM( args, 0 );
- /*
- * if first item isn't a sequence, then assume it's a bunch of MVerts
- * and wrap inside a tuple
- */
- if( !PySequence_Check( tmp ) ) {
- args = Py_BuildValue( "(O)", args );
- if( !args )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Py_BuildValue() failed" );
- /*
- * otherwise, assume it already a bunch of sequences so use as-is
- */
- } else {
- Py_INCREF( args ); /* so we can safely DECREF later */
- }
- break;
- default: /* anything else is definitely wrong */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of sequence pairs" );
- }
-
- /* make sure there is something to add */
- len = PySequence_Size( args );
- if( len == 0 ) {
- Py_DECREF ( args );
- Py_RETURN_NONE;
- }
-
- /* verify the param list and get a total count of number of edges */
- new_edge_count = 0;
- for( i = 0; i < len; ++i ) {
- tmp = PySequence_GetItem( args, i );
-
- /* not a tuple of MVerts... error */
- if( !PySequence_Check( tmp ) ) {
- Py_DECREF( tmp );
- Py_DECREF( args );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected sequence of MVert sequences" );
- }
-
- /* not the right number of MVerts... error */
- nverts = PySequence_Size( tmp );
- if( nverts < 2 || nverts > 4 ) {
- Py_DECREF( tmp );
- Py_DECREF( args );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected 2 to 4 MVerts per sequence" );
- }
-
- if( EXPP_check_sequence_consistency( tmp, &MVert_Type ) == 1 ) {
-
- /* get MVerts, check they're from this mesh */
- ok = 1;
- for( j = 0; ok && j < nverts; ++j ) {
- e[0] = (BPy_MVert *)PySequence_GetItem( tmp, j );
- if( (void *)e[0]->data != (void *)self->mesh )
- ok = 0;
- Py_DECREF( e[0] );
- }
- Py_DECREF( tmp );
-
- /* not MVerts from another mesh ... error */
- if( !ok ) {
- Py_DECREF( args );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "vertices are from a different mesh" );
- }
- } else {
- ok = 0;
- for( j = 0; ok == 0 && j < nverts; ++j ) {
- PyObject *item = PySequence_ITEM( tmp, j );
- if( !PyInt_Check( item ) )
- ok = 1;
- else {
- int index = PyInt_AsLong ( item );
- if( index < 0 || index >= self->mesh->totvert )
- ok = 2;
- }
- Py_DECREF( item );
- }
- Py_DECREF( tmp );
-
- /* not ints or outside of vertex list ... error */
- if( ok ) {
- Py_DECREF( args );
- if( ok == 1 )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an integer index" );
- else
- return EXPP_ReturnPyObjError( PyExc_KeyError,
- "index out of range" );
- }
- }
-
- if( nverts == 2 )
- ++new_edge_count; /* if only two vert, then add only edge */
- else
- new_edge_count += nverts; /* otherwise, one edge per vert */
- }
-
- /* OK, commit to allocating the search structures */
- newpair = (SrchEdges *)MEM_callocN( sizeof(SrchEdges)*new_edge_count,
- "MEdgePairs" );
-
- /* scan the input list and build the new edge pair list */
- len = PySequence_Size( args );
- tmppair = newpair;
- new_edge_count = 0;
- for( i = 0; i < len; ++i ) {
- int edge_count;
- int eedges[4];
- tmp = PySequence_GetItem( args, i );
- nverts = PySequence_Size( tmp );
-
- /* get new references for the vertices */
- for(j = 0; j < nverts; ++j ) {
- PyObject *item = PySequence_ITEM( tmp, j );
- if( BPy_MVert_Check( item ) ) {
- eedges[j] = ((BPy_MVert *)item)->index;
- } else {
- eedges[j] = PyInt_AsLong ( item );
- }
- Py_DECREF( item );
- }
- Py_DECREF( tmp );
-
- if( nverts == 2 )
- edge_count = 1; /* again, two verts give just one edge */
- else
- edge_count = nverts;
-
- /* now add the edges to the search list */
- for( j = 0; j < edge_count; ++j ) {
- int k = j+1;
- if( k == nverts ) /* final edge */
- k = 0;
-
- /* sort verts into search list, skip if two are the same */
- if( eedges[j] != eedges[k] ) {
- if( eedges[j] < eedges[k] ) {
- tmppair->v[0] = eedges[j];
- tmppair->v[1] = eedges[k];
- tmppair->swap = 0;
- } else {
- tmppair->v[0] = eedges[k];
- tmppair->v[1] = eedges[j];
- tmppair->swap = 1;
- }
- tmppair->index = new_edge_count;
- ++new_edge_count;
- tmppair++;
- }
- }
-
- }
-
- /* sort the new edge pairs */
- qsort( newpair, new_edge_count, sizeof(SrchEdges), medge_comp );
-
- /*
- * find duplicates in the new list and mark. if it's a duplicate,
- * then mark by setting second vert index to 0 (a real edge won't have
- * second vert index of 0 since verts are sorted)
- */
-
- good_edges = new_edge_count; /* all edges are good at this point */
-
- tmppair = newpair; /* "last good edge" */
- tmppair2 = &tmppair[1]; /* "current candidate edge" */
- for( i = 0; i < new_edge_count; ++i ) {
- if( tmppair->v[0] != tmppair2->v[0] ||
- tmppair->v[1] != tmppair2->v[1] )
- tmppair = tmppair2; /* last != current, so current == last */
- else {
- tmppair2->v[1] = 0; /* last == current, so mark as duplicate */
- --good_edges; /* one less good edge */
- }
- tmppair2++;
- }
-
- /* if mesh has edges, see if any of the new edges are already in it */
- if( mesh->totedge ) {
- oldpair = (SrchEdges *)MEM_callocN( sizeof(SrchEdges)*mesh->totedge,
- "MEdgePairs" );
-
- /*
- * build a search list of new edges (don't need to update "swap"
- * field, since we're not creating edges here)
- */
- tmppair = oldpair;
- tmpedge = mesh->medge;
- for( i = 0; i < mesh->totedge; ++i ) {
- if( tmpedge->v1 < tmpedge->v2 ) {
- tmppair->v[0] = tmpedge->v1;
- tmppair->v[1] = tmpedge->v2;
- } else {
- tmppair->v[0] = tmpedge->v2;
- tmppair->v[1] = tmpedge->v1;
- }
- ++tmpedge;
- ++tmppair;
- }
-
- /* sort the old edge pairs */
- qsort( oldpair, mesh->totedge, sizeof(SrchEdges), medge_comp );
-
- /* eliminate new edges already in the mesh */
- tmppair = newpair;
- for( i = new_edge_count; i-- ; ) {
- if( tmppair->v[1] ) {
- if( bsearch( tmppair, oldpair, mesh->totedge,
- sizeof(SrchEdges), medge_comp ) ) {
- tmppair->v[1] = 0; /* mark as duplicate */
- --good_edges;
- }
- }
- tmppair++;
- }
- MEM_freeN( oldpair );
- }
-
- /* if any new edges are left, add to list */
- if( good_edges ) {
- CustomData edata;
- int totedge = mesh->totedge+good_edges;
-
- /* create custom edge data arrays and copy existing edges into it */
- CustomData_copy( &mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge );
- CustomData_copy_data( &mesh->edata, &edata, 0, 0, mesh->totedge );
-
- if ( !CustomData_has_layer( &edata, CD_MEDGE ) )
- CustomData_add_layer( &edata, CD_MEDGE, CD_CALLOC, NULL, totedge );
-
- /* replace old with new data */
- CustomData_free( &mesh->edata, mesh->totedge );
- mesh->edata = edata;
- mesh_update_customdata_pointers( mesh );
-
- /* resort edges into original order */
- qsort( newpair, new_edge_count, sizeof(SrchEdges), medge_index_comp );
-
- /* point to the first edge we're going to add */
- tmpedge = &mesh->medge[mesh->totedge];
- tmppair = newpair;
-
- /* as we find a good edge, add it */
- while( good_edges ) {
- if( tmppair->v[1] ) { /* not marked as duplicate ! */
- if( !tmppair->swap ) {
- tmpedge->v1 = tmppair->v[0];
- tmpedge->v2 = tmppair->v[1];
- } else {
- tmpedge->v1 = tmppair->v[1];
- tmpedge->v2 = tmppair->v[0];
- }
- tmpedge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
- mesh->totedge++;
- --good_edges;
- ++tmpedge;
- }
- tmppair++;
- }
- }
-
- /* clean up and leave */
- mesh_update( mesh );
- MEM_freeN( newpair );
- Py_DECREF ( args );
- Py_RETURN_NONE;
-}
-
-static PyObject *MEdgeSeq_delete( BPy_MEdgeSeq * self, PyObject *args )
-{
- Mesh *mesh = self->mesh;
- MEdge *srcedge;
- MFace *srcface;
- unsigned int *vert_table, *del_table, *edge_table;
- int i, len;
- int face_count, edge_count, vert_count;
-
- /*
- * if input tuple contains a single sequence, use it as input instead;
- * otherwise use the sequence as-is and check later that it contains
- * one or more integers or MVerts
- */
- if( PySequence_Size( args ) == 1 ) {
- PyObject *tmp = PyTuple_GET_ITEM( args, 0 );
- if( PySequence_Check( tmp ) )
- args = tmp;
- }
-
- /* if sequence is empty, do nothing */
- len = PySequence_Size( args );
- if( len == 0 ) {
- Py_RETURN_NONE;
- }
-
- edge_table = (unsigned int *)MEM_callocN( len*sizeof( unsigned int ),
- "edge_table" );
-
- /* get the indices of edges to be removed */
- for( i = len; i--; ) {
- PyObject *tmp = PySequence_GetItem( args, i );
- if( BPy_MEdge_Check( tmp ) )
- edge_table[i] = ((BPy_MEdge *)tmp)->index;
- else if( PyInt_Check( tmp ) )
- edge_table[i] = PyInt_AsLong ( tmp );
- else {
- MEM_freeN( edge_table );
- Py_DECREF( tmp );
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of ints or MEdges" );
- }
- Py_DECREF( tmp );
-
- /* if index out-of-range, throw exception */
- if( edge_table[i] >= (unsigned int)mesh->totedge ) {
- MEM_freeN( edge_table );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "array index out of range" );
- }
- }
-
- /*
- * build two tables: first table marks vertices which belong to an edge
- * which is being deleted
- */
- del_table = (unsigned int *)MEM_callocN(
- mesh->totvert*sizeof( unsigned int ), "vert_table" );
-
- /*
- * Borrow a trick from editmesh code: for each edge to be deleted, mark
- * its vertices as well. Then go through face list and look for two
- * consecutive marked vertices.
- */
-
- /* mark each edge that's to be deleted */
- srcedge = mesh->medge;
- for( i = len; i--; ) {
- unsigned int idx = edge_table[i];
- del_table[srcedge[idx].v1] = UINT_MAX;
- del_table[srcedge[idx].v2] = UINT_MAX;
- srcedge[idx].v1 = UINT_MAX;
- }
-
- /*
- * second table is used for vertices which become orphaned (belong to no
- * edges) and need to be deleted; it's also the normal lookup table for
- * old->new vertex indices
- */
-
- vert_table = (unsigned int *)MEM_mallocN(
- mesh->totvert*sizeof( unsigned int ), "vert_table" );
-
- /* assume all edges will be deleted (fills with UINT_MAX) */
- memset( vert_table, UCHAR_MAX, mesh->totvert*sizeof( unsigned int ) );
-
- /* unmark vertices of each "good" edge; count each "bad" edge */
- edge_count = 0;
- for( i = mesh->totedge; i--; ++srcedge )
- if( srcedge->v1 != UINT_MAX )
- vert_table[srcedge->v1] = vert_table[srcedge->v2] = 0;
- else
- ++edge_count;
-
- /*
- * find faces which no longer have all edges
- */
-
- face_count = 0;
- srcface = mesh->mface;
- for( i = 0; i < mesh->totface; ++i, ++srcface ) {
- int len = srcface->v4 ? 4 : 3;
- unsigned int id[4];
- int del;
-
- id[0] = del_table[srcface->v1];
- id[1] = del_table[srcface->v2];
- id[2] = del_table[srcface->v3];
- id[3] = del_table[srcface->v4];
-
- del = ( id[0] == UINT_MAX && id[1] == UINT_MAX ) ||
- ( id[1] == UINT_MAX && id[2] == UINT_MAX );
- if( !del ) {
- if( len == 3 )
- del = ( id[2] == UINT_MAX && id[0] == UINT_MAX );
- else
- del = ( id[2] == UINT_MAX && id[3] == UINT_MAX ) ||
- ( id[3] == UINT_MAX && id[0] == UINT_MAX );
- }
- if( del ) {
- srcface->v1 = UINT_MAX;
- ++face_count;
- }
- }
-
- /* fix the vertex lookup table, if any verts to delete, do so now */
- vert_count = make_vertex_table( vert_table, mesh->totvert );
- if( vert_count )
- delete_verts( mesh, vert_table, vert_count );
-
- /* delete faces which have a deleted edge */
- delete_faces( mesh, vert_table, face_count );
-
- /* now delete the edges themselves */
- delete_edges( mesh, vert_table, edge_count );
-
- /* clean up and return */
- MEM_freeN( del_table );
- MEM_freeN( vert_table );
- MEM_freeN( edge_table );
- mesh_update ( mesh );
- Py_RETURN_NONE;
-}
-
-static PyObject *MEdgeSeq_collapse( BPy_MEdgeSeq * self, PyObject *args )
-{
- MEdge *srcedge;
- unsigned int *edge_table;
- float (*vert_list)[3];
- int i, len;
- Base *base, *basact;
- Mesh *mesh = self->mesh;
- Object *object = NULL;
- PyObject *tmp;
-
- /*
- * when using removedoublesflag(), we need to switch to editmode, so
- * nobody else can be using it
- */
-
- if( G.obedit )
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "can't use collapse() while in edit mode" );
-
- /* make sure we get a tuple of sequences of something */
- switch( PySequence_Size( args ) ) {
- case 1:
- /* if a sequence... */
- tmp = PyTuple_GET_ITEM( args, 0 );
- if( PySequence_Check( tmp ) ) {
- PyObject *tmp2;
-
- /* ignore empty sequences */
- if( !PySequence_Size( tmp ) ) {
- Py_RETURN_NONE;
- }
-
- /* if another sequence, use it */
- tmp2 = PySequence_ITEM( tmp, 0 );
- if( PySequence_Check( tmp2 ) )
- args = tmp;
- Py_INCREF( args );
- Py_DECREF( tmp2 );
- } else
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of sequence pairs" );
- break;
- case 2: /* two args may be individual edges/verts */
- tmp = PyTuple_GET_ITEM( args, 0 );
- /*
- * if first item isn't a sequence, then assume it's a bunch of MVerts
- * and wrap inside a tuple
- */
- if( !PySequence_Check( tmp ) ) {
- args = Py_BuildValue( "(O)", args );
- if( !args )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Py_BuildValue() failed" );
- /*
- * otherwise, assume it already a bunch of sequences so use as-is
- */
- } else {
- Py_INCREF( args ); /* so we can safely DECREF later */
- }
- break;
- default: /* anything else is definitely wrong */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of sequence pairs" );
- }
-
- /* if sequence is empty, do nothing */
- len = PySequence_Size( args );
- if( len == 0 ) {
- Py_RETURN_NONE;
- }
-
- /* allocate table of edge indices and new vertex values */
-
- edge_table = (unsigned int *)MEM_callocN( len*sizeof( unsigned int ),
- "edge_table" );
- vert_list = (float (*)[3])MEM_callocN( 3*len*sizeof( float ),
- "vert_list" );
-
- /* get the indices of edges to be collapsed and new vert locations */
- for( i = len; i--; ) {
- PyObject *tmp1;
- PyObject *tmp2;
-
- tmp = PySequence_GetItem( args, i );
-
- /* if item isn't sequence of size 2, error */
- if( !PySequence_Check( tmp ) || PySequence_Size( tmp ) != 2 ) {
- MEM_freeN( edge_table );
- MEM_freeN( vert_list );
- Py_DECREF( tmp );
- Py_DECREF( args );
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of (MEdges, vector)" );
- }
-
- /* if items aren't a MEdge/int and vector, error */
- tmp1 = PySequence_GetItem( tmp, 0 );
- tmp2 = PySequence_GetItem( tmp, 1 );
- Py_DECREF( tmp );
- if( !(BPy_MEdge_Check( tmp1 ) || PyInt_Check( tmp1 )) ||
- !VectorObject_Check ( tmp2 ) ) {
- MEM_freeN( edge_table );
- MEM_freeN( vert_list );
- Py_DECREF( tmp1 );
- Py_DECREF( tmp2 );
- Py_DECREF( args );
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of (MEdges, vector)" );
- }
-
- /* store edge index, new vertex location */
- if( PyInt_Check( tmp1 ) )
- edge_table[i] = PyInt_AsLong ( tmp1 );
- else
- edge_table[i] = ((BPy_MEdge *)tmp1)->index;
- memcpy( vert_list[i], ((VectorObject *)tmp2)->vec,
- 3*sizeof( float ) );
- Py_DECREF( tmp1 );
- Py_DECREF( tmp2 );
-
- /* if index out-of-range, throw exception */
- if( edge_table[i] >= (unsigned int)mesh->totedge ) {
- MEM_freeN( edge_table );
- MEM_freeN( vert_list );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "edge index out of range" );
- }
- }
-
- /*
- * simple algorithm:
- * (1) deselect all verts
- * (2) for each edge
- * (2a) replace both verts with the new vert
- * (2b) select both verts
- * (3) call removedoublesflag()
- */
-
- /* (1) deselect all verts */
- for( i = mesh->totvert; i--; )
- mesh->mvert[i].flag &= ~SELECT;
-
- /* (2) replace edge's verts and select them */
- for( i = len; i--; ) {
- srcedge = &mesh->medge[edge_table[i]];
- memcpy( &mesh->mvert[srcedge->v1].co, vert_list[i], 3*sizeof( float ) );
- memcpy( &mesh->mvert[srcedge->v2].co, vert_list[i], 3*sizeof( float ) );
- mesh->mvert[srcedge->v1].flag |= SELECT;
- mesh->mvert[srcedge->v2].flag |= SELECT;
- }
-
- /* (3) call removedoublesflag() */
- for( base = FIRSTBASE; base; base = base->next ) {
- if( base->object->type == OB_MESH &&
- base->object->data == self->mesh ) {
- object = base->object;
- break;
- }
- }
-
- basact = BASACT;
- BASACT = base;
-
- removedoublesflag( 1, 0, 0.0 );
- /* make mesh's object active, enter mesh edit mode */
- G.obedit = object;
-
- /* exit edit mode, free edit mesh */
- load_editMesh();
- free_editMesh(G.editMesh);
-
- BASACT = basact;
-
- /* clean up and exit */
- Py_DECREF( args );
- MEM_freeN( vert_list );
- MEM_freeN( edge_table );
- mesh_update ( mesh );
- Py_RETURN_NONE;
-}
-
-
-static PyObject *MEdgeSeq_selected( BPy_MEdgeSeq * self )
-{
- int i, count;
- Mesh *mesh = self->mesh;
- MEdge *tmpedge;
- PyObject *list;
-
- /* first count selected edges (quicker than appending to PyList?) */
- count = 0;
- tmpedge = mesh->medge;
- for( i = 0; i < mesh->totedge; ++i, ++tmpedge )
- if( (mesh->mvert[tmpedge->v1].flag & SELECT) &&
- (mesh->mvert[tmpedge->v2].flag & SELECT) )
- ++count;
-
- list = PyList_New( count );
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyList_New() failed" );
-
- /* next, insert selected edges into list */
- count = 0;
- tmpedge = mesh->medge;
- for( i = 0; i < mesh->totedge; ++i, ++tmpedge ) {
- if( (mesh->mvert[tmpedge->v1].flag & SELECT) &&
- (mesh->mvert[tmpedge->v2].flag & SELECT) ) {
- PyObject *tmp = PyInt_FromLong( i );
- if( !tmp ) {
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyInt_FromLong() failed" );
- }
- PyList_SET_ITEM( list, count, tmp );
- ++count;
- }
- }
- return list;
-}
-
-static PyObject *MEdgeSeq_add_layertype(BPy_MEdgeSeq *self, PyObject *args)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_addPropLayer_internal(me, &(me->edata), me->totedge, args);
-}
-static PyObject *MEdgeSeq_del_layertype(BPy_MEdgeSeq *self, PyObject *value)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_removePropLayer_internal(me, &(me->edata), me->totedge, value);
-}
-static PyObject *MEdgeSeq_rename_layertype(BPy_MEdgeSeq *self, PyObject *args)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_renamePropLayer_internal(me,&(me->edata),args);
-}
-static PyObject *MEdgeSeq_PropertyList(BPy_MEdgeSeq *self)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_propList_internal(&(me->edata));
-}
-
-
-static struct PyMethodDef BPy_MEdgeSeq_methods[] = {
- {"extend", (PyCFunction)MEdgeSeq_extend, METH_VARARGS,
- "add edges to mesh"},
- {"delete", (PyCFunction)MEdgeSeq_delete, METH_VARARGS,
- "delete edges from mesh"},
- {"selected", (PyCFunction)MEdgeSeq_selected, METH_NOARGS,
- "returns a list containing indices of selected edges"},
- {"collapse", (PyCFunction)MEdgeSeq_collapse, METH_VARARGS,
- "collapse one or more edges to a vertex"},
- {"addPropertyLayer",(PyCFunction)MEdgeSeq_add_layertype, METH_VARARGS,
- "add a new property layer"},
- {"removePropertyLayer",(PyCFunction)MEdgeSeq_del_layertype, METH_O,
- "removes a property layer"},
- {"renamePropertyLayer",(PyCFunction)MEdgeSeq_rename_layertype, METH_VARARGS,
- "renames an existing property layer"},
-
- {NULL, NULL, 0, NULL}
-};
-static PyGetSetDef BPy_MEdgeSeq_getseters[] = {
- {"properties",
- (getter)MEdgeSeq_PropertyList, (setter)NULL,
- "edge property layers, read only",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-/************************************************************************
- *
- * Python MEdgeSeq_Type standard operators
- *
- ************************************************************************/
-
-/*****************************************************************************/
-/* Python MEdgeSeq_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject MEdgeSeq_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender MEdgeSeq", /* char *tp_name; */
- sizeof( BPy_MEdgeSeq ), /* 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; */
- NULL, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &MEdgeSeq_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) MEdgeSeq_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) MEdgeSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_MEdgeSeq_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_MEdgeSeq_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
-};
-
-/************************************************************************
- *
- * Face attributes
- *
- ************************************************************************/
-
-static MFace * MFace_get_pointer( BPy_MFace * self )
-{
- if( self->index >= self->mesh->totface )
- return (MFace *)EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "MFace is no longer valid" );
- return &self->mesh->mface[self->index];
-}
-
-/*
- * get a face's vertices
- */
-
-static PyObject *MFace_getVerts( BPy_MFace * self )
-{
- PyObject *attr;
- MFace *face = MFace_get_pointer( self );
-
- if( !face )
- return NULL;
-
- attr = PyTuple_New( face->v4 ? 4 : 3 );
-
- if( !attr )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyTuple_New() failed" );
-
- PyTuple_SetItem( attr, 0, MVert_CreatePyObject( self->mesh, face->v1 ) );
- PyTuple_SetItem( attr, 1, MVert_CreatePyObject( self->mesh, face->v2 ) );
- PyTuple_SetItem( attr, 2, MVert_CreatePyObject( self->mesh, face->v3 ) );
- if( face->v4 )
- PyTuple_SetItem( attr, 3, MVert_CreatePyObject( self->mesh,
- face->v4 ) );
-
- return attr;
-}
-
-/*
- * set a face's vertices
- */
-
-static int MFace_setVerts( BPy_MFace * self, PyObject * args )
-{
- BPy_MVert *v1, *v2, *v3, *v4 = NULL;
- MFace *face = MFace_get_pointer( self );
-
- if( !face )
- return -1;
-
- if( !PyArg_ParseTuple ( args, "O!O!O!|O!", &MVert_Type, &v1,
- &MVert_Type, &v2, &MVert_Type, &v3, &MVert_Type, &v4 ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected tuple of 3 or 4 MVerts" );
-
- if( v1->index == v2->index ||
- v1->index == v3->index ||
- v2->index == v3->index )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "cannot assign 2 or move verts that are the same" );
-
- if(v4 && ( v1->index == v4->index ||
- v2->index == v4->index ||
- v3->index == v4->index ))
- return EXPP_ReturnIntError( PyExc_ValueError,
- "cannot assign 2 or move verts that are the same" );
-
- if( v1->index >= self->mesh->totvert ||
- v2->index >= self->mesh->totvert ||
- v3->index >= self->mesh->totvert ||
- (v4 &&( v4->index >= self->mesh->totvert)))
- return EXPP_ReturnIntError( PyExc_ValueError,
- "cannot assign verts that have been removed" );
-
- face->v1 = v1->index;
- face->v2 = v2->index;
- face->v3 = v3->index;
- if( v4 )
- face->v4 = v4->index;
- return 0;
-}
-
-/*
- * get face's material index
- */
-
-static PyObject *MFace_getMat( BPy_MFace * self )
-{
- MFace *face = MFace_get_pointer( self );
-
- if( !face )
- return NULL;
-
- return PyInt_FromLong( face->mat_nr );
-}
-
-/*
- * set face's material index
- */
-
-static int MFace_setMat( BPy_MFace * self, PyObject * value )
-{
- MFace *face = MFace_get_pointer( self );
-
- if( !face )
- return -1; /* error is set */
-
- return EXPP_setIValueRange( value, &face->mat_nr, 0, 15, 'b' );
-}
-
-/*
- * get a face's index
- */
-
-static PyObject *MFace_getIndex( BPy_MFace * self )
-{
- MFace *face = MFace_get_pointer( self );
-
- if( !face )
- return NULL; /* error is set */
-
- return PyInt_FromLong( self->index );
-}
-
-/*
- * get face's normal index
- */
-
-static PyObject *MFace_getNormal( BPy_MFace * self )
-{
- float *vert[4];
- float no[3];
- MFace *face = MFace_get_pointer( self );
-
- Mesh *me = self->mesh;
-
- if( !face )
- return NULL; /* error is set */
-
- if MFACE_VERT_BADRANGE_CHECK(me, face)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "one or more MFace vertices are no longer valid" );
-
- vert[0] = me->mvert[face->v1].co;
- vert[1] = me->mvert[face->v2].co;
- vert[2] = me->mvert[face->v3].co;
- if( face->v4 ) {
- vert[3] = me->mvert[face->v4].co;
- CalcNormFloat4( vert[0], vert[1], vert[2], vert[3], no );
- } else
- CalcNormFloat( vert[0], vert[1], vert[2], no );
-
- return newVectorObject( no, 3, Py_NEW );
-}
-
-/*
- * get face's center location
- */
-
-static PyObject *MFace_getCent( BPy_MFace * self )
-{
- float *vert[4];
- float cent[3]= {0,0,0};
- int i=3, j, k;
- Mesh *me = self->mesh;
- MFace *face = MFace_get_pointer( self );
-
- if( !face )
- return NULL; /* error is set */
-
-
- if MFACE_VERT_BADRANGE_CHECK(me, face)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "one or more MFace vertices are no longer valid" );
-
- vert[0] = me->mvert[face->v1].co;
- vert[1] = me->mvert[face->v2].co;
- vert[2] = me->mvert[face->v3].co;
- if( face->v4 ) {
- vert[3] = me->mvert[face->v4].co;
- i=4;
- }
-
- for (j=0;j<i;j++) {
- for (k=0;k<3;k++) {
- cent[k]+=vert[j][k];
- }
- }
-
- for (j=0;j<3;j++) {
- cent[j]=cent[j]/i;
- }
- return newVectorObject( cent, 3, Py_NEW );
-}
-
-/*
- * get face's area
- */
-static PyObject *MFace_getArea( BPy_MFace * self )
-{
- float *v1,*v2,*v3,*v4;
- MFace *face = MFace_get_pointer( self );
- Mesh *me = self->mesh;
-
- if( !face )
- return NULL; /* error is set */
-
- if MFACE_VERT_BADRANGE_CHECK(me, face)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "one or more MFace vertices are no longer valid" );
-
- v1 = me->mvert[face->v1].co;
- v2 = me->mvert[face->v2].co;
- v3 = me->mvert[face->v3].co;
-
- if( face->v4 ) {
- v4 = me->mvert[face->v4].co;
- return PyFloat_FromDouble( AreaQ3Dfl(v1, v2, v3, v4));
- } else
- return PyFloat_FromDouble( AreaT3Dfl(v1, v2, v3));
-}
-
-/*
- * get one of a face's mface flag bits
- */
-
-static PyObject *MFace_getMFlagBits( BPy_MFace * self, void * type )
-{
- MFace *face = MFace_get_pointer( self );
-
- if( !face )
- return NULL; /* error is set */
-
- return EXPP_getBitfield( &face->flag, (int)((long)type & 0xff), 'b' );
-}
-
-/*
- * set one of a face's mface flag bits
- */
-
-static int MFace_setMFlagBits( BPy_MFace * self, PyObject * value,
- void * type )
-{
- MFace *face = MFace_get_pointer( self );
-
- if( !face )
- return -1; /* error is set */
-
- return EXPP_setBitfield( value, &face->flag,
- (int)((long)type & 0xff), 'b' );
-}
-
-static int MFace_setSelect( BPy_MFace * self, PyObject * value,
- void * type_unused )
-{
- MFace *face = MFace_get_pointer( self );
- int param = PyObject_IsTrue( value );
- Mesh *me;
-
- if( !face )
- return -1; /* error is set */
-
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- me = self->mesh;
- if( param ) {
- face->flag |= ME_FACE_SEL;
- me->mvert[face->v1].flag |= SELECT;
- me->mvert[face->v2].flag |= SELECT;
- me->mvert[face->v3].flag |= SELECT;
- if( face->v4 )
- me->mvert[face->v4].flag |= SELECT;
- }
- else {
- face->flag &= ~ME_FACE_SEL;
- me->mvert[face->v1].flag &= ~SELECT;
- me->mvert[face->v2].flag &= ~SELECT;
- me->mvert[face->v3].flag &= ~SELECT;
- if( face->v4 )
- me->mvert[face->v4].flag &= ~SELECT;
- }
-
- if( self->mesh->mselect ) {
- MEM_freeN( self->mesh->mselect );
- self->mesh->mselect = NULL;
- }
-
- return 0;
-}
-
-/*
- * get face's texture image
- */
-
-static PyObject *MFace_getImage( BPy_MFace *self )
-{
- MTFace *face;
- if( !self->mesh->mtface )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "face has no texture values" );
-
- if( !MFace_get_pointer( self ) )
- return NULL;
-
- face = &self->mesh->mtface[self->index];
-
- if( face->tpage )
- return Image_CreatePyObject( face->tpage );
- else
- Py_RETURN_NONE;
-}
-
-/*
- * change or clear face's texture image
- */
-
-static int MFace_setImage( BPy_MFace *self, PyObject *value )
-{
- MTFace *face;
-
- if( !MFace_get_pointer( self ) )
- return -1;
-
- if( value && value != Py_None && !BPy_Image_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected image object or None" );
-
- if( !self->mesh->mtface )
-#if 0
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
-#else
- make_tfaces( self->mesh );
-#endif
-
- face = &self->mesh->mtface[self->index];
-
- if( value == NULL || value == Py_None )
- face->tpage = NULL; /* should memory be freed? */
- else {
- face->tpage = ( ( BPy_Image * ) value )->image;
- face->mode |= TF_TEX;
- }
-
- return 0;
-}
-
-#define MFACE_FLAG_BITMASK ( TF_SELECT | TF_SEL1 | \
- TF_SEL2 | TF_SEL3 | TF_SEL4 | TF_HIDE )
-
-/*
-* get face's texture flag
-*/
-
-static PyObject *MFace_getFlag( BPy_MFace *self )
-{
- int flag;
- if( !self->mesh->mtface )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "face has no texture values" );
-
- if( !MFace_get_pointer( self ) )
- return NULL;
-
- flag = self->mesh->mtface[self->index].flag & MFACE_FLAG_BITMASK;
-
- /* so old scripts still work */
- if (self->index == self->mesh->act_face)
- flag |= TF_ACTIVE;
-
- return PyInt_FromLong( (long)( flag ) );
-}
-
-/*
- * set face's texture flag
- */
-
-static int MFace_setFlag( BPy_MFace *self, PyObject *value )
-{
- int param;
-
- if( !self->mesh->mtface )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
-
- if( !MFace_get_pointer( self ) )
- return -1;
-
- if( !PyInt_Check ( value ) ) {
- char errstr[128];
- sprintf ( errstr , "expected int bitmask of 0x%04x", MFACE_FLAG_BITMASK );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
- param = PyInt_AS_LONG ( value );
-
- /* only one face can be active, so don't allow that here */
- if( param & TF_ACTIVE )
- param &= ~TF_ACTIVE;
-
- if( ( param & MFACE_FLAG_BITMASK ) != param )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid bit(s) set in mask" );
-
- /* merge active setting with other new params */
- param |= (self->mesh->mtface[self->index].flag);
- self->mesh->mtface[self->index].flag = (char)param;
-
- return 0;
-}
-
-/*
- * get face's texture mode
- */
-
-static PyObject *MFace_getMode( BPy_MFace *self )
-{
- if( !self->mesh->mtface )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "face has no texture values" );
-
- if( !MFace_get_pointer( self ) )
- return NULL;
-
- return PyInt_FromLong( self->mesh->mtface[self->index].mode );
-}
-
-/*
- * set face's texture mode
- */
-
-static int MFace_setMode( BPy_MFace *self, PyObject *value )
-{
- int param;
- static short bitmask = TF_DYNAMIC
- | TF_TEX
- | TF_SHAREDVERT
- | TF_LIGHT
- | TF_SHAREDCOL
- | TF_TILES
- | TF_BILLBOARD
- | TF_TWOSIDE
- | TF_INVISIBLE
- | TF_OBCOL
- | TF_BILLBOARD2
- | TF_SHADOW
- | TF_BMFONT;
-
- if( !self->mesh->mtface )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
-
- if( !MFace_get_pointer( self ) )
- return -1;
-
- if( !PyInt_Check ( value ) ) {
- char errstr[128];
- sprintf ( errstr , "expected int bitmask of 0x%04x", bitmask );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
- param = PyInt_AS_LONG ( value );
-
- if( param == 0xffff ) /* if param is ALL, set everything but HALO */
- param = bitmask ^ TF_BILLBOARD;
- else if( ( param & bitmask ) != param )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid bit(s) set in mask" );
-
- /* Blender UI doesn't allow these on at the same time */
-
- if( ( param & (TF_BILLBOARD | TF_BILLBOARD2) ) ==
- (TF_BILLBOARD | TF_BILLBOARD2) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "HALO and BILLBOARD cannot be enabled simultaneously" );
-
- self->mesh->mtface[self->index].mode = (short)param;
-
- return 0;
-}
-
-/*
- * get face's texture transparency setting
- */
-
-static PyObject *MFace_getTransp( BPy_MFace *self )
-{
- if( !self->mesh->mtface )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "face has no texture values" );
-
- if( !MFace_get_pointer( self ) )
- return NULL;
-
- return PyInt_FromLong( self->mesh->mtface[self->index].transp );
-}
-
-/*
- * set face's texture transparency setting
- */
-
-static int MFace_setTransp( BPy_MFace *self, PyObject *value )
-{
- if( !self->mesh->mtface )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
-
- if( !MFace_get_pointer( self ) )
- return -1;
-
- return EXPP_setIValueRange( value,
- &self->mesh->mtface[self->index].transp, TF_SOLID, TF_SUB, 'b' );
-}
-
-/*
- * get a face's texture UV coord values
- */
-
-static PyObject *MFace_getUV( BPy_MFace * self )
-{
- MTFace *face;
- PyObject *attr;
- int length, i;
-
- if( !self->mesh->mtface )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "face has no texture values" );
-
- if( !MFace_get_pointer( self ) )
- return NULL;
-
- face = &self->mesh->mtface[self->index];
- length = self->mesh->mface[self->index].v4 ? 4 : 3;
- attr = PyTuple_New( length );
-
- if( !attr )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyTuple_New() failed" );
-
- for( i=0; i<length; ++i ) {
- PyObject *vector = newVectorObject( face->uv[i], 2, Py_WRAP );
- if( !vector )
- return NULL;
- PyTuple_SetItem( attr, i, vector );
- }
-
- return attr;
-}
-
-/*
- * set a face's texture UV coord values
- */
-
-static int MFace_setUV( BPy_MFace * self, PyObject * value )
-{
- MTFace *face;
- int length, i;
-
- if( !MFace_get_pointer( self ) )
- return -1;
-
- if( !PySequence_Check( value ) ||
- EXPP_check_sequence_consistency( value, &vector_Type ) != 1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected sequence of vectors" );
-
- length = self->mesh->mface[self->index].v4 ? 4 : 3;
- if( length != PySequence_Size( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "size of vertex and UV sequences differ" );
-
- if( !self->mesh->mtface )
-#if 0
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
-#else
- make_tfaces( self->mesh );
-#endif
-
- face = &self->mesh->mtface[self->index];
- for( i=0; i<length; ++i ) {
- VectorObject *vector = (VectorObject *)PySequence_ITEM( value, i );
- face->uv[i][0] = vector->vec[0];
- face->uv[i][1] = vector->vec[1];
- Py_DECREF( vector );
- }
- return 0;
-}
-
-/*
- * get a face's texture UV coord select state
- */
-
-static PyObject *MFace_getUVSel( BPy_MFace * self )
-{
- MTFace *face;
- PyObject *attr;
- int length, i, mask;
-
- if( !self->mesh->mtface )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "face has no texture values" );
-
- if( !MFace_get_pointer( self ) )
- return NULL;
-
- face = &self->mesh->mtface[self->index];
- length = self->mesh->mface[self->index].v4 ? 4 : 3;
- attr = PyTuple_New( length );
-
- if( !attr )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyTuple_New() failed" );
-
- /* get coord select state, one bit at a time */
- mask = TF_SEL1;
- for( i=0; i<length; ++i, mask <<= 1 ) {
- PyObject *value = PyInt_FromLong( face->flag & mask ? 1 : 0 );
- if( !value ) {
- Py_DECREF( attr );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyInt_FromLong() failed" );
- }
- PyTuple_SetItem( attr, i, value );
- }
-
- return attr;
-}
-
-/*
- * set a face's texture UV coord select state
- */
-
-static int MFace_setUVSel( BPy_MFace * self, PyObject * value )
-{
- MTFace *face;
- int length, i, mask;
-
- if( !MFace_get_pointer( self ) )
- return -1;
-
- if( !PySequence_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a tuple of integers" );
-
- length = self->mesh->mface[self->index].v4 ? 4 : 3;
- if( length != PySequence_Size( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "size of vertex and UV lists differ" );
-
- if( !self->mesh->mtface )
-#if 0
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
-#else
- make_tfaces( self->mesh );
-#endif
-
- /* set coord select state, one bit at a time */
- face = &self->mesh->mtface[self->index];
- mask = TF_SEL1;
- for( i=0; i<length; ++i, mask <<= 1 ) {
- PyObject *tmp = PySequence_GetItem( value, i ); /* adds a reference, remove below */
- if( !PyInt_Check( tmp ) ) {
- Py_DECREF(tmp);
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a tuple of integers" );
- }
- if( PyInt_AsLong( tmp ) )
- face->flag |= mask;
- else
- face->flag &= ~mask;
- Py_DECREF(tmp);
- }
- return 0;
-}
-
-/*
- * get a face's vertex colors. note that if mesh->mtfaces is defined, then
- * it takes precedent over mesh->mcol
- */
-
-static PyObject *MFace_getCol( BPy_MFace * self )
-{
- PyObject *attr;
- int length, i;
- MCol * mcol;
-
- /* if there's no mesh color vectors or texture faces, nothing to do */
-
- if( !self->mesh->mcol )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "face has no vertex colors" );
-
- if( !MFace_get_pointer( self ) )
- return NULL;
-
- mcol = &self->mesh->mcol[self->index*4];
-
- length = self->mesh->mface[self->index].v4 ? 4 : 3;
- attr = PyTuple_New( length );
-
- if( !attr )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyTuple_New() failed" );
-
- for( i=0; i<length; ++i ) {
- PyObject *color = MCol_CreatePyObject( &mcol[i] );
- if( !color )
- return NULL;
- PyTuple_SetItem( attr, i, color );
- }
-
- return attr;
-}
-
-/*
- * set a face's vertex colors
- */
-
-static int MFace_setCol( BPy_MFace * self, PyObject *value )
-{
- int length, i;
- MCol * mcol;
-
- /* if there's no mesh color vectors or texture faces, nothing to do */
-
- if( !self->mesh->mcol )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no vertex colors" );
-
- if( !MFace_get_pointer( self ) )
- return -1;
-
- mcol = &self->mesh->mcol[self->index*4];
-
- length = self->mesh->mface[self->index].v4 ? 4 : 3;
-
- if( !PyList_Check( value ) && !PyTuple_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a sequence of MCols" );
-
- if( EXPP_check_sequence_consistency( value, &MCol_Type ) != 1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a sequence of MCols" );
-
- if( PySequence_Size( value ) != length )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "incorrect number of colors for this face" );
-
- for( i=0; i<length; ++i ) {
- BPy_MCol *obj = (BPy_MCol *)PySequence_ITEM( value, i );
- mcol[i].r = obj->color->r;
- mcol[i].g = obj->color->g;
- mcol[i].b = obj->color->b;
- mcol[i].a = obj->color->a;
- Py_DECREF( obj );
- }
- return 0;
-}
-
-
-/*
- * get edge keys for using in a dictionary or set key
- */
-
-static PyObject *MFace_getEdgeKeys( BPy_MFace * self )
-{
- MFace *face = MFace_get_pointer( self );
- PyObject *attr, *edpair;
-
- if (!face)
- return NULL; /* error set */
-
- if (face->v4) {
- attr = PyTuple_New( 4 );
- edpair = PyTuple_New( 2 );
- if (face->v1 > face->v2) {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v2) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v1) );
- } else {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v1) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v2) );
- }
- PyTuple_SET_ITEM( attr, 0, edpair );
-
- edpair = PyTuple_New( 2 );
- if (face->v2 > face->v3) {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v3) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v2) );
- } else {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v2) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v3) );
- }
- PyTuple_SET_ITEM( attr, 1, edpair );
-
- edpair = PyTuple_New( 2 );
- if (face->v3 > face->v4) {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v4) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v3) );
- } else {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v3) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v4) );
- }
- PyTuple_SET_ITEM( attr, 2, edpair );
-
- edpair = PyTuple_New( 2 );
- if (face->v4 > face->v1) {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v1) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v4) );
- } else {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v4) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v1) );
- }
- PyTuple_SET_ITEM( attr, 3, edpair );
-
- } else {
-
- attr = PyTuple_New( 3 );
- edpair = PyTuple_New( 2 );
- if (face->v1 > face->v2) {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v2) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v1) );
- } else {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v1) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v2) );
- }
- PyTuple_SET_ITEM( attr, 0, edpair );
-
- edpair = PyTuple_New( 2 );
- if (face->v2 > face->v3) {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v3) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v2) );
- } else {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v2) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v3) );
- }
- PyTuple_SET_ITEM( attr, 1, edpair );
-
- edpair = PyTuple_New( 2 );
- if (face->v3 > face->v1) {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v1) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v3) );
- } else {
- PyTuple_SET_ITEM( edpair, 0, PyInt_FromLong(face->v3) );
- PyTuple_SET_ITEM( edpair, 1, PyInt_FromLong(face->v1) );
- }
- PyTuple_SET_ITEM( attr, 2, edpair );
- }
-
- return attr;
-}
-
-
-/************************************************************************
- *
- * Python MFace_Type attributes get/set structure
- *
- ************************************************************************/
-
-static PyGetSetDef BPy_MFace_getseters[] = {
- {"verts",
- (getter)MFace_getVerts, (setter)MFace_setVerts,
- "face's vertices",
- NULL},
- {"v",
- (getter)MFace_getVerts, (setter)MFace_setVerts,
- "deprecated: see 'verts'",
- NULL},
- {"mat",
- (getter)MFace_getMat, (setter)MFace_setMat,
- "face's material index",
- NULL},
- {"index",
- (getter)MFace_getIndex, (setter)NULL,
- "face's index",
- NULL},
- {"no",
- (getter)MFace_getNormal, (setter)NULL,
- "face's normal",
- NULL},
- {"cent",
- (getter)MFace_getCent, (setter)NULL,
- "face's center",
- NULL},
- {"area",
- (getter)MFace_getArea, (setter)NULL,
- "face's 3D area",
- NULL},
-
- {"hide",
- (getter)MFace_getMFlagBits, (setter)MFace_setMFlagBits,
- "face hidden in edit mode",
- (void *)ME_HIDE},
- {"sel",
- (getter)MFace_getMFlagBits, (setter)MFace_setSelect,
- "face selected in edit mode",
- (void *)ME_FACE_SEL},
- {"smooth",
- (getter)MFace_getMFlagBits, (setter)MFace_setMFlagBits,
- "face smooth enabled",
- (void *)ME_SMOOTH},
-
- /* attributes for texture faces (mostly, I think) */
-
- {"col",
- (getter)MFace_getCol, (setter)MFace_setCol,
- "face's vertex colors",
- NULL},
- {"flag",
- (getter)MFace_getFlag, (setter)MFace_setFlag,
- "flags associated with texture faces",
- NULL},
- {"image",
- (getter)MFace_getImage, (setter)MFace_setImage,
- "image associated with texture faces",
- NULL},
- {"mode",
- (getter)MFace_getMode, (setter)MFace_setMode,
- "modes associated with texture faces",
- NULL},
- {"transp",
- (getter)MFace_getTransp, (setter)MFace_setTransp,
- "transparency of texture faces",
- NULL},
- {"uv",
- (getter)MFace_getUV, (setter)MFace_setUV,
- "face's UV coordinates",
- NULL},
- {"uvSel",
- (getter)MFace_getUVSel, (setter)MFace_setUVSel,
- "face's UV coordinates select status",
- NULL},
- {"edge_keys",
- (getter)MFace_getEdgeKeys, (setter)NULL,
- "for each edge this face uses return an ordered tuple edge pair that can be used as a key in a dictionary or set",
- NULL},
-
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/************************************************************************
- *
- * Python MFace_Type iterator (iterates over vertices)
- *
- ************************************************************************/
-
-/*
- * Initialize the interator index
- */
-
-static PyObject *MFace_getIter( BPy_MFace * self )
-{
- if (self->iter==-1) {
- self->iter = 0;
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- BPy_MFace *seq= (BPy_MFace *)MFace_CreatePyObject(self->mesh, self->index);
- seq->iter = 0;
- return (PyObject *) seq;
- }
-}
-
-/*
- * Return next MVert. Throw an exception after the final vertex.
- */
-
-static PyObject *MFace_nextIter( BPy_MFace * self )
-{
- struct MFace *face = &self->mesh->mface[self->index];
- int len = self->mesh->mface[self->index].v4 ? 4 : 3;
-
- if( self->iter == len ) {
- self->iter = -1;
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- ++self->iter;
- switch ( self->iter ) {
- case 1:
- return MVert_CreatePyObject( self->mesh, face->v1 );
- case 2:
- return MVert_CreatePyObject( self->mesh, face->v2 );
- case 3:
- return MVert_CreatePyObject( self->mesh, face->v3 );
- default :
- return MVert_CreatePyObject( self->mesh, face->v4 );
- }
-}
-
-/************************************************************************
- *
- * Python MFace_Type methods
- *
- ************************************************************************/
-
-/************************************************************************
- *
- * Python MFace_Type standard operations
- *
- ************************************************************************/
-static int MFace_compare( BPy_MFace * a, BPy_MFace * b )
-{
- return( a->mesh == b->mesh && a->index == b->index ) ? 0 : -1;
-}
-
-static PyObject *MFace_repr( BPy_MFace* self )
-{
- MFace *face = MFace_get_pointer( self );
-
- if( !face )
- return NULL;
-
- if( face->v4 )
- return PyString_FromFormat( "[MFace (%d %d %d %d) %d]",
- (int)face->v1, (int)face->v2,
- (int)face->v3, (int)face->v4, (int)self->index );
- else
- return PyString_FromFormat( "[MFace (%d %d %d) %d]",
- (int)face->v1, (int)face->v2,
- (int)face->v3, (int)self->index );
-}
-
-static long MFace_hash( BPy_MFace *self )
-{
- return (long)self->index;
-}
-
-static int MFace_len( BPy_MFace * self )
-{
- if( self->index >= self->mesh->totface )
- return 0;
- return self->mesh->mface[self->index].v4 ? 4 : 3;
-}
-
-static PySequenceMethods MFace_as_sequence = {
- ( inquiry ) MFace_len, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) 0, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- 0,0,0,
-};
-
-static PyObject *MFace_getProp( BPy_MFace *self, PyObject *args)
-{
- Mesh *me = (Mesh *)self->mesh;
- MFace *face = MFace_get_pointer( self );
- if( !face )
- return NULL;
- mesh_update_customdata_pointers(me); //!
- return Mesh_getProperty_internal(&(me->fdata), self->index, args);
-}
-
-static PyObject *MFace_setProp( BPy_MFace *self, PyObject *args)
-{
- Mesh *me = (Mesh *)self->mesh;
- PyObject *obj;
- MFace *face = MFace_get_pointer( self );
- if( !face )
- return NULL; /* error set */
-
- obj = Mesh_setProperty_internal(&(me->fdata), self->index, args);
- mesh_update_customdata_pointers(me); //!
- return obj;
-}
-
-static struct PyMethodDef BPy_MFace_methods[] = {
- {"getProperty", (PyCFunction)MFace_getProp, METH_O,
- "get property indicated by name"},
- {"setProperty", (PyCFunction)MFace_setProp, METH_VARARGS,
- "set property indicated by name"},
- {NULL, NULL, 0, NULL}
-};
-/************************************************************************
- *
- * Python MFace_Type structure definition
- *
- ************************************************************************/
-
-PyTypeObject MFace_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender MFace", /* char *tp_name; */
- sizeof( BPy_MFace ), /* 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 ) MFace_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) MFace_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &MFace_as_sequence, /* PySequenceMethods *tp_as_sequence; */
- NULL, /* PyMappingMethods *tp_as_mapping; */
-
- /* More standard operations (here for binary compatibility) */
-
- ( hashfunc ) MFace_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 */
- ( getiterfunc ) MFace_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) MFace_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_MFace_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_MFace_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 *MFace_CreatePyObject( Mesh * mesh, int i )
-{
- BPy_MFace *obj = PyObject_NEW( BPy_MFace, &MFace_Type );
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyObject_New() failed" );
-
- obj->mesh = mesh;
- obj->index = i;
- obj->iter= -1;
- return (PyObject *)obj;
-}
-
-/************************************************************************
- *
- * Face sequence
- *
- ************************************************************************/
-
-static int MFaceSeq_len( BPy_MFaceSeq * self )
-{
- return self->mesh->totface;
-}
-
-static PyObject *MFaceSeq_item( BPy_MFaceSeq * self, int i )
-{
- if( i < 0 || i >= self->mesh->totface )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-
- return MFace_CreatePyObject( self->mesh, i );
-}
-
-static PySequenceMethods MFaceSeq_as_sequence = {
- ( inquiry ) MFaceSeq_len, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) MFaceSeq_item, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- 0,0,0,
-};
-
-/************************************************************************
- *
- * Python MFaceSeq_Type iterator (iterates over faces)
- *
- ************************************************************************/
-
-/*
- * Initialize the interator index
- */
-
-static PyObject *MFaceSeq_getIter( BPy_MFaceSeq * self )
-{
- if (self->iter==-1) {
- self->iter = 0;
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- BPy_MFaceSeq *seq = (BPy_MFaceSeq *)MFaceSeq_CreatePyObject(self->mesh);
- seq->iter = 0;
- return (PyObject *)seq;
- }
-}
-
-/*
- * Return next MFace.
- */
-
-static PyObject *MFaceSeq_nextIter( BPy_MFaceSeq * self )
-{
- if( self->iter == self->mesh->totface ) {
- self->iter= -1; /* not being used in a seq */
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
- return MFace_CreatePyObject( self->mesh, self->iter++ );
-}
-
-/************************************************************************
- *
- * Python MFaceSeq_Type methods
- *
- ************************************************************************/
-
-static PyObject *MFaceSeq_extend( BPy_MEdgeSeq * self, PyObject *args,
- PyObject *keywds )
-{
- /*
- * (a) check input for valid edge objects, faces which consist of
- * only three or four edges
- * (b) check input to be sure edges form a closed face (each edge
- * contains verts in two other different edges?)
- *
- * (1) build list of new faces; remove duplicates
- * * use existing "v4=0 rule" for 3-vert faces
- * (2) build list of existing faces for searching
- * (3) from new face list, remove existing faces:
- */
-
- int len, nverts;
- int i, j, k, new_face_count;
- int good_faces;
- SrchFaces *oldpair, *newpair, *tmppair, *tmppair2;
- PyObject *tmp;
- MFace *tmpface;
- Mesh *mesh = self->mesh;
- int ignore_dups = 0;
- PyObject *return_list = NULL;
- char flag = ME_FACE_SEL;
-
- /* before we try to add faces, add edges; if it fails; exit */
-
- tmp = MEdgeSeq_extend( self, args );
- if( !tmp )
- return NULL;
- Py_DECREF( tmp );
-
- /* process any keyword arguments */
- if( keywds ) {
- PyObject *res = PyDict_GetItemString( keywds, "ignoreDups" );
- if( res ) {
- ignore_dups = PyObject_IsTrue( res );
- if (ignore_dups==-1) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "keyword argument \"ignoreDups\" expected True/False or 0/1" );
- }
- }
- res = PyDict_GetItemString( keywds, "indexList" );
- if (res) {
- switch( PyObject_IsTrue( res ) ) {
- case 0:
- break;
- case -1:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "keyword argument \"indexList\" expected True/False or 0/1" );
- default:
- return_list = PyList_New( 0 );
- }
- }
-
- res = PyDict_GetItemString( keywds, "smooth" );
- if (res) {
- switch( PyObject_IsTrue( res ) ) {
- case 0:
- break;
- case -1:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "keyword argument \"smooth\" expected True/False or 0/1" );
- default:
- flag |= ME_SMOOTH;
-
- }
- }
- }
-
- /* make sure we get a tuple of sequences of something */
-
- switch( PySequence_Size( args ) ) {
- case 1: /* better be a sequence or a tuple */
- /* if a sequence... */
- tmp = PyTuple_GET_ITEM( args, 0 );
- if( PySequence_Check( tmp ) ) {
- PyObject *tmp2;
-
- /* ignore empty sequences */
- if( !PySequence_Size( tmp ) ) {
- Py_RETURN_NONE;
- }
-
- /* if another sequence, use it */
- tmp2 = PySequence_ITEM( tmp, 0 );
- if( PySequence_Check( tmp2 ) )
- args = tmp;
- Py_INCREF( args );
- Py_DECREF( tmp2 );
- } else
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of sequence pairs" );
- break;
- case 2:
- case 3:
- case 4: /* two to four args may be individual verts */
- tmp = PyTuple_GET_ITEM( args, 0 );
- /*
- * if first item isn't a sequence, then assume it's a bunch of MVerts
- * and wrap inside a tuple
- */
- if( !PySequence_Check( tmp ) ) {
- args = Py_BuildValue( "(O)", args );
- if( !args )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Py_BuildValue() failed" );
- /*
- * otherwise, assume it already a bunch of sequences so use as-is
- */
- } else {
- Py_INCREF( args ); /* so we can safely DECREF later */
- }
- break;
- default: /* anything else is definitely wrong */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of sequence pairs" );
- }
-
- /* if nothing to add, just exit */
- len = PySequence_Size( args );
- if( len == 0 ) {
- Py_DECREF( args );
- Py_RETURN_NONE;
- }
-
- /*
- * Since we call MEdgeSeq_extend first, we already know the input list
- * is valid. Here we just need to count the total number of faces.
- */
-
- new_face_count = 0;
- for( i = 0; i < len; ++i ) {
- tmp = PySequence_ITEM( args, i );
- nverts = PySequence_Size( tmp );
- if( return_list || nverts != 2 )
- ++new_face_count; /* new faces must have 3 or 4 verts */
- Py_DECREF( tmp );
- }
-
- /* OK, commit to allocating the search structures */
- newpair = (SrchFaces *)MEM_callocN( sizeof(SrchFaces)*new_face_count,
- "MFacePairs" );
-
- /* scan the input list and build the new face pair list */
- len = PySequence_Size( args );
- tmppair = newpair;
-
- for( i = 0; i < len; ++i ) {
- MFace tmpface;
- unsigned int vert[4]={0,0,0,0};
- unsigned char order[4]={0,1,2,3};
- tmp = PySequence_GetItem( args, i );
- nverts = PySequence_Size( tmp );
-
- if( nverts == 2 ) { /* again, ignore 2-vert tuples */
- if( return_list ) /* if returning indices, mark as deleted */
- tmppair->v[1] = 0;
- Py_DECREF( tmp );
- continue;
- }
-
- /*
- * get the face's vertices' indexes
- */
-
- for( j = 0; j < nverts; ++j ) {
- PyObject *item = PySequence_ITEM( tmp, j );
- if( BPy_MVert_Check( item ) )
- vert[j] = ((BPy_MVert *)item)->index;
- else
- vert[j] = PyInt_AsLong( item );
- Py_DECREF( item );
- }
- Py_DECREF( tmp );
- tmpface.v1 = vert[0];
- tmpface.v2 = vert[1];
- tmpface.v3 = vert[2];
- tmpface.v4 = vert[3];
-
- /*
- * go through some contortions to guarantee the third and fourth
- * vertices are not index 0
- */
- eeek_fix( &tmpface, nverts == 4 );
- vert[0] = tmpface.v1;
- vert[1] = tmpface.v2;
- vert[2] = tmpface.v3;
- if( nverts == 3 )
- vert[3] = tmppair->v[3] = 0;
- else
- vert[3] = tmpface.v4;
-
- /*
- * sort the verts before placing in pair list. the order of
- * vertices in the face is very important, so keep track of
- * the original order
- */
-
- for( j = nverts-1; j >= 0; --j ) {
- for( k = 0; k < j; ++k ) {
- if( vert[k] > vert[k+1] ) {
- SWAP( int, vert[k], vert[k+1] );
- SWAP( char, order[k], order[k+1] );
- } else if( vert[k] == vert[k+1] ) {
- break;
- }
- }
- if( k < j )
- break;
- tmppair->v[j] = vert[j];
- }
- if( j >= 0 ) { /* a duplicate vertex found */
- if( return_list ) { /* if returning index list */
- tmppair->v[1] = 0; /* mark as deleted */
- } else {
- --new_face_count; /* otherwise skip */
- continue;
- }
- }
- tmppair->index = i;
-
- /* pack order into a byte */
- tmppair->order = order[0]|(order[1]<<2)|(order[2]<<4)|(order[3]<<6);
- ++tmppair;
- }
-
- /*
- * find duplicates in the new list and mark. if it's a duplicate,
- * then mark by setting second vert index to 0 (a real edge won't have
- * second vert index of 0 since verts are sorted)
- */
-
- good_faces = new_face_count; /* assume all faces good to start */
-
- tmppair = newpair; /* "last good edge" */
- tmppair2 = &tmppair[1]; /* "current candidate edge" */
- if( !ignore_dups ) {
-
- /* sort the new face pairs */
- qsort( newpair, new_face_count, sizeof(SrchFaces), mface_comp );
-
- for( i = 0; i < new_face_count; ++i ) {
- if( mface_comp( tmppair, tmppair2 ) )
- tmppair = tmppair2; /* last != current, so current == last */
- else {
- tmppair2->v[1] = 0; /* last == current, so mark as duplicate */
- --good_faces; /* one less good face */
- }
- tmppair2++;
- }
- }
-
- /* if mesh has faces, see if any of the new faces are already in it */
- if( mesh->totface && !ignore_dups ) {
- oldpair = (SrchFaces *)MEM_callocN( sizeof(SrchFaces)*mesh->totface,
- "MFacePairs" );
-
- tmppair = oldpair;
- tmpface = mesh->mface;
- for( i = 0; i < mesh->totface; ++i ) {
- unsigned char order[4]={0,1,2,3};
- int verts[4];
- verts[0]=tmpface->v1;
- verts[1]=tmpface->v2;
- verts[2]=tmpface->v3;
- verts[3]=tmpface->v4;
-
- len = ( tmpface->v4 ) ? 3 : 2;
- tmppair->v[3] = 0; /* for triangular faces */
-
- /* sort the verts before placing in pair list here too */
- for( j = len; j >= 0; --j ) {
- for( k = 0; k < j; ++k )
- if( verts[k] > verts[k+1] ) {
- SWAP( int, verts[k], verts[k+1] );
- SWAP( unsigned char, order[k], order[k+1] );
- }
- tmppair->v[j] = verts[j];
- }
-
- /* pack order into a byte */
- tmppair->order = order[0]|(order[1]<<2)|(order[2]<<4)|(order[3]<<6);
- ++tmppair;
- ++tmpface;
- }
-
- /* sort the old face pairs */
- qsort( oldpair, mesh->totface, sizeof(SrchFaces), mface_comp );
-
- /* eliminate new faces already in the mesh */
- tmppair = newpair;
- for( i = good_faces; i ; ) {
- if( tmppair->v[1] ) {
- if( bsearch( tmppair, oldpair, mesh->totface,
- sizeof(SrchFaces), mface_comp ) ) {
- tmppair->v[1] = 0; /* mark as duplicate */
- --good_faces;
- }
- --i;
- }
- tmppair++;
- }
- MEM_freeN( oldpair );
- }
-
- /* if any new faces are left, add to list */
- if( good_faces || return_list ) {
- int totface = mesh->totface+good_faces; /* new face count */
- CustomData fdata;
-
- CustomData_copy( &mesh->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface );
- CustomData_copy_data( &mesh->fdata, &fdata, 0, 0, mesh->totface );
-
- if ( !CustomData_has_layer( &fdata, CD_MFACE ) )
- CustomData_add_layer( &fdata, CD_MFACE, CD_CALLOC, NULL, totface );
-
- CustomData_free( &mesh->fdata, mesh->totface );
- mesh->fdata = fdata;
- mesh_update_customdata_pointers( mesh );
-
- /* sort the faces back into their original input list order */
- if( !ignore_dups )
- qsort( newpair, new_face_count, sizeof(SrchFaces),
- mface_index_comp );
-
-
- /* point to the first face we're going to add */
- tmpface = &mesh->mface[mesh->totface];
- tmppair = newpair;
-
- if( return_list )
- good_faces = new_face_count; /* assume all faces good to start */
-
- /* as we find a good face, add it */
- while ( good_faces ) {
- if( tmppair->v[1] ) {
- int i;
- unsigned int index[4];
- unsigned char order = tmppair->order;
-
- /* unpack the order of the vertices */
- for( i = 0; i < 4; ++i ) {
- index[(order & 0x03)] = i;
- order >>= 2;
- }
-
- /* now place vertices in the proper order */
- tmpface->v1 = tmppair->v[index[0]];
- tmpface->v2 = tmppair->v[index[1]];
- tmpface->v3 = tmppair->v[index[2]];
- tmpface->v4 = tmppair->v[index[3]];
-
- tmpface->flag = flag;
-
- if( return_list ) {
- tmp = PyInt_FromLong( mesh->totface );
- PyList_Append( return_list, tmp );
- Py_DECREF(tmp);
- }
- mesh->totface++;
- ++tmpface;
- --good_faces;
- } else if( return_list ) {
- PyList_Append( return_list, Py_None );
- --good_faces;
- }
- tmppair++;
- }
- }
-
- /* clean up and leave */
- mesh_update( mesh );
- Py_DECREF ( args );
- MEM_freeN( newpair );
-
- if( return_list )
- return return_list;
- else
- Py_RETURN_NONE;
-}
-
-struct fourEdges
-{
- FaceEdges *v[4];
-};
-
-static PyObject *MFaceSeq_delete( BPy_MFaceSeq * self, PyObject *args )
-{
- unsigned int *face_table;
- int i, len;
- Mesh *mesh = self->mesh;
- MFace *tmpface;
- int face_count;
- int edge_also = 0;
-
- /* check for valid inputs */
-
- if( PySequence_Size( args ) != 2 ||
- !PyArg_ParseTuple( args, "iO", &edge_also, &args ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected and int and a sequence of ints or MFaces" );
-
- if( !PyList_Check( args ) && !PyTuple_Check( args ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected and int and a sequence of ints or MFaces" );
-
- /* see how many args we need to parse */
- len = PySequence_Size( args );
- if( len < 1 )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "sequence must contain at least one int or MFace" );
-
- face_table = MEM_callocN( len*sizeof( unsigned int ),
- "face_table" );
-
- /* get the indices of faces to be removed */
- for( i = len; i--; ) {
- PyObject *tmp = PySequence_GetItem( args, i );
- if( BPy_MFace_Check( tmp ) )
- face_table[i] = ((BPy_MFace *)tmp)->index;
- else if( PyInt_Check( tmp ) )
- face_table[i] = PyInt_AsLong( tmp );
- else {
- MEM_freeN( face_table );
- Py_DECREF( tmp );
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of ints or MFaces" );
- }
- Py_DECREF( tmp );
-
- /* if index out-of-range, throw exception */
- if( face_table[i] >= (unsigned int)mesh->totface ) {
- MEM_freeN( face_table );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "array index out of range" );
- }
- }
-
- if( edge_also ) {
- /*
- * long version
- *
- * (1) build sorted table of all edges
- * (2) construct face->edge lookup table for all faces
- * face->e1 = mesh->medge[i]
- * (3) (delete sorted table)
- * (4) mark all edges as live
- * (5) mark all edges for deleted faces as dead
- * (6) mark all edges for remaining faces as live
- * (7) delete all dead edges
- * (8) (delete face lookup table)
- *
- */
-
- FaceEdges *edge_table, *tmp_et;
- MEdge *tmpedge;
- FaceEdges **face_edges;
- FaceEdges **tmp_fe;
- struct fourEdges *fface;
- int edge_count;
-
- edge_table = MEM_mallocN( mesh->totedge*sizeof( FaceEdges ),
- "edge_table" );
-
- tmpedge = mesh->medge;
- tmp_et = edge_table;
-
- for( i = 0; i < mesh->totedge; ++i ) {
- if( tmpedge->v1 < tmpedge->v2 ) {
- tmp_et->v[0] = tmpedge->v1;
- tmp_et->v[1] = tmpedge->v2;
- } else {
- tmp_et->v[0] = tmpedge->v2;
- tmp_et->v[1] = tmpedge->v1;
- }
- tmp_et->index = i;
- tmp_et->sel = 1; /* select each edge */
- ++tmpedge;
- ++tmp_et;
- }
-
- /* sort the edge pairs */
- qsort( edge_table, mesh->totedge, sizeof(FaceEdges), faceedge_comp );
-
- /* build face translation table, lookup edges */
- face_edges = MEM_callocN( 4*sizeof(FaceEdges*)*mesh->totface,
- "face_edges" );
-
- tmp_fe = face_edges;
- tmpface = mesh->mface;
- for( i = mesh->totface; i--; ++tmpface ) {
- FaceEdges *ptrs[4];
- unsigned int verts[4];
- int j,k;
- FaceEdges target;
- int len=tmpface->v4 ? 4 : 3;
-
- ptrs[3] = NULL;
- verts[0] = tmpface->v1;
- verts[1] = tmpface->v2;
- verts[2] = tmpface->v3;
- if( len == 4 )
- verts[3] = tmpface->v4;
- for( j = 0; j < len; ++j ) {
- k = (j+1) % len;
- if( verts[j] < verts[k] ) {
- target.v[0] = verts[j];
- target.v[1] = verts[k];
- } else {
- target.v[0] = verts[k];
- target.v[1] = verts[j];
- }
- ptrs[j] = bsearch( &target, edge_table, mesh->totedge,
- sizeof(FaceEdges), faceedge_comp );
- }
- for( j = 0; j < 4; ++j, ++tmp_fe )
- *tmp_fe = ptrs[j];
- }
-
- /* for each face, deselect each edge */
- tmpface = mesh->mface;
- face_count = 0;
- for( i = len; i--; ) {
- if( tmpface[face_table[i]].v1 != UINT_MAX ) {
- fface = (void *)face_edges;
- fface += face_table[i];
- fface->v[0]->sel = 0;
- fface->v[1]->sel = 0;
- fface->v[2]->sel = 0;
- if( fface->v[3] )
- fface->v[3]->sel = 0;
- tmpface[face_table[i]].v1 = UINT_MAX;
- ++face_count;
- }
- }
-
- /* for each remaining face, select all edges */
- tmpface = mesh->mface;
- fface = (struct fourEdges *)face_edges;
- for( i = mesh->totface; i--; ++tmpface, ++fface ) {
- if( tmpface->v1 != UINT_MAX ) {
- fface->v[0]->sel = 1;
- fface->v[1]->sel = 1;
- fface->v[2]->sel = 1;
- if( fface->v[3] )
- fface->v[3]->sel = 1;
- }
- }
- /* now mark the selected edges for deletion */
-
- edge_count = 0;
- for( i = 0; i < mesh->totedge; ++i ) {
- if( !edge_table[i].sel ) {
- mesh->medge[edge_table[i].index].v1 = UINT_MAX;
- ++edge_count;
- }
- }
-
- if( edge_count )
- delete_edges( mesh, NULL, edge_count );
-
- MEM_freeN( face_edges );
- MEM_freeN( edge_table );
- } else {
- /* mark faces to delete */
- tmpface = mesh->mface;
- face_count = 0;
- for( i = len; i--; )
- if( tmpface[face_table[i]].v1 != UINT_MAX ) {
- tmpface[face_table[i]].v1 = UINT_MAX;
- ++face_count;
- }
- }
-
- /* delete faces which have a deleted edge */
- delete_faces( mesh, NULL, face_count );
-
- /* clean up and return */
- MEM_freeN( face_table );
- mesh_update ( mesh );
- Py_RETURN_NONE;
-}
-
-/* copied from meshtools.c - should make generic? */
-static void permutate(void *list, int num, int size, int *index)
-{
- void *buf;
- int len;
- int i;
-
- len = num * size;
-
- buf = MEM_mallocN(len, "permutate");
- memcpy(buf, list, len);
-
- for (i = 0; i < num; i++) {
- memcpy((char *)list + (i * size), (char *)buf + (index[i] * size), size);
- }
- MEM_freeN(buf);
-}
-
-/* this wrapps list sorting then applies back to the mesh */
-static PyObject *MFaceSeq_sort( BPy_MEdgeSeq * self, PyObject *args,
- PyObject *keywds )
-{
- PyObject *ret, *sort_func, *newargs;
-
- Mesh *mesh = self->mesh;
- PyObject *sorting_list;
- CustomDataLayer *layer;
- int i, *index;
-
- /* get a list for internal use */
- sorting_list = PySequence_List( (PyObject *)self );
- if( !sorting_list )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyList_New() failed" );
-
- /* create index list */
- index = (int *) MEM_mallocN(sizeof(int) * mesh->totface, "sort faces");
- if (!index)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "faces.sort(...) failed to allocate memory" );
-
- newargs = EXPP_PyTuple_New_Prepend(args, sorting_list);
- sort_func = PyObject_GetAttrString( ((PyObject *)&PyList_Type), "sort");
-
- ret = PyObject_Call(sort_func, newargs, keywds);
-
- Py_DECREF(newargs);
- Py_DECREF(sort_func);
-
- if (ret) {
- /* copy the faces indicies to index */
- for (i = 0; i < mesh->totface; i++)
- index[i] = ((BPy_MFace *)PyList_GET_ITEM(sorting_list, i))->index;
-
- for(i = 0; i < mesh->fdata.totlayer; i++) {
- layer = &mesh->fdata.layers[i];
- permutate(layer->data, mesh->totface, CustomData_sizeof(layer->type), index);
- }
- }
- Py_DECREF(sorting_list);
- MEM_freeN(index);
- return ret;
-}
-
-static PyObject *MFaceSeq_selected( BPy_MFaceSeq * self )
-{
- int i, count;
- Mesh *mesh = self->mesh;
- MFace *tmpface;
- PyObject *list;
-
- /* first count selected faces (quicker than appending to PyList?) */
- count = 0;
- tmpface = mesh->mface;
- for( i = 0; i < mesh->totface; ++i, ++tmpface )
- if( tmpface->flag & ME_FACE_SEL )
- ++count;
-
- list = PyList_New( count );
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyList_New() failed" );
-
- /* next, insert selected faces into list */
- count = 0;
- tmpface = mesh->mface;
- for( i = 0; i < mesh->totface; ++i, ++tmpface ) {
- if( tmpface->flag & ME_FACE_SEL ) {
- PyObject *tmp = PyInt_FromLong( i );
- if( !tmp ) {
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyInt_FromLong() failed" );
- }
- PyList_SET_ITEM( list, count, tmp );
- ++count;
- }
- }
- return list;
-}
-
-static PyObject *MFaceSeq_add_layertype(BPy_MFaceSeq *self, PyObject *args)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_addPropLayer_internal(me, &(me->fdata), me->totface, args);
-}
-static PyObject *MFaceSeq_del_layertype(BPy_MFaceSeq *self, PyObject *value)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_removePropLayer_internal(me, &(me->fdata), me->totface, value);
-}
-static PyObject *MFaceSeq_rename_layertype(BPy_MFaceSeq *self, PyObject *args)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_renamePropLayer_internal(me,&(me->fdata),args);
-}
-static PyObject *MFaceSeq_PropertyList(BPy_MFaceSeq *self)
-{
- Mesh *me = (Mesh*)self->mesh;
- return Mesh_propList_internal(&(me->fdata));
-}
-
-static struct PyMethodDef BPy_MFaceSeq_methods[] = {
- {"extend", (PyCFunction)MFaceSeq_extend, METH_VARARGS|METH_KEYWORDS,
- "add faces to mesh"},
- {"delete", (PyCFunction)MFaceSeq_delete, METH_VARARGS,
- "delete faces from mesh"},
- {"sort", (PyCFunction)MFaceSeq_sort, METH_VARARGS|METH_KEYWORDS,
- "sort the faces using list sorts syntax"},
- {"selected", (PyCFunction)MFaceSeq_selected, METH_NOARGS,
- "returns a list containing indices of selected faces"},
- {"addPropertyLayer",(PyCFunction)MFaceSeq_add_layertype, METH_VARARGS,
- "add a new property layer"},
- {"removePropertyLayer",(PyCFunction)MFaceSeq_del_layertype, METH_O,
- "removes a property layer"},
- {"renamePropertyLayer",(PyCFunction)MFaceSeq_rename_layertype, METH_VARARGS,
- "renames an existing property layer"},
- {NULL, NULL, 0, NULL}
-};
-static PyGetSetDef BPy_MFaceSeq_getseters[] = {
- {"properties",
- (getter)MFaceSeq_PropertyList, (setter)NULL,
- "vertex property layers, read only",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-/************************************************************************
- *
- * Python MFaceSeq_Type standard operations
- *
- ************************************************************************/
-
-/*****************************************************************************/
-/* Python MFaceSeq_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject MFaceSeq_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender MFaceSeq", /* char *tp_name; */
- sizeof( BPy_MFaceSeq ), /* 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; */
- NULL, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &MFaceSeq_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 )MFaceSeq_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc )MFaceSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_MFaceSeq_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_MFaceSeq_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
-};
-
-/************************************************************************
- *
- * Python BPy_Mesh methods
- *
- ************************************************************************/
-
-static PyObject *Mesh_calcNormals( BPy_Mesh * self )
-{
- Mesh *mesh = self->mesh;
-
- mesh_calc_normals( mesh->mvert, mesh->totvert, mesh->mface,
- mesh->totface, NULL );
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_vertexShade( BPy_Mesh * self )
-{
- Base *base = FIRSTBASE;
-
- if( G.obedit )
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "can't shade vertices while in edit mode" );
-
- while( base ) {
- if( base->object->type == OB_MESH &&
- base->object->data == self->mesh ) {
- base->flag |= SELECT;
- set_active_base( base );
- make_vertexcol(1);
- countall();
- Py_RETURN_NONE;
- }
- base = base->next;
- }
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "object not found in baselist!" );
-}
-
-/*
- * force display list update
- */
-
-static PyObject *Mesh_Update( BPy_Mesh * self, PyObject *args, PyObject *kwd )
-{
-
- char *blockname= NULL;
- static char *kwlist[] = {"key", NULL};
-
- if( !PyArg_ParseTupleAndKeywords(args, kwd, "|s", kwlist, &blockname) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Expected nothing or the name of a shapeKey");
-
- if (blockname) {
- Mesh *me = self->mesh;
- MVert *mv = me->mvert;
- Key *key= me->key;
- KeyBlock *kb;
- float (*co)[3];
- int i;
-
- if (!key)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Cannot update the key for this mesh, it has no shape keys");
-
- for (kb = key->block.first; kb; kb=kb->next)
- if (strcmp(blockname, kb->name)==0)
- break;
-
- if (!kb)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "This requested key to update does not exist");
-
- for(i=0, co= kb->data; i<me->totvert; i++, mv++, co++)
- VECCOPY(*co, mv->co);
- } else {
- /* Normal operation */
- mesh_update( self->mesh );
- }
- Py_RETURN_NONE;
-}
-
-/*
- * search for a single edge in mesh's edge list
- */
-
-static PyObject *Mesh_findEdge( BPy_Mesh * self, PyObject *args )
-{
- int i;
- unsigned int v1, v2;
- PyObject *tmp;
- MEdge *edge = self->mesh->medge;
-
- if( EXPP_check_sequence_consistency( args, &MVert_Type ) == 1 &&
- PySequence_Size( args ) == 2 ) {
- tmp = PyTuple_GET_ITEM( args, 0 );
- v1 = ((BPy_MVert *)tmp)->index;
- tmp = PyTuple_GET_ITEM( args, 1 );
- v2 = ((BPy_MVert *)tmp)->index;
- } else if( PyArg_ParseTuple( args, "ii", &v1, &v2 ) ) {
- if( (int)v1 >= self->mesh->totvert || (int)v2 >= self->mesh->totvert )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "index out of range" );
- } else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "expected tuple of two ints or MVerts" );
-
- for( i = 0; i < self->mesh->totedge; ++i ) {
- if( ( edge->v1 == v1 && edge->v2 == v2 )
- || ( edge->v1 == v2 && edge->v2 == v1 ) ) {
- tmp = PyInt_FromLong( i );
- if( tmp )
- return tmp;
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyInt_FromLong() failed" );
- }
- ++edge;
- }
- Py_RETURN_NONE;
-}
-
-/*
- * search for a group of edges in mesh's edge list
- */
-
-static PyObject *Mesh_findEdges( PyObject * self, PyObject *args )
-{
- int len;
- int i;
- SrchEdges *oldpair, *tmppair, target, *result;
- PyObject *list, *tmp;
- BPy_MVert *v1, *v2;
- unsigned int index1, index2;
- MEdge *tmpedge;
- Mesh *mesh = ((BPy_Mesh *)self)->mesh;
-
- /* if no edges, nothing to do */
-
- if( !mesh->totedge )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "mesh has no edges" );
-
- /* make sure we get a sequence of tuples of something */
-
- tmp = PyTuple_GET_ITEM( args, 0 );
- switch( PySequence_Size ( args ) ) {
- case 1: /* better be a list or a tuple */
- if( !PySequence_Check ( tmp ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of tuple int or MVert pairs" );
- args = tmp;
- Py_INCREF( args ); /* so we can safely DECREF later */
- break;
- case 2: /* take any two args and put into a tuple */
- if( PyTuple_Check( tmp ) )
- Py_INCREF( args ); /* if first arg is a tuple, assume both are */
- else {
- args = Py_BuildValue( "((OO))", tmp, PyTuple_GET_ITEM( args, 1 ) );
- if( !args )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Py_BuildValue() failed" );
- }
- break;
- default: /* anything else is definitely wrong */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of tuple pairs" );
- }
-
- len = PySequence_Size( args );
- if( len == 0 ) {
- Py_DECREF( args );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected at least one tuple" );
- }
-
- /* if a single edge, handle the simpler way */
- if( len == 1 ) {
- PyObject *result;
- tmp = PySequence_GetItem( args, 0 );
- result = Mesh_findEdge( (BPy_Mesh *)self, tmp );
- Py_DECREF( tmp );
- Py_DECREF( args );
- return result;
- }
-
- /* build a list of all edges so we can search */
- oldpair = (SrchEdges *)MEM_callocN( sizeof(SrchEdges)*mesh->totedge,
- "MEdgePairs" );
-
- tmppair = oldpair;
- tmpedge = mesh->medge;
- for( i = 0; i < mesh->totedge; ++i ) {
- if( tmpedge->v1 < tmpedge->v2 ) {
- tmppair->v[0] = tmpedge->v1;
- tmppair->v[1] = tmpedge->v2;
- } else {
- tmppair->v[0] = tmpedge->v2;
- tmppair->v[1] = tmpedge->v1;
- }
- tmppair->index = i;
- ++tmpedge;
- ++tmppair;
- }
-
- /* sort the old edge pairs */
- qsort( oldpair, mesh->totedge, sizeof(SrchEdges), medge_comp );
-
- list = PyList_New( len );
- if( !len )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyList_New() failed" );
-
- /* scan the input list, find vert pairs, then search the edge list */
-
- for( i = 0; i < len; ++i ) {
- tmp = PySequence_GetItem( args, i );
- if( !PyTuple_Check( tmp ) || PyTuple_Size( tmp ) != 2 ) {
- MEM_freeN( oldpair );
- Py_DECREF( tmp );
- Py_DECREF( args );
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected tuple pair" );
- }
-
- /* get objects, check that they are both MVerts of this mesh */
- v1 = (BPy_MVert *)PyTuple_GET_ITEM( tmp, 0 );
- v2 = (BPy_MVert *)PyTuple_GET_ITEM( tmp, 1 );
- Py_DECREF ( tmp );
- if( BPy_MVert_Check( v1 ) && BPy_MVert_Check( v2 ) ) {
- if( v1->data != (void *)mesh || v2->data != (void *)mesh ) {
- MEM_freeN( oldpair );
- Py_DECREF( args );
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "one or both MVerts do not belong to this mesh" );
- }
- index1 = v1->index;
- index2 = v2->index;
- } else if( PyInt_Check( v1 ) && PyInt_Check( v2 ) ) {
- index1 = PyInt_AsLong( (PyObject *)v1 );
- index2 = PyInt_AsLong( (PyObject *)v2 );
- if( (int)index1 >= mesh->totvert
- || (int)index2 >= mesh->totvert ) {
- MEM_freeN( oldpair );
- Py_DECREF( args );
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "index out of range" );
- }
- } else {
- MEM_freeN( oldpair );
- Py_DECREF( args );
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected tuple to contain MVerts" );
- }
-
- /* sort verts into order */
- if( index1 < index2 ) {
- target.v[0] = index1;
- target.v[1] = index2;
- } else {
- target.v[0] = index2;
- target.v[1] = index1;
- }
-
- /* search edge list for a match; result is index or None */
- result = bsearch( &target, oldpair, mesh->totedge,
- sizeof(SrchEdges), medge_comp );
- if( result )
- tmp = PyInt_FromLong( result->index );
- else
- tmp = EXPP_incr_ret( Py_None );
- if( !tmp ) {
- MEM_freeN( oldpair );
- Py_DECREF( args );
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyInt_FromLong() failed" );
- }
- PyList_SET_ITEM( list, i, tmp );
- }
-
- MEM_freeN( oldpair );
- Py_DECREF ( args );
- return list;
-}
-
-/*
- * replace mesh data with mesh data from another object
- */
-
-
-static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args )
-{
- Object *ob = NULL;
- PyObject *object_arg;
- ID tmpid;
- Mesh *tmpmesh;
- Curve *tmpcu = NULL;
- DerivedMesh *dm;
- Object *tmpobj = NULL;
- int cage = 0, render = 0, i;
-
- if( !PyArg_ParseTuple( args, "O|ii", &object_arg, &cage, &render ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected object or string and optional integer arguments" );
-
- if ( PyString_Check( object_arg ) ) {
- char *name;
- name = PyString_AsString ( object_arg );
- ob = ( Object * ) GetIdFromList( &( G.main->object ), name );
- if( !ob )
- return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
- } else if ( BPy_Object_Check(object_arg) ) {
- ob = (( BPy_Object * ) object_arg)->object;
- } else {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected object or string and optional integer arguments" );
- }
-
- if( cage != 0 && cage != 1 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "cage value must be 0 or 1" );
-
-
-
- /* perform the mesh extraction based on type */
- switch (ob->type) {
- case OB_FONT:
- case OB_CURVE:
- case OB_SURF:
- /* copies object and modifiers (but not the data) */
- tmpobj= copy_object( ob );
- tmpcu = (Curve *)tmpobj->data;
- tmpcu->id.us--;
-
- /* if getting the original caged mesh, delete object modifiers */
- if( cage )
- object_free_modifiers(tmpobj);
-
- /* copies the data */
- tmpobj->data = copy_curve( (Curve *) ob->data );
-
-#if 0
- /* copy_curve() sets disp.first null, so currently not need */
- {
- Curve *cu;
- cu = (Curve *)tmpobj->data;
- if( cu->disp.first )
- MEM_freeN( cu->disp.first );
- cu->disp.first = NULL;
- }
-
-#endif
-
- /* get updated display list, and convert to a mesh */
- makeDispListCurveTypes( tmpobj, 0 );
- nurbs_to_mesh( tmpobj );
-
- /* nurbs_to_mesh changes the type tp a mesh, check it worked */
- if (tmpobj->type != OB_MESH) {
- free_libblock_us( &G.main->object, tmpobj );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cant convert curve to mesh. Does the curve have any segments?" );
- }
- tmpmesh = tmpobj->data;
- free_libblock_us( &G.main->object, tmpobj );
- break;
- case OB_MBALL:
- /* metaballs don't have modifiers, so just convert to mesh */
- ob = find_basis_mball( ob );
- tmpmesh = add_mesh("Mesh");
- mball_to_mesh( &ob->disp, tmpmesh );
-
- break;
- case OB_MESH:
- /* copies object and modifiers (but not the data) */
- if (cage) {
- /* copies the data */
- tmpmesh = copy_mesh( ob->data );
- /* if not getting the original caged mesh, get final derived mesh */
- } else {
- /* Make a dummy mesh, saves copying */
-
- /* Write the display mesh into the dummy mesh */
- if (render)
- dm = mesh_create_derived_render( ob, CD_MASK_MESH );
- else
- dm = mesh_create_derived_view( ob, CD_MASK_MESH );
-
- tmpmesh = add_mesh( "Mesh" );
- DM_to_mesh( dm, tmpmesh );
- dm->release( dm );
- }
-
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Object does not have geometry data" );
- }
-
- /* free mesh data in the original */
- free_mesh( self->mesh );
- /* save a copy of our ID, dup the temporary mesh, restore the ID */
- tmpid = self->mesh->id;
- memcpy( self->mesh, tmpmesh, sizeof( Mesh ) );
- self->mesh->id = tmpid;
-
- /* if mesh has keys, make sure they point back to this mesh */
- if( self->mesh->key )
- self->mesh->key->from = (ID *)self->mesh;
-
-
-
- /* Copy materials to new object */
- switch (ob->type) {
- case OB_SURF:
- self->mesh->totcol = tmpcu->totcol;
-
- /* free old material list (if it exists) and adjust user counts */
- if( tmpcu->mat ) {
- for( i = tmpcu->totcol; i-- > 0; ) {
-
- /* are we an object material or data based? */
- if (ob->colbits & 1<<i) {
- self->mesh->mat[i] = ob->mat[i];
- ob->mat[i]->id.us++;
- tmpmesh->mat[i]->id.us--;
- } else {
- self->mesh->mat[i] = tmpcu->mat[i];
- if (self->mesh->mat[i]) {
- tmpmesh->mat[i]->id.us++;
- }
- }
- }
- }
- break;
-
-#if 0
- /* Crashes when assigning the new material, not sure why */
- case OB_MBALL:
- tmpmb = (MetaBall *)ob->data;
- self->mesh->totcol = tmpmb->totcol;
-
- /* free old material list (if it exists) and adjust user counts */
- if( tmpmb->mat ) {
- for( i = tmpmb->totcol; i-- > 0; ) {
- self->mesh->mat[i] = tmpmb->mat[i]; /* CRASH HERE ??? */
- if (self->mesh->mat[i]) {
- tmpmb->mat[i]->id.us++;
- }
- }
- }
- break;
-#endif
-
- case OB_MESH:
- if (!cage) {
- Mesh *origmesh= ob->data;
- self->mesh->flag= origmesh->flag;
- self->mesh->mat = MEM_dupallocN(origmesh->mat);
- self->mesh->totcol = origmesh->totcol;
- self->mesh->smoothresh= origmesh->smoothresh;
- if( origmesh->mat ) {
- for( i = origmesh->totcol; i-- > 0; ) {
- /* are we an object material or data based? */
- if (ob->colbits & 1<<i) {
- self->mesh->mat[i] = ob->mat[i];
-
- if (ob->mat[i])
- ob->mat[i]->id.us++;
- if (origmesh->mat[i])
- origmesh->mat[i]->id.us--;
- } else {
- self->mesh->mat[i] = origmesh->mat[i];
-
- if (origmesh->mat[i])
- origmesh->mat[i]->id.us++;
- }
- }
- }
- }
- break;
- } /* end copy materials */
-
-
-
- /* remove the temporary mesh */
- BLI_remlink( &G.main->mesh, tmpmesh );
- MEM_freeN( tmpmesh );
-
- /* make sure materials get updated in objects */
- test_object_materials( ( ID * ) self->mesh );
-
- mesh_update( self->mesh );
- Py_RETURN_NONE;
-}
-
-/*
- * apply a transform to the mesh's vertices
- *
- * WARNING: unlike NMesh, this method ALWAYS changes the original mesh
- */
-
-static PyObject *Mesh_transform( BPy_Mesh *self, PyObject *args, PyObject *kwd )
-{
- Mesh *mesh = self->mesh;
- MVert *mvert;
- /*PyObject *pymat = NULL;*/
- MatrixObject *bpymat=NULL;
- int i, recalc_normals = 0, selected_only = 0;
-
- static char *kwlist[] = {"matrix", "recalc_normals", "selected_only", NULL};
-
- if( !PyArg_ParseTupleAndKeywords(args, kwd, "|O!ii", kwlist,
- &matrix_Type, &bpymat, &recalc_normals, &selected_only) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "matrix must be a 4x4 transformation matrix\n"
- "for example as returned by object.matrixWorld\n"
- "and optionaly keyword bools, recalc_normals and selected_only\n");
- }
-
- if (!bpymat)
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "the first argument must be a matrix or\n"
- "matrix passed as a keyword argument\n");
-
-
- /*bpymat = ( MatrixObject * ) pymat;*/
-
- if( bpymat->colSize != 4 || bpymat->rowSize != 4 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "matrix must be a 4x4 transformation matrix\n"
- "for example as returned by object.getMatrix()" );
-
- /* loop through all the verts and transform by the supplied matrix */
- mvert = mesh->mvert;
- if (selected_only) {
- for( i = 0; i < mesh->totvert; i++, mvert++ ) {
- if (mvert->flag & SELECT) {
- Mat4MulVecfl( (float(*)[4])*bpymat->matrix, mvert->co );
- }
- }
- } else {
- for( i = 0; i < mesh->totvert; i++, mvert++ ) {
- Mat4MulVecfl( (float(*)[4])*bpymat->matrix, mvert->co );
- }
- }
-
- if( recalc_normals ) {
- /* loop through all the verts and transform normals by the inverse
- * of the transpose of the supplied matrix */
- float invmat[4][4], vec[3], nx, ny, nz;
-
- /*
- * we only need to invert a 3x3 submatrix, because the 4th component of
- * affine vectors is 0, but Mat4Invert reports non invertible matrices
- */
-
- if (!Mat4Invert((float(*)[4])*invmat, (float(*)[4])*bpymat->matrix))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "given matrix is not invertible");
-
- /*
- * since normal is stored as shorts, convert to float
- */
-
- mvert = mesh->mvert;
- for( i = 0; i < mesh->totvert; i++, mvert++ ) {
- nx= vec[0] = (float)(mvert->no[0] / 32767.0);
- ny= vec[1] = (float)(mvert->no[1] / 32767.0);
- nz= vec[2] = (float)(mvert->no[2] / 32767.0);
- vec[0] = nx*invmat[0][0] + ny*invmat[0][1] + nz*invmat[0][2];
- vec[1] = nx*invmat[1][0] + ny*invmat[1][1] + nz*invmat[1][2];
- vec[2] = nx*invmat[2][0] + ny*invmat[2][1] + nz*invmat[2][2];
- Normalize( vec );
- mvert->no[0] = (short)(vec[0] * 32767.0);
- mvert->no[1] = (short)(vec[1] * 32767.0);
- mvert->no[2] = (short)(vec[2] * 32767.0);
- }
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * value )
-{
- char *groupStr = PyString_AsString(value);
- struct Object *object;
-
- if( !groupStr )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- object = ( ( BPy_Mesh * ) self )->object;
-
- if( object == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh not linked to an object" );
-
- /* add_defgroup_name clamps the name to 32, make sure that dosnt change */
- add_defgroup_name( object, groupStr );
-
- EXPP_allqueue( REDRAWBUTSALL, 1 );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_removeVertGroup( PyObject * self, PyObject * value )
-{
- char *groupStr = PyString_AsString(value);
- struct Object *object;
- int nIndex;
- bDeformGroup *pGroup;
-
- if( G.obedit )
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "can't use removeVertGroup() while in edit mode" );
-
- if( !groupStr )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if( ( ( BPy_Mesh * ) self )->object == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first..." );
-
- object = ( ( BPy_Mesh * ) self )->object;
-
- pGroup = get_named_vertexgroup( object, groupStr );
- if( pGroup == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "group does not exist!" );
-
- nIndex = get_defgroup_num( object, pGroup );
- if( nIndex == -1 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no deform groups assigned to mesh" );
- nIndex++;
- object->actdef = (unsigned short)nIndex;
-
- del_defgroup_in_object_mode( object );
-
- EXPP_allqueue( REDRAWBUTSALL, 1 );
-
- Py_RETURN_NONE;
-}
-
-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);
-
-static PyObject *Mesh_assignVertsToGroup( BPy_Mesh * self, PyObject * args )
-{
- char *groupStr;
- int nIndex;
- bDeformGroup *pGroup;
- PyObject *listObject;
- int tempInt;
- int x;
- int assignmode = WEIGHT_REPLACE;
- float weight = 1.0;
- Object *object = self->object;
- Mesh *mesh = self->mesh;
-
- if( !object )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first" );
-
- if( ((Mesh *)object->data) != mesh )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object no longer linked to this mesh" );
-
- if( !PyArg_ParseTuple ( args, "sO!fi", &groupStr, &PyList_Type,
- &listObject, &weight, &assignmode) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string, list, float, string arguments" );
- }
-
- pGroup = get_named_vertexgroup( object, groupStr );
- if( pGroup == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "group does not exist!" );
-
- nIndex = get_defgroup_num( object, pGroup );
- if( nIndex == -1 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no deform groups assigned to mesh" );
-
-
- if( assignmode != WEIGHT_REPLACE && assignmode != WEIGHT_ADD &&
- assignmode != WEIGHT_SUBTRACT )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "bad assignment mode" );
-
- /* makes a set of dVerts corresponding to the mVerts */
- if( !mesh->dvert )
- create_dverts( &mesh->id );
-
- /* loop list adding verts to group */
- for( x = 0; x < PyList_Size( listObject ); x++ ) {
- if( !PyArg_Parse ( PyList_GetItem( listObject, x ), "i", &tempInt ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "python list integer not parseable" );
-
- if( tempInt < 0 || tempInt >= mesh->totvert )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "bad vertex index in list" );
-
- add_vert_defnr( object, nIndex, tempInt, weight, assignmode );
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_removeVertsFromGroup( BPy_Mesh * self, PyObject * args )
-{
- /* not passing a list will remove all verts from group */
-
- char *groupStr;
- int nIndex;
- Object *object;
- Mesh *mesh;
- bDeformGroup *pGroup;
- PyObject *listObject = NULL;
- int tempInt;
- int i;
-
- object = self->object;
- mesh = self->mesh;
- if( !object )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first" );
-
- if( ((Mesh *)object->data) != mesh )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object no longer linked to this mesh" );
-
- if( !PyArg_ParseTuple
- ( args, "s|O!", &groupStr, &PyList_Type, &listObject ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string and optional list argument" );
-
- if( !mesh->dvert )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "this mesh contains no deform vertices" );
-
- pGroup = get_named_vertexgroup( object, groupStr );
- if( pGroup == NULL )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "group does not exist!" );
-
- nIndex = get_defgroup_num( object, pGroup );
- if( nIndex == -1 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "no deform groups assigned to mesh" );
-
- /* get out of edit mode */
-
- if( G.obedit ) {
- load_editMesh();
- free_editMesh(G.editMesh);
- G.obedit = NULL;
- }
-
- if( !listObject ) /* no list given */
- for( i = 0; i < mesh->totvert; i++ )
- remove_vert_def_nr( object, nIndex, i );
- else /* loop list removing verts to group */
- for( i = 0; i < PyList_Size( listObject ); i++ ) {
- if( !PyArg_Parse( PyList_GetItem( listObject, i ), "i", &tempInt ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "python list integer not parseable" );
-
- if( tempInt < 0 || tempInt >= mesh->totvert )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "bad vertex index in list" );
-
- remove_vert_def_nr( object, nIndex, tempInt );
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_getVertsFromGroup( BPy_Mesh* self, PyObject * args )
-{
- /*
- * not passing a list will return all verts from group
- * passing indecies not part of the group will not return data in pyList
- * can be used as a index/group check for a vertex
- */
-
- char *groupStr;
- int nIndex;
- bDeformGroup *pGroup;
- MDeformVert *dvert;
- int i, k, count;
- PyObject *vertexList;
- Object *object;
- Mesh *mesh;
-
- int num = 0;
- int weightRet = 0;
- PyObject *listObject = NULL;
-
- object = self->object;
- mesh = self->mesh;
- if( !object )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first" );
-
- if( ((Mesh *)object->data) != mesh )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object no longer linked to this mesh" );
-
- if( !PyArg_ParseTuple( args, "s|iO!", &groupStr, &weightRet,
- &PyList_Type, &listObject ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string and optional int and list arguments" );
-
- if( weightRet < 0 || weightRet > 1 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "return weights flag must be 0 or 1" );
-
- if( !mesh->dvert )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "this mesh contains no deform vertices" );
-
- pGroup = get_named_vertexgroup( object, groupStr );
- if( !pGroup )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "group does not exist!" );
-
- nIndex = get_defgroup_num( object, pGroup );
- if( nIndex == -1 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no deform groups assigned to mesh" );
-
- count = 0;
-
- if( !listObject ) { /* do entire group */
- vertexList = PyList_New( mesh->totvert );
- if( !vertexList )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "getVertsFromGroup: can't create pylist!" );
-
- dvert = mesh->dvert;
- for( num = 0; num < mesh->totvert; num++, ++dvert ) {
- for( i = 0; i < dvert->totweight; i++ ) {
- if( dvert->dw[i].def_nr == nIndex ) {
- PyObject *attr;
- if( weightRet )
- attr = Py_BuildValue( "(i,f)", num,
- dvert->dw[i].weight );
- else
- attr = PyInt_FromLong ( num );
- PyList_SetItem( vertexList, count, attr );
- count++;
- }
- }
- }
-
- if (count < mesh->totvert)
- PyList_SetSlice(vertexList, count, mesh->totvert, NULL);
-
- } else { /* do individual vertices */
- int listObjectLen = PyList_Size( listObject );
-
- vertexList = PyList_New( listObjectLen );
- for( i = 0; i < listObjectLen; i++ ) {
- PyObject *attr = NULL;
-
- num = PyInt_AsLong( PyList_GetItem( listObject, i ) );
- if (num == -1) {/* -1 is an error AND an invalid range, we dont care which */
- Py_DECREF(vertexList);
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "python list integer not parseable" );
- }
-
- if( num < 0 || num >= mesh->totvert ) {
- Py_DECREF(vertexList);
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "bad vertex index in list" );
- }
- dvert = mesh->dvert + num;
- for( k = 0; k < dvert->totweight; k++ ) {
- if( dvert->dw[k].def_nr == nIndex ) {
- if( weightRet )
- attr = Py_BuildValue( "(i,f)", num,
- dvert->dw[k].weight );
- else
- attr = PyInt_FromLong ( num );
- PyList_SetItem( vertexList, count, attr );
- count++;
- }
- }
- }
- if (count < listObjectLen)
- PyList_SetSlice(vertexList, count, listObjectLen, NULL);
- }
-
- return vertexList;
-}
-
-static PyObject *Mesh_renameVertGroup( BPy_Mesh * self, PyObject * args )
-{
- char *oldGr = NULL;
- char *newGr = NULL;
- bDeformGroup *defGroup;
- Object *object;
- Mesh *mesh;
-
- object = self->object;
- mesh = self->mesh;
- if( !object )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first" );
-
- if( ((Mesh *)object->data) != mesh )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object no longer linked to this mesh" );
-
- if( !PyArg_ParseTuple( args, "ss", &oldGr, &newGr ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected two string arguments" );
-
- defGroup = get_named_vertexgroup( object, oldGr );
- if( !defGroup )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't find the vertex group" );
-
- PyOS_snprintf( defGroup->name, 32, newGr );
- unique_vertexgroup_name( defGroup, object );
-
- Py_RETURN_NONE;
-}
-
-
-
-
-static PyObject *Mesh_getVertGroupNames( BPy_Mesh * self )
-{
- bDeformGroup *defGroup;
- PyObject *list;
- Object *obj = self->object;
- Mesh *mesh = self->mesh;
- int count;
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first" );
-
- if( ((Mesh *)obj->data) != mesh )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object no longer linked to this mesh" );
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This mesh must be linked to an object" );
-
- count = 0;
- for( defGroup = obj->defbase.first; defGroup; defGroup = defGroup->next )
- ++count;
-
- list = PyList_New( count );
- count = 0;
- for( defGroup = obj->defbase.first; defGroup; defGroup = defGroup->next )
- PyList_SET_ITEM( list, count++,
- PyString_FromString( defGroup->name ) );
-
- return list;
-}
-
-static PyObject *Mesh_getVertexInfluences( BPy_Mesh * self, PyObject * args )
-{
- int index;
- PyObject *influence_list = NULL;
- Object *object = self->object;
- Mesh *me = self->mesh;
-
- /* Get a reference to the mesh object wrapped in here. */
- if( !object )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This mesh must be linked to an object" );
-
- /* Parse the parameters: only on integer (vertex index) */
- if( !PyArg_ParseTuple( args, "i", &index ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument (index of the vertex)" );
-
- /* check for valid index */
- if( index < 0 || index >= me->totvert )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "vertex index out of range" );
-
- influence_list = PyList_New( 0 );
-
- /* Proceed only if we have vertex deformation information */
- if( me->dvert ) {
- int i;
- MDeformWeight *sweight = NULL;
-
- /* Number of bones influencing the vertex */
- int totinfluences = me->dvert[index].totweight;
-
- /* Get the reference of the first weight structure */
- sweight = me->dvert[index].dw;
-
- /* Build the list only with weights and names of the influent bones */
- for( i = 0; i < totinfluences; i++, sweight++ ) {
- bDeformGroup *defgroup = BLI_findlink( &object->defbase,
- sweight->def_nr );
- if( defgroup )
- PyList_Append( influence_list, Py_BuildValue( "[sf]",
- defgroup->name, sweight->weight ) );
- }
- }
-
- return influence_list;
-}
-
-static PyObject *Mesh_removeAllKeys( BPy_Mesh * self )
-{
- Mesh *mesh = self->mesh;
-
- if( !mesh || !mesh->key )
- Py_RETURN_FALSE;
-
- mesh->key->id.us--;
- mesh->key = NULL;
-
- Py_RETURN_TRUE;
-}
-
-
-static PyObject *Mesh_insertKey( BPy_Mesh * self, PyObject * args )
-{
- Mesh *mesh = self->mesh;
- int fra = -1, oldfra = -1;
- char *type = NULL;
- short typenum;
-
- if (mesh->mr)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Shape Keys cannot be added to meshes with multires" );
-
- if( !PyArg_ParseTuple( args, "|is", &fra, &type ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or an int and optionally a string as arguments" );
-
- if( !type || !strcmp( type, "relative" ) )
- typenum = 1;
- else if( !strcmp( type, "absolute" ) )
- typenum = 2;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "if given, type should be 'relative' or 'absolute'" );
-
- if( fra > 0 ) {
- fra = EXPP_ClampInt( fra, 1, MAXFRAME );
- oldfra = G.scene->r.cfra;
- G.scene->r.cfra = fra;
- }
-
- insert_meshkey( mesh, typenum );
- allspace(REMAKEIPO, 0);
-
- if( fra > 0 )
- G.scene->r.cfra = oldfra;
-
- Py_RETURN_NONE;
-}
-
-
-
-
-/* Custom Data Layers */
-
-static PyObject * Mesh_addCustomLayer_internal(Mesh *me, PyObject * args, int type)
-{
- char *name = NULL;
- CustomData *data = &me->fdata;
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string or nothing" );
-
- if (strlen(name)>31)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, maximum name length is 31" );
-
- if (name)
- CustomData_add_layer_named(data, type, CD_DEFAULT,
- NULL, me->totface, name);
- else
- CustomData_add_layer(data, type, CD_DEFAULT,
- NULL, me->totface);
- mesh_update_customdata_pointers(me);
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_addUVLayer( BPy_Mesh * self, PyObject * args )
-{
- return Mesh_addCustomLayer_internal(self->mesh, args, CD_MTFACE);
-}
-
-static PyObject *Mesh_addColorLayer( BPy_Mesh * self, PyObject * args )
-{
- return Mesh_addCustomLayer_internal(self->mesh, args, CD_MCOL);
-}
-
-static PyObject *Mesh_removeLayer_internal( BPy_Mesh * self, PyObject * value, int type )
-{
- Mesh *me = self->mesh;
- CustomData *data = &me->fdata;
- char *name = PyString_AsString(value);
- int i;
-
- if( !name )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if (strlen(name)>31)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, maximum name length is 31" );
-
- i = CustomData_get_named_layer_index(data, type, name);
-
- if (i==-1)
- return EXPP_ReturnPyObjError(PyExc_ValueError,
- "No matching layers to remove" );
-
- CustomData_free_layer(data, type, me->totface, i);
- mesh_update_customdata_pointers(me);
-
- /* No more Color or UV layers left ?
- switch modes if this is the active object */
- if (!CustomData_has_layer(data, type)) {
- if (me == get_mesh(OBACT)) {
- if(type == CD_MCOL && (G.f & G_VERTEXPAINT))
- G.f &= ~G_VERTEXPAINT; /* get out of vertexpaint mode */
- if(type == CD_MTFACE && (G.f & G_FACESELECT))
- G.f |= ~G_FACESELECT; /* get out of faceselect mode */
- }
- }
-
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Mesh_removeUVLayer( BPy_Mesh * self, PyObject * value )
-{
- return Mesh_removeLayer_internal(self, value, CD_MTFACE);
-}
-
-static PyObject *Mesh_removeColorLayer( BPy_Mesh * self, PyObject * value )
-{
- return Mesh_removeLayer_internal(self, value, CD_MCOL);
-}
-
-
-static PyObject *Mesh_renameLayer_internal( BPy_Mesh * self, PyObject * args, int type )
-{
- CustomData *data;
- CustomDataLayer *layer;
- Mesh *mesh = self->mesh;
- int i;
- char *name_from, *name_to;
-
- data = &mesh->fdata;
-
- if( !PyArg_ParseTuple( args, "ss", &name_from, &name_to ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 2 strings" );
-
- if (strlen(name_from)>31 || strlen(name_to)>31)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "error, maximum name length is 31" );
-
- i = CustomData_get_named_layer_index(data, type, name_from);
-
- if (i==-1)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "layer name was not found" );
-
- layer = &data->layers[i];
- strcpy(layer->name, name_to); /* we alredy know the string sizes are under 32 */
- CustomData_set_layer_unique_name(data, i);
- Py_RETURN_NONE;
-}
-
-static PyObject *Mesh_renameUVLayer( BPy_Mesh * self, PyObject * args )
-{
- return Mesh_renameLayer_internal( self, args, CD_MTFACE );
-}
-
-static PyObject *Mesh_renameColorLayer( BPy_Mesh * self, PyObject * args )
-{
- return Mesh_renameLayer_internal( self, args, CD_MCOL );
-}
-
-
-static PyObject *Mesh_getLayerNames_internal( BPy_Mesh * self, int type )
-{
- CustomData *data;
- CustomDataLayer *layer;
- PyObject *str, *list = PyList_New( 0 );
- Mesh *mesh = self->mesh;
- int i;
- data = &mesh->fdata;
-
- /* see if there is a duplicate */
- for(i=0; i<data->totlayer; i++) {
- layer = &data->layers[i];
- if(layer->type == type) {
- str = PyString_FromString(layer->name);
- PyList_Append( list, str );
- Py_DECREF(str);
- }
- }
- return list;
-}
-
-static PyObject *Mesh_getUVLayerNames( BPy_Mesh * self )
-{
- return Mesh_getLayerNames_internal(self, CD_MTFACE);
-}
-
-static PyObject *Mesh_getColorLayerNames( BPy_Mesh * self )
-{
- return Mesh_getLayerNames_internal(self, CD_MCOL);
-}
-/* used by activeUVLayer and activeColorLayer attrs */
-static PyObject *Mesh_getActiveLayer( BPy_Mesh * self, void *type )
-{
- CustomData *data = &self->mesh->fdata;
- int layer_type = (int)type;
- int i;
- if (layer_type < 0) { /* hack, if negative, its the renderlayer.*/
- layer_type = -layer_type;
- i = CustomData_get_render_layer_index(data, layer_type);
- } else {
- i = CustomData_get_active_layer_index(data, layer_type);
- }
- if (i == -1) /* so -1 is for no active layer 0+ for an active layer */
- Py_RETURN_NONE;
- else {
- return PyString_FromString( data->layers[i].name);
- }
-}
-
-static int Mesh_setActiveLayer( BPy_Mesh * self, PyObject * value, void *type )
-{
- CustomData *data = &self->mesh->fdata;
- char *name;
- int i,ok,n,layer_type = (int)type, render=0;
-
- if( !PyString_Check( value ) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected a string argument" );
-
- if (layer_type<0) {
- layer_type = -layer_type;
- render = 1;
- }
-
- name = PyString_AsString( value );
- ok = 0;
- n = 0;
- for(i=0; i < data->totlayer; ++i) {
- if(data->layers[i].type == layer_type) {
- if (strcmp(data->layers[i].name, name)==0) {
- ok = 1;
- break;
- }
- n++;
- }
- }
-
- if (!ok)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "layer name does not exist" );
- if (render) {
- CustomData_set_layer_render(data, layer_type, n);
- } else {
- CustomData_set_layer_active(data, layer_type, n);
- mesh_update_customdata_pointers(self->mesh);
- }
- return 0;
-}
-
-
-/* multires */
-static PyObject *Mesh_getMultiresLevelCount( BPy_Mesh * self )
-{
- int i;
- if (!self->mesh->mr)
- i=0;
- else
- i= self->mesh->mr->level_count;
-
- return PyInt_FromLong(i);
-}
-
-
-static PyObject *Mesh_getMultires( BPy_Mesh * self, void *type )
-{
- int i=0;
- if (self->mesh->mr) {
- switch ((int)type) {
- case MESH_MULTIRES_LEVEL:
- i = self->mesh->mr->newlvl;
- break;
- case MESH_MULTIRES_EDGE:
- i = self->mesh->mr->edgelvl;
- break;
- case MESH_MULTIRES_PIN:
- i = self->mesh->mr->pinlvl;
- break;
- case MESH_MULTIRES_RENDER:
- i = self->mesh->mr->renderlvl;
- break;
- }
- }
-
- return PyInt_FromLong(i);
-}
-
-static int Mesh_setMultires( BPy_Mesh * self, PyObject *value, void *type )
-{
- int i;
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- if (!self->object)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This mesh must be linked to an object" );
-
- if (!self->mesh->mr)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "the mesh has no multires data" );
-
- if (!self->mesh->mr->level_count)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "multires data has no levels added" );
-
- i = PyInt_AsLong(value);
-
- if (i<1||i>self->mesh->mr->level_count)
- return EXPP_ReturnIntError( PyExc_TypeError,
- "value out of range" );
-
- switch ((int)type) {
- case MESH_MULTIRES_LEVEL:
- self->mesh->mr->newlvl = i;
- multires_set_level(self->object, self->mesh, 0);
- break;
- case MESH_MULTIRES_EDGE:
- self->mesh->mr->edgelvl = i;
- multires_edge_level_update(self->object, self->mesh);
- break;
- case MESH_MULTIRES_PIN:
- self->mesh->mr->pinlvl = i;
- break;
- case MESH_MULTIRES_RENDER:
- self->mesh->mr->renderlvl = i;
- break;
- }
-
- return 0;
-}
-
-/* end multires */
-
-
-static PyObject *Mesh_Tools( BPy_Mesh * self, int type, void **args )
-{
- Base *base;
- int result;
- Object *object = NULL;
- PyObject *attr = NULL;
-
- /* if already in edit mode, exit */
-
- if( G.obedit )
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "can't use mesh tools while in edit mode" );
-
- for( base = FIRSTBASE; base; base = base->next ) {
- if( base->object->type == OB_MESH &&
- base->object->data == self->mesh ) {
- object = base->object;
- break;
- }
- }
- if( !object )
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "can't find an object for the mesh" );
-
- if( object->type != OB_MESH )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Object specified is not a mesh." );
-
- /* make mesh's object active, enter mesh edit mode */
- G.obedit = object;
- make_editMesh();
-
- /* apply operation, then exit edit mode */
- switch( type ) {
- case MESH_TOOL_TOSPHERE:
- vertices_to_sphere();
- break;
- case MESH_TOOL_VERTEXSMOOTH:
- vertexsmooth();
- break;
- case MESH_TOOL_FLIPNORM:
- /* would be simple to rewrite this to not use edit mesh */
- /* see flipface() */
- flip_editnormals();
- break;
- case MESH_TOOL_SUBDIV:
- esubdivideflag( 1, 0.0, *((int *)args[0]), 1, 0 );
- break;
- case MESH_TOOL_REMDOUB:
- result = removedoublesflag( 1, 0, *((float *)args[0]) );
-
- attr = PyInt_FromLong( result );
- if( !attr )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyInt_FromLong() failed" );
- break;
- case MESH_TOOL_FILL:
- fill_mesh();
- break;
- case MESH_TOOL_RECALCNORM:
- righthandfaces( *((int *)args[0]) );
- break;
- case MESH_TOOL_TRI2QUAD:
- join_triangles();
- break;
- case MESH_TOOL_QUAD2TRI:
- convert_to_triface( *((int *)args[0]) );
- break;
- }
-
- /* exit edit mode, free edit mesh */
- load_editMesh();
- free_editMesh(G.editMesh);
-
- if(G.f & G_FACESELECT)
- EXPP_allqueue( REDRAWIMAGE, 0 );
- if(G.f & G_WEIGHTPAINT)
- mesh_octree_table(G.obedit, NULL, 'e');
- G.obedit = NULL;
-
- DAG_object_flush_update(G.scene, object, OB_RECALC_DATA);
-
- if( attr )
- return attr;
-
- Py_RETURN_NONE;
-}
-
-/*
- * "Subdivide" function
- */
-
-static PyObject *Mesh_subdivide( BPy_Mesh * self, PyObject * args )
-{
- int beauty = 0;
- void *params = &beauty;
-
- if( !PyArg_ParseTuple( args, "|i", &beauty ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or an int argument" );
-
- return Mesh_Tools( self, MESH_TOOL_SUBDIV, &params );
-}
-
-/*
- * "Smooth" function
- */
-
-static PyObject *Mesh_smooth( BPy_Mesh * self )
-{
- return Mesh_Tools( self, MESH_TOOL_VERTEXSMOOTH, NULL );
-}
-
-/*
- * "Remove doubles" function
- */
-
-static PyObject *Mesh_removeDoubles( BPy_Mesh * self, PyObject *args )
-{
- float limit;
- void *params = &limit;
-
- if( !PyArg_ParseTuple( args, "f", &limit ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- limit = EXPP_ClampFloat( limit, 0.0f, 1.0f );
-
- return Mesh_Tools( self, MESH_TOOL_REMDOUB, &params );
-}
-
-/*
- * "recalc normals" function
- */
-
-static PyObject *Mesh_recalcNormals( BPy_Mesh * self, PyObject *args )
-{
- int direction = 0;
- void *params = &direction;
-
- if( !PyArg_ParseTuple( args, "|i", &direction ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or an int in range [0,1]" );
-
- if( direction < 0 || direction > 1 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected int in range [0,1]" );
-
- /* righthandfaces(1) = outward, righthandfaces(2) = inward */
- ++direction;
-
- return Mesh_Tools( self, MESH_TOOL_RECALCNORM, &params );
-}
-
-/*
- * "Quads to Triangles" function
- */
-
-static PyObject *Mesh_quad2tri( BPy_Mesh * self, PyObject *args )
-{
- int kind = 0;
- void *params = &kind;
-
- if( !PyArg_ParseTuple( args, "|i", &kind ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or an int in range [0,1]" );
-
- if( kind < 0 || kind > 1 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected int in range [0,1]" );
-
- return Mesh_Tools( self, MESH_TOOL_QUAD2TRI, &params );
-}
-
-/*
- * "Triangles to Quads" function
- */
-
-static PyObject *Mesh_tri2quad( BPy_Mesh * self )
-{
- return Mesh_Tools( self, MESH_TOOL_TRI2QUAD, NULL );
-}
-
-/*
- * "Flip normals" function
- */
-
-static PyObject *Mesh_flipNormals( BPy_Mesh * self )
-{
- return Mesh_Tools( self, MESH_TOOL_FLIPNORM, NULL );
-}
-
-/*
- * "To sphere" function
- */
-
-static PyObject *Mesh_toSphere( BPy_Mesh * self )
-{
- return Mesh_Tools( self, MESH_TOOL_TOSPHERE, NULL );
-}
-
-/*
- * "Fill" (scan fill) function
- */
-
-static PyObject *Mesh_fill( BPy_Mesh * self )
-{
- return Mesh_Tools( self, MESH_TOOL_FILL, NULL );
-}
-
-
-/*
- * "pointInside" function
- */
-/* Warning - this is ordered - need to test both orders to be sure */
-#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 short pointInside_internal(float *vec, float *v1, float *v2, float *v3 )
-{
- float z,w1,w2,w3,wtot;
-
-
- if (vec[2] > MAX3(v1[2], v2[2], v3[2]))
- return 0;
-
- /* need to test both orders */
- if (!POINT_IN_TRI(vec, v1,v2,v3) && !POINT_IN_TRI(vec, v3,v2,v1))
- return 0;
-
- w1= AreaF2Dfl(vec, v2, v3);
- w2= AreaF2Dfl(v1, vec, v3);
- w3= AreaF2Dfl(v1, v2, vec);
- wtot = w1+w2+w3;
- w1/=wtot; w2/=wtot; w3/=wtot;
- z =((v1[2] * w1) +
- (v2[2] * w2) +
- (v3[2] * w3));
-
- /* only return true if the face is above vec*/
- if (vec[2] < z )
- return 1;
-
- return 0;
-}
-
-static PyObject *Mesh_pointInside( BPy_Mesh * self, PyObject * args, PyObject *kwd )
-{
- Mesh *mesh = self->mesh;
- MFace *mf = mesh->mface;
- MVert *mvert = mesh->mvert;
- int i;
- int isect_count=0;
- int selected_only = 0;
- VectorObject *vec;
- static char *kwlist[] = {"point", "selected_only", NULL};
-
- if( !PyArg_ParseTupleAndKeywords(args, kwd, "|O!i", kwlist,
- &vector_Type, &vec, &selected_only) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a vector and an optional bool argument");
- }
-
- if(vec->size < 3)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Mesh.pointInside(vec) expects a 3D vector object\n");
-
- for( i = 0; i < mesh->totface; mf++, i++ ) {
- if (!selected_only || mf->flag & ME_FACE_SEL) {
- if (pointInside_internal(vec->vec, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co)) {
- isect_count++;
- } else if (mf->v4 && pointInside_internal(vec->vec,mvert[mf->v1].co, mvert[mf->v3].co, mvert[mf->v4].co)) {
-
- isect_count++;
- }
- }
- }
-
- if (isect_count % 2)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-
-/*
- * "__copy__" return a copy of the mesh
- */
-
-static PyObject *Mesh_copy( BPy_Mesh * self )
-{
- BPy_Mesh *obj;
-
- obj = (BPy_Mesh *)PyObject_NEW( BPy_Mesh, &Mesh_Type );
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyObject_New() failed" );
-
- obj->mesh = copy_mesh( self->mesh );
- obj->mesh->id.us= 0;
- obj->object = NULL;
- obj->new = 1;
- return (PyObject *)obj;
-}
-
-
-static struct PyMethodDef BPy_Mesh_methods[] = {
- {"calcNormals", (PyCFunction)Mesh_calcNormals, METH_NOARGS,
- "all recalculate vertex normals"},
- {"vertexShade", (PyCFunction)Mesh_vertexShade, METH_VARARGS,
- "color vertices based on the current lighting setup"},
- {"findEdges", (PyCFunction)Mesh_findEdges, METH_VARARGS,
- "find indices of an multiple edges in the mesh"},
- {"getFromObject", (PyCFunction)Mesh_getFromObject, METH_VARARGS,
- "Get a mesh by name"},
- {"update", (PyCFunction)Mesh_Update, METH_VARARGS | METH_KEYWORDS,
- "Update display lists after changes to mesh"},
- {"transform", (PyCFunction)Mesh_transform, METH_VARARGS | METH_KEYWORDS,
- "Applies a transformation matrix to mesh's vertices"},
- {"addVertGroup", (PyCFunction)Mesh_addVertGroup, METH_O,
- "Assign vertex group name to the object linked to the mesh"},
- {"removeVertGroup", (PyCFunction)Mesh_removeVertGroup, METH_O,
- "Delete vertex group name from the object linked to the mesh"},
- {"assignVertsToGroup", (PyCFunction)Mesh_assignVertsToGroup, METH_VARARGS,
- "Assigns vertices to a vertex group"},
- {"removeVertsFromGroup", (PyCFunction)Mesh_removeVertsFromGroup, METH_VARARGS,
- "Removes vertices from a vertex group"},
- {"getVertsFromGroup", (PyCFunction)Mesh_getVertsFromGroup, METH_VARARGS,
- "Get index and optional weight for vertices in vertex group"},
- {"renameVertGroup", (PyCFunction)Mesh_renameVertGroup, METH_VARARGS,
- "Rename an existing vertex group"},
- {"getVertGroupNames", (PyCFunction)Mesh_getVertGroupNames, METH_NOARGS,
- "Get names of vertex groups"},
- {"getVertexInfluences", (PyCFunction)Mesh_getVertexInfluences, METH_VARARGS,
- "Get list of the influences of bones for a given mesh vertex"},
- /* Shape Keys */
- {"removeAllKeys", (PyCFunction)Mesh_removeAllKeys, METH_NOARGS,
- "Remove all the shape keys from a mesh"},
- {"insertKey", (PyCFunction)Mesh_insertKey, METH_VARARGS,
- "(frame = None, type = 'relative') - inserts a Mesh key at the given frame"},
- /* Mesh tools */
- {"smooth", (PyCFunction)Mesh_smooth, METH_NOARGS,
- "Flattens angle of selected faces (experimental)"},
- {"flipNormals", (PyCFunction)Mesh_flipNormals, METH_NOARGS,
- "Toggles the direction of selected face's normals (experimental)"},
- {"toSphere", (PyCFunction)Mesh_toSphere, METH_NOARGS,
- "Moves selected vertices outward in a spherical shape (experimental)"},
- {"fill", (PyCFunction)Mesh_fill, METH_NOARGS,
- "Scan fill a closed edge loop (experimental)"},
- {"triangleToQuad", (PyCFunction)Mesh_tri2quad, METH_VARARGS,
- "Convert selected triangles to quads (experimental)"},
- {"quadToTriangle", (PyCFunction)Mesh_quad2tri, METH_VARARGS,
- "Convert selected quads to triangles (experimental)"},
- {"subdivide", (PyCFunction)Mesh_subdivide, METH_VARARGS,
- "Subdivide selected edges in a mesh (experimental)"},
- {"remDoubles", (PyCFunction)Mesh_removeDoubles, METH_VARARGS,
- "Removes duplicates from selected vertices (experimental)"},
- {"recalcNormals", (PyCFunction)Mesh_recalcNormals, METH_VARARGS,
- "Recalculates inside or outside normals (experimental)"},
- {"pointInside", (PyCFunction)Mesh_pointInside, METH_VARARGS|METH_KEYWORDS,
- "Recalculates inside or outside normals (experimental)"},
-
- /* mesh custom data layers */
- {"addUVLayer", (PyCFunction)Mesh_addUVLayer, METH_VARARGS,
- "adds a UV layer to this mesh"},
- {"addColorLayer", (PyCFunction)Mesh_addColorLayer, METH_VARARGS,
- "adds a color layer to this mesh "},
- {"removeUVLayer", (PyCFunction)Mesh_removeUVLayer, METH_O,
- "removes a UV layer to this mesh"},
- {"removeColorLayer", (PyCFunction)Mesh_removeColorLayer, METH_O,
- "removes a color layer to this mesh"},
- {"getUVLayerNames", (PyCFunction)Mesh_getUVLayerNames, METH_NOARGS,
- "Get names of UV layers"},
- {"getColorLayerNames", (PyCFunction)Mesh_getColorLayerNames, METH_NOARGS,
- "Get names of Color layers"},
- {"renameUVLayer", (PyCFunction)Mesh_renameUVLayer, METH_VARARGS,
- "Rename a UV Layer"},
- {"renameColorLayer", (PyCFunction)Mesh_renameColorLayer, METH_VARARGS,
- "Rename a Color Layer"},
-
- /* python standard class functions */
- {"__copy__", (PyCFunction)Mesh_copy, METH_NOARGS,
- "Return a copy of the mesh"},
- {"copy", (PyCFunction)Mesh_copy, METH_NOARGS,
- "Return a copy of the mesh"},
- {NULL, NULL, 0, NULL}
-};
-
-/************************************************************************
- *
- * Python BPy_Mesh attributes
- *
- ************************************************************************/
-
-static PyObject *MVertSeq_CreatePyObject( Mesh * mesh )
-{
-
- BPy_MVertSeq *obj = PyObject_NEW( BPy_MVertSeq, &MVertSeq_Type);
- obj->mesh = mesh;
-
- /*
- an iter of -1 means this seq has not been used as an iterator yet
- once it is, then any other calls on getIter will return a new copy of BPy_MVertSeq
- This means you can loop do nested loops with the same iterator without worrying about
- the iter variable being used twice and messing up the loops.
- */
- obj->iter = -1;
- return (PyObject *)obj;
-}
-
-static PyObject *Mesh_getVerts( BPy_Mesh * self )
-{
- return MVertSeq_CreatePyObject(self->mesh);
-}
-
-static int Mesh_setVerts( BPy_Mesh * self, PyObject * args )
-{
- MVert *dst;
- MVert *src;
- int i;
-
- /* special case if None: delete the mesh */
- if( args == NULL || args == Py_None ) {
- Mesh *me = self->mesh;
- free_mesh( me );
- me->mvert = NULL; me->medge = NULL; me->mface = NULL;
- me->mtface = NULL; me->dvert = NULL; me->mcol = NULL;
- me->msticky = NULL; me->mat = NULL; me->bb = NULL; me->mselect = NULL;
- me->totvert = me->totedge = me->totface = me->totcol = 0;
- mesh_update( me );
- return 0;
- }
-
- if( PyList_Check( args ) ) {
- if( EXPP_check_sequence_consistency( args, &MVert_Type ) != 1 &&
- EXPP_check_sequence_consistency( args, &PVert_Type ) != 1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list of MVerts" );
-
- if( PyList_Size( args ) != self->mesh->totvert )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "list must have the same number of vertices as the mesh" );
-
- dst = self->mesh->mvert;
- for( i = 0; i < PyList_Size( args ); ++i ) {
- BPy_MVert *v = (BPy_MVert *)PyList_GET_ITEM( args, i );
-
- if( BPy_MVert_Check( v ) )
- src = &((Mesh *)v->data)->mvert[v->index];
- else
- src = (MVert *)v->data;
-
- memcpy( dst, src, sizeof(MVert) );
- ++dst;
- }
- } else if( args->ob_type == &MVertSeq_Type ) {
- Mesh *mesh = ( (BPy_MVertSeq *) args)->mesh;
-
- if( mesh->totvert != self->mesh->totvert )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "vertex sequences must have the same number of vertices" );
-
- memcpy( self->mesh->mvert, mesh->mvert, mesh->totvert*sizeof(MVert) );
- } else
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list or sequence of MVerts" );
- return 0;
-}
-
-static PyObject *MEdgeSeq_CreatePyObject( Mesh *mesh )
-{
- BPy_MEdgeSeq *obj = PyObject_NEW( BPy_MEdgeSeq, &MEdgeSeq_Type);
- obj->mesh = mesh;
- obj->iter = -1; /* iterator not yet used */
- return (PyObject *)obj;
-}
-
-static PyObject *Mesh_getEdges( BPy_Mesh * self )
-{
- return MEdgeSeq_CreatePyObject(self->mesh);
-}
-
-static PyObject *MFaceSeq_CreatePyObject( Mesh * mesh )
-{
- BPy_MFaceSeq *obj= PyObject_NEW( BPy_MFaceSeq, &MFaceSeq_Type);
- obj->mesh = mesh;
- obj->iter = -1; /* iterator not yet used */
- return (PyObject *)obj;
-}
-
-static PyObject *Mesh_getFaces( BPy_Mesh * self )
-{
- return MFaceSeq_CreatePyObject( self->mesh );
-}
-
-static PyObject *Mesh_getMaterials( BPy_Mesh *self )
-{
- return EXPP_PyList_fromMaterialList( self->mesh->mat,
- self->mesh->totcol, 1 );
-}
-
-static int Mesh_setMaterials( BPy_Mesh *self, PyObject * value )
-{
- Material **matlist;
- int len;
-
- if( !PySequence_Check( value ) ||
- !EXPP_check_sequence_consistency( value, &Material_Type ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "list should only contain materials or None)" );
-
- len = PyList_Size( value );
- if( len > 16 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "list can't have more than 16 materials" );
-
- /* free old material list (if it exists) and adjust user counts */
- if( self->mesh->mat ) {
- Mesh *me = self->mesh;
- int i;
- for( i = me->totcol; i-- > 0; )
- if( me->mat[i] )
- me->mat[i]->id.us--;
- MEM_freeN( me->mat );
- }
-
- /* build the new material list, increment user count, store it */
-
- matlist = EXPP_newMaterialList_fromPyList( value );
- EXPP_incr_mats_us( matlist, len );
- self->mesh->mat = matlist;
- self->mesh->totcol = (short)len;
-
-/**@ This is another ugly fix due to the weird material handling of blender.
- * it makes sure that object material lists get updated (by their length)
- * according to their data material lists, otherwise blender crashes.
- * It just stupidly runs through all objects...BAD BAD BAD.
- */
-
- test_object_materials( ( ID * ) self->mesh );
-
- return 0;
-}
-
-static PyObject *Mesh_getMaxSmoothAngle( BPy_Mesh * self )
-{
- return PyInt_FromLong( self->mesh->smoothresh );
-}
-
-static int Mesh_setMaxSmoothAngle( BPy_Mesh *self, PyObject *value )
-{
- return EXPP_setIValueClamped( value, &self->mesh->smoothresh,
- MESH_SMOOTHRESH_MIN,
- MESH_SMOOTHRESH_MAX, 'h' );
-}
-
-static PyObject *Mesh_getSubDivLevels( BPy_Mesh * self )
-{
- return Py_BuildValue( "(h,h)",
- self->mesh->subdiv, self->mesh->subdivr );
-}
-
-static int Mesh_setSubDivLevels( BPy_Mesh *self, PyObject *value )
-{
- int subdiv[2];
- int i;
- PyObject *tmp;
-
- if( !PyTuple_Check( value ) || PyTuple_Size( value ) != 2 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected (int, int) as argument" );
-
- for( i = 0; i < 2; i++ ) {
- tmp = PyTuple_GET_ITEM( value, i );
- if( !PyInt_Check( tmp ) )
- return EXPP_ReturnIntError ( PyExc_TypeError,
- "expected a list [int, int] as argument" );
- subdiv[i] = EXPP_ClampInt( PyInt_AsLong( tmp ),
- MESH_SUBDIV_MIN,
- MESH_SUBDIV_MAX );
- }
-
- self->mesh->subdiv = (short)subdiv[0];
- self->mesh->subdivr = (short)subdiv[1];
- return 0;
-}
-
-static PyObject *Mesh_getFlag( BPy_Mesh * self, void *type )
-{
- switch( (long)type ) {
- case MESH_HASFACEUV:
- return self->mesh->mtface ? EXPP_incr_ret_True() :
- EXPP_incr_ret_False();
- case MESH_HASMCOL:
- return self->mesh->mcol ? EXPP_incr_ret_True() :
- EXPP_incr_ret_False();
- case MESH_HASVERTUV:
- return self->mesh->msticky ? EXPP_incr_ret_True() :
- EXPP_incr_ret_False();
- case MESH_HASMULTIRES:
- return self->mesh->mr ? EXPP_incr_ret_True() :
- EXPP_incr_ret_False();
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get attribute" );
- }
-}
-
-static int Mesh_setFlag( BPy_Mesh * self, PyObject *value, void *type )
-{
- int param;
- Mesh *mesh = self->mesh;
-
- param = PyObject_IsTrue( value );
-
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- /* sticky is independent of faceUV and vertUV */
-
- switch( (long)type ) {
- case MESH_HASFACEUV:
- if( !param ) {
- if( mesh->mtface ) {
- CustomData_free_layers( &mesh->fdata, CD_MTFACE, mesh->totface );
- mesh->mtface = NULL;
- }
- } else if( !mesh->mtface ) {
- if( !mesh->totface )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "mesh has no faces" );
- make_tfaces( mesh );
- }
- return 0;
- case MESH_HASMCOL:
- if( !param ) {
- if( mesh->mcol ) {
- CustomData_free_layers( &mesh->fdata, CD_MCOL, mesh->totface );
- mesh->mcol = NULL;
- }
- } else if( !mesh->mcol ) {
- /* TODO: mesh_create_shadedColors */
- mesh->mcol = CustomData_add_layer( &mesh->fdata, CD_MCOL,
- CD_DEFAULT, NULL, mesh->totface );
- }
- return 0;
- case MESH_HASVERTUV:
- if( !param ) {
- if( mesh->msticky ) {
- CustomData_free_layer_active( &mesh->vdata, CD_MSTICKY, mesh->totvert );
- mesh->msticky = NULL;
- }
- } else {
- if( !mesh->msticky ) {
- mesh->msticky = CustomData_add_layer( &mesh->vdata, CD_MSTICKY,
- CD_CALLOC, NULL, mesh->totvert );
- memset( mesh->msticky, 255, mesh->totvert*sizeof( MSticky ) );
- /* TODO: rework RE_make_sticky() so we can calculate */
- }
- }
- return 0;
- case MESH_HASMULTIRES:
- if (!self->object)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This mesh must be linked to an object" );
-
- if( !param ) {
- if ( mesh->mr ) {
- multires_delete(self->object, mesh);
- }
- } else {
- if ( !mesh->mr ) {
- if (mesh->key)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "Cannot enable multires for a mesh with shape keys" );
- multires_make(self->object, mesh);
- }
- }
- return 0;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "couldn't get attribute" );
- }
-}
-
-static PyObject *Mesh_getMode( BPy_Mesh * self )
-{
- return PyInt_FromLong( self->mesh->flag );
-}
-
-static int Mesh_setMode( BPy_Mesh *self, PyObject *value )
-{
- short param;
- static short bitmask = ME_ISDONE | ME_NOPUNOFLIP | ME_TWOSIDED |
- ME_UVEFFECT | ME_VCOLEFFECT | ME_AUTOSMOOTH | ME_SMESH |
- ME_SUBSURF | ME_OPT_EDGES;
-
- if( !PyInt_Check ( value ) ) {
- char errstr[128];
- sprintf ( errstr , "expected int bitmask of 0x%04x", bitmask );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
- param = (short)PyInt_AS_LONG ( value );
-
- if( ( param & bitmask ) != param )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid bit(s) set in mask" );
-
- self->mesh->flag = param;
-
- return 0;
-}
-
-static PyObject *Mesh_getKey( BPy_Mesh * self )
-{
- if( self->mesh->key )
- return Key_CreatePyObject(self->mesh->key);
- else
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Mesh_getActiveFace( BPy_Mesh * self )
-{
- /* not needed but keep incase exceptions make use of it */
- if( !self->mesh->mtface )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "face has no texture values" );
-
- if (self->mesh->act_face != -1 && self->mesh->act_face <= self->mesh->totface)
- return PyInt_FromLong( self->mesh->act_face );
-
- Py_RETURN_NONE;
-}
-
-static int Mesh_setActiveFace( BPy_Mesh * self, PyObject * value )
-{
- int param;
-
- /* if no texture faces, error */
-
- if( !self->mesh->mtface )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "face has no texture values" );
-
- /* if param isn't an int, error */
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an int argument" );
-
- /* check for a valid index */
-
- param = PyInt_AsLong( value );
- if( param < 0 || param > self->mesh->totface )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "face index out of range" );
-
- self->mesh->act_face = param;
- return 0;
-}
-
-static PyObject *Mesh_getActiveGroup( BPy_Mesh * self )
-{
- bDeformGroup *defGroup;
- Object *object = self->object;
-
- if( !object )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This mesh must be linked to an object" );
-
- if( object->actdef ) {
- defGroup = BLI_findlink( &object->defbase, object->actdef-1 );
- return PyString_FromString( defGroup->name );
- }
-
- Py_RETURN_NONE;
-}
-
-static int Mesh_setActiveGroup( BPy_Mesh * self, PyObject * arg )
-{
- char *name;
- int tmp;
- Object *object = self->object;
-
- if( !object )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This mesh must be linked to an object" );
-
- if( !PyString_Check( arg ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected a string argument" );
-
- name = PyString_AsString( arg );
- tmp = object->actdef;
- vertexgroup_select_by_name( object, name );
- if( !object->actdef ) {
- object->actdef = tmp;
- return EXPP_ReturnIntError( PyExc_ValueError,
- "vertex group not found" );
- }
-
- return 0;
-}
-
-static PyObject *Mesh_getTexMesh( BPy_Mesh * self )
-{
- Mesh *texme= self->mesh->texcomesh;
-
- if (texme)
- return Mesh_CreatePyObject( texme, NULL );
- else
- Py_RETURN_NONE;
-}
-
-static int Mesh_setTexMesh( BPy_Mesh * self, PyObject * value )
-{
- int ret = GenericLib_assignData(value, (void **) &self->mesh->texcomesh, 0, 1, ID_ME, 0);
-
- if (ret==0 && value!=Py_None) /*This must be a mesh type*/
- (( BPy_Mesh * ) value)->new= 0;
-
- return ret;
-}
-
-static int Mesh_setSel( BPy_Mesh * self, PyObject * value )
-{
- int i, param = PyObject_IsTrue( value );
- Mesh *me = self->mesh;
- MVert *mvert = me->mvert;
- MEdge *medge = me->medge;
- MFace *mface = me->mface;
-
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if( param ) {
- for( i = 0; i < me->totvert; ++mvert, ++i )
- mvert->flag |= SELECT;
- for( i = 0; i < me->totedge; ++medge, ++i )
- medge->flag |= SELECT;
- for( i = 0; i < me->totface; ++mface, ++i )
- mface->flag |= ME_FACE_SEL;
- } else {
- for( i = 0; i < me->totvert; ++mvert, ++i )
- mvert->flag &= ~SELECT;
- for( i = 0; i < me->totedge; ++medge, ++i )
- medge->flag &= ~SELECT;
- for( i = 0; i < me->totface; ++mface, ++i )
- mface->flag &= ~ME_FACE_SEL;
- }
-
- return 0;
-}
-
-static int Mesh_setHide( BPy_Mesh * self, PyObject * value )
-{
- int i, param = PyObject_IsTrue( value );
- Mesh *me = self->mesh;
- MVert *mvert = me->mvert;
- MEdge *medge = me->medge;
- MFace *mface = me->mface;
-
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if( param ) {
- for( i = 0; i < me->totvert; ++mvert, ++i )
- mvert->flag |= ME_HIDE;
- for( i = 0; i < me->totedge; ++medge, ++i )
- medge->flag |= ME_HIDE;
- for( i = 0; i < me->totface; ++mface, ++i )
- mface->flag |= ME_HIDE;
- } else {
- for( i = 0; i < me->totvert; ++mvert, ++i )
- mvert->flag &= ~ME_HIDE;
- for( i = 0; i < me->totedge; ++medge, ++i )
- medge->flag &= ~ME_HIDE;
- for( i = 0; i < me->totface; ++mface, ++i )
- mface->flag &= ~ME_HIDE;
- }
-
- return 0;
-}
-
-/************************************************************************
- *
- * Python Mesh_Type standard operations
- *
- ************************************************************************/
-
-static void Mesh_dealloc( BPy_Mesh * self )
-{
- Mesh *mesh = self->mesh;
-
- /* if the mesh is new and has no users, delete it */
- if( self->new && !mesh->id.us )
- free_libblock( &G.main->mesh, mesh );
-
- PyObject_DEL( self );
-}
-
-static int Mesh_compare( BPy_Mesh * a, BPy_Mesh * b )
-{
- return ( a->mesh == b->mesh ) ? 0 : -1;
-}
-
-static PyObject *Mesh_repr( BPy_Mesh * self )
-{
- return PyString_FromFormat( "[Mesh \"%s\"]",
- self->mesh->id.name + 2 );
-}
-
-/*****************************************************************************/
-/* Python Mesh_Type attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Mesh_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"verts",
- (getter)Mesh_getVerts, (setter)Mesh_setVerts,
- "The mesh's vertices (MVert)",
- NULL},
- {"edges",
- (getter)Mesh_getEdges, (setter)NULL,
- "The mesh's edge data (MEdge)",
- NULL},
- {"faces",
- (getter)Mesh_getFaces, (setter)NULL,
- "The mesh's face data (MFace)",
- NULL},
- {"materials",
- (getter)Mesh_getMaterials, (setter)Mesh_setMaterials,
- "List of the mesh's materials",
- NULL},
- {"degr",
- (getter)Mesh_getMaxSmoothAngle, (setter)Mesh_setMaxSmoothAngle,
- "The max angle for auto smoothing",
- NULL},
- {"maxSmoothAngle",
- (getter)Mesh_getMaxSmoothAngle, (setter)Mesh_setMaxSmoothAngle,
- "deprecated: see 'degr'",
- NULL},
- {"subDivLevels",
- (getter)Mesh_getSubDivLevels, (setter)Mesh_setSubDivLevels,
- "The display and rendering subdivision levels",
- NULL},
- {"mode",
- (getter)Mesh_getMode, (setter)Mesh_setMode,
- "The mesh's mode bitfield",
- NULL},
- {"key",
- (getter)Mesh_getKey, (setter)NULL,
- "The mesh's key",
- NULL},
- {"faceUV",
- (getter)Mesh_getFlag, (setter)Mesh_setFlag,
- "UV-mapped textured faces enabled",
- (void *)MESH_HASFACEUV},
- {"vertexColors",
- (getter)Mesh_getFlag, (setter)Mesh_setFlag,
- "Vertex colors for the mesh enabled",
- (void *)MESH_HASMCOL},
- {"vertexUV",
- (getter)Mesh_getFlag, (setter)Mesh_setFlag,
- "'Sticky' flag for per vertex UV coordinates enabled",
- (void *)MESH_HASVERTUV},
- {"multires",
- (getter)Mesh_getFlag, (setter)Mesh_setFlag,
- "'Sticky' flag for per vertex UV coordinates enabled",
- (void *)MESH_HASMULTIRES},
- {"activeFace",
- (getter)Mesh_getActiveFace, (setter)Mesh_setActiveFace,
- "Index of the mesh's active texture face (in UV editor)",
- NULL},
- {"activeGroup",
- (getter)Mesh_getActiveGroup, (setter)Mesh_setActiveGroup,
- "Active group for the mesh",
- NULL},
-
- /* uv layers */
- {"activeColorLayer",
- (getter)Mesh_getActiveLayer, (setter)Mesh_setActiveLayer,
- "Name of the active UV layer",
- (void *)CD_MCOL},
- {"activeUVLayer",
- (getter)Mesh_getActiveLayer, (setter)Mesh_setActiveLayer,
- "Name of the active vertex color layer",
- (void *)CD_MTFACE},
- /* hack flip CD_MCOL so it uses the render setting */
- {"renderColorLayer",
- (getter)Mesh_getActiveLayer, (setter)Mesh_setActiveLayer,
- "Name of the render UV layer",
- (void *)-CD_MCOL},
- {"renderUVLayer",
- (getter)Mesh_getActiveLayer, (setter)Mesh_setActiveLayer,
- "Name of the render vertex color layer",
- (void *)-CD_MTFACE},
-
-
-
- /* Multires */
- {"multiresLevelCount",
- (getter)Mesh_getMultiresLevelCount, (setter)NULL,
- "The total number of multires levels",
- NULL},
- {"multiresDrawLevel",
- (getter)Mesh_getMultires, (setter)Mesh_setMultires,
- "The current multires display level",
- (void *)MESH_MULTIRES_LEVEL},
- {"multiresEdgeLevel",
- (getter)Mesh_getMultires, (setter)Mesh_setMultires,
- "The current multires edge level",
- (void *)MESH_MULTIRES_EDGE},
- {"multiresPinLevel",
- (getter)Mesh_getMultires, (setter)Mesh_setMultires,
- "The current multires pin level",
- (void *)MESH_MULTIRES_PIN},
- {"multiresRenderLevel",
- (getter)Mesh_getMultires, (setter)Mesh_setMultires,
- "The current multires render level",
- (void *)MESH_MULTIRES_RENDER},
-
- {"texMesh",
- (getter)Mesh_getTexMesh, (setter)Mesh_setTexMesh,
- "The meshes tex mesh proxy texture coord mesh",
- NULL},
- {"sel",
- (getter)NULL, (setter)Mesh_setSel,
- "Select/deselect all verts, edges, faces in the mesh",
- NULL},
- {"hide",
- (getter)NULL, (setter)Mesh_setHide,
- "Hide/unhide all verts, edges, faces in the mesh",
- NULL},
-
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python Mesh_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Mesh_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Mesh", /* char *tp_name; */
- sizeof( BPy_Mesh ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) Mesh_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) Mesh_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Mesh_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_Mesh_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Mesh_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
-};
-
-/*
- * get one or all mesh data objects
- */
-
-static PyObject *M_Mesh_Get( PyObject * self_unused, PyObject * args )
-{
- char *name = NULL;
- Mesh *mesh = NULL;
- BPy_Mesh* obj;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected zero or one string arguments" );
-
- if( name ) {
- mesh = ( Mesh * ) GetIdFromList( &( G.main->mesh ), name );
-
- if( !mesh ) {
- char error_msg[64];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Mesh \"%s\" not found", name );
- return ( EXPP_ReturnPyObjError
- ( PyExc_NameError, error_msg ) );
- }
- return Mesh_CreatePyObject( mesh, NULL );
- } else { /* () - return a list with all meshes in the scene */
- PyObject *meshlist;
- Link *link;
- int index = 0;
-
- meshlist = PyList_New( BLI_countlist( &( G.main->mesh ) ) );
-
- if( !meshlist )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" );
-
- link = G.main->mesh.first;
- index = 0;
- while( link ) {
- obj = ( BPy_Mesh * ) Mesh_CreatePyObject( ( Mesh * )link, NULL );
- PyList_SetItem( meshlist, index, ( PyObject * ) obj );
- index++;
- link = link->next;
- }
- return meshlist;
- }
-}
-
-/*
- * create a new mesh data object
- */
-
-static PyObject *M_Mesh_New( PyObject * self_unused, PyObject * args )
-{
- char *name = "Mesh";
- Mesh *mesh;
- BPy_Mesh *obj;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or a string as argument" );
-
- obj = (BPy_Mesh *)PyObject_NEW( BPy_Mesh, &Mesh_Type );
-
- if( !obj )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyObject_New() failed" );
-
- mesh = add_mesh(name); /* doesn't return NULL now, but might someday */
-
- if( !mesh ) {
- Py_DECREF ( obj );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "FATAL: could not create mesh object" );
- }
-
- /* Bound box set to null needed because a new mesh is initialized
- with a bounding box of -1 -1 -1 -1 -1 -1
- if its not set to null the bounding box is not re-calculated
- when ob.getBoundBox() is called.*/
- MEM_freeN(mesh->bb);
- mesh->bb= NULL;
-
- mesh->id.us = 0;
-
- obj->mesh = mesh;
- obj->object = NULL;
- obj->new = 1;
- return (PyObject *)obj;
-}
-
-/*
- * creates a new MVert for users to manipulate
- */
-
-static PyObject *M_Mesh_MVert( PyObject * self_unused, PyObject * args )
-{
- int i;
- MVert vert;
-
- /* initialize the new vert's data */
- memset( &vert, 0, sizeof( MVert ) );
-
- /*
- * accept either a 3D vector or tuple of three floats
- */
-
- if( PyTuple_Size ( args ) == 1 ) {
- PyObject *tmp = PyTuple_GET_ITEM( args, 0 );
- if( !VectorObject_Check( tmp ) || ((VectorObject *)tmp)->size != 3 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected three floats or vector of size 3" );
- for( i = 0; i < 3; ++i )
- vert.co[i] = ((VectorObject *)tmp)->vec[i];
- } else if( !PyArg_ParseTuple ( args, "fff",
- &vert.co[0], &vert.co[1], &vert.co[2] ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected three floats or vector of size 3" );
-
- /* make a new MVert from the data */
- return PVert_CreatePyObject( &vert );
-}
-
-static PyObject *M_Mesh_Modes( PyObject * self_unused, PyObject * args )
-{
- int modes = 0;
-
- if( !G.scene ) {
- Py_RETURN_NONE;
- }
-
- if( !PyArg_ParseTuple( args, "|i", &modes ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected optional int as argument" );
-
- if( modes > ( SCE_SELECT_VERTEX | SCE_SELECT_EDGE | SCE_SELECT_FACE ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "value out of range" );
-
- if( modes > 0 )
- G.scene->selectmode = (short)modes;
-
- return PyInt_FromLong( G.scene->selectmode );
-}
-
-static struct PyMethodDef M_Mesh_methods[] = {
- {"New", (PyCFunction)M_Mesh_New, METH_VARARGS,
- "Create a new mesh"},
- {"Get", (PyCFunction)M_Mesh_Get, METH_VARARGS,
- "Get a mesh by name"},
- {"MVert", (PyCFunction)M_Mesh_MVert, METH_VARARGS,
- "Create a new MVert"},
- {"Mode", (PyCFunction)M_Mesh_Modes, METH_VARARGS,
- "Get/set edit selection mode(s)"},
- {NULL, NULL, 0, NULL},
-};
-
-static PyObject *M_Mesh_ModesDict( void )
-{
- PyObject *Modes = PyConstant_New( );
-
- if( Modes ) {
- BPy_constant *d = ( BPy_constant * ) Modes;
-
- PyConstant_Insert( d, "NOVNORMALSFLIP",
- PyInt_FromLong( ME_NOPUNOFLIP ) );
- PyConstant_Insert( d, "TWOSIDED", PyInt_FromLong( ME_TWOSIDED ) );
- PyConstant_Insert( d, "AUTOSMOOTH",
- PyInt_FromLong( ME_AUTOSMOOTH ) );
- }
-
- return Modes;
-}
-
-/* Set constants for face drawing mode -- see drawmesh.c */
-
-static PyObject *M_Mesh_FaceModesDict( void )
-{
- PyObject *FM = PyConstant_New( );
-
- if( FM ) {
- BPy_constant *d = ( BPy_constant * ) FM;
-
- PyConstant_Insert( d, "BILLBOARD",
- PyInt_FromLong( TF_BILLBOARD2 ) );
- PyConstant_Insert( d, "ALL", PyInt_FromLong( 0xffff ) );
- PyConstant_Insert( d, "HALO", PyInt_FromLong( TF_BILLBOARD ) );
- PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( TF_DYNAMIC ) );
- PyConstant_Insert( d, "INVISIBLE", PyInt_FromLong( TF_INVISIBLE ) );
- PyConstant_Insert( d, "LIGHT", PyInt_FromLong( TF_LIGHT ) );
- PyConstant_Insert( d, "OBCOL", PyInt_FromLong( TF_OBCOL ) );
- PyConstant_Insert( d, "SHADOW", PyInt_FromLong( TF_SHADOW ) );
- PyConstant_Insert( d, "TEXT", PyInt_FromLong( TF_BMFONT ) );
- PyConstant_Insert( d, "SHAREDVERT", PyInt_FromLong( TF_SHAREDVERT ) );
- PyConstant_Insert( d, "SHAREDCOL", PyInt_FromLong( TF_SHAREDCOL ) );
- PyConstant_Insert( d, "TEX", PyInt_FromLong( TF_TEX ) );
- PyConstant_Insert( d, "TILES", PyInt_FromLong( TF_TILES ) );
- PyConstant_Insert( d, "TWOSIDE", PyInt_FromLong( TF_TWOSIDE ) );
- }
-
- return FM;
-}
-
-static PyObject *M_Mesh_FaceFlagsDict( void )
-{
- PyObject *FF = PyConstant_New( );
-
- if( FF ) {
- BPy_constant *d = ( BPy_constant * ) FF;
-
- PyConstant_Insert( d, "SELECT", PyInt_FromLong( TF_SELECT ) );
- PyConstant_Insert( d, "HIDE", PyInt_FromLong( TF_HIDE ) );
- PyConstant_Insert( d, "ACTIVE", PyInt_FromLong( TF_ACTIVE ) ); /* deprecated */
- }
-
- return FF;
-}
-
-static PyObject *M_Mesh_FaceTranspModesDict( void )
-{
- PyObject *FTM = PyConstant_New( );
-
- if( FTM ) {
- BPy_constant *d = ( BPy_constant * ) FTM;
-
- PyConstant_Insert( d, "SOLID", PyInt_FromLong( TF_SOLID ) );
- PyConstant_Insert( d, "ADD", PyInt_FromLong( TF_ADD ) );
- PyConstant_Insert( d, "ALPHA", PyInt_FromLong( TF_ALPHA ) );
- PyConstant_Insert( d, "SUB", PyInt_FromLong( TF_SUB ) );
- }
-
- return FTM;
-}
-
-static PyObject *M_Mesh_EdgeFlagsDict( void )
-{
- PyObject *EF = PyConstant_New( );
-
- if( EF ) {
- BPy_constant *d = ( BPy_constant * ) EF;
-
- PyConstant_Insert(d, "SELECT", PyInt_FromLong( SELECT ) );
- PyConstant_Insert(d, "EDGEDRAW", PyInt_FromLong( ME_EDGEDRAW ) );
- PyConstant_Insert(d, "EDGERENDER", PyInt_FromLong( ME_EDGERENDER ) );
- PyConstant_Insert(d, "SEAM", PyInt_FromLong( ME_SEAM ) );
- PyConstant_Insert(d, "FGON", PyInt_FromLong( ME_FGON ) );
- PyConstant_Insert(d, "LOOSE", PyInt_FromLong( ME_LOOSEEDGE ) );
- PyConstant_Insert(d, "SHARP", PyInt_FromLong( ME_SHARP ) );
- }
-
- return EF;
-}
-
-static PyObject *M_Mesh_VertAssignDict( void )
-{
- PyObject *Vert = PyConstant_New( );
- if( Vert ) {
- BPy_constant *d = ( BPy_constant * ) Vert;
- PyConstant_Insert(d, "ADD", PyInt_FromLong(WEIGHT_ADD));
- PyConstant_Insert(d, "REPLACE", PyInt_FromLong(WEIGHT_REPLACE));
- PyConstant_Insert(d, "SUBTRACT", PyInt_FromLong(WEIGHT_SUBTRACT));
- }
- return Vert;
-}
-
-
-static PyObject *M_Mesh_SelectModeDict( void )
-{
- PyObject *Mode = PyConstant_New( );
- if( Mode ) {
- BPy_constant *d = ( BPy_constant * ) Mode;
- PyConstant_Insert(d, "VERTEX", PyInt_FromLong(SCE_SELECT_VERTEX));
- PyConstant_Insert(d, "EDGE", PyInt_FromLong(SCE_SELECT_EDGE));
- PyConstant_Insert(d, "FACE", PyInt_FromLong(SCE_SELECT_FACE));
- }
- return Mode;
-}
-
-static char M_Mesh_doc[] = "The Blender.Mesh submodule";
-
-PyObject *Mesh_Init( void )
-{
- PyObject *submodule;
-
- PyObject *Modes = M_Mesh_ModesDict( );
- PyObject *FaceFlags = M_Mesh_FaceFlagsDict( );
- PyObject *FaceModes = M_Mesh_FaceModesDict( );
- PyObject *FaceTranspModes = M_Mesh_FaceTranspModesDict( );
- PyObject *EdgeFlags = M_Mesh_EdgeFlagsDict( );
- PyObject *AssignModes = M_Mesh_VertAssignDict( );
- PyObject *SelectModes = M_Mesh_SelectModeDict( );
- PyObject *PropertyTypes = M_Mesh_PropertiesTypeDict( );
-
- if( PyType_Ready( &MCol_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &MVert_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &PVert_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &MVertSeq_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &MEdge_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &MEdgeSeq_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &MFace_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &MFaceSeq_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &Mesh_Type ) < 0 )
- return NULL;
-
- submodule =
- Py_InitModule3( "Blender.Mesh", M_Mesh_methods, M_Mesh_doc );
- PyDict_SetItemString( PyModule_GetDict( submodule ),
- "Primitives", MeshPrimitives_Init( ) );
-
- if( Modes )
- PyModule_AddObject( submodule, "Modes", Modes );
- if( FaceFlags )
- PyModule_AddObject( submodule, "FaceFlags", FaceFlags );
- if( FaceModes )
- PyModule_AddObject( submodule, "FaceModes", FaceModes );
- if( FaceTranspModes )
- PyModule_AddObject( submodule, "FaceTranspModes",
- FaceTranspModes );
- if( EdgeFlags )
- PyModule_AddObject( submodule, "EdgeFlags", EdgeFlags );
- if( AssignModes )
- PyModule_AddObject( submodule, "AssignModes", AssignModes );
- if( SelectModes )
- PyModule_AddObject( submodule, "SelectModes", SelectModes );
- if( PropertyTypes )
- PyModule_AddObject( submodule, "PropertyTypes", PropertyTypes );
-
-
-
- return submodule;
-}
-
-/* These are needed by Object.c */
-
-PyObject *Mesh_CreatePyObject( Mesh * me, Object *obj )
-{
- BPy_Mesh *nmesh = PyObject_NEW( BPy_Mesh, &Mesh_Type );
-
- if( !nmesh )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Mesh object" );
-
- nmesh->mesh = me;
- nmesh->object = obj;
- nmesh->new = 0;
- G.totmesh++;
-
- return ( PyObject * ) nmesh;
-}
-
-
-Mesh *Mesh_FromPyObject( PyObject * pyobj, Object *obj )
-{
- BPy_Mesh *blen_obj;
-
- blen_obj = ( BPy_Mesh * ) pyobj;
- if (obj)
- blen_obj->object = obj;
-
- return blen_obj->mesh;
-
-}
diff --git a/source/blender/python/api2_2x/Mesh.h b/source/blender/python/api2_2x/Mesh.h
deleted file mode 100644
index d73c5c5925e..00000000000
--- a/source/blender/python/api2_2x/Mesh.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c
deleted file mode 100644
index 72152bd1a9a..00000000000
--- a/source/blender/python/api2_2x/Metaball.c
+++ /dev/null
@@ -1,1189 +0,0 @@
-/*
- * $Id: Metaball.c 11136 2007-07-01 05:41:23Z 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 *****
- */
-
-#include "Metaball.h" /*This must come first*/
-
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_mball.h"
-#include "BKE_library.h"
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h" /* for quat normal */
-#include "DNA_object_types.h"
-#include "Mathutils.h"
-#include "Material.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-/* for dealing with materials */
-#include "MEM_guardedalloc.h"
-#include "BKE_material.h"
-
-/* checks for the metaelement being removed */
-#define METAELEM_DEL_CHECK_PY(bpy_meta_elem) if (!(bpy_meta_elem->metaelem)) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "Metaball has been removed" ) );
-#define METAELEM_DEL_CHECK_INT(bpy_meta_elem) if (!(bpy_meta_elem->metaelem)) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "Metaball has been removed" ) );
-
-/*****************************************************************************/
-/* Python API function prototypes for the Metaball module. */
-/*****************************************************************************/
-static PyObject *M_Metaball_New( PyObject * self, PyObject * args );
-static PyObject *M_Metaball_Get( 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.Metaball.__doc__ */
-/*****************************************************************************/
-static char M_Metaball_doc[] =
- "The Blender Metaball module\n\n\nMetaballs are primitive shapes\
- such as balls, pipes, boxes and planes,\
- that can join each other to create smooth,\
- organic volumes\n. The shapes themseves are called\
- 'Metaelements' and can be accessed from the Metaball module.";
-
-static char M_Metaball_New_doc[] = "Creates new metaball object data";
-
-static char M_Metaball_Get_doc[] = "Retreives an existing metaball object data";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Metaball module: */
-/*****************************************************************************/
-struct PyMethodDef M_Metaball_methods[] = {
- {"New", M_Metaball_New, METH_VARARGS, M_Metaball_New_doc},
- {"Get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-static PyObject *M_MetaElem_TypesDict( void )
-{
- PyObject *Types = PyConstant_New( );
-
- if( Types ) {
- BPy_constant *d = ( BPy_constant * ) Types;
-
- PyConstant_Insert( d, "BALL", PyInt_FromLong( MB_BALL ) );
- /* PyConstant_Insert( d, "TUBEX", PyInt_FromLong( MB_TUBEX ) ); - DEPRICATED */
- /* PyConstant_Insert( d, "TUBEY", PyInt_FromLong( MB_TUBEY ) ); - DEPRICATED */
- /* PyConstant_Insert( d, "TUBEZ", PyInt_FromLong( MB_TUBEZ ) ); - DEPRICATED */
- PyConstant_Insert( d, "TUBE", PyInt_FromLong( MB_TUBE ) );
- PyConstant_Insert( d, "PLANE", PyInt_FromLong( MB_PLANE ) );
- PyConstant_Insert( d, "ELIPSOID",PyInt_FromLong( MB_ELIPSOID ) );
- PyConstant_Insert( d, "CUBE", PyInt_FromLong( MB_CUBE ) );
- }
-
- return Types;
-}
-
-static PyObject *M_MetaElem_UpdateDict( void )
-{
- PyObject *Update = PyConstant_New( );
-
- if( Update ) {
- BPy_constant *d = ( BPy_constant * ) Update;
- PyConstant_Insert( d, "ALWAYS", PyInt_FromLong( MB_UPDATE_ALWAYS ) );
- PyConstant_Insert( d, "HALFRES",PyInt_FromLong( MB_UPDATE_HALFRES ) );
- PyConstant_Insert( d, "FAST", PyInt_FromLong( MB_UPDATE_FAST ) );
- PyConstant_Insert( d, "NEVER", PyInt_FromLong( MB_UPDATE_NEVER ) );
- }
-
- return Update;
-}
-
-/*****************************************************************************/
-/* Python BPy_Metaball methods declarations: */
-/*****************************************************************************/
-static PyObject *Metaball_getElements( BPy_Metaball * self );
-static PyObject *Metaball_getMaterials( BPy_Metaball * self );
-static int Metaball_setMaterials( BPy_Metaball * self, PyObject * value );
-static PyObject *Metaball_getWiresize( BPy_Metaball * self );
-static int Metaball_setWiresize( BPy_Metaball * self, PyObject * value );
-static PyObject *Metaball_getRendersize( BPy_Metaball * self );
-static int Metaball_setRendersize( BPy_Metaball * self, PyObject * value);
-static PyObject *Metaball_getThresh( BPy_Metaball * self );
-static int Metaball_setThresh( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getUpdate( BPy_Metaball * self );
-static int Metaball_setUpdate( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_copy( BPy_Metaball * self );
-
-/*****************************************************************************/
-/* Python BPy_Metaball methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Metaball_methods[] = {
- /* name, method, flags, doc */
- {"__copy__", ( PyCFunction ) Metaball_copy,
- METH_NOARGS, "() - Return a copy of this metaball"},
- {"copy", ( PyCFunction ) Metaball_copy,
- METH_NOARGS, "() - Return a copy of this metaball"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Metaelem methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Metaelem_methods[] = {
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python Metaball_Type callback function prototypes: */
-/*****************************************************************************/
-static PyObject *Metaball_repr( BPy_Metaball * self );
-static int Metaball_compare( BPy_Metaball * a, BPy_Metaball * b );
-
-/*****************************************************************************/
-/* Python Metaelem_Type callback function prototypes: */
-/*****************************************************************************/
-static void Metaelem_dealloc( BPy_Metaelem * self );
-static PyObject *Metaelem_repr( BPy_Metaelem * self );
-static int Metaelem_compare( BPy_Metaelem * a, BPy_Metaelem * b );
-
-static PyObject *Metaelem_getType( BPy_Metaelem *self );
-static int Metaelem_setType( BPy_Metaelem * self, PyObject * args );
-static PyObject *Metaelem_getCoord( BPy_Metaelem * self );
-static int Metaelem_setCoord( BPy_Metaelem * self, VectorObject * value );
-static PyObject *Metaelem_getDims( BPy_Metaelem * self );
-static int Metaelem_setDims( BPy_Metaelem * self, VectorObject * value );
-static PyObject *Metaelem_getQuat( BPy_Metaelem * self );
-static int Metaelem_setQuat( BPy_Metaelem * self, QuaternionObject * value );
-static PyObject *Metaelem_getStiffness( BPy_Metaelem * self );
-static int Metaelem_setStiffness( BPy_Metaelem * self, PyObject * value );
-static PyObject *Metaelem_getRadius( BPy_Metaelem * self );
-static int Metaelem_setRadius( BPy_Metaelem * self, PyObject * value );
-
-static PyObject *Metaelem_getMFlagBits( BPy_Metaelem * self, void * type );
-static int Metaelem_setMFlagBits( BPy_Metaelem * self, PyObject * value, void * type );
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Metaball_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"materials",
- (getter)Metaball_getMaterials, (setter)Metaball_setMaterials,
- "Number of metaball users",
- NULL},
- {"elements",
- (getter)Metaball_getElements, (setter)NULL,
- "Elements in this metaball",
- NULL},
- {"wiresize",
- (getter)Metaball_getWiresize, (setter)Metaball_setWiresize,
- "The density to draw the metaball in the 3D view",
- NULL},
- {"rendersize",
- (getter)Metaball_getRendersize, (setter)Metaball_setRendersize,
- "The density to render wire",
- NULL},
- {"thresh",
- (getter)Metaball_getThresh, (setter)Metaball_setThresh,
- "The density to render wire",
- NULL},
- {"update",
- (getter)Metaball_getUpdate, (setter)Metaball_setUpdate,
- "The setting for updating this metaball data",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-/*****************************************************************************/
-/* Python TypeMetaball structure definition: */
-/*****************************************************************************/
-PyTypeObject Metaball_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Metaball", /* char *tp_name; */
- sizeof( BPy_Metaball ), /* 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 ) Metaball_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Metaball_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_Metaball_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Metaball_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 PyGetSetDef BPy_Metaelem_getseters[] = {
- {"type",
- (getter)Metaelem_getType, (setter)Metaelem_setType,
- "Metaelem Type",
- NULL},
- {"co",
- (getter)Metaelem_getCoord, (setter)Metaelem_setCoord,
- "Metaelem Location",
- NULL},
- {"quat",
- (getter)Metaelem_getQuat, (setter)Metaelem_setQuat,
- "Metaelem Rotation Quat",
- NULL},
- {"dims",
- (getter)Metaelem_getDims, (setter)Metaelem_setDims,
- "Metaelem Dimensions",
- NULL},
- {"stiffness",
- (getter)Metaelem_getStiffness, (setter)Metaelem_setStiffness,
- "MetaElem stiffness",
- NULL},
- {"radius",
- (getter)Metaelem_getRadius, (setter)Metaelem_setRadius,
- "The radius of the MetaElem",
- NULL},
- {"negative",
- (getter)Metaelem_getMFlagBits, (setter)Metaelem_setMFlagBits,
- "The density to render wire",
- (void *)MB_NEGATIVE},
- {"hide",
- (getter)Metaelem_getMFlagBits, (setter)Metaelem_setMFlagBits,
- "The density to render wire",
- (void *)MB_HIDE},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-/*****************************************************************************/
-/* Python TypeMetaelem structure definition: */
-/*****************************************************************************/
-PyTypeObject Metaelem_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Metaelem", /* char *tp_name; */
- sizeof( BPy_Metaelem ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) Metaelem_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) Metaelem_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Metaelem_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_Metaelem_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Metaelem_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_Metaball_New */
-/* Python equivalent: Blender.Metaball.New */
-/*****************************************************************************/
-static PyObject *M_Metaball_New( PyObject * self, PyObject * args )
-{
- char *name = 0;
- BPy_Metaball *pymball; /* for Data object wrapper in Python */
- MetaBall *blmball; /* for actual Data we create in Blender */
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "Metaball.New() - expected string argument (or nothing)" ) );
-
- /* first create the MetaBall Data in Blender */
- if (name)
- blmball = add_mball( name );
- else
- blmball = add_mball( "Meta" );
-
- if( blmball ) {
- /* return user count to zero since add_mball() incref'ed it */
- blmball->id.us = 0;
- /* now create the wrapper obj in Python */
- pymball =
- ( BPy_Metaball * ) PyObject_NEW( BPy_Metaball,
- &Metaball_Type );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Metaball.New() - couldn't create data in Blender" ) );
-
- if( pymball == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create MetaBall Data object" ) );
-
- pymball->metaball = blmball;
- /*link Python mballer wrapper to Blender MetaBall */
-
- return ( PyObject * ) pymball;
-}
-
-
-/*****************************************************************************/
-/* Function: M_Metaball_Get */
-/* Python equivalent: Blender.Metaball.Get */
-/* Description: Receives a string and returns the metaball data obj */
-/* whose name matches the string. If no argument is */
-/* passed in, a list of all metaball data names in the */
-/* current scene is returned. */
-/*****************************************************************************/
-static PyObject *M_Metaball_Get( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- MetaBall *mball_iter = NULL;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "Metaball.Get() - expected string argument (or nothing)" ) );
-
- if( name ) { /* (name) - Search mball by name */
- mball_iter = ( MetaBall * ) GetIdFromList( &( G.main->mball ), name );
-
- if (!mball_iter) {
- char error_msg[128];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Metaball.Get(\"%s\") - not found", name );
- return ( EXPP_ReturnPyObjError
- ( PyExc_NameError, error_msg ) );
- }
- return Metaball_CreatePyObject(mball_iter);
-
- } else { /* () - return a list of all mballs in the scene */
-
- PyObject *mballlist = PyList_New( BLI_countlist( &( G.main->mball ) ) );
- int index=0;
-
- if( mballlist == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "MetaBall.Get() - couldn't create PyList" ) );
-
- mball_iter = G.main->mball.first;
- while( mball_iter ) {
- PyList_SetItem( mballlist, index, Metaball_CreatePyObject(mball_iter) );
- index++;
- mball_iter = mball_iter->id.next;
- }
- return mballlist;
- }
-
-}
-
-
-/*****************************************************************************/
-/* Function: initObject */
-/*****************************************************************************/
-PyObject *Metaball_Init( void )
-{
- PyObject *submodule;
- PyObject *Types= M_MetaElem_TypesDict( );
- PyObject *Update= M_MetaElem_UpdateDict( );
-
- if( PyType_Ready( &Metaball_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &Metaelem_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &MetaElemSeq_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Metaball", M_Metaball_methods, M_Metaball_doc);
-
- if( Types )
- PyModule_AddObject( submodule, "Types", Types );
- PyModule_AddObject( submodule, "Update", Update );
-
- /*Add SUBMODULES to the module*/
- /*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); */ /*creates a *new* module*/
- return submodule;
-}
-
-MetaBall *Metaball_FromPyObject( PyObject * pyobj )
-{
- return ( ( BPy_Metaball * ) pyobj )->metaball;
-}
-
-static PyObject *Metaball_getMaterials( BPy_Metaball *self )
-{
- return EXPP_PyList_fromMaterialList( self->metaball->mat,
- self->metaball->totcol, 1 );
-}
-static int Metaball_setMaterials( BPy_Metaball *self, PyObject * value )
-{
- Material **matlist;
- int len;
-
- if( !PySequence_Check( value ) ||
- !EXPP_check_sequence_consistency( value, &Material_Type ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaball.materials - list should only contain materials or None)" );
-
- len = PyList_Size( value );
- if( len > 16 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaball.materials - list can't have more than 16 materials" );
-
- /* free old material list (if it exists) and adjust user counts */
- if( self->metaball->mat ) {
- MetaBall *mb = self->metaball;
- int i;
- for( i = mb->totcol; i-- > 0; )
- if( mb->mat[i] )
- mb->mat[i]->id.us--;
- MEM_freeN( mb->mat );
- }
-
- /* build the new material list, increment user count, store it */
-
- matlist = EXPP_newMaterialList_fromPyList( value );
- EXPP_incr_mats_us( matlist, len );
- self->metaball->mat = matlist;
- self->metaball->totcol = (short)len;
-
-/**@ This is another ugly fix due to the weird material handling of blender.
- * it makes sure that object material lists get updated (by their length)
- * according to their data material lists, otherwise blender crashes.
- * It just stupidly runs through all objects...BAD BAD BAD.
- */
-
- test_object_materials( ( ID * ) self->metaball );
-
- return 0;
-}
-
-static PyObject *Metaball_getWiresize( BPy_Metaball * self )
-{
- return PyFloat_FromDouble( self->metaball->wiresize );
-}
-
-static int Metaball_setWiresize( BPy_Metaball * self, PyObject * value )
-{
- float param;
- if( !PyNumber_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaball.wiresize - expected float argument" );
-
- param = (float)PyFloat_AsDouble( value );
-
- self->metaball->wiresize = EXPP_ClampFloat(param, 0.05f, 1.0);
- return 0;
-
-}
-static PyObject *Metaball_getRendersize( BPy_Metaball * self )
-{
- return PyFloat_FromDouble( self->metaball->rendersize );
-}
-
-static int Metaball_setRendersize( BPy_Metaball * self, PyObject * value )
-{
-
- float param;
- if( !PyNumber_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaball.rendersize - expected float argument" );
-
- param = (float)PyFloat_AsDouble( value );
-
- self->metaball->rendersize = EXPP_ClampFloat(param, 0.05f, 1.0);
- return 0;
-}
-
-static PyObject *Metaball_getThresh( BPy_Metaball * self )
-{
- return PyFloat_FromDouble( self->metaball->thresh );
-}
-
-static int Metaball_setThresh( BPy_Metaball * self, PyObject * value )
-{
-
- float param;
- if( !PyNumber_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaball.thresh - expected float argument" );
-
- param = (float)PyFloat_AsDouble( value );
-
- self->metaball->thresh = EXPP_ClampFloat(param, 0.0, 5.0);
- return 0;
-}
-
-static PyObject *Metaball_getUpdate( BPy_Metaball * self )
-{
- return PyInt_FromLong( (long)self->metaball->flag );
-}
-
-static int Metaball_setUpdate( BPy_Metaball * self, PyObject * value )
-{
-
- int param;
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaball.update - expected an int argument" );
-
- param = (int)PyInt_AS_LONG( value );
-
- self->metaball->flag = EXPP_ClampInt( param, 0, 3 );
- return 0;
-}
-
-static PyObject *Metaball_copy( BPy_Metaball * self )
-{
- BPy_Metaball *pymball; /* for Data object wrapper in Python */
- MetaBall *blmball; /* for actual Data we create in Blender */
-
- blmball = copy_mball( self->metaball ); /* first create the MetaBall Data in Blender */
-
- if( blmball ) {
- /* return user count to zero since add_mball() incref'ed it */
- blmball->id.us = 0;
- /* now create the wrapper obj in Python */
- pymball =
- ( BPy_Metaball * ) PyObject_NEW( BPy_Metaball,
- &Metaball_Type );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "metaball.__copy__() - couldn't create data in Blender" ) );
-
- if( pymball == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "metaball.__copy__() - couldn't create data in Blender" ) );
-
- pymball->metaball = blmball;
-
- return ( PyObject * ) pymball;
-}
-
-
-/* These are needed by Object.c */
-PyObject *Metaball_CreatePyObject( MetaBall * mball)
-{
- BPy_Metaball *py_mball= PyObject_NEW( BPy_Metaball, &Metaball_Type );
-
- if( !py_mball )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Metaball object" );
-
- py_mball->metaball= mball;
-
- return ( PyObject * ) py_mball;
-}
-
-
-static PyObject *MetaElemSeq_CreatePyObject(BPy_Metaball *self, MetaElem *iter)
-{
- BPy_MetaElemSeq *seq = PyObject_NEW( BPy_MetaElemSeq, &MetaElemSeq_Type);
- seq->bpymetaball = self; Py_INCREF(self);
- seq->iter= iter;
- return (PyObject *)seq;
-}
-
-/*
- * Element, get an instance of the iterator.
- */
-static PyObject *Metaball_getElements( BPy_Metaball * self )
-{
- return MetaElemSeq_CreatePyObject(self, NULL);
-}
-
-/*
- * Metaelem dealloc - free from memory
- */
-/* This is a callback function for the BPy_Metaelem type. It is */
-static void Metaelem_dealloc( BPy_Metaelem * self )
-{
- self->metaelem= NULL; /* so any references to the same bpyobject will raise an error */
- PyObject_DEL( self );
-}
-
-/*
- * elem.type - int to set the shape of the element
- */
-static PyObject *Metaelem_getType( BPy_Metaelem *self )
-{
- METAELEM_DEL_CHECK_PY(self);
-
- return PyInt_FromLong( self->metaelem->type );
-}
-static int Metaelem_setType( BPy_Metaelem * self, PyObject * value )
-{
- int type;
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaelem.type - expected an integer (bitmask) as argument" );
-
- METAELEM_DEL_CHECK_INT(self);
-
- type = PyInt_AS_LONG( value );
-
- if( (type < 0) || ( type > ( MB_BALL | MB_TUBEX | MB_TUBEY | MB_TUBEZ | MB_TUBE | MB_PLANE | MB_ELIPSOID | MB_CUBE ) ))
- return EXPP_ReturnIntError( PyExc_ValueError,
- "metaelem.type - value out of range" );
-
- self->metaelem->type= type;
- return 0;
-}
-
-/*
- * elem.co - non wrapped vector representing location
- */
-static PyObject *Metaelem_getCoord( BPy_Metaelem * self )
-{
- float co[3];
-
- METAELEM_DEL_CHECK_PY(self);
-
- co[0]= self->metaelem->x;
- co[1]= self->metaelem->y;
- co[2]= self->metaelem->z;
-
- return newVectorObject( co, 3, Py_NEW );
-}
-static int Metaelem_setCoord( BPy_Metaelem * self, VectorObject * value )
-{
-
- if( !VectorObject_Check( value ) || value->size != 3 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaelem.co - expected vector argument of size 3" );
-
- METAELEM_DEL_CHECK_INT(self);
-
- self->metaelem->x= value->vec[0];
- self->metaelem->y= value->vec[1];
- self->metaelem->z= value->vec[2];
- return 0;
-}
-
-/*
- * elem.dims - non wrapped vector representing the xyz dimensions
- * only effects some element types
- */
-static PyObject *Metaelem_getDims( BPy_Metaelem * self )
-{
- float co[3];
- METAELEM_DEL_CHECK_PY(self);
-
- co[0]= self->metaelem->expx;
- co[1]= self->metaelem->expy;
- co[2]= self->metaelem->expz;
- return newVectorObject( co, 3, Py_NEW );
-}
-static int Metaelem_setDims( BPy_Metaelem * self, VectorObject * value )
-{
- if( !VectorObject_Check( value ) || value->size != 3 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaelem.dims - expected vector argument of size 3" );
-
- METAELEM_DEL_CHECK_INT(self);
-
- self->metaelem->expx= EXPP_ClampFloat(value->vec[0], 0.0, 20.0);
- self->metaelem->expy= EXPP_ClampFloat(value->vec[1], 0.0, 20.0);
- self->metaelem->expz= EXPP_ClampFloat(value->vec[2], 0.0, 20.0);
- return 0;
-}
-
-/*
- * elem.quat - non wrapped quat representing the rotation
- * only effects some element types - a rotated ball has no effect for eg.
- */
-static PyObject *Metaelem_getQuat( BPy_Metaelem * self )
-{
- METAELEM_DEL_CHECK_PY(self);
- return newQuaternionObject(self->metaelem->quat, Py_NEW);
-}
-static int Metaelem_setQuat( BPy_Metaelem * self, QuaternionObject * value )
-{
- int i;
- if( !QuaternionObject_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaelem.quat - expected quat argument" );
-
- METAELEM_DEL_CHECK_INT(self);
-
- for (i = 0; i < 4; i++)
- self->metaelem->quat[i]= value->quat[i];
-
- /* need to normalize or metaball drawing can go into an infinate loop */
- NormalQuat(self->metaelem->quat);
-
- return 0;
-}
-
-/*
- * elem.hide and elem.sel - get/set true false
- */
-static PyObject *Metaelem_getMFlagBits( BPy_Metaelem * self, void * type )
-{
- METAELEM_DEL_CHECK_PY(self);
- return EXPP_getBitfield( &(self->metaelem->flag), (int)((long)type ), 'h' );
-}
-static int Metaelem_setMFlagBits( BPy_Metaelem * self, PyObject * value,
- void * type )
-{
- METAELEM_DEL_CHECK_INT(self);
- return EXPP_setBitfield( value, &(self->metaelem->flag),
- (int)((long)type), 'h' );
-}
-
-/*
- * elem.stiffness - floating point, the volume of this element.
- */
-static PyObject *Metaelem_getStiffness( BPy_Metaelem *self )
-{
- METAELEM_DEL_CHECK_PY(self);
- return PyFloat_FromDouble( self->metaelem->s );
-}
-static int Metaelem_setStiffness( BPy_Metaelem *self, PyObject *value)
-{
- if( !PyNumber_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaelem.stiffness - expected float argument" );
-
- self->metaelem->s = EXPP_ClampFloat((float)PyFloat_AsDouble( value ), 0.0, 10.0);
- return 0;
-}
-
-/*
- * elem.radius- floating point, the size if the element
- */
-static PyObject *Metaelem_getRadius( BPy_Metaelem *self )
-{
- METAELEM_DEL_CHECK_PY(self);
- return PyFloat_FromDouble( self->metaelem->rad );
-}
-static int Metaelem_setRadius( BPy_Metaelem *self, PyObject *value)
-{
- if( !PyNumber_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "metaelem.radius - expected float argument" );
-
- self->metaelem->rad = /* is 5000 too small? */
- EXPP_ClampFloat((float)PyFloat_AsDouble( value ), 0.0, 5000.0);
-
- return 0;
-}
-
-
-/*
- * callback functions for comparison.
- * It compares two Metaball_Type objects. Only the "==" and "!="
- * comparisons are meaninful. Returns 0 for equality and -1 if
- * they don't point to the same Blender struct.
- * In Python it becomes 1 if they are equal, 0 otherwise.
- */
-static int Metaball_compare( BPy_Metaball * a, BPy_Metaball * b )
-{
- MetaBall *pa = a->metaball, *pb = b->metaball;
- return ( pa == pb ) ? 0 : -1;
-}
-
-static int MetaElemSeq_compare( BPy_MetaElemSeq * a, BPy_MetaElemSeq * b )
-{
- MetaBall *pa = a->bpymetaball->metaball, *pb = b->bpymetaball->metaball;
- return ( pa == pb ) ? 0 : -1;
-}
-
-static int Metaelem_compare( BPy_Metaelem * a, BPy_Metaelem * b )
-{
- MetaElem *pa = a->metaelem, *pb = b->metaelem;
- return ( pa == pb ) ? 0 : -1;
-}
-
-/*
- * repr function
- * callback functions building meaninful string to representations
- */
-static PyObject *Metaball_repr( BPy_Metaball * self )
-{
- return PyString_FromFormat( "[Metaball \"%s\"]",
- self->metaball->id.name + 2 );
-}
-
-static PyObject *Metaelem_repr( BPy_Metaelem * self )
-{
- return PyString_FromString( "Metaelem" );
-}
-
-static PyObject *MetaElemSeq_repr( BPy_MetaElemSeq * self )
-{
- return PyString_FromFormat( "[Metaball Iterator \"%s\"]",
- self->bpymetaball->metaball->id.name + 2 );
-}
-
-
-
-/*
- * MeteElem Seq sequence
- */
-
-static PyObject *MetaElem_CreatePyObject( MetaElem *metaelem )
-{
- BPy_Metaelem *elem= PyObject_NEW( BPy_Metaelem, &Metaelem_Type);
- elem->metaelem = metaelem; Py_INCREF(elem);
- return (PyObject *)elem;
-}
-
-static int MetaElemSeq_len( BPy_MetaElemSeq * self )
-{
- return BLI_countlist( &( self->bpymetaball->metaball->elems ) );
-}
-
-
-static PySequenceMethods MetaElemSeq_as_sequence = {
- ( inquiry ) MetaElemSeq_len, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) 0, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- 0,0,0,
-};
-
-/************************************************************************
- *
- * Python MetaElemSeq_Type iterator (iterates over Metaballs)
- *
- ************************************************************************/
-
-/*
- * Initialize the interator
- */
-
-static PyObject *MetaElemSeq_getIter( BPy_MetaElemSeq * self )
-{
- if (!self->iter) { /* not alredy looping on this data, */
- self->iter = self->bpymetaball->metaball->elems.first;
- return EXPP_incr_ret ( (PyObject *) self );
- } else
- return MetaElemSeq_CreatePyObject(self->bpymetaball, self->bpymetaball->metaball->elems.first);
-}
-
-/*
- * Return next MetaElem.
- */
-
-static PyObject *MetaElemSeq_nextIter( BPy_MetaElemSeq * self )
-{
- PyObject *object;
- if( !(self->iter) || !(self->bpymetaball->metaball) ) {
- self->iter= NULL;
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- object= MetaElem_CreatePyObject( self->iter );
- self->iter= self->iter->next;
- return object;
-}
-
-/*
- * Adds and returns a new metaelement,
- * no args are taken so the returned metaball must be modified after adding.
- * Accessed as mball.elements.add() where mball is a python metaball data type.
- */
-static PyObject *MetaElemSeq_add( BPy_MetaElemSeq * self )
-{
- MetaElem *ml;
-
- ml = MEM_callocN( sizeof( MetaElem ), "metaelem" );
- BLI_addhead( &( self->bpymetaball->metaball->elems ), ml );
- ml->x = 0;
- ml->y = 0;
- ml->z = 0;
- ml->quat[0]= 1.0;
- ml->quat[1]= 0.0;
- ml->quat[2]= 0.0;
- ml->quat[3]= 0.0;
- ml->rad = 2;
- ml->s = 2.0;
- ml->flag = SELECT;
- ml->type = 0;
- ml->expx = 1;
- ml->expy = 1;
- ml->expz = 1;
- ml->type = MB_BALL;
-
- return MetaElem_CreatePyObject(ml);
-}
-
-
-/*
- * removes a metaelement if it is a part of the metaball,
- * no args are taken so the returned metaball must be modified after adding.
- * Accessed as mball.elements.add() where mball is a python metaball data type.
- */
-static PyObject *MetaElemSeq_remove( BPy_MetaElemSeq * self, BPy_Metaelem *elem )
-{
- MetaElem *ml_iter, *ml_py;
-
- if( !BPy_Metaelem_Check(elem) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "elements.remove(metaelem) - expected a Metaball element" );
-
- METAELEM_DEL_CHECK_PY(elem);
-
- ml_py= elem->metaelem;
-
- for (ml_iter= self->bpymetaball->metaball->elems.first; ml_iter; ml_iter= ml_iter->next) {
- if (ml_py == ml_iter) {
- elem->metaelem= NULL;
- BLI_freelinkN( &(self->bpymetaball->metaball->elems), ml_py);
- Py_RETURN_NONE;
- }
- }
-
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "elements.remove(elem): elem not in meta elements" );
-
-}
-
-static struct PyMethodDef BPy_MetaElemSeq_methods[] = {
- {"add", (PyCFunction)MetaElemSeq_add, METH_NOARGS,
- "add metaelem to metaball data"},
- {"remove", (PyCFunction)MetaElemSeq_remove, METH_O,
- "remove element from metaball data"},
- {NULL, NULL, 0, NULL}
-};
-
-/************************************************************************
- *
- * Python MetaElemSeq_Type standard operations
- *
- ************************************************************************/
-
-static void MetaElemSeq_dealloc( BPy_MetaElemSeq * self )
-{
- Py_DECREF(self->bpymetaball);
- PyObject_DEL( self );
-}
-
-/*****************************************************************************/
-/* Python MetaElemSeq_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject MetaElemSeq_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender MetaElemSeq", /* char *tp_name; */
- sizeof( BPy_MetaElemSeq ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) MetaElemSeq_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) MetaElemSeq_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) MetaElemSeq_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &MetaElemSeq_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) MetaElemSeq_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) MetaElemSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_MetaElemSeq_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
-};
-
diff --git a/source/blender/python/api2_2x/Metaball.h b/source/blender/python/api2_2x/Metaball.h
deleted file mode 100644
index 6be35dbd3fb..00000000000
--- a/source/blender/python/api2_2x/Metaball.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Modifier.c b/source/blender/python/api2_2x/Modifier.c
deleted file mode 100644
index 57f09332c03..00000000000
--- a/source/blender/python/api2_2x/Modifier.c
+++ /dev/null
@@ -1,1693 +0,0 @@
-/*
- * $Id: Modifier.c 12840 2007-12-11 01:58:22Z 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.
- *
- * This is a new part of Blender.
- *
- * Contributor(s): Ken Hughes, Campbell Barton
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-/* TODO, accessing a modifier sequence of a deleted object will crash blender at the moment, not sure how to fix this. */
-
-
-#include "Modifier.h" /*This must come first*/
-
-#include "DNA_object_types.h"
-#include "DNA_effect_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_vec_types.h"
-
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_modifier.h"
-#include "BKE_library.h"
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "MEM_guardedalloc.h"
-#include "butspace.h"
-#include "blendef.h"
-#include "mydevice.h"
-
-#include "Object.h"
-#include "Texture.h"
-#include "Mathutils.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-/* checks for the scene being removed */
-#define MODIFIER_DEL_CHECK_PY(bpy_modifier) if (!(bpy_modifier->md)) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "Modifier has been removed" ) )
-#define MODIFIER_DEL_CHECK_INT(bpy_modifier) if (!(bpy_modifier->md)) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "Modifier has been removed" ) )
-
-enum mod_constants {
- /*Apply to all modifiers*/
- EXPP_MOD_RENDER = 0,
- EXPP_MOD_REALTIME,
- EXPP_MOD_EDITMODE,
- EXPP_MOD_ONCAGE,
-
- /*GENERIC*/
- EXPP_MOD_OBJECT, /*ARMATURE, LATTICE, CURVE, BOOLEAN, ARRAY*/
- EXPP_MOD_VERTGROUP, /*ARMATURE, LATTICE, CURVE, SMOOTH, CAST*/
- EXPP_MOD_LIMIT, /*ARRAY, MIRROR*/
- EXPP_MOD_FLAG, /*MIRROR, WAVE*/
- EXPP_MOD_COUNT, /*DECIMATOR, ARRAY*/
- EXPP_MOD_LENGTH, /*BUILD, ARRAY*/
- EXPP_MOD_FACTOR, /*SMOOTH, CAST*/
- EXPP_MOD_ENABLE_X, /*SMOOTH, CAST*/
- EXPP_MOD_ENABLE_Y, /*SMOOTH, CAST*/
- EXPP_MOD_ENABLE_Z, /*SMOOTH, CAST*/
- EXPP_MOD_TYPES, /*SUBSURF, CAST*/
-
- /*SUBSURF SPECIFIC*/
- EXPP_MOD_LEVELS,
- EXPP_MOD_RENDLEVELS,
- EXPP_MOD_OPTIMAL,
- EXPP_MOD_UV,
-
- /*ARMATURE SPECIFIC*/
- EXPP_MOD_ENVELOPES,
-
- /*ARRAY SPECIFIC*/
- EXPP_MOD_OBJECT_OFFSET,
- EXPP_MOD_OBJECT_CURVE,
- EXPP_MOD_OFFSET_VEC,
- EXPP_MOD_SCALE_VEC,
- EXPP_MOD_MERGE_DIST,
-
- /*BUILD SPECIFIC*/
- EXPP_MOD_START,
- EXPP_MOD_SEED,
- EXPP_MOD_RANDOMIZE,
-
- /*MIRROR SPECIFIC*/
- EXPP_MOD_AXIS_X,
- EXPP_MOD_AXIS_Y,
- EXPP_MOD_AXIS_Z,
-
- /*DECIMATE SPECIFIC*/
- EXPP_MOD_RATIO,
-
- /*WAVE SPECIFIC*/
- EXPP_MOD_STARTX,
- EXPP_MOD_STARTY,
- EXPP_MOD_HEIGHT,
- EXPP_MOD_WIDTH,
- EXPP_MOD_NARROW,
- EXPP_MOD_SPEED,
- EXPP_MOD_DAMP,
- EXPP_MOD_LIFETIME,
- EXPP_MOD_TIMEOFFS,
-
- /*BOOLEAN SPECIFIC*/
- EXPP_MOD_OPERATION,
-
- /*EDGE SPLIT SPECIFIC */
- EXPP_MOD_EDGESPLIT_ANGLE,
- EXPP_MOD_EDGESPLIT_FROM_ANGLE,
- EXPP_MOD_EDGESPLIT_FROM_SHARP,
-
- /* DISPLACE */
- EXPP_MOD_UVLAYER,
- EXPP_MOD_MID_LEVEL,
- EXPP_MOD_STRENGTH,
- EXPP_MOD_TEXTURE,
- EXPP_MOD_MAPPING,
- EXPP_MOD_DIRECTION,
-
- /* SMOOTH */
- EXPP_MOD_REPEAT,
-
- /* CAST */
- EXPP_MOD_RADIUS,
- EXPP_MOD_SIZE,
- EXPP_MOD_USE_OB_TRANSFORM,
- EXPP_MOD_SIZE_FROM_RADIUS
-
- /* yet to be implemented */
- /* EXPP_MOD_HOOK_,*/
- /* , */
-};
-
-/*****************************************************************************/
-/* Python BPy_Modifier methods declarations: */
-/*****************************************************************************/
-static PyObject *Modifier_getName( BPy_Modifier * self );
-static int Modifier_setName( BPy_Modifier * self, PyObject *arg );
-static PyObject *Modifier_getType( BPy_Modifier * self );
-static PyObject *Modifier_reset( BPy_Modifier * self );
-
-static PyObject *Modifier_getData( BPy_Modifier * self, PyObject * key );
-static int Modifier_setData( BPy_Modifier * self, PyObject * key,
- PyObject * value );
-
-/*****************************************************************************/
-/* Python BPy_Modifier methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Modifier_methods[] = {
- /* name, method, flags, doc */
- {"reset", (PyCFunction)Modifier_reset, METH_NOARGS,
- "resets a hook modifier location"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Modifier attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Modifier_getseters[] = {
- {"name",
- (getter)Modifier_getName, (setter)Modifier_setName,
- "Modifier name", NULL},
- {"type",
- (getter)Modifier_getType, (setter)NULL,
- "Modifier type (read only)", NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python Modifier_Type Mapping Methods table: */
-/*****************************************************************************/
-static PyMappingMethods Modifier_as_mapping = {
- NULL, /* mp_length */
- ( binaryfunc ) Modifier_getData, /* mp_subscript */
- ( objobjargproc ) Modifier_setData, /* mp_ass_subscript */
-};
-
-/*****************************************************************************/
-/* Python Modifier_Type callback function prototypes: */
-/*****************************************************************************/
-static PyObject *Modifier_repr( BPy_Modifier * self );
-
-/*****************************************************************************/
-/* Python Modifier_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Modifier_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Modifier", /* char *tp_name; */
- sizeof( BPy_Modifier ), /* 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 ) Modifier_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- NULL, /* PySequenceMethods *tp_as_sequence; */
- &Modifier_as_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 */
- NULL, /* getiterfunc tp_iter; */
- NULL, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_Modifier_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Modifier_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
-};
-
-/*****************************************************************************/
-/* Python BPy_Modifier methods: */
-/*****************************************************************************/
-
-/*
- * return the name of this modifier
- */
-
-static PyObject *Modifier_getName( BPy_Modifier * self )
-{
- MODIFIER_DEL_CHECK_PY(self);
- return PyString_FromString( self->md->name );
-}
-
-/*
- * set the name of this modifier
- */
-
-static int Modifier_setName( BPy_Modifier * self, PyObject * attr )
-{
- char *name = PyString_AsString( attr );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected string arg" );
-
- MODIFIER_DEL_CHECK_INT(self);
-
- BLI_strncpy( self->md->name, name, sizeof( self->md->name ) );
-
- return 0;
-}
-
-/*
- * return the type of this modifier
- */
-
-static PyObject *Modifier_getType( BPy_Modifier * self )
-{
- MODIFIER_DEL_CHECK_PY(self);
-
- return PyInt_FromLong( self->md->type );
-}
-
-static PyObject *subsurf_getter( BPy_Modifier * self, int type )
-{
- SubsurfModifierData *md = ( SubsurfModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_TYPES:
- return PyInt_FromLong( ( long )md->subdivType );
- case EXPP_MOD_LEVELS:
- return PyInt_FromLong( ( long )md->levels );
- case EXPP_MOD_RENDLEVELS:
- return PyInt_FromLong( ( long )md->renderLevels );
- case EXPP_MOD_OPTIMAL:
- return PyBool_FromLong( ( long )
- ( md->flags & eSubsurfModifierFlag_ControlEdges ) ) ;
- case EXPP_MOD_UV:
- return PyBool_FromLong( ( long )
- ( md->flags & eSubsurfModifierFlag_SubsurfUv ) ) ;
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError,
- "key not found" );
- }
-}
-
-static int subsurf_setter( BPy_Modifier * self, int type,
- PyObject *value )
-{
- SubsurfModifierData *md = (SubsurfModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_TYPES:
- return EXPP_setIValueRange( value, &md->subdivType, 0, 1, 'h' );
- case EXPP_MOD_LEVELS:
- return EXPP_setIValueClamped( value, &md->levels, 1, 6, 'h' );
- case EXPP_MOD_RENDLEVELS:
- return EXPP_setIValueClamped( value, &md->renderLevels, 1, 6, 'h' );
- case EXPP_MOD_OPTIMAL:
- return EXPP_setBitfield( value, &md->flags,
- eSubsurfModifierFlag_ControlEdges, 'h' );
- case EXPP_MOD_UV:
- return EXPP_setBitfield( value, &md->flags,
- eSubsurfModifierFlag_SubsurfUv, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *armature_getter( BPy_Modifier * self, int type )
-{
- ArmatureModifierData *md = (ArmatureModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_OBJECT:
- return Object_CreatePyObject( md->object );
- case EXPP_MOD_VERTGROUP:
- return PyBool_FromLong( ( long )( md->deformflag & 1 ) ) ;
- case EXPP_MOD_ENVELOPES:
- return PyBool_FromLong( ( long )( md->deformflag & 2 ) ) ;
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int armature_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- ArmatureModifierData *md = (ArmatureModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_OBJECT:
- return GenericLib_assignData(value, (void **) &md->object, 0, 0, ID_OB, OB_ARMATURE);
- case EXPP_MOD_VERTGROUP:
- return EXPP_setBitfield( value, &md->deformflag, 1, 'h' );
- case EXPP_MOD_ENVELOPES:
- return EXPP_setBitfield( value, &md->deformflag, 2, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *lattice_getter( BPy_Modifier * self, int type )
-{
- LatticeModifierData *md = (LatticeModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_OBJECT:
- return Object_CreatePyObject( md->object );
- case EXPP_MOD_VERTGROUP:
- return PyString_FromString( md->name ) ;
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int lattice_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- LatticeModifierData *md = (LatticeModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_OBJECT:
- return GenericLib_assignData(value, (void **) &md->object, (void **) &self->object, 0, ID_OB, OB_LATTICE);
- case EXPP_MOD_VERTGROUP: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
- BLI_strncpy( md->name, name, sizeof( md->name ) );
- break;
- }
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
- return 0;
-}
-
-static PyObject *curve_getter( BPy_Modifier * self, int type )
-{
- CurveModifierData *md = (CurveModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_OBJECT:
- return Object_CreatePyObject( md->object );
- case EXPP_MOD_VERTGROUP:
- return PyString_FromString( md->name ) ;
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int curve_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- CurveModifierData *md = (CurveModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_OBJECT:
- return GenericLib_assignData(value, (void **) &md->object, (void **) &self->object, 0, ID_OB, OB_CURVE);
- case EXPP_MOD_VERTGROUP: {
- char *name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string arg" );
- BLI_strncpy( md->name, name, sizeof( md->name ) );
- break;
- }
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
- return 0;
-}
-
-static PyObject *build_getter( BPy_Modifier * self, int type )
-{
- BuildModifierData *md = (BuildModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_START:
- return PyFloat_FromDouble( ( float )md->start );
- case EXPP_MOD_LENGTH:
- return PyFloat_FromDouble( ( float )md->length );
- case EXPP_MOD_SEED:
- return PyInt_FromLong( ( long )md->seed );
- case EXPP_MOD_RANDOMIZE:
- return PyBool_FromLong( ( long )md->randomize ) ;
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int build_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- BuildModifierData *md = (BuildModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_START:
- return EXPP_setFloatClamped( value, &md->start, 1.0, MAXFRAMEF );
- case EXPP_MOD_LENGTH:
- return EXPP_setFloatClamped( value, &md->length, 1.0, MAXFRAMEF );
- case EXPP_MOD_SEED:
- return EXPP_setIValueClamped( value, &md->seed, 1, MAXFRAME, 'i' );
- case EXPP_MOD_RANDOMIZE:
- return EXPP_setBitfield( value, &md->randomize, 1, 'i' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *mirror_getter( BPy_Modifier * self, int type )
-{
- MirrorModifierData *md = (MirrorModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_LIMIT:
- return PyFloat_FromDouble( (double)md->tolerance );
- case EXPP_MOD_FLAG:
- return PyBool_FromLong( (long)( md->flag & MOD_MIR_CLIPPING ) ) ;
- case EXPP_MOD_AXIS_X:
- return PyBool_FromLong( ( long )
- ( md->flag & MOD_MIR_AXIS_X ) ) ;
- case EXPP_MOD_AXIS_Y:
- return PyBool_FromLong( ( long )
- ( md->flag & MOD_MIR_AXIS_Y ) ) ;
- case EXPP_MOD_AXIS_Z:
- return PyBool_FromLong( ( long )
- ( md->flag & MOD_MIR_AXIS_Z ) ) ;
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int mirror_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- MirrorModifierData *md = (MirrorModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_LIMIT:
- return EXPP_setFloatClamped( value, &md->tolerance, 0.0, 1.0 );
- case EXPP_MOD_FLAG:
- return EXPP_setBitfield( value, &md->flag, MOD_MIR_CLIPPING, 'i' );
- case EXPP_MOD_AXIS_X:
- return EXPP_setBitfield( value, &md->flag, MOD_MIR_AXIS_X, 'h' );
- case EXPP_MOD_AXIS_Y:
- return EXPP_setBitfield( value, &md->flag, MOD_MIR_AXIS_Y, 'h' );
- case EXPP_MOD_AXIS_Z:
- return EXPP_setBitfield( value, &md->flag, MOD_MIR_AXIS_Z, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *decimate_getter( BPy_Modifier * self, int type )
-{
- DecimateModifierData *md = (DecimateModifierData *)(self->md);
-
- if( type == EXPP_MOD_RATIO )
- return PyFloat_FromDouble( (double)md->percent );
- else if( type == EXPP_MOD_COUNT )
- return PyInt_FromLong( (long)md->faceCount );
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
-}
-
-static int decimate_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- DecimateModifierData *md = (DecimateModifierData *)(self->md);
-
- if( type == EXPP_MOD_RATIO )
- return EXPP_setFloatClamped( value, &md->percent, 0.0, 1.0 );
- else if( type == EXPP_MOD_COUNT )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "value is read-only" );
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
-}
-
-static PyObject *smooth_getter( BPy_Modifier * self, int type )
-{
- SmoothModifierData *md = (SmoothModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_FACTOR:
- return PyFloat_FromDouble( (double)md->fac );
- case EXPP_MOD_REPEAT:
- return PyInt_FromLong( (long)md->repeat );
- case EXPP_MOD_VERTGROUP:
- return PyString_FromString( md->defgrp_name ) ;
- case EXPP_MOD_ENABLE_X:
- return EXPP_getBitfield( &md->flag, MOD_SMOOTH_X, 'h' );
- case EXPP_MOD_ENABLE_Y:
- return EXPP_getBitfield( &md->flag, MOD_SMOOTH_Y, 'h' );
- case EXPP_MOD_ENABLE_Z:
- return EXPP_getBitfield( &md->flag, MOD_SMOOTH_Z, 'h' );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int smooth_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- SmoothModifierData *md = (SmoothModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_FACTOR:
- return EXPP_setFloatClamped( value, &md->fac, -10.0, 10.0 );
- case EXPP_MOD_REPEAT:
- return EXPP_setIValueRange( value, &md->repeat, 0, 30, 'h' );
- case EXPP_MOD_VERTGROUP: {
- char *name = PyString_AsString( value );
- if( !name ) return EXPP_ReturnIntError( PyExc_TypeError, "expected string arg" );
- BLI_strncpy( md->defgrp_name, name, sizeof( md->defgrp_name ) );
- return 0;
- }
- case EXPP_MOD_ENABLE_X:
- return EXPP_setBitfield( value, &md->flag, MOD_SMOOTH_X, 'h' );
- case EXPP_MOD_ENABLE_Y:
- return EXPP_setBitfield( value, &md->flag, MOD_SMOOTH_Y, 'h' );
- case EXPP_MOD_ENABLE_Z:
- return EXPP_setBitfield( value, &md->flag, MOD_SMOOTH_Z, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *cast_getter( BPy_Modifier * self, int type )
-{
- CastModifierData *md = (CastModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_TYPES:
- return PyInt_FromLong( (long)md->type );
- case EXPP_MOD_FACTOR:
- return PyFloat_FromDouble( (double)md->fac );
- case EXPP_MOD_RADIUS:
- return PyFloat_FromDouble( (double)md->radius );
- case EXPP_MOD_SIZE:
- return PyFloat_FromDouble( (double)md->size );
- case EXPP_MOD_OBJECT:
- return Object_CreatePyObject( md->object );
- case EXPP_MOD_VERTGROUP:
- return PyString_FromString( md->defgrp_name ) ;
- case EXPP_MOD_ENABLE_X:
- return EXPP_getBitfield( &md->flag, MOD_CAST_X, 'h' );
- case EXPP_MOD_ENABLE_Y:
- return EXPP_getBitfield( &md->flag, MOD_CAST_Y, 'h' );
- case EXPP_MOD_ENABLE_Z:
- return EXPP_getBitfield( &md->flag, MOD_CAST_Z, 'h' );
- case EXPP_MOD_USE_OB_TRANSFORM:
- return EXPP_getBitfield( &md->flag, MOD_CAST_USE_OB_TRANSFORM, 'h' );
- case EXPP_MOD_SIZE_FROM_RADIUS:
- return EXPP_getBitfield( &md->flag, MOD_CAST_SIZE_FROM_RADIUS, 'h' );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int cast_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- CastModifierData *md = (CastModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_TYPES:
- return EXPP_setIValueRange( value, &md->type, 0, MOD_CAST_TYPE_CUBOID, 'h' );
- case EXPP_MOD_FACTOR:
- return EXPP_setFloatClamped( value, &md->fac, -10.0, 10.0 );
- case EXPP_MOD_RADIUS:
- return EXPP_setFloatClamped( value, &md->radius, 0.0, 100.0 );
- case EXPP_MOD_SIZE:
- return EXPP_setFloatClamped( value, &md->size, 0.0, 100.0 );
- case EXPP_MOD_OBJECT: {
- Object *ob_new=NULL;
- if (value == Py_None) {
- md->object = NULL;
- } else if (BPy_Object_Check( value )) {
- ob_new = ((( BPy_Object * )value)->object);
- md->object = ob_new;
- } else {
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Expected an Object or None value" );
- }
- return 0;
- }
- case EXPP_MOD_VERTGROUP: {
- char *name = PyString_AsString( value );
- if( !name ) return EXPP_ReturnIntError( PyExc_TypeError, "expected string arg" );
- BLI_strncpy( md->defgrp_name, name, sizeof( md->defgrp_name ) );
- return 0;
- }
- case EXPP_MOD_ENABLE_X:
- return EXPP_setBitfield( value, &md->flag, MOD_CAST_X, 'h' );
- case EXPP_MOD_ENABLE_Y:
- return EXPP_setBitfield( value, &md->flag, MOD_CAST_Y, 'h' );
- case EXPP_MOD_ENABLE_Z:
- return EXPP_setBitfield( value, &md->flag, MOD_CAST_Z, 'h' );
- case EXPP_MOD_USE_OB_TRANSFORM:
- return EXPP_setBitfield( value, &md->flag, MOD_CAST_USE_OB_TRANSFORM, 'h' );
- case EXPP_MOD_SIZE_FROM_RADIUS:
- return EXPP_setBitfield( value, &md->flag, MOD_CAST_SIZE_FROM_RADIUS, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *wave_getter( BPy_Modifier * self, int type )
-{
- WaveModifierData *md = (WaveModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_STARTX:
- return PyFloat_FromDouble( (double)md->startx );
- case EXPP_MOD_STARTY:
- return PyFloat_FromDouble( (double)md->starty );
- case EXPP_MOD_HEIGHT:
- return PyFloat_FromDouble( (double)md->height );
- case EXPP_MOD_WIDTH:
- return PyFloat_FromDouble( (double)md->width );
- case EXPP_MOD_NARROW:
- return PyFloat_FromDouble( (double)md->narrow );
- case EXPP_MOD_SPEED:
- return PyFloat_FromDouble( (double)md->speed );
- case EXPP_MOD_DAMP:
- return PyFloat_FromDouble( (double)md->damp );
- case EXPP_MOD_LIFETIME:
- return PyFloat_FromDouble( (double)md->lifetime );
- case EXPP_MOD_TIMEOFFS:
- return PyFloat_FromDouble( (double)md->timeoffs );
- case EXPP_MOD_FLAG:
- return PyInt_FromLong( (long)md->flag );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int wave_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- WaveModifierData *md = (WaveModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_STARTX:
- return EXPP_setFloatClamped( value, &md->startx, -100.0, 100.0 );
- case EXPP_MOD_STARTY:
- return EXPP_setFloatClamped( value, &md->starty, -100.0, 100.0 );
- case EXPP_MOD_HEIGHT:
- return EXPP_setFloatClamped( value, &md->height, -2.0, 2.0 );
- case EXPP_MOD_WIDTH:
- return EXPP_setFloatClamped( value, &md->width, 0.0, 5.0 );
- case EXPP_MOD_NARROW:
- return EXPP_setFloatClamped( value, &md->width, 0.0, 5.0 );
- case EXPP_MOD_SPEED:
- return EXPP_setFloatClamped( value, &md->speed, -2.0, 2.0 );
- case EXPP_MOD_DAMP:
- return EXPP_setFloatClamped( value, &md->damp, -MAXFRAMEF, MAXFRAMEF );
- case EXPP_MOD_LIFETIME:
- return EXPP_setFloatClamped( value, &md->lifetime, -MAXFRAMEF, MAXFRAMEF );
- case EXPP_MOD_TIMEOFFS:
- return EXPP_setFloatClamped( value, &md->timeoffs, -MAXFRAMEF, MAXFRAMEF );
- case EXPP_MOD_FLAG:
- return EXPP_setIValueRange( value, &md->flag, 0,
- MOD_WAVE_X | MOD_WAVE_Y | MOD_WAVE_CYCL, 'h' );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *array_getter( BPy_Modifier * self, int type )
-{
- ArrayModifierData *md = (ArrayModifierData *)(self->md);
-
- if( type == EXPP_MOD_OBJECT_OFFSET )
- return Object_CreatePyObject( md->offset_ob );
- else if( type == EXPP_MOD_OBJECT_CURVE )
- return Object_CreatePyObject( md->curve_ob );
- else if( type == EXPP_MOD_COUNT )
- return PyInt_FromLong( (long)md->count );
- else if( type == EXPP_MOD_LENGTH )
- return PyFloat_FromDouble( md->length );
- else if( type == EXPP_MOD_MERGE_DIST )
- return PyFloat_FromDouble( md->merge_dist );
- else if( type == EXPP_MOD_OFFSET_VEC)
- return newVectorObject( md->offset, 3, Py_NEW );
- else if( type == EXPP_MOD_SCALE_VEC)
- return newVectorObject( md->scale, 3, Py_NEW );
-
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
-}
-
-static int array_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- ArrayModifierData *md = (ArrayModifierData *)(self->md);
- switch( type ) {
- case EXPP_MOD_OBJECT_OFFSET:
- return GenericLib_assignData(value, (void **) &md->offset_ob, (void **) &self->object, 0, ID_OB, 0);
- case EXPP_MOD_OBJECT_CURVE:
- return GenericLib_assignData(value, (void **) &md->curve_ob, 0, 0, ID_OB, OB_CURVE);
- case EXPP_MOD_COUNT:
- return EXPP_setIValueClamped( value, &md->count, 1, 1000, 'i' );
- case EXPP_MOD_LENGTH:
- return EXPP_setFloatClamped( value, &md->length, 0.0, 1000.0 );
- case EXPP_MOD_MERGE_DIST:
- return EXPP_setFloatClamped( value, &md->merge_dist, 0.0, 1000.0 );
- case EXPP_MOD_OFFSET_VEC:
- return EXPP_setVec3Clamped( value, md->offset, -10000.0, 10000.0 );
- case EXPP_MOD_SCALE_VEC:
- return EXPP_setVec3Clamped( value, md->scale, -10000.0, 10000.0 );
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *boolean_getter( BPy_Modifier * self, int type )
-{
- BooleanModifierData *md = (BooleanModifierData *)(self->md);
-
- if( type == EXPP_MOD_OBJECT )
- return Object_CreatePyObject( md->object );
- else if( type == EXPP_MOD_OPERATION )
- return PyInt_FromLong( ( long )md->operation ) ;
-
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
-}
-
-static int boolean_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- BooleanModifierData *md = (BooleanModifierData *)(self->md);
-
- if( type == EXPP_MOD_OBJECT )
- return GenericLib_assignData(value, (void **) &md->object, (void **) &self->object, 0, ID_OB, OB_MESH);
- else if( type == EXPP_MOD_OPERATION )
- return EXPP_setIValueRange( value, &md->operation,
- eBooleanModifierOp_Intersect, eBooleanModifierOp_Difference,
- 'h' );
-
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
-}
-
-
-static PyObject *edgesplit_getter( BPy_Modifier * self, int type )
-{
- EdgeSplitModifierData *md = (EdgeSplitModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_EDGESPLIT_ANGLE:
- return PyFloat_FromDouble( (double)md->split_angle );
- case EXPP_MOD_EDGESPLIT_FROM_ANGLE:
- return PyBool_FromLong( ( long )
- ( md->flags & MOD_EDGESPLIT_FROMANGLE ) ) ;
- case EXPP_MOD_EDGESPLIT_FROM_SHARP:
- return PyBool_FromLong( ( long )
- ( md->flags & MOD_EDGESPLIT_FROMFLAG ) ) ;
-
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int edgesplit_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- EdgeSplitModifierData *md = (EdgeSplitModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_EDGESPLIT_ANGLE:
- return EXPP_setFloatClamped( value, &md->split_angle, 0.0, 180.0 );
- case EXPP_MOD_EDGESPLIT_FROM_ANGLE:
- return EXPP_setBitfield( value, &md->flags,
- MOD_EDGESPLIT_FROMANGLE, 'h' );
- case EXPP_MOD_EDGESPLIT_FROM_SHARP:
- return EXPP_setBitfield( value, &md->flags,
- MOD_EDGESPLIT_FROMFLAG, 'h' );
-
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-static PyObject *displace_getter( BPy_Modifier * self, int type )
-{
- DisplaceModifierData *md = (DisplaceModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_TEXTURE:
- if (md->texture) Texture_CreatePyObject( md->texture );
- else Py_RETURN_NONE;
- case EXPP_MOD_STRENGTH:
- return PyFloat_FromDouble( (double)md->strength );
- case EXPP_MOD_DIRECTION:
- PyInt_FromLong( md->direction );
- case EXPP_MOD_VERTGROUP:
- return PyString_FromString( md->defgrp_name ) ;
- case EXPP_MOD_MID_LEVEL:
- return PyFloat_FromDouble( (double)md->midlevel );
- case EXPP_MOD_MAPPING:
- PyInt_FromLong( md->texmapping );
- case EXPP_MOD_OBJECT:
- return Object_CreatePyObject( md->map_object );
- case EXPP_MOD_UVLAYER:
- return PyString_FromString( md->uvlayer_name );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int displace_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- DisplaceModifierData *md = (DisplaceModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_TEXTURE:
- return GenericLib_assignData(value, (void **) &md->texture, 0, 1, ID_TE, 0);
- case EXPP_MOD_STRENGTH:
- return EXPP_setFloatClamped( value, &md->strength, -1000.0, 1000.0 );
-
- case EXPP_MOD_DIRECTION:
- return EXPP_setIValueClamped( value, &md->direction,
- MOD_DISP_DIR_X, MOD_DISP_DIR_RGB_XYZ, 'i' );
-
- case EXPP_MOD_VERTGROUP: {
- char *name = PyString_AsString( value );
- if( !name ) return EXPP_ReturnIntError( PyExc_TypeError, "expected string arg" );
- BLI_strncpy( md->defgrp_name, name, sizeof( md->defgrp_name ) );
- return 0;
- }
- case EXPP_MOD_MID_LEVEL:
- return EXPP_setFloatClamped( value, &md->midlevel, 0.0, 1.0 );
-
- case EXPP_MOD_MAPPING:
- return EXPP_setIValueClamped( value, &md->texmapping,
- MOD_DISP_MAP_LOCAL, MOD_DISP_MAP_UV, 'i' );
-
- case EXPP_MOD_OBJECT: {
- Object *ob_new=NULL;
- if (value == Py_None) {
- md->map_object = NULL;
- } else if (BPy_Object_Check( value )) {
- ob_new = ((( BPy_Object * )value)->object);
- md->map_object = ob_new;
- } else {
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Expected an Object or None value" );
- }
- return 0;
- }
-
- case EXPP_MOD_UVLAYER: {
- char *name = PyString_AsString( value );
- if( !name ) return EXPP_ReturnIntError( PyExc_TypeError, "expected string arg" );
- BLI_strncpy( md->uvlayer_name, name, sizeof( md->uvlayer_name ) );
- return 0;
- }
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-}
-
-
-/* static PyObject *uvproject_getter( BPy_Modifier * self, int type )
-{
- DisplaceModifierData *md = (DisplaceModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_MID_LEVEL:
- return PyFloat_FromDouble( (double)md->midlevel );
- default:
- return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
- }
-}
-
-static int uvproject_setter( BPy_Modifier *self, int type, PyObject *value )
-{
- DisplaceModifierData *md = (DisplaceModifierData *)(self->md);
-
- switch( type ) {
- case EXPP_MOD_TEXTURE:
- return 0;
- default:
- return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
- }
-} */
-
-
-/*
- * get data from a modifier
- */
-
-static PyObject *Modifier_getData( BPy_Modifier * self, PyObject * key )
-{
- int setting;
-
- if( !PyInt_Check( key ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int arg as stored in Blender.Modifier.Settings" );
-
- MODIFIER_DEL_CHECK_PY(self);
-
- setting = PyInt_AsLong( key );
- switch( setting ) {
- case EXPP_MOD_RENDER:
- return EXPP_getBitfield( &self->md->mode, eModifierMode_Render, 'h' );
- case EXPP_MOD_REALTIME:
- return EXPP_getBitfield( &self->md->mode, eModifierMode_Realtime, 'h' );
- case EXPP_MOD_EDITMODE:
- return EXPP_getBitfield( &self->md->mode, eModifierMode_Editmode, 'h' );
- case EXPP_MOD_ONCAGE:
- return EXPP_getBitfield( &self->md->mode, eModifierMode_OnCage, 'h' );
- default:
- switch( self->md->type ) {
- case eModifierType_Subsurf:
- return subsurf_getter( self, setting );
- case eModifierType_Armature:
- return armature_getter( self, setting );
- case eModifierType_Lattice:
- return lattice_getter( self, setting );
- case eModifierType_Curve:
- return curve_getter( self, setting );
- case eModifierType_Build:
- return build_getter( self, setting );
- case eModifierType_Mirror:
- return mirror_getter( self, setting );
- case eModifierType_Decimate:
- return decimate_getter( self, setting );
- case eModifierType_Smooth:
- return smooth_getter( self, setting );
- case eModifierType_Cast:
- return cast_getter( self, setting );
- case eModifierType_Wave:
- return wave_getter( self, setting );
- case eModifierType_Boolean:
- return boolean_getter( self, setting );
- case eModifierType_Array:
- return array_getter( self, setting );
- case eModifierType_EdgeSplit:
- return edgesplit_getter( self, setting );
- case eModifierType_Displace:
- return displace_getter( self, setting );
- /*case eModifierType_UVProject:
- return uvproject_getter( self, setting );*/
- case eModifierType_Hook:
- case eModifierType_Softbody:
- case eModifierType_None:
- Py_RETURN_NONE;
- }
- }
- return EXPP_ReturnPyObjError( PyExc_KeyError,
- "unknown key or modifier type" );
-}
-
-static int Modifier_setData( BPy_Modifier * self, PyObject * key,
- PyObject * arg )
-{
- int key_int;
-
- if( !PyNumber_Check( key ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an int arg as stored in Blender.Modifier.Settings" );
-
- MODIFIER_DEL_CHECK_INT(self);
-
- key_int = PyInt_AsLong( key );
-
- /* Chach for standard modifier settings */
- switch( key_int ) {
- case EXPP_MOD_RENDER:
- return EXPP_setBitfield( arg, &self->md->mode,
- eModifierMode_Render, 'h' );
- case EXPP_MOD_REALTIME:
- return EXPP_setBitfield( arg, &self->md->mode,
- eModifierMode_Realtime, 'h' );
- case EXPP_MOD_EDITMODE:
- return EXPP_setBitfield( arg, &self->md->mode,
- eModifierMode_Editmode, 'h' );
- case EXPP_MOD_ONCAGE:
- return EXPP_setBitfield( arg, &self->md->mode,
- eModifierMode_OnCage, 'h' );
- }
-
- switch( self->md->type ) {
- case eModifierType_Subsurf:
- return subsurf_setter( self, key_int, arg );
- case eModifierType_Armature:
- return armature_setter( self, key_int, arg );
- case eModifierType_Lattice:
- return lattice_setter( self, key_int, arg );
- case eModifierType_Curve:
- return curve_setter( self, key_int, arg );
- case eModifierType_Build:
- return build_setter( self, key_int, arg );
- case eModifierType_Mirror:
- return mirror_setter( self, key_int, arg );
- case eModifierType_Array:
- return array_setter( self, key_int, arg );
- case eModifierType_Decimate:
- return decimate_setter( self, key_int, arg );
- case eModifierType_Smooth:
- return smooth_setter( self, key_int, arg );
- case eModifierType_Cast:
- return cast_setter( self, key_int, arg );
- case eModifierType_Wave:
- return wave_setter( self, key_int, arg );
- case eModifierType_Boolean:
- return boolean_setter( self, key_int, arg );
- case eModifierType_EdgeSplit:
- return edgesplit_setter( self, key_int, arg );
- case eModifierType_Displace:
- return displace_setter( self, key_int, arg );
- /*case eModifierType_UVProject:
- return uvproject_setter( self, key_int, arg );*/
- case eModifierType_Hook:
- case eModifierType_Softbody:
- case eModifierType_None:
- return 0;
- }
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "unsupported modifier setting" );
-}
-
-
-static PyObject *Modifier_reset( BPy_Modifier * self )
-{
- Object *ob = self->object;
- ModifierData *md = self->md;
- HookModifierData *hmd = (HookModifierData*) md;
-
- MODIFIER_DEL_CHECK_PY(self);
-
- if (md->type != eModifierType_Hook)
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "can only reset hooks" );
-
- if (hmd->object) {
- Mat4Invert(hmd->object->imat, hmd->object->obmat);
- Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
- }
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: Modifier_repr */
-/* Description: This is a callback function for the BPy_Modifier type. It */
-/* builds a meaningful string to represent modifier objects. */
-/*****************************************************************************/
-static PyObject *Modifier_repr( BPy_Modifier * self )
-{
- ModifierTypeInfo *mti;
- if (self->md==NULL)
- return PyString_FromString( "[Modifier - Removed");
-
- mti= modifierType_getInfo(self->md->type);
- return PyString_FromFormat( "[Modifier \"%s\", Type \"%s\"]", self->md->name, mti->name );
-}
-
-/* Three Python Modifier_Type helper functions needed by the Object module: */
-
-/*****************************************************************************/
-/* Function: Modifier_CreatePyObject */
-/* Description: This function will create a new BPy_Modifier from an */
-/* existing Blender modifier structure. */
-/*****************************************************************************/
-PyObject *Modifier_CreatePyObject( Object *ob, ModifierData * md )
-{
- BPy_Modifier *pymod;
- pymod = ( BPy_Modifier * ) PyObject_NEW( BPy_Modifier, &Modifier_Type );
- if( !pymod )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Modifier object" );
- pymod->md = md;
- pymod->object = ob;
- return ( PyObject * ) pymod;
-}
-
-/*****************************************************************************/
-/* Function: Modifier_FromPyObject */
-/* Description: This function returns the Blender modifier from the given */
-/* PyObject. */
-/*****************************************************************************/
-ModifierData *Modifier_FromPyObject( PyObject * pyobj )
-{
- return ( ( BPy_Modifier * ) pyobj )->md;
-}
-
-/*****************************************************************************/
-/* Modifier Sequence wrapper */
-/*****************************************************************************/
-
-/*
- * Initialize the interator
- */
-
-static PyObject *ModSeq_getIter( BPy_ModSeq * self )
-{
- if (!self->iter) {
- self->iter = (ModifierData *)self->object->modifiers.first;
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- return ModSeq_CreatePyObject(self->object, (ModifierData *)self->object->modifiers.first);
- }
-}
-
-/*
- * Get the next Modifier
- */
-
-static PyObject *ModSeq_nextIter( BPy_ModSeq * self )
-{
- ModifierData *iter = self->iter;
- if( iter ) {
- self->iter = iter->next;
- return Modifier_CreatePyObject( self->object, iter );
- }
-
- self->iter= NULL; /* mark as not iterating */
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
-}
-
-/* return the number of modifiers */
-
-static int ModSeq_length( BPy_ModSeq * self )
-{
- return BLI_countlist( &self->object->modifiers );
-}
-
-/* return a modifier */
-
-static PyObject *ModSeq_item( BPy_ModSeq * self, int i )
-{
- ModifierData *md = NULL;
-
- /* if index is negative, start counting from the end of the list */
- if( i < 0 )
- i += ModSeq_length( self );
-
- /* skip through the list until we get the modifier or end of list */
-
- for( md = self->object->modifiers.first; i && md; --i ) md = md->next;
-
- if( md )
- return Modifier_CreatePyObject( self->object, md );
- else
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-}
-
-/*****************************************************************************/
-/* Python BPy_ModSeq sequence table: */
-/*****************************************************************************/
-static PySequenceMethods ModSeq_as_sequence = {
- ( inquiry ) ModSeq_length, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) ModSeq_item, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- ( objobjproc ) 0, /* sq_contains */
- ( binaryfunc ) 0, /* sq_inplace_concat */
- ( intargfunc ) 0, /* sq_inplace_repeat */
-};
-
-/*
- * helper function to check for a valid modifier argument
- */
-
-static ModifierData *locate_modifier( BPy_ModSeq *self, BPy_Modifier * value )
-{
- ModifierData *md;
-
- /* check that argument is a modifier */
- if( !BPy_Modifier_Check(value) )
- return (ModifierData *)EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an modifier as an argument" );
-
- /* check whether modifier has been removed */
- if( !value->md )
- return (ModifierData *)EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This modifier has been removed!" );
-
- /* find the modifier in the object's list */
- for( md = self->object->modifiers.first; md; md = md->next )
- if( md == value->md )
- return md;
-
- /* return exception if we can't find the modifier */
- return (ModifierData *)EXPP_ReturnPyObjError( PyExc_AttributeError,
- "This modifier is not in the object's stack" );
-}
-
-/* create a new modifier at the end of the list */
-
-static PyObject *ModSeq_append( BPy_ModSeq *self, PyObject *value )
-{
- int type = PyInt_AsLong(value);
-
- /* type 0 is eModifierType_None, should we be able to add one of these? */
- if( type <= 0 || type >= NUM_MODIFIER_TYPES )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Not an int or argument out of range, expected an int from Blender.Modifier.Type" );
-
- BLI_addtail( &self->object->modifiers, modifier_new( type ) );
- return Modifier_CreatePyObject( self->object, self->object->modifiers.last );
-}
-
-/* remove an existing modifier */
-
-static PyObject *ModSeq_remove( BPy_ModSeq *self, BPy_Modifier *value )
-{
- ModifierData *md = locate_modifier( self, value );
-
- /* if we can't locate the modifier, return (exception already set) */
- if( !md )
- return (PyObject *)NULL;
-
- /* do the actual removal */
- BLI_remlink( &self->object->modifiers, md );
- modifier_free( md );
-
- /* erase the link to the modifier */
- value->md = NULL;
-
- Py_RETURN_NONE;
-}
-
-/* move the modifier up in the stack */
-
-static PyObject *ModSeq_moveUp( BPy_ModSeq * self, BPy_Modifier * value )
-{
- ModifierData *md = locate_modifier( self, value );
-
- /* if we can't locate the modifier, return (exception already set) */
- if( !md )
- return (PyObject *)NULL;
-
- if( mod_moveUp( self->object, md ) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot move above a modifier requiring original data" );
-
- Py_RETURN_NONE;
-}
-
-/* move the modifier down in the stack */
-
-static PyObject *ModSeq_moveDown( BPy_ModSeq * self, BPy_Modifier *value )
-{
- ModifierData *md = locate_modifier( self, value );
-
- /* if we can't locate the modifier, return (exception already set) */
- if( !md )
- return (PyObject *)NULL;
-
- if( mod_moveDown( self->object, md ) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot move beyond a non-deforming modifier" );
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Python BPy_ModSeq methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_ModSeq_methods[] = {
- /* name, method, flags, doc */
- {"append", ( PyCFunction ) ModSeq_append, METH_O,
- "(type) - add a new modifier, where type is the type of modifier"},
- {"remove", ( PyCFunction ) ModSeq_remove, METH_O,
- "(modifier) - remove an existing modifier, where modifier is a modifier from this object."},
- {"moveUp", ( PyCFunction ) ModSeq_moveUp, METH_O,
- "(modifier) - Move a modifier up in stack"},
- {"moveDown", ( PyCFunction ) ModSeq_moveDown, METH_O,
- "(modifier) - Move a modifier down in stack"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python ModSeq_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject ModSeq_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.Modifiers", /* char *tp_name; */
- sizeof( BPy_ModSeq ), /* 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 ) NULL, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &ModSeq_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 )ModSeq_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc )ModSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_ModSeq_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
-};
-
-/*****************************************************************************/
-/* Function: ModSeq_CreatePyObject */
-/* Description: This function will create a new BPy_ModSeq from an */
-/* existing ListBase structure. */
-/*****************************************************************************/
-PyObject *ModSeq_CreatePyObject( Object *ob, ModifierData *iter )
-{
- BPy_ModSeq *pymod;
- pymod = ( BPy_ModSeq * ) PyObject_NEW( BPy_ModSeq, &ModSeq_Type );
- if( !pymod )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_ModSeq object" );
- pymod->object = ob;
- pymod->iter = iter;
- return ( PyObject * ) pymod;
-}
-
-static PyObject *M_Modifier_TypeDict( void )
-{
- PyObject *S = PyConstant_New( );
-
- if( S ) {
- BPy_constant *d = ( BPy_constant * ) S;
-
- PyConstant_Insert( d, "SUBSURF",
- PyInt_FromLong( eModifierType_Subsurf ) );
- PyConstant_Insert( d, "ARMATURE",
- PyInt_FromLong( eModifierType_Armature ) );
- PyConstant_Insert( d, "LATTICE",
- PyInt_FromLong( eModifierType_Lattice ) );
- PyConstant_Insert( d, "CURVE",
- PyInt_FromLong( eModifierType_Curve ) );
- PyConstant_Insert( d, "BUILD",
- PyInt_FromLong( eModifierType_Build ) );
- PyConstant_Insert( d, "MIRROR",
- PyInt_FromLong( eModifierType_Mirror ) );
- PyConstant_Insert( d, "DECIMATE",
- PyInt_FromLong( eModifierType_Decimate ) );
- PyConstant_Insert( d, "WAVE",
- PyInt_FromLong( eModifierType_Wave ) );
- PyConstant_Insert( d, "BOOLEAN",
- PyInt_FromLong( eModifierType_Boolean ) );
- PyConstant_Insert( d, "ARRAY",
- PyInt_FromLong( eModifierType_Array ) );
- PyConstant_Insert( d, "EDGESPLIT",
- PyInt_FromLong( eModifierType_EdgeSplit ) );
- PyConstant_Insert( d, "SMOOTH",
- PyInt_FromLong( eModifierType_Smooth ) );
- PyConstant_Insert( d, "CAST",
- PyInt_FromLong( eModifierType_Cast ) );
- PyConstant_Insert( d, "DISPLACE",
- PyInt_FromLong( eModifierType_Displace ) );
- }
- return S;
-}
-
-
-static PyObject *M_Modifier_SettingsDict( void )
-{
- PyObject *S = PyConstant_New( );
-
- if( S ) {
- BPy_constant *d = ( BPy_constant * ) S;
-
-/*
-# The lines below are a python script that uses the enum variables to create
-# the lines below
-# START PYSCRIPT
-st='''
- EXPP_MOD_RENDER = 0,
- EXPP_MOD_REALTIME,
- EXPP_MOD_EDITMODE,
- etc.. copy from above
-'''
-
-base= '''
- PyConstant_Insert( d, "%s",
- PyInt_FromLong( EXPP_MOD_%s ) );
-'''
-for var in st.replace(',','').split('\n'):
-
- var= var.split()
- if not var: continue
- var= var[0]
- if (not var) or var.startswith('/'): continue
-
- var='_'.join(var.split('_')[2:])
- print base % (var, var),
-# END PYSCRIPT
-*/
-
- /*Auto generated from the above script*/
- PyConstant_Insert( d, "RENDER",
- PyInt_FromLong( EXPP_MOD_RENDER ) );
- PyConstant_Insert( d, "REALTIME",
- PyInt_FromLong( EXPP_MOD_REALTIME ) );
- PyConstant_Insert( d, "EDITMODE",
- PyInt_FromLong( EXPP_MOD_EDITMODE ) );
- PyConstant_Insert( d, "ONCAGE",
- PyInt_FromLong( EXPP_MOD_ONCAGE ) );
- PyConstant_Insert( d, "OBJECT",
- PyInt_FromLong( EXPP_MOD_OBJECT ) );
- PyConstant_Insert( d, "VERTGROUP",
- PyInt_FromLong( EXPP_MOD_VERTGROUP ) );
- PyConstant_Insert( d, "LIMIT",
- PyInt_FromLong( EXPP_MOD_LIMIT ) );
- PyConstant_Insert( d, "FLAG",
- PyInt_FromLong( EXPP_MOD_FLAG ) );
- PyConstant_Insert( d, "COUNT",
- PyInt_FromLong( EXPP_MOD_COUNT ) );
- PyConstant_Insert( d, "LENGTH",
- PyInt_FromLong( EXPP_MOD_LENGTH ) );
- PyConstant_Insert( d, "FACTOR",
- PyInt_FromLong( EXPP_MOD_FACTOR ) );
- PyConstant_Insert( d, "ENABLE_X",
- PyInt_FromLong( EXPP_MOD_ENABLE_X ) );
- PyConstant_Insert( d, "ENABLE_Y",
- PyInt_FromLong( EXPP_MOD_ENABLE_Y ) );
- PyConstant_Insert( d, "ENABLE_Z",
- PyInt_FromLong( EXPP_MOD_ENABLE_Z ) );
- PyConstant_Insert( d, "TYPES",
- PyInt_FromLong( EXPP_MOD_TYPES ) );
- PyConstant_Insert( d, "LEVELS",
- PyInt_FromLong( EXPP_MOD_LEVELS ) );
- PyConstant_Insert( d, "RENDLEVELS",
- PyInt_FromLong( EXPP_MOD_RENDLEVELS ) );
- PyConstant_Insert( d, "OPTIMAL",
- PyInt_FromLong( EXPP_MOD_OPTIMAL ) );
- PyConstant_Insert( d, "UV",
- PyInt_FromLong( EXPP_MOD_UV ) );
- PyConstant_Insert( d, "ENVELOPES",
- PyInt_FromLong( EXPP_MOD_ENVELOPES ) );
- PyConstant_Insert( d, "OBJECT_OFFSET",
- PyInt_FromLong( EXPP_MOD_OBJECT_OFFSET ) );
- PyConstant_Insert( d, "OBJECT_CURVE",
- PyInt_FromLong( EXPP_MOD_OBJECT_CURVE ) );
- PyConstant_Insert( d, "OFFSET_VEC",
- PyInt_FromLong( EXPP_MOD_OFFSET_VEC ) );
- PyConstant_Insert( d, "SCALE_VEC",
- PyInt_FromLong( EXPP_MOD_SCALE_VEC ) );
- PyConstant_Insert( d, "MERGE_DIST",
- PyInt_FromLong( EXPP_MOD_MERGE_DIST ) );
- PyConstant_Insert( d, "START",
- PyInt_FromLong( EXPP_MOD_START ) );
- PyConstant_Insert( d, "SEED",
- PyInt_FromLong( EXPP_MOD_SEED ) );
- PyConstant_Insert( d, "RANDOMIZE",
- PyInt_FromLong( EXPP_MOD_RANDOMIZE ) );
- PyConstant_Insert( d, "AXIS_X",
- PyInt_FromLong( EXPP_MOD_AXIS_X ) );
- PyConstant_Insert( d, "AXIS_Y",
- PyInt_FromLong( EXPP_MOD_AXIS_Y ) );
- PyConstant_Insert( d, "AXIS_Z",
- PyInt_FromLong( EXPP_MOD_AXIS_Z ) );
- PyConstant_Insert( d, "RATIO",
- PyInt_FromLong( EXPP_MOD_RATIO ) );
- PyConstant_Insert( d, "STARTX",
- PyInt_FromLong( EXPP_MOD_STARTX ) );
- PyConstant_Insert( d, "STARTY",
- PyInt_FromLong( EXPP_MOD_STARTY ) );
- PyConstant_Insert( d, "HEIGHT",
- PyInt_FromLong( EXPP_MOD_HEIGHT ) );
- PyConstant_Insert( d, "WIDTH",
- PyInt_FromLong( EXPP_MOD_WIDTH ) );
- PyConstant_Insert( d, "NARROW",
- PyInt_FromLong( EXPP_MOD_NARROW ) );
- PyConstant_Insert( d, "SPEED",
- PyInt_FromLong( EXPP_MOD_SPEED ) );
- PyConstant_Insert( d, "DAMP",
- PyInt_FromLong( EXPP_MOD_DAMP ) );
- PyConstant_Insert( d, "LIFETIME",
- PyInt_FromLong( EXPP_MOD_LIFETIME ) );
- PyConstant_Insert( d, "TIMEOFFS",
- PyInt_FromLong( EXPP_MOD_TIMEOFFS ) );
- PyConstant_Insert( d, "OPERATION",
- PyInt_FromLong( EXPP_MOD_OPERATION ) );
- PyConstant_Insert( d, "EDGESPLIT_ANGLE",
- PyInt_FromLong( EXPP_MOD_EDGESPLIT_ANGLE ) );
- PyConstant_Insert( d, "EDGESPLIT_FROM_ANGLE",
- PyInt_FromLong( EXPP_MOD_EDGESPLIT_FROM_ANGLE ) );
- PyConstant_Insert( d, "EDGESPLIT_FROM_SHARP",
- PyInt_FromLong( EXPP_MOD_EDGESPLIT_FROM_SHARP ) );
- PyConstant_Insert( d, "UVLAYER",
- PyInt_FromLong( EXPP_MOD_UVLAYER ) );
- PyConstant_Insert( d, "MID_LEVEL",
- PyInt_FromLong( EXPP_MOD_MID_LEVEL ) );
- PyConstant_Insert( d, "STRENGTH",
- PyInt_FromLong( EXPP_MOD_STRENGTH ) );
- PyConstant_Insert( d, "TEXTURE",
- PyInt_FromLong( EXPP_MOD_TEXTURE ) );
- PyConstant_Insert( d, "MAPPING",
- PyInt_FromLong( EXPP_MOD_MAPPING ) );
- PyConstant_Insert( d, "DIRECTION",
- PyInt_FromLong( EXPP_MOD_DIRECTION ) );
- PyConstant_Insert( d, "REPEAT",
- PyInt_FromLong( EXPP_MOD_REPEAT ) );
- PyConstant_Insert( d, "RADIUS",
- PyInt_FromLong( EXPP_MOD_RADIUS ) );
- PyConstant_Insert( d, "SIZE",
- PyInt_FromLong( EXPP_MOD_SIZE ) );
- PyConstant_Insert( d, "USE_OB_TRANSFORM",
- PyInt_FromLong( EXPP_MOD_USE_OB_TRANSFORM ) );
- PyConstant_Insert( d, "SIZE_FROM_RADIUS",
- PyInt_FromLong( EXPP_MOD_SIZE_FROM_RADIUS ) );
- /*End Auto generated code*/
- }
- return S;
-}
-
-/*****************************************************************************/
-/* Function: Modifier_Init */
-/*****************************************************************************/
-PyObject *Modifier_Init( void )
-{
- PyObject *submodule;
- PyObject *TypeDict = M_Modifier_TypeDict( );
- PyObject *SettingsDict = M_Modifier_SettingsDict( );
-
- if( PyType_Ready( &ModSeq_Type ) < 0 ||
- PyType_Ready( &Modifier_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Modifier", NULL,
- "Modifer module for accessing and creating object modifier data" );
-
- if( TypeDict ) {
- PyModule_AddObject( submodule, "Type", TypeDict ); /* deprecated */
- /* since PyModule_AddObject() steals a reference, we need to
- incref TypeDict to use it again */
- Py_INCREF( TypeDict);
- PyModule_AddObject( submodule, "Types", TypeDict );
- }
-
- if( SettingsDict )
- PyModule_AddObject( submodule, "Settings", SettingsDict );
-
- return submodule;
-}
diff --git a/source/blender/python/api2_2x/Modifier.h b/source/blender/python/api2_2x/Modifier.h
deleted file mode 100644
index 12afc591c2c..00000000000
--- a/source/blender/python/api2_2x/Modifier.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/NLA.c b/source/blender/python/api2_2x/NLA.c
deleted file mode 100644
index a0bdaa83d07..00000000000
--- a/source/blender/python/api2_2x/NLA.c
+++ /dev/null
@@ -1,1590 +0,0 @@
-/*
- * $Id: NLA.c 11907 2007-08-31 18:21:12Z 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 "NLA.h" /*This must come first*/
-
-#include "DNA_curve_types.h"
-#include "DNA_scene_types.h"
-#include "BKE_action.h"
-#include "BKE_nla.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_library.h"
-#include "BLI_blenlib.h"
-#include "Object.h"
-#include "Ipo.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-#include "blendef.h"
-#include "MEM_guardedalloc.h"
-
-#define ACTSTRIP_STRIDEAXIS_X 0
-#define ACTSTRIP_STRIDEAXIS_Y 1
-#define ACTSTRIP_STRIDEAXIS_Z 2
-
-/*****************************************************************************/
-/* Python API function prototypes for the NLA module. */
-/*****************************************************************************/
-static PyObject *M_NLA_NewAction( PyObject * self, PyObject * args );
-static PyObject *M_NLA_CopyAction( PyObject * self, PyObject * args );
-static PyObject *M_NLA_GetActions( PyObject * self );
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Armature.NLA.__doc__ */
-/*****************************************************************************/
-char M_NLA_doc[] =
- "The Blender NLA module -This module provides control over Armature keyframing in Blender.";
-char M_NLA_NewAction_doc[] =
- "(name) - Create new action for linking to an object.";
-char M_NLA_CopyAction_doc[] = "(name) - Copy action and return copy.";
-char M_NLA_GetActions_doc[] = "(name) - Returns a dictionary of actions.";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Armature.NLA module: */
-/*****************************************************************************/
-struct PyMethodDef M_NLA_methods[] = {
- {"NewAction", ( PyCFunction ) M_NLA_NewAction, METH_VARARGS,
- M_NLA_NewAction_doc},
- {"CopyAction", ( PyCFunction ) M_NLA_CopyAction, METH_VARARGS,
- M_NLA_CopyAction_doc},
- {"GetActions", ( PyCFunction ) M_NLA_GetActions, METH_NOARGS,
- M_NLA_GetActions_doc},
- {NULL, NULL, 0, NULL}
-};
-/*****************************************************************************/
-/* Python BPy_Action methods declarations: */
-/*****************************************************************************/
-static PyObject *Action_setActive( BPy_Action * self, PyObject * args );
-static PyObject *Action_getFrameNumbers(BPy_Action *self);
-static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * value );
-static PyObject *Action_getChannelNames( BPy_Action * self );
-static PyObject *Action_renameChannel( BPy_Action * self, PyObject * args );
-static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * value );
-static PyObject *Action_removeChannel( BPy_Action * self, PyObject * value );
-static PyObject *Action_getAllChannelIpos( BPy_Action * self );
-
-/*****************************************************************************/
-/* Python BPy_Action methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Action_methods[] = {
- /* name, method, flags, doc */
- {"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
- "() - return Action name"},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "(str) - rename Action"},
- {"setActive", ( PyCFunction ) Action_setActive, METH_VARARGS,
- "(str) -set this action as the active action for an object"},
- {"getFrameNumbers", (PyCFunction) Action_getFrameNumbers, METH_NOARGS,
- "() - get the frame numbers at which keys have been inserted"},
- {"getChannelIpo", ( PyCFunction ) Action_getChannelIpo, METH_O,
- "(str) -get the Ipo from a named action channel in this action"},
- {"getChannelNames", ( PyCFunction ) Action_getChannelNames, METH_NOARGS,
- "() -get the channel names for this action"},
- {"renameChannel", ( PyCFunction ) Action_renameChannel, METH_VARARGS,
- "(from, to) -rename the channel from string to string"},
- {"verifyChannel", ( PyCFunction ) Action_verifyChannel, METH_O,
- "(str) -verify the channel in this action"},
- {"removeChannel", ( PyCFunction ) Action_removeChannel, METH_O,
- "(str) -remove the channel from the action"},
- {"getAllChannelIpos", ( PyCFunction ) Action_getAllChannelIpos,
- METH_NOARGS,
- "() - Return a dict of (name:ipo)-keys containing each channel in the object's action"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python TypeAction callback function prototypes: */
-/*****************************************************************************/
-static int Action_compare( BPy_Action * a, BPy_Action * b );
-static PyObject *Action_repr( BPy_Action * bone );
-
-/*-------------------------------------------------------------------------*/
-static PyObject *M_NLA_NewAction( PyObject * self_unused, PyObject * args )
-{
- char *name_str = "DefaultAction";
- BPy_Action *py_action = NULL; /* for Action Data object wrapper in Python */
- bAction *bl_action = NULL; /* for actual Action Data we create in Blender */
-
- if( !PyArg_ParseTuple( args, "|s", &name_str ) ) {
- EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected string or nothing" );
- return NULL;
- }
- /* Create new action globally */
- bl_action = alloc_libblock( &G.main->action, ID_AC, name_str );
- bl_action->id.flag |= LIB_FAKEUSER; /* no need to assign a user because alloc_libblock alredy assigns one */
-
-
- /* now create the wrapper obj in Python */
- if( bl_action )
- py_action =
- ( BPy_Action * ) PyObject_NEW( BPy_Action,
- &Action_Type );
- else {
- EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Action Data in Blender" );
- return NULL;
- }
-
- if( py_action == NULL ) {
- EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create Action Data object" );
- return NULL;
- }
-
- py_action->action = bl_action; /* link Python action wrapper with Blender Action */
-
- Py_INCREF( py_action );
- return ( PyObject * ) py_action;
-}
-
-static PyObject *M_NLA_CopyAction( PyObject * self_unused, PyObject * args )
-{
- BPy_Action *py_action = NULL;
- bAction *copyAction = NULL;
-
- if( !PyArg_ParseTuple( args, "O!", &Action_Type, &py_action ) ) {
- EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected python action type" );
- return NULL;
- }
- copyAction = copy_action( py_action->action );
- return Action_CreatePyObject( copyAction );
-}
-
-static PyObject *M_NLA_GetActions( PyObject * self_unused )
-{
- PyObject *dict = PyDict_New( );
- bAction *action = NULL;
-
- for( action = G.main->action.first; action; action = action->id.next ) {
- PyObject *py_action = Action_CreatePyObject( action );
- if( py_action ) {
- /* Insert dict entry using the bone name as key */
- if( PyDict_SetItemString
- ( dict, action->id.name + 2, py_action ) != 0 ) {
- Py_DECREF( py_action );
- Py_DECREF( dict );
-
- return EXPP_ReturnPyObjError
- ( PyExc_RuntimeError,
- "NLA_GetActions: couldn't set dict item" );
- }
- Py_DECREF( py_action );
- } else {
- Py_DECREF( dict );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "NLA_GetActions: could not create Action object" ) );
- }
- }
- return dict;
-}
-
-static PyObject *Action_getFrameNumbers(BPy_Action *self)
-{
- bActionChannel *achan = NULL;
- IpoCurve *icu = NULL;
- BezTriple *bezt = NULL;
- int verts;
- PyObject *py_list = NULL;
-
- py_list = PyList_New(0);
- for(achan = self->action->chanbase.first; achan; achan = achan->next){
- if (achan->ipo) {
- for (icu = achan->ipo->curve.first; icu; icu = icu->next){
- bezt= icu->bezt;
- if(bezt) {
- verts = icu->totvert;
- while(verts--) {
- PyObject *value;
- value = PyInt_FromLong((int)bezt->vec[1][0]);
- if ( PySequence_Contains(py_list, value) == 0){
- PyList_Append(py_list, value);
- }
- Py_DECREF(value);
- bezt++;
- }
- }
- }
- }
- }
- PyList_Sort(py_list);
- return EXPP_incr_ret(py_list);
-}
-
-static PyObject *Action_setActive( BPy_Action * self, PyObject * args )
-{
- BPy_Object *object;
-
- if( !self->action )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get attribute from a NULL action" );
-
- if( !PyArg_ParseTuple( args, "O!", &Object_Type, &object ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected python object argument" );
-
- if( object->object->type != OB_ARMATURE )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object not of type armature" );
-
- /* if object is already attached to an action, decrement user count */
- if( object->object->action )
- --object->object->action->id.us;
-
- /* set the active action to object */
- object->object->action = self->action;
- ++object->object->action->id.us;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * value )
-{
- char *chanName = PyString_AsString(value);
- bActionChannel *chan;
-
- if( !chanName )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "string expected" );
-
- chan = get_action_channel( self->action, chanName );
- if( !chan )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "no channel with that name" );
-
- if( !chan->ipo ) {
- Py_RETURN_NONE;
- }
-
- return Ipo_CreatePyObject( chan->ipo );
-}
-
-static PyObject *Action_getChannelNames( BPy_Action * self )
-{
- PyObject *list = PyList_New( BLI_countlist(&(self->action->chanbase)) );
- bActionChannel *chan = NULL;
- int index=0;
- for( chan = self->action->chanbase.first; chan; chan = chan->next ) {
- PyList_SetItem( list, index, PyString_FromString(chan->name) );
- index++;
- }
- return list;
-}
-
-static PyObject *Action_renameChannel( BPy_Action * self, PyObject * args )
-{
- char *chanFrom, *chanTo;
- bActionChannel *chan;
-
- if( !PyArg_ParseTuple( args, "ss", &chanFrom, &chanTo ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "2 strings expected" );
-
- chan = get_action_channel( self->action, chanFrom );
- if( !chan )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "no channel with that name" );
- if (strlen(chanTo) > 31)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "new name greater then 31 characters long" );
-
- if (get_action_channel( self->action, chanTo ))
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "channel target name alredy exists" );
-
- strcpy(chan->name, chanTo);
-
- Py_RETURN_NONE;
-}
-
-/*----------------------------------------------------------------------*/
-static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * value )
-{
- char *chanName = PyString_AsString(value);
- bActionChannel *chan;
-
- if( !self->action )
- ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create channel for a NULL action" ) );
-
- if( !chanName )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected string argument" ) );
-
- chan = verify_action_channel(self->action, chanName);
-
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Action_removeChannel( BPy_Action * self, PyObject * value )
-{
- char *chanName = PyString_AsString(value);
- bActionChannel *chan;
-
- if( !chanName )
- return (EXPP_ReturnPyObjError( PyExc_AttributeError,
- "string expected" ));
-
-
- chan = get_action_channel( self->action, chanName );
- if( chan == NULL ) {
- EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no channel with that name..." );
- return NULL;
- }
- /*release ipo*/
- if( chan->ipo )
- chan->ipo->id.us--;
-
- /*remove channel*/
- BLI_freelinkN( &self->action->chanbase, chan );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Action_getAllChannelIpos( BPy_Action * self )
-{
- PyObject *dict = PyDict_New( );
- bActionChannel *chan = NULL;
-
- for( chan = self->action->chanbase.first; chan; chan = chan->next ) {
- PyObject *ipo_attr;
- if( chan->ipo )
- ipo_attr = Ipo_CreatePyObject( chan->ipo );
- else {
- ipo_attr = Py_None;
- Py_INCREF( ipo_attr );
- }
- if( ipo_attr ) {
- /* Insert dict entry using the bone name as key*/
- if( PyDict_SetItemString( dict, chan->name, ipo_attr )
- != 0 ) {
- Py_DECREF( ipo_attr );
- Py_DECREF( dict );
-
- return EXPP_ReturnPyObjError
- ( PyExc_RuntimeError,
- "Action_getAllChannelIpos: couldn't set dict item" );
- }
- Py_DECREF( ipo_attr );
- } else {
- Py_DECREF( dict );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Action_getAllChannelIpos: could not create Ipo object" ) );
- }
- }
- return dict;
-}
-
-/*----------------------------------------------------------------------*/
-static int Action_compare( BPy_Action * a, BPy_Action * b )
-{
- return ( a->action == b->action ) ? 0 : -1;
-}
-
-/*----------------------------------------------------------------------*/
-static PyObject *Action_repr( BPy_Action * self )
-{
- if( self->action )
- return PyString_FromFormat( "[Action \"%s\"]",
- self->action->id.name + 2 );
- else
- return PyString_FromString( "NULL" );
-}
-
-/*----------------------------------------------------------------------*/
-PyObject *Action_CreatePyObject( struct bAction * act )
-{
- BPy_Action *blen_action;
-
- if(!act) Py_RETURN_NONE;
-
- blen_action =
- ( BPy_Action * ) PyObject_NEW( BPy_Action, &Action_Type );
-
- if( !blen_action) {
- return ( EXPP_ReturnPyObjError
- ( PyExc_RuntimeError, "failure to create object!" ) );
- }
- blen_action->action = act;
- return ( ( PyObject * ) blen_action );
-}
-
-/*----------------------------------------------------------------------*/
-struct bAction *Action_FromPyObject( PyObject * py_obj )
-{
- BPy_Action *blen_obj;
-
- blen_obj = ( BPy_Action * ) py_obj;
- return ( blen_obj->action );
-}
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Action_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python TypeAction structure definition: */
-/*****************************************************************************/
-PyTypeObject Action_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
- "Blender Action", /* tp_name */
- sizeof( BPy_Action ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- NULL, /* tp_dealloc */
- NULL, /* tp_print */
- NULL, /* tp_getattr */
- NULL, /* tp_setattr */
- ( cmpfunc ) Action_compare, /* tp_compare */
- ( reprfunc ) Action_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_Action_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Action_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
-};
-
-
-
-/*****************************************************************************/
-/* ActionStrip wrapper */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* Python BPy_ActionStrip attributes: */
-/*****************************************************************************/
-
-/*
- * return the action for the action strip
- */
-
-static PyObject *ActionStrip_getAction( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return Action_CreatePyObject( self->strip->act );
-}
-
-/*
- * return the start frame of the action strip
- */
-
-static PyObject *ActionStrip_getStripStart( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyFloat_FromDouble( self->strip->start );
-}
-
-/*
- * set the start frame of the action strip
- */
-
-static int ActionStrip_setStripStart( BPy_ActionStrip * self, PyObject * value )
-{
- int retval;
-
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- retval = EXPP_setFloatClamped( value, &self->strip->start,
- -1000.0, self->strip->end-1 );
- if( !retval ) {
- float max = self->strip->end - self->strip->start;
- if( self->strip->blendin > max )
- self->strip->blendin = max;
- if( self->strip->blendout > max )
- self->strip->blendout = max;
- }
- return retval;
-}
-
-/*
- * return the ending frame of the action strip
- */
-
-static PyObject *ActionStrip_getStripEnd( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyFloat_FromDouble( self->strip->end );
-}
-
-/*
- * set the ending frame of the action strip
- */
-
-static int ActionStrip_setStripEnd( BPy_ActionStrip * self, PyObject * value )
-{
- int retval;
-
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- retval = EXPP_setFloatClamped( value, &self->strip->end,
- self->strip->start+1, MAXFRAMEF );
- if( !retval ) {
- float max = self->strip->end - self->strip->start;
- if( self->strip->blendin > max )
- self->strip->blendin = max;
- if( self->strip->blendout > max )
- self->strip->blendout = max;
- }
- return retval;
-}
-
-/*
- * return the start frame of the action
- */
-
-static PyObject *ActionStrip_getActionStart( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyFloat_FromDouble( self->strip->actstart );
-}
-
-/*
- * set the start frame of the action
- */
-
-static int ActionStrip_setActionStart( BPy_ActionStrip * self, PyObject * value )
-{
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return EXPP_setFloatClamped( value, &self->strip->actstart,
- -1000.0, self->strip->actend-1 );
-}
-
-/*
- * return the ending frame of the action
- */
-
-static PyObject *ActionStrip_getActionEnd( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyFloat_FromDouble( self->strip->actend );
-}
-
-/*
- * set the ending frame of the action
- */
-
-static int ActionStrip_setActionEnd( BPy_ActionStrip * self, PyObject * value )
-{
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return EXPP_setFloatClamped( value, &self->strip->actend,
- self->strip->actstart+1, MAXFRAMEF );
-}
-
-/*
- * return the repeat value of the action strip
- */
-
-static PyObject *ActionStrip_getRepeat( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyFloat_FromDouble( self->strip->repeat );
-}
-
-/*
- * set the repeat value of the action strip
- */
-
-static int ActionStrip_setRepeat( BPy_ActionStrip * self, PyObject * value )
-{
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return EXPP_setFloatClamped( value, &self->strip->repeat,
- 0.001f, 1000.0f );
-}
-
-/*
- * return the blend in of the action strip
- */
-
-static PyObject *ActionStrip_getBlendIn( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyFloat_FromDouble( self->strip->blendin );
-}
-
-/*
- * set the blend in value of the action strip
- */
-
-static int ActionStrip_setBlendIn( BPy_ActionStrip * self, PyObject * value )
-{
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return EXPP_setFloatClamped( value, &self->strip->blendin,
- 0.0, self->strip->end - self->strip->start );
-}
-
-/*
- * return the blend out of the action strip
- */
-
-static PyObject *ActionStrip_getBlendOut( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyFloat_FromDouble( self->strip->blendout );
-}
-
-/*
- * set the blend out value of the action strip
- */
-
-static int ActionStrip_setBlendOut( BPy_ActionStrip * self, PyObject * value )
-{
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return EXPP_setFloatClamped( value, &self->strip->blendout,
- 0.0, self->strip->end - self->strip->start );
-}
-
-/*
- * return the blend mode of the action strip
- */
-
-static PyObject *ActionStrip_getBlendMode( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyInt_FromLong( (long)self->strip->mode ) ;
-}
-
-/*
- * set the blend mode value of the action strip
- */
-
-static int ActionStrip_setBlendMode( BPy_ActionStrip * self, PyObject * value )
-{
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return EXPP_setIValueRange( value, &self->strip->mode,
- 0, ACTSTRIPMODE_ADD, 'h' );
-}
-
-/*
- * return the flag settings of the action strip
- */
-
-#define ACTIONSTRIP_MASK (ACTSTRIP_SELECT | ACTSTRIP_USESTRIDE \
- | ACTSTRIP_HOLDLASTFRAME | ACTSTRIP_ACTIVE | ACTSTRIP_LOCK_ACTION)
-
-static PyObject *ActionStrip_getFlag( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyInt_FromLong( (long)( self->strip->flag & ACTIONSTRIP_MASK ) ) ;
-}
-
-/*
- * set the flag settings out value of the action strip
- */
-
-static int ActionStrip_setFlag( BPy_ActionStrip * self, PyObject * arg )
-{
- PyObject *num = PyNumber_Int( arg );
- int value;
-
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
- if( !num )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
- value = PyInt_AS_LONG( num );
- Py_DECREF( num );
-
- if( ( value & ACTIONSTRIP_MASK ) != value ) {
- char errstr[128];
- sprintf ( errstr , "expected int bitmask of 0x%04x", ACTIONSTRIP_MASK );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
-
- self->strip->flag = (short)value;
- return 0;
-}
-
-/*
- * return the stride axis of the action strip
- */
-
-static PyObject *ActionStrip_getStrideAxis( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyInt_FromLong( (long)self->strip->stride_axis ) ;
-}
-
-/*
- * set the stride axis of the action strip
- */
-
-static int ActionStrip_setStrideAxis( BPy_ActionStrip * self, PyObject * value )
-{
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return EXPP_setIValueRange( value, &self->strip->stride_axis,
- ACTSTRIP_STRIDEAXIS_X, ACTSTRIP_STRIDEAXIS_Z, 'h' );
-}
-
-/*
- * return the stride length of the action strip
- */
-
-static PyObject *ActionStrip_getStrideLength( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyFloat_FromDouble( (double)self->strip->stridelen ) ;
-}
-
-/*
- * set the stride length of the action strip
- */
-
-static int ActionStrip_setStrideLength( BPy_ActionStrip * self, PyObject * value )
-{
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return EXPP_setFloatClamped( value, &self->strip->stridelen,
- 0.0001f, 1000.0 );
-}
-
-/*
- * return the stride bone name
- */
-
-static PyObject *ActionStrip_getStrideBone( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- return PyString_FromString( self->strip->stridechannel );
-}
-
-static PyObject *ActionStrip_getGroupTarget( BPy_ActionStrip * self )
-{
- if( !self->strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- if (self->strip->object) {
- return Object_CreatePyObject( self->strip->object );
- } else {
- Py_RETURN_NONE;
- }
-}
-
-/*
- * set the stride bone name
- */
-
-static int ActionStrip_setStrideBone( BPy_ActionStrip * self, PyObject * attr )
-{
- char *name = PyString_AsString( attr );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected string arg" );
-
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- BLI_strncpy( self->strip->stridechannel, name, 32 );
-
- return 0;
-}
-
-static int ActionStrip_setGroupTarget( BPy_ActionStrip * self, PyObject * args )
-{
- if( !self->strip )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- if( (PyObject *)args == Py_None )
- self->strip->object = NULL;
- else if( BPy_Object_Check( args ) )
- self->strip->object = ((BPy_Object *)args)->object;
- else
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an object or None" );
- return 0;
-}
-
-/*****************************************************************************/
-/* Python BPy_Constraint attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_ActionStrip_getseters[] = {
- {"action",
- (getter)ActionStrip_getAction, (setter)NULL,
- "Action associated with the strip", NULL},
- {"stripStart",
- (getter)ActionStrip_getStripStart, (setter)ActionStrip_setStripStart,
- "Starting frame of the strip", NULL},
- {"stripEnd",
- (getter)ActionStrip_getStripEnd, (setter)ActionStrip_setStripEnd,
- "Ending frame of the strip", NULL},
- {"actionStart",
- (getter)ActionStrip_getActionStart, (setter)ActionStrip_setActionStart,
- "Starting frame of the action", NULL},
- {"actionEnd",
- (getter)ActionStrip_getActionEnd, (setter)ActionStrip_setActionEnd,
- "Ending frame of the action", NULL},
- {"repeat",
- (getter)ActionStrip_getRepeat, (setter)ActionStrip_setRepeat,
- "The number of times to repeat the action range", NULL},
- {"blendIn",
- (getter)ActionStrip_getBlendIn, (setter)ActionStrip_setBlendIn,
- "Number of frames of motion blending", NULL},
- {"blendOut",
- (getter)ActionStrip_getBlendOut, (setter)ActionStrip_setBlendOut,
- "Number of frames of ease-out", NULL},
- {"mode",
- (getter)ActionStrip_getBlendMode, (setter)ActionStrip_setBlendMode,
- "Setting of blending mode", NULL},
- {"flag",
- (getter)ActionStrip_getFlag, (setter)ActionStrip_setFlag,
- "Setting of blending flags", NULL},
- {"strideAxis",
- (getter)ActionStrip_getStrideAxis, (setter)ActionStrip_setStrideAxis,
- "Dominant axis for stride bone", NULL},
- {"strideLength",
- (getter)ActionStrip_getStrideLength, (setter)ActionStrip_setStrideLength,
- "Distance covered by one complete cycle of the action", NULL},
- {"strideBone",
- (getter)ActionStrip_getStrideBone, (setter)ActionStrip_setStrideBone,
- "Name of Bone used for stride", NULL},
- {"groupTarget",
- (getter)ActionStrip_getGroupTarget, (setter)ActionStrip_setGroupTarget,
- "Name of target armature within group", NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python BPy_ActionStrip methods: */
-/*****************************************************************************/
-
-/*
- * restore the values of ActionStart and ActionEnd to their defaults
- */
-
-static PyObject *ActionStrip_resetLimits( BPy_ActionStrip *self )
-{
- bActionStrip *strip = self->strip;
-
- if( !strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- calc_action_range( strip->act, &strip->actstart, &strip->actend, 1 );
-
- Py_RETURN_NONE;
-}
-
-/*
- * reset the strip size
- */
-
-static PyObject *ActionStrip_resetStripSize( BPy_ActionStrip *self )
-{
- float mapping;
- bActionStrip *strip = self->strip;
-
- if( !strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- mapping = (strip->actend - strip->actstart) / (strip->end - strip->start);
- strip->end = strip->start + mapping*(strip->end - strip->start);
-
- Py_RETURN_NONE;
-}
-
-/*
- * snap to start and end to nearest frames
- */
-
-static PyObject *ActionStrip_snapToFrame( BPy_ActionStrip *self )
-{
- bActionStrip *strip = self->strip;
-
- if( !strip )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
-
- strip->start= (float)floor(strip->start+0.5);
- strip->end= (float)floor(strip->end+0.5);
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Python BPy_ActionStrip methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_ActionStrip_methods[] = {
- /* name, method, flags, doc */
- {"resetActionLimits", ( PyCFunction ) ActionStrip_resetLimits, METH_NOARGS,
- "Restores the values of ActionStart and ActionEnd to their defaults"},
- {"resetStripSize", ( PyCFunction ) ActionStrip_resetStripSize, METH_NOARGS,
- "Resets the Action Strip size to its creation values"},
- {"snapToFrame", ( PyCFunction ) ActionStrip_snapToFrame, METH_NOARGS,
- "Snaps the ends of the action strip to the nearest whole numbered frame"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python ActionStrip_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject ActionStrip_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.ActionStrip", /* char *tp_name; */
- sizeof( BPy_ActionStrip ), /* 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 ) NULL, /* 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_ActionStrip_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_ActionStrip_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_ActionStrip_FlagsDict( void )
-{
- PyObject *S = PyConstant_New( );
-
- if( S ) {
- BPy_constant *d = ( BPy_constant * ) S;
- PyConstant_Insert( d, "SELECT",
- PyInt_FromLong( ACTSTRIP_SELECT ) );
- PyConstant_Insert( d, "STRIDE_PATH",
- PyInt_FromLong( ACTSTRIP_USESTRIDE ) );
- PyConstant_Insert( d, "HOLD",
- PyInt_FromLong( ACTSTRIP_HOLDLASTFRAME ) );
- PyConstant_Insert( d, "ACTIVE",
- PyInt_FromLong( ACTSTRIP_ACTIVE ) );
- PyConstant_Insert( d, "LOCK_ACTION",
- PyInt_FromLong( ACTSTRIP_LOCK_ACTION ) );
- }
- return S;
-}
-
-static PyObject *M_ActionStrip_AxisDict( void )
-{
- PyObject *S = PyConstant_New( );
-
- if( S ) {
- BPy_constant *d = ( BPy_constant * ) S;
- PyConstant_Insert( d, "STRIDEAXIS_X",
- PyInt_FromLong( ACTSTRIP_STRIDEAXIS_X ) );
- PyConstant_Insert( d, "STRIDEAXIS_Y",
- PyInt_FromLong( ACTSTRIP_STRIDEAXIS_Y ) );
- PyConstant_Insert( d, "STRIDEAXIS_Z",
- PyInt_FromLong( ACTSTRIP_STRIDEAXIS_Z ) );
- }
- return S;
-}
-
-static PyObject *M_ActionStrip_ModeDict( void )
-{
- PyObject *S = PyConstant_New( );
-
- if( S ) {
- BPy_constant *d = ( BPy_constant * ) S;
- PyConstant_Insert( d, "MODE_ADD",
- PyInt_FromLong( ACTSTRIPMODE_ADD ) );
- }
- return S;
-}
-
-PyObject *ActionStrip_CreatePyObject( struct bActionStrip *strip )
-{
- BPy_ActionStrip *pyobj;
- pyobj = ( BPy_ActionStrip * ) PyObject_NEW( BPy_ActionStrip,
- &ActionStrip_Type );
- if( !pyobj )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_ActionStrip object" );
- pyobj->strip = strip;
- return ( PyObject * ) pyobj;
-}
-
-/*****************************************************************************/
-/* ActionStrip Sequence wrapper */
-/*****************************************************************************/
-
-/*
- * Initialize the iterator
- */
-
-static PyObject *ActionStrips_getIter( BPy_ActionStrips * self )
-{
- self->iter = (bActionStrip *)self->ob->nlastrips.first;
- return EXPP_incr_ret ( (PyObject *) self );
-}
-
-/*
- * Get the next action strip
- */
-
-static PyObject *ActionStrips_nextIter( BPy_ActionStrips * self )
-{
- bActionStrip *strip = self->iter;
- if( strip ) {
- self->iter = strip->next;
- return ActionStrip_CreatePyObject( strip );
- }
-
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
-}
-
-/* return the number of action strips */
-
-static int ActionStrips_length( BPy_ActionStrips * self )
-{
- return BLI_countlist( &self->ob->nlastrips );
-}
-
-/* return an action strip */
-
-static PyObject *ActionStrips_item( BPy_ActionStrips * self, int i )
-{
- bActionStrip *strip = NULL;
-
- /* if index is negative, start counting from the end of the list */
- if( i < 0 )
- i += ActionStrips_length( self );
-
- /* skip through the list until we get the strip or end of list */
-
- strip = self->ob->nlastrips.first;
-
- while( i && strip ) {
- --i;
- strip = strip->next;
- }
-
- if( strip )
- return ActionStrip_CreatePyObject( strip );
- else
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-}
-
-/*****************************************************************************/
-/* Python BPy_ActionStrips sequence table: */
-/*****************************************************************************/
-static PySequenceMethods ActionStrips_as_sequence = {
- ( inquiry ) ActionStrips_length, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) ActionStrips_item, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- ( objobjproc ) 0, /* sq_contains */
- ( binaryfunc ) 0, /* sq_inplace_concat */
- ( intargfunc ) 0, /* sq_inplace_repeat */
-};
-
-
-/*****************************************************************************/
-/* Python BPy_ActionStrip methods: */
-/*****************************************************************************/
-
-/*
- * helper function to check for a valid action strip argument
- */
-
-static bActionStrip *locate_strip( BPy_ActionStrips *self,
- PyObject *args, BPy_ActionStrip **stripobj )
-{
- bActionStrip *strip = NULL;
- BPy_ActionStrip *pyobj;
-
- /* check that argument is a constraint */
- if( !PyArg_ParseTuple( args, "O!", &ActionStrip_Type, &pyobj ) ) {
- EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an action strip as an argument" );
- return NULL;
- }
-
- if( !pyobj->strip ) {
- EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This strip has been removed!" );
- return NULL;
- }
-
- /* if caller needs the object, return it */
- if( stripobj )
- *stripobj = pyobj;
-
- /* find the action strip in the NLA */
- for( strip = self->ob->nlastrips.first; strip; strip = strip->next )
- if( strip == pyobj->strip )
- return strip;
-
- /* return exception if we can't find the strip */
- EXPP_ReturnPyObjError( PyExc_AttributeError,
- "action strip does not belong to this object" );
- return NULL;
-}
-
-/*
- * remove an action strip from the NLA
- */
-
-static PyObject *ActionStrips_remove( BPy_ActionStrips *self, PyObject * args )
-{
- BPy_ActionStrip *pyobj;
- bActionStrip *strip = locate_strip( self, args, &pyobj );
-
- /* return exception if we can't find the strip */
- if( !strip )
- return (PyObject *)NULL;
-
- /* do the actual removal */
- free_actionstrip(strip);
- BLI_remlink(&self->ob->nlastrips, strip);
- MEM_freeN(strip);
-
- pyobj->strip = NULL;
- Py_RETURN_NONE;
-}
-
-/*
- * move an action strip up in the strip list
- */
-
-static PyObject *ActionStrips_moveUp( BPy_ActionStrips *self, PyObject * args )
-{
- bActionStrip *strip = locate_strip( self, args, NULL );
-
- /* return exception if we can't find the strip */
- if( !strip )
- return (PyObject *)NULL;
-
- /* if strip is not already the first, move it up */
- if( strip != self->ob->nlastrips.first ) {
- BLI_remlink(&self->ob->nlastrips, strip);
- BLI_insertlink(&self->ob->nlastrips, strip->prev->prev, strip);
- }
-
- Py_RETURN_NONE;
-}
-
-/*
- * move an action strip down in the strip list
- */
-
-static PyObject *ActionStrips_moveDown( BPy_ActionStrips *self, PyObject * args )
-{
- bActionStrip *strip = locate_strip( self, args, NULL );
-
- /* return exception if we can't find the strip */
- if( !strip )
- return (PyObject *)NULL;
-
- /* if strip is not already the last, move it down */
- if( strip != self->ob->nlastrips.last ) {
- BLI_remlink(&self->ob->nlastrips, strip);
- BLI_insertlink(&self->ob->nlastrips, strip->next, strip);
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *ActionStrips_append( BPy_ActionStrips *self, PyObject * args )
-{
- BPy_Action *pyobj;
- Object *ob;
- bActionStrip *strip;
- bAction *act;
-
- /* check that argument is an action */
- if( !PyArg_ParseTuple( args, "O!", &Action_Type, &pyobj ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an action as an argument" );
-
- ob = self->ob;
- act = pyobj->action;
-
- /* Initialize the new action block */
- strip = MEM_callocN( sizeof(bActionStrip), "bActionStrip" );
-
- strip->act = act;
- calc_action_range( strip->act, &strip->actstart, &strip->actend, 1 );
- strip->start = (float)G.scene->r.cfra;
- strip->end = strip->start + ( strip->actend - strip->actstart );
- /* simple prevention of zero strips */
- if( strip->start > strip->end-2 )
- strip->end = strip->start+100;
-
- strip->flag = ACTSTRIP_LOCK_ACTION;
- find_stridechannel(ob, strip);
-
- strip->repeat = 1.0;
- act->id.us++;
-
- BLI_addtail(&ob->nlastrips, strip);
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Python BPy_ActionStrips methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_ActionStrips_methods[] = {
- /* name, method, flags, doc */
- {"append", ( PyCFunction ) ActionStrips_append, METH_VARARGS,
- "(action) - append a new actionstrip using existing action"},
- {"remove", ( PyCFunction ) ActionStrips_remove, METH_VARARGS,
- "(strip) - remove an existing strip from this actionstrips"},
- {"moveUp", ( PyCFunction ) ActionStrips_moveUp, METH_VARARGS,
- "(strip) - move an existing strip up in the actionstrips"},
- {"moveDown", ( PyCFunction ) ActionStrips_moveDown, METH_VARARGS,
- "(strip) - move an existing strip down in the actionstrips"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python ActionStrips_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject ActionStrips_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.ActionStrips", /* char *tp_name; */
- sizeof( BPy_ActionStrips ), /* 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 ) NULL, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &ActionStrips_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 )ActionStrips_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc )ActionStrips_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_ActionStrips_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
-};
-
-PyObject *ActionStrips_CreatePyObject( Object *ob )
-{
- BPy_ActionStrips *pyseq;
- pyseq = ( BPy_ActionStrips * ) PyObject_NEW( BPy_ActionStrips,
- &ActionStrips_Type );
- if( !pyseq )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_ActionStrips object" );
- pyseq->ob = ob;
- return ( PyObject * ) pyseq;
-}
-
-/*****************************************************************************/
-/* Function: NLA_Init */
-/*****************************************************************************/
-PyObject *NLA_Init( void )
-{
- PyObject *FlagsDict = M_ActionStrip_FlagsDict( );
- PyObject *AxisDict = M_ActionStrip_AxisDict( );
- PyObject *ModeDict = M_ActionStrip_ModeDict( );
- PyObject *submodule;
-
- if( PyType_Ready( &Action_Type ) < 0
- || PyType_Ready( &ActionStrip_Type ) < 0
- || PyType_Ready( &ActionStrips_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Armature.NLA",
- M_NLA_methods, M_NLA_doc );
-
- if( FlagsDict )
- PyModule_AddObject( submodule, "Flags", FlagsDict );
- if( AxisDict )
- PyModule_AddObject( submodule, "StrideAxes", AxisDict );
- if( ModeDict )
- PyModule_AddObject( submodule, "Modes", ModeDict );
-
- return submodule;
-}
diff --git a/source/blender/python/api2_2x/NLA.h b/source/blender/python/api2_2x/NLA.h
deleted file mode 100644
index 50bfa32b7e7..00000000000
--- a/source/blender/python/api2_2x/NLA.h
+++ /dev/null
@@ -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
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
deleted file mode 100644
index 6570613e94a..00000000000
--- a/source/blender/python/api2_2x/NMesh.c
+++ /dev/null
@@ -1,4164 +0,0 @@
-/*
- * $Id: NMesh.c 12108 2007-09-22 17:54:13Z 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, but it borrows all the old NMesh code.
- *
- * Contributor(s): Willian P. Germano, Jordi Rovira i Bonet, Joseph Gilbert,
- * Bala Gi, Alexander Szakaly, Stephane Soppera, Campbell Barton, Ken Hughes,
- * Daniel Dunbar.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "NMesh.h" /*This must come first*/
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_key_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_space_types.h"
-#include "DNA_curve_types.h"
-
-#include "BDR_editface.h" /* make_tfaces */
-#include "BDR_vpaint.h"
-#include "BDR_editobject.h"
-
-#include "BIF_editdeform.h"
-#include "BIF_editkey.h" /* insert_meshkey */
-#include "BIF_editview.h"
-#include "BIF_space.h"
-
-#include "BKE_customdata.h"
-#include "BKE_deform.h"
-#include "BKE_mesh.h"
-#include "BKE_material.h"
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_displist.h"
-#include "BKE_object.h"
-#include "BKE_mball.h"
-#include "BKE_utildefines.h"
-#include "BKE_depsgraph.h"
-#include "BKE_idprop.h"
-
-#include "BLI_arithb.h"
-#include "BLI_blenlib.h"
-
-#include "blendef.h"
-#include "mydevice.h"
-#include "Object.h"
-#include "Key.h"
-#include "Mathutils.h"
-#include "IDProp.h"
-#include "constant.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-extern void countall(void);
-
-/* EXPP Mesh defines */
-
-#define NMESH_FRAME_MAX 30000
-#define NMESH_SMOOTHRESH 30
-#define NMESH_SMOOTHRESH_MIN 1
-#define NMESH_SMOOTHRESH_MAX 80
-#define NMESH_SUBDIV 1
-#define NMESH_SUBDIV_MIN 0
-#define NMESH_SUBDIV_MAX 6
-
-/* Globals */
-static PyObject *g_nmeshmodule = NULL;
-
-static int unlink_existingMeshData( Mesh * mesh );
-static int convert_NMeshToMesh( Mesh *mesh, BPy_NMesh *nmesh );
-static void check_dverts(Mesh *me, int old_totverts);
-static PyObject *NMesh_printDebug( PyObject * self );
-static PyObject *NMesh_addEdge( PyObject * self, PyObject * args );
-static PyObject *NMesh_findEdge( PyObject * self, PyObject * args );
-static PyObject *NMesh_removeEdge( PyObject * self, PyObject * args );
-static PyObject *NMesh_addFace( PyObject * self, PyObject * args );
-static PyObject *NMesh_removeFace( PyObject * self, PyObject * args );
-static PyObject *NMesh_addVertGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_removeVertGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_assignVertsToGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_removeVertsFromGroup( PyObject * self,PyObject * args );
-static PyObject *NMesh_getVertsFromGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_renameVertGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_getVertGroupNames( PyObject * self );
-static PyObject *NMesh_transform (PyObject *self, PyObject *args);
-
-static char NMesh_printDebug_doc[] =
- "print debug info about the mesh.";
-
-static char NMesh_getKey_doc[] =
- "get the Key object linked to this mesh";
-
-static char NMesh_addEdge_doc[] =
- "create an edge between two vertices.\n\
-If an edge already exists between those vertices, it is returned.\n\
-(In Blender, only zero or one edge can link two vertices.)\n\
-Created edge is automatically added to edges list.";
-
-static char NMesh_findEdge_doc[] =
- "find an edge between two vertices.";
-
-static char NMesh_removeEdge_doc[] =
- "remove an edge between two vertices.\n\
-All faces using this edge are removed from faces list.";
-
-static char NMesh_addFace_doc[] =
- "add a face to face list and add to edge list (if edge data exists) necessary edges.";
-
-static char NMesh_removeFace_doc[] =
- "remove a face for face list and remove edges no more used by any other face (if \
-edge data exists).";
-
-static char NMesh_addVertGroup_doc[] =
- "add a named and empty vertex(deform) Group to a mesh that has been linked\n\
-to an object. ";
-
-static char NMesh_removeVertGroup_doc[] =
- "remove a named vertex(deform) Group from a mesh that has been linked\n\
-to an object. Will remove all verts assigned to group.";
-
-static char NMesh_assignVertsToGroup_doc[] =
- "Adds an array (a python list) of vertex points (by index) to a named\n\
-vertex group. The list will have an associated wieght assigned to them.\n\
-The weight represents the amount of influence this group has over these\n\
-vertex points. Weights should be in the range of 0.0 - 1.0.\n\
-The assignmode can be either 'add', 'subtract', or 'replace'. If this vertex\n\
-is not assigned to the group 'add' creates a new association with the weight\n\
-specified, otherwise the weight given is added to the current weight of the\n\
-vertex.\n\
-'subtract' will attempt to subtract the weight passed from a vertex already\n\
-associated with a group, else it does nothing. 'replace' attempts to replace\n\
-the weight with the new weight value for an already associated vertex/group,\n\
-else it does nothing. The mesh must have all it's vertex points set before\n\
-attempting to assign any vertex points to a vertex group.";
-
-static char NMesh_removeVertsFromGroup_doc[] =
- "Remove an array (a python list) of vertex points from a named group in a\n\
-mesh that has been linked to an object. If no list is given this will remove\n\
-all vertex point associations with the group passed";
-
-static char NMesh_getVertsFromGroup_doc[] =
- "By passing a python list of vertex indices and a named group, this will\n\
-return a python list representing the indeces that are a part of this vertex.\n\
-group. If no association was found for the index passed nothing will be\n\
-return for the index. An optional flag will also return the weights as well";
-
-static char NMesh_renameVertGroup_doc[] = "Renames a vertex group";
-
-static char NMesh_getVertGroupNames_doc[] =
- "Returns a list of all the vertex group names";
-
-static char M_NMesh_doc[] = "The Blender.NMesh submodule";
-
-static char M_NMesh_Col_doc[] = "([r, g, b, a]) - Get a new mesh color\n\n\
-[r=255, g=255, b=255, a=255] Specify the color components";
-
-static char M_NMesh_Face_doc[] =
- "(vertexlist = None) - Get a new face, and pass optional vertex list";
-
-static char NMFace_append_doc[] =
- "(vert) - appends Vertex 'vert' to face vertex list";
-
-static char M_NMesh_Vert_doc[] = "([x, y, z]) - Get a new vertex\n\n\
-[x, y, z] Specify new coordinates";
-
-static char NMesh_getMaterials_doc[] =
- "(i = -1) - Get this mesh's list of materials.\n\
-(i = -1) - int: determines the list's contents:\n\
--1: return the current list, possibly modified by the script (default);\n\
- 0: get a fresh list from the Blender mesh -- modifications not included,\n\
- unless the script called mesh.update() first;\n\
- 1: like 0, but does not ignore empty slots, returns them as 'None'.";
-
-static char NMesh_setMaterials_doc[] =
- "(matlist) - Set this mesh's list of materials. This method makes sure\n\
-the passed matlist is valid (can only include up to 16 materials and None's).";
-
-static char NMesh_addMaterial_doc[] =
- "(material) - add a new Blender Material 'material' to this Mesh's materials\n\
-list.";
-
-static char NMesh_insertKey_doc[] =
- "(frame = None, type = 'relative') - inserts a Mesh key at the given frame\n\
-if called without arguments, it inserts the key at the current Scene frame.\n\
-(type) - 'relative' or 'absolute'. Only relevant on the first call to this\n\
-function for each nmesh.";
-
-static char NMesh_removeAllKeys_doc[] =
- "() - removes all keys from this mesh\n\
-returns True if successful or False if this NMesh wasn't linked to a real\n\
-Blender Mesh yet or the Mesh had no keys";
-
-static char NMesh_getSelectedFaces_doc[] =
- "(flag = None) - returns list of selected Faces\n\
-If flag = 1, return indices instead";
-
-static char NMesh_getActiveFace_doc[] =
- "returns the index of the active face ";
-
-static char NMesh_hasVertexUV_doc[] =
- "(flag = None) - returns 1 if Mesh has per vertex UVs ('Sticky')\n\
-The optional argument sets the Sticky flag";
-
-static char NMesh_hasFaceUV_doc[] =
- "(flag = None) - returns 1 if Mesh has textured faces\n\
-The optional argument sets the textured faces flag";
-
-static char NMesh_hasVertexColours_doc[] =
- "(flag = None) - returns 1 if Mesh has vertex colors.\n\
-The optional argument sets the vertex color flag";
-
-static char NMesh_getVertexInfluences_doc[] =
- "Return a list of the influences of bones in the vertex \n\
-specified by index. The list contains pairs with the \n\
-bone name and the weight.";
-
-static char NMesh_update_doc[] =
-"(recalc_normals = 0, store_edges = 0, vertex_shade = 0) - Updates the Mesh.\n\
-Optional arguments: if given and nonzero:\n\
-'recalc_normals': normal vectors are recalculated;\n\
-'store_edges': edges data is stored.\n\
-'vertex_shade': vertex colors are added based on the current lamp setup.";
-
-static char NMesh_getMode_doc[] =
- "() - get the mode flags of this nmesh as an or'ed int value.";
-
-static char NMesh_setMode_doc[] =
- "(int or none to 5 strings) - set the mode flags of this nmesh.\n\
-() - unset all flags.";
-
-static char NMesh_getMaxSmoothAngle_doc[] =
- "() - get the max smooth angle for mesh auto smoothing.";
-
-static char NMesh_setMaxSmoothAngle_doc[] =
- "(int) - set the max smooth angle for mesh auto smoothing in the range\n\
-[1,80] in degrees.";
-
-static char NMesh_getSubDivLevels_doc[] =
- "() - get the subdivision levels for display and rendering: [display, render]";
-
-static char NMesh_setSubDivLevels_doc[] =
- "([int, int]) - set the subdivision levels for [display, render] -- they are\n\
-clamped to the range [0,6].";
-
-static char M_NMesh_New_doc[] =
- "() - returns a new, empty NMesh mesh object\n";
-
-static char M_NMesh_GetRaw_doc[] = "([name]) - Get a raw mesh from Blender\n\n\
-[name] Name of the mesh to be returned\n\n\
-If name is not specified a new empty mesh is\n\
-returned, otherwise Blender returns an existing\n\
-mesh.";
-
-static char M_NMesh_GetNames_doc[] = "\
-() - Get a list with the names of all available meshes in Blender\n\n\
-Any of these names can be passed to NMesh.GetRaw() for the actual mesh data.";
-
-static char M_NMesh_GetRawFromObject_doc[] =
- "(name) - Get the raw mesh used by a Blender object\n\n\
-(name) Name of the object to get the mesh from\n\n\
-This returns the mesh as used by the object, which\n\
-means it contains all deformations and modifications.";
-
-static char M_NMesh_PutRaw_doc[] =
- "(mesh, name = None, recalc_normals = 1, store_edges = 0]) -\n\
-Return a raw mesh to Blender\n\n\
-(mesh) The NMesh object to store\n\
-[name] The mesh to replace\n\
-[recalc_normals = 1] Flag to control vertex normal recalculation\n\
-[store_edges=0] Store edges data in the blender mesh\n\
-If the name of a mesh to replace is not given a new\n\
-object is created and returned.";
-
-static char NMesh_transform_doc[] =
-"(matrix, recalc_normals = 0) - Transform the mesh by the supplied 4x4 matrix\n\
-if recalc_normals is True, vertex normals are transformed along with \n\
-vertex coordinatess.\n";
-
-
-void mesh_update( Mesh * mesh, Object * ob )
-{
- if (ob) {
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
- }
- else {
- ob = G.main->object.first;
- while (ob) {
- if (ob->data == mesh) {
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
- break;
- }
- ob = ob->id.next;
- }
- }
-}
-
-/*
- * before trying to convert NMesh data back to mesh, verify that the
- * lists contain the right type of data
- */
-
-static int check_NMeshLists( BPy_NMesh *nmesh )
-{
- int i;
-
- if( !PySequence_Check( nmesh->verts ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh verts are not a sequence" );
- if( !PySequence_Check( nmesh->edges ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh edges are not a sequence" );
- if( !PySequence_Check( nmesh->faces ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh faces are not a sequence" );
- if( !PySequence_Check( nmesh->materials ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh materials are not a sequence" );
-
- if( EXPP_check_sequence_consistency( nmesh->verts, &NMVert_Type ) != 1 )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh vertices must be NMVerts" );
- if( EXPP_check_sequence_consistency( nmesh->edges, &NMEdge_Type ) != 1 )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh edges must be NMEdges" );
- if( EXPP_check_sequence_consistency( nmesh->faces, &NMFace_Type ) != 1 )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh faces must be NMFaces" );
- for( i = 0 ; i < PySequence_Length(nmesh->faces); ++i ) {
- int j, err=0;
- PyObject *col, *v, *uv;
- BPy_NMFace *face=(BPy_NMFace *)PySequence_GetItem(nmesh->faces, i);
-
- col = face->col;
- uv = face->uv;
- v = face->v;
- Py_DECREF( face );
- if( EXPP_check_sequence_consistency( face->col, &NMCol_Type ) != 1 ) {
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh face col must be NMCols" );
- }
- if( EXPP_check_sequence_consistency( face->v, &NMVert_Type ) != 1 )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh face v must be NMVerts" );
-
- for( j = 0 ; !err && j < PySequence_Length( face->uv ); ++j ) {
- PyObject *uv = PySequence_GetItem( face->uv, j);
- if( PySequence_Check(uv) && PySequence_Length(uv) == 2 ) {
- PyObject *p1 = PySequence_GetItem(uv, 0);
- PyObject *p2 = PySequence_GetItem(uv, 1);
- if( !PyNumber_Check(p1) || !PyNumber_Check(p2) )
- err = 1;
- Py_DECREF( p1 );
- Py_DECREF( p2 );
- }
- else {
- err = 1;
- }
-
- Py_DECREF( uv );
- }
- if( err )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "nmesh face uv must contain sequence of 2 floats" );
- }
- return 0;
-}
-
-
-/*****************************/
-/* Mesh Color Object */
-/*****************************/
-
-static void NMCol_dealloc( PyObject * self )
-{
- PyObject_DEL( self );
-}
-
-static BPy_NMCol *newcol( char r, char g, char b, char a )
-{
- BPy_NMCol *mc = ( BPy_NMCol * ) PyObject_NEW( BPy_NMCol, &NMCol_Type );
-
- mc->r = r;
- mc->g = g;
- mc->b = b;
- mc->a = a;
-
- return mc;
-}
-
-static PyObject *M_NMesh_Col( PyObject * self, PyObject * args )
-{
- char r = 255, g = 255, b = 255, a = 255;
-
- if( PyArg_ParseTuple( args, "|bbbb", &r, &g, &b, &a ) )
- return ( PyObject * ) newcol( r, g, b, a );
-
- return NULL;
-}
-
-static PyObject *NMCol_getattr( PyObject * self, char *name )
-{
- BPy_NMCol *mc = ( BPy_NMCol * ) self;
-
- if( strcmp( name, "r" ) == 0 )
- return Py_BuildValue( "i", mc->r );
- else if( strcmp( name, "g" ) == 0 )
- return Py_BuildValue( "i", mc->g );
- else if( strcmp( name, "b" ) == 0 )
- return Py_BuildValue( "i", mc->b );
- else if( strcmp( name, "a" ) == 0 )
- return Py_BuildValue( "i", mc->a );
- else if( strcmp( name, "__members__" ) == 0 )
- return Py_BuildValue( "[s,s,s,s]", "r", "g", "b", "a" );
-
- return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
-}
-
-static int NMCol_setattr( PyObject * self, char *name, PyObject * v )
-{
- BPy_NMCol *mc = ( BPy_NMCol * ) self;
- char ival;
-
- if( !PyArg_Parse( v, "b", &ival ) )
- return -1;
-
- ival = ( char ) EXPP_ClampInt( ival, 0, 255 );
-
- if( strcmp( name, "r" ) == 0 )
- mc->r = (unsigned char)ival;
- else if( strcmp( name, "g" ) == 0 )
- mc->g = (unsigned char)ival;
- else if( strcmp( name, "b" ) == 0 )
- mc->b = (unsigned char)ival;
- else if( strcmp( name, "a" ) == 0 )
- mc->a = (unsigned char)ival;
- else
- return -1;
-
- return 0;
-}
-
-static PyObject *NMCol_repr( BPy_NMCol * self )
-{
- static char s[256];
- sprintf( s, "[NMCol - <%d, %d, %d, %d>]", self->r, self->g, self->b,
- self->a );
- return Py_BuildValue( "s", s );
-}
-
-PyTypeObject NMCol_Type = {
- PyObject_HEAD_INIT( NULL ) 0, /* ob_size */
- "Blender NMCol", /* tp_name */
- sizeof( BPy_NMCol ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- ( destructor ) NMCol_dealloc, /* tp_dealloc */
- ( printfunc ) 0, /* tp_print */
- ( getattrfunc ) NMCol_getattr, /* tp_getattr */
- ( setattrfunc ) NMCol_setattr, /* tp_setattr */
- 0, /* tp_compare */
- ( reprfunc ) NMCol_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del to avoid a warning */
-};
-
-/*****************************/
-/* NMesh Python Object */
-/*****************************/
-static void NMFace_dealloc( PyObject * self )
-{
- BPy_NMFace *mf = ( BPy_NMFace * ) self;
-
- Py_DECREF( mf->v );
- Py_DECREF( mf->uv );
- Py_DECREF( mf->col );
-
- PyObject_DEL( self );
-}
-
-static PyObject *new_NMFace( PyObject * vertexlist )
-{
- BPy_NMFace *mf = PyObject_NEW( BPy_NMFace, &NMFace_Type );
- PyObject *vlcopy;
-
- if( vertexlist ) { /* create a copy of the given vertex list */
- PyObject *item;
- int i, len = PyList_Size( vertexlist );
-
- vlcopy = PyList_New( len );
-
- if( !vlcopy ) {
- Py_DECREF(mf);
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" );
- }
- for( i = 0; i < len; i++ ) {
- item = PySequence_GetItem( vertexlist, i ); /* PySequence increfs */
-
- if( item )
- PyList_SET_ITEM( vlcopy, i, item );
- else {
- Py_DECREF(mf);
- Py_DECREF(vlcopy);
- return EXPP_ReturnPyObjError
- ( PyExc_RuntimeError,
- "couldn't get vertex from a PyList" );
- }
- }
- } else /* create an empty vertex list */
- vlcopy = PyList_New( 0 );
-
- mf->v = vlcopy;
- mf->uv = PyList_New( 0 );
- mf->image = NULL;
- mf->mode = TF_DYNAMIC + TF_TEX;
- mf->flag = TF_SELECT;
- mf->transp = TF_SOLID;
- mf->col = PyList_New( 0 );
-
- mf->mf_flag = 0;
- mf->mat_nr = 0;
- mf->orig_index = -1;
-
- return ( PyObject * ) mf;
-}
-
-static PyObject *M_NMesh_Face( PyObject * self, PyObject * args )
-{
- PyObject *vertlist = NULL;
-
- if( !PyArg_ParseTuple( args, "|O!", &PyList_Type, &vertlist ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of vertices or nothing as argument" );
-
-/* if (!vertlist) vertlist = PyList_New(0); */
-
- return new_NMFace( vertlist );
-}
-
-static PyObject *NMFace_append( PyObject * self, PyObject * args )
-{
- PyObject *vert;
- BPy_NMFace *f = ( BPy_NMFace * ) self;
-
- if( !PyArg_ParseTuple( args, "O!", &NMVert_Type, &vert ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an NMVert object" );
-
- PyList_Append( f->v, vert );
-
- Py_RETURN_NONE;
-}
-
-#undef MethodDef
-#define MethodDef(func) {#func, NMFace_##func, METH_VARARGS, NMFace_##func##_doc}
-
-static struct PyMethodDef NMFace_methods[] = {
- MethodDef( append ),
- {NULL, NULL, 0, NULL}
-};
-
-static PyObject *NMFace_getattr( PyObject * self, char *name )
-{
- BPy_NMFace *mf = ( BPy_NMFace * ) self;
-
- if( strcmp( name, "v" ) == 0 )
- return Py_BuildValue( "O", mf->v );
- else if( strcmp( name, "col" ) == 0 )
- return Py_BuildValue( "O", mf->col );
- else if( strcmp( name, "mat" ) == 0 ) // emulation XXX
- return Py_BuildValue( "i", mf->mat_nr );
- else if( strcmp( name, "materialIndex" ) == 0 )
- return Py_BuildValue( "i", mf->mat_nr );
- else if( strcmp( name, "smooth" ) == 0 )
- return Py_BuildValue( "i", (mf->mf_flag & ME_SMOOTH) ? 1:0 );
- else if( strcmp( name, "sel" ) == 0 )
- return Py_BuildValue( "i", (mf->mf_flag & ME_FACE_SEL) ? 1:0 );
- else if( strcmp( name, "hide" ) == 0 )
- return Py_BuildValue( "i", (mf->mf_flag & ME_HIDE) ? 1:0 );
-
- else if( strcmp( name, "image" ) == 0 ) {
- if( mf->image )
- return Image_CreatePyObject( mf->image );
- else
- Py_RETURN_NONE;
- }
-
- else if( strcmp( name, "mode" ) == 0 )
- return Py_BuildValue( "i", mf->mode );
- else if( strcmp( name, "flag" ) == 0 )
- return Py_BuildValue( "i", mf->flag );
- else if( strcmp( name, "transp" ) == 0 )
- return Py_BuildValue( "i", mf->transp );
- else if( strcmp( name, "uv" ) == 0 )
- return Py_BuildValue( "O", mf->uv );
-
- else if( ( strcmp( name, "normal" ) == 0 )
- || ( strcmp( name, "no" ) == 0 ) ) {
-
- if( EXPP_check_sequence_consistency( mf->v, &NMVert_Type ) ==
- 1 ) {
-
- float fNormal[3] = { 0.0, 0.0, 0.0 };
- float *vco[4] = { NULL, NULL, NULL, NULL };
- int nSize = PyList_Size( mf->v );
- int loop;
-
- if( nSize != 3 && nSize != 4 )
- return EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "face must contain either 3 or 4 verts" );
-
- for( loop = 0; loop < nSize; loop++ ) {
- BPy_NMVert *v =
- ( BPy_NMVert * ) PyList_GetItem( mf->v,
- loop );
- vco[loop] = ( float * ) v->co;
- }
-
- if( nSize == 4 )
- CalcNormFloat4( vco[0], vco[1], vco[2], vco[3],
- fNormal );
- else
- CalcNormFloat( vco[0], vco[1], vco[2],
- fNormal );
-
- return Py_BuildValue( "[f,f,f]", fNormal[0],
- fNormal[1], fNormal[2] );
- } else // EXPP_check_sequence_consistency failed
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "this face does not contain a series of NMVerts" );
- }
-
- else if( strcmp( name, "__members__" ) == 0 )
- return Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s,s,s]",
- "v", "col", "mat", "materialIndex",
- "smooth", "image", "mode", "flag",
- "transp", "uv", "normal", "sel", "hide");
- return Py_FindMethod( NMFace_methods, ( PyObject * ) self, name );
-}
-
-static int NMFace_setattr( PyObject * self, char *name, PyObject * v )
-{
- BPy_NMFace *mf = ( BPy_NMFace * ) self;
- short ival;
- char cval;
-
- if( strcmp( name, "v" ) == 0 ) {
-
- if( PySequence_Check( v ) ) {
- Py_DECREF( mf->v );
- mf->v = EXPP_incr_ret( v );
-
- return 0;
- }
- } else if( strcmp( name, "col" ) == 0 ) {
-
- if( PySequence_Check( v ) ) {
- Py_DECREF( mf->col );
- mf->col = EXPP_incr_ret( v );
-
- return 0;
- }
- } else if( !strcmp( name, "mat" ) || !strcmp( name, "materialIndex" ) ) {
- PyArg_Parse( v, "b", &cval );
- mf->mat_nr = cval;
-
- return 0;
- } else if( strcmp( name, "smooth" ) == 0 ) {
- PyArg_Parse( v, "h", &ival );
- if (ival) mf->mf_flag |= ME_SMOOTH;
- else mf->mf_flag &= ~ME_SMOOTH;
-
- return 0;
- } else if( strcmp( name, "sel" ) == 0 ) {
- PyArg_Parse( v, "h", &ival );
- if (ival) mf->mf_flag |= ME_FACE_SEL;
- else mf->mf_flag &= ~ME_FACE_SEL;
-
- return 0;
- } else if( strcmp( name, "hide" ) == 0 ) {
- PyArg_Parse( v, "h", &ival );
- if (ival) mf->mf_flag |= ME_HIDE;
- else mf->mf_flag &= ~ME_HIDE;
-
- return 0;
-
- } else if( strcmp( name, "uv" ) == 0 ) {
-
- if( PySequence_Check( v ) ) {
- Py_DECREF( mf->uv );
- mf->uv = EXPP_incr_ret( v );
-
- return 0;
- }
- } else if( strcmp( name, "flag" ) == 0 ) {
- PyArg_Parse( v, "h", &ival );
- mf->flag = ival;
-
- return 0;
- } else if( strcmp( name, "mode" ) == 0 ) {
- PyArg_Parse( v, "h", &ival );
- mf->mode = ival;
-
- return 0;
- } else if( strcmp( name, "transp" ) == 0 ) {
- PyArg_Parse( v, "b", &cval );
- mf->transp = cval;
-
- return 0;
- } else if( strcmp( name, "image" ) == 0 ) {
- PyObject *pyimg;
- if( !PyArg_Parse( v, "O!", &Image_Type, &pyimg ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected image object" );
-
- if( pyimg == Py_None ) {
- mf->image = NULL;
-
- return 0;
- }
-
- mf->image = ( ( BPy_Image * ) pyimg )->image;
-
- return 0;
- }
-
- return EXPP_ReturnIntError( PyExc_AttributeError, name );
-}
-
-static PyObject *NMFace_repr( PyObject * self )
-{
- return PyString_FromString( "[NMFace]" );
-}
-
-static int NMFace_len( BPy_NMFace * self )
-{
- return PySequence_Length( self->v );
-}
-
-static PyObject *NMFace_item( BPy_NMFace * self, int i )
-{
- return PySequence_GetItem( self->v, i ); // new ref
-}
-
-static PyObject *NMFace_slice( BPy_NMFace * self, int begin, int end )
-{
- return PyList_GetSlice( self->v, begin, end ); // new ref
-}
-
-static PySequenceMethods NMFace_SeqMethods = {
- ( inquiry ) NMFace_len, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) NMFace_item, /* sq_item */
- ( intintargfunc ) NMFace_slice, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- 0,0,0,
-};
-
-PyTypeObject NMFace_Type = {
- PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
- "Blender NMFace", /*tp_name */
- sizeof( BPy_NMFace ), /*tp_basicsize */
- 0, /*tp_itemsize */
- /* methods */
- ( destructor ) NMFace_dealloc, /*tp_dealloc */
- ( printfunc ) 0, /*tp_print */
- ( getattrfunc ) NMFace_getattr, /*tp_getattr */
- ( setattrfunc ) NMFace_setattr, /*tp_setattr */
- 0, /*tp_compare */
- ( reprfunc ) NMFace_repr, /*tp_repr */
- 0, /*tp_as_number */
- &NMFace_SeqMethods, /*tp_as_sequence */
- 0, /*tp_as_mapping */
- 0, /*tp_hash */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del to avoid a warning */
-};
-
-static BPy_NMVert *newvert( float *co )
-{
- BPy_NMVert *mv = PyObject_NEW( BPy_NMVert, &NMVert_Type );
-
- mv->co[0] = co[0];
- mv->co[1] = co[1];
- mv->co[2] = co[2];
-
- mv->no[0] = mv->no[1] = mv->no[2] = 0.0;
- mv->uvco[0] = mv->uvco[1] = mv->uvco[2] = 0.0;
- mv->flag = 0;
-
- return mv;
-}
-
-static PyObject *M_NMesh_Vert( PyObject * self, PyObject * args )
-{
- float co[3] = { 0.0, 0.0, 0.0 };
-
- if( !PyArg_ParseTuple( args, "|fff", &co[0], &co[1], &co[2] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected three floats (or nothing) as arguments" );
-
- return ( PyObject * ) newvert( co );
-}
-
-static void NMVert_dealloc( PyObject * self )
-{
- PyObject_DEL( self );
-}
-
-static PyObject *NMVert_getattr( PyObject * self, char *name )
-{
- BPy_NMVert *mv = ( BPy_NMVert * ) self;
-
- if( !strcmp( name, "co" ) || !strcmp( name, "loc" ) )
- return newVectorObject(mv->co,3,Py_WRAP);
-
- else if( strcmp( name, "no" ) == 0 )
- return newVectorObject(mv->no,3,Py_WRAP);
- else if( strcmp( name, "uvco" ) == 0 )
- return newVectorObject(mv->uvco,3,Py_WRAP);
- else if( strcmp( name, "index" ) == 0 )
- return PyInt_FromLong( mv->index );
- else if( strcmp( name, "sel" ) == 0 )
- return PyInt_FromLong( mv->flag & 1 );
- else if( strcmp( name, "__members__" ) == 0 )
- return Py_BuildValue( "[s,s,s,s,s]", "co", "no", "uvco",
- "index", "sel" );
-
- return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
-}
-
-static int NMVert_setattr( PyObject * self, char *name, PyObject * v )
-{
- BPy_NMVert *mv = ( BPy_NMVert * ) self;
- int i;
-
- if( strcmp( name, "index" ) == 0 ) {
- PyArg_Parse( v, "i", &i );
- mv->index = i;
- return 0;
- } else if( strcmp( name, "sel" ) == 0 ) {
- PyArg_Parse( v, "i", &i );
- mv->flag = i ? 1 : 0;
- return 0;
- } else if( strcmp( name, "uvco" ) == 0 ) {
-
- if( !PyArg_ParseTuple( v, "ff|f",
- &( mv->uvco[0] ), &( mv->uvco[1] ),
- &( mv->uvco[2] ) ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "Vector tuple or triple expected" );
-
- return 0;
- }
-
- return EXPP_ReturnIntError( PyExc_AttributeError, name );
-}
-
-static int NMVert_len( BPy_NMVert * self )
-{
- return 3;
-}
-
-static PyObject *NMVert_item( BPy_NMVert * self, int i )
-{
- if( i < 0 || i >= 3 )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-
- return Py_BuildValue( "f", self->co[i] );
-}
-
-static PyObject *NMVert_slice( BPy_NMVert * self, int begin, int end )
-{
- PyObject *list;
- int count;
-
- if( begin < 0 )
- begin = 0;
- if( end > 3 )
- end = 3;
- if( begin > end )
- begin = end;
-
- list = PyList_New( end - begin );
-
- for( count = begin; count < end; count++ )
- PyList_SetItem( list, count - begin,
- PyFloat_FromDouble( self->co[count] ) );
-
- return list;
-}
-
-static int NMVert_ass_item( BPy_NMVert * self, int i, PyObject * ob )
-{
- if( i < 0 || i >= 3 )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "array assignment index out of range" );
-
- if( !PyNumber_Check( ob ) )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "NMVert member must be a number" );
-
- self->co[i] = (float)PyFloat_AsDouble( ob );
-
- return 0;
-}
-
-static int NMVert_ass_slice( BPy_NMVert * self, int begin, int end,
- PyObject * seq )
-{
- int count;
-
- if( begin < 0 )
- begin = 0;
- if( end > 3 )
- end = 3;
- if( begin > end )
- begin = end;
-
- if( !PySequence_Check( seq ) )
- EXPP_ReturnIntError( PyExc_TypeError,
- "illegal argument type for built-in operation" );
-
- if( PySequence_Length( seq ) != ( end - begin ) )
- EXPP_ReturnIntError( PyExc_TypeError,
- "size mismatch in slice assignment" );
-
- for( count = begin; count < end; count++ ) {
- PyObject *ob = PySequence_GetItem( seq, count );
-
- if( !PyArg_Parse( ob, "f", &self->co[count] ) ) {
- Py_DECREF( ob );
- return -1;
- }
-
- Py_DECREF( ob );
- }
-
- return 0;
-}
-
-static PySequenceMethods NMVert_SeqMethods = {
- ( inquiry ) NMVert_len, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) NMVert_item, /* sq_item */
- ( intintargfunc ) NMVert_slice, /* sq_slice */
- ( intobjargproc ) NMVert_ass_item, /* sq_ass_item */
- ( intintobjargproc ) NMVert_ass_slice, /* sq_ass_slice */
- 0,0,0,
-};
-
-PyTypeObject NMVert_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /*ob_size */
- "Blender NMVert", /*tp_name */
- sizeof( BPy_NMVert ), /*tp_basicsize */
- 0, /*tp_itemsize */
- /* methods */
- ( destructor ) NMVert_dealloc, /*tp_dealloc */
- ( printfunc ) 0, /*tp_print */
- ( getattrfunc ) NMVert_getattr, /*tp_getattr */
- ( setattrfunc ) NMVert_setattr, /*tp_setattr */
- 0, /*tp_compare */
- ( reprfunc ) 0, /*tp_repr */
- 0, /*tp_as_number */
- &NMVert_SeqMethods, /*tp_as_sequence */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_del */
-};
-
-
-/*****************************
- * NMEdge
- *****************************/
-
-static BPy_NMEdge *new_NMEdge( BPy_NMVert * v1, BPy_NMVert * v2, char crease, short flag)
-{
- BPy_NMEdge *edge=NULL;
-
- if (!v1 || !v2) return NULL;
- if (!BPy_NMVert_Check(v1) || !BPy_NMVert_Check(v2)) return NULL;
-
- edge = PyObject_NEW( BPy_NMEdge, &NMEdge_Type );
-
- edge->v1=EXPP_incr_ret((PyObject*)v1);
- edge->v2=EXPP_incr_ret((PyObject*)v2);
- edge->flag=flag;
- edge->crease=crease;
-
- return edge;
-}
-
-static void NMEdge_dealloc( PyObject * self )
-{
- BPy_NMEdge *edge=(BPy_NMEdge *)self;
-
- Py_DECREF(edge->v1);
- Py_DECREF(edge->v2);
-
- PyObject_DEL(self);
-}
-
-static PyObject *NMEdge_getattr( PyObject * self, char *name )
-{
- BPy_NMEdge *edge=(BPy_NMEdge *)self;
-
- if ( strcmp( name, "v1" ) == 0 )
- return EXPP_incr_ret( edge->v1 );
- else if ( strcmp( name, "v2" ) == 0 )
- return EXPP_incr_ret( edge->v2 );
- else if ( strcmp( name, "flag" ) == 0 )
- return PyInt_FromLong( edge->flag );
- else if ( strcmp( name, "crease" ) == 0 )
- return PyInt_FromLong( edge->crease );
- else if( strcmp( name, "__members__" ) == 0 )
- return Py_BuildValue( "[s,s,s,s]",
- "v1", "v2", "flag", "crease" );
-
- return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
-}
-
-static int NMEdge_setattr( PyObject * self, char *name, PyObject * v )
-{
- BPy_NMEdge *edge=(BPy_NMEdge *)self;
-
- if ( strcmp( name, "flag" ) == 0 )
- {
- short flag=0;
- if( !PyInt_Check( v ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- flag = ( short ) PyInt_AsLong( v );
-
- edge->flag = flag;
-
- return 0;
- }
- else if ( strcmp( name, "crease" ) == 0 )
- {
- char crease=0;
- if( !PyInt_Check( v ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- crease = ( char ) PyInt_AsLong( v );
-
- edge->crease = crease;
-
- return 0;
- }
-
- return EXPP_ReturnIntError( PyExc_AttributeError, name );
-}
-
-PyTypeObject NMEdge_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /*ob_size */
- "Blender NMEdge", /*tp_name */
- sizeof( BPy_NMEdge ), /*tp_basicsize */
- 0, /*tp_itemsize */
- /* methods */
- ( destructor ) NMEdge_dealloc, /*tp_dealloc */
- ( printfunc ) 0, /*tp_print */
- ( getattrfunc ) NMEdge_getattr, /*tp_getattr */
- ( setattrfunc ) NMEdge_setattr, /*tp_setattr */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,
-};
-
-static void NMesh_dealloc( PyObject * self )
-{
- BPy_NMesh *me = ( BPy_NMesh * ) self;
-
- CustomData_free( &me->fdata, me->totfdata );
-
- Py_DECREF( me->name );
- Py_DECREF( me->verts );
- Py_DECREF( me->faces );
- Py_DECREF( me->materials );
- Py_DECREF( me->edges );
-
- PyObject_DEL( self );
-}
-
-static PyObject *NMesh_getMaterials( PyObject * self, PyObject * args )
-{
- BPy_NMesh *nm = ( BPy_NMesh * ) self;
- PyObject *list = NULL;
- Mesh *me = nm->mesh;
- int all = -1;
-
- if( !PyArg_ParseTuple( args, "|i", &all ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or an int (bool) as argument" );
-
- if( all >= 0 ) {
- if (!me)
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "meshes obtained with GetRawFromObject don't support this option");
-
- list = EXPP_PyList_fromMaterialList( me->mat, me->totcol,
- all );
- Py_DECREF( nm->materials ); /* update nmesh.materials attribute */
- nm->materials = EXPP_incr_ret( list );
- } else
- list = EXPP_incr_ret( nm->materials );
-
- return list;
-}
-
-static PyObject *NMesh_setMaterials( PyObject * self, PyObject * args )
-{
- BPy_NMesh *me = ( BPy_NMesh * ) self;
- PyObject *pymats = NULL;
-
- if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &pymats ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of materials (None's also accepted) as argument" );
-
- if( !EXPP_check_sequence_consistency( pymats, &Material_Type ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "list should only contain materials (None's also accepted)" );
-
- if( PyList_Size( pymats ) > 16 )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "list can't have more than 16 materials" );
-
- Py_DECREF( me->materials );
- me->materials = EXPP_incr_ret( pymats );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_addMaterial( PyObject * self, PyObject * args )
-{
- BPy_NMesh *me = ( BPy_NMesh * ) self;
- BPy_Material *pymat;
- Material *mat;
- PyObject *iter;
- int i, len = 0;
-
- if( !PyArg_ParseTuple( args, "O!", &Material_Type, &pymat ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Blender Material PyObject" );
-
- mat = pymat->material;
- len = PyList_Size( me->materials );
-
- if( len >= 16 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "object data material lists can't have more than 16 materials" );
-
- for( i = 0; i < len; i++ ) {
- iter = PyList_GetItem( me->materials, i );
- if( mat == Material_FromPyObject( iter ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "material already in the list" );
- }
-
- PyList_Append( me->materials, ( PyObject * ) pymat );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_getKey( BPy_NMesh * self )
-{
- PyObject *keyobj;
-
- if( self->mesh->key )
- keyobj = Key_CreatePyObject(self->mesh->key);
- else
- keyobj = EXPP_incr_ret(Py_None);
-
- return keyobj;
-}
-
-static PyObject *NMesh_removeAllKeys( PyObject * self, PyObject * args )
-{
- BPy_NMesh *nm = ( BPy_NMesh * ) self;
- Mesh *me = nm->mesh;
-
- if( !PyArg_ParseTuple( args, "" ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "this function expects no arguments" );
-
- if( !me || !me->key )
- return EXPP_incr_ret_False();
-
- me->key->id.us--;
- me->key = 0;
-
- return EXPP_incr_ret_True();
-}
-
-static PyObject *NMesh_insertKey( PyObject * self, PyObject * args )
-{
- int fra = -1, oldfra = -1;
- char *type = NULL;
- short typenum;
- BPy_NMesh *nm = ( BPy_NMesh * ) self;
- Mesh *mesh = nm->mesh;
-
- if( !PyArg_ParseTuple( args, "|is", &fra, &type ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or an int and optionally a string as arguments" );
-
- if( !type || !strcmp( type, "relative" ) )
- typenum = 1;
- else if( !strcmp( type, "absolute" ) )
- typenum = 2;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "if given, type should be 'relative' or 'absolute'" );
-
- if( fra > 0 ) {
- fra = EXPP_ClampInt( fra, 1, NMESH_FRAME_MAX );
- oldfra = G.scene->r.cfra;
- G.scene->r.cfra = (int)fra;
- }
-
- if( !mesh )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "update this NMesh first with its .update() method" );
-
- insert_meshkey( mesh, typenum );
- allspace(REMAKEIPO, 0);
-
- if( fra > 0 )
- G.scene->r.cfra = (int)oldfra;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_getSelectedFaces( PyObject * self, PyObject * args )
-{
- BPy_NMesh *nm = ( BPy_NMesh * ) self;
- Mesh *me = nm->mesh;
- int i, totfaces, flag = 0;
- PyObject *l, *pyval;
-
- if( !PyArg_ParseTuple( args, "|i", &flag ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected int argument (or nothing)" );
-
- l = PyList_New( 0 );
- if( me == NULL || me->mface == NULL)
- return l;
-
- /* make sure not to write more faces then we have */
- totfaces= MIN2(me->totface, PySequence_Length(nm->faces));
-
- if( flag ) {
- for( i = 0; i < totfaces; i++ ) {
- if( me->mface[i].flag & ME_FACE_SEL ) {
- pyval = PyInt_FromLong( i );
- PyList_Append( l, pyval );
- Py_DECREF(pyval);
- }
- }
- } else {
- for( i = 0; i < totfaces; i++ ) {
- if( me->mface[i].flag & ME_FACE_SEL )
- PyList_Append( l, PyList_GetItem( nm->faces, i ) );
- }
- }
- return l;
-}
-
-static PyObject *NMesh_getActiveFace( PyObject * self )
-{
- if( ( ( BPy_NMesh * ) self )->sel_face < 0 )
- Py_RETURN_NONE;
-
- return Py_BuildValue( "i", ( ( BPy_NMesh * ) self )->sel_face );
-}
-
-static PyObject *NMesh_hasVertexUV( PyObject * self, PyObject * args )
-{
- BPy_NMesh *me = ( BPy_NMesh * ) self;
- int flag = -1;
-
- if( !PyArg_ParseTuple( args, "|i", &flag ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument (or nothing)" );
-
- switch ( flag ) {
- case 0:
- me->flags &= ~NMESH_HASVERTUV;
- break;
- case 1:
- me->flags |= NMESH_HASVERTUV;
- break;
- default:
- break;
- }
-
- if( me->flags & NMESH_HASVERTUV )
- return EXPP_incr_ret_True();
- else
- return EXPP_incr_ret_False();
-}
-
-static PyObject *NMesh_hasFaceUV( PyObject * self, PyObject * args )
-{
- BPy_NMesh *me = ( BPy_NMesh * ) self;
- int flag = -1;
-
- if( !PyArg_ParseTuple( args, "|i", &flag ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument (or nothing)" );
-
- switch ( flag ) {
- case 0:
- me->flags &= ~NMESH_HASFACEUV;
- break;
- case 1:
- me->flags |= NMESH_HASFACEUV;
- break;
- default:
- break;
- }
-
- if( me->flags & NMESH_HASFACEUV )
- return EXPP_incr_ret_True();
- else
- return EXPP_incr_ret_False();
-}
-
-static PyObject *NMesh_hasVertexColours( PyObject * self, PyObject * args )
-{
- BPy_NMesh *me = ( BPy_NMesh * ) self;
- int flag = -1;
-
- if( !PyArg_ParseTuple( args, "|i", &flag ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument (or nothing)" );
-
- switch ( flag ) {
- case 0:
- me->flags &= ~NMESH_HASMCOL;
- break;
- case 1:
- me->flags |= NMESH_HASMCOL;
- break;
- default:
- break;
- }
-
- if( me->flags & NMESH_HASMCOL )
- return EXPP_incr_ret_True();
- else
- return EXPP_incr_ret_False();
-}
-
-static PyObject *NMesh_update( PyObject *self, PyObject *a, PyObject *kwd )
-{
- BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
- Mesh *mesh = nmesh->mesh;
- int recalc_normals = 0, store_edges = 0, vertex_shade = 0;
- static char *kwlist[] = {"recalc_normals", "store_edges",
- "vertex_shade", NULL};
- int needs_redraw = 1;
- int old_totvert = 0;
-
- if (!PyArg_ParseTupleAndKeywords(a, kwd, "|iii", kwlist, &recalc_normals,
- &store_edges, &vertex_shade ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected nothing or one to three bool(s) (0 or 1) as argument" );
-
- if( check_NMeshLists( nmesh ) )
- return NULL;
-
- if( mesh ) {
- old_totvert = mesh->totvert;
- unlink_existingMeshData( mesh );
- if( !convert_NMeshToMesh( mesh, nmesh ) )
- return NULL;
- if (mesh->dvert) check_dverts(mesh, old_totvert);
- } else {
- mesh = Mesh_fromNMesh( nmesh );
- /* if mesh is NULL, there was an error */
- if( !mesh )
- return NULL;
- nmesh->mesh = mesh;
- }
-
- if( recalc_normals )
- mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, mesh->totface, NULL);
-
- mesh_update( mesh, nmesh->object );
-
- nmesh_updateMaterials( nmesh );
-
- if( nmesh->name && nmesh->name != Py_None )
- new_id( &( G.main->mesh ), &mesh->id,
- PyString_AsString( nmesh->name ) );
-
- if (vertex_shade) {
- Base *base = FIRSTBASE;
-
- if (!nmesh->object)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "link this mesh to an object first with ob.link(mesh)" );
-
- if (G.obedit)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "can't shade vertices while in edit mode" );
-
- while (base) {
- if (base->object == nmesh->object) {
- base->flag |= SELECT;
- nmesh->object->flag = (short)base->flag;
- set_active_base (base);
- needs_redraw = 0; /* already done in make_vertexcol */
- break;
- }
- base = base->next;
- }
-
- /* recalculate the derived mesh before trying to use it */
- makeDerivedMesh(nmesh->object, CD_MASK_BAREMESH);
- make_vertexcol(1);
-
- countall();
- }
-
- if( !during_script( ) && needs_redraw)
- EXPP_allqueue( REDRAWVIEW3D, 0 );
-
- return PyInt_FromLong( 1 );
-}
-
-/** Implementation of the python method getVertexInfluence for an NMesh object.
- * This method returns a list of pairs (string,float) with bone names and
- * influences that this vertex receives.
- * @author Jordi Rovira i Bonet
- */
-
-static PyObject *NMesh_getVertexInfluences( PyObject * self, PyObject * args )
-{
- int index;
- PyObject *influence_list = NULL;
- Object *object = ( ( BPy_NMesh * ) self )->object;
- Mesh *me = ( ( BPy_NMesh * ) self )->mesh;
-
- /* Get a reference to the mesh object wrapped in here. */
- if( !me )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "unlinked nmesh: call its .update() method first" );
-
- if( !object )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This mesh must be linked to an object" );
-
- /* Parse the parameters: only on integer (vertex index) */
- if( !PyArg_ParseTuple( args, "i", &index ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument (index of the vertex)" );
-
- /* check for valid index */
- if( index < 0 || index >= me->totvert )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "vertex index out of range" );
-
- influence_list = PyList_New( 0 );
-
- /* Proceed only if we have vertex deformation information */
- if( me->dvert ) {
- int i;
- MDeformWeight *sweight = NULL;
-
- /* Number of bones influencing the vertex */
- int totinfluences = me->dvert[index].totweight;
-
- /* Get the reference of the first weight structure */
- sweight = me->dvert[index].dw;
-
- /* Build the list only with weights and names of the influent bones */
- for( i = 0; i < totinfluences; i++, sweight++ ) {
- bDeformGroup *defgroup = (bDeformGroup *) BLI_findlink( &object->defbase,
- sweight->def_nr );
- if( defgroup )
- PyList_Append( influence_list, Py_BuildValue( "[sf]",
- defgroup->name, sweight->weight ) );
- }
- }
-
- return influence_list;
-}
-
-Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh )
-{
- Mesh *mesh = NULL;
-
- mesh = add_mesh( "Mesh" );
-
- if( !mesh ) {
- PyErr_SetString( PyExc_RuntimeError,
- "FATAL: could not create mesh object" );
- return NULL;
- }
-
- mesh->id.us = 0; /* no user yet */
- G.totmesh++;
-
- if( !convert_NMeshToMesh( mesh, nmesh ) )
- return NULL;
-
- return mesh;
-}
-
-static PyObject *NMesh_getMaxSmoothAngle( BPy_NMesh * self )
-{
- return PyInt_FromLong( self->smoothresh );
-}
-
-static PyObject *NMesh_setMaxSmoothAngle( PyObject * self, PyObject * args )
-{
- short value = 0;
- BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
-
- if( !PyArg_ParseTuple( args, "h", &value ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected an int in [1, 80] as argument" );
-
- nmesh->smoothresh =
- ( short ) EXPP_ClampInt( value, NMESH_SMOOTHRESH_MIN,
- NMESH_SMOOTHRESH_MAX );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_getSubDivLevels( BPy_NMesh * self )
-{
- return Py_BuildValue( "[h,h]", self->subdiv[0], self->subdiv[1] );
-}
-
-static PyObject *NMesh_setSubDivLevels( PyObject * self, PyObject * args )
-{
- short display = 0, render = 0;
- BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
-
- if( !PyArg_ParseTuple( args, "(hh)", &display, &render ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a sequence [int, int] as argument" );
-
- nmesh->subdiv[0] =
- ( short ) EXPP_ClampInt( display, NMESH_SUBDIV_MIN,
- NMESH_SUBDIV_MAX );
-
- nmesh->subdiv[1] =
- ( short ) EXPP_ClampInt( render, NMESH_SUBDIV_MIN,
- NMESH_SUBDIV_MAX );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_getMode( BPy_NMesh * self )
-{
- return PyInt_FromLong( self->mode );
-}
-
-static PyObject *NMesh_setMode( PyObject * self, PyObject * args )
-{
- BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
- PyObject *arg1 = NULL;
- char *m[5] = { NULL, NULL, NULL, NULL, NULL };
- short i, mode = 0;
-
- if( !PyArg_ParseTuple ( args, "|Ossss", &arg1, &m[1], &m[2], &m[3], &m[4] ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected an int or from none to 5 strings as argument(s)" );
-
- if (arg1) {
- if (PyInt_Check(arg1)) {
- mode = (short)PyInt_AsLong(arg1);
- }
- else if (PyString_Check(arg1)) {
- m[0] = PyString_AsString(arg1);
- for( i = 0; i < 5; i++ ) {
- if( !m[i] ) break;
- else if( strcmp( m[i], "NoVNormalsFlip" ) == 0 )
- mode |= ME_NOPUNOFLIP;
- else if( strcmp( m[i], "TwoSided" ) == 0 )
- mode |= ME_TWOSIDED;
- else if( strcmp( m[i], "AutoSmooth" ) == 0 )
- mode |= ME_AUTOSMOOTH;
- else if( m[i][0] == '\0' )
- mode = 0;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown NMesh mode" );
- }
- }
- else return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected an int or from none to 5 strings as argument(s)" );
- }
-
- nmesh->mode = mode;
-
- Py_RETURN_NONE;
-}
-
-/* METH_VARARGS: function(PyObject *self, PyObject *args) */
-#undef MethodDef
-#define MethodDef(func) {#func, NMesh_##func, METH_VARARGS, NMesh_##func##_doc}
-
-static struct PyMethodDef NMesh_methods[] = {
- MethodDef( addEdge ),
- MethodDef( findEdge ),
- MethodDef( removeEdge ),
- MethodDef( addFace ),
- MethodDef( removeFace ),
- MethodDef( addVertGroup ),
- MethodDef( removeVertGroup ),
- MethodDef( assignVertsToGroup ),
- MethodDef( removeVertsFromGroup ),
- MethodDef( getVertsFromGroup ),
- MethodDef( renameVertGroup ),
- MethodDef( hasVertexColours ),
- MethodDef( hasFaceUV ),
- MethodDef( hasVertexUV ),
- MethodDef( getSelectedFaces ),
- MethodDef( getVertexInfluences ),
- MethodDef( getMaterials ),
- MethodDef( setMaterials ),
- MethodDef( addMaterial ),
- MethodDef( insertKey ),
- MethodDef( removeAllKeys ),
- MethodDef( setMode ),
- MethodDef( setMaxSmoothAngle ),
- MethodDef( setSubDivLevels ),
- MethodDef( transform ),
-
-/* METH_NOARGS: function(PyObject *self) */
-#undef MethodDef
-#define MethodDef(func) {#func, (PyCFunction)NMesh_##func, METH_NOARGS,\
- NMesh_##func##_doc}
-
- MethodDef( printDebug ),
- MethodDef( getVertGroupNames ),
- MethodDef( getActiveFace ),
- MethodDef( getKey ),
- MethodDef( getMode ),
- MethodDef( getMaxSmoothAngle ),
- MethodDef( getSubDivLevels ),
-
-/* METH_VARARGS | METH_KEYWORDS:
- * function(PyObject *self, PyObject *args, PyObject *keywords) */
-#undef MethodDef
-#define MethodDef(func) {#func, (PyCFunction)NMesh_##func,\
- METH_VARARGS | METH_KEYWORDS, NMesh_##func##_doc}
-
- MethodDef( update ),
- {NULL, NULL, 0, NULL}
-};
-
-static PyObject *NMesh_getattr( PyObject * self, char *name )
-{
- BPy_NMesh *me = ( BPy_NMesh * ) self;
-
- if( strcmp( name, "name" ) == 0 )
- return EXPP_incr_ret( me->name );
-
- else if ( strcmp( name, "properties" ) == 0 )
- return BPy_Wrap_IDProperty( (ID*)me->mesh, IDP_GetProperties((ID*)me->mesh, 1), NULL );
-
- else if( strcmp( name, "mode" ) == 0 )
- return PyInt_FromLong( me->mode );
-
- else if( strcmp( name, "block_type" ) == 0 ) /* for compatibility */
- return PyString_FromString( "NMesh" );
-
- else if( strcmp( name, "materials" ) == 0 )
- return EXPP_incr_ret( me->materials );
-
- else if( strcmp( name, "verts" ) == 0 )
- return EXPP_incr_ret( me->verts );
-
- else if( strcmp( name, "maxSmoothAngle" ) == 0 )
- return PyInt_FromLong( me->smoothresh );
-
- else if( strcmp( name, "subDivLevels" ) == 0 )
- return Py_BuildValue( "[h,h]", me->subdiv[0], me->subdiv[1] );
-
- else if( strcmp( name, "users" ) == 0 ) {
- if( me->mesh ) {
- return PyInt_FromLong( me->mesh->id.us );
- } else { /* it's a free mesh: */
- return Py_BuildValue( "i", 0 );
- }
- }
- else if (strcmp( name, "key") == 0)
- return NMesh_getKey((BPy_NMesh*)self);
-
- else if( strcmp( name, "faces" ) == 0 )
- return EXPP_incr_ret( me->faces );
-
- else if( strcmp( name, "edges" ) == 0 )
- {
- return EXPP_incr_ret( me->edges );
- }
- else if( strcmp( name, "__members__" ) == 0 )
- return Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s]",
- "name", "materials", "verts", "users",
- "faces", "maxSmoothAngle",
- "subdivLevels", "edges", "key" );
-
- return Py_FindMethod( NMesh_methods, ( PyObject * ) self, name );
-}
-
-static int NMesh_setattr( PyObject * self, char *name, PyObject * v )
-{
- BPy_NMesh *me = ( BPy_NMesh * ) self;
-
- if( !strcmp( name, "name" ) ) {
-
- if( !PyString_Check( v ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string argument" );
-
- Py_DECREF( me->name );
- me->name = EXPP_incr_ret( v );
- }
-
- else if( !strcmp( name, "mode" ) ) {
- short mode;
-
- if( !PyInt_Check( v ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- mode = ( short ) PyInt_AsLong( v );
- if( mode >= 0 )
- me->mode = mode;
- else
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected positive int argument" );
- }
-
- else if( !strcmp( name, "verts" ) || !strcmp( name, "faces" ) ||
- !strcmp( name, "materials" ) ) {
-
- if( PySequence_Check( v ) ) {
-
- if( strcmp( name, "materials" ) == 0 ) {
- Py_DECREF( me->materials );
- me->materials = EXPP_incr_ret( v );
- } else if( strcmp( name, "verts" ) == 0 ) {
- Py_DECREF( me->verts );
- me->verts = EXPP_incr_ret( v );
- } else {
- Py_DECREF( me->faces );
- me->faces = EXPP_incr_ret( v );
- }
- }
-
- else
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list" );
- }
-
- else if( !strcmp( name, "maxSmoothAngle" ) ) {
- short smoothresh = 0;
-
- if( !PyInt_Check( v ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- smoothresh = ( short ) PyInt_AsLong( v );
-
- me->smoothresh =
- (short)EXPP_ClampInt( smoothresh, NMESH_SMOOTHRESH_MIN,
- NMESH_SMOOTHRESH_MAX );
- }
-
- else if( !strcmp( name, "subDivLevels" ) ) {
- int subdiv[2] = { 0, 0 };
- int i;
- PyObject *tmp;
-
- if( !PySequence_Check( v ) || ( PySequence_Length( v ) != 2 ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list [int, int] as argument" );
-
- for( i = 0; i < 2; i++ ) {
- tmp = PySequence_GetItem( v, i );
- if( tmp ) {
- if( !PyInt_Check( tmp ) ) {
- Py_DECREF( tmp );
- return EXPP_ReturnIntError
- ( PyExc_TypeError,
- "expected a list [int, int] as argument" );
- }
-
- subdiv[i] = PyInt_AsLong( tmp );
- me->subdiv[i] =
- ( short ) EXPP_ClampInt( subdiv[i],
- NMESH_SUBDIV_MIN,
- NMESH_SUBDIV_MAX );
- Py_DECREF( tmp );
- } else
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "couldn't retrieve subdiv values from list" );
- }
- }
- else if( strcmp( name, "edges" ) == 0 )
- {
- if (PySequence_Check(v))
- {
- Py_DECREF(me->edges);
- me->edges = EXPP_incr_ret( v );
- }
- }
- else
- return EXPP_ReturnIntError( PyExc_AttributeError, name );
-
- return 0;
-}
-
-PyTypeObject NMesh_Type = {
- PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
- "Blender NMesh", /*tp_name */
- sizeof( BPy_NMesh ), /*tp_basicsize */
- 0, /*tp_itemsize */
- /* methods */
- ( destructor ) NMesh_dealloc, /*tp_dealloc */
- ( printfunc ) 0, /*tp_print */
- ( getattrfunc ) NMesh_getattr, /*tp_getattr */
- ( setattrfunc ) NMesh_setattr, /*tp_setattr */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-
-static BPy_NMFace *nmface_from_data( BPy_NMesh * mesh, int vidxs[4],
- char mat_nr, char flag, MTFace * tface, MCol * col, int orig_index )
-{
- BPy_NMFace *newf = PyObject_NEW( BPy_NMFace, &NMFace_Type );
- int i, len;
-
- if( vidxs[3] )
- len = 4;
- else
- len = 3;
-
- newf->v = PyList_New( len );
-
- for( i = 0; i < len; i++ )
- PyList_SetItem( newf->v, i,
- EXPP_incr_ret( PyList_GetItem
- ( mesh->verts, vidxs[i] ) ) );
-
- if( tface ) {
- newf->uv = PyList_New( len ); // per-face UV coordinates
-
- for( i = 0; i < len; i++ ) {
- PyList_SetItem( newf->uv, i,
- Py_BuildValue( "(ff)", tface->uv[i][0],
- tface->uv[i][1] ) );
- }
-
- if( tface->tpage ) /* pointer to image per face: */
- newf->image = ( Image * ) tface->tpage;
- else
- newf->image = NULL;
-
- newf->mode = tface->mode; /* draw mode */
- newf->flag = tface->flag; /* select flag */
- newf->transp = tface->transp; /* transparency flag */
- } else {
- newf->mode = TF_DYNAMIC; /* just to initialize it to something meaninful, */
- /* since without tfaces there are no tface->mode's, obviously. */
- newf->image = NULL;
- newf->uv = PyList_New( 0 );
- }
-
- newf->mat_nr = mat_nr;
- newf->mf_flag = flag; /* MFace flag */
- newf->orig_index = orig_index;
-
- if( col ) {
- newf->col = PyList_New( 4 );
- for( i = 0; i < 4; i++, col++ ) {
- PyList_SetItem( newf->col, i,
- ( PyObject * ) newcol( col->b, col->g,
- col->r,
- col->a ) );
- }
- } else
- newf->col = PyList_New( 0 );
-
- return newf;
-}
-
-static BPy_NMEdge *nmedge_from_index( BPy_NMesh * mesh, int v0idx, int v1idx)
-{
- BPy_NMVert *v1=(BPy_NMVert *)PyList_GetItem( mesh->verts, v0idx);
- BPy_NMVert *v2=(BPy_NMVert *)PyList_GetItem( mesh->verts, v1idx);
- return new_NMEdge(v1, v2, (char)0.0, 0);
-}
-
-static BPy_NMEdge *nmedge_from_data( BPy_NMesh * mesh, MEdge *edge )
-{
- BPy_NMVert *v1=(BPy_NMVert *)PyList_GetItem( mesh->verts, edge->v1 );
- BPy_NMVert *v2=(BPy_NMVert *)PyList_GetItem( mesh->verts, edge->v2 );
- return new_NMEdge(v1, v2, edge->crease, edge->flag);
-}
-
-static BPy_NMVert *nmvert_from_data( MVert * vert, MSticky * st, float *co,
- int idx, char flag )
-{
- BPy_NMVert *mv = PyObject_NEW( BPy_NMVert, &NMVert_Type );
-
- mv->co[0] = co[0];
- mv->co[1] = co[1];
- mv->co[2] = co[2];
-
- mv->no[0] = (float)(vert->no[0] / 32767.0);
- mv->no[1] = (float)(vert->no[1] / 32767.0);
- mv->no[2] = (float)(vert->no[2] / 32767.0);
-
- if( st ) {
- mv->uvco[0] = st->co[0];
- mv->uvco[1] = st->co[1];
- mv->uvco[2] = 0.0;
-
- } else
- mv->uvco[0] = mv->uvco[1] = mv->uvco[2] = 0.0;
-
- mv->index = idx;
- mv->flag = flag & 1;
-
- return mv;
-}
-
-static int get_active_faceindex( Mesh * me )
-{
- if( me == NULL )
- return -1;
-
- if (me->act_face != -1 && me->act_face < me->totface)
- return me->act_face;
- return -1;
-}
-
-static BPy_NMVert *nmvert_from_float(float *co, float *no, int idx) {
- BPy_NMVert *mv;
-
- mv = PyObject_NEW( BPy_NMVert, &NMVert_Type );
-
- mv->index = idx;
-
- mv->co[0] = co[0];
- mv->co[1] = co[1];
- mv->co[2] = co[2];
-
- mv->no[0] = no[0];
- mv->no[1] = no[1];
- mv->no[2] = no[2];
-
- mv->uvco[0] = mv->uvco[1] = mv->uvco[2] = 0.0;
-
- mv->flag = 0;
-
- return mv;
-}
-
-static BPy_NMFace *nmface_from_index( BPy_NMesh * mesh, int vidxs[4], char mat_nr )
-{
- BPy_NMFace *newf = PyObject_NEW( BPy_NMFace, &NMFace_Type );
- int i, len;
-
- if( vidxs[3] )
- len = 4;
- else if( vidxs[2] )
- len = 3;
- else
- len = 2;
-
- newf->v = PyList_New( len );
-
- for( i = 0; i < len; i++ )
- PyList_SetItem( newf->v, i,
- EXPP_incr_ret( PyList_GetItem
- ( mesh->verts, vidxs[i] ) ) );
-
- newf->mode = TF_DYNAMIC; /* just to initialize it to something meaninful, */
- /* since without tfaces there are no tface->mode's, obviously. */
- newf->image = NULL;
- newf->uv = PyList_New( 0 );
-
- newf->mat_nr = mat_nr;
- newf->mf_flag = 0;
- newf->orig_index = -1;
-
- newf->col = PyList_New( 0 );
-
- return newf;
-}
-
-/* RATHER EVIL FUNCTION BORROWED FROM fix_faceindices IN editmesh.c */
-static void correctFaceIndex(int vidx[4])
-{
- if (vidx[3]) {
- if (vidx[1] == 0) {
- vidx[1] = vidx[2];
- vidx[2] = vidx[3];
- vidx[3] = vidx[0];
- vidx[0] = 0;
- }
- if (vidx[2] == 0) {
- int t = vidx[1];
- vidx[2] = vidx[0];
- vidx[1] = vidx[3];
- vidx[3] = t;
- vidx[0] = 0;
- }
- if (vidx[3] == 0) {
- vidx[3] = vidx[2];
- vidx[2] = vidx[1];
- vidx[1] = vidx[0];
- vidx[0] = 0;
- }
- }
- else if (vidx[1] == 0) {
- vidx[1] = vidx[2];
- vidx[2] = vidx[0];
- vidx[0] = 0;
- }
- else if (vidx[2] == 0) {
- vidx[2] = vidx[1];
- vidx[1] = vidx[0];
- vidx[0] = 0;
- }
-}
-
-/*
- CREATES A NMESH FROM DISPLIST DATA. INSPIRED BY THE FUNCTIONS CALLED WHEN
- CONVERTING OBJECTS TO MESH.
- */
-static PyObject *new_NMesh_displist(ListBase *lb, Object *ob)
-{
- BPy_NMesh *me;
- DispList *dl;
- float *data, *ndata;
- float normal[3] = {1, 0, 0};
- int vidx[4];
- int parts, p1, p2, p3, p4, a, b, one_normal=0, ioffset=0;
- int *index;
-
- /* Note: This routine does not create new edges for the faces
- * it adds... should be fixed for consistency.
- */
-
- if (ob->type == OB_CURVE || ob->type == OB_FONT)
- one_normal = 1;
-
- me = PyObject_NEW( BPy_NMesh, &NMesh_Type );
- me->name = EXPP_incr_ret( Py_None );
- me->flags = 0;
- me->mode = ME_TWOSIDED; /* default for new meshes */
- me->subdiv[0] = NMESH_SUBDIV;
- me->subdiv[1] = NMESH_SUBDIV;
- me->smoothresh = NMESH_SMOOTHRESH;
- me->edges = PyList_New( 0 );
-
- me->object = ob;
- me->materials = EXPP_PyList_fromMaterialList( ob->mat, ob->totcol, 0 );
-
- me->verts = PyList_New( 0 );
- me->faces = PyList_New( 0 );
-
- memset(&me->fdata, 0, sizeof(me->fdata));
- me->totfdata = 0;
-
- dl= lb->first;
- while(dl) {
- parts= dl->parts;
- index= dl->index;
- data= dl->verts;
- ndata= dl->nors;
-
- switch(dl->type) {
- case DL_SEGM:
- for(a=0; a<dl->parts*dl->nr; a++, data+=3) {
- PyList_Append(me->verts, ( PyObject * ) nmvert_from_float(data, normal, a));
- }
-
- vidx[2] = vidx[3] = 0;
-
- for(a=0; a<dl->parts; a++) {
- for(b=1; b<dl->nr; b++) {
- int v0 = ioffset + a * dl->nr + b-1;
- int v1 = ioffset + a * dl->nr + b;
- PyList_Append(me->edges, ( PyObject * ) nmedge_from_index(me, v0, v1));
- }
- }
- ioffset += dl->parts * dl->nr;
- break;
- case DL_POLY:
- for(a=0; a<dl->parts*dl->nr; a++, data+=3) {
- PyList_Append(me->verts, ( PyObject * ) nmvert_from_float(data, normal, a));
- }
-
- vidx[2] = vidx[3] = 0;
-
- for(a=0; a<dl->parts; a++) {
- for(b=0; b<dl->nr; b++) {
- int v1, v0 = ioffset + a * dl->nr + b;
- if(b==dl->nr-1) v1 = ioffset + a * dl->nr;
- else v1= ioffset + a * dl->nr + b+1;
- PyList_Append(me->edges, ( PyObject * ) nmedge_from_index(me, v0, v1));
- }
- }
- ioffset += dl->parts * dl->nr;
- break;
- case DL_SURF:
- for(a=0; a<dl->parts*dl->nr; a++, data+=3, ndata+=3) {
- PyList_Append(me->verts, ( PyObject * ) nmvert_from_float(data, ndata, a));
- }
-
- for(a=0; a<dl->parts; a++) {
-
- DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
-
-
- for(; b<dl->nr; b++) {
- vidx[0] = p2 + ioffset;
- vidx[1] = p1 + ioffset;
- vidx[2] = p3 + ioffset;
- vidx[3] = p4 + ioffset;
- correctFaceIndex(vidx);
-
- PyList_Append(me->faces, ( PyObject * ) nmface_from_index(me, vidx, (char)dl->col));
-
- p2 = p1;
- p4 = p3;
- p1++;
- p3++;
- }
- }
- ioffset += dl->parts * dl->nr;
- break;
-
- case DL_INDEX3:
- if (one_normal)
- for(a=0; a<dl->nr; a++, data+=3)
- PyList_Append(me->verts, ( PyObject * ) nmvert_from_float(data, ndata, a));
- else
- for(a=0; a<dl->nr; a++, data+=3, ndata+=3)
- PyList_Append(me->verts, ( PyObject * ) nmvert_from_float(data, ndata, a));
-
- while(parts--) {
- vidx[0] = index[0] + ioffset;
- vidx[1] = index[1] + ioffset;
- vidx[2] = index[2] + ioffset;
- vidx[3] = 0;
- correctFaceIndex(vidx);
-
- PyList_Append(me->faces, ( PyObject * ) nmface_from_index(me, vidx, (char)dl->col));
- index+= 3;
- }
- ioffset += dl->nr;
-
- break;
-
- case DL_INDEX4:
- for(a=0; a<dl->nr; a++, data+=3, ndata+=3) {
- PyList_Append(me->verts, ( PyObject * ) nmvert_from_float(data, ndata, a));
- }
-
- while(parts--) {
- vidx[0] = index[0] + ioffset;
- vidx[1] = index[1] + ioffset;
- vidx[2] = index[2] + ioffset;
- vidx[3] = index[3] + ioffset;
- correctFaceIndex(vidx);
-
- PyList_Append(me->faces, ( PyObject * ) nmface_from_index(me, vidx, (char)dl->col));
- index+= 4;
- }
- ioffset += dl->nr;
- break;
- }
- dl= dl->next;
- }
-
- return ( PyObject * ) me;
-}
-
-static PyObject *new_NMesh_internal( Mesh * oldmesh,
- DerivedMesh *dm )
-{
- BPy_NMesh *me = PyObject_NEW( BPy_NMesh, &NMesh_Type );
- me->flags = 0;
- me->mode = ME_TWOSIDED; /* default for new meshes */
- me->subdiv[0] = NMESH_SUBDIV;
- me->subdiv[1] = NMESH_SUBDIV;
- me->smoothresh = NMESH_SMOOTHRESH;
-
- me->object = NULL; /* not linked to any object yet */
-
- if( !oldmesh ) {
- me->name = EXPP_incr_ret( Py_None );
- me->materials = PyList_New( 0 );
- me->verts = PyList_New( 0 );
- me->edges = PyList_New( 0 );
- me->faces = PyList_New( 0 );
- me->mesh = 0;
- memset(&me->fdata, 0, sizeof(me->fdata));
- me->totfdata = 0;
- } else {
- MVert *mverts;
- MSticky *msticky;
- MFace *mfaces;
- MTFace *tfaces;
- MCol *mcols;
- MEdge *medges;
- CustomData *fdata;
- int i, totvert, totface, totedge;
-
- me->name = PyString_FromString( oldmesh->id.name + 2 );
- me->mesh = oldmesh;
- me->mode = oldmesh->flag; /* yes, we save the mesh flags in nmesh->mode */
- me->subdiv[0] = oldmesh->subdiv;
- me->subdiv[1] = oldmesh->subdivr;
- me->smoothresh = oldmesh->smoothresh;
-
- me->sel_face = get_active_faceindex( oldmesh );
-
- if( dm ) {
- msticky = NULL;
- mverts = dm->getVertArray(dm);
- mfaces = dm->getFaceArray(dm);
- tfaces = dm->getFaceDataArray(dm, CD_MTFACE);
- mcols = dm->getFaceDataArray(dm, CD_MCOL);
- medges = dm->getEdgeArray(dm);
- fdata = &dm->faceData;
-
- totvert = dm->getNumVerts(dm);
- totedge = dm->getNumEdges(dm);
- totface = dm->getNumFaces(dm);;
- } else {
- msticky = oldmesh->msticky;
- mverts = oldmesh->mvert;
- mfaces = oldmesh->mface;
- tfaces = oldmesh->mtface;
- mcols = oldmesh->mcol;
- medges = oldmesh->medge;
- fdata = &oldmesh->fdata;
-
- totvert = oldmesh->totvert;
- totface = oldmesh->totface;
- totedge = oldmesh->totedge;
- }
-
- /* copy non active mcol and mtface layers, these can't be edited
- but will be preserved */
- CustomData_copy( fdata, &me->fdata, CD_MASK_MCOL|CD_MASK_MTFACE,
- CD_DUPLICATE, totface );
- me->totfdata = totface;
-
- if( msticky )
- me->flags |= NMESH_HASVERTUV;
- if( tfaces )
- me->flags |= NMESH_HASFACEUV;
- if( mcols )
- me->flags |= NMESH_HASMCOL;
-
- me->verts = PyList_New( totvert );
-
- for( i = 0; i < totvert; i++ ) {
- MVert *oldmv = &mverts[i];
- MSticky *oldst = msticky ? &msticky[i] : NULL;
-
- PyList_SetItem( me->verts, i,
- ( PyObject * ) nmvert_from_data( oldmv,
- oldst,
- oldmv->co,
- i,
- oldmv->flag ) );
- }
-
- me->faces = PyList_New( totface );
- for( i = 0; i < totface; i++ ) {
- MTFace *oldtf = tfaces ? &tfaces[i] : NULL;
- MCol *oldmc = mcols ? &mcols[i * 4] : NULL;
- MFace *oldmf = &mfaces[i];
- int vidxs[4];
- vidxs[0] = oldmf->v1;
- vidxs[1] = oldmf->v2;
- vidxs[2] = oldmf->v3;
- vidxs[3] = oldmf->v4;
-
- PyList_SetItem( me->faces, i,
- ( PyObject * ) nmface_from_data( me,
- vidxs,
- oldmf->
- mat_nr,
- oldmf->
- flag,
- oldtf,
- oldmc,
- i) );
- }
-
- me->edges = PyList_New( totedge );
- for( i = 0; i < totedge; i++ )
- {
- MEdge *edge = &medges[i];
- PyList_SetItem( me->edges, i, (PyObject*)nmedge_from_data ( me, edge ) );
- }
-
- me->materials = EXPP_PyList_fromMaterialList( oldmesh->mat, oldmesh->totcol, 0 );
- }
-
- return ( PyObject * ) me;
-}
-
-PyObject *new_NMesh( Mesh * oldmesh )
-{
- return new_NMesh_internal( oldmesh, NULL );
-}
-
-static PyObject *M_NMesh_New( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- PyObject *ret = NULL;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or a string as argument" );
-
- ret = new_NMesh( NULL );
-
- if( ret && name ) {
- BPy_NMesh *nmesh = ( BPy_NMesh * ) ret;
- Py_DECREF( nmesh->name );
- nmesh->name = PyString_FromString( name );
- }
-
- return ret;
-}
-
-static PyObject *M_NMesh_GetRaw( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- Mesh *oldmesh = NULL;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" );
-
- if( name ) {
- oldmesh = ( Mesh * ) GetIdFromList( &( G.main->mesh ), name );
-
- if( !oldmesh )
- return EXPP_incr_ret( Py_None );
- }
-
- return new_NMesh( oldmesh );
-}
-
-static PyObject *M_NMesh_GetNames(PyObject *self)
-{
- PyObject *names = PyList_New(0), *tmpstr;
- Mesh *me = G.main->mesh.first;
-
- while (me) {
- tmpstr = PyString_FromString(me->id.name+2);
- PyList_Append(names, tmpstr);
- Py_DECREF(tmpstr);
- me = me->id.next;
- }
-
- return names;
-}
-
-/* Note: NMesh.GetRawFromObject gets the display list mesh from Blender:
- * the vertices are already transformed / deformed. */
-static PyObject *M_NMesh_GetRawFromObject( PyObject * self, PyObject * args )
-{
- Object *ob;
- PyObject *nmesh;
- ListBase *lb=0;
- DispList *dl;
- char *name;
-
- if( !PyArg_ParseTuple( args, "s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- ob = ( Object * ) GetIdFromList( &( G.main->object ), name );
-
- if( !ob )
- return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
-
-
- switch (ob->type) {
- case OB_MBALL:
- if( is_basis_mball(ob)) {
- lb= &ob->disp;
- if(lb->first==0) makeDispListMBall(ob);
- nmesh = new_NMesh_displist(lb, ob);
- }
- else {
- return EXPP_ReturnPyObjError( PyExc_AttributeError, "Object does not have geometry data" );
- }
- break;
- case OB_FONT:
- case OB_CURVE:
- {
- Curve *cu= ob->data;
-
- lb= &cu->disp;
- if(lb->first==0) makeDispListCurveTypes(ob, 0);
-
- dl= lb->first;
- if(dl==0)
- return EXPP_ReturnPyObjError( PyExc_AttributeError, "Object does not have geometry data" );
-
- if(dl->nors==0) addnormalsDispList(ob, lb);
-
- nmesh = new_NMesh_displist(lb, ob);
- }
- break;
- case OB_SURF:
-
- lb= &((Curve *)ob->data)->disp;
- if(lb->first==0) makeDispListCurveTypes(ob, 0);
-
- dl= lb->first;
- if(dl==0)
- return EXPP_ReturnPyObjError( PyExc_AttributeError, "Object does not have geometry data" );
-
- if(dl->nors==0) addnormalsDispList(ob, lb);
- nmesh = new_NMesh_displist(lb, ob);
-
- break;
- case OB_MESH:
- {
- CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MTFACE
- | CD_MASK_MCOL;
- DerivedMesh *dm = mesh_create_derived_render( ob, dataMask );
- nmesh = new_NMesh_internal( ob->data, dm );
- dm->release(dm);
- }
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_AttributeError, "Object does not have geometry data" );
- }
-
-/* @hack: to mark that (deformed) mesh is readonly, so the update function
- * will not try to write it. */
-
- ( ( BPy_NMesh * ) nmesh )->mesh = 0;
-
- return nmesh;
-}
-
-static void mvert_from_data( MVert * mv, MSticky * st, BPy_NMVert * from )
-{
- mv->co[0] = from->co[0];
- mv->co[1] = from->co[1];
- mv->co[2] = from->co[2];
-
- mv->no[0] = (short)(from->no[0] * 32767.0);
- mv->no[1] = (short)(from->no[1] * 32767.0);
- mv->no[2] = (short)(from->no[2] * 32767.0);
-
- mv->flag = ( from->flag & 1 );
- mv->mat_nr = 0;
-
- if( st ) {
- st->co[0] = from->uvco[0];
- st->co[1] = from->uvco[1];
- }
-}
-
-static int assignFaceUV( MTFace * tf, BPy_NMFace * nmface )
-{
- PyObject *fuv, *tmp;
- int i;
- int len;
-
- fuv = nmface->uv;
- /* if no UV info, allows things to proceed as normal */
- if( PySequence_Length( fuv ) == 0 ) {
- tf->uv[0][0] = 0.0f; tf->uv[0][1] = 1.0f;
- tf->uv[1][0] = 0.0f; tf->uv[1][1] = 0.0f;
- tf->uv[2][0] = 1.0f; tf->uv[2][1] = 0.0f;
- tf->uv[3][1] = 1.0f; tf->uv[3][1] = 1.0f;
- return 1;
- }
-
- /* if there are too many uv coordinates, only take the first 4 */
- len = PySequence_Length( fuv );
- if( len > 4 )
- len = 4;
-
- /* fuv = [(u_1, v_1), ... (u_n, v_n)] */
- for( i = 0; i < len; i++ ) {
- tmp = PyList_GetItem( fuv, i ); /* stolen reference ! */
- if( !PyArg_ParseTuple
- ( tmp, "ff", &( tf->uv[i][0] ), &( tf->uv[i][1] ) ) ) {
- PyErr_SetString ( PyExc_TypeError,
- "expected tuple of two floats for uv" );
- return 0;
- }
- }
- if( nmface->image ) { /* image assigned ? */
- tf->tpage = ( void * ) nmface->image;
- } else
- tf->tpage = 0;
-
- tf->mode = nmface->mode; /* copy mode */
- tf->flag = (char)nmface->flag; /* copy flag */
- tf->transp = nmface->transp; /* copy transp flag */
-
- return 1;
-}
-
-static int mface_from_data( MFace * mf, CustomData *fdata, int findex,
- BPy_NMFace * from )
-{
- BPy_NMVert *nmv;
- MTFace *tf = CustomData_get(fdata, findex, CD_MTFACE);
- MCol *col = CustomData_get(fdata, findex, CD_MCOL);
-
- int numverts = PyList_Size( from->v );
- if( numverts != 3 && numverts != 4 ) { /* face can only have three or four verts */
- PyErr_SetString ( PyExc_RuntimeError,
- "faces must have at 3 or 4 vertices" );
- return 0;
- }
-
- nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 0 );
- if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
- mf->v1 = nmv->index;
- else
- mf->v1 = 0;
-
- nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 1 );
- if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
- mf->v2 = nmv->index;
- else
- mf->v2 = 0;
-
- nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 2 );
- if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
- mf->v3 = nmv->index;
- else
- mf->v3 = 0;
-
- if( numverts == 4 ) {
- nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 3 );
- if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
- mf->v4 = nmv->index;
- else
- mf->v4 = 0;
- }
-
- if( tf )
- if( !assignFaceUV( tf, from ) )
- return 0;
-
- mf->mat_nr = from->mat_nr;
- mf->flag = from->mf_flag;
-
- if( col ) {
- int i, len = PySequence_Length( from->col );
-
- if( len > 4 )
- len = 4;
-
- for( i = 0; i < len; i++, col++ ) {
- BPy_NMCol *mc =
- ( BPy_NMCol * ) PySequence_GetItem( from->col,
- i );
- if( !BPy_NMCol_Check( mc ) ) {
- Py_DECREF( mc );
- continue;
- }
-
- col->b = mc->r;
- col->g = mc->g;
- col->r = mc->b;
- col->a = mc->a;
-
- Py_DECREF( mc );
- }
- }
-
- test_index_face(mf, fdata, findex, numverts);
-
- return 1;
-}
-
-/* check for a valid UV sequence */
-static int check_validFaceUV( BPy_NMesh * nmesh )
-{
- PyObject *faces;
- BPy_NMFace *nmface;
- int i, n;
-
- faces = nmesh->faces;
- for( i = 0; i < PySequence_Length( faces ); i++ ) {
- nmface = ( BPy_NMFace * ) PyList_GetItem( faces, i );
- n = PySequence_Length( nmface->uv );
- if( n != PySequence_Length( nmface->v ) ) {
- if( n > 0 )
- printf( "Warning: different length of vertex and UV coordinate " "list in face!\n" );
- return 0;
- }
- }
- return 1;
-}
-
-/* this is a copy of unlink_mesh in mesh.c, because ... */
-static void EXPP_unlink_mesh( Mesh * me )
-{
- int a;
-
- if( me == 0 )
- return;
-
- for( a = 0; a < me->totcol; a++ ) {
- if( me->mat[a] )
- me->mat[a]->id.us--;
- me->mat[a] = 0;
- }
-
-/* ... here we want to preserve mesh keys */
-/* if users want to get rid of them, they can use mesh.removeAllKeys() */
-/*
- if(me->key) me->key->id.us--;
- me->key= 0;
-*/
- if( me->texcomesh )
- me->texcomesh = 0;
-
- me->totcol = 0;
-}
-
-static int unlink_existingMeshData( Mesh * mesh )
-{
- MDeformVert *dvert= NULL;
-
- EXPP_unlink_mesh( mesh );
-
- if(mesh->dvert) {
- /* we don't want to remove dvert here, check_dverts still needs it */
- dvert= mesh->dvert;
- CustomData_set_layer( &mesh->vdata, CD_MDEFORMVERT, NULL );
- }
-
- CustomData_free( &mesh->vdata, mesh->totvert );
- CustomData_free( &mesh->edata, mesh->totedge );
- CustomData_free( &mesh->fdata, mesh->totface );
- mesh_update_customdata_pointers( mesh );
-
- if(dvert)
- mesh->dvert= CustomData_add_layer( &mesh->vdata, CD_MDEFORMVERT,
- CD_ASSIGN, dvert, mesh->totvert );
-
- mesh->totedge = 0;
-
- if( mesh->mat ) {
- MEM_freeN( mesh->mat );
- mesh->mat = NULL;
- }
-
- return 1;
-}
-
-Material **nmesh_updateMaterials( BPy_NMesh * nmesh )
-{
- Material **matlist;
- Mesh *mesh = nmesh->mesh;
- int len = PyList_Size( nmesh->materials );
-
- if( !mesh ) {
- printf( "FATAL INTERNAL ERROR: illegal call to updateMaterials()\n" );
- return 0;
- }
-
- if( len > 0 ) {
- matlist = EXPP_newMaterialList_fromPyList( nmesh->materials );
- EXPP_incr_mats_us( matlist, len );
-
- if( mesh->mat )
- MEM_freeN( mesh->mat );
-
- mesh->mat = matlist;
-
- } else {
- matlist = 0;
- }
- mesh->totcol = (short)len;
-
-/**@ This is another ugly fix due to the weird material handling of blender.
- * it makes sure that object material lists get updated (by their length)
- * according to their data material lists, otherwise blender crashes.
- * It just stupidly runs through all objects...BAD BAD BAD.
- */
- test_object_materials( ( ID * ) mesh );
-
- return matlist;
-}
-
-PyObject *NMesh_assignMaterials_toObject( BPy_NMesh * nmesh, Object * ob )
-{
- BPy_Material *pymat;
- Material *ma;
- int i;
- short old_matmask;
- Mesh *mesh = nmesh->mesh;
- int nmats; /* number of mats == len(nmesh->materials) */
-
- old_matmask = ob->colbits; /*@ HACK: save previous colbits */
- ob->colbits = 0; /* make assign_material work on mesh linked material */
-
- nmats = PyList_Size( nmesh->materials );
-
- if( nmats > 0 && !mesh->mat ) {
- ob->totcol = (char)nmats;
- mesh->totcol = (short)nmats;
- mesh->mat =
- MEM_callocN( sizeof( void * ) * nmats, "bpy_memats" );
-
- if( ob->mat )
- MEM_freeN( ob->mat );
- ob->mat =
- MEM_callocN( sizeof( void * ) * nmats, "bpy_obmats" );
- }
-
- for( i = 0; i < nmats; i++ ) {
- pymat = ( BPy_Material * ) PySequence_GetItem( nmesh->
- materials, i );
-
- if( BPy_Material_Check( ( PyObject * ) pymat ) ) {
- ma = pymat->material;
- assign_material( ob, ma, i + 1 ); /*@ XXX don't use this function anymore */
- } else {
- Py_DECREF( pymat );
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Material type in attribute list 'materials'!" );
- }
-
- Py_DECREF( pymat );
- }
-
- ob->colbits = old_matmask; /*@ HACK */
-
- ob->actcol = 1;
- Py_RETURN_NONE;
-}
-
-static void fill_medge_from_nmesh(Mesh * mesh, BPy_NMesh * nmesh)
-{
- int i,j;
- MEdge *faces_edges=NULL;
- int tot_faces_edges=0;
- int tot_valid_faces_edges=0;
- int nmeshtotedges=PyList_Size(nmesh->edges);
- int tot_valid_nmedges=0;
- BPy_NMEdge **valid_nmedges=NULL;
-
- valid_nmedges=MEM_callocN(nmeshtotedges*sizeof(BPy_NMEdge *), "make BPy_NMEdge");
-
- /* First compute the list of edges that exists because faces exists */
- make_edges(mesh, 0); /* 0 = draw all edges */
-
- faces_edges=mesh->medge;
- tot_faces_edges=mesh->totedge;
- tot_valid_faces_edges=tot_faces_edges;
-
- mesh->medge= CustomData_set_layer(&mesh->edata, CD_MEDGE, NULL);
- CustomData_free_layer_active(&mesh->edata, CD_MEDGE, mesh->totedge);
- mesh->totedge = 0;
-
- /* Flag each edge in faces_edges that is already in nmesh->edges list.
- * Flaging an edge means MEdge v1=v2=0.
- * Each time an edge is flagged, tot_valid_faces_edges is decremented.
- *
- * Also store in valid_nmedges pointers to each valid NMEdge in nmesh->edges.
- * An invalid NMEdge is an edge that has a vertex that is not in the vertices
- * list. Ie its index is -1.
- * Each time an valid NMEdge is flagged, tot_valid_nmedges is incremented.
- */
- for( i = 0; i < nmeshtotedges; ++i )
- {
- int v1idx,v2idx;
- BPy_NMEdge *edge=( BPy_NMEdge *) PyList_GetItem(nmesh->edges, i);
- BPy_NMVert *v=(BPy_NMVert *)edge->v1;
- v1idx=v->index;
- v=(BPy_NMVert *)edge->v2;
- v2idx=v->index;
- if (-1 == v1idx || -1 == v2idx) continue;
- valid_nmedges[tot_valid_nmedges]=edge;
- ++tot_valid_nmedges;
- for( j = 0; j < tot_faces_edges; j++ )
- {
- MEdge *me=faces_edges+j;
- if ( ((int)me->v1==v1idx && (int)me->v2==v2idx) ||
- ((int)me->v1==v2idx && (int)me->v2==v1idx) )
- {
- me->v1=0; me->v2=0;
- --tot_valid_faces_edges;
- }
- }
- }
-
- /* tot_valid_faces_edges < 0 causes a sigsegv crash, so we
- * clamp to prevent it
- * (this is related to faces (correctly) requiring at least 3 verts now,
- * which can break old scripts -- maybe we should also warn about the
- * 'broken' mesh the user created, but for now, until we investigate
- * better, this should do) */
- if (tot_valid_faces_edges < 0) tot_valid_faces_edges = 0;
-
- /* Now we have the total count of valid edges */
- mesh->totedge=tot_valid_nmedges+tot_valid_faces_edges;
- mesh->medge= CustomData_add_layer( &mesh->edata, CD_MEDGE, CD_CALLOC, NULL,
- mesh->totedge );
-
- for ( i = 0; i < tot_valid_nmedges; ++i )
- {
- BPy_NMEdge *edge=valid_nmedges[i];
- MEdge *medge=mesh->medge+i;
- int v1=((BPy_NMVert *)edge->v1)->index;
- int v2=((BPy_NMVert *)edge->v2)->index;
- medge->v1=v1;
- medge->v2=v2;
- medge->flag=edge->flag;
- medge->crease=edge->crease;
- }
- for ( i = 0, j = tot_valid_nmedges; i < tot_faces_edges; ++i )
- {
- MEdge *edge=faces_edges+i;
- if (edge->v1!=0 || edge->v2!=0) // valid edge
- {
- MEdge *medge=mesh->medge+j;
- medge->v1=edge->v1;
- medge->v2=edge->v2;
- medge->flag=ME_EDGEDRAW|ME_EDGERENDER;
- medge->crease=0;
- ++j;
- }
- }
-
- MEM_freeN( valid_nmedges );
- MEM_freeN( faces_edges );
-}
-
-/* this should ensure meshes don't end up with wrongly sized
- * me->dvert arrays, which can cause hangs; it's not ideal,
- * it's better to wrap dverts in NMesh, but it should do for now
- * since there are also methods in NMesh to edit dverts in the actual
- * mesh in Blender and anyway this is memory friendly */
-static void check_dverts(Mesh *me, int old_totvert)
-{
- int totvert = me->totvert;
-
- /* if vert count didn't change or there are no dverts, all is fine */
- if ((totvert == old_totvert) || (!me->dvert)) return;
- /* if all verts have been deleted, free old dverts */
- else if (totvert == 0) {
- CustomData_free_layer_active( &me->vdata, CD_MDEFORMVERT, old_totvert );
- me->dvert= NULL;
- }
- else {
- /* verts added or removed, make new me->dvert */
- MDeformVert *mdv = MEM_callocN( sizeof(MDeformVert)*totvert, "mdv" );
- copy_dverts( mdv, me->dvert, MIN2( old_totvert, totvert ) );
- free_dverts( me->dvert, old_totvert );
- me->dvert= CustomData_set_layer( &me->vdata, CD_MDEFORMVERT, mdv );
- }
-}
-
-static void check_mtface_mcols( BPy_NMesh *nmesh, Mesh *mesh )
-{
- int i;
-
- /* copy non-active mcol and mtface layers based on original index */
- CustomData_merge( &nmesh->fdata, &mesh->fdata, CD_MASK_MCOL|CD_MASK_MTFACE,
- CD_DEFAULT, mesh->totface );
-
- for( i = 0; i < mesh->totface; i++ ) {
- BPy_NMFace *mf =
- ( BPy_NMFace * ) PySequence_GetItem( nmesh->faces, i );
-
- if ( mf->orig_index != -1 )
- CustomData_copy_data( &nmesh->fdata, &mesh->fdata, mf->orig_index,
- i, 1 );
-
- Py_DECREF( mf );
- }
-
- /* add new layers if needed */
- if( ( nmesh->flags & NMESH_HASMCOL ) &&
- !CustomData_has_layer( &mesh->fdata, CD_MCOL ) ) {
- mesh->mcol = CustomData_add_layer( &mesh->fdata, CD_MCOL,
- CD_DEFAULT, NULL, mesh->totface );
- }
-
- if( ( nmesh->flags & NMESH_HASFACEUV ) || check_validFaceUV( nmesh ) ) {
- if ( !CustomData_has_layer( &mesh->fdata, CD_MTFACE) )
- make_tfaces( mesh );
- nmesh->flags |= NMESH_HASFACEUV;
- }
- else
- CustomData_free_layers( &mesh->fdata, CD_MTFACE, mesh->totface );
-
- /* active uvs and colors from NMFace will be written in mface_from_data */
-}
-
-static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh)
-{
- MFace *newmf;
- MVert *newmv;
- MSticky *newst;
- int nmeshtotedges;
- int i, j, ok;
-
- /* Minor note: we used 'mode' because 'flag' was already used internally
- * by nmesh */
- mesh->flag = nmesh->mode;
- mesh->smoothresh = nmesh->smoothresh;
- mesh->subdiv = nmesh->subdiv[0];
- mesh->subdivr = nmesh->subdiv[1];
-
- /*@ material assignment moved to PutRaw */
- mesh->totvert = PySequence_Length( nmesh->verts );
- if( mesh->totvert ) {
- if( nmesh->flags & NMESH_HASVERTUV )
- mesh->msticky = CustomData_add_layer( &mesh->vdata, CD_MSTICKY,
- CD_CALLOC, NULL, mesh->totvert );
-
- mesh->mvert = CustomData_add_layer( &mesh->vdata, CD_MVERT, CD_CALLOC,
- NULL, mesh->totvert );
- }
-
- if( mesh->totvert )
- mesh->totface = PySequence_Length( nmesh->faces );
- else
- mesh->totface = 0;
-
- if( mesh->totface ) {
- check_mtface_mcols( nmesh, mesh );
-
- mesh->mface = CustomData_add_layer( &mesh->fdata, CD_MFACE, CD_CALLOC,
- NULL, mesh->totface );
- }
-
- mesh_update_customdata_pointers( mesh );
-
- /*@ This stuff here is to tag all the vertices referenced
- * by faces, then untag the vertices which are actually
- * in the vert list. Any vertices untagged will be ignored
- * by the mface_from_data function. It comes from my
- * screwed up decision to not make faces only store the
- * index. - Zr
- */
- for( i = 0; i < mesh->totface; i++ ) {
- BPy_NMFace *mf =
- ( BPy_NMFace * ) PySequence_GetItem( nmesh->faces, i );
-
- j = PySequence_Length( mf->v );
- while( j-- ) {
- BPy_NMVert *mv =
- ( BPy_NMVert * ) PySequence_GetItem( mf->v,
- j );
- if( BPy_NMVert_Check( mv ) )
- mv->index = -1;
- Py_DECREF( mv );
- }
-
- Py_DECREF( mf );
- }
- /* do the same for edges if there is edge data */
- nmeshtotedges=PyList_Size(nmesh->edges);
- for( i = 0; i < nmeshtotedges; ++i )
- {
- BPy_NMEdge *edge=( BPy_NMEdge *) PyList_GetItem(nmesh->edges, i);
- BPy_NMVert *v=(BPy_NMVert *)edge->v1;
- v->index=-1;
- v=(BPy_NMVert *)edge->v2;
- v->index=-1;
- }
-
- for( i = 0; i < mesh->totvert; i++ ) {
- BPy_NMVert *mv =
- ( BPy_NMVert * ) PySequence_GetItem( nmesh->verts, i );
- mv->index = i;
- Py_DECREF( mv );
- }
-
- newmv = mesh->mvert;
- newst = mesh->msticky;
- for( i = 0; i < mesh->totvert; i++ ) {
- PyObject *mv = PySequence_GetItem( nmesh->verts, i );
- mvert_from_data( newmv, newst, ( BPy_NMVert * ) mv );
- Py_DECREF( mv );
-
- newmv++;
- if( newst )
- newst++;
- }
-
- newmf = mesh->mface;
- for( i = 0; i < mesh->totface; i++ ) {
- PyObject *mf = PySequence_GetItem( nmesh->faces, i );
- ok = mface_from_data( newmf, &mesh->fdata, i, ( BPy_NMFace * ) mf );
- Py_DECREF( mf );
- if( !ok )
- return 0;
- newmf++;
- }
-
- /* Always do this to ensure no loose edges in faces */
- fill_medge_from_nmesh(mesh, nmesh);
-
- return 1;
-}
-
-static PyObject *M_NMesh_PutRaw( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- Mesh *mesh = NULL;
- Object *ob = NULL;
- BPy_NMesh *nmesh;
- int recalc_normals = 1;
- int store_edges = 0;
- int old_totvert = 0;
-
- if( !PyArg_ParseTuple( args, "O!|sii",
- &NMesh_Type, &nmesh, &name, &recalc_normals, &store_edges ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected an NMesh object and optionally also a string and two ints" );
-
- if( check_NMeshLists( nmesh ) )
- return NULL;
-
- if( name )
- mesh = ( Mesh * ) GetIdFromList( &( G.main->mesh ), name );
-
- if( !mesh || mesh->id.us == 0 ) {
- ob = add_object( OB_MESH );
- if( !ob ) {
- PyErr_SetString( PyExc_RuntimeError,
- "Fatal: could not create mesh object" );
- return 0;
- }
-
- if( !mesh )
- mesh = ( Mesh * ) ob->data;
- else
- set_mesh( ob, mesh ); // also does id.us++
-
- nmesh->object = ob; // linking so vgrouping methods know which obj to work on
- }
-
- if( name )
- new_id( &( G.main->mesh ), &mesh->id, name );
- else if( nmesh->name && nmesh->name != Py_None )
- new_id( &( G.main->mesh ), &mesh->id,
- PyString_AsString( nmesh->name ) );
-
- old_totvert = mesh->totvert;
-
- unlink_existingMeshData( mesh );
- if( !convert_NMeshToMesh( mesh, nmesh ) )
- return NULL;
- nmesh->mesh = mesh;
-
- if (mesh->dvert) check_dverts(mesh, old_totvert);
-
- if( recalc_normals )
- mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, mesh->totface, NULL);
-
- mesh_update( mesh, nmesh->object );
-
- if( !during_script( ) )
- EXPP_allqueue( REDRAWVIEW3D, 0 );
-
- if (ob && G.obedit) { /* prevents a crash when a new object is created */
- exit_editmode(EM_FREEDATA);
- enter_editmode(0);
- }
-
- // @OK...this requires some explanation:
- // Materials can be assigned two ways:
- // a) to the object data (in this case, the mesh)
- // b) to the Object
- //
- // Case a) is wanted, if Mesh data should be shared among objects,
- // as well as its materials (up to 16)
- // Case b) is wanted, when Mesh data should be shared, but not the
- // materials. For example, you want several checker boards sharing their
- // mesh data, but having different colors. So you would assign material
- // index 0 to all even, index 1 to all odd faces and bind the materials
- // to the Object instead (MaterialButtons: [OB] "link materials to object")
- //
- // This feature implies that pointers to materials can be stored in
- // an object or a mesh. The number of total materials MUST be
- // synchronized (ob->totcol <-> mesh->totcol). We avoid the dangerous
- // direct access by calling blenderkernel/material.c:assign_material().
-
- // The flags setting the material binding is found in ob->colbits, where
- // each bit indicates the binding PER MATERIAL
-
- if( ob ) { // we created a new object
- NMesh_assignMaterials_toObject( nmesh, ob );
- EXPP_synchronizeMaterialLists( ob );
- return Object_CreatePyObject( ob );
- } else {
- mesh->mat =
- EXPP_newMaterialList_fromPyList( nmesh->materials );
- EXPP_incr_mats_us( mesh->mat,
- PyList_Size( nmesh->materials ) );
- Py_RETURN_NONE;
- }
-
-}
-
-#undef MethodDef
-#define MethodDef(func) \
- {#func, M_NMesh_##func, METH_VARARGS, M_NMesh_##func##_doc}
-
-static struct PyMethodDef M_NMesh_methods[] = {
- MethodDef( Col ),
- MethodDef( Vert ),
- MethodDef( Face ),
- MethodDef( New ),
- MethodDef( GetRaw ),
- MethodDef( GetRawFromObject ),
- MethodDef( PutRaw ),
- {"GetNames", (PyCFunction)M_NMesh_GetNames, METH_NOARGS,
- M_NMesh_GetNames_doc},
- {NULL, NULL, 0, NULL}
-};
-
-static PyObject *M_NMesh_Modes( void )
-{
- PyObject *Modes = PyConstant_New( );
-
- if( Modes ) {
- BPy_constant *d = ( BPy_constant * ) Modes;
-
- PyConstant_Insert( d, "NOVNORMALSFLIP",
- PyInt_FromLong
- ( ME_NOPUNOFLIP ) );
- PyConstant_Insert( d, "TWOSIDED",
- PyInt_FromLong( ME_TWOSIDED ) );
- PyConstant_Insert( d, "AUTOSMOOTH",
- PyInt_FromLong
- ( ME_AUTOSMOOTH ) );
- }
-
- return Modes;
-}
-
-#undef EXPP_ADDCONST
-#define EXPP_ADDCONST(dict, name) \
- PyConstant_Insert(dict, #name, PyInt_FromLong(TF_##name))
-/* Set constants for face drawing mode -- see drawmesh.c */
-
-static PyObject *M_NMesh_FaceModesDict( void )
-{
- PyObject *FM = PyConstant_New( );
-
- if( FM ) {
- BPy_constant *d = ( BPy_constant * ) FM;
-
- PyConstant_Insert( d, "BILLBOARD",
- PyInt_FromLong( TF_BILLBOARD2 ) );
- PyConstant_Insert( d, "ALL", PyInt_FromLong( 0x7fff ) );
- PyConstant_Insert( d, "HALO", PyInt_FromLong( TF_BILLBOARD ) );
- PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( TF_DYNAMIC ) );
- PyConstant_Insert( d, "INVISIBLE", PyInt_FromLong( TF_INVISIBLE ) );
- PyConstant_Insert( d, "LIGHT", PyInt_FromLong( TF_LIGHT ) );
- PyConstant_Insert( d, "OBCOL", PyInt_FromLong( TF_OBCOL ) );
- PyConstant_Insert( d, "SHADOW", PyInt_FromLong( TF_SHADOW ) );
- PyConstant_Insert( d, "TEXT", PyInt_FromLong( TF_BMFONT ) );
- PyConstant_Insert( d, "SHAREDVERT", PyInt_FromLong( TF_SHAREDVERT ) );
- PyConstant_Insert( d, "SHAREDCOL", PyInt_FromLong( TF_SHAREDCOL ) );
- PyConstant_Insert( d, "TEX", PyInt_FromLong( TF_TEX ) );
- PyConstant_Insert( d, "TILES", PyInt_FromLong( TF_TILES ) );
- PyConstant_Insert( d, "TWOSIDE", PyInt_FromLong( TF_TWOSIDE ) );
- }
-
- return FM;
-}
-
-static PyObject *M_NMesh_FaceFlagsDict( void )
-{
- PyObject *FF = PyConstant_New( );
-
- if( FF ) {
- BPy_constant *d = ( BPy_constant * ) FF;
-
- EXPP_ADDCONST( d, SELECT );
- EXPP_ADDCONST( d, HIDE );
- EXPP_ADDCONST( d, ACTIVE );
- }
-
- return FF;
-}
-
-static PyObject *M_NMesh_FaceTranspModesDict( void )
-{
- PyObject *FTM = PyConstant_New( );
-
- if( FTM ) {
- BPy_constant *d = ( BPy_constant * ) FTM;
-
- EXPP_ADDCONST( d, SOLID );
- EXPP_ADDCONST( d, ADD );
- EXPP_ADDCONST( d, ALPHA );
- EXPP_ADDCONST( d, SUB );
- }
-
- return FTM;
-}
-
-static PyObject *M_NMesh_EdgeFlagsDict( void )
-{
- PyObject *EF = PyConstant_New( );
-
- if( EF ) {
- BPy_constant *d = ( BPy_constant * ) EF;
-
- PyConstant_Insert(d, "SELECT", PyInt_FromLong(1));
- PyConstant_Insert(d, "EDGEDRAW", PyInt_FromLong(ME_EDGEDRAW));
- PyConstant_Insert(d, "EDGERENDER", PyInt_FromLong(ME_EDGERENDER));
- PyConstant_Insert(d, "SEAM", PyInt_FromLong(ME_SEAM));
- PyConstant_Insert(d, "FGON", PyInt_FromLong(ME_FGON));
- }
-
- return EF;
-}
-
-PyObject *NMesh_Init( void )
-{
- PyObject *submodule;
-
- PyObject *Modes = M_NMesh_Modes( );
- PyObject *FaceFlags = M_NMesh_FaceFlagsDict( );
- PyObject *FaceModes = M_NMesh_FaceModesDict( );
- PyObject *FaceTranspModes = M_NMesh_FaceTranspModesDict( );
- PyObject *EdgeFlags = M_NMesh_EdgeFlagsDict( );
-
- NMCol_Type.ob_type = &PyType_Type;
- NMFace_Type.ob_type = &PyType_Type;
- NMVert_Type.ob_type = &PyType_Type;
- NMesh_Type.ob_type = &PyType_Type;
-
- submodule =
- Py_InitModule3( "Blender.NMesh", M_NMesh_methods,
- M_NMesh_doc );
-
- if( Modes )
- PyModule_AddObject( submodule, "Modes", Modes );
- if( FaceFlags )
- PyModule_AddObject( submodule, "FaceFlags", FaceFlags );
- if( FaceModes )
- PyModule_AddObject( submodule, "FaceModes", FaceModes );
- if( FaceTranspModes )
- PyModule_AddObject( submodule, "FaceTranspModes",
- FaceTranspModes );
- if( EdgeFlags )
- PyModule_AddObject( submodule, "EdgeFlags", EdgeFlags );
-
- g_nmeshmodule = submodule;
- return submodule;
-}
-
-/* These are needed by Object.c */
-
-PyObject *NMesh_CreatePyObject( Mesh * me, Object * ob )
-{
- BPy_NMesh *nmesh = ( BPy_NMesh * ) new_NMesh( me );
-
- if( nmesh )
- nmesh->object = ob; /* linking nmesh and object for vgrouping methods */
-
- return ( PyObject * ) nmesh;
-}
-
-int NMesh_CheckPyObject( PyObject * pyobj )
-{
- return ( pyobj->ob_type == &NMesh_Type );
-}
-
-Mesh *NMesh_FromPyObject( PyObject * pyobj, Object * ob )
-{
- if( pyobj->ob_type == &NMesh_Type ) {
- Mesh *mesh;
- BPy_NMesh *nmesh = ( BPy_NMesh * ) pyobj;
-
- if( nmesh->mesh ) {
- mesh = nmesh->mesh;
- } else {
- mesh = Mesh_fromNMesh( nmesh );
- if( !mesh ) /* NULL means an PyError */
- return NULL;
-
- nmesh->mesh = mesh;
-
- nmesh->object = ob; /* linking for vgrouping methods */
- if( nmesh->name && nmesh->name != Py_None )
- new_id( &( G.main->mesh ), &mesh->id,
- PyString_AsString( nmesh->name ) );
- mesh_update( mesh, nmesh->object );
- nmesh_updateMaterials( nmesh );
- }
- return mesh;
- }
-
- PyErr_SetString( PyExc_AttributeError,
- "link argument type is not supported " );
- return NULL;
-}
-
-#define POINTER_CROSS_EQ(a1, a2, b1, b2) (((a1)==(b1) && (a2)==(b2)) || ((a1)==(b2) && (a2)==(b1)))
-
-static PyObject *findEdge( BPy_NMesh *nmesh, BPy_NMVert *v1, BPy_NMVert *v2, int create)
-{
- int i;
-
- for ( i = 0; i < PyList_Size(nmesh->edges); ++i )
- {
- BPy_NMEdge *edge=(BPy_NMEdge*)PyList_GetItem( nmesh->edges, i );
- if (!BPy_NMEdge_Check(edge)) continue;
- if ( POINTER_CROSS_EQ((BPy_NMVert*)edge->v1, (BPy_NMVert*)edge->v2, v1, v2) )
- {
- return EXPP_incr_ret((PyObject*)edge);
- }
- }
-
- /* if this line is reached, edge has not been found */
- if (create)
- {
- PyObject *newEdge=(PyObject *)new_NMEdge(v1, v2, 0, ME_EDGEDRAW|ME_EDGERENDER);
- PyList_Append(nmesh->edges, newEdge);
- return newEdge;
- }
- else
- Py_RETURN_NONE;
-}
-
-static void removeEdge( BPy_NMesh *nmesh, BPy_NMVert *v1, BPy_NMVert *v2, int ununsedOnly)
-{
- int i,j;
- BPy_NMEdge *edge=NULL;
- int edgeUsedByFace=0;
- int totedge=PyList_Size(nmesh->edges);
-
- /* find the edge in the edge list */
- for ( i = 0; i < totedge; ++i )
- {
- edge=(BPy_NMEdge*)PyList_GetItem( nmesh->edges, i );
- if (!BPy_NMEdge_Check(edge)) continue;
- if ( POINTER_CROSS_EQ((BPy_NMVert*)edge->v1, (BPy_NMVert*)edge->v2, v1, v2) )
- {
- break;
- }
- }
-
- if (i==totedge || !edge) // edge not found
- return;
-
- for ( j = PyList_Size(nmesh->faces)-1; j >= 0 ; --j )
- {
- BPy_NMFace *face=(BPy_NMFace *)PyList_GetItem(nmesh->faces, j);
- int k, del_face=0;
- int totv;
- if (!BPy_NMFace_Check(face)) continue;
- totv=PyList_Size(face->v);
- if (totv<2) continue;
- for ( k = 0; k < totv && !del_face; ++k )
- {
- BPy_NMVert *fe_v1=(BPy_NMVert *)PyList_GetItem(face->v, k ? k-1 : totv-1);
- BPy_NMVert *fe_v2=(BPy_NMVert *)PyList_GetItem(face->v, k);
- if ( POINTER_CROSS_EQ(v1, v2, fe_v1, fe_v2) )
- {
- edgeUsedByFace=1;
- del_face=1;
- }
- }
- if (del_face && !ununsedOnly)
- {
- PySequence_DelItem(nmesh->faces, j);
- }
- }
-
- if (!ununsedOnly || (ununsedOnly && !edgeUsedByFace) )
- PySequence_DelItem(nmesh->edges, PySequence_Index(nmesh->edges, (PyObject*)edge));
-}
-
-
-static PyObject *NMesh_addEdge( PyObject * self, PyObject * args )
-{
- BPy_NMesh *bmesh=(BPy_NMesh *)self;
- BPy_NMVert *v1=NULL, *v2=NULL;
-
- if (!PyArg_ParseTuple
- ( args, "O!O!", &NMVert_Type, &v1, &NMVert_Type, &v2 ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected NMVert, NMVert" );
- }
-
- if (v1==v2)
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "vertices must be different" );
-
- return findEdge(bmesh, v1, v2, 1);
-}
-
-static PyObject *NMesh_findEdge( PyObject * self, PyObject * args )
-{
- BPy_NMesh *bmesh=(BPy_NMesh *)self;
- BPy_NMVert *v1=NULL, *v2=NULL;
-
- if (!PyArg_ParseTuple
- ( args, "O!O!", &NMVert_Type, &v1, &NMVert_Type, &v2 ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected NMVert, NMVert" );
- }
-
- if (v1==v2)
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "vertices must be different" );
-
- return findEdge(bmesh, v1, v2, 0);
-}
-
-static PyObject *NMesh_removeEdge( PyObject * self, PyObject * args )
-{
- BPy_NMesh *bmesh=(BPy_NMesh *)self;
- BPy_NMVert *v1=NULL, *v2=NULL;
-
- if (!PyArg_ParseTuple
- ( args, "O!O!", &NMVert_Type, &v1, &NMVert_Type, &v2 ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected NMVert, NMVert" );
- }
-
- if (v1==v2)
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "vertices must be different" );
- removeEdge(bmesh, v1, v2, 0);
-
- Py_RETURN_NONE;
-}
-
-
-static PyObject *NMesh_addFace( PyObject * self, PyObject * args )
-{
- BPy_NMesh *nmesh=(BPy_NMesh *)self;
-
- BPy_NMFace *face;
- int totv=0;
-
- if (!PyArg_ParseTuple
- ( args, "O!", &NMFace_Type, &face ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected NMFace argument" );
- }
-
- totv=PyList_Size(face->v);
-
- /*
- * Before edges data exists, having faces with two vertices was
- * the only way of storing edges not attached to any face.
- */
- if (totv!=2)
- PyList_Append(nmesh->faces, (PyObject*)face);
-
- if (totv>=2)
- {
- /* when totv==2, there is only one edge, when totv==3 there is three edges
- * and when totv==4 there is four edges.
- * that's why in the following line totv==2 is a special case */
- PyObject *edges = PyList_New((totv==2) ? 1 : totv);
- if (totv==2)
- {
- BPy_NMVert *fe_v1=(BPy_NMVert *)PyList_GetItem(face->v, 0);
- BPy_NMVert *fe_v2=(BPy_NMVert *)PyList_GetItem(face->v, 1);
- BPy_NMEdge *edge=(BPy_NMEdge *)findEdge(nmesh, fe_v1, fe_v2, 1);
- PyList_SetItem(edges, 0, (PyObject*)edge); // PyList_SetItem steals the reference
- }
- else
- {
- int k;
- for ( k = 0; k < totv; ++k )
- {
- BPy_NMVert *fe_v1=(BPy_NMVert *)PyList_GetItem(face->v, k ? k-1 : totv-1);
- BPy_NMVert *fe_v2=(BPy_NMVert *)PyList_GetItem(face->v, k);
- BPy_NMEdge *edge=(BPy_NMEdge *)findEdge(nmesh, fe_v1, fe_v2, 1);
- PyList_SetItem(edges, k, (PyObject*)edge); // PyList_SetItem steals the reference
- }
- }
- return edges;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_removeFace( PyObject * self, PyObject * args )
-{
- BPy_NMesh *nmesh=(BPy_NMesh *)self;
-
- BPy_NMFace *face;
- int totv=0;
-
- if (!PyArg_ParseTuple
- ( args, "O!", &NMFace_Type, &face ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected NMFace argument" );
- }
-
- totv=PyList_Size(face->v);
-
- {
- int index=PySequence_Index(nmesh->faces, (PyObject*)face);
- if (index>=0)
- PySequence_DelItem(nmesh->faces, index);
- }
-
- if (totv>=2)
- {
- /* when totv==2, there is only one edge, when totv==3 there is three edges
- * and when totv==4 there is four edges.
- * that's why in the following line totv==2 is a special case */
- if (totv==2)
- {
- BPy_NMVert *fe_v1=(BPy_NMVert *)PyList_GetItem(face->v, 0);
- BPy_NMVert *fe_v2=(BPy_NMVert *)PyList_GetItem(face->v, 1);
- removeEdge(nmesh, fe_v1, fe_v2, 1);
- }
- else
- {
- int k;
- for ( k = 0; k < totv; ++k )
- {
- BPy_NMVert *fe_v1=(BPy_NMVert *)PyList_GetItem(face->v, k ? k-1 : totv-1);
- BPy_NMVert *fe_v2=(BPy_NMVert *)PyList_GetItem(face->v, k);
- removeEdge(nmesh, fe_v1, fe_v2, 1);
- }
- }
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_printDebug( PyObject * self )
-{
- BPy_NMesh *bmesh=(BPy_NMesh *)self;
-
- Mesh *mesh=bmesh->mesh;
-
- printf("**Vertices\n");
- {
- int i;
- for (i=0; i<mesh->totvert; ++i)
- {
- MVert *v=mesh->mvert+i;
- double x=v->co[0];
- double y=v->co[1];
- double z=v->co[2];
- printf(" %2d : %.3f %.3f %.3f\n", i, x, y, z);
- }
- }
-
- printf("**Edges\n");
- {
- int i;
- for (i=0; i<mesh->totedge; ++i)
- {
- MEdge *e=mesh->medge+i;
- int v1 = e->v1;
- int v2 = e->v2;
- int flag = e->flag;
- printf(" %2d : %2d %2d flag=%d\n", i, v1, v2, flag);
- }
- }
-
- printf("**Faces\n");
- {
- int i;
- for (i=0; i<mesh->totface; ++i)
- {
- MFace *e=((MFace*)(mesh->mface))+i;
- int v1 = e->v1;
- int v2 = e->v2;
- int v3 = e->v3;
- int v4 = e->v4;
- printf(" %2d : %2d %2d %2d %2d\n", i, v1, v2, v3, v4);
- }
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_addVertGroup( PyObject * self, PyObject * args )
-{
- char *groupStr;
- struct Object *object;
- PyObject *tempStr;
-
- if( !PyArg_ParseTuple( args, "s", &groupStr ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if( ( ( BPy_NMesh * ) self )->object == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first..." );
-
- object = ( ( BPy_NMesh * ) self )->object;
-
- //get clamped name
- tempStr = PyString_FromStringAndSize( groupStr, 32 );
- groupStr = PyString_AsString( tempStr );
-
- add_defgroup_name( object, groupStr );
-
- EXPP_allqueue( REDRAWBUTSALL, 1 );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_removeVertGroup( PyObject * self, PyObject * args )
-{
- char *groupStr;
- struct Object *object;
- int nIndex;
- bDeformGroup *pGroup;
-
- if( !PyArg_ParseTuple( args, "s", &groupStr ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if( ( ( BPy_NMesh * ) self )->object == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first..." );
-
- object = ( ( BPy_NMesh * ) self )->object;
-
- pGroup = get_named_vertexgroup( object, groupStr );
- if( pGroup == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "group does not exist!" );
-
- nIndex = get_defgroup_num( object, pGroup );
- if( nIndex == -1 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no deform groups assigned to mesh" );
- nIndex++;
- object->actdef = (unsigned short)nIndex;
-
- del_defgroup( object );
-
- EXPP_allqueue( REDRAWBUTSALL, 1 );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_assignVertsToGroup( PyObject * self, PyObject * args )
-{
- //listObject is an integer list of vertex indices to add to group
- //groupStr = group name
- //weight is a float defining the weight this group has on this vertex
- //assignmode = "replace", "add", "subtract"
- // replace weight - add addition weight to vertex for this group
- // - remove group influence from this vertex
- //the function will not like it if your in editmode...
-
- char *groupStr;
- char *assignmodeStr = NULL;
- int nIndex;
- int assignmode;
- float weight = 1.0;
- struct Object *object;
- bDeformGroup *pGroup;
- PyObject *listObject;
- int tempInt;
- int x;
-
- if( ( ( BPy_NMesh * ) self )->object == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first..." );
-
- if( !PyArg_ParseTuple
- ( args, "sO!fs", &groupStr, &PyList_Type, &listObject, &weight,
- &assignmodeStr ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string, list, float, string arguments" );
- }
-
- object = ( ( BPy_NMesh * ) self )->object;
-
- if( object->data == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object contains no data..." );
-
- pGroup = get_named_vertexgroup( object, groupStr );
- if( pGroup == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "group does not exist!" );
-
- nIndex = get_defgroup_num( object, pGroup );
- if( nIndex == -1 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no deform groups assigned to mesh" );
-
- if( assignmodeStr == NULL )
- assignmode = 1; /* default */
- else if( STREQ( assignmodeStr, "replace" ) )
- assignmode = 1;
- else if( STREQ( assignmodeStr, "add" ) )
- assignmode = 2;
- else if( STREQ( assignmodeStr, "subtract" ) )
- assignmode = 3;
- else
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "bad assignment mode" );
-
- //makes a set of dVerts corresponding to the mVerts
- if( !( ( Mesh * ) object->data )->dvert ) {
- create_dverts( object->data );
- }
- //loop list adding verts to group
- for( x = 0; x < PyList_Size( listObject ); x++ ) {
- if( !
- ( PyArg_Parse
- ( ( PyList_GetItem( listObject, x ) ), "i",
- &tempInt ) ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "python list integer not parseable" );
- }
-
- if( tempInt < 0
- || tempInt >= ( ( Mesh * ) object->data )->totvert ) {
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "bad vertex index in list" );
- }
-
- add_vert_defnr( object, nIndex, tempInt, weight, assignmode );
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_removeVertsFromGroup( PyObject * self, PyObject * args )
-{
- //not passing a list will remove all verts from group
-
- char *groupStr;
- int nIndex;
- struct Object *object;
- bDeformGroup *pGroup;
- PyObject *listObject;
- int tempInt;
- int x, argc;
-
- /* argc is the number of parameters passed in: 1 (no list given) or 2: */
- argc = PyObject_Length( args );
-
- if( !PyArg_ParseTuple
- ( args, "s|O!", &groupStr, &PyList_Type, &listObject ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string and optional list argument" );
-
- if( ( ( BPy_NMesh * ) self )->object == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first..." );
-
- object = ( ( BPy_NMesh * ) self )->object;
-
- if( object->data == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object contains no data..." );
-
- if( ( !( ( Mesh * ) object->data )->dvert ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "this mesh contains no deform vertices...'" );
-
- pGroup = get_named_vertexgroup( object, groupStr );
- if( pGroup == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "group does not exist!" );
-
- nIndex = get_defgroup_num( object, pGroup );
- if( nIndex == -1 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no deform groups assigned to mesh" );
-
- if( argc == 1 ) { /* no list given */
- //enter editmode
- if( ( G.obedit == 0 ) ) {
- //set current object
- BASACT->object = object;
- G.obedit = BASACT->object;
- }
- //set current vertex group
- nIndex++;
- object->actdef = (unsigned short)nIndex;
-
- //clear all dVerts in active group
- remove_verts_defgroup( 1 );
-
- //exit editmode
- G.obedit = 0;
- } else {
- if( G.obedit != 0 ) //remove_vert_def_nr doesn't like it if your in editmode
- G.obedit = 0;
-
- //loop list adding verts to group
- for( x = 0; x < PyList_Size( listObject ); x++ ) {
- if( !
- ( PyArg_Parse
- ( ( PyList_GetItem( listObject, x ) ), "i",
- &tempInt ) ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "python list integer not parseable" );
-
- if( tempInt < 0
- || tempInt >=
- ( ( Mesh * ) object->data )->totvert )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "bad vertex index in list" );
-
- remove_vert_def_nr( object, nIndex, tempInt );
- }
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_getVertsFromGroup( PyObject * self, PyObject * args )
-{
- //not passing a list will return all verts from group
- //passing indecies not part of the group will not return data in pyList
- //can be used as a index/group check for a vertex
-
- char *groupStr;
- int nIndex;
- int weightRet;
- struct Object *object;
- bDeformGroup *pGroup;
- MVert *mvert;
- MDeformVert *dvert;
- float weight;
- int i, k, l1, l2, count;
- int num = 0;
- PyObject *tempVertexList = NULL;
- PyObject *vertexList;
- PyObject *listObject;
- int tempInt;
- int x;
-
- listObject = Py_None; //can't use NULL macro because compiler thinks
- //it's a 0 and we need to check 0 index vertex pos
- l1 = FALSE;
- l2 = FALSE;
- weightRet = 0;
-
- if( !PyArg_ParseTuple( args, "s|iO!", &groupStr, &weightRet,
- &PyList_Type, &listObject ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string and optional int and list arguments" );
-
- if( weightRet < 0 || weightRet > 1 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "return weights flag must be 0 or 1..." );
-
- if( ( ( BPy_NMesh * ) self )->object == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "mesh must be linked to an object first..." );
-
- object = ( ( BPy_NMesh * ) self )->object;
-
- if( object->data == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object contains no data..." );
-
- if( ( !( ( Mesh * ) object->data )->dvert ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "this mesh contains no deform vertices...'" );
-
- pGroup = get_named_vertexgroup( object, groupStr );
- if( pGroup == NULL )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "group does not exist!" );
-
- nIndex = get_defgroup_num( object, pGroup );
- if( nIndex == -1 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no deform groups assigned to mesh" );
-
- //temporary list
- tempVertexList = PyList_New( ( ( Mesh * ) object->data )->totvert );
- if( tempVertexList == NULL )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "getVertsFromGroup: can't create pylist!" );
-
- count = 0;
-
- if( listObject == Py_None ) //do entire group
- {
- for( k = 0; k < ( ( Mesh * ) object->data )->totvert; k++ ) {
- dvert = ( ( Mesh * ) object->data )->dvert + k;
-
- for( i = 0; i < dvert->totweight; i++ ) {
- if( dvert->dw[i].def_nr == nIndex ) {
- mvert = ( ( Mesh * ) object->data )->
- mvert + k;
- weight = dvert->dw[i].weight;
- //printf("index =%3d weight:%10f\n", k, weight);
-
- if( weightRet == 1 )
- PyList_SetItem( tempVertexList,
- count,
- Py_BuildValue
- ( "(i,f)", k,
- weight ) );
- else if( weightRet == 0 )
- PyList_SetItem( tempVertexList,
- count,
- Py_BuildValue
- ( "i", k ) );
-
- count++;
- }
- }
- }
- } else //do single vertex
- {
- //loop list adding verts to group
- for( x = 0; x < PyList_Size( listObject ); x++ ) {
- if( !
- ( PyArg_Parse
- ( ( PyList_GetItem( listObject, x ) ), "i",
- &tempInt ) ) ) {
- Py_DECREF(tempVertexList);
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "python list integer not parseable" );
- }
- if( tempInt < 0
- || tempInt >=
- ( ( Mesh * ) object->data )->totvert ) {
- Py_DECREF(tempVertexList);
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "bad vertex index in list" );
- }
- num = tempInt;
- dvert = ( ( Mesh * ) object->data )->dvert + num;
- for( i = 0; i < dvert->totweight; i++ ) {
- l1 = TRUE;
- if( dvert->dw[i].def_nr == nIndex ) {
- l2 = TRUE;
- mvert = ( ( Mesh * ) object->data )->
- mvert + num;
-
- weight = dvert->dw[i].weight;
- //printf("index =%3d weight:%10f\n", num, weight);
-
- if( weightRet == 1 ) {
- PyList_SetItem( tempVertexList,
- count,
- Py_BuildValue
- ( "(i,f)", num,
- weight ) );
- } else if( weightRet == 0 )
- PyList_SetItem( tempVertexList,
- count,
- Py_BuildValue
- ( "i", num ) );
-
- count++;
- }
- if( l2 == FALSE )
- printf( "vertex at index %d is not part of passed group...\n", tempInt );
- }
- if( l1 == FALSE )
- printf( "vertex at index %d is not assigned to a vertex group...\n", tempInt );
-
- l1 = l2 = FALSE; //reset flags
- }
- }
- //only return what we need
- vertexList = PyList_GetSlice( tempVertexList, 0, count );
-
- Py_DECREF( tempVertexList );
-
- return ( vertexList );
-}
-
-static PyObject *NMesh_renameVertGroup( PyObject * self, PyObject * args )
-{
- char *oldGr = NULL;
- char *newGr = NULL;
- bDeformGroup *defGroup = NULL;
- /*PyObject *tempStr; */
-
-
- if( !( ( BPy_NMesh * ) self )->object )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This mesh must be linked to an object" );
-
- if( !PyArg_ParseTuple( args, "ss", &oldGr, &newGr ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Expected string & string argument" );
-
- defGroup =
- get_named_vertexgroup( ( ( BPy_NMesh * ) self )->object,
- oldGr );
- if( defGroup == NULL )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Couldn't find the expected vertex group" );
-
- PyOS_snprintf( defGroup->name, 32, newGr );
- unique_vertexgroup_name( defGroup, ( ( BPy_NMesh * ) self )->object );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *NMesh_getVertGroupNames( PyObject * self )
-{
- bDeformGroup *defGroup;
- PyObject *list, *tmpstr;
-
- if( !( ( BPy_NMesh * ) self )->object )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This mesh must be linked to an object" );
-
- list = PyList_New( 0 );
- for( defGroup = ( ( ( BPy_NMesh * ) self )->object )->defbase.first;
- defGroup; defGroup = defGroup->next ) {
-
- tmpstr = PyString_FromString( defGroup->name );
- if( PyList_Append( list, tmpstr) < 0 ) {
- Py_XDECREF(list);
- Py_XDECREF(tmpstr);
- return EXPP_ReturnPyObjError( PyExc_RuntimeError, "Couldn't add item to list" );
- }
- Py_XDECREF(tmpstr);
- }
-
- return list;
-}
-
-static PyObject *NMesh_transform (PyObject *self, PyObject *args)
-{
- BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
- BPy_NMVert *mv;
- PyObject *ob1 = NULL;
- MatrixObject *mat;
- float vx, vy, vz;
- int i, recalc_normals = 0;
-
- if( !PyArg_ParseTuple( args, "O!|i", &matrix_Type, &ob1, &recalc_normals ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected matrix and optionally an int as arguments" ) );
-
- mat = ( MatrixObject * ) ob1;
-
- if( mat->colSize != 4 || mat->rowSize != 4 )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "matrix must be a 4x4 transformation matrix\n"
- "for example as returned by object.getMatrix()" ) );
-
- /* loop through all the verts and transform locations by the supplied
- * matrix */
- for( i = 0; i < PySequence_Length(nmesh->verts); i++ ) {
- mv = ( BPy_NMVert * ) PySequence_GetItem( nmesh->verts, i );
- vx = mv->co[0];
- vy = mv->co[1];
- vz = mv->co[2];
-
- /* Mat4MulVecfl(mat->matrix, mv->co); */
- mv->co[0] = vx*mat->matrix[0][0] + vy*mat->matrix[1][0] +
- vz*mat->matrix[2][0] + mat->matrix[3][0];
- mv->co[1] = vx*mat->matrix[0][1] + vy*mat->matrix[1][1] +
- vz*mat->matrix[2][1] + mat->matrix[3][1];
- mv->co[2] = vx*mat->matrix[0][2] + vy*mat->matrix[1][2] +
- vz*mat->matrix[2][2] + mat->matrix[3][2];
-
- Py_DECREF(mv);
- }
-
- if ( recalc_normals ) {
- /* loop through all the verts and transform normals by the inverse
- * of the transpose of the supplied matrix */
- float invmat[4][4];
-
- /* we only need to invert a 3x3 submatrix, because the 4th component of
- * affine vectors is 0, but Mat4Invert reports non invertible matrices */
- if (!Mat4Invert((float(*)[4])*invmat, (float(*)[4])*mat->matrix))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "given matrix is not invertible");
-
- for( i = 0; i < PySequence_Length(nmesh->verts); i++ ) {
- mv = ( BPy_NMVert * ) PySequence_GetItem( nmesh->verts, i );
- vx = mv->no[0];
- vy = mv->no[1];
- vz = mv->no[2];
- mv->no[0] = vx*invmat[0][0] + vy*invmat[0][1] + vz*invmat[0][2];
- mv->no[1] = vx*invmat[1][0] + vy*invmat[1][1] + vz*invmat[1][2];
- mv->no[2] = vx*invmat[2][0] + vy*invmat[2][1] + vz*invmat[2][2];
- Normalize(mv->no);
- Py_DECREF(mv);
- }
- }
-
- /* should we alternatively return a list of changed verts (and preserve
- * the original ones) ? */
- Py_RETURN_NONE;
-}
diff --git a/source/blender/python/api2_2x/NMesh.h b/source/blender/python/api2_2x/NMesh.h
deleted file mode 100644
index 3a3b6e10088..00000000000
--- a/source/blender/python/api2_2x/NMesh.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Node.c b/source/blender/python/api2_2x/Node.c
deleted file mode 100644
index 2871eda9432..00000000000
--- a/source/blender/python/api2_2x/Node.c
+++ /dev/null
@@ -1,1213 +0,0 @@
-/*
- * $Id: Node.c 10454 2007-04-04 11:27:43Z 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 */
-#include "Node.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_node.h"
-
-#include "DNA_material_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "gen_utils.h"
-
-static PyObject *Node_repr( BPy_Node * self );
-static int Node_compare(BPy_Node *a, BPy_Node *b);
-static PyObject *ShadeInput_repr( BPy_ShadeInput * self );
-static int ShadeInput_compare(BPy_ShadeInput *a, BPy_ShadeInput *b);
-
-/**
- * Take the descriptions from dict and create sockets for those in socks
- * socks is a socketstack from a bNodeTypeInfo
- */
-static int dict_socks_to_typeinfo(PyObject *dict, bNodeSocketType **socks, int len, int stage) {
- int a = 0, pos = 0;
- PyObject *key = NULL, *value = NULL;
- bNodeSocketType *newsocks = NULL;
-
- if(stage!=SH_NODE_DYNAMIC_READY && stage!=SH_NODE_DYNAMIC_ADDEXIST) {
- newsocks = MEM_callocN(sizeof(bNodeSocketType)*(len+1), "bNodeSocketType");
-
- if (dict) {
- if(PyDict_Check(dict)) {
- while(PyDict_Next(dict, &pos, &key, &value)) {
- if(PyTuple_Check(value) && PyTuple_Size(value)==7) {
- newsocks[a].name = BLI_strdup(PyString_AsString(key));
- newsocks[a].type = (int)(PyInt_AsLong(PyTuple_GetItem(value, 0)));
- newsocks[a].val1 = (float)(PyFloat_AsDouble(PyTuple_GetItem(value, 1)));
- newsocks[a].val2 = (float)(PyFloat_AsDouble(PyTuple_GetItem(value, 2)));
- newsocks[a].val3 = (float)(PyFloat_AsDouble(PyTuple_GetItem(value, 3)));
- newsocks[a].val4 = (float)(PyFloat_AsDouble(PyTuple_GetItem(value, 4)));
- newsocks[a].min = (float)(PyFloat_AsDouble(PyTuple_GetItem(value, 5)));
- newsocks[a].max = (float)(PyFloat_AsDouble(PyTuple_GetItem(value, 6)));
- a++;
- }
- }
- } else {
- return(EXPP_ReturnIntError( PyExc_AttributeError, "INPUT must be a dict"));
- }
- }
- newsocks[a].type = -1;
- if(*socks) {
- int b = 0;
- while((*socks)[b].type!=-1) {
- MEM_freeN((*socks)[b].name);
- (*socks)[b].name = NULL;
- b++;
- }
- MEM_freeN(*socks);
- }
- *socks = newsocks;
- }
- return 0;
-}
-
-/* Get number of complying entries in a dict.
- *
- */
-static int num_dict_sockets(PyObject *dict) {
- int a = 0, pos = 0;
- PyObject *key = NULL, *value = NULL;
- while(PyDict_Next(dict, &pos, &key, &value)) {
- if(PyTuple_Check(value) && PyTuple_Size(value)==7)
- a++;
- }
- return a;
-}
-
-static int Map_socketdef(PyObject *self, PyObject *args, void *closure)
-{
- int newincnt = 0, newoutcnt = 0;
- bNode *node = NULL;
- BPy_DefinitionMap *defs= NULL;
-
- Py_INCREF(args);
- Py_INCREF(self);
-
- defs= (BPy_DefinitionMap *)self;
- node= defs->node;
-
- if(!node) {
- fprintf(stderr,"! no bNode in BPy_Node (Map_socketdef)\n");
- return 0;
- }
-
- if(node->custom1==SH_NODE_DYNAMIC_READY && node->custom1==SH_NODE_DYNAMIC_ADDEXIST)
- return 0;
-
- switch((int)closure) {
- case 'I':
- if (args) {
- if(PyDict_Check(args)) {
- newincnt = num_dict_sockets(args);
- dict_socks_to_typeinfo(args, &(node->typeinfo->inputs), newincnt, node->custom1);
- } else {
- Py_DECREF(self);
- Py_DECREF(args);
- return(EXPP_ReturnIntError( PyExc_AttributeError, "INPUT must be a dict"));
- }
- }
- break;
- case 'O':
- if (args) {
- if(PyDict_Check(args)) {
- newoutcnt = num_dict_sockets(args);
- dict_socks_to_typeinfo(args, &(node->typeinfo->outputs), newoutcnt, node->custom1);
- } else {
- Py_DECREF(self);
- Py_DECREF(args);
- return(EXPP_ReturnIntError( PyExc_AttributeError, "OUTPUT must be a dict"));
- }
- }
- break;
- default:
- fprintf(stderr, "Hrm, why we got no dict? Todo: figure out proper complaint to scripter\n");
- break;
- }
- Py_DECREF(self);
- Py_DECREF(args);
- return 0;
-}
-
-static PyGetSetDef InputDefMap_getseters[] = {
- {"definitions", (getter)NULL, (setter)Map_socketdef,
- "Set the inputs definition (dictionary)",
- (void *)'I'},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-PyTypeObject InputDefMap_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.Node.InputDefinitions", /* char *tp_name; */
- sizeof( BPy_DefinitionMap ), /* 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; */
- NULL, /* 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/input 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 */
- 0, //( getiterfunc) MVertSeq_getIter, /* getiterfunc tp_iter; */
- 0, //( iternextfunc ) MVertSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- 0, //BPy_MVertSeq_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- InputDefMap_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
-};
-
-BPy_DefinitionMap *Node_CreateInputDefMap(bNode *node) {
- BPy_DefinitionMap *map = PyObject_NEW(BPy_DefinitionMap, &InputDefMap_Type);
- map->node = node;
- return map;
-}
-
-/***************************************/
-
-static PyGetSetDef OutputDefMap_getseters[] = {
- {"definitions", (getter)NULL, (setter)Map_socketdef,
- "Set the outputs definition (dictionary)",
- (void *)'O'},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-PyTypeObject OutputDefMap_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.Node.OutputDefinitions", /* char *tp_name; */
- sizeof( BPy_DefinitionMap ), /* 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; */
- NULL, /* 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 */
- 0, //( getiterfunc) MVertSeq_getIter, /* getiterfunc tp_iter; */
- 0, //( iternextfunc ) MVertSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- 0, //BPy_MVertSeq_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- OutputDefMap_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
-};
-
-BPy_DefinitionMap *Node_CreateOutputDefMap(bNode *node) {
- BPy_DefinitionMap *map = PyObject_NEW(BPy_DefinitionMap, &OutputDefMap_Type);
- map->node = node;
- return map;
-}
-
-/***************************************/
-
-static int sockinmap_len ( BPy_SockMap * self) {
- int a = 0;
- if(self->typeinfo) {
- while(self->typeinfo->inputs[a].type!=-1)
- a++;
- }
- return a;
-}
-
-static int sockinmap_has_key( BPy_SockMap *self, PyObject *key) {
- int a = 0;
- char *strkey = PyString_AsString(key);
-
- if(self->typeinfo){
- while(self->typeinfo->inputs[a].type!=-1) {
- if(BLI_strcaseeq(self->typeinfo->inputs[a].name, strkey)) {
- return a;
- }
- a++;
- }
- }
- return -1;
-}
-
-PyObject *sockinmap_subscript(BPy_SockMap *self, PyObject *idx) {
- int a, _idx;
- a = sockinmap_len(self);
-
- if (PyString_Check(idx)) {
- _idx = sockinmap_has_key( self, idx);
- }
- else if(PyInt_Check(idx)) {
- PyErr_SetString(PyExc_ValueError, "int index not implemented");
- Py_RETURN_NONE;
- }
- else if (PySlice_Check(idx)) {
- PyErr_SetString(PyExc_ValueError, "slices not implemented");
- Py_RETURN_NONE;
- } else {
- PyErr_SetString(PyExc_IndexError, "Index must be string");
- Py_RETURN_NONE;
- }
-
-
- switch(self->typeinfo->inputs[_idx].type) {
- case SOCK_VALUE:
- return Py_BuildValue("f", self->stack[_idx]->vec[0]);
- break;
- case SOCK_VECTOR:
- return Py_BuildValue("(fff)", self->stack[_idx]->vec[0], self->stack[_idx]->vec[1], self->stack[_idx]->vec[2]);
- break;
- case SOCK_RGBA:
- return Py_BuildValue("(ffff)", self->stack[_idx]->vec[0], self->stack[_idx]->vec[1], self->stack[_idx]->vec[2], self->stack[_idx]->vec[3]);
- break;
- default:
- break;
- }
- Py_RETURN_NONE;
-}
-
-/* read only */
-static PyMappingMethods sockinmap_as_mapping = {
- ( inquiry ) sockinmap_len, /* mp_length */
- ( binaryfunc ) sockinmap_subscript, /* mp_subscript */
- ( objobjargproc ) 0 /* mp_ass_subscript */
-};
-
-PyTypeObject SockInMap_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.Node.InputSockets", /* char *tp_name; */
- sizeof( BPy_SockMap ), /* 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; */
- NULL, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- NULL, /* PySequenceMethods *tp_as_sequence; */
- &sockinmap_as_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 */
- 0, //( getiterfunc) MVertSeq_getIter, /* getiterfunc tp_iter; */
- 0, //( iternextfunc ) MVertSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- 0, //BPy_MVertSeq_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
-};
-
-static int sockoutmap_len ( BPy_SockMap * self) {
- int a = 0;
- if(self->typeinfo) {
- while(self->typeinfo->outputs[a].type!=-1)
- a++;
- }
- return a;
-}
-
-static int sockoutmap_has_key( BPy_SockMap *self, PyObject *key) {
- int a = 0;
- char *strkey = PyString_AsString(key);
-
- if(self->typeinfo){
- while(self->typeinfo->outputs[a].type!=-1) {
- if(BLI_strcaseeq(self->typeinfo->outputs[a].name, strkey)) {
- return a;
- }
- a++;
- }
- }
- return -1;
-}
-
-static int sockoutmap_assign_subscript(BPy_SockMap *self, PyObject *idx, PyObject *value) {
- int a, _idx;
- a = sockoutmap_len(self);
- if(PyInt_Check(idx)) {
- _idx = (int)PyInt_AsLong(idx);
- }
- else if (PyString_Check(idx)) {
- _idx = sockoutmap_has_key( self, idx);
- }
- else if (PySlice_Check(idx)) {
- PyErr_SetString(PyExc_ValueError, "slices not implemented, yet");
- return -1;
- } else {
- PyErr_SetString(PyExc_IndexError, "Index must be int or string");
- return -1;
- }
- if(_idx > -1) {
- switch(self->typeinfo->outputs[_idx].type) {
- case SOCK_VALUE:
- if(PyTuple_Size(value)==1)
- self->stack[_idx]->vec[0] = (float)PyFloat_AsDouble(PyTuple_GetItem(value, 0));
- return 0;
- break;
- case SOCK_VECTOR:
- if(PyTuple_Size(value)==3) {
- self->stack[_idx]->vec[0] = (float)PyFloat_AsDouble(PyTuple_GetItem(value, 0));
- self->stack[_idx]->vec[1] = (float)PyFloat_AsDouble(PyTuple_GetItem(value, 1));
- self->stack[_idx]->vec[2] = (float)PyFloat_AsDouble(PyTuple_GetItem(value, 2));
- }
- return 0;
- break;
- case SOCK_RGBA:
- if(PyTuple_Size(value)==4) {
- self->stack[_idx]->vec[0] = (float)PyFloat_AsDouble(PyTuple_GetItem(value, 0));
- self->stack[_idx]->vec[1] = (float)PyFloat_AsDouble(PyTuple_GetItem(value, 1));
- self->stack[_idx]->vec[2] = (float)PyFloat_AsDouble(PyTuple_GetItem(value, 2));
- self->stack[_idx]->vec[3] = (float)PyFloat_AsDouble(PyTuple_GetItem(value, 3));
- }
- return 0;
- break;
- default:
- break;
- }
- }
- return 0;
-}
-
-/* write only */
-static PyMappingMethods sockoutmap_as_mapping = {
- ( inquiry ) sockoutmap_len, /* mp_length */
- ( binaryfunc ) 0, /* mp_subscript */
- ( objobjargproc ) sockoutmap_assign_subscript /* mp_ass_subscript */
-};
-
-PyTypeObject SockOutMap_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.Node.OutputSockets", /* char *tp_name; */
- sizeof( BPy_SockMap ), /* 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; */
- NULL, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- NULL, /* PySequenceMethods *tp_as_sequence; */
- &sockoutmap_as_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 */
- 0, //( getiterfunc) MVertSeq_getIter, /* getiterfunc tp_iter; */
- 0, //( iternextfunc ) MVertSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- 0, //BPy_MVertSeq_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
-};
-
-
-static BPy_SockMap *Node_CreateInputMap(bNode *node, bNodeStack **stack) {
- BPy_SockMap *map= PyObject_NEW(BPy_SockMap, &SockInMap_Type);
- map->typeinfo= node->typeinfo;
- map->stack= stack;
- return map;
-}
-
-static PyObject *Node_GetInputMap(BPy_Node *self) {
- BPy_SockMap *inmap= Node_CreateInputMap(self->node, self->in);
- return (PyObject *)(inmap);
-}
-
-#define SURFACEVIEWVECTOR 0
-#define VIEWNORMAL 1
-#define SURFACENORMAL 2
-#define GLOBALTEXTURE 3
-#define TEXTURE 4
-#define PIXEL 5
-#define COLOR 6
-#define SPECULAR 7
-#define MIRROR 8
-#define AMBIENT 9
-#define AMBIENTFACTOR 10
-#define EMITFACTOR 11
-#define DISPLACE 12
-#define STRAND 13
-#define STRESS 14
-#define TANGENT 15
-#define SURFACE_D 30
-#define TEXTURE_D 31
-#define GLOBALTEXTURE_D 32
-#define REFLECTION_D 33
-#define NORMAL_D 34
-#define STICKY_D 35
-#define REFRACT_D 36
-#define STRAND_D 37
-
-static PyObject *ShadeInput_getAttribute(BPy_ShadeInput *self, void *type) {
- PyObject *obj= NULL;
- if(self->shi) {
- switch((int)type) {
- case SURFACEVIEWVECTOR:
- obj= Py_BuildValue("(fff)", self->shi->view[0], self->shi->view[1], self->shi->view[2]);
- break;
- case VIEWNORMAL:
- obj= Py_BuildValue("(fff)", self->shi->vn[0], self->shi->vn[1], self->shi->vn[2]);
- break;
- case SURFACENORMAL:
- obj= Py_BuildValue("(fff)", self->shi->facenor[0], self->shi->facenor[1], self->shi->facenor[2]);
- break;
- case GLOBALTEXTURE:
- obj= Py_BuildValue("(fff)", self->shi->gl[0], self->shi->gl[1], self->shi->gl[2]);
- break;
- case TEXTURE:
- obj= Py_BuildValue("(fff)", self->shi->lo[0], self->shi->lo[1], self->shi->lo[2]);
- break;
- case PIXEL:
- obj= Py_BuildValue("(ii)", self->shi->xs, self->shi->ys);
- break;
- case COLOR:
- obj= Py_BuildValue("(fff)", self->shi->r, self->shi->g, self->shi->b);
- break;
- case SPECULAR:
- obj= Py_BuildValue("(fff)", self->shi->specr, self->shi->specg, self->shi->specb);
- break;
- case MIRROR:
- obj= Py_BuildValue("(fff)", self->shi->mirr, self->shi->mirg, self->shi->mirb);
- break;
- case AMBIENT:
- obj= Py_BuildValue("(fff)", self->shi->ambr, self->shi->ambg, self->shi->ambb);
- break;
- case AMBIENTFACTOR:
- obj= PyFloat_FromDouble((double)(self->shi->amb));
- break;
- case EMITFACTOR:
- obj= PyFloat_FromDouble((double)(self->shi->emit));
- break;
- case DISPLACE:
- obj= Py_BuildValue("(fff)", self->shi->displace[0], self->shi->displace[1], self->shi->displace[2]);
- break;
- case STRAND:
- obj= PyFloat_FromDouble((double)(self->shi->strand));
- break;
- case STRESS:
- obj= PyFloat_FromDouble((double)(self->shi->stress));
- break;
- case TANGENT:
- obj= Py_BuildValue("(fff)", self->shi->tang[0], self->shi->tang[1], self->shi->tang[2]);
- break;
- case SURFACE_D:
- obj= Py_BuildValue("(fff)(fff)", self->shi->dxco[0], self->shi->dxco[1], self->shi->dxco[2], self->shi->dyco[0], self->shi->dyco[1], self->shi->dyco[2]);
- break;
- case TEXTURE_D:
- obj= Py_BuildValue("(fff)(fff)", self->shi->dxlo[0], self->shi->dxlo[1], self->shi->dxlo[2], self->shi->dylo[0], self->shi->dylo[1], self->shi->dylo[2]);
- break;
- case GLOBALTEXTURE_D:
- obj= Py_BuildValue("(fff)(fff)", self->shi->dxgl[0], self->shi->dxgl[1], self->shi->dxgl[2], self->shi->dygl[0], self->shi->dygl[1], self->shi->dygl[2]);
- break;
- case REFLECTION_D:
- obj= Py_BuildValue("(fff)(fff)", self->shi->dxref[0], self->shi->dxref[1], self->shi->dxref[2], self->shi->dyref[0], self->shi->dyref[1], self->shi->dyref[2]);
- break;
- case NORMAL_D:
- obj= Py_BuildValue("(fff)(fff)", self->shi->dxno[0], self->shi->dxno[1], self->shi->dxno[2], self->shi->dyno[0], self->shi->dyno[1], self->shi->dyno[2]);
- break;
- case STICKY_D:
- obj= Py_BuildValue("(fff)(fff)", self->shi->dxsticky[0], self->shi->dxsticky[1], self->shi->dxsticky[2], self->shi->dysticky[0], self->shi->dysticky[1], self->shi->dysticky[2]);
- break;
- case REFRACT_D:
- obj= Py_BuildValue("(fff)(fff)", self->shi->dxrefract[0], self->shi->dxrefract[1], self->shi->dxrefract[2], self->shi->dyrefract[0], self->shi->dyrefract[1], self->shi->dyrefract[2]);
- break;
- case STRAND_D:
- obj= Py_BuildValue("(ff)", self->shi->dxstrand, self->shi->dystrand);
- break;
- default:
- break;
- }
- }
-
- if(!obj) {
- Py_RETURN_NONE;
- }
- return obj;
-}
-
-static BPy_SockMap *Node_CreateOutputMap(bNode *node, bNodeStack **stack) {
- BPy_SockMap *map = PyObject_NEW(BPy_SockMap, &SockOutMap_Type);
- map->typeinfo= node->typeinfo;
- map->stack= stack;
- return map;
-}
-
-static PyObject *Node_GetOutputMap(BPy_Node *self) {
- BPy_SockMap *outmap= Node_CreateOutputMap(self->node, self->out);
- return (PyObject *)outmap;
-}
-
-static PyObject *Node_GetShi(BPy_Node *self) {
- BPy_ShadeInput *shi= ShadeInput_CreatePyObject(self->shi);
- return (PyObject *)shi;
-
-}
-
-static PyObject *node_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- PyObject *self;
- assert(type!=NULL && type->tp_alloc!=NULL);
- self= type->tp_alloc(type, 1);
- return self;
-}
-
-static int node_init(BPy_Node *self, PyObject *args, PyObject *kwds)
-{
- return 0;
-}
-
-static PyGetSetDef BPy_Node_getseters[] = {
- {"ins",
- (getter)Node_GetInputMap, (setter)NULL,
- "Get the ShadeInput mapping (dictionary)",
- NULL},
- {"outs",
- (getter)Node_GetOutputMap, (setter)NULL,
- "Get the ShadeInput mapping (dictionary)",
- NULL},
- {"shi",
- (getter)Node_GetShi, (setter)NULL,
- "Get the ShadeInput (ShadeInput)",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-static PyGetSetDef BPy_ShadeInput_getseters[] = {
- {"texture",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the current texture coordinate (tuple)",
- (void*)TEXTURE},
- {"texture_global",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the current global texture coordinate (tuple)",
- (void*)GLOBALTEXTURE},
- {"surface_normal",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the current surface normal (tuple)",
- (void*)SURFACENORMAL},
- {"view_normal",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the current view normal (tuple)",
- (void*)VIEWNORMAL},
- {"surface_view_vec",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the vector pointing to the viewpoint from the point being shaded (tuple)",
- (void*)SURFACEVIEWVECTOR},
- {"pixel",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the x,y-coordinate for the pixel rendered (tuple)",
- (void*)PIXEL},
- {"color",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the color for the point being shaded (tuple)",
- (void*)COLOR},
- {"specular",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the specular color for the point being shaded (tuple)",
- (void*)SPECULAR},
- {"mirror",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the mirror color for the point being shaded (tuple)",
- (void*)MIRROR},
- {"ambient",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the ambient color for the point being shaded (tuple)",
- (void*)AMBIENT},
- {"ambient_factor",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the ambient factor for the point being shaded (float)",
- (void*)AMBIENTFACTOR},
- {"emit_factor",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the emit factor for the point being shaded (float)",
- (void*)EMITFACTOR},
- {"displace",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the displace vector for the point being shaded (tuple)",
- (void*)DISPLACE},
- {"strand",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the strand factor(float)",
- (void*)STRAND},
- {"stress",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the stress factor(float)",
- (void*)STRESS},
- {"tangent",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the tangent vector (tuple)",
- (void*)TANGENT},
- {"surface_d",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the surface d (tuple of tuples)",
- (void*)SURFACE_D},
- {"texture_d",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the texture d (tuple of tuples)",
- (void*)TEXTURE_D},
- {"texture_global_d",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the global texture d (tuple of tuples)",
- (void*)GLOBALTEXTURE_D},
- {"reflection_d",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the reflection d (tuple of tuples)",
- (void*)REFLECTION_D},
- {"normal_d",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the normal d (tuple of tuples)",
- (void*)NORMAL_D},
- {"sticky_d",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the sticky d (tuple of tuples)",
- (void*)STICKY_D},
- {"refract_d",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the refract d (tuple of tuples)",
- (void*)REFRACT_D},
- {"strand_d",
- (getter)ShadeInput_getAttribute, (setter)NULL,
- "Get the strand d (tuple)",
- (void*)REFRACT_D},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-PyTypeObject Node_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.Node.node", /* char *tp_name; */
- sizeof( BPy_Node ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- NULL,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL /*( getattrfunc ) PyObject_GenericGetAttr*/, /* getattrfunc tp_getattr; */
- NULL /*( setattrfunc ) PyObject_GenericSetAttr*/, /* setattrfunc tp_setattr; */
- ( cmpfunc ) Node_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Node_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|Py_TPFLAGS_BASETYPE, /* 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, /*BPy_Node_methods,*/ /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Node_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; */
- (initproc)node_init, /* initproc tp_init; */
- /*PyType_GenericAlloc*/NULL, /* allocfunc tp_alloc; */
- node_new, /* 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 ShadeInput_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender.Node.ShadeInput", /* char *tp_name; */
- sizeof( BPy_ShadeInput ), /* 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 ) ShadeInput_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) ShadeInput_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 ***/
- NULL, /*BPy_Node_methods,*/ /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_ShadeInput_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
-};
-
-
-/* Initialise Node module */
-PyObject *Node_Init(void)
-{
- PyObject *submodule;
-
- if( PyType_Ready( &Node_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &ShadeInput_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &OutputDefMap_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &InputDefMap_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &SockInMap_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &SockOutMap_Type ) < 0 )
- return NULL;
- submodule = Py_InitModule3( "Blender.Node", NULL, "");
-
- PyModule_AddIntConstant(submodule, "VALUE", SOCK_VALUE);
- PyModule_AddIntConstant(submodule, "RGBA", SOCK_RGBA);
- PyModule_AddIntConstant(submodule, "VECTOR", SOCK_VECTOR);
-
- Py_INCREF(&Node_Type);
- PyModule_AddObject(submodule, "node", (PyObject *)&Node_Type);
-
- return submodule;
-
-}
-
-static int Node_compare(BPy_Node *a, BPy_Node *b)
-{
- bNode *pa = a->node, *pb = b->node;
- return (pa==pb) ? 0 : -1;
-}
-
-static PyObject *Node_repr(BPy_Node *self)
-{
- return PyString_FromFormat( "[Node \"%s\"]",
- self->node ? self->node->id->name+2 : "empty node");
-}
-
-BPy_Node *Node_CreatePyObject(bNode *node)
-{
- BPy_Node *pynode;
-
- pynode = (BPy_Node *)PyObject_NEW(BPy_Node, &Node_Type);
- if(!pynode) {
- fprintf(stderr,"Couldn't create BPy_Node object\n");
- return (BPy_Node *)(EXPP_ReturnPyObjError(PyExc_MemoryError, "couldn't create BPy_Node object"));
- }
-
- pynode->node= node;
-
- return pynode;
-}
-
-void InitNode(BPy_Node *self, bNode *node) {
- self->node= node;
-}
-
-bNode *Node_FromPyObject(PyObject *pyobj)
-{
- return ((BPy_Node *)pyobj)->node;
-}
-
-void Node_SetStack(BPy_Node *self, bNodeStack **stack, int type)
-{
- if(type==NODE_INPUTSTACK) {
- self->in= stack;
- } else if(type==NODE_OUTPUTSTACK) {
- self->out= stack;
- }
-}
-
-void Node_SetShi(BPy_Node *self, ShadeInput *shi)
-{
- self->shi= shi;
-}
-
-/*********************/
-
-static int ShadeInput_compare(BPy_ShadeInput *a, BPy_ShadeInput *b)
-{
- ShadeInput *pa = a->shi, *pb = b->shi;
- return (pa==pb) ? 0 : -1;
-}
-
-static PyObject *ShadeInput_repr(BPy_ShadeInput *self)
-{
- return PyString_FromFormat( "[ShadeInput @ \"%p\"]", self);
-}
-
-BPy_ShadeInput *ShadeInput_CreatePyObject(ShadeInput *shi)
-{
- BPy_ShadeInput *pyshi;
-
- pyshi = (BPy_ShadeInput *)PyObject_NEW(BPy_ShadeInput, &ShadeInput_Type);
- if(!pyshi) {
- fprintf(stderr,"Couldn't create BPy_ShadeInput object\n");
- return (BPy_ShadeInput *)(EXPP_ReturnPyObjError(PyExc_MemoryError, "couldn't create BPy_ShadeInput object"));
- }
-
- pyshi->shi = shi;
-
- return pyshi;
-}
-#endif
-
diff --git a/source/blender/python/api2_2x/Node.h b/source/blender/python/api2_2x/Node.h
deleted file mode 100644
index 434d0aa684a..00000000000
--- a/source/blender/python/api2_2x/Node.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Noise.c b/source/blender/python/api2_2x/Noise.c
deleted file mode 100644
index dcee6f45d2a..00000000000
--- a/source/blender/python/api2_2x/Noise.c
+++ /dev/null
@@ -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;
-}
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
deleted file mode 100644
index 83c8ed7df3d..00000000000
--- a/source/blender/python/api2_2x/Object.c
+++ /dev/null
@@ -1,5964 +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 Object module provides generic access to Objects of various types via
- * the Python interface.
- *
- *
- * Contributor(s): Michel Selten, Willian Germano, Jacques Guignot,
- * Joseph Gilbert, Stephen Swaney, Bala Gi, Campbell Barton, Johnny Matthews,
- * Ken Hughes, Alex Mole, Jean-Michel Soler
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-struct SpaceIpo;
-struct rctf;
-
-#include "Object.h" /*This must come first */
-
-#include "DNA_object_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_object_force.h"
-#include "DNA_userdef_types.h"
-#include "DNA_key_types.h" /* for pinShape and activeShape */
-
-#include "BKE_action.h"
-#include "BKE_anim.h" /* used for dupli-objects */
-#include "BKE_depsgraph.h"
-#include "BKE_effect.h"
-#include "BKE_font.h"
-#include "BKE_property.h"
-#include "BKE_mball.h"
-#include "BKE_softbody.h"
-#include "BKE_utildefines.h"
-#include "BKE_armature.h"
-#include "BKE_lattice.h"
-#include "BKE_mesh.h"
-#include "BKE_library.h"
-#include "BKE_object.h"
-#include "BKE_curve.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_scene.h"
-#include "BKE_nla.h"
-#include "BKE_material.h"
-#include "BKE_modifier.h"
-#include "BKE_idprop.h"
-#include "BKE_object.h"
-#include "BKE_key.h" /* for setting the activeShape */
-#include "BKE_displist.h"
-
-#include "BSE_editipo.h"
-#include "BSE_edit.h"
-
-#include "BIF_space.h"
-#include "BIF_editview.h"
-#include "BIF_drawscene.h"
-#include "BIF_meshtools.h"
-#include "BIF_editarmature.h"
-#include "BIF_editaction.h"
-#include "BIF_editnla.h"
-
-#include "BLI_arithb.h"
-#include "BLI_blenlib.h"
-
-#include "BDR_editobject.h"
-#include "BDR_editcurve.h"
-#include "BDR_drawobject.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "mydevice.h"
-#include "blendef.h"
-#include "Scene.h"
-#include "Mathutils.h"
-#include "Mesh.h"
-#include "NMesh.h"
-#include "Curve.h"
-#include "Ipo.h"
-#include "Armature.h"
-#include "Pose.h"
-#include "Camera.h"
-#include "Lamp.h"
-#include "Lattice.h"
-#include "Text.h"
-#include "Text3d.h"
-#include "Metaball.h"
-#include "Draw.h"
-#include "NLA.h"
-#include "logic.h"
-#include "Effect.h"
-#include "Group.h"
-#include "Modifier.h"
-#include "Constraint.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-#include "EXPP_interface.h"
-#include "BIF_editkey.h"
-#include "IDProp.h"
-
-/* Defines for insertIpoKey */
-
-#define IPOKEY_LOC 0
-#define IPOKEY_ROT 1
-#define IPOKEY_SIZE 2
-#define IPOKEY_LOCROT 3
-#define IPOKEY_LOCROTSIZE 4
-#define IPOKEY_PI_STRENGTH 5
-#define IPOKEY_PI_FALLOFF 6
-#define IPOKEY_PI_MAXDIST 7 /*Not Ready Yet*/
-#define IPOKEY_PI_SURFACEDAMP 8
-#define IPOKEY_PI_RANDOMDAMP 9
-#define IPOKEY_PI_PERM 10
-#define IPOKEY_LAYER 19
-
-#define PFIELD_FORCE 1
-#define PFIELD_VORTEX 2
-#define PFIELD_MAGNET 3
-#define PFIELD_WIND 4
-
-enum obj_consts {
- EXPP_OBJ_ATTR_LOC_X = 0,
- EXPP_OBJ_ATTR_LOC_Y,
- EXPP_OBJ_ATTR_LOC_Z,
- EXPP_OBJ_ATTR_DLOC_X,
- EXPP_OBJ_ATTR_DLOC_Y,
- EXPP_OBJ_ATTR_DLOC_Z,
- EXPP_OBJ_ATTR_ROT_X,
- EXPP_OBJ_ATTR_ROT_Y,
- EXPP_OBJ_ATTR_ROT_Z,
- EXPP_OBJ_ATTR_DROT_X,
- EXPP_OBJ_ATTR_DROT_Y,
- EXPP_OBJ_ATTR_DROT_Z,
- EXPP_OBJ_ATTR_SIZE_X,
- EXPP_OBJ_ATTR_SIZE_Y,
- EXPP_OBJ_ATTR_SIZE_Z,
- EXPP_OBJ_ATTR_DSIZE_X,
- EXPP_OBJ_ATTR_DSIZE_Y,
- EXPP_OBJ_ATTR_DSIZE_Z,
- EXPP_OBJ_ATTR_LOC,
- EXPP_OBJ_ATTR_DLOC,
- EXPP_OBJ_ATTR_DROT,
- EXPP_OBJ_ATTR_SIZE,
- EXPP_OBJ_ATTR_DSIZE,
- EXPP_OBJ_ATTR_LAYERMASK,
- EXPP_OBJ_ATTR_COLBITS,
- EXPP_OBJ_ATTR_DRAWMODE,
- EXPP_OBJ_ATTR_DRAWTYPE,
- EXPP_OBJ_ATTR_DUPON,
- EXPP_OBJ_ATTR_DUPOFF,
- EXPP_OBJ_ATTR_DUPSTA,
- EXPP_OBJ_ATTR_DUPEND,
- EXPP_OBJ_ATTR_DUPFACESCALEFAC,
- EXPP_OBJ_ATTR_TIMEOFFSET,
- EXPP_OBJ_ATTR_DRAWSIZE,
- EXPP_OBJ_ATTR_PARENT_TYPE,
- EXPP_OBJ_ATTR_PASSINDEX,
- EXPP_OBJ_ATTR_ACT_MATERIAL,
- EXPP_OBJ_ATTR_ACT_SHAPE,
-
- EXPP_OBJ_ATTR_PI_SURFACEDAMP, /* these need to stay together */
- EXPP_OBJ_ATTR_PI_RANDOMDAMP, /* and in order */
- EXPP_OBJ_ATTR_PI_PERM,
- EXPP_OBJ_ATTR_PI_STRENGTH,
- EXPP_OBJ_ATTR_PI_FALLOFF,
- EXPP_OBJ_ATTR_PI_MAXDIST,
- EXPP_OBJ_ATTR_PI_SBDAMP,
- EXPP_OBJ_ATTR_PI_SBIFACETHICK,
- EXPP_OBJ_ATTR_PI_SBOFACETHICK,
-
- EXPP_OBJ_ATTR_SB_NODEMASS, /* these need to stay together */
- EXPP_OBJ_ATTR_SB_GRAV, /* and in order */
- EXPP_OBJ_ATTR_SB_MEDIAFRICT,
- EXPP_OBJ_ATTR_SB_RKLIMIT,
- EXPP_OBJ_ATTR_SB_PHYSICSSPEED,
- EXPP_OBJ_ATTR_SB_GOALSPRING,
- EXPP_OBJ_ATTR_SB_GOALFRICT,
- EXPP_OBJ_ATTR_SB_MINGOAL,
- EXPP_OBJ_ATTR_SB_MAXGOAL,
- EXPP_OBJ_ATTR_SB_DEFGOAL,
- EXPP_OBJ_ATTR_SB_INSPRING,
- EXPP_OBJ_ATTR_SB_INFRICT,
-
-};
-
-#define EXPP_OBJECT_DRAWSIZEMIN 0.01f
-#define EXPP_OBJECT_DRAWSIZEMAX 10.0f
-
-/* clamping and range values for particle interaction settings */
-#define EXPP_OBJECT_PIDAMP_MIN 0.0f
-#define EXPP_OBJECT_PIDAMP_MAX 1.0f
-#define EXPP_OBJECT_PIRDAMP_MIN 0.0f
-#define EXPP_OBJECT_PIRDAMP_MAX 1.0f
-#define EXPP_OBJECT_PIPERM_MIN 0.0f
-#define EXPP_OBJECT_PIPERM_MAX 1.0f
-#define EXPP_OBJECT_PISTRENGTH_MIN 0.0f
-#define EXPP_OBJECT_PISTRENGTH_MAX 1000.0f
-#define EXPP_OBJECT_PIPOWER_MIN 0.0f
-#define EXPP_OBJECT_PIPOWER_MAX 10.0f
-#define EXPP_OBJECT_PIMAXDIST_MIN 0.0f
-#define EXPP_OBJECT_PIMAXDIST_MAX 1000.0f
-#define EXPP_OBJECT_PISBDAMP_MIN 0.0f
-#define EXPP_OBJECT_PISBDAMP_MAX 1.0f
-#define EXPP_OBJECT_PISBIFTMIN 0.001f
-#define EXPP_OBJECT_PISBIFTMAX 1.0f
-#define EXPP_OBJECT_PISBOFTMIN 0.001f
-#define EXPP_OBJECT_PISBOFTMAX 1.0f
-
-/* clamping and range values for softbody settings */
-#define EXPP_OBJECT_SBMASS_MIN 0.0f
-#define EXPP_OBJECT_SBMASS_MAX 50.0f
-#define EXPP_OBJECT_SBGRAVITY_MIN 0.0f
-#define EXPP_OBJECT_SBGRAVITY_MAX 10.0f
-#define EXPP_OBJECT_SBFRICTION_MIN 0.0f
-#define EXPP_OBJECT_SBFRICTION_MAX 10.0f
-#define EXPP_OBJECT_SBSPEED_MIN 0.01f
-#define EXPP_OBJECT_SBSPEED_MAX 100.0f
-#define EXPP_OBJECT_SBERRORLIMIT_MIN 0.01f
-#define EXPP_OBJECT_SBERRORLIMIT_MAX 1.0f
-#define EXPP_OBJECT_SBGOALSPRING_MIN 0.0f
-#define EXPP_OBJECT_SBGOALSPRING_MAX 0.999f
-#define EXPP_OBJECT_SBGOALFRICT_MIN 0.0f
-#define EXPP_OBJECT_SBGOALFRICT_MAX 10.0f
-#define EXPP_OBJECT_SBMINGOAL_MIN 0.0f
-#define EXPP_OBJECT_SBMINGOAL_MAX 1.0f
-#define EXPP_OBJECT_SBMAXGOAL_MIN 0.0f
-#define EXPP_OBJECT_SBMAXGOAL_MAX 1.0f
-#define EXPP_OBJECT_SBINSPRING_MIN 0.0f
-#define EXPP_OBJECT_SBINSPRING_MAX 0.999f
-#define EXPP_OBJECT_SBINFRICT_MIN 0.0f
-#define EXPP_OBJECT_SBINFRICT_MAX 10.0f
-#define EXPP_OBJECT_SBDEFGOAL_MIN 0.0f
-#define EXPP_OBJECT_SBDEFGOAL_MAX 1.0f
-#define EXPP_OBJECT_SBNODEMASSMIN 0.001f
-#define EXPP_OBJECT_SBNODEMASSMAX 50.0f
-#define EXPP_OBJECT_SBGRAVMIN 0.0f
-#define EXPP_OBJECT_SBGRAVMAX 10.0f
-#define EXPP_OBJECT_SBMEDIAFRICTMIN 0.0f
-#define EXPP_OBJECT_SBMEDIAFRICTMAX 10.0f
-#define EXPP_OBJECT_SBRKLIMITMIN 0.01f
-#define EXPP_OBJECT_SBRKLIMITMAX 1.0f
-#define EXPP_OBJECT_SBPHYSICSSPEEDMIN 0.01f
-#define EXPP_OBJECT_SBPHYSICSSPEEDMAX 100.0f
-#define EXPP_OBJECT_SBGOALSPRINGMIN 0.0f
-#define EXPP_OBJECT_SBGOALSPRINGMAX 0.999f
-#define EXPP_OBJECT_SBGOALFRICTMIN 0.0f
-#define EXPP_OBJECT_SBGOALFRICTMAX 10.0f
-#define EXPP_OBJECT_SBMINGOALMIN 0.0f
-#define EXPP_OBJECT_SBMINGOALMAX 1.0f
-#define EXPP_OBJECT_SBMAXGOALMIN 0.0f
-#define EXPP_OBJECT_SBMAXGOALMAX 1.0f
-#define EXPP_OBJECT_SBDEFGOALMIN 0.0f
-#define EXPP_OBJECT_SBDEFGOALMAX 1.0f
-#define EXPP_OBJECT_SBINSPRINGMIN 0.0f
-#define EXPP_OBJECT_SBINSPRINGMAX 0.999f
-#define EXPP_OBJECT_SBINFRICTMIN 0.0f
-#define EXPP_OBJECT_SBINFRICTMAX 10.0f
-#define EXPP_OBJECT_DUPFACESCALEFACMIN 0.001f
-#define EXPP_OBJECT_DUPFACESCALEFACMAX 10000.0f
-
-/*****************************************************************************/
-/* Python API function prototypes for the Blender module. */
-/*****************************************************************************/
-static PyObject *M_Object_New( PyObject * self, PyObject * args );
-PyObject *M_Object_Get( PyObject * self, PyObject * args );
-static PyObject *M_Object_GetSelected( PyObject * self );
-static PyObject *M_Object_Duplicate( PyObject * self, PyObject * args, PyObject *kwd);
-
-/* HELPER FUNCTION FOR PARENTING */
-static PyObject *internal_makeParent(Object *parent, PyObject *py_child, int partype, int noninverse, int fast, int v1, int v2, int v3, char *bonename);
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Object.__doc__ */
-/*****************************************************************************/
-char M_Object_doc[] = "The Blender Object module\n\n\
-This module provides access to **Object Data** in Blender.\n";
-
-char M_Object_New_doc[] =
- "(type) - Add a new object of type 'type' in the current scene";
-
-char M_Object_Get_doc[] =
- "(name) - return the object with the name 'name', returns None if not\
- found.\n\
- If 'name' is not specified, it returns a list of all objects in the\n\
- current scene.";
-
-char M_Object_GetSelected_doc[] =
- "() - Returns a list of selected Objects in the active layer(s)\n\
-The active object is the first in the list, if visible";
-
-char M_Object_Duplicate_doc[] =
- "(linked) - Duplicate all selected, visible objects in the current scene";
-
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Object module: */
-/*****************************************************************************/
-struct PyMethodDef M_Object_methods[] = {
- {"New", ( PyCFunction ) M_Object_New, METH_VARARGS,
- M_Object_New_doc},
- {"Get", ( PyCFunction ) M_Object_Get, METH_VARARGS,
- M_Object_Get_doc},
- {"GetSelected", ( PyCFunction ) M_Object_GetSelected, METH_NOARGS,
- M_Object_GetSelected_doc},
- {"Duplicate", ( PyCFunction ) M_Object_Duplicate, METH_VARARGS | METH_KEYWORDS,
- M_Object_Duplicate_doc},
- {NULL, NULL, 0, NULL}
-};
-
-
-/*****************************************************************************/
-/* Python BPy_Object methods declarations: */
-/*****************************************************************************/
-static int setupSB(Object* ob); /*Make sure Softbody Pointer is initialized */
-static int setupPI(Object* ob);
-
-static PyObject *Object_buildParts( BPy_Object * self );
-static PyObject *Object_clearIpo( BPy_Object * self );
-static PyObject *Object_clrParent( BPy_Object * self, PyObject * args );
-static PyObject *Object_clearTrack( BPy_Object * self, PyObject * args );
-static PyObject *Object_getData(BPy_Object *self, PyObject *args, PyObject *kwd);
-static PyObject *Object_getDeltaLocation( BPy_Object * self );
-static PyObject *Object_getDrawMode( BPy_Object * self );
-static PyObject *Object_getDrawType( BPy_Object * self );
-static PyObject *Object_GetEuler( BPy_Object * self, PyObject * args );
-static PyObject *Object_getInverseMatrix( BPy_Object * self );
-static PyObject *Object_getIpo( BPy_Object * self );
-static PyObject *Object_getLocation( BPy_Object * self, PyObject * args );
-static PyObject *Object_getMaterials( BPy_Object * self, PyObject * args );
-static PyObject *Object_getMatrix( BPy_Object * self, PyObject * args );
-static PyObject *Object_getParent( BPy_Object * self );
-static PyObject *Object_getParentBoneName( BPy_Object * self );
-static int Object_setParentBoneName( BPy_Object * self, PyObject * value );
-static PyObject *Object_getSize( BPy_Object * self, PyObject * args );
-static PyObject *Object_getTimeOffset( BPy_Object * self );
-static PyObject *Object_getTracked( BPy_Object * self );
-static PyObject *Object_getType( BPy_Object * self );
-static PyObject *Object_getBoundBox( BPy_Object * self );
-static PyObject *Object_getAction( BPy_Object * self );
-static PyObject *Object_getPose( BPy_Object * self );
-static PyObject *Object_evaluatePose( BPy_Object * self, PyObject *args );
-static PyObject *Object_getSelected( BPy_Object * self );
-static PyObject *Object_makeDisplayList( BPy_Object * self );
-static PyObject *Object_link( BPy_Object * self, PyObject * args );
-static PyObject *Object_makeParent( BPy_Object * self, PyObject * args );
-static PyObject *Object_join( BPy_Object * self, PyObject * args );
-static PyObject *Object_makeParentDeform( BPy_Object * self, PyObject * args );
-static PyObject *Object_makeParentVertex( BPy_Object * self, PyObject * args );
-static PyObject *Object_makeParentBone( BPy_Object * self, PyObject * args );
-static PyObject *Object_materialUsage( void );
-static PyObject *Object_getDupliObjects ( BPy_Object * self);
-static PyObject *Object_getEffects( BPy_Object * self );
-static PyObject *Object_setDeltaLocation( BPy_Object * self, PyObject * args );
-static PyObject *Object_SetDrawMode( BPy_Object * self, PyObject * args );
-static PyObject *Object_SetDrawType( BPy_Object * self, PyObject * args );
-static PyObject *Object_SetEuler( BPy_Object * self, PyObject * args );
-static PyObject *Object_SetMatrix( BPy_Object * self, PyObject * args );
-static PyObject *Object_SetIpo( BPy_Object * self, PyObject * args );
-static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args );
-static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args );
-static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args );
-static PyObject *Object_setConstraintInfluenceForBone( BPy_Object * self, PyObject * args );
-static PyObject *Object_setLocation( BPy_Object * self, PyObject * args );
-static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args );
-static PyObject *Object_setSize( BPy_Object * self, PyObject * args );
-static PyObject *Object_setTimeOffset( BPy_Object * self, PyObject * args );
-static PyObject *Object_makeTrack( BPy_Object * self, PyObject * args );
-static PyObject *Object_shareFrom( BPy_Object * self, PyObject * args );
-static PyObject *Object_Select( BPy_Object * self, PyObject * args );
-static PyObject *Object_getAllProperties( BPy_Object * self );
-static PyObject *Object_addProperty( BPy_Object * self, PyObject * args );
-static PyObject *Object_removeProperty( BPy_Object * self, PyObject * args );
-static PyObject *Object_getProperty( BPy_Object * self, PyObject * args );
-static PyObject *Object_removeAllProperties( BPy_Object * self );
-static PyObject *Object_copyAllPropertiesTo( BPy_Object * self,
- PyObject * args );
-static PyObject *Object_getScriptLinks( BPy_Object * self, PyObject * value );
-static PyObject *Object_addScriptLink( BPy_Object * self, PyObject * args );
-static PyObject *Object_clearScriptLinks( BPy_Object * self, PyObject *args );
-static PyObject *Object_getPIStrength( BPy_Object * self );
-static PyObject *Object_setPIStrength( BPy_Object * self, PyObject * args );
-static PyObject *Object_getPIFalloff( BPy_Object * self );
-static PyObject *Object_setPIFalloff( BPy_Object * self, PyObject * args );
-static PyObject *Object_getPIMaxDist( BPy_Object * self );
-static PyObject *Object_setPIMaxDist( BPy_Object * self, PyObject * args );
-static PyObject *Object_getPIUseMaxDist( BPy_Object * self );
-static PyObject *Object_SetPIUseMaxDist( BPy_Object * self, PyObject * args );
-static PyObject *Object_getPIType( BPy_Object * self );
-static PyObject *Object_SetPIType( BPy_Object * self, PyObject * args );
-static PyObject *Object_getPIPerm( BPy_Object * self );
-static PyObject *Object_SetPIPerm( BPy_Object * self, PyObject * args );
-static PyObject *Object_getPIRandomDamp( BPy_Object * self );
-static PyObject *Object_setPIRandomDamp( BPy_Object * self, PyObject * args );
-static PyObject *Object_getPISurfaceDamp( BPy_Object * self );
-static PyObject *Object_SetPISurfaceDamp( BPy_Object * self, PyObject * args );
-static PyObject *Object_getPIDeflection( BPy_Object * self );
-static PyObject *Object_SetPIDeflection( BPy_Object * self, PyObject * args );
-
-static int Object_setRBMass( BPy_Object * self, PyObject * args );
-static int Object_setRBFlags( BPy_Object * self, PyObject * args );
-static int Object_setRBShapeBoundType( BPy_Object * self, PyObject * args );
-
-static PyObject *Object_getSBMass( BPy_Object * self );
-static PyObject *Object_setSBMass( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBGravity( BPy_Object * self );
-static PyObject *Object_setSBGravity( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBFriction( BPy_Object * self );
-static PyObject *Object_setSBFriction( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBErrorLimit( BPy_Object * self );
-static PyObject *Object_setSBErrorLimit( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBGoalSpring( BPy_Object * self );
-static PyObject *Object_setSBGoalSpring( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBGoalFriction( BPy_Object * self );
-static PyObject *Object_setSBGoalFriction( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBMinGoal( BPy_Object * self );
-static PyObject *Object_setSBMinGoal( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBMaxGoal( BPy_Object * self );
-static PyObject *Object_setSBMaxGoal( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBInnerSpring( BPy_Object * self );
-static PyObject *Object_setSBInnerSpring( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBInnerSpringFriction( BPy_Object * self );
-static PyObject *Object_setSBInnerSpringFriction( BPy_Object * self, PyObject * args );
-
-static PyObject *Object_isSB( BPy_Object * self );
-static PyObject *Object_getSBDefaultGoal( BPy_Object * self );
-static PyObject *Object_setSBDefaultGoal( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBUseGoal( BPy_Object * self );
-static PyObject *Object_SetSBUseGoal( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBUseEdges( BPy_Object * self );
-static PyObject *Object_SetSBUseEdges( BPy_Object * self, PyObject * args );
-static PyObject *Object_getSBStiffQuads( BPy_Object * self );
-static PyObject *Object_SetSBStiffQuads( BPy_Object * self, PyObject * args );
-static PyObject *Object_insertShapeKey(BPy_Object * self);
-static PyObject *Object_copyNLA( BPy_Object * self, PyObject * args );
-static PyObject *Object_convertActionToStrip( BPy_Object * self );
-static PyObject *Object_copy(BPy_Object * self); /* __copy__ */
-
-/*****************************************************************************/
-/* Python BPy_Object methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Object_methods[] = {
- /* name, method, flags, doc */
- {"buildParts", ( PyCFunction ) Object_buildParts, METH_NOARGS,
- "Recalcs particle system (if any) "},
- {"getIpo", ( PyCFunction ) Object_getIpo, METH_NOARGS,
- "Returns the ipo of this object (if any) "},
- {"clrParent", ( PyCFunction ) Object_clrParent, METH_VARARGS,
- "Clears parent object. Optionally specify:\n\
-mode\n\tnonzero: Keep object transform\nfast\n\t>0: Don't update scene \
-hierarchy (faster)"},
- {"clearTrack", ( PyCFunction ) Object_clearTrack, METH_VARARGS,
- "Make this object not track another anymore. Optionally specify:\n\
-mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \
-hierarchy (faster)"},
- {"getData", ( PyCFunction ) Object_getData, METH_VARARGS | METH_KEYWORDS,
- "(name_only = 0, mesh = 0) - Returns the datablock object containing the object's \
-data, e.g. Mesh.\n\
-If 'name_only' is nonzero or True, only the name of the datablock is returned"},
- {"getDeltaLocation", ( PyCFunction ) Object_getDeltaLocation,
- METH_NOARGS,
- "Returns the object's delta location (x, y, z)"},
- {"getDrawMode", ( PyCFunction ) Object_getDrawMode, METH_NOARGS,
- "Returns the object draw modes"},
- {"getDrawType", ( PyCFunction ) Object_getDrawType, METH_NOARGS,
- "Returns the object draw type"},
- {"getAction", ( PyCFunction ) Object_getAction, METH_NOARGS,
- "Returns the active action for this object"},
- {"evaluatePose", ( PyCFunction ) Object_evaluatePose, METH_VARARGS,
- "(framenum) - Updates the pose to a certain frame number when the Object is\
- bound to an Action"},
- {"getPose", ( PyCFunction ) Object_getPose, METH_NOARGS,
- "() - returns the pose from an object if it exists, else None"},
- {"isSelected", ( PyCFunction ) Object_getSelected, METH_NOARGS,
- "Return a 1 or 0 depending on whether the object is selected"},
- {"getEuler", ( PyCFunction ) Object_GetEuler, METH_VARARGS,
- "(space = 'localspace' / 'worldspace') - Returns the object's rotation as Euler rotation vector\n\
-(rotX, rotY, rotZ)"},
- {"getInverseMatrix", ( PyCFunction ) Object_getInverseMatrix,
- METH_NOARGS,
- "Returns the object's inverse matrix"},
- {"getLocation", ( PyCFunction ) Object_getLocation, METH_VARARGS,
- "(space = 'localspace' / 'worldspace') - Returns the object's location (x, y, z)\n\
-"},
- {"getMaterials", ( PyCFunction ) Object_getMaterials, METH_VARARGS,
- "(i = 0) - Returns list of materials assigned to the object.\n\
-if i is nonzero, empty slots are not ignored: they are returned as None's."},
- {"getMatrix", ( PyCFunction ) Object_getMatrix, METH_VARARGS,
- "(str = 'worldspace') - Returns the object matrix.\n\
-(str = 'worldspace') - the desired matrix: worldspace (default), localspace\n\
-or old_worldspace.\n\
-\n\
-'old_worldspace' was the only behavior before Blender 2.34. With it the\n\
-matrix is not updated for changes made by the script itself\n\
-(like obj.LocX = 10) until a redraw happens, either called by the script or\n\
-automatic when the script finishes."},
- {"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
- "Returns the name of the object"},
- {"getParent", ( PyCFunction ) Object_getParent, METH_NOARGS,
- "Returns the object's parent object"},
- {"getParentBoneName", ( PyCFunction ) Object_getParentBoneName, METH_NOARGS,
- "Returns None, or the 'sub-name' of the parent (eg. Bone name)"},
- {"getSize", ( PyCFunction ) Object_getSize, METH_VARARGS,
- "(space = 'localspace' / 'worldspace') - Returns the object's size (x, y, z)"},
- {"getTimeOffset", ( PyCFunction ) Object_getTimeOffset, METH_NOARGS,
- "Returns the object's time offset"},
- {"getTracked", ( PyCFunction ) Object_getTracked, METH_NOARGS,
- "Returns the object's tracked object"},
- {"getType", ( PyCFunction ) Object_getType, METH_NOARGS,
- "Returns type of string of Object"},
-/* Particle Interaction */
-
- {"getPIStrength", ( PyCFunction ) Object_getPIStrength, METH_NOARGS,
- "Returns Particle Interaction Strength"},
- {"setPIStrength", ( PyCFunction ) Object_setPIStrength, METH_VARARGS,
- "Sets Particle Interaction Strength"},
- {"getPIFalloff", ( PyCFunction ) Object_getPIFalloff, METH_NOARGS,
- "Returns Particle Interaction Falloff"},
- {"setPIFalloff", ( PyCFunction ) Object_setPIFalloff, METH_VARARGS,
- "Sets Particle Interaction Falloff"},
- {"getPIMaxDist", ( PyCFunction ) Object_getPIMaxDist, METH_NOARGS,
- "Returns Particle Interaction Max Distance"},
- {"setPIMaxDist", ( PyCFunction ) Object_setPIMaxDist, METH_VARARGS,
- "Sets Particle Interaction Max Distance"},
- {"getPIUseMaxDist", ( PyCFunction ) Object_getPIUseMaxDist, METH_NOARGS,
- "Returns bool for Use Max Distace in Particle Interaction "},
- {"setPIUseMaxDist", ( PyCFunction ) Object_SetPIUseMaxDist, METH_VARARGS,
- "Sets if Max Distance should be used in Particle Interaction"},
- {"getPIType", ( PyCFunction ) Object_getPIType, METH_NOARGS,
- "Returns Particle Interaction Type"},
- {"setPIType", ( PyCFunction ) Object_SetPIType, METH_VARARGS,
- "sets Particle Interaction Type"},
- {"getPIPerm", ( PyCFunction ) Object_getPIPerm, METH_NOARGS,
- "Returns Particle Interaction Permiability"},
- {"setPIPerm", ( PyCFunction ) Object_SetPIPerm, METH_VARARGS,
- "Sets Particle Interaction Permiability"},
- {"getPISurfaceDamp", ( PyCFunction ) Object_getPISurfaceDamp, METH_NOARGS,
- "Returns Particle Interaction Surface Damping"},
- {"setPISurfaceDamp", ( PyCFunction ) Object_SetPISurfaceDamp, METH_VARARGS,
- "Sets Particle Interaction Surface Damping"},
- {"getPIRandomDamp", ( PyCFunction ) Object_getPIRandomDamp, METH_NOARGS,
- "Returns Particle Interaction Random Damping"},
- {"setPIRandomDamp", ( PyCFunction ) Object_setPIRandomDamp, METH_VARARGS,
- "Sets Particle Interaction Random Damping"},
- {"getPIDeflection", ( PyCFunction ) Object_getPIDeflection, METH_NOARGS,
- "Returns Particle Interaction Deflection"},
- {"setPIDeflection", ( PyCFunction ) Object_SetPIDeflection, METH_VARARGS,
- "Sets Particle Interaction Deflection"},
-
-/* Softbody */
-
- {"isSB", ( PyCFunction ) Object_isSB, METH_NOARGS,
- "True if object is a soft body"},
- {"getSBMass", ( PyCFunction ) Object_getSBMass, METH_NOARGS,
- "Returns SB Mass"},
- {"setSBMass", ( PyCFunction ) Object_setSBMass, METH_VARARGS,
- "Sets SB Mass"},
- {"getSBGravity", ( PyCFunction ) Object_getSBGravity, METH_NOARGS,
- "Returns SB Gravity"},
- {"setSBGravity", ( PyCFunction ) Object_setSBGravity, METH_VARARGS,
- "Sets SB Gravity"},
- {"getSBFriction", ( PyCFunction ) Object_getSBFriction, METH_NOARGS,
- "Returns SB Friction"},
- {"setSBFriction", ( PyCFunction ) Object_setSBFriction, METH_VARARGS,
- "Sets SB Friction"},
- {"getSBErrorLimit", ( PyCFunction ) Object_getSBErrorLimit, METH_NOARGS,
- "Returns SB ErrorLimit"},
- {"setSBErrorLimit", ( PyCFunction ) Object_setSBErrorLimit, METH_VARARGS,
- "Sets SB ErrorLimit"},
- {"getSBGoalSpring", ( PyCFunction ) Object_getSBGoalSpring, METH_NOARGS,
- "Returns SB GoalSpring"},
- {"setSBGoalSpring", ( PyCFunction ) Object_setSBGoalSpring, METH_VARARGS,
- "Sets SB GoalSpring"},
- {"getSBGoalFriction", ( PyCFunction ) Object_getSBGoalFriction, METH_NOARGS,
- "Returns SB GoalFriction"},
- {"setSBGoalFriction", ( PyCFunction ) Object_setSBGoalFriction, METH_VARARGS,
- "Sets SB GoalFriction"},
- {"getSBMinGoal", ( PyCFunction ) Object_getSBMinGoal, METH_NOARGS,
- "Returns SB MinGoal"},
- {"setSBMinGoal", ( PyCFunction ) Object_setSBMinGoal, METH_VARARGS,
- "Sets SB MinGoal "},
- {"getSBMaxGoal", ( PyCFunction ) Object_getSBMaxGoal, METH_NOARGS,
- "Returns SB MaxGoal"},
- {"setSBMaxGoal", ( PyCFunction ) Object_setSBMaxGoal, METH_VARARGS,
- "Sets SB MaxGoal"},
- {"getSBInnerSpring", ( PyCFunction ) Object_getSBInnerSpring, METH_NOARGS,
- "Returns SB InnerSpring"},
- {"setSBInnerSpring", ( PyCFunction ) Object_setSBInnerSpring, METH_VARARGS,
- "Sets SB InnerSpring"},
- {"getSBInnerSpringFriction", ( PyCFunction ) Object_getSBInnerSpringFriction, METH_NOARGS,
- "Returns SB InnerSpringFriction"},
- {"setSBInnerSpringFriction", ( PyCFunction ) Object_setSBInnerSpringFriction, METH_VARARGS,
- "Sets SB InnerSpringFriction"},
- {"getSBDefaultGoal", ( PyCFunction ) Object_getSBDefaultGoal, METH_NOARGS,
- "Returns SB DefaultGoal"},
- {"setSBDefaultGoal", ( PyCFunction ) Object_setSBDefaultGoal, METH_VARARGS,
- "Sets SB DefaultGoal"},
- {"getSBUseGoal", ( PyCFunction ) Object_getSBUseGoal, METH_NOARGS,
- "Returns SB UseGoal"},
- {"setSBUseGoal", ( PyCFunction ) Object_SetSBUseGoal, METH_VARARGS,
- "Sets SB UseGoal"},
- {"getSBUseEdges", ( PyCFunction ) Object_getSBUseEdges, METH_NOARGS,
- "Returns SB UseEdges"},
- {"setSBUseEdges", ( PyCFunction ) Object_SetSBUseEdges, METH_VARARGS,
- "Sets SB UseEdges"},
- {"getSBStiffQuads", ( PyCFunction ) Object_getSBStiffQuads, METH_NOARGS,
- "Returns SB StiffQuads"},
- {"setSBStiffQuads", ( PyCFunction ) Object_SetSBStiffQuads, METH_VARARGS,
- "Sets SB StiffQuads"},
- {"getBoundBox", ( PyCFunction ) Object_getBoundBox, METH_NOARGS,
- "Returns the object's bounding box"},
- {"makeDisplayList", ( PyCFunction ) Object_makeDisplayList, METH_NOARGS,
- "Update this object's Display List. Some changes like turning\n\
-'SubSurf' on for a mesh need this method (followed by a Redraw) to\n\
-show the changes on the 3d window."},
- {"link", ( PyCFunction ) Object_link, METH_VARARGS,
- "Links Object with data provided in the argument. The data must\n\
-match the Object's type, so you cannot link a Lamp to a Mesh type object."},
- {"makeParent", ( PyCFunction ) Object_makeParent, METH_VARARGS,
- "Makes the object the parent of the objects provided in the\n\
-argument which must be a list of valid Objects. Optional extra arguments:\n\
-mode:\n\t0: make parent with inverse\n\t1: without inverse\n\
-fast:\n\t0: update scene hierarchy automatically\n\t\
-don't update scene hierarchy (faster). In this case, you must\n\t\
-explicitly update the Scene hierarchy."},
- {"join", ( PyCFunction ) Object_join, METH_VARARGS,
- "(object_list) - Joins the objects in object list of the same type, into this object."},
- {"makeParentDeform", ( PyCFunction ) Object_makeParentDeform, METH_VARARGS,
- "Makes the object the deformation parent of the objects provided in the \n\
-argument which must be a list of valid Objects. Optional extra arguments:\n\
-mode:\n\t0: make parent with inverse\n\t1: without inverse\n\
-fast:\n\t0: update scene hierarchy automatically\n\t\
-don't update scene hierarchy (faster). In this case, you must\n\t\
-explicitly update the Scene hierarchy."},
- {"makeParentVertex", ( PyCFunction ) Object_makeParentVertex, METH_VARARGS,
- "Makes the object the vertex parent of the objects provided in the \n\
-argument which must be a list of valid Objects. \n\
-The second argument is a tuple of 1 or 3 positive integers which corresponds \
-to the index of the vertex you are parenting to.\n\
-Optional extra arguments:\n\
-mode:\n\t0: make parent with inverse\n\t1: without inverse\n\
-fast:\n\t0: update scene hierarchy automatically\n\t\
-don't update scene hierarchy (faster). In this case, you must\n\t\
-explicitly update the Scene hierarchy."},
- {"makeParentBone", ( PyCFunction ) Object_makeParentBone, METH_VARARGS,
- "Makes this armature objects bone, the parent of the objects provided in the \n\
-argument which must be a list of valid Objects. Optional extra arguments:\n\
-mode:\n\t0: make parent with inverse\n\t1: without inverse\n\
-fast:\n\t0: update scene hierarchy automatically\n\t\
-don't update scene hierarchy (faster). In this case, you must\n\t\
-explicitely update the Scene hierarchy."},
-
- {"materialUsage", ( PyCFunction ) Object_materialUsage, METH_NOARGS,
- "Determines the way the material is used and returns status.\n\
-Possible arguments (provide as strings):\n\
-\tData: Materials assigned to the object's data are shown. (default)\n\
-\tObject: Materials assigned to the object are shown."},
- {"setDeltaLocation", ( PyCFunction ) Object_setDeltaLocation,
- METH_VARARGS,
- "Sets the object's delta location which must be a vector triple."},
- {"setDrawMode", ( PyCFunction ) Object_SetDrawMode, METH_VARARGS,
- "Sets the object's drawing mode. The argument can be a sum of:\n\
-2: axis\n4: texspace\n8: drawname\n16: drawimage\n32: drawwire\n64: drawxray\n128: drawtransp"},
- {"setDrawType", ( PyCFunction ) Object_SetDrawType, METH_VARARGS,
- "Sets the object's drawing type. The argument must be one of:\n\
-1: Bounding box\n2: Wire\n3: Solid\n4: Shaded\n5: Textured"},
- {"setEuler", ( PyCFunction ) Object_SetEuler, METH_VARARGS,
- "Set the object's rotation according to the specified Euler\n\
-angles. The argument must be a vector triple"},
- {"setMatrix", ( PyCFunction ) Object_SetMatrix, METH_VARARGS,
- "Set and apply a new local matrix for the object"},
- {"setLocation", ( PyCFunction ) Object_setLocation, METH_VARARGS,
- "Set the object's location. The first argument must be a vector\n\
-triple."},
- {"setMaterials", ( PyCFunction ) Object_setMaterials, METH_VARARGS,
- "Sets materials. The argument must be a list of valid material\n\
-objects."},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "Sets the name of the object"},
- {"setSize", ( PyCFunction ) Object_setSize, METH_VARARGS,
- "Set the object's size. The first argument must be a vector\n\
-triple."},
- {"setTimeOffset", ( PyCFunction ) Object_setTimeOffset, METH_VARARGS,
- "Set the object's time offset."},
- {"makeTrack", ( PyCFunction ) Object_makeTrack, METH_VARARGS,
- "(trackedobj, fast = 0) - Make this object track another.\n\
- (trackedobj) - the object that will be tracked.\n\
- (fast = 0) - if 0: update the scene hierarchy automatically. If you\n\
- set 'fast' to a nonzero value, don't forget to update the scene yourself\n\
- (see scene.update())."},
- {"shareFrom", ( PyCFunction ) Object_shareFrom, METH_VARARGS,
- "Link data of self with object specified in the argument. This\n\
-works only if self and the object specified are of the same type."},
- {"select", ( PyCFunction ) Object_Select, METH_VARARGS,
- "( 1 or 0 ) - Set the selected state of the object.\n\
- 1 is selected, 0 not selected "},
- {"setIpo", ( PyCFunction ) Object_SetIpo, METH_VARARGS,
- "(Blender Ipo) - Sets the object's ipo"},
- {"clearIpo", ( PyCFunction ) Object_clearIpo, METH_NOARGS,
- "() - Unlink ipo from this object"},
-
- {"insertIpoKey", ( PyCFunction ) Object_insertIpoKey, METH_VARARGS,
- "( Object IPO type ) - Inserts a key into IPO"},
- {"insertPoseKey", ( PyCFunction ) Object_insertPoseKey, METH_VARARGS,
- "( Object Pose type ) - Inserts a key into Action"},
- {"insertCurrentPoseKey", ( PyCFunction ) Object_insertCurrentPoseKey, METH_VARARGS,
- "( Object Pose type ) - Inserts a key into Action based on current pose"},
- {"setConstraintInfluenceForBone", ( PyCFunction ) Object_setConstraintInfluenceForBone, METH_VARARGS,
- "( ) - sets a constraint influence for a certain bone in this (armature)object."},
- {"copyNLA", ( PyCFunction ) Object_copyNLA, METH_VARARGS,
- "( ) - copies all NLA strips from another object to this object."},
- {"convertActionToStrip", ( PyCFunction ) Object_convertActionToStrip, METH_NOARGS,
- "( ) - copies all NLA strips from another object to this object."},
- {"getAllProperties", ( PyCFunction ) Object_getAllProperties, METH_NOARGS,
- "() - Get all the properties from this object"},
- {"addProperty", ( PyCFunction ) Object_addProperty, METH_VARARGS,
- "() - Add a property to this object"},
- {"removeProperty", ( PyCFunction ) Object_removeProperty, METH_VARARGS,
- "() - Remove a property from this object"},
- {"getProperty", ( PyCFunction ) Object_getProperty, METH_VARARGS,
- "() - Get a property from this object by name"},
- {"removeAllProperties", ( PyCFunction ) Object_removeAllProperties,
- METH_NOARGS,
- "() - removeAll a properties from this object"},
- {"copyAllPropertiesTo", ( PyCFunction ) Object_copyAllPropertiesTo,
- METH_VARARGS,
- "() - copy all properties from this object to another object"},
- {"getScriptLinks", ( PyCFunction ) Object_getScriptLinks, METH_O,
- "(eventname) - Get a list of this object's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged, Redraw or Render."},
- {"addScriptLink", ( PyCFunction ) Object_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new object scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged, Redraw or Render."},
- {"clearScriptLinks", ( PyCFunction ) Object_clearScriptLinks,
- METH_VARARGS,
- "() - Delete all scriptlinks from this object.\n"
- "([s1<,s2,s3...>]) - Delete specified scriptlinks from this object."},
- {"insertShapeKey", ( PyCFunction ) Object_insertShapeKey, METH_NOARGS,
- "() - Insert a Shape Key in the current object"},
- {"__copy__", ( PyCFunction ) Object_copy, METH_NOARGS,
- "() - Return a copy of this object."},
- {"copy", ( PyCFunction ) Object_copy, METH_NOARGS,
- "() - Return a copy of this object."},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* PythonTypeObject callback function prototypes */
-/*****************************************************************************/
-static void Object_dealloc( BPy_Object * obj );
-static PyObject *Object_repr( BPy_Object * obj );
-static int Object_compare( BPy_Object * a, BPy_Object * b );
-
-/*****************************************************************************/
-/* Function: M_Object_New */
-/* Python equivalent: Blender.Object.New */
-/*****************************************************************************/
-
-/*
- * Note: if this method is called without later linking object data to it,
- * errors can be caused elsewhere in Blender. Future versions of the API
- * will designate obdata as a parameter to this method to prevent this, and
- * eventually this method will be deprecated.
- *
- * When we can guarantee that objects will always have valid obdata,
- * unlink_object() should be edited to remove checks for NULL pointers and
- * debugging messages.
- */
-
-PyObject *M_Object_New( PyObject * self_unused, PyObject * args )
-{
- struct Object *object;
- int type;
- char *str_type;
- char *name = NULL;
- PyObject *py_object;
- BPy_Object *blen_object;
-
- if( !PyArg_ParseTuple( args, "s|s", &str_type, &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "string expected as argument" );
-
- if( strcmp( str_type, "Armature" ) == 0 )
- type = OB_ARMATURE;
- else if( strcmp( str_type, "Camera" ) == 0 )
- type = OB_CAMERA;
- else if( strcmp( str_type, "Curve" ) == 0 )
- type = OB_CURVE;
- else if (strcmp (str_type, "Text") == 0)
- type = OB_FONT;
- else if( strcmp( str_type, "Lamp" ) == 0 )
- type = OB_LAMP;
- else if( strcmp( str_type, "Lattice" ) == 0 )
- type = OB_LATTICE;
- else if( strcmp( str_type, "Mball" ) == 0 )
- type = OB_MBALL;
- else if( strcmp( str_type, "Mesh" ) == 0 )
- type = OB_MESH;
- else if( strcmp( str_type, "Surf" ) == 0 )
- type = OB_SURF;
-/* else if (strcmp (str_type, "Wave") == 0) type = OB_WAVE; */
- else if( strcmp( str_type, "Empty" ) == 0 )
- type = OB_EMPTY;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Unknown type specified" );
-
- /* Create a new object. */
- if( name == NULL ) {
- /* No name is specified, set the name to the type of the object. */
- name = str_type;
- }
- object = add_only_object(type, name);
-
- object->flag = 0;
- object->lay = 1; /* Layer, by default visible*/
- object->data = NULL;
-
- /* user count is incremented in Object_CreatePyObject */
- object->id.us = 0;
-
- /* Create a Python object from it. */
- py_object = Object_CreatePyObject( object );
- blen_object = (BPy_Object *)py_object;
-
- /* store the real object type in the PyObject, treat this as an Empty
- * until it has some obdata */
- blen_object->realtype = object->type;
- object->type = OB_EMPTY;
-
- return py_object;
-}
-
-/*****************************************************************************/
-/* Function: M_Object_Get */
-/* Python equivalent: Blender.Object.Get */
-/*****************************************************************************/
-PyObject *M_Object_Get( PyObject * self_unused, PyObject * args )
-{
- struct Object *object;
- PyObject *blen_object;
- char *name = NULL;
-
- PyArg_ParseTuple( args, "|s", &name );
-
- if( name != NULL ) {
- object = ( Object * ) GetIdFromList( &( G.main->object ), name );
-
- /* No object exists with the name specified in the argument name. */
- if( !object ){
- char buffer[128];
- PyOS_snprintf( buffer, sizeof(buffer),
- "object \"%s\" not found", name);
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- buffer );
- }
-
- /* objects used in pydriver expressions need this */
- if (bpy_during_pydriver())
- bpy_pydriver_appendToList(object);
-
- return Object_CreatePyObject( object );
- } else {
- /* No argument has been given. Return a list of all objects. */
- PyObject *obj_list;
- Link *link;
- int index;
-
- /* do not allow Get() (w/o arguments) inside pydriver, otherwise
- * we'd have to update all objects in the DAG */
- if (bpy_during_pydriver())
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Object.Get requires an argument when used in pydrivers" );
-
- obj_list = PyList_New( BLI_countlist( &( G.main->object ) ) );
-
- if( !obj_list )
- return EXPP_ReturnPyObjError( PyExc_SystemError,
- "List creation failed." );
-
- link = G.main->object.first;
- index = 0;
- while( link ) {
- object = ( Object * ) link;
- blen_object = Object_CreatePyObject( object );
- if( !blen_object ) {
- Py_DECREF( obj_list );
- Py_RETURN_NONE;
- }
- PyList_SetItem( obj_list, index, blen_object );
- index++;
- link = link->next;
- }
- return obj_list;
- }
-}
-
-/*****************************************************************************/
-/* Function: M_Object_GetSelected */
-/* Python equivalent: Blender.Object.GetSelected */
-/*****************************************************************************/
-static PyObject *M_Object_GetSelected( PyObject * self_unused )
-{
- PyObject *blen_object;
- PyObject *list;
- Base *base_iter;
-
- list = PyList_New( 0 );
-
- if( G.vd == NULL ) {
- /* No 3d view has been initialized yet, simply return an empty list */
- return list;
- }
-
- if( ( G.scene->basact ) &&
- ( ( G.scene->basact->flag & SELECT ) &&
- ( G.scene->basact->lay & G.vd->lay ) ) ) {
-
- /* Active object is first in the list. */
- blen_object = Object_CreatePyObject( G.scene->basact->object );
- if( !blen_object ) {
- Py_DECREF( list );
- Py_RETURN_NONE;
- }
- PyList_Append( list, blen_object );
- Py_DECREF( blen_object );
- }
-
- base_iter = G.scene->base.first;
- while( base_iter ) {
- if( ( ( base_iter->flag & SELECT ) &&
- ( base_iter->lay & G.vd->lay ) ) &&
- ( base_iter != G.scene->basact ) ) {
-
- blen_object = Object_CreatePyObject( base_iter->object );
- if( blen_object ) {
- PyList_Append( list, blen_object );
- Py_DECREF( blen_object );
- }
- }
- base_iter = base_iter->next;
- }
- return list;
-}
-
-
-/*****************************************************************************/
-/* Function: M_Object_Duplicate */
-/* Python equivalent: Blender.Object.Duplicate */
-/*****************************************************************************/
-static PyObject *M_Object_Duplicate( PyObject * self_unused,
- PyObject * args, PyObject *kwd )
-{
- int dupflag= 0; /* this a flag, passed to adduplicate() and used instead of U.dupflag sp python can set what is duplicated */
-
- /* the following variables are bools, if set true they will modify the dupflag to pass to adduplicate() */
- int mesh_dupe = 0;
- int surface_dupe = 0;
- int curve_dupe = 0;
- int text_dupe = 0;
- int metaball_dupe = 0;
- int armature_dupe = 0;
- int lamp_dupe = 0;
- int material_dupe = 0;
- int texture_dupe = 0;
- int ipo_dupe = 0;
-
- static char *kwlist[] = {"mesh", "surface", "curve",
- "text", "metaball", "armature", "lamp", "material", "texture", "ipo", NULL};
-
- /* duplicating in background causes segfaults */
- if( G.background == 1 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot duplicate objects in background mode" );
-
-
- if (!PyArg_ParseTupleAndKeywords(args, kwd, "|iiiiiiiiii", kwlist,
- &mesh_dupe, &surface_dupe, &curve_dupe, &text_dupe, &metaball_dupe,
- &armature_dupe, &lamp_dupe, &material_dupe, &texture_dupe, &ipo_dupe))
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or bool keywords 'mesh', 'surface', 'curve', 'text', 'metaball', 'armature', 'lamp' 'material', 'texture' and 'ipo' as arguments" );
-
- /* USER_DUP_ACT for actions is not supported in the UI so dont support it here */
- if (mesh_dupe) dupflag |= USER_DUP_MESH;
- if (surface_dupe) dupflag |= USER_DUP_SURF;
- if (curve_dupe) dupflag |= USER_DUP_CURVE;
- if (text_dupe) dupflag |= USER_DUP_FONT;
- if (metaball_dupe) dupflag |= USER_DUP_MBALL;
- if (armature_dupe) dupflag |= USER_DUP_ARM;
- if (lamp_dupe) dupflag |= USER_DUP_LAMP;
- if (material_dupe) dupflag |= USER_DUP_MAT;
- if (texture_dupe) dupflag |= USER_DUP_TEX;
- if (ipo_dupe) dupflag |= USER_DUP_IPO;
- adduplicate(2, dupflag); /* 2 is a mode with no transform and no redraw, Duplicate the current selection, context sensitive */
- Py_RETURN_NONE;
-}
-
-
-/*****************************************************************************/
-/* Python BPy_Object methods: */
-/*****************************************************************************/
-
-static PyObject *Object_buildParts( BPy_Object * self )
-{
- build_particle_system( self->object );
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_clearIpo( BPy_Object * self )
-{
- Object *ob = self->object;
- Ipo *ipo = ( Ipo * ) ob->ipo;
-
- if( ipo ) {
- ID *id = &ipo->id;
- if( id->us > 0 )
- id->us--;
- ob->ipo = NULL;
-
- Py_RETURN_TRUE;
- }
-
- Py_RETURN_FALSE; /* no ipo found */
-}
-
-static PyObject *Object_clrParent( BPy_Object * self, PyObject * args )
-{
- int mode = 0;
- int fast = 0;
-
- if( !PyArg_ParseTuple( args, "|ii", &mode, &fast ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected one or two optional integers as arguments" );
-
- /* Remove the link only, the object is still in the scene. */
- self->object->parent = NULL;
-
- if( mode == 2 ) {
- /* Keep transform */
- apply_obmat( self->object );
- }
-
- if( !fast )
- DAG_scene_sort( G.scene );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_clearTrack( BPy_Object * self, PyObject * args )
-{
- int mode = 0;
- int fast = 0;
-
- if( !PyArg_ParseTuple( args, "|ii", &mode, &fast ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected one or two optional integers as arguments" );
-
- /* Remove the link only, the object is still in the scene. */
- self->object->track = NULL;
-
- if( mode ) {
- /* Keep transform */
- apply_obmat( self->object );
- }
-
- if( !fast )
- DAG_scene_sort( G.scene );
-
- Py_RETURN_NONE;
-}
-
-/* adds object data to a Blender object, if object->data = NULL */
-int EXPP_add_obdata( struct Object *object )
-{
- if( object->data != NULL )
- return -1;
-
- switch ( object->type ) {
- case OB_ARMATURE:
- /* TODO: Do we need to add something to G? (see the OB_LAMP case) */
- object->data = add_armature( "Armature" );
- break;
- case OB_CAMERA:
- /* TODO: Do we need to add something to G? (see the OB_LAMP case) */
- object->data = add_camera( "Camera" );
- break;
- case OB_CURVE:
- object->data = add_curve( "Curve", OB_CURVE );
- G.totcurve++;
- break;
- case OB_LAMP:
- object->data = add_lamp( "Lamp" );
- G.totlamp++;
- break;
- case OB_MESH:
- object->data = add_mesh( "Mesh" );
- G.totmesh++;
- break;
- case OB_LATTICE:
- object->data = ( void * ) add_lattice( "Lattice" );
- object->dt = OB_WIRE;
- break;
- case OB_MBALL:
- object->data = add_mball( "Meta" );
- break;
-
- /* TODO the following types will be supported later,
- be sure to update Scene_link when new types are supported
- case OB_SURF:
- object->data = add_curve(OB_SURF);
- G.totcurve++;
- break;
- case OB_FONT:
- object->data = add_curve(OB_FONT);
- break;
- case OB_WAVE:
- object->data = add_wave();
- break;
- */
- default:
- break;
- }
-
- if( !object->data )
- return -1;
-
- return 0;
-}
-
-static PyObject *Object_getDeltaLocation( BPy_Object * self )
-{
- return Py_BuildValue( "fff", self->object->dloc[0],
- self->object->dloc[1], self->object->dloc[2] );
-}
-
-static PyObject *Object_getAction( BPy_Object * self )
-{
- if( self->object->action )
- return Action_CreatePyObject( self->object->action );
- Py_RETURN_NONE;
-}
-
-static int Object_setAction( BPy_Object * self, PyObject * value )
-{
- return GenericLib_assignData(value, (void **) &self->object->action, 0, 1, ID_AC, 0);
-}
-
-static PyObject *Object_evaluatePose(BPy_Object *self, PyObject *args)
-{
- int frame = 1;
- if( !PyArg_ParseTuple( args, "i", &frame ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
-
- frame = EXPP_ClampInt(frame, MINFRAME, MAXFRAME);
- G.scene->r.cfra = frame;
- do_all_pose_actions(self->object);
- where_is_pose (self->object);
-
- Py_RETURN_NONE;
-}
-
-static PyObject * Object_getPose(BPy_Object *self)
-{
- /*if there is no pose will return PyNone*/
- return PyPose_FromPose(self->object->pose, self->object->id.name+2);
-}
-
-static PyObject *Object_getSelected( BPy_Object * self )
-{
- Base *base;
-
- base = FIRSTBASE;
- while( base ) {
- if( base->object == self->object ) {
- if( base->flag & SELECT ) {
- Py_RETURN_TRUE;
- } else {
- Py_RETURN_FALSE;
- }
- }
- base = base->next;
- }
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "could not find object's selection state" );
-}
-
-static int Object_setSelect( BPy_Object * self, PyObject * value )
-{
- Base *base;
- int param = PyObject_IsTrue( value );
-
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- base = FIRSTBASE;
- while( base ) {
- if( base->object == self->object ) {
- if( param ) {
- base->flag |= SELECT;
- self->object->flag = (short)base->flag;
- set_active_base( base );
- } else {
- base->flag &= ~SELECT;
- self->object->flag = (short)base->flag;
- }
- break;
- }
- base = base->next;
- }
- if (base) { /* was the object selected? */
- countall( );
- }
- return 0;
-}
-
-static PyObject *Object_GetEuler( BPy_Object * self, PyObject * args )
-{
- char *space = "localspace"; /* default to local */
- float eul[3];
-
- if( !PyArg_ParseTuple( args, "|s", &space ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string or nothing" );
-
- if( BLI_streq( space, "worldspace" ) ) { /* Worldspace matrix */
- float mat3[3][3];
- disable_where_script( 1 );
- where_is_object( self->object );
- Mat3CpyMat4(mat3, self->object->obmat);
- Mat3ToEul(mat3, eul);
- disable_where_script( 0 );
- } else if( BLI_streq( space, "localspace" ) ) { /* Localspace matrix */
- eul[0] = self->object->rot[0];
- eul[1] = self->object->rot[1];
- eul[2] = self->object->rot[2];
- } else {
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected either nothing, 'localspace' (default) or 'worldspace'" );
- }
-
- return ( PyObject * ) newEulerObject( eul, Py_NEW );
-}
-
-static PyObject *Object_getInverseMatrix( BPy_Object * self )
-{
- MatrixObject *inverse =
- ( MatrixObject * ) newMatrixObject( NULL, 4, 4, Py_NEW );
- Mat4Invert( (float ( * )[4])*inverse->matrix, self->object->obmat );
-
- return ( ( PyObject * ) inverse );
-}
-
-static PyObject *Object_getIpo( BPy_Object * self )
-{
- struct Ipo *ipo = self->object->ipo;
-
- if( ipo )
- return Ipo_CreatePyObject( ipo );
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getLocation( BPy_Object * self, PyObject * args )
-{
- char *space = "localspace"; /* default to local */
- PyObject *attr;
- if( !PyArg_ParseTuple( args, "|s", &space ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string or nothing" );
-
- if( BLI_streq( space, "worldspace" ) ) { /* Worldspace matrix */
- disable_where_script( 1 );
- where_is_object( self->object );
-
- attr = Py_BuildValue( "fff",
- self->object->obmat[3][0],
- self->object->obmat[3][1],
- self->object->obmat[3][2] );
-
- disable_where_script( 0 );
- } else if( BLI_streq( space, "localspace" ) ) { /* Localspace matrix */
- attr = Py_BuildValue( "fff",
- self->object->loc[0],
- self->object->loc[1],
- self->object->loc[2] );
- } else {
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected either nothing, 'localspace' (default) or 'worldspace'" );
- }
-
- return attr;
-}
-
-static PyObject *Object_getMaterials( BPy_Object * self, PyObject * args )
-{
- int all = 0;
-
- if( !PyArg_ParseTuple( args, "|i", &all ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int or nothing" );
-
- return EXPP_PyList_fromMaterialList( self->object->mat,
- self->object->totcol, all );
-}
-
-static PyObject *Object_getParent( BPy_Object * self )
-{
- return Object_CreatePyObject( self->object->parent );
-}
-
-static PyObject *Object_getParentBoneName( BPy_Object * self )
-{
- if( self->object->parent && self->object->parent->type==OB_ARMATURE && self->object->parsubstr[0] != '\0' )
- return PyString_FromString( self->object->parsubstr );
- Py_RETURN_NONE;
-}
-
-static int Object_setParentBoneName( BPy_Object * self, PyObject *value )
-{
- char *bonename;
-
- if (!PyString_Check(value))
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an int or nothing" );
-
- if (
- self->object->parent &&
- self->object->parent->type == OB_ARMATURE &&
- self->object->partype == PARBONE
- ) {/* its all good */} else
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "can only set the parent bone name for objects that already have a bone parent" );
-
- bonename = PyString_AsString(value);
-
- if (!get_named_bone(self->object->parent->data, bonename))
- return EXPP_ReturnIntError( PyExc_ValueError,
- "cannot parent to this bone: invalid bone name" );
-
- strcpy(self->object->parsubstr, bonename);
- DAG_scene_sort( G.scene );
- return 0;
-}
-
-static PyObject *Object_getSize( BPy_Object * self, PyObject * args )
-{
- char *space = "localspace"; /* default to local */
- PyObject *attr;
- if( !PyArg_ParseTuple( args, "|s", &space ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string or nothing" );
-
- if( BLI_streq( space, "worldspace" ) ) { /* Worldspace matrix */
- float rot[3];
- float mat[3][3], imat[3][3], tmat[3][3];
- disable_where_script( 1 );
- where_is_object( self->object );
-
- Mat3CpyMat4(mat, self->object->obmat);
-
- /* functionality copied from editobject.c apply_obmat */
- Mat3ToEul(mat, rot);
- EulToMat3(rot, tmat);
- Mat3Inv(imat, tmat);
- Mat3MulMat3(tmat, imat, mat);
-
- attr = Py_BuildValue( "fff",
- tmat[0][0],
- tmat[1][1],
- tmat[2][2] );
- disable_where_script( 0 );
- } else if( BLI_streq( space, "localspace" ) ) { /* Localspace matrix */
- attr = Py_BuildValue( "fff",
- self->object->size[0],
- self->object->size[1],
- self->object->size[2] );
- } else {
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected either nothing, 'localspace' (default) or 'worldspace'" );
- }
- return attr;
-}
-
-static PyObject *Object_getTimeOffset( BPy_Object * self )
-{
- return PyFloat_FromDouble ( (double) self->object->sf );
-}
-
-static PyObject *Object_getTracked( BPy_Object * self )
-{
- return Object_CreatePyObject( self->object->track );
-}
-
-static PyObject *Object_getType( BPy_Object * self )
-{
- char *str;
- int type = self->object->type;
-
- /* if object not yet linked to data, return the stored type */
- if( self->realtype != OB_EMPTY )
- type = self->realtype;
-
- switch ( type ) {
- case OB_ARMATURE:
- str = "Armature";
- break;
- case OB_CAMERA:
- str = "Camera";
- break;
- case OB_CURVE:
- str = "Curve";
- break;
- case OB_EMPTY:
- str = "Empty";
- break;
- case OB_FONT:
- str = "Text";
- break;
- case OB_LAMP:
- str = "Lamp";
- break;
- case OB_LATTICE:
- str = "Lattice";
- break;
- case OB_MBALL:
- str = "MBall";
- break;
- case OB_MESH:
- str = "Mesh";
- break;
- case OB_SURF:
- str = "Surf";
- break;
- case OB_WAVE:
- str = "Wave";
- break;
- default:
- str = "unknown";
- break;
- }
-
- return PyString_FromString( str );
-}
-
-static PyObject *Object_getBoundBox( BPy_Object * self )
-{
- int i;
- float *vec = NULL;
- PyObject *vector, *bbox;
-
- if( !self->object->data )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "This object isn't linked to any object data (mesh, curve, etc) yet" );
-
- if( !self->object->bb ) { /* if no ob bbox, we look in obdata */
- Mesh *me;
- Curve *curve;
- switch ( self->object->type ) {
- case OB_MESH:
- me = self->object->data;
- vec = (float*) mesh_get_bb(self->object)->vec;
- break;
- case OB_CURVE:
- case OB_FONT:
- case OB_SURF:
- curve = self->object->data;
- if( !curve->bb )
- tex_space_curve( curve );
- vec = ( float * ) curve->bb->vec;
- break;
- default:
- Py_RETURN_NONE;
- }
-
- { /* transform our obdata bbox by the obmat.
- the obmat is 4x4 homogeneous coords matrix.
- each bbox coord is xyz, so we make it homogenous
- by padding it with w=1.0 and doing the matrix mult.
- afterwards we divide by w to get back to xyz.
- */
- /* printmatrix4( "obmat", self->object->obmat); */
-
- float tmpvec[4]; /* tmp vector for homogenous coords math */
- int i;
- float *from;
-
- bbox = PyList_New( 8 );
- if( !bbox )
- return EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create pylist" );
- for( i = 0, from = vec; i < 8; i++, from += 3 ) {
- memcpy( tmpvec, from, 3 * sizeof( float ) );
- tmpvec[3] = 1.0f; /* set w coord */
- Mat4MulVec4fl( self->object->obmat, tmpvec );
- /* divide x,y,z by w */
- tmpvec[0] /= tmpvec[3];
- tmpvec[1] /= tmpvec[3];
- tmpvec[2] /= tmpvec[3];
-
-#if 0
- { /* debug print stuff */
- int i;
-
- printf( "\nobj bbox transformed\n" );
- for( i = 0; i < 4; ++i )
- printf( "%f ", tmpvec[i] );
-
- printf( "\n" );
- }
-#endif
-
- /* because our bounding box is calculated and
- does not have its own memory,
- we must create vectors that allocate space */
-
- vector = newVectorObject( NULL, 3, Py_NEW);
- memcpy( ( ( VectorObject * ) vector )->vec,
- tmpvec, 3 * sizeof( float ) );
- PyList_SET_ITEM( bbox, i, vector );
- }
- }
- } else { /* the ob bbox exists */
- vec = ( float * ) self->object->bb->vec;
-
- if( !vec )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't retrieve bounding box data" );
-
- bbox = PyList_New( 8 );
-
- if( !bbox )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create pylist" );
-
- /* create vectors referencing object bounding box coords */
- for( i = 0; i < 8; i++ ) {
- vector = newVectorObject( vec, 3, Py_WRAP );
- PyList_SET_ITEM( bbox, i, vector );
- vec += 3;
- }
- }
-
- return bbox;
-}
-
-static PyObject *Object_makeDisplayList( BPy_Object * self )
-{
- Object *ob = self->object;
-
- if( ob->type == OB_FONT ) {
- Curve *cu = ob->data;
- freedisplist( &cu->disp );
- text_to_curve( ob, 0 );
- }
-
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_link( BPy_Object * self, PyObject * args )
-{
- PyObject *py_data;
- ID *id;
- ID *oldid;
- int obj_id;
- void *data = NULL;
- int ok;
-
- if( !PyArg_ParseTuple( args, "O", &py_data ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an object as argument" );
-
- if( BPy_Armature_Check( py_data ) )
- data = ( void * ) PyArmature_AsArmature((BPy_Armature*)py_data);
- else if( BPy_Camera_Check( py_data ) )
- data = ( void * ) Camera_FromPyObject( py_data );
- else if( BPy_Lamp_Check( py_data ) )
- data = ( void * ) Lamp_FromPyObject( py_data );
- else if( BPy_Curve_Check( py_data ) )
- data = ( void * ) Curve_FromPyObject( py_data );
- else if( BPy_NMesh_Check( py_data ) ) {
- data = ( void * ) NMesh_FromPyObject( py_data, self->object );
- if( !data ) /* NULL means there is already an error */
- return NULL;
- } else if( BPy_Mesh_Check( py_data ) )
- data = ( void * ) Mesh_FromPyObject( py_data, self->object );
- else if( BPy_Lattice_Check( py_data ) )
- data = ( void * ) Lattice_FromPyObject( py_data );
- else if( BPy_Metaball_Check( py_data ) )
- data = ( void * ) Metaball_FromPyObject( py_data );
- else if( BPy_Text3d_Check( py_data ) )
- data = ( void * ) Text3d_FromPyObject( py_data );
-
- /* have we set data to something good? */
- if( !data )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "link argument type is not supported " );
-
- oldid = ( ID * ) self->object->data;
- id = ( ID * ) data;
- obj_id = MAKE_ID2( id->name[0], id->name[1] );
-
- /* if the object object has not been linked to real data before, we
- * can now let it assume its real type */
- if( self->realtype != OB_EMPTY ) {
- self->object->type = self->realtype;
- self->realtype = OB_EMPTY;
- }
-
- ok = 1;
- switch ( obj_id ) {
- case ID_AR:
- if( self->object->type != OB_ARMATURE ) {
- ok = 0;
- }
- break;
- case ID_CA:
- if( self->object->type != OB_CAMERA ) {
- ok = 0;
- }
- break;
- case ID_LA:
- if( self->object->type != OB_LAMP ) {
- ok = 0;
- }
- break;
- case ID_ME:
- if( self->object->type != OB_MESH ) {
- ok = 0;
- }
- break;
- case ID_CU:
- if( self->object->type != OB_CURVE && self->object->type != OB_FONT ) {
- ok = 0;
- }
- break;
- case ID_LT:
- if( self->object->type != OB_LATTICE ) {
- ok = 0;
- }
- break;
- case ID_MB:
- if( self->object->type != OB_MBALL ) {
- ok = 0;
- }
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Linking this object type is not supported" );
- }
-
- if( !ok )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "The 'link' object is incompatible with the base object" );
- self->object->data = data;
-
- /* creates the curve for the text object */
- if (self->object->type == OB_FONT)
- text_to_curve(self->object, 0);
-
- id_us_plus( id );
- if( oldid ) {
- if( oldid->us > 0 ) {
- oldid->us--;
- } else {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "old object reference count below 0" );
- }
- }
-
- /* make sure data and object materials are consistent */
- test_object_materials( id );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_makeParentVertex( BPy_Object * self, PyObject * args )
-{
- PyObject *list;
- PyObject *vlist;
- PyObject *py_child;
- PyObject *ret_val;
- Object *parent;
- int noninverse = 0;
- int fast = 0;
- int partype;
- int v1, v2=0, v3=0;
- int i;
-
- /* Check if the arguments passed to makeParent are valid. */
- if( !PyArg_ParseTuple( args, "OO|ii", &list, &vlist, &noninverse, &fast ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects, a tuple of integers and one or two integers as arguments" );
-
- if( !PySequence_Check( list ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" );
-
- if (!PyTuple_Check( vlist ))
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a tuple of integers" );
-
- switch( PyTuple_Size( vlist ) ) {
- case 1:
- if( !PyArg_ParseTuple( vlist, "i", &v1 ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a tuple of 1 or 3 integers" );
-
- if ( v1 < 0 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "indices must be strictly positive" );
-
- partype = PARVERT1;
- break;
- case 3:
- if( !PyArg_ParseTuple( vlist, "iii", &v1, &v2, &v3 ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a tuple of 1 or 3 integers" );
-
- if ( v1 < 0 || v2 < 0 || v3 < 0)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "indices must be strictly positive" );
- partype = PARVERT3;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a tuple of 1 or 3 integers" );
- }
-
- parent = ( Object * ) self->object;
-
- if (!ELEM3(parent->type, OB_MESH, OB_CURVE, OB_SURF))
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Parent Vertex only applies to curve, mesh or surface objects" );
-
- if (parent->id.us == 0)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "object must be linked to a scene before it can become a parent");
-
- /* Check if the PyObject passed in list is a Blender object. */
- for( i = 0; i < PySequence_Length( list ); i++ ) {
- py_child = PySequence_GetItem( list, i );
-
- ret_val = internal_makeParent(parent, py_child, partype, noninverse, fast, v1, v2, v3, NULL);
- Py_DECREF (py_child);
-
- if (ret_val)
- Py_DECREF(ret_val);
- else {
- if (!fast) /* need to sort when interrupting in the middle of the list */
- DAG_scene_sort( G.scene );
- return NULL; /* error has been set already */
- }
- }
-
- if (!fast) /* otherwise, only sort at the end */
- DAG_scene_sort( G.scene );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_makeParentDeform( BPy_Object * self, PyObject * args )
-{
- PyObject *list;
- PyObject *py_child;
- PyObject *ret_val;
- Object *parent;
- int noninverse = 0;
- int fast = 0;
- int i;
-
- /* Check if the arguments passed to makeParent are valid. */
- if( !PyArg_ParseTuple( args, "O|ii", &list, &noninverse, &fast ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects and one or two integers as arguments" );
-
- if( !PySequence_Check( list ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" );
-
- parent = ( Object * ) self->object;
-
- if (parent->type != OB_CURVE && parent->type != OB_ARMATURE)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Parent Deform only applies to curve or armature objects" );
-
- if (parent->id.us == 0)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "object must be linked to a scene before it can become a parent");
-
- /* Check if the PyObject passed in list is a Blender object. */
- for( i = 0; i < PySequence_Length( list ); i++ ) {
- py_child = PySequence_GetItem( list, i );
-
- ret_val = internal_makeParent(parent, py_child, PARSKEL, noninverse, fast, 0, 0, 0, NULL);
- Py_DECREF (py_child);
-
- if (ret_val)
- Py_DECREF(ret_val);
- else {
- if (!fast) /* need to sort when interupting in the middle of the list */
- DAG_scene_sort( G.scene );
- return NULL; /* error has been set already */
- }
- }
-
- if (!fast) /* otherwise, only sort at the end */
- DAG_scene_sort( G.scene );
-
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Object_makeParentBone( BPy_Object * self, PyObject * args )
-{
- char *bonename;
- PyObject *list;
- PyObject *py_child;
- PyObject *ret_val;
- Object *parent;
- int noninverse = 0;
- int fast = 0;
- int i;
-
- /* Check if the arguments passed to makeParent are valid. */
- if( !PyArg_ParseTuple( args, "Os|ii", &list, &bonename, &noninverse, &fast ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects, bonename and optionally two integers as arguments" );
-
- parent = ( Object * ) self->object;
-
- if (parent->type != OB_ARMATURE)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Parent Bone only applies to armature objects" );
-
- if (parent->id.us == 0)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "object must be linked to a scene before it can become a parent");
-
- if (!parent->data)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "object must be linked to armature data");
-
- if (!get_named_bone(parent->data, bonename))
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Parent Bone Name is not in the armature" );
-
- /* Check if the PyObject passed in list is a Blender object. */
- for( i = 0; i < PySequence_Length( list ); i++ ) {
- py_child = PySequence_GetItem( list, i );
-
- ret_val = internal_makeParent(parent, py_child, PARBONE, noninverse, fast, 0, 0, 0, bonename);
- Py_DECREF (py_child);
-
- if (ret_val)
- Py_DECREF(ret_val);
- else {
- if (!fast) /* need to sort when interupting in the middle of the list */
- DAG_scene_sort( G.scene );
- return NULL; /* error has been set already */
- }
- }
-
- if (!fast) /* otherwise, only sort at the end */
- DAG_scene_sort( G.scene );
-
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Object_makeParent( BPy_Object * self, PyObject * args )
-{
- PyObject *list;
- PyObject *py_child;
- PyObject *ret_val;
- Object *parent;
- int noninverse = 0;
- int fast = 0;
- int i;
-
- /* Check if the arguments passed to makeParent are valid. */
- if( !PyArg_ParseTuple( args, "O|ii", &list, &noninverse, &fast ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects and one or two integers as arguments" );
-
- if( !PySequence_Check( list ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" );
-
- parent = ( Object * ) self->object;
-
- if (parent->id.us == 0)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "object must be linked to a scene before it can become a parent");
-
- /* Check if the PyObject passed in list is a Blender object. */
- for( i = 0; i < PySequence_Length( list ); i++ ) {
- py_child = PySequence_GetItem( list, i );
-
- ret_val = internal_makeParent(parent, py_child, PAROBJECT, noninverse, fast, 0, 0, 0, NULL);
- Py_DECREF (py_child);
-
- if (ret_val)
- Py_DECREF(ret_val);
- else {
- if (!fast) /* need to sort when interupting in the middle of the list */
- DAG_scene_sort( G.scene );
- return NULL; /* error has been set already */
- }
- }
-
- if (!fast) /* otherwise, only sort at the end */
- DAG_scene_sort( G.scene );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_join( BPy_Object * self, PyObject * args )
-{
- PyObject *list;
- PyObject *py_child;
- Object *parent;
- Object *child;
- Scene *temp_scene;
- Scene *orig_scene;
- Base *temp_base;
- short type;
- int i, ok=0, ret_value=0, list_length=0;
-
- /* joining in background causes segfaults */
- if( G.background == 1 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot join objects in background mode" );
-
- /* Check if the arguments passed to makeParent are valid. */
- if( !PyArg_ParseTuple( args, "O", &list ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" );
-
- if( !PySequence_Check( list ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" );
-
- list_length = PySequence_Length( list ); /* if there are no objects to join then exit silently */
-
- if( !list_length ) {
- Py_RETURN_NONE;
- }
-
- parent = ( Object * ) self->object;
- type = parent->type;
-
- /* Only these object types are sypported */
- if( type!=OB_MESH && type!=OB_CURVE && type!=OB_SURF && type!=OB_ARMATURE )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Base object is not a type Blender can join" );
-
- if( !object_in_scene( parent, G.scene ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object must be in the current scene" );
-
- /* exit editmode so join can be done */
- if( G.obedit )
- exit_editmode( EM_FREEDATA );
-
- temp_scene = add_scene( "Scene" ); /* make the new scene */
- temp_scene->lay= 1; /* first layer on */
-
- /* TODO: use EXPP_check_sequence_consistency here */
-
- /* Check if the PyObject passed in list is a Blender object. */
- for( i = 0; i < list_length; i++ ) {
- py_child = PySequence_GetItem( list, i );
- if( !BPy_Object_Check( py_child ) ) {
- /* Cleanup */
- free_libblock( &G.main->scene, temp_scene );
- Py_DECREF( py_child );
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects, one or more of the list items is not a Blender Object." );
- } else {
- /* List item is an object, is it the same type? */
- child = ( Object * ) Object_FromPyObject( py_child );
- Py_DECREF( py_child );
- if( parent->type == child->type ) {
- if( !object_in_scene( child, G.scene ) ) {
- free_libblock( &G.main->scene, temp_scene );
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object must be in the current scene" );
- }
-
- ok =1;
- /* Add a new base, then link the base to the temp_scene */
- temp_base = MEM_callocN( sizeof( Base ), "pynewbase" );
- /* we know these types are the same, link to the temp scene
- * for joining */
- temp_base->object = child; /* link object to the new base */
- temp_base->flag |= SELECT;
- temp_base->lay = 1; /*1 layer on */
-
- BLI_addhead( &temp_scene->base, temp_base ); /* finally, link new base to scene */
- child->id.us += 1; /*Would usually increase user count but in this case it's ok not to */
-
- /*DAG_object_flush_update(temp_scene, temp_base->object, OB_RECALC_DATA);*/
- }
- }
- }
-
- orig_scene = G.scene; /* backup our scene */
-
- /* Add the main object into the temp_scene */
- temp_base = MEM_callocN( sizeof( Base ), "pynewbase" );
- temp_base->object = parent; /* link object to the new base */
- temp_base->flag |= SELECT;
- temp_base->lay = 1; /*1 layer on */
- BLI_addhead( &temp_scene->base, temp_base ); /* finally, link new base to scene */
- parent->id.us += 1;
-
- /* all objects in the scene, set it active and the active object */
- set_scene( temp_scene );
- set_active_base( temp_base );
-
- /* Do the joining now we know everythings OK. */
- if(type == OB_MESH)
- ret_value = join_mesh();
- else if(type == OB_CURVE)
- ret_value = join_curve(OB_CURVE);
- else if(type == OB_SURF)
- ret_value = join_curve(OB_SURF);
- else if(type == OB_ARMATURE)
- ret_value = join_armature();
-
- /* May use this for correcting object user counts later on */
- /*
- if (!ret_value) {
- temp_base = temp_scene->base.first;
- while( base ) {
- object = base->object;
- object->id.us +=1
- base = base->next;
- }
- }*/
-
- /* remove old scene */
- set_scene( orig_scene );
- free_libblock( &G.main->scene, temp_scene );
-
- /* no objects were of the correct type, return None */
- if (!ok) {
- Py_RETURN_NONE;
- }
-
- /* If the join failed then raise an error */
- if (!ret_value)
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
-"Blender failed to join the objects, this is not a script error.\n\
-Please add exception handling to your script with a RuntimeError exception\n\
-letting the user know that their data could not be joined." ) );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *internal_makeParent(Object *parent, PyObject *py_child,
- int partype, /* parenting type */
- int noninverse, int fast, /* parenting arguments */
- int v1, int v2, int v3, /* for vertex parent */
- char *bonename) /* for bone parents - assume the name is already checked to be a valid bone name*/
-{
- Object *child = NULL;
-
- if( BPy_Object_Check( py_child ) )
- child = ( Object * ) Object_FromPyObject( py_child );
-
- if( child == NULL )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Object Type expected" );
-
- if( test_parent_loop( parent, child ) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "parenting loop detected - parenting failed" );
-
- if (partype == PARSKEL && child->type != OB_MESH)
- child->partype = PAROBJECT;
- else
- child->partype = (short)partype;
-
- if (partype == PARVERT3) {
- child->par1 = v1;
- child->par2 = v2;
- child->par3 = v3;
- }
- else if (partype == PARVERT1) {
- child->par1 = v1;
- } else if (partype == PARBONE) {
- strcpy( child->parsubstr, bonename );
- }
-
-
-
- child->parent = parent;
- /* py_obj_child = (BPy_Object *) py_child; */
- if( noninverse == 1 ) {
- Mat4One(child->parentinv);
- /* Parent inverse = unity */
- child->loc[0] = 0.0;
- child->loc[1] = 0.0;
- child->loc[2] = 0.0;
- } else {
- what_does_parent( child );
- Mat4Invert( child->parentinv, workob.obmat );
- clear_workob();
- }
-
- if( !fast )
- child->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_materialUsage( void )
-{
- return EXPP_ReturnPyObjError( PyExc_NotImplementedError,
- "materialUsage: not yet implemented" );
-}
-
-static PyObject *Object_setDeltaLocation( BPy_Object * self, PyObject * args )
-{
- float dloc1;
- float dloc2;
- float dloc3;
- int status;
-
- if( PyObject_Length( args ) == 3 )
- status = PyArg_ParseTuple( args, "fff", &dloc1, &dloc2,
- &dloc3 );
- else
- status = PyArg_ParseTuple( args, "(fff)", &dloc1, &dloc2,
- &dloc3 );
-
- if( !status )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected sequence argument of 3 floats" );
-
- self->object->dloc[0] = dloc1;
- self->object->dloc[1] = dloc2;
- self->object->dloc[2] = dloc3;
-
- /* since we have messed with object, we need to flag for DAG recalc */
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-#define DTX_MASK ( OB_AXIS | OB_TEXSPACE | OB_DRAWNAME | \
- OB_DRAWIMAGE | OB_DRAWWIRE | OB_DRAWXRAY | OB_DRAWTRANSP )
-
-static PyObject *Object_getDrawMode( BPy_Object * self )
-{
- return PyInt_FromLong( (long)(self->object->dtx & DTX_MASK) );
-}
-
-static int Object_setDrawMode( BPy_Object * self, PyObject * args )
-{
- PyObject* integer = PyNumber_Int( args );
- int value;
-
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- value = ( int )PyInt_AS_LONG( integer );
- Py_DECREF( integer );
- if( value & ~DTX_MASK )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "undefined bit(s) set in bitfield" );
-
- self->object->dtx = value;
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-
-static PyObject *Object_getDrawType( BPy_Object * self )
-{
- return PyInt_FromLong( (long)self->object->dt );
-}
-
-static int Object_setDrawType( BPy_Object * self, PyObject * value )
-{
- /* since we mess with object, we need to flag for DAG recalc */
- self->object->recalc |= OB_RECALC_OB;
-
- return EXPP_setIValueRange( value, &self->object->dt,
- OB_BOUNDBOX, OB_TEXTURE, 'b' );
-}
-
-static int Object_setEuler( BPy_Object * self, PyObject * args )
-{
- float rot1, rot2, rot3;
- int status = 0; /* failure */
-
- if( PyTuple_Check( args ) && PyTuple_Size( args ) == 1 )
- args = PyTuple_GET_ITEM( args, 0 );
-
- if( EulerObject_Check( args ) ) {
- rot1 = ( ( EulerObject * ) args )->eul[0];
- rot2 = ( ( EulerObject * ) args )->eul[1];
- rot3 = ( ( EulerObject * ) args )->eul[2];
- status = 1;
- } else if( PySequence_Check( args ) && PySequence_Size( args ) == 3 ) {
- if( PyList_Check( args ) )
- args = PySequence_Tuple( args );
- else
- Py_INCREF( args );
- status = PyArg_ParseTuple( args, "fff", &rot1, &rot2, &rot3 );
- Py_DECREF( args );
- }
-
- if( !status )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected euler or sequence of 3 floats" );
-
- self->object->rot[0] = rot1;
- self->object->rot[1] = rot2;
- self->object->rot[2] = rot3;
-
- /* since we have messed with object, we need to flag for DAG recalc */
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-
-static int Object_setMatrix( BPy_Object * self, MatrixObject * mat )
-#if 0
-{
- int x, y;
-
- if( !MatrixObject_Check( mat ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected matrix object as argument" );
-
- if( mat->rowSize == 4 && mat->colSize == 4 ) {
- for( x = 0; x < 4; x++ ) {
- for( y = 0; y < 4; y++ ) {
- self->object->obmat[x][y] = mat->matrix[x][y];
- }
- }
- } else if( mat->rowSize == 3 && mat->colSize == 3 ) {
- for( x = 0; x < 3; x++ ) {
- for( y = 0; y < 3; y++ ) {
- self->object->obmat[x][y] = mat->matrix[x][y];
- }
- }
- /* if a 3x3 matrix, clear the fourth row/column */
- for( x = 0; x < 3; x++ )
- self->object->obmat[x][3] = self->object->obmat[3][x] = 0.0;
- self->object->obmat[3][3] = 1.0;
- } else
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected 3x3 or 4x4 matrix" );
-
- apply_obmat( self->object );
-
- /* since we have messed with object, we need to flag for DAG recalc */
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-#endif
-{
- int x, y;
- float matrix[4][4]; /* for the result */
- float invmat[4][4]; /* for the result */
-
- if( !MatrixObject_Check( mat ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected matrix object as argument" );
-
- if( mat->rowSize == 4 && mat->colSize == 4 ) {
- for( x = 0; x < 4; x++ ) {
- for( y = 0; y < 4; y++ ) {
- matrix[x][y] = mat->matrix[x][y];
- }
- }
- } else if( mat->rowSize == 3 && mat->colSize == 3 ) {
- for( x = 0; x < 3; x++ ) {
- for( y = 0; y < 3; y++ ) {
- matrix[x][y] = mat->matrix[x][y];
- }
- }
- /* if a 3x3 matrix, clear the fourth row/column */
- for( x = 0; x < 3; x++ )
- matrix[x][3] = matrix[3][x] = 0.0;
- matrix[3][3] = 1.0;
- } else
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected 3x3 or 4x4 matrix" );
-
- /* localspace matrix is truly relative to the parent, but parameters
- * stored in object are relative to parentinv matrix. Undo the parent
- * inverse part before updating obmat and calling apply_obmat() */
- if( self->object->parent ) {
- Mat4Invert( invmat, self->object->parentinv );
- Mat4MulMat4( self->object->obmat, matrix, invmat );
- } else
- Mat4CpyMat4( self->object->obmat, matrix );
-
- apply_obmat( self->object );
-
- /* since we have messed with object, we need to flag for DAG recalc */
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-
-
-/*
- * Object_insertIpoKey()
- * inserts Object IPO key for LOC, ROT, SIZE, LOCROT, LOCROTSIZE, or LAYER
- * Note it also inserts actions!
- */
-
-static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args )
-{
- Object *ob= self->object;
- int key = 0;
- char *actname= NULL;
-
- if( !PyArg_ParseTuple( args, "i", &key ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
-
- if(ob->ipoflag & OB_ACTION_OB)
- actname= "Object";
-
- if (key == IPOKEY_LOC || key == IPOKEY_LOCROT || key == IPOKEY_LOCROTSIZE){
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_X, 0);
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Y, 0);
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Z, 0);
- }
- if (key == IPOKEY_ROT || key == IPOKEY_LOCROT || key == IPOKEY_LOCROTSIZE){
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_X, 0);
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Y, 0);
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Z, 0);
- }
- if (key == IPOKEY_SIZE || key == IPOKEY_LOCROTSIZE ){
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_X, 0);
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Y, 0);
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Z, 0);
- }
- if (key == IPOKEY_LAYER ){
- insertkey((ID *)ob, ID_OB, actname, NULL,OB_LAY, 0);
- }
-
- if (key == IPOKEY_PI_STRENGTH ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FSTR, 0);
- } else if (key == IPOKEY_PI_FALLOFF ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FFALL, 0);
- } else if (key == IPOKEY_PI_SURFACEDAMP ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_SDAMP, 0);
- } else if (key == IPOKEY_PI_RANDOMDAMP ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_RDAMP, 0);
- } else if (key == IPOKEY_PI_PERM ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_PERM, 0);
- }
-
- allspace(REMAKEIPO, 0);
- EXPP_allqueue(REDRAWIPO, 0);
- EXPP_allqueue(REDRAWVIEW3D, 0);
- EXPP_allqueue(REDRAWACTION, 0);
- EXPP_allqueue(REDRAWNLA, 0);
-
- Py_RETURN_NONE;
-}
-
-/*
- * Object_insertPoseKey()
- * inserts a Action Pose key from a given pose (sourceaction, frame) to the
- * active action to a given framenum
- */
-
-static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
-{
- Object *ob= self->object;
- BPy_Action *sourceact;
- char *chanName;
- int actframe;
-
-
- /* for doing the time trick, similar to editaction bake_action_with_client() */
- int oldframe;
- int curframe;
-
- if( !PyArg_ParseTuple( args, "O!sii", &Action_Type, &sourceact,
- &chanName, &actframe, &curframe ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expects an action to copy poses from, a string for chan/bone name, an int argument for frame to extract from the action and finally another int for the frame where to put the new key in the active object.action" );
-
- extract_pose_from_action(ob->pose, sourceact->action, (float)actframe);
-
- oldframe = G.scene->r.cfra;
- G.scene->r.cfra = curframe;
-
- /* XXX: must check chanName actually exists, otherwise segfaults! */
- //achan = get_action_channel(sourceact->action, chanName);
-
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, 0);
-
- G.scene->r.cfra = oldframe;
-
- allspace(REMAKEIPO, 0);
- EXPP_allqueue(REDRAWIPO, 0);
- EXPP_allqueue(REDRAWVIEW3D, 0);
- EXPP_allqueue(REDRAWACTION, 0);
- EXPP_allqueue(REDRAWNLA, 0);
-
- /* restore, but now with the new action in place */
- /*extract_pose_from_action(ob->pose, ob->action, G.scene->r.cfra);
- where_is_pose(ob);*/
-
- EXPP_allqueue(REDRAWACTION, 1);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args )
-{
- Object *ob= self->object;
- char *chanName;
-
- /* for doing the time trick, similar to editaction bake_action_with_client() */
- int oldframe;
- int curframe;
-
- if( !PyArg_ParseTuple( args, "si", &chanName, &curframe ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected chan/bone name, and a time (int) argument" );
-
- oldframe = G.scene->r.cfra;
- G.scene->r.cfra = curframe;
-
- /* XXX: must check chanName actually exists, otherwise segfaults! */
-
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, 0);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, 0);
-
- G.scene->r.cfra = oldframe;
-
- allspace(REMAKEIPO, 0);
- EXPP_allqueue(REDRAWIPO, 0);
- EXPP_allqueue(REDRAWVIEW3D, 0);
- EXPP_allqueue(REDRAWACTION, 0);
- EXPP_allqueue(REDRAWNLA, 0);
-
- /* restore */
- extract_pose_from_action(ob->pose, ob->action, (float)G.scene->r.cfra);
- where_is_pose(ob);
-
- EXPP_allqueue(REDRAWACTION, 1);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_setConstraintInfluenceForBone( BPy_Object * self,
- PyObject * args )
-{
- char *boneName, *constName;
- float influence;
- IpoCurve *icu;
-
- if( !PyArg_ParseTuple( args, "ssf", &boneName, &constName, &influence ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expects bonename, constraintname, influenceval" );
-
- icu = verify_ipocurve((ID *)self->object, ID_CO, boneName, constName, NULL,
- CO_ENFORCE);
-
- if (!icu)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot get a curve from this IPO, may be using libdata" );
-
- insert_vert_icu(icu, (float)CFRA, influence, 0);
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_copyNLA( BPy_Object * self, PyObject * args ) {
- BPy_Object *bpy_fromob;
-
- if( !PyArg_ParseTuple( args, "O", &bpy_fromob ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "requires a Blender Object to copy NLA strips from." );
- copy_nlastrips(&self->object->nlastrips, &bpy_fromob->object->nlastrips);
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-/*Now that BPY has a Strip type, return the created strip.*/
-static PyObject *Object_convertActionToStrip( BPy_Object * self )
-{
- bActionStrip *strip = convert_action_to_strip( self->object );
- return ActionStrip_CreatePyObject( strip );
-}
-
-static PyObject *Object_setLocation( BPy_Object * self, PyObject * args )
-{
- float loc1;
- float loc2;
- float loc3;
- int status;
-
- if( PyObject_Length( args ) == 3 )
- status = PyArg_ParseTuple( args, "fff", &loc1, &loc2, &loc3 );
- else
- status = PyArg_ParseTuple( args, "(fff)", &loc1, &loc2,
- &loc3 );
-
- if( !status )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected list argument of 3 floats" );
-
- self->object->loc[0] = loc1;
- self->object->loc[1] = loc2;
- self->object->loc[2] = loc3;
-
- /* since we have messed with object, we need to flag for DAG recalc */
- self->object->recalc |= OB_RECALC_OB;
- DAG_object_flush_update(G.scene, self->object, OB_RECALC_DATA);
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args )
-{
- PyObject *list;
- int len;
- int i;
- Material **matlist = NULL;
-
- if (!self->object->data)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "object must be linked to object data (e.g. to a mesh) first" );
-
- if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &list ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list (of materials or None) as argument" );
-
- len = PyList_Size(list);
-
- /* Object_getMaterials can return '[]' (zero-length list), so that must
- * also be accepted by this method for
- * ob2.setMaterials(ob1.getMaterials()) to always work.
- * In other words, list can be '[]' and so len can be zero. */
- if (len > 0) {
- if( len > MAXMAT )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "list must have from 1 up to 16 materials" );
-
- matlist = EXPP_newMaterialList_fromPyList( list );
- if( !matlist )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "material list must be a list of valid materials!" );
- }
-
- if( self->object->mat )
- EXPP_releaseMaterialList( self->object->mat, self->object->totcol );
-
- /* Increase the user count on all materials */
- for( i = 0; i < len; i++ ) {
- if( matlist[i] )
- id_us_plus( ( ID * ) matlist[i] );
- }
- self->object->mat = matlist;
- self->object->totcol = (char)len;
- self->object->actcol = (char)len;
-
- switch ( self->object->type ) {
- case OB_CURVE: /* fall through */
- case OB_FONT: /* fall through */
- case OB_MESH: /* fall through */
- case OB_MBALL: /* fall through */
- case OB_SURF:
- EXPP_synchronizeMaterialLists( self->object );
- break;
- default:
- break;
- }
-
- /* since we have messed with object, we need to flag for DAG recalc */
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_setSize( BPy_Object * self, PyObject * args )
-{
- float sizex;
- float sizey;
- float sizez;
- int status;
-
- if( PyObject_Length( args ) == 3 )
- status = PyArg_ParseTuple( args, "fff", &sizex, &sizey,
- &sizez );
- else
- status = PyArg_ParseTuple( args, "(fff)", &sizex, &sizey,
- &sizez );
-
- if( !status )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected list argument of 3 floats" );
-
- self->object->size[0] = sizex;
- self->object->size[1] = sizey;
- self->object->size[2] = sizez;
-
- /* since we have messed with object, we need to flag for DAG recalc */
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_makeTrack( BPy_Object * self, PyObject * args )
-{
- BPy_Object *tracked = NULL;
- Object *ob = self->object;
- int fast = 0;
-
- if( !PyArg_ParseTuple( args, "O!|i", &Object_Type, &tracked, &fast ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an object and optionally also an int as arguments." );
-
- ob->track = tracked->object;
-
- if( !fast )
- DAG_scene_sort( G.scene );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_shareFrom( BPy_Object * self, PyObject * args )
-{
- BPy_Object *object;
- ID *id;
- ID *oldid;
-
- if( !PyArg_ParseTuple( args, "O!", &Object_Type, &object ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an object argument" );
-
- if( !object->object->data )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Object argument has no data linked yet or is an empty" );
-
- if( self->object->type != object->object->type &&
- self->realtype != object->object->type)
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "objects are not of same data type" );
-
- switch ( object->object->type ) {
- case OB_MESH:
- case OB_LAMP:
- case OB_CAMERA: /* we can probably add the other types, too */
- case OB_ARMATURE:
- case OB_CURVE:
- case OB_SURF:
- case OB_LATTICE:
-
- /* if this object had no data, we need to enable the realtype */
- if (self->object->type == OB_EMPTY) {
- self->object->type= self->realtype;
- self->realtype = OB_EMPTY;
- }
-
- oldid = ( ID * ) self->object->data;
- id = ( ID * ) object->object->data;
- self->object->data = object->object->data;
-
- if( self->object->type == OB_MESH && id ) {
- self->object->totcol = 0;
- EXPP_synchronizeMaterialLists( self->object );
- }
-
- id_us_plus( id );
- if( oldid ) {
- if( oldid->us > 0 ) {
- oldid->us--;
- } else {
- return EXPP_ReturnPyObjError ( PyExc_RuntimeError,
- "old object reference count below 0" );
- }
- }
-
- Py_RETURN_NONE;
- default:
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "object type not supported" );
- }
-}
-
-static PyObject *Object_getAllProperties( BPy_Object * self )
-{
- PyObject *prop_list, *pyval;
- bProperty *prop = NULL;
-
- prop_list = PyList_New( 0 );
-
- prop = self->object->prop.first;
- while( prop ) {
- pyval = Property_CreatePyObject( prop );
- PyList_Append( prop_list, pyval );
- Py_DECREF(pyval);
- prop = prop->next;
- }
- return prop_list;
-}
-
-static PyObject *Object_getProperty( BPy_Object * self, PyObject * args )
-{
- char *prop_name = NULL;
- bProperty *prop = NULL;
-
- if( !PyArg_ParseTuple( args, "s", &prop_name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string" );
-
- prop = get_property( self->object, prop_name );
- if( prop )
- return Property_CreatePyObject( prop );
-
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't find the property" );
-}
-
-static PyObject *Object_addProperty( BPy_Object * self, PyObject * args )
-{
- bProperty *prop = NULL;
- char *prop_name = NULL;
- PyObject *prop_data = Py_None;
- char *prop_type = NULL;
- short type = -1;
- BPy_Property *py_prop = NULL;
- int argslen = PyObject_Length( args );
-
- if( argslen == 3 || argslen == 2 ) {
- if( !PyArg_ParseTuple( args, "sO|s", &prop_name, &prop_data,
- &prop_type ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expecting string, data, and optional string" );
- }
- } else if( argslen == 1 ) {
- if( !PyArg_ParseTuple( args, "O!", &property_Type, &py_prop ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expecting a Property" );
-
- if( py_prop->property != NULL )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Property is already added to an object" );
- } else {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 1,2 or 3 arguments" );
- }
-
- /*parse property type*/
- if( !py_prop ) {
- if( prop_type ) {
- if( BLI_streq( prop_type, "BOOL" ) )
- type = PROP_BOOL;
- else if( BLI_streq( prop_type, "INT" ) )
- type = PROP_INT;
- else if( BLI_streq( prop_type, "FLOAT" ) )
- type = PROP_FLOAT;
- else if( BLI_streq( prop_type, "TIME" ) )
- type = PROP_TIME;
- else if( BLI_streq( prop_type, "STRING" ) )
- type = PROP_STRING;
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "BOOL, INT, FLOAT, TIME or STRING expected" );
- } else {
- /*use the default*/
- if( PyInt_Check( prop_data ) )
- type = PROP_INT;
- else if( PyFloat_Check( prop_data ) )
- type = PROP_FLOAT;
- else if( PyString_Check( prop_data ) )
- type = PROP_STRING;
- }
- } else {
- type = py_prop->type;
- }
-
- /*initialize a new bProperty of the specified type*/
- prop = new_property( type );
-
- /*parse data*/
- if( !py_prop ) {
- BLI_strncpy( prop->name, prop_name, 32 );
- if( PyInt_Check( prop_data ) ) {
- *( ( int * ) &prop->data ) =
- ( int ) PyInt_AsLong( prop_data );
- } else if( PyFloat_Check( prop_data ) ) {
- *( ( float * ) &prop->data ) =
- ( float ) PyFloat_AsDouble( prop_data );
- } else if( PyString_Check( prop_data ) ) {
- BLI_strncpy( prop->poin,
- PyString_AsString( prop_data ),
- MAX_PROPSTRING );
- }
- } else {
- py_prop->property = prop;
-
- /* this should never be able to happen is we just assigned a valid
- * proper to py_prop->property */
-
- if( !updateProperyData( py_prop ) ) {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Could not update property data" );
- }
- }
-
- /*add to property listbase for the object*/
- BLI_addtail( &self->object->prop, prop );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_removeProperty( BPy_Object * self, PyObject * args )
-{
- char *prop_name = NULL;
- BPy_Property *py_prop = NULL;
- bProperty *prop = NULL;
-
- /* we accept either a property stringname or actual object */
- if( PyTuple_Size( args ) == 1 ) {
- PyObject *prop = PyTuple_GET_ITEM( args, 0 );
- if( BPy_Property_Check( prop ) )
- py_prop = (BPy_Property *)prop;
- else
- prop_name = PyString_AsString( prop );
- }
- if( !py_prop && !prop_name )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a Property or a string" );
-
- /*remove the link, free the data, and update the py struct*/
- if( py_prop ) {
- BLI_remlink( &self->object->prop, py_prop->property );
- if( updatePyProperty( py_prop ) ) {
- free_property( py_prop->property );
- py_prop->property = NULL;
- }
- } else {
- prop = get_property( self->object, prop_name );
- if( prop ) {
- BLI_remlink( &self->object->prop, prop );
- free_property( prop );
- }
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_removeAllProperties( BPy_Object * self )
-{
- free_properties( &self->object->prop );
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_copyAllPropertiesTo( BPy_Object * self,
- PyObject * args )
-{
- PyObject *dest;
- bProperty *prop = NULL;
- bProperty *propn = NULL;
-
- if( !PyArg_ParseTuple( args, "O!", &Object_Type, &dest ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an Object" );
-
- /*make a copy of all its properties*/
- prop = self->object->prop.first;
- while( prop ) {
- propn = copy_property( prop );
- BLI_addtail( &( ( BPy_Object * ) dest )->object->prop, propn );
- prop = prop->next;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_addScriptLink( BPy_Object * self, PyObject * args )
-{
- Object *obj = self->object;
- ScriptLink *slink = &obj->scriptlink;
- return EXPP_addScriptLink( slink, args, 0 );
-}
-
-static PyObject *Object_clearScriptLinks( BPy_Object * self, PyObject * args )
-{
- Object *obj = self->object;
- ScriptLink *slink = &obj->scriptlink;
- return EXPP_clearScriptLinks( slink, args );
-}
-
-static PyObject *Object_getScriptLinks( BPy_Object * self, PyObject * value )
-{
- Object *obj = self->object;
- ScriptLink *slink = &obj->scriptlink;
- return EXPP_getScriptLinks( slink, value, 0 );
-}
-
-static PyObject *Object_getNLAflagBits ( BPy_Object * self )
-{
- if (self->object->nlaflag & OB_NLA_OVERRIDE)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static int Object_setNLAflagBits ( BPy_Object * self, PyObject * value )
-{
- int param;
-
- param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if (param)
- self->object->nlaflag |= OB_NLA_OVERRIDE;
- else
- self->object->nlaflag &= ~OB_NLA_OVERRIDE;
-
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-
-static PyObject *Object_getDupliObjects( BPy_Object * self )
-{
- Object *ob= self->object;
-
- if(ob->transflag & OB_DUPLI) {
- /* before make duplis, update particle for current frame */
- if(ob->transflag & OB_DUPLIVERTS) {
- PartEff *paf= give_parteff(ob);
- if(paf) {
- if(paf->flag & PAF_ANIMATED) build_particle_system(ob);
- }
- }
- if(ob->type!=OB_MBALL) {
- PyObject *list;
- DupliObject *dupob;
- int index;
- ListBase *duplilist = object_duplilist(G.scene, ob);
-
- list = PyList_New( BLI_countlist(duplilist) );
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyList_New() failed" );
-
- for(dupob= duplilist->first, index=0; dupob; dupob= dupob->next, index++) {
- PyObject *pair;
- pair = PyTuple_New( 2 );
-
- PyTuple_SET_ITEM( pair, 0, Object_CreatePyObject(dupob->ob) );
- PyTuple_SET_ITEM( pair, 1, newMatrixObject((float*)dupob->mat,4,4,Py_NEW) );
- PyList_SET_ITEM( list, index, pair);
- }
- free_object_duplilist(duplilist);
- return list;
- }
- }
- return PyList_New( 0 );
-}
-
-static PyObject *Object_getDupliGroup( BPy_Object * self )
-{
- Object *ob= self->object;
-
- if( ob->dup_group )
- return Group_CreatePyObject( ob->dup_group );
-
- Py_RETURN_NONE;
-}
-
-static int Object_setDupliGroup( BPy_Object * self, PyObject * value )
-{
- return GenericLib_assignData(value, (void **) &self->object->dup_group, 0, 1, ID_GR, 0);
-}
-
-static PyObject *Object_getEffects( BPy_Object * self )
-{
- PyObject *effect_list, *pyval;
- Effect *eff;
-
- effect_list = PyList_New( 0 );
- if( !effect_list )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "PyList_New() failed" );
-
- eff = self->object->effect.first;
-
- while( eff ) {
- pyval = EffectCreatePyObject( eff, self->object );
- PyList_Append( effect_list, pyval );
- Py_DECREF(pyval);
- eff = eff->next;
- }
- return effect_list;
-}
-
-static PyObject *Object_getActionStrips( BPy_Object * self )
-{
- return ActionStrips_CreatePyObject( self->object );
-}
-
-static PyObject *Object_getConstraints( BPy_Object * self )
-{
- return ObConstraintSeq_CreatePyObject( self->object );
-}
-
-static PyObject *Object_getModifiers( BPy_Object * self )
-{
- return ModSeq_CreatePyObject( self->object, NULL );
-}
-
-static int Object_setModifiers( BPy_Object * self, PyObject * value )
-{
- BPy_ModSeq *pymodseq;
- ModifierData *md;
-
- if (!BPy_ModSeq_Check(value))
- return EXPP_ReturnIntError( PyExc_TypeError,
- "can only assign another objects modifiers" );
-
- pymodseq = ( BPy_ModSeq * ) value;
-
- if (self->object->type != pymodseq->object->type)
- return EXPP_ReturnIntError( PyExc_TypeError,
- "can only assign modifiers between objects of the same type" );
-
- if (self->object == pymodseq->object)
- return 0;
-
- object_free_modifiers(self->object);
- for (md=pymodseq->object->modifiers.first; md; md=md->next) {
- if (md->type!=eModifierType_Hook) {
- ModifierData *nmd = modifier_new(md->type);
- modifier_copyData(md, nmd);
- BLI_addtail(&self->object->modifiers, nmd);
- }
- }
-
- DAG_object_flush_update(G.scene, self->object, OB_RECALC_DATA);
- return 0;
-}
-
-static PyObject *Object_insertShapeKey(BPy_Object * self)
-{
- insert_shapekey(self->object);
- Py_RETURN_NONE;
-}
-
-/* __copy__() */
-static PyObject *Object_copy(BPy_Object * self)
-{
- /* copy_object never returns NULL */
- struct Object *object= copy_object( self->object );
- object->id.us= 0; /*is 1 by default, not sure why */
-
- /* Create a Python object from it. */
- return Object_CreatePyObject( object );
-}
-
-/*****************************************************************************/
-/* Function: Object_CreatePyObject */
-/* Description: This function will create a new BlenObject from an existing */
-/* Object structure. */
-/*****************************************************************************/
-PyObject *Object_CreatePyObject( struct Object * obj )
-{
- BPy_Object *blen_object;
-
- if( !obj ) Py_RETURN_NONE;
-
- blen_object =
- ( BPy_Object * ) PyObject_NEW( BPy_Object, &Object_Type );
-
- if( blen_object == NULL ) {
- return ( NULL );
- }
- blen_object->object = obj;
- blen_object->realtype = OB_EMPTY;
- obj->id.us++;
- return ( ( PyObject * ) blen_object );
-}
-
-/*****************************************************************************/
-/* Function: Object_FromPyObject */
-/* Description: This function returns the Blender object from the given */
-/* PyObject. */
-/*****************************************************************************/
-struct Object *Object_FromPyObject( PyObject * py_obj )
-{
- BPy_Object *blen_obj;
-
- blen_obj = ( BPy_Object * ) py_obj;
- return ( blen_obj->object );
-}
-
-/*****************************************************************************/
-/* Function: Object_dealloc */
-/* Description: This is a callback function for the BlenObject type. It is */
-/* the destructor function. */
-/*****************************************************************************/
-static void Object_dealloc( BPy_Object * self )
-{
- if( self->realtype != OB_EMPTY )
- free_libblock_us( &G.main->object, self->object );
- else
- self->object->id.us--;
-
-#if 0 /* this will adjust the ID and if zero delete the object */
- free_libblock_us( &G.main->object, self->object );
-#endif
- PyObject_DEL( self );
-}
-
-/*****************************************************************************/
-/* Function: Object_compare */
-/* Description: This is a callback function for the BPy_Object type. It */
-/* compares two Object_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 Object_compare( BPy_Object * a, BPy_Object * b )
-{
- return ( a->object == b->object ) ? 0 : -1;
-}
-
-/*****************************************************************************/
-/* Function: Object_repr */
-/* Description: This is a callback function for the BPy_Object type. It */
-/* builds a meaninful string to represent object objects. */
-/*****************************************************************************/
-static PyObject *Object_repr( BPy_Object * self )
-{
- return PyString_FromFormat( "[Object \"%s\"]",
- self->object->id.name + 2 );
-}
-
-/* Particle Deflection functions */
-
-static PyObject *Object_getPIDeflection( BPy_Object * self )
-{
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- return PyBool_FromLong( ( long ) self->object->pd->deflect );
-}
-
-static int Object_setPIDeflection( BPy_Object * self, PyObject * value )
-{
- int param;
-
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected true/false argument" );
-
- self->object->pd->deflect = (short)param;
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-
-static PyObject *Object_getPIType( BPy_Object * self )
-{
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- return PyInt_FromLong( ( long )self->object->pd->forcefield );
-}
-
-static int Object_setPIType( BPy_Object * self, PyObject * value )
-{
- int status;
- int oldforcefield;
-
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- oldforcefield = self->object->pd->forcefield;
- status = EXPP_setIValueRange( value, &self->object->pd->forcefield,
- PFIELD_FORCE, PFIELD_GUIDE, 'h' );
-
- /*
- * if value was set successfully but is PFIELD_MAGNET, restore the old
- * value and throw exception
- */
- if( !status ) {
- if ( self->object->pd->forcefield == PFIELD_MAGNET ) {
- self->object->pd->forcefield = oldforcefield;
- return EXPP_ReturnIntError( PyExc_ValueError,
- "PFIELD_MAGNET not supported" );
- }
- self->object->recalc |= OB_RECALC_OB;
- }
- return status;
-}
-
-static PyObject *Object_getPIUseMaxDist( BPy_Object * self )
-{
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- return PyBool_FromLong( ( long )self->object->pd->flag );
-}
-
-static int Object_setPIUseMaxDist( BPy_Object * self, PyObject * value )
-{
- int param;
-
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected true/false argument" );
-
- self->object->pd->flag = (short)param;
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-
-/* RIGIDBODY FUNCTIONS */
-
-static PyObject *Object_getRBMass( BPy_Object * self )
-{
- return PyFloat_FromDouble( (double)self->object->mass );
-}
-
-static int Object_setRBMass( BPy_Object * self, PyObject * args )
-{
- float value;
- PyObject* flt = PyNumber_Float( args );
-
- if( !flt )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
- value = (float)PyFloat_AS_DOUBLE( flt );
- Py_DECREF( flt );
-
- if( value < 0.0f )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "acceptable values are non-negative, 0.0 or more" );
-
- self->object->mass = value;
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-
-/* this is too low level, possible to add helper methods */
-
-#define GAMEFLAG_MASK ( OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
- OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | \
- OB_BOUNDS | OB_COLLISION_RESPONSE | OB_SECTOR | OB_PROP | \
- OB_MAINACTOR )
-
-static PyObject *Object_getRBFlags( BPy_Object * self )
-{
- return PyInt_FromLong( (long)( self->object->gameflag & GAMEFLAG_MASK ) );
-}
-
-static int Object_setRBFlags( BPy_Object * self, PyObject * args )
-{
- PyObject* integer = PyNumber_Int( args );
- int value;
-
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- value = ( int )PyInt_AS_LONG( integer );
- Py_DECREF( integer );
- if( value & ~GAMEFLAG_MASK )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "undefined bit(s) set in bitfield" );
-
- self->object->gameflag = value;
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-
-static PyObject *Object_getRBShapeBoundType( BPy_Object * self )
-{
- return PyInt_FromLong( (long)self->object->boundtype );
-}
-
-static int Object_setRBShapeBoundType( BPy_Object * self, PyObject * args )
-{
- self->object->recalc |= OB_RECALC_OB;
- return EXPP_setIValueRange( args, &self->object->boundtype,
- 0, OB_BOUND_DYN_MESH, 'h' );
-}
-
-/* SOFTBODY FUNCTIONS */
-
-PyObject *Object_isSB(BPy_Object *self)
-{
- if( self->object->soft )
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static PyObject *Object_getSBUseGoal( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( self->object->softflag & OB_SB_GOAL )
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static int Object_setSBUseGoal( BPy_Object * self, PyObject * value )
-{
- int setting = PyObject_IsTrue( value );
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( setting == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected true/false argument" );
-
- if( setting )
- self->object->softflag |= OB_SB_GOAL;
- else
- self->object->softflag &= ~OB_SB_GOAL;
-
- self->object->recalc |= OB_RECALC_OB;
- return 0;
-}
-
-static PyObject *Object_getSBUseEdges( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( self->object->softflag & OB_SB_EDGES )
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static int Object_setSBUseEdges( BPy_Object * self, PyObject * value )
-{
- int setting = PyObject_IsTrue( value );
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( setting == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected true/false argument" );
-
- if( setting )
- self->object->softflag |= OB_SB_EDGES;
- else
- self->object->softflag &= ~OB_SB_EDGES;
-
- self->object->recalc |= OB_RECALC_OB;
- return 0;
-}
-
-static PyObject *Object_getSBStiffQuads( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( self->object->softflag & OB_SB_QUADS )
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static int Object_setSBStiffQuads( BPy_Object * self, PyObject * value )
-{
- int setting = PyObject_IsTrue( value );
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( setting == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected true/false argument" );
-
- if( setting )
- self->object->softflag |= OB_SB_QUADS;
- else
- self->object->softflag &= ~OB_SB_QUADS;
-
- self->object->recalc |= OB_RECALC_OB;
- return 0;
-}
-
-static int setupSB( Object* ob )
-{
- ob->soft= sbNew();
- ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
-
- if( !ob->soft )
- return 0;
- /* all this is initialized in sbNew() */
-#if 0
- ob->soft->mediafrict = 0.5f;
- ob->soft->nodemass = 1.0f;
- ob->soft->grav = 0.0f;
- ob->soft->rklimit = 0.1f;
-
- ob->soft->goalspring = 0.5f;
- ob->soft->goalfrict = 0.0f;
- ob->soft->mingoal = 0.0f;
- ob->soft->maxgoal = 1.0f;
- ob->soft->defgoal = 0.7f;
-
- ob->soft->inspring = 0.5f;
- ob->soft->infrict = 0.5f;
-#endif
- return 1;
-}
-
-static int setupPI( Object* ob )
-{
- if( ob->pd==NULL ) {
- ob->pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
- /* and if needed, init here */
- }
-
- if( !ob->pd )
- return 0;
-
- ob->pd->deflect =0;
- ob->pd->forcefield =0;
- ob->pd->flag =0;
- ob->pd->pdef_damp =0;
- ob->pd->pdef_rdamp =0;
- ob->pd->pdef_perm =0;
- ob->pd->f_strength =0;
- ob->pd->f_power =0;
- ob->pd->maxdist =0;
- return 1;
-}
-
-/*
- * scan list of Objects looking for matching obdata.
- * if found, set OB_RECALC_DATA flag.
- * call this from a bpy type update() method.
- */
-
-void Object_updateDag( void *data )
-{
- Object *ob;
-
- if( !data )
- return;
-
- for( ob = G.main->object.first; ob; ob= ob->id.next ){
- if( ob->data == data ) {
- ob->recalc |= OB_RECALC_DATA;
- }
- }
-}
-
-/*
- * utilities routines for handling generic getters and setters
- */
-
-/*
- * get integer attributes
- */
-
-static PyObject *getIntAttr( BPy_Object *self, void *type )
-{
- int param;
- struct Object *object = self->object;
-
- switch( (int)type ) {
- case EXPP_OBJ_ATTR_LAYERMASK:
- param = object->lay;
- break;
- case EXPP_OBJ_ATTR_COLBITS:
- param = object->colbits;
- if( param < 0 ) param += 65536;
- break;
- case EXPP_OBJ_ATTR_DRAWMODE:
- param = object->dtx;
- break;
- case EXPP_OBJ_ATTR_DRAWTYPE:
- param = object->dt;
- break;
- case EXPP_OBJ_ATTR_PARENT_TYPE:
- param = object->partype;
- break;
- case EXPP_OBJ_ATTR_DUPON:
- param = object->dupon;
- break;
- case EXPP_OBJ_ATTR_DUPOFF:
- param = object->dupoff;
- break;
- case EXPP_OBJ_ATTR_DUPSTA:
- param = object->dupsta;
- break;
- case EXPP_OBJ_ATTR_DUPEND:
- param = object->dupend;
- break;
- case EXPP_OBJ_ATTR_PASSINDEX:
- param = object->index;
- break;
- case EXPP_OBJ_ATTR_ACT_MATERIAL:
- param = object->actcol;
- break;
- case EXPP_OBJ_ATTR_ACT_SHAPE:
- param = object->shapenr;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type in getIntAttr" );
- }
-
- return PyInt_FromLong( param );
-}
-
-/*
- * set integer attributes which require clamping
- */
-
-static int setIntAttrClamp( BPy_Object *self, PyObject *value, void *type )
-{
- void *param;
- struct Object *object = self->object;
- int min, max, size;
-
- switch( (int)type ) {
- case EXPP_OBJ_ATTR_DUPON:
- min = 1;
- max = 1500;
- size = 'H'; /* in case max is later made > 32767 */
- param = (void *)&object->dupon;
- break;
- case EXPP_OBJ_ATTR_DUPOFF:
- min = 0;
- max = 1500;
- size = 'H'; /* in case max is later made > 32767 */
- param = (void *)&object->dupoff;
- break;
- case EXPP_OBJ_ATTR_DUPSTA:
- min = 1;
- max = 32767;
- size = 'H'; /* in case max is later made > 32767 */
- param = (void *)&object->dupsta;
- break;
- case EXPP_OBJ_ATTR_DUPEND:
- min = 1;
- max = 32767;
- size = 'H'; /* in case max is later made > 32767 */
- param = (void *)&object->dupend;
- break;
- case EXPP_OBJ_ATTR_PASSINDEX:
- min = 0;
- max = 1000;
- size = 'H'; /* in case max is later made > 32767 */
- param = (void *)&object->index;
- break;
- case EXPP_OBJ_ATTR_ACT_MATERIAL:
- min = 1;
- max = object->totcol;
- size = 'b'; /* in case max is later made > 128 */
- param = (void *)&object->actcol;
- break;
- case EXPP_OBJ_ATTR_ACT_SHAPE:
- {
- Key *key= ob_get_key(object);
- KeyBlock *kb;
- min = 1;
- max = 0;
- if (key) {
- max= 1;
- for (kb = key->block.first; kb; kb=kb->next, max++);
- }
- size = 'h'; /* in case max is later made > 128 */
- param = (void *)&object->shapenr;
- break;
- }
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setIntAttrClamp");
- }
-
- self->object->recalc |= OB_RECALC_OB;
- return EXPP_setIValueClamped( value, param, min, max, size );
-}
-
-/*
- * set integer attributes which require range checking
- */
-
-static int setIntAttrRange( BPy_Object *self, PyObject *value, void *type )
-{
- void *param;
- struct Object *object = self->object;
- int min, max, size;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- /* these parameters require clamping */
-
- switch( (int)type ) {
- case EXPP_OBJ_ATTR_COLBITS:
- min = 0;
- max = 0xffff;
- size = 'H';
- param = (void *)&object->colbits;
- break;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setIntAttrRange" );
- }
-
- self->object->recalc |= OB_RECALC_OB;
- return EXPP_setIValueRange( value, param, min, max, size );
-}
-
-/*
- * get floating point attributes
- */
-
-static PyObject *getFloatAttr( BPy_Object *self, void *type )
-{
- float param;
- struct Object *object = self->object;
-
- if( (int)type >= EXPP_OBJ_ATTR_PI_SURFACEDAMP &&
- (int)type <= EXPP_OBJ_ATTR_PI_SBOFACETHICK ) {
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
- }
- else if( (int)type >= EXPP_OBJ_ATTR_SB_NODEMASS &&
- (int)type <= EXPP_OBJ_ATTR_SB_INFRICT ) {
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
- }
-
- switch( (int)type ) {
- case EXPP_OBJ_ATTR_LOC_X:
- param = object->loc[0];
- break;
- case EXPP_OBJ_ATTR_LOC_Y:
- param = object->loc[1];
- break;
- case EXPP_OBJ_ATTR_LOC_Z:
- param = object->loc[2];
- break;
- case EXPP_OBJ_ATTR_DLOC_X:
- param = object->dloc[0];
- break;
- case EXPP_OBJ_ATTR_DLOC_Y:
- param = object->dloc[1];
- break;
- case EXPP_OBJ_ATTR_DLOC_Z:
- param = object->dloc[2];
- break;
- case EXPP_OBJ_ATTR_ROT_X:
- param = object->rot[0];
- break;
- case EXPP_OBJ_ATTR_ROT_Y:
- param = object->rot[1];
- break;
- case EXPP_OBJ_ATTR_ROT_Z:
- param = object->rot[2];
- break;
- case EXPP_OBJ_ATTR_DROT_X:
- param = object->drot[0];
- break;
- case EXPP_OBJ_ATTR_DROT_Y:
- param = object->drot[1];
- break;
- case EXPP_OBJ_ATTR_DROT_Z:
- param = object->drot[2];
- break;
- case EXPP_OBJ_ATTR_SIZE_X:
- param = object->size[0];
- break;
- case EXPP_OBJ_ATTR_SIZE_Y:
- param = object->size[1];
- break;
- case EXPP_OBJ_ATTR_SIZE_Z:
- param = object->size[2];
- break;
- case EXPP_OBJ_ATTR_DSIZE_X:
- param = object->dsize[0];
- break;
- case EXPP_OBJ_ATTR_DSIZE_Y:
- param = object->dsize[1];
- break;
- case EXPP_OBJ_ATTR_DSIZE_Z:
- param = object->dsize[2];
- break;
- case EXPP_OBJ_ATTR_TIMEOFFSET:
- param = object->sf;
- break;
- case EXPP_OBJ_ATTR_DRAWSIZE:
- param = object->empty_drawsize;
- break;
- case EXPP_OBJ_ATTR_PI_SURFACEDAMP:
- param = object->pd->pdef_perm;
- break;
- case EXPP_OBJ_ATTR_PI_RANDOMDAMP:
- param = object->pd->pdef_rdamp;
- break;
- case EXPP_OBJ_ATTR_PI_PERM:
- param = object->pd->pdef_perm;
- break;
- case EXPP_OBJ_ATTR_PI_STRENGTH:
- param = object->pd->f_strength;
- break;
- case EXPP_OBJ_ATTR_PI_FALLOFF:
- param = object->pd->f_power;
- break;
- case EXPP_OBJ_ATTR_PI_MAXDIST:
- param = object->pd->maxdist;
- break;
- case EXPP_OBJ_ATTR_PI_SBDAMP:
- param = object->pd->pdef_sbdamp;
- break;
- case EXPP_OBJ_ATTR_PI_SBIFACETHICK:
- param = object->pd->pdef_sbift;
- break;
- case EXPP_OBJ_ATTR_PI_SBOFACETHICK:
- param = object->pd->pdef_sboft;
- break;
- case EXPP_OBJ_ATTR_SB_NODEMASS:
- param = self->object->soft->nodemass;
- break;
- case EXPP_OBJ_ATTR_SB_GRAV:
- param = self->object->soft->grav;
- break;
- case EXPP_OBJ_ATTR_SB_MEDIAFRICT:
- param = self->object->soft->mediafrict;
- break;
- case EXPP_OBJ_ATTR_SB_RKLIMIT:
- param = object->soft->rklimit;
- break;
- case EXPP_OBJ_ATTR_SB_PHYSICSSPEED:
- param = object->soft->physics_speed;
- break;
- case EXPP_OBJ_ATTR_SB_GOALSPRING:
- param = object->soft->goalspring;
- break;
- case EXPP_OBJ_ATTR_SB_GOALFRICT:
- param = object->soft->goalfrict;
- break;
- case EXPP_OBJ_ATTR_SB_MINGOAL:
- param = object->soft->mingoal;
- break;
- case EXPP_OBJ_ATTR_SB_MAXGOAL:
- param = object->soft->maxgoal;
- break;
- case EXPP_OBJ_ATTR_SB_DEFGOAL:
- param = object->soft->defgoal;
- break;
- case EXPP_OBJ_ATTR_SB_INSPRING:
- param = object->soft->inspring;
- break;
- case EXPP_OBJ_ATTR_SB_INFRICT:
- param = object->soft->infrict;
- break;
- case EXPP_OBJ_ATTR_DUPFACESCALEFAC:
- param = object->dupfacesca;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type in getFloatAttr" );
- }
-
- return PyFloat_FromDouble( param );
-}
-
-/*
- * set floating point attributes which require clamping
- */
-
-static int setFloatAttrClamp( BPy_Object *self, PyObject *value, void *type )
-{
- float *param;
- struct Object *object = self->object;
- float min, max;
-
- if( (int)type >= EXPP_OBJ_ATTR_PI_SURFACEDAMP &&
- (int)type <= EXPP_OBJ_ATTR_PI_SBOFACETHICK ) {
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
- }
- else if( (int)type >= EXPP_OBJ_ATTR_SB_NODEMASS &&
- (int)type <= EXPP_OBJ_ATTR_SB_INFRICT ) {
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "softbody could not be accessed" );
- }
-
- switch( (int)type ) {
- case EXPP_OBJ_ATTR_DRAWSIZE:
- min = EXPP_OBJECT_DRAWSIZEMIN;
- max = EXPP_OBJECT_DRAWSIZEMAX;
- param = &object->empty_drawsize;
- break;
- case EXPP_OBJ_ATTR_TIMEOFFSET:
- min = -MAXFRAMEF;
- max = MAXFRAMEF;
- param = &object->sf;
- break;
- case EXPP_OBJ_ATTR_PI_SURFACEDAMP:
- min = EXPP_OBJECT_PIDAMP_MIN;
- max = EXPP_OBJECT_PIDAMP_MAX;
- param = &object->pd->pdef_perm;
- break;
- case EXPP_OBJ_ATTR_PI_RANDOMDAMP:
- min = EXPP_OBJECT_PIRDAMP_MIN;
- max = EXPP_OBJECT_PIRDAMP_MAX;
- param = &object->pd->pdef_rdamp;
- break;
- case EXPP_OBJ_ATTR_PI_PERM:
- min = EXPP_OBJECT_PIPERM_MIN;
- max = EXPP_OBJECT_PIPERM_MAX;
- param = &object->pd->pdef_perm;
- break;
- case EXPP_OBJ_ATTR_PI_STRENGTH:
- min = EXPP_OBJECT_PISTRENGTH_MIN;
- max = EXPP_OBJECT_PISTRENGTH_MAX;
- param = &object->pd->f_strength;
- break;
- case EXPP_OBJ_ATTR_PI_FALLOFF:
- min = EXPP_OBJECT_PIPOWER_MIN;
- max = EXPP_OBJECT_PIPOWER_MAX;
- param = &object->pd->f_power;
- break;
- case EXPP_OBJ_ATTR_PI_MAXDIST:
- min = EXPP_OBJECT_PIMAXDIST_MIN;
- max = EXPP_OBJECT_PIMAXDIST_MAX;
- param = &object->pd->maxdist;
- break;
- case EXPP_OBJ_ATTR_PI_SBDAMP:
- min = EXPP_OBJECT_PISBDAMP_MIN;
- max = EXPP_OBJECT_PISBDAMP_MAX;
- param = &object->pd->pdef_sbdamp;
- break;
- case EXPP_OBJ_ATTR_PI_SBIFACETHICK:
- min = EXPP_OBJECT_PISBIFTMIN;
- max = EXPP_OBJECT_PISBIFTMAX;
- param = &object->pd->pdef_sbift;
- break;
- case EXPP_OBJ_ATTR_PI_SBOFACETHICK:
- min = EXPP_OBJECT_PISBOFTMIN;
- max = EXPP_OBJECT_PISBOFTMAX;
- param = &object->pd->pdef_sboft;
- break;
- case EXPP_OBJ_ATTR_SB_NODEMASS:
- min = EXPP_OBJECT_SBNODEMASSMIN;
- max = EXPP_OBJECT_SBNODEMASSMAX;
- param = &self->object->soft->nodemass;
- break;
- case EXPP_OBJ_ATTR_SB_GRAV:
- min = EXPP_OBJECT_SBGRAVMIN;
- max = EXPP_OBJECT_SBGRAVMAX;
- param = &self->object->soft->grav;
- break;
- case EXPP_OBJ_ATTR_SB_MEDIAFRICT:
- min = EXPP_OBJECT_SBMEDIAFRICTMIN;
- max = EXPP_OBJECT_SBMEDIAFRICTMAX;
- param = &self->object->soft->mediafrict;
- break;
- case EXPP_OBJ_ATTR_SB_RKLIMIT:
- min = EXPP_OBJECT_SBRKLIMITMIN;
- max = EXPP_OBJECT_SBRKLIMITMAX;
- param = &self->object->soft->rklimit;
- break;
- case EXPP_OBJ_ATTR_SB_PHYSICSSPEED:
- min = EXPP_OBJECT_SBPHYSICSSPEEDMIN;
- max = EXPP_OBJECT_SBPHYSICSSPEEDMAX;
- param = &self->object->soft->physics_speed;
- break;
- case EXPP_OBJ_ATTR_SB_GOALSPRING:
- min = EXPP_OBJECT_SBGOALSPRINGMIN;
- max = EXPP_OBJECT_SBGOALSPRINGMAX;
- param = &self->object->soft->goalspring;
- break;
- case EXPP_OBJ_ATTR_SB_GOALFRICT:
- min = EXPP_OBJECT_SBGOALFRICTMIN;
- max = EXPP_OBJECT_SBGOALFRICTMAX;
- param = &self->object->soft->goalfrict;
- break;
- case EXPP_OBJ_ATTR_SB_MINGOAL:
- min = EXPP_OBJECT_SBMINGOALMIN;
- max = EXPP_OBJECT_SBMINGOALMAX;
- param = &self->object->soft->mingoal;
- break;
- case EXPP_OBJ_ATTR_SB_MAXGOAL:
- min = EXPP_OBJECT_SBMAXGOALMIN;
- max = EXPP_OBJECT_SBMAXGOALMAX;
- param = &self->object->soft->maxgoal;
- break;
- case EXPP_OBJ_ATTR_SB_DEFGOAL:
- min = EXPP_OBJECT_SBDEFGOALMIN;
- max = EXPP_OBJECT_SBDEFGOALMAX;
- param = &self->object->soft->defgoal;
- break;
- case EXPP_OBJ_ATTR_SB_INSPRING:
- min = EXPP_OBJECT_SBINSPRINGMIN;
- max = EXPP_OBJECT_SBINSPRINGMAX;
- param = &self->object->soft->inspring;
- break;
- case EXPP_OBJ_ATTR_SB_INFRICT:
- min = EXPP_OBJECT_SBINFRICTMIN;
- max = EXPP_OBJECT_SBINFRICTMAX;
- param = &self->object->soft->infrict;
- break;
- case EXPP_OBJ_ATTR_DUPFACESCALEFAC:
- min = EXPP_OBJECT_DUPFACESCALEFACMIN;
- max = EXPP_OBJECT_DUPFACESCALEFACMAX;
- param = &self->object->dupfacesca;
- break;
-
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setFloatAttrClamp" );
- }
-
- self->object->recalc |= OB_RECALC_OB;
- return EXPP_setFloatClamped( value, param, min, max );
-}
-
-/*
- * set floating point attributes
- */
-
-static int setFloatAttr( BPy_Object *self, PyObject *value, void *type )
-{
- float param;
- struct Object *object = self->object;
-
- if( !PyNumber_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
-
- param = (float)PyFloat_AsDouble( value );
-
- switch( (int)type ) {
- case EXPP_OBJ_ATTR_LOC_X:
- object->loc[0] = param;
- break;
- case EXPP_OBJ_ATTR_LOC_Y:
- object->loc[1] = param;
- break;
- case EXPP_OBJ_ATTR_LOC_Z:
- object->loc[2] = param;
- break;
- case EXPP_OBJ_ATTR_DLOC_X:
- object->dloc[0] = param;
- break;
- case EXPP_OBJ_ATTR_DLOC_Y:
- object->dloc[1] = param;
- break;
- case EXPP_OBJ_ATTR_DLOC_Z:
- object->dloc[2] = param;
- break;
- case EXPP_OBJ_ATTR_ROT_X:
- object->rot[0] = param;
- break;
- case EXPP_OBJ_ATTR_ROT_Y:
- object->rot[1] = param;
- break;
- case EXPP_OBJ_ATTR_ROT_Z:
- object->rot[2] = param;
- break;
- case EXPP_OBJ_ATTR_DROT_X:
- object->drot[0] = param;
- break;
- case EXPP_OBJ_ATTR_DROT_Y:
- object->drot[1] = param;
- break;
- case EXPP_OBJ_ATTR_DROT_Z:
- object->drot[2] = param;
- break;
- case EXPP_OBJ_ATTR_SIZE_X:
- object->size[0] = param;
- break;
- case EXPP_OBJ_ATTR_SIZE_Y:
- object->size[1] = param;
- break;
- case EXPP_OBJ_ATTR_SIZE_Z:
- object->size[2] = param;
- break;
- case EXPP_OBJ_ATTR_DSIZE_X:
- object->dsize[0] = param;
- break;
- case EXPP_OBJ_ATTR_DSIZE_Y:
- object->dsize[1] = param;
- break;
- case EXPP_OBJ_ATTR_DSIZE_Z:
- object->dsize[2] = param;
- break;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setFloatAttr " );
- }
- self->object->recalc |= OB_RECALC_OB;
- return 0;
-}
-
-/*
- * get 3-tuple floating point attributes
- */
-
-static PyObject *getFloat3Attr( BPy_Object *self, void *type )
-{
- float *param;
- struct Object *object = self->object;
-
- switch( (int)type ) {
- case EXPP_OBJ_ATTR_LOC:
- param = object->loc;
- break;
- case EXPP_OBJ_ATTR_DLOC:
- param = object->dloc;
- break;
- case EXPP_OBJ_ATTR_DROT:
- param = object->drot;
- break;
- case EXPP_OBJ_ATTR_SIZE:
- param = object->size;
- break;
- case EXPP_OBJ_ATTR_DSIZE:
- param = object->dsize;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type in getFloat3Attr" );
- }
-
- return Py_BuildValue( "(fff)", param[0], param[1], param[2] );
-}
-
-/*
- * set 3-tuple floating point attributes
- */
-
-static int setFloat3Attr( BPy_Object *self, PyObject *value, void *type )
-{
- int i;
- float *dst, param[3];
- struct Object *object = self->object;
-
- value = PySequence_Tuple( value );
-
- if( !value || !PyArg_ParseTuple( value, "fff", &param[0], &param[1], &param[2] ) ) {
- Py_XDECREF( value );
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list or tuple of 3 floats" );
- }
-
- Py_DECREF( value );
- switch( (int)type ) {
- case EXPP_OBJ_ATTR_LOC:
- dst = object->loc;
- break;
- case EXPP_OBJ_ATTR_DLOC:
- dst = object->dloc;
- break;
- case EXPP_OBJ_ATTR_DROT:
- dst = object->drot;
- break;
- case EXPP_OBJ_ATTR_SIZE:
- dst = object->size;
- break;
- case EXPP_OBJ_ATTR_DSIZE:
- dst = object->dsize;
- break;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setFloat3Attr" );
- }
-
- for( i = 0; i < 3; ++i )
- dst[i] = param[i];
-
- self->object->recalc |= OB_RECALC_OB;
- return 0;
-}
-
-/*****************************************************************************/
-/* BPy_Object methods and attribute handlers */
-/*****************************************************************************/
-
-static PyObject *Object_getShapeFlag( BPy_Object *self, void *type )
-{
- if (self->object->shapeflag & (int)type)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static int Object_setShapeFlag( BPy_Object *self, PyObject *value,
- void *type )
-{
- if (PyObject_IsTrue(value) )
- self->object->shapeflag |= (int)type;
- else
- self->object->shapeflag &= ~(int)type;
-
- self->object->recalc |= OB_RECALC_OB;
- return 0;
-}
-
-static PyObject *Object_getRestricted( BPy_Object *self, void *type )
-{
- if (self->object->restrictflag & (int)type)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static int Object_setRestricted( BPy_Object *self, PyObject *value,
- void *type )
-{
- int param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if ( param )
- self->object->restrictflag |= (int)type;
- else
- self->object->restrictflag &= ~(int)type;
-
- return 0;
-}
-
-static PyObject *Object_getDrawModeBits( BPy_Object *self, void *type )
-{
- return EXPP_getBitfield( (void *)&self->object->dtx, (int)type, 'b' );
-}
-
-static int Object_setDrawModeBits( BPy_Object *self, PyObject *value,
- void *type )
-{
- self->object->recalc |= OB_RECALC_OB;
- return EXPP_setBitfield( value, (void *)&self->object->dtx,
- (int)type, 'b' );
-}
-
-static PyObject *Object_getTransflagBits( BPy_Object *self, void *type )
-{
- return EXPP_getBitfield( (void *)&self->object->transflag,
- (int)type, 'h' );
-}
-
-static int Object_setTransflagBits( BPy_Object *self, PyObject *value,
- void *type )
-{
- self->object->recalc |= OB_RECALC_OB;
- return EXPP_setBitfield( value, (void *)&self->object->transflag,
- (int)type, 'h' );
-}
-
-static PyObject *Object_getLayers( BPy_Object * self )
-{
- int layers, bit;
- PyObject *laylist = PyList_New( 0 );
-
- if( !laylist )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "PyList_New() failed" );
-
- layers = self->object->lay & 0xfffff; /* get layer bitmask */
-
- /*
- * starting with the first layer, and until there are no more layers,
- * find which layers are visible
- */
-
- for( bit = 1; layers; ++bit ) {
- if( layers & 1 ) { /* if layer is visible, add to list */
- PyObject *item = PyInt_FromLong( bit );
- PyList_Append( laylist, item );
- Py_DECREF( item );
- }
- layers >>= 1; /* go to the next layer */
- }
- return laylist;
-}
-
-/*
- * usage note: caller of this func needs to do a Blender.Redraw(-1)
- * to update and redraw the interface
- */
-
-static int Object_setLayers( BPy_Object * self, PyObject *value )
-{
- int layers = 0, val, i, len_list, local;
- Base *base;
-
- if( !PyList_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list of integers in the range [1, 20]" );
-
- len_list = PyList_Size( value );
-
- /* build a bitmask, check for values outside of range */
-
- for( i = 0; i < len_list; i++ ) {
- PyObject* integer = PyNumber_Int( PyList_GetItem( value, i ) );
- val = PyInt_AsLong( integer );
- Py_XDECREF( integer );
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "list must contain only integer numbers" );
- if( val < 1 || val > 20 )
- return EXPP_ReturnIntError ( PyExc_ValueError,
- "layer values must be in the range [1, 20]" );
- layers |= 1 << ( val - 1 );
- }
-
- /* do this, to ensure layers are set for objects not in current scene */
- self->object->lay= layers;
-
- /* update any bases pointing to our object */
- base = FIRSTBASE; /* first base in current scene */
- while( base ) {
- if( base->object == self->object ) {
- base->lay &= 0xFFF00000;
- local = base->lay;
- base->lay = local | layers;
- self->object->lay = base->lay;
- break;
- }
- base = base->next;
- }
-
- /* these to calls here are overkill! (ton) */
- if (base) { /* The object was found? */
- countall();
- DAG_scene_sort( G.scene );
- }
- return 0;
-}
-
-static int Object_setLayersMask( BPy_Object *self, PyObject *value )
-{
- int layers = 0, local;
- Base *base;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an integer (bitmask) as argument" );
-
- layers = PyInt_AS_LONG( value );
-
- /* make sure some bits are set, and only those bits are set */
-
- if( !( layers & 0xFFFFF ) || ( layers & 0xFFF00000 ) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "bitmask must have between 1 and 20 bits set" );
-
- /* update any bases pointing to our object */
-
- base = FIRSTBASE; /* first base in current scene */
- while( base ) {
- if( base->object == self->object ) {
- base->lay &= 0xFFF00000;
- local = base->lay;
- base->lay = local | layers;
- self->object->lay = base->lay;
- break;
- }
- base = base->next;
- }
- if (base) { /* The object was found? */
- countall();
- DAG_scene_sort( G.scene );
- }
- return 0;
-}
-
-/*
- * this should accept a Py_None argument and just delete the Ipo link
- * (as Object_clearIpo() does)
- */
-
-static int Object_setIpo( BPy_Object * self, PyObject * value )
-{
- return GenericLib_assignData(value, (void **) &self->object->ipo, 0, 1, ID_IP, ID_OB);
-}
-
-static int Object_setTracked( BPy_Object * self, PyObject * value )
-{
- int ret;
- ret = GenericLib_assignData(value, (void **) &self->object->track, 0, 0, ID_OB, 0);
- if (ret==0) {
- self->object->recalc |= OB_RECALC_OB;
- DAG_scene_sort( G.scene );
- }
- return ret;
-}
-
-/* Localspace matrix */
-
-static PyObject *Object_getMatrixLocal( BPy_Object * self )
-{
- if( self->object->parent ) {
- float matrix[4][4]; /* for the result */
- float invmat[4][4]; /* for inverse of parent's matrix */
-
- Mat4Invert(invmat, self->object->parent->obmat );
- Mat4MulMat4(matrix, self->object->obmat, invmat);
- return newMatrixObject((float*)matrix,4,4,Py_NEW);
- } else { /* no parent, so return world space matrix */
- disable_where_script( 1 );
- where_is_object( self->object );
- disable_where_script( 0 );
- return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
- }
-}
-
-/* Worldspace matrix */
-
-static PyObject *Object_getMatrixWorld( BPy_Object * self )
-{
- disable_where_script( 1 );
- where_is_object( self->object );
- disable_where_script( 0 );
- return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
-}
-
-/* Parent Inverse matrix */
-
-static PyObject *Object_getMatrixParentInverse( BPy_Object * self )
-{
- return newMatrixObject((float*)self->object->parentinv,4,4,Py_WRAP);
-}
-
-/*
- * Old behavior, prior to Blender 2.34, where eventual changes made by the
- * script itself were not taken into account until a redraw happened, either
- * called by the script or upon its exit.
- */
-
-static PyObject *Object_getMatrixOldWorld( BPy_Object * self )
-{
- return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
-}
-
-/*
- * get one of three different matrix representations
- */
-
-static PyObject *Object_getMatrix( BPy_Object * self, PyObject * args )
-{
- char *space = "worldspace"; /* default to world */
- char *errstr = "expected nothing, 'worldspace' (default), 'localspace' or 'old_worldspace'";
-
- if( !PyArg_ParseTuple( args, "|s", &space ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError, errstr );
-
- if( BLI_streq( space, "worldspace" ) )
- return Object_getMatrixWorld( self );
- else if( BLI_streq( space, "localspace" ) )
- return Object_getMatrixLocal( self );
- else if( BLI_streq( space, "old_worldspace" ) )
- return Object_getMatrixOldWorld( self );
- else
- return EXPP_ReturnPyObjError( PyExc_ValueError, errstr );
-}
-
-static PyObject *get_obj_data( BPy_Object *self, int mesh )
-{
- Object *object = self->object;
- PyObject *data_object = NULL;
-
- switch ( object->type ) {
- case OB_ARMATURE:
- data_object = Armature_CreatePyObject( object->data );
- break;
- case OB_CAMERA:
- data_object = Camera_CreatePyObject( object->data );
- break;
- case OB_CURVE:
- case OB_SURF:
- data_object = Curve_CreatePyObject( object->data );
- break;
- case ID_IM:
- data_object = Image_CreatePyObject( object->data );
- break;
- case ID_IP:
- data_object = Ipo_CreatePyObject( object->data );
- break;
- case OB_LAMP:
- data_object = Lamp_CreatePyObject( object->data );
- break;
- case OB_LATTICE:
- data_object = Lattice_CreatePyObject( object->data );
- break;
- case ID_MA:
- break;
- case OB_MESH:
- if( !mesh ) /* get as NMesh (default) */
- data_object = NMesh_CreatePyObject( object->data, object );
- else /* else get as Mesh */
- data_object = Mesh_CreatePyObject( object->data, object );
- break;
- case OB_MBALL:
- data_object = Metaball_CreatePyObject( object->data );
- break;
- case ID_OB:
- data_object = Object_CreatePyObject( object->data );
- break;
- case ID_SCE:
- break;
- case OB_FONT:
- data_object = Text3d_CreatePyObject( object->data );
- break;
- case ID_WO:
- break;
- default:
- break;
- }
-
- if( data_object )
- return data_object;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getData( BPy_Object *self, PyObject *args,
- PyObject *kwd )
-{
- Object *object = self->object;
- int name_only = 0;
- int mesh = 0; /* default mesh type = NMesh */
- static char *kwlist[] = {"name_only", "mesh", NULL};
-
- if( !PyArg_ParseTupleAndKeywords(args, kwd, "|ii", kwlist,
- &name_only, &mesh) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or bool keywords 'name_only' or 'mesh' as argument" );
-
- /* if there's no obdata, try to create it */
- if( object->data == NULL ) {
- int tmptype = object->type; /* save current type */
-
- /* if we have no data and are faking an empty, set the type */
- if( self->realtype != OB_EMPTY )
- object->type = self->realtype;
-
- if( EXPP_add_obdata( object ) != 0 ) { /* couldn't create obdata */
- object->type = tmptype; /* restore previous type */
- Py_RETURN_NONE;
- }
-
- /* if we set data successfully, clear the fake type */
- self->realtype = OB_EMPTY;
- }
-
- /* user wants only the name of the data object */
- if( name_only ) {
- ID *id = object->data;
- return PyString_FromString( id->name+2 );
- }
-
- return get_obj_data( self, mesh );
-}
-
-static PyObject *Object_getEuler( BPy_Object * self )
-{
- return ( PyObject * ) newEulerObject( self->object->rot, Py_WRAP );
-}
-
-#define PROTFLAGS_MASK ( OB_LOCK_LOCX | OB_LOCK_LOCY | OB_LOCK_LOCZ | \
- OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | \
- OB_LOCK_SCALEX | OB_LOCK_SCALEY | OB_LOCK_SCALEZ )
-
-static PyObject *Object_getProtectFlags( BPy_Object * self )
-{
- return PyInt_FromLong( (long)(self->object->protectflag & PROTFLAGS_MASK) );
-}
-
-static int Object_setProtectFlags( BPy_Object * self, PyObject * args )
-{
- PyObject* integer = PyNumber_Int( args );
- short value;
-
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- value = ( short )PyInt_AS_LONG( integer );
- Py_DECREF( integer );
- if( value & ~PROTFLAGS_MASK )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "undefined bit(s) set in bitfield" );
-
- self->object->protectflag = value;
- self->object->recalc |= OB_RECALC_OB;
- return 0;
-}
-
-static PyObject *Object_getRBRadius( BPy_Object * self )
-{
- return PyFloat_FromDouble( (double) self->object->inertia );
-}
-
-static int Object_setRBRadius( BPy_Object * self, PyObject * args )
-{
- float value;
- PyObject* flt = PyNumber_Float( args );
-
- if( !flt )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
- value = (float)PyFloat_AS_DOUBLE( flt );
- Py_DECREF( flt );
-
- if( value < 0.0f )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "acceptable values are non-negative, 0.0 or more" );
-
- self->object->inertia = value;
- self->object->recalc |= OB_RECALC_OB;
-
- return 0;
-}
-
-static PyObject *Object_getRBHalfExtents( BPy_Object * self )
-{
- float center[3], extents[3];
-
- get_local_bounds( self->object, center, extents );
- return Py_BuildValue( "[fff]", extents[0], extents[1], extents[2] );
-}
-
-static PyGetSetDef BPy_Object_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"LocX",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The X location coordinate of the object",
- (void *)EXPP_OBJ_ATTR_LOC_X},
- {"LocY",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The Y location coordinate of the object",
- (void *)EXPP_OBJ_ATTR_LOC_Y},
- {"LocZ",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The Z location coordinate of the object",
- (void *)EXPP_OBJ_ATTR_LOC_Z},
- {"dLocX",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The delta X location coordinate of the object",
- (void *)EXPP_OBJ_ATTR_DLOC_X},
- {"dLocY",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The delta Y location coordinate of the object",
- (void *)EXPP_OBJ_ATTR_DLOC_Y},
- {"dLocZ",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The delta Z location coordinate of the object",
- (void *)EXPP_OBJ_ATTR_DLOC_Z},
- {"RotX",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The X rotation angle (in radians) of the object",
- (void *)EXPP_OBJ_ATTR_ROT_X},
- {"RotY",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The Y rotation angle (in radians) of the object",
- (void *)EXPP_OBJ_ATTR_ROT_Y},
- {"RotZ",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The Z rotation angle (in radians) of the object",
- (void *)EXPP_OBJ_ATTR_ROT_Z},
- {"dRotX",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The delta X rotation angle (in radians) of the object",
- (void *)EXPP_OBJ_ATTR_DROT_X},
- {"dRotY",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The delta Y rotation angle (in radians) of the object",
- (void *)EXPP_OBJ_ATTR_DROT_Y},
- {"dRotZ",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The delta Z rotation angle (in radians) of the object",
- (void *)EXPP_OBJ_ATTR_DROT_Z},
- {"SizeX",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The X size of the object",
- (void *)EXPP_OBJ_ATTR_SIZE_X},
- {"SizeY",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The Y size of the object",
- (void *)EXPP_OBJ_ATTR_SIZE_Y},
- {"SizeZ",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The Z size of the object",
- (void *)EXPP_OBJ_ATTR_SIZE_Z},
- {"dSizeX",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The delta X size of the object",
- (void *)EXPP_OBJ_ATTR_DSIZE_X},
- {"dSizeY",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The delta Y size of the object",
- (void *)EXPP_OBJ_ATTR_DSIZE_Y},
- {"dSizeZ",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "The delta Z size of the object",
- (void *)EXPP_OBJ_ATTR_DSIZE_Z},
-
- {"loc",
- (getter)getFloat3Attr, (setter)setFloat3Attr,
- "The (X,Y,Z) location coordinates of the object",
- (void *)EXPP_OBJ_ATTR_LOC},
- {"dloc",
- (getter)getFloat3Attr, (setter)setFloat3Attr,
- "The delta (X,Y,Z) location coordinates of the object",
- (void *)EXPP_OBJ_ATTR_DLOC},
- {"rot",
- (getter)Object_getEuler, (setter)Object_setEuler,
- "The (X,Y,Z) rotation angles (in degrees) of the object",
- NULL},
- {"drot",
- (getter)getFloat3Attr, (setter)setFloat3Attr,
- "The delta (X,Y,Z) rotation angles (in radians) of the object",
- (void *)EXPP_OBJ_ATTR_DROT},
- {"size",
- (getter)getFloat3Attr, (setter)setFloat3Attr,
- "The (X,Y,Z) size of the object",
- (void *)EXPP_OBJ_ATTR_SIZE},
- {"dsize",
- (getter)getFloat3Attr, (setter)setFloat3Attr,
- "The delta (X,Y,Z) size of the object",
- (void *)EXPP_OBJ_ATTR_DSIZE},
- {"Layer",
- (getter)getIntAttr, (setter)Object_setLayersMask,
- "The object layers (bitfield)",
- (void *)EXPP_OBJ_ATTR_LAYERMASK},
- {"Layers",
- (getter)getIntAttr, (setter)Object_setLayersMask,
- "The object layers (bitfield)",
- (void *)EXPP_OBJ_ATTR_LAYERMASK},
- {"layers",
- (getter)Object_getLayers, (setter)Object_setLayers,
- "The object layers (list of ints)",
- NULL},
- {"ipo",
- (getter)Object_getIpo, (setter)Object_setIpo,
- "Object's Ipo data",
- NULL},
- {"colbits",
- (getter)getIntAttr, (setter)setIntAttrRange,
- "The Material usage bitfield",
- (void *)EXPP_OBJ_ATTR_COLBITS},
- {"drawMode",
- (getter)getIntAttr, (setter)Object_setDrawMode,
- "The object's drawing mode bitfield",
- (void *)EXPP_OBJ_ATTR_DRAWMODE},
- {"drawType",
- (getter)getIntAttr, (setter)Object_setDrawType,
- "The object's drawing type",
- (void *)EXPP_OBJ_ATTR_DRAWTYPE},
- {"parentType",
- (getter)getIntAttr, (setter)NULL,
- "The object's parent type",
- (void *)EXPP_OBJ_ATTR_PARENT_TYPE},
- {"DupOn",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "DupOn setting (for DupliFrames)",
- (void *)EXPP_OBJ_ATTR_DUPON},
- {"DupOff",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "DupOff setting (for DupliFrames)",
- (void *)EXPP_OBJ_ATTR_DUPOFF},
- {"DupSta",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "Starting frame (for DupliFrames)",
- (void *)EXPP_OBJ_ATTR_DUPSTA},
- {"DupEnd",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "Ending frame (for DupliFrames)",
- (void *)EXPP_OBJ_ATTR_DUPEND},
- {"passIndex",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "Index for object masks in the compositor",
- (void *)EXPP_OBJ_ATTR_PASSINDEX},
- {"activeMaterial",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "Index for the active material (displayed in the material panel)",
- (void *)EXPP_OBJ_ATTR_ACT_MATERIAL},
- {"mat",
- (getter)Object_getMatrixWorld, (setter)NULL,
- "worldspace matrix: absolute, takes vertex parents, tracking and Ipos into account",
- NULL},
- {"matrix",
- (getter)Object_getMatrixWorld, (setter)NULL,
- "worldspace matrix: absolute, takes vertex parents, tracking and Ipos into account",
- NULL},
- {"matrixWorld",
- (getter)Object_getMatrixWorld, (setter)NULL,
- "worldspace matrix: absolute, takes vertex parents, tracking and Ipos into account",
- NULL},
- {"matrixLocal",
- (getter)Object_getMatrixLocal, (setter)Object_setMatrix,
- "localspace matrix: relative to the object's parent",
- NULL},
- {"matrixParentInverse",
- (getter)Object_getMatrixParentInverse, (setter)NULL,
- "parents inverse matrix: parents localspace inverted matrix",
- NULL},
- {"matrixOldWorld",
- (getter)Object_getMatrixOldWorld, (setter)NULL,
- "old-type worldspace matrix (prior to Blender 2.34)",
- NULL},
- {"data",
- (getter)get_obj_data, (setter)NULL,
- "The Datablock object linked to this object",
- NULL},
- {"sel",
- (getter)Object_getSelected, (setter)Object_setSelect,
- "The object's selection state",
- NULL},
- {"parent",
- (getter)Object_getParent, (setter)NULL,
- "The object's parent object (if parented)",
- NULL},
- {"parentbonename",
- (getter)Object_getParentBoneName, (setter)Object_setParentBoneName,
- "The object's parent object's sub name",
- NULL},
- {"track",
- (getter)Object_getTracked, (setter)Object_setTracked,
- "The object's tracked object",
- NULL},
- {"timeOffset",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "The time offset of the object's animation",
- (void *)EXPP_OBJ_ATTR_TIMEOFFSET},
- {"type",
- (getter)Object_getType, (setter)NULL,
- "The object's type",
- NULL},
- {"boundingBox",
- (getter)Object_getBoundBox, (setter)NULL,
- "The bounding box of this object",
- NULL},
- {"action",
- (getter)Object_getAction, (setter)Object_setAction,
- "The action associated with this object (if defined)",
- NULL},
- {"game_properties",
- (getter)Object_getAllProperties, (setter)NULL,
- "The object's properties",
- NULL},
-
- {"piFalloff",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "The particle interaction falloff power",
- (void *)EXPP_OBJ_ATTR_PI_FALLOFF},
- {"piMaxDist",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Max distance for the particle interaction field to work",
- (void *)EXPP_OBJ_ATTR_PI_MAXDIST},
- {"piPermeability",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Probability that a particle will pass through the mesh",
- (void *)EXPP_OBJ_ATTR_PI_PERM},
- {"piRandomDamp",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Random variation of particle interaction damping",
- (void *)EXPP_OBJ_ATTR_PI_RANDOMDAMP},
- {"piStrength",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Particle interaction force field strength",
- (void *)EXPP_OBJ_ATTR_PI_STRENGTH},
- {"piSurfaceDamp",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Amount of damping during particle collision",
- (void *)EXPP_OBJ_ATTR_PI_SURFACEDAMP},
- {"piSoftbodyDamp",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Damping factor for softbody deflection",
- (void *)EXPP_OBJ_ATTR_PI_SBDAMP},
- {"piSoftbodyIThick",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Inner face thickness for softbody deflection",
- (void *)EXPP_OBJ_ATTR_PI_SBIFACETHICK},
- {"piSoftbodyOThick",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Outer face thickness for softbody deflection",
- (void *)EXPP_OBJ_ATTR_PI_SBOFACETHICK},
-
- {"piDeflection",
- (getter)Object_getPIDeflection, (setter)Object_setPIDeflection,
- "Deflects particles based on collision",
- NULL},
- {"piType",
- (getter)Object_getPIType, (setter)Object_setPIType,
- "Type of particle interaction (force field, wind, etc)",
- NULL},
- {"piUseMaxDist",
- (getter)Object_getPIUseMaxDist, (setter)Object_setPIUseMaxDist,
- "Use a maximum distance for the field to work",
- NULL},
-
- {"sbMass",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Softbody point mass (heavier is slower)",
- (void *)EXPP_OBJ_ATTR_SB_NODEMASS},
- {"sbGrav",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Apply gravitation to softbody point movement",
- (void *)EXPP_OBJ_ATTR_SB_GRAV},
- {"sbFriction",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "General media friction for softbody point movements",
- (void *)EXPP_OBJ_ATTR_SB_MEDIAFRICT},
- {"sbSpeed",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Tweak timing for physics to control softbody frequency and speed",
- (void *)EXPP_OBJ_ATTR_SB_MEDIAFRICT},
- {"sbErrorLimit",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Softbody Runge-Kutta ODE solver error limit (low values give more precision)",
- (void *)EXPP_OBJ_ATTR_SB_RKLIMIT},
- {"sbGoalSpring",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Softbody goal (vertex target position) spring stiffness",
- (void *)EXPP_OBJ_ATTR_SB_GOALSPRING},
- {"sbGoalFriction",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Softbody goal (vertex target position) friction",
- (void *)EXPP_OBJ_ATTR_SB_GOALFRICT},
- {"sbMinGoal",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Softbody goal minimum (vertex group weights scaled to match this range)",
- (void *)EXPP_OBJ_ATTR_SB_MINGOAL},
- {"sbMaxGoal",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Softbody goal maximum (vertex group weights scaled to match this range)",
- (void *)EXPP_OBJ_ATTR_SB_MAXGOAL},
- {"sbDefaultGoal",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Default softbody goal value, when no vertex group used",
- (void *)EXPP_OBJ_ATTR_SB_DEFGOAL},
- {"sbInnerSpring",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Softbody edge spring stiffness",
- (void *)EXPP_OBJ_ATTR_SB_INSPRING},
- {"sbInnerSpringFrict",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "Softbody edge spring friction",
- (void *)EXPP_OBJ_ATTR_SB_INFRICT},
- {"isSoftBody",
- (getter)Object_isSB, (setter)NULL,
- "True if object is a soft body",
- NULL},
- {"sbUseGoal",
- (getter)Object_getSBUseGoal, (setter)Object_setSBUseGoal,
- "Softbody forces for vertices to stick to animated position enabled",
- NULL},
- {"sbUseEdges",
- (getter)Object_getSBUseEdges, (setter)Object_setSBUseEdges,
- "Softbody use edges as springs enabled",
- NULL},
- {"sbStiffQuads",
- (getter)Object_getSBStiffQuads, (setter)Object_setSBStiffQuads,
- "Softbody adds diagonal springs on 4-gons enabled",
- NULL},
-
- {"axis",
- (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
- "Display of active object's center and axis enabled",
- (void *)OB_AXIS},
- {"texSpace",
- (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
- "Display of active object's texture space enabled",
- (void *)OB_TEXSPACE},
- {"nameMode",
- (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
- "Display of active object's name enabled",
- (void *)OB_DRAWNAME},
- {"wireMode",
- (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
- "Add the active object's wireframe over solid drawing enabled",
- (void *)OB_DRAWWIRE},
- {"xRay",
- (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
- "Draw the active object in front of others enabled",
- (void *)OB_DRAWXRAY},
- {"transp",
- (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
- "Transparent materials for the active object (mesh only) enabled",
- (void *)OB_DRAWTRANSP},
-
- {"enableNLAOverride",
- (getter)Object_getNLAflagBits, (setter)Object_setNLAflagBits,
- "Toggles Action-NLA based animation",
- (void *)OB_NLA_OVERRIDE},
-
- {"enableDupVerts",
- (getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
- "Duplicate child objects on all vertices",
- (void *)OB_DUPLIVERTS},
- {"enableDupFaces",
- (getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
- "Duplicate child objects on all faces",
- (void *)OB_DUPLIFACES},
- {"enableDupFacesScale",
- (getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
- "Use face scale to scale all dupliFaces",
- (void *)OB_DUPLIFACES_SCALE},
- {"dupFacesScaleFac",
- (getter)getFloatAttr, (setter)setFloatAttr,
- "Use face scale to scale all dupliFaces",
- (void *)EXPP_OBJ_ATTR_DUPFACESCALEFAC},
- {"enableDupFrames",
- (getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
- "Make copy of object for every frame",
- (void *)OB_DUPLIFRAMES},
- {"enableDupGroup",
- (getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
- "Enable group instancing",
- (void *)OB_DUPLIGROUP},
- {"enableDupRot",
- (getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
- "Rotate dupli according to vertex normal",
- (void *)OB_DUPLIROT},
- {"enableDupNoSpeed",
- (getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
- "Set dupliframes to still, regardless of frame",
- (void *)OB_DUPLINOSPEED},
- {"DupObjects",
- (getter)Object_getDupliObjects, (setter)NULL,
- "Get a list of tuple pairs (object, matrix), for getting dupli objects",
- NULL},
- {"DupGroup",
- (getter)Object_getDupliGroup, (setter)Object_setDupliGroup,
- "Get a list of tuples for object duplicated by dupliframe",
- NULL},
-
- {"effects",
- (getter)Object_getEffects, (setter)NULL,
- "The list of particle effects associated with the object",
- NULL},
- {"actionStrips",
- (getter)Object_getActionStrips, (setter)NULL,
- "The action strips associated with the object",
- NULL},
- {"constraints",
- (getter)Object_getConstraints, (setter)NULL,
- "The constraints associated with the object",
- NULL},
- {"modifiers",
- (getter)Object_getModifiers, (setter)Object_setModifiers,
- "The modifiers associated with the object",
- NULL},
- {"protectFlags",
- (getter)Object_getProtectFlags, (setter)Object_setProtectFlags,
- "The \"transform locking\" bitfield for the object",
- NULL},
- {"drawSize",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "The size to display the Empty",
- (void *)EXPP_OBJ_ATTR_DRAWSIZE},
-
- {"rbFlags",
- (getter)Object_getRBFlags, (setter)Object_setRBFlags,
- "Rigid body flags",
- NULL},
- {"rbMass",
- (getter)Object_getRBMass, (setter)Object_setRBMass,
- "Rigid body object mass",
- NULL},
- {"rbRadius",
- (getter)Object_getRBRadius, (setter)Object_setRBRadius,
- "Rigid body bounding sphere size",
- NULL},
- {"rbShapeBoundType",
- (getter)Object_getRBShapeBoundType, (setter)Object_setRBShapeBoundType,
- "Rigid body physics bounds object type",
- NULL},
- {"rbHalfExtents",
- (getter)Object_getRBHalfExtents, (setter)NULL,
- "Rigid body physics bounds object type",
- NULL},
-
- {"restrictDisplay",
- (getter)Object_getRestricted, (setter)Object_setRestricted,
- "Toggle object restrictions",
- (void *)OB_RESTRICT_VIEW},
- {"restrictSelect",
- (getter)Object_getRestricted, (setter)Object_setRestricted,
- "Toggle object restrictions",
- (void *)OB_RESTRICT_SELECT},
- {"restrictRender",
- (getter)Object_getRestricted, (setter)Object_setRestricted,
- "Toggle object restrictions",
- (void *)OB_RESTRICT_RENDER},
-
- {"pinShape",
- (getter)Object_getShapeFlag, (setter)Object_setShapeFlag,
- "Set the state for pinning this object",
- (void *)OB_SHAPE_LOCK},
- {"activeShape",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "set the index for the active shape key",
- (void *)EXPP_OBJ_ATTR_ACT_SHAPE},
-
-
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python Object_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Object_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Object", /* char *tp_name; */
- sizeof( BPy_Object ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) Object_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) Object_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Object_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_Object_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Object_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_Object_DrawModesDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "AXIS", PyInt_FromLong( OB_AXIS ) );
- PyConstant_Insert( d, "TEXSPACE", PyInt_FromLong( OB_TEXSPACE ) );
- PyConstant_Insert( d, "NAME", PyInt_FromLong( OB_DRAWNAME ) );
- PyConstant_Insert( d, "WIRE", PyInt_FromLong( OB_DRAWWIRE ) );
- PyConstant_Insert( d, "XRAY", PyInt_FromLong( OB_DRAWXRAY ) );
- PyConstant_Insert( d, "TRANSP", PyInt_FromLong( OB_DRAWTRANSP ) );
- }
- return M;
-}
-
-static PyObject *M_Object_DrawTypesDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "BOUNDBOX", PyInt_FromLong( OB_BOUNDBOX ) );
- PyConstant_Insert( d, "WIRE", PyInt_FromLong( OB_WIRE ) );
- PyConstant_Insert( d, "SOLID", PyInt_FromLong( OB_SOLID ) );
- PyConstant_Insert( d, "SHADED", PyInt_FromLong( OB_SHADED ) );
- }
- return M;
-}
-
-static PyObject *M_Object_ParentTypesDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "OBJECT", PyInt_FromLong( PAROBJECT ) );
- PyConstant_Insert( d, "CURVE", PyInt_FromLong( PARCURVE ) );
-
- /* 2.43 was released as LATTICE as PARKEY, my bad,
- lattice uses PARSKEL also - Campbell */
- PyConstant_Insert( d, "LATTICE", PyInt_FromLong( PARSKEL ) );
-
- PyConstant_Insert( d, "ARMATURE", PyInt_FromLong( PARSKEL ) );
- PyConstant_Insert( d, "VERT1", PyInt_FromLong( PARVERT1 ) );
- PyConstant_Insert( d, "VERT3", PyInt_FromLong( PARVERT3 ) );
- PyConstant_Insert( d, "BONE", PyInt_FromLong( PARBONE ) );
- }
- return M;
-}
-
-static PyObject *M_Object_PITypesDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "NONE", PyInt_FromLong( 0 ) );
- PyConstant_Insert( d, "FORCE", PyInt_FromLong( PFIELD_FORCE ) );
- PyConstant_Insert( d, "VORTEX", PyInt_FromLong( PFIELD_VORTEX ) );
- PyConstant_Insert( d, "WIND", PyInt_FromLong( PFIELD_WIND ) );
- PyConstant_Insert( d, "GUIDE", PyInt_FromLong( PFIELD_GUIDE ) );
- }
- return M;
-}
-
-static PyObject *M_Object_ProtectDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "LOCX", PyInt_FromLong( OB_LOCK_LOCX ) );
- PyConstant_Insert( d, "LOCY", PyInt_FromLong( OB_LOCK_LOCY ) );
- PyConstant_Insert( d, "LOCZ", PyInt_FromLong( OB_LOCK_LOCZ ) );
- PyConstant_Insert( d, "LOC", PyInt_FromLong( OB_LOCK_LOC ) );
- PyConstant_Insert( d, "ROTX", PyInt_FromLong( OB_LOCK_ROTX ) );
- PyConstant_Insert( d, "ROTY", PyInt_FromLong( OB_LOCK_ROTY ) );
- PyConstant_Insert( d, "ROTZ", PyInt_FromLong( OB_LOCK_ROTZ ) );
- PyConstant_Insert( d, "ROT",
- PyInt_FromLong( OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ ) );
- PyConstant_Insert( d, "SCALEX", PyInt_FromLong( OB_LOCK_SCALEX ) );
- PyConstant_Insert( d, "SCALEY", PyInt_FromLong( OB_LOCK_SCALEY ) );
- PyConstant_Insert( d, "SCALEZ", PyInt_FromLong( OB_LOCK_SCALEZ ) );
- PyConstant_Insert( d, "SCALE",
- PyInt_FromLong( OB_LOCK_SCALEX|OB_LOCK_SCALEY|OB_LOCK_SCALEZ ) );
- }
- return M;
-}
-
-static PyObject *M_Object_RBFlagsDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( OB_DYNAMIC ) );
- PyConstant_Insert( d, "CHILD", PyInt_FromLong( OB_CHILD ) );
- PyConstant_Insert( d, "ACTOR", PyInt_FromLong( OB_ACTOR ) );
- PyConstant_Insert( d, "USEFH", PyInt_FromLong( OB_DO_FH ) );
- PyConstant_Insert( d, "ROTFH", PyInt_FromLong( OB_ROT_FH ) );
- PyConstant_Insert( d, "ANISOTROPIC",
- PyInt_FromLong( OB_ANISOTROPIC_FRICTION ) );
- PyConstant_Insert( d, "GHOST", PyInt_FromLong( OB_GHOST ) );
- PyConstant_Insert( d, "RIGIDBODY", PyInt_FromLong( OB_RIGID_BODY ) );
- PyConstant_Insert( d, "BOUNDS", PyInt_FromLong( OB_BOUNDS ) );
- PyConstant_Insert( d, "COLLISION_RESPONSE",
- PyInt_FromLong( OB_COLLISION_RESPONSE ) );
- PyConstant_Insert( d, "SECTOR", PyInt_FromLong( OB_SECTOR ) );
- PyConstant_Insert( d, "PROP", PyInt_FromLong( OB_PROP ) );
- PyConstant_Insert( d, "MAINACTOR", PyInt_FromLong( OB_MAINACTOR ) );
- }
- return M;
-}
-
-static PyObject *M_Object_RBShapeBoundDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "BOX", PyInt_FromLong( OB_BOUND_BOX ) );
- PyConstant_Insert( d, "SPHERE", PyInt_FromLong( OB_BOUND_SPHERE ) );
- PyConstant_Insert( d, "CYLINDER", PyInt_FromLong( OB_BOUND_CYLINDER ) );
- PyConstant_Insert( d, "CONE", PyInt_FromLong( OB_BOUND_CONE ) );
- PyConstant_Insert( d, "POLYHEDERON", PyInt_FromLong( OB_BOUND_POLYH ) );
- }
- return M;
-}
-
-static PyObject *M_Object_IpoKeyTypesDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "LOC", PyInt_FromLong( IPOKEY_LOC ) );
- PyConstant_Insert( d, "ROT", PyInt_FromLong( IPOKEY_ROT ) );
- PyConstant_Insert( d, "SIZE", PyInt_FromLong( IPOKEY_SIZE ) );
- PyConstant_Insert( d, "LOCROT", PyInt_FromLong( IPOKEY_LOCROT ) );
- PyConstant_Insert( d, "LOCROTSIZE", PyInt_FromLong( IPOKEY_LOCROTSIZE ) );
- PyConstant_Insert( d, "LAYER", PyInt_FromLong( IPOKEY_LAYER ) );
-
- PyConstant_Insert( d, "PI_STRENGTH", PyInt_FromLong( IPOKEY_PI_STRENGTH ) );
- PyConstant_Insert( d, "PI_FALLOFF", PyInt_FromLong( IPOKEY_PI_FALLOFF ) );
- PyConstant_Insert( d, "PI_SURFACEDAMP", PyInt_FromLong( IPOKEY_PI_SURFACEDAMP ) );
- PyConstant_Insert( d, "PI_RANDOMDAMP", PyInt_FromLong( IPOKEY_PI_RANDOMDAMP ) );
- PyConstant_Insert( d, "PI_PERM", PyInt_FromLong( IPOKEY_PI_PERM ) );
- }
- return M;
-}
-
-/*****************************************************************************/
-/* Function: initObject */
-/*****************************************************************************/
-PyObject *Object_Init( void )
-{
- PyObject *module, *dict;
- PyObject *DrawModesDict = M_Object_DrawModesDict( );
- PyObject *DrawTypesDict = M_Object_DrawTypesDict( );
- PyObject *ParentTypesDict = M_Object_ParentTypesDict( );
- PyObject *ProtectDict = M_Object_ProtectDict( );
- PyObject *PITypesDict = M_Object_PITypesDict( );
- PyObject *RBFlagsDict = M_Object_RBFlagsDict( );
- PyObject *RBShapesDict = M_Object_RBShapeBoundDict( );
- PyObject *IpoKeyTypesDict = M_Object_IpoKeyTypesDict( );
-
- PyType_Ready( &Object_Type ) ;
-
- module = Py_InitModule3( "Blender.Object", M_Object_methods,
- M_Object_doc );
-
-
- /* We Should Remove these!!!! */
- PyModule_AddIntConstant( module, "LOC", IPOKEY_LOC );
- PyModule_AddIntConstant( module, "ROT", IPOKEY_ROT );
- PyModule_AddIntConstant( module, "SIZE", IPOKEY_SIZE );
- PyModule_AddIntConstant( module, "LOCROT", IPOKEY_LOCROT );
- PyModule_AddIntConstant( module, "LOCROTSIZE", IPOKEY_LOCROTSIZE );
- PyModule_AddIntConstant( module, "LAYER", IPOKEY_LAYER );
-
- PyModule_AddIntConstant( module, "PI_STRENGTH", IPOKEY_PI_STRENGTH );
- PyModule_AddIntConstant( module, "PI_FALLOFF", IPOKEY_PI_FALLOFF );
- PyModule_AddIntConstant( module, "PI_SURFACEDAMP", IPOKEY_PI_SURFACEDAMP );
- PyModule_AddIntConstant( module, "PI_RANDOMDAMP", IPOKEY_PI_RANDOMDAMP );
- PyModule_AddIntConstant( module, "PI_PERM", IPOKEY_PI_PERM );
-
- PyModule_AddIntConstant( module, "NONE",0 );
- PyModule_AddIntConstant( module, "FORCE",PFIELD_FORCE );
- PyModule_AddIntConstant( module, "VORTEX",PFIELD_VORTEX );
- PyModule_AddIntConstant( module, "MAGNET",PFIELD_MAGNET );
- PyModule_AddIntConstant( module, "WIND",PFIELD_WIND );
- /* Only keeping above so as not to break compat */
-
-
- if( DrawModesDict )
- PyModule_AddObject( module, "DrawModes", DrawModesDict );
- if( DrawTypesDict )
- PyModule_AddObject( module, "DrawTypes", DrawTypesDict );
- if( ParentTypesDict )
- PyModule_AddObject( module, "ParentTypes", ParentTypesDict );
- if( PITypesDict )
- PyModule_AddObject( module, "PITypes", PITypesDict );
- if( ProtectDict )
- PyModule_AddObject( module, "ProtectFlags", ProtectDict );
- if( RBFlagsDict )
- PyModule_AddObject( module, "RBFlags", RBFlagsDict );
- if( RBShapesDict )
- PyModule_AddObject( module, "RBShapes", RBShapesDict );
- if( IpoKeyTypesDict )
- PyModule_AddObject( module, "IpoKeyTypes", IpoKeyTypesDict );
-
- /*Add SUBMODULES to the module*/
- dict = PyModule_GetDict( module ); /*borrowed*/
- PyDict_SetItemString(dict, "Pose", Pose_Init()); /*creates a *new* module*/
- /*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); */ /*creates a *new* module*/
-
- return ( module );
-}
-
-/* #####DEPRECATED###### */
-
-static PyObject *Object_SetIpo( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Object_setIpo );
-}
-
-static PyObject *Object_Select( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Object_setSelect );
-}
-
-static PyObject *Object_SetDrawMode( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Object_setDrawMode );
-}
-
-static PyObject *Object_SetDrawType( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Object_setDrawType );
-}
-
-static PyObject *Object_SetMatrix( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Object_setMatrix );
-}
-
-static PyObject *Object_SetEuler( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)Object_setEuler );
-}
-
-static PyObject *Object_setTimeOffset( BPy_Object * self, PyObject * args )
-{
- float newTimeOffset;
-
- if( !PyArg_ParseTuple( args, "f", &newTimeOffset ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float as argument" );
-
- self->object->sf = newTimeOffset;
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-
-/*************************************************************************/
-/* particle defection methods */
-/*************************************************************************/
-
-static PyObject *Object_SetPIDeflection( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Object_setPIDeflection );
-}
-
-static PyObject *Object_SetPIType( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Object_setPIType );
-}
-
-static PyObject *Object_SetPIUseMaxDist( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Object_setPIUseMaxDist );
-}
-
-static PyObject *Object_getPISurfaceDamp( BPy_Object * self )
-{
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->pd->pdef_damp );
-}
-
-static PyObject *Object_SetPISurfaceDamp( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return NULL;
-
- self->object->pd->pdef_damp = EXPP_ClampFloat( value,
- EXPP_OBJECT_PIDAMP_MIN, EXPP_OBJECT_PIDAMP_MAX );
- self->object->recalc |= OB_RECALC_OB;
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getPIPerm( BPy_Object * self )
-{
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
- return PyFloat_FromDouble ( (double) self->object->pd->pdef_perm );
-}
-
-static PyObject *Object_SetPIPerm( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return NULL;
-
- self->object->pd->pdef_perm = EXPP_ClampFloat( value,
- EXPP_OBJECT_PIPERM_MIN, EXPP_OBJECT_PIPERM_MAX );
- self->object->recalc |= OB_RECALC_OB;
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getPIStrength( BPy_Object * self )
-{
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->pd->f_strength );
-}
-
-static PyObject *Object_setPIStrength( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->pd->f_strength = EXPP_ClampFloat( value,
- EXPP_OBJECT_PISTRENGTH_MIN, EXPP_OBJECT_PISTRENGTH_MAX );
- self->object->recalc |= OB_RECALC_OB;
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getPIFalloff( BPy_Object * self )
-{
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->pd->f_power );
-}
-
-static PyObject *Object_setPIFalloff( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->pd->f_power = EXPP_ClampFloat( value,
- EXPP_OBJECT_PIPOWER_MIN, EXPP_OBJECT_PIPOWER_MAX );
- self->object->recalc |= OB_RECALC_OB;
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getPIMaxDist( BPy_Object * self )
-{
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->pd->maxdist );
-}
-
-static PyObject *Object_setPIMaxDist( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->pd->maxdist = EXPP_ClampFloat( value,
- EXPP_OBJECT_PIMAXDIST_MIN, EXPP_OBJECT_PIMAXDIST_MAX );
- self->object->recalc |= OB_RECALC_OB;
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getPIRandomDamp( BPy_Object * self )
-{
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->pd->pdef_rdamp );
-}
-
-static PyObject *Object_setPIRandomDamp( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->pd && !setupPI(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return NULL;
-
- self->object->pd->pdef_rdamp = EXPP_ClampFloat( value,
- EXPP_OBJECT_PIRDAMP_MIN, EXPP_OBJECT_PIRDAMP_MAX );
- self->object->recalc |= OB_RECALC_OB;
- Py_RETURN_NONE;
-}
-
-/*************************************************************************/
-/* softbody methods */
-/*************************************************************************/
-
-static PyObject *Object_getSBMass( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->nodemass );
-}
-
-static PyObject *Object_setSBMass( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->nodemass = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBNODEMASSMIN, EXPP_OBJECT_SBNODEMASSMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBGravity( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->grav );
-}
-
-static PyObject *Object_setSBGravity( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->grav = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBGRAVMIN, EXPP_OBJECT_SBGRAVMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBFriction( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->mediafrict );
-}
-
-static PyObject *Object_setSBFriction( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->mediafrict = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBMEDIAFRICTMIN, EXPP_OBJECT_SBMEDIAFRICTMAX );
- self->object->recalc |= OB_RECALC_OB;
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBErrorLimit( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->rklimit );
-}
-
-static PyObject *Object_setSBErrorLimit( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->rklimit = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBRKLIMITMIN, EXPP_OBJECT_SBRKLIMITMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBGoalSpring( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->goalspring );
-}
-
-static PyObject *Object_setSBGoalSpring( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->goalspring = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBGOALSPRINGMIN, EXPP_OBJECT_SBGOALSPRINGMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBGoalFriction( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->goalfrict );
-}
-
-static PyObject *Object_setSBGoalFriction( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->goalfrict = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBGOALFRICTMIN, EXPP_OBJECT_SBGOALFRICTMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBMinGoal( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->mingoal );
-}
-
-static PyObject *Object_setSBMinGoal( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->mingoal = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBMINGOALMIN, EXPP_OBJECT_SBMINGOALMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBMaxGoal( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->maxgoal );
-}
-
-static PyObject *Object_setSBMaxGoal( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->maxgoal = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBMAXGOALMIN, EXPP_OBJECT_SBMAXGOALMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBDefaultGoal( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->defgoal );
-}
-
-static PyObject *Object_setSBDefaultGoal( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->defgoal = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBDEFGOALMIN, EXPP_OBJECT_SBDEFGOALMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBInnerSpring( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->inspring );
-}
-
-static PyObject *Object_setSBInnerSpring( BPy_Object * self, PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->inspring = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBINSPRINGMIN, EXPP_OBJECT_SBINSPRINGMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_getSBInnerSpringFriction( BPy_Object * self )
-{
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- return PyFloat_FromDouble( ( double ) self->object->soft->infrict );
-}
-
-static PyObject *Object_setSBInnerSpringFriction( BPy_Object * self,
- PyObject * args )
-{
- float value;
-
- if( !self->object->soft && !setupSB(self->object) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed" );
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- self->object->soft->infrict = EXPP_ClampFloat( value,
- EXPP_OBJECT_SBINFRICTMIN, EXPP_OBJECT_SBINFRICTMAX );
- self->object->recalc |= OB_RECALC_OB;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Object_SetSBUseGoal( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Object_setSBUseGoal );
-}
-
-static PyObject *Object_SetSBUseEdges( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Object_setSBUseEdges );
-}
-
-static PyObject *Object_SetSBStiffQuads( BPy_Object * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Object_setSBStiffQuads );
-}
diff --git a/source/blender/python/api2_2x/Object.h b/source/blender/python/api2_2x/Object.h
deleted file mode 100644
index 7891f99da09..00000000000
--- a/source/blender/python/api2_2x/Object.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Particle.c b/source/blender/python/api2_2x/Particle.c
deleted file mode 100644
index 84c0c727792..00000000000
--- a/source/blender/python/api2_2x/Particle.c
+++ /dev/null
@@ -1,1040 +0,0 @@
-/*
- * $Id: Particle.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): Jacques Guignot, Jean-Michel Soler
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Particle.h" /*This must come first */
-
-#include "DNA_object_types.h"
-#include "BKE_effect.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_object.h"
-#include "BLI_blenlib.h"
-#include "gen_utils.h"
-
-/*****************************************************************************/
-/* Python API function prototypes for the Particle module. */
-/*****************************************************************************/
-PyObject *M_Particle_New( PyObject * self, PyObject * args );
-PyObject *M_Particle_Get( PyObject * self, PyObject * args );
-
-/*****************************************************************************/
-/* Python BPy_Particle methods declarations: */
-/*****************************************************************************/
-PyObject *Effect_getType( BPy_Effect * self );
-PyObject *Effect_setType( BPy_Effect * self, PyObject * args );
-PyObject *Effect_getFlag( BPy_Effect * self );
-PyObject *Effect_setFlag( BPy_Effect * self, PyObject * args );
-PyObject *Particle_getSta( BPy_Particle * self );
-PyObject *Particle_setSta( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getEnd( BPy_Particle * self );
-PyObject *Particle_setEnd( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getLifetime( BPy_Particle * self );
-PyObject *Particle_setLifetime( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getNormfac( BPy_Particle * self );
-PyObject *Particle_setNormfac( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getObfac( BPy_Particle * self );
-PyObject *Particle_setObfac( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getRandfac( BPy_Particle * self );
-PyObject *Particle_setRandfac( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getTexfac( BPy_Particle * self );
-PyObject *Particle_setTexfac( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getRandlife( BPy_Particle * self );
-PyObject *Particle_setRandlife( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getNabla( BPy_Particle * self );
-PyObject *Particle_setNabla( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getVectsize( BPy_Particle * self );
-PyObject *Particle_setVectsize( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getTotpart( BPy_Particle * self );
-PyObject *Particle_setTotpart( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getTotkey( BPy_Particle * self );
-PyObject *Particle_setTotkey( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getSeed( BPy_Particle * self );
-PyObject *Particle_setSeed( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getForce( BPy_Particle * self );
-PyObject *Particle_setForce( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getMult( BPy_Particle * self );
-PyObject *Particle_setMult( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getLife( BPy_Particle * self );
-PyObject *Particle_setLife( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getMat( BPy_Particle * self );
-PyObject *Particle_setMat( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getChild( BPy_Particle * self );
-PyObject *Particle_setChild( BPy_Particle * self, PyObject * a );
-PyObject *Particle_getDefvec( BPy_Particle * self );
-PyObject *Particle_setDefvec( BPy_Particle * self, PyObject * a );
-
-/*****************************************************************************/
-/* Python Particle_Type callback function prototypes: */
-/*****************************************************************************/
-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 );
-
-
-/*****************************************************************************/
-/* Python BPy_Particle methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Particle_methods[] = {
- {"getType", ( PyCFunction ) Effect_getType,
- METH_NOARGS, "() - Return Effect type"},
- {"setType", ( PyCFunction ) Effect_setType,
- METH_VARARGS, "() - Set Effect type"},
- {"getFlag", ( PyCFunction ) Effect_getFlag,
- METH_NOARGS, "() - Return Effect flag"},
- {"setFlag", ( PyCFunction ) Effect_setFlag,
- METH_VARARGS, "() - Set Effect flag"},
- {"getStartTime", ( PyCFunction ) Particle_getSta,
- METH_NOARGS, "()-Return particle start time"},
- {"setStartTime", ( PyCFunction ) Particle_setSta, METH_VARARGS,
- "()- Sets particle start time"},
- {"getEndTime", ( PyCFunction ) Particle_getEnd,
- METH_NOARGS, "()-Return particle end time"},
- {"setEndTime", ( PyCFunction ) Particle_setEnd, METH_VARARGS,
- "()- Sets particle end time"},
- {"getLifetime", ( PyCFunction ) Particle_getLifetime,
- METH_NOARGS, "()-Return particle life time"},
- {"setLifetime", ( PyCFunction ) Particle_setLifetime, METH_VARARGS,
- "()- Sets particle life time "},
- {"getNormfac", ( PyCFunction ) Particle_getNormfac,
- METH_NOARGS, "()-Return particle life time"},
- {"setNormfac", ( PyCFunction ) Particle_setNormfac, METH_VARARGS,
- "()- Sets particle life time "},
- {"getObfac", ( PyCFunction ) Particle_getObfac,
- METH_NOARGS, "()-Return particle life time"},
- {"setObfac", ( PyCFunction ) Particle_setObfac, METH_VARARGS,
- "()- Sets particle life time "},
- {"getRandfac", ( PyCFunction ) Particle_getRandfac,
- METH_NOARGS, "()-Return particle life time"},
- {"setRandfac", ( PyCFunction ) Particle_setRandfac, METH_VARARGS,
- "()- Sets particle life time "},
- {"getTexfac", ( PyCFunction ) Particle_getTexfac,
- METH_NOARGS, "()-Return particle life time"},
- {"setTexfac", ( PyCFunction ) Particle_setTexfac, METH_VARARGS,
- "()- Sets particle life time "},
- {"getRandlife", ( PyCFunction ) Particle_getRandlife,
- METH_NOARGS, "()-Return particle life time"},
- {"setRandlife", ( PyCFunction ) Particle_setRandlife, METH_VARARGS,
- "()- Sets particle life time "},
- {"getNabla", ( PyCFunction ) Particle_getNabla,
- METH_NOARGS, "()-Return particle life time"},
- {"setNabla", ( PyCFunction ) Particle_setNabla, METH_VARARGS,
- "()- Sets particle life time "},
- {"getVectsize", ( PyCFunction ) Particle_getVectsize,
- METH_NOARGS, "()-Return particle life time"},
- {"setVectsize", ( PyCFunction ) Particle_setVectsize, METH_VARARGS,
- "()- Sets particle life time "},
- {"getTotpart", ( PyCFunction ) Particle_getTotpart,
- METH_NOARGS, "()-Return particle life time"},
- {"setTotpart", ( PyCFunction ) Particle_setTotpart, METH_VARARGS,
- "()- Sets particle life time "},
- {"getTotkey", ( PyCFunction ) Particle_getTotkey,
- METH_NOARGS, "()-Return particle life time"},
- {"setTotkey", ( PyCFunction ) Particle_setTotkey, METH_VARARGS,
- "()- Sets particle life time "},
- {"getSeed", ( PyCFunction ) Particle_getSeed,
- METH_NOARGS, "()-Return particle life time"},
- {"setSeed", ( PyCFunction ) Particle_setSeed, METH_VARARGS,
- "()- Sets particle life time "},
- {"getForce", ( PyCFunction ) Particle_getForce,
- METH_NOARGS, "()-Return particle life time"},
- {"setForce", ( PyCFunction ) Particle_setForce, METH_VARARGS,
- "()- Sets particle life time "},
- {"getMult", ( PyCFunction ) Particle_getMult,
- METH_NOARGS, "()-Return particle life time"},
- {"setMult", ( PyCFunction ) Particle_setMult, METH_VARARGS,
- "()- Sets particle life time "},
- {"getLife", ( PyCFunction ) Particle_getLife,
- METH_NOARGS, "()-Return particle life time"},
- {"setLife", ( PyCFunction ) Particle_setLife, METH_VARARGS,
- "()- Sets particle life time "},
- {"getMat", ( PyCFunction ) Particle_getMat,
- METH_NOARGS, "()-Return particle life time"},
- {"setMat", ( PyCFunction ) Particle_setMat, METH_VARARGS,
- "()- Sets particle life time "},
- {"getChild", ( PyCFunction ) Particle_getChild,
- METH_NOARGS, "()-Return particle life time"},
- {"setChild", ( PyCFunction ) Particle_setChild, METH_VARARGS,
- "()- Sets particle life time "},
- {"getDefvec", ( PyCFunction ) Particle_getDefvec,
- METH_NOARGS, "()-Return particle life time"},
- {"setDefvec", ( PyCFunction ) Particle_setDefvec, METH_VARARGS,
- "()- Sets particle life time "},
-
-
- {NULL, NULL, 0, NULL}
-};
-
-/**************** prototypes ********************/
-PyObject *Particle_Init( void );
-
-
-/*****************************************************************************/
-/* Python Particle_Type structure definition: */
-/*****************************************************************************/
-
-PyTypeObject Particle_Type = {
- PyObject_HEAD_INIT( NULL )
- 0,
- "Particle",
- sizeof( BPy_Particle ),
- 0,
-
- ( destructor ) ParticleDeAlloc,
- 0,
- ( getattrfunc ) ParticleGetAttr,
- ( setattrfunc ) ParticleSetAttr,
- 0,
- ( reprfunc ) ParticleRepr,
- 0,
- 0,
- 0,
- 0,
- 0, 0, 0, 0, 0, 0,
- 0,
- 0, 0, 0, 0, 0, 0,
- BPy_Particle_methods,
- 0,
-};
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Particle.__doc__ */
-/*****************************************************************************/
-char M_Particle_doc[] = "The Blender Particle module\n\n\
-This module provides access to **Object Data** in Blender.\n\
-Functions :\n\
- New(object mesh's name) : creates a new part object and adds it to the given mesh object \n\
- Get(name) : retreives a particle with the given name (mandatory)\n\
- get(name) : same as Get. Kept for compatibility reasons.\n";
-char M_Particle_New_doc[] = "New(name) : creates a new part object and adds it to the given mesh object\n";
-char M_Particle_Get_doc[] = "xxx";
-
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Particle module: */
-/*****************************************************************************/
-struct PyMethodDef M_Particle_methods[] = {
- {"New", ( PyCFunction ) M_Particle_New, METH_VARARGS, M_Particle_New_doc},
- {"Get", M_Particle_Get, METH_VARARGS, M_Particle_Get_doc},
- {"get", M_Particle_Get, METH_VARARGS, M_Particle_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-
-/*****************************************************************************/
-/* Function: M_Particle_New */
-/* Python equivalent: Blender.Effect.Particle.New */
-/* Description : Create a particle effect and add a link */
-/* to the given mesh-type Object */
-/* Data : String mesh object name */
-/* Return : pyobject particle */
-/*****************************************************************************/
-PyObject *M_Particle_New( PyObject * self, PyObject * args )
-{
- BPy_Effect *pyeffect;
- Effect *bleffect = 0;
- Object *ob;
- char *name = NULL;
-
- if( !PyArg_ParseTuple( args, "s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- for( ob = G.main->object.first; ob; ob = ob->id.next )
- if( !strcmp( name, ob->id.name + 2 ) )
- break;
-
- if( !ob )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object does not exist" );
-
- if( ob->type != OB_MESH )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "object is not a mesh" );
-
- pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
- if( !pyeffect )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create Effect Data object" );
-
- bleffect = add_effect( EFF_PARTICLE );
- if( !bleffect ) {
- Py_DECREF( pyeffect );
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Effect Data in Blender" );
- }
-
- pyeffect->effect = (PartEff *)bleffect;
- BLI_addtail( &ob->effect, bleffect );
-
- return ( PyObject * ) pyeffect;
-}
-
-/*****************************************************************************/
-/* Function: M_Particle_Get */
-/* Python equivalent: Blender.Effect.Particle.Get */
-/*****************************************************************************/
-PyObject *M_Particle_Get( PyObject * self, PyObject * args )
-{
- /*arguments : string object name
- int : position of effect in the obj's effect list */
- char *name = 0;
- Object *object_iter;
- Effect *eff;
- BPy_Particle *wanted_eff;
- int num, i;
-
- if( !PyArg_ParseTuple( args, "si", &name, &num ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected string int argument" ) );
-
- object_iter = G.main->object.first;
- if( !object_iter )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Scene contains no object" );
-
- while( object_iter ) {
- if( strcmp( name, object_iter->id.name + 2 ) ) {
- object_iter = object_iter->id.next;
- continue;
- }
-
- if( object_iter->effect.first != NULL ) {
- eff = object_iter->effect.first;
- for( i = 0; i < num; i++ ) {
- if( eff->type != EFF_PARTICLE )
- continue;
- eff = eff->next;
- if( !eff )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "Object" ) );
- }
- wanted_eff =
- ( BPy_Particle * ) PyObject_NEW( BPy_Particle,
- &Particle_Type );
- wanted_eff->particle = eff;
- return ( PyObject * ) wanted_eff;
- }
- object_iter = object_iter->id.next;
- }
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-/*****************************************************************************/
-/* Function: Particle_Init */
-/*****************************************************************************/
-PyObject *Particle_Init( void )
-{
- PyObject *submodule;
-
- if( PyType_Ready( &Particle_Type) < 0)
- return NULL;
-
- submodule =
- Py_InitModule3( "Blender.Particle", M_Particle_methods, M_Particle_doc );
- return ( submodule );
-}
-
-/*****************************************************************************/
-/* Python BPy_Particle methods: */
-/*****************************************************************************/
-
-PyObject *Particle_getSta( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->sta );
-}
-
-
-
-PyObject *Particle_setSta( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val = 0;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->sta = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-PyObject *Particle_getEnd( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->end );
-}
-
-
-
-PyObject *Particle_setEnd( BPy_Particle * self, PyObject * args )
-{
- float val = 0;
- PartEff *ptr = ( PartEff * ) self->particle;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->end = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-PyObject *Particle_getLifetime( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->lifetime );
-}
-
-
-
-PyObject *Particle_setLifetime( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val = 0;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->lifetime = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-PyObject *Particle_getNormfac( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->normfac );
-}
-
-
-
-PyObject *Particle_setNormfac( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val = 0;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->normfac = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-PyObject *Particle_getObfac( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->obfac );
-}
-
-
-
-PyObject *Particle_setObfac( BPy_Particle * self, PyObject * args )
-{
- float val = 0;
- PartEff *ptr = ( PartEff * ) self->particle;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->obfac = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-PyObject *Particle_getRandfac( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->randfac );
-}
-
-
-
-PyObject *Particle_setRandfac( BPy_Particle * self, PyObject * args )
-{
- float val = 0;
- PartEff *ptr = ( PartEff * ) self->particle;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->randfac = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-PyObject *Particle_getTexfac( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->texfac );
-}
-
-
-
-PyObject *Particle_setTexfac( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val = 0;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->texfac = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-PyObject *Particle_getRandlife( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->randlife );
-}
-
-
-
-PyObject *Particle_setRandlife( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val = 0;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->randlife = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-PyObject *Particle_getNabla( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->nabla );
-}
-
-
-
-PyObject *Particle_setNabla( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val = 0;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->nabla = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-PyObject *Particle_getVectsize( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyFloat_FromDouble( ptr->vectsize );
-}
-
-
-
-PyObject *Particle_setVectsize( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val = 0;
- if( !PyArg_ParseTuple( args, "f", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
- ptr->vectsize = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-PyObject *Particle_getTotpart( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyInt_FromLong( ptr->totpart );
-}
-
-
-
-PyObject *Particle_setTotpart( BPy_Particle * self, PyObject * args )
-{
- int val = 0;
- PartEff *ptr = ( PartEff * ) self->particle;
- if( !PyArg_ParseTuple( args, "i", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
- ptr->totpart = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-PyObject *Particle_getTotkey( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyInt_FromLong( ptr->totkey );
-}
-
-
-
-PyObject *Particle_setTotkey( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- int val = 0;
- if( !PyArg_ParseTuple( args, "i", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
- ptr->totkey = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-PyObject *Particle_getSeed( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return PyInt_FromLong( ptr->seed );
-}
-
-
-
-PyObject *Particle_setSeed( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- int val = 0;
- if( !PyArg_ParseTuple( args, "i", &val ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
- ptr->seed = val;
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-PyObject *Particle_getForce( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return Py_BuildValue( "(f,f,f)", ptr->force[0], ptr->force[1],
- ptr->force[2] );
-}
-
-
-PyObject *Particle_setForce( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val[3];
- if( PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
- val[0] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
- val[1] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
- val[2] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
- /*
- if (!PyArg_ParseTuple(args, "fff", val,val+1,val+2 ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected three float arguments"));
- */
- ptr->force[0] = val[0];
- ptr->force[1] = val[1];
- ptr->force[2] = val[2];
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-PyObject *Particle_getMult( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return Py_BuildValue( "(f,f,f,f)",
- ptr->mult[0], ptr->mult[1], ptr->mult[2],
- ptr->mult[3] );
-}
-
-
-PyObject *Particle_setMult( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val[4];
- if( PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
- val[0] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
- val[1] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
- val[2] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
- val[3] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 3 ) );
- ptr->mult[0] = val[0];
- ptr->mult[1] = val[1];
- ptr->mult[2] = val[2];
- ptr->mult[3] = val[3];
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-
-PyObject *Particle_getLife( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return Py_BuildValue( "(f,f,f,f)",
- ptr->life[0], ptr->life[1], ptr->life[2],
- ptr->life[3] );
-}
-
-
-PyObject *Particle_setLife( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val[4];
- if( PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
- val[0] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
- val[1] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
- val[2] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
- val[3] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 3 ) );
- ptr->life[0] = val[0];
- ptr->life[1] = val[1];
- ptr->life[2] = val[2];
- ptr->life[3] = val[3];
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-PyObject *Particle_getChild( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return Py_BuildValue( "(f,f,f,f)",
- ptr->child[0], ptr->child[1], ptr->child[2],
- ptr->child[3] );
-}
-
-
-PyObject *Particle_setChild( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val[4];
- if( PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
- val[0] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
- val[1] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
- val[2] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
- val[3] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 3 ) );
- ptr->child[0] = (short)val[0];
- ptr->child[1] = (short)val[1];
- ptr->child[2] = (short)val[2];
- ptr->child[3] = (short)val[3];
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-
-PyObject *Particle_getMat( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return Py_BuildValue( "(f,f,f,f)",
- ptr->mat[0], ptr->mat[1], ptr->mat[2],
- ptr->mat[3] );
-}
-
-
-PyObject *Particle_setMat( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val[4];
- if( PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
- val[0] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
- val[1] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
- val[2] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
- val[3] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 3 ) );
- ptr->mat[0] = (short)val[0];
- ptr->mat[1] = (short)val[1];
- ptr->mat[2] = (short)val[2];
- ptr->mat[3] = (short)val[3];
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-PyObject *Particle_getDefvec( BPy_Particle * self )
-{
-
- PartEff *ptr = ( PartEff * ) self->particle;
- return Py_BuildValue( "(f,f,f)",
- ptr->defvec[0], ptr->defvec[1], ptr->defvec[2] );
-}
-
-
-PyObject *Particle_setDefvec( BPy_Particle * self, PyObject * args )
-{
- PartEff *ptr = ( PartEff * ) self->particle;
- float val[3];
- if( PyTuple_Size( args ) == 1 )
- args = PyTuple_GetItem( args, 0 );
- val[0] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
- val[1] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
- val[2] = (float)PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
- ptr->defvec[0] = val[0];
- ptr->defvec[1] = val[1];
- ptr->defvec[2] = val[2];
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-/*****************************************************************************/
-/* Function: ParticleDeAlloc */
-/* Description: This is a callback function for the BPy_Particle type. It is */
-/* the destructor function. */
-/*****************************************************************************/
-void ParticleDeAlloc( BPy_Particle * self )
-{
- PartEff *ptr = ( PartEff * ) self;
- PyObject_DEL( ptr );
-}
-
-/*****************************************************************************/
-/* Function: ParticleGetAttr */
-/* Description: This is a callback function for the BPy_Particle type. It is */
-/* the function that accesses BPy_Particle "member variables" */
-/* and methods. */
-/*****************************************************************************/
-
-
-PyObject *ParticleGetAttr( BPy_Particle * self, char *name )
-{
-
- if( strcmp( name, "seed" ) == 0 )
- return Particle_getSeed( self );
- else if( strcmp( name, "nabla" ) == 0 )
- return Particle_getNabla( self );
- else if( strcmp( name, "sta" ) == 0 )
- return Particle_getSta( self );
- else if( strcmp( name, "end" ) == 0 )
- return Particle_getEnd( self );
- else if( strcmp( name, "lifetime" ) == 0 )
- return Particle_getLifetime( self );
- else if( strcmp( name, "normfac" ) == 0 )
- return Particle_getNormfac( self );
- else if( strcmp( name, "obfac" ) == 0 )
- return Particle_getObfac( self );
- else if( strcmp( name, "randfac" ) == 0 )
- return Particle_getRandfac( self );
- else if( strcmp( name, "texfac" ) == 0 )
- return Particle_getTexfac( self );
- else if( strcmp( name, "randlife" ) == 0 )
- return Particle_getRandlife( self );
- else if( strcmp( name, "vectsize" ) == 0 )
- return Particle_getVectsize( self );
- else if( strcmp( name, "totpart" ) == 0 )
- return Particle_getTotpart( self );
- else if( strcmp( name, "force" ) == 0 )
- return Particle_getForce( self );
- else if( strcmp( name, "mult" ) == 0 )
- return Particle_getMult( self );
- else if( strcmp( name, "life" ) == 0 )
- return Particle_getLife( self );
- else if( strcmp( name, "child" ) == 0 )
- return Particle_getChild( self );
- else if( strcmp( name, "mat" ) == 0 )
- return Particle_getMat( self );
- else if( strcmp( name, "defvec" ) == 0 )
- return Particle_getDefvec( self );
-
-
- return Py_FindMethod( BPy_Particle_methods, ( PyObject * ) self,
- name );
-}
-
-/*****************************************************************************/
-/* Function: ParticleSetAttr */
-/* Description: This is a callback function for the BPy_Particle type. */
-/* It is the function that sets Particle Data attributes */
-/* (member vars) */
-/*****************************************************************************/
-int ParticleSetAttr( BPy_Particle * self, char *name, PyObject * value )
-{
-
- PyObject *valtuple;
- PyObject *error = NULL;
-
- valtuple = Py_BuildValue( "(N)", value );
-
- if( !valtuple )
- return EXPP_ReturnIntError( PyExc_MemoryError,
- "ParticleSetAttr: couldn't create PyTuple" );
-
- if( strcmp( name, "seed" ) == 0 )
- error = Particle_setSeed( self, valtuple );
- else if( strcmp( name, "nabla" ) == 0 )
- error = Particle_setNabla( self, valtuple );
- else if( strcmp( name, "sta" ) == 0 )
- error = Particle_setSta( self, valtuple );
- else if( strcmp( name, "end" ) == 0 )
- error = Particle_setEnd( self, valtuple );
- else if( strcmp( name, "lifetime" ) == 0 )
- error = Particle_setLifetime( self, valtuple );
- else if( strcmp( name, "normfac" ) == 0 )
- error = Particle_setNormfac( self, valtuple );
- else if( strcmp( name, "obfac" ) == 0 )
- error = Particle_setObfac( self, valtuple );
- else if( strcmp( name, "randfac" ) == 0 )
- error = Particle_setRandfac( self, valtuple );
- else if( strcmp( name, "texfac" ) == 0 )
- error = Particle_setTexfac( self, valtuple );
- else if( strcmp( name, "randlife" ) == 0 )
- error = Particle_setRandlife( self, valtuple );
- else if( strcmp( name, "nabla" ) == 0 )
- error = Particle_setNabla( self, valtuple );
- else if( strcmp( name, "vectsize" ) == 0 )
- error = Particle_setVectsize( self, valtuple );
- else if( strcmp( name, "totpart" ) == 0 )
- error = Particle_setTotpart( self, valtuple );
- else if( strcmp( name, "seed" ) == 0 )
- error = Particle_setSeed( self, valtuple );
- else if( strcmp( name, "force" ) == 0 )
- error = Particle_setForce( self, valtuple );
- else if( strcmp( name, "mult" ) == 0 )
- error = Particle_setMult( self, valtuple );
- else if( strcmp( name, "life" ) == 0 )
- error = Particle_setLife( self, valtuple );
- else if( strcmp( name, "child" ) == 0 )
- error = Particle_setChild( self, valtuple );
- else if( strcmp( name, "mat" ) == 0 )
- error = Particle_setMat( self, valtuple );
- else if( strcmp( name, "defvec" ) == 0 )
- error = Particle_setDefvec( self, valtuple );
-
- else {
- Py_DECREF( valtuple );
-
- if( ( strcmp( name, "Types" ) == 0 ) ||
- ( strcmp( name, "Modes" ) == 0 ) )
- return ( EXPP_ReturnIntError( PyExc_AttributeError,
- "constant dictionary -- cannot be changed" ) );
-
- else
- return ( EXPP_ReturnIntError( PyExc_KeyError,
- "attribute not found" ) );
- }
-
- Py_DECREF(valtuple);
- if( error != Py_None )
- return -1;
-
- Py_DECREF( Py_None );
- return 0;
-}
-
-/*****************************************************************************/
-/* Function: ParticlePrint */
-/* Description: This is a callback function for the BPy_Particle type. It */
-/* particles a meaninful string to 'print' particle objects. */
-/*****************************************************************************/
-/*
-int ParticlePrint(BPy_Particle *self, FILE *fp, int flags)
-{
- printf("Hi, I'm a particle!");
- return 0;
-}
-*/
-/*****************************************************************************/
-/* Function: ParticleRepr */
-/* Description: This is a callback function for the BPy_Particle type. It */
-/* particles a meaninful string to represent particle objects. */
-/*****************************************************************************/
-PyObject *ParticleRepr( void )
-{
- return PyString_FromString( "Particle" );
-}
-
-PyObject *ParticleCreatePyObject( struct Effect * particle )
-{
- BPy_Particle *blen_object;
-
-
- blen_object =
- ( BPy_Particle * ) PyObject_NEW( BPy_Particle,
- &Particle_Type );
-
- if( blen_object == NULL ) {
- return ( NULL );
- }
- blen_object->particle = particle;
- return ( ( PyObject * ) blen_object );
-
-}
-
-int ParticleCheckPyObject( PyObject * py_obj )
-{
- return ( py_obj->ob_type == &Particle_Type );
-}
-
-
-struct Particle *ParticleFromPyObject( PyObject * py_obj )
-{
- BPy_Particle *blen_obj;
-
- blen_obj = ( BPy_Particle * ) py_obj;
- return ( ( struct Particle * ) blen_obj->particle );
-
-}
diff --git a/source/blender/python/api2_2x/Particle.h b/source/blender/python/api2_2x/Particle.h
deleted file mode 100644
index 73b5363dac6..00000000000
--- a/source/blender/python/api2_2x/Particle.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Pose.c b/source/blender/python/api2_2x/Pose.c
deleted file mode 100644
index 01fbe591a74..00000000000
--- a/source/blender/python/api2_2x/Pose.c
+++ /dev/null
@@ -1,1395 +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 *****
-*/
-
-#include "Pose.h"
-
-
-#include "mydevice.h"
-#include "BKE_armature.h"
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_action.h"
-#include "BKE_utildefines.h"
-#include "BIF_editaction.h"
-#include "BIF_space.h"
-#include "BIF_poseobject.h"
-#include "BKE_depsgraph.h"
-#include "DNA_object_types.h"
-#include "DNA_ipo_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_space_types.h" //1 - this order
-#include "BSE_editipo.h" //2
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "Mathutils.h"
-#include "Object.h"
-#include "Constraint.h"
-#include "NLA.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-#include "DNA_armature_types.h" /*used for pose bone select*/
-
-#include "MEM_guardedalloc.h"
-
-extern void chan_calc_mat(bPoseChannel *chan);
-
-//------------------------ERROR CODES---------------------------------
-//This is here just to make me happy and to have more consistant error strings :)
-static const char sPoseError[] = "Pose - Error: ";
-//static const char sPoseBadArgs[] = "Pose - Bad Arguments: ";
-static const char sPoseBoneError[] = "PoseBone - Error: ";
-//static const char sPoseBoneBadArgs[] = "PoseBone - Bad Arguments: ";
-static const char sPoseBonesDictError[] = "PoseBone - Error: ";
-//static const char sPoseBonesDictBadArgs[] = "PoseBone - Bad Arguments: ";
-
-//################## PoseBonesDict_Type (internal) ########################
-/*This is an internal psuedo-dictionary type that allows for manipulation
-* of posechannels inside of a pose structure. It is a subobject of pose.
-* i.e. Pose.bones['key']*/
-//################################################################
-
-//------------------METHOD IMPLEMENTATIONS-----------------------------
-//------------------------Pose.bones.items()
-//Returns a list of key:value pairs like dict.items()
-static PyObject* PoseBonesDict_items(BPy_PoseBonesDict *self)
-{
- return PyDict_Items(self->bonesMap);
-}
-//------------------------Pose.bones.keys()
-//Returns a list of keys like dict.keys()
-static PyObject* PoseBonesDict_keys(BPy_PoseBonesDict *self)
-{
- return PyDict_Keys(self->bonesMap);
-}
-//------------------------Armature.bones.values()
-//Returns a list of values like dict.values()
-static PyObject* PoseBonesDict_values(BPy_PoseBonesDict *self)
-{
- return PyDict_Values(self->bonesMap);
-}
-//------------------ATTRIBUTE IMPLEMENTATION---------------------------
-//------------------TYPE_OBECT IMPLEMENTATION-----------------------
-//------------------------tp_doc
-//The __doc__ string for this object
-static char BPy_PoseBonesDict_doc[] = "This is an internal subobject of pose\
-designed to act as a Py_PoseBone dictionary.";
-
-//------------------------tp_methods
-//This contains a list of all methods the object contains
-static PyMethodDef BPy_PoseBonesDict_methods[] = {
- {"items", (PyCFunction) PoseBonesDict_items, METH_NOARGS,
- "() - Returns the key:value pairs from the dictionary"},
- {"keys", (PyCFunction) PoseBonesDict_keys, METH_NOARGS,
- "() - Returns the keys the dictionary"},
- {"values", (PyCFunction) PoseBonesDict_values, METH_NOARGS,
- "() - Returns the values from the dictionary"},
- {NULL, NULL, 0, NULL}
-};
-//-----------------(internal)
-static int PoseBoneMapping_Init(PyObject *dictionary, ListBase *posechannels){
- bPoseChannel *pchan = NULL;
- PyObject *py_posechannel = NULL;
-
- for (pchan = posechannels->first; pchan; pchan = pchan->next){
- py_posechannel = PyPoseBone_FromPosechannel(pchan);
- if (!py_posechannel)
- return -1;
-
- if(PyDict_SetItemString(dictionary,
- pchan->name, py_posechannel) == -1){
- return -1;
- }
- Py_DECREF(py_posechannel);
- }
- return 0;
-}
-
-//----------------- BonesDict_InitBones
-static int PoseBonesDict_InitBones(BPy_PoseBonesDict *self)
-{
- PyDict_Clear(self->bonesMap);
- if (PoseBoneMapping_Init(self->bonesMap, self->bones) == -1)
- return 0;
- return 1;
-}
-
-//------------------------tp_repr
-//This is the string representation of the object
-static PyObject *PoseBonesDict_repr(BPy_PoseBonesDict *self)
-{
- char buffer[128], *str;
- PyObject *key, *value;
- int pos = 0;
-
- /* probably a bit of overkill but better then crashing */
- str = MEM_mallocN( 64 + ( PyDict_Size( self->bonesMap ) * 128), "PoseBonesDict_repr" );
- str[0] = '\0';
-
- sprintf(buffer, "[Pose Bone Dict: {");
- strcat(str,buffer);
- while (PyDict_Next(self->bonesMap, &pos, &key, &value)) {
- sprintf(buffer, "%s : %s, ", PyString_AsString(key),
- PyString_AsString(value->ob_type->tp_repr(value)));
- strcat(str,buffer);
- }
- sprintf(buffer, "}]\n");
- strcat(str,buffer);
-
- MEM_freeN( str );
-
- return PyString_FromString(str);
-}
-
-//------------------------tp_dealloc
-//This tells how to 'tear-down' our object when ref count hits 0
-static void PoseBonesDict_dealloc(BPy_PoseBonesDict * self)
-{
- Py_DECREF(self->bonesMap);
- PoseBonesDict_Type.tp_free(self);
- return;
-}
-//------------------------mp_length
-//This gets the size of the dictionary
-static int PoseBonesDict_len(BPy_PoseBonesDict *self)
-{
- return BLI_countlist(self->bones);
-}
-//-----------------------mp_subscript
-//This defines getting a bone from the dictionary - x = Bones['key']
-static PyObject *PoseBonesDict_GetItem(BPy_PoseBonesDict *self, PyObject* key)
-{
- PyObject *value = NULL;
-
- value = PyDict_GetItem(self->bonesMap, key);
- if(value == NULL)
- Py_RETURN_NONE;
-
- return EXPP_incr_ret(value);
-}
-//------------------TYPE_OBECT DEFINITION--------------------------
-//Mapping Protocol
-static PyMappingMethods PoseBonesDict_MapMethods = {
- (inquiry) PoseBonesDict_len, //mp_length
- (binaryfunc)PoseBonesDict_GetItem, //mp_subscript
- 0, //mp_ass_subscript
-};
-//PoseBonesDict TypeObject
-PyTypeObject PoseBonesDict_Type = {
- PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "PoseBonesDict", //tp_name
- sizeof(BPy_PoseBonesDict), //tp_basicsize
- 0, //tp_itemsize
- (destructor)PoseBonesDict_dealloc, //tp_dealloc
- 0, //tp_print
- 0, //tp_getattr
- 0, //tp_setattr
- 0, //tp_compare
- (reprfunc) PoseBonesDict_repr, //tp_repr
- 0, //tp_as_number
- 0, //tp_as_sequence
- &PoseBonesDict_MapMethods, //tp_as_mapping
- 0, //tp_hash
- 0, //tp_call
- 0, //tp_str
- 0, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
- BPy_PoseBonesDict_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- 0, //tp_richcompare
- 0, //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- BPy_PoseBonesDict_methods, //tp_methods
- 0, //tp_members
- 0, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- 0, //tp_init
- 0, //tp_alloc
- 0, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-//-----------------------PyPoseBonesDict_FromPyPose
-static PyObject *PyPoseBonesDict_FromPyPose(BPy_Pose *py_pose)
-{
- BPy_PoseBonesDict *py_posebonesdict = NULL;
-
- //create py object
- py_posebonesdict = (BPy_PoseBonesDict *)PoseBonesDict_Type.tp_alloc(&PoseBonesDict_Type, 0);
- if (!py_posebonesdict)
- goto RuntimeError;
-
- //create internal dictionaries
- py_posebonesdict->bonesMap = PyDict_New();
- if (!py_posebonesdict->bonesMap)
- goto RuntimeError;
-
- //set listbase pointer
- py_posebonesdict->bones = &py_pose->pose->chanbase;
-
- //now that everything is setup - init the mappings
- if (!PoseBonesDict_InitBones(py_posebonesdict))
- goto RuntimeError;
-
- return (PyObject*)py_posebonesdict;
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s",
- sPoseBonesDictError, "Failed to create class");
-}
-
-//################## Pose_Type ##########################
-/*This type is a wrapper for a pose*/
-//####################################################
-//------------------METHOD IMPLEMENTATIONS------------------------------
-static PyObject *Pose_update(BPy_Pose *self)
-{
- Object *daddy = NULL;
-
- self->pose->flag |= POSE_RECALC;
-
- for (daddy = G.main->object.first; daddy; daddy = daddy->id.next){
- if (daddy->pose == self->pose){
- break;
- }
- }
-
- if(daddy)
- where_is_pose(daddy);
-
- Py_RETURN_NONE;
-}
-//------------------------tp_methods
-//This contains a list of all methods the object contains
-static PyMethodDef BPy_Pose_methods[] = {
- {"update", (PyCFunction) Pose_update, METH_NOARGS,
- "() - Rebuilds the pose with new values"},
- {NULL, NULL, 0, NULL}
-};
-//------------------ATTRIBUTE IMPLEMENTATIONS---------------------------
-//------------------------Pose.bones (getter)
-//Gets the bones attribute
-static PyObject *Pose_getBoneDict(BPy_Pose *self, void *closure)
-{
- return EXPP_incr_ret((PyObject*)self->Bones);
-}
-//------------------------Pose.bones (setter)
-//Sets the bones attribute
-static int Pose_setBoneDict(BPy_Pose *self, PyObject *value, void *closure)
-{
- goto AttributeError;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s",
- sPoseError, "You are not allowed to change the .bones attribute");
-}
-//------------------TYPE_OBECT IMPLEMENTATION---------------------------
-//------------------------tp_getset
-//This contains methods for attributes that require checking
-static PyGetSetDef BPy_Pose_getset[] = {
- {"bones", (getter)Pose_getBoneDict, (setter)Pose_setBoneDict,
- "The pose's Bone dictionary", NULL},
- {NULL, NULL, NULL, NULL, NULL}
-};
-//------------------------tp_dealloc
-//This tells how to 'tear-down' our object when ref count hits 0
-static void Pose_dealloc(BPy_Pose *self)
-{
- Py_DECREF(self->Bones);
- Pose_Type.tp_free(self);
- return;
-}
-//------------------------tp_cmp
-//This compares 2 pose types
-static int Pose_compare(BPy_Pose *a, BPy_Pose *b )
-{
- return ( a->pose== b->pose ) ? 0 : -1;
-}
-//------------------------tp_repr
-//This is the string representation of the object
-static PyObject *Pose_repr(BPy_Pose *self)
-{
- return PyString_FromFormat( "[Pose \"%s\"]", self->name);
-}
-//------------------------tp_doc
-//The __doc__ string for this object
-static char BPy_Pose_doc[] = "This object wraps a Blender Pose object.";
-
-//------------------TYPE_OBECT DEFINITION--------------------------
-PyTypeObject Pose_Type = {
- PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "Pose", //tp_name
- sizeof(BPy_Pose), //tp_basicsize
- 0, //tp_itemsize
- (destructor)Pose_dealloc, //tp_dealloc
- 0, //tp_print
- 0, //tp_getattr
- 0, //tp_setattr
- (cmpfunc)Pose_compare, //tp_compare
- (reprfunc)Pose_repr, //tp_repr
- 0, //tp_as_number
- 0, //tp_as_sequence
- 0, //tp_as_mapping
- 0, //tp_hash
- 0, //tp_call
- 0, //tp_str
- 0, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
- BPy_Pose_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- 0, //tp_richcompare
- 0, //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- BPy_Pose_methods, //tp_methods
- 0, //tp_members
- BPy_Pose_getset, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- 0, //tp_init
- 0, //tp_alloc
- 0, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-//################## PoseBone_Type #####################
-/*This type is a wrapper for a posechannel*/
-//####################################################
-//------------------METHOD IMPLEMENTATIONS------------------------------
-//------------------------------PoseBone.insertKey()
-static PyObject *PoseBone_insertKey(BPy_PoseBone *self, PyObject *args)
-{
- PyObject *parent_object = NULL;
- PyObject *constants = NULL, *item = NULL;
- int frame = 1, oldframe, length, x, numeric_value = 0, oldflag, no_ipo_update = 0;
- bPoseChannel *pchan = NULL;
-
-
- if (!PyArg_ParseTuple(args, "O!i|Oi", &Object_Type, &parent_object, &frame, &constants, &no_ipo_update ))
- goto AttributeError;
-
- /* incase we ever have a value other then 1 for fast */
- if (no_ipo_update)
- no_ipo_update = 1;
-
- //verify that this pchannel is part of the object->pose
- for (pchan = ((BPy_Object*)parent_object)->object->pose->chanbase.first;
- pchan; pchan = pchan->next){
- if (pchan == self->posechannel)
- break;
- }
- if (!pchan)
- goto AttributeError2;
-
- //verify that there is an action bound to this object
- if (!((BPy_Object*)parent_object)->object->action){
- goto AttributeError5;
- }
-
- oldflag = self->posechannel->flag;
- self->posechannel->flag = 0;
- //set the flags for this posechannel
- if (constants){
- if(PySequence_Check(constants)){
- length = PySequence_Length(constants);
- for (x = 0; x < length; x++){
- item = PySequence_GetItem(constants, x);
- if (item == EXPP_GetModuleConstant("Blender.Object.Pose", "ROT")){
- numeric_value |= POSE_ROT;
- }else if (item == EXPP_GetModuleConstant("Blender.Object.Pose", "LOC")){
- numeric_value |= POSE_LOC;
- }else if (item == EXPP_GetModuleConstant("Blender.Object.Pose", "SIZE")){
- numeric_value |= POSE_SIZE;
- }else{
- Py_DECREF(item);
- self->posechannel->flag = (short)oldflag;
- goto AttributeError4;
- }
- Py_DECREF(item);
- }
- self->posechannel->flag = (short)numeric_value;
- }else if (BPy_Constant_Check(constants)){
- if (constants == EXPP_GetModuleConstant("Blender.Object.Pose", "ROT")){
- numeric_value |= POSE_ROT;
- }else if (constants == EXPP_GetModuleConstant("Blender.Object.Pose", "LOC")){
- numeric_value |= POSE_LOC;
- }else if (constants == EXPP_GetModuleConstant("Blender.Object.Pose", "SIZE")){
- numeric_value |= POSE_SIZE;
- }else{
- self->posechannel->flag = (short)oldflag;
- goto AttributeError4;
- }
- self->posechannel->flag = (short)numeric_value;
- }else{
- goto AttributeError3;
- }
- }else{ //nothing passed so set them all
- self->posechannel->flag |= POSE_ROT;
- self->posechannel->flag |= POSE_LOC;
- self->posechannel->flag |= POSE_SIZE;
- }
-
- //set the frame we want insertion on
- oldframe = G.scene->r.cfra;
- G.scene->r.cfra = frame;
-
- //add the action channel if it's not there
- verify_action_channel(((BPy_Object*)parent_object)->object->action,
- self->posechannel->name);
-
- //insert the pose keys
- if (self->posechannel->flag & POSE_ROT){
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_QUAT_X, no_ipo_update);
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_QUAT_Y, no_ipo_update);
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_QUAT_Z, no_ipo_update);
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_QUAT_W, no_ipo_update);
- }
- if (self->posechannel->flag & POSE_LOC){
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_LOC_X, no_ipo_update);
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_LOC_Y, no_ipo_update);
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_LOC_Z, no_ipo_update);
- }
- if (self->posechannel->flag & POSE_SIZE){
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_SIZE_X, no_ipo_update);
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_SIZE_Y, no_ipo_update);
- insertkey(&((BPy_Object*)parent_object)->object->id,
- ID_PO, self->posechannel->name, NULL, AC_SIZE_Z, no_ipo_update);
- }
-
- //flip the frame back
- G.scene->r.cfra = oldframe;
-
- //update the IPOs
- if (no_ipo_update==0)
- remake_action_ipos (((BPy_Object*)parent_object)->object->action);
-
- Py_RETURN_NONE;
-
-AttributeError:
- return EXPP_objError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".insertKey: ", "expects an Object, int, (optional) constants");
-AttributeError2:
- return EXPP_objError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".insertKey: ", "wrong object detected. \
- Use the object this pose came from");
-AttributeError3:
- return EXPP_objError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".insertKey: ", "Expects a constant or list of constants");
-AttributeError4:
- return EXPP_objError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".insertKey: ", "Please use a constant defined in the Pose module");
-AttributeError5:
- return EXPP_objError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".insertKey: ", "You must set up and link an Action to this object first");
-}
-//------------------------tp_methods
-//This contains a list of all methods the object contains
-static PyMethodDef BPy_PoseBone_methods[] = {
- {"insertKey", (PyCFunction) PoseBone_insertKey, METH_VARARGS,
- "() - insert a key for this pose into an action"},
- {NULL, NULL, 0, NULL}
-};
-//------------------ATTRIBUTE IMPLEMENTATIONS---------------------------
-//------------------------PoseBone.name (getter)
-//Gets the name attribute
-static PyObject *PoseBone_getName(BPy_PoseBone *self, void *closure)
-{
- return PyString_FromString(self->posechannel->name);
-}
-//------------------------PoseBone.name (setter)
-//Sets the name attribute
-static int PoseBone_setName(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- char *name = "";
-
- if (!PyArg_Parse(value, "s", &name))
- goto AttributeError;
-
- BLI_strncpy(self->posechannel->name, name, 32);
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".name: ", "expects a string");
-}
-//------------------------PoseBone.loc (getter)
-//Gets the loc attribute
-static PyObject *PoseBone_getLoc(BPy_PoseBone *self, void *closure)
-{
- return newVectorObject(self->posechannel->loc, 3, Py_WRAP);
-}
-//------------------------PoseBone.loc (setter)
-//Sets the loc attribute
-static int PoseBone_setLoc(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- VectorObject *vec = NULL;
- int x;
-
- if (!PyArg_Parse(value, "O!", &vector_Type, &vec))
- goto AttributeError;
- if (vec->size != 3)
- goto AttributeError;
-
- for (x = 0; x < 3; x++){
- self->posechannel->loc[x] = vec->vec[x];
- }
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".loc: ", "expects a 3d vector object");
-}
-//------------------------PoseBone.size (getter)
-//Gets the size attribute
-static PyObject *PoseBone_getSize(BPy_PoseBone *self, void *closure)
-{
- return newVectorObject(self->posechannel->size, 3, Py_WRAP);
-}
-//------------------------PoseBone.size (setter)
-//Sets the size attribute
-static int PoseBone_setSize(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- VectorObject *vec = NULL;
- int x;
-
- if (!PyArg_Parse(value, "O!", &vector_Type, &vec))
- goto AttributeError;
- if (vec->size != 3)
- goto AttributeError;
-
- for (x = 0; x < 3; x++){
- self->posechannel->size[x] = vec->vec[x];
- }
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".size: ", "expects a 3d vector object");
-}
-//------------------------PoseBone.quat (getter)
-//Gets the quat attribute
-static PyObject *PoseBone_getQuat(BPy_PoseBone *self, void *closure)
-{
- return newQuaternionObject(self->posechannel->quat, Py_WRAP);
-}
-//------------------------PoseBone.quat (setter)
-//Sets the quat attribute
-static int PoseBone_setQuat(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- QuaternionObject *quat = NULL;
- int x;
-
- if (!PyArg_Parse(value, "O!", &quaternion_Type, &quat))
- goto AttributeError;
-
- for (x = 0; x < 4; x++){
- self->posechannel->quat[x] = quat->quat[x];
- }
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".quat: ", "expects a quaternion object");
-}
-//------------------------PoseBone.localMatrix (getter)
-//Gets the chan_mat
-static PyObject *PoseBone_getLocalMatrix(BPy_PoseBone *self, void *closure)
-{
- return newMatrixObject((float*)self->posechannel->chan_mat, 4, 4, Py_WRAP);
-}
-//------------------------PoseBone.localMatrix (setter)
-//Sets the chan_mat
-static int PoseBone_setLocalMatrix(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- MatrixObject *matrix = NULL;
- float size[3], quat[4], loc[3];
- float mat3[3][3], mat4[4][4];
- int matsize = 0;
-
- if (!PyArg_Parse(value, "O!", &matrix_Type, &matrix))
- goto AttributeError;
-
- if (matrix->rowSize == 3 && matrix->colSize == 3){
- matsize = 3;
- Mat3CpyMat3(mat3, (float(*)[3])*matrix->matrix);
- }else if (matrix->rowSize == 4 && matrix->colSize == 4){
- matsize = 4;
- Mat4CpyMat4(mat4, (float(*)[4])*matrix->matrix);
- }
-
- if (matsize != 3 && matsize != 4){
- goto AttributeError;
- }
-
- //get size and rotation
- if (matsize == 3){
- Mat3ToSize(mat3, size);
- Mat3Ortho(mat3);
- Mat3ToQuat(mat3, quat);
- }else if (matsize == 4){
- Mat4ToSize(mat4, size);
- Mat4Ortho(mat4);
- Mat4ToQuat(mat4, quat);
- }
-
- //get loc
- if (matsize == 4) {
- VECCOPY(loc, matrix->matrix[3]);
- }
- else {
- loc[0]= loc[1]= loc[2]= 0.0f;
- }
-
- //copy new attributes
- VECCOPY(self->posechannel->size, size);
- QUATCOPY(self->posechannel->quat, quat);
- if (matsize == 4){
- VECCOPY(self->posechannel->loc, loc);
- }
-
- //rebuild matrix
- chan_calc_mat(self->posechannel);
- return 0;
-
-AttributeError:
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".localMatrix: ", "expects a 3x3 or 4x4 matrix object");
-}
-//------------------------PoseBone.poseMatrix (getter)
-//Gets the pose_mat
-static PyObject *PoseBone_getPoseMatrix(BPy_PoseBone *self, void *closure)
-{
- return newMatrixObject((float*)self->posechannel->pose_mat, 4, 4, Py_WRAP);
-}
-//------------------------PoseBone.poseMatrix (setter)
-//Sets the pose_mat
-static int PoseBone_setPoseMatrix(BPy_PoseBone *self, MatrixObject *value, void *closure)
-{
- float delta_mat[4][4], quat[4]; /* rotation */
- float size[4]; /* size only */
-
- if( !MatrixObject_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected matrix object as argument" );
-
- if( value->colSize != 4 || value->rowSize != 4 )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "matrix must be a 4x4 transformation matrix\n"
- "for example as returned by object.matrixWorld" );
-
- /* get bone-space cursor matrix and extract location */
- armature_mat_pose_to_bone(self->posechannel, (float (*)[4]) *value->matrix, delta_mat);
-
- /* Visual Location */
- VECCOPY(self->posechannel->loc, delta_mat[3]);
-
- /* Visual Size */
- Mat4ToSize(delta_mat, size);
- VECCOPY(self->posechannel->size, size);
-
- /* Visual Rotation */
- Mat4ToQuat(delta_mat, quat);
- QUATCOPY(self->posechannel->quat, quat);
-
- return 0;
-}
-//------------------------PoseBone.constraints (getter)
-//Gets the constraints sequence
-static PyObject *PoseBone_getConstraints(BPy_PoseBone *self, void *closure)
-{
- return PoseConstraintSeq_CreatePyObject( self->posechannel );
-}
-//------------------------PoseBone.limitmin (getter)
-//Gets the pose bone limitmin value
-static PyObject *PoseBone_getLimitMin(BPy_PoseBone *self, void *closure)
-{
- float mylimitmin[3];
- Object *obj = NULL;
-
- obj = Object_FromPoseChannel(self->posechannel);
- if (obj==NULL){
- return EXPP_ReturnPyObjError(PyExc_AttributeError, "Bone data is not found");
- }
- mylimitmin[0]=0.0f;
- mylimitmin[1]=0.0f;
- mylimitmin[2]=0.0f;
- if(pose_channel_in_IK_chain(obj, self->posechannel)){
- if ((self->posechannel->ikflag & BONE_IK_NO_XDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_XLIMIT)) {
- mylimitmin[0] = self->posechannel->limitmin[0];
- }
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_YDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_YLIMIT)) {
- mylimitmin[1] = self->posechannel->limitmin[1];
- }
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_ZDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_ZLIMIT)) {
- mylimitmin[2] = self->posechannel->limitmin[2];
- }
- }
- }
- return newVectorObject(mylimitmin, 3, Py_NEW);
-}
-//------------------------PoseBone.limitmin (setter)
-//Sets the pose bone limitmin value
-static int PoseBone_setLimitMin(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- float newlimitmin[3];
- int x;
- Object *obj = NULL;
- if(!PySequence_Check(value)){
- return EXPP_ReturnIntError(PyExc_AttributeError, "Argument is not a sequence");
- }
- if (PySequence_Size(value) !=3){
- return EXPP_ReturnIntError(PyExc_AttributeError, "Argument size must be 3");
- }
- newlimitmin[0]=0.0f;
- newlimitmin[1]=0.0f;
- newlimitmin[2]=0.0f;
- for (x = 0; x<3;x++){
- PyObject *item;
- item = PySequence_GetItem(value, x); //new reference
- if (PyFloat_Check(item)){
- newlimitmin[x] = (float)PyFloat_AsDouble(item);
- }else if (PyInt_Check(item)){
- newlimitmin[x] = (float)PyInt_AsLong(item);
- }
- Py_DECREF(item);
- }
- obj = Object_FromPoseChannel(self->posechannel);
- if (obj==NULL){
- return EXPP_ReturnIntError(PyExc_AttributeError, "Bone data is not found");
- }
- if(!pose_channel_in_IK_chain(obj, self->posechannel)){
- return EXPP_ReturnIntError(PyExc_AttributeError, "Bone is not part of an IK chain");
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_XDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_XLIMIT)) {
- self->posechannel->limitmin[0] = EXPP_ClampFloat(newlimitmin[0], -180.0f, 0.0f);
- }
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_YDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_YLIMIT)) {
- self->posechannel->limitmin[1] = EXPP_ClampFloat(newlimitmin[1], -180.0f, 0.0f);
- }
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_ZDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_ZLIMIT)) {
- self->posechannel->limitmin[2] = EXPP_ClampFloat(newlimitmin[2], -180.0f, 0.0f);
- }
- }
- DAG_object_flush_update(G.scene, obj, OB_RECALC_DATA);
- return 0;
-}
-
-//------------------------PoseBone.limitmax (getter)
-//Gets the pose bone limitmax value
-static PyObject *PoseBone_getLimitMax(BPy_PoseBone *self, void *closure)
-{
- float mylimitmax[3];
- Object *obj = NULL;
-
- obj = Object_FromPoseChannel(self->posechannel);
- if (obj==NULL){
- return EXPP_ReturnPyObjError(PyExc_AttributeError, "Bone data is not found");
- }
- mylimitmax[0]=0.0f;
- mylimitmax[1]=0.0f;
- mylimitmax[2]=0.0f;
- if(pose_channel_in_IK_chain(obj, self->posechannel)){
- if ((self->posechannel->ikflag & BONE_IK_NO_XDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_XLIMIT)) {
- mylimitmax[0] = self->posechannel->limitmax[0];
- }
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_YDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_YLIMIT)) {
- mylimitmax[1] = self->posechannel->limitmax[1];
- }
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_ZDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_ZLIMIT)) {
- mylimitmax[2] = self->posechannel->limitmax[2];
- }
- }
- }
- return newVectorObject(mylimitmax, 3, Py_NEW);
-}
-//------------------------PoseBone.limitmax (setter)
-//Sets the pose bone limitmax value
-static int PoseBone_setLimitMax(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- float newlimitmax[3];
- int x;
- Object *obj = NULL;
- if(!PySequence_Check(value)){
- return EXPP_ReturnIntError(PyExc_AttributeError, "Argument is not a sequence");
- }
- if (PySequence_Size(value) !=3){
- return EXPP_ReturnIntError(PyExc_AttributeError, "Argument size must be 3");
- }
- newlimitmax[0]=0.0f;
- newlimitmax[1]=0.0f;
- newlimitmax[2]=0.0f;
- for (x = 0; x<3;x++){
- PyObject *item;
- item = PySequence_GetItem(value, x); //new reference
- if (PyFloat_Check(item)){
- newlimitmax[x] = (float)PyFloat_AsDouble(item);
- }else if (PyInt_Check(item)){
- newlimitmax[x] = (float)PyInt_AsLong(item);
- }
- Py_DECREF(item);
- }
- obj = Object_FromPoseChannel(self->posechannel);
- if (obj==NULL){
- return EXPP_ReturnIntError(PyExc_AttributeError, "Bone data is not found");
- }
- if(!pose_channel_in_IK_chain(obj, self->posechannel)){
- return EXPP_ReturnIntError(PyExc_AttributeError, "Bone is not part of an IK chain");
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_XDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_XLIMIT)) {
- self->posechannel->limitmax[0] = EXPP_ClampFloat(newlimitmax[0], 0.0f, 180.0f);
- }
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_YDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_YLIMIT)) {
- self->posechannel->limitmax[1] = EXPP_ClampFloat(newlimitmax[1], 0.0f, 180.0f);
- }
- }
- if ((self->posechannel->ikflag & BONE_IK_NO_ZDOF)==0) {
- if ((self->posechannel->ikflag & BONE_IK_ZLIMIT)) {
- self->posechannel->limitmax[2] = EXPP_ClampFloat(newlimitmax[2], 0.0f, 180.0f);
- }
- }
- DAG_object_flush_update(G.scene, obj, OB_RECALC_DATA);
- return 0;
-}
-//------------------------PoseBone.head (getter)
-//Gets the pose head position
-static PyObject *PoseBone_getHead(BPy_PoseBone *self, void *closure)
-{
- return newVectorObject(self->posechannel->pose_head, 3, Py_NEW);
-}
-//------------------------PoseBone.head (setter)
-//Sets the pose head position
-static int PoseBone_setHead(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".head: ", "not able to set this property");
-}
-//------------------------PoseBone.tail (getter)
-//Gets the pose tail position
-static PyObject *PoseBone_getTail(BPy_PoseBone *self, void *closure)
-{
- return newVectorObject(self->posechannel->pose_tail, 3, Py_NEW);
-}
-//------------------------PoseBone.tail (setter)
-//Sets the pose tail position
-static int PoseBone_setTail(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- return EXPP_intError(PyExc_AttributeError, "%s%s%s",
- sPoseBoneError, ".tail: ", "not able to set this property");
-}
-//------------------------PoseBone.sel (getter)
-//Gets the pose bones selection
-static PyObject *PoseBone_getSelect(BPy_PoseBone *self, void *closure)
-{
- if (self->posechannel->bone->flag & BONE_SELECTED)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-//------------------------PoseBone.sel (setter)
-//Sets the pose bones selection
-static int PoseBone_setSelect(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- int param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if ( param )
- self->posechannel->bone->flag |= BONE_SELECTED;
- else
- self->posechannel->bone->flag &= ~(BONE_SELECTED | BONE_ACTIVE);
- return 0;
-}
-
-
-//------------------------PoseBone.parent (getter)
-//Gets the bones parent if any
-static PyObject *PoseBone_getParent(BPy_PoseBone *self, void *closure)
-{
- if (self->posechannel->parent)
- return PyPoseBone_FromPosechannel(self->posechannel->parent);
- else
- Py_RETURN_NONE;
-}
-
-//------------------------PoseBone.displayObject (getter)
-//Gets the pose bones object used for display
-static PyObject *PoseBone_getDisplayObject(BPy_PoseBone *self, void *closure)
-{
- if (self->posechannel->custom)
- return Object_CreatePyObject(self->posechannel->custom);
- else
- Py_RETURN_NONE;
-}
-
-//------------------------PoseBone.displayObject (setter)
-//Sets the pose bones object used for display
-static int PoseBone_setDisplayObject(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- return GenericLib_assignData(value, (void **) &self->posechannel->custom, 0, 0, ID_OB, 0);
-}
-
-//------------------------PoseBone.hasIK (getter)
-//Returns True/False if the bone has IK's
-static PyObject *PoseBone_hasIK(BPy_PoseBone *self, void *closure)
-{
- Object *obj = NULL;
-
- obj = Object_FromPoseChannel(self->posechannel);
- if (obj==NULL)
- Py_RETURN_FALSE;
-
- if( pose_channel_in_IK_chain(obj, self->posechannel) )
- Py_RETURN_TRUE;
-
- Py_RETURN_FALSE;
-}
-
-//------------------------PoseBone.stretch (getter)
-//Gets the pose bones IK Stretch value
-static PyObject *PoseBone_getStretch(BPy_PoseBone *self, void *closure)
-{
- return PyFloat_FromDouble( self->posechannel->ikstretch );
-}
-
-//------------------------PoseBone.stretch (setter)
-//Sets the pose bones IK Stretch value
-static int PoseBone_setStretch(BPy_PoseBone *self, PyObject *value, void *closure)
-{
- float ikstretch;
-
- if( !PyNumber_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
-
- ikstretch = (float)PyFloat_AsDouble(value);
- if (ikstretch<0) ikstretch = 0.0;
- if (ikstretch>1) ikstretch = 1.0;
- self->posechannel->ikstretch = ikstretch;
- return 0;
-}
-
-//------------------------PoseBone.stiffX/Y/Z (getter)
-//Gets the pose bones IK stiffness
-static PyObject *PoseBone_getStiff(BPy_PoseBone *self, void *axis)
-{
- return PyFloat_FromDouble( self->posechannel->stiffness[(int)axis] );
-}
-
-//------------------------PoseBone.stiffX/Y/Z (setter)
-//Sets the pose bones IK stiffness
-static int PoseBone_setStiff(BPy_PoseBone *self, PyObject *value, void *axis)
-{
- float stiff;
-
- if( !PyNumber_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
-
- stiff = (float)PyFloat_AsDouble(value);
- if (stiff<0) stiff = 0;
- if (stiff>0.990) stiff = 0.990f;
- self->posechannel->stiffness[(int)axis] = stiff;
- return 0;
-}
-
-//------------------------PoseBone.* (getter)
-//Gets the pose bones flag
-/*
-static PyObject *PoseBone_getFlag(BPy_PoseBone *self, void *flag)
-{
- if (self->posechannel->flag & (int)flag)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-
-}
-*/
-
-//------------------------PoseBone.* (setter)
-//Gets the pose bones flag
-/*
-static int PoseBone_setFlag(BPy_PoseBone *self, PyObject *value, void *flag)
-{
- if ( PyObject_IsTrue(value) )
- self->posechannel->flag |= (int)flag;
- else
- self->posechannel->flag &= ~(int)flag;
- return 0;
-}
-*/
-
-//------------------------PoseBone.* (getter)
-//Gets the pose bones ikflag
-static PyObject *PoseBone_getIKFlag(BPy_PoseBone *self, void *flag)
-{
- if (self->posechannel->ikflag & (int)flag)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-
-}
-
-//------------------------PoseBone.* (setter)
-//Sets the pose bones ikflag
-static int PoseBone_setIKFlag(BPy_PoseBone *self, PyObject *value, void *flag)
-{
- int param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if ( param )
- self->posechannel->ikflag |= (int)flag;
- else
- self->posechannel->ikflag &= ~(int)flag;
- return 0;
-}
-
-//------------------------Bone.layerMask (get)
-static PyObject *PoseBone_getLayerMask(BPy_PoseBone *self)
-{
- /* do this extra stuff because the short's bits can be negative values */
- unsigned short laymask = 0;
- laymask |= self->posechannel->bone->layer;
- return PyInt_FromLong((int)laymask);
-}
-//------------------------Bone.layerMask (set)
-static int PoseBone_setLayerMask(BPy_PoseBone *self, PyObject *value)
-{
- int laymask;
- if (!PyInt_Check(value)) {
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected an integer (bitmask) as argument" );
- }
-
- laymask = PyInt_AsLong(value);
-
- if (laymask <= 0 || laymask > (1<<16) - 1)
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "bitmask must have from 1 up to 16 bits set");
-
- self->posechannel->bone->layer = 0;
- self->posechannel->bone->layer |= laymask;
-
- return 0;
-}
-
-//------------------TYPE_OBECT IMPLEMENTATION---------------------------
-//------------------------tp_getset
-//This contains methods for attributes that require checking
-static PyGetSetDef BPy_PoseBone_getset[] = {
- {"name", (getter)PoseBone_getName, (setter)PoseBone_setName,
- "The pose bone's name", NULL},
- {"loc", (getter)PoseBone_getLoc, (setter)PoseBone_setLoc,
- "The pose bone's change in location as a vector", NULL},
- {"size", (getter)PoseBone_getSize, (setter)PoseBone_setSize,
- "The pose bone's change in size as a vector", NULL},
- {"quat", (getter)PoseBone_getQuat, (setter)PoseBone_setQuat,
- "The pose bone's change in rotation as a quat", NULL},
- {"localMatrix", (getter)PoseBone_getLocalMatrix, (setter)PoseBone_setLocalMatrix,
- "The pose bone's change matrix built from the quat, loc, and size", NULL},
- {"poseMatrix", (getter)PoseBone_getPoseMatrix, (setter)PoseBone_setPoseMatrix,
- "The pose bone's matrix", NULL},
- {"head", (getter)PoseBone_getHead, (setter)PoseBone_setHead,
- "The pose bone's head positon", NULL},
- {"tail", (getter)PoseBone_getTail, (setter)PoseBone_setTail,
- "The pose bone's tail positon", NULL},
- {"sel", (getter)PoseBone_getSelect, (setter)PoseBone_setSelect,
- "The pose selection state", NULL},
- {"limitMin", (getter)PoseBone_getLimitMin, (setter)PoseBone_setLimitMin,
- "The pose bone dof min", NULL},
- {"limitMax", (getter)PoseBone_getLimitMax, (setter)PoseBone_setLimitMax,
- "The pose bone dof max", NULL},
- {"constraints", (getter)PoseBone_getConstraints, (setter)NULL,
- "The list of contraints that pertain to this pose bone", NULL},
- {"parent", (getter)PoseBone_getParent, (setter)NULL,
- "The bones parent (read only for posebones)", NULL},
- {"displayObject", (getter)PoseBone_getDisplayObject, (setter)PoseBone_setDisplayObject,
- "The poseMode object to draw in place of this bone", NULL},
-
- {"hasIK", (getter)PoseBone_hasIK, (setter)NULL,
- "True if the pose bone has IK (readonly)", NULL },
-
- {"stretch", (getter)PoseBone_getStretch, (setter)PoseBone_setStretch,
- "Stretch the bone to the IK Target", NULL },
-
- {"stiffX", (getter)PoseBone_getStiff, (setter)PoseBone_setStiff,
- "bones stiffness on the X axis", (void *)0 },
- {"stiffY", (getter)PoseBone_getStiff, (setter)PoseBone_setStiff,
- "bones stiffness on the Y axis", (void *)1 },
- {"stiffZ", (getter)PoseBone_getStiff, (setter)PoseBone_setStiff,
- "bones stiffness on the Z axis", (void *)2 },
-
- {"limitX", (getter)PoseBone_getIKFlag, (setter)PoseBone_setIKFlag,
- "limit rotation over X axis when part of an IK", (void *)BONE_IK_XLIMIT },
- {"limitY", (getter)PoseBone_getIKFlag, (setter)PoseBone_setIKFlag,
- "limit rotation over Y axis when part of an IK", (void *)BONE_IK_YLIMIT },
- {"limitZ", (getter)PoseBone_getIKFlag, (setter)PoseBone_setIKFlag,
- "limit rotation over Z axis when part of an IK", (void *)BONE_IK_ZLIMIT },
-
- {"lockXRot", (getter)PoseBone_getIKFlag, (setter)PoseBone_setIKFlag,
- "disable X DoF when part of an IK", (void *)BONE_IK_NO_XDOF },
- {"lockYRot", (getter)PoseBone_getIKFlag, (setter)PoseBone_setIKFlag,
- "disable Y DoF when part of an IK", (void *)BONE_IK_NO_YDOF },
- {"lockZRot", (getter)PoseBone_getIKFlag, (setter)PoseBone_setIKFlag,
- "disable Z DoF when part of an IK", (void *)BONE_IK_NO_ZDOF },
- {"layerMask", (getter)PoseBone_getLayerMask, (setter)PoseBone_setLayerMask,
- "Layer bitmask", NULL },
- {NULL, NULL, NULL, NULL, NULL}
-};
-//------------------------tp_dealloc
-//This tells how to 'tear-down' our object when ref count hits 0
-static void PoseBone_dealloc(BPy_PoseBone *self)
-{
- PoseBone_Type.tp_free(self);
- return;
-}
-//------------------------tp_repr
-//This is the string representation of the object
-static PyObject *PoseBone_repr(BPy_PoseBone *self)
-{
- return PyString_FromFormat( "[PoseBone \"%s\"]", self->posechannel->name);
-}
-//------------------------tp_doc
-//The __doc__ string for this object
-static char BPy_PoseBone_doc[] = "This object wraps a Blender PoseBone object.";
-
-//------------------TYPE_OBECT DEFINITION--------------------------
-PyTypeObject PoseBone_Type = {
- PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "PoseBone", //tp_name
- sizeof(BPy_PoseBone), //tp_basicsize
- 0, //tp_itemsize
- (destructor)PoseBone_dealloc, //tp_dealloc
- 0, //tp_print
- 0, //tp_getattr
- 0, //tp_setattr
- 0, //tp_compare
- (reprfunc)PoseBone_repr, //tp_repr
- 0, //tp_as_number
- 0, //tp_as_sequence
- 0, //tp_as_mapping
- 0, //tp_hash
- 0, //tp_call
- 0, //tp_str
- 0, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
- BPy_PoseBone_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- 0, //tp_richcompare
- 0, //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- BPy_PoseBone_methods, //tp_methods
- 0, //tp_members
- BPy_PoseBone_getset, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- 0, //tp_init
- 0, //tp_alloc
- 0, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-//-------------------MODULE METHODS IMPLEMENTATION------------------------
-//-------------------MODULE METHODS DEFINITION-----------------------------
-struct PyMethodDef M_Pose_methods[] = {
- {NULL, NULL, 0, NULL}
-};
-//-------------------MODULE INITIALIZATION--------------------------------
-PyObject *Pose_Init(void)
-{
- PyObject *module;
-
- //Initializes TypeObject.ob_type
- if (PyType_Ready(&Pose_Type) < 0 || PyType_Ready(&PoseBone_Type) < 0 ||
- PyType_Ready(&PoseBonesDict_Type) < 0) {
- Py_RETURN_NONE;
- }
-
- //Register the module
- module = Py_InitModule3("Blender.Object.Pose", M_Pose_methods,
- "The Blender Pose module");
-
- //Add TYPEOBJECTS to the module
- PyModule_AddObject(module, "Pose",
- EXPP_incr_ret((PyObject *)&Pose_Type)); //*steals*
- PyModule_AddObject(module, "PoseBone",
- EXPP_incr_ret((PyObject *)&PoseBone_Type)); //*steals*
-
- //Add CONSTANTS to the module
- PyModule_AddObject(module, "ROT",
- PyConstant_NewInt("ROT", POSE_ROT));
- PyModule_AddObject(module, "LOC",
- PyConstant_NewInt("LOC", POSE_LOC));
- PyModule_AddObject(module, "SIZE",
- PyConstant_NewInt("SIZE", POSE_SIZE));
-
- return module;
-}
-//------------------VISIBLE PROTOTYPE IMPLEMENTATION-----------------------
-//------------------------------PyPose_FromPose (internal)
-//Returns a PyPose from a bPose - return PyNone if bPose is NULL
-PyObject *PyPose_FromPose(bPose *pose, char *name)
-{
- BPy_Pose *py_pose = NULL;
-
- if (pose){
- py_pose = (BPy_Pose*)Pose_Type.tp_alloc(&Pose_Type, 0);
- if (!py_pose)
- goto RuntimeError;
-
- py_pose->pose = pose;
- BLI_strncpy(py_pose->name, name, 24);
-
- //create armature.bones
- py_pose->Bones = (BPy_PoseBonesDict*)PyPoseBonesDict_FromPyPose(py_pose);
- if (!py_pose->Bones)
- goto RuntimeError;
-
- return (PyObject*)py_pose;
- }else{
- Py_RETURN_NONE;
- }
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sPoseError, "PyPose_FromPose: ", "Internal Error Ocurred");
-}
-//------------------------------PyPoseBone_FromPosechannel (internal)
-//Returns a PyPoseBone from a bPoseChannel - return PyNone if bPoseChannel is NULL
-PyObject *PyPoseBone_FromPosechannel(bPoseChannel *pchan)
-{
- BPy_PoseBone *py_posechannel = NULL;
-
- if (pchan){
- py_posechannel = (BPy_PoseBone*)PoseBone_Type.tp_alloc(&PoseBone_Type, 0);
- if (!py_posechannel)
- goto RuntimeError;
- py_posechannel->posechannel = pchan;
- return (PyObject*)py_posechannel;
- }else{
- Py_RETURN_NONE;
- }
-
-RuntimeError:
- return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sPoseBoneError, "PyPoseBone_FromPosechannel: ", "Internal Error Ocurred");
-}
-//------------------------------Object_FromPoseChannel (internal)
-//An ugly method for determining where the pchan chame from
-Object *Object_FromPoseChannel(bPoseChannel *curr_pchan)
-{
- int success = 0;
- Object *obj = NULL;
- bPoseChannel *pchan = NULL;
- for(obj = G.main->object.first; obj; obj = obj->id.next){
- if (obj->pose){
- for (pchan = obj->pose->chanbase.first; pchan; pchan = pchan->next){
- if (curr_pchan == pchan){
- success = 1;
- break;
- }
- }
- if (success)
- break;
- }
- }
- return obj;
-}
diff --git a/source/blender/python/api2_2x/Pose.h b/source/blender/python/api2_2x/Pose.h
deleted file mode 100644
index 17a9f871ee3..00000000000
--- a/source/blender/python/api2_2x/Pose.h
+++ /dev/null
@@ -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
diff --git a/source/blender/python/api2_2x/Registry.c b/source/blender/python/api2_2x/Registry.c
deleted file mode 100644
index 4eb4fd93294..00000000000
--- a/source/blender/python/api2_2x/Registry.c
+++ /dev/null
@@ -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;
-}
diff --git a/source/blender/python/api2_2x/Registry.h b/source/blender/python/api2_2x/Registry.h
deleted file mode 100644
index 58cfe65dfd0..00000000000
--- a/source/blender/python/api2_2x/Registry.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c
deleted file mode 100644
index 397cee0ad5e..00000000000
--- a/source/blender/python/api2_2x/Scene.c
+++ /dev/null
@@ -1,1868 +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, Jacques Guignot, Joseph Gilbert,
- * Campbell Barton, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-struct View3D;
-
-#include "Scene.h" /*This must come first */
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "MEM_guardedalloc.h" /* for MEM_callocN */
-#include "DNA_space_types.h" /* SPACE_VIEW3D, SPACE_SEQ */
-#include "DNA_screen_types.h"
-#include "DNA_userdef_types.h" /* U.userdefs */
-#include "DNA_object_types.h" /* SceneObSeq_new */
-#include "BKE_depsgraph.h"
-#include "BKE_library.h"
-#include "BKE_object.h"
-#include "BKE_scene.h"
-#include "BKE_font.h"
-#include "BKE_idprop.h"
-#include "BLI_blenlib.h" /* only for SceneObSeq_new */
-#include "BSE_drawview.h" /* for play_anim */
-#include "BSE_headerbuttons.h" /* for copy_scene */
-#include "BSE_sequence.h" /* to clear_scene_in_allseqs */
-#include "BSE_node.h" /* to clear_scene_in_nodes */
-#include "BIF_drawscene.h" /* for set_scene */
-#include "BIF_space.h" /* for copy_view3d_lock() */
-#include "BIF_screen.h" /* curarea */
-#include "BDR_editobject.h" /* free_and_unlink_base() */
-#include "mydevice.h" /* for #define REDRAW */
-#include "DNA_view3d_types.h"
-
-/* python types */
-#include "Object.h"
-#include "Camera.h"
-/* only for SceneObSeq_new */
-#include "BKE_material.h"
-#include "BLI_arithb.h"
-#include "Armature.h"
-#include "Lamp.h"
-#include "Curve.h"
-#include "NMesh.h"
-#include "Mesh.h"
-#include "World.h"
-#include "Lattice.h"
-#include "Metaball.h"
-#include "IDProp.h"
-#include "Text3d.h"
-#include "Library.h"
-
-#include "gen_utils.h"
-#include "gen_library.h"
-#include "sceneRender.h"
-#include "sceneRadio.h"
-#include "sceneTimeLine.h"
-#include "sceneSequence.h"
-
-
-#include "BKE_utildefines.h" /* vec copy */
-#include "vector.h"
-
-PyObject *M_Object_Get( PyObject * self, PyObject * args ); /* from Object.c */
-
-/* checks for the scene being removed */
-#define SCENE_DEL_CHECK_PY(bpy_scene) if (!(bpy_scene->scene)) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "Scene has been removed" ) )
-#define SCENE_DEL_CHECK_INT(bpy_scene) if (!(bpy_scene->scene)) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "Scene has been removed" ) )
-
-
-enum obj_consts {
- EXPP_OBSEQ_NORMAL = 0,
- EXPP_OBSEQ_SELECTED,
- EXPP_OBSEQ_CONTEXT
-};
-
-
-/*-----------------------Python API function prototypes for the Scene module--*/
-static PyObject *M_Scene_New( PyObject * self, PyObject * args,
- PyObject * keywords );
-static PyObject *M_Scene_Get( PyObject * self, PyObject * args );
-static PyObject *M_Scene_GetCurrent( PyObject * self );
-static PyObject *M_Scene_getCurrent_deprecated( PyObject * self );
-static PyObject *M_Scene_Unlink( PyObject * self, PyObject * arg );
-/*-----------------------Scene module doc strings-----------------------------*/
-static char M_Scene_doc[] = "The Blender.Scene submodule";
-static char M_Scene_New_doc[] =
- "(name = 'Scene') - Create a new Scene called 'name' in Blender.";
-static char M_Scene_Get_doc[] =
- "(name = None) - Return the scene called 'name'. If 'name' is None, return a list with all Scenes.";
-static char M_Scene_GetCurrent_doc[] =
- "() - Return the currently active Scene in Blender.";
-static char M_Scene_Unlink_doc[] =
- "(scene) - Unlink (delete) scene 'Scene' from Blender. (scene) is of type Blender scene.";
-/*----------------------Scene module method def----------------------------*/
-struct PyMethodDef M_Scene_methods[] = {
- {"New", ( PyCFunction ) M_Scene_New, METH_VARARGS | METH_KEYWORDS,
- M_Scene_New_doc},
- {"Get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc},
- {"get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc},
- {"GetCurrent", ( PyCFunction ) M_Scene_GetCurrent,
- METH_NOARGS, M_Scene_GetCurrent_doc},
- {"getCurrent", ( PyCFunction ) M_Scene_getCurrent_deprecated,
- METH_NOARGS, M_Scene_GetCurrent_doc},
- {"Unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc},
- {"unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc},
- {NULL, NULL, 0, NULL}
-};
-/*-----------------------BPy_Scene method declarations--------------------*/
-static PyObject *Scene_getLayerList( BPy_Scene * self );
-static PyObject *Scene_oldsetLayers( BPy_Scene * self, PyObject * arg );
-static PyObject *Scene_copy( BPy_Scene * self, PyObject * arg );
-static PyObject *Scene_makeCurrent( BPy_Scene * self );
-static PyObject *Scene_update( BPy_Scene * self, PyObject * args );
-static PyObject *Scene_link( BPy_Scene * self, PyObject * args );
-static PyObject *Scene_unlink( BPy_Scene * self, PyObject * args );
-static PyObject *Scene_getChildren( BPy_Scene * self );
-static PyObject *Scene_getActiveObject(BPy_Scene *self);
-static PyObject *Scene_getCurrentCamera( BPy_Scene * self );
-static PyObject *Scene_setCurrentCamera( BPy_Scene * self, PyObject * args );
-static PyObject *Scene_getRenderingContext( BPy_Scene * self );
-static PyObject *Scene_getRadiosityContext( BPy_Scene * self );
-static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * value );
-static PyObject *Scene_getSequence( BPy_Scene * self );
-static PyObject *Scene_addScriptLink( BPy_Scene * self, PyObject * args );
-static PyObject *Scene_clearScriptLinks( BPy_Scene * self, PyObject * args );
-static PyObject *Scene_play( BPy_Scene * self, PyObject * args );
-static PyObject *Scene_getTimeLine( BPy_Scene * self );
-
-
-/*internal*/
-static int Scene_compare( BPy_Scene * a, BPy_Scene * b );
-static PyObject *Scene_repr( BPy_Scene * self );
-
-/*object seq*/
-static PyObject *SceneObSeq_CreatePyObject( BPy_Scene *self, Base *iter, int mode);
-
-/*-----------------------BPy_Scene method def------------------------------*/
-static PyMethodDef BPy_Scene_methods[] = {
- /* name, method, flags, doc */
- {"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
- "() - Return Scene name"},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "(str) - Change Scene name"},
- {"getLayers", ( PyCFunction ) Scene_getLayerList, METH_NOARGS,
- "() - Return a list of layers int indices which are set in this scene "},
- {"setLayers", ( PyCFunction ) Scene_oldsetLayers, METH_VARARGS,
- "(layers) - Change layers which are set in this scene\n"
- "(layers) - list of integers in the range [1, 20]."},
- {"copy", ( PyCFunction ) Scene_copy, METH_VARARGS,
- "(duplicate_objects = 1) - Return a copy of this scene\n"
- "The optional argument duplicate_objects defines how the scene\n"
- "children are duplicated:\n\t0: Link Objects\n\t1: Link Object Data"
- "\n\t2: Full copy\n"},
- {"makeCurrent", ( PyCFunction ) Scene_makeCurrent, METH_NOARGS,
- "() - Make self the current scene"},
- {"update", ( PyCFunction ) Scene_update, METH_VARARGS,
- "(full = 0) - Update scene self.\n"
- "full = 0: sort the base list of objects."
- "full = 1: full update -- also regroups, does ipos, keys"},
- {"link", ( PyCFunction ) Scene_link, METH_VARARGS,
- "(obj) - Link Object obj to this scene"},
- {"unlink", ( PyCFunction ) Scene_unlink, METH_VARARGS,
- "(obj) - Unlink Object obj from this scene"},
- {"getChildren", ( PyCFunction ) Scene_getChildren, METH_NOARGS,
- "() - Return list of all objects linked to this scene"},
- {"getActiveObject", (PyCFunction)Scene_getActiveObject, METH_NOARGS,
- "() - Return this scene's active object"},
- {"getCurrentCamera", ( PyCFunction ) Scene_getCurrentCamera,
- METH_NOARGS,
- "() - Return current active Camera"},
- {"getScriptLinks", ( PyCFunction ) Scene_getScriptLinks, METH_O,
- "(eventname) - Get a list of this scene's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged, OnLoad, OnSave, Redraw or Render."},
- {"addScriptLink", ( PyCFunction ) Scene_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new scene scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged, OnLoad, OnSave, Redraw or Render."},
- {"clearScriptLinks", ( PyCFunction ) Scene_clearScriptLinks,
- METH_VARARGS,
- "() - Delete all scriptlinks from this scene.\n"
- "([s1<,s2,s3...>]) - Delete specified scriptlinks from this scene."},
- {"setCurrentCamera", ( PyCFunction ) Scene_setCurrentCamera,
- METH_VARARGS,
- "() - Set the currently active Camera"},
- {"getRenderingContext", ( PyCFunction ) Scene_getRenderingContext,
- METH_NOARGS,
- "() - Get the rendering context for the scene and return it as a BPy_RenderData"},
- {"getRadiosityContext", ( PyCFunction ) Scene_getRadiosityContext,
- METH_NOARGS,
- "() - Get the radiosity context for this scene."},
- {"play", ( PyCFunction ) Scene_play, METH_VARARGS,
- "(mode = 0, win = VIEW3D) - Play realtime animation in Blender"
- " (not rendered).\n"
- "(mode) - int:\n"
- "\t0 - keep playing in biggest given 'win';\n"
- "\t1 - keep playing in all 'win', VIEW3D and SEQ windows;\n"
- "\t2 - play once in biggest given 'win';\n"
- "\t3 - play once in all 'win', VIEW3D and SEQ windows.\n"
- "(win) - int: see Blender.Window.Types. Only these are meaningful here:"
- "VIEW3D, SEQ, IPO, ACTION, NLA, SOUND. But others are also accepted, "
- "since they can be used just as an interruptible timer. If 'win' is not"
- "available or invalid, VIEW3D is tried, then any bigger window."
- "Returns 0 for normal exit or 1 when canceled by user input."},
- {"getTimeLine", ( PyCFunction ) Scene_getTimeLine, METH_NOARGS,
- "() - Get time line of this Scene"},
- {NULL, NULL, 0, NULL}
-};
-
-
-/*****************************************************************************/
-/* Python BPy_Scene getsetattr funcs: */
-/*****************************************************************************/
-static PyObject *Scene_getLayerMask( BPy_Scene * self )
-{
- SCENE_DEL_CHECK_PY(self);
- return PyInt_FromLong( self->scene->lay & ((1<<20)-1) );
-}
-
-static int Scene_setLayerMask( BPy_Scene * self, PyObject * value )
-{
- int laymask = 0;
-
- SCENE_DEL_CHECK_INT(self);
-
- if (!PyInt_Check(value)) {
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected an integer (bitmask) as argument" );
- }
-
- laymask = PyInt_AsLong(value);
-
- if (laymask <= 0 || laymask > (1<<20) - 1) /* binary: 1111 1111 1111 1111 1111 */
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "bitmask must have from 1 up to 20 bits set");
-
- self->scene->lay = laymask;
- /* if this is the current scene then apply the scene layers value
- * to the view layers value: */
- if (G.vd && (self->scene == G.scene)) {
- int val, bit = 0;
- G.vd->lay = laymask;
-
- while( bit < 20 ) {
- val = 1 << bit;
- if( laymask & val ) {
- G.vd->layact = val;
- break;
- }
- bit++;
- }
- }
-
- return 0;
-}
-
-static PyObject *Scene_getLayerList( BPy_Scene * self )
-{
- PyObject *laylist, *item;
- int layers, bit = 0, val = 0;
-
- SCENE_DEL_CHECK_PY(self);
-
- laylist = PyList_New( 0 );
-
- if( !laylist )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create pylist!" ) );
-
- layers = self->scene->lay;
-
- while( bit < 20 ) {
- val = 1 << bit;
- if( layers & val ) {
- item = Py_BuildValue( "i", bit + 1 );
- PyList_Append( laylist, item );
- Py_DECREF( item );
- }
- bit++;
- }
- return laylist;
-}
-
-static int Scene_setLayerList( BPy_Scene * self, PyObject * value )
-{
- PyObject *item = NULL;
- int layers = 0, val, i, len_list;
-
- SCENE_DEL_CHECK_INT(self);
-
- if( !PySequence_Check( value ) )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list of integers in the range [1, 20]" ) );
-
- len_list = PySequence_Size(value);
-
- if (len_list == 0)
- return ( EXPP_ReturnIntError( PyExc_AttributeError,
- "list can't be empty, at least one layer must be set" ) );
-
- for( i = 0; i < len_list; i++ ) {
- item = PySequence_GetItem( value, i );
-
- if( !PyInt_Check( item ) ) {
- Py_DECREF( item );
- return EXPP_ReturnIntError
- ( PyExc_AttributeError,
- "list must contain only integer numbers" );
- }
-
- val = ( int ) PyInt_AsLong( item );
- if( val < 1 || val > 20 )
- return EXPP_ReturnIntError
- ( PyExc_AttributeError,
- "layer values must be in the range [1, 20]" );
-
- layers |= 1 << ( val - 1 );
- }
- self->scene->lay = layers;
-
- if (G.vd && (self->scene == G.scene)) {
- int bit = 0;
- G.vd->lay = layers;
-
- while( bit < 20 ) {
- val = 1 << bit;
- if( layers & val ) {
- G.vd->layact = val;
- break;
- }
- bit++;
- }
- }
-
- return 0;
-}
-
-static PyObject *Scene_getWorld( BPy_Scene * self )
-{
- SCENE_DEL_CHECK_PY(self);
-
- if (!self->scene->world)
- Py_RETURN_NONE;
- return World_CreatePyObject(self->scene->world);
-}
-
-static int Scene_setWorld( BPy_Scene * self, PyObject * value )
-{
- SCENE_DEL_CHECK_INT(self);
- return GenericLib_assignData(value, (void **) &self->scene->world, NULL, 1, ID_WO, 0);
-}
-
-/* accessed from scn.objects */
-static PyObject *Scene_getObjects( BPy_Scene *self)
-{
- SCENE_DEL_CHECK_PY(self);
- return SceneObSeq_CreatePyObject(self, NULL, 0);
-}
-
-static PyObject *Scene_getCursor( BPy_Scene * self )
-{
- SCENE_DEL_CHECK_PY(self);
- return newVectorObject( self->scene->cursor, 3, Py_WRAP );
-}
-
-static int Scene_setCursor( BPy_Scene * self, PyObject * value )
-{
- VectorObject *bpy_vec;
- SCENE_DEL_CHECK_INT(self);
- if (!VectorObject_Check(value))
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "expected a vector" ) );
-
- bpy_vec = (VectorObject *)value;
-
- if (bpy_vec->size != 3)
- return ( EXPP_ReturnIntError( PyExc_ValueError,
- "can only assign a 3D vector" ) );
-
- VECCOPY(self->scene->cursor, bpy_vec->vec);
- return 0;
-}
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Scene_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"Layers",
- (getter)Scene_getLayerMask, (setter)Scene_setLayerMask,
- "Scene layer bitmask",
- NULL},
- {"layers",
- (getter)Scene_getLayerList, (setter)Scene_setLayerList,
- "Scene layer list",
- NULL},
- {"world",
- (getter)Scene_getWorld, (setter)Scene_setWorld,
- "Scene layer bitmask",
- NULL},
- {"cursor",
- (getter)Scene_getCursor, (setter)Scene_setCursor,
- "Scene layer bitmask",
- NULL},
- {"timeline",
- (getter)Scene_getTimeLine, (setter)NULL,
- "Scenes timeline (read only)",
- NULL},
- {"render",
- (getter)Scene_getRenderingContext, (setter)NULL,
- "Scenes rendering context (read only)",
- NULL},
- {"radiosity",
- (getter)Scene_getRadiosityContext, (setter)NULL,
- "Scenes radiosity context (read only)",
- NULL},
- {"sequence",
- (getter)Scene_getSequence, (setter)NULL,
- "Scene sequencer data (read only)",
- NULL},
-
- {"objects",
- (getter)Scene_getObjects, (setter)NULL,
- "Scene object iterator",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-
-/*-----------------------BPy_Scene method def------------------------------*/
-PyTypeObject Scene_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
- "Scene", /* tp_name */
- sizeof( BPy_Scene ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- NULL, /* tp_dealloc */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) Scene_compare, /* tp_compare */
- ( reprfunc ) Scene_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_Scene_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Scene_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
-};
-
-/*-----------------------Scene module Init())-----------------------------*/
-PyObject *Scene_Init( void )
-{
-
- PyObject *submodule;
- PyObject *dict;
-
- if( PyType_Ready( &Scene_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &SceneObSeq_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Scene", M_Scene_methods, M_Scene_doc );
-
- dict = PyModule_GetDict( submodule );
- PyDict_SetItemString( dict, "Render", Render_Init( ) );
- PyDict_SetItemString( dict, "Radio", Radio_Init( ) );
- PyDict_SetItemString( dict, "Sequence", Sequence_Init( ) );
-
- return submodule;
-}
-
-/*-----------------------compare----------------------------------------*/
-static int Scene_compare( BPy_Scene * a, BPy_Scene * b )
-{
- return ( a->scene == b->scene ) ? 0 : -1;
-}
-
-/*----------------------repr--------------------------------------------*/
-static PyObject *Scene_repr( BPy_Scene * self )
-{
- if( !(self->scene) )
- return PyString_FromString( "[Scene - Removed]");
- else
- return PyString_FromFormat( "[Scene \"%s\"]",
- self->scene->id.name + 2 );
-}
-
-/*-----------------------CreatePyObject---------------------------------*/
-PyObject *Scene_CreatePyObject( Scene * scene )
-{
- BPy_Scene *pyscene;
-
- pyscene = ( BPy_Scene * ) PyObject_NEW( BPy_Scene, &Scene_Type );
-
- if( !pyscene )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Scene object" );
-
- pyscene->scene = scene;
-
- return ( PyObject * ) pyscene;
-}
-
-/*-----------------------FromPyObject-----------------------------------*/
-Scene *Scene_FromPyObject( PyObject * pyobj )
-{
- return ( ( BPy_Scene * ) pyobj )->scene;
-}
-
-/*-----------------------Scene module function defintions---------------*/
-/*-----------------------Scene.New()------------------------------------*/
-static PyObject *M_Scene_New( PyObject * self, PyObject * args,
- PyObject * kword )
-{
- char *name = "Scene";
- char *kw[] = { "name", NULL };
- PyObject *pyscene; /* for the Scene object wrapper in Python */
- Scene *blscene; /* for the actual Scene we create in Blender */
-
- if( !PyArg_ParseTupleAndKeywords( args, kword, "|s", kw, &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a string or an empty argument list" ) );
-
- blscene = add_scene( name ); /* first create the Scene in Blender */
-
- if( blscene ) {
- /* normally, for most objects, we set the user count to zero here.
- * Scene is different than most objs since it is the container
- * for all the others. Since add_scene() has already set
- * the user count to one, we leave it alone.
- */
-
- /* now create the wrapper obj in Python */
- pyscene = Scene_CreatePyObject( blscene );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Scene obj in Blender" ) );
-
- if( pyscene == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create Scene PyObject" ) );
-
- return pyscene;
-}
-
-/*-----------------------Scene.Get()------------------------------------*/
-static PyObject *M_Scene_Get( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- Scene *scene_iter;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" ) );
-
- scene_iter = G.main->scene.first;
-
- if( name ) { /* (name) - Search scene by name */
-
- PyObject *wanted_scene = NULL;
-
- while( ( scene_iter ) && ( wanted_scene == NULL ) ) {
-
- if( strcmp( name, scene_iter->id.name + 2 ) == 0 )
- wanted_scene =
- Scene_CreatePyObject( scene_iter );
-
- scene_iter = scene_iter->id.next;
- }
-
- if( wanted_scene == NULL ) { /* Requested scene doesn't exist */
- char error_msg[64];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Scene \"%s\" not found", name );
- return ( EXPP_ReturnPyObjError
- ( PyExc_NameError, error_msg ) );
- }
-
- return wanted_scene;
- }
-
- else { /* () - return a list with wrappers for all scenes in Blender */
- int index = 0;
- PyObject *sce_pylist, *pyobj;
-
- sce_pylist = PyList_New( BLI_countlist( &( G.main->scene ) ) );
-
- if( sce_pylist == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" ) );
-
- while( scene_iter ) {
- pyobj = Scene_CreatePyObject( scene_iter );
-
- if( !pyobj ) {
- Py_DECREF(sce_pylist);
- return ( EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create PyString" ) );
- }
- PyList_SET_ITEM( sce_pylist, index, pyobj );
-
- scene_iter = scene_iter->id.next;
- index++;
- }
-
- return sce_pylist;
- }
-}
-
-/*-----------------------Scene.GetCurrent()------------------------------*/
-static PyObject *M_Scene_GetCurrent( PyObject * self )
-{
- return Scene_CreatePyObject( ( Scene * ) G.scene );
-}
-
-static PyObject *M_Scene_getCurrent_deprecated( PyObject * self )
-{
- static char warning = 1;
- if( warning ) {
- printf("Blender.Scene.getCurrent() is deprecated,\n\tuse Blender.Scene.GetCurrent() instead.\n");
- --warning;
- }
-
- return Scene_CreatePyObject( ( Scene * ) G.scene );
-}
-
-
-/*-----------------------Scene.Unlink()----------------------------------*/
-static PyObject *M_Scene_Unlink( PyObject * self, PyObject * args )
-{
- PyObject *pyobj;
- BPy_Scene *pyscn;
- Scene *scene, *sce;
- bScreen *sc;
-
- if( !PyArg_ParseTuple( args, "O!", &Scene_Type, &pyobj ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Scene PyType object" );
-
- pyscn = (BPy_Scene *)pyobj;
- scene = pyscn->scene;
-
- SCENE_DEL_CHECK_PY(pyscn);
-
- if( scene == G.scene )
- return EXPP_ReturnPyObjError( PyExc_SystemError,
- "current Scene cannot be removed!" );
-
- /* Copied from header_info.c */
-
- /* check all sets */
- for (sce= G.main->scene.first; sce; sce= sce->id.next) {
- if(sce->set == scene) sce->set= 0;
- }
-
- /* check all sequences */
- clear_scene_in_allseqs(scene);
-
- /* check render layer nodes in other scenes */
- clear_scene_in_nodes(scene);
-
- for (sc= G.main->screen.first; sc; sc= sc->id.next ) {
- if(sc->scene == scene) sc->scene= G.scene;
- }
-
- free_libblock( &G.main->scene, scene );
-
- pyscn->scene= NULL;
- Py_RETURN_NONE;
-}
-
-/* DEPRECATE ME !!! */
-/*-----------------------BPy_Scene function defintions-------------------*/
-
-/*-----------------------Scene.setLayers()---------------------------------*/
-static PyObject *Scene_oldsetLayers( BPy_Scene * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)Scene_setLayerList );
-}
-/* END DEPRECATE CODE */
-
-
-/*-----------------------Scene.copy()------------------------------------*/
-static PyObject *Scene_copy( BPy_Scene * self, PyObject * args )
-{
- short dup_objs = 1;
- Scene *scene = self->scene;
-
- SCENE_DEL_CHECK_PY(self);
-
- if( !PyArg_ParseTuple( args, "|h", &dup_objs ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int in [0,2] or nothing as argument" );
-
- return Scene_CreatePyObject( copy_scene( scene, dup_objs ) );
-}
-
-/*-----------------------Scene.makeCurrent()-----------------------------*/
-static PyObject *Scene_makeCurrent( BPy_Scene * self )
-{
- Scene *scene = self->scene;
-#if 0 /* add back in when bpy becomes "official" */
- static char warning = 1;
- if( warning ) {
- printf("scene.makeCurrent() deprecated!\n\tuse bpy.scenes.active = scene instead\n");
- --warning;
- }
-#endif
-
- SCENE_DEL_CHECK_PY(self);
-
- if( scene && scene != G.scene) {
- set_scene( scene );
- scene_update_for_newframe(scene, scene->lay);
- }
-
- Py_RETURN_NONE;
-}
-
-/*-----------------------Scene.update()----------------------------------*/
-static PyObject *Scene_update( BPy_Scene * self, PyObject * args )
-{
- Scene *scene = self->scene;
- int full = 0;
-
- SCENE_DEL_CHECK_PY(self);
- if( !PyArg_ParseTuple( args, "|i", &full ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or int (0 or 1) argument" );
-
-/* Under certain circunstances, DAG_scene_sort *here* can crash Blender.
- * A "RuntimeError: max recursion limit" happens when a scriptlink
- * on frame change has scene.update(1).
- * Investigate better how to avoid this. */
- if( !full )
- DAG_scene_sort( scene );
-
- else if( full == 1 ) {
- int enablescripts = G.f & G_DOSCRIPTLINKS;
-
- /*Disable scriptlinks to prevent firing off newframe scriptlink
- events.*/
- G.f &= ~G_DOSCRIPTLINKS;
- set_scene_bg( scene );
- scene_update_for_newframe( scene, scene->lay );
-
- /*re-enabled scriptlinks if necassary.*/
- if (enablescripts) G.f |= G_DOSCRIPTLINKS;
- } else
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "in method scene.update(full), full should be:\n"
- "0: to only sort scene elements (old behavior); or\n"
- "1: for a full update (regroups, does ipos, keys, etc.)" );
-
- Py_RETURN_NONE;
-}
-
-/*-----------------------Scene.link()------------------------------------*/
-static PyObject *Scene_link( BPy_Scene * self, PyObject * args )
-{
- Scene *scene = self->scene;
- BPy_Object *bpy_obj;
- Object *object = NULL;
- static char warning = 1;
-
- if( warning ) {
- printf("scene.link(ob) deprecated!\n\tuse scene.objects.link(ob) instead\n");
- --warning;
- }
-
- SCENE_DEL_CHECK_PY(self);
-
- if( !PyArg_ParseTuple( args, "O!", &Object_Type, &bpy_obj ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Object argument" );
-
-
- /*return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Could not create data on demand for this object type!" );*/
-
- object = bpy_obj->object;
-
- /* Object.c's EXPP_add_obdata does not support these objects */
- if (!object->data && (object->type == OB_SURF || object->type == OB_FONT || object->type == OB_WAVE )) {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Object has no data and new data cant be automaticaly created for Surf, Text or Wave type objects!" );
- } else {
- /* Ok, all is fine, let's try to link it */
- Base *base;
-
- /* We need to link the object to a 'Base', then link this base
- * to the scene. See DNA_scene_types.h ... */
-
- /* First, check if the object isn't already in the scene */
- base = object_in_scene( object, scene );
- /* if base is not NULL ... */
- if( base ) /* ... the object is already in one of the Scene Bases */
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "object already in scene!" );
-
- /* not linked, go get mem for a new base object */
-
- base = MEM_callocN( sizeof( Base ), "pynewbase" );
-
- if( !base )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't allocate new Base for object" );
-
- /* if the object has not yet been linked to object data, then
- * set the real type before we try creating data */
-
- if( bpy_obj->realtype != OB_EMPTY ) {
- object->type = bpy_obj->realtype;
- bpy_obj->realtype = OB_EMPTY;
- }
-
- /* check if this object has obdata, case not, try to create it */
-
- if( !object->data && ( object->type != OB_EMPTY ) )
- EXPP_add_obdata( object ); /* returns -1 on error, defined in Object.c */
-
- base->object = object; /* link object to the new base */
- base->lay = object->lay;
- base->flag = object->flag;
-
- object->id.us += 1; /* incref the object user count in Blender */
-
- BLI_addhead( &scene->base, base ); /* finally, link new base to scene */
- }
-
- Py_RETURN_NONE;
-}
-
-/*-----------------------Scene.unlink()----------------------------------*/
-static PyObject *Scene_unlink( BPy_Scene * self, PyObject * args )
-{
- BPy_Object *bpy_obj = NULL;
- Scene *scene = self->scene;
- Base *base;
- static char warning = 1;
-
- if( warning ) {
- printf("scene.unlink(ob) deprecated!\n\tuse scene.objects.unlink(ob) instead\n");
- --warning;
- }
-
- SCENE_DEL_CHECK_PY(self);
-
- if( !PyArg_ParseTuple( args, "O!", &Object_Type, &bpy_obj ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Object as argument" );
-
- /* is the object really in the scene? */
- base = object_in_scene( bpy_obj->object, scene );
-
- if( base ) { /* if it is, remove it */
- if (scene->basact==base)
- scene->basact= NULL; /* in case the object was selected */
-
- free_and_unlink_base_from_scene( scene, base );
- Py_RETURN_TRUE;
- }
- else
- Py_RETURN_FALSE;
-}
-
-/*-----------------------Scene.getChildren()-----------------------------*/
-static PyObject *Scene_getChildren( BPy_Scene * self )
-{
- Scene *scene = self->scene;
- PyObject *pylist;
- PyObject *bpy_obj;
- Object *object;
- Base *base;
- static char warning = 1;
-
- if( warning ) {
- printf("scene.getChildren() deprecated!\n\tuse scene.objects instead\n");
- --warning;
- }
-
- SCENE_DEL_CHECK_PY(self);
-
- pylist = PyList_New( 0 );
-
- base = scene->base.first;
-
- while( base ) {
- object = base->object;
-
- bpy_obj = Object_CreatePyObject( object );
-
- if( !bpy_obj ) {
- Py_DECREF(pylist);
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create new object wrapper" );
- }
- PyList_Append( pylist, bpy_obj );
- Py_DECREF( bpy_obj ); /* PyList_Append incref'ed it */
-
- base = base->next;
- }
-
- return pylist;
-}
-
-/*-----------------------Scene.getActiveObject()------------------------*/
-static PyObject *Scene_getActiveObject(BPy_Scene *self)
-{
- Scene *scene = self->scene;
- PyObject *pyob;
- Object *ob;
- static char warning = 1;
-
- if( warning ) {
- printf("scene.getActiveObject() deprecated!\n\tuse scene.objects.active instead\n");
- --warning;
- }
-
- SCENE_DEL_CHECK_PY(self);
-
- ob = ((scene->basact) ? (scene->basact->object) : 0);
-
- if (ob) {
- pyob = Object_CreatePyObject( ob );
-
- if (!pyob)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "couldn't create new object wrapper!");
-
- return pyob;
- }
-
- Py_RETURN_NONE; /* no active object */
-}
-
-/*-----------------------Scene.getCurrentCamera()------------------------*/
-static PyObject *Scene_getCurrentCamera( BPy_Scene * self )
-{
- static char warning = 1;
-
- if( warning ) {
- printf("scene.getCurrentCamera() deprecated!\n\tuse scene.objects.camera instead\n");
- --warning;
- }
-
- SCENE_DEL_CHECK_PY(self);
- /* None is ok */
- return Object_CreatePyObject( self->scene->camera );
-}
-
-/*-----------------------Scene.setCurrentCamera()------------------------*/
-static PyObject *Scene_setCurrentCamera( BPy_Scene * self, PyObject * args )
-{
- Object *object;
- BPy_Object *cam_obj;
- Scene *scene = self->scene;
- static char warning = 1;
-
- if( warning ) {
- printf("scene.setCurrentCamera(ob) deprecated!\n\tSet scene.objects.camera = ob instead\n");
- --warning;
- }
-
- SCENE_DEL_CHECK_PY(self);
-
- if( !PyArg_ParseTuple( args, "O!", &Object_Type, &cam_obj ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Camera Object as argument" );
-
- object = cam_obj->object;
- if( object->type != OB_CAMERA )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expected Camera Object as argument" );
-
- scene->camera = object; /* set the current Camera */
-
- /* if this is the current scene, update its window now */
- if( !G.background && scene == G.scene ) /* Traced a crash to redrawing while in background mode -Campbell */
- copy_view3d_lock( REDRAW );
-
-/* XXX copy_view3d_lock(REDRAW) prints "bad call to addqueue: 0 (18, 1)".
- * The same happens in bpython. */
-
- Py_RETURN_NONE;
-}
-
-/*-----------------------Scene.getRenderingContext()---------------------*/
-static PyObject *Scene_getRenderingContext( BPy_Scene * self )
-{
- SCENE_DEL_CHECK_PY(self);
- return RenderData_CreatePyObject( self->scene );
-}
-
-static PyObject *Scene_getRadiosityContext( BPy_Scene * self )
-{
- SCENE_DEL_CHECK_PY(self);
- return Radio_CreatePyObject( self->scene );
-}
-
-static PyObject *Scene_getSequence( BPy_Scene * self )
-{
- SCENE_DEL_CHECK_PY(self);
- if (self->scene->ed) /* we should create this if its not there :/ */
- return SceneSeq_CreatePyObject( self->scene, NULL );
- else
- Py_RETURN_NONE;
-}
-
-/* scene.addScriptLink */
-static PyObject *Scene_addScriptLink( BPy_Scene * self, PyObject * args )
-{
- Scene *scene = self->scene;
- ScriptLink *slink = NULL;
-
- SCENE_DEL_CHECK_PY(self);
-
- slink = &( scene )->scriptlink;
-
- return EXPP_addScriptLink( slink, args, 1 );
-}
-
-/* scene.clearScriptLinks */
-static PyObject *Scene_clearScriptLinks( BPy_Scene * self, PyObject * args )
-{
- Scene *scene = self->scene;
- ScriptLink *slink = NULL;
-
- SCENE_DEL_CHECK_PY(self);
-
- slink = &( scene )->scriptlink;
-
- return EXPP_clearScriptLinks( slink, args );
-}
-
-/* scene.getScriptLinks */
-static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * value )
-{
- Scene *scene = self->scene;
- ScriptLink *slink = NULL;
- PyObject *ret = NULL;
-
- SCENE_DEL_CHECK_PY(self);
-
- slink = &( scene )->scriptlink;
-
- ret = EXPP_getScriptLinks( slink, value, 1 );
-
- if( ret )
- return ret;
- else
- return NULL;
-}
-
-static PyObject *Scene_play( BPy_Scene * self, PyObject * args )
-{
- int mode = 0, win = SPACE_VIEW3D;
- PyObject *ret = NULL;
- ScrArea *sa = NULL, *oldsa = curarea;
-
- SCENE_DEL_CHECK_PY(self);
-
- if( !PyArg_ParseTuple( args, "|ii", &mode, &win ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing, or or two ints as arguments." );
-
- if( mode < 0 || mode > 3 )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "mode should be in range [0, 3]." );
-
- switch ( win ) {
- case SPACE_VIEW3D:
- case SPACE_SEQ:
- case SPACE_IPO:
- case SPACE_ACTION:
- case SPACE_NLA:
- case SPACE_SOUND:
- case SPACE_BUTS: /* from here they don't 'play', but ... */
- case SPACE_TEXT: /* ... might be used as a timer. */
- case SPACE_SCRIPT:
- case SPACE_OOPS:
- case SPACE_IMAGE:
- case SPACE_IMASEL:
- case SPACE_INFO:
- case SPACE_FILE:
- break;
- default:
- win = SPACE_VIEW3D;
- }
-
- /* we have to move to a proper win */
- sa = find_biggest_area_of_type( win );
- if( !sa && win != SPACE_VIEW3D )
- sa = find_biggest_area_of_type( SPACE_VIEW3D );
-
- if( !sa )
- sa = find_biggest_area( );
-
- if( sa )
- areawinset( sa->win );
-
- /* play_anim returns 0 for normal exit or 1 if user canceled it */
- ret = PyInt_FromLong( (long)play_anim( mode ) );
-
- if( sa )
- areawinset( oldsa->win );
-
- return ret;
-}
-
-static PyObject *Scene_getTimeLine( BPy_Scene *self )
-{
- BPy_TimeLine *tm;
-
- SCENE_DEL_CHECK_PY(self);
-
- tm= (BPy_TimeLine *) PyObject_NEW (BPy_TimeLine, &TimeLine_Type);
- if (!tm)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_TimeLine object");
- tm->marker_list= &(self->scene->markers);
- tm->sfra= (int) self->scene->r.sfra;
- tm->efra= (int) self->scene->r.efra;
-
- return (PyObject *)tm;
-}
-
-/************************************************************************
- *
- * Object Sequence
- *
- ************************************************************************/
-/*
- * create a thin wrapper for the scenes objects
- */
-
-/* accessed from scn.objects.selected or scn.objects.context */
-static PyObject *SceneObSeq_getObjects( BPy_SceneObSeq *self, void *mode)
-{
- SCENE_DEL_CHECK_PY(self->bpyscene);
- return SceneObSeq_CreatePyObject(self->bpyscene, NULL, (int)((long)mode));
-}
-
-int SceneObSeq_setObjects( BPy_SceneObSeq *self, PyObject *value, void *_mode_)
-{
- /*
- ONLY SUPPORTS scn.objects.selected and scn.objects.context
- cannot assign to scn.objects yet!!!
- */
- PyObject *item;
- Scene *scene= self->bpyscene->scene;
- Object *blen_ob;
- Base *base;
- int size, mode = (int)_mode_;
-
- SCENE_DEL_CHECK_INT(self->bpyscene);
-
- /* scn.objects.selected = scn.objects - shortcut to select all */
- if (BPy_SceneObSeq_Check(value)) {
- BPy_SceneObSeq *bpy_sceneseq = (BPy_SceneObSeq *)value;
- if (self->bpyscene->scene != bpy_sceneseq->bpyscene->scene)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "Cannot assign a SceneObSeq type from another scene" );
- if (bpy_sceneseq->mode != EXPP_OBSEQ_NORMAL)
- return EXPP_ReturnIntError( PyExc_ValueError,
- "Can only assign scn.objects to scn.objects.context or scn.objects.selected" );
-
- for (base= scene->base.first; base; base= base->next) {
- base->flag |= SELECT;
- base->object->flag |= SELECT;
-
- if (mode==EXPP_OBSEQ_CONTEXT && G.vd) {
- base->object->lay= base->lay= G.vd->lay;
- }
- }
- return 0;
- }
-
- if (!PySequence_Check(value))
- return EXPP_ReturnIntError( PyExc_ValueError,
- "Error, must assign a sequence of objects to scn.objects.selected" );
-
- /* for context and selected, just deselect, dont remove */
- for (base= scene->base.first; base; base= base->next) {
- base->flag &= ~SELECT;
- base->object->flag &= ~SELECT;
- }
-
- size = PySequence_Length(value);
- while (size) {
- size--;
- item = PySequence_GetItem(value, size);
- if ( PyObject_TypeCheck(item, &Object_Type) ) {
- blen_ob= ((BPy_Object *)item)->object;
- base = object_in_scene( blen_ob, scene );
- if (base) {
- blen_ob->flag |= SELECT;
- base->flag |= SELECT;
- if (mode==EXPP_OBSEQ_CONTEXT && G.vd) {
- blen_ob->restrictflag &= ~OB_RESTRICT_VIEW;
- blen_ob->lay= base->lay= G.vd->lay;
- }
- }
- }
- Py_DECREF(item);
- }
- return 0;
-}
-
-
-static PyObject *SceneObSeq_CreatePyObject( BPy_Scene *self, Base *iter, int mode )
-{
- BPy_SceneObSeq *seq = PyObject_NEW( BPy_SceneObSeq, &SceneObSeq_Type);
- seq->bpyscene = self; Py_INCREF(self);
- seq->iter = iter;
- seq->mode = mode;
- return (PyObject *)seq;
-}
-
-static int SceneObSeq_len( BPy_SceneObSeq * self )
-{
- Scene *scene= self->bpyscene->scene;
- SCENE_DEL_CHECK_INT(self->bpyscene);
-
- if (self->mode == EXPP_OBSEQ_NORMAL)
- return BLI_countlist( &( scene->base ) );
- else if (self->mode == EXPP_OBSEQ_SELECTED) {
- int len=0;
- Base *base;
- for (base= scene->base.first; base; base= base->next) {
- if (base->flag & SELECT) {
- len++;
- }
- }
- return len;
- } else if (self->mode == EXPP_OBSEQ_CONTEXT) {
- int len=0;
- Base *base;
-
- if( G.vd == NULL ) /* No 3d view has been initialized yet, simply return an empty list */
- return 0;
-
- for (base= scene->base.first; base; base= base->next) {
- if TESTBASE(base) {
- len++;
- }
- }
- return len;
- }
- /*should never run this */
- return 0;
-}
-
-/*
- * retrive a single Object from somewhere in the Object list
- */
-
-static PyObject *SceneObSeq_item( BPy_SceneObSeq * self, int i )
-{
- int index=0;
- Base *base= NULL;
- Scene *scene= self->bpyscene->scene;
-
- SCENE_DEL_CHECK_PY(self->bpyscene);
-
- /* objects */
- if (self->mode==EXPP_OBSEQ_NORMAL)
- for (base= scene->base.first; base && i!=index; base= base->next, index++) {}
- /* selected */
- else if (self->mode==EXPP_OBSEQ_SELECTED) {
- for (base= scene->base.first; base && i!=index; base= base->next)
- if (base->flag & SELECT)
- index++;
- }
- /* context */
- else if (self->mode==EXPP_OBSEQ_CONTEXT) {
- if (G.vd)
- for (base= scene->base.first; base && i!=index; base= base->next)
- if TESTBASE(base)
- index++;
- }
-
- if (!(base))
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-
- return Object_CreatePyObject( base->object );
-}
-
-static PySequenceMethods SceneObSeq_as_sequence = {
- ( inquiry ) SceneObSeq_len, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) SceneObSeq_item, /* sq_item */
- ( intintargfunc ) 0, /* sq_slice */
- ( intobjargproc ) 0, /* sq_ass_item */
- ( intintobjargproc ) 0, /* sq_ass_slice */
- 0,0,0,
-};
-
-
-/************************************************************************
- *
- * Python SceneObSeq_Type iterator (iterates over GroupObjects)
- *
- ************************************************************************/
-
-/*
- * Initialize the interator index
- */
-
-static PyObject *SceneObSeq_getIter( BPy_SceneObSeq * self )
-{
- /* we need to get the first base, but for selected context we may need to advance
- to the first selected or first conext base */
- Base *base= self->bpyscene->scene->base.first;
-
- SCENE_DEL_CHECK_PY(self->bpyscene);
-
- if (self->mode==EXPP_OBSEQ_SELECTED)
- while (base && !(base->flag & SELECT))
- base= base->next;
- else if (self->mode==EXPP_OBSEQ_CONTEXT) {
- if (!G.vd)
- base= NULL; /* will never iterate if we have no */
- else
- while (base && !TESTBASE(base))
- base= base->next;
- }
- /* create a new iterator if were alredy using this one */
- if (self->iter==NULL) {
- self->iter = base;
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- return SceneObSeq_CreatePyObject(self->bpyscene, base, self->mode);
- }
-}
-
-/*
- * Return next SceneOb.
- */
-
-static PyObject *SceneObSeq_nextIter( BPy_SceneObSeq * self )
-{
- PyObject *object;
- Base *base;
- if( !(self->iter) || !(self->bpyscene->scene) ) {
- self->iter= NULL;
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- object= Object_CreatePyObject( self->iter->object );
- base= self->iter->next;
-
- if (self->mode==EXPP_OBSEQ_SELECTED)
- while (base && !(base->flag & SELECT))
- base= base->next;
- else if (self->mode==EXPP_OBSEQ_CONTEXT) {
- if (!G.vd)
- base= NULL; /* will never iterate if we have no */
- else
- while (base && !TESTBASE(base))
- base= base->next;
- }
- self->iter= base;
- return object;
-}
-
-
-static PyObject *SceneObSeq_link( BPy_SceneObSeq * self, PyObject *pyobj )
-{
- SCENE_DEL_CHECK_PY(self->bpyscene);
-
- /* this shold eventually replace Scene_link */
- if (self->mode != EXPP_OBSEQ_NORMAL)
- return (EXPP_ReturnPyObjError( PyExc_TypeError,
- "Cannot link to objects.selection or objects.context!" ));
-
- /*
- if (self->iter != NULL)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Cannot modify scene objects while iterating" );
- */
-
- if( PyTuple_Size(pyobj) == 1 ) {
- BPy_LibraryData *seq = ( BPy_LibraryData * )PyTuple_GET_ITEM( pyobj, 0 );
- if( BPy_LibraryData_Check( seq ) )
- return LibraryData_importLibData( seq, seq->name,
- ( seq->kind == OBJECT_IS_LINK ? FILE_LINK : 0 ),
- self->bpyscene->scene );
- }
- return Scene_link(self->bpyscene, pyobj);
-}
-
-/* This is buggy with new object data not already linked to an object, for now use the above code */
-static PyObject *SceneObSeq_new( BPy_SceneObSeq * self, PyObject *args )
-{
-
- void *data = NULL;
- char *name = NULL;
- char *desc = NULL;
- short type = OB_EMPTY;
- struct Object *object;
- Base *base;
- PyObject *py_data;
- Scene *scene= self->bpyscene->scene;
-
- SCENE_DEL_CHECK_PY(self->bpyscene);
-
- if (self->mode != EXPP_OBSEQ_NORMAL)
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Cannot add new to objects.selection or objects.context!" );
-
- if( !PyArg_ParseTuple( args, "O|s", &py_data, &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "scene.objects.new(obdata) - expected obdata to be\n\ta python obdata type or the string 'Empty'" );
-
- if( BPy_Armature_Check( py_data ) ) {
- data = ( void * ) Armature_FromPyObject( py_data );
- type = OB_ARMATURE;
- } else if( BPy_Camera_Check( py_data ) ) {
- data = ( void * ) Camera_FromPyObject( py_data );
- type = OB_CAMERA;
- } else if( BPy_Lamp_Check( py_data ) ) {
- data = ( void * ) Lamp_FromPyObject( py_data );
- type = OB_LAMP;
- } else if( BPy_Curve_Check( py_data ) ) {
- data = ( void * ) Curve_FromPyObject( py_data );
- type = OB_CURVE;
- } else if( BPy_NMesh_Check( py_data ) ) {
- data = ( void * ) NMesh_FromPyObject( py_data, NULL );
- type = OB_MESH;
- if( !data ) /* NULL means there is already an error */
- return NULL;
- } else if( BPy_Mesh_Check( py_data ) ) {
- data = ( void * ) Mesh_FromPyObject( py_data, NULL );
- type = OB_MESH;
- } else if( BPy_Lattice_Check( py_data ) ) {
- data = ( void * ) Lattice_FromPyObject( py_data );
- type = OB_LATTICE;
- } else if( BPy_Metaball_Check( py_data ) ) {
- data = ( void * ) Metaball_FromPyObject( py_data );
- type = OB_MBALL;
- } else if( BPy_Text3d_Check( py_data ) ) {
- data = ( void * ) Text3d_FromPyObject( py_data );
- type = OB_FONT;
- } else if( ( desc = PyString_AsString( (PyObject *)py_data ) ) != NULL ) {
- if( !strcmp( desc, "Empty" ) ) {
- type = OB_EMPTY;
- data = NULL;
- } else
- goto typeError;
- } else {
-typeError:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an object and optionally a string as arguments" );
- }
-
- if (!name) {
- if (type == OB_EMPTY)
- name = "Empty";
- else
- name = ((ID *)data)->name + 2;
- }
-
- object = add_only_object(type, name);
-
- if( data ) {
- object->data = data;
- id_us_plus((ID *)data);
- }
-
- object->flag = SELECT;
-
- /* creates the curve for the text object */
- if (type == OB_FONT)
- text_to_curve(object, 0);
-
- /* link to scene */
- base = MEM_callocN( sizeof( Base ), "pynewbase" );
-
- if( !base )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't allocate new Base for object" );
-
- base->object = object; /* link object to the new base */
-
- if (scene == G.scene && G.vd) {
- if (G.vd->localview) {
- object->lay= G.vd->layact + G.vd->lay;
- } else {
- object->lay= G.vd->layact;
- }
- } else {
- base->lay= object->lay = scene->lay & ((1<<20)-1); /* Layer, by default visible*/
- }
-
- base->lay= object->lay;
-
- base->flag = SELECT;
- object->id.us = 1; /* we will exist once in this scene */
-
- BLI_addhead( &(scene->base), base ); /* finally, link new base to scene */
-
- /* make sure data and object materials are consistent */
- test_object_materials( (ID *)object->data );
-
- /* so we can deal with vertex groups */
- if (type == OB_MESH)
- ((BPy_Mesh *)py_data)->object = object;
-
- return Object_CreatePyObject( object );
-
-}
-
-static PyObject *SceneObSeq_unlink( BPy_SceneObSeq * self, PyObject *args )
-{
- PyObject *pyobj;
- Object *blen_ob;
- Scene *scene;
- Base *base= NULL;
-
- SCENE_DEL_CHECK_PY(self->bpyscene);
-
- if (self->mode != EXPP_OBSEQ_NORMAL)
- return (EXPP_ReturnPyObjError( PyExc_TypeError,
- "Cannot add new to objects.selection or objects.context!" ));
-
- if( !PyArg_ParseTuple( args, "O!", &Object_Type, &pyobj ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a python object as an argument" ) );
-
- blen_ob = ( ( BPy_Object * ) pyobj )->object;
-
- scene = self->bpyscene->scene;
-
- /* is the object really in the scene? */
- base = object_in_scene( blen_ob, scene);
- if( base ) { /* if it is, remove it */
- if (scene->basact==base)
- scene->basact= NULL; /* in case the object was selected */
- free_and_unlink_base_from_scene(scene, base);
- Py_RETURN_TRUE;
- }
- Py_RETURN_FALSE;
-}
-
-PyObject *SceneObSeq_getActive(BPy_SceneObSeq *self)
-{
- Base *base;
- SCENE_DEL_CHECK_PY(self->bpyscene);
-
- if (self->mode!=EXPP_OBSEQ_NORMAL)
- return (EXPP_ReturnPyObjError( PyExc_TypeError,
- "cannot get active from objects.selected or objects.context" ));
-
- base= self->bpyscene->scene->basact;
- if (!base)
- Py_RETURN_NONE;
-
- return Object_CreatePyObject( base->object );
-}
-
-static int SceneObSeq_setActive(BPy_SceneObSeq *self, PyObject *value)
-{
- Base *base;
-
- SCENE_DEL_CHECK_INT(self->bpyscene);
-
- if (self->mode!=EXPP_OBSEQ_NORMAL)
- return (EXPP_ReturnIntError( PyExc_TypeError,
- "cannot set active from objects.selected or objects.context" ));
-
- if (value==Py_None) {
- self->bpyscene->scene->basact= NULL;
- return 0;
- }
-
- if (!BPy_Object_Check(value))
- return (EXPP_ReturnIntError( PyExc_ValueError,
- "Object or None types can only be assigned to active!" ));
-
- base = object_in_scene( ((BPy_Object *)value)->object, self->bpyscene->scene );
-
- if (!base)
- return (EXPP_ReturnIntError( PyExc_ValueError,
- "cannot assign an active object outside the scene." ));
-
- self->bpyscene->scene->basact= base;
- return 0;
-}
-
-PyObject *SceneObSeq_getCamera(BPy_SceneObSeq *self)
-{
- SCENE_DEL_CHECK_PY(self->bpyscene);
-
- if (self->mode!=EXPP_OBSEQ_NORMAL)
- return (EXPP_ReturnPyObjError( PyExc_TypeError,
- "cannot get camera from objects.selected or objects.context" ));
-
- return Object_CreatePyObject( self->bpyscene->scene->camera );
-}
-
-static int SceneObSeq_setCamera(BPy_SceneObSeq *self, PyObject *value)
-{
- int ret;
-
- SCENE_DEL_CHECK_INT(self->bpyscene);
- if (self->mode!=EXPP_OBSEQ_NORMAL)
- return EXPP_ReturnIntError( PyExc_TypeError,
- "cannot set camera from objects.selected or objects.context" );
-
- ret = GenericLib_assignData(value, (void **) &self->bpyscene->scene->camera, 0, 0, ID_OB, 0);
-
- /* if this is the current scene, update its window now */
- if( ret == 0 && !G.background && self->bpyscene->scene == G.scene ) /* Traced a crash to redrawing while in background mode -Campbell */
- copy_view3d_lock( REDRAW );
-
-/* XXX copy_view3d_lock(REDRAW) prints "bad call to addqueue: 0 (18, 1)".
- * The same happens in bpython. */
-
- return ret;
-}
-
-
-static struct PyMethodDef BPy_SceneObSeq_methods[] = {
- {"link", (PyCFunction)SceneObSeq_link, METH_VARARGS,
- "link object to this scene"},
- {"new", (PyCFunction)SceneObSeq_new, METH_VARARGS,
- "Create a new object in this scene from the obdata given and return a new object"},
- {"unlink", (PyCFunction)SceneObSeq_unlink, METH_VARARGS,
- "unlinks the object from the scene"},
- {NULL, NULL, 0, NULL}
-};
-
-/************************************************************************
- *
- * Python SceneObSeq_Type standard operations
- *
- ************************************************************************/
-
-static void SceneObSeq_dealloc( BPy_SceneObSeq * self )
-{
- Py_DECREF(self->bpyscene);
- PyObject_DEL( self );
-}
-
-static int SceneObSeq_compare( BPy_SceneObSeq * a, BPy_SceneObSeq * b )
-{
- return ( a->bpyscene->scene == b->bpyscene->scene && a->mode == b->mode) ? 0 : -1;
-}
-
-/*
- * repr function
- * callback functions building meaninful string to representations
- */
-static PyObject *SceneObSeq_repr( BPy_SceneObSeq * self )
-{
- if( !(self->bpyscene->scene) )
- return PyString_FromFormat( "[Scene ObjectSeq Removed]" );
- else if (self->mode==EXPP_OBSEQ_SELECTED)
- return PyString_FromFormat( "[Scene ObjectSeq Selected \"%s\"]",
- self->bpyscene->scene->id.name + 2 );
- else if (self->mode==EXPP_OBSEQ_CONTEXT)
- return PyString_FromFormat( "[Scene ObjectSeq Context \"%s\"]",
- self->bpyscene->scene->id.name + 2 );
-
- /*self->mode==0*/
- return PyString_FromFormat( "[Scene ObjectSeq \"%s\"]",
- self->bpyscene->scene->id.name + 2 );
-}
-
-static PyGetSetDef SceneObSeq_getseters[] = {
- {"selected",
- (getter)SceneObSeq_getObjects, (setter)SceneObSeq_setObjects,
- "sequence of selected objects",
- (void *)EXPP_OBSEQ_SELECTED},
- {"context",
- (getter)SceneObSeq_getObjects, (setter)SceneObSeq_setObjects,
- "sequence of user context objects",
- (void *)EXPP_OBSEQ_CONTEXT},
- {"active",
- (getter)SceneObSeq_getActive, (setter)SceneObSeq_setActive,
- "active object",
- NULL},
- {"camera",
- (getter)SceneObSeq_getCamera, (setter)SceneObSeq_setCamera,
- "camera object",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python SceneObSeq_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject SceneObSeq_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender SceneObSeq", /* char *tp_name; */
- sizeof( BPy_SceneObSeq ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) SceneObSeq_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- ( cmpfunc ) SceneObSeq_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) SceneObSeq_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &SceneObSeq_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) SceneObSeq_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) SceneObSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_SceneObSeq_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- SceneObSeq_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
-};
diff --git a/source/blender/python/api2_2x/Scene.h b/source/blender/python/api2_2x/Scene.h
deleted file mode 100644
index eefa72562b5..00000000000
--- a/source/blender/python/api2_2x/Scene.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Sound.c b/source/blender/python/api2_2x/Sound.c
deleted file mode 100644
index 25f557eb0c1..00000000000
--- a/source/blender/python/api2_2x/Sound.c
+++ /dev/null
@@ -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
-};
-
-
diff --git a/source/blender/python/api2_2x/Sound.h b/source/blender/python/api2_2x/Sound.h
deleted file mode 100644
index 06e9a95bdc5..00000000000
--- a/source/blender/python/api2_2x/Sound.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/SurfNurb.c b/source/blender/python/api2_2x/SurfNurb.c
deleted file mode 100644
index 1d2e74a26a8..00000000000
--- a/source/blender/python/api2_2x/SurfNurb.c
+++ /dev/null
@@ -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 );
-}
-
diff --git a/source/blender/python/api2_2x/SurfNurb.h b/source/blender/python/api2_2x/SurfNurb.h
deleted file mode 100644
index 30d9a48012e..00000000000
--- a/source/blender/python/api2_2x/SurfNurb.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c
deleted file mode 100644
index e936eb56b59..00000000000
--- a/source/blender/python/api2_2x/Sys.c
+++ /dev/null
@@ -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);
-}
diff --git a/source/blender/python/api2_2x/Sys.h b/source/blender/python/api2_2x/Sys.h
deleted file mode 100644
index 3e5f78f4922..00000000000
--- a/source/blender/python/api2_2x/Sys.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c
deleted file mode 100644
index 29c404f7266..00000000000
--- a/source/blender/python/api2_2x/Text.c
+++ /dev/null
@@ -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
-};
diff --git a/source/blender/python/api2_2x/Text.h b/source/blender/python/api2_2x/Text.h
deleted file mode 100644
index 90de82f1254..00000000000
--- a/source/blender/python/api2_2x/Text.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Text3d.c b/source/blender/python/api2_2x/Text3d.c
deleted file mode 100644
index 6194b232401..00000000000
--- a/source/blender/python/api2_2x/Text3d.c
+++ /dev/null
@@ -1,1206 +0,0 @@
-/*
- * $Id: Text3d.c 11099 2007-06-28 13:46: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): Joilnen Leite
- * Johnny Matthews
- * Campbell BArton
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Text3d.h" /*This must come first*/
-
-#include "DNA_object_types.h"
-#include "MEM_guardedalloc.h"
-#include "BKE_curve.h"
-#include "BKE_library.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BIF_editfont.h" /* do_textedit() */
-#include "Curve.h"
-#include "constant.h"
-#include "Font.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-
-enum t3d_consts {
- EXPP_T3D_ATTR_FRAME_WIDTH = 0,
- EXPP_T3D_ATTR_FRAME_HEIGHT,
- EXPP_T3D_ATTR_FRAME_X,
- EXPP_T3D_ATTR_FRAME_Y
-};
-
-
-/*no prototypes declared in header files - external linkage outside of python*/
-extern VFont *get_builtin_font(void);
-extern void freedisplist(struct ListBase *lb);
-extern VFont *give_vfontpointer(int);
-extern VFont *exist_vfont(char *str);
-extern VFont *load_vfont(char *name);
-extern int BLI_exist(char *name);
-
-/*****************************************************************************/
-/* Python API function prototypes for the Text3D module. */
-/*****************************************************************************/
-static PyObject *M_Text3d_New( PyObject * self, PyObject * args );
-static PyObject *M_Text3d_Get( PyObject * self, PyObject * args );
-PyObject *M_Text3d_LoadFont (PyObject * self, PyObject * args );
-
-/*****************************************************************************
- * Python callback function prototypes for the Text3D module.
- *****************************************************************************/
-static PyObject *return_ModuleConstant( char *constant_name);
-static PyObject *generate_ModuleIntConstant(char *name, int value);
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Text3d module: */
-/*****************************************************************************/
-struct PyMethodDef M_Text3d_methods[] = {
- {"New", ( PyCFunction ) M_Text3d_New, METH_VARARGS, NULL},
- {"Get", ( PyCFunction ) M_Text3d_Get, METH_VARARGS, NULL},
- {"LoadFont", ( PyCFunction ) M_Text3d_LoadFont, METH_O, NULL},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python Text3d_Type callback function prototypes: */
-/*****************************************************************************/
-/* int Text3dPrint (BPy_Text3d *msh, FILE *fp, int flags); */
-
-
-static PyObject *Text3d_repr( BPy_Text3d * self );
-static int Text3d_compare( BPy_Text3d * a, BPy_Text3d * b );
-
-/*****************************************************************************/
-/* Python BPy_Text3d methods declarations: */
-/*****************************************************************************/
-/*PyObject *Text3d_getType(BPy_Text3d *self);*/
-static PyObject *Text3d_getName( BPy_Text3d * self );
-static PyObject *Text3d_setName( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * value );
-static PyObject *Text3d_getText( BPy_Text3d * self );
-static PyObject *Text3d_getDrawMode( BPy_Text3d * self );
-static PyObject *Text3d_setDrawMode( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getUVorco( BPy_Text3d * self );
-static PyObject *Text3d_setUVorco( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getBevelAmount( BPy_Text3d * self );
-static PyObject *Text3d_setBevelAmount( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getDefaultResolution( BPy_Text3d * self );
-static PyObject *Text3d_setDefaultResolution( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getWidth( BPy_Text3d * self );
-static PyObject *Text3d_setWidth( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getExtrudeDepth( BPy_Text3d * self );
-static PyObject *Text3d_setExtrudeDepth( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getExtrudeBevelDepth( BPy_Text3d * self );
-static PyObject *Text3d_setExtrudeBevelDepth( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getShear( BPy_Text3d * self );
-static PyObject *Text3d_setShear( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getSize( BPy_Text3d * self );
-static PyObject *Text3d_setSize( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getLineSeparation( BPy_Text3d * self );
-static PyObject *Text3d_setLineSeparation( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getSpacing( BPy_Text3d * self );
-static PyObject *Text3d_setSpacing( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getXoffset( BPy_Text3d * self );
-static PyObject *Text3d_setXoffset( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getYoffset( BPy_Text3d * self );
-static PyObject *Text3d_setYoffset( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getAlignment( BPy_Text3d * self );
-static PyObject *Text3d_setAlignment( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_getFont( BPy_Text3d * self );
-static PyObject *Text3d_setFont( BPy_Text3d * self, PyObject * args );
-static PyObject *Text3d_addFrame( BPy_Text3d * self );
-static PyObject *Text3d_removeFrame( BPy_Text3d * self, PyObject * args );
-
-/*****************************************************************************/
-/* Python BPy_Text3d methods table: */
-/*****************************************************************************/
-char M_Text3D_doc[] = "The Blender Text3D module\n\n\
- This module provides control over Text Curve objects in Blender.\n";
-
-static PyMethodDef BPy_Text3d_methods[] = {
- {"getName", ( PyCFunction ) Text3d_getName,
- METH_NOARGS, "() - Return Text3d Data name"},
- {"setName", ( PyCFunction ) Text3d_setName,
- METH_VARARGS, "() - Sets Text3d Data name"},
- {"setText", ( PyCFunction ) Text3d_setText,
- METH_O, "() - Sets Text3d Data"},
- {"getText", ( PyCFunction ) Text3d_getText,
- METH_NOARGS, "() - Gets Text3d Data"},
- {"getDrawMode", ( PyCFunction ) Text3d_getDrawMode,
- METH_NOARGS, "() - Return the font drawing mode"},
- {"setDrawMode", ( PyCFunction ) Text3d_setDrawMode,
- METH_VARARGS, "(int) - Set the font drawing mode"},
- {"getUVorco", ( PyCFunction ) Text3d_getUVorco,
- METH_NOARGS, "() - Return wether UV coords are used for Texture mapping"},
- {"setUVorco", ( PyCFunction ) Text3d_setUVorco,
- METH_VARARGS, "() - Set the font to use UV coords for Texture mapping"},
- {"getBevelAmount", ( PyCFunction ) Text3d_getBevelAmount,
- METH_NOARGS, "() - Return bevel resolution"},
- {"setBevelAmount", ( PyCFunction ) Text3d_setBevelAmount,
- METH_VARARGS, "() - Sets bevel resolution"},
- {"getDefaultResolution", ( PyCFunction ) Text3d_getDefaultResolution,
- METH_NOARGS, "() - Return Default text resolution"},
- {"setDefaultResolution", ( PyCFunction ) Text3d_setDefaultResolution,
- METH_VARARGS, "() - Sets Default text Resolution"},
- {"getWidth", ( PyCFunction ) Text3d_getWidth,
- METH_NOARGS, "() - Return curve width"},
- {"setWidth", ( PyCFunction ) Text3d_setWidth,
- METH_VARARGS, "(int) - Sets curve width"},
- {"getExtrudeDepth", ( PyCFunction ) Text3d_getExtrudeDepth,
- METH_NOARGS, "() - Gets Text3d ExtrudeDepth"},
- {"setExtrudeDepth", ( PyCFunction ) Text3d_setExtrudeDepth,
- METH_VARARGS, "() - Sets Text3d ExtrudeDepth"},
- {"getExtrudeBevelDepth", ( PyCFunction ) Text3d_getExtrudeBevelDepth,
- METH_NOARGS, "() - Gets Text3d ExtrudeBevelDepth"},
- {"setExtrudeBevelDepth", ( PyCFunction ) Text3d_setExtrudeBevelDepth,
- METH_VARARGS, "() - Sets Text3d ExtrudeBevelDepth"},
- {"getShear", ( PyCFunction ) Text3d_getShear,
- METH_NOARGS, "() - Gets Text3d Shear Data"},
- {"setShear", ( PyCFunction ) Text3d_setShear,
- METH_VARARGS, "() - Sets Text3d Shear Data"},
- {"getSize", ( PyCFunction ) Text3d_getSize,
- METH_NOARGS, "() - Gets Text3d Size Data"},
- {"setSize", ( PyCFunction ) Text3d_setSize,
- METH_VARARGS, "() - Sets Text3d Size Data"},
- {"getLineSeparation", ( PyCFunction ) Text3d_getLineSeparation,
- METH_NOARGS, "() - Gets Text3d LineSeparation Data"},
- {"setLineSeparation", ( PyCFunction ) Text3d_setLineSeparation,
- METH_VARARGS, "() - Sets Text3d LineSeparation Data"},
- {"getSpacing", ( PyCFunction ) Text3d_getSpacing,
- METH_NOARGS, "() - Gets Text3d letter spacing"},
- {"setSpacing", ( PyCFunction ) Text3d_setSpacing,
- METH_VARARGS, "() - Sets Text3d letter spacing"},
- {"getXoffset", ( PyCFunction ) Text3d_getXoffset,
- METH_NOARGS, "() - Gets Text3d Xoffset Data"},
- {"setXoffset", ( PyCFunction ) Text3d_setXoffset,
- METH_VARARGS, "() - Sets Text3d Xoffset Data"},
- {"getYoffset", ( PyCFunction ) Text3d_getYoffset,
- METH_NOARGS, "() - Gets Text3d Yoffset Data"},
- {"setYoffset", ( PyCFunction ) Text3d_setYoffset,
- METH_VARARGS, "() - Sets Text3d Yoffset Data"},
- {"getAlignment", ( PyCFunction ) Text3d_getAlignment,
- METH_NOARGS, "() - Gets Text3d Alignment Data"},
- {"setAlignment", ( PyCFunction ) Text3d_setAlignment,
- METH_VARARGS, "() - Sets Text3d Alignment Data"},
- {"getFont", ( PyCFunction ) Text3d_getFont,
- METH_NOARGS, "() - Gets font list for Text3d"},
- {"setFont", ( PyCFunction ) Text3d_setFont,
- METH_VARARGS, "() - Sets font for Text3d"},
- {"addFrame", ( PyCFunction ) Text3d_addFrame,
- METH_NOARGS, "() - adds a new text frame"},
- {"removeFrame", ( PyCFunction ) Text3d_removeFrame,
- METH_VARARGS, "(index) - remove this frame"},
- {NULL, NULL, 0, NULL}
-};
-
-
-static PyObject *Text3d_getTotalFrames( BPy_Text3d * self )
-{
- return PyInt_FromLong( (long)(self->curve->totbox ) );
-}
-
-static PyObject *Text3d_getActiveFrame( BPy_Text3d * self )
-{
- return PyInt_FromLong( (long)(self->curve->actbox-1) );
-}
-
-static int Text3d_setActiveFrame( BPy_Text3d * self, PyObject * value )
-{
- struct Curve *curve= self->curve;
- PyObject* frame_int = PyNumber_Int( value );
- int index;
-
-
- if( !frame_int )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
-
- index = ( int )PyInt_AS_LONG( frame_int );
- index ++;
- if (index < 1 || index > curve->totbox)
- return EXPP_ReturnIntError( PyExc_IndexError,
- "index out of range" );
-
- curve->actbox = index;
-
- return 0;
-}
-
-
-static PyObject *getFloatAttr( BPy_Text3d *self, void *type )
-{
- float param;
- struct Curve *curve= self->curve;
-
- switch( (int)type ) {
- case EXPP_T3D_ATTR_FRAME_WIDTH:
- param = curve->tb[curve->actbox-1].w;
- break;
- case EXPP_T3D_ATTR_FRAME_HEIGHT:
- param = curve->tb[curve->actbox-1].h;
- break;
- case EXPP_T3D_ATTR_FRAME_X:
- param = curve->tb[curve->actbox-1].x;
- break;
- case EXPP_T3D_ATTR_FRAME_Y:
- param = curve->tb[curve->actbox-1].y;
- break;
-
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type in getFloatAttr" );
- }
- return PyFloat_FromDouble( param );
-}
-
-static int setFloatAttrClamp( BPy_Text3d *self, PyObject *value, void *type )
-{
- float *param;
- struct Curve *curve= self->curve;
- float min, max;
-
- switch( (int)type ) {
- case EXPP_T3D_ATTR_FRAME_WIDTH:
- min = 0.0;
- max = 50.0;
- param = &(curve->tb[curve->actbox-1].w);
- break;
- case EXPP_T3D_ATTR_FRAME_HEIGHT:
- min = 0.0;
- max = 50.0;
- param = &(curve->tb[curve->actbox-1].h);
- break;
- case EXPP_T3D_ATTR_FRAME_X:
- min = 0.0;
- max = 50.0;
- param = &(curve->tb[curve->actbox-1].x);
- break;
- case EXPP_T3D_ATTR_FRAME_Y:
- min = 0.0;
- max = 50.0;
- param = &(curve->tb[curve->actbox-1].y);
- break;
-
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setFloatAttrClamp" );
- }
-
- return EXPP_setFloatClamped( value, param, min, max );
-}
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Text3d_getseters[] = {
- GENERIC_LIB_GETSETATTR, /* didnt have any attributes, at least lets have the standard ID attrs */
- {"activeFrame",
- (getter)Text3d_getActiveFrame, (setter)Text3d_setActiveFrame,
- "the index of the active text frame",
- NULL},
- {"totalFrames",
- (getter)Text3d_getTotalFrames, (setter)NULL,
- "the total number of text frames",
- NULL},
-
- {"frameWidth",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "the width of the active text frame",
- (void *)EXPP_T3D_ATTR_FRAME_WIDTH},
- {"frameHeight",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "the height of the active text frame",
- (void *)EXPP_T3D_ATTR_FRAME_HEIGHT},
- {"frameX",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "the X position of the active text frame",
- (void *)EXPP_T3D_ATTR_FRAME_X},
- {"frameY",
- (getter)getFloatAttr, (setter)setFloatAttrClamp,
- "the Y position of the active text frame",
- (void *)EXPP_T3D_ATTR_FRAME_Y},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python Text3d_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Text3d_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
- "Text3d", /* tp_name */
- sizeof( BPy_Text3d ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- NULL, /* tp_dealloc */
- NULL, /* tp_print */
- NULL, /* tp_getattr */
- NULL, /* tp_setattr */
- ( cmpfunc ) Text3d_compare, /* tp_compare */
- ( reprfunc ) Text3d_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_Text3d_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Text3d_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
-};
-
-
-/*
- * Text3d_update( )
- * method to update display list for a Curve.
- */
-static PyObject *Text3d_update( BPy_Text3d * self )
-{
- freedisplist( &self->curve->disp );
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: M_Text3d_New */
-/* Python equivalent: Blender.Text3d.New */
-/*****************************************************************************/
-
-PyObject *M_Text3d_New( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- BPy_Text3d *pytext3d; /* for Curve Data object wrapper in Python */
- Text3d *bltext3d = 0; /* for actual Curve Data we create in Blender */
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected string argument or no argument" ) );
-
- bltext3d = add_curve( "Text", OB_FONT ); /* first create the Curve Data in Blender */
- bltext3d->vfont= get_builtin_font();
- bltext3d->vfont->id.us++;
- bltext3d->str= MEM_mallocN(12, "str");
- strcpy(bltext3d->str, "Text");
- bltext3d->pos= 4;
-
- bltext3d->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo");
- bltext3d->totbox= bltext3d->actbox= 1;
- bltext3d->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox");
- bltext3d->tb[0].w = bltext3d->tb[0].h = 0.0;
-
- if( bltext3d == NULL ) /* bail out if add_curve() failed */
- return ( EXPP_ReturnPyObjError
- ( PyExc_RuntimeError,
- "couldn't create Curve Data in Blender" ) );
-
- /* return user count to zero because add_curve() inc'd it */
- bltext3d->id.us = 0;
- /* create python wrapper obj */
- pytext3d = ( BPy_Text3d * ) PyObject_NEW( BPy_Text3d, &Text3d_Type );
-
- if( pytext3d == NULL )
- return ( EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create Curve Data object" ) );
-
- pytext3d->curve = bltext3d; /* link Python curve wrapper to Blender Curve */
- if( name )
- rename_id( &bltext3d->id, name );
-
- Text3d_update ( pytext3d );
- return ( PyObject * ) pytext3d;
-}
-
-PyObject *M_Text3d_Get( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- Text3d *curv_iter;
- BPy_Text3d *wanted_curv;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) ) /* expects nothing or a string */
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected string argument" ) );
- if( name ) { /*a name has been given */
- /* Use the name to search for the curve requested */
- wanted_curv = NULL;
- curv_iter = G.main->curve.first;
-
- while( ( curv_iter ) && ( wanted_curv == NULL ) ) {
-
- if( strcmp( name, curv_iter->id.name + 2 ) == 0 ) {
- wanted_curv = ( BPy_Text3d * )
- PyObject_NEW( BPy_Text3d, &Text3d_Type );
- if( wanted_curv )
- wanted_curv->curve = curv_iter;
- }
-
- curv_iter = curv_iter->id.next;
- }
-
- if( wanted_curv == NULL ) { /* Requested curve doesn't exist */
- char error_msg[64];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Curve \"%s\" not found", name );
- return ( EXPP_ReturnPyObjError
- ( PyExc_NameError, error_msg ) );
- }
-
- return ( PyObject * ) wanted_curv;
- } /* end of if(name) */
- else {
- /* no name has been given; return a list of all curves by name. */
- PyObject *curvlist;
-
- curv_iter = G.main->curve.first;
- curvlist = PyList_New( 0 );
-
- if( curvlist == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" ) );
-
- while( curv_iter && curv_iter->vfont ) {
- BPy_Text3d *found_text3d =
- ( BPy_Text3d * ) PyObject_NEW( BPy_Text3d,
- &Text3d_Type );
- found_text3d->curve = curv_iter;
- PyList_Append( curvlist, ( PyObject * ) found_text3d );
- Py_DECREF(found_text3d);
- curv_iter = curv_iter->id.next;
- }
- return ( curvlist );
- }
-}
-
-static PyObject *generate_ModuleIntConstant(char *name, int value)
-{
- PyObject *constant = PyConstant_New();
-
- PyConstant_Insert((BPy_constant*)constant,
- "value", PyInt_FromLong(value));
- PyConstant_Insert((BPy_constant*)constant,
- "name", PyString_FromString(name));
-
- Py_INCREF(constant);
- return constant;
-}
-
-PyObject *Text3d_Init( void )
-{
- //module
- PyObject *submodule, *dict;
-
- //add module...
- if( PyType_Ready( &Text3d_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Text3d", M_Text3d_methods,
- M_Text3D_doc);
-
- //add constants to module...
- PyModule_AddObject( submodule, "LEFT",
- generate_ModuleIntConstant("Text3d.LEFT", CU_LEFT));
- PyModule_AddObject( submodule, "MIDDLE",
- generate_ModuleIntConstant("Text3d.MIDDLE", CU_MIDDLE));
- PyModule_AddObject( submodule, "RIGHT",
- generate_ModuleIntConstant("Text3d.RIGHT", CU_RIGHT));
- PyModule_AddObject( submodule, "FLUSH",
- generate_ModuleIntConstant("Text3d.FLUSH", CU_FLUSH));
- PyModule_AddObject( submodule, "JUSTIFY",
- generate_ModuleIntConstant("Text3d.JUSTIFY", CU_JUSTIFY));
- PyModule_AddObject( submodule, "DRAW3D",
- generate_ModuleIntConstant("Text3d.DRAW3D", CU_3D));
- PyModule_AddObject( submodule, "DRAWFRONT",
- generate_ModuleIntConstant("Text3d.DRAWFRONT", CU_FRONT));
- PyModule_AddObject( submodule, "DRAWBACK",
- generate_ModuleIntConstant("Text3d.DRAWBACK", CU_BACK));
- PyModule_AddObject( submodule, "UVORCO",
- generate_ModuleIntConstant("Text3d.UVORCO", CU_UV_ORCO));
- dict = PyModule_GetDict( submodule );
- PyDict_SetItemString( dict, "Font", Font_Init( ) );
- return ( submodule );
-}
-
-/****************************************************************************
- * Function: Text3d_repr
- * Description: Callback function for the BPy_Text3d type to It
- * build a meaninful string to represent Text3d objects.
- *
- ***************************************************************************/
-
-static PyObject *Text3d_repr( BPy_Text3d * self )
-{
- /* skip over CU in idname. CUTEXT */
- return PyString_FromFormat( "[Text3d \"%s\"]",
- self->curve->id.name + 2 );
-}
-
-/****************************************************************************
- * Function: Text3d_compare
- * Description: Callback function for the BPy_Text3d type to Compare 2 types
- *
- ***************************************************************************/
-
-/* mat_a==mat_b or mat_a!=mat_b*/
-static int Text3d_compare( BPy_Text3d * a, BPy_Text3d * b )
-{
- return ( a->curve == b->curve) ? 0 : -1;
-}
-
-struct Text3d *Text3d_FromPyObject( PyObject * py_obj )
-{
- BPy_Text3d *blen_obj;
-
- blen_obj = ( BPy_Text3d * ) py_obj;
- return ((struct Text3d*) blen_obj->curve );
-}
-
-static PyObject *return_ModuleConstant( char *constant_name){
-
- PyObject *module = NULL, *dict = NULL, *constant = NULL;;
-
- module = PyImport_AddModule("Blender.Text3d");
- if(!module){ //null = error returning module
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "error encountered with returning module constant..." ) );
- }
- dict = PyModule_GetDict(module); //never fails
-
- constant = PyDict_GetItemString(dict, constant_name);
- if(!constant){ //null = key not found
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "error encountered with returning module constant..." ) );
- }
-
- return EXPP_incr_ret( constant );
-}
-
-static PyObject *Text3d_getName( BPy_Text3d * self )
-{
- return Curve_getName( (BPy_Curve*)self );
-}
-
-static PyObject *Text3d_setName( BPy_Text3d * self, PyObject * args )
-{
- return Curve_setName( (BPy_Curve*)self,args );
-}
-
-static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * value )
-{
- char *text = PyString_AsString(value);
-
- if( !text )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected string argument" );
-
- /*
- * If the text is currently being edited, then we have to put the
- * text into the edit buffer.
- */
-
- if( G.obedit && G.obedit->data == self->curve ) {
- short qual = G.qual;
- G.qual = 0; /* save key qualifier, then clear it */
- self->curve->pos = self->curve->len = 0;
- while ( *text )
- do_textedit( 0, 0, *text++ );
- G.qual = qual;
- } else {
- short len = (short)strlen(text);
- MEM_freeN( self->curve->str );
- self->curve->str = MEM_callocN( len+sizeof(wchar_t), "str" );
- strcpy( self->curve->str, text );
- self->curve->pos = len;
- self->curve->len = len;
-
- if( self->curve->strinfo )
- MEM_freeN( self->curve->strinfo );
- /* don't know why this is +4, just duplicating load_editText() */
- self->curve->strinfo = MEM_callocN( (len+4) *sizeof(CharInfo),
- "strinfo");
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *Text3d_getText( BPy_Text3d * self )
-{
- if( self->curve->str )
- return PyString_FromString( self->curve->str );
-
- Py_RETURN_NONE;
-}
-
-static PyObject* Text3d_getDrawMode(BPy_Text3d* self)
-{
- PyObject *tuple = NULL;
- int size = 0, pos = 0;
-
- //get the tuple size
- if(self->curve->flag & CU_3D)
- size++;
- if (self->curve->flag & CU_FRONT)
- size++;
- if (self->curve->flag & CU_BACK)
- size++;
-
- //generate tuple
- tuple = PyTuple_New(size);
-
- //load tuple
- if(self->curve->flag & CU_3D){
- PyTuple_SET_ITEM( tuple, pos, return_ModuleConstant("DRAW3D"));
- pos++;
- }
- if (self->curve->flag & CU_FRONT){
- PyTuple_SET_ITEM( tuple, pos, return_ModuleConstant("DRAWFRONT"));
- pos++;
- }
- if (self->curve->flag & CU_BACK){
- PyTuple_SET_ITEM( tuple, pos, return_ModuleConstant("DRAWBACK"));
- pos++;
- }
-
- return tuple;
-}
-
-static PyObject* Text3d_setDrawMode(BPy_Text3d* self,PyObject* args)
-{
- PyObject *listObject = NULL;
- int size, i;
- short temp;
-
- size = PySequence_Length(args);
- if ( size == 1 ) {
- listObject = PySequence_GetItem(args, 0);
- if ( PySequence_Check(listObject) ) {
- size = PySequence_Length(listObject);
- }else{ //not a sequence but maybe a single constant
- Py_INCREF(args);
- listObject = args;
- }
- } else { //a list of objects (non-sequence)
- Py_INCREF(args);
- listObject = args;
- }
- if ( size > 3 || size < 1 ) {
- //bad number of arguments
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "too many parameters - expects 1 - 3 constants" ) );
- }
- //clear bits
- temp = self->curve->flag; //in case of failure
- if(self->curve->flag & CU_3D)
- self->curve->flag &= ~CU_3D;
- if(self->curve->flag & CU_FRONT)
- self->curve->flag &= ~CU_FRONT;
- if(self->curve->flag & CU_BACK)
- self->curve->flag &= ~CU_BACK;
-
- //parse and set bits
- for (i = 0; i < size; i++) {
- PyObject *v;
- int value;
-
- v = PySequence_GetItem(listObject, i);
- if (v == NULL) { //unable to return item - null = failure
- Py_DECREF(listObject);
- self->curve->flag = temp;
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unable to parse list" ) );
- }
- if( !BPy_Constant_Check(v)){
- Py_DECREF(listObject);
- Py_DECREF(v);
- self->curve->flag = temp;
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "bad argument types - expects module constants" ) );
- }
- value = PyInt_AS_LONG(PyDict_GetItemString(
- ((BPy_constant*)v)->dict, "value"));
- self->curve->flag |= (short)value;
- Py_DECREF(v);
- }
- Py_DECREF(listObject);
- Py_RETURN_NONE;
-}
-
-static PyObject* Text3d_getUVorco(BPy_Text3d* self)
-{
- if(self->curve->flag & CU_UV_ORCO)
- return EXPP_incr_ret_True();
- else
- return EXPP_incr_ret_False();
-}
-
-static PyObject* Text3d_setUVorco(BPy_Text3d* self,PyObject* args)
-{
- int flag;
-
- if( !PyArg_ParseTuple( args, "i", &flag ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected TRUE or FALSE (1 or 0)" );
-
- if( flag < 0 || flag > 1 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected TRUE or FALSE (1 or 0)" );
-
- if( flag )
- self->curve->flag |= CU_UV_ORCO;
- else
- self->curve->flag &= ~CU_UV_ORCO;
-
- Py_RETURN_NONE;
-}
-
-static PyObject* Text3d_getBevelAmount(BPy_Text3d* self)
-{
- return Curve_getBevresol((BPy_Curve*)self);
-}
-
-static PyObject* Text3d_setBevelAmount(BPy_Text3d* self,PyObject* args)
-{
- return Curve_setBevresol((BPy_Curve*)self,args);
-}
-
-static PyObject *Text3d_getDefaultResolution( BPy_Text3d * self )
-{
- return Curve_getResolu( (BPy_Curve*)self );
-}
-
-static PyObject *Text3d_setDefaultResolution( BPy_Text3d * self, PyObject * args )
-{
- return Curve_setResolu( (BPy_Curve*)self,args );
-}
-
-static PyObject *Text3d_getWidth( BPy_Text3d * self )
-{
- return Curve_getWidth( (BPy_Curve*)self );
-}
-
-static PyObject *Text3d_setWidth( BPy_Text3d * self, PyObject * args )
-{
- return Curve_setWidth( (BPy_Curve*)self,args );
-}
-
-static PyObject *Text3d_getExtrudeDepth( BPy_Text3d * self )
-{
- return Curve_getExt1( (BPy_Curve*)self );
-}
-
-static PyObject *Text3d_setExtrudeDepth( BPy_Text3d * self, PyObject * args )
-{
- return Curve_setExt1( (BPy_Curve*)self,args );
-}
-
-static PyObject *Text3d_getExtrudeBevelDepth( BPy_Text3d * self )
-{
- return Curve_getExt2( (BPy_Curve*)self );
-}
-
-static PyObject *Text3d_setExtrudeBevelDepth( BPy_Text3d * self, PyObject * args )
-{
- return Curve_setExt2( (BPy_Curve*)self,args );
-}
-
-static PyObject *Text3d_getShear( BPy_Text3d * self )
-{
- PyObject *attr = PyFloat_FromDouble( (double) self->curve->shear );
-
- if( attr )
- return attr;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Curve.shear attribute" ) );
-}
-
-static PyObject *Text3d_setShear( BPy_Text3d * self, PyObject * args )
-{
- float value;
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
-
- if(value > 1.0f || value < -1.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 1.0 and -1.0" ) );
- self->curve->shear = value;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Text3d_getSize( BPy_Text3d * self )
-{
- PyObject *attr = PyFloat_FromDouble( (double) self->curve->fsize );
-
- if( attr )
- return attr;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Curve.fsize attribute" ) );
-}
-
-static PyObject *Text3d_setSize( BPy_Text3d * self, PyObject * args )
-{
- float value;
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
-
- if(value > 10.0f || value < 0.1f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 10.0 and 0.1" ) );
- self->curve->fsize = value;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Text3d_getLineSeparation( BPy_Text3d * self )
-{
- PyObject *attr = PyFloat_FromDouble( (double) self->curve->linedist );
-
- if( attr )
- return attr;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Curve.linedist attribute" ) );
-}
-
-static PyObject *Text3d_setLineSeparation( BPy_Text3d * self, PyObject * args )
-{
- float value;
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
-
- if(value > 10.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 10.0 and 0.0" ) );
- self->curve->linedist = value;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Text3d_getSpacing( BPy_Text3d * self )
-{
- PyObject *attr = PyFloat_FromDouble( (double) self->curve->spacing );
-
- if( attr )
- return attr;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Curve.spacing attribute" ) );
-}
-
-static PyObject *Text3d_setSpacing( BPy_Text3d * self, PyObject * args )
-{
- float value;
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
-
- if(value > 10.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 10.0 and 0.0" ) );
- self->curve->spacing = value;
-
- Py_RETURN_NONE;
-}
-static PyObject *Text3d_getXoffset( BPy_Text3d * self )
-{
- PyObject *attr = PyFloat_FromDouble( (double) self->curve->xof );
-
- if( attr )
- return attr;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Curve.xof attribute" ) );
-}
-
-static PyObject *Text3d_setXoffset( BPy_Text3d * self, PyObject * args )
-{
- float value;
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
-
- if(value > 50.0f || value < -50.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 50.0 and -50.0" ) );
- self->curve->xof = value;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Text3d_getYoffset( BPy_Text3d * self )
-{
- PyObject *attr = PyFloat_FromDouble( (double) self->curve->yof );
-
- if( attr )
- return attr;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Curve.yof attribute" ) );
-}
-
-static PyObject *Text3d_setYoffset( BPy_Text3d * self, PyObject * args )
-{
- float value;
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
-
- if(value > 50.0f || value < -50.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 50.0 and -50.0" ) );
- self->curve->yof = value;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Text3d_getAlignment( BPy_Text3d * self )
-{
- if(self->curve->spacemode == CU_LEFT){
- return return_ModuleConstant("LEFT");
- }else if (self->curve->spacemode == CU_MIDDLE){
- return return_ModuleConstant("MIDDLE");
- }else if (self->curve->spacemode == CU_RIGHT){
- return return_ModuleConstant("RIGHT");
- }else if (self->curve->spacemode == CU_FLUSH){
- return return_ModuleConstant("FLUSH");
- }else if (self->curve->spacemode == CU_JUSTIFY){
- return return_ModuleConstant("JUSTIFY");
- }
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Curve.spacemode attribute" ) );
-}
-
-static PyObject *Text3d_setAlignment( BPy_Text3d * self, PyObject * args )
-{
- BPy_constant *constant;
- int value;
-
- if( !PyArg_ParseTuple( args, "O!", &constant_Type, &constant ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected module constant" ) );
-
- value = PyInt_AS_LONG(PyDict_GetItemString(constant->dict, "value"));
- self->curve->spacemode = (short)value;
-
- Py_RETURN_NONE;
-}
-
-
-/*****************************************************************************
- * Function: Text3d_CreatePyObject
- * Description: This function will create a new BPy_Text3d from an existing
- * Blender structure.
- *****************************************************************************/
-
-PyObject *Text3d_CreatePyObject( Text3d * text3d )
-{
- BPy_Text3d *pytext3d;
-
- pytext3d = ( BPy_Text3d * ) PyObject_NEW( BPy_Text3d, &Text3d_Type );
-
- if( !pytext3d )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Text3d object" );
-
- pytext3d->curve = text3d;
-
- return ( PyObject * ) pytext3d;
-}
-
-static PyObject *Text3d_getFont( BPy_Text3d * self )
-{
- if (self->curve)
- return Font_CreatePyObject (self->curve->vfont);
- else
- Py_RETURN_NONE;
-}
-
-static PyObject *Text3d_setFont( BPy_Text3d * self, PyObject * args )
-{
- BPy_Font *pyobj= NULL;
- VFont *vf; //, *vfont;
- if( !PyArg_ParseTuple( args, "|O!",&Font_Type, &pyobj) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string" );
- if( !pyobj ) {
- // pyobj= M_Text3d_LoadFont (self, Py_BuildValue("(s)", "<builtin>"));
- self->curve->vfont= get_builtin_font ();
- Py_RETURN_NONE;
- }
- vf= exist_vfont(pyobj->font->name);
- if (vf) {
- id_us_plus((ID *)vf);
- self->curve->vfont->id.us--;
- self->curve->vfont= vf;
- }
- else {
- vf= load_vfont (pyobj->font->name);
- if (vf) {
- id_us_plus((ID *)vf);
- self->curve->vfont->id.us--;
- self->curve->vfont= vf;
- }
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *Text3d_addFrame( BPy_Text3d * self )
-{
- Curve *cu = self->curve;
-
- if (cu->totbox >= 256)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "limited to 256 frames" );
-
- cu->totbox++;
- cu->tb[cu->totbox-1]= cu->tb[cu->totbox-2];
- Py_RETURN_NONE;
-}
-
-static PyObject *Text3d_removeFrame( BPy_Text3d * self, PyObject * args )
-{
- Curve *cu = self->curve;
- int index, i;
-
- if (cu->totbox == 1)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot remove the last frame" );
-
- index = cu->totbox-1;
-
- if( !PyArg_ParseTuple( args, "|i", &index ) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "expected an int" );
-
- if (index < 0 || index >= cu->totbox )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "index out of range" );
-
- for (i = index; i < cu->totbox; i++) cu->tb[i]= cu->tb[i+1];
- cu->totbox--;
- cu->actbox--;
- Py_RETURN_NONE;
-}
-
-
-PyObject *M_Text3d_LoadFont( PyObject * self, PyObject * value )
-{
- char *fontfile= PyString_AsString(value);
- FILE *file= NULL;
- VFont *vf= NULL;
-
- if( !fontfile )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a string" );
- vf= exist_vfont(fontfile);
- if( vf )
- return Font_CreatePyObject( vf );
- /* No use for that -- lukep
- else
- vf= NULL;
- */
- file= fopen( fontfile, "r");
-
- if( file || !strcmp (fontfile, "<builtin>") ) {
- load_vfont( fontfile );
- if(file) fclose( file );
- vf = exist_vfont( fontfile );
- if(vf)
- return Font_CreatePyObject( vf );
- Py_RETURN_NONE;
- }
-
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "string isn't filename or fontpath" );
-}
-
diff --git a/source/blender/python/api2_2x/Text3d.h b/source/blender/python/api2_2x/Text3d.h
deleted file mode 100644
index ddab385ca66..00000000000
--- a/source/blender/python/api2_2x/Text3d.h
+++ /dev/null
@@ -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 */
-
diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c
deleted file mode 100644
index 66ed88df8d0..00000000000
--- a/source/blender/python/api2_2x/Texture.c
+++ /dev/null
@@ -1,2516 +0,0 @@
-/*
- * $Id: Texture.c 12535 2007-11-09 10:29:19Z 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, Nathan Letwory, Joilnen B. Leite, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-#include "Texture.h" /*This must come first*/
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_idprop.h"
-#include "BKE_library.h"
-#include "BKE_texture.h"
-#include "BKE_utildefines.h"
-
-#include "BLI_blenlib.h"
-
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_texture_types.h"
-
-#include "MTex.h"
-#include "Image.h"
-#include "Ipo.h"
-#include "IDProp.h"
-#include "constant.h"
-#include "blendef.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-#include "vector.h" /* for Texture_evaluate(vec) */
-#include "Material.h" /* for EXPP_Colorband_fromPyList and EXPP_PyList_fromColorband */
-#include "RE_shader_ext.h"
-
-/*****************************************************************************/
-/* Blender.Texture constants */
-/*****************************************************************************/
-#define EXPP_TEX_TYPE_NONE 0
-
-#define EXPP_TEX_TYPE_MIN EXPP_TEX_TYPE_NONE
-#define EXPP_TEX_TYPE_MAX TEX_DISTNOISE
-
-#define EXPP_TEX_ANIMFRAME_MIN 0
-#define EXPP_TEX_ANIMFRAME_MAX ((int)MAXFRAMEF)
-#define EXPP_TEX_ANIMLEN_MIN 0
-#define EXPP_TEX_ANIMLEN_MAX ((int)(MAXFRAMEF)/2)
-#define EXPP_TEX_ANIMMONSTART_MIN 0
-#define EXPP_TEX_ANIMMONSTART_MAX ((int)MAXFRAMEF)
-#define EXPP_TEX_ANIMMONDUR_MIN 0
-#define EXPP_TEX_ANIMMONDUR_MAX 250
-#define EXPP_TEX_ANIMOFFSET_MIN -((int)MAXFRAMEF)
-#define EXPP_TEX_ANIMOFFSET_MAX ((int)MAXFRAMEF)
-#define EXPP_TEX_ANIMSTART_MIN 1
-#define EXPP_TEX_ANIMSTART_MAX ((int)MAXFRAMEF)
-#define EXPP_TEX_FIEIMA_MIN 1
-#define EXPP_TEX_FIEIMA_MAX 200
-#define EXPP_TEX_NOISEDEPTH_MIN 0
-#define EXPP_TEX_NOISEDEPTH_MAX 6
-/* max depth is different for magic type textures */
-#define EXPP_TEX_NOISEDEPTH_MAX_MAGIC 10
-#define EXPP_TEX_REPEAT_MIN 1
-#define EXPP_TEX_REPEAT_MAX 512
-
-#define EXPP_TEX_FILTERSIZE_MIN 0.1f
-#define EXPP_TEX_FILTERSIZE_MAX 25.0f
-#define EXPP_TEX_NOISESIZE_MIN 0.0001f
-#define EXPP_TEX_NOISESIZE_MAX 2.0f
-#define EXPP_TEX_BRIGHTNESS_MIN 0.0f
-#define EXPP_TEX_BRIGHTNESS_MAX 2.0f
-#define EXPP_TEX_CONTRAST_MIN 0.01f
-#define EXPP_TEX_CONTRAST_MAX 5.0f
-#define EXPP_TEX_CROP_MIN -10.0f
-#define EXPP_TEX_CROP_MAX 10.0f
-#define EXPP_TEX_RGBCOL_MIN 0.0f
-#define EXPP_TEX_RGBCOL_MAX 2.0f
-#define EXPP_TEX_TURBULENCE_MIN 0.0f
-#define EXPP_TEX_TURBULENCE_MAX 200.0f
-#define EXPP_TEX_MH_G_MIN 0.0001f
-#define EXPP_TEX_MH_G_MAX 2.0f
-#define EXPP_TEX_LACUNARITY_MIN 0.0f
-#define EXPP_TEX_LACUNARITY_MAX 6.0f
-#define EXPP_TEX_OCTS_MIN 0.0f
-#define EXPP_TEX_OCTS_MAX 8.0f
-#define EXPP_TEX_ISCALE_MIN 0.0f
-#define EXPP_TEX_ISCALE_MAX 10.0f
-#define EXPP_TEX_EXP_MIN 0.010f
-#define EXPP_TEX_EXP_MAX 10.0f
-#define EXPP_TEX_WEIGHT1_MIN -2.0f
-#define EXPP_TEX_WEIGHT1_MAX 2.0f
-#define EXPP_TEX_WEIGHT2_MIN -2.0f
-#define EXPP_TEX_WEIGHT2_MAX 2.0f
-#define EXPP_TEX_WEIGHT3_MIN -2.0f
-#define EXPP_TEX_WEIGHT3_MAX 2.0f
-#define EXPP_TEX_WEIGHT4_MIN -2.0f
-#define EXPP_TEX_WEIGHT4_MAX 2.0f
-#define EXPP_TEX_DISTAMNT_MIN 0.0f
-#define EXPP_TEX_DISTAMNT_MAX 10.0f
-
-/* i can't find these defined anywhere- they're just taken from looking at */
-/* the button creation code in source/blender/src/buttons_shading.c */
-/* cloud stype */
-#define EXPP_TEX_STYPE_CLD_DEFAULT 0
-#define EXPP_TEX_STYPE_CLD_COLOR 1
-/* wood stype */
-#define EXPP_TEX_STYPE_WOD_BANDS 0
-#define EXPP_TEX_STYPE_WOD_RINGS 1
-#define EXPP_TEX_STYPE_WOD_BANDNOISE 2
-#define EXPP_TEX_STYPE_WOD_RINGNOISE 3
-/* magic stype */
-#define EXPP_TEX_STYPE_MAG_DEFAULT 0
-/* marble stype */
-#define EXPP_TEX_STYPE_MBL_SOFT 0
-#define EXPP_TEX_STYPE_MBL_SHARP 1
-#define EXPP_TEX_STYPE_MBL_SHARPER 2
-/* blend stype */
-#define EXPP_TEX_STYPE_BLN_LIN 0
-#define EXPP_TEX_STYPE_BLN_QUAD 1
-#define EXPP_TEX_STYPE_BLN_EASE 2
-#define EXPP_TEX_STYPE_BLN_DIAG 3
-#define EXPP_TEX_STYPE_BLN_SPHERE 4
-#define EXPP_TEX_STYPE_BLN_HALO 5
-/* stucci stype */
-#define EXPP_TEX_STYPE_STC_PLASTIC 0
-#define EXPP_TEX_STYPE_STC_WALLIN 1
-#define EXPP_TEX_STYPE_STC_WALLOUT 2
-/* noise stype */
-#define EXPP_TEX_STYPE_NSE_DEFAULT 0
-/* image stype */
-#define EXPP_TEX_STYPE_IMG_DEFAULT 0
-/* plug-in stype */
-#define EXPP_TEX_STYPE_PLG_DEFAULT 0
-/* envmap stype */
-#define EXPP_TEX_STYPE_ENV_STATIC 0
-#define EXPP_TEX_STYPE_ENV_ANIM 1
-#define EXPP_TEX_STYPE_ENV_LOAD 2
-/* musgrave stype */
-#define EXPP_TEX_STYPE_MUS_MFRACTAL 0
-#define EXPP_TEX_STYPE_MUS_RIDGEDMF 1
-#define EXPP_TEX_STYPE_MUS_HYBRIDMF 2
-#define EXPP_TEX_STYPE_MUS_FBM 3
-#define EXPP_TEX_STYPE_MUS_HTERRAIN 4
-/* voronoi stype */
-#define EXPP_TEX_STYPE_VN_INT 0
-#define EXPP_TEX_STYPE_VN_COL1 1
-#define EXPP_TEX_STYPE_VN_COL2 2
-#define EXPP_TEX_STYPE_VN_COL3 3
-
-#define EXPP_TEX_EXTEND_MIN TEX_EXTEND
-#define EXPP_TEX_EXTEND_MAX TEX_CHECKER
-
-#define EXPP_TEX_NOISE_SINE 0
-#define EXPP_TEX_NOISE_SAW 1
-#define EXPP_TEX_NOISE_TRI 2
-#define EXPP_TEX_NOISEBASIS2 0xffff
-
-/****************************************************************************/
-/* Texture String->Int maps */
-/****************************************************************************/
-
-static const EXPP_map_pair tex_type_map[] = {
- {"None", EXPP_TEX_TYPE_NONE},
- {"Clouds", TEX_CLOUDS},
- {"Wood", TEX_WOOD},
- {"Marble", TEX_MARBLE},
- {"Magic", TEX_MAGIC},
- {"Blend", TEX_BLEND},
- {"Stucci", TEX_STUCCI},
- {"Noise", TEX_NOISE},
- {"Image", TEX_IMAGE},
- {"Plugin", TEX_PLUGIN},
- {"EnvMap", TEX_ENVMAP},
- {"Musgrave", TEX_MUSGRAVE},
- {"Voronoi", TEX_VORONOI},
- {"DistortedNoise", TEX_DISTNOISE},
- {NULL, 0}
-};
-
-static const EXPP_map_pair tex_flag_map[] = {
-/* NOTE "CheckerOdd" and "CheckerEven" are new */
- {"ColorBand", TEX_COLORBAND },
- {"FlipBlend", TEX_FLIPBLEND},
- {"NegAlpha", TEX_NEGALPHA},
- {"CheckerOdd",TEX_CHECKER_ODD},
- {"CheckerEven",TEX_CHECKER_EVEN},
- {"PreviewAlpha",TEX_PRV_ALPHA},
- {"RepeatXMirror",TEX_REPEAT_XMIR},
- {"RepeatYMirror",TEX_REPEAT_YMIR},
- {NULL, 0}
-};
-
-/* NOTE: flags moved to image... */
-static const EXPP_map_pair tex_imageflag_map[] = {
- {"InterPol", TEX_INTERPOL},
- {"UseAlpha", TEX_USEALPHA},
- {"MipMap", TEX_MIPMAP},
- {"Rot90", TEX_IMAROT},
- {"CalcAlpha", TEX_CALCALPHA},
- {"NormalMap", TEX_NORMALMAP},
- {NULL, 0}
-};
-
-static const EXPP_map_pair tex_extend_map[] = {
- {"Extend", TEX_EXTEND},
- {"Clip", TEX_CLIP},
- {"ClipCube", TEX_CLIPCUBE},
- {"Repeat", TEX_REPEAT},
-/* NOTE "Checker" is new */
- {"Checker", TEX_CHECKER},
- {NULL, 0}
-};
-
-/* array of maps for stype */
-static const EXPP_map_pair tex_stype_default_map[] = {
- {"Default", 0},
- {NULL, 0}
-};
-static const EXPP_map_pair tex_stype_clouds_map[] = {
- {"Default", 0},
- {"CloudDefault", EXPP_TEX_STYPE_CLD_DEFAULT},
- {"CloudColor", EXPP_TEX_STYPE_CLD_COLOR},
- {NULL, 0}
-};
-static const EXPP_map_pair tex_stype_wood_map[] = {
- {"Default", 0},
- {"WoodBands", EXPP_TEX_STYPE_WOD_BANDS},
- {"WoodRings", EXPP_TEX_STYPE_WOD_RINGS},
- {"WoodBandNoise", EXPP_TEX_STYPE_WOD_BANDNOISE},
- {"WoodRingNoise", EXPP_TEX_STYPE_WOD_RINGNOISE},
- {NULL, 0}
-};
-static const EXPP_map_pair tex_stype_marble_map[] = {
- {"Default", 0},
- {"MarbleSoft", EXPP_TEX_STYPE_MBL_SOFT},
- {"MarbleSharp", EXPP_TEX_STYPE_MBL_SHARP},
- {"MarbleSharper", EXPP_TEX_STYPE_MBL_SHARPER},
- {NULL, 0}
-};
-static const EXPP_map_pair tex_stype_blend_map[] = {
- {"Default", 0},
- {"BlendLin", EXPP_TEX_STYPE_BLN_LIN},
- {"BlendQuad", EXPP_TEX_STYPE_BLN_QUAD},
- {"BlendEase", EXPP_TEX_STYPE_BLN_EASE},
- {"BlendDiag", EXPP_TEX_STYPE_BLN_DIAG},
- {"BlendSphere", EXPP_TEX_STYPE_BLN_SPHERE},
- {"BlendHalo", EXPP_TEX_STYPE_BLN_HALO},
- {NULL, 0}
-};
-static const EXPP_map_pair tex_stype_stucci_map[] = {
- {"Default", 0},
- {"StucciPlastic", EXPP_TEX_STYPE_STC_PLASTIC},
- {"StucciWallIn", EXPP_TEX_STYPE_STC_WALLIN},
- {"StucciWallOut", EXPP_TEX_STYPE_STC_WALLOUT},
- {NULL, 0}
-};
-static const EXPP_map_pair tex_stype_envmap_map[] = {
- {"Default", 0},
- {"EnvmapStatic", EXPP_TEX_STYPE_ENV_STATIC},
- {"EnvmapAnim", EXPP_TEX_STYPE_ENV_ANIM},
- {"EnvmapLoad", EXPP_TEX_STYPE_ENV_LOAD},
- {NULL, 0}
-};
-
-static const EXPP_map_pair tex_stype_musg_map[] = {
- {"Default", 0},
- {"MultiFractal", EXPP_TEX_STYPE_MUS_MFRACTAL},
- {"HeteroTerrain", EXPP_TEX_STYPE_MUS_HTERRAIN},
- {"RidgedMultiFractal", EXPP_TEX_STYPE_MUS_RIDGEDMF},
- {"HybridMultiFractal", EXPP_TEX_STYPE_MUS_HYBRIDMF},
- {"fBM", EXPP_TEX_STYPE_MUS_FBM},
- {NULL, 0}
-};
-
-static const EXPP_map_pair tex_stype_distortednoise_map[] = {
- {"Default", 0},
- {"BlenderOriginal", TEX_BLENDER},
- {"OriginalPerlin", TEX_STDPERLIN},
- {"ImprovedPerlin", TEX_NEWPERLIN},
- {"VoronoiF1", TEX_VORONOI_F1},
- {"VoronoiF2", TEX_VORONOI_F2},
- {"VoronoiF3", TEX_VORONOI_F3},
- {"VoronoiF4", TEX_VORONOI_F4},
- {"VoronoiF2-F1", TEX_VORONOI_F2F1},
- {"VoronoiCrackle", TEX_VORONOI_CRACKLE},
- {"CellNoise", TEX_CELLNOISE},
- {NULL, 0}
-};
-
-static const EXPP_map_pair tex_stype_voronoi_map[] = {
- {"Default", 0},
- {"Int", EXPP_TEX_STYPE_VN_INT},
- {"Col1", EXPP_TEX_STYPE_VN_COL1},
- {"Col2", EXPP_TEX_STYPE_VN_COL2},
- {"Col3", EXPP_TEX_STYPE_VN_COL3},
- {NULL, 0}
-};
-
-static const EXPP_map_pair tex_distance_voronoi_map[] = {
- {"Default", 0},
- {"Distance", TEX_DISTANCE},
- {"DistanceSquared", TEX_DISTANCE_SQUARED},
- {"Manhattan", TEX_MANHATTAN},
- {"Chebychev", TEX_CHEBYCHEV},
- {"MinkovskyHalf", TEX_MINKOVSKY_HALF},
- {"MinkovskyFour", TEX_MINKOVSKY_FOUR},
- {"Minkovsky", TEX_MINKOVSKY},
- {NULL, 0}
-};
-
-static const EXPP_map_pair *tex_stype_map[] = {
- tex_stype_default_map, /* none */
- tex_stype_clouds_map,
- tex_stype_wood_map,
- tex_stype_marble_map,
- tex_stype_default_map, /* magic */
- tex_stype_blend_map,
- tex_stype_stucci_map,
- tex_stype_default_map, /* noise */
- tex_stype_default_map, /* image */
- tex_stype_default_map, /* plugin */
- tex_stype_envmap_map,
- tex_stype_musg_map, /* musgrave */
- tex_stype_voronoi_map, /* voronoi */
- tex_stype_distortednoise_map, /* distorted noise */
- tex_distance_voronoi_map
-};
-
-/*****************************************************************************/
-/* Python API function prototypes for the Texture module. */
-/*****************************************************************************/
-static PyObject *M_Texture_New( PyObject * self, PyObject * args,
- PyObject * keywords );
-static PyObject *M_Texture_Get( 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.Texture.__doc__ */
-/*****************************************************************************/
-static char M_Texture_doc[] = "The Blender Texture module\n\
-\n\
-This module provides access to **Texture** objects in Blender\n";
-
-static char M_Texture_New_doc[] = "Texture.New (name = 'Tex'):\n\
- Return a new Texture object with the given type and name.";
-
-static char M_Texture_Get_doc[] = "Texture.Get (name = None):\n\
- Return the texture with the given 'name', None if not found, or\n\
- Return a list with all texture objects in the current scene,\n\
- if no argument was given.";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Texture module: */
-/*****************************************************************************/
-struct PyMethodDef M_Texture_methods[] = {
- {"New", ( PyCFunction ) M_Texture_New, METH_VARARGS | METH_KEYWORDS,
- M_Texture_New_doc},
- {"Get", M_Texture_Get, METH_VARARGS, M_Texture_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Texture methods declarations: */
-/*****************************************************************************/
-#define GETFUNC(name) static PyObject *Texture_##name(BPy_Texture *self)
-#define OLDSETFUNC(name) static PyObject *Texture_old##name(BPy_Texture *self, \
- PyObject *args)
-#define SETFUNC(name) static int Texture_##name(BPy_Texture *self, \
- PyObject *value)
-#if 0
-GETFUNC( getExtend );
-GETFUNC( getImage );
-GETFUNC( getType );
-GETFUNC( getSType );
-GETFUNC( clearIpo );
-GETFUNC( getAnimMontage );
-GETFUNC( getAnimLength );
-SETFUNC( setAnimLength );
-SETFUNC( setAnimMontage );
-#endif
-
-GETFUNC( oldgetSType );
-GETFUNC( oldgetType );
-
-GETFUNC( clearIpo );
-GETFUNC( getAnimFrames );
-GETFUNC( getAnimOffset );
-GETFUNC( getAnimStart );
-GETFUNC( getBrightness );
-GETFUNC( getContrast );
-GETFUNC( getCrop );
-GETFUNC( getDistAmnt );
-GETFUNC( getDistMetric );
-GETFUNC( getExp );
-GETFUNC( getExtend );
-GETFUNC( getIntExtend );
-GETFUNC( getFieldsPerImage );
-GETFUNC( getFilterSize );
-GETFUNC( getFlags );
-GETFUNC( getHFracDim );
-GETFUNC( getImage );
-GETFUNC( getIpo );
-GETFUNC( getIScale );
-GETFUNC( getLacunarity );
-GETFUNC( getNoiseBasis );
-GETFUNC( getNoiseDepth );
-GETFUNC( getNoiseSize );
-GETFUNC( getNoiseType );
-GETFUNC( getOcts );
-GETFUNC( getRepeat );
-GETFUNC( getRGBCol );
-GETFUNC( getSType );
-GETFUNC( getTurbulence );
-GETFUNC( getType );
-GETFUNC( getWeight1 );
-GETFUNC( getWeight2 );
-GETFUNC( getWeight3 );
-GETFUNC( getWeight4 );
-#if 0
-/* not defined */
-GETFUNC( getUsers );
-#endif
-
-OLDSETFUNC( setDistMetric );
-OLDSETFUNC( setDistNoise ); /* special case used for ".noisebasis = ... */
-OLDSETFUNC( setExtend );
-OLDSETFUNC( setFlags );
-OLDSETFUNC( setImage );
-OLDSETFUNC( setImageFlags );
-OLDSETFUNC( setIpo );
-OLDSETFUNC( setNoiseBasis );
-OLDSETFUNC( setSType );
-OLDSETFUNC( setType );
-
-SETFUNC( setAnimFrames );
-SETFUNC( setAnimOffset );
-SETFUNC( setAnimStart );
-SETFUNC( setBrightness );
-SETFUNC( setContrast );
-SETFUNC( setCrop );
-SETFUNC( setDistAmnt );
-SETFUNC( setDistMetric );
-SETFUNC( setExp );
-SETFUNC( setIntExtend );
-SETFUNC( setFieldsPerImage );
-SETFUNC( setFilterSize );
-SETFUNC( setFlags );
-SETFUNC( setHFracDim );
-SETFUNC( setImage );
-SETFUNC( setIpo );
-SETFUNC( setIScale );
-SETFUNC( setLacunarity );
-SETFUNC( setNoiseBasis );
-SETFUNC( setNoiseDepth );
-SETFUNC( setNoiseSize );
-SETFUNC( setNoiseType );
-SETFUNC( setOcts );
-SETFUNC( setRepeat );
-SETFUNC( setRGBCol );
-SETFUNC( setSType );
-SETFUNC( setTurbulence );
-SETFUNC( setType );
-SETFUNC( setWeight1 );
-SETFUNC( setWeight2 );
-SETFUNC( setWeight3 );
-SETFUNC( setWeight4 );
-
-static PyObject *Texture_getImageFlags( BPy_Texture *self, void *type );
-static PyObject *Texture_getIUserFlags( BPy_Texture *self, void *type );
-static PyObject *Texture_getIUserCyclic( BPy_Texture *self );
-static PyObject *Texture_getNoiseBasis2( BPy_Texture *self, void *type );
-static int Texture_setImageFlags( BPy_Texture *self, PyObject *args,
- void *type );
-static int Texture_setIUserFlags( BPy_Texture *self, PyObject *args,
- void *type );
-static int Texture_setIUserCyclic( BPy_Texture *self, PyObject *args );
-static int Texture_setNoiseBasis2( BPy_Texture *self, PyObject *args,
- void *type );
-
-static PyObject *Texture_getColorband( BPy_Texture * self);
-int Texture_setColorband( BPy_Texture * self, PyObject * value);
-static PyObject *Texture_evaluate( BPy_Texture *self, PyObject *value );
-static PyObject *Texture_copy( BPy_Texture *self );
-
-/*****************************************************************************/
-/* Python BPy_Texture methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Texture_methods[] = {
- /* name, method, flags, doc */
- {"getExtend", ( PyCFunction ) Texture_getExtend, METH_NOARGS,
- "() - Return Texture extend mode"},
- {"getImage", ( PyCFunction ) Texture_getImage, METH_NOARGS,
- "() - Return Texture Image"},
- {"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
- "() - Return Texture name"},
- {"getSType", ( PyCFunction ) Texture_oldgetSType, METH_NOARGS,
- "() - Return Texture stype as string"},
- {"getType", ( PyCFunction ) Texture_oldgetType, METH_NOARGS,
- "() - Return Texture type as string"},
- {"getIpo", ( PyCFunction ) Texture_getIpo, METH_NOARGS,
- "() - Return Texture Ipo"},
- {"setIpo", ( PyCFunction ) Texture_oldsetIpo, METH_VARARGS,
- "(Blender Ipo) - Set Texture Ipo"},
- {"clearIpo", ( PyCFunction ) Texture_clearIpo, METH_NOARGS,
- "() - Unlink Ipo from this Texture."},
- {"setExtend", ( PyCFunction ) Texture_oldsetExtend, METH_VARARGS,
- "(s) - Set Texture extend mode"},
- {"setFlags", ( PyCFunction ) Texture_oldsetFlags, METH_VARARGS,
- "(f1,f2,f3,f4,f5) - Set Texture flags"},
- {"setImage", ( PyCFunction ) Texture_oldsetImage, METH_VARARGS,
- "(Blender Image) - Set Texture Image"},
- {"setImageFlags", ( PyCFunction ) Texture_oldsetImageFlags, METH_VARARGS,
- "(s,s,s,s,...) - Set Texture image flags"},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "(s) - Set Texture name"},
- {"setSType", ( PyCFunction ) Texture_oldsetSType, METH_VARARGS,
- "(s) - Set Texture stype"},
- {"setType", ( PyCFunction ) Texture_oldsetType, METH_VARARGS,
- "(s) - Set Texture type"},
- {"setNoiseBasis", ( PyCFunction ) Texture_oldsetNoiseBasis, METH_VARARGS,
- "(s) - Set Noise basis"},
- {"setDistNoise", ( PyCFunction ) Texture_oldsetDistNoise, METH_VARARGS,
- "(s) - Set Dist Noise"},
- {"setDistMetric", ( PyCFunction ) Texture_oldsetDistMetric, METH_VARARGS,
- "(s) - Set Dist Metric"},
- {"evaluate", ( PyCFunction ) Texture_evaluate, METH_O,
- "(vector) - evaluate the texture at this position"},
- {"__copy__", ( PyCFunction ) Texture_copy, METH_NOARGS,
- "() - return a copy of the the texture"},
- {"copy", ( PyCFunction ) Texture_copy, METH_NOARGS,
- "() - return a copy of the the texture"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python Texture_Type attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Texture_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"animFrames",
- (getter)Texture_getAnimFrames, (setter)Texture_setAnimFrames,
- "Number of frames of a movie to use",
- NULL},
-#if 0
- {"animLength",
- (getter)Texture_getAnimLength, (setter)Texture_setAnimLength,
- "Number of frames of a movie to use (0 for all)",
- NULL},
- {"animMontage",
- (getter)Texture_getAnimMontage, (setter)Texture_setAnimMontage,
- "Montage mode, start frames and durations",
- NULL},
-#endif
- {"animOffset",
- (getter)Texture_getAnimOffset, (setter)Texture_setAnimOffset,
- "Offsets the number of the first movie frame to use",
- NULL},
- {"animStart",
- (getter)Texture_getAnimStart, (setter)Texture_setAnimStart,
- "Starting frame of the movie to use",
- NULL},
- {"brightness",
- (getter)Texture_getBrightness, (setter)Texture_setBrightness,
- "Changes the brightness of a texture's color",
- NULL},
- {"contrast",
- (getter)Texture_getContrast, (setter)Texture_setContrast,
- "Changes the contrast of a texture's color",
- NULL},
- {"crop",
- (getter)Texture_getCrop, (setter)Texture_setCrop,
- "Sets the cropping extents (for image textures)",
- NULL},
- {"distAmnt",
- (getter)Texture_getDistAmnt, (setter)Texture_setDistAmnt,
- "Amount of distortion (for distorted noise textures)",
- NULL},
- {"distMetric",
- (getter)Texture_getDistMetric, (setter)Texture_setDistMetric,
- "The distance metric (for Voronoi textures)",
- NULL},
- {"exp",
- (getter)Texture_getExp, (setter)Texture_setExp,
- "Minkovsky exponent (for Minkovsky Voronoi textures)",
- NULL},
- {"extend",
- (getter)Texture_getIntExtend, (setter)Texture_setIntExtend,
- "Texture's 'Extend' mode (for image textures)",
- NULL},
- {"fieldsPerImage",
- (getter)Texture_getFieldsPerImage, (setter)Texture_setFieldsPerImage,
- "Number of fields per rendered frame",
- NULL},
- {"filterSize",
- (getter)Texture_getFilterSize, (setter)Texture_setFilterSize,
- "The filter size (for image and envmap textures)",
- NULL},
- {"flags",
- (getter)Texture_getFlags, (setter)Texture_setFlags,
- "Texture's 'Flag' bits",
- NULL},
- {"hFracDim",
- (getter)Texture_getHFracDim, (setter)Texture_setHFracDim,
- "Highest fractional dimension (for Musgrave textures)",
- NULL},
- {"imageFlags",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Texture's 'ImageFlags' bits",
- NULL},
- {"image",
- (getter)Texture_getImage, (setter)Texture_setImage,
- "Texture's image object",
- NULL},
- {"ipo",
- (getter)Texture_getIpo, (setter)Texture_setIpo,
- "Texture Ipo data",
- NULL},
- {"iScale",
- (getter)Texture_getIScale, (setter)Texture_setIScale,
- "Intensity output scale (for Musgrave and Voronoi textures)",
- NULL},
- {"lacunarity",
- (getter)Texture_getLacunarity, (setter)Texture_setLacunarity,
- "Gap between succesive frequencies (for Musgrave textures)",
- NULL},
- {"noiseBasis",
- (getter)Texture_getNoiseBasis, (setter)Texture_setNoiseBasis,
- "Noise basis type (wood, stucci, marble, clouds, Musgrave, distorted noise)",
- NULL},
- {"noiseBasis2",
- (getter)Texture_getNoiseBasis2, (setter)Texture_setNoiseBasis2,
- "Additional noise basis type (wood, marble, distorted noise)",
- (void *)EXPP_TEX_NOISEBASIS2},
- {"noiseDepth",
- (getter)Texture_getNoiseDepth, (setter)Texture_setNoiseDepth,
- "Noise depth (magic, marble, clouds)",
- NULL},
- {"noiseSize",
- (getter)Texture_getNoiseSize, (setter)Texture_setNoiseSize,
- "Noise size (wood, stucci, marble, clouds, Musgrave, distorted noise, Voronoi)",
- NULL},
-/* NOTE for API rewrite: should use dict constants instead of strings */
- {"noiseType",
- (getter)Texture_getNoiseType, (setter)Texture_setNoiseType,
- "Noise type (for wood, stucci, marble, clouds textures)",
- NULL},
- {"octs",
- (getter)Texture_getOcts, (setter)Texture_setOcts,
- "Number of frequencies (for Musgrave textures)",
- NULL},
- {"repeat",
- (getter)Texture_getRepeat, (setter)Texture_setRepeat,
- "Repetition multiplier (for image textures)",
- NULL},
- {"rgbCol",
- (getter)Texture_getRGBCol, (setter)Texture_setRGBCol,
- "RGB color tuple",
- NULL},
- {"stype",
- (getter)Texture_getSType, (setter)Texture_setSType,
- "Texture's 'SType' mode",
- NULL},
- {"turbulence",
- (getter)Texture_getTurbulence, (setter)Texture_setTurbulence,
- "Turbulence (for magic, wood, stucci, marble textures)",
- NULL},
- {"type",
- (getter)Texture_getType, (setter)Texture_setType,
- "Texture's 'Type' mode",
- NULL},
- {"weight1",
- (getter)Texture_getWeight1, (setter)Texture_setWeight1,
- "Weight 1 (for Voronoi textures)",
- NULL},
- {"weight2",
- (getter)Texture_getWeight2, (setter)Texture_setWeight2,
- "Weight 2 (for Voronoi textures)",
- NULL},
- {"weight3",
- (getter)Texture_getWeight3, (setter)Texture_setWeight3,
- "Weight 3 (for Voronoi textures)",
- NULL},
- {"weight4",
- (getter)Texture_getWeight4, (setter)Texture_setWeight4,
- "Weight 4 (for Voronoi textures)",
- NULL},
- {"sine",
- (getter)Texture_getNoiseBasis2, (setter)Texture_setNoiseBasis2,
- "Produce bands using sine wave (marble, wood textures)",
- (void *)EXPP_TEX_NOISE_SINE},
- {"saw",
- (getter)Texture_getNoiseBasis2, (setter)Texture_setNoiseBasis2,
- "Produce bands using saw wave (marble, wood textures)",
- (void *)EXPP_TEX_NOISE_SAW},
- {"tri",
- (getter)Texture_getNoiseBasis2, (setter)Texture_setNoiseBasis2,
- "Produce bands using triangle wave (marble, wood textures)",
- (void *)EXPP_TEX_NOISE_TRI},
- {"interpol",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Interpolate image's pixels to fit texture mapping enabled ('ImageFlags')",
- (void *)TEX_INTERPOL},
- {"useAlpha",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Use of image's alpha channel enabled ('ImageFlags')",
- (void *)TEX_USEALPHA},
- {"calcAlpha",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Calculation of image's alpha channel enabled ('ImageFlags')",
- (void *)TEX_CALCALPHA},
- {"mipmap",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Mipmaps enabled ('ImageFlags')",
- (void *)TEX_MIPMAP},
- {"rot90",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "X/Y flip for rendering enabled ('ImageFlags')",
- (void *)TEX_IMAROT},
- {"autoRefresh",
- (getter)Texture_getIUserFlags, (setter)Texture_setIUserFlags,
- "Refresh image on frame changes enabled",
- (void *)IMA_ANIM_ALWAYS},
- {"cyclic",
- (getter)Texture_getIUserCyclic, (setter)Texture_setIUserCyclic,
- "Cycling of animated frames enabled",
- NULL},
-#if 0
- /* disabled, moved to image */
- {"fields",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Use of image's fields enabled ('ImageFlags')",
- (void *)TEX_FIELDS},
- {"movie",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Movie frames as images enabled ('ImageFlags')",
- (void *)TEX_ANIM5},
- {"anti",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Image anti-aliasing enabled ('ImageFlags')",
- (void *)TEX_ANTIALI},
- {"stField",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Standard field deinterlacing enabled ('ImageFlags')",
- (void *)TEX_STD_FIELD},
-#endif
- {"normalMap",
- (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
- "Use of image RGB values for normal mapping enabled ('ImageFlags')",
- (void *)TEX_NORMALMAP},
- {"colorband",
- (getter)Texture_getColorband, (setter)Texture_setColorband,
- "The colorband for this texture",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python Texture_Type callback function prototypes: */
-/*****************************************************************************/
-static int Texture_compare( BPy_Texture * a, BPy_Texture * b );
-static PyObject *Texture_repr( BPy_Texture * self );
-
-/*****************************************************************************/
-/* Python Texture_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Texture_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Texture", /* char *tp_name; */
- sizeof( BPy_Texture ), /* 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 ) Texture_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Texture_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_Texture_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Texture_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_Texture_New( PyObject * self, PyObject * args,
- PyObject * kwords )
-{
- char *name_str = "Tex";
- static char *kwlist[] = { "name_str", NULL };
- PyObject *pytex; /* for Texture object wrapper in Python */
- Tex *bltex; /* for actual Tex we create in Blender */
-
- /* Parse the arguments passed in by the Python interpreter */
- if( !PyArg_ParseTupleAndKeywords
- ( args, kwords, "|s", kwlist, &name_str ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected zero, one or two strings as arguments" );
-
- bltex = add_texture( name_str ); /* first create the texture in Blender */
-
- if( bltex ) /* now create the wrapper obj in Python */
- pytex = Texture_CreatePyObject( bltex );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Texture in Blender" );
-
- /* let's return user count to zero, because add_texture() incref'd it */
- bltex->id.us = 0;
-
- if( pytex == NULL )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create Tex PyObject" );
-
- return pytex;
-}
-
-static PyObject *M_Texture_Get( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- Tex *tex_iter;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" );
-
- tex_iter = G.main->tex.first;
-
- if( name ) { /* (name) - Search for texture by name */
-
- PyObject *wanted_tex = NULL;
-
- while( tex_iter ) {
- if( STREQ( name, tex_iter->id.name + 2 ) ) {
- wanted_tex =
- Texture_CreatePyObject( tex_iter );
- break;
- }
-
- tex_iter = tex_iter->id.next;
- }
-
- if( !wanted_tex ) { /* Requested texture doesn't exist */
- char error_msg[64];
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "Texture \"%s\" not found", name );
- return EXPP_ReturnPyObjError( PyExc_NameError,
- error_msg );
- }
-
- return wanted_tex;
- }
-
- else { /* () - return a list of wrappers for all textures in the scene */
- int index = 0;
- PyObject *tex_pylist, *pyobj;
-
- tex_pylist = PyList_New( BLI_countlist( &( G.main->tex ) ) );
- if( !tex_pylist )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" );
-
- while( tex_iter ) {
- pyobj = Texture_CreatePyObject( tex_iter );
- if( !pyobj ) {
- Py_DECREF(tex_pylist);
- return EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create Texture PyObject" );
- }
- PyList_SET_ITEM( tex_pylist, index, pyobj );
-
- tex_iter = tex_iter->id.next;
- index++;
- }
-
- return tex_pylist;
- }
-}
-
-static int Texture_compare( BPy_Texture * a, BPy_Texture * b )
-{
- return ( a->texture == b->texture ) ? 0 : -1;
-}
-
-static PyObject *Texture_repr( BPy_Texture * self )
-{
- return PyString_FromFormat( "[Texture \"%s\"]",
- self->texture->id.name + 2 );
-}
-
-static PyObject *M_Texture_TypesDict( void )
-{
- PyObject *Types = PyConstant_New( );
- if( Types ) {
- BPy_constant *d = ( BPy_constant * ) Types;
- PyConstant_Insert(d, "NONE", PyInt_FromLong(EXPP_TEX_TYPE_NONE));
- PyConstant_Insert(d, "CLOUDS", PyInt_FromLong(TEX_CLOUDS));
- PyConstant_Insert(d, "WOOD", PyInt_FromLong(TEX_WOOD));
- PyConstant_Insert(d, "MARBLE", PyInt_FromLong(TEX_MARBLE));
- PyConstant_Insert(d, "MAGIC", PyInt_FromLong(TEX_MAGIC));
- PyConstant_Insert(d, "BLEND", PyInt_FromLong(TEX_BLEND));
- PyConstant_Insert(d, "STUCCI", PyInt_FromLong(TEX_STUCCI));
- PyConstant_Insert(d, "NOISE", PyInt_FromLong(TEX_NOISE));
- PyConstant_Insert(d, "IMAGE", PyInt_FromLong(TEX_IMAGE));
- PyConstant_Insert(d, "PLUGIN", PyInt_FromLong(TEX_PLUGIN));
- PyConstant_Insert(d, "ENVMAP", PyInt_FromLong(TEX_ENVMAP));
- PyConstant_Insert(d, "MUSGRAVE", PyInt_FromLong(TEX_MUSGRAVE));
- PyConstant_Insert(d, "VORONOI", PyInt_FromLong(TEX_VORONOI));
- PyConstant_Insert(d, "DISTNOISE", PyInt_FromLong(TEX_DISTNOISE));
- }
- return Types;
-}
-
-static PyObject *M_Texture_STypesDict( void )
-{
- PyObject *STypes = PyConstant_New( );
- if( STypes ) {
- BPy_constant *d = ( BPy_constant * ) STypes;
-
- PyConstant_Insert(d, "CLD_DEFAULT",
- PyInt_FromLong(EXPP_TEX_STYPE_CLD_DEFAULT));
- PyConstant_Insert(d, "CLD_COLOR",
- PyInt_FromLong(EXPP_TEX_STYPE_CLD_COLOR));
- PyConstant_Insert(d, "WOD_BANDS",
- PyInt_FromLong(EXPP_TEX_STYPE_WOD_BANDS));
- PyConstant_Insert(d, "WOD_RINGS",
- PyInt_FromLong(EXPP_TEX_STYPE_WOD_RINGS));
- PyConstant_Insert(d, "WOD_BANDNOISE",
- PyInt_FromLong(EXPP_TEX_STYPE_WOD_BANDNOISE));
- PyConstant_Insert(d, "WOD_RINGNOISE",
- PyInt_FromLong(EXPP_TEX_STYPE_WOD_RINGNOISE));
- PyConstant_Insert(d, "MAG_DEFAULT",
- PyInt_FromLong(EXPP_TEX_STYPE_MAG_DEFAULT));
- PyConstant_Insert(d, "MBL_SOFT",
- PyInt_FromLong(EXPP_TEX_STYPE_MBL_SOFT));
- PyConstant_Insert(d, "MBL_SHARP",
- PyInt_FromLong(EXPP_TEX_STYPE_MBL_SHARP));
- PyConstant_Insert(d, "MBL_SHARPER",
- PyInt_FromLong(EXPP_TEX_STYPE_MBL_SHARPER));
- PyConstant_Insert(d, "BLN_LIN",
- PyInt_FromLong(EXPP_TEX_STYPE_BLN_LIN));
- PyConstant_Insert(d, "BLN_QUAD",
- PyInt_FromLong(EXPP_TEX_STYPE_BLN_QUAD));
- PyConstant_Insert(d, "BLN_EASE",
- PyInt_FromLong(EXPP_TEX_STYPE_BLN_EASE));
- PyConstant_Insert(d, "BLN_DIAG",
- PyInt_FromLong(EXPP_TEX_STYPE_BLN_DIAG));
- PyConstant_Insert(d, "BLN_SPHERE",
- PyInt_FromLong(EXPP_TEX_STYPE_BLN_SPHERE));
- PyConstant_Insert(d, "BLN_HALO",
- PyInt_FromLong(EXPP_TEX_STYPE_BLN_HALO));
- PyConstant_Insert(d, "STC_PLASTIC",
- PyInt_FromLong(EXPP_TEX_STYPE_STC_PLASTIC));
- PyConstant_Insert(d, "STC_WALLIN",
- PyInt_FromLong(EXPP_TEX_STYPE_STC_WALLIN));
- PyConstant_Insert(d, "STC_WALLOUT",
- PyInt_FromLong(EXPP_TEX_STYPE_STC_WALLOUT));
- PyConstant_Insert(d, "NSE_DEFAULT",
- PyInt_FromLong(EXPP_TEX_STYPE_NSE_DEFAULT));
- PyConstant_Insert(d, "IMG_DEFAULT",
- PyInt_FromLong(EXPP_TEX_STYPE_IMG_DEFAULT));
- PyConstant_Insert(d, "PLG_DEFAULT",
- PyInt_FromLong(EXPP_TEX_STYPE_PLG_DEFAULT));
- PyConstant_Insert(d, "ENV_STATIC",
- PyInt_FromLong(EXPP_TEX_STYPE_ENV_STATIC));
- PyConstant_Insert(d, "ENV_ANIM",
- PyInt_FromLong(EXPP_TEX_STYPE_ENV_ANIM));
- PyConstant_Insert(d, "ENV_LOAD",
- PyInt_FromLong(EXPP_TEX_STYPE_ENV_LOAD));
- PyConstant_Insert(d, "MUS_MFRACTAL",
- PyInt_FromLong(EXPP_TEX_STYPE_MUS_MFRACTAL));
- PyConstant_Insert(d, "MUS_RIDGEDMF",
- PyInt_FromLong(EXPP_TEX_STYPE_MUS_RIDGEDMF));
- PyConstant_Insert(d, "MUS_HYBRIDMF",
- PyInt_FromLong(EXPP_TEX_STYPE_MUS_HYBRIDMF));
- PyConstant_Insert(d, "MUS_FBM",
- PyInt_FromLong(EXPP_TEX_STYPE_MUS_FBM));
- PyConstant_Insert(d, "MUS_HTERRAIN",
- PyInt_FromLong(EXPP_TEX_STYPE_MUS_HTERRAIN));
- PyConstant_Insert(d, "DN_BLENDER",
- PyInt_FromLong(TEX_BLENDER));
- PyConstant_Insert(d, "DN_PERLIN",
- PyInt_FromLong(TEX_STDPERLIN));
- PyConstant_Insert(d, "DN_IMPROVEDPERLIN",
- PyInt_FromLong(TEX_NEWPERLIN));
- PyConstant_Insert(d, "DN_VORONOIF1",
- PyInt_FromLong(TEX_VORONOI_F1));
- PyConstant_Insert(d, "DN_VORONOIF2",
- PyInt_FromLong(TEX_VORONOI_F2));
- PyConstant_Insert(d, "DN_VORONOIF3",
- PyInt_FromLong(TEX_VORONOI_F3));
- PyConstant_Insert(d, "DN_VORONOIF4",
- PyInt_FromLong(TEX_VORONOI_F4));
- PyConstant_Insert(d, "DN_VORONOIF2F1",
- PyInt_FromLong(TEX_VORONOI_F2F1));
- PyConstant_Insert(d, "DN_VORONOICRACKLE",
- PyInt_FromLong(TEX_VORONOI_CRACKLE));
- PyConstant_Insert(d, "DN_CELLNOISE",
- PyInt_FromLong(TEX_CELLNOISE));
- PyConstant_Insert(d, "VN_INT",
- PyInt_FromLong(EXPP_TEX_STYPE_VN_INT));
- PyConstant_Insert(d, "VN_COL1",
- PyInt_FromLong(EXPP_TEX_STYPE_VN_COL1));
- PyConstant_Insert(d, "VN_COL2",
- PyInt_FromLong(EXPP_TEX_STYPE_VN_COL2));
- PyConstant_Insert(d, "VN_COL3",
- PyInt_FromLong(EXPP_TEX_STYPE_VN_COL3));
- PyConstant_Insert(d, "VN_TEX_DISTANCE",
- PyInt_FromLong(TEX_DISTANCE));
- PyConstant_Insert(d, "VN_TEX_DISTANCE_SQUARED",
- PyInt_FromLong(TEX_DISTANCE_SQUARED));
- PyConstant_Insert(d, "VN_TEX_MANHATTAN",
- PyInt_FromLong(TEX_MANHATTAN));
- PyConstant_Insert(d, "VN_TEX_CHEBYCHEV",
- PyInt_FromLong(TEX_CHEBYCHEV));
- PyConstant_Insert(d, "VN_TEX_MINKOVSKY_HALF",
- PyInt_FromLong(TEX_MINKOVSKY_HALF));
- PyConstant_Insert(d, "VN_TEX_MINKOVSKY_FOUR",
- PyInt_FromLong(TEX_MINKOVSKY_FOUR));
- PyConstant_Insert(d, "VN_TEX_MINKOVSKY",
- PyInt_FromLong(TEX_MINKOVSKY));
-
- }
- return STypes;
-}
-
-static PyObject *M_Texture_TexCoDict( void )
-{
- PyObject *TexCo = PyConstant_New( );
- if( TexCo ) {
- BPy_constant *d = ( BPy_constant * ) TexCo;
- PyConstant_Insert(d, "ORCO", PyInt_FromLong(TEXCO_ORCO));
- PyConstant_Insert(d, "REFL", PyInt_FromLong(TEXCO_REFL));
- PyConstant_Insert(d, "NOR", PyInt_FromLong(TEXCO_NORM));
- PyConstant_Insert(d, "GLOB", PyInt_FromLong(TEXCO_GLOB));
- PyConstant_Insert(d, "UV", PyInt_FromLong(TEXCO_UV));
- PyConstant_Insert(d, "OBJECT", PyInt_FromLong(TEXCO_OBJECT));
- PyConstant_Insert(d, "WIN", PyInt_FromLong(TEXCO_WINDOW));
- PyConstant_Insert(d, "VIEW", PyInt_FromLong(TEXCO_VIEW));
- PyConstant_Insert(d, "STICK", PyInt_FromLong(TEXCO_STICKY));
- PyConstant_Insert(d, "STRESS", PyInt_FromLong(TEXCO_STRESS));
- PyConstant_Insert(d, "TANGENT", PyInt_FromLong(TEXCO_TANGENT));
- }
- return TexCo;
-}
-
-static PyObject *M_Texture_MapToDict( void )
-{
- PyObject *MapTo = PyConstant_New( );
- if( MapTo ) {
- BPy_constant *d = ( BPy_constant * ) MapTo;
- PyConstant_Insert(d, "COL", PyInt_FromLong(MAP_COL));
- PyConstant_Insert(d, "NOR", PyInt_FromLong(MAP_NORM));
- PyConstant_Insert(d, "CSP", PyInt_FromLong(MAP_COLSPEC));
- PyConstant_Insert(d, "CMIR", PyInt_FromLong(MAP_COLMIR));
- PyConstant_Insert(d, "REF", PyInt_FromLong(MAP_REF));
- PyConstant_Insert(d, "SPEC", PyInt_FromLong(MAP_SPEC));
- PyConstant_Insert(d, "HARD", PyInt_FromLong(MAP_HAR));
- PyConstant_Insert(d, "ALPHA", PyInt_FromLong(MAP_ALPHA));
- PyConstant_Insert(d, "EMIT", PyInt_FromLong(MAP_EMIT));
- PyConstant_Insert(d, "RAYMIR", PyInt_FromLong(MAP_RAYMIRR));
- PyConstant_Insert(d, "AMB", PyInt_FromLong(MAP_AMB));
- PyConstant_Insert(d, "TRANSLU", PyInt_FromLong(MAP_TRANSLU));
- PyConstant_Insert(d, "DISP", PyInt_FromLong(MAP_DISPLACE));
- PyConstant_Insert(d, "WARP", PyInt_FromLong(MAP_WARP));
- }
- return MapTo;
-}
-
-static PyObject *M_Texture_FlagsDict( void )
-{
- PyObject *Flags = PyConstant_New( );
- if( Flags ) {
- BPy_constant *d = ( BPy_constant * ) Flags;
- PyConstant_Insert(d, "COLORBAND", PyInt_FromLong(TEX_COLORBAND));
- PyConstant_Insert(d, "FLIPBLEND", PyInt_FromLong(TEX_FLIPBLEND));
- PyConstant_Insert(d, "NEGALPHA", PyInt_FromLong(TEX_NEGALPHA));
- PyConstant_Insert(d, "CHECKER_ODD", PyInt_FromLong(TEX_CHECKER_ODD));
- PyConstant_Insert(d, "CHECKER_EVEN", PyInt_FromLong(TEX_CHECKER_EVEN));
- PyConstant_Insert(d, "PREVIEW_ALPHA", PyInt_FromLong(TEX_PRV_ALPHA));
- PyConstant_Insert(d, "REPEAT_XMIR", PyInt_FromLong(TEX_REPEAT_XMIR));
- PyConstant_Insert(d, "REPEAT_YMIR", PyInt_FromLong(TEX_REPEAT_YMIR));
- }
- return Flags;
-}
-
-static PyObject *M_Texture_ExtendModesDict( void )
-{
- PyObject *ExtendModes = PyConstant_New( );
- if( ExtendModes ) {
- BPy_constant *d = ( BPy_constant * ) ExtendModes;
- PyConstant_Insert(d, "EXTEND", PyInt_FromLong(TEX_EXTEND));
- PyConstant_Insert(d, "CLIP", PyInt_FromLong(TEX_CLIP));
- PyConstant_Insert(d, "CLIPCUBE", PyInt_FromLong(TEX_CLIPCUBE));
- PyConstant_Insert(d, "REPEAT", PyInt_FromLong(TEX_REPEAT));
- }
- return ExtendModes;
-}
-
-static PyObject *M_Texture_ImageFlagsDict( void )
-{
- PyObject *ImageFlags = PyConstant_New( );
- if( ImageFlags ) {
- BPy_constant *d = ( BPy_constant * ) ImageFlags;
- PyConstant_Insert(d, "INTERPOL", PyInt_FromLong(TEX_INTERPOL));
- PyConstant_Insert(d, "USEALPHA", PyInt_FromLong(TEX_USEALPHA));
- PyConstant_Insert(d, "MIPMAP", PyInt_FromLong(TEX_MIPMAP));
- PyConstant_Insert(d, "ROT90", PyInt_FromLong(TEX_IMAROT));
- PyConstant_Insert(d, "CALCALPHA", PyInt_FromLong(TEX_CALCALPHA));
- PyConstant_Insert(d, "NORMALMAP", PyInt_FromLong(TEX_NORMALMAP));
- }
- return ImageFlags;
-}
-
-static PyObject *M_Texture_NoiseDict( void )
-{
- PyObject *Noise = PyConstant_New( );
- if( Noise ) {
- BPy_constant *d = ( BPy_constant * ) Noise;
- PyConstant_Insert(d, "SINE", PyInt_FromLong(EXPP_TEX_NOISE_SINE));
- PyConstant_Insert(d, "SAW", PyInt_FromLong(EXPP_TEX_NOISE_SAW));
- PyConstant_Insert(d, "TRI", PyInt_FromLong(EXPP_TEX_NOISE_TRI));
- PyConstant_Insert(d, "BLENDER", PyInt_FromLong(TEX_BLENDER));
- PyConstant_Insert(d, "PERLIN", PyInt_FromLong(TEX_STDPERLIN));
- PyConstant_Insert(d, "IMPROVEDPERLIN", PyInt_FromLong(TEX_NEWPERLIN));
- PyConstant_Insert(d, "VORONOIF1", PyInt_FromLong(TEX_VORONOI_F1));
- PyConstant_Insert(d, "VORONOIF2", PyInt_FromLong(TEX_VORONOI_F2));
- PyConstant_Insert(d, "VORONOIF3", PyInt_FromLong(TEX_VORONOI_F3));
- PyConstant_Insert(d, "VORONOIF4", PyInt_FromLong(TEX_VORONOI_F4));
- PyConstant_Insert(d, "VORONOIF2F1", PyInt_FromLong(TEX_VORONOI_F2F1));
- PyConstant_Insert(d, "VORONOICRACKLE",
- PyInt_FromLong(TEX_VORONOI_CRACKLE));
- PyConstant_Insert(d, "CELLNOISE", PyInt_FromLong(TEX_CELLNOISE));
- }
- return Noise;
-}
-
-static PyObject *M_Texture_BlendModesDict( void )
-{
- PyObject *BlendModes = PyConstant_New( );
- if( BlendModes ) {
- BPy_constant *d = ( BPy_constant * ) BlendModes;
- PyConstant_Insert(d, "MIX", PyInt_FromLong(MTEX_BLEND));
- PyConstant_Insert(d, "MULTIPLY", PyInt_FromLong(MTEX_MUL));
- PyConstant_Insert(d, "ADD", PyInt_FromLong(MTEX_ADD));
- PyConstant_Insert(d, "SUBTRACT", PyInt_FromLong(MTEX_SUB));
- PyConstant_Insert(d, "DIVIDE", PyInt_FromLong(MTEX_DIV));
- PyConstant_Insert(d, "DARKEN", PyInt_FromLong(MTEX_DARK));
- PyConstant_Insert(d, "DIFFERENCE", PyInt_FromLong(MTEX_DIFF));
- PyConstant_Insert(d, "LIGHTEN", PyInt_FromLong(MTEX_LIGHT));
- PyConstant_Insert(d, "SCREEN", PyInt_FromLong(MTEX_SCREEN));
- }
- return BlendModes;
-}
-
-static PyObject *M_Texture_MappingsDict( void )
-{
- PyObject *Mappings = PyConstant_New( );
- if( Mappings ) {
- BPy_constant *d = ( BPy_constant * ) Mappings;
- PyConstant_Insert(d, "FLAT", PyInt_FromLong(MTEX_FLAT));
- PyConstant_Insert(d, "CUBE", PyInt_FromLong(MTEX_CUBE));
- PyConstant_Insert(d, "TUBE", PyInt_FromLong(MTEX_TUBE));
- PyConstant_Insert(d, "SPHERE", PyInt_FromLong(MTEX_SPHERE));
- }
- return Mappings;
-}
-
-static PyObject *M_Texture_ProjDict( void )
-{
- PyObject *Proj = PyConstant_New( );
- if( Proj ) {
- BPy_constant *d = ( BPy_constant * ) Proj;
- PyConstant_Insert(d, "NONE", PyInt_FromLong(PROJ_N));
- PyConstant_Insert(d, "X", PyInt_FromLong(PROJ_X));
- PyConstant_Insert(d, "Y", PyInt_FromLong(PROJ_Y));
- PyConstant_Insert(d, "Z", PyInt_FromLong(PROJ_Z));
- }
- return Proj;
-}
-
-PyObject *Texture_Init( void )
-{
- PyObject *submodule;
- PyObject *dict;
-
- /* constants */
- PyObject *Types = M_Texture_TypesDict( );
- PyObject *STypes = M_Texture_STypesDict( );
- PyObject *TexCo = M_Texture_TexCoDict( );
- PyObject *MapTo = M_Texture_MapToDict( );
- PyObject *Flags = M_Texture_FlagsDict( );
- PyObject *ExtendModes = M_Texture_ExtendModesDict( );
- PyObject *ImageFlags = M_Texture_ImageFlagsDict( );
- PyObject *Noise = M_Texture_NoiseDict( );
- PyObject *BlendModes = M_Texture_BlendModesDict( );
- PyObject *Mappings = M_Texture_MappingsDict( );
- PyObject *Proj = M_Texture_ProjDict( );
-
- if( PyType_Ready( &Texture_Type ) < 0)
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Texture",
- M_Texture_methods, M_Texture_doc );
-
- if( Types )
- PyModule_AddObject( submodule, "Types", Types );
- if( STypes )
- PyModule_AddObject( submodule, "STypes", STypes );
- if( TexCo )
- PyModule_AddObject( submodule, "TexCo", TexCo );
- if( MapTo )
- PyModule_AddObject( submodule, "MapTo", MapTo );
- if( Flags )
- PyModule_AddObject( submodule, "Flags", Flags );
- if( ExtendModes )
- PyModule_AddObject( submodule, "ExtendModes", ExtendModes );
- if( ImageFlags )
- PyModule_AddObject( submodule, "ImageFlags", ImageFlags );
- if( Noise )
- PyModule_AddObject( submodule, "Noise", Noise );
- if ( BlendModes )
- PyModule_AddObject( submodule, "BlendModes", BlendModes );
- if ( Mappings )
- PyModule_AddObject( submodule, "Mappings", Mappings );
- if ( Proj )
- PyModule_AddObject( submodule, "Proj", Proj );
-
- /* Add the MTex submodule to this module */
- dict = PyModule_GetDict( submodule );
- PyDict_SetItemString( dict, "MTex", MTex_Init( ) );
-
- return submodule;
-}
-
-PyObject *Texture_CreatePyObject( Tex * tex )
-{
- BPy_Texture *pytex;
-
- pytex = ( BPy_Texture * ) PyObject_NEW( BPy_Texture, &Texture_Type );
- if( !pytex )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create BPy_Texture PyObject" );
-
- pytex->texture = tex;
- return ( PyObject * ) pytex;
-}
-
-Tex *Texture_FromPyObject( PyObject * pyobj )
-{
- return ( ( BPy_Texture * ) pyobj )->texture;
-}
-
-/*****************************************************************************/
-/* Python BPy_Texture methods: */
-/*****************************************************************************/
-
-static PyObject *Texture_getExtend( BPy_Texture * self )
-{
- const char *extend = NULL;
-
- if( EXPP_map_getStrVal
- ( tex_extend_map, self->texture->extend, &extend ) )
- return PyString_FromString( extend );
-
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "invalid internal extend mode" );
-}
-
-static PyObject *Texture_getImage( BPy_Texture * self )
-{
- /* we need this to be an IMAGE texture, and we must have an image */
- if( ( self->texture->type == TEX_IMAGE ||
- self->texture->type == TEX_ENVMAP )
- && self->texture->ima )
- return Image_CreatePyObject( self->texture->ima );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Texture_oldgetSType( BPy_Texture * self )
-{
- const char *stype = NULL;
- int n_stype;
-
- if( self->texture->type == TEX_VORONOI )
- n_stype = self->texture->vn_coltype;
-#if 0
- else if( self->texture->type == TEX_MUSGRAVE )
- n_stype = self->texture->noisebasis;
-#endif
- else if( self->texture->type == TEX_ENVMAP )
- n_stype = self->texture->env->stype;
- else
- n_stype = self->texture->stype;
-
- if( EXPP_map_getStrVal( tex_stype_map[self->texture->type],
- n_stype, &stype ) )
- return PyString_FromString( stype );
-
-
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "invalid texture stype internally" );
-}
-
-static PyObject *Texture_oldgetType( BPy_Texture * self )
-{
- const char *type = NULL;
-
- if( EXPP_map_getStrVal( tex_type_map, self->texture->type, &type ) )
- return PyString_FromString( type );
-
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "invalid texture type internally" );
-}
-
-static int Texture_setAnimFrames( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->texture->iuser.frames,
- EXPP_TEX_ANIMFRAME_MIN,
- EXPP_TEX_ANIMFRAME_MAX, 'h' );
-}
-
-static int Texture_setIUserCyclic( BPy_Texture * 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->texture->iuser.cycl = 1;
- else
- self->texture->iuser.cycl = 0;
- return 0;
-}
-
-#if 0
-/* this was stupid to begin with! (ton) */
-static int Texture_setAnimLength( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->texture->len,
- EXPP_TEX_ANIMLEN_MIN,
- EXPP_TEX_ANIMLEN_MAX, 'h' );
-}
-
-/* this is too simple to keep supporting? disabled for time being (ton) */
-static int Texture_setAnimMontage( BPy_Texture * self, PyObject * value )
-{
- int fradur[4][2];
- int i;
-
- if( !PyArg_ParseTuple( value, "(ii)(ii)(ii)(ii)",
- &fradur[0][0], &fradur[0][1],
- &fradur[1][0], &fradur[1][1],
- &fradur[2][0], &fradur[2][1],
- &fradur[3][0], &fradur[3][1] ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a tuple of tuples" );
-
- for( i = 0; i < 4; ++i ) {
- self->texture->fradur[i][0] =
- (short)EXPP_ClampInt ( fradur[i][0], EXPP_TEX_ANIMMONSTART_MIN,
- EXPP_TEX_ANIMMONSTART_MAX );
- self->texture->fradur[i][1] =
- (short)EXPP_ClampInt ( fradur[i][1], EXPP_TEX_ANIMMONDUR_MIN,
- EXPP_TEX_ANIMMONDUR_MAX );
- }
-
- return 0;
-}
-#endif
-
-static int Texture_setAnimOffset( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->texture->iuser.offset,
- EXPP_TEX_ANIMOFFSET_MIN,
- EXPP_TEX_ANIMOFFSET_MAX, 'h' );
-}
-
-static int Texture_setAnimStart( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->texture->iuser.sfra,
- EXPP_TEX_ANIMSTART_MIN,
- EXPP_TEX_ANIMSTART_MAX, 'h' );
-}
-
-static int Texture_setBrightness( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->bright,
- EXPP_TEX_BRIGHTNESS_MIN,
- EXPP_TEX_BRIGHTNESS_MAX );
-}
-
-static int Texture_setContrast( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->contrast,
- EXPP_TEX_CONTRAST_MIN,
- EXPP_TEX_CONTRAST_MAX );
-}
-
-static int Texture_setCrop( BPy_Texture * self, PyObject * value )
-{
- float crop[4];
-
- if( !PyArg_ParseTuple( value, "ffff",
- &crop[0], &crop[1], &crop[2], &crop[3] ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected tuple of 4 floats" );
-
- self->texture->cropxmin = EXPP_ClampFloat( crop[0], EXPP_TEX_CROP_MIN,
- EXPP_TEX_CROP_MAX );
- self->texture->cropymin = EXPP_ClampFloat( crop[1], EXPP_TEX_CROP_MIN,
- EXPP_TEX_CROP_MAX );
- self->texture->cropxmax = EXPP_ClampFloat( crop[2], EXPP_TEX_CROP_MIN,
- EXPP_TEX_CROP_MAX );
- self->texture->cropymax = EXPP_ClampFloat( crop[3], EXPP_TEX_CROP_MIN,
- EXPP_TEX_CROP_MAX );
-
- return 0;
-}
-
-static int Texture_setIntExtend( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setIValueRange ( value, &self->texture->extend,
- EXPP_TEX_EXTEND_MIN,
- EXPP_TEX_EXTEND_MAX, 'h' );
-}
-
-static int Texture_setFieldsPerImage( BPy_Texture * self,
- PyObject * value )
-{
- return EXPP_setIValueClamped ( value, &self->texture->iuser.fie_ima,
- EXPP_TEX_FIEIMA_MIN,
- EXPP_TEX_FIEIMA_MAX, 'h' );
-
-}
-
-static int Texture_setFilterSize( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->filtersize,
- EXPP_TEX_FILTERSIZE_MIN,
- EXPP_TEX_FILTERSIZE_MAX );
-}
-
-static int Texture_setFlags( BPy_Texture * self, PyObject * value )
-{
- int param;
-
- if( !PyInt_Check( value ) ) {
- char errstr[128];
- sprintf ( errstr , "expected int bitmask of 0x%08x", TEX_FLAG_MASK );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
- param = PyInt_AS_LONG ( value );
-
- if ( ( param & TEX_FLAG_MASK ) != param )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid bit(s) set in mask" );
-
- self->texture->flag = (short)param;
-
-#if 0
- /* if Colorband enabled, make sure we allocate memory for it */
-
- if ( ( param & TEX_COLORBAND ) && !self->texture->coba )
- self->texture->coba = add_colorband();
-#endif
-
- return 0;
-}
-
-static int Texture_setImage( BPy_Texture * self, PyObject * value )
-{
- Image *blimg = NULL;
-
- if( !BPy_Image_Check (value) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an Image" );
- blimg = Image_FromPyObject( value );
-
- if( self->texture->ima ) {
- self->texture->ima->id.us--;
- }
-
- self->texture->ima = blimg;
- id_us_plus( &blimg->id );
-
- return 0;
-}
-
-static int Texture_setImageFlags( BPy_Texture * self, PyObject * value,
- void *type )
-{
- short param;
-
- /*
- * if type is non-zero, then attribute is "mipmap", "calcAlpha", etc.,
- * so set/clear the bit in the bitfield based on the type
- */
-
- if( (int)type ) {
- int err;
- param = self->texture->imaflag;
- err = EXPP_setBitfield( value, &param, (int)type, 'h' );
- if( err )
- return err;
-
- /*
- * if type is zero, then attribute is "imageFlags", so check
- * value for a valid bitmap range.
- */
-
- } else {
- int bitmask = TEX_INTERPOL
- | TEX_USEALPHA
- | TEX_MIPMAP
- | TEX_IMAROT
- | TEX_CALCALPHA
- | TEX_NORMALMAP;
-
- if( !PyInt_Check( value ) ) {
- char errstr[128];
- sprintf ( errstr , "expected int bitmask of 0x%08x", bitmask );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
-
- param = (short)PyInt_AS_LONG( value );
- if( ( param & bitmask ) != param )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid bit(s) set in mask" );
- }
-
- /* everything is OK; save the new flag setting */
-
- self->texture->imaflag = param;
- return 0;
-}
-
-static int Texture_setIUserFlags( BPy_Texture * self, PyObject * value,
- void *flag )
-{
- int param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if( param )
- self->texture->iuser.flag |= (int)flag;
- else
- self->texture->iuser.flag &= ~(int)flag;
- return 0;
-}
-
-static int Texture_setNoiseDepth( BPy_Texture * self, PyObject * value )
-{
- short max = EXPP_TEX_NOISEDEPTH_MAX;
-
- /* for whatever reason, magic texture has a different max value */
-
- if( self->texture->type == TEX_MAGIC )
- max = EXPP_TEX_NOISEDEPTH_MAX_MAGIC;
-
- return EXPP_setIValueClamped ( value, &self->texture->noisedepth,
- EXPP_TEX_NOISEDEPTH_MIN, max, 'h' );
-}
-
-static int Texture_setNoiseSize( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->noisesize,
- EXPP_TEX_NOISESIZE_MIN,
- EXPP_TEX_NOISESIZE_MAX );
-}
-
-static int Texture_setNoiseType( BPy_Texture * self, PyObject * value )
-{
- char *param;
-
- if( !PyString_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string argument" );
- param = PyString_AS_STRING( value );
-
- if( STREQ( param, "soft" ) )
- self->texture->noisetype = TEX_NOISESOFT;
- else if( STREQ( param, "hard" ) )
- self->texture->noisetype = TEX_NOISEPERL;
- else
- return EXPP_ReturnIntError( PyExc_ValueError,
- "noise type must be 'soft' or 'hard'" );
-
- return 0;
-}
-
-static int Texture_setNoiseBasis( BPy_Texture * self, PyObject * value )
-{
- int param;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int (see 'Noise' constant dictionary)" );
-
- param = PyInt_AS_LONG ( value );
-
- if ( param < TEX_BLENDER
- || ( param > TEX_VORONOI_CRACKLE
- && param != TEX_CELLNOISE ) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid noise type" );
-
- self->texture->noisebasis = (short)param;
- return 0;
-}
-
-static int Texture_setNoiseBasis2( BPy_Texture * self, PyObject * value,
- void *type )
-{
- /*
- * if type is EXPP_TEX_NOISEBASIS2, then this is the "noiseBasis2"
- * attribute, so check the range and set the whole value
- */
-
- if( (int)type == EXPP_TEX_NOISEBASIS2 ) {
- int param;
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int (see 'Noise' constant dictionary)" );
-
- param = PyInt_AS_LONG ( value );
-
- if ( param < TEX_BLENDER
- || ( param > TEX_VORONOI_CRACKLE
- && param != TEX_CELLNOISE ) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid noise type" );
-
- self->texture->noisebasis2 = (short)param;
-
- /*
- * for other type values, the attribute is "sine", "saw" or "tri",
- * so set the noise basis to the supplied type if value is 1
- */
-
- } else {
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int value of 1" );
-
- if( PyInt_AS_LONG ( value ) != 1 )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected int value of 1" );
-
- self->texture->noisebasis2 = (short)(int)type;
- }
- return 0;
-}
-
-static int Texture_setRepeat( BPy_Texture * self, PyObject * args )
-{
- int repeat[2];
-
- if( !PyArg_ParseTuple( args, "ii", &repeat[0], &repeat[1] ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected tuple of 2 ints" );
-
- self->texture->xrepeat = (short)EXPP_ClampInt( repeat[0], EXPP_TEX_REPEAT_MIN,
- EXPP_TEX_REPEAT_MAX );
- self->texture->yrepeat = (short)EXPP_ClampInt( repeat[1], EXPP_TEX_REPEAT_MIN,
- EXPP_TEX_REPEAT_MAX );
-
- return 0;
-}
-
-static int Texture_setRGBCol( BPy_Texture * self, PyObject * args )
-{
- float rgb[3];
-
- if( !PyArg_ParseTuple( args, "fff", &rgb[0], &rgb[1], &rgb[2] ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected tuple of 3 floats" );
-
- self->texture->rfac = EXPP_ClampFloat( rgb[0], EXPP_TEX_RGBCOL_MIN,
- EXPP_TEX_RGBCOL_MAX );
- self->texture->gfac = EXPP_ClampFloat( rgb[1], EXPP_TEX_RGBCOL_MIN,
- EXPP_TEX_RGBCOL_MAX );
- self->texture->bfac = EXPP_ClampFloat( rgb[2], EXPP_TEX_RGBCOL_MIN,
- EXPP_TEX_RGBCOL_MAX );
-
- return 0;
-}
-
-static int Texture_setSType( BPy_Texture * self, PyObject * value )
-{
- short param;
- const char *dummy = NULL;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- param = (short)PyInt_AS_LONG ( value );
-
- /* use the stype map to find out if this is a valid stype for this type *
- * note that this will allow CLD_COLOR when type is ENVMAP. there's not *
- * much that we can do about this though. */
- if( !EXPP_map_getStrVal
- ( tex_stype_map[self->texture->type], param, &dummy ) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "invalid stype (for this type)" );
-
- if( self->texture->type == TEX_VORONOI )
- self->texture->vn_coltype = param;
-#if 0
- else if( self->texture->type == TEX_MUSGRAVE )
- self->texture->noisebasis = param;
-#endif
- else if( self->texture->type == TEX_ENVMAP )
- self->texture->env->stype = param;
- else
- self->texture->stype = param;
-
- return 0;
-}
-
-static int Texture_setTurbulence( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->turbul,
- EXPP_TEX_TURBULENCE_MIN,
- EXPP_TEX_TURBULENCE_MAX );
-}
-
-static int Texture_setHFracDim( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->mg_H,
- EXPP_TEX_MH_G_MIN,
- EXPP_TEX_MH_G_MAX );
-}
-
-static int Texture_setLacunarity( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->mg_lacunarity,
- EXPP_TEX_LACUNARITY_MIN,
- EXPP_TEX_LACUNARITY_MAX );
-}
-
-static int Texture_setOcts( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->mg_octaves,
- EXPP_TEX_OCTS_MIN,
- EXPP_TEX_OCTS_MAX );
-}
-
-static int Texture_setIScale( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->ns_outscale,
- EXPP_TEX_ISCALE_MIN,
- EXPP_TEX_ISCALE_MAX );
-}
-
-static int Texture_setType( BPy_Texture * self, PyObject * value )
-{
- int err = EXPP_setIValueRange ( value, &self->texture->type,
- EXPP_TEX_TYPE_MIN,
- EXPP_TEX_TYPE_MAX, 'h' );
-
- /*
- * if we set the texture OK, and it's a environment map, and
- * there is no environment map yet, allocate one (code borrowed
- * from texture_panel_envmap() in source/blender/src/buttons_shading.c)
- */
-
- if( !err && self->texture->type == TEX_ENVMAP
- && !self->texture->env ) {
- self->texture->env = BKE_add_envmap();
- self->texture->env->object= OBACT;
- }
- return err;
-}
-
-static int Texture_setDistMetric( BPy_Texture * self, PyObject * value )
-{
-#if 0
- char *dist = NULL;
-
- if( !PyArg_ParseTuple( value, "s", &dist ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- /* can we really trust texture->type? */
- if( self->texture->type == TEX_VORONOI &&
- !EXPP_map_getShortVal( tex_stype_map[self->texture->type + 2],
- dist, &self->texture->vn_distm ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid dist metric type" );
-
- Py_RETURN_NONE;
-#else
- return EXPP_setIValueRange ( value, &self->texture->vn_distm,
- TEX_DISTANCE,
- TEX_MINKOVSKY, 'h' );
-#endif
-}
-
-static int Texture_setExp( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->vn_mexp,
- EXPP_TEX_EXP_MIN,
- EXPP_TEX_EXP_MAX );
-}
-
-static int Texture_setWeight1( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->vn_w1,
- EXPP_TEX_WEIGHT1_MIN,
- EXPP_TEX_WEIGHT1_MAX );
-}
-
-static int Texture_setWeight2( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->vn_w2,
- EXPP_TEX_WEIGHT2_MIN,
- EXPP_TEX_WEIGHT2_MAX );
-}
-
-static int Texture_setWeight3( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->vn_w3,
- EXPP_TEX_WEIGHT3_MIN,
- EXPP_TEX_WEIGHT3_MAX );
-}
-
-static int Texture_setWeight4( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->vn_w4,
- EXPP_TEX_WEIGHT4_MIN,
- EXPP_TEX_WEIGHT4_MAX );
-}
-
-static int Texture_setDistAmnt( BPy_Texture * self, PyObject * value )
-{
- return EXPP_setFloatClamped ( value, &self->texture->dist_amount,
- EXPP_TEX_DISTAMNT_MIN,
- EXPP_TEX_DISTAMNT_MAX );
-}
-
-static PyObject *Texture_getIpo( BPy_Texture * self )
-{
- struct Ipo *ipo = self->texture->ipo;
-
- if( !ipo )
- Py_RETURN_NONE;
-
- return Ipo_CreatePyObject( ipo );
-}
-
-/*
- * this should accept a Py_None argument and just delete the Ipo link
- * (as Texture_clearIpo() does)
- */
-
-static int Texture_setIpo( BPy_Texture * self, PyObject * value )
-{
- Ipo *ipo = NULL;
- Ipo *oldipo = self->texture->ipo;
- ID *id;
-
- /* if parameter is not None, check for valid Ipo */
-
- if ( value != Py_None ) {
- if ( !BPy_Ipo_Check( value ) )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "expected an Ipo object" );
-
- ipo = Ipo_FromPyObject( value );
-
- if( !ipo )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "null ipo!" );
-
- if( ipo->blocktype != ID_TE )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Ipo is not a texture data Ipo" );
- }
-
- /* if already linked to Ipo, delete link */
-
- if ( oldipo ) {
- id = &oldipo->id;
- if( id->us > 0 )
- id->us--;
- }
-
- /* assign new Ipo and increment user count, or set to NULL if deleting */
-
- self->texture->ipo = ipo;
- if ( ipo ) {
- id = &ipo->id;
- id_us_plus(id);
- }
-
- return 0;
-}
-
-static PyObject *Texture_getAnimFrames( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->iuser.frames );
-}
-
-static PyObject *Texture_getIUserCyclic( BPy_Texture *self )
-{
- if( self->texture->iuser.cycl )
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-#if 0
-/* disabled. this option was too stupid! (ton) */
-static PyObject *Texture_getAnimLength( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->len );
-}
-
-static PyObject *Texture_getAnimMontage( BPy_Texture *self )
-{
- return Py_BuildValue( "((i,i),(i,i),(i,i),(i,i))",
- self->texture->fradur[0][0],
- self->texture->fradur[0][1],
- self->texture->fradur[1][0],
- self->texture->fradur[1][1],
- self->texture->fradur[2][0],
- self->texture->fradur[2][1],
- self->texture->fradur[3][0],
- self->texture->fradur[3][1] );
-}
-#endif
-
-static PyObject *Texture_getAnimOffset( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->iuser.offset );
-}
-
-static PyObject *Texture_getAnimStart( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->iuser.sfra );
-}
-
-static PyObject *Texture_getBrightness( BPy_Texture *self )
-{
- return PyFloat_FromDouble ( self->texture->bright );
-}
-
-static PyObject *Texture_getContrast( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->contrast );
-}
-
-static PyObject *Texture_getCrop( BPy_Texture *self )
-{
- return Py_BuildValue( "(f,f,f,f)",
- self->texture->cropxmin,
- self->texture->cropymin,
- self->texture->cropxmax,
- self->texture->cropymax );
-}
-
-static PyObject *Texture_getDistAmnt( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->dist_amount );
-}
-
-static PyObject *Texture_getDistMetric( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->vn_distm );
-}
-
-static PyObject *Texture_getExp( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->vn_mexp );
-}
-
-static PyObject *Texture_getIntExtend( BPy_Texture * self )
-{
- return PyInt_FromLong( self->texture->extend );
-}
-
-static PyObject *Texture_getFieldsPerImage( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->iuser.fie_ima );
-}
-
-static PyObject *Texture_getFilterSize( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->filtersize );
-}
-
-static PyObject *Texture_getFlags( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->flag );
-}
-
-static PyObject *Texture_getHFracDim( BPy_Texture *self )
-{
- return PyInt_FromLong( (long)self->texture->mg_H );
-}
-
-static PyObject *Texture_getImageFlags( BPy_Texture *self, void *type )
-{
- /* type == 0 means attribute "imageFlags"
- * other types means attribute "mipmap", "calcAlpha", etc
- */
-
- if( (int)type )
- return EXPP_getBitfield( &self->texture->imaflag, (int)type, 'h' );
- else
- return PyInt_FromLong( self->texture->imaflag );
-}
-
-static PyObject *Texture_getIUserFlags( BPy_Texture *self, void *flag )
-{
- if( self->texture->iuser.flag & (int)flag )
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-static PyObject *Texture_getIScale( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->ns_outscale );
-}
-
-static PyObject *Texture_getLacunarity( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->mg_lacunarity );
-}
-
-static PyObject *Texture_getNoiseBasis( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->noisebasis );
-}
-
-static PyObject *Texture_getNoiseBasis2( BPy_Texture *self, void *type )
-{
- /* type == EXPP_TEX_NOISEBASIS2 means attribute "noiseBasis2"
- * other types means attribute "sine", "saw", or "tri" attribute
- */
-
- if( (int)type == EXPP_TEX_NOISEBASIS2 )
- return PyInt_FromLong( self->texture->noisebasis2 );
- else
- return PyInt_FromLong( ( self->texture->noisebasis2 == (int)type ) ? 1 : 0 );
-}
-
-static PyObject *Texture_getNoiseDepth( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->noisedepth );
-}
-
-static PyObject *Texture_getNoiseSize( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->noisesize );
-}
-
-static PyObject *Texture_getNoiseType( BPy_Texture *self )
-{
- if ( self->texture->noisetype == TEX_NOISESOFT )
- return PyString_FromString( "soft" );
- else
- return PyString_FromString( "hard" );
-}
-
-static PyObject *Texture_getOcts( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->mg_octaves );
-}
-
-static PyObject *Texture_getRepeat( BPy_Texture *self )
-{
- return Py_BuildValue( "(i,i)", self->texture->xrepeat,
- self->texture->yrepeat );
-}
-
-static PyObject *Texture_getRGBCol( BPy_Texture *self )
-{
- return Py_BuildValue( "(f,f,f)", self->texture->rfac,
- self->texture->gfac, self->texture->bfac );
-}
-
-static PyObject *Texture_getSType( BPy_Texture *self )
-{
- if( self->texture->type == TEX_VORONOI )
- return PyInt_FromLong( self->texture->vn_coltype );
-#if 0
- if( self->texture->type == TEX_MUSGRAVE )
- return PyInt_FromLong( self->texture->noisebasis );
-#endif
- if( self->texture->type == TEX_ENVMAP )
- return PyInt_FromLong( self->texture->env->stype );
-
- return PyInt_FromLong( self->texture->stype );
-}
-
-static PyObject *Texture_getTurbulence( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->turbul );
-}
-
-static PyObject *Texture_getType( BPy_Texture *self )
-{
- return PyInt_FromLong( self->texture->type );
-}
-
-static PyObject *Texture_getWeight1( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->vn_w1 );
-}
-
-static PyObject *Texture_getWeight2( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->vn_w2 );
-}
-
-static PyObject *Texture_getWeight3( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->vn_w3 );
-}
-
-static PyObject *Texture_getWeight4( BPy_Texture *self )
-{
- return PyFloat_FromDouble( self->texture->vn_w4 );
-}
-
-/* #####DEPRECATED###### */
-
-static PyObject *Texture_oldsetImage( BPy_Texture * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)Texture_setImage );
-}
-
-static PyObject *Texture_oldsetIpo( BPy_Texture * self, PyObject * args )
-{
- return EXPP_setterWrapper ( (void *)self, args, (setter)Texture_setIpo );
-}
-
-/*
- * clearIpo() returns True/False depending on whether material has an Ipo
- */
-
-static PyObject *Texture_clearIpo( BPy_Texture * self )
-{
- /* if Ipo defined, delete it and return true */
-
- if( self->texture->ipo ) {
- PyObject *value = Py_BuildValue( "(O)", Py_None );
- EXPP_setterWrapper( (void *)self, value, (setter)Texture_setIpo );
- Py_DECREF( value );
- return EXPP_incr_ret_True();
- }
- return EXPP_incr_ret_False(); /* no ipo found */
-}
-
-/*
- * these older setter methods take strings as parameters; check the list of
- * strings to figure out which bits to set, then call new attribute setters
- * using the wrapper.
- */
-
-static PyObject *Texture_oldsetFlags( BPy_Texture * self, PyObject * args )
-{
- unsigned int i, flag = 0;
- PyObject *value, *error;
-
- /* check that we're passed a tuple */
-
- if ( !PyTuple_Check( args ) )
- return EXPP_ReturnPyObjError ( PyExc_AttributeError,
- "expected a tuple of string arguments" );
-
- /* check each argument for type, find its value */
-
- for ( i = PyTuple_Size( args ); i-- ; ) {
- short thisflag;
- char * name = PyString_AsString( PyTuple_GET_ITEM( args, i ) );
- if( !name )
- return EXPP_ReturnPyObjError ( PyExc_AttributeError,
- "expected string argument" );
-
- if( !EXPP_map_getShortVal( tex_flag_map, name, &thisflag ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown Texture flag argument" ) );
-
- flag |= thisflag;
- }
-
- /* build tuple, call wrapper */
-
- value = Py_BuildValue( "(i)", flag );
- error = EXPP_setterWrapper( (void *)self, value, (setter)Texture_setFlags );
- Py_DECREF ( value );
- return error;
-}
-
-/*
- * Texture_oldsetType() and Texture_oldsetExtend()
- *
- * These older setter methods convert a string into an integer setting, so
- * doesn't make sense to try wrapping them.
- */
-
-static PyObject *Texture_oldsetType( BPy_Texture * self, PyObject * args )
-{
- char *type = NULL;
-
- if( !PyArg_ParseTuple( args, "s", &type ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if( !EXPP_map_getShortVal( tex_type_map, type, &self->texture->type ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid texture type" );
-
- /*
- * if we set the texture OK, and it's a environment map, and
- * there is no environment map yet, allocate one (code borrowed
- * from texture_panel_envmap() in source/blender/src/buttons_shading.c)
- */
-
- if( self->texture->type == TEX_ENVMAP
- && !self->texture->env ) {
- self->texture->env = BKE_add_envmap();
- self->texture->env->object= OBACT;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Texture_oldsetExtend( BPy_Texture * self, PyObject * args )
-{
- char *extend = NULL;
- if( !PyArg_ParseTuple( args, "s", &extend ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if( !EXPP_map_getShortVal
- ( tex_extend_map, extend, &self->texture->extend ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid extend mode" );
-
- Py_RETURN_NONE;
-}
-
-/*
- * Texture_oldsetNoiseBasis(), Texture_oldsetDistNoise()
- * Texture_oldsetSType(), Texture_oldsetDistMetric(),
- * Texture_oldsetImageFlags()
- *
- * these old setter methods behave differently from the attribute
- * setters, so they are left unchanged.
- */
-
-static PyObject *Texture_oldsetNoiseBasis( BPy_Texture * self, PyObject * args )
-{
-/* NOTE: leave as-is: don't use setterWrapper */
- char *nbasis;
-
- if( !PyArg_ParseTuple( args, "s", &nbasis ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
- if( self->texture->type == TEX_MUSGRAVE &&
- EXPP_map_getShortVal( tex_stype_map[TEX_DISTNOISE],
- nbasis, &self->texture->noisebasis ) );
- else if( self->texture->type == TEX_DISTNOISE &&
- !EXPP_map_getShortVal( tex_stype_map[TEX_DISTNOISE],
- nbasis, &self->texture->noisebasis2 ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid noise basis" );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Texture_oldsetDistNoise( BPy_Texture * self, PyObject * args )
-{
-/* NOTE: leave as-is: don't use setterWrapper */
- char *nbasis;
-
- if( !PyArg_ParseTuple( args, "s", &nbasis ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
- if( self->texture->type == TEX_DISTNOISE &&
- !EXPP_map_getShortVal( tex_stype_map[TEX_DISTNOISE],
- nbasis, &self->texture->noisebasis ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid noise basis" );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Texture_oldsetSType( BPy_Texture * self, PyObject * args )
-{
- char *stype = NULL;
- if( !PyArg_ParseTuple( args, "s", &stype ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- /* can we really trust texture->type? */
- if( ( self->texture->type == TEX_VORONOI &&
- EXPP_map_getShortVal( tex_stype_map[self->texture->type],
- stype, &self->texture->vn_coltype ) ) );
-#if 0
- else if( ( self->texture->type == TEX_MUSGRAVE &&
- EXPP_map_getShortVal( tex_stype_map
- [TEX_DISTNOISE], stype,
- &self->texture->noisebasis ) ) );
-#endif
- else if( ( self->texture->type == TEX_ENVMAP &&
- EXPP_map_getShortVal( tex_stype_map[self->texture->type],
- stype, &self->texture->env->stype ) ) );
- else if( !EXPP_map_getShortVal
- ( tex_stype_map[self->texture->type], stype,
- &self->texture->stype ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid texture stype" );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Texture_oldsetDistMetric( BPy_Texture * self, PyObject * args )
-{
-/* NOTE: leave as-is: don't use setterWrapper */
- char *dist = NULL;
-
- if( !PyArg_ParseTuple( args, "s", &dist ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
- /* can we really trust texture->type? */
- if( self->texture->type == TEX_VORONOI &&
- !EXPP_map_getShortVal( tex_stype_map[self->texture->type + 2],
- dist, &self->texture->vn_distm ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid dist metric type" );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Texture_oldsetImageFlags( BPy_Texture * self, PyObject * args )
-{
- unsigned int i, flag = 0;
-
- /* check that we're passed a tuple of no more than 3 args*/
-
- if( !PyTuple_Check( args ) )
- return EXPP_ReturnPyObjError ( PyExc_AttributeError,
- "expected tuple of string arguments" );
-
- /* check each argument for type, find its value */
-
- for( i = PyTuple_Size( args ); i-- ; ) {
- short thisflag;
- char * name = PyString_AsString( PyTuple_GET_ITEM( args, i ) );
- if( !name )
- return EXPP_ReturnPyObjError ( PyExc_AttributeError,
- "expected string argument" );
-
- if( !EXPP_map_getShortVal( tex_imageflag_map, name, &thisflag ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "unknown Texture image flag name" );
-
- flag |= thisflag;
- }
-
- self->texture->imaflag = (short)flag;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *Texture_getColorband( BPy_Texture * self)
-{
- return EXPP_PyList_fromColorband( self->texture->coba );
-}
-
-int Texture_setColorband( BPy_Texture * self, PyObject * value)
-{
- return EXPP_Colorband_fromPyList( &self->texture->coba, value );
-}
-
-static PyObject *Texture_evaluate( BPy_Texture * self, PyObject * value )
-{
- TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
- float vec[4];
- /* int rgbnor; dont use now */
-
- if (VectorObject_Check(value)) {
- if(((VectorObject *)value)->size < 3)
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expects a 3D vector object or a tuple of 3 numbers");
-
- /* rgbnor = .. we don't need this now */
- multitex_ext(self->texture, ((VectorObject *)value)->vec, NULL, NULL, 1, &texres);
- } else {
- float vec_in[3];
- if (!PyTuple_Check(value) || PyTuple_Size(value) < 3)
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expects a 3D vector object or a tuple of 3 numbers");
-
- vec_in[0] = PyFloat_AsDouble(PyTuple_GET_ITEM(value, 0));
- vec_in[1] = PyFloat_AsDouble(PyTuple_GET_ITEM(value, 1));
- vec_in[2] = PyFloat_AsDouble(PyTuple_GET_ITEM(value, 2));
- if (PyErr_Occurred())
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expects a 3D vector object or a tuple of 3 numbers");
-
- multitex_ext(self->texture, vec_in, NULL, NULL, 1, &texres);
- }
- vec[0] = texres.tr;
- vec[1] = texres.tg;
- vec[2] = texres.tb;
- vec[3] = texres.tin;
-
- return newVectorObject(vec, 4, Py_NEW);
-}
-
-static PyObject *Texture_copy( BPy_Texture * self )
-{
- Tex *tex = copy_texture(self->texture );
- tex->id.us = 0;
- return Texture_CreatePyObject(tex);
-}
diff --git a/source/blender/python/api2_2x/Texture.h b/source/blender/python/api2_2x/Texture.h
deleted file mode 100644
index a00fe6faf94..00000000000
--- a/source/blender/python/api2_2x/Texture.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Types.c b/source/blender/python/api2_2x/Types.c
deleted file mode 100644
index 425584f84ac..00000000000
--- a/source/blender/python/api2_2x/Types.c
+++ /dev/null
@@ -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;
-}
diff --git a/source/blender/python/api2_2x/Types.h b/source/blender/python/api2_2x/Types.h
deleted file mode 100644
index b905ab75d62..00000000000
--- a/source/blender/python/api2_2x/Types.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c
deleted file mode 100644
index 73edcb2df9c..00000000000
--- a/source/blender/python/api2_2x/Window.c
+++ /dev/null
@@ -1,1594 +0,0 @@
-/*
- * $Id: Window.c 12813 2007-12-07 09:51: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): Willian P. Germano, Tom Musgrove, Michael Reimpell,
- * Yann Vernier, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include <Python.h>
-
-#include "BDR_editobject.h" /* enter / leave editmode */
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_object.h" /* for during_script() and during_scriptlink() */
-#include "BKE_scene.h" /* scene_find_camera() */
-#include "BPI_script.h"
-#include "BIF_mywindow.h"
-#include "BIF_imasel.h"
-#include "BSE_headerbuttons.h"
-#include "BSE_filesel.h"
-#include "BIF_editmesh.h" /* for undo_push_mesh() */
-#include "BIF_screen.h"
-#include "BIF_space.h"
-#include "BIF_drawtext.h"
-#include "BIF_poseobject.h"
-#include "DNA_view3d_types.h"
-#include "DNA_space_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_text_types.h"
-#include "DNA_object_types.h"
-#include "mydevice.h"
-#include "blendef.h" /* OBACT */
-#include "windowTheme.h"
-#include "Mathutils.h"
-#include "constant.h"
-#include "gen_utils.h"
-#include "Armature.h"
-
-/* Pivot Types
--0 for Bounding Box Center; \n\
--1 for 3D Cursor\n\
--2 for Individual Centers\n\
--3 for Median Point\n\
--4 for Active Object"; */
-
-#define PIVOT_BOUNDBOX 0
-#define PIVOT_CURSOR 1
-#define PIVOT_INDIVIDUAL 2
-#define PIVOT_MEDIAN 3
-#define PIVOT_ACTIVE 4
-
-/* See Draw.c */
-extern int EXPP_disable_force_draw;
-extern void setcameratoview3d(void);
-
-/*****************************************************************************/
-/* Python API function prototypes for the Window module. */
-/*****************************************************************************/
-PyObject *M_Window_Redraw( PyObject * self, PyObject * args );
-static PyObject *M_Window_RedrawAll( PyObject * self, PyObject * args );
-static PyObject *M_Window_QRedrawAll( PyObject * self, PyObject * args );
-static PyObject *M_Window_DrawProgressBar( PyObject * self, PyObject * args );
-static PyObject *M_Window_GetCursorPos( PyObject * self );
-static PyObject *M_Window_SetCursorPos( PyObject * self, PyObject * args );
-static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args );
-static PyObject *M_Window_GetViewVector( PyObject * self );
-static PyObject *M_Window_GetActiveLayer( PyObject * self );
-static PyObject *M_Window_SetActiveLayer( PyObject * self, PyObject * args );
-static PyObject *M_Window_GetViewQuat( PyObject * self );
-static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args );
-static PyObject *M_Window_GetViewOffset( PyObject * self );
-static PyObject *M_Window_SetViewOffset( PyObject * self, PyObject * args );
-static PyObject *M_Window_GetViewMatrix( PyObject * self );
-static PyObject *M_Window_GetPerspMatrix( PyObject * self );
-static PyObject *M_Window_FileSelector( PyObject * self, PyObject * args );
-static PyObject *M_Window_ImageSelector( PyObject * self, PyObject * args );
-static PyObject *M_Window_EditMode( PyObject * self, PyObject * args );
-static PyObject *M_Window_PoseMode( PyObject * self, PyObject * args );
-static PyObject *M_Window_ViewLayers( PyObject * self, PyObject * args );
-static PyObject *M_Window_CameraView( PyObject * self, PyObject * args );
-static PyObject *M_Window_QTest( PyObject * self );
-static PyObject *M_Window_QRead( PyObject * self );
-static PyObject *M_Window_QAdd( PyObject * self, PyObject * args );
-static PyObject *M_Window_QHandle( PyObject * self, PyObject * args );
-static PyObject *M_Window_GetMouseCoords( PyObject * self );
-static PyObject *M_Window_SetMouseCoords( PyObject * self, PyObject * args );
-static PyObject *M_Window_GetMouseButtons( PyObject * self );
-static PyObject *M_Window_GetKeyQualifiers( PyObject * self );
-static PyObject *M_Window_SetKeyQualifiers( PyObject * self, PyObject * args );
-static PyObject *M_Window_GetAreaSize( PyObject * self );
-static PyObject *M_Window_GetAreaID( PyObject * self );
-static PyObject *M_Window_GetScreenSize( PyObject * self );
-static PyObject *M_Window_GetScreens( PyObject * self );
-static PyObject *M_Window_SetScreen( PyObject * self, PyObject * value );
-static PyObject *M_Window_GetScreenInfo( PyObject * self, PyObject * args,
- PyObject * kwords );
-static PyObject *M_Window_GetPivot( PyObject * self );
-static PyObject *M_Window_SetPivot( PyObject * self, PyObject * value );
-
-PyObject *Window_Init( void );
-
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Window.__doc__ */
-/*****************************************************************************/
-static char M_Window_doc[] = "The Blender Window module\n\n";
-
-static char M_Window_Redraw_doc[] =
- "() - Force a redraw of a specific Window Type (see Window.Types)";
-
-static char M_Window_RedrawAll_doc[] = "() - Redraw all windows";
-
-static char M_Window_QRedrawAll_doc[] =
- "() - Redraw all windows by queue event";
-
-static char M_Window_FileSelector_doc[] =
- "(callback [, title, filename]) - Open a file selector window.\n\
-The selected file name is used as argument to a function callback f(name)\n\
-that you must provide. 'title' is optional and defaults to 'SELECT FILE'.\n\
-'filename' is optional and defaults to Blender.Get('filename').\n\n\
-Example:\n\n\
-import Blender\n\n\
-def my_function(filename):\n\
- print 'The selected file was: ', filename\n\n\
-Blender.Window.FileSelector(my_function, 'SAVE FILE')\n";
-
-static char M_Window_ImageSelector_doc[] =
- "(callback [, title, filename]) - Open an image selector window.\n\
-The selected file name is used as argument to a function callback f(name)\n\
-that you must provide. 'title' is optional and defaults to 'SELECT IMAGE'.\n\
-'filename' is optional and defaults to Blender.Get('filename').\n\n\
-Example:\n\n\
-import Blender\n\n\
-def my_function(filename):\n\
- print 'The selected image file was: ', filename\n\n\
-Blender.Window.ImageSelector(my_function, 'LOAD IMAGE')\n";
-
-static char M_Window_DrawProgressBar_doc[] =
- "(done, text) - Draw a progress bar.\n\
-'done' is a float value <= 1.0, 'text' contains info about what is\n\
-currently being done.";
-
-static char M_Window_GetCursorPos_doc[] =
- "() - Get the current 3d cursor position as a list of three floats.";
-
-static char M_Window_SetCursorPos_doc[] =
- "([f,f,f]) - Set the current 3d cursor position from a list of three floats.";
-
-static char M_Window_WaitCursor_doc[] =
- "(bool) - Set cursor to wait mode (nonzero bool) or normal mode (0).";
-
-static char M_Window_GetViewVector_doc[] =
- "() - Get the current 3d view vector as a list of three floats [x,y,z].";
-
-static char M_Window_GetActiveLayer_doc[] =
- "() - Get the current 3d views active layer where new objects are created.";
-
-static char M_Window_SetActiveLayer_doc[] =
- "(int) - Set the current 3d views active layer where new objects are created.";
-
-static char M_Window_GetViewMatrix_doc[] =
- "() - Get the current 3d view matrix.";
-
-static char M_Window_GetPerspMatrix_doc[] =
- "() - Get the current 3d Persp matrix.";
-
-static char M_Window_EditMode_doc[] =
- "() - Get the current status -- 0: not in edit mode; 1: in edit mode.\n\
-(status) - if 1: enter edit mode; if 0: leave edit mode.\n\
-Returns the current status. This function is mostly useful to leave\n\
-edit mode before applying changes to a mesh (otherwise the changes will\n\
-be lost) and then returning to it upon leaving.";
-static char M_Window_PoseMode_doc[] =
- "() - Get the current status -- 0: not in pose mode; 1: in edit mode";
-
-static char M_Window_ViewLayers_doc[] =
- "(layers = [], winid = None) - Get/set active layers in all 3d View windows.\n\
-() - Make no changes, only return currently visible layers.\n\
-(layers = []) - a list of integers, each in the range [1, 20].\n\
-(layers = [], winid = int) - layers as above, winid is an optional.\n\
-arg that makes the function only set layers for that view.\n\
-This function returns the currently visible layers as a list of ints.";
-
-static char M_Window_GetViewQuat_doc[] =
- "() - Get the current VIEW3D view quaternion values.";
-
-static char M_Window_SetViewQuat_doc[] =
- "(quat) - Set the current VIEW3D view quaternion values.\n\
-(quat) - [f,f,f,f] or f,f,f,f: the new float values.";
-
-static char M_Window_GetViewOffset_doc[] =
- "() - Get the current VIEW3D view offset values.";
-
-static char M_Window_SetViewOffset_doc[] =
- "(ofs) - Set the current VIEW3D view offset values.\n\
-(ofs) - [f,f,f] or f,f,f: the new float values.";
-
-static char M_Window_CameraView_doc[] =
- "(camtov3d = 0) - Set the current VIEW3D view to the active camera's view.\n\
-(camtov3d = 0) - bool: if nonzero it's the camera that gets positioned at the\n\
-current view, instead of the view being changed to that of the camera.\n\n\
-If no camera is the active object, the active camera for the current scene\n\
-is used.";
-
-static char M_Window_QTest_doc[] =
- "() - Check if there are pending events in the event queue.";
-
-static char M_Window_QRead_doc[] =
- "() - Get the next pending event from the event queue.\n\
-This function returns a list [event, val], where:\n\
-event - int: the key or mouse event (see Blender.Draw module);\n\
-val - int: if 1 it's a key or mouse button press, if 0 a release. For\n\
- mouse movement events 'val' returns the new coordinates in x or y.";
-
-static char M_Window_QAdd_doc[] =
- "(win, evt, val, after = 0) - Add an event to some window's event queue.\n\
-(win) - int: the win id, see Blender.Window.GetScreenInfo();\n\
-(evt) - int: the event number, see events in Blender.Draw;\n\
-(val) - bool: 1 for a key press, 0 for a release;\n\
-(after) - bool: if 1 the event is put after the current queue and added later.";
-
-static char M_Window_QHandle_doc[] =
- "(win) - Process all events for the given window (area) now.\n\
-(win) - int: the window id, see Blender.Window.GetScreenInfo().\n\n\
-See Blender.Window.QAdd() for how to send events to a particular window.";
-
-static char M_Window_GetMouseCoords_doc[] =
- "() - Get mouse pointer's current screen coordinates.";
-
-static char M_Window_SetMouseCoords_doc[] =
- "(x, y) - Set mouse pointer's current screen coordinates.\n\
-(x,y) - ints ([x, y] also accepted): the new x, y coordinates.";
-
-static char M_Window_GetMouseButtons_doc[] =
- "() - Get the current mouse button state (see Blender.Window.MButs dict).";
-
-static char M_Window_GetKeyQualifiers_doc[] =
- "() - Get the current qualifier keys state.\n\
-An int is returned: or'ed combination of values in Blender.Window.Qual's dict.";
-
-static char M_Window_SetKeyQualifiers_doc[] =
- "(qual) - Fake qualifier keys state.\n\
-(qual) - int: an or'ed combination of the values in Blender.Window.Qual dict.\n\
-Note: remember to reset to 0 after handling the related event (see QAdd()).";
-
-static char M_Window_GetAreaID_doc[] =
- "() - Get the current window's (area) ID.";
-
-static char M_Window_GetAreaSize_doc[] =
- "() - Get the current window's (area) size as [width, height].";
-
-static char M_Window_GetScreenSize_doc[] =
- "() - Get the screen's size as [width, height].";
-
-static char M_Window_GetScreens_doc[] =
- "() - Get a list with the names of all available screens.";
-
-static char M_Window_SetScreen_doc[] =
- "(name) - Set current screen to the one with the given 'name'.";
-
-static char M_Window_GetScreenInfo_doc[] =
- "(type = -1, rect = 'win', screen = None)\n\
-- Get info about the the areas in the current screen setup.\n\
-(type = -1) - int: the space type (Blender.Window.Types) to restrict the\n\
- results to, all if -1;\n\
-(rect = 'win') - str: the rectangle of interest. This defines if the corner\n\
- coordinates returned will refer to:\n\
- - the whole area: 'total';\n\
- - only the header: 'header';\n\
- - only the window content (default): 'win'.\n\
-(screen = None) - str: the screen name, current if not given.\n\n\
-A list of dictionaries (one for each area) is returned.\n\
-Each dictionary has keys:\n\
-'vertices': [xmin, ymin, xmax, ymax] area corners;\n\
-'win': window type, see Blender.Window.Types dict;\n\
-'id': area's id.";
-
-static char M_Window_SetPivot_doc[] =
- "(Pivot) - Set Pivot Mode for 3D Viewport:\n\
-Options are: \n\
--PivotTypes.BOUNDBOX for Bounding Box Center; \n\
--PivotTypes.CURSOR for 3D Cursor\n\
--PivotTypes.INDIVIDUAL for Individual Centers\n\
--PivotTypes.MEDIAN for Median Point\n\
--PivotTypes.ACTIVE for Active Object";
-
-static char M_Window_GetPivot_doc[] =
- "Return the pivot for the active 3d window";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Window module: */
-/*****************************************************************************/
-struct PyMethodDef M_Window_methods[] = {
- {"Redraw", M_Window_Redraw, METH_VARARGS, M_Window_Redraw_doc},
- {"RedrawAll", M_Window_RedrawAll, METH_VARARGS,
- M_Window_RedrawAll_doc},
- {"QRedrawAll", M_Window_QRedrawAll, METH_VARARGS,
- M_Window_QRedrawAll_doc},
- {"FileSelector", M_Window_FileSelector, METH_VARARGS,
- M_Window_FileSelector_doc},
- {"ImageSelector", ( PyCFunction ) M_Window_ImageSelector, METH_VARARGS,
- M_Window_ImageSelector_doc},
- {"DrawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
- M_Window_DrawProgressBar_doc},
- {"drawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
- M_Window_DrawProgressBar_doc},
- {"GetCursorPos", ( PyCFunction ) M_Window_GetCursorPos, METH_NOARGS,
- M_Window_GetCursorPos_doc},
- {"SetCursorPos", M_Window_SetCursorPos, METH_VARARGS,
- M_Window_SetCursorPos_doc},
- {"WaitCursor", M_Window_WaitCursor, METH_VARARGS,
- M_Window_WaitCursor_doc},
- {"GetViewVector", ( PyCFunction ) M_Window_GetViewVector, METH_NOARGS,
- M_Window_GetViewVector_doc},
- {"GetActiveLayer", ( PyCFunction ) M_Window_GetActiveLayer, METH_NOARGS,
- M_Window_GetActiveLayer_doc},
- {"SetActiveLayer", ( PyCFunction ) M_Window_SetActiveLayer, METH_VARARGS,
- M_Window_SetActiveLayer_doc},
- {"GetViewQuat", ( PyCFunction ) M_Window_GetViewQuat, METH_NOARGS,
- M_Window_GetViewQuat_doc},
- {"SetViewQuat", ( PyCFunction ) M_Window_SetViewQuat, METH_VARARGS,
- M_Window_SetViewQuat_doc},
- {"GetViewOffset", ( PyCFunction ) M_Window_GetViewOffset, METH_NOARGS,
- M_Window_GetViewOffset_doc},
- {"SetViewOffset", ( PyCFunction ) M_Window_SetViewOffset, METH_VARARGS,
- M_Window_SetViewOffset_doc},
- {"GetViewMatrix", ( PyCFunction ) M_Window_GetViewMatrix, METH_NOARGS,
- M_Window_GetViewMatrix_doc},
- {"GetPerspMatrix", ( PyCFunction ) M_Window_GetPerspMatrix, METH_NOARGS,
- M_Window_GetPerspMatrix_doc},
- {"EditMode", ( PyCFunction ) M_Window_EditMode, METH_VARARGS,
- M_Window_EditMode_doc},
- {"PoseMode", ( PyCFunction ) M_Window_PoseMode, METH_VARARGS,
- M_Window_PoseMode_doc},
- {"ViewLayers", ( PyCFunction ) M_Window_ViewLayers, METH_VARARGS,
- M_Window_ViewLayers_doc},
- /* typo, deprecate someday: */
- {"ViewLayer", ( PyCFunction ) M_Window_ViewLayers, METH_VARARGS,
- M_Window_ViewLayers_doc},
- {"CameraView", ( PyCFunction ) M_Window_CameraView, METH_VARARGS,
- M_Window_CameraView_doc},
- {"QTest", ( PyCFunction ) M_Window_QTest, METH_NOARGS,
- M_Window_QTest_doc},
- {"QRead", ( PyCFunction ) M_Window_QRead, METH_NOARGS,
- M_Window_QRead_doc},
- {"QAdd", ( PyCFunction ) M_Window_QAdd, METH_VARARGS,
- M_Window_QAdd_doc},
- {"QHandle", ( PyCFunction ) M_Window_QHandle, METH_VARARGS,
- M_Window_QHandle_doc},
- {"GetMouseCoords", ( PyCFunction ) M_Window_GetMouseCoords,
- METH_NOARGS,
- M_Window_GetMouseCoords_doc},
- {"SetMouseCoords", ( PyCFunction ) M_Window_SetMouseCoords,
- METH_VARARGS,
- M_Window_SetMouseCoords_doc},
- {"GetMouseButtons", ( PyCFunction ) M_Window_GetMouseButtons,
- METH_NOARGS,
- M_Window_GetMouseButtons_doc},
- {"GetKeyQualifiers", ( PyCFunction ) M_Window_GetKeyQualifiers,
- METH_NOARGS,
- M_Window_GetKeyQualifiers_doc},
- {"SetKeyQualifiers", ( PyCFunction ) M_Window_SetKeyQualifiers,
- METH_VARARGS,
- M_Window_SetKeyQualifiers_doc},
- {"GetAreaSize", ( PyCFunction ) M_Window_GetAreaSize, METH_NOARGS,
- M_Window_GetAreaSize_doc},
- {"GetAreaID", ( PyCFunction ) M_Window_GetAreaID, METH_NOARGS,
- M_Window_GetAreaID_doc},
- {"GetScreenSize", ( PyCFunction ) M_Window_GetScreenSize, METH_NOARGS,
- M_Window_GetScreenSize_doc},
- {"GetScreens", ( PyCFunction ) M_Window_GetScreens, METH_NOARGS,
- M_Window_GetScreens_doc},
- {"SetScreen", ( PyCFunction ) M_Window_SetScreen, METH_O,
- M_Window_SetScreen_doc},
- {"GetScreenInfo", ( PyCFunction ) M_Window_GetScreenInfo,
- METH_VARARGS | METH_KEYWORDS, M_Window_GetScreenInfo_doc},
- {"GetPivot", ( PyCFunction ) M_Window_GetPivot, METH_NOARGS,
- M_Window_GetPivot_doc},
- {"SetPivot", ( PyCFunction ) M_Window_SetPivot, METH_O,
- M_Window_SetPivot_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Function: M_Window_Redraw */
-/* Python equivalent: Blender.Window.Redraw */
-/*****************************************************************************/
-/* not static so py_slider_update in Draw.[ch] can use it */
-PyObject *M_Window_Redraw( PyObject * self, PyObject * args )
-{
- ScrArea *tempsa, *sa;
- int wintype = SPACE_VIEW3D;
- short redraw_all = 0;
-
- if( !PyArg_ParseTuple( args, "|i", &wintype ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument (or nothing)" ) );
-
- if( wintype < 0 )
- redraw_all = 1;
-
- if( !during_script( ) && !G.background ) {
- tempsa = curarea;
- sa = G.curscreen->areabase.first;
-
- while( sa ) {
-
- if( sa->spacetype == wintype || redraw_all ) {
- if (sa->spacetype == SPACE_SCRIPT && EXPP_disable_force_draw) {
- scrarea_queue_redraw(sa);
- }
- else {
- /* do not call fancy hacks here like pop_space_text(st); (ton) */
- scrarea_do_windraw( sa );
- if( sa->headwin ) scrarea_do_headdraw( sa );
- }
- }
- sa = sa->next;
- }
-
- if( curarea != tempsa )
- areawinset( tempsa->win );
-
- if( curarea ) { /* is null if Blender is in bg mode */
- if( curarea->headwin )
- scrarea_do_headdraw( curarea );
- screen_swapbuffers( );
- }
- }
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: M_Window_RedrawAll */
-/* Python equivalent: Blender.Window.RedrawAll */
-/*****************************************************************************/
-static PyObject *M_Window_RedrawAll( PyObject * self, PyObject * args )
-{
- PyObject *arg = Py_BuildValue( "(i)", -1 );
- PyObject *ret = M_Window_Redraw( self, arg );
- Py_DECREF(arg);
- return ret;
-}
-
-/*****************************************************************************/
-/* Function: M_Window_QRedrawAll */
-/* Python equivalent: Blender.Window.QRedrawAll */
-/*****************************************************************************/
-static PyObject *M_Window_QRedrawAll( PyObject * self, PyObject * args )
-{
- EXPP_allqueue( REDRAWALL, 0 );
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: M_Window_FileSelector */
-/* Python equivalent: Blender.Window.FileSelector */
-/*****************************************************************************/
-
-/* This is the callback to "activate_fileselect" below. It receives the
- * selected filename and (using it as argument) calls the Python callback
- * provided by the script writer and stored in EXPP_FS_PyCallback. */
-
-static void getSelectedFile( char *name )
-{
- PyObject *pycallback;
- PyObject *result;
- Script *script;
-
- /* let's find the script that owns this callback */
- script = G.main->script.first;
- while (script) {
- if (script->flags & SCRIPT_RUNNING) break;
- script = script->id.next;
- }
-
- if (!script) {
- if (curarea->spacetype == SPACE_SCRIPT) {
- SpaceScript *sc = curarea->spacedata.first;
- script = sc->script;
- }
- }
-
- pycallback = script->py_browsercallback;
-
- if (pycallback) {
- result = PyObject_CallFunction( pycallback, "s", name );
-
- if (!result) {
- if (G.f & G_DEBUG)
- fprintf(stderr, "BPy error: Callback call failed!\n");
- }
- else Py_DECREF(result);
-
- if (script->py_browsercallback == pycallback)
- script->py_browsercallback = NULL;
- /* else another call to selector was made inside pycallback */
-
- Py_DECREF(pycallback);
- }
-
- return;
-}
-
-static PyObject *M_Window_FileSelector( PyObject * self, PyObject * args )
-{
- char *title = "SELECT FILE";
- char *filename = G.sce;
- SpaceScript *sc;
- Script *script = NULL;
- PyObject *pycallback = NULL;
- int startspace = 0;
-
- if (during_scriptlink())
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "script links can't call the file selector");
-
- if (G.background)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "the file selector is not available in background mode");
-
- if((!PyArg_ParseTuple( args, "O|ss", &pycallback, &title, &filename))
- || (!PyCallable_Check(pycallback)))
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "\nexpected a callback function (and optionally one or two strings) "
- "as argument(s)" );
-
- Py_INCREF(pycallback);
-
-/* trick: we move to a spacescript because then the fileselector will properly
- * unset our SCRIPT_FILESEL flag when the user chooses a file or cancels the
- * selection. This is necessary because when a user cancels, the
- * getSelectedFile function above doesn't get called and so couldn't unset the
- * flag. */
- startspace = curarea->spacetype;
- if( startspace != SPACE_SCRIPT )
- newspace( curarea, SPACE_SCRIPT );
-
- sc = curarea->spacedata.first;
-
- /* let's find the script that called us */
- script = G.main->script.first;
- while (script) {
- if (script->flags & SCRIPT_RUNNING) break;
- script = script->id.next;
- }
-
- if( !script ) {
- /* if not running, then we were already on a SpaceScript space, executing
- * a registered callback -- aka: this script has a gui */
- script = sc->script; /* this is the right script */
- } else { /* still running, use the trick */
- script->lastspace = startspace;
- sc->script = script;
- }
-
- script->flags |= SCRIPT_FILESEL;
-
- /* clear any previous callback (nested calls to selector) */
- if (script->py_browsercallback) {
- Py_DECREF((PyObject *)script->py_browsercallback);
- }
- script->py_browsercallback = pycallback;
-
- activate_fileselect( FILE_BLENDER, title, filename, getSelectedFile );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_ImageSelector( PyObject * self, PyObject * args )
-{
- char *title = "SELECT IMAGE";
- char *filename = G.sce;
- SpaceScript *sc;
- Script *script = NULL;
- PyObject *pycallback = NULL;
- int startspace = 0;
-
- if (during_scriptlink())
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "script links can't call the image selector");
-
- if (G.background)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "the image selector is not available in background mode");
-
- if( !PyArg_ParseTuple( args, "O|ss", &pycallback, &title, &filename )
- || (!PyCallable_Check(pycallback)))
- return EXPP_ReturnPyObjError ( PyExc_AttributeError,
- "\nexpected a callback function (and optionally one or two strings) "
- "as argument(s)" );
-
- Py_INCREF(pycallback);
-
-/* trick: we move to a spacescript because then the fileselector will properly
- * unset our SCRIPT_FILESEL flag when the user chooses a file or cancels the
- * selection. This is necessary because when a user cancels, the
- * getSelectedFile function above doesn't get called and so couldn't unset the
- * flag. */
- startspace = curarea->spacetype;
- if( startspace != SPACE_SCRIPT )
- newspace( curarea, SPACE_SCRIPT );
-
- sc = curarea->spacedata.first;
-
- /* let's find the script that called us */
- script = G.main->script.first;
- while (script) {
- if (script->flags & SCRIPT_RUNNING) break;
- script = script->id.next;
- }
-
- if( !script ) {
- /* if not running, then we were already on a SpaceScript space, executing
- * a registered callback -- aka: this script has a gui */
- script = sc->script; /* this is the right script */
- } else { /* still running, use the trick */
- script->lastspace = startspace;
- sc->script = script;
- }
-
- script->flags |= SCRIPT_FILESEL; /* same flag as filesel */
- /* clear any previous callback (nested calls to selector) */
- if (script->py_browsercallback) {
- Py_DECREF((PyObject *)script->py_browsercallback);
- }
- script->py_browsercallback = pycallback;
-
- activate_imageselect( FILE_BLENDER, title, filename, getSelectedFile );
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: M_Window_DrawProgressBar */
-/* Python equivalent: Blender.Window.DrawProgressBar */
-/*****************************************************************************/
-static PyObject *M_Window_DrawProgressBar( PyObject * self, PyObject * args )
-{
- float done;
- char *info = NULL;
- int retval = 0;
- ScrArea *sa = curarea;
-
- if (G.background)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "the progress bar is not available in background mode");
-
- if( !PyArg_ParseTuple( args, "fs", &done, &info ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a float and a string as arguments" ) );
-
- retval = progress_bar( done, info );
-
- areawinset(sa->win);
-
- return Py_BuildValue( "i", retval );
-}
-
-/*****************************************************************************/
-/* Function: M_Window_GetCursorPos */
-/* Python equivalent: Blender.Window.GetCursorPos */
-/*****************************************************************************/
-static PyObject *M_Window_GetCursorPos( PyObject * self )
-{
- float *cursor = NULL;
- PyObject *pylist;
-
- if( G.vd && G.vd->localview )
- cursor = G.vd->cursor;
- else
- cursor = G.scene->cursor;
-
- pylist = Py_BuildValue( "[fff]", cursor[0], cursor[1], cursor[2] );
-
- if( !pylist )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "GetCursorPos: couldn't create pylist" ) );
-
- return pylist;
-}
-
-/*****************************************************************************/
-/* Function: M_Window_SetCursorPos */
-/* Python equivalent: Blender.Window.SetCursorPos */
-/*****************************************************************************/
-static PyObject *M_Window_SetCursorPos( PyObject * self, PyObject * args )
-{
- int ok = 0;
- float val[3];
-
- if( PyObject_Length( args ) == 3 )
- ok = PyArg_ParseTuple( args, "fff", &val[0], &val[1],
- &val[2] );
- else
- ok = PyArg_ParseTuple( args, "(fff)", &val[0], &val[1],
- &val[2] );
-
- if( !ok )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected [f,f,f] or f,f,f as arguments" );
-
- if( G.vd && G.vd->localview ) {
- G.vd->cursor[0] = val[0];
- G.vd->cursor[1] = val[1];
- G.vd->cursor[2] = val[2];
- } else {
- G.scene->cursor[0] = val[0];
- G.scene->cursor[1] = val[1];
- G.scene->cursor[2] = val[2];
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args )
-{
- int bool;
-
- if( !PyArg_ParseTuple( args, "i", &bool ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected bool (0 or 1) or nothing as argument" );
-
- waitcursor( bool ); /* nonzero bool sets, zero unsets */
-
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* Function: M_Window_GetViewVector */
-/* Python equivalent: Blender.Window.GetViewVector */
-/*****************************************************************************/
-static PyObject *M_Window_GetViewVector( PyObject * self )
-{
- float *vec = NULL;
-
- if( !G.vd )
- Py_RETURN_NONE;
-
- vec = G.vd->viewinv[2];
-
- return Py_BuildValue( "[fff]", vec[0], vec[1], vec[2] );
-}
-
-/*****************************************************************************/
-/* Function: M_Window_GetActiveLayer */
-/* Python equivalent: Blender.Window.GetActiveLayer */
-/*****************************************************************************/
-static PyObject *M_Window_GetActiveLayer( PyObject * self )
-{
- if (!G.vd) {
- return PyInt_FromLong(0);
- } else {
- return PyInt_FromLong( G.vd->layact );
- }
-}
-
-static PyObject *M_Window_SetActiveLayer( PyObject * self, PyObject * args )
-{
- int layer, bit=1;
- if( !PyArg_ParseTuple( args, "i", &layer ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int" ) );
-
- if (!G.vd)
- Py_RETURN_FALSE;
-
- bit= 0;
- while(bit<32) {
- if(layer & (1<<bit)) {
- G.vd->layact= 1<<bit;
- G.vd->lay |= G.vd->layact;
-
- if (G.vd->scenelock) {
- G.scene->lay |= G.vd->layact;
- }
- bit = -1; /* no error */
- break;
- }
- bit++;
- }
-
- if (bit != -1)
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "The flag could not be used for the active layer" ) );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_GetViewQuat( PyObject * self )
-{
- float *vec = NULL;
-
- if( !G.vd )
- Py_RETURN_NONE;
-
- vec = G.vd->viewquat;
-
- return Py_BuildValue( "[ffff]", vec[0], vec[1], vec[2], vec[3] );
-}
-
-static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args )
-{
- int ok = 0;
- float val[4];
-
- if( !G.vd )
- Py_RETURN_NONE;
-
- if( PyObject_Length( args ) == 4 )
- ok = PyArg_ParseTuple( args, "ffff", &val[0], &val[1], &val[2],
- &val[3] );
- else
- ok = PyArg_ParseTuple( args, "(ffff)", &val[0], &val[1],
- &val[2], &val[3] );
-
- if( !ok )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected [f,f,f,f] or f,f,f,f as arguments" );
-
- G.vd->viewquat[0] = val[0];
- G.vd->viewquat[1] = val[1];
- G.vd->viewquat[2] = val[2];
- G.vd->viewquat[3] = val[3];
-
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_GetViewOffset( PyObject * self )
-{
- if( !G.vd )
- Py_RETURN_NONE;
- return Py_BuildValue( "[fff]", G.vd->ofs[0], G.vd->ofs[1], G.vd->ofs[2] );
-}
-
-static PyObject *M_Window_SetViewOffset( PyObject * self, PyObject * args )
-{
- int ok = 0;
- float val[3];
-
- if( !G.vd )
- Py_RETURN_NONE;
-
- if( PyObject_Length( args ) == 3 )
- ok = PyArg_ParseTuple( args, "fff", &val[0], &val[1],
- &val[2] );
- else
- ok = PyArg_ParseTuple( args, "(fff)", &val[0], &val[1],
- &val[2] );
-
- if( !ok )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected [f,f,f] or f,f,f as arguments" );
-
- G.vd->ofs[0] = val[0];
- G.vd->ofs[1] = val[1];
- G.vd->ofs[2] = val[2];
-
- Py_RETURN_NONE;
-}
-
-
-/*****************************************************************************/
-/* Function: M_Window_GetViewMatrix */
-/* Python equivalent: Blender.Window.GetViewMatrix */
-/*****************************************************************************/
-static PyObject *M_Window_GetViewMatrix( PyObject * self )
-{
- if( !G.vd )
- Py_RETURN_NONE;
-
- return newMatrixObject( ( float * ) G.vd->viewmat, 4, 4, Py_WRAP );
-}
-
-/*****************************************************************************/
-/* Function: M_Window_GetPerspMatrix */
-/* Python equivalent: Blender.Window.GetPerspMatrix */
-/*****************************************************************************/
-static PyObject *M_Window_GetPerspMatrix( PyObject * self )
-{
- if( !G.vd )
- Py_RETURN_NONE;
-
- return newMatrixObject( ( float * ) G.vd->persmat, 4, 4, Py_WRAP );
-}
-
-
-/* update_armature_weakrefs()
- * helper function used in M_Window_EditMode.
- * rebuilds list of Armature weakrefs in __main__
- */
-
-static int update_armature_weakrefs()
-{
- /* stuff for armature weak refs */
- char *list_name = ARM_WEAKREF_LIST_NAME;
- PyObject *maindict = NULL, *armlist = NULL;
- PyObject *pyarmature = NULL;
- int x;
-
- maindict= PyModule_GetDict(PyImport_AddModule( "__main__"));
- armlist = PyDict_GetItemString(maindict, list_name);
- if( !armlist){
- printf("Oops - update_armature_weakrefs()\n");
- return 0;
- }
-
- for (x = 0; x < PySequence_Size(armlist); x++){
- pyarmature = PyWeakref_GetObject(PySequence_GetItem( armlist, x));
- if (pyarmature != Py_None)
- Armature_RebuildEditbones(pyarmature);
- }
- return 1;
-}
-
-
-static PyObject *M_Window_EditMode( PyObject * self, PyObject * args )
-{
- short status = -1;
- char *undo_str = "From script";
- int undo_str_len = 11;
- int do_undo = 1;
-
- if( !PyArg_ParseTuple( args,
- "|hs#i", &status, &undo_str, &undo_str_len, &do_undo ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected optional int (bool), string and int (bool) as arguments" );
-
- if( status >= 0 ) {
- if( status ) {
- if( !G.obedit ){
-
- //update armatures
- if(! update_armature_weakrefs()){
- return EXPP_ReturnPyObjError(
- PyExc_RuntimeError,
- "internal error - update_armature_weakrefs");
- }
-
- //enter editmode
- enter_editmode(0);
- }
- } else if( G.obedit ) {
- if( undo_str_len > 63 )
- undo_str[63] = '\0'; /* 64 is max */
- BIF_undo_push( undo_str ); /* This checks user undo settings */
- exit_editmode( EM_FREEDATA );
-
- //update armatures
- if(! update_armature_weakrefs()){
- return EXPP_ReturnPyObjError(
- PyExc_RuntimeError,
- "internal error - update_armature_weakrefs");
- }
-
- }
- }
-
- return Py_BuildValue( "h", G.obedit ? 1 : 0 );
-}
-
-static PyObject *M_Window_PoseMode( PyObject * self, PyObject * args )
-{
- short status = -1;
- short is_posemode = 0;
- Base *base;
-
- if( !PyArg_ParseTuple( args, "|h", &status ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected optional int (bool) as argument" );
-
- if( status >= 0 ) {
- if( status ) {
- enter_posemode();
- } else if( G.obedit ) {
- exit_posemode();
- }
- }
-
- base= BASACT;
- if (base && base->object->flag & OB_POSEMODE) {
- is_posemode = 1;
- }
-
- return Py_BuildValue( "h", is_posemode );
-}
-
-static PyObject *M_Window_ViewLayers( PyObject * self, PyObject * args )
-{
- PyObject *item = NULL;
- PyObject *list = NULL, *resl = NULL;
- int val, i, bit = 0, layer = 0, len_list;
- short winid = -1;
-
- if( !G.scene ) {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "can't get pointer to global scene" );
- }
-
- /* Pase Args, Nothing, One list, Or a list and an int */
- if (PyTuple_GET_SIZE(args)!=0) {
- if( !PyArg_ParseTuple ( args, "O!|h", &PyList_Type, &list, &winid) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "nothing or a list and optionaly a window ID argument" );
- }
- }
-
- if( list ) {
- len_list = PyList_Size(list);
-
- if (len_list == 0)
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "list can't be empty, at list one layer must be set" );
-
- for( i = 0; i < len_list; i++ ) {
- item = PyList_GetItem( list, i );
- if( !PyInt_Check( item ) )
- return EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "list must contain only integer numbers" );
-
- val = ( int ) PyInt_AsLong( item );
- if( val < 1 || val > 20 )
- return EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "layer values must be in the range [1, 20]" );
-
- layer |= 1 << ( val - 1 );
- }
-
- if (winid==-1) {
- /* set scene and viewport */
- G.scene->lay = layer;
- if (G.vd) {
- G.vd->lay = layer;
-
- while( bit < 20 ) {
- val = 1 << bit;
- if( layer & val ) {
- G.vd->layact = val;
- break;
- }
- bit++;
- }
- }
- } else {
- /* only set the windows layer */
- ScrArea *sa;
- SpaceLink *sl;
- View3D *vd;
-
- if (G.curscreen) { /* can never be too careful */
- for (sa=G.curscreen->areabase.first; sa; sa= sa->next) {
- if (winid == sa->win) {
-
- for (sl= sa->spacedata.first; sl; sl= sl->next)
- if(sl->spacetype==SPACE_VIEW3D)
- break;
-
- if (!sl)
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "The window matching the winid has no 3d viewport" );
-
- vd= (View3D *) sl;
- vd->lay = layer;
-
- for(bit= 0; bit < 20; bit++) {
- val = 1 << bit;
- if( layer & val ) {
- vd->layact = val;
- break;
- }
- }
-
- winid = -1; /* so we know its done */
- break;
- }
- }
- if (winid!=-1)
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "The winid argument did not match any window" );
- }
- }
- }
-
- resl = PyList_New( 0 );
- if( !resl )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create pylist!" ) );
-
- layer = G.scene->lay;
-
- bit = 0;
- while( bit < 20 ) {
- val = 1 << bit;
- if( layer & val ) {
- item = Py_BuildValue( "i", bit + 1 );
- PyList_Append( resl, item );
- Py_DECREF( item );
- }
- bit++;
- }
-
- return resl;
-}
-
-static PyObject *M_Window_CameraView( PyObject * self, PyObject * args )
-{
- short camtov3d = 0;
-
- if( !PyArg_ParseTuple( args, "|i", &camtov3d ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int (from Window.Views) as argument" );
-
- if( !G.vd )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "this function can only be used after a 3d View has been initialized" );
-
- if( !G.vd->camera ) {
- if( BASACT && OBACT->type == OB_CAMERA )
- G.vd->camera = OBACT;
- else
- G.vd->camera = scene_find_camera( G.scene );
- handle_view3d_lock( );
- }
-
- G.vd->persp = 2;
- G.vd->view = 0;
-
- if( camtov3d )
- setcameratoview3d( );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_QTest( PyObject * self )
-{
- return Py_BuildValue( "h", qtest( ) );
-}
-
-static PyObject *M_Window_QRead( PyObject * self )
-{
- short val = 0;
- unsigned short event;
-
- if (G.background)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "QRead is not available in background mode");
-
- event = extern_qread( &val );
-
- return Py_BuildValue( "ii", event, val );
-}
-
-static PyObject *M_Window_QAdd( PyObject * self, PyObject * args )
-{
- short win;
- short evt; /* unsigned, we check below */
- short val;
- short after = 0;
-
- if (G.background)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "QAdd is not available in background mode");
-
- if( !PyArg_ParseTuple( args, "hhh|h", &win, &evt, &val, &after ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected three or four ints as arguments" );
-
- if( evt < 0 ) /* evt is unsigned short */
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "event value must be a positive int, check events in Blender.Draw" );
-
- if( after )
- addafterqueue( win, evt, val );
- else
- addqueue( win, evt, val );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_QHandle( PyObject * self, PyObject * args )
-{
- short win;
- ScrArea *sa;
- ScrArea *oldsa = NULL;
-
- if (G.background)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "QHandle is not available in background mode");
-
- if (!G.curscreen)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "No screens available");
-
- if( !PyArg_ParseTuple( args, "h", &win ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int as argument" );
-
- for (sa= G.curscreen->areabase.first; sa; sa= sa->next)
- if( sa->win == win )
- break;
-
- if( sa ) {
- BWinEvent evt;
- short do_redraw = 0, do_change = 0;
-
- if( sa != curarea || sa->win != mywinget( ) ) {
- oldsa = curarea;
- areawinset( sa->win );
- set_g_activearea( sa );
- }
- while( bwin_qread( sa->win, &evt ) ) {
- if( evt.event == REDRAW ) {
- do_redraw = 1;
- } else if( evt.event == CHANGED ) {
- sa->win_swap = 0;
- do_change = 1;
- do_redraw = 1;
- } else {
- scrarea_do_winhandle( sa, &evt );
- }
- }
- }
-
- if( oldsa ) {
- areawinset( oldsa->win );
- set_g_activearea( oldsa );
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_GetMouseCoords( PyObject * self )
-{
- short mval[2];
-
- getmouse( mval );
-
- return Py_BuildValue( "hh", mval[0], mval[1] );
-}
-
-static PyObject *M_Window_SetMouseCoords( PyObject * self, PyObject * args )
-{
- int ok, x, y;
-
- if( !G.curscreen )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "no current screen to retrieve info from!" );
-
- x = G.curscreen->sizex / 2;
- y = G.curscreen->sizey / 2;
-
- if( PyObject_Length( args ) == 2 )
- ok = PyArg_ParseTuple( args, "hh", &x, &y );
- else
- ok = PyArg_ParseTuple( args, "|(hh)", &x, &y );
-
- if( !ok )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected [i, i] or i,i as arguments (or nothing)." );
-
- warp_pointer( x, y );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_GetMouseButtons( PyObject * self )
-{
- short mbut = get_mbut( );
-
- return Py_BuildValue( "h", mbut );
-}
-
-static PyObject *M_Window_GetKeyQualifiers( PyObject * self )
-{
- short qual = get_qual( );
-
- return Py_BuildValue( "h", qual );
-}
-
-static PyObject *M_Window_SetKeyQualifiers( PyObject * self, PyObject * args )
-{
- short qual = 0;
-
- if( !PyArg_ParseTuple( args, "|h", &qual ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or an int (or'ed flags) as argument" );
-
- if( qual < 0 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "value must be a positive int, check Blender.Window.Qual" );
-
- G.qual = qual;
-
- return Py_BuildValue( "h", qual );
-}
-
-static PyObject *M_Window_GetAreaSize( PyObject * self )
-{
- ScrArea *sa = curarea;
-
- if( !sa )
- Py_RETURN_NONE;
-
- return Py_BuildValue( "hh", sa->winx, sa->winy );
-}
-
-static PyObject *M_Window_GetAreaID( PyObject * self )
-{
- ScrArea *sa = curarea;
-
- if( !sa )
- Py_RETURN_NONE;
-
- return Py_BuildValue( "h", sa->win );
-}
-
-static PyObject *M_Window_GetScreenSize( PyObject * self )
-{
- bScreen *scr = G.curscreen;
-
- if( !scr )
- Py_RETURN_NONE;
-
- return Py_BuildValue( "hh", scr->sizex, scr->sizey );
-}
-
-
-static PyObject *M_Window_SetScreen( PyObject * self, PyObject * value )
-{
- bScreen *scr = G.main->screen.first;
- char *name = PyString_AsString(value);
-
- if( !name )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string as argument" );
-
- while( scr ) {
- if( !strcmp( scr->id.name + 2, name ) ) {
- setscreen( scr );
- break;
- }
- scr = scr->id.next;
- }
-
- if( !scr )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no such screen, check Window.GetScreens() for valid names" );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_GetScreens( PyObject * self )
-{
- bScreen *scr = G.main->screen.first;
- PyObject *list = PyList_New( 0 );
- PyObject *str = NULL;
-
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create py list!" );
-
- while( scr ) {
- str = PyString_FromString( scr->id.name + 2 );
-
- if( !str ) {
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create py string!" );
- }
-
- PyList_Append( list, str ); /* incref's str */
- Py_DECREF( str );
-
- scr = scr->id.next;
- }
-
- return list;
-}
-
-static PyObject *M_Window_GetScreenInfo( PyObject * self, PyObject * args,
- PyObject * kwords )
-{
- ScrArea *sa = G.curscreen->areabase.first;
- bScreen *scr = G.main->screen.first;
- PyObject *item, *list;
- rcti *rct;
- int type = -1;
- char *rect = "win";
- char *screen = "";
- static char *kwlist[] = { "type", "rect", "screen", NULL };
- int rctype = 0;
-
- if( !PyArg_ParseTupleAndKeywords( args, kwords, "|iss", kwlist, &type,
- &rect, &screen ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected nothing or an int and two strings as arguments" );
-
- if( !strcmp( rect, "win" ) )
- rctype = 0;
- else if( !strcmp( rect, "total" ) )
- rctype = 1;
- else if( !strcmp( rect, "header" ) )
- rctype = 2;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "requested invalid type for area rectangle coordinates." );
-
- list = PyList_New( 0 );
-
- if( screen && screen[0] != '\0' ) {
- while( scr ) {
- if( !strcmp( scr->id.name + 2, screen ) ) {
- sa = scr->areabase.first;
- break;
- }
- scr = scr->id.next;
- }
- }
-
- if( !scr ) {
- Py_DECREF( list );
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no such screen, see existing ones with Window.GetScreens." );
- }
-
- while( sa ) {
- if( type != -1 && sa->spacetype != type ) {
- sa = sa->next;
- continue;
- }
-
- switch ( rctype ) {
- case 0:
- rct = &sa->winrct;
- break;
- case 1:
- rct = &sa->totrct;
- break;
- case 2:
- default:
- rct = &sa->headrct;
- }
-
- item = Py_BuildValue( "{s:[h,h,h,h],s:h,s:h}",
- "vertices", rct->xmin, rct->ymin,
- rct->xmax, rct->ymax, "type",
- ( short ) sa->spacetype, "id",
- ( short ) sa->win );
- PyList_Append( list, item );
- Py_DECREF( item );
-
- sa = sa->next;
- }
-
- return list;
-}
-
-static PyObject *M_Window_GetPivot( PyObject * self )
-{
- if (G.vd) {
- return PyInt_FromLong( G.vd->around );
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *M_Window_SetPivot( PyObject * self, PyObject * value)
-
-{
- short pivot;
- if (G.vd) {
- pivot = (short)PyInt_AsLong( value );
-
- if ( pivot > 4 || pivot < 0 )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Expected a constant from Window.PivotTypes" );
-
- G.vd->around = pivot;
- }
- Py_RETURN_NONE;
-}
-
-
-/*****************************************************************************/
-/* Function: Window_Init */
-/*****************************************************************************/
-PyObject *Window_Init( void )
-{
- PyObject *submodule, *Types, *Qual, *MButs, *PivotTypes, *dict;
-
- submodule =
- Py_InitModule3( "Blender.Window", M_Window_methods,
- M_Window_doc );
-
- dict = PyModule_GetDict( submodule );
- if( dict )
- PyDict_SetItemString( dict, "Theme", Theme_Init( ) );
-
- Types = PyConstant_New( );
- Qual = PyConstant_New( );
- MButs = PyConstant_New( );
- PivotTypes = PyConstant_New( );
-
- if( Types ) {
- BPy_constant *d = ( BPy_constant * ) Types;
-
- PyConstant_Insert( d, "VIEW3D", PyInt_FromLong( SPACE_VIEW3D ) );
- PyConstant_Insert( d, "IPO", PyInt_FromLong( SPACE_IPO ) );
- PyConstant_Insert( d, "OOPS", PyInt_FromLong( SPACE_OOPS ) );
- PyConstant_Insert( d, "BUTS", PyInt_FromLong( SPACE_BUTS ) );
- PyConstant_Insert( d, "FILE", PyInt_FromLong( SPACE_FILE ) );
- PyConstant_Insert( d, "IMAGE", PyInt_FromLong( SPACE_IMAGE ) );
- PyConstant_Insert( d, "INFO", PyInt_FromLong( SPACE_INFO ) );
- PyConstant_Insert( d, "SEQ", PyInt_FromLong( SPACE_SEQ ) );
- PyConstant_Insert( d, "IMASEL", PyInt_FromLong( SPACE_IMASEL ) );
- PyConstant_Insert( d, "SOUND", PyInt_FromLong( SPACE_SOUND ) );
- PyConstant_Insert( d, "ACTION", PyInt_FromLong( SPACE_ACTION ) );
- PyConstant_Insert( d, "TEXT", PyInt_FromLong( SPACE_TEXT ) );
- PyConstant_Insert( d, "NLA", PyInt_FromLong( SPACE_NLA ) );
- PyConstant_Insert( d, "SCRIPT", PyInt_FromLong( SPACE_SCRIPT ) );
- PyConstant_Insert( d, "TIME", PyInt_FromLong( SPACE_TIME ) );
- PyConstant_Insert( d, "NODE", PyInt_FromLong( SPACE_NODE ) );
-
- PyModule_AddObject( submodule, "Types", Types );
- }
-
- if( Qual ) {
- BPy_constant *d = ( BPy_constant * ) Qual;
-
- PyConstant_Insert( d, "LALT", PyInt_FromLong( L_ALTKEY ) );
- PyConstant_Insert( d, "RALT", PyInt_FromLong( R_ALTKEY ) );
- PyConstant_Insert( d, "ALT", PyInt_FromLong( LR_ALTKEY ) );
- PyConstant_Insert( d, "LCTRL", PyInt_FromLong( L_CTRLKEY ) );
- PyConstant_Insert( d, "RCTRL", PyInt_FromLong( R_CTRLKEY ) );
- PyConstant_Insert( d, "CTRL", PyInt_FromLong( LR_CTRLKEY ) );
- PyConstant_Insert( d, "LSHIFT", PyInt_FromLong( L_SHIFTKEY ) );
- PyConstant_Insert( d, "RSHIFT", PyInt_FromLong( R_SHIFTKEY ) );
- PyConstant_Insert( d, "SHIFT", PyInt_FromLong( LR_SHIFTKEY ) );
-
- PyModule_AddObject( submodule, "Qual", Qual );
- }
-
- if( MButs ) {
- BPy_constant *d = ( BPy_constant * ) MButs;
-
- PyConstant_Insert( d, "L", PyInt_FromLong( L_MOUSE ) );
- PyConstant_Insert( d, "M", PyInt_FromLong( M_MOUSE ) );
- PyConstant_Insert( d, "R", PyInt_FromLong( R_MOUSE ) );
-
- PyModule_AddObject( submodule, "MButs", MButs );
- }
-
- if( PivotTypes ) {
- BPy_constant *d = ( BPy_constant * ) PivotTypes;
-
- PyConstant_Insert(d, "BOUNDBOX", PyInt_FromLong( PIVOT_BOUNDBOX ) );
- PyConstant_Insert(d, "CURSOR", PyInt_FromLong( PIVOT_CURSOR ) );
- PyConstant_Insert(d, "MEDIAN", PyInt_FromLong( PIVOT_MEDIAN ) );
- PyConstant_Insert(d, "ACTIVE", PyInt_FromLong( PIVOT_ACTIVE ) );
- PyConstant_Insert(d, "INDIVIDUAL", PyInt_FromLong( PIVOT_INDIVIDUAL ) );
-
- PyModule_AddObject( submodule, "PivotTypes", PivotTypes );
- }
- return submodule;
-}
diff --git a/source/blender/python/api2_2x/Window.h b/source/blender/python/api2_2x/Window.h
deleted file mode 100644
index a39856ecd58..00000000000
--- a/source/blender/python/api2_2x/Window.h
+++ /dev/null
@@ -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 */
diff --git a/source/blender/python/api2_2x/World.c b/source/blender/python/api2_2x/World.c
deleted file mode 100644
index a6fac327360..00000000000
--- a/source/blender/python/api2_2x/World.c
+++ /dev/null
@@ -1,1034 +0,0 @@
-/*
- * $Id: World.c 12078 2007-09-18 06:41:29Z 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, Johnny Matthews
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-/**
- * \file World.c
- * \ingroup scripts
- * \brief Blender.World Module and World Data PyObject implementation.
- *
- * Note: Parameters between "<" and ">" are optional. But if one of them is
- * given, all preceding ones must be given, too. Of course, this only relates
- * to the Python functions and methods described here and only inside Python
- * code. [ This will go to another file later, probably the main exppython
- * doc file]. XXX Better: put optional args with their default value:
- * (self, name = "MyName")
- */
-
-#include "World.h" /*This must come first*/
-
-#include "DNA_scene_types.h" /* for G.scene */
-#include "BKE_global.h"
-#include "BKE_world.h"
-#include "BKE_main.h"
-#include "BKE_library.h"
-#include "BLI_blenlib.h"
-#include "BSE_editipo.h"
-#include "BIF_space.h"
-#include "mydevice.h"
-#include "Ipo.h"
-#include "gen_utils.h"
-#include "gen_library.h"
-
-#define IPOKEY_ZENITH 0
-#define IPOKEY_HORIZON 1
-#define IPOKEY_MIST 2
-#define IPOKEY_STARS 3
-#define IPOKEY_OFFSET 4
-#define IPOKEY_SIZE 5
-/*****************************************************************************/
-/* Python BPy_World methods declarations: */
-/*****************************************************************************/
-static PyObject *World_getRange( BPy_World * self );
-static PyObject *World_setRange( BPy_World * self, PyObject * args );
-static PyObject *World_getIpo( BPy_World * self );
-static PyObject *World_oldsetIpo( BPy_World * self, PyObject * args );
-static int World_setIpo( BPy_World * self, PyObject * args );
-static PyObject *World_clearIpo( BPy_World * self );
-static PyObject *World_insertIpoKey( BPy_World * self, PyObject * args );
-static PyObject *World_getMode( BPy_World * self );
-static PyObject *World_oldsetMode( BPy_World * self, PyObject * args );
-static int World_setMode( BPy_World * self, PyObject * args );
-static PyObject *World_getSkytype( BPy_World * self );
-static PyObject *World_oldsetSkytype( BPy_World * self, PyObject * args );
-static int World_setSkytype( BPy_World * self, PyObject * args );
-static PyObject *World_getMistype( BPy_World * self );
-static PyObject *World_oldsetMistype( BPy_World * self, PyObject * args );
-static int World_setMistype( BPy_World * self, PyObject * args );
-static PyObject *World_getHor( BPy_World * self );
-static PyObject *World_oldsetHor( BPy_World * self, PyObject * args );
-static int World_setHor( BPy_World * self, PyObject * args );
-static PyObject *World_getZen( BPy_World * self );
-static PyObject *World_oldsetZen( BPy_World * self, PyObject * args );
-static int World_setZen( BPy_World * self, PyObject * args );
-static PyObject *World_getAmb( BPy_World * self );
-static PyObject *World_oldsetAmb( BPy_World * self, PyObject * args );
-static int World_setAmb( BPy_World * self, PyObject * args );
-static PyObject *World_getStar( BPy_World * self );
-static PyObject *World_oldsetStar( BPy_World * self, PyObject * args );
-static int World_setStar( BPy_World * self, PyObject * args );
-static PyObject *World_getMist( BPy_World * self );
-static PyObject *World_oldsetMist( BPy_World * self, PyObject * args );
-static int World_setMist( BPy_World * self, PyObject * args );
-static PyObject *World_getScriptLinks( BPy_World * self, PyObject * value );
-static PyObject *World_addScriptLink( BPy_World * self, PyObject * args );
-static PyObject *World_clearScriptLinks( BPy_World * self, PyObject * args );
-static PyObject *World_setCurrent( BPy_World * self );
-static PyObject *World_copy( BPy_World * self );
-
-
-/*****************************************************************************/
-/* Python API function prototypes for the World module. */
-/*****************************************************************************/
-static PyObject *M_World_New( PyObject * self, PyObject * args,
- PyObject * keywords );
-static PyObject *M_World_Get( PyObject * self, PyObject * args );
-static PyObject *M_World_GetCurrent( PyObject * self );
-
-
-/*****************************************************************************/
-/* Python World_Type callback function prototypes: */
-/*****************************************************************************/
-//static int World_Print (BPy_World *self, FILE *fp, int flags);
-static int World_Compare( BPy_World * a, BPy_World * b );
-static PyObject *World_Repr( BPy_World * self );
-
-
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.World.__doc__ */
-/*****************************************************************************/
-static char M_World_doc[] = "The Blender World module\n\n\
-This module provides access to **World Data** objects in Blender\n\n";
-
-static char M_World_New_doc[] = "() - return a new World object";
-
-static char M_World_Get_doc[] =
- "(name) - return the world with the name 'name', \
-returns None if not found.\n If 'name' is not specified, \
-it returns a list of all worlds in the\ncurrent scene.";
-static char M_World_GetCurrent_doc[] = "() - returns the current world, or \
-None if the Scene has no world";
-
-
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.World module: */
-/*****************************************************************************/
-struct PyMethodDef M_World_methods[] = {
- {"New", ( PyCFunction ) M_World_New, METH_VARARGS | METH_KEYWORDS,
- M_World_New_doc},
- {"Get", M_World_Get, METH_VARARGS, M_World_Get_doc},
- {"GetActive", ( PyCFunction ) M_World_GetCurrent, METH_NOARGS,
- M_World_GetCurrent_doc},
- {"GetCurrent", ( PyCFunction ) M_World_GetCurrent, METH_NOARGS,
- M_World_GetCurrent_doc},
- {"get", M_World_Get, METH_VARARGS, M_World_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-
-
-/*****************************************************************************/
-/* Python BPy_World methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_World_methods[] = {
- {"getRange", ( PyCFunction ) World_getRange, METH_NOARGS,
- "() - Return World Range"},
- {"setRange", ( PyCFunction ) World_setRange, METH_VARARGS,
- "() - Change this World's range"},
- {"getIpo", ( PyCFunction ) World_getIpo, METH_NOARGS,
- "() - Return World Ipo"},
- {"setIpo", ( PyCFunction ) World_oldsetIpo, METH_VARARGS,
- "() - Change this World's ipo"},
- {"clearIpo", ( PyCFunction ) World_clearIpo, METH_VARARGS,
- "() - Unlink Ipo from this World"},
- {"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
- "() - Return World Data name"},
- {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
- "() - Set World Data name"},
- {"getMode", ( PyCFunction ) World_getMode, METH_NOARGS,
- "() - Return World Data mode"},
- {"setMode", ( PyCFunction ) World_oldsetMode, METH_VARARGS,
- "(i) - Set World Data mode"},
- {"getSkytype", ( PyCFunction ) World_getSkytype, METH_NOARGS,
- "() - Return World Data skytype"},
- {"setSkytype", ( PyCFunction ) World_oldsetSkytype, METH_VARARGS,
- "() - Return World Data skytype"},
- {"getMistype", ( PyCFunction ) World_getMistype, METH_NOARGS,
- "() - Return World Data mistype"},
- {"setMistype", ( PyCFunction ) World_oldsetMistype, METH_VARARGS,
- "() - Return World Data mistype"},
- {"getHor", ( PyCFunction ) World_getHor, METH_NOARGS,
- "() - Return World Data hor"},
- {"setHor", ( PyCFunction ) World_oldsetHor, METH_VARARGS,
- "() - Return World Data hor"},
- {"getZen", ( PyCFunction ) World_getZen, METH_NOARGS,
- "() - Return World Data zen"},
- {"setZen", ( PyCFunction ) World_oldsetZen, METH_VARARGS,
- "() - Return World Data zen"},
- {"getAmb", ( PyCFunction ) World_getAmb, METH_NOARGS,
- "() - Return World Data amb"},
- {"setAmb", ( PyCFunction ) World_oldsetAmb, METH_VARARGS,
- "() - Return World Data amb"},
- {"getStar", ( PyCFunction ) World_getStar, METH_NOARGS,
- "() - Return World Data star"},
- {"setStar", ( PyCFunction ) World_oldsetStar, METH_VARARGS,
- "() - Return World Data star"},
- {"getMist", ( PyCFunction ) World_getMist, METH_NOARGS,
- "() - Return World Data mist"},
- {"setMist", ( PyCFunction ) World_oldsetMist, METH_VARARGS,
- "() - Return World Data mist"},
- {"getScriptLinks", ( PyCFunction ) World_getScriptLinks, METH_O,
- "(eventname) - Get a list of this world's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged, Redraw or Render."},
- {"addScriptLink", ( PyCFunction ) World_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new world scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged, Redraw or Render."},
- {"clearScriptLinks", ( PyCFunction ) World_clearScriptLinks,
- METH_VARARGS,
- "() - Delete all scriptlinks from this world.\n"
- "([s1<,s2,s3...>]) - Delete specified scriptlinks from this world."},
- {"setCurrent", ( PyCFunction ) World_setCurrent, METH_NOARGS,
- "() - Makes this world the active world for the current scene."},
- {"makeActive", ( PyCFunction ) World_setCurrent, METH_NOARGS,
- "please use setCurrent instead, this alias will be removed."},
- {"insertIpoKey", ( PyCFunction ) World_insertIpoKey, METH_VARARGS,
- "( World IPO type ) - Inserts a key into the IPO"},
- {"__copy__", ( PyCFunction ) World_copy, METH_NOARGS,
- "() - Makes a copy of this world."},
- {"copy", ( PyCFunction ) World_copy, METH_NOARGS,
- "() - Makes a copy of this world."},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_World_getseters[] = {
- GENERIC_LIB_GETSETATTR,
- {"skytype", (getter)World_getSkytype, (setter)World_setSkytype,
- "sky settings as a list", NULL},
- {"mode", (getter)World_getMode, (setter)World_setMode,
- "world mode", NULL},
- {"mistype", (getter)World_getMistype, (setter)World_setMistype,
- "world mist type", NULL},
- {"hor", (getter)World_getHor, (setter)World_setHor,
- "world horizon color", NULL},
- {"amb", (getter)World_getAmb, (setter)World_setAmb,
- "world ambient color", NULL},
- {"mist", (getter)World_getMist, (setter)World_setMist,
- "world mist settings", NULL},
- {"ipo", (getter)World_getIpo, (setter)World_setIpo,
- "world ipo", NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python World_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject World_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
- "World", /* tp_name */
- sizeof( BPy_World ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- NULL, /* tp_dealloc */
- 0, /* tp_print */
- NULL, /* tp_getattr */
- NULL, /* tp_setattr */
- ( cmpfunc ) World_Compare, /* tp_compare */
- ( reprfunc ) World_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_World_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_World_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
-};
-
-/**
- * \defgroup World_Module Blender.World module functions
- *
- */
-
-/*@{*/
-
-/**
- * \brief Python module function: Blender.World.New()
- *
- * This is the .New() function of the Blender.World submodule. It creates
- * new World Data in Blender and returns its Python wrapper object. The
- * name parameter is mandatory.
- * \param <name> - string: The World Data name.
- * \return A new World PyObject.
- */
-
-static PyObject *M_World_New( PyObject * self, PyObject * args,
- PyObject * kwords )
-{
- char *name = NULL;
- BPy_World *pyworld;
- World *blworld;
-
- if( !PyArg_ParseTuple( args, "s", &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" ) );
-
-
- blworld = add_world( name );
-
- if( blworld ) {
- /* return user count to zero because add_world() inc'd it */
- blworld->id.us = 0;
- /* create python wrapper obj */
- pyworld =
- ( BPy_World * ) PyObject_NEW( BPy_World, &World_Type );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create World Data in Blender" ) );
-
- if( pyworld == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create World Data object" ) );
-
- pyworld->world = blworld;
-
- return ( PyObject * ) pyworld;
-}
-
-/**
- * \brief Python module function: Blender.World.Get()
- *
- * This is the .Get() function of the Blender.World submodule. It searches
- * the list of current World Data objects and returns a Python wrapper for
- * the one with the name provided by the user. If called with no arguments,
- * it returns a list of all current World Data object names in Blender.
- * \param <name> - string: The name of an existing Blender World Data object.
- * \return () - A list with the names of all current World Data objects;\n
- * \return (name) - A Python wrapper for the World Data called 'name'
- * in Blender.
- */
-
-static PyObject *M_World_Get( PyObject * self, PyObject * args )
-{
-
- char *name = NULL;
- World *world_iter;
- PyObject *worldlist;
- char error_msg[64];
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" ) );
-
- if( name ) { /* (name) - Search world by name */
- world_iter = ( World * ) GetIdFromList( &( G.main->world ), name );
-
- if( world_iter == NULL ) { /* Requested world doesn't exist */
- PyOS_snprintf( error_msg, sizeof( error_msg ),
- "World \"%s\" not found", name );
- return ( EXPP_ReturnPyObjError
- ( PyExc_NameError, error_msg ) );
- }
-
- return ( PyObject * ) World_CreatePyObject(world_iter);
- }
-
- else { /* return a list of all worlds in the scene */
- world_iter = G.main->world.first;
- worldlist = PyList_New( 0 );
- if( worldlist == NULL )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" ) );
-
- while( world_iter ) {
- BPy_World *found_world =
- ( BPy_World * ) PyObject_NEW( BPy_World,
- &World_Type );
- found_world->world = world_iter;
- PyList_Append( worldlist, ( PyObject * ) found_world );
- Py_DECREF(found_world);
-
- world_iter = world_iter->id.next;
- }
- return ( worldlist );
- }
-
-}
-
-static PyObject *M_World_GetCurrent( PyObject * self )
-{
- BPy_World *w = NULL;
-#if 0 /* add back in when bpy becomes "official" */
- static char warning = 1;
- if( warning ) {
- printf("Blender.World.GetCurrent() deprecated!\n\tuse bpy.scenes.world instead\n");
- --warning;
- }
-#endif
-
- if( !G.scene->world )
- Py_RETURN_NONE;
-
- w = ( BPy_World * ) PyObject_NEW( BPy_World, &World_Type );
- w->world = G.scene->world;
- return ( PyObject * ) w;
-}
-
-/*@}*/
-
-/**
- * \brief Initializes the Blender.World submodule
- *
- * This function is used by Blender_Init() in Blender.c to register the
- * Blender.World submodule in the main Blender module.
- * \return PyObject*: The initialized submodule.
- */
-
-PyObject *World_Init( void )
-{
- PyObject *submodule;
-
- if( PyType_Ready( &World_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.World",
- M_World_methods, M_World_doc );
-
- PyModule_AddIntConstant( submodule, "ZENITH", IPOKEY_ZENITH );
- PyModule_AddIntConstant( submodule, "HORIZON", IPOKEY_HORIZON );
- PyModule_AddIntConstant( submodule, "MIST", IPOKEY_MIST );
- PyModule_AddIntConstant( submodule, "STARS", IPOKEY_STARS );
- PyModule_AddIntConstant( submodule, "OFFSET", IPOKEY_OFFSET );
- PyModule_AddIntConstant( submodule, "SIZE", IPOKEY_SIZE );
-
- return ( submodule );
-}
-
-/*****************************************************************************/
-/* Python BPy_World methods: */
-/*****************************************************************************/
-static PyObject *World_getRange( BPy_World * self )
-{
- return PyFloat_FromDouble( self->world->range );
-}
-
-static PyObject *World_setRange( BPy_World * self, PyObject * args )
-{
- float range = 0.f;
- if( !PyArg_ParseTuple( args, "f", &range ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected a float argument" ) );
- self->world->range = range;
- Py_RETURN_NONE;
-}
-
-
-static PyObject *World_getIpo( BPy_World * self )
-{
- struct Ipo *ipo = self->world->ipo;
-
- if( !ipo )
- Py_RETURN_NONE;
-
- return Ipo_CreatePyObject( ipo );
-}
-
-static int World_setIpo( BPy_World * self, PyObject * value )
-{
- return GenericLib_assignData(value, (void **) &self->world->ipo, 0, 1, ID_IP, ID_WO);
-}
-
-static PyObject *World_oldsetIpo( BPy_World * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)World_setIpo );
-}
-
-static PyObject *World_clearIpo( BPy_World * self )
-{
- World *world = self->world;
- Ipo *ipo = ( Ipo * ) world->ipo;
-
- if( ipo ) {
- ID *id = &ipo->id;
- if( id->us > 0 )
- id->us--;
- world->ipo = NULL;
-
- return EXPP_incr_ret_True();
- }
-
- return EXPP_incr_ret_False(); /* no ipo found */
-}
-
-/**
- * \brief World PyMethod getSkytype
- *
- * \return int : The World Data skytype.
- */
-
-static PyObject *World_getSkytype( BPy_World * self )
-{
- return PyInt_FromLong( ( long ) self->world->skytype );
-}
-
-
-/**
- * \brief World PyMethod setSkytype
- *
- * \return int : The World Data skytype.
- */
-
-static int World_setSkytype( BPy_World * self, PyObject * value )
-{
- if( !PyInt_Check(value) )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" ) );
- self->world->skytype = (short)PyInt_AsLong(value);
- return 0;
-}
-
-static PyObject *World_oldsetSkytype( BPy_World * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)World_setSkytype );
-}
-
-
-/**
- * \brief World PyMethod getMode
- *
- * \return int : The World Data mode.
- */
-
-static PyObject *World_getMode( BPy_World * self )
-{
- return PyInt_FromLong( ( long ) self->world->mode );
-}
-
-
-/**
- * \brief World PyMethod setMode
- *
- * \return int : The World Data mode.
- */
-
-static int World_setMode( BPy_World * self, PyObject * value )
-{
- if( !PyInt_Check(value) )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" ) );
- self->world->mode = (short)PyInt_AsLong(value);
- return 0;
-}
-
-static PyObject *World_oldsetMode( BPy_World * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)World_setMode );
-}
-
-
-
-/**
- * \brief World PyMethod getMistype
- *
- * \return int : The World Data mistype.
- */
-
-static PyObject *World_getMistype( BPy_World * self )
-{
- return PyInt_FromLong( ( long ) self->world->mistype );
-}
-
-
-/**
- * \brief World PyMethod setMistype
- *
- * \return int : The World Data mistype.
- */
-
-static int World_setMistype( BPy_World * self, PyObject * value )
-{
- if( !PyInt_Check(value) )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" ) );
- self->world->mistype = (short)PyInt_AsLong(value);
- return 0;
-}
-
-static PyObject *World_oldsetMistype( BPy_World * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)World_setMistype );
-}
-
-
-
-static PyObject *World_getHor( BPy_World * self )
-{
- PyObject *attr = PyList_New( 3 );
- if( !attr )
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create list" ) );
- PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->horr ) );
- PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->horg ) );
- PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->horb ) );
- return attr;
-}
-
-
-static int World_setHor( BPy_World * self, PyObject * value )
-{
- if( !PyList_Check( value ) )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "expected list argument" ) );
- if( PyList_Size( value ) != 3 )
- return ( EXPP_ReturnIntError
- ( PyExc_TypeError, "list size must be 3" ) );
- self->world->horr = (float)PyFloat_AsDouble( PyList_GetItem( value, 0 ) );
- self->world->horg = (float)PyFloat_AsDouble( PyList_GetItem( value, 1 ) );
- self->world->horb = (float)PyFloat_AsDouble( PyList_GetItem( value, 2 ) );
- return 0;
-}
-
-static PyObject *World_oldsetHor( BPy_World * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)World_setHor );
-}
-
-static PyObject *World_getZen( BPy_World * self )
-{
- PyObject *attr = PyList_New( 3 );
- if( !attr )
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create list" ) );
- PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->zenr ) );
- PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->zeng ) );
- PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->zenb ) );
- return attr;
-}
-
-
-static int World_setZen( BPy_World * self, PyObject * value )
-{
- if( !PyList_Check( value ) )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "expected list argument" ) );
- if( PyList_Size( value ) != 3 )
- return ( EXPP_ReturnIntError
- ( PyExc_TypeError, "list size must be 3" ) );
- self->world->zenr = (float)PyFloat_AsDouble( PyList_GetItem( value, 0 ) );
- self->world->zeng = (float)PyFloat_AsDouble( PyList_GetItem( value, 1 ) );
- self->world->zenb = (float)PyFloat_AsDouble( PyList_GetItem( value, 2 ) );
- return 0;
-}
-
-static PyObject *World_oldsetZen( BPy_World * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)World_setZen );
-}
-
-
-static PyObject *World_getAmb( BPy_World * self )
-{
- PyObject *attr = PyList_New( 3 );
- if( !attr )
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create list" ) );
- PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->ambr ) );
- PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->ambg ) );
- PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->ambb ) );
- return attr;
-}
-
-
-static int World_setAmb( BPy_World * self, PyObject * value )
-{
- if( !PyList_Check( value ) )
- return ( EXPP_ReturnIntError( PyExc_TypeError,
- "expected list argument" ) );
- if( PyList_Size( value ) != 3 )
- return ( EXPP_ReturnIntError
- ( PyExc_TypeError, "wrong list size" ) );
- self->world->ambr = (float)PyFloat_AsDouble( PyList_GetItem( value, 0 ) );
- self->world->ambg = (float)PyFloat_AsDouble( PyList_GetItem( value, 1 ) );
- self->world->ambb = (float)PyFloat_AsDouble( PyList_GetItem( value, 2 ) );
- return 0;
-}
-
-static PyObject *World_oldsetAmb( BPy_World * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)World_setAmb );
-}
-
-static PyObject *World_getStar( BPy_World * self )
-{
- PyObject *attr = PyList_New( 7 );
- if( !attr )
- return ( EXPP_ReturnPyObjError
- ( PyExc_RuntimeError, "couldn't create list" ) );
- PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->starr ) );
- PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->starg ) );
- PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->starb ) );
- PyList_SET_ITEM( attr, 3, PyFloat_FromDouble( self->world->starsize ) );
- PyList_SET_ITEM( attr, 4, PyFloat_FromDouble( self->world->starmindist ) );
- PyList_SET_ITEM( attr, 5, PyFloat_FromDouble( self->world->stardist ) );
- PyList_SET_ITEM( attr, 6, PyFloat_FromDouble( self->world->starcolnoise ) );
- return attr;
-}
-
-
-static int World_setStar( BPy_World * self, PyObject * value )
-{
- if( !PyList_Check( value ) )
- return ( EXPP_ReturnIntError
- ( PyExc_TypeError, "expected list argument" ) );
- if( PyList_Size( value ) != 7 )
- return ( EXPP_ReturnIntError
- ( PyExc_TypeError, "wrong list size" ) );
- self->world->starr = (float)PyFloat_AsDouble( PyList_GetItem( value, 0 ) );
- self->world->starg = (float)PyFloat_AsDouble( PyList_GetItem( value, 1 ) );
- self->world->starb = (float)PyFloat_AsDouble( PyList_GetItem( value, 2 ) );
- self->world->starsize =
- (float)PyFloat_AsDouble( PyList_GetItem( value, 3 ) );
- self->world->starmindist =
- (float)PyFloat_AsDouble( PyList_GetItem( value, 4 ) );
- self->world->stardist =
- (float)PyFloat_AsDouble( PyList_GetItem( value, 5 ) );
- self->world->starcolnoise =
- (float)PyFloat_AsDouble( PyList_GetItem( value, 6 ) );
- return 0;
-}
-
-static PyObject *World_oldsetStar( BPy_World * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)World_setStar );
-}
-
-
-static PyObject *World_getMist( BPy_World * self )
-{
- PyObject *attr = PyList_New( 4 );
- if( !attr )
- return ( EXPP_ReturnPyObjError
- ( PyExc_RuntimeError, "couldn't create list" ) );
- PyList_SET_ITEM( attr, 0, PyFloat_FromDouble( self->world->misi ) );
- PyList_SET_ITEM( attr, 1, PyFloat_FromDouble( self->world->miststa ) );
- PyList_SET_ITEM( attr, 2, PyFloat_FromDouble( self->world->mistdist ) );
- PyList_SET_ITEM( attr, 3, PyFloat_FromDouble( self->world->misthi ) );
- return attr;
-}
-
-static int World_setMist( BPy_World * self, PyObject * value )
-{
- if( !PyList_Check( value ) )
- return ( EXPP_ReturnIntError
- ( PyExc_TypeError, "expected list argument" ) );
- if( PyList_Size( value ) != 4 )
- return ( EXPP_ReturnIntError
- ( PyExc_TypeError, "wrong list size" ) );
- self->world->misi = (float)PyFloat_AsDouble( PyList_GetItem( value, 0 ) );
- self->world->miststa =
- (float)PyFloat_AsDouble( PyList_GetItem( value, 1 ) );
- self->world->mistdist =
- (float)PyFloat_AsDouble( PyList_GetItem( value, 2 ) );
- self->world->misthi =
- (float)PyFloat_AsDouble( PyList_GetItem( value, 3 ) );
- return 0;
-}
-
-static PyObject *World_oldsetMist( BPy_World * self, PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)World_setMist );
-}
-
-
-/* world.addScriptLink */
-static PyObject *World_addScriptLink( BPy_World * self, PyObject * args )
-{
- World *world = self->world;
- ScriptLink *slink = NULL;
-
- slink = &( world )->scriptlink;
-
- return EXPP_addScriptLink( slink, args, 0 );
-}
-
-/* world.clearScriptLinks */
-static PyObject *World_clearScriptLinks( BPy_World * self, PyObject * args )
-{
- World *world = self->world;
- ScriptLink *slink = NULL;
-
- slink = &( world )->scriptlink;
-
- return EXPP_clearScriptLinks( slink, args );
-}
-
-/* world.getScriptLinks */
-static PyObject *World_getScriptLinks( BPy_World * self, PyObject * value )
-{
- World *world = self->world;
- ScriptLink *slink = NULL;
- PyObject *ret = NULL;
-
- slink = &( world )->scriptlink;
-
- ret = EXPP_getScriptLinks( slink, value, 0 );
-
- if( ret )
- return ret;
- else
- return NULL;
-}
-
-
-/* world.setCurrent */
-static PyObject *World_setCurrent( BPy_World * self )
-{
- World *world = self->world;
-#if 0 /* add back in when bpy becomes "official" */
- static char warning = 1;
- if( warning ) {
- printf("world.setCurrent() deprecated!\n\tuse bpy.scenes.world=world instead\n");
- --warning;
- }
-#endif
-
- /* If there is a world then it now has one less user */
- if( G.scene->world )
- G.scene->world->id.us--;
- world->id.us++;
- G.scene->world = world;
- Py_RETURN_NONE;
-}
-
-/* world.__copy__ */
-static PyObject *World_copy( BPy_World * self )
-{
- World *world = copy_world(self->world );
- world->id.us = 0;
- return World_CreatePyObject(world);
-}
-
-/**
- * \brief The World PyType compare function
- *
- * This function compares two given World PyObjects, returning 0 for equality
- * and -1 otherwise. In Python it becomes 1 if they are equal and 0 case not.
- * The comparison is done with their pointers to Blender World Data objects,
- * so any two wrappers pointing to the same Blender World Data will be
- * considered the same World PyObject. Currently, only the "==" and "!="
- * comparisons are meaninful -- the "<", "<=", ">" or ">=" are not.
- */
-
-static int World_Compare( BPy_World * a, BPy_World * b )
-{
- return ( a->world == b->world ) ? 0 : -1;
-}
-
-/**
- * \brief The World PyType print callback
- *
- * This function is called when the user tries to print a PyObject of type
- * World. It builds a string with the name of the wrapped Blender World.
- */
-
-/*
-static int World_Print(BPy_World *self, FILE *fp, int flags)
-{
- fprintf(fp, "[World \"%s\"]", self->world->id.name+2);
- return 0;
-}
-*/
-
-/**
- * \brief The World PyType repr callback
- *
- * This function is called when the statement "repr(myworld)" is executed in
- * Python. Repr gives a string representation of a PyObject.
- */
-
-static PyObject *World_Repr( BPy_World * self )
-{
- return PyString_FromFormat( "[World \"%s\"]",
- self->world->id.name + 2 );
-}
-
-/*@}*/
-/*
-static int World_compare (BPy_World *a, BPy_World *b)
-{
- World *pa = a->world, *pb = b->world;
- return (pa == pb) ? 0:-1;
-}
-*/
-PyObject *World_CreatePyObject( struct World * world )
-{
- BPy_World *blen_object;
-
- blen_object = ( BPy_World * ) PyObject_NEW( BPy_World, &World_Type );
-
- if( blen_object == NULL ) {
- return ( NULL );
- }
- blen_object->world = world;
- return ( ( PyObject * ) blen_object );
-}
-
-World *World_FromPyObject( PyObject * py_obj )
-{
- BPy_World *blen_obj;
-
- blen_obj = ( BPy_World * ) py_obj;
- return ( blen_obj->world );
-
-}
-
-/*
- * World_insertIpoKey()
- * inserts World IPO key for ZENITH,HORIZON,MIST,STARS,OFFSET,SIZE
- */
-
-static PyObject *World_insertIpoKey( BPy_World * self, PyObject * args )
-{
- int key = 0, map;
-
- if( !PyArg_ParseTuple( args, "i", &( key ) ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
-
- map = texchannel_to_adrcode(self->world->texact);
-
- if(key == IPOKEY_ZENITH) {
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_R, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_G, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_B, 0);
- }
- if(key == IPOKEY_HORIZON) {
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_R, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_G, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_B, 0);
- }
- if(key == IPOKEY_MIST) {
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISI, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTDI, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTSTA, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTHI, 0);
- }
- if(key == IPOKEY_STARS) {
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_R, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_G, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_B, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARDIST, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARSIZE, 0);
- }
- if(key == IPOKEY_OFFSET) {
- insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_X, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Y, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Z, 0);
- }
- if(key == IPOKEY_SIZE) {
- insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_X, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Y, 0);
- insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Z, 0);
- }
-
- allspace(REMAKEIPO, 0);
- EXPP_allqueue(REDRAWIPO, 0);
- EXPP_allqueue(REDRAWVIEW3D, 0);
- EXPP_allqueue(REDRAWACTION, 0);
- EXPP_allqueue(REDRAWNLA, 0);
-
- Py_RETURN_NONE;
-}
diff --git a/source/blender/python/api2_2x/World.h b/source/blender/python/api2_2x/World.h
deleted file mode 100644
index 71c407bff19..00000000000
--- a/source/blender/python/api2_2x/World.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * $Id: World.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_WORLD_H
-#define EXPP_WORLD_H
-
-#include <Python.h>
-#include "DNA_world_types.h"
-
-#define BPy_World_Check(v) ((v)->ob_type==&World_Type)
-
-/* Python BPy_World structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- World * world; /* Libdata must be second */
-} BPy_World;
-
-extern PyTypeObject World_Type;
-
-/*****************************************************************************/
-/* Python World_Type helper functions needed by Blender (the Init function) */
-/* and Object modules. */
-/*****************************************************************************/
-
-PyObject *World_Init( void );
-PyObject *World_CreatePyObject( World * world );
-World *World_FromPyObject( PyObject * pyobj );
-
-#endif /* EXPP_WORLD_H */
diff --git a/source/blender/python/api2_2x/bpy.c b/source/blender/python/api2_2x/bpy.c
deleted file mode 100644
index 6ddbcfe4096..00000000000
--- a/source/blender/python/api2_2x/bpy.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * $Id: bpy.c 10550 2007-04-18 22:53:20Z 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, Willian P. Germano, Joseph Gilbert,
- * Campbell Barton
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-/* for open, close in Blender_Load */
-
-#include "BLI_blenlib.h"
-#include "BKE_global.h"
-#include "BKE_utildefines.h"
-#include "BKE_scene.h"
-#include "BKE_main.h"
-
-#include "DNA_scene_types.h"
-
-#include "Types.h"
-#include "Library.h"
-
-#include "bpy.h"
-#include "bpy_data.h"
-#include "bpy_config.h"
-
-/*****************************************************************************/
-/* Global variables */
-/*****************************************************************************/
-PyObject *g_bpydict;
-
-/*****************************************************************************/
-/* Function: initBlender */
-/*****************************************************************************/
-
-void m_bpy_init(void)
-{
- PyObject *module;
- PyObject *dict;
-
- /* G.scene should only aver be NULL if blender is executed in
- background mode, not loading a blend file and executing a python script eg.
- blender -P somescript.py -b
- The if below solves the segfaults that happen when python runs and
- G.scene is NULL */
- if(G.background && G.main->scene.first==NULL) {
- Scene *sce= add_scene("1");
- /*set_scene(sce);*/ /* causes a crash */
- G.scene= sce;
- }
-
- module = Py_InitModule3("bpy", NULL, "The main bpy module");
-
- types_InitAll(); /* set all our pytypes to &PyType_Type */
-
- dict = PyModule_GetDict(module);
- g_bpydict = dict;
-
- PyModule_AddObject( module, "config", Config_CreatePyObject() );
- PyDict_SetItemString( dict, "data", Data_Init());
- PyDict_SetItemString( dict, "libraries", Library_Init( ) );
-
-}
diff --git a/source/blender/python/api2_2x/bpy.h b/source/blender/python/api2_2x/bpy.h
deleted file mode 100644
index 855da49bd2b..00000000000
--- a/source/blender/python/api2_2x/bpy.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * $Id: bpy.h 10546 2007-04-18 14:40:01Z 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, Willian P. Germano
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#ifndef EXPP_BPYMOD_H
-#define EXPP_BPYMOD_H
-
-#include <Python.h>
-
-extern PyObject *g_bpydict;
-void m_bpy_init( void );
-
-#endif /* EXPP_BPYMOD_H */
diff --git a/source/blender/python/api2_2x/bpy_config.c b/source/blender/python/api2_2x/bpy_config.c
deleted file mode 100644
index ce8ce0bc39c..00000000000
--- a/source/blender/python/api2_2x/bpy_config.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * $Id: bpy_config.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): Campbell Barton
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-/* python types */
-#include "DNA_userdef_types.h"
-#include "../api2_2x/gen_utils.h"
-#include "bpy_config.h"
-
-enum conf_consts {
- /*string*/
- EXPP_CONF_ATTR_PATH_YF_EXPORT = 0,
- EXPP_CONF_ATTR_PATH_FONT,
- EXPP_CONF_ATTR_PATH_RENDER,
- EXPP_CONF_ATTR_PATH_TEXTURE,
- EXPP_CONF_ATTR_PATH_PYTHON,
- EXPP_CONF_ATTR_PATH_TEX_PLUGIN,
- EXPP_CONF_ATTR_PATH_SOUND,
- EXPP_CONF_ATTR_PATH_SEQ_PLUGIN,
- EXPP_CONF_ATTR_PATH_TEMP,
-
- /*int*/
- EXPP_CONF_ATTR_UNDOSTEPS,
- EXPP_CONF_ATTR_TEX_TIMEOUT,
- EXPP_CONF_ATTR_TEX_COLLECT_RATE,
- EXPP_CONF_ATTR_MEM_CACHE_LIMIT,
- EXPP_CONF_ATTR_FONT_SIZE
-};
-
-PyObject *Config_CreatePyObject( )
-{
- BPy_Config *conf = PyObject_NEW( BPy_Config, &Config_Type);
- return (PyObject *)conf;
-}
-
-/*
- * repr function
- * callback functions building meaninful string to representations
- */
-static PyObject *Config_repr( BPy_Config * self )
-{
- return PyString_FromFormat( "[Blender Configuration Data]");
-}
-
-
-/*-----------------------Config module Init())-----------------------------*/
-/* see Main.c */
-/*
-static struct PyMethodDef BPy_Config_methods[] = {
- {"new", (PyCFunction)MainSeq_new, METH_VARARGS,
- "(name) - Create a new object in this scene from the obdata given and return a new object"},
- {"load", (PyCFunction)MainSeq_load, METH_VARARGS,
- "(filename) - loads the given filename for image, font and sound types"},
- {"unlink", (PyCFunction)MainSeq_unlink, METH_VARARGS,
- "unlinks the object from the scene"},
- {NULL, NULL, 0, NULL}
-};*/
-
-/*
- * get integer attributes
- */
-static PyObject *getStrAttr( BPy_Config *self, void *type )
-{
- char *param = NULL;
-
- switch( (int)type ) {
- case EXPP_CONF_ATTR_PATH_YF_EXPORT:
- param = U.yfexportdir;
- break;
- case EXPP_CONF_ATTR_PATH_FONT:
- param = U.fontdir;
- break;
- case EXPP_CONF_ATTR_PATH_RENDER:
- param = U.renderdir;
- break;
- case EXPP_CONF_ATTR_PATH_TEXTURE:
- param = U.textudir;
- break;
- case EXPP_CONF_ATTR_PATH_PYTHON:
- param = U.pythondir;
- break;
- case EXPP_CONF_ATTR_PATH_TEX_PLUGIN:
- param = U.plugtexdir;
- break;
- case EXPP_CONF_ATTR_PATH_SOUND:
- param = U.sounddir;
- break;
- case EXPP_CONF_ATTR_PATH_SEQ_PLUGIN:
- param = U.plugseqdir;
- break;
- case EXPP_CONF_ATTR_PATH_TEMP:
- param = U.tempdir;
- break;
-
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type in getStrAttr" );
- }
-
- return PyString_FromString( param );
-}
-
-/*
- * set integer attributes which require clamping
- */
-
-static int setStrAttr( BPy_Config *self, PyObject *value, void *type )
-{
- char *param;
- int len=160;
- char *str = PyString_AsString(value);
-
- if (!str)
- return EXPP_ReturnIntError( PyExc_TypeError,
- "error, must assign a python string for setStrAttr");
-
- switch( (int)type ) {
- case EXPP_CONF_ATTR_PATH_YF_EXPORT:
- param = U.yfexportdir;
- break;
- case EXPP_CONF_ATTR_PATH_FONT:
- param = U.fontdir;
- break;
- case EXPP_CONF_ATTR_PATH_RENDER:
- param = U.renderdir;
- break;
- case EXPP_CONF_ATTR_PATH_TEXTURE:
- param = U.textudir;
- break;
- case EXPP_CONF_ATTR_PATH_PYTHON:
- param = U.pythondir;
- break;
- case EXPP_CONF_ATTR_PATH_TEX_PLUGIN:
- param = U.plugtexdir;
- break;
- case EXPP_CONF_ATTR_PATH_SOUND:
- param = U.sounddir;
- break;
- case EXPP_CONF_ATTR_PATH_SEQ_PLUGIN:
- param = U.plugseqdir;
- break;
- case EXPP_CONF_ATTR_PATH_TEMP:
- param = U.tempdir;
- break;
-
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setStrAttr");
- }
-
- strncpy(param, str, len);
- return 0;
-}
-
-
-/*
- * get integer attributes
- */
-
-static PyObject *getIntAttr( BPy_Config *self, void *type )
-{
- int param;
-
- switch( (int)type ) {
- case EXPP_CONF_ATTR_UNDOSTEPS:
- param = (int)U.undosteps;
- break;
- case EXPP_CONF_ATTR_TEX_TIMEOUT:
- param = U.textimeout;
- break;
- case EXPP_CONF_ATTR_TEX_COLLECT_RATE:
- param = U.texcollectrate;
- break;
- case EXPP_CONF_ATTR_MEM_CACHE_LIMIT:
- param = U.memcachelimit;
- break;
- case EXPP_CONF_ATTR_FONT_SIZE:
- param = U.fontsize;
- break;
-
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type in getIntAttr" );
- }
-
- return PyInt_FromLong( param );
-}
-
-/*
- * set integer attributes which require clamping
- */
-
-static int setIntAttrClamp( BPy_Config *self, PyObject *value, void *type )
-{
- void *param;
- int min, max, size;
-
- switch( (int)type ) {
- case EXPP_CONF_ATTR_UNDOSTEPS:
- min = 0;
- max = 64;
- size = 'h';
- param = (void *)&U.undosteps;
- break;
- case EXPP_CONF_ATTR_TEX_TIMEOUT:
- min = 1;
- max = 3600;
- size = 'i';
- param = (void *)&U.textimeout;
- break;
- case EXPP_CONF_ATTR_TEX_COLLECT_RATE:
- min = 1;
- max = 3600;
- size = 'i';
- param = (void *)&U.texcollectrate;
- break;
- case EXPP_CONF_ATTR_MEM_CACHE_LIMIT:
- min = 1;
- max = 1024;
- size = 'i';
- param = (void *)&U.memcachelimit;
- break;
- case EXPP_CONF_ATTR_FONT_SIZE:
- min = 8;
- max = 16;
- size = 'i';
- param = (void *)&U.fontsize;
- break;
-
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setIntAttrClamp");
- }
- return EXPP_setIValueClamped( value, param, min, max, size );
-}
-
-static PyGetSetDef Config_getseters[] = {
-
- /* ints & shorts */
- {"undoSteps",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "undo steps",
- (void *)EXPP_CONF_ATTR_UNDOSTEPS},
- {"textureTimeout",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "time for textures to stay in openGL memory",
- (void *)EXPP_CONF_ATTR_TEX_TIMEOUT},
- {"textureCollectRate",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "intervel for textures to be tagged as used",
- (void *)EXPP_CONF_ATTR_TEX_COLLECT_RATE},
- {"sequenceMemCacheLimit",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "maximum memory for the sequencer to use as cache",
- (void *)EXPP_CONF_ATTR_MEM_CACHE_LIMIT},
- {"fontSize",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "user interface font size",
- (void *)EXPP_CONF_ATTR_FONT_SIZE},
-
- /* Paths */
- {"yfExportDir",
- (getter)getStrAttr, (setter)setStrAttr,
- "yafray export path",
- (void *)EXPP_CONF_ATTR_PATH_YF_EXPORT},
- {"fontDir",
- (getter)getStrAttr, (setter)setStrAttr,
- "default font path",
- (void *)EXPP_CONF_ATTR_PATH_FONT},
- {"renderDir",
- (getter)getStrAttr, (setter)setStrAttr,
- "default render path",
- (void *)EXPP_CONF_ATTR_PATH_RENDER},
- {"textureDir",
- (getter)getStrAttr, (setter)setStrAttr,
- "default texture path",
- (void *)EXPP_CONF_ATTR_PATH_TEXTURE},
- {"userScriptsDir",
- (getter)getStrAttr, (setter)setStrAttr,
- "user scripts path",
- (void *)EXPP_CONF_ATTR_PATH_PYTHON},
- {"texturePluginsDir",
- (getter)getStrAttr, (setter)setStrAttr,
- "default texture plugins path",
- (void *)EXPP_CONF_ATTR_PATH_TEX_PLUGIN},
- {"soundDir",
- (getter)getStrAttr, (setter)setStrAttr,
- "default sound path",
- (void *)EXPP_CONF_ATTR_PATH_SOUND},
- {"sequencePluginsDir",
- (getter)getStrAttr, (setter)setStrAttr,
- "sequencer plugins path",
- (void *)EXPP_CONF_ATTR_PATH_SEQ_PLUGIN},
- {"tempDir",
- (getter)getStrAttr, (setter)setStrAttr,
- "temporary file path",
- (void *)EXPP_CONF_ATTR_PATH_TEMP},
-
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-/*
- * Python Config_Type structure definition
- */
-PyTypeObject Config_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Config", /* char *tp_name; */
- sizeof( BPy_Config ), /* 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)Config_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 ***/
- NULL, /*BPy_Config_methods*/ /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- Config_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
-};
diff --git a/source/blender/python/api2_2x/bpy_config.h b/source/blender/python/api2_2x/bpy_config.h
deleted file mode 100644
index ae1f114dc81..00000000000
--- a/source/blender/python/api2_2x/bpy_config.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * $Id: bpy_config.h 10546 2007-04-18 14:40:01Z 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): Campbell Barton
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#ifndef EXPP_BPY_CONFIG_H
-#define EXPP_BPY_CONFIG_H
-
-#include <Python.h>
-
-/* The Main PyType Object defined in Main.c */
-extern PyTypeObject Config_Type;
-
-#define BPy_Config_Check(v) \
- ((v)->ob_type == &Config_Type)
-
-/* Main sequence, iterate on the libdatas listbase*/
-typedef struct {
- PyObject_VAR_HEAD /* required python macro */
-} BPy_Config;
-
-PyObject *Config_CreatePyObject();
-
-
-#endif /* EXPP_BPY_CONFIG_H */
diff --git a/source/blender/python/api2_2x/bpy_data.c b/source/blender/python/api2_2x/bpy_data.c
deleted file mode 100644
index fd5fe27fbaf..00000000000
--- a/source/blender/python/api2_2x/bpy_data.c
+++ /dev/null
@@ -1,817 +0,0 @@
-/*
- * $Id: bpy_data.c 12056 2007-09-17 06:11:06Z aligorith $
- *
- * ***** 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 "bpy_data.h"
-
-#include "MEM_guardedalloc.h" /* for MEM_callocN */
-#include "DNA_space_types.h" /* SPACE_VIEW3D, SPACE_SEQ */
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h" /* LibBlockSeq_new */
-#include "DNA_texture_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
-#include "DNA_group_types.h"
-#include "DNA_world_types.h"
-#include "DNA_vfont_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_sound_types.h"
-#include "DNA_text_types.h"
-#include "DNA_action_types.h"
-#include "DNA_meta_types.h"
-
-/* Use the add_* from BKE_* */
-#include "BKE_global.h"
-#include "BKE_utildefines.h" /* clamp */
-#include "BKE_armature.h"
-#include "BKE_ipo.h"
-#include "BKE_image.h"
-#include "BKE_main.h"
-#include "BKE_library.h"
-#include "BKE_lattice.h"
-#include "BKE_object.h"
-#include "BKE_scene.h"
-#include "BKE_sca.h" /*free_text_controllers*/
-#include "BKE_font.h"
-#include "BKE_mball.h"
-#include "BKE_mesh.h"
-#include "BKE_curve.h"
-#include "BKE_material.h"
-#include "BKE_group.h"
-#include "BKE_text.h"
-#include "BKE_texture.h"
-#include "BKE_world.h"
-
-#include "BLI_blenlib.h" /* BLI_countlist */
-#include "BIF_drawscene.h" /* for set_scene */
-#include "BIF_screen.h" /* curarea */
-#include "BIF_drawimage.h" /* what image */
-#include "BIF_drawtext.h" /* unlink_text */
-#include "BIF_editsound.h" /* sound_new_sound */
-#include "BIF_editaction.h" /* add_empty_action */
-
-/* python types */
-#include "../BPY_extern.h" /* clearing scriptlinks */
-
-#include "gen_utils.h"
-#include "gen_library.h" /* generic ID functions */
-
-#include "Object.h"
-#include "Camera.h"
-#include "Armature.h"
-#include "Lamp.h"
-#include "Curve.h"
-#include "NMesh.h"
-#include "Mesh.h"
-#include "Lattice.h"
-#include "Metaball.h"
-#include "Text.h"
-#include "Text3d.h"
-#include "Font.h"
-#include "Group.h"
-#include "World.h"
-#include "Texture.h"
-#include "Ipo.h"
-#include "Text.h"
-#include "Sound.h"
-#include "NLA.h"
-#include "Scene.h"
-#include "Library.h"
-
-#include "bpy_config.h" /* config pydata */
-
-/* used only for texts.active */
-#include "BIF_screen.h"
-#include "DNA_space_types.h"
-#include "DNA_screen_types.h"
-
-extern VFont *get_builtin_font(void);
-
-static PyObject *LibBlockSeq_CreatePyObject( Link *iter, int type )
-{
- BPy_LibBlockSeq *seq = PyObject_NEW( BPy_LibBlockSeq, &LibBlockSeq_Type);
- seq->iter = iter;
- seq->type = type;
- return (PyObject *)seq;
-}
-
-
-static int LibBlockSeq_len( BPy_LibBlockSeq * self )
-{
- ListBase *lb = wich_libbase(G.main, self->type);
- return BLI_countlist( lb );
-}
-
-static PyObject * LibBlockSeq_subscript(BPy_LibBlockSeq * self, PyObject *key)
-{
- char *name;
- char *lib= NULL;
- char use_lib = 0;
- ID *id;
-
- id = (ID *)wich_libbase(G.main, self->type)->first;
-
- if ( PyString_Check(key) ) {
- name = PyString_AsString ( key );
- } else if (PyTuple_Check(key) && (PyTuple_Size(key) == 2) ) {
- PyObject *pydata;
- use_lib = 1;
-
- /* Get the first arg */
- pydata = PyTuple_GET_ITEM(key, 0);
- if (!PyString_Check(pydata)) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "the data name must be a string" );
- }
-
- name = PyString_AsString ( pydata );
-
- /* Get the second arg */
- pydata = PyTuple_GET_ITEM(key, 1);
- if (pydata == Py_None) {
- lib = NULL; /* data must be local */
- } else if (PyString_Check(pydata)) {
- lib = PyString_AsString ( pydata );
- if (!strcmp( "", lib)) {
- lib = NULL; /* and empty string also means data must be local */
- }
- } else {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "the lib name must be a string or None" );
- }
- } else {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected the a name string or a tuple (lib, name)" );
- }
-
- for (; id; id = id->next) {
- if(!strcmp( name, id->name+2 )) {
- if (
- (!use_lib) || /* any data, local or external lib data */
- (use_lib && !lib && !id->lib) || /* only local */
- (lib && use_lib && id->lib && (!strcmp( id->lib->name, lib))) /* only external lib */
- )
- {
- return GetPyObjectFromID(id);
- }
- }
- }
- return ( EXPP_ReturnPyObjError
- ( PyExc_KeyError, "Requested data does not exist") );
-}
-
-static PyMappingMethods LibBlockSeq_as_mapping = {
- ( inquiry ) LibBlockSeq_len, /* mp_length */
- ( binaryfunc ) LibBlockSeq_subscript, /* mp_subscript */
- ( objobjargproc ) 0, /* mp_ass_subscript */
-};
-
-
-/************************************************************************
- *
- * Python LibBlockSeq_Type iterator (iterates over GroupObjects)
- *
- ************************************************************************/
-
-/*
- * Initialize the interator index
- */
-
-static PyObject *LibBlockSeq_getIter( BPy_LibBlockSeq * self )
-{
- /* we need to get the first base, but for selected context we may need to advance
- to the first selected or first conext base */
-
- ListBase *lb;
- Link *link;
- lb = wich_libbase(G.main, self->type);
-
- link = lb->first;
-
- /* create a new iterator if were alredy using this one */
- if (self->iter==NULL) {
- self->iter = link;
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- return LibBlockSeq_CreatePyObject(link, self->type);
- }
-}
-
-/*
- * Return next LibBlockSeq iter.
- */
-
-static PyObject *LibBlockSeq_nextIter( BPy_LibBlockSeq * self )
-{
- PyObject *object;
- Link *link;
- if( !(self->iter) ) {
- self->iter= NULL;
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- object = GetPyObjectFromID((ID *)self->iter);
-
- link= self->iter->next;
- self->iter= link;
- return object;
-}
-
-PyObject *LibBlockSeq_getActive(BPy_LibBlockSeq *self)
-{
- switch (self->type) {
- case ID_SCE:
- if ( !G.scene ) {
- Py_RETURN_NONE;
- } else {
- return Scene_CreatePyObject( ( Scene * ) G.scene );
- }
-
- break;
- case ID_IM:
- if (!G.sima || !G.sima->image) {
- Py_RETURN_NONE;
- } else {
- what_image( G.sima ); /* make sure image data exists */
- return Image_CreatePyObject( G.sima->image );
- }
- break;
- case ID_TXT: {
- SpaceText *st= curarea->spacedata.first;
-
- if (st->spacetype!=SPACE_TEXT || st->text==NULL) {
- Py_RETURN_NONE;
- } else {
- return Text_CreatePyObject( st->text );
- }
- }
- }
-
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Only Scene and Image types have the active attribute" );
-}
-
-static int LibBlockSeq_setActive(BPy_LibBlockSeq *self, PyObject *value)
-{
- switch (self->type) {
- case ID_SCE:
- if (!BPy_Scene_Check(value)) {
- return EXPP_ReturnIntError(PyExc_TypeError,
- "Must be a scene" );
- } else {
- BPy_Scene *bpydata;
- Scene *data;
-
- bpydata = (BPy_Scene *)value;
- data= bpydata->scene;
-
- if (!data)
- return EXPP_ReturnIntError(PyExc_RuntimeError,
- "This Scene has been removed" );
-
- if (data != G.scene) {
- set_scene( data );
- scene_update_for_newframe(data, data->lay);
- }
- }
- return 0;
-
- case ID_IM:
- if (!BPy_Image_Check(value)) {
- return EXPP_ReturnIntError(PyExc_TypeError,
- "Must be a scene" );
- } else {
- BPy_Image *bpydata;
- Image *data;
-
- if (!G.sima)
- return 0;
-
- bpydata = (BPy_Image *)value;
- data= bpydata->image;
-
- if (!data)
- return EXPP_ReturnIntError(PyExc_RuntimeError,
- "This Scene has been removed" );
-
- if (data != G.sima->image)
- G.sima->image= data;
- }
- return 0;
-
- case ID_TXT:
- if (!BPy_Text_Check(value)) {
- return EXPP_ReturnIntError(PyExc_TypeError,
- "Must be a text" );
- } else {
- SpaceText *st= curarea->spacedata.first;
- Text *data = ((BPy_Text *)value)->text;
-
- if( !data )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This object isn't linked to a Blender Text Object" );
- if(st->spacetype!=SPACE_TEXT)
- return 0;
- st->text = data;
- }
- return 0;
- }
-
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Only Scene and Image types have the active attribute" );
-}
-
-static int LibBlockSeq_setTag(BPy_LibBlockSeq *self, PyObject *value)
-{
- ID *id;
- int param = PyObject_IsTrue( value );
-
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- id = (ID *)wich_libbase(G.main, self->type)->first;
-
- if (param) {
- for (; id; id = id->next) {
- id->flag |= LIB_DOIT;
- }
- } else {
- for (; id; id = id->next) {
- id->flag &= ~LIB_DOIT;
- }
- }
-
- return 0;
-}
-
-
-/* New Data, internal functions */
-Mesh *add_mesh__internal(char *name)
-{
- Mesh *mesh = add_mesh(name); /* doesn't return NULL now, but might someday */
-
- /* Bound box set to null needed because a new mesh is initialized
- with a bounding box of -1 -1 -1 -1 -1 -1
- if its not set to null the bounding box is not re-calculated
- when ob.getBoundBox() is called.*/
- MEM_freeN(mesh->bb);
- mesh->bb= NULL;
- return mesh;
-}
-
-/* used for new and load */
-PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd)
-{
- ID *id = NULL;
- char *name=NULL, *filename=NULL, *data_type=NULL;
- int img_width=256, img_height=256;
- float color[] = {0, 0, 0, 1};
- short data_code = 0;
- int user_count = 0;
-
- /* Load from file */
- if ( ( self->type==ID_IM || self->type==ID_VF ||
- self->type==ID_SO || self->type==ID_TXT) &&
- ( PyTuple_Size( args ) < 3 ))
- {
- static char *kwlist[] = {"name", "filename", NULL};
-
- if(PyArg_ParseTupleAndKeywords(args, kwd, "|ss", kwlist, &name, &filename) && filename ) {
- PyObject *ret= NULL;
-
- if (strlen(filename) > FILE_MAXDIR + FILE_MAXFILE - 1)
- return ( EXPP_ReturnPyObjError( PyExc_IOError,
- "filename too long" ) );
-
- if (self->type == ID_IM) {
- Image *img = BKE_add_image_file( filename );
- if (!img)
- return ( EXPP_ReturnPyObjError( PyExc_IOError,
- "couldn't load image" ) );
- ret = Image_CreatePyObject( img );
-
- } else if (self->type == ID_VF) {
- VFont *vf = load_vfont (filename);
- if (!vf)
- return EXPP_ReturnPyObjError( PyExc_IOError,
- "couldn't load font" );
- ret = Font_CreatePyObject(vf);
-
- } else if (self->type == ID_SO) {
- bSound *snd = sound_new_sound( filename );
- if (!snd)
- return EXPP_ReturnPyObjError( PyExc_IOError,
- "couldn't load sound" );
- ret = Sound_CreatePyObject(snd);
-
- } else if (self->type == ID_TXT) {
- Text *txt = NULL;
- txt = add_text( filename );
- if( !txt )
- return EXPP_ReturnPyObjError( PyExc_IOError,
- "couldn't load text" );
- ret = Text_CreatePyObject(txt);
- }
-
- if (!ret)
- return EXPP_ReturnPyObjError( PyExc_IOError,
- "couldn't create pyobject on load, unknown error" );
- if (name) {
- ID *id = ((BPy_GenericLib *)ret)->id;
- rename_id( id, name );
- }
- return ret;
- }
- }
-
- /* New Data */
- if (self->type == ID_IM) {
- /* Image, accepts width and height*/
- if( !PyArg_ParseTuple( args, "|sii", &name, &img_width, &img_height ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "one string and two ints expected as arguments" );
- CLAMP(img_width, 4, 5000);
- CLAMP(img_height, 4, 5000);
-
- } else if (self->type == ID_CU) {
- /* Curve, needs name and type strings */
- if( !PyArg_ParseTuple( args, "ss", &name, &data_type ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "two strings expected as arguments" );
-
- if( !strcmp( data_type, "Curve" ) ) data_code = OB_CURVE;
- else if( !strcmp( data_type, "Text3d" ) ) data_code = OB_FONT;/*
- else if( !strcmp( data_type, "Surf" ) ) data_code = OB_SURF;*/
- else return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Second argument for Curve type incorrect\t\nmust be a string in (Curve or Text - Surf is not supported yet)" );
-
- } else if (self->type == ID_IP) {
- /* IPO, needs name and type strings */
- if( !PyArg_ParseTuple( args, "ss", &name, &data_type ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "two strings expected as arguments" );
-
- if( !strcmp( data_type, "Object" ) ) data_code = ID_OB;
- else if( !strcmp( data_type, "Camera" ) ) data_code = ID_CA;
- else if( !strcmp( data_type, "World" ) ) data_code = ID_WO;
- else if( !strcmp( data_type, "Material" ) ) data_code = ID_MA;
- else if( !strcmp( data_type, "Texture" ) ) data_code = ID_TE;
- else if( !strcmp( data_type, "Lamp" ) ) data_code = ID_LA;
- else if( !strcmp( data_type, "Action" ) ) data_code = ID_PO;
- else if( !strcmp( data_type, "Constraint" ) ) data_code = ID_CO;
- else if( !strcmp( data_type, "Sequence" ) ) data_code = ID_SEQ;
- else if( !strcmp( data_type, "Curve" ) ) data_code = ID_CU;
- else if( !strcmp( data_type, "Key" ) ) data_code = ID_KE;
- else return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Second argument for IPO type incorrect\t\nmust be a string in (Object, Camera, World, Material, Texture, Lamp, Action, Sequence, Curve, Key)" );
-
- } else {
- /* Other types only need the name */
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "new(name) - name must be a string argument" );
- }
-
- switch (self->type) {
- case ID_SCE:
- id = (ID *)add_scene( name?name:"Scene" );
- user_count = 1;
- break;
- case ID_OB:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Add objects through the scenes objects iterator" );
- case ID_ME:
- id = (ID *)add_mesh__internal( name?name:"Mesh" );
- break;
- case ID_CU:
- id = (ID *)add_curve( name?name:"Curve", data_code );
- if (data_code==OB_FONT) {
- Text3d *text3d = (Text3d *)id;
- text3d->vfont= get_builtin_font();
- text3d->vfont->id.us++;
- text3d->str= MEM_mallocN(sizeof(wchar_t), "str");
- text3d->str[0] = '\0';
- text3d->totbox= text3d->actbox= 1;
- text3d->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox");
- text3d->tb[0].w = text3d->tb[0].h = 0.0;
-
- } /*else { CURVE - Dont need to do anything } */
- break;
- case ID_MB:
- id = (ID *)add_mball( name?name:"MBall" );
- break;
- case ID_MA:
- id = (ID *)add_material( name?name:"Material" );
- break;
- case ID_TE:
- id = (ID *)add_texture( name?name:"Texture" );
- break;
- case ID_IM:
- {
- id = (ID *)BKE_add_image_size(img_width, img_height, name?name:"Image", 0, color);
- if( !id )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyObject Image_Type" ) );
- /* new images have zero user count */
- break;
- }
- case ID_LT:
- id = (ID *)add_lattice( name?name:"Lattice" );
- break;
- case ID_LA:
- id = (ID *)add_lamp( name?name:"Lamp" );
- break;
- case ID_CA:
- id = (ID *)add_camera( name?name:"Camera" );
- break;
- case ID_IP:
- id = (ID *)add_ipo( name?name:"Ipo", data_code );
- break;
- case ID_WO:
- id = (ID *)add_world( name?name:"World" );
- break;
- case ID_VF:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Cannot create new fonts, use the load() function to load from a file" );
- case ID_TXT:
- id = (ID *)add_empty_text( name?name:"Text" );
- user_count = 1;
- break;
- case ID_SO:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Cannot create new sounds, use the load() function to load from a file" );
- case ID_GR:
- id = (ID *)add_group( name?name:"Group" );
- user_count = 1;
- break;
- case ID_AR:
- id = (ID *)add_armature( name?name:"Armature" );
- break;
- case ID_AC:
- id = (ID *)add_empty_action( name?name:"Action" );
- user_count = 1;
- break;
- }
-
- if (!id)
- Py_RETURN_NONE;
-
- /* set some types user count to 1, otherwise zero */
- id->us = user_count;
-
- return GetPyObjectFromID(id);
-}
-
-
-PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * value)
-{
- switch (self->type) {
- case ID_SCE:
- if( !BPy_Scene_Check(value) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Scene object" );
- } else {
- Scene *data = ((BPy_Scene *)value)->scene;
-
- if (!data)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This Scene has been removed" );
-
- /* Run the removal code */
- free_libblock( &G.main->scene, data );
- ((BPy_Scene *)value)->scene = NULL;
- Py_RETURN_NONE;
- }
- case ID_GR:
- if( !BPy_Group_Check(value) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Group object" );
- } else {
- Group *data = ((BPy_Group *)value)->group;
-
- if (!data)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This Group has been removed alredy" );
-
- /* Run the removal code */
- free_group(data);
- unlink_group(data);
- data->id.us= 0;
- free_libblock( &G.main->group, data );
- ((BPy_Group *)value)->group = NULL;
-
- Py_RETURN_NONE;
- }
-
- case ID_TXT:
- if( !BPy_Text_Check(value) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Text object" );
- } else {
- Text *data = ((BPy_Text *)value)->text;
-
- if (!data)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "This Group has been removed alredy" );
-
- /* Run the removal code */
- BPY_clear_bad_scriptlinks( data );
- free_text_controllers( data );
- unlink_text( data );
- free_libblock( &G.main->text, data );
- ((BPy_Text *)value)->text = NULL;
-
- Py_RETURN_NONE;
- }
- }
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Only types Scene, Group and Text can unlink" );
-}
-
-static int LibBlockSeq_compare( BPy_LibBlockSeq * a, BPy_LibBlockSeq * b )
-{
- return ( a->type == b->type) ? 0 : -1;
-}
-
-/*
- * repr function
- * callback functions building meaninful string to representations
- */
-static PyObject *LibBlockSeq_repr( BPy_LibBlockSeq * self )
-{
- return PyString_FromFormat( "[LibBlockSeq Iterator]");
-}
-
-static PyGetSetDef LibBlockSeq_getseters[] = {
- {"active",
- (getter)LibBlockSeq_getActive, (setter)LibBlockSeq_setActive,
- "active object",
- NULL},
- {"tag",
- (getter)NULL, (setter)LibBlockSeq_setTag,
- "tag all data in True or False (write only)",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-static struct PyMethodDef BPy_LibBlockSeq_methods[] = {
- {"new", (PyCFunction)LibBlockSeq_new, METH_VARARGS | METH_KEYWORDS,
- "(name) - Create a new object in this scene from the obdata given and return a new object"},
- {"unlink", (PyCFunction)LibBlockSeq_unlink, METH_O,
- "unlinks the object from the scene"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python LibBlockSeq_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject LibBlockSeq_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender LibBlockSeq", /* char *tp_name; */
- sizeof( BPy_LibBlockSeq ), /* 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 ) LibBlockSeq_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) LibBlockSeq_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- NULL, /* PySequenceMethods *tp_as_sequence; */
- &LibBlockSeq_as_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) LibBlockSeq_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) LibBlockSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_LibBlockSeq_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- LibBlockSeq_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
-};
-
-
-/*-----------------------------BPy module Init())-----------------------------*/
-
-PyObject * Data_Init( void )
-{
- PyObject *module;
- PyObject *dict;
-
-
- PyType_Ready( &LibBlockSeq_Type );
- PyType_Ready( &Config_Type );
-
- /*submodule = Py_InitModule3( "Blender.Main", NULL, M_Main_doc );*/
- module = Py_InitModule3( "bpy.data", NULL, "The bpy.data submodule" );
- dict = PyModule_GetDict( module );
-
- /* Python Data Types */
- PyModule_AddObject( module, "scenes", LibBlockSeq_CreatePyObject(NULL, ID_SCE) );
- PyModule_AddObject( module, "objects", LibBlockSeq_CreatePyObject(NULL, ID_OB) );
- PyModule_AddObject( module, "meshes", LibBlockSeq_CreatePyObject(NULL, ID_ME) );
- PyModule_AddObject( module, "curves", LibBlockSeq_CreatePyObject(NULL, ID_CU) );
- PyModule_AddObject( module, "metaballs",LibBlockSeq_CreatePyObject(NULL, ID_MB) );
- PyModule_AddObject( module, "materials",LibBlockSeq_CreatePyObject(NULL, ID_MA) );
- PyModule_AddObject( module, "textures", LibBlockSeq_CreatePyObject(NULL, ID_TE) );
- PyModule_AddObject( module, "images", LibBlockSeq_CreatePyObject(NULL, ID_IM) );
- PyModule_AddObject( module, "lattices", LibBlockSeq_CreatePyObject(NULL, ID_LT) );
- PyModule_AddObject( module, "lamps", LibBlockSeq_CreatePyObject(NULL, ID_LA) );
- PyModule_AddObject( module, "cameras", LibBlockSeq_CreatePyObject(NULL, ID_CA) );
- PyModule_AddObject( module, "ipos", LibBlockSeq_CreatePyObject(NULL, ID_IP) );
- PyModule_AddObject( module, "worlds", LibBlockSeq_CreatePyObject(NULL, ID_WO) );
- PyModule_AddObject( module, "fonts", LibBlockSeq_CreatePyObject(NULL, ID_VF) );
- PyModule_AddObject( module, "texts", LibBlockSeq_CreatePyObject(NULL, ID_TXT) );
- PyModule_AddObject( module, "sounds", LibBlockSeq_CreatePyObject(NULL, ID_SO) );
- PyModule_AddObject( module, "groups", LibBlockSeq_CreatePyObject(NULL, ID_GR) );
- PyModule_AddObject( module, "armatures",LibBlockSeq_CreatePyObject(NULL, ID_AR) );
- PyModule_AddObject( module, "actions", LibBlockSeq_CreatePyObject(NULL, ID_AC) );
- return module;
-}
diff --git a/source/blender/python/api2_2x/bpy_data.h b/source/blender/python/api2_2x/bpy_data.h
deleted file mode 100644
index 45600df6471..00000000000
--- a/source/blender/python/api2_2x/bpy_data.h
+++ /dev/null
@@ -1,55 +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 *****
-*/
-
-#ifndef EXPP_BPYDATA_H
-#define EXPP_BPYDATA_H
-
-#include <Python.h>
-#include "DNA_listBase.h"
-
-/* The Main PyType Object defined in Main.c */
-extern PyTypeObject LibBlockSeq_Type;
-
-#define BPy_LibBlockSeq_Check(v) \
- ((v)->ob_type == &LibBlockSeq_Type)
-
-/* Main sequence, iterate on the libdatas listbase*/
-typedef struct {
- PyObject_VAR_HEAD /* required python macro */
- Link *iter; /* so we can iterate over the listbase */
-
- short type; /* store the ID type such as ID_ME */
-} BPy_LibBlockSeq;
-
-
-PyObject * Data_Init( void );
-
-#endif /* EXPP_BPYDATA_H */
diff --git a/source/blender/python/api2_2x/bpy_types.h b/source/blender/python/api2_2x/bpy_types.h
deleted file mode 100644
index fcada098d1e..00000000000
--- a/source/blender/python/api2_2x/bpy_types.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * $Id: bpy_types.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_bpy_types_h
-#define EXPP_bpy_types_h
-
-
-/*****************************************************************************/
-/* Camera Data */
-/*****************************************************************************/
-
-
-/*****************************************************************************/
-/* Lamp Data */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* Ipo Data */
-/*****************************************************************************/
-
-
-
-/*****************************************************************************/
-/* Metaball Data */
-/*****************************************************************************/
-
-
-/*****************************************************************************/
-/* Metaelem Data */
-/*****************************************************************************/
-
-
-/*****************************************************************************/
-/* Effect Data */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* Wave Data */
-/*****************************************************************************/
-
-
-/*****************************************************************************/
-/* Build Data */
-/*****************************************************************************/
-
-
-/*****************************************************************************/
-/* Particle Data */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* Curve Data */
-/*****************************************************************************/
-
-/**********
- CurNurb data
-***********/
-
-
-/*****************************************************************************/
-/* World Data */
-/*****************************************************************************/
-
-
-#endif /* EXPP_bpy_types_h */
diff --git a/source/blender/python/api2_2x/charRGBA.c b/source/blender/python/api2_2x/charRGBA.c
deleted file mode 100644
index 087ddecc1c5..00000000000
--- a/source/blender/python/api2_2x/charRGBA.c
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * $Id: charRGBA.c 10782 2007-05-26 04:39:31Z 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 "charRGBA.h" /*This must come first */
-#include "gen_utils.h"
-
-/* This file is heavily based on the old bpython Constant object code in
- Blender */
-
-/*****************************************************************************/
-/* Python charRGBA_Type callback function prototypes: */
-/*****************************************************************************/
-static PyObject *charRGBA_repr( BPy_charRGBA * self );
-
-static int charRGBALength( BPy_charRGBA * self );
-
-static PyObject *charRGBASubscript( BPy_charRGBA * self, PyObject * key );
-static int charRGBAAssSubscript( BPy_charRGBA * self, PyObject * who,
- PyObject * cares );
-
-static PyObject *charRGBAItem( BPy_charRGBA * self, int i );
-static int charRGBAAssItem( BPy_charRGBA * self, int i, PyObject * ob );
-static PyObject *charRGBASlice( BPy_charRGBA * self, int begin, int end );
-static int charRGBAAssSlice( BPy_charRGBA * self, int begin, int end,
- PyObject * seq );
-static PyObject *charRGBA_getColor( BPy_charRGBA * self, void * type);
-static int charRGBA_setColor( BPy_charRGBA * self, PyObject * value, void * type);
-
-/*****************************************************************************/
-/* Python charRGBA_Type Mapping Methods table: */
-/*****************************************************************************/
-static PyMappingMethods charRGBAAsMapping = {
- ( inquiry ) charRGBALength, /* mp_length */
- ( binaryfunc ) charRGBASubscript, /* mp_subscript */
- ( objobjargproc ) charRGBAAssSubscript, /* mp_ass_subscript */
-};
-
-/*****************************************************************************/
-/* Python charRGBA_Type Sequence Methods table: */
-/*****************************************************************************/
-static PySequenceMethods charRGBAAsSequence = {
- ( inquiry ) charRGBALength, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) charRGBAItem, /* sq_item */
- ( intintargfunc ) charRGBASlice, /* sq_slice */
- ( intobjargproc ) charRGBAAssItem, /* sq_ass_item */
- ( intintobjargproc ) charRGBAAssSlice, /* sq_ass_slice */
-};
-
-static PyGetSetDef charRGBA_getseters[] = {
- {"R",
- (getter)charRGBA_getColor, (setter)charRGBA_setColor,
- "the red component",
- (void *) 0},
- {"r",
- (getter)charRGBA_getColor, (setter)charRGBA_setColor,
- "the red component",
- (void *) 0},
- {"G",
- (getter)charRGBA_getColor, (setter)charRGBA_setColor,
- "the green component",
- (void *) 1},
- {"g",
- (getter)charRGBA_getColor, (setter)charRGBA_setColor,
- "the green component",
- (void *) 1},
- {"B",
- (getter)charRGBA_getColor, (setter)charRGBA_setColor,
- "the blue component",
- (void *) 2},
- {"b",
- (getter)charRGBA_getColor, (setter)charRGBA_setColor,
- "the blue component",
- (void *) 2},
- {"A",
- (getter)charRGBA_getColor, (setter)charRGBA_setColor,
- "the alpha component",
- (void *) 3},
- {"a",
- (getter)charRGBA_getColor, (setter)charRGBA_setColor,
- "the alpha component",
- (void *) 3},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python charRGBA_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject charRGBA_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "charRGBA", /* tp_name */
- sizeof( BPy_charRGBA ), /* 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 ) charRGBA_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- NULL, /* PyNumberMethods *tp_as_number; */
- &charRGBAAsSequence, /* PySequenceMethods *tp_as_sequence; */
- &charRGBAAsMapping, /* 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; */
- charRGBA_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: charRGBA_New */
-/*****************************************************************************/
-PyObject *charRGBA_New( char *rgba )
-{
- BPy_charRGBA *charRGBA = NULL;
-
- /*
- * When called the first time, charRGBA_Type.tp_dealloc will be NULL.
- * If that's the case, initialize the PyTypeObject. If the
- * initialization succeeds, then create a new object.
- */
-
- if( charRGBA_Type.tp_dealloc || PyType_Ready( &charRGBA_Type ) >= 0 ) {
- charRGBA = ( BPy_charRGBA * ) PyObject_NEW( BPy_charRGBA,
- &charRGBA_Type );
- }
-
- if( charRGBA == NULL )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create charRGBA object" );
-
- /* rgba is a pointer to the first item of a char[4] array */
- charRGBA->rgba[0] = &rgba[0];
- charRGBA->rgba[1] = &rgba[1];
- charRGBA->rgba[2] = &rgba[2];
- charRGBA->rgba[3] = &rgba[3];
-
- return ( PyObject * ) charRGBA;
-}
-
-/*****************************************************************************/
-/* Functions: charRGBA_getCol and charRGBA_setCol */
-/* Description: These functions get/set rgba color triplet values. The */
-/* get function returns a tuple, the set one accepts three */
-/* chars (separated or in a tuple) as arguments. */
-/*****************************************************************************/
-PyObject *charRGBA_getCol( BPy_charRGBA * self )
-{
- PyObject *list = PyList_New( 4 );
-
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" );
-
- PyList_SET_ITEM( list, 0, PyInt_FromLong( *(self->rgba[0])) );
- PyList_SET_ITEM( list, 1, PyInt_FromLong( *(self->rgba[1])) );
- PyList_SET_ITEM( list, 2, PyInt_FromLong( *(self->rgba[2])) );
- PyList_SET_ITEM( list, 3, PyInt_FromLong( *(self->rgba[3])) );
- return list;
-}
-
-PyObject *charRGBA_setCol( BPy_charRGBA * self, PyObject * args )
-{
- int ok;
- char r = 0, g = 0, b = 0, a = 0;
-
- if( PyObject_Length( args ) == 4 )
- ok = PyArg_ParseTuple( args, "bbbb", &r, &g, &b, &a );
-
- else
- ok = PyArg_ParseTuple( args, "|(bbbb)", &r, &g, &b, &a );
-
- if( !ok )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 1-byte ints [b,b,b,b] or b,b,b,b as arguments (or nothing)" );
-
- *( self->rgba[0] ) = (char)EXPP_ClampInt( r, 0, 255 );
- *( self->rgba[1] ) = (char)EXPP_ClampInt( g, 0, 255 );
- *( self->rgba[2] ) = (char)EXPP_ClampInt( b, 0, 255 );
- *( self->rgba[3] ) = (char)EXPP_ClampInt( a, 0, 255 );
-
- return EXPP_incr_ret( Py_None );
-}
-
-/* return color value for one of the components */
-
-static PyObject *charRGBA_getColor( BPy_charRGBA * self, void * type)
-{
- int index = ((long)type) & 3;
- return PyInt_FromLong ( *self->rgba[index] );
-}
-
-/* sets the color value of one of the components */
-
-static int charRGBA_setColor( BPy_charRGBA * self, PyObject * value,
- void * type)
-{
- int index = ((long)type) & 3;
- PyObject *num = PyNumber_Int( value );
-
- /* argument must be a number */
- if( !num )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected char argument" );
-
- /* clamp valut to 0..255 then assign */
- *self->rgba[index] = (char)EXPP_ClampInt( (int)PyInt_AS_LONG(value),
- 0, 255 );
- Py_DECREF( num );
- return 0;
-}
-
-/*****************************************************************************/
-/* Section: charRGBA as Mapping */
-/* These functions provide code to access charRGBA objects as */
-/* mappings. */
-/*****************************************************************************/
-static int charRGBALength( BPy_charRGBA * self )
-{
- return 4;
-}
-
-static PyObject *charRGBASubscript( BPy_charRGBA * self, PyObject * key )
-{
- char *name = NULL;
- int i;
-
- if( PyNumber_Check( key ) )
- return charRGBAItem( self, ( int ) PyInt_AsLong( key ) );
-
- if( !PyArg_ParseTuple( key, "s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int or string argument" );
-
- if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
- i = 0;
- else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
- i = 1;
- else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
- i = 2;
- else if( !strcmp( name, "A" ) || !strcmp( name, "a" ) )
- i = 3;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
-
- return PyInt_FromLong( (long)(*self->rgba[i]) );
-}
-
-static int charRGBAAssSubscript( BPy_charRGBA * self, PyObject * key,
- PyObject * v )
-{
- char *name = NULL;
- int i;
-
- if( !PyNumber_Check( v ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "value to assign must be a number" );
-
- if( PyNumber_Check( key ) )
- return charRGBAAssItem( self, ( int ) PyInt_AsLong( key ), v );
-
- if( !PyArg_Parse( key, "s", &name ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int or string argument" );
-
- if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
- i = 0;
- else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
- i = 1;
- else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
- i = 2;
- else if( !strcmp( name, "A" ) || !strcmp( name, "a" ) )
- i = 3;
- else
- return EXPP_ReturnIntError( PyExc_AttributeError, name );
-
- *( self->rgba[i] ) = (char)EXPP_ClampInt( PyInt_AsLong( v ), 0, 255 );
-
- return 0;
-}
-
-/*****************************************************************************/
-/* Section: charRGBA as Sequence */
-/* These functions provide code to access charRGBA objects as */
-/* sequences. */
-/*****************************************************************************/
-static PyObject *charRGBAItem( BPy_charRGBA * self, int i )
-{
- if( i < 0 || i >= 4 )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-
- return PyInt_FromLong( *(self->rgba[i]) );
-}
-
-static PyObject *charRGBASlice( BPy_charRGBA * self, int begin, int end )
-{
- PyObject *list;
- int count;
-
- if( begin < 0 )
- begin = 0;
- if( end > 4 )
- end = 4;
- if( begin > end )
- begin = end;
-
- list = PyList_New( end - begin );
-
- for( count = begin; count < end; count++ )
- PyList_SetItem( list, count - begin,
- PyInt_FromLong( *( self->rgba[count] ) ) );
-
- return list;
-}
-
-static int charRGBAAssItem( BPy_charRGBA * self, int i, PyObject * ob )
-{
- if( i < 0 || i >= 4 )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "array assignment index out of range" );
-
- if( !PyNumber_Check( ob ) )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "color component must be a number" );
-
- *( self->rgba[i] ) = (char)EXPP_ClampInt( PyInt_AsLong( ob ), 0, 255 );
-
- return 0;
-}
-
-static int charRGBAAssSlice( BPy_charRGBA * self, int begin, int end,
- PyObject * seq )
-{
- int count;
-
- if( begin < 0 )
- begin = 0;
- if( end > 4 )
- end = 4;
- if( begin > end )
- begin = end;
-
- if( !PySequence_Check( seq ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "illegal argument type for built-in operation" );
-
- if( PySequence_Length( seq ) != ( end - begin ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "size mismatch in slice assignment" );
-
- for( count = begin; count < end; count++ ) {
- char value;
- PyObject *ob = PySequence_GetItem( seq, count );
-
- if( !PyArg_Parse( ob, "b", &value ) ) {
- Py_DECREF( ob );
- return -1;
- }
-
- *( self->rgba[count] ) = (char)EXPP_ClampInt( value, 0, 255 );
-
- Py_DECREF( ob );
- }
-
- return 0;
-}
-
-/*****************************************************************************/
-/* Function: charRGBA_repr */
-/* Description: This is a callback function for the BPy_charRGBA type. It */
-/* builds a meaninful string to represent charRGBA objects. */
-/*****************************************************************************/
-static PyObject *charRGBA_repr( BPy_charRGBA * self )
-{
- char r, g, b, a;
-
- r = *( self->rgba[0] );
- g = *( self->rgba[1] );
- b = *( self->rgba[2] );
- a = *( self->rgba[3] );
-
- return PyString_FromFormat( "[%d, %d, %d, %d]", r, g, b, a );
-}
diff --git a/source/blender/python/api2_2x/charRGBA.h b/source/blender/python/api2_2x/charRGBA.h
deleted file mode 100644
index 9cc3dc739d1..00000000000
--- a/source/blender/python/api2_2x/charRGBA.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * $Id: charRGBA.h 10280 2007-03-16 14:44:31Z 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_charRGBA_H
-#define EXPP_charRGBA_H
-
-#include <Python.h>
-
-/* Objects of <type 'charRGBA'> are used inside other Blender Python
- * objects, so this header file must contain only 'public' declarations */
-/* there's also rgbTuple, for rgb floats and a color obj in NMesh, messy! */
-
-/* Python BPy_charRGBA structure definition: */
-
-typedef struct {
- PyObject_HEAD
- char *rgba[4]; /* array of four pointers to chars */
-
-} BPy_charRGBA;
-
-extern PyTypeObject charRGBA_Type;
-
-/*****************************************************************************/
-/* Python API function prototypes for the charRGBA helper module. */
-/*****************************************************************************/
-PyObject *charRGBA_New( char *rgba );
-PyObject *charRGBA_getCol( BPy_charRGBA * self );
-PyObject *charRGBA_setCol( BPy_charRGBA * self, PyObject * args );
-
-#endif /* EXPP_charRGBA_H */
diff --git a/source/blender/python/api2_2x/constant.c b/source/blender/python/api2_2x/constant.c
deleted file mode 100644
index 1034fbd616c..00000000000
--- a/source/blender/python/api2_2x/constant.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * $Id: constant.c 10778 2007-05-25 16:43:25Z 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, Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include "constant.h" /*This must come first */
-
-#include "gen_utils.h"
-#include "BLI_blenlib.h"
-
-PyTypeObject constant_Type;
-
-//------------------METHOD IMPLEMENTATIONS-----------------------------
-//------------------------constant.items()
-//Returns a list of key:value pairs like dict.items()
-PyObject* constant_items(BPy_constant *self)
-{
- return PyDict_Items(self->dict);
-}
-//------------------------constant.keys()
-//Returns a list of keys like dict.keys()
-PyObject* constant_keys(BPy_constant *self)
-{
- return PyDict_Keys(self->dict);
-}
-//------------------------constant.values()
-//Returns a list of values like dict.values()
-PyObject* constant_values(BPy_constant *self)
-{
- return PyDict_Values(self->dict);
-}
-//------------------ATTRIBUTE IMPLEMENTATION---------------------------
-//------------------TYPE_OBECT IMPLEMENTATION--------------------------
-//-----------------------(internal)
-//Creates a new constant object
-static PyObject *new_const(void)
-{
- BPy_constant *constant;
-
- constant = (BPy_constant *) PyObject_NEW(BPy_constant, &constant_Type);
- if(constant == NULL){
- return (EXPP_ReturnPyObjError(PyExc_MemoryError,
- "couldn't create constant object"));
- }
- if((constant->dict = PyDict_New()) == NULL){
- return (EXPP_ReturnPyObjError(PyExc_MemoryError,
- "couldn't create constant object's dictionary"));
- }
-
- return (PyObject *)constant;
-}
-//------------------------tp_doc
-//The __doc__ string for this object
-static char BPy_constant_doc[] = "This is an internal subobject of armature\
-designed to act as a Py_Bone dictionary.";
-
-//------------------------tp_methods
-//This contains a list of all methods the object contains
-static PyMethodDef BPy_constant_methods[] = {
- {"items", (PyCFunction) constant_items, METH_NOARGS,
- "() - Returns the key:value pairs from the dictionary"},
- {"keys", (PyCFunction) constant_keys, METH_NOARGS,
- "() - Returns the keys the dictionary"},
- {"values", (PyCFunction) constant_values, METH_NOARGS,
- "() - Returns the values from the dictionary"},
- {NULL, NULL, 0, NULL}
-};
-//------------------------mp_length
-static int constantLength(BPy_constant *self)
-{
- return 0;
-}
-//------------------------mp_subscript
-static PyObject *constantSubscript(BPy_constant *self, PyObject *key)
-{
- if(self->dict) {
- PyObject *v = PyDict_GetItem(self->dict, key);
- if(v) {
- return EXPP_incr_ret(v);
- }
- return EXPP_ReturnPyObjError( PyExc_KeyError,
- "key not found" );
- }
- return NULL;
-}
-//------------------------mp_ass_subscript
-static int constantAssSubscript(BPy_constant *self, PyObject *who, PyObject *cares)
-{
- return 0; /* no user assignments allowed */
-}
-//------------------------tp_getattro
-static PyObject *constant_getAttro(BPy_constant * self, PyObject *value)
-{
- if(self->dict) {
- PyObject *v;
- char *name = PyString_AS_STRING( value );
-
- if(!strcmp(name, "__members__"))
- return PyDict_Keys(self->dict);
-
-#if 0
- if(!strcmp(name, "__methods__") || !strcmp(name, "__dict__")) {
- return PyObject_GenericGetAttr( (PyObject *)self, value );
- }
-#endif
-
- v = PyDict_GetItemString(self->dict, name);
- if(v) {
- return EXPP_incr_ret(v); /* was a borrowed ref */
- }
- return PyObject_GenericGetAttr( (PyObject *)self, value );
- }
- return (EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "constant object lacks a dictionary"));
-}
-//------------------------tp_repr
-static PyObject *constant_repr(BPy_constant * self)
-{
- char str[4096];
- PyObject *key, *value, *tempstr;
- int pos = 0;
-
- BLI_strncpy(str,"[Constant: ",4096);
- tempstr = PyString_FromString("name");
- value = PyDict_GetItem( self->dict, tempstr );
- Py_DECREF(tempstr);
- if(value) {
- strcat(str, PyString_AsString(value));
- } else {
- short sep = 0;
- strcat(str,"{");
- while (PyDict_Next(self->dict, &pos, &key, &value)) {
- if( sep )
- strcat (str, ", ");
- else
- sep = 1;
- strcat (str, PyString_AsString(key));
- }
- strcat(str,"}");
- }
- strcat(str, "]");
- return PyString_FromString(str);
-}
-//------------------------tp_dealloc
-static void constant_dealloc(BPy_constant * self)
-{
- Py_DECREF(self->dict);
- PyObject_DEL(self);
-}
-
-//------------------TYPE_OBECT DEFINITION------------------------------
-static PyMappingMethods constantAsMapping = {
- (inquiry) constantLength, // mp_length
- (binaryfunc) constantSubscript, // mp_subscript
- (objobjargproc) constantAssSubscript, // mp_ass_subscript
-};
-
-PyTypeObject constant_Type = {
- PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "Constant", //tp_name
- sizeof(BPy_constant), //tp_basicsize
- 0, //tp_itemsize
- (destructor)constant_dealloc, //tp_dealloc
- 0, //tp_print
- 0, //tp_getattr
- 0, //tp_setattr
- 0, //tp_compare
- (reprfunc) constant_repr, //tp_repr
- 0, //tp_as_number
- 0, //tp_as_sequence
- &constantAsMapping, //tp_as_mapping
- 0, //tp_hash
- 0, //tp_call
- 0, //tp_str
- (getattrofunc)constant_getAttro, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
- BPy_constant_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- 0, //tp_richcompare
- 0, //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- BPy_constant_methods, //tp_methods
- 0, //tp_members
- 0, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- 0, //tp_init
- 0, //tp_alloc
- 0, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-//------------------VISIBLE PROTOTYPE IMPLEMENTATION-------------------
-//Creates a default empty constant
-PyObject *PyConstant_New(void)
-{
- return new_const();
-}
-//Inserts a key:value pair into the constant and then returns 0/1
-int PyConstant_Insert(BPy_constant *self, char *name, PyObject *value)
-{
- PyType_Ready( &constant_Type );
- return EXPP_dict_set_item_str(self->dict, name, value);
-}
-//This is a helper function for generating constants......
-PyObject *PyConstant_NewInt(char *name, int value)
-{
- PyObject *constant = PyConstant_New();
-
- if (constant)
- {
- PyConstant_Insert((BPy_constant*)constant, "name", PyString_FromString(name));
- PyConstant_Insert((BPy_constant*)constant, "value", PyInt_FromLong(value));
- }
- return constant;
-}
-//This is a helper function for generating constants......
-PyObject *PyConstant_NewString(char *name, char *value)
-{
- PyObject *constant = PyConstant_New();
-
- if (constant)
- {
- PyConstant_Insert((BPy_constant*)constant, "name", PyString_FromString(name));
- PyConstant_Insert((BPy_constant*)constant, "value", PyString_FromString(value));
- }
- return constant;
-}
diff --git a/source/blender/python/api2_2x/constant.h b/source/blender/python/api2_2x/constant.h
deleted file mode 100644
index 1e325cef012..00000000000
--- a/source/blender/python/api2_2x/constant.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * $Id: constant.h 7089 2006-03-18 15:23: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): Willian P. Germano, Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#ifndef EXPP_constant_H
-#define EXPP_constant_H
-
-#include <Python.h>
-
-/*-------------------TYPE CHECKS-------------------------------*/
-#define BPy_Constant_Check(v) ((v)->ob_type==&constant_Type)
-/*-------------------TYPEOBJECT--------------------------------*/
-extern PyTypeObject constant_Type;
-/*-------------------STRUCT DEFINITION-------------------------*/
-typedef struct {
- PyObject_HEAD
- PyObject * dict;
-} BPy_constant;
-/*-------------------VISIBLE PROTOTYPES-----------------------*/
-PyObject *PyConstant_New(void);
-int PyConstant_Insert(BPy_constant *self, char *name, PyObject *value);
-PyObject *PyConstant_NewInt(char *name, int value);
-PyObject *PyConstant_NewString(char *name, char *value);
-
-#endif /* EXPP_constant_H */
diff --git a/source/blender/python/api2_2x/doc/API_intro.py b/source/blender/python/api2_2x/doc/API_intro.py
deleted file mode 100644
index a630c47229e..00000000000
--- a/source/blender/python/api2_2x/doc/API_intro.py
+++ /dev/null
@@ -1,247 +0,0 @@
-# This is not a real module, it's simply an introductory text.
-
-"""
-The Blender Python API Reference
-================================
-
- An asterisk (*) means the module has been updated.
-
- for a full list of changes since 2.42 see U{http://mediawiki.blender.org/index.php/Release_Notes/Notes243/Python_API}
-
- Top Module:
- -----------
-
- - L{Blender}
- - L{bpy<Bpy>} (experimental)
-
- Submodules:
- -----------
- - L{Armature} (*)
- - L{NLA}
- - L{Action<NLA.Action>}
- - L{BezTriple} (*)
- - L{BGL}
- - L{Camera} (*)
- - L{Curve} (*)
- - L{Draw} (*)
- - L{Effect}
- - L{Geometry} (*)
- - L{Group} (*)
- - L{Image} (*)
- - L{Ipo} (*)
- - L{IpoCurve} (*)
- - L{Key} (*)
- - L{Lamp}
- - L{Lattice} (*)
- - L{Library} (*)
- - L{Material} (*)
- - L{Mathutils} (*)
- - L{Mesh} (*)
- - L{MeshPrimitives} (*)
- - L{Metaball} (*)
- - L{NMesh} (deprecated)
- - L{Noise}
- - L{Object} (*)
- - L{Modifier} (*)
- - L{Pose} (*)
- - L{Constraint} (*)
- - L{ActionStrips<NLA>} (*)
- - L{Registry}
- - L{Scene} (*)
- - L{Radio}
- - L{Render} (*)
- - L{Sound} (*)
- - L{Text}
- - L{Text3d}
- - L{Font}
- - L{Texture} (*)
- - L{TimeLine}
- - L{Types}
- - L{Window}
- - L{Theme} (*)
- - L{World}
- - L{sys<Sys>}
-
- Additional information:
- -----------------------
-
- - L{Special features<API_related>}:
- - scripts: registering in menus, documenting, configuring (new);
- - command line examples (new);
- - script links (*), space handler script links, Group module (new).
-
-Introduction:
-=============
-
- This reference documents the Blender Python API, a growing collection of
- Python modules (libraries) that give access to part of the program's internal
- data and functions.
-
- Through scripting Blender can be extended in real-time via
- U{Python <www.python.org>}, an impressive high level, multi-paradigm, open
- source language. Newcomers are recommended to start with the tutorial that
- comes with it.
-
- This opens many interesting possibilities, ranging from automating repetitive
- tasks to adding new functionality to the program: procedural models,
- importers and exporters, even complex applications and so on. Blender itself
- comes with some scripts, but many others can be found in the Scripts & Plugins
- sections and forum posts at the Blender-related sites listed below.
-
-Scripting and Blender:
-======================
-
-These are the basic ways to execute scripts in Blender:
-
- 1. They can be loaded or typed as text files in the Text Editor window, then
- executed with ALT+P.
- 2. Via command line: C{blender -P <scriptname>} will start Blender and execute
- the given script. <scriptname> can be a filename in the user's file system or
- the name of a text saved in a .blend Blender file:
- 'blender myfile.blend -P textname'.
- 3. Via command line in I{background mode}: use the '-b' flag (the order is
- important): C{blender -b <blendfile> -P <scriptname>}. <blendfile> can be any
- .blend file, including the default .B.blend that is in Blender's home directory
- L{Blender.Get}('homedir'). In this mode no window will be opened and the
- program will leave as soon as the script finishes execution.
- 4. Properly registered scripts can be selected directly from the program's
- menus.
- 5. Scriptlinks: these are also loaded or typed in the Text Editor window and
- can be linked to objects, materials or scenes using the Scriptlink buttons
- tab. Script links get executed automatically when their events (ONLOAD,
- REDRAW, FRAMECHANGED) are triggered. Normal scripts can create (L{Text}) and
- link other scripts to objects and events, see L{Object.Object.addScriptLink},
- for example.
- 6. A script can call another script (that will run in its own context, with
- its own global dictionary) with the L{Blender.Run} module function.
-
-
-Interaction with users:
------------------------
-
- Scripts can:
- - simply run and exit;
- - pop messages, menus and small number and text input boxes;
- - draw graphical user interfaces (GUIs) with OpenGL calls and native
- program buttons, which stay there accepting user input like any other
- Blender window until the user closes them;
- - attach themselves to a space's event or drawing code (aka space handlers,
- L{check here<API_related>});
- - make changes to the 3D View (set visible layer(s), view point, etc);
- - grab the main input event queue and process (or pass to Blender) selected
- keyboard, mouse, redraw events -- not considered good practice, but still
- available for private use;
- - tell Blender to execute other scripts (see L{Blender.Run}());
- - use external Python libraries, if available.
-
- You can read the documentation for the L{Window}, L{Draw} and L{BGL} modules
- for more information and also check the Python site for external modules that
- might be useful to you. Note though that any imported module will become a
- requirement of your script, since Blender itself does not bundle external
- modules.
-
-Command line mode:
-------------------
-
- Python was embedded in Blender, so to access BPython modules you need to
- run scripts from the program itself: you can't import the Blender module
- into an external Python interpreter.
-
- On the other hand, for many tasks it's possible to control Blender via
- some automated process using scripts. Interested readers should learn about
- features like "OnLoad" script links, the "-b <blendfile>" (background mode)
- and "-P <script>" (run script) command line options and API calls like
- L{Blender.Save}, L{Blender.Load}, L{Blender.Quit} and the L{Library} and
- L{Render} modules.
-
- Note that command line scripts are run before Blender initializes its windows
- (and in '-b' mode no window will be initialized), so many functions that get
- or set window related attributes (like most in L{Window}) don't work here. If
- you need those, use an ONLOAD script link (see L{Scene.Scene.addScriptLink})
- instead -- it's also possible to use a command line script to write or set an
- ONLOAD script link. Check the L{Blender.mode} module var to know if Blender
- is being executed in "background" or "interactive" mode.
-
- L{Click here for command line and background mode examples<API_related>}.
-
-
-Demo mode:
-----------
-
- Blender has a demo mode, where once started it can work without user
- intervention, "showing itself off". Demos can render stills and animations,
- play rendered or real-time animations, calculate radiosity simulations and
- do many other nifty things. If you want to turn a .blend file into a demo,
- write a script to run the show and link it as a scene "OnLoad" scriptlink.
- The demo will then be played automatically whenever this .blend file is
- opened, B{unless Blender was started with the "-y" parameter}.
-
-The Game Engine API:
---------------------
-
- Blender has a game engine for users to create and play 3d games. This
- engine lets programmers add scripts to improve game AI, control, etc, making
- more complex interaction and tricks possible. The game engine API is
- separate from the Blender Python API this document references and you can
- find its own ref doc in the doc section of the main sites below.
-
-Blender Data Structures:
-------------------------
-
- Programs manipulate data structures. Blender python scripts are no exception.
- Blender uses an Object Oriented architecture. The BPython interface tries to
- present Blender objects and their attributes in the same way you see them
- through the User Interface (the GUI). One key to BPython programming is
- understanding the information presented in Blender's OOPS window where Blender
- objects and their relationships are displayed.
-
- Each Blender graphic element (Mesh, Lamp, Curve, etc.) is composed from two
- parts: an Object and ObData. The Object holds information about the position,
- rotation and size of the element. This is information that all elements have
- in common. The ObData holds information specific to that particular type of
- element.
-
- Each Object has a link to its associated ObData. A single ObData may be
- shared by many Objects. A graphic element also has a link to a list of
- Materials. By default, this list is associated with the ObData.
-
- All Blender objects have a unique name. However, the name is qualified by the
- type of the object. This means you can have a Lamp Object called Lamp.001
- (OB:Lamp.001) and a Lamp ObData called Lamp.001 (LA:Lamp.001).
-
- For a more in-depth look at Blender internals, and some understanding of why
- Blender works the way it does, see the U{Blender Architecture document
- <http://www.blender3d.org/cms/Blender_Architecture.336.0.html>}.
-
-
-A note to newbie script writers:
---------------------------------
-
- Interpreted languages are known to be much slower than compiled code, but for
- many applications the difference is negligible or acceptable. Also, with
- profiling (or even simple direct timing with L{Blender.sys.time<Sys.time>}) to
- identify slow areas and well thought optimizations, the speed can be
- I{considerably} improved in many cases. Try some of the best BPython scripts
- to get an idea of what can be done, you may be surprised.
-
-@author: The Blender Python Team
-@requires: Blender 2.43 or newer.
-@version: 2.43
-@see: U{www.blender3d.org<http://www.blender3d.org>}: main site
-@see: U{www.blender.org<http://www.blender.org>}: documentation and forum
-@see: U{blenderartists.org<http://blenderartists.org>}: user forum
-@see: U{projects.blender.org<http://projects.blender.org>}
-@see: U{blender architecture<http://www.blender3d.org/cms/Blender_Architecture.336.0.html>}: blender architecture document
-@see: U{www.python.org<http://www.python.org>}
-@see: U{www.python.org/doc<http://www.python.org/doc>}
-@see: U{Blending into Python<en.wikibooks.org/wiki/Blender_3D:_Blending_Into_Python>}: User contributed documentation, featuring a blender/python cookbook with many examples.
-
-@note: the official version of this reference guide is only updated for each
- new Blender release. But you can build the current CVS
- version yourself: install epydoc, grab all files in the
- source/blender/python/api2_2x/doc/ folder of Blender's CVS and use the
- epy_docgen.sh script also found there to generate the html docs.
- Naturally you will also need a recent Blender binary to try the new
- features. If you prefer not to compile it yourself, there is a testing
- builds forum at U{blender.org<http://www.blender.org>}.
-"""
diff --git a/source/blender/python/api2_2x/doc/API_related.py b/source/blender/python/api2_2x/doc/API_related.py
deleted file mode 100644
index 87b29e7f524..00000000000
--- a/source/blender/python/api2_2x/doc/API_related.py
+++ /dev/null
@@ -1,564 +0,0 @@
-# This is not a real module, it's simply an introductory text.
-
-"""
-Blender Python related features
-===============================
-
- L{Back to Main Page<API_intro>}
-
-
-Introduction:
-=============
-
- This page describes special features available to BPython scripts:
-
- - Command line mode is accessible with the '-P' and '-b' Blender options.
- - Registration allows scripts to become available from some pre-defined menus
- in Blender, like Import, Export, Wizards and so on.
- - Script links are Blender Texts (scripts) executed when a particular event
- (redraws, .blend file loading, saving, frame changed, etc.) occurs. Now
- there are also "Space Handlers" to draw onto or get events from a given
- space (only 3D View now) in some window.
- - Proper documentation data is used by the 'Scripts Help Browser' script to
- show help information for any registered script. Your own GUI can use
- this facility with the L{Blender.ShowHelp} function.
- - Configuration is for data in your script that can be tweaked according to
- user taste or needs. Like documentation, this is another helper
- functionality -- you don't need to provide a GUI yourself to edit config
- data.
-
-
- Command line usage:
- ===================
-
- Specifying scripts:
- -------------------
-
- The '-P' option followed either by:
- - a script filename (full pathname if not in the same folder where you run
- the command);
- - the name of a Text in a .blend file (that must also be specified)
- will open Blender and immediately run the given script.
-
- Example::
-
- # open Blender and execute the given script:
- blender -P script.py
-
- Passing parameters:
- -------------------
-
- To pass parameters to the script you can:
- - write them to a file before running Blender, then make your script parse that file;
- - set environment variables and access them with the 'os' module:
-
- Examples with parameters being passed to the script via command line::
-
- # execute a command like:
-
- myvar=value blender -P script.py
-
- # and in script.py access myvar with os.getenv
- # (os.environ and os.setenv are also useful):
-
- # script.py:
- import os
- val = os.getenv('myvar')
-
- # To pass multiple parameters, simply write them in sequence,
- # separated by spaces:
-
- myvar1=value1 myvar2=value2 mystr="some string data" blender -P script.py
-
- Background mode:
- ----------------
-
- In '-b' mode no windows will be opened: the program will run as a command
- line tool able to render stills and animations and execute any working Python
- script with complete access to loaded .blend's file contents. Once the task
- is completed, the program will exit.
-
- Background mode examples::
-
- # Open Blender in background mode with file 'myfile.blend'
- # and run the script 'script.py':
-
- blender -b myfile.blend -P script.py
-
- # Note: a .blend file is always required. 'script.py' can be a file
- # in the file system or a Blender Text stored in 'myfile.blend'.
-
- # Let's assume 'script.py' has code to render the current frame;
- # this line will set the [s]tart and [e]nd (and so the current) frame to
- # frame 44 and call the script:
-
- blender -b myfile.blend -s 44 -e 44 -P script.py
-
- # Using now a script written to render animations, we set different
- # start and end frames and then execute this line:
-
- blender -b myfile.blend -s 1 -e 10 -P script.py
-
- # Note: we can also set frames and define if we want a single image or
- # an animation in the script body itself, naturally.
-
- The rendered pictures will be written to the default render folder, that can
- also be set via BPython (take a look at L{Render.RenderData}). Their
- names will be the equivalent frame number followed by the extension of the
- chosen image type: 0001.png, for example. To rename them to something else,
- coders can use the C{rename} function in the standard 'os' Python module.
-
- Reminder: if you just need to render, it's not necessary to have a script.
- Blender can create stills and animations with its own command line arguments.
- Example:
- - a single image at frame 44: blender -b myfile.blend -f 44
- - an animation from frame 1 to 10: blender -b myfile.blend -s 1 -e 10 -a
-
-
- Script links:
- =============
-
- Object script links:
- --------------------
-
- Users can link Blender Text scripts and objects to have the script
- code executed when specific events occur to the objects. For example, if a
- Camera has an script link set to "FrameChanged", the script will be executed
- whenever the current frame is changed. Links can either be manually added by
- users on the Buttons window -> Scripts tab or created by another script (see,
- for example, L{Object.addScriptLink<Object.Object.addScriptLink>}).
-
- These are the types which can be linked to scripts:
- - Camera Data;
- - Lamp Data;
- - Materials;
- - Objects;
- - Scenes;
- - Worlds.
-
- And these are the available event choices:
- - Redraw;
- - FrameChanged;
- - Render;
- - OnLoad (*);
- - OnSave (*).
-
- (*) only available for scenes
-
- There are three L{Blender} module variables that script link authors should
- be aware of:
- - B{bylink}: True if the script is running as a script link;
- - B{link}: the object the running script was linked to (None if this is
- not a script link);
- - B{event}: the event type, if the running script is being executed as a
- script link.
-
- Example::
- #script link
- import Blender
- if Blender.bylink: # we're running as a script link
- print "Event: %s for %s" % (Blender.event, Blender.link)
-
- B{Important note about "Render" events}:
-
- Each "Render" script link is executed twice: before rendering and after, for
- reverting changes and for possible clean up actions. Before rendering,
- 'Blender.event' will be "Render" and after rendering it will be "PostRender".
-
- Example::
- # render script link
- import Blender
- event = Blender.event
- if event == "Render":
- # prepare for rendering
- create_my_very_detailed_mesh_data()
- elif event == "PostRender":
- # done rendering, clean up
- delete_my_very_detailed_mesh_data()
-
- As suggested by the example above, this is especially useful for script links
- that need to generate data only useful while rendering, or in case they need
- to switch between two mesh data objects, one meant for realtime display and
- the other, more detailed, for renders.
-
- Space Handler script links:
- ---------------------------
-
- This is a new kind of script linked to spaces in a given window. Right now
- only the 3D View has the necessary hooks, but the plan is to add access to
- other types, too. Just to clarify naming conventions: in Blender, a screen
- is partitioned in windows (also called areas) and each window can show any
- space. Spaces are: 3D View, Text Editor, Scripts, Buttons, User Preferences,
- Oops, etc.
-
- Space handlers are texts in the Text Editor, like other script links, but they
- need to have a special header to be recognized -- B{I{the first line in the
- text file}} must inform:
- 1. that they are space handlers;
- 2. the space they belong to;
- 3. whether they are EVENT or DRAW handlers.
-
- Example header for a 3D View EVENT handler::
-
- # SPACEHANDLER.VIEW3D.EVENT
-
- Example header for a 3D View DRAW handler::
-
- # SPACEHANDLER.VIEW3D.DRAW
-
- Available space handlers can be toggled "on" or "off" in the space header's
- B{View->Space Handler Scripts} submenu, by the user.
-
- EVENT space handler scripts are called by that space's event handling callback
- in Blender. The script receives the event B{before} it is further processed
- by the program. An EVENT handler script should check Blender.event (compare
- it against L{Draw} events) and either:
- - process it (the script must set Blender.event to None then);
- - ignore it.
-
- Setting C{Blender.event = None} tells Blender not to go on processing itself
- the event, because it was grabbed by the script.
-
- Example::
-
- # SPACEHANDLER.VIEW3D.EVENT
-
- import Blender
- from Blender import Draw
- evt = Blender.event
- return_it = False
-
- if evt == Draw.LEFTMOUSE:
- print "Swallowing the left mouse button press"
- elif evt == Draw.AKEY:
- print "Swallowing an 'a' character"
- else:
- print "Let the 3D View itself process this event:", evt
- return_it = True
-
- # if Blender should not process itself the passed event:
- if not return_it: Blender.event = None
-
- DRAW space handlers are called by that space's drawing callback in Blender.
- The script is called B{after} the space has been drawn.
-
- Two of the L{Blender} module variables related to script links assume
- different roles for space handlers:
- - B{bylink} is the same: True if the script is running as a script link;
- - B{link}: integer from the L{Blender}.SpaceHandlers constant dictionary,
- tells what space this handler belongs to and the handler's type
- (EVENT, DRAW);
- - B{event}:
- - EVENT handlers: an input event (check keys and mouse events in L{Draw})
- to be processed or ignored.
- - DRAW handlers: 0 always.
-
- B{Guidelines (important)}:
- - EVENT handlers can access and change Blender objects just like any other
- script, but they should not draw to the screen, B{use a DRAW handler to do
- that}. Specifically: L{Draw.Image} and the L{BGL} drawing functions
- should not be used inside an EVENT handler.
- - DRAW handlers should leave the space in the same state it was before they
- were executed. OpenGL attributes and the modelview and projection matrices
- are automatically saved (pushed) before a DRAW handler runs and restored
- (popped) after it finishes, no need to worry about that. Draw handlers
- should not grab events;
- - If script handlers need to pass information to each other (for example an
- EVENT handler passing info to a DRAW handler), use the L{Registry} module.
- - in short: use the event handler to deal with events and the draw handler to
- draw and your script will be following the recommended practices for
- Blender code.
-
- Registering scripts:
- ====================
-
- To be registered a script needs two things:
- - to be either in the default scripts directory or in the user defined scripts
- path (see User Preferences window -> File Paths tab -> Python path);
- - to have a proper header.
-
- Try 'blender -d' to know where your default directory for scripts is, it will
- inform either the directory or the file with that info already parsed, which is
- in the same directory of the scripts folder.
-
- The header should be like this one (all double and single apostrophes below
- are required)::
- #!BPY
-
- # \"\"\"
- # Name: 'Script Name'
- # Blender: 233
- # Group: 'Export'
- # Submenu: 'All' all
- # Submenu: 'Selected' sel
- # Submenu: 'Configure (gui)' gui
- # Tooltip: 'Export to some format.'
- # \"\"\"
-
- where:
- - B{Name} is the string that will appear in the menu;
- - B{Blender} is the minimum program version required to run the script;
- - B{Group} defines where the script will be put, see all groups in the
- Scripts Window's header, menu "Scripts";
- - B{Submenu} adds optional submenus for further control;
- - B{Tooltip} is the (short) tooltip string for the menu entry.
-
- note:
- - all double and single apostrophes above are required;
- - you can "comment out" the header above, by starting lines with
- '#', like we did. This is not required (except for the first line, #!BPY,
- of course), but this way the header won't conflict with Python tools that
- you can use to generate documentation for your script code. Just
- remember to keep this header above any other line with triple
- double-quotes (\"\"\") in your script.
-
- Submenu lines are not required, use them if you want to provide extra
- options. To see which submenu the user chose, check the "__script__"
- dictionary in your code: __script__['arg'] has the defined keyword (the word
- after the submenu string name: all, sel or gui in the example above) of the
- chosen submenu. For example, if the user clicked on submenu 'Selected' above,
- __script__['arg'] will be "sel".
-
- If your script requires extra data or configuration files, there is a special
- folder where they can be saved: see 'datadir' in L{Blender.Get}.
-
-
- Documenting scripts:
- ====================
-
- The "Scripts Help Browser" script in the Help menu can parse special variables
- from registered scripts and display help information for users. For that,
- authors only need to add proper information to their scripts, after the
- registration header.
-
- The expected variables:
-
- - __bpydoc__ (or __doc__) (type: string):
- - The main help text. Write a first short paragraph explaining what the
- script does, then add the rest of the help text, leaving a blank line
- between each new paragraph. To force line breaks you can use <br> tags.
-
- - __author__ (type: string or list of strings):
- - Author name(s).
-
- - __version__ (type: string):
- - Script version. A good recommendation is using a version number followed
- by the date in the format YYYY/MM/DD: "1.0 2005/12/31".
-
- - __url__ (type: string or list of strings):
- - Internet links that are shown as buttons in the help screen. Clicking
- them opens the user's default browser at the specified location. The
- expected format for each url entry is e.g.
- "Author's site, http://www.somewhere.com". The first part, before the
- comma (','), is used as the button's tooltip. There are two preset
- options: "blender" and "elysiun", which link to the Python forums at
- blender.org and elysiun.com, respectively.
-
- - __email__ (optional, type: string or list of strings):
- - Equivalent to __url__, but opens the user's default email client. You
- can write the email as someone:somewhere*com and the help script will
- substitute accordingly: someone@somewhere.com. This is only a minor help
- to hide emails from spammers, since your script may be available at some
- site. "scripts" is the available preset, with the email address of the
- mailing list devoted to scripting in Blender, bf-scripts-dev@blender.org.
- You should only use this one if you are subscribed to the list:
- http://projects.blender.org/mailman/listinfo/bf-scripts-dev for more
- information.
-
- Example::
- __author__ = 'Mr. Author'
- __version__ = '1.0 2005/01/01'
- __url__ = ["Author's site, http://somewhere.com",
- "Support forum, http://somewhere.com/forum/", "blender", "elysiun"]
- __email__ = ["Mr. Author, mrauthor:somewhere*com", "scripts"]
- __bpydoc__ = \"\"\"\\
- This script does this and that.
-
- Explaining better, this script helps you create ...
-
- You can write as many paragraphs as needed.
-
- Shortcuts:<br>
- Esc or Q: quit.<br>
- etc.
-
- Supported:<br>
- Meshes, metaballs.
-
- Known issues:<br>
- This is just an example, there's no actual script.
-
- Notes:<br>
- You can check scripts bundled with Blender to see more examples of how to
- add documentation to your own works.
- \"\"\"
-
- B{Note}: your own GUI or menu code can display documentation by calling the
- help browser with the L{Blender.ShowHelp} function.
-
- Configuring scripts:
- ====================
-
- The L{Blender.Registry<Registry>} module provides a simplified way to keep
- scripts configuration options in memory and also saved in config files.
- And with the "Scripts Config Editor" script in the System menu users can later
- view and edit the options easily.
-
- Let's first clarify what we mean by config options: they are simple data
- (bools, ints, floats, strings) used by programs to conform to user
- preferences. The buttons in Blender's User Preferences window are a good
- example.
-
- For example, a particular exporter might include:
- - SEPARATE_MATS = False: a bool variable (True / False) to determine if it
- should write materials to a separate file;
- - VERSION = 2: an int to define an specific version of the export format;
- - TEX_DIR = "/path/to/textures": a default texture dir to prepend to all
- exported texture filenames instead of their actual paths.
-
- The script needs to provide users a GUI to configure these options -- or else
- directly editing the source code would be the only way to change them. And to
- store changes made to the GUI so they can be reloaded any time the script is
- executed, programmers have to write and load their own config files (ideally at
- L{Blender.Get}('udatadir') or, if not available, L{Blender.Get}('datadir')).
-
- This section describes BPython facilities (based on the L{Registry} module and
- the config editor) that can take care of this in a simplified (and much
- recommended) way.
-
- Here's how it works::
-
- # sample_exporter.py
- import Blender
- from Blender import Registry
-
- # First define all config variables with their default values:
- SEPARATE_MATERIALS = True
- VERSION = True
- TEX_DIR = ''
- EXPORT_DIR = ''
-
- # Then define a function to update the Registry:
- def registry_update():
- # populate a dict with current config values:
- d = {
- 'SEPARATE_MATERIALS': SEPARATE_MATERIALS,
- 'VERSION': VERSION,
- 'TEX_DIR': TEX_DIR,
- 'EXPORT_DIR': EXPORT_DIR
- }
- # store the key (optional 3rd arg tells if
- # the data should also be written to a file):
- Registry.SetKey('sample_exporter', d, True)
-
- # (A good convention is to use the script name as Registry key)
-
- # Now we check if our key is available in the Registry or file system:
- regdict = Registry.GetKey('sample_exporter', True)
-
- # If this key already exists, update config variables with its values:
- if regdict:
- try:
- SEPARATE_MATERIALS = regdict['SEPARATE_MATERIALS']
- VERSION = regdict['VERSION']
- TEX_DIR = regdict['TEX_DIR']
- EXPORT_DIR = regdict['EXPORT_DIR']
-
- # if data was corrupted (or a new version of the script changed
- # (expanded, removed, renamed) the config vars and users may have
- # the old config file around):
- except: update_registry() # rewrite it
-
- else: # if the key doesn't exist yet, use our function to create it:
- update_registry()
-
- # ...
-
- Hint: nicer code than the simplistic example above can be written by keeping
- config var names in a list of strings and using the exec function.
-
- B{Note}: if your script's GUI lets users change config vars, call the
- registry_update() function in the button events callback to save the changes.
- On the other hand, you don't need to handle configuration
- in your own gui, it can be left for the 'Scripts Config Editor',
- which should have access to your script's config key as soon as the
- above code is executed once (as soon as SetKey is executed).
-
- B{Note} (limits for config vars): strings longer than 300 characters are
- clamped and the number of items in dictionaries, sequences and the config key
- itself is limited to 60.
-
-
- Scripts Configuration Editor:
- -----------------------------
-
- This script should be available from the System menu in the Scripts window.
- It provides a GUI to view and edit saved configuration data, both from the
- Registry dictionary in memory and the scripts config data dir. This is
- useful for all scripts with config vars, but especially for those without GUIs,
- like most importers and exporters, since this editor will provide one for them.
-
- The example above already gives a good idea of how the information can be
- prepared to be accessible from this editor, but there is more worth knowing:
-
- 1. String vars that end with '_dir' or '_file' (can be upper case, too) are
- recognized as input boxes for dirs or files and a 'browse' button is added to
- their right side, to call the file selector.
-
- 2. Both key names and configuration variables names starting with an
- underscore ('_') are ignored by the editor. Programmers can use this feature
- for any key or config var that is not meant to be configured by this editor.
-
- 3. The following information refers to extra config variables that may be
- added specifically to aid the configuration editor script. To clarify, in the
- example code above these variables (the string 'script' and the dictionaries
- 'tooltips' and 'limits') would appear along with SEPARATE_MATERIALS, VERSION,
- TEX_DIR and EXPORT_DIR, wherever they are written.
-
- Minor note: these names are case insensitive: tooltips, TOOLTIPS, etc. are all
- recognized.
-
- 3.1 The config editor will try to display a 'help' button for a key, to show
- documentation for the script that owns it. To find this "owner script", it
- will first look for a config variable called 'script', a string containing
- the name of the owner Python file (with or without '.py' extension)::
-
- script = 'sample_exporter.py'
-
- If there is no such variable, the editor will check if the file formed by the
- key name and the '.py' extension exists. If both alternatives fail, no help
- button will be displayed.
-
- 3.2 You can define tooltips for the buttons that the editor creates for your
- config data (string input, toggle, number sliders). Simply create a dict
- called 'tooltips', where config var names are keys and their tooltips,
- values::
-
- tooltips = {
- 'EXPORT_DIR': 'default folder where exported files should be saved',
- 'VERBOSE': 'print info and warning messages to the console',
- 'SEPARATE_MATERIALS': 'write materials to their own file'
- }
-
- 3.3 Int and float button sliders need min and max limits. This can be passed
- to the editor via a dict called 'limits' (ivar1, ivar2 and fvar are meant as
- extra config vars that might have been in the example code above)::
-
- limits = {'ivar1': [-10, 10], 'ivar2': [0, 100], 'fvar1': [-12.3, 15.4]}
-
- 4. The Config Editor itself maintains a Registry key called "General", with
- general options relevant to many scripts, like "verbose" to tell if the user
- wants messages printed to the console and "confirm overwrite", to know if
- a script should ask for confirmation before overwriting files (all exporters
- are recommended to access the General key and check this var -- L{sys.exists
- <Sys.exists>} tells if files or folders already exist).
-
- Hint: for actual examples, try the ac3d importer and exporter (it's enough to
- call them from the menus then cancel with ESC), as those have been updated to
- use this config system. After calling them their config data will be available
- in the Config Editor. We also recommend adding a section about config vars
- in your script's help info, as done in the ac3d ones.
-
- L{Back to Main Page<API_intro>}
- ===============================
-"""
diff --git a/source/blender/python/api2_2x/doc/Armature.py b/source/blender/python/api2_2x/doc/Armature.py
deleted file mode 100644
index 0dbaf28d6f8..00000000000
--- a/source/blender/python/api2_2x/doc/Armature.py
+++ /dev/null
@@ -1,368 +0,0 @@
-# Blender.Armature module and the Armature PyType object
-
-"""
-The Blender.Armature submodule.
-
-Armature
-========
-
-This module provides access to B{Armature} objects in Blender. These are
-"skeletons", used to deform and animate other objects -- meshes, for
-example.
-
-Example::
- import Blender
- from Blender import Armature
- from Blender.Mathutils import *
- #
- arms = Armature.Get()
- for arm in arms.values():
- arm.drawType = Armature.STICK #set the draw type
- arm.makeEditable() #enter editmode
-
- #generating new editbone
- eb = Armature.Editbone()
- eb.roll = 10
- eb.parent = arm.bones['Bone.003']
- eb.head = Vector(1,1,1)
- eb.tail = Vector(0,0,1)
- eb.options = [Armature.HINGE, Armature.CONNECTED]
-
- #add the bone
- arm.bones['myNewBone'] = eb
-
- #delete an old bone
- del arm.bones['Bone.002']
-
- arm.update() #save changes
-
- for bone in arm.bones.values():
- #print bone.matrix['ARMATURESPACE']
- print bone.parent, bone.name
- print bone.children, bone.name
- print bone.options, bone.name
-
-
-Example::
- # Adds empties for every bone in the selected armature, an example of getting worldspace locations for bones.
- from Blender import *
- def test_arm():
- scn= Scene.GetCurrent()
- arm_ob= scn.objects.active
-
- if not arm_ob or arm_ob.type != 'Armature':
- Draw.PupMenu('not an armature object')
- return
-
- # Deselect all
- for ob in scn.objects:
- if ob != arm_ob:
- ob.sel= 0
-
- arm_mat= arm_ob.matrixWorld
-
- arm_data= arm_ob.getData()
-
- bones= arm_data.bones.values()
- for bone in bones:
- bone_mat= bone.matrix['ARMATURESPACE']
- bone_mat_world= bone_mat*arm_mat
-
- ob_empty= scn.objects.new('Empty')
- ob_empty.setMatrix(bone_mat_world)
-
- test_arm()
-
-@var CONNECTED: Connect this bone to parent
-@type CONNECTED: Constant
-@var HINGE: Don't inherit rotation or scale from parent
-@type HINGE: Constant
-@var NO_DEFORM: If bone will not deform geometry
-@type NO_DEFORM: Constant
-@var MULTIPLY: Multiply bone with vertex group
-@type MULTIPLY: Constant
-@var HIDDEN_EDIT: Bone is hidden in editmode
-@type HIDDEN_EDIT: Constant
-@var ROOT_SELECTED: Root of the Bone is selected
-@type ROOT_SELECTED: Constant
-@var BONE_SELECTED: Bone is selected
-@type BONE_SELECTED: Constant
-@var TIP_SELECTED: Tip of the Bone is selected
-@type TIP_SELECTED: Constant
-@var OCTAHEDRON: Bones drawn as octahedrons
-@type OCTAHEDRON: Constant
-@var STICK: Bones drawn as a line
-@type STICK: Constant
-@var BBONE: Bones draw as a segmented B-spline
-@type BBONE: Constant
-@var ENVELOPE: Bones draw as a stick with envelope influence
-@type ENVELOPE: Constant
-"""
-
-def Get (name = None):
- """
- Get the Armature object(s) from Blender.
- @type name: string, nothing, or list of strings
- @param name: The string name of an armature.
- @rtype: Blender Armature or a list of Blender Armatures
- @return: It depends on the I{name} parameter:
- - (name): The Armature object with the given I{name};
- - (name, name, ...): A list of Armature objects
- - (): A list with all Armature objects in the current scene.
- @warning: In versions 2.42 and earlier, a string argument for an armature
- that doesn't exist will return None. Later versions raise a Value error.
- """
-
-def New (name = None):
- """
- Return a new armature.
- @type name: string or nothing
- @param name: The string name of the new armature.
- @rtype: Blender Armature.
- @return: A new armature.
- """
-
-class Armature:
- """
- The Armature object
- ===================
- This object gives access to Armature-specific data in Blender.
- @ivar bones: A Dictionary of Bones (BonesDict) that make up this armature.
- @type bones: BonesDict Object
- @ivar vertexGroups: Whether vertex groups define deformation
- @type vertexGroups: Bool
- @ivar envelopes: Whether bone envelopes define deformation
- @type envelopes: Bool
- @ivar restPosition: Show rest position (no posing possible)
- @type restPosition: Bool
- @ivar delayDeform: Don't deform children when manipulating bones
- @type delayDeform: Bool
- @ivar drawAxes: Draw bone axes
- @type drawAxes: Bool
- @ivar drawNames: Draw bone names
- @type drawNames: Bool
- @ivar ghost: Draw ghosts around frame for current Action
- @type ghost: Bool
- @ivar ghostStep: Number of frames between ghosts
- @type ghostStep: Int
- @ivar drawType: The drawing type that is used to display the armature
- Acceptable values are:
- - Armature.OCTAHEDRON: bones drawn as octahedrons
- - Armature.STICK: bones drawn as sticks
- - Armature.BBONE: bones drawn as b-bones
- - Armature.ENVELOPE: bones drawn as sticks with envelopes
- @type drawType: Constant Object
- @ivar mirrorEdit: X-axis mirrored editing
- @type mirrorEdit: Bool
- @ivar autoIK: Adds temporary IK chains while grabbing bones
- @type autoIK: Bool
- @ivar layerMask: Layer bitmask
- Example::
- # set armature to layers 14 and 16
- armature.layerMask = (1<<13) + (1<<15)
- @type layerMask: Int
- """
-
- def __init__(name = 'myArmature'):
- """
- Initializer for the Armature TypeObject.
- Example::
- myNewArmature = Blender.Armature.Armature('AR_1')
- @param name: The name for the new armature
- @type name: string
- @return: New Armature Object
- @rtype: Armature Object
- """
-
- def makeEditable():
- """
- Put the armature into EditMode for editing purposes. (Enters Editmode)
- @warning: Using Window.Editmode() to switch the editmode manually will cause problems and possibly even crash Blender.
- @warning: This is only needed for operations such as adding and removing bones.
- @warning: Do access pose data until you have called update() or settings will be lost.
- @warning: The armature should not be in manual editmode
- prior to calling this method. The armature must be parented
- to an object prior to editing.
- @rtype: None
- """
-
- def update():
- """
- Save all changes and update the armature. (Leaves Editmode)
- @note: Must have called makeEditable() first.
- @rtype: None
- """
-
-import id_generics
-Armature.__doc__ += id_generics.attributes
-
-class BonesDict:
- """
- The BonesDict object
- ====================
- This object gives gives dictionary like access to the bones in an armature.
- It is internal to blender but is called as 'Armature.bones'
-
- Removing a bone:
- Example::
- del myArmature.bones['bone_name']
- Adding a bone:
- Example::
- myEditBone = Armature.Editbone()
- myArmature.bones['bone_name'] = myEditBone
- """
-
- def items():
- """
- Return the key, value pairs in this dictionary
- @rtype: string, BPy_bone
- @return: All strings, and py_bones in the armature (in that order)
- """
-
- def keys():
- """
- Return the keys in this dictionary
- @rtype: string
- @return: All strings representing the bone names
- """
-
- def values():
- """
- Return the values in this dictionary
- @rtype: BPy_bone
- @return: All BPy_bones in this dictionary
- """
-
-class Bone:
- """
- The Bone object
- ===============
- This object gives access to Bone-specific data in Blender. This object
- cannot be instantiated but is returned by BonesDict when the armature is not in editmode.
- @ivar name: The name of this Bone.
- @type name: String
- @ivar roll: This Bone's roll value.
- Keys are:
- - 'ARMATURESPACE' - this roll in relation to the armature
- - 'BONESPACE' - the roll in relation to itself
- @type roll: Dictionary
- @ivar head: This Bone's "head" ending position when in rest state.
- Keys are:
- - 'ARMATURESPACE' - this head position in relation to the armature
- - 'BONESPACE' - the head position in relation to itself.
- @type head: Dictionary
- @ivar tail: This Bone's "tail" ending position when in rest state.
- Keys are:
- - 'ARMATURESPACE' - this tail position in relation to the armature
- - 'BONESPACE' - the tail position in relation to itself
- @type tail: Dictionary
- @ivar matrix: This Bone's matrix. This cannot be set.
- Keys are:
- - 'ARMATURESPACE' - this matrix of the bone in relation to the armature
- - 'BONESPACE' - the matrix of the bone in relation to itself
- @type matrix: Matrix Object
- @ivar parent: The parent Bone.
- @type parent: Bone Object
- @ivar children: The children directly attached to this bone.
- @type children: List of Bone Objects
- @ivar weight: The bone's weight.
- @type weight: Float
- @ivar options: Various bone options which can be:
- - Armature.CONNECTED: IK to parent
- - Armature.HINGE: No parent rotation or scaling
- - Armature.NO_DEFORM: The bone does not deform geometry
- - Armature.MULTIPLY: Multiply vgroups by envelope
- - Armature.HIDDEN_EDIT: Hide bones in editmode
- - Armature.ROOT_SELECTED: Selection of root ball of bone
- - Armature.BONE_SELECTED: Selection of bone
- - Armature.TIP_SELECTED: Selection of tip ball of bone
- @type options: List of Constants
- @ivar subdivision: The number of bone subdivisions.
- @type subdivision: Int
- @ivar deformDist: The deform distance of the bone
- @type deformDist: Float
- @ivar length: The length of the bone. This cannot be set.
- @type length: Float
- @ivar headRadius: The radius of this bones head (used for envalope bones)
- @type headRadius: Float
- @ivar tailRadius: The radius of this bones head (used for envalope bones)
- @type tailRadius: Float
- @ivar layerMask: Layer bitmask
- Example::
- # set bone to layers 14 and 16
- bone.layerMask = (1<<13) + (1<<15)
- @type layerMask: Int
- """
-
- def hasParent():
- """
- Whether or not this bone has a parent
- @rtype: Bool
- """
-
- def hasChildren():
- """
- Whether or not this bone has children
- @rtype: Bool
- """
-
- def getAllChildren():
- """
- Gets all the children under this bone including the children's children.
- @rtype: List of Bone object
- @return: all bones under this one
- """
-
-class Editbone:
- """
- The Editbone Object
- ===================
- This object is a wrapper for editbone data and is used only in the manipulation
- of the armature in editmode.
- @ivar name: The name of this Bone.
- @type name: String
- @ivar roll: This Bone's roll value (armaturespace).
- @type roll: Float
- @ivar head: This Bone's "head" ending position when in rest state (armaturespace).
- @type head: Vector Object
- @ivar tail: This Bone's "tail" ending position when in rest state (armaturespace).
- @type tail: Vector Object
- @ivar matrix: This Bone's matrix. (armaturespace)
- @type matrix: Matrix Object
- @ivar parent: The parent Bone.
- @type parent: Editbone Object
- @ivar weight: The bone's weight.
- @type weight: Float
- @ivar options: Various bone options which can be:
- - Armature.CONNECTED: IK to parent
- - Armature.HINGE: No parent rotation or scaling
- - Armature.NO_DEFORM: The bone does not deform geometry
- - Armature.MULTIPLY: Multiply vgroups by envelope
- - Armature.HIDDEN_EDIT: Hide bones in editmode
- - Armature.ROOT_SELECTED: Selection of root ball of bone
- - Armature.BONE_SELECTED: Selection of bone
- - Armature.TIP_SELECTED: Selection of tip ball of bone
- @type options: List of Constants
- @ivar subdivision: The number of bone subdivisions.
- @type subdivision: Int
- @ivar deformDist: The deform distance of the bone
- @type deformDist: Float
- @ivar length: The length of the bone. This cannot be set.
- @type length: Float
- @ivar headRadius: The radius of this bones head (used for envalope bones)
- @type headRadius: Float
- @ivar tailRadius: The radius of this bones head (used for envalope bones)
- @type tailRadius: Float
- """
-
- def hasParent():
- """
- Whether or not this bone has a parent
- @rtype: Bool
- """
-
- def clearParent():
- """
- Set the parent to None
- @rtype: None
- """
diff --git a/source/blender/python/api2_2x/doc/BGL.py b/source/blender/python/api2_2x/doc/BGL.py
deleted file mode 100644
index 661042f341b..00000000000
--- a/source/blender/python/api2_2x/doc/BGL.py
+++ /dev/null
@@ -1,1778 +0,0 @@
-# Blender.BGL module (OpenGL wrapper)
-
-"""
-The Blender.BGL submodule (the OpenGL wrapper).
-
-B{New}: some GLU functions: L{gluLookAt}, etc.
-
-The Blender.BGL submodule
-=========================
-
-This module wraps OpenGL constants and functions, making them available from
-within Blender Python.
-
-The complete list can be retrieved from the module itself, by listing its
-contents: dir(Blender.BGL). A simple search on the net can point to more
-than enough material to teach OpenGL programming, from books to many
-collections of tutorials.
-
-The "red book": "I{OpenGL Programming Guide: The Official Guide to Learning
-OpenGL}" and the online NeHe tutorials are two of the best resources.
-
-Example::
- import Blender
- from Blender.BGL import *
- from Blender import Draw
- R = G = B = 0
- A = 1
- title = "Testing BGL + Draw"
- instructions = "Use mouse buttons or wheel to change the background color."
- quitting = " Press ESC or q to quit."
- len1 = Draw.GetStringWidth(title)
- len2 = Draw.GetStringWidth(instructions + quitting)
- #
- def show_win():
- glClearColor(R,G,B,A) # define color used to clear buffers
- glClear(GL_COLOR_BUFFER_BIT) # use it to clear the color buffer
- glColor3f(0.35,0.18,0.92) # define default color
- glBegin(GL_POLYGON) # begin a vertex data list
- glVertex2i(165, 158)
- glVertex2i(252, 55)
- glVertex2i(104, 128)
- glEnd()
- glColor3f(0.4,0.4,0.4) # change default color
- glRecti(40, 96, 60+len1, 113)
- glColor3f(1,1,1)
- glRasterPos2i(50,100) # move cursor to x = 50, y = 100
- Draw.Text(title) # draw this text there
- glRasterPos2i(350,40) # move cursor again
- Draw.Text(instructions + quitting) # draw another msg
- glBegin(GL_LINE_LOOP) # begin a vertex-data list
- glVertex2i(46,92)
- glVertex2i(120,92)
- glVertex2i(120,115)
- glVertex2i(46,115)
- glEnd() # close this list
- #
- def ev(evt, val): # event callback for Draw.Register()
- global R,G,B,A # ... it handles input events
- if evt == Draw.ESCKEY or evt == Draw.QKEY:
- Draw.Exit() # this quits the script
- elif not val: return
- elif evt == Draw.LEFTMOUSE: R = 1 - R
- elif evt == Draw.MIDDLEMOUSE: G = 1 - G
- elif evt == Draw.RIGHTMOUSE: B = 1 - B
- elif evt == Draw.WHEELUPMOUSE:
- R += 0.1
- if R > 1: R = 1
- elif evt == Draw.WHEELDOWNMOUSE:
- R -= 0.1
- if R < 0: R = 0
- else:
- return # don't redraw if nothing changed
- Draw.Redraw(1) # make changes visible.
- #
- Draw.Register(show_win, ev, None) # start the main loop
-
-@note: you can use the L{Image} module and L{Image.Image} BPy object to load
- and set textures. See L{Image.Image.glLoad} and L{Image.Image.glFree},
- for example.
-@see: U{www.opengl.org}
-@see: U{nehe.gamedev.net}
-"""
-
-def glAccum(op, value):
- """
- Operate on the accumulation buffer
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/accum.html}
-
- @type op: Enumerated constant
- @param op: The accumulation buffer operation.
- @type value: float
- @param value: a value used in the accumulation buffer operation.
- """
-
-def glAlphaFunc(func, ref):
- """
- Specify the alpha test function
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/alphafunc.html}
-
- @type func: Enumerated constant
- @param func: Specifies the alpha comparison function.
- @type ref: float
- @param ref: The reference value that incoming alpha values are compared to.
- Clamped between 0 and 1.
- """
-
-def glAreTexturesResident(n, textures, residences):
- """
- Determine if textures are loaded in texture memory
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/aretexturesresident.html}
-
- @type n: int
- @param n: Specifies the number of textures to be queried.
- @type textures: Buffer object I{type GL_INT}
- @param textures: Specifies an array containing the names of the textures to be queried
- @type residences: Buffer object I{type GL_INT}(boolean)
- @param residences: An array in which the texture residence status in returned.The residence status of a
- texture named by an element of textures is returned in the corresponding element of residences.
- """
-
-def glBegin(mode):
- """
- Delimit the vertices of a primitive or a group of like primatives
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/begin.html}
-
- @type mode: Enumerated constant
- @param mode: Specifies the primitive that will be create from vertices between glBegin and
- glEnd.
- """
-
-def glBindTexture(target, texture):
- """
- Bind a named texture to a texturing target
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/bindtexture.html}
-
- @type target: Enumerated constant
- @param target: Specifies the target to which the texture is bound.
- @type texture: unsigned int
- @param texture: Specifies the name of a texture.
- """
-
-def glBitmap(width, height, xorig, yorig, xmove, ymove, bitmap):
- """
- Draw a bitmap
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/bitmap.html}
-
- @type width, height: int
- @param width, height: Specify the pixel width and height of the bitmap image.
- @type xorig,yorig: float
- @param xorig,yorig: Specify the location of the origin in the bitmap image. The origin is measured
- from the lower left corner of the bitmap, with right and up being the positive axes.
- @type xmove,ymove: float
- @param xmove,ymove: Specify the x and y offsets to be added to the current raster position after
- the bitmap is drawn.
- @type bitmap: Buffer object I{type GL_BYTE}
- @param bitmap: Specifies the address of the bitmap image.
- """
-
-def glBlendFunc(sfactor, dfactor):
- """
- Specify pixel arithmetic
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/blendfunc.html}
-
- @type sfactor: Enumerated constant
- @param sfactor: Specifies how the red, green, blue, and alpha source blending factors are
- computed.
- @type dfactor: Enumerated constant
- @param dfactor: Specifies how the red, green, blue, and alpha destination blending factors are
- computed.
- """
-
-def glCallList(list):
- """
- Execute a display list
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/calllist.html}
-
- @type list: unsigned int
- @param list: Specifies the integer name of the display list to be executed.
- """
-
-def glCallLists(n, type, lists):
- """
- Execute a list of display lists
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/calllists.html}
-
- @type n: int
- @param n: Specifies the number of display lists to be executed.
- @type type: Enumerated constant
- @param type: Specifies the type of values in lists.
- @type lists: Buffer object
- @param lists: Specifies the address of an array of name offsets in the display list.
- The pointer type is void because the offsets can be bytes, shorts, ints, or floats,
- depending on the value of type.
- """
-
-def glClear(mask):
- """
- Clear buffers to preset values
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/clear.html}
-
- @type mask: Enumerated constant(s)
- @param mask: Bitwise OR of masks that indicate the buffers to be cleared.
- """
-
-def glClearAccum(red, green, blue, alpha):
- """
- Specify clear values for the accumulation buffer
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/clearaccum.html}
-
- @type red,green,blue,alpha: float
- @param red,green,blue,alpha: Specify the red, green, blue, and alpha values used when the
- accumulation buffer is cleared. The initial values are all 0.
- """
-
-def glClearColor(red, green, blue, alpha):
- """
- Specify clear values for the color buffers
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/clearcolor.html}
-
- @type red,green,blue,alpha: float
- @param red,green,blue,alpha: Specify the red, green, blue, and alpha values used when the
- color buffers are cleared. The initial values are all 0.
- """
-
-def glClearDepth(depth):
- """
- Specify the clear value for the depth buffer
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/cleardepth.html}
-
- @type depth: int
- @param depth: Specifies the depth value used when the depth buffer is cleared.
- The initial value is 1.
- """
-
-def glClearIndex(c):
- """
- Specify the clear value for the color index buffers
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/clearindex.html}
-
- @type c: float
- @param c: Specifies the index used when the color index buffers are cleared.
- The initial value is 0.
- """
-
-def glClearStencil(s):
- """
- Specify the clear value for the stencil buffer
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/clearstencil.html}
-
- @type s: int
- @param s: Specifies the index used when the stencil buffer is cleared. The initial value is 0.
- """
-
-def glClipPlane (plane, equation):
- """
- Specify a plane against which all geometry is clipped
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/clipplane.html}
-
- @type plane: Enumerated constant
- @param plane: Specifies which clipping plane is being positioned.
- @type equation: Buffer object I{type GL_FLOAT}(double)
- @param equation: Specifies the address of an array of four double- precision floating-point
- values. These values are interpreted as a plane equation.
- """
-
-def glColor (red, green, blue, alpha):
- """
- B{glColor3b, glColor3d, glColor3f, glColor3i, glColor3s, glColor3ub, glColor3ui, glColor3us,
- glColor4b, glColor4d, glColor4f, glColor4i, glColor4s, glColor4ub, glColor4ui, glColor4us,
- glColor3bv, glColor3dv, glColor3fv, glColor3iv, glColor3sv, glColor3ubv, glColor3uiv,
- glColor3usv, glColor4bv, glColor4dv, glColor4fv, glColor4iv, glColor4sv, glColor4ubv,
- glColor4uiv, glColor4usv}
-
- Set a new color.
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/color.html}
-
- @type red,green,blue,alpha: Depends on function prototype.
- @param red,green,blue: Specify new red, green, and blue values for the current color.
- @param alpha: Specifies a new alpha value for the current color. Included only in the
- four-argument glColor4 commands. (With '4' colors only)
- """
-
-def glColorMask(red, green, blue, alpha):
- """
- Enable and disable writing of frame buffer color components
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/colormask.html}
-
- @type red,green,blue,alpha: int (boolean)
- @param red,green,blue,alpha: Specify whether red, green, blue, and alpha can or cannot be
- written into the frame buffer. The initial values are all GL_TRUE, indicating that the
- color components can be written.
- """
-
-def glColorMaterial(face, mode):
- """
- Cause a material color to track the current color
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/colormaterial.html}
-
- @type face: Enumerated constant
- @param face: Specifies whether front, back, or both front and back material parameters should
- track the current color.
- @type mode: Enumerated constant
- @param mode: Specifies which of several material parameters track the current color.
- """
-
-def glCopyPixels(x, y, width, height, type):
- """
- Copy pixels in the frame buffer
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/copypixels.html}
-
- @type x,y: int
- @param x,y: Specify the window coordinates of the lower left corner of the rectangular
- region of pixels to be copied.
- @type width, height: int
- @param width,height: Specify the dimensions of the rectangular region of pixels to be copied.
- Both must be non-negative.
- @type type: Enumerated constant
- @param type: Specifies whether color values, depth values, or stencil values are to be copied.
- """
-
-def glCullFace(mode):
- """
- Specify whether front- or back-facing facets can be culled
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/cullface.html}
-
- @type mode: Enumerated constant
- @param mode: Specifies whether front- or back-facing facets are candidates for culling.
- """
-
-def glDeleteLists(list, range):
- """
- Delete a contiguous group of display lists
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/deletelists.html}
-
- @type list: unsigned int
- @param list: Specifies the integer name of the first display list to delete
- @type range: int
- @param range: Specifies the number of display lists to delete
- """
-
-def glDeleteTextures(n, textures):
- """
- Delete named textures
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/deletetextures.html}
-
- @type n: int
- @param n: Specifies the number of textures to be deleted
- @type textures: Buffer I{GL_INT}
- @param textures: Specifies an array of textures to be deleted
- """
-
-def glDepthFunc(func):
- """
- Specify the value used for depth buffer comparisons
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/depthfunc.html}
-
- @type func: Enumerated constant
- @param func: Specifies the depth comparison function.
- """
-
-def glDepthMask(flag):
- """
- Enable or disable writing into the depth buffer
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/depthmask.html}
-
- @type flag: int (boolean)
- @param flag: Specifies whether the depth buffer is enabled for writing. If flag is GL_FALSE,
- depth buffer writing is disabled. Otherwise, it is enabled. Initially, depth buffer
- writing is enabled.
- """
-
-def glDepthRange(zNear, zFar):
- """
- Specify mapping of depth values from normalized device coordinates to window coordinates
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/depthrange.html}
-
- @type zNear: int
- @param zNear: Specifies the mapping of the near clipping plane to window coordinates.
- The initial value is 0.
- @type zFar: int
- @param zFar: Specifies the mapping of the far clipping plane to window coordinates.
- The initial value is 1.
- """
-
-def glDisable(cap):
- """
- Disable server-side GL capabilities
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/enable.html}
-
- @type cap: Enumerated constant
- @param cap: Specifies a symbolic constant indicating a GL capability.
- """
-
-def glDrawBuffer(mode):
- """
- Specify which color buffers are to be drawn into
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/drawbuffer.html}
-
- @type mode: Enumerated constant
- @param mode: Specifies up to four color buffers to be drawn into.
- """
-
-def glDrawPixels(width, height, format, type, pixels):
- """
- Write a block of pixels to the frame buffer
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/drawpixels.html}
-
- @type width, height: int
- @param width, height: Specify the dimensions of the pixel rectangle to be
- written into the frame buffer.
- @type format: Enumerated constant
- @param format: Specifies the format of the pixel data.
- @type type: Enumerated constant
- @param type: Specifies the data type for pixels.
- @type pixels: Buffer object
- @param pixels: Specifies a pointer to the pixel data.
- """
-
-def glEdgeFlag (flag):
- """
- B{glEdgeFlag, glEdgeFlagv}
-
- Flag edges as either boundary or non-boundary
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/edgeflag.html}
-
- @type flag: Depends of function prototype
- @param flag: Specifies the current edge flag value.The initial value is GL_TRUE.
- """
-
-def glEnable(cap):
- """
- Enable server-side GL capabilities
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/enable.html}
-
- @type cap: Enumerated constant
- @param cap: Specifies a symbolic constant indicating a GL capability.
- """
-
-def glEnd():
- """
- Delimit the vertices of a primitive or group of like primitives
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/begin.html}
- """
-
-def glEndList():
- """
- Create or replace a display list
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/newlist.html}
- """
-
-def glEvalCoord (u,v):
- """
- B{glEvalCoord1d, glEvalCoord1f, glEvalCoord2d, glEvalCoord2f, glEvalCoord1dv, glEvalCoord1fv,
- glEvalCoord2dv, glEvalCoord2fv}
-
- Evaluate enabled one- and two-dimensional maps
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/evalcoord.html}
-
- @type u: Depends on function prototype.
- @param u: Specifies a value that is the domain coordinate u to the basis function defined
- in a previous glMap1 or glMap2 command. If the function prototype ends in 'v' then
- u specifies a pointer to an array containing either one or two domain coordinates. The first
- coordinate is u. The second coordinate is v, which is present only in glEvalCoord2 versions.
- @type v: Depends on function prototype. (only with '2' prototypes)
- @param v: Specifies a value that is the domain coordinate v to the basis function defined
- in a previous glMap2 command. This argument is not present in a glEvalCoord1 command.
- """
-
-def glEvalMesh (mode, i1, i2):
- """
- B{glEvalMesh1 or glEvalMesh2}
-
- Compute a one- or two-dimensional grid of points or lines
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/evalmesh.html}
-
- @type mode: Enumerated constant
- @param mode: In glEvalMesh1, specifies whether to compute a one-dimensional
- mesh of points or lines.
- @type i1, i2: int
- @param i1, i2: Specify the first and last integer values for the grid domain variable i.
- """
-
-def glEvalPoint (i, j):
- """
- B{glEvalPoint1 and glEvalPoint2}
-
- Generate and evaluate a single point in a mesh
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/evalpoint.html}
-
- @type i: int
- @param i: Specifies the integer value for grid domain variable i.
- @type j: int (only with '2' prototypes)
- @param j: Specifies the integer value for grid domain variable j (glEvalPoint2 only).
- """
-
-def glFeedbackBuffer (size, type, buffer):
- """
- Controls feedback mode
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/feedbackbuffer.html}
-
- @type size: int
- @param size:Specifies the maximum number of values that can be written into buffer.
- @type type: Enumerated constant
- @param type:Specifies a symbolic constant that describes the information that
- will be returned for each vertex.
- @type buffer: Buffer object I{GL_FLOAT}
- @param buffer: Returns the feedback data.
- """
-
-def glFinish():
- """
- Block until all GL execution is complete
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/finish.html}
- """
-
-def glFlush():
- """
- Force Execution of GL commands in finite time
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/flush.html}
- """
-
-def glFog (pname, param):
- """
- B{glFogf, glFogi, glFogfv, glFogiv}
-
- Specify fog parameters
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/fog.html}
-
- @type pname: Enumerated constant
- @param pname: Specifies a single-valued fog parameter. If the function prototype
- ends in 'v' specifies a fog parameter.
- @type param: Depends on function prototype.
- @param param: Specifies the value or values to be assigned to pname. GL_FOG_COLOR
- requires an array of four values. All other parameters accept an array containing
- only a single value.
- """
-
-def glFrontFace(mode):
- """
- Define front- and back-facing polygons
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/frontface.html}
-
- @type mode: Enumerated constant
- @param mode: Specifies the orientation of front-facing polygons.
- """
-
-def glFrustum(left, right, bottom, top, zNear, zFar):
- """
- Multiply the current matrix by a perspective matrix
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/frustum.html}
-
- @type left, right: double (float)
- @param left, right: Specify the coordinates for the left and right vertical
- clipping planes.
- @type top, bottom: double (float)
- @param top, bottom: Specify the coordinates for the bottom and top horizontal
- clipping planes.
- @type zNear, zFar: double (float)
- @param zNear, zFar: Specify the distances to the near and far depth clipping planes.
- Both distances must be positive.
- """
-
-def glGenLists(range):
- """
- Generate a contiguous set of empty display lists
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/genlists.html}
-
- @type range: int
- @param range: Specifies the number of contiguous empty display lists to be generated.
- """
-
-def glGenTextures(n, textures):
- """
- Generate texture names
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/gentextures.html}
-
- @type n: int
- @param n: Specifies the number of textures name to be generated.
- @type textures: Buffer object I{type GL_INT}
- @param textures: Specifies an array in which the generated textures names are stored.
- """
-
-def glGet (pname, param):
- """
- B{glGetBooleanv, glGetfloatv, glGetFloatv, glGetIntegerv}
-
- Return the value or values of a selected parameter
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/get.html}
-
- @type pname: Enumerated constant
- @param pname: Specifies the parameter value to be returned.
- @type param: Depends on function prototype.
- @param param: Returns the value or values of the specified parameter.
- """
-
-def glGetClipPlane(plane, equation):
- """
- Return the coefficients of the specified clipping plane
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/getclipplane.html}
-
- @type plane: Enumerated constant
- @param plane: Specifies a clipping plane. The number of clipping planes depends on the
- implementation, but at least six clipping planes are supported. They are identified by
- symbolic names of the form GL_CLIP_PLANEi where 0 < i < GL_MAX_CLIP_PLANES.
- @type equation: Buffer object I{type GL_FLOAT}
- @param equation: Returns four float (double)-precision values that are the coefficients of the
- plane equation of plane in eye coordinates. The initial value is (0, 0, 0, 0).
- """
-
-def glGetError():
- """
- Return error information
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/geterror.html}
- """
-
-def glGetLight (light, pname, params):
- """
- B{glGetLightfv and glGetLightiv}
-
- Return light source parameter values
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/getlight.html}
-
- @type light: Enumerated constant
- @param light: Specifies a light source. The number of possible lights depends on the
- implementation, but at least eight lights are supported. They are identified by symbolic
- names of the form GL_LIGHTi where 0 < i < GL_MAX_LIGHTS.
- @type pname: Enumerated constant
- @param pname: Specifies a light source parameter for light.
- @type params: Buffer object. Depends on function prototype.
- @param params: Returns the requested data.
- """
-
-def glGetMap (target, query, v):
- """
- B{glGetMapdv, glGetMapfv, glGetMapiv}
-
- Return evaluator parameters
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/getmap.html}
-
- @type target: Enumerated constant
- @param target: Specifies the symbolic name of a map.
- @type query: Enumerated constant
- @param query: Specifies which parameter to return.
- @type v: Buffer object. Depends on function prototype.
- @param v: Returns the requested data.
- """
-
-def glGetMaterial (face, pname, params):
- """
- B{glGetMaterialfv, glGetMaterialiv}
-
- Return material parameters
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/getmaterial.html}
-
- @type face: Enumerated constant
- @param face: Specifies which of the two materials is being queried.
- representing the front and back materials, respectively.
- @type pname: Enumerated constant
- @param pname: Specifies the material parameter to return.
- @type params: Buffer object. Depends on function prototype.
- @param params: Returns the requested data.
- """
-
-def glGetPixelMap (map, values):
- """
- B{glGetPixelMapfv, glGetPixelMapuiv, glGetPixelMapusv}
-
- Return the specified pixel map
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/getpixelmap.html}
-
- @type map: Enumerated constant
- @param map: Specifies the name of the pixel map to return.
- @type values: Buffer object. Depends on function prototype.
- @param values: Returns the pixel map contents.
- """
-
-def glGetPolygonStipple(mask):
- """
- Return the polygon stipple pattern
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/getpolygonstipple.html}
-
- @type mask: Buffer object I{type GL_BYTE}
- @param mask: Returns the stipple pattern. The initial value is all 1's.
- """
-
-def glGetString(name):
- """
- Return a string describing the current GL connection
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/getstring.html}
-
- @type name: Enumerated constant
- @param name: Specifies a symbolic constant.
-
- """
-
-def glGetTexEnv (target, pname, params):
- """
- B{glGetTexEnvfv, glGetTexEnviv}
-
- Return texture environment parameters
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/gettexenv.html}
-
- @type target: Enumerated constant
- @param target: Specifies a texture environment. Must be GL_TEXTURE_ENV.
- @type pname: Enumerated constant
- @param pname: Specifies the symbolic name of a texture environment parameter.
- @type params: Buffer object. Depends on function prototype.
- @param params: Returns the requested data.
- """
-
-def glGetTexGen (coord, pname, params):
- """
- B{glGetTexGendv, glGetTexGenfv, glGetTexGeniv}
-
- Return texture coordinate generation parameters
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/gettexgen.html}
-
- @type coord: Enumerated constant
- @param coord: Specifies a texture coordinate.
- @type pname: Enumerated constant
- @param pname: Specifies the symbolic name of the value(s) to be returned.
- @type params: Buffer object. Depends on function prototype.
- @param params: Returns the requested data.
- """
-
-def glGetTexImage(target, level, format, type, pixels):
- """
- Return a texture image
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/getteximage.html}
-
- @type target: Enumerated constant
- @param target: Specifies which texture is to be obtained.
- @type level: int
- @param level: Specifies the level-of-detail number of the desired image.
- Level 0 is the base image level. Level n is the nth mipmap reduction image.
- @type format: Enumerated constant
- @param format: Specifies a pixel format for the returned data.
- @type type: Enumerated constant
- @param type: Specifies a pixel type for the returned data.
- @type pixels: Buffer object.
- @param pixels: Returns the texture image. Should be a pointer to an array of the
- type specified by type
- """
-
-def glGetTexLevelParameter (target, level, pname, params):
- """
- B{glGetTexLevelParameterfv, glGetTexLevelParameteriv}
-
- return texture parameter values for a specific level of detail
- @see: U{opengl.org/developers/documentation/man_pages/hardcopy/GL/html/gl/gettexlevelparameter.html}
-
- @type target: Enumerated constant
- @param target: Specifies the symbolic name of the target texture.
- @type level: int
- @param level: Specifies the level-of-detail number of the desired image.
- Level 0 is the base image level. Level n is the nth mipmap reduction image.
- @type pname: Enumerated constant
- @param pname: Specifies the symbolic name of a texture parameter.
- @type params: Buffer object. Depends on function prototype.
- @param params: Returns the requested data.
- """
-
-def glGetTexParameter (target, pname, params):
- """
- B{glGetTexParameterfv, glGetTexParameteriv}
-
- Return texture parameter values
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/gettexparameter.html}
-
- @type target: Enumerated constant
- @param target: Specifies the symbolic name of the target texture.
- @type pname: Enumerated constant
- @param pname: Specifies the symbolic name the target texture.
- @type params: Buffer object. Depends on function prototype.
- @param params: Returns the texture parameters.
- """
-
-def glHint(target, mode):
- """
- Specify implementation-specific hints
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/hint.html}
-
- @type target: Enumerated constant
- @param target: Specifies a symbolic constant indicating the behavior to be
- controlled.
- @type mode: Enumerated constant
- @param mode: Specifies a symbolic constant indicating the desired behavior.
- """
-
-def glIndex (c):
- """
- B{glIndexd, glIndexf, glIndexi, glIndexs, glIndexdv, glIndexfv, glIndexiv, glIndexsv}
-
- Set the current color index
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/index_.html}
-
- @type c: Buffer object. Depends on function prototype.
- @param c: Specifies a pointer to a one element array that contains the new value for
- the current color index.
- """
-
-def glInitNames():
- """
- Initialize the name stack
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/initnames.html}
- """
-
-def glIsEnabled(cap):
- """
- Test whether a capability is enabled
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/isenabled.html}
-
- @type cap: Enumerated constant
- @param cap: Specifies a constant representing a GL capability.
- """
-
-def glIsList(list):
- """
- Determine if a name corresponds to a display-list
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/islist.html}
-
- @type list: unsigned int
- @param list: Specifies a potential display-list name.
- """
-
-def glIsTexture(texture):
- """
- Determine if a name corresponds to a texture
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/istexture.html}
-
- @type texture: unsigned int
- @param texture: Specifies a value that may be the name of a texture.
- """
-
-def glLight (light, pname, param):
- """
- B{glLightf,glLighti, glLightfv, glLightiv}
-
- Set the light source parameters
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/light.html}
-
- @type light: Enumerated constant
- @param light: Specifies a light. The number of lights depends on the implementation,
- but at least eight lights are supported. They are identified by symbolic names of the
- form GL_LIGHTi where 0 < i < GL_MAX_LIGHTS.
- @type pname: Enumerated constant
- @param pname: Specifies a single-valued light source parameter for light.
- @type param: Depends on function prototype.
- @param param: Specifies the value that parameter pname of light source light will be set to.
- If function prototype ends in 'v' specifies a pointer to the value or values that
- parameter pname of light source light will be set to.
- """
-
-def glLightModel (pname, param):
- """
- B{glLightModelf, glLightModeli, glLightModelfv, glLightModeliv}
-
- Set the lighting model parameters
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/lightmodel.html}
-
- @type pname: Enumerated constant
- @param pname: Specifies a single-value light model parameter.
- @type param: Depends on function prototype.
- @param param: Specifies the value that param will be set to. If function prototype ends in 'v'
- specifies a pointer to the value or values that param will be set to.
- """
-
-def glLineStipple(factor, pattern):
- """
- Specify the line stipple pattern
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/linestipple.html}
-
- @type factor: int
- @param factor: Specifies a multiplier for each bit in the line stipple pattern.
- If factor is 3, for example, each bit in the pattern is used three times before
- the next bit in the pattern is used. factor is clamped to the range [1, 256] and
- defaults to 1.
- @type pattern: unsigned short int
- @param pattern: Specifies a 16-bit integer whose bit pattern determines which fragments
- of a line will be drawn when the line is rasterized. Bit zero is used first; the default
- pattern is all 1's.
- """
-
-def glLineWidth(width):
- """
- Specify the width of rasterized lines.
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/linewidth.html}
-
- @type width: float
- @param width: Specifies the width of rasterized lines. The initial value is 1.
- """
-
-def glListBase(base):
- """
- Set the display-list base for glCallLists
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/listbase.html}
-
- @type base: unsigned int
- @param base: Specifies an integer offset that will be added to glCallLists
- offsets to generate display-list names. The initial value is 0.
- """
-
-def glLoadIdentity():
- """
- Replace the current matrix with the identity matrix
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/loadidentity.html}
- """
-
-def glLoadMatrix (m):
- """
- B{glLoadMatrixd, glLoadMatixf}
-
- Replace the current matrix with the specified matrix
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/loadmatrix.html}
-
- @type m: Buffer object. Depends on function prototype.
- @param m: Specifies a pointer to 16 consecutive values, which are used as the elements
- of a 4x4 column-major matrix.
- """
-
-def glLoadName(name):
- """
- Load a name onto the name stack.
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/loadname.html}
-
- @type name: unsigned int
- @param name: Specifies a name that will replace the top value on the name stack.
- """
-
-def glLogicOp(opcode):
- """
- Specify a logical pixel operation for color index rendering
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/logicop.html}
-
- @type opcode: Enumerated constant
- @param opcode: Specifies a symbolic constant that selects a logical operation.
- """
-
-def glMap1 (target, u1, u2, stride, order, points):
- """
- B{glMap1d, glMap1f}
-
- Define a one-dimensional evaluator
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/map1.html}
-
- @type target: Enumerated constant
- @param target: Specifies the kind of values that are generated by the evaluator.
- @type u1, u2: Depends on function prototype.
- @param u1,u2: Specify a linear mapping of u, as presented to glEvalCoord1, to ^, t
- he variable that is evaluated by the equations specified by this command.
- @type stride: int
- @param stride: Specifies the number of floats or float (double)s between the beginning
- of one control point and the beginning of the next one in the data structure
- referenced in points. This allows control points to be embedded in arbitrary data
- structures. The only constraint is that the values for a particular control point must
- occupy contiguous memory locations.
- @type order: int
- @param order: Specifies the number of control points. Must be positive.
- @type points: Buffer object. Depends on function prototype.
- @param points: Specifies a pointer to the array of control points.
- """
-
-def glMap2 (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points):
- """
- B{glMap2d, glMap2f}
-
- Define a two-dimensional evaluator
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/map2.html}
-
- @type target: Enumerated constant
- @param target: Specifies the kind of values that are generated by the evaluator.
- @type u1, u2: Depends on function prototype.
- @param u1,u2: Specify a linear mapping of u, as presented to glEvalCoord2, to ^, t
- he variable that is evaluated by the equations specified by this command. Initially
- u1 is 0 and u2 is 1.
- @type ustride: int
- @param ustride: Specifies the number of floats or float (double)s between the beginning
- of control point R and the beginning of control point R ij, where i and j are the u
- and v control point indices, respectively. This allows control points to be embedded
- in arbitrary data structures. The only constraint is that the values for a particular
- control point must occupy contiguous memory locations. The initial value of ustride is 0.
- @type uorder: int
- @param uorder: Specifies the dimension of the control point array in the u axis.
- Must be positive. The initial value is 1.
- @type v1, v2: Depends on function prototype.
- @param v1, v2: Specify a linear mapping of v, as presented to glEvalCoord2, to ^,
- one of the two variables that are evaluated by the equations specified by this command.
- Initially, v1 is 0 and v2 is 1.
- @type vstride: int
- @param vstride: Specifies the number of floats or float (double)s between the beginning of control
- point R and the beginning of control point R ij, where i and j are the u and v control
- point(indices, respectively. This allows control points to be embedded in arbitrary data
- structures. The only constraint is that the values for a particular control point must
- occupy contiguous memory locations. The initial value of vstride is 0.
- @type vorder: int
- @param vorder: Specifies the dimension of the control point array in the v axis.
- Must be positive. The initial value is 1.
- @type points: Buffer object. Depends on function prototype.
- @param points: Specifies a pointer to the array of control points.
- """
-
-def glMapGrid (un, u1,u2 ,vn, v1, v2):
- """
- B{glMapGrid1d, glMapGrid1f, glMapGrid2d, glMapGrid2f}
-
- Define a one- or two-dimensional mesh
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/mapgrid.html}
-
- @type un: int
- @param un: Specifies the number of partitions in the grid range interval
- [u1, u2]. Must be positive.
- @type u1, u2: Depends on function prototype.
- @param u1, u2: Specify the mappings for integer grid domain values i=0 and i=un.
- @type vn: int
- @param vn: Specifies the number of partitions in the grid range interval [v1, v2]
- (glMapGrid2 only).
- @type v1, v2: Depends on function prototype.
- @param v1, v2: Specify the mappings for integer grid domain values j=0 and j=vn
- (glMapGrid2 only).
- """
-
-def glMaterial (face, pname, params):
- """
- Specify material parameters for the lighting model.
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/material.html}
-
- @type face: Enumerated constant
- @param face: Specifies which face or faces are being updated. Must be one of:
- @type pname: Enumerated constant
- @param pname: Specifies the single-valued material parameter of the face
- or faces that is being updated. Must be GL_SHININESS.
- @type params: int
- @param params: Specifies the value that parameter GL_SHININESS will be set to.
- If function prototype ends in 'v' specifies a pointer to the value or values that
- pname will be set to.
- """
-
-def glMatrixMode(mode):
- """
- Specify which matrix is the current matrix.
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/matrixmode.html}
-
- @type mode: Enumerated constant
- @param mode: Specifies which matrix stack is the target for subsequent matrix operations.
- """
-
-def glMultMatrix (m):
- """
- B{glMultMatrixd, glMultMatrixf}
-
- Multiply the current matrix with the specified matrix
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/multmatrix.html}
-
- @type m: Buffer object. Depends on function prototype.
- @param m: Points to 16 consecutive values that are used as the elements of a 4x4 column
- major matrix.
- """
-
-def glNewList(list, mode):
- """
- Create or replace a display list
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/newlist.html}
-
- @type list: unsigned int
- @param list: Specifies the display list name
- @type mode: Enumerated constant
- @param mode: Specifies the compilation mode.
- """
-
-def glNormal3 (nx, ny, nz, v):
- """
- B{Normal3b, Normal3bv, Normal3d, Normal3dv, Normal3f, Normal3fv, Normal3i, Normal3iv,
- Normal3s, Normal3sv}
-
- Set the current normal vector
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/normal.html}
-
- @type nx, ny, nz: Depends on function prototype. (non - 'v' prototypes only)
- @param nx, ny, nz: Specify the x, y, and z coordinates of the new current normal.
- The initial value of the current normal is the unit vector, (0, 0, 1).
- @type v: Buffer object. Depends on function prototype. ('v' prototypes)
- @param v: Specifies a pointer to an array of three elements: the x,y, and z coordinates
- of the new current normal.
- """
-
-def glOrtho(left, right, bottom, top, zNear, zFar):
- """
- Multiply the current matrix with an orthographic matrix
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/ortho.html}
-
- @type left, right: double (float)
- @param left, right: Specify the coordinates for the left and
- right vertical clipping planes.
- @type bottom, top: double (float)
- @param bottom, top: Specify the coordinates for the bottom and top
- horizontal clipping planes.
- @type zNear, zFar: double (float)
- @param zNear, zFar: Specify the distances to the nearer and farther
- depth clipping planes. These values are negative if the plane is to be behind the viewer.
- """
-
-def glPassThrough(token):
- """
- Place a marker in the feedback buffer
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/passthrough.html}
-
- @type token: float
- @param token: Specifies a marker value to be placed in the feedback
- buffer following a GL_PASS_THROUGH_TOKEN.
- """
-
-def glPixelMap (map, mapsize, values):
- """
- B{glPixelMapfv, glPixelMapuiv, glPixelMapusv}
-
- Set up pixel transfer maps
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pixelmap.html}
-
- @type map: Enumerated constant
- @param map: Specifies a symbolic map name.
- @type mapsize: int
- @param mapsize: Specifies the size of the map being defined.
- @type values: Buffer object. Depends on function prototype.
- @param values: Specifies an array of mapsize values.
- """
-
-def glPixelStore (pname, param):
- """
- B{glPixelStoref, glPixelStorei}
-
- Set pixel storage modes
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pixelstore.html}
-
- @type pname: Enumerated constant
- @param pname: Specifies the symbolic name of the parameter to be set.
- Six values affect the packing of pixel data into memory.
- Six more affect the unpacking of pixel data from memory.
- @type param: Depends on function prototype.
- @param param: Specifies the value that pname is set to.
- """
-
-def glPixelTransfer (pname, param):
- """
- B{glPixelTransferf, glPixelTransferi}
-
- Set pixel transfer modes
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pixeltransfer.html}
-
- @type pname: Enumerated constant
- @param pname: Specifies the symbolic name of the pixel transfer parameter to be set.
- @type param: Depends on function prototype.
- @param param: Specifies the value that pname is set to.
- """
-
-def glPixelZoom(xfactor, yfactor):
- """
- Specify the pixel zoom factors
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pixelzoom.html}
-
- @type xfactor, yfactor: float
- @param xfactor, yfactor: Specify the x and y zoom factors for pixel write operations.
- """
-
-def glPointSize(size):
- """
- Specify the diameter of rasterized points
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pointsize.html}
-
- @type size: float
- @param size: Specifies the diameter of rasterized points. The initial value is 1.
- """
-
-def glPolygonMode(face, mode):
- """
- Select a polygon rasterization mode
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/polygonmode.html}
-
- @type face: Enumerated constant
- @param face: Specifies the polygons that mode applies to.
- Must be GL_FRONT for front-facing polygons, GL_BACK for back- facing polygons,
- or GL_FRONT_AND_BACK for front- and back-facing polygons.
- @type mode: Enumerated constant
- @param mode: Specifies how polygons will be rasterized.
- The initial value is GL_FILL for both front- and back- facing polygons.
- """
-
-def glPolygonOffset(factor, units):
- """
- Set the scale and units used to calculate depth values
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/polygonoffset.html}
-
- @type factor: float
- @param factor: Specifies a scale factor that is used to create a variable depth
- offset for each polygon. The initial value is 0.
- @type units: float
- @param units: Is multiplied by an implementation-specific value to create a constant
- depth offset. The initial value is 0.
- """
-
-def glPolygonStipple(mask):
- """
- Set the polygon stippling pattern
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/polygonstipple.html}
-
- @type mask: Buffer object I{type GL_BYTE}
- @param mask: Specifies a pointer to a 32x32 stipple pattern that will be unpacked
- from memory in the same way that glDrawPixels unpacks pixels.
- """
-
-def glPopAttrib():
- """
- Pop the server attribute stack
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pushattrib.html}
- """
-
-def glPopClientAttrib():
- """
- Pop the client attribute stack
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pushclientattrib.html}
- """
-
-def glPopMatrix():
- """
- Pop the current matrix stack
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pushmatrix.html}
- """
-
-def glPopName():
- """
- Pop the name stack
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pushname.html}
- """
-
-def glPrioritizeTextures(n, textures, priorities):
- """
- Set texture residence priority
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/prioritizetextures.html}
-
- @type n: int
- @param n:Specifies the number of textures to be prioritized.
- @type textures: Buffer I{type GL_INT}
- @param textures: Specifies an array containing the names of the textures to be prioritized.
- @type priorities: Buffer I{type GL_FLOAT}
- @param priorities: Specifies an array containing the texture priorities. A priority given
- in an element of priorities applies to the texture named by the corresponding element of textures.
- """
-
-def glPushAttrib(mask):
- """
- Push the server attribute stack
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pushattrib.html}
-
- @type mask: Enumerated constant(s)
- @param mask: Specifies a mask that indicates which attributes to save.
- """
-
-def glPushClientAttrib(mask):
- """
- Push the client attribute stack
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pushclientattrib.html}
-
- @type mask: Enumerated constant(s)
- @param mask: Specifies a mask that indicates which attributes to save.
- """
-
-def glPushMatrix():
- """
- Push the current matrix stack
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pushmatrix.html}
- """
-
-def glPushName(name):
- """
- Push the name stack
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pushname.html}
-
- @type name: unsigned int
- @param name: Specifies a name that will be pushed onto the name stack.
- """
-
-def glRasterPos (x,y,z,w):
- """
- B{glRasterPos2d, glRasterPos2f, glRasterPos2i, glRasterPos2s, glRasterPos3d,
- glRasterPos3f, glRasterPos3i, glRasterPos3s, glRasterPos4d, glRasterPos4f,
- glRasterPos4i, glRasterPos4s, glRasterPos2dv, glRasterPos2fv, glRasterPos2iv,
- glRasterPos2sv, glRasterPos3dv, glRasterPos3fv, glRasterPos3iv, glRasterPos3sv,
- glRasterPos4dv, glRasterPos4fv, glRasterPos4iv, glRasterPos4sv}
-
- Specify the raster position for pixel operations
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rasterpos.html}
-
- @type x, y, z, w: Depends on function prototype. (z and w for '3' and '4' prototypes only)
- @param x,y,z,w: Specify the x,y,z, and w object coordinates (if present) for the
- raster position. If function prototype ends in 'v' specifies a pointer to an array of two,
- three, or four elements, specifying x, y, z, and w coordinates, respectively.
- @note:
- If you are drawing to the 3d view with a Scriptlink of a space handler
- the zoom level of the panels will scale the glRasterPos by the view matrix.
- so a X of 10 will not always offset 10 pixels as you would expect.
-
- To work around this get the scale value of the view matrix and use it to scale your pixel values.
-
- Workaround::
-
- import Blender
- from Blender.BGL import *
- xval, yval= 100, 40
- # Get the scale of the view matrix
- viewMatrix = Buffer(GL_FLOAT, 16)
- glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix)
- f = 1/viewMatrix[0]
- glRasterPos2f(xval*f, yval*f) # Instead of the usual glRasterPos2i(xval, yval)
- """
-
-def glReadBuffer(mode):
- """
- Select a color buffer source for pixels.
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/readbuffer.html}
-
- @type mode: Enumerated constant
- @param mode: Specifies a color buffer.
- """
-
-def glReadPixels(x, y, width, height, format, type, pixels):
- """
- Read a block of pixels from the frame buffer
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/readpixels.html}
-
- @type x,y: int
- @param x,y:Specify the window coordinates of the first pixel that is read
- from the frame buffer. This location is the lower left corner of a rectangular
- block of pixels.
- @type width, height: int
- @param width, height: Specify the dimensions of the pixel rectangle. width and
- height of one correspond to a single pixel.
- @type format: Enumerated constant
- @param format: Specifies the format of the pixel data.
- @type type: Enumerated constant
- @param type: Specifies the data type of the pixel data.
- @type pixels: Buffer object
- @param pixels: Returns the pixel data.
- """
-
-def glRect (x1,y1,x2,y2,v1,v2):
- """
- B{glRectd, glRectf, glRecti, glRects, glRectdv, glRectfv, glRectiv, glRectsv}
-
- Draw a rectangle
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rect.html}
-
- @type x1, y1: Depends on function prototype. (for non 'v' prototypes only)
- @param x1, y1: Specify one vertex of a rectangle
- @type x2, y2: Depends on function prototype. (for non 'v' prototypes only)
- @param x2, y2: Specify the opposite vertex of the rectangle
- @type v1, v2: Depends on function prototype. (for 'v' prototypes only)
- @param v1, v2: Specifies a pointer to one vertex of a rectangle and the pointer
- to the opposite vertex of the rectangle
- """
-
-def glRenderMode(mode):
- """
- Set rasterization mode
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rendermode.html}
-
- @type mode: Enumerated constant
- @param mode: Specifies the rasterization mode.
- """
-
-def glRotate (angle, x, y, z):
- """
- B{glRotated, glRotatef}
-
- Multiply the current matrix by a rotation matrix
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rotate.html}
-
- @type angle: Depends on function prototype.
- @param angle: Specifies the angle of rotation in degrees.
- @type x,y,z: Depends on function prototype.
- @param x,y,z: Specify the x,y, and z coordinates of a vector respectively.
- """
-
-def glScale (x,y,z):
- """
- B{glScaled, glScalef}
-
- Multiply the current matrix by a general scaling matrix
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/scale.html}
-
- @type x,y,z: Depends on function prototype.
- @param x,y,z: Specify scale factors along the x,y, and z axes, respectively.
- """
-
-def glScissor(x,y,width,height):
- """
- Define the scissor box
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/scissor.html}
-
- @type x,y: int
- @param x,y: Specify the lower left corner of the scissor box. Initially (0, 0).
- @type width, height: int
- @param width height: Specify the width and height of the scissor box. When a
- GL context is first attached to a window, width and height are set to the
- dimensions of that window.
- """
-
-def glSelectBuffer(size, buffer):
- """
- Establish a buffer for selection mode values
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/selectbuffer.html}
-
- @type size: int
- @param size: Specifies the size of buffer
- @type buffer: Buffer I{type GL_INT}
- @param buffer: Returns the selection data
- """
-
-def glShadeModel(mode):
- """
- Select flat or smooth shading
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/shademodel.html}
-
- @type mode: Enumerated constant
- @param mode: Specifies a symbolic value representing a shading technique.
- """
-
-def glStencilFuc(func, ref, mask):
- """
- Set function and reference value for stencil testing
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/stencilfunc.html}
-
- @type func: Enumerated constant
- @param func:Specifies the test function.
- @type ref: int
- @param ref:Specifies the reference value for the stencil test. ref is clamped to
- the range [0,2n-1], where n is the number of bitplanes in the stencil buffer.
- The initial value is 0.
- @type mask: unsigned int
- @param mask:Specifies a mask that is ANDed with both the reference value and
- the stored stencil value when the test is done. The initial value is all 1's.
- """
-
-def glStencilMask(mask):
- """
- Control the writing of individual bits in the stencil planes
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/stencilmask.html}
-
- @type mask: unsigned int
- @param mask: Specifies a bit mask to enable and disable writing of individual bits
- in the stencil planes. Initially, the mask is all 1's.
- """
-
-def glStencilOp(fail, zfail, zpass):
- """
- Set stencil test actions
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/stencilop.html}
-
- @type fail: Enumerated constant
- @param fail: Specifies the action to take when the stencil test fails.
- The initial value is GL_KEEP.
- @type zfail: Enumerated constant
- @param zfail: Specifies the stencil action when the stencil test passes, but the
- depth test fails. zfail accepts the same symbolic constants as fail.
- The initial value is GL_KEEP.
- @type zpass: Enumerated constant
- @param zpass: Specifies the stencil action when both the stencil test and the
- depth test pass, or when the stencil test passes and either there is no depth
- buffer or depth testing is not enabled. zpass accepts the same symbolic constants
- as fail. The initial value is GL_KEEP.
- """
-
-def glTexCoord (s,t,r,q,v):
- """
- B{glTexCoord1d, glTexCoord1f, glTexCoord1i, glTexCoord1s, glTexCoord2d, glTexCoord2f,
- glTexCoord2i, glTexCoord2s, glTexCoord3d, glTexCoord3f, glTexCoord3i, glTexCoord3s,
- glTexCoord4d, glTexCoord4f, glTexCoord4i, glTexCoord4s, glTexCoord1dv, glTexCoord1fv,
- glTexCoord1iv, glTexCoord1sv, glTexCoord2dv, glTexCoord2fv, glTexCoord2iv,
- glTexCoord2sv, glTexCoord3dv, glTexCoord3fv, glTexCoord3iv, glTexCoord3sv,
- glTexCoord4dv, glTexCoord4fv, glTexCoord4iv, glTexCoord4sv}
-
- Set the current texture coordinates
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/texcoord.html}
-
- @type s,t,r,q: Depends on function prototype. (r and q for '3' and '4' prototypes only)
- @param s,t,r,q: Specify s, t, r, and q texture coordinates. Not all parameters are
- present in all forms of the command.
- @type v: Buffer object. Depends on function prototype. (for 'v' prototypes only)
- @param v: Specifies a pointer to an array of one, two, three, or four elements,
- which in turn specify the s, t, r, and q texture coordinates.
- """
-
-def glTexEnv (target, pname, param):
- """
- B{glTextEnvf, glTextEnvi, glTextEnvfv, glTextEnviv}
-
- Set texture environment parameters
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/texenv.html}
-
- @type target: Enumerated constant
- @param target: Specifies a texture environment. Must be GL_TEXTURE_ENV.
- @type pname: Enumerated constant
- @param pname: Specifies the symbolic name of a single-valued texture environment
- parameter. Must be GL_TEXTURE_ENV_MODE.
- @type param: Depends on function prototype.
- @param param: Specifies a single symbolic constant. If function prototype ends in 'v'
- specifies a pointer to a parameter array that contains either a single symbolic
- constant or an RGBA color
- """
-
-def glTexGen (coord, pname, param):
- """
- B{glTexGend, glTexGenf, glTexGeni, glTexGendv, glTexGenfv, glTexGeniv}
-
- Control the generation of texture coordinates
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/texgen.html}
-
- @type coord: Enumerated constant
- @param coord: Specifies a texture coordinate.
- @type pname: Enumerated constant
- @param pname: Specifies the symbolic name of the texture- coordinate generation function.
- @type param: Depends on function prototype.
- @param param: Specifies a single-valued texture generation parameter.
- If function prototype ends in 'v' specifies a pointer to an array of texture
- generation parameters. If pname is GL_TEXTURE_GEN_MODE, then the array must
- contain a single symbolic constant. Otherwise, params holds the coefficients
- for the texture-coordinate generation function specified by pname.
- """
-
-def glTexImage1D(target, level, internalformat, width, border, format, type, pixels):
- """
- Specify a one-dimensional texture image
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/teximage1d.html}
-
- @type target: Enumerated constant
- @param target: Specifies the target texture.
- @type level: int
- @param level: Specifies the level-of-detail number. Level 0 is the base image level.
- Level n is the nth mipmap reduction image.
- @type internalformat: int
- @param internalformat: Specifies the number of color components in the texture.
- @type width: int
- @param width: Specifies the width of the texture image. Must be 2n+2(border) for
- some integer n. All implementations support texture images that are at least 64
- texels wide. The height of the 1D texture image is 1.
- @type border: int
- @param border: Specifies the width of the border. Must be either 0 or 1.
- @type format: Enumerated constant
- @param format: Specifies the format of the pixel data.
- @type type: Enumerated constant
- @param type: Specifies the data type of the pixel data.
- @type pixels: Buffer object.
- @param pixels: Specifies a pointer to the image data in memory.
- """
-
-def glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels):
- """
- Specify a two-dimensional texture image
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/teximage2d.html}
-
- @type target: Enumerated constant
- @param target: Specifies the target texture.
- @type level: int
- @param level: Specifies the level-of-detail number. Level 0 is the base image level.
- Level n is the nth mipmap reduction image.
- @type internalformat: int
- @param internalformat: Specifies the number of color components in the texture.
- @type width: int
- @param width: Specifies the width of the texture image. Must be 2n+2(border) for
- some integer n. All implementations support texture images that are at least 64
- texels wide.
- @type height: int
- @param height: Specifies the height of the texture image. Must be 2m+2(border) for
- some integer m. All implementations support texture images that are at least 64
- texels high.
- @type border: int
- @param border: Specifies the width of the border. Must be either 0 or 1.
- @type format: Enumerated constant
- @param format: Specifies the format of the pixel data.
- @type type: Enumerated constant
- @param type: Specifies the data type of the pixel data.
- @type pixels: Buffer object.
- @param pixels: Specifies a pointer to the image data in memory.
- """
-
-def glTexParameter (target, pname, param):
- """
- B{glTexParameterf, glTexParameteri, glTexParameterfv, glTexParameteriv}
-
- Set texture parameters
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/texparameter.html}
-
- @type target: Enumerated constant
- @param target: Specifies the target texture.
- @type pname: Enumerated constant
- @param pname: Specifies the symbolic name of a single-valued texture parameter.
- @type param: Depends on function prototype.
- @param param: Specifies the value of pname. If function prototype ends in 'v' specifies
- a pointer to an array where the value or values of pname are stored.
- """
-
-def glTranslate (x, y, z):
- """
- B{glTranslatef, glTranslated}
-
- Multiply the current matrix by a translation matrix
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/translate.html}
-
- @type x,y,z: Depends on function prototype.
- @param x,y,z: Specify the x, y, and z coordinates of a translation vector.
- """
-
-def glVertex (x,y,z,w,v):
- """
- B{glVertex2d, glVertex2f, glVertex2i, glVertex2s, glVertex3d, glVertex3f, glVertex3i,
- glVertex3s, glVertex4d, glVertex4f, glVertex4i, glVertex4s, glVertex2dv, glVertex2fv,
- glVertex2iv, glVertex2sv, glVertex3dv, glVertex3fv, glVertex3iv, glVertex3sv, glVertex4dv,
- glVertex4fv, glVertex4iv, glVertex4sv}
-
- Specify a vertex
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/vertex.html}
-
- @type x,y,z,w: Depends on function prototype (z and w for '3' and '4' prototypes only)
- @param x,y,z,w: Specify x, y, z, and w coordinates of a vertex. Not all parameters
- are present in all forms of the command.
- @type v: Buffer object. Depends of function prototype (for 'v' prototypes only)
- @param v: Specifies a pointer to an array of two, three, or four elements. The
- elements of a two-element array are x and y; of a three-element array, x, y, and z;
- and of a four-element array, x, y, z, and w.
- """
-
-def glViewport(x,y,width,height):
- """
- Set the viewport
- @see: U{www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/viewport.html}
-
- @type x,y: int
- @param x,y: Specify the lower left corner of the viewport rectangle,
- in pixels. The initial value is (0,0).
- @type width,height: int
- @param width,height: Specify the width and height of the viewport. When a GL context
- is first attached to a window, width and height are set to the dimensions of that window.
- """
-
-def gluPerspective(fovY, aspect, zNear, zFar):
- """
- Set up a perspective projection matrix.
- @see: U{http://biology.ncsa.uiuc.edu/cgi-bin/infosrch.cgi?cmd=getdoc&coll=0650&db=bks&fname=/SGI_Developer/OpenGL_RM/ch06.html#id5577288}
-
- @type fovY: double
- @param fovY: Specifies the field of view angle, in degrees, in the y direction.
- @type aspect: double
- @param aspect: Specifies the aspect ratio that determines the field of view in the x direction.
- The aspect ratio is the ratio of x (width) to y (height).
- @type zNear: double
- @param zNear: Specifies the distance from the viewer to the near clipping plane (always positive).
- @type zFar: double
- @param zFar: Specifies the distance from the viewer to the far clipping plane (always positive).
- """
-
-def gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz):
- """
- Define a viewing transformation
- @see: U{http://biology.ncsa.uiuc.edu/cgi-bin/infosrch.cgi?cmd=getdoc&coll=0650&db=bks&fname=/SGI_Developer/OpenGL_RM/ch06.html#id5573042}
-
- @type eyex, eyey, eyez: double
- @param eyex, eyey, eyez: Specifies the position of the eye point.
- @type centerx, centery, centerz: double
- @param centerx, centery, centerz: Specifies the position of the reference point.
- @type upx, upy, upz: double
- @param upx, upy, upz: Specifies the direction of the up vector.
- """
-
-def gluOrtho2D(left, right, bottom, top):
- """
- Define a 2-D orthographic projection matrix
- @see: U{http://biology.ncsa.uiuc.edu/cgi-bin/infosrch.cgi?cmd=getdoc&coll=0650&db=bks&fname=/SGI_Developer/OpenGL_RM/ch06.html#id5578074}
-
- @type left, right: double
- @param left, right: Specify the coordinates for the left and right vertical clipping planes.
- @type bottom, top: double
- @param bottom, top: Specify the coordinates for the bottom and top horizontal clipping planes.
- """
-
-def gluPickMatrix(x, y, width, height, viewport):
- """
- Define a picking region
- @see: U{http://biology.ncsa.uiuc.edu/cgi-bin/infosrch.cgi?cmd=getdoc&coll=0650&db=bks&fname=/SGI_Developer/OpenGL_RM/ch06.html#id5578074}
-
- @type x, y: double
- @param x, y: Specify the center of a picking region in window coordinates.
- @type width, height: double
- @param width, height: Specify the width and height, respectively, of the picking region in window coordinates.
- @type viewport: Buffer object. [int]
- @param viewport: Specifies the current viewport.
- """
-
-def gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winx, winy, winz):
- """
- Map object coordinates to window coordinates.
- @see: U{http://biology.ncsa.uiuc.edu/cgi-bin/infosrch.cgi?cmd=getdoc&coll=0650&db=bks&fname=/SGI_Developer/OpenGL_RM/ch06.html#id5578074}
-
- @type objx, objy, objz: double
- @param objx, objy, objz: Specify the object coordinates.
- @type modelMatrix: Buffer object. [double]
- @param modelMatrix: Specifies the current modelview matrix (as from a glGetDoublev call).
- @type projMatrix: Buffer object. [double]
- @param projMatrix: Specifies the current projection matrix (as from a glGetDoublev call).
- @type viewport: Buffer object. [int]
- @param viewport: Specifies the current viewport (as from a glGetIntegerv call).
- @type winx, winy, winz: Buffer object. [double]
- @param winx, winy, winz: Return the computed window coordinates.
- """
-
-def gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz):
- """
- Map object coordinates to window
- coordinates.
- @see: U{http://biology.ncsa.uiuc.edu/cgi-bin/infosrch.cgi?cmd=getdoc&coll=0650&db=bks&fname=/SGI_Developer/OpenGL_RM/ch06.html#id5582204}
-
- @type winx, winy, winz: double
- @param winx, winy, winz: Specify the window coordinates to be mapped.
- @type modelMatrix: Buffer object. [double]
- @param modelMatrix: Specifies the current modelview matrix (as from a glGetDoublev call).
- @type projMatrix: Buffer object. [double]
- @param projMatrix: Specifies the current projection matrix (as from a glGetDoublev call).
- @type viewport: Buffer object. [int]
- @param viewport: Specifies the current viewport (as from a glGetIntegerv call).
- @type objx, objy, objz: Buffer object. [double]
- @param objx, objy, objz: Return the computed object coordinates.
- """
-
-class Buffer:
- """
- The Buffer object is simply a block of memory that is delineated and initialized by the
- user. Many OpenGL functions return data to a C-style pointer, however, because this
- is not possible in python the Buffer object can be used to this end. Wherever pointer
- notation is used in the OpenGL functions the Buffer object can be used in it's BGL
- wrapper. In some instances the Buffer object will need to be initialized with the template
- parameter, while in other instances the user will want to create just a blank buffer
- which will be zeroed by default.
-
- Example with Buffer::
- import Blender
- from Blender import BGL
- myByteBuffer = BGL.Buffer(BGL.GL_BYTE, [32,32])
- BGL.glGetPolygonStipple(myByteBuffer)
- print myByteBuffer.dimensions
- print myByteBuffer.list
- sliceBuffer = myByteBuffer[0:16]
- print sliceBuffer
-
- @ivar list: The contents of the Buffer.
- @ivar dimensions: The size of the Buffer.
- """
-
- def __init__(type, dimensions, template = None):
- """
- This will create a new Buffer object for use with other BGL OpenGL commands.
- Only the type of argument to store in the buffer and the dimensions of the buffer
- are necessary. Buffers are zeroed by default unless a template is supplied, in
- which case the buffer is initialized to the template.
-
- @type type: int
- @param type: The format to store data in. The type should be one of
- GL_BYTE, GL_SHORT, GL_INT, or GL_FLOAT.
- @type dimensions: An int or sequence object specifying the dimensions of the buffer.
- @param dimensions: If the dimensions are specified as an int a linear array will
- be created for the buffer. If a sequence is passed for the dimensions, the buffer
- becomes n-Dimensional, where n is equal to the number of parameters passed in the
- sequence. Example: [256,2] is a two- dimensional buffer while [256,256,4] creates
- a three- dimensional buffer. You can think of each additional dimension as a sub-item
- of the dimension to the left. i.e. [10,2] is a 10 element array each with 2 sub-items.
- [(0,0), (0,1), (1,0), (1,1), (2,0), ...] etc.
- @type template: A python sequence object (optional)
- @param template: A sequence of matching dimensions which will be used to initialize
- the Buffer. If a template is not passed in all fields will be initialized to 0.
- @rtype: Buffer object
- @return: The newly created buffer as a PyObject.
- """
diff --git a/source/blender/python/api2_2x/doc/BezTriple.py b/source/blender/python/api2_2x/doc/BezTriple.py
deleted file mode 100644
index eb12dd0051e..00000000000
--- a/source/blender/python/api2_2x/doc/BezTriple.py
+++ /dev/null
@@ -1,96 +0,0 @@
-# Blender.BezTriple module and the BezTriple PyType object
-
-"""
-The Blender.BezTriple submodule
-
-B{New}:
- - new attributes L{handleTypes<BezTriple.handleTypes>},
- L{selects<BezTriple.selects>} and L{weight<BezTriple.weight>}
-
-This module provides access to the BezTriple Data in Blender. It is used by
-CurNurb and IpoCurve objects.
-
-@type HandleTypes: readonly dictionary
-@var HandleTypes: The available BezTriple handle types.
- - FREE - handle has no constraints
- - AUTO - completely constrain handle based on knot position
- - VECT - constraint handle to line between current and neighboring knot
- - ALIGN - constrain handle to lie in a straight line with knot's other
- handle
- - AUTOANIM - constrain IPO handles to be horizontal on extremes
-"""
-
-def New (coords):
- """
- Create a new BezTriple object.
-
- @type coords: sequence of three or nine floats
- @param coords: the coordinate values for the new control point. If three
- floats are given, then the handle values are automatically generated.
- @rtype: BezTriple
- @return: a new BezTriple object
- """
-
-class BezTriple:
- """
- The BezTriple object
- ====================
- This object gives access to generic data from all BezTriple objects in
- Blender.
- @ivar pt : the [x,y] coordinates for knot point of this BezTriple. After
- changing coordinates of a Ipo curve, it is advisable to call
- L{IpoCurve.recalc()<IpoCurve.IpoCurve.recalc>} to update the curve.
- @type pt: list of two floats
- @ivar vec : a list of the 3 points [ handle, knot, handle ] that comprise a
- BezTriple, with each point composed of a list [x,y,z] of floats. The list
- looks like [ [H1x, H1y, H1z], [Px, Py, Pz], [H2x, H2y, H2z] ].
- Example::
- # where bt is of type BezTriple
- # and h1, p, and h2 are lists of 3 floats
- h1, p, h2 = bt.vec
- @type vec: list of points
- @ivar tilt: the tilt/alpha value for the point
- @type tilt: float
- @ivar radius: the radius of this point (used for tapering bevels)
- @type radius: float
- @ivar hide: the visibility status of the knot. B{Note}: true/nonzero means
- I{not} hidden. B{Note}: primarily intended for curves; not a good idea to
- hide IPO control points.
- @type hide: int
- @ivar handleTypes: the types of the point's two handles. See
- L{HandleTypes} for a complete description.
- @type handleTypes list of two ints
- @ivar selects: the select status for [handle, knot, handle]. True/nonzero
- if the point is selected.
- @type selects: list of three ints
- @ivar weight: the weight assigned to the control point. Useful for
- softbodies and possibly others.
- @type weight: float
- """
-
- def getPoints():
- """
- Returns the x,y coordinates of the Bezier knot point (B{deprecated}).
- See the L{BezTriple.pt} attribute.
- @rtype: list of floats
- @return: list of the x and y coordinates of the Bezier point.
- """
-
- def setPoints(newval):
- """
- Sets the x,y coordinates of the Bezier knot point (B{deprecated}).
- See the L{BezTriple.pt} attribute.
- @type newval: tuple of 2 floats
- @param newval: the x and y coordinates of the new Bezier point.
- @rtype: None
- @return: None
- """
-
- def getTriple():
- """
- Returns the x,y,z coordinates for each of the three points that make up
- a BezierTriple (B{deprecated}). See the L{BezTriple.vec} attribute.
- @rtype: list consisting of 3 lists of 3 floats
- @return: handle1, knot, handle2
- """
-
diff --git a/source/blender/python/api2_2x/doc/Blender.py b/source/blender/python/api2_2x/doc/Blender.py
deleted file mode 100644
index 088a02c547c..00000000000
--- a/source/blender/python/api2_2x/doc/Blender.py
+++ /dev/null
@@ -1,240 +0,0 @@
-# The Blender Module
-
-# The module files in this folder are used to create the API documentation.
-# Doc system used: epydoc - http://epydoc.sf.net
-# pseudo command line (check the epy_docgen.sh file):
-# epydoc -o BPY_API_23x --url "http://www.blender.org" -t Blender.py \
-# -n "Blender" --no-private --no-frames Blender.py \
-# Types.py Scene.py Object.py [ ... etc]
-
-"""
-The main Blender module.
-
-B{New}: L{Run}, L{UpdateMenus}, new options to L{Get}, L{ShowHelp},
-L{SpaceHandlers} dictionary.
-L{UnpackModes} dictionary.
-
-Blender
-=======
-
-@type bylink: bool
-@var bylink: True if the current script is being executed as a script link.
-@type link: Blender Object or None; integer (space handlers)
-@var link: for normal script links, 'link' points to the linked Object (can be
- a scene, object (mesh, camera, lamp), material or
- world). For space handler script links, 'link' is an integer from the
- Blender.L{SpaceHandlers} dictionary. For script not running as script
- links, 'link' is None.
-@type event: string or int
-@var event: this has three possible uses: script link type or events callback
- ascii value:
- - for normal script links it is a string representing the link type
- (OnLoad, FrameChanged, Redraw, etc.).
- - for EVENT space handler script links it is the passed event.
- - for normal L{GUI<Draw.Register>} scripts I{during the events callback},
- it holds the ascii value of the current event, if it is a valid one.
- Users interested in this should also check the builtin 'ord' and 'chr'
- Python functions.
-@type mode: string
-@var mode: Blender's current mode:
- - 'interactive': normal mode, with an open window answering to user input;
- - 'background': Blender was started as 'C{blender -b <blender file>}' and
- will exit as soon as it finishes rendering or executing a script
- (ex: 'C{blender -b <blender file> -P <script>}'). Try 'C{blender -h}'
- for more detailed informations.
-@type UnpackModes: constant dictionary
-@var UnpackModes: dictionary with available unpack modes.
- - USE_LOCAL - use files in current directory (create when necessary)
- - WRITE_LOCAL - write files in current directory (overwrite when necessary)
- - USE_ORIGINAL - use files in original location (create when necessary)
- - WRITE_ORIGINAL - write files in original location (overwrite when necessary)
-@type SpaceHandlers: constant dictionary
-@var SpaceHandlers: dictionary with space handler types.
- - VIEW3D_EVENT;
- - VIEW3D_DRAW.
-"""
-
-def Set (request, data):
- """
- Update settings in Blender.
- @type request: string
- @param request: The setting to change:
- - 'curframe': the current animation frame
- - 'compressfile' : compress file writing a blend file (Use a boolean value True/False).
- - 'uscriptsdir': user scripts dir
- - 'yfexportdir': yafray temp xml storage dir
- - 'fontsdir': font dir
- - 'texturesdir': textures dir
- - 'seqpluginsdir': sequencer plugin dir
- - 'renderdir': default render output dir
- - 'soundsdir': sound dir
- - 'tempdir': temp file storage dir
- @type data: int or string
- @param data: The new value.
- """
-
-def Get (request):
- """
- Retrieve settings from Blender.
- @type request: string
- @param request: The setting data to be returned:
- - 'curframe': the current animation frame.
- - 'curtime' : the current animation time.
- - 'compressfile' : compress setting from the file menu, return 0 for false or 1 for true.
- - 'staframe': the start frame of the animation.
- - 'endframe': the end frame of the animation.
- - 'rt': the value of the 'rt' button for general debugging
- - 'filename': the name of the last file read or written.
- - 'homedir': Blender's home directory.
- - 'datadir' : the path to the dir where scripts should store and
- retrieve their data files, including saved configuration (can
- be None, if not found).
- - 'udatadir': the path to the user defined data dir. This may not be
- available (is None if not found), but users that define uscriptsdir
- have a place for their own scripts and script data that won't be
- erased when a new version of Blender is installed. For this reason
- we recommend scripts check this dir first and use it, if available.
- - 'scriptsdir': the path to the main dir where scripts are stored.
- - 'uscriptsdir': the path to the user defined dir for scripts. (*)
- - 'icondir': the path to blenders icon theme files.
- - 'yfexportdir': the path to the user defined dir for yafray export. (*)
- - 'fontsdir': the path to the user defined dir for fonts. (*)
- - 'texturesdir': the path to the user defined dir for textures. (*)
- - 'texpluginsdir': the path to the user defined dir for texture plugins. (*)
- - 'seqpluginsdir': the path to the user defined dir for sequence plugins. (*)
- - 'renderdir': the path to the user defined dir for render output. (*)
- - 'soundsdir': the path to the user defined dir for sound files. (*)
- - 'tempdir': the path to the user defined dir for storage of Blender
- temporary files. (*)
- - 'version' : the Blender version number.
- @note: (*) these can be set in Blender at the User Preferences window -> File
- Paths tab.
- @warn: this function returns None for requested dir paths that have not been
- set or do not exist in the user's file system.
- @return: The requested data or None if not found.
- """
-
-def Redraw ():
- """
- Redraw all 3D windows.
- """
-
-def Load (filename = None):
- """
- Load a Blender .blend file or any of the other supported file formats.
-
- Supported formats:
- - Blender's .blend;
- - DXF;
- - Open Inventor 1.0 ASCII;
- - Radiogour;
- - STL;
- - Videoscape;
- - VRML 1.0 asc.
-
- @type filename: string
- @param filename: the pathname to the desired file. If 'filename'
- isn't given or if it contains the substring '.B.blend', the default
- .B.blend file is loaded.
-
- @warn: loading a new .blend file removes the current data in Blender. For
- safety, this function saves the current data as an auto-save file in
- the temporary dir used by Blender before loading a new Blender file.
- @warn: after a call to Load(blendfile), current data in Blender is lost,
- including the Python dictionaries. Any posterior references in the
- script to previously defined data will generate a NameError. So it's
- better to put Blender.Load as the last executed command in the script,
- when this function is used to open .blend files.
- @warn: if in edit mode, this function leaves it, since Blender itself
- requires that.
- @note: for all types except .blend files, this function only works in
- interactive mode, not in background, following what Blender itself does.
- """
-
-def Save (filename, overwrite = 0):
- """
- Save a Blender .blend file with the current program data or export to
- one of the builtin file formats.
-
- Supported formats:
- - Blender (.blend);
- - DXF (.dxf);
- - STL (.stl);
- - Videoscape (.obj);
- - VRML 1.0 (.wrl).
-
- @type filename: string
- @param filename: the filename for the file to be written. It must have one
- of the supported extensions or an error will be returned.
- @type overwrite: int (bool)
- @param overwrite: if non-zero, file 'filename' will be overwritten if it
- already exists (can be checked with L{Blender.sys.exists<Sys.exists>}.
- By default existing files are not overwritten (an error is returned).
-
- @note: The substring ".B.blend" is not accepted inside 'filename'.
- @note: DXF, STL and Videoscape export only B{selected} meshes.
- """
-
-def Run (script):
- """
- Execute the given script.
- @type script: string
- @param script: the name of an available Blender Text (use L{Text.Get}() to
- get a complete list) or the full pathname to a Python script file in the
- system.
- @note: the script is executed in its own context -- with its own global
- dictionary -- as if it had been executed from the Text Editor or chosen
- from a menu.
- """
-
-def ShowHelp (script):
- """
- Show help for the given script. This is a time-saver ("code-saver") for
- scripts that need to feature a 'help' button in their GUIs or a 'help'
- submenu option. With proper documentation strings, calling this function is
- enough to present a screen with help information plus link and email buttons.
- @type script: string
- @param script: the filename of a registered Python script.
- @note: this function uses L{Run} and the "Scripts Help Browser" script. This
- means that it expects proper doc strings in the script to be able to show
- help for it (otherwise it offers to load the script source code as text).
- The necessary information about doc strings is L{given here<API_related>}.
- @note: 'script' doesn't need to be a full path name: "filename.py" is enough.
- Note, though, that this function only works for properly registered
- scripts (those that appear in menus).
- """
-
-def UpdateMenus ():
- """
- Update the menus that list registered scripts. This will scan the default
- and user defined (if available) folder(s) for scripts that have registration
- data and will make them accessible via menus.
- @note: only scripts that save other new scripts in the default or user
- defined folders need to call this function.
- """
-def UnpackAll (mode):
- """
- Unpack all files with specified mode.
- @param mode: The Mode for unpacking. Must be one of the modes in
- Blender.UnpackModes dictionary.
- @type mode: int
- """
-def PackAll ():
- """
- Pack all files.
- """
-
-def CountPackedFiles():
- """
- Returns the number of packed files.
- """
-
-def Quit ():
- """
- Exit from Blender immediately.
- @warn: the use of this function should obviously be avoided, it is available
- because there are some cases where it can be useful, like in automated
- tests. For safety, a "quit.blend" file is saved (normal Blender behavior
- upon exiting) when this function is called, so the data in Blender isn't
- lost.
- """
diff --git a/source/blender/python/api2_2x/doc/Blender_API.css b/source/blender/python/api2_2x/doc/Blender_API.css
deleted file mode 100644
index 22c00536282..00000000000
--- a/source/blender/python/api2_2x/doc/Blender_API.css
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Generated by CaScadeS, a stylesheet editor for Mozilla Composer */
-
- font { font-family: sans-serif ! important;
- }
-
- p { color: rgb(0, 0, 0);
- font-family: sans-serif;
- }
-
- pre { color: rgb(0, 0, 0);
- font-family: monospace;
- }
-
- a { font-family: sans-serif;
- color: rgb(0, 135, 0);
- font-weight: bold;
- }
-
- a:visited { font-family: sans-serif;
- color: rgb(102, 102, 102);
- }
-
- a:hover { font-family: sans-serif;
- color: rgb(184, 73, 0);
- }
-
- h1 { font-family: sans-serif;
- color: rgb(255, 102, 0);
- }
-
- h2 { font-family: sans-serif;
- color: rgb(255, 102, 0);
- }
-
- h3 { font-family: sans-serif;
- color: rgb(255, 102, 0);
- }
-
- table { color: rgb(0, 0, 0);
- opacity: 1;
- border-bottom-color: rgb(0, 102, 0);
- background-color: rgb(217, 216, 239);
- }
-
diff --git a/source/blender/python/api2_2x/doc/Bpy.py b/source/blender/python/api2_2x/doc/Bpy.py
deleted file mode 100644
index e5eb751cf04..00000000000
--- a/source/blender/python/api2_2x/doc/Bpy.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# bpy module and the bpy PyType object
-
-"""
-The bpy module.
-
-bpy
-===
-
- ATTENTION: This module is EXPERIMENTAL.
- Features documented here are subject to change.
-
- The bpy module is intended as a replacement for the Blender module.
- It will eventually provide the same features and functionality.
-
- This module uses a different model for the way data is accessed, added and removed. The various types such as groups, meshes, etc., are unchanged.
-
- At the moment it provides an alternative way to access data from python.
-
- Submodules:
- -----------
- - L{data<Bpy_data>}
- - L{libraries<LibData.Libraries>}
- - L{config<Bpy_config>}
-"""
-
diff --git a/source/blender/python/api2_2x/doc/Bpy_config.py b/source/blender/python/api2_2x/doc/Bpy_config.py
deleted file mode 100644
index ec3eb261c03..00000000000
--- a/source/blender/python/api2_2x/doc/Bpy_config.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# bpy module and the bpy PyType object
-
-"""
-bpy.config
-==========
-
-This module gives you direct access to blenders preferences.
-
-@var undoSteps: number of undo steps to store.
-@type undoSteps: int
-@var textureTimeout: free textures from openGL memory if unused after this time.
-@type textureTimeout: int
-@var textureCollectRate: tag textures as being used at this interval of time.
-@type textureCollectRate: int
-@var sequenceMemCacheLimit: how much memory to use for a sequencer cache.
-@type sequenceMemCacheLimit: int
-@var fontSize: display size for fonts in the user interface.
-@type fontSize: int
-@var yfExportDir: yafray export path.
-@type yfExportDir: string
-@var fontDir: default font path.
-@type fontDir: string
-@var renderDir: default render path.
-@type renderDir: string
-@var textureDir: default texture path.
-@type textureDir: string
-@var userScriptsDir: path for user scripts.
-@type userScriptsDir: string
-@var texturePluginsDir: default texture plugin path.
-@type texturePluginsDir: string
-@var soundDir: default sound path.
-@type soundDir: string
-@var sequencePluginsDir: default sequencer plugin path.
-@type sequencePluginsDir: string
-@var tempDir: path where temp files are saved.
-@type tempDir: string
-"""
-
diff --git a/source/blender/python/api2_2x/doc/Bpy_data.py b/source/blender/python/api2_2x/doc/Bpy_data.py
deleted file mode 100644
index e228db688d7..00000000000
--- a/source/blender/python/api2_2x/doc/Bpy_data.py
+++ /dev/null
@@ -1,281 +0,0 @@
-# bpy module and the bpy PyType object
-
-"""
-The bpy module.
-
-bpy.data (Generic Data Access)
-==============================
-
-Example::
-
- # apply the active image to the active mesh
- # this script has no error checking to keep it small and readable.
-
- sce= bpy.data.scenes.active
- ob_act = sce.objects.active # assuming we have an active, might be None
- me = ob_act.getData(mesh=1) # assuming a mesh type, could be any
- img = bpy.data.images.active # assuming we have an active image
-
- for f in me.faces:
- f.image = img
-
- Window.RedrawAll()
-
-Example::
-
- # make a new object from an existing mesh
- # and make it active
- scn= bpy.data.scenes.active
- me = bpy.data.meshes['mymesh']
- ob = sce.objects.new(me) # new object from the mesh
- sce.objects.active = ob
-
-Example::
- # print the names of any non local objects
- sce= bpy.data.scenes.active
- for ob in sce.objects:
- if ob.lib:
- print 'external object:', ob.name, ob.lib
-
-Example::
- # add an empty object at each vertex of the active mesh
- scn= bpy.data.scenes.active
- ob_act = sce.objects.active
- matrix = ob_act.matrixWorld
- me = ob_act.getData(mesh=1)
-
- for v in me.verts:
- ob = sce.objects.new('Empty')
- ob.loc = v.co * matrix # transform the vertex location by the objects matrix.
-
-
-Example::
- # load all the wave sound files in a directory
- import os
- sound_dir = '/home/me/soundfiles/'
- sounds_new = []
- for fname in os.listdir(sound_dir):
- if fname.lower().endswith('.wav'):
- try:
- snd = bpy.data.sounds.new(filename = sound_dir + fname)
- except:
- snd = None
-
- if snd:
- sounds_new.append(snd)
-
- # Print the sounds
- for snd in sounds_new:
- print snd
-
-Example::
- # apply a new image to each selected mesh object as a texface.
- width, height= 512, 512
- scn= bpy.data.scenes.active
-
- for ob in sce.objects.context:
- if not ob.lib and ob.type == 'Mesh': # object isn't from a library and is a mesh
- me = ob.getData(mesh=1)
- me.faceUV = True # add UV coords and textures if we don't have them.
-
- # Make an image named after the mesh
- img = bpy.data.images.new(me.name, width, height)
-
- for f in me.faces:
- f.image = img
-
- Window.RedrawAll()
-
-
-
-@var scenes: sequence for L{scene<Scene.Scene>} data
-@type scenes: L{libBlockSeq}
-@var objects: sequence for L{object<Object.Object>} data
-@type objects: L{libBlockSeq}
-@var meshes: sequence for L{mesh<Mesh.Mesh>} data
-@type meshes: L{libBlockSeq}
-@var curves: sequence for L{curve<Curve.Curve>} data, used to store Curve, Surface and Text3d data.
-@type curves: L{libBlockSeq}
-@var metaballs: sequence for L{metaball<Metaball.Metaball>} data
-@type metaballs: L{libBlockSeq}
-@var materials: sequence for L{material<Material.Material>} data
-@type materials: L{libBlockSeq}
-@var textures: sequence for L{texture<Texture.Texture>} data
-@type textures: L{libBlockSeq}
-@var images: sequence for L{image<Image.Image>} data
-@type images: L{libBlockSeq}
-@var lattices: sequence for L{lattice<Lattice.Lattice>} data
-@type lattices: L{libBlockSeq}
-@var lamps: sequence for L{lamp<Lamp.Lamp>} data
-@type lamps: L{libBlockSeq}
-@var cameras: sequence for L{camera<Camera.Camera>} data
-@type cameras: L{libBlockSeq}
-@var ipos: sequence for L{ipo<Ipo.Ipo>} data
-@type ipos: L{libBlockSeq}
-@var worlds: sequence for L{world<World.World>} data
-@type worlds: L{libBlockSeq}
-@var fonts: sequence for L{font<Font.Font>} data
-@type fonts: L{libBlockSeq}
-@var texts: sequence for L{text<Text.Text>} data
-@type texts: L{libBlockSeq}
-@var sounds: sequence for L{sound<Sound.Sound>} data
-@type sounds: L{libBlockSeq}
-@var groups: sequence for L{group<Group.Group>} data
-@type groups: L{libBlockSeq}
-@var armatures: sequence for L{armature<Armature.Armature>} data
-@type armatures: L{libBlockSeq}
-@var actions: sequence for L{action<NLA.Action>} data
-@type actions: L{libBlockSeq}
-"""
-
-
-class libBlockSeq:
- """
- Generic Data Access
- ===================
- This provides a unified way to access and manipulate data types in Blender
- (scene, object, mesh, curve, metaball, material, texture, image, lattice,
- lamp, camera, ipo, world, font, text, sound, groups, armatures, actions).
-
- Get Item
- ========
- To get a datablock by name you can use dictionary-like syntax.
-
- >>> ob = bpy.data.objects['myobject']
-
- Note that this can only be used for getting.
-
- >>> bpy.data.objects['myobject'] = data # will raise an error
-
- B{Library distinctions}
-
- Blender doesn't allow naming collisions within its own data, but it's
- possible to run into naming collisions when you have data linked from an external blend file.
-
- You can specify where the data is from by using a (name, library) pair as the key.
-
- >>> group = bpy.data.groups['mygroup', '//mylib.blend'] # only return data linked from mylib
-
- If you want to get a group from the local data only you can use None
-
- >>> group = bpy.data.groups['mygroup', None] # always returns local data
-
- Sequence
- ========
- These generic datablocks are sequence datatypes. They are not lists. They support the dictionary and iterator protocols. This implies the following
-
- - A B{for} statement allows you to loop through data using the iterator protocol without wasting resources on creating a large list.
-
- >>> for me in bpy.data.meshes:
- ... print me.name
-
- - You can also use len() to see how many datablocks exist.
-
- >>> print len(bpy.data.scenes)
-
- - Because the sequences are not lists and the [] operator is used to get items by name, you cannot use indexing to retrieve an item.
-
- >>> ob = bpy.data.objects[-1] # will raise an error
-
- - If you want to access the entire sequence as a list simply use the list() constructor.
-
- >>> ipo_list = list(bpy.data.ipos)
-
- @type tag: Bool
- @ivar tag: A fast way to set the tag value of every member of the sequence to True or False
-
- For example
-
- >>> bpy.data.meshes.tag = True
-
- Is the same as...
-
- >>> for me in bpy.data.meshes: me.tag = True
-
- @type active: Datablock or None
- @ivar active: The active member of the datatype
-
- Applies to:
- - L{images}
- - L{scenes}
- - L{texts}
- This can also be used to set the active data.
-
- >>> bpy.data.images.active = bpy.data.images.new(filename = '/home/me/someimage.jpg')
-
- """
-
- def new(name):
- """
- fixme: need description for parameters.
- This function returns a new datablock containing no data or loaded from a file.
-
- Most datatypes accept a name for their argument except for L{sounds}, L{fonts}, L{ipos} and L{curves} that need an additional argument.
-
- The name argument is optional if not given a default name will be assigned.
-
- The name given may be modified by blender to make it unique.
-
- Loading From File
- =================
- For L{images}, L{texts}, L{sounds}, L{fonts} types you can use the filename keyword to make a new datablock from a file.
-
- New L{sounds}, L{fonts} can only be made with the a filename given.
-
- The filename can a keyword or the second argument, use the keyword only for the datablocks new name to be set by the filename.
-
- >>> sound = bpy.data.sounds.new('newsound', '~/mysound.wav') # uses the first string given for the name.
-
- >>> sound = bpy.data.sounds.new(filename = '~/mysound.wav') # will use the filename to make the name.
-
- Images
- ======
- Images optionally accept extra 2 arguments for width and height, values between 4 and 5000 if no args are given they will be 256.
-
- >>> img = bpy.data.images.new(name, 512, 512)
-
- Curves
- ======
- Curves need 2 arguments: bpy.data.curves.new(name, type) type must be one of the following...
- - 'Curve'
- - 'Text3d'
-
- >>> text3d = bpy.data.curves.new('MyCurve', 'Text3d')
-
- Ipos
- ====
- Ipos need 2 arguments: bpy.data.ipos.new(name, type) type must be one of the following...
- - 'Camera'
- - 'World'
- - 'Material'
- - 'Texture'
- - 'Lamp'
- - 'Action'
- - 'Constraint'
- - 'Sequence'
- - 'Curve'
- - 'Key'
- Objects cannot be created from bpy.data.objects;
- objects must be created from the scene. Here are some examples.
-
- >>> ob = bpy.data.scenes.active.objects.new('Empty')
-
- >>> scn = bpy.data.scenes.active
- ... ob = sce.objects.new(bpy.data.meshes.new('mymesh'))
-
- @rtype: datablock
- """
-
- def unlink(datablock):
- """
- This function removes a datablock.
- applies to:
- - L{scenes}
- - L{groups}
- - L{texts}
- Other types will raise an error.
- @rtype: None
- """
-
-
- \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/Camera.py b/source/blender/python/api2_2x/doc/Camera.py
deleted file mode 100644
index c4e664efa66..00000000000
--- a/source/blender/python/api2_2x/doc/Camera.py
+++ /dev/null
@@ -1,257 +0,0 @@
-# Blender.Camera module and the Camera PyType object
-
-"""
-The Blender.Camera submodule.
-
-B{New}: L{Camera.clearScriptLinks} accepts a parameter now.
-
-Camera Data
-===========
-
-This module provides access to B{Camera Data} objects in Blender.
-
-Example::
-
- from Blender import Camera, Object, Scene
- cam = Camera.New('ortho') # create new ortho camera data
- cam.scale = 6.0 # set scale value for ortho view
- scn = Scene.GetCurrent() # get current scene
- ob = scn.objects.new(cam) # add a new camera object from the data
- scn.setCurrentCamera(ob) # make this camera the active
-"""
-
-def New (type = 'persp', name = 'CamData'):
- """
- Create a new Camera Data object.
- @type type: string
- @param type: The Camera type: 'persp' or 'ortho'.
- @type name: string
- @param name: The Camera Data name.
- @rtype: Blender Camera
- @return: The created Camera Data object.
- """
-
-def Get (name = None):
- """
- Get the Camera Data object(s) from Blender.
- @type name: string
- @param name: The name of the Camera Data.
- @rtype: Blender Camera or a list of Blender Cameras
- @return: It depends on the I{name} parameter:
- - (name): The Camera Data object with the given I{name};
- - (): A list with all Camera Data objects in the current scene.
- """
-
-class Camera:
- """
- The Camera Data object
- ======================
- This object gives access to Camera-specific data in Blender.
- @ivar type: The Camera type: 'persp' or 'ortho'
- @ivar mode: The mode flags: B{ORed value}: 'showLimits':1, 'showMist':2.
- @ivar lens: The lens value in [1.0, 250.0], only relevant to *persp* cameras.
- @ivar angle: The lens value in degrees [7.323871, 172.847331], only relevant to *persp* cameras.
- @ivar scale: The scale value in [0.01, 1000.00], only relevant to *ortho* cameras.
- @ivar clipStart: The clip start value in [0.0, 100.0].
- @ivar clipEnd: The clip end value in [1.0, 5000.0].
- @ivar dofDist: The dofDist value in [0.0, 5000.0].
- @ivar shiftX: The horizontal offset of the camera [-2.0, 2.0].
- @ivar shiftY: The vertical offset of the camera [-2.0, 2.0].
- @ivar alpha: The PassePart alpha [0.0, 1.0].
- @ivar drawSize: The display size for the camera an the 3d view [0.1, 10.0].
- @type ipo: Blender Ipo
- @ivar ipo: The "camera data" ipo linked to this camera data object.
- Set to None to clear the ipo.
-
- @ivar drawLimits: Toggle the option to show limits in the 3d view.
- @ivar drawName: Toggle the option to show the camera name in the 3d view.
- @ivar drawMist: Toggle the option to show mist in the 3d view.
- @ivar drawTileSafe: Toggle the option to show tile safe in the 3d view.
- @ivar drawPassepartout: Toggle the option to show pass part out in the 3d view.
-
- @warning: Most member variables assume values in some [Min, Max] interval.
- When trying to set them, the given parameter will be clamped to lie in
- that range: if val < Min, then val = Min, if val > Max, then val = Max.
- """
-
- def getName():
- """
- Get the name of this Camera Data object. (B{deprecated}) See the L{name} attribute.
- @rtype: string
- """
-
- def setName(name):
- """
- Set the name of this Camera Data object. (B{deprecated}) See the L{name} attribute.
- @type name: string
- @param name: The new name.
- """
-
- def getIpo():
- """
- Get the Ipo associated with this camera data object, if any. (B{deprecated})
- @rtype: Ipo
- @return: the wrapped ipo or None. (B{deprecated}) See the L{ipo} attribute.
- """
-
- def setIpo(ipo):
- """
- Link an ipo to this camera data object. (B{deprecated}) See the L{ipo} attribute.
- @type ipo: Blender Ipo
- @param ipo: a "camera data" ipo.
- """
-
- def clearIpo():
- """
- Unlink the ipo from this camera data object. (B{deprecated}) See the L{ipo} attribute.
- @return: True if there was an ipo linked or False otherwise.
- """
-
- def getType():
- """
- Get this Camera's type. (B{deprecated}) See the L{type} attribute.
- @rtype: int
- @return: 0 for 'persp' or 1 for 'ortho'.
- """
-
- def setType(type):
- """
- Set this Camera's type. (B{deprecated}) See the L{type} attribute.
- @type type: string
- @param type: The Camera type: 'persp' or 'ortho'.
- """
-
- def getMode():
- """
- Get this Camera's mode flags. (B{deprecated}) See the L{mode} attribute.
- @rtype: int
- @return: B{OR'ed value}: 'showLimits' is 1, 'showMist' is 2, or
- respectively, 01 and 10 in binary.
- """
-
- def setMode(mode1 = None, mode2 = None):
- """
- Set this Camera's mode flags. Mode strings given are turned 'on'. (B{deprecated}) See the L{mode} attribute.
- Those not provided are turned 'off', so cam.setMode() -- without
- arguments -- turns off all mode flags for Camera cam.
- @type mode1: string
- @type mode2: string
- @param mode1: A mode flag: 'showLimits' or 'showMist'.
- @param mode2: A mode flag: 'showLimits' or 'showMist'.
- """
-
- def getLens():
- """
- Get the lens value. (B{deprecated}) See the L{lens} attribute.
- @rtype: float
- @warn: lens is only relevant for perspective (L{getType}) cameras.
- """
-
- def setLens(lens):
- """
- Set the lens value. (B{deprecated}) See the L{lens} attribute.
- @type lens: float
- @param lens: The new lens value.
- @warn: lens is only relevant for perspective (L{type}) cameras.
- """
-
- def getScale():
- """
- Get the scale value. (B{deprecated}) See the L{scale} attribute.
- @rtype: float
- @warn: scale is only relevant for ortho (L{type}) cameras.
- """
-
- def setScale(scale):
- """
- Set the scale value. (B{deprecated}) See the L{scale} attribute.
- @type scale: float
- @param scale: The new scale value in [0.01, 1000.00].
- @warn: scale is only relevant for ortho (L{getType}) cameras.
- """
-
- def getClipStart():
- """
- Get the clip start value. (B{deprecated}) See the L{clipStart} attribute.
- @rtype: float
- """
-
- def setClipStart(clipstart):
- """
- Set the clip start value. (B{deprecated}) See the L{clipStart} attribute.
- @type clipstart: float
- @param clipstart: The new lens value.
- """
-
- def getClipEnd():
- """
- Get the clip end value. (B{deprecated}) See the L{clipEnd} attribute.
- @rtype: float
- """
-
- def setClipEnd(clipend):
- """
- Set the clip end value. (B{deprecated}) See the L{clipEnd} attribute.
- @type clipend: float
- @param clipend: The new clip end value.
- """
-
- def getDrawSize():
- """
- Get the draw size value. (B{deprecated}) See the L{drawSize} attribute.
- @rtype: float
- """
-
- def setDrawSize(drawsize):
- """
- Set the draw size value. (B{deprecated}) See the L{drawSize} attribute.
- @type drawsize: float
- @param drawsize: The new draw size value.
- """
-
- def getScriptLinks (event):
- """
- Get a list with this Camera's script links of type 'event'.
- @type event: string
- @param event: "FrameChanged", "Redraw" or "Render".
- @rtype: list
- @return: a list with Blender L{Text} names (the script links of the given
- 'event' type) or None if there are no script links at all.
- """
-
- def clearScriptLinks (links = None):
- """
- Delete script links from this Camera. If no list is specified, all
- script links are deleted.
- @type links: list of strings
- @param links: None (default) or a list of Blender L{Text} names.
- """
-
- def addScriptLink (text, event):
- """
- Add a new script link to this Camera.
- @type text: string
- @param text: the name of an existing Blender L{Text}.
- @type event: string
- @param event: "FrameChanged", "Redraw" or "Render".
- """
-
- def insertIpoKey(keytype):
- """
- Inserts keytype values in camera ipo at curframe. Uses module constants.
- @type keytype: Integer
- @param keytype:
- -LENS
- -CLIPPING
- @return: py_none
- """
-
- def __copy__ ():
- """
- Make a copy of this camera
- @rtype: Camera
- @return: a copy of this camera
- """
-
-import id_generics
-Camera.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/Constraint.py b/source/blender/python/api2_2x/doc/Constraint.py
deleted file mode 100644
index 4c1981c5238..00000000000
--- a/source/blender/python/api2_2x/doc/Constraint.py
+++ /dev/null
@@ -1,248 +0,0 @@
-# Blender.Constraint module and the Constraint PyType object
-
-"""
-The Blender.Constraint submodule
-
-B{New}:
- - provides access to Blender's constraint stack
-
-This module provides access to the Constraint Data in Blender.
-
-Examples::
- from Blender import *
-
- ob = Object.Get('Cube')
- if len(ob.constraints) > 0:
- const = ob.constraints[0]
- if const.type == Constraint.Type.FLOOR:
- offs = const[Constraint.Settings.OFFSET]
-
-Or to print all the constraints attached to each bone in a pose::
- from Blender import *
-
- ob = Object.Get('Armature')
- pose = ob.getPose()
- for bonename in pose.bones.keys():
- bone = pose.bones[bonename]
- for const in bone.constraints:
- print bone.name,'=>',const
-
-@type Type: readonly dictionary
-@var Type: Constant Constraint dict used by L{Constraints.append()} and
- for comparison with L{Constraint.type}. Values are
- TRACKTO, IKSOLVER, FOLLOWPATH, COPYROT, COPYLOC, COPYSIZE, ACTION,
- LOCKTRACK, STRETCHTO, FLOOR, LIMITLOC, LIMITROT, LIMITSIZE, CLAMPTO,
- PYTHON, CHILDOF, TRANSFORM, NULL
-
-@type Settings: readonly dictionary
-@var Settings: Constant dict used for changing constraint settings.
- - Used for all constraints
- - TARGET (Object) (Note: not used by Limit Location (LIMITLOC),
- Limit Rotation (LIMITROT), Limit Scale (LIMITSIZE))
- - BONE (string): name of Bone sub-target (for armature targets) (Note: not
- used by Stretch To (STRETCHTO), Limit Location (LIMITLOC), Limit Rotation
- (LIMITROT), Limit Scale (LIMITSIZE), Follow Path (FOLLOWPATH), Clamp To (CLAMPTO))
- - Used by some constraints:
- - OWNERSPACE (int): for TRACKTO, COPYLOC, COPYROT, COPYSIZE, LIMITLOC, LIMITROT, LIMITSIZE, PYTHON, TRANSFORM
- If the owner is an object, values are SPACE_WORLD, SPACE_LOCAL
- If the owner is a bone, values are SPACE_WORLD, SPACE_POSE, SPACE_PARLOCAL, SPACE_LOCAL
- - TARGETSPACE (int): for TRACKTO, COPYLOC, COPYROT, COPYSIZE, PYTHON, TRANSFORM, ACTION
- If the owner is an object, values are SPACE_WORLD, SPACE_LOCAL
- If the owner is a bone, values are SPACE_WORLD, SPACE_POSE, SPACE_PARLOCAL, SPACE_LOCAL
- - Used by IK Solver (IKSOLVER) constraint:
- - TOLERANCE (float): clamped to [0.0001:1.0]
- - ITERATIONS (int): clamped to [1,10000]
- - CHAINLEN (int): clamped to [0,255]
- - POSWEIGHT (float): clamped to [0.01,1.0]
- - ROTWEIGHT (float): clamped to [0.01,1.0]
- - ROTATE (bool)
- - USETIP (bool)
- - Used by Action (ACTION) constraint:
- - ACTION (Action Object)
- - START (int): clamped to [1,maxframe]
- - END (int): clamped to [1,maxframe]
- - MIN (float): clamped to [-1000.0,1000.0] for Location, [-180.0,180.0] for Rotation, [0.0001,1000.0] for Scaling
- - MAX (float): clamped to [-1000.0,1000.0] for Location, [-180.0,180.0] for Rotation, [0.0001,1000.0] for Scaling
- - KEYON (int): values are XLOC, YLOC, ZLOC, XROT, YROT, ZROT, XSIZE, YSIZE, ZSIZE
- - Used by Track To (TRACKTO) constraint:
- - TRACK (int): values are TRACKX, TRACKY, TRACKZ, TRACKNEGX,
- TRACKNEGY, TRACKNEGZ
- - UP (int): values are UPX, UPY, UPZ
- - Used by Stretch To (STRETCHTO) constraint:
- - RESTLENGTH (float): clamped to [0.0:100.0]
- - VOLVARIATION (float): clamped to [0.0:100.0]
- - VOLUMEMODE (int): values are VOLUMEXZ, VOLUMEX, VOLUMEZ,
- VOLUMENONE
- - PLANE (int): values are PLANEX, PLANEZ
- - Used by Follow Path (FOLLOWPATH) constraint:
- - FOLLOW (bool)
- - OFFSET (float): clamped to [-maxframe:maxframe]
- - FORWARD (int): values are TRACKX, TRACKY, TRACKZ, TRACKNEGX,
- TRACKNEGY, TRACKNEGZ
- - UP (int): values are UPX, UPY, UPZ
- - Used by Lock Track (FOLLOWPATH) constraint:
- - TRACK (int): values are TRACKX, TRACKY, TRACKZ, TRACKNEGX,
- TRACKNEGY, TRACKNEGZ
- - LOCK (int): values are LOCKX, LOCKY, LOCKZ
- - Used by Clamp To (CLAMPTO) constraint:
- - CLAMP (int): values are CLAMPAUTO, CLAMPX, CLAMPY, CLAMPZ
- - CLAMPCYCLIC (bool)
- - Used by Floor (FLOOR) constraint:
- - MINMAX (int): values are MINX, MINY, MINZ, MAXX, MAXY, MAXZ
- - OFFSET (float): clamped to [-100.0,100.0]
- - STICKY (bool)
- - Used by Copy Location (COPYLOC) and Copy Rotation (COPYROT)
- - COPY (bitfield): any combination of COPYX, COPYY and COPYZ with possible addition of COPYXINVERT, COPYYINVERT and COPYZINVERT to invert that particular input (if on).
- - Used by Copy Size (COPYSIZE) constraint:
- - COPY (bitfield): any combination of COPYX, COPYY and COPYZ
- - Used by Limit Location (LIMITLOC) constraint:
- - LIMIT (bitfield): any combination of LIMIT_XMIN, LIMIT_XMAX,
- LIMIT_YMIN, LIMIT_YMAX, LIMIT_ZMIN, LIMIT_ZMAX
- - XMIN (float): clamped to [-1000.0,1000.0]
- - XMAX (float): clamped to [-1000.0,1000.0]
- - YMIN (float): clamped to [-1000.0,1000.0]
- - YMAX (float): clamped to [-1000.0,1000.0]
- - ZMIN (float): clamped to [-1000.0,1000.0]
- - ZMAX (float): clamped to [-1000.0,1000.0]
- - Used by Limit Rotation (LIMITROT) constraint:
- - LIMIT (bitfield): any combination of LIMIT_XROT, LIMIT_YROT,
- LIMIT_ZROT
- - XMIN (float): clamped to [-360.0,360.0]
- - XMAX (float): clamped to [-360.0,360.0]
- - YMIN (float): clamped to [-360.0,360.0]
- - YMAX (float): clamped to [-360.0,360.0]
- - ZMIN (float): clamped to [-360.0,360.0]
- - ZMAX (float): clamped to [-360.0,360.0]
- - Used by Limit Scale (LIMITSIZE) constraint:
- - LIMIT (bitfield): any combination of LIMIT_XMIN, LIMIT_XMAX,
- LIMIT_YMIN, LIMIT_YMAX, LIMIT_ZMIN, LIMIT_ZMAX
- - XMIN (float): clamped to [0.0001,1000.0]
- - XMAX (float): clamped to [0.0001,1000.0]
- - YMIN (float): clamped to [0.0001,1000.0]
- - YMAX (float): clamped to [0.0001,1000.0]
- - ZMIN (float): clamped to [0.0001,1000.0]
- - ZMAX (float): clamped to [0.0001,1000.0]
- - Used by Python Script (PYTHON) constraint:
- - SCRIPT (Text): script to use
- - PROPERTIES (IDProperties): ID-Properties of constraint
- - Used by Child Of (CHILDOF) constraint:
- - COPY (bitfield): any combination of PARLOCX, PARLOCY, PARLOCZ,
- PARROTX, PARROTY, PARROTZ, PARSIZEX, PARSIZEY, PARSIZEZ.
- - Used by Transformation (TRANSFORM) constraint:
- - FROM (int): values are LOC, ROT, SCALE
- - TO (int): values are LOC, ROT, SCALE
- - MAPX, MAPY, MAPZ (int): values are LOC, ROT, SCALE
- - EXTRAPOLATE (bool)
- - FROM_MINX, FROM_MINY, FROM_MINZ, FROM_MAXX,
- FROM_MAXY, FROM_MAXZ (float):
- If FROM==LOC, then is clamped to [-1000.0, 1000.0]
- If FROM==ROT, then is clamped to [-360.0, 360.0]
- If FROM==SCALE, then is clamped to [0.0001, 1000.0]
- - TO_MINX, TO_MINY, TO_MINZ, TO_MAXX, TO_MAXY, TO_MAXZ (float):
- If TO==LOC, then is clamped to [-1000.0, 1000.0]
- If TO==ROT, then is clamped to [-360.0, 360.0]
- If TO==SCALE, then is clamped to [0.0001, 1000.0]
-
-"""
-
-class Constraints:
- """
- The Constraints object
- ======================
- This object provides access to sequence of
- L{constraints<Constraint.Constraint>} for a particular object.
- They can be accessed from L{Object.constraints<Object.Object.constraints>}.
- or L{PoseBone.constraints<Pose.PoseBone.constraints>}.
- """
-
- def __getitem__(index):
- """
- This operator returns one of the constraints in the stack.
- @type index: int
- @return: an Constraint object
- @rtype: Constraint
- @raise KeyError: index was out of range
- """
-
- def __len__():
- """
- Returns the number of constraints in the constraint stack.
- @return: number of Constraints
- @rtype: int
- """
-
- def append(type):
- """
- Appends a new constraint to the end of the constraint stack.
- @param type: a constant specifying the type of constraint to create. as from L{Type}
- @type type: int constant
- @rtype: Constraint
- @return: the new Constraint
- """
-
- def remove(con):
- """
- Remove a constraint from this objects constraint sequence.
- @param con: a constraint from this sequence to remove.
- @type con: Constraint
- @note: Accessing attributes of the constraint after it is removed will
- throw an exception.
- """
-
- def moveUp(con):
- """
- Moves the constraint up in the object's constraint stack.
- @param con: a constraint from this sequence to remove.
- @type con: Constraint
- @rtype: None
- """
-
- def moveDown(con):
- """
- Moves the constraint down in the object's constraint stack.
- @param con: a constraint from this sequence to remove.
- @type con: Constraint
- @rtype: None
- """
-
-class Constraint:
- """
- The Constraint object
- =====================
- This object provides access to a constraint for a particular object
- accessed from L{Constraints}.
- @ivar name: The name of this constraint. 29 chars max.
- @type name: string
- @ivar type: The type of this constraint. Read-only. The returned value
- matches the types in L{Type}.
- @type type: int
- @ivar influence: The influence value of the constraint. Valid values
- are in the range [0.0,1.0].
- @type influence: float
- """
-
- def __getitem__(key):
- """
- This operator returns one of the constraint's data attributes.
- @param key: value from constraint's L{Constraint.Settings} constant
- @type key: int constant
- @return: the requested data
- @rtype: varies
- @raise KeyError: the key does not exist for the constraint
- """
-
- def __setitem__(key):
- """
- This operator changes one of the constraint's data attributes.
- @param key: value from constraint's L{Constraint.Settings} constant
- @type key: int constant
- @raise KeyError: the key does not exist for the constraint
- """
-
- def insertKey(frame):
- """
- Adds an influence keyframe for the constraint Ipo.
- @rtype: None
- @param frame: the frame number at which to insert the key.
- @type frame: float
- """
diff --git a/source/blender/python/api2_2x/doc/Curve.py b/source/blender/python/api2_2x/doc/Curve.py
deleted file mode 100644
index c3760bc2c1d..00000000000
--- a/source/blender/python/api2_2x/doc/Curve.py
+++ /dev/null
@@ -1,723 +0,0 @@
-# Blender.Curve module and the Curve PyType object
-
-"""
-The Blender.Curve submodule.
-
-Curve Data
-==========
-
-This module provides access to B{Curve Data} objects in Blender.
-
-A Blender Curve Data consists of multiple L{CurNurb}(s). Try converting a Text object to a Curve to see an example of this. Each curve is of
-type Bezier or Nurb. The underlying L{CurNurb}(s) can be accessed with
-the [] operator. Operator [] returns an object of type L{CurNurb}. Removing a L{CurNurb} can be done this way too. del curve[0] removes the first curve.
-
-Note that L{CurNurb} can be used to acces a curve of any type (Poly, Bezier or Nurb)
-
-The Curve module also supports the Python iterator interface. This means you
-can access the L{CurNurb}(s) in a Curve and the control points in a L{CurNurb} using a
-Python B{for} statement.
-
-
-Add a Curve to a Scene Example::
- from Blender import Curve, Object, Scene
- cu = Curve.New() # create new curve data
- scn = Scene.GetCurrent() # get current scene
- ob = scn.objects.new(cu) # make a new curve from the curve data
-
-Iterator Example::
- from Blender import Curve, Object, Scene
- scn = Scene.GetCurrent() # get current scene
- ob = scn.objects.active
- curvedata = ob.data
- for curnurb in curvedata:
- print type( curnurb ), curnurb
- for point in curnurb:
- print type( point ), point
-
-Creating a Curve from a list of Vec triples Examples::
- from Blender import *
- def bezList2Curve(bezier_vecs):
- '''
- Take a list or vector triples and converts them into a bezier curve object
- '''
-
- def bezFromVecs(vecs):
- '''
- Bezier triple from 3 vecs, shortcut functon
- '''
- bt= BezTriple.New(\
- vecs[0].x, vecs[0].y, vecs[0].z,\
- vecs[1].x, vecs[1].y, vecs[1].z,\
- vecs[2].x, vecs[2].y, vecs[2].z)
-
- bt.handleTypes= (BezTriple.HandleTypes.FREE, BezTriple.HandleTypes.FREE)
-
- return bt
-
- # Create the curve data with one point
- cu= Curve.New()
- cu.appendNurb(bezFromVecs(bezier_vecs[0])) # We must add with a point to start with
- cu_nurb= cu[0] # Get the first curve just added in the CurveData
-
-
- i= 1 # skip first vec triple because it was used to init the curve
- while i<len(bezier_vecs):
- bt_vec_triple= bezier_vecs[i]
- bt= bezFromVecs(bt_vec_triple)
- cu_nurb.append(bt)
- i+=1
-
- # Add the Curve into the scene
- scn= Scene.GetCurrent()
- ob = scn.objects.new(cu)
- return ob
-"""
-
-def New ( name):
- """
- Create a new Curve Data object.
- @type name: string
- @param name: The Curve Data name.
- @rtype: Blender Curve
- @return: The created Curve Data object.
- """
-
-def Get (name = None):
- """
- Get the Curve Data object(s) from Blender.
- @type name: string
- @param name: The name of the Curve Data.
- @rtype: Blender Curve or a list of Blender Curves
- @return: It depends on the 'name' parameter:
- - (name): The Curve Data object with the given name;
- - (): A list with all Curve Data objects in the current scene.
- """
-
-class Curve:
- """
- The Curve Data object
- =====================
- This object gives access to Curve and Surface data linked from Blender Objects.
-
- @ivar name: The Curve Data name.
- @type name: string
- @ivar pathlen: The Curve Data path length, used to set the number of frames for an animation (not the physical length).
- @type pathlen: int
- @ivar totcol: The Curve Data maximal number of linked materials. Read-only.
- @type totcol: int
- @ivar flag: The Curve Data flag value; see L{getFlag()} for the semantics.
- @ivar bevresol: The Curve Data bevel resolution. [0 - 32]
- @type bevresol: int
- @ivar resolu: The Curve Data U-resolution (used for curve and surface resolution) [0 - 1024].
- @type resolu: int
- @ivar resolv: The Curve Data V-resolution (used for surface resolution) [0 - 1024].
- @type resolv: int
- @ivar width: The Curve Data width [0 - 2].
- @type width: float
- @ivar ext1: The Curve Data extent1 Called "Extrude" in the user interface (for bevels only).
- @type ext1: float
- @ivar ext2: The Curve Data extent2 - Called "Bevel Depth" in the user interface (for bevels only).
- @type ext2: float
- @ivar loc: The Curve Data location(from the center).
- @type loc: list of 3 floats
- @ivar rot: The Curve Data rotation(from the center).
- @type rot: list of 3 floats
- @ivar size: The Curve Data size(from the center).
- @type size: list of 3 floats
- @ivar bevob: The Curve Bevel Object
- @type bevob: Blender L{Object<Object.Object>} or None
- @ivar taperob: The Curve Taper Object
- @type taperob: Blender L{Object<Object.Object>} or None
- @ivar key: The Key object associated with this Curve, if any.
- @type key: Blender L{Key<Key.Key>}
- @ivar materials: The curves's materials. Each curve can reference up to
- 16 materials. Empty slots in the curve's list are represented by B{None}.
- B{Note}: L{Object.colbits<Object.Object.colbits>} needs to be set correctly
- for each object in order for these materials to be used instead of
- the object's materials.
- B{Note}: The list that's returned is I{not} linked to the original curve.
- curve.materials.append(material) won't do anything.
- Use curve.materials += [material] instead.
- @type materials: list of L{Material}s
- """
-
- def getName():
- """
- Get the name of this Curve Data object.
- @rtype: string
- """
-
- def setName(name):
- """
- Set the name of this Curve Data object.
- @rtype: None
- @type name: string
- @param name: The new name.
- """
-
- def getPathLen():
- """
- Get this Curve's path frame length, used for an animated path.
- @rtype: int
- @return: the path length.
- """
-
- def setPathLen(len):
- """
- Set this Curve's path length.
- @rtype: None
- @type len: int
- @param len: the new curve's length.
- """
-
- def getTotcol():
- """
- Get the number of materials linked to the Curve.
- @rtype: int
- @return: number of materials linked.
- """
-
- def setTotcol(totcol):
- """
- Set the number of materials linked to the Curve. B{Note}: this method
- will probably be deprecated in the future.
- @rtype: None
- @type totcol: int
- @param totcol: number of materials linked.
- @warn: It is not advisable to use this method unless you know what you
- are doing; it's possible to
- corrupt a .blend file if you don't know what you're doing. If you want
- to change the number of materials, use the L{materials} attribute.
- """
-
- def getFlag():
- """
- Get the Curve flag value.
- This item is a bitfield whose value is a combination of the following parameters.
- - Bit 0 : "3D" is set
- - Bit 1 : "Front" is set
- - Bit 2 : "Back" is set
- - Bit 3 : "CurvePath" is set.
- - Bit 4 : "CurveFollow" is set.
-
- @rtype: integer bitfield
- """
-
- def setFlag(val):
- """
- Set the Curve flag value. The flag corresponds to the Blender settings for 3D, Front, Back, CurvePath and CurveFollow. This parameter is a bitfield.
- @rtype: None
- @type val: integer bitfield
- @param val : The Curve's flag bits. See L{getFlag} for the meaning of the individual bits.
- """
-
- def getBevresol():
- """
- Get the Curve's bevel resolution value.
- @rtype: float
- """
-
- def setBevresol(bevelresol):
- """
- Set the Curve's bevel resolution value.
- @rtype: None
- @type bevelresol: float
- @param bevelresol: The new Curve's bevel resolution value.
- """
-
- def getResolu():
- """
- Get the Curve's U-resolution value.
- @rtype: float
- """
-
- def setResolu(resolu):
- """
- Set the Curve's U-resolution value. [0 - 1024]
- This is used for surfaces and curves.
- @rtype: None
- @type resolu: float
- @param resolu: The new Curve's U-resolution value.
- """
-
- def getResolv():
- """
- Get the Curve's V-resolution value.
- @rtype: float
- """
-
- def setResolv(resolv):
- """
- Set the Curve's V-resolution value. [0 - 1024].
- This is used for surfaces only.
- @rtype: None
- @type resolv: float
- @param resolv: The new Curve's V-resolution value.
- """
-
- def getWidth():
- """
- Get the Curve's width value.
- @rtype: float
- """
-
- def setWidth(width):
- """
- Set the Curve's width value.
- @rtype: None
- @type width: float
- @param width: The new Curve's width value.
- """
-
- def getExt1():
- """
- Get the Curve's ext1 value.
- @rtype: float
- """
-
- def setExt1(ext1):
- """
- Set the Curve's ext1 value.
- @rtype: None
- @type ext1: float
- @param ext1: The new Curve's ext1 value.
- """
-
- def getExt2():
- """
- Get the Curve's ext2 value.
- @rtype: float
- """
-
- def setExt2(ext2):
- """
- Set the Curve's ext2 value.
- @rtype: None
- @type ext2: float
- @param ext2: The new Curve's ext2 value.
- """
-
- def getControlPoint(numcurve,numpoint):
- """
- Get the curve's control point value (B{deprecated}). The numpoint arg
- is an index into the list of points and starts with 0. B{Note}: new
- scripts should use the [] operator on Curves and CurNurbs. Example::
- curve = Blender.Curve.Get('Curve')
- p0 = curve[0][0] # get first point from first nurb
- # -- OR --
- nurb = curve[0] # get first nurb
- p0 = nurb[0] # get nurb's first point
-
- @type numcurve: int
- @type numpoint: int
- @rtype: list of floats
- @return: depends upon the curve's type.
- - type Bezier : a list of nine floats. Values are x, y, z for handle-1, vertex and handle-2
- - type Nurb : a list of 4 floats. Values are x, y, z, w.
-
- """
-
- def setControlPoint( numcurve, numpoint, controlpoint):
- """
- Set the Curve's controlpoint value. The numpoint arg is an index into the list of points and starts with 0.
- @rtype: None
- @type numcurve: int
- @type numpoint: int
- @type controlpoint: list
- @param numcurve: index for spline in Curve, starting from 0
- @param numpoint: index for point in spline, starting from 0
- @param controlpoint: The new controlpoint value.
- See L{getControlPoint} for the length of the list.
- """
-
- def appendPoint( numcurve, new_control_point ):
- """
- Add a new control point to the indicated curve (B{deprecated}).
- New scripts should use L{CurNurb.append()}.
- @rtype: None
- @type numcurve: int
- @type new_control_point: list of floats or BezTriple
- @param numcurve: index for spline in Curve, starting from 0
- @param new_control_point: depends on curve's type.
- - type Bezier: a BezTriple
- - type Nurb: a list of four or five floats for the xyzw values
- @raise AttributeError: throws exception if numcurve is out of range.
- """
-
- def appendNurb( new_point ):
- """
- add a new curve to this Curve. The new point is added to the new curve. Blender does not support a curve with zero points. The new curve is added to the end of the list of curves in the Curve.
- @rtype: CurNurb
- @return: the newly added spline
- @type new_point: BezTriple or list of xyzw coordinates for a Nurb curve.
- @param new_point: see L{CurNurb.append} for description of parameter.
- """
-
- def getLoc():
- """
- Get the curve's location value.
- @rtype: a list of 3 floats.
- """
-
- def setLoc(location):
- """
- Set the curve's location value.
- @rtype: None
- @type location: list[3]
- @param location: The new Curve's location values.
- """
-
- def getRot():
- """
- Get the curve's rotation value.
- @rtype: a list of 3 floats.
- """
-
- def setRot(rotation):
- """
- Set the Curve's rotation value.
- @rtype: None
- @type rotation: list[3]
- @param rotation: The new Curve's rotation values.
- """
-
- def getSize():
- """
- Get the curve's size value.
- @rtype: a list of 3 floats.
- """
-
- def setSize(size):
- """
- Set the curve size value.
- @rtype: None
- @type size: list[3]
- @param size: The new Curve's size values.
- """
-
- def getMaterials():
- """
- Returns a list of materials assigned to the Curve.
- @rtype: list of Material Objects
- @return: list of Material Objects assigned to the Curve.
- """
-
- def getBevOb():
- """
- Returns the Bevel Object (BevOb) assigned to the Curve.
- @rtype: Blender Object or None
- @return: Bevel Object (BevOb) assigned to the Curve.
- """
-
- def setBevOb( object ):
- """
- Assign a Bevel Object (BevOb) to the Curve. Passing None as the object parameter removes the bevel.
- @rtype: None
- @return: None
- @type object: Curve type Blender Object
- @param object: Blender Object to assign as Bevel Object (BevOb)
- @raise TypeError: throws exception if the parameter is not a Curve type Blender Object or None
- """
-
- def getTaperOb():
- """
- Returns the Taper Object (TaperOb) assigned to the Curve.
- @rtype: Blender Object or None
- @return: Taper Object (TaperOb) assigned to the Curve.
- """
-
- def setTaperOb( object ):
- """
- Assign a Taper Object (TaperOb) to the Curve. Passing None as the object parameter removes the taper.
- @rtype: None
- @return: None
- @type object: Curve type Blender Object
- @param object: Blender Object to assign as Taper Object (TaperOb)
- @raise TypeError: throws exception if the parameter is not a Curve type Blender Object or None
- """
-
- def update():
- """
- Updates display list for a Curve.
- Used after making changes to control points.
- You B{must} use this if you want to see your changes!
- @rtype: None
- @return: None
- """
-
- def isNurb( curve_num ):
- """
- Tells type of a CurNurb (B{deprecated}).
- New scripts should use L{CurNurb.isNurb()}.
-
- @rtype: integer
- @return: Zero if curve is type Bezier, one if curve is of type Nurb.
- @type curve_num: integer
- @param curve_num: zero-based index into list of curves in this Curve.
- @raise AttributeError: throws exception if curve_num is out of range.
- """
-
- def isCyclic( curve_num ):
- """
- Tells whether or not a CurNurb is cyclic (closed) (B{deprecated}).
- New scripts should use L{CurNurb.isCyclic()}.
-
- @rtype: boolean
- @return: True if is cyclic, False if not
- @type curve_num: integer
- @param curve_num: zero-based index into list of curves in this Curve
- @raise AttributeError: throws exception if curve_num is out of range.
- """
-
- def switchDirection( ):
- """
- Reverse the direction of a curve.
- @return: None
-
- I{B{Example:}}
- # This example switches the direction of all curves on the active object.
- from Blender import *
- scn = Scene.GetCurrent()
- ob = scn.objects.active # must be a curve
- data = ob.data
- for cu in data: cu.switchDirection()
- """
-
- def getNumCurves():
- """
- Get the number of curves in this Curve Data object.
- @rtype: integer
- """
-
- def getNumPoints( curve_num ):
- """
- Get the number of control points in the curve (B{deprecated}).
- New scripts should use the len operator (I{len(curve)}).
- @type curve_num: integer
- @param curve_num: zero-based index into list of curves in this Curve
- @rtype: integer
- """
-
- def getKey():
- """
- Return the L{Key<Key.Key>} object containing the keyframes for this
- curve, if any.
- @rtype: L{Key<Key.Key>} object or None
- """
-
- def recalc():
- """
- Recalculate control point handles after a curve has been changed.
- @rtype: None
- """
-
- def __copy__ ():
- """
- Make a copy of this curve
- @rtype: Curve
- @return: a copy of this curve
- """
-
-class CurNurb:
- """
- The CurNurb Object
- ==================
- This object provides access to the control points of the curves that make up a Blender Curve ObData.
-
- The CurNurb supports the python iterator protocol which means you can use a python for statement to access the points in a curve.
-
- The CurNurb also supports the sequence protocol which means you can access the control points of a CurNurb using the [] operator.
-
- Note that CurNurb is used for accesing poly, bezier and nurbs type curves.
-
- @ivar flagU: The CurNurb knot flag U. See L{setFlagU} for description.
- @type flagU: int
- @ivar flagV: The CurNurb knot flag V. See L{setFlagU} for description.
- @type flagV: int
- @ivar type: The type of the curve (Poly: 0, Bezier: 1, NURBS: 4)
- @type type: int
- @ivar knotsU: The knot vector in the U direction. The tuple will be empty
- if the curve isn't a NURB or doesn't have knots in this direction.
- @type knotsU: tuple of floats
- @ivar knotsV: The knot vector in the V direction. The tuple will be empty
- if the curve isn't a NURB or doesn't have knots in this direction.
- @type knotsV: tuple of floats
- @ivar smooth: Set the smoothing for this curve (applies to cuve objects that have a bevel)
- @type smooth: bool
- """
-
- def __setitem__( n, point ):
- """
- Replace the Nth point in the curve. The type of the argument must match the type of the curve. List of 4 floats (optional 5th float is the tilt value in radians) for Nurbs or BezTriple for Bezier.
- @rtype: None
- @return: None
- @type n: integer
- @param n: the index of the element to replace
- @type point: BezTriple or list of 4 floats (optional 5th float is the tilt value in radians)
- @param point: the point that will replace the one in the curve. The point can be either a BezTriple type or a list of 4 floats in x,y,z,w (optionally tilt in radians as 5th value) format for a Nurb curve.
- """
-
- def __getitem__( n ):
- """
- Get the Nth element in the curve. For Bezier curves, that element is a BezTriple. For the rest (Poly and Nurbs), it is a list of 5 floats: x, y, z, weight, tilt (in radians). NOTE 1: This element is independent on the curve, modifying it will not affect the curve. NOTE 2: Each successive call returns a new object.
- @rtype: BezTriple (Bezier Curve) or List of 5 floats [x, y, z, w, t] for Poly or Nurbs
- @return: The Nth element in the curve
- @type n: integer
- @param n: the index of the element to return
- """
-
- def append( new_point ):
- """
- Appends a new point to a curve. This method appends points to both Bezier and Nurb curves. The type of the argument must match the type of the curve. List of 4 floats (optional 5th float is the tilt value in radians) for Nurbs or BezTriple for Bezier.
- @rtype: None
- @return: None
- @type new_point: BezTriple or list of 4 floats (optional 5th float is the tilt value in radians)
- @param new_point: the new point to be appended to the curve. The new point can be either a BezTriple type or a list of 4 floats in x,y,z,w (optionally tilt in radians as 5th value) format for a Nurb curve.
- """
-
- def setMatIndex( index ):
- """
- Sets the Material index for this CurNurb.
- @rtype: None
- @return: None
- @type index: integer
- @param index: the new value for the Material number of this CurNurb. No range checking is done.
- """
-
- def getMatIndex():
- """
- Returns the Material index for this CurNurb.
- @rtype: integer
- @return: integer
- """
-
- def isNurb():
- """
- Boolean method used to determine whether a CurNurb is of type Bezier or of type Nurb.
- @rtype: boolean
- @return: True or False
- """
-
- def isCyclic():
- """
- Boolean method checks whether a CurNurb is cyclic (a closed curve) or not.
- @rtype: boolean
- @return: True or False
- """
-
- def getFlagU():
- """
- Get the CurNurb knot flag U.
- @rtype: integer
- @return: See L{setFlagU} for description of return value.
- """
-
- def setFlagU( flag ):
- """
- Set the entire CurNurb knot flag U (knots are recalculated automatically).
- The flag can be one of six values:
- - 0 or 1: uniform knots
- - 2 or 3: endpoints knots
- - 4 or 5: bezier knots
- Bit 0 controls whether or not the curve is cyclic (1 = cyclic).
- @type flag: integer
- @param flag: CurNurb knot flag
- @rtype: None
- @return: None
- """
-
- def getFlagV():
- """
- Get the CurNurb knot flag V.
- @rtype: integer
- @return: See L{setFlagU} for description of return value.
- """
-
- def setFlagV( value ):
- """
- Set the CurNurb knot flag V (knots are recalculated automatically).
- @type value: integer
- @param value: See L{setFlagU} for description of return.
- @rtype: None
- @return: None
- """
-
- def getType():
- """
- Get the type of the curve.
- @rtype: integer
- @return: 0 - Poly, 1 - Bezier, 4 - NURBS
- """
-
- def setType( value ):
- """
- Set the type of the curve and converts the curve to its new type if needed
- @type value: integer
- @param value: CurNurb type flag (0 - Poly, 1 - Bezier, 4 - NURBS)
- @rtype: None
- @return: None
- """
-
-class SurfNurb:
- """
- The SurfNurb Object
- ===================
- This object provides access to the control points of the surfaces that make
- up a Blender Curve.
-
- The SurfNurb supports the Python iterator and sequence protocols which
- means you can use a python B{for} statement or [] operator to access the
- points in a surface. Points are accessed linearly; for a N-by-M UV surface,
- the first N control points correspond to V=0, then second N to V=1, and so
- on.
-
- @ivar flagU: The knot flag U. Changing the knot type automatically
- recalculates the knots. The flag can be one of three values:
- - 0 : uniform knots
- - 1 : endpoints knots
- - 2 : bezier knots
- @type flagU: int
- @ivar flagV: The knot flag V. See L{flagU} for description.
- @type flagV: int
- @ivar pointsU: The number of control points in the U direction (read only).
- @type pointsU: int
- @ivar pointsV: The number of control points in the V direction (read only).
- @type pointsV: int
- @ivar cyclicU: The cyclic setting for the U direction (True = cyclic).
- @type cyclicU: boolean
- @ivar cyclicV: The cyclic setting for the V direction (True = cyclic).
- @type cyclicV: boolean
- @ivar orderU: The order setting for the U direction. Values are clamped
- to the range [2:6] and not greater than the U dimension.
- @type orderU: int
- @ivar orderV: The order setting for the V direction. Values are clamped
- to the range [2:6] and not greater than the V dimension.
- @type orderV: int
- """
-
- def __setitem__( n, point ):
- """
- Set the Nth control point in the surface.
- @rtype: None
- @return: None
- @type n: integer
- @param n: the index of the point to replace
- @type point: list of 4 floats (optional 5th float is the tilt value
- in radians)
- @param point: the point that will replace the one in the curve. The
- point is list of 4 floats in x,y,z,w (optionally tilt in radians as
- 5th value) format.
- """
-
- def __getitem__( n ):
- """
- Get the Nth control point in the surface.
- @rtype: List of 5 floats [x, y, z, w, t] for Poly or Nurbs
- @return: The Nth point in the curve
- @type n: integer
- @param n: the index of the point to return
- @note: This returned value is independent on the curve; modifying it will not affect the curve.
- @note: Each successive call returns a new object.
- """
-
diff --git a/source/blender/python/api2_2x/doc/Curvedoc.txt b/source/blender/python/api2_2x/doc/Curvedoc.txt
deleted file mode 100644
index cb435ff4048..00000000000
--- a/source/blender/python/api2_2x/doc/Curvedoc.txt
+++ /dev/null
@@ -1,105 +0,0 @@
-CURVE Module documentation
-
-
-
-
-INTRODUCTION
-
-The Curve module gives access to the curves objects. Curves are used for many things in blender : creation of graphical objects, duplication of meshes, displacement of meshes, in IPOs for instance.
-Blender has three main types of curves :
- nurbs curves, each control point has three coordinates.
- bezier curves, each control point has nine coordinates.
- text curves, which represent graphical text objects.
-
-
-
-
-
-
-functions of the module :
-
-Get(Name:string) : returns the Curve whose name is Name.
-
-get : same as Get
-
-New(Name:string (optional)) : Creates a new Curve Object.
-If the parameter Name is given, it will be the name of the Curve Object,
-else the name will be choosen by blender.
-
-
-Curve Object member functions :
-
-getName() : Retreives the Curve Object name.
-
-setName(Name : string) : Sets the Curve Object name.
-
-getPathLen() : Retrieves the Curve Object path length.
-
-setPathLen(len:int) : Sets the Curve Object path length.
-
-getTotcol() : Retreives the parameter totcol of the Curve.
-
-setTotcol(val:int) : Sets the parameter totcol
-/*I do not know what means this parameter...*/
-
-getFlag()Retrieves the mode of the Curve Object
-
-setFlag(val:int) :Sets the mode of the Curve.
-
-The mode of the curve is a combination of parameters.
-Bits 0,1,2 : "Back", "Front" and "3D".
-Bit 3 : "CurvePath" is set.
-Bit 4 : "CurveFollow" is set.
-
-getBevresol() : Retreives the bevel resolution of the curve.
-
-setBevresol(val:float) : Sets the bevel resolution of the curve.
-
-getResolu() : Retreives the U-resolution of the curve.
-
-setResolu(val:int) : sets the U-resolution of the curve.
-
-getResolv() : Retreives the V-resolution of the curve.
-
-setResolv(val:int) : sets the V-resolution of the curve.
-
-getWidth() : Retreives the bevel width of the curve.
-
-setWidth(val:float) : Sets the bevel width.
-
-getExt1() : Retreives the bevel height1 of the curve.
-
-setExt1(val:float) : Sets the bevel height1 of the curve.
-
-getExt2() : Retreives the bevel height2 of the curve.
-
-setExt2(val:float) : Sets the bevel height2 of the curve.
-
-getControlPoint(i:int) : Retreives the i-th control point.
-Depending upon the curve type, returne a list of 4(nurbs) or 9(bez) floats.
-
-setControlPoint(i:int, x1:float,...x4:float)
-setControlPoint(i:int, x1:float,...x9:float) : Sets the i-th control point value.
-
-getLoc() : Retreives the Curve location(from the center)
-
-setLoc(x:float,y:float,z:float) : Sets the Curve location
-
-getRot() : Retreives the Curve rotation(from the center)
-
-setRot(x:float,y:float,z:float) : Sets the Curve rotation.
-
-getSize() : Retreives the Curve size.
-
-setSize(x:float,y:float,z:float) : Sets the Curve size.
-
-Direct acces to the parameters values : You cann read and write the parameter XXX with the following syntax :
-val = obj.XXX
-or obj.XXX = val.
-The possible parameters names are :"name","pathlen","resolu","resolv","width","ext1", and "ext2"
-
-
-
-
-
-Submodules : No submodule.
diff --git a/source/blender/python/api2_2x/doc/Draw.py b/source/blender/python/api2_2x/doc/Draw.py
deleted file mode 100644
index 9b6f29b6b51..00000000000
--- a/source/blender/python/api2_2x/doc/Draw.py
+++ /dev/null
@@ -1,880 +0,0 @@
-# Blender.Draw module and the Button PyType object
-
-"""
-The Blender.Draw submodule.
-
-Draw
-====
-
-B{New}:
- - access to ASCII values in L{events<Register>} callbacks;
- - 'large' fonts for L{Text} and L{GetStringWidth}.
- - Pop-up blocks with L{PupBlock}
- - Color Picker button with L{ColorPicker}
-
-This module provides access to a B{windowing interface} in Blender. Its widgets
-include many kinds of buttons: push, toggle, menu, number, string, slider,
-scrollbar, plus support for text drawing. It also includes keyboard keys and
-mouse button code values in its dictionary, see a list after this example.
-
-Example::
- import Blender
- from Blender import Draw, BGL
-
- mystring = ""
- mymsg = ""
- toggle = 0
-
- def event(evt, val): # the function to handle input events
- global mystring, mymsg
-
- if not val: # val = 0: it's a key/mbutton release
- if evt in [Draw.LEFTMOUSE, Draw.MIDDLEMOUSE, Draw.RIGHTMOUSE]:
- mymsg = "You released a mouse button."
- Draw.Redraw(1)
- return
-
- if evt == Draw.ESCKEY:
- Draw.Exit() # exit when user presses ESC
- return
-
- elif Draw.AKEY <= evt <= Draw.ZKEY: mystring += chr(evt)
- elif evt == Draw.SPACEKEY: mystring += ' '
- elif evt == Draw.BACKSPACEKEY and len(mystring):
- mystring = mystring[:-1]
- else: return # no need to redraw if nothing changed
-
- Draw.Redraw(1)
-
- def button_event(evt): # the function to handle Draw Button events
- global mymsg, toggle
- if evt == 1:
- mymsg = "You pressed the toggle button."
- toggle = 1 - toggle
- Draw.Redraw(1)
-
- def gui(): # the function to draw the screen
- global mystring, mymsg, toggle
- if len(mystring) > 90: mystring = ""
- BGL.glClearColor(0,0,1,1)
- BGL.glClear(BGL.GL_COLOR_BUFFER_BIT)
- BGL.glColor3f(1,1,1)
- Draw.Toggle("Toggle", 1, 10, 10, 55, 20, toggle,"A toggle button")
- BGL.glRasterPos2i(72, 16)
- if toggle: toggle_state = "down"
- else: toggle_state = "up"
- Draw.Text("The toggle button is %s." % toggle_state, "small")
- BGL.glRasterPos2i(10, 230)
- Draw.Text("Type letters from a to z, ESC to leave.")
- BGL.glRasterPos2i(20, 200)
- Draw.Text(mystring)
- BGL.glColor3f(1,0.4,0.3)
- BGL.glRasterPos2i(340, 70)
- Draw.Text(mymsg, "tiny")
-
- Draw.Register(gui, event, button_event) # registering the 3 callbacks
-
-All available events:
- - ACCENTGRAVEKEY
- - AKEY
- - BACKSLASHKEY
- - BACKSPACEKEY
- - BKEY
- - CAPSLOCKKEY
- - CKEY
- - COMMAKEY
- - DELKEY
- - DKEY
- - DOWNARROWKEY
- - EIGHTKEY
- - EKEY
- - ENDKEY
- - EQUALKEY
- - ESCKEY
- - F10KEY
- - F11KEY
- - F12KEY
- - F1KEY
- - F2KEY
- - F3KEY
- - F4KEY
- - F5KEY
- - F6KEY
- - F7KEY
- - F8KEY
- - F9KEY
- - FIVEKEY
- - FKEY
- - FOURKEY
- - GKEY
- - HKEY
- - HOMEKEY
- - IKEY
- - INPUTCHANGE
- - INSERTKEY
- - JKEY
- - KEYBD
- - KKEY
- - LEFTALTKEY
- - LEFTARROWKEY
- - LEFTBRACKETKEY
- - LEFTCTRLKEY
- - LEFTMOUSE
- - LEFTSHIFTKEY
- - LINEFEEDKEY
- - LKEY
- - MIDDLEMOUSE
- - MINUSKEY
- - MKEY
- - MOUSEX
- - MOUSEY
- - NINEKEY
- - NKEY
- - OKEY
- - ONEKEY
- - PAD0
- - PAD1
- - PAD2
- - PAD3
- - PAD4
- - PAD5
- - PAD6
- - PAD7
- - PAD8
- - PAD9
- - PADASTERKEY
- - PADENTER
- - PADMINUS
- - PADPERIOD
- - PADPLUSKEY
- - PADSLASHKEY
- - PAGEDOWNKEY
- - PAGEUPKEY
- - PAUSEKEY
- - PERIODKEY
- - PKEY
- - QFULL
- - QKEY
- - QUOTEKEY
- - Q_FIRSTTIME
- - RAWKEYBD
- - REDRAW
- - RETKEY
- - RIGHTALTKEY
- - RIGHTARROWKEY
- - RIGHTBRACKETKEY
- - RIGHTCTRLKEY
- - RIGHTMOUSE
- - RIGHTSHIFTKEY
- - RKEY
- - SEMICOLONKEY
- - SEVENKEY
- - SIXKEY
- - SKEY
- - SLASHKEY
- - SPACEKEY
- - TABKEY
- - THREEKEY
- - TIMER0
- - TIMER1
- - TIMER2
- - TIMER3
- - TKEY
- - TWOKEY
- - UKEY
- - UPARROWKEY
- - VKEY
- - WHEELDOWNMOUSE
- - WHEELUPMOUSE
- - WINCLOSE
- - WINFREEZE
- - WINQUIT
- - WINTHAW
- - WKEY
- - XKEY
- - YKEY
- - ZEROKEY
- - ZKEY
-
-@note: function Button has an alias: L{PushButton}.
-
-@warn: B{very important}: if using your script causes "Error totblock"
-messages when Blender exits (meaning that memory has been leaked), this may
-have been caused by an ignored return value from one of the button types. To
-avoid this, assign created buttons return values to B{global} variables,
-instead of ignoring them. Examples::
-
- # avoid this, it can cause memory leaks:
- Draw.Toggle(...)
- Draw.Number(...)
- Draw.String(...)
- # this is correct -- assuming the variables are globals:
- my_toggle_button = Draw.Toggle(...)
- my_int_button = Draw.Number(...)
- my_str_button = Draw.String(...)
-
-
-@warn: Inside the windowing loop (after Draw.Register() has been executed and
-before Draw.Exit() is called), don't use the redraw functions from other
-modules (Blender and Window). The Draw submodule has its own Draw.Redraw() and
-Draw.Draw() functions that can be used inside the windowing loop.
-"""
-
-def Exit():
- """
- Exit the windowing interface.
- """
-
-def BeginAlign():
- """
- Buttons after this function will draw aligned (button layout only).
- """
-
-def EndAlign():
- """
- Use after BeginAlign() to stop aligning the buttons (button layout only).
- """
-
-def UIBlock(draw):
- """
- This function creates a popup area where buttons, labels, sliders etc can be drawn.
-
- @type draw: function
- @param draw: A function to draw to the popup area, taking no arguments: draw().
-
- @note: The size of the popup will expand to fit the bounds of the buttons created in the draw function.
- @note: Be sure to use the mouse coordinates to position the buttons under the mouse,
- so the popup dosn't exit as soon as it opens.
- The coordinates for buttons start 0,0 at the bottom left hand side of the screen.
- @note: Within this popup, Redraw events and the registered button callback will not work.
- For buttons to run events, use per button callbacks.
- @note: OpenGL drawing functions wont work within this popup, for text use L{Label} rather then L{Text}
- @warning: L{Menu} will not work properly within a UIBlock, this is a limitation with blenders user interface internals.
- """
-
-def Register(draw = None, event = None, button = None):
- """
- Register callbacks for windowing.
- @type draw: function
- @type event: function
- @type button: function
- @param draw: A function to draw the screen, taking no arguments: draw().
- @param event: A function to handle keyboard and mouse input events, taking
- two arguments: f(evt, val), where:
- - 'evt' (int) is the event number;
- - 'val' (int) is the value modifier. If val = 0, the event refers to a
- key or mouse button being released. Otherwise it's a key/button press.
- @param button: A function to handle Draw Button events, taking one argument:
- f(evt), where:
- - 'evt' is the button number (see the I{event} parameter in L{Button}).
- @note: note that in the example at the beginning of this page Draw.Register
- is called only once. It's not necessary to re-register the callbacks,
- they will stay until Draw.Exit is called. It's enough to redraw the
- screen, when a relevant event is caught.
- @note: only during the B{event} callback: the L{Blender}.ascii variable holds
- the ASCII integer value (if it exists and is valid) of the current event.
- """
-
-def Redraw(after = 0):
- """
- Queue a redraw event. Redraw events are buffered so that, regardless of how
- many events are queued, the window only receives one redraw event.
- @type after: int
- @param after: If non-zero, the redraw is processed before other input events.
- """
-
-def Draw():
- """
- Force an immediate redraw. Forced redraws are not buffered. In other words,
- the window is redrawn once every time this function is called.
- """
-
-def Create(value):
- """
- Create a default Button object.
- @type value: int, float, string or 3 floats
- @param value: The value to store in the button.
- @rtype: Blender Button
- @return: The Button created.
- @note: String values must have less then 400 characters.
- """
-
-def PushButton(name, event, x, y, width, height, tooltip = None, callback = None):
- """
- Create a new (push) Button object.
- @type name: string
- @param name: The string to display on the button.
- @type event: int
- @param event: The event number to pass to the button event function when
- activated.
- @type x: int
- @type y: int
- @param x: The lower left x (horizontal) coordinate of the button.
- @param y: The lower left y (vertical) coordinate of the button.
- @type width: int
- @type height: int
- @param width: The button width.
- @param height: The button height.
- @type tooltip: string
- @param tooltip: The button's tooltip (the string that appears when the mouse
- is kept over the button).
- @type callback: function
- @param callback: an optional argument so this button can have its own
- callback function. the function will run whenever this button is pressed.
- This function must accept 2 arguments (event, val).
- @note: This function used to be called only "Button". We added an
- alternative alias to avoid a name clash with the L{Button} class/type that
- caused trouble in this documentation's generation. The old name shouldn't
- be deprecated, use Button or PushButton (better) at your choice.
- """
-
-def PupMenu(name, maxrow = None):
- """
- Create a pop-up menu.
-
- The menu options are specified through the 'name' parameter, like with
- L{Menu}: options are followed by a format code and separated by the '|'
- character. Valid format codes are:
- - %t - The option should be used as the title of the pop-up;
- - %l - insert a separating line (only works if 'maxrow' isn't given);
- - %xB{N} - Chosen this option, PupMenu should return the integer B{N}.
-
- Example::
- name = "OK?%t|QUIT BLENDER" # if no %xN int is set, indices start from 1
- result = Draw.PupMenu(name)
- if result:
- Draw.PupMenu("Really?%t|Yes|No")
-
- @type name: string
- @param name: The format string to define the contents of the button.
- @type maxrow: int
- @param maxrow: The maximum number of rows for each column in the pop-up.
- @rtype: int
- @return: the chosen entry number or -1 if none was chosen.
- """
-
-def PupIntInput(text, default, min, max):
- """
- Create an integer number input pop-up.
-
- This allows python to use Blender's integer number pop-up input.
-
- Example::
- default = 50
- min = 0
- max = 100
-
- msg = "Set this value between 0 and 100"
- result = Draw.PupIntInput(msg, default, min, max)
- if result != None:
- print result
- else:
- print 'no user input'
-
- @type text: string
- @param text: The text that is displayed in the pop-up.
- @type default: int
- @param default: The value that the pop-up is set to initially.
- @type min: int
- @param min: The lowest value the pop-up will allow.
- @type max: int
- @param max: The highest value the pop-up will allow.
- @rtype: int
- @return: the number chosen or None if none was chosen.
- """
-
-def PupFloatInput(text, default, min, max, clickStep, floatLen):
- """
- Create a floating point number input pop-up.
-
- This allows python to use Blender's floating point pop-up input.
-
- Example::
- default = 50
- min = 0.0
- max = 10.0
- clickStep = 100
- floatLen = 3
-
- msg = "Set this value between 0 and 100"
- result = Draw.PupFloatInput(msg, default, min, max, clickStep, floatLen)
- if result != None:
- print result
- else:
- print 'no user input'
-
- @type text: string
- @param text: The text that is displayed in the pop-up.
- @type default: float
- @param default: The value that the pop-up is set to initially.
- @type min: float
- @param min: The lowest value the pop-up will allow.
- @type max: float
- @param max: The highest value the pop-up will allow.
- @type clickStep: int
- @param clickStep: How much is incremented per user click, 100 will increment 1.0, 10 will increment 0.1 etc.
- @type floatLen: int
- @param floatLen: The number of decimal places to display, between 2 and 4.
- @rtype: float
- @return: the number chosen or None if none was chosen.
- """
-
-def PupStrInput(text, default, max = 20):
- """
- Create a string input pop-up.
-
- This allows python to use Blender's string pop-up input.
-
- Example::
- Blender.Draw.PupStrInput("Name:", "untitled", 25)
-
- @type text: string
- @param text: The text that is displayed in the pop-up.
- @type default: string
- @param default: The value that the pop-up is set to initially. If it's longer
- then 'max', it's truncated.
- @type max: int
- @param max: The most characters the pop-up input will allow. If not given
- it defaults to 20 chars. It should be in the range [1, 100].
- @rtype: string
- @return: The text entered by the user or None if none was chosen.
- """
-
-def PupBlock(title, sequence):
- """
- Display a pop-up block.
-
- Possible formats for the items in the sequence parameter.
- (Value are objects created with L{Create})
- - string: Defines a label
- - (string, Value, string): Defines a toggle button. The first string is the text on the button, the optional second string is the tooltip.
- - (string, Value, min, max, string): Defines a numeric or string button, depending on the content of Value. The first string is the text on the button, the optional second string is the tooltip. I{For string, max is the maximum length of the string and min is unused.}
-
- Example::
- import Blender
-
- text = Blender.Draw.Create("short text")
- f = Blender.Draw.Create(1.0)
- i = Blender.Draw.Create(2)
- tog = Blender.Draw.Create(0)
-
- block = []
-
- block.append(("Name: ", text, 0, 30, "this is some tool tip"))
- block.append("Some Label")
- block.append(("Value: ", f, 0.0, 100.0))
- block.append(("Value: ", i, 0, 100))
- block.append(("Option", tog, "another tooltip"))
-
- retval = Blender.Draw.PupBlock("PupBlock test", block)
-
- print "PupBlock returned", retval
-
- print "text\\t", text
- print "float\\t", f
- print "int\\t", i
- print "toggle\\t", tog
-
- @warning: On cancel, the Value objects are brought back to there initial values except for string values which will still contain the modified values.
- @type title: string
- @param title: The title of the block.
- @param sequence: A sequence defining what the block contains.
- The order of the list is the order of appearance, from top down.
- @rtype: int
- @return: 1 if the pop-up is confirmed, 0 otherwise
- """
-
-def Menu(name, event, x, y, width, height, default, tooltip = None, callback = None):
- """
- Create a new Menu Button object.
-
- The menu options are specified through the 'name' of the button. Options are
- I{followed} by a format code and separated by the '|' (pipe) character. Valid
- format codes are:
- - %t - The option should be used as the title;
- - %l - Insert a separating line;
- - %xB{N} - The option should set the integer B{N} in the button value.
-
- Example::
- name = "The Title %t|First Entry %x1|Second Entry %x2|Third Entry %x3"
- menu = Draw.Menu(name, 2, 60, 120, 200, 40, 3, "Just a test menu.")
- # note that, since default = 3, the "Third Entry"
- # will appear as the default choice in the Menu.
-
- @type name: string
- @param name: The format string to define the contents of the button.
- @type event: int
- @param event: The event number to pass to the button event function when
- activated.
- @type x: int
- @type y: int
- @param x: The lower left x (horizontal) coordinate of the button.
- @param y: The lower left y (vertical) coordinate of the button.
- @type width: int
- @type height: int
- @param width: The button width.
- @param height: The button height.
- @type default: int
- @param default: The number of the option to be selected by default.
- @type tooltip: string
- @param tooltip: The button's tooltip (the string that appears when the mouse
- is kept over the button).
- @type callback: function
- @param callback: an optional argument so this button can have its own
- callback function. the function will run whenever this button is pressed.
- This function must accept 2 arguments (event, val).
- @rtype: Blender Button
- @return: The Button created.
- """
-
-def Toggle(name, event, x, y, width, height, default, tooltip = None, callback = None):
- """
- Create a new Toggle Button object.
- @type name: string
- @param name: The string to display on the button.
- @type event: int
- @param event: The event number to pass to the button event function when
- activated.
- @type x: int
- @type y: int
- @param x: The lower left x (horizontal) coordinate of the button.
- @param y: The lower left y (vertical) coordinate of the button.
- @type width: int
- @type height: int
- @param width: The button width.
- @param height: The button height.
- @type default: int
- @param default: The value specifying the default state:
- (0 for "up", 1 for "down").
- @type tooltip: string
- @param tooltip: The button's tooltip (the string that appears when the mouse
- is kept over the button).
- @type callback: function
- @param callback: an optional argument so this button can have its own
- callback function. the function will run whenever this button is pressed.
- This function must accept 2 arguments (event, val).
- @rtype: Blender Button
- @return: The Button created.
- """
-
-def Slider(name, event, x, y, width, height, initial, min, max, realtime = 1,
- tooltip = None, callback = None):
- """
- Create a new Slider Button object.
- @type name: string
- @param name: The string to display on the button.
- @type event: int
- @param event: The event number to pass to the button event function when
- activated.
- @type x: int
- @type y: int
- @param x: The lower left x (horizontal) coordinate of the button.
- @param y: The lower left y (vertical) coordinate of the button.
- @type width: int
- @type height: int
- @param width: The button width.
- @param height: The button height.
- @type initial: int or float
- @type min: int or float
- @type max: int or float
- @param initial: The initial value.
- @param min: The minimum value.
- @param max: The maximum value.
- @type realtime: int
- @param realtime: If non-zero (the default), the slider will emit events as
- it is edited.
- @type tooltip: string
- @param tooltip: The button's tooltip (the string that appears when the mouse
- is kept over the button).
-
- @type callback: function
- @param callback: an optional argument so this button can have its own
- callback function. the function will run whenever this button is pressed.
- This function must accept 2 arguments (event, val).
- @rtype: Blender Button
- @return: The Button created.
- @note: slider callbacks will not work if the realtime setting is enabled.
- """
-
-#def Scrollbar(event, x, y, width, height, initial, min, max, realtime = 1,
-# tooltip = None):
-# """
-# Create a new Scrollbar Button object.
-# @type event: int
-# @param event: The event number to pass to the button event function when
-# activated.
-# @type x: int
-# @type y: int
-# @param x: The lower left x (horizontal) coordinate of the button.
-# @param y: The lower left y (vertical) coordinate of the button.
-# @type width: int
-# @type height: int
-# @param width: The button width.
-# @param height: The button height.
-# @type initial: int or float
-# @type min: int or float
-# @type max: int or float
-# @param initial: The initial value.
-# @param min: The minimum value.
-# @param max: The maximum value.
-# @type realtime: int
-# @param realtime: If non-zero (the default), the slider will emit events as
-# it is edited.
-# @type tooltip: string
-# @param tooltip: The button's tooltip (the string that appears when the mouse
-# is kept over the button).
-# @rtype: Blender Button
-# @return: The Button created.
-# """
-
-def ColorPicker(event, x, y, width, height, initial, tooltip = None, callback = None):
- """
- Create a new Color Picker Button object.
- @type event: int
- @param event: The event number to pass to the button event function when
- activated.
- @type x: int
- @type y: int
- @param x: The lower left x (horizontal) coordinate of the button.
- @param y: The lower left y (vertical) coordinate of the button.
- @type width: int
- @type height: int
- @param width: The button width.
- @param height: The button height.
- @type initial: 3-float tuple
- @param initial: The initial color value. All values must be between 0 and 1
- @type tooltip: string
- @param tooltip: The button's tooltip (the string that appears when the mouse
- is kept over the button).
- @type callback: function
- @param callback: an optional argument so this button can have its own
- callback function. the function will run whenever this button is pressed.
- This function must accept 2 arguments (event, val).
- @rtype: Blender Button
- @return: The Button created.
- @note: The color picker will not work if the Register's event function is None.
- @note: Using the same button variable with more then 1 button at a time will corrupt memory.
- """
-
-def Normal(event, x, y, width, height, initial, tooltip = None, callback = None):
- """
- Create a new Normal button, this allows you to set a 3d vector by rotating a sphere.
- @type event: int
- @param event: The event number to pass to the button event function when
- activated.
- @type x: int
- @type y: int
- @param x: The lower left x (horizontal) coordinate of the button.
- @param y: The lower left y (vertical) coordinate of the button.
- @type width: int
- @type height: int
- @param width: The button width - non square normal buttons .
- @param height: The button height.
- @type initial: 3-float tuple
- @param initial: The initial vector value.
- @type tooltip: string
- @param tooltip: The button's tooltip (the string that appears when the mouse
- is kept over the button).
- @type callback: function
- @param callback: an optional argument so this button can have its own
- callback function. the function will run whenever this button is pressed.
- This function must accept 2 arguments (event, val).
- @rtype: Blender Button
- @return: The Button created.
- @note: The normal button will not work if the Register's event function is None.
- @note: Using the same button variable with more then 1 button at a time will corrupt memory.
- """
-
-def Number(name, event, x, y, width, height, initial, min, max, tooltip = None, callback = None):
- """
- Create a new Number Button object.
- @type name: string
- @param name: The string to display on the button.
- @type event: int
- @param event: The event number to pass to the button event function when
- activated.
- @type x: int
- @type y: int
- @param x: The lower left x (horizontal) coordinate of the button.
- @param y: The lower left y (vertical) coordinate of the button.
- @type width: int
- @type height: int
- @param width: The button width.
- @param height: The button height.
- @type initial: int or float
- @type min: int or float
- @type max: int or float
- @param initial: The initial value.
- @param min: The minimum value.
- @param max: The maximum value.
- @type tooltip: string
- @param tooltip: The button's tooltip (the string that appears when the mouse
- is kept over the button).
- @type callback: function
- @param callback: an optional argument so this button can have its own
- callback function. the function will run whenever this button is pressed.
- This function must accept 2 arguments (event, val).
- @rtype: Blender Button
- @return: The Button created.
-
- I{B{Example:}}
-
- This example draws a single floating point value::
- from Blender import Draw
- b= Draw.Create(0.0) # Data for floating point button
- def bevent(evt):
- print 'My Button event:', evt
- def gui():
- global b
- b= Draw.Number('value: ', 1000, 0,0, 200, 20, b.val, 0,10, 'some text tip')
-
- Draw.Register(gui, None, bevent) # we are not going to worry about keyboard and mouse events
- """
-
-
-def String(name, event, x, y, width, height, initial, length, tooltip = None, callback = None):
- """
- Create a new String Button object.
- @type name: string
- @param name: The string to display on the button.
- @type event: int
- @param event: The event number to pass to the button event function when
- activated.
- @type x: int
- @type y: int
- @param x: The lower left x (horizontal) coordinate of the button.
- @param y: The lower left y (vertical) coordinate of the button.
- @type width: int
- @type height: int
- @param width: The button width.
- @param height: The button height.
- @type initial: string
- @param initial: The string to display initially.
- @type length: int
- @param length: The maximum input length.
- @type tooltip: string
- @param tooltip: The button's tooltip (the string that appears when the mouse
- is kept over the button).
- @type callback: function
- @param callback: an optional argument so this button can have its own
- callback function. the function will run whenever this button is pressed.
- This function must accept 2 arguments (event, val).
- @rtype: Blender Button
- @return: The Button created.
- """
-
-def GetStringWidth(string, fontsize = 'normal'):
- """
- Get the width in pixels of a string.
- @type string: string
- @param string: A string.
- @type fontsize: string
- @param fontsize: The size of the font: 'large', 'normal', 'small' or 'tiny'.
- @rtype: int
- @return: The width of I{string} with the chosen I{fontsize}.
- """
-
-def Text(string, fontsize = 'normal'):
- """
- Draw a string on the screen.
-
- Text location is set using the OpenGL raster location functions L{BGL.glRasterPos} before the text is drawn.
- This sets the text location from the lower left corner of the current window.
-
- Text color is set using the OpenGL color functions L{BGL.glColor} before the text is drawn.
-
- @type string: string
- @param string: The text string to draw.
- @type fontsize: string
- @param fontsize: The size of the font: 'large', 'normal', 'small' or 'tiny'.
- @rtype: int
- @return: The width of I{string} drawn with the chosen I{fontsize}.
- @note: For drawing text in the 3d view see the workaround in L{BGL.glRasterPos}
- """
-
-def Label(string, x, y, w, h):
- """
- Draw a text lable on the screen.
-
- @type string: string
- @param string: The text string to draw.
- @rtype: None
- @return: None
- """
-
-def Image(image, x, y, zoomx=1.0, zoomy=1.0, clipx=0, clipy=0, clipw=-1, cliph=-1):
- """
- Draw an image on the screen.
-
- The image is drawn at the location specified by the coordinates (x,y). A
- pair of optional zoom factors (in horizontal and vertical directions) can
- be applied to the image as it is drawn, and an additional clipping rectangle
- can be applied to extract a particular sub-region of the image to draw.
-
- Note that the clipping rectangle is given in image space coordinates. In
- image space, the origin is located at the bottom left, with x coordinates
- increasing to the right and y coordinates increasing upwards. No matter
- where the clipping rectangle is placed in image space, the lower-left pixel
- drawn on the screen is always placed at the coordinates (x,y). The
- clipping rectangle is itself clipped to the dimensions of the image. If
- either the width or the height of the clipping rectangle are negative then
- the corresponding dimension (width or height) is set to include as much of
- the image as possible.
-
- For drawing images with alpha blending with the background you will need to enable blending as shown in the example.
-
- Example::
- import Blender
- from Blender import BGL, Image, Draw
-
- myimage = Image.Load('myimage.png')
-
- def gui():
- BGL.glEnable( BGL.GL_BLEND ) # Only needed for alpha blending images with background.
- BGL.glBlendFunc(BGL.GL_SRC_ALPHA, BGL.GL_ONE_MINUS_SRC_ALPHA)
-
- Draw.Image(myimage, 50, 50)
-
- BGL.glDisable( BGL.GL_BLEND )
- def event(evt, val):
- if evt == Draw.ESCKEY:
- Draw.Exit()
-
- Draw.Register(gui, event, None)
-
- @type image: Blender.Image
- @param image: The image to draw.
- @type x: int
- @param x: The lower left x (horizontal) position of the origin of the image.
- @type y: int
- @param y: The lower left y (vertical) position of the origin of the image.
- @type zoomx: float
- @param zoomx: The x (horizontal) zoom factor to use when drawing the image.
- @type zoomy: float
- @param zoomy: The y (vertical) zoom factor to use when drawing the image.
- @type clipx: int
- @param clipx: The lower left x (horizontal) origin of the clipping rectangle
- within the image. A value of 0 indicates the left of the
- image.
- @type clipy: int
- @param clipy: The lower left y (vertical) origin of the clipping rectangle
- within the image. A value of 0 indicates the bottom of the
- image.
- @type clipw: int
- @param clipw: The width of the clipping rectangle within the image. If this
- value is negative then the clipping rectangle includes as much
- of the image as possible in the x (horizontal) direction.
- @type cliph: int
- @param cliph: The height of the clipping rectangle within the image. If this
- value is negative then the clipping rectangle includes as much
- of the image as possible in the y (vertical) direction.
- """
-
-class Button:
- """
- The Button object
- =================
- This object represents a button in Blender's GUI.
- @type val: int or float, string or 3-float tuple (depends on button type).
- @ivar val: The button's value.
- """
diff --git a/source/blender/python/api2_2x/doc/Effect.py b/source/blender/python/api2_2x/doc/Effect.py
deleted file mode 100644
index 70f4287ae36..00000000000
--- a/source/blender/python/api2_2x/doc/Effect.py
+++ /dev/null
@@ -1,590 +0,0 @@
-# Blender.Effect module and the Effect PyType effect
-
-"""
-The Blender.Effect submodule
-
-B{new}: now L{Get}('objname') (without specifying second parameter: 'position') returns a list of all effects linked to object "objname".
-
-Effect
-======
-
-INTRODUCTION
-
-The Effect module allows you to access all the data of particle effects.
-An effect can modify a mesh object using particles, where vertex of
-the mesh emits particles, which can themselves emit new particles.
-
-In the Blender internals, the effect object is just a placeholder for
-the particle effect. Prior to v2.39 build and wave effects were also
-supported by Blender, and the Python API supported all three types of
-effects. They were removed in v2.39 when the build and wave modifiers
-were implemented.
-
-
-Example::
- import Blender
- listffects = Blender.Effect.Get()
- print listeffects
- eff = listeffects[0]
- #we suppose the first effect is a build effect
- print eff.getLen()
- eff.setLen(500)
-
-@type Flags: read-only dictionary
-@var Flags: The particle effect flags. Values can be ORed.
- - SELECTED: The particle effect is selected in the UI. (Read-only)
- - BSPLINE: Use a B-spline formula for particle interpolation
- - STATIC: Make static particles
- - ANIMATED: Recalculate static particles for each rendered frame
- - VERTS: Emit particles from vertices
- - FACES: Emit particles from faces
- - EVENDIST: Use even distribution based on face area (requires FACES)
- - TRUERAND: Use true random distribution based on face area (requires FACES)
- - UNBORN: Make particles appear before they are emitted
- - DIED: Make particles appear after they have died
- - EMESH: Render emitter mesh
-
-@type SpeedTypes: read-only dictionary
-@var SpeedTypes: The available settings for selecting particle speed vectors.
-Only one setting is active at a time.
- - INTENSITY: Use texture intensity
- - RGB: Use RGB values
- - GRADIENT: Use texture gradient
-"""
-
-def New (name):
- """
- Creates a new particle effect and attaches to an object.
- @type name: string
- @param name: The name of object to associate with the effect. Only mesh
- objects are supported.
- @rtype: Blender Effect
- @return: the new effect
- """
-
-def Get (name = None, position = None):
- """
- Get an Effect from Blender.
- @type name: string
- @param name: The name of object linked to the effect.
- @type position: int
- @param position: The position of the effect in the list of effects linked to the object.
- @rtype: Blender Effect or a list of Blender Effects
- @return: It depends on the 'objname, position' parameters:
- - (): A list with all Effects in the current scene;
- - (name): A list with all Effects linked to the given object;
- - (name, position): The Effect linked to the given object at the given position
- """
-
-class Effect:
- """
- The Effect object
- =================
- This object gives access to particle effect data in Blender.
-
- @ivar child: The number of children a particle may have.
- Values are clamped to the range [1,600].
- @type child: tuple of 4 ints
- @ivar childMat: The materials used by the 4 generation particles.
- Values are clamped to the range [1,16].
- @type childMat: tuple of 4 ints
- @ivar damping: The particle damping factor. This controls the rate at
- which particles decelerate.
- Values are clamped to the range [0.0,1.0].
- @type damping: float
- @ivar defvec: The x, y and z axis of the force defined by the texture.
- Values are clamped to the range [-1.0,1.0].
- @type defvec: tuple of 3 floats
- @ivar disp: The percentage of particles displayed.
- Value is clamped to the range [0,100].
- @type disp: int
- @ivar dispMat: The material used for the particles.
- Value is clamped to the range [1,16].
- @type dispMat: int
- @ivar emissionTex: The texture used for texture emission.
- Value is clamped to the range [1,10].
- @type emissionTex: int
- @ivar end: The end time of the effect.
- Value is clamped to the range [1.0,30000.0].
- @type end: float
- @ivar flag: The flag bitfield. See L{Flags} for values.
- @type flag: int
- @ivar force: The constant force applied to the parts.
- Values are clamped to the range [-1.0,1.0].
- @type force: tuple of 3 floats
- @ivar forceTex: The texture used for force.
- Value is clamped to the range [1,10].
- @type forceTex: int
- @ivar jitter: Jitter table distribution: maximum particles per face.
- Values are clamped to the range [0,200].
- @type jitter: int
- @ivar life: The lifetime of of the next generation of particles.
- Values are clamped to the range [1.0,30000.0].
- @type life: tuple of 4 floats
- @ivar lifetime: The lifetime of the effect.
- Value is clamped to the range [1.0,30000.0].
- @type lifetime: float
- @ivar mult: The probabilities of a particle having a child.
- Values are clamped to the range [0.0,1.0].
- @type mult: tuple of 4 floats
- @ivar nabla: The nabla value.
- Value is clamped to the range [0.0001,1.0].
- @type nabla: float
- @ivar normfac: The normal strength of the particles relative to mesh.
- Value is clamped to the range [-2.0,2.0].
- @type normfac: float
- @ivar obfac: The strength of the particles relative to objects.
- Value is clamped to the range [-1.0,1.0].
- @type obfac: float
- @ivar randfac: The initial random speed of the particles.
- Value is clamped to the range [0.0,2.0].
- @type randfac: float
- @ivar randlife: The variability of the life of the particles.
- Value is clamped to the range [0.0,2.0].
- @type randlife: float
- @ivar seed: The seed of the random number generator.
- Value is clamped to the range [0,255].
- @type seed: int
- @ivar speedType: Controls which texture property affects particle speeds.
- See L{SpeedTypes} for values and their meanings.
- @type speedType: int
- @ivar speedVGroup: The name of the vertex group used for speed control.
- @type speedVGroup: str
- @ivar sta: The start time of the effect.
- Value is clamped to the range [-250.0,30000.0].
- @type sta: float
- @ivar staticStep: percentage of skipped particles in static display.
- Value is clamped to the range [1,100].
- @type staticStep: int
- @ivar stype: The bitfield for vector.
- @type stype: int
- @ivar texfac: The initial speed of the particles caused by the texture.
- Value is clamped to the range [0.0,2.0].
- @type texfac: float
- @ivar totpart: The total number of particles.
- Value is clamped to the range [1,100000].
- @type totpart: int
- @ivar totkey: The total number of key positions.
- Value is clamped to the range [1,100].
- @type totkey: int
- @ivar type: The type of the effect. Deprecated.
- @type type: int
- @ivar vectsize: The size of vectors associated to the particles (if any).
- Value is clamped to the range [0.0,1.0].
- @type vectsize: float
- @ivar vGroup: The name of the vertex group used for emitted particles.
- @type vGroup: str
- """
-
- def getType():
- """
- Retrieves the type of an effect object.
- Deprecated, since only particle effects are supported.
- @rtype: int
- @return: the type of an effect object : should always return 1
- (particle effect)
- """
-
- def setType(name):
- """
- Deprecated, since only particle effects are supported.
- @type name: int
- @param name : the new type.
- @rtype: None
- @return: None
- """
-
- def getFlag():
- """
- Retrieves the flag of an effect object. The flag is a bit-mask.
- @rtype: int
- @return: The flag of the effect is a combination of parameters. See
- L{Flags} for values.
-
- """
-
- def setFlag(newflag):
- """
- Sets the flag of an effect object. See L{Flags} for values.
- @type newflag: int
- @param newflag: the new flag.
- @rtype: None
- @return: None
- """
-
- def getStartTime():
- """
- Retrieves the starting time of a particle effect object
- @rtype: float
- @return: the starting time of the effect.
- """
-
- def setSta(newstart):
- """
- Sets the starting time of an particle effect object
- @type newstart: float
- @param newstart: the new starting time.
- @rtype: None
- @return: None
- """
-
- def getEndTime():
- """
- Retrieves the end time of a particle effect object
- @rtype: float
- @return: the end time of the effect.
- """
-
- def setEnd(newendrt):
- """
- Sets the end time of an particle effect object
- @type newendrt: float
- @param newendrt: the new end time.
- @rtype: None
- @return: None
- """
-
- def getLifetime():
- """
- Retrieves the lifetime of a particle effect object
- @rtype: float
- @return: the lifetime of the effect.
- """
-
-
- def setLifetime(newlifetime):
- """
- Sets the lifetime of a particle effect object
- @type newlifetime: float
- @param newlifetime: the new lifetime.
- @rtype: None
- @return: None
- """
-
- def getNormfac():
- """
- Retrieves the normal strength of the particles (relatively to mesh).
- @rtype: float
- @return: normal strength of the particles (relatively to mesh).
- """
-
- def setNormfac(newnormfac):
- """
- Sets the normal strength of the particles (relatively to mesh).
- @type newnormfac: float
- @param newnormfac: the normal strength of the particles (relatively to mesh).
- @rtype: None
- @return: None
- """
-
- def getObfac():
- """
- Retrieves the initial strength of the particles relatively to objects.
- @rtype: float
- @return: initial strength of the particles (relatively to mesh).
- """
-
- def setObfac(newobfac):
- """
- Sets the initial strength of the particles relatively to objects.
- @type newobfac: float
- @param newobfac: the initial strength of the particles relatively to objects.
- @rtype: None
- @return: None
- """
-
- def getRandfac():
- """
- Retrieves the random strength applied to the particles.
- @rtype: float
- @return: random strength applied to the particles.
- """
-
- def setRandfac(newrandfac):
- """
- Sets the random strength applied to the particles.
- @type newrandfac: float
- @param newrandfac: the random strength applied to the particles.
- @rtype: None
- @return: None
- """
-
- def getStype():
- """
- Retrieves the vect state of an effect object.
- @rtype: int
- @return: the Stype (Vect) of an effect object : 0 , Vect is not enabled, 1, Vect is enabled
- (particle effect)
- """
-
- def setStype(int):
- """
- @type int : int
- @param int : state of the Stype : 0 not enabled, 1 enabled.
- @rtype: None
- @return: None
- """
-
- def getTexfac():
- """
- Retrieves the strength applied to the particles from the texture of the object.
- @rtype: float
- @return: strength applied to the particles from the texture of the object.
- """
-
- def setTexfac(newtexfac):
- """
- Sets the strength applied to the particles from the texture of the object.
- @type newtexfac: float
- @param newtexfac: the strength applied to the particles from the texture of the object.
- @rtype: None
- @return: None
- """
-
- def getRandlife():
- """
- Retrieves the variability of the life of the particles.
- @rtype: float
- @return: variability of the life of the particles.
- """
-
- def setRandlife(newrandlife):
- """
- Sets the variability of the life of the particles.
- @type newrandlife: float
- @param newrandlife: the variability of the life of the particles.
- @rtype: None
- @return: None
- """
-
- def getNabla():
- """
- Retrieves the sensibility of the particles to the variations of the texture.
- @rtype: float
- @return: sensibility of the particles to the variations of the texture.
- """
-
-
- def setNabla(newnabla):
- """
- Sets the sensibility of the particles to the variations of the texture.
- @type newnabla: float
- @param newnabla: the sensibility of the particles to the variations of the texture.
- @rtype: None
- @return: None
- """
-
- def getVectsize():
- """
- Retrieves the size of the vector which is associated to the particles.
- @rtype: float
- @return: size of the vector which is associated to the particles.
- """
-
-
- def setVectsize(newvectsize):
- """
- Sets the size of the vector which is associated to the particles.
- @type newvectsize: float
- @param newvectsize: the size of the vector which is associated to the particles.
- @rtype: None
- @return: None
- """
-
- def getTotpart():
- """
- Retrieves the total number of particles.
- @rtype: int
- @return: the total number of particles.
- """
-
-
- def setTotpart(newtotpart):
- """
- Sets the the total number of particles.
- @type newtotpart: int
- @param newtotpart: the the total number of particles.
- @rtype: None
- @return: None
- """
-
- def getTotkey():
- """
- Retrieves the number of keys associated to the particles (kind of degree of freedom)
- @rtype: int
- @return: number of keys associated to the particles.
- """
-
- def setTotkey(newtotkey):
- """
- Sets the number of keys associated to the particles.
- @type newtotkey: int
- @param newtotkey: number of keys associated to the particles.
- @rtype: None
- @return: None
- """
-
- def getSeed():
- """
- Retrieves the random number generator seed.
- @rtype: int
- @return: current seed value.
- """
-
- def setSeed(newseed):
- """
- Sets the random number generator seed.
- @type newseed: int
- @param newseed: new seed value.
- @rtype: None
- @return: None
- """
-
- def getForce():
- """
- Retrieves the force applied to the particles.
- @rtype: tuple of three floats
- @return: force applied to the particles.
- """
-
- def setForce(newforce):
- """
- Sets the force applied to the particles.
- @type newforce: tuple of 3 floats
- @param newforce: force applied to the particles.
- @rtype: None
- @return: None
- """
-
- def getMult():
- """
- Retrieves the probabilities of a particle having a child.
- @rtype: tuple of 4 floats
- @return: probabilities of a particle having a child.
- """
-
- def setMult(newmult):
- """
- Sets the probabilities of a particle having a child.
- @type newmult: tuple of 4 floats
- @param newmult: probabilities of a particle having a child.
- @rtype: None
- @return: None
- """
-
- def getLife():
- """
- Retrieves the average life of the particles (4 generations)
- @rtype: tuple of 4 floats
- @return: average life of the particles (4 generations)
- """
-
- def setLife(newlife):
- """
- Sets the average life of the particles (4 generations).
- @type newlife: tuple of 4 floats
- @param newlife: average life of the particles (4 generations).
- @rtype: None
- @return: None
- """
-
- def getChild():
- """
- Retrieves the average number of children of the particles (4 generations).
- @rtype: tuple of 4 ints
- @return: average number of children of the particles (4 generations).
- """
-
- def setChild(newchild):
- """
- Sets the average number of children of the particles (4 generations).
- @type newchild: tuple of 4 ints
- @param newchild: average number of children of the particles (4 generations).
- @rtype: None
- @return: None
- """
-
- def getMat():
- """
- Retrieves the indexes of the materials associated to the particles (4 generations).
- @rtype: tuple of 4 ints
- @return: indexes of the materials associated to the particles (4 generations).
- """
-
- def setMat(newmat):
- """
- Sets the indexes of the materials associated to the particles (4 generations).
- @type newmat: tuple of 4 ints
- @param newmat: the indexes of the materials associated to the particles (4 generations).
- @rtype: None
- @return: None
- """
-
- def getDefvec():
- """
- Retrieves the x, y and z components of the force defined by the texture.
- @rtype: tuple of 3 floats
- @return: x, y and z components of the force defined by the texture.
- """
-
- def setDefvec(newdefvec):
- """
- Sets the x, y and z components of the force defined by the texture.
- @type newdefvec: tuple of 3 floats
- @param newdefvec: the x, y and z components of the force defined by the
- texture.
- @rtype: None
- @return: None
- """
-
- def getParticlesLoc():
- """
- Gets the location of each particle at the current time in worldspace.
- @rtype: A list of vector or a list of vector lists.
- @return: The coordinates of each particle at the current time.
- If the "Vect" option is enabled a list Vector pairs will be returned with a start and end point for each particle.
- When static particles are enabled, a list of lists will be returned, each item a strand of particles.
-
- Example::
-
- import Blender
- from Blender import Effect, Object
- scn= Blender.Scene.GetCurrent()
- ob= scn.getActiveObject()
- effect= ob.effects[0]
- particles= effect.getParticlesLoc()
-
- # Check that particles are points only (not static and not vectors)
- if not effect.getFlag() & Effect.Flags.STATIC or not effect.getStype():
- for pt in particles:
- ob_empty= scn.objects.new('Empty')
- ob_empty.setLocation(pt)
-
- else: # Particles will be a list
- for pt in particles:
- for pt_item in pt:
- ob_empty= scn.objects.new('Empty')
- ob_empty.setLocation(pt_item)
-
- Example::
- # Converts particles into a mesh with edges for strands
- from Blender import Scene, Mathutils, Effect, Mesh, Object
- scn= Scene.GetCurrent()
- ob= scn.getActiveObject()
- me= Mesh.New()
-
- effects= Effect.Get()
- for eff in effects:
- for p in eff.getParticlesLoc():
- # p is either a vector or a list of vectors. me.verts.extend() will deal with either
- print p
- me.verts.extend(p)
-
- if type(p)==list: # Are we a strand or a pair, then add edges.
- if len(p)>1:
- edges= [(i, i+1) for i in range(len(me.verts)-len(p), len(me.verts)-1)]
- me.edges.extend( edges )
-
- print len(me.verts)
- ob= scn.objects.new(me)
- """
diff --git a/source/blender/python/api2_2x/doc/Effectdoc.txt b/source/blender/python/api2_2x/doc/Effectdoc.txt
deleted file mode 100644
index 76cff428ed6..00000000000
--- a/source/blender/python/api2_2x/doc/Effectdoc.txt
+++ /dev/null
@@ -1,257 +0,0 @@
-EFFECT Module documentation
-
-
-INTRODUCTION
-The module effect allows you to access all the data of an effect.
-An effect can modify an object (typically a mesh) in three different ways.
- a) the build effect : makes the mesh appear progressively.
- b) the wave effect : waves appear on the mesh (which should be fine-grained)
- c) the particle effect : every vertex of the mesh emits particles,
-which can themselves emit new particles. This effect is the most parameterizable.
-
-In the blender internals, the effect object is just a placeholder for the "real"
- effect, which can be a wave, particle or build effect. The python API follows
-this structure : the Effect module grants access to (the few) data which
- are shared between all effects. It has three submodules : Wave, Build, Particle
-, which grant r/w access to the real parameters of these effects.
-
-
-
-
-functions of the module :
-
-Get(Name:string,pos:int) : returns the pos-th Effect associated
- to the object whose name is Name.
-
-get : same as Get
-
-New(Type:string ) : Creates and returns a new Effect Object.
-The parameter Type can take the values "particle", "wave" or "build"
-
-
-
-Effect object member functions :
-
-getType() : Retrieves the type of the Effect Object.
-
-setType(val:int) : Sets the type of the Effect Object.
-The possible values of the type are :
- 0 : effect build.
- 1 : effect particle.
- 2 : effect wave.
-
-
-getFlag()Retrieves the flag of the Effect Object
-
-setFlag(val:int) :Sets the flag
-
-The flag of the effect is a combination of parameters, whose semantics depend upon the effect type.
-All types :
-Bit 0 : set to 1 if the effect is selected in the effects window.
-Wave effect :
-Bits 1,2,3 : set to 1 if the button "X", "Y" or "Cycl" is clicked.
-Particle effect :
-Bits 1,2,3 : set to 1 if the button "Bspline", "Static" or "Face" is clicked.
-
-
-
-
-
-
-Submodules : Wave, Build, Particle.
-
-
-
-
-Wave module
-
-
-
-functions of the module :
-
-Get(Name:string,pos:int) : returns the pos-th wave Effect associated to the object whose name is Name.
-
-get : same as Get
-
-New( ) : Creates and returns a new Wave Object.
-
-
-Wave object member functions :
-
-getStartx() : returns the startx parameter of the wave object.
-
-setStartx(val:int) : sets the startx parameter of the wave object.
-
-getStarty() : returns the starty parameter of the wave object.
-
-setStarty(val:int) : sets the starty parameter of the wave object.
-
-getHeight() : returns the height parameter of the wave object.
-
-setHeight(val:int) : sets the height parameter of the wave object.
-
-getWidth() : returns the width parameter of the wave object.
-
-setWidth(val:int) : sets the width parameter of the wave object.
-
-getNarrow() : returns the narrow parameter of the wave object.
-
-setNarrow(val:int) : sets the narrow parameter of the wave object.
-
-getSpeed() : returns the speed parameter of the wave object.
-
-setSpeed(val:int) : sets the speed parameter of the wave object.
-
-getMinfac() : returns the minfac parameter of the wave object.
-
-setMinfac(val:int) : sets the minfac parameter of the wave object.
-
-getDamp() : returns the damp parameter of the wave object.
-
-setDamp(val:int) : sets the damp parameter of the wave object.
-
-getTimeoffs() : returns the timeoffs parameter of the wave object.
-
-setTimeoffs(val:int) : sets the time offset parameter of the wave object.
-
-getLifetime() : returns the lifetime parameter of the wave object.
-
-setLifetime(val:int) : sets the lifetime parameter of the wave object.
-
-
-
-The Object.attr syntax
-
-Wave attributes can be read/written with the object.attr syntax.
-Example :
-
-w = Blender.Wave.Get("Obname",3) #retrieves the 4th effect associated to the object named Obname
-a = w.speed # a is now the value corresponding to the speed of the effect
-w.speed = 42 # the speed of the effect is now equal to 42
-
-The parameter can take these values : "lifetime","timeoffs","damp","minfac","speed","narrow","width","height","startx","starty"
-
-
-
-
-Build module
-
-
-
-functions of the module :
-
-Get(Name:string,pos:int) : returns the pos-th build Effect associated to the object whose name is Name.
-
-get(Name:string,pos:int) : same as Get
-
-New( ) : Creates and returns a new Build Object.
-
-
-Build object member functions :
-
-getLen() : returns the length of the effect (in frames).
-
-setLen(val:float) : sets the length of the effect (in frames).
-
-getSfra() : returns the starting frame of the effect.
-
-setSfra(val:float) : sets the starting frame of the effect.
-
-
-The Object.attribute syntax
-
-The attribute can take these values : "sfra","len".
-
-
-Particle module
-
-
-
-functions of the module :
-
-Get(Name:string,pos:int) : returns the pos-th particle Effect associated to the object whose name is Name.
-
-get(Name:string,pos:int) : same as Get
-
-New( ) : Creates and returns a new Effect Object.
-
-
-Particle object member functions :
-
-getStartTime() : returns the start time of the particle effect (in frames).
-
-setStartTime(val:float) : sets the start time of the particle effect (in frames).
-
-getEndTime() : returns the end time of the particle effect (in frames).
-
-setEndTime(val:float) : sets the end time of the particle effect (in frames).
-
-getLifeTime() : returns the life time of the particles.
-
-setLifeTime(val:float) : sets the life time of the particles.
-
-getNormfac() : returns the normal strength of the particles (relatively to mesh).
-
-setNormfac(val:float) : sets the normal strength of the particles(relatively to mesh).
-
-getObfac() : returns the initial of the particles relatively to objects.
-
-setObfac(val:float) : sets the initial of the particles relatively to objects.
-
-getRandfac() : returns the initial random speed of the particles.
-
-setRandfac(val:float) : sets the initial random speed of the particles.
-
-getTexfac() : returns the initial speed of the particles caused by the texture.
-
-setTexfac(val:float) : sets the initial speed of the particles caused by the texture.
-
-getRandlife() : returns the variability of the life of the particles.
-
-setRandlife(val:float) : sets the variability of the life of the particles.
-
-getNabla() : returns the dimension of the area for gradient computation.
-
-setNabla(val:float) : sets the dimension of the area for gradient computation.
-
-getTotpart() : returns the total number of particles.
-
-setTotpart(val:int) : sets the total number of particles.
-
-getTotkey() : returns the number of key positions.
-
-setTotkey(val:int) : sets the number of key positions.
-
-getSeed() : returns the seed of the RNG.
-
-setSeed(val:int) : sets the seed of the RNG.
-
-getSeed() : returns the x,y,z components of the constant force applied to the particles.
-
-setSeed(valx:float,valy:float,valz:float) : sets the x,y,z components of the constant force applied to the particles.
-
-getMult() : returns the 4 probabilities of a particle having a child.
-
-setMult(val1:float,val2:float,val3:float,val4:float) : sets the 4 probabilities of a particle having a child.
-
-getLife() : returns the lifespan of the 4 generation particles.
-
-setLife(val1:float,val2:float,val3:float,val4:float) : sets the lifespan of the 4 generation particles.
-
-getMat() : returns the material used by the 4 generation particles.
-
-setMat(val1:float,val2:float,val3:float,val4:float) : sets the material used by the 4 generation particles.
-
-getChild() : returns the number of children a particle may have.
-
-setChild(val1:float,val2:float,val3:float,val4:float) : sets the number of children a particle may have.
-
-getDefvec() : returns the x, y and z axis of the force defined by the texture.
-
-setDefvec(val1:float,val2:float,val3:float) : sets the x, y and z axis of the force defined by the texture.
-
-
-
-The Object.attribute syntax
-
-The attribute can take these values : "seed","nabla","sta","end","lifetime","normfac","obfac","randfac","texfac","randlife","vectsize","totpart","force","mult","life","child","mat","defvec". \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/Font.py b/source/blender/python/api2_2x/doc/Font.py
deleted file mode 100644
index c0ad66d0462..00000000000
--- a/source/blender/python/api2_2x/doc/Font.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# Blender.Text3d.Font module and the Font PyType object
-
-"""
-The Blender.Text3d.Font subsubmodule.
-
-Text3d.Font Objects
-===================
-
-This module provides access to B{Font} objects in Blender.
-
-Example::
- import Blender
- from Blender import Text3d
-
- # Load a font
- myfont= Text3d.Font.Load('/usr/share/fonts/ttf/verdana.ttf')
-
- #
- for font in Text3d.Font.Get():
- print font.name, font.filename, font.packed
-"""
-
-def Load (filename):
- """
- Create a new Text3d.Font object.
- @type filename: string
- @param filename: file of the font
- @rtype: Blender Text3d.Font
- @return: The created Text3d.Font Data object.
- """
-
-def Get (name = None):
- """
- Get the Text3d.Font object(s) from Blender.
- @type name: string
- @param name: The name of the Text3d object.
- @rtype: Blender Text3d or a list of Blender Text3ds
- @return: It depends on the 'name' parameter:
- - (name): The Text3d object with the given name;
- - (): A list with all Font objects in the current .blend file.
- """
-class Font:
- """
- The Text3d.Font object
- ======================
- This object gives access Blender's B{Font} objects
- @ivar filename: The filename (path) of the file loaded into this Font.
- @type filename: string
- @ivar packed: Boolean, True when the sample is packed (readonly).
- @type packed: string
- """
-
- def pack():
- """
- Packs the sound into the current blend file.
- @note: An error will be raised if the sound is already packed or the filename path does not exist.
- @returns: nothing
- @rtype: none
- """
-
- def unpack(mode):
- """
- Unpacks the sound to the samples filename.
- @param mode: One of the values in Blender.UnpackModes dict.
- @note: An error will be raised if the sound is not packed or the filename path does not exist.
- @returns: nothing
- @rtype: none
- @type mode: int
- """
diff --git a/source/blender/python/api2_2x/doc/Geometry.py b/source/blender/python/api2_2x/doc/Geometry.py
deleted file mode 100644
index f882f4b3b57..00000000000
--- a/source/blender/python/api2_2x/doc/Geometry.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# Blender.Geometry module and its subtypes
-
-"""
-The Blender.Geometry submodule.
-
-Geometry
-========
-
-This new module provides access to a geometry function.
-"""
-
-def PolyFill(polylines):
- """
- Takes a list of polylines and calculates triangles that would fill in the polylines.
- Multiple lines can be used to make holes inside a polyline, or fill in 2 seperate lines at once.
- @type polylines: List of lists containing vectors, each representing a closed polyline.
- @rtype: list
- @return: a list if tuples each a tuple of 3 ints representing a triangle indexing the points given.
- @note: 2D Vectors will have an assumed Z axis of zero, 4D Vectors W axis is ignored.
- @note: The order of points in a polyline effect the direction returned triangles face, reverse the order of a polyline to flip the normal of returned faces.
-
- I{B{Example:}}
-
- The example below creates 2 polylines and fills them in with faces, then makes a mesh in the current scene::
- import Blender
- Vector= Blender.Mathutils.Vector
-
- # Outline of 5 points
- polyline1= [Vector(-2.0, 1.0, 1.0), Vector(-1.0, 2.0, 1.0), Vector(1.0, 2.0, 1.0), Vector(1.0, -1.0, 1.0), Vector(-1.0, -1.0, 1.0)]
- polyline2= [Vector(-1, 1, 1.0), Vector(0, 1, 1.0), Vector(0, 0, 1.0), Vector(-1.0, 0.0, 1.0)]
- fill= Blender.Geometry.PolyFill([polyline1, polyline2])
-
- # Make a new mesh and add the truangles into it
- me= Blender.Mesh.New()
- me.verts.extend(polyline1)
- me.verts.extend(polyline2)
- me.faces.extend(fill) # Add the faces, they reference the verts in polyline 1 and 2
-
- scn = Blender.Scene.GetCurrent()
- ob = scn.objects.new(me)
- Blender.Redraw()
- """
-
-def LineIntersect2D(vec1, vec2, vec3, vec4):
- """
- Takes 2 lines vec1, vec2 for the 2 points of the first line and vec2, vec3 for the 2 points of the second line.
- @rtype: Vector
- @return: a 2D Vector for the intersection or None where there is no intersection.
- """
-
-def ClosestPointOnLine(pt, vec1, vec2):
- """
- Takes 2 lines vec1, vec2 for the 2 points of the first line and vec2, vec3 for the 2 points of the second line.
- @rtype: tuple
- @return: a tuple containing a vector and a float, the vector is the closest point on the line, the float is the position on the line, between 0 and 1 the point is on the line.
- """
-
-def PointInTriangle2D(pt, tri_pt1, tri_pt2, tri_pt3):
- """
- Takes 4 vectors (one for the test point and 3 for the triangle)
- This is a 2d function so only X and Y are used, Z and W will be ignored.
- @rtype: bool
- @return: True or False depending on the points intersection.
- """
-
-def BoxPack2D(boxlist):
- """
- Takes a list of 2D boxes and packs them into a square.
- Each box in boxlist must be a list of at least 4 items - [x,y,w,h], after running this script,
- the X and Y values in each box will be moved to packed, non overlapping locations.
-
- Example::
-
- # Make 500 random boxes, pack them and make a mesh from it
- from Blender import Geometry, Scene, Mesh
- import random
- boxes = []
- for i in xrange(500):
- boxes.append( [0,0, random.random()+0.1, random.random()+0.1] )
- boxsize = Geometry.BoxPack2D(boxes)
- print 'BoxSize', boxsize
- me = Mesh.New()
- for x in boxes:
- me.verts.extend([(x[0],x[1], 0), (x[0],x[1]+x[3], 0), (x[0]+x[2],x[1]+x[3], 0), (x[0]+x[2],x[1], 0) ])
- v1= me.verts[-1]
- v2= me.verts[-2]
- v3= me.verts[-3]
- v4= me.verts[-4]
- me.faces.extend([(v1,v2,v3,v4)])
- scn = Scene.GetCurrent()
- scn.objects.new(me)
-
- @note: Each boxlist item can be longer then 4, the extra items are ignored and stay untouched.
- @rtype: tuple
- @return: a tuple pair - (width, height) of all the packed boxes.
- """
- \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/Group.py b/source/blender/python/api2_2x/doc/Group.py
deleted file mode 100644
index aca7c56b4a5..00000000000
--- a/source/blender/python/api2_2x/doc/Group.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# Blender.Group module and the Group PyType object
-
-"""
-The Blender.Group submodule.
-
-Group
-=====
-
-This module provides access to B{Group} data in Blender.
-
-Example::
-
- # Make Dupli's Real, as a python script.
-
- from Blender import *
-
- scn= Scene.GetCurrent()
- for ob in scn.objects:
- print 'Object Group Settings'
- print ob.name, ob.type
- print 'enableDupVerts:', ob.enableDupVerts
- print 'enableDupFrames:', ob.enableDupFrames
- print 'enableDupGroup:', ob.enableDupGroup
- print 'DupGroup:', ob.DupGroup
- dupe_obs= ob.DupObjects
- print 'num dup obs:', len(dupe_obs)
-
- for dup_ob, dup_matrix in dupe_obs:
- print '\tDupOb', dup_ob.name
- scn.objects.new(dup_ob.data)
- new_ob.setMatrix(dup_matrix)
- new_ob.sel= 1 # select all real instances.
-
- ob.sel=0 # Desel the original object
-
- Window.RedrawAll()
-
-Example::
-
- # Make a new group with the selected objects, and add an instance of this group.
-
- from Blender import *
-
- scn= Scene.GetCurrent()
-
- # New Group
- grp= Group.New('mygroup')
- grp.objects= scn.objects
-
- # Instance the group at an empty using dupligroups
- ob= scn.objects.new(None)
- ob.enableDupGroup= True
- ob.DupGroup= grp
- Window.RedrawAll()
-
-
-Example::
-
- # Remove all non mesh objects from a group.
-
- from Blender import *
-
- scn= Scene.GetCurrent()
-
- # New Group
- grp= Group.Get('mygroup')
- for ob in list(grp.objects): # Convert to a list before looping because we are removing items
- if ob.type != 'Mesh':
- grp.objects.unlink(ob)
-"""
-
-def New (name = None):
- """
- Make a new empty group, name optional, default is "Group"
- @type name: string
- @param name: The name of the new group.
- @rtype: Blender Group
- @return: A Empty Blender Group object
- """
-
-def Get (name = None):
- """
- Get the Group object(s) from Blender.
- @type name: string
- @param name: The name of the Group object.
- @rtype: Blender Group or a list of Blender Groups
- @return: It depends on the I{name} parameter:
- - (name): The Group object called I{name}, Exception if it is not found.
- - (): A list with all Group objects in the current blend file.
- """
-
-def Unlink (group):
- """
- Unlink (delete) this group from Blender.
- @Note: No objects will be removed, just the group that references them.
- @type group: group
- @param group: A group to remove from this blend file, does not remove objects that this group uses.
- """
-
-
-class Group:
- """
- The Group object
- ================
- This object gives access to Groups in Blender.
- @ivar layers: Layer bitmask for this group.
- @type layers: int
- @ivar objects: Objects that this group uses.
- This is a sequence with-list like access so use list(grp.objects) if you need to use a list (where grp is a group).
- The groups objects can be set by assigning a list or iterator of objects to the groups objects.
- objects.link() and objects.unlink() also work with the the objects iterator just like with lists.
-
- B{Note}: append() and remove() have been deprecated and replaced by link() and unlink(),
- after Blender 2.43 append() and remove() will not be available.
- @type objects: custom object sequence
- """
-
- def __copy__ ():
- """
- Make a copy of this group
- @rtype: Group
- @return: a copy of this group
- """
-
-import id_generics
-Group.__doc__ += id_generics.attributes
-
diff --git a/source/blender/python/api2_2x/doc/IDProp.py b/source/blender/python/api2_2x/doc/IDProp.py
deleted file mode 100644
index 0a0df335fa3..00000000000
--- a/source/blender/python/api2_2x/doc/IDProp.py
+++ /dev/null
@@ -1,130 +0,0 @@
-class IDGroup:
- """
- The IDGroup Type
- ================
- This type supports both iteration and the []
- operator to get child ID properties.
-
- You can also add new properties using the [] operator.
- For example::
-
- group['a float!'] = 0.0
- group['an int!'] = 0
- group['a string!'] = "hi!"
- group['an array!'] = [0, 0, 1.0, 0]
-
- group['a subgroup!] = {"float": 0.0, "an int": 1.0, "an array": [1, 2],
- "another subgroup": {"a": 0.0, "str": "bleh"}}
-
- Note that for arrays, the array type defaults to int unless a float is found
- while scanning the template list; if any floats are found, then the whole
- array is float.
-
- You can also delete properties with the del operator. For example:
-
- del group['property']
-
- To get the type of a property, use the type() operator, for example::
-
- if type(group['bleh']) == str: pass
-
- To tell if the property is a group or array type, import the Blender.Types module and test
- against IDGroupType and IDArrayType, like so::
-
- from Blender.Types import IDGroupType, IDArrayType.
-
- if type(group['bleghr']) == IDGroupType:
- (do something)
-
- @ivar name: The name of the property
- @type name: string
- """
-
- def pop(item):
- """
- Pop an item from the group property.
- @type item: string
- @param item: The item name.
- @rtype: can be dict, list, int, float or string.
- @return: The removed property.
- """
-
- def update(updatedict):
- """
- Updates items in the dict, similar to normal python
- dictionary method .update().
- @type updatedict: dict
- @param updatedict: A dict of simple types to derive updated/new IDProperties from.
- @rtype: None
- @return: None
- """
-
- def keys():
- """
- Returns a list of the keys in this property group.
- @rtype: list of strings.
- @return: a list of the keys in this property group.
- """
-
- def values():
- """
- Returns a list of the values in this property group.
-
- Note that unless a value is itself a property group or an array, you
- cannot change it by changing the values in this list, you must change them
- in the parent property group.
-
- For example,
-
- group['some_property'] = new_value
-
- . . .is correct, while,
-
- values = group.values()
- values[0] = new_value
-
- . . .is wrong.
-
- @rtype: list of strings.
- @return: a list of the values in this property group.
- """
-
- def iteritems():
- """
- Implements the python dictionary iteritmes method.
-
- For example::
-
- for k, v in group.iteritems():
- print "Property name: " + k
- print "Property value: " + str(v)
-
- @rtype: an iterator that spits out items of the form [key, value]
- @return: an iterator.
- """
-
- def convert_to_pyobject():
- """
- Converts the entire property group to a purely python form.
-
- @rtype: dict
- @return: A python dictionary representing the property group
- """
-
-class IDArray:
- """
- The IDArray Type
- ================
-
- @ivar type: returns the type of the array, can be either IDP_Int or IDP_Float
- """
-
- def __getitem__(index):
- pass
-
- def __setitem__(index, value):
- pass
-
- def __len__():
- pass
- \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/Image.py b/source/blender/python/api2_2x/doc/Image.py
deleted file mode 100644
index 6d613b3c8fe..00000000000
--- a/source/blender/python/api2_2x/doc/Image.py
+++ /dev/null
@@ -1,374 +0,0 @@
-# Blender.Image module and the Image PyType object
-
-"""
-The Blender.Image submodule.
-
-Image
-=====
-
-B{New}: L{Image.clampX}, L{Image.clampY}.
-
-This module provides access to B{Image} objects in Blender.
-
-Example::
- import Blender
- from Blender import Image
- #
- image = Image.Load("/path/to/my/image.png") # load an image file
- print "Image from", image.getFilename(),
- print "loaded to obj", image.getName())
- image.setXRep(4) # set x tiling factor
- image.setYRep(2) # set y tiling factor
- print "All Images available now:", Image.Get()
-
-@type Sources: readonly dictionary
-@var Sources: The available Image Source.
- - STILL: Single image file
- - MOVIE: Movie file
- - SEQUENCE: Multiple image files, as sequence
- - GENERATED: Generated image
-"""
-
-def Load (filename):
- """
- Load the image called 'filename' into an Image object.
- @type filename: string
- @param filename: The full path to the image file.
- @rtype: Blender Image
- @return: A Blender Image object with the data from I{filename}.
- """
-
-def New (name, width, height, depth):
- """
- Create a new Image object.
- @type name: string
- @param name: The name of the new Image object.
- @type width: int
- @param width: The width of the new Image object, between 1 and 5000.
- @type height: int
- @param height: The height of the new Image object, between 1 and 5000.
- @type depth: int
- @param depth: The colour depth of the new Image object. (8:Grey, 24:RGB, 32:RGBA). (Not implimented yet, all new images will be 24bit)
- @rtype: Blender Image
- @return: A new Blender Image object.
- """
-
-def Get (name = None):
- """
- Get the Image object(s) from Blender.
- @type name: string
- @param name: The name of the Image object.
- @rtype: Blender Image or a list of Blender Images
- @return: It depends on the I{name} parameter:
- - (name): The Image object called I{name}, None if not found;
- - (): A list with all Image objects in the current scene.
- """
-
-def GetCurrent ():
- """
- Get the currently displayed Image from Blenders UV/Image window.
- When multiple images are displayed, the last active UV/Image windows image is used.
- @rtype: Blender Image
- @return: The Current Blender Image, If there is no current image it returns None.
- """
-
-from IDProp import IDGroup, IDArray
-class Image:
- """
- The Image object
- ================
- This object gives access to Images in Blender.
- @ivar filename: The filename (path) to the image file loaded into this Image
- object.
- @type filename: string
- @ivar size: The [width, height] dimensions of the image (in pixels).
- @type size: list
- @ivar depth: The pixel depth of the image. [8, 16, 18, 24, 32]
- @type depth: int
- @ivar xrep: Texture tiling: the number of repetitions in the x (horizontal)
- axis. [1, 16].
- @ivar yrep: Texture tiling: the number of repetitions in the y (vertical)
- axis [1, 16].
- @type xrep: int
- @type yrep: int
- @ivar start: Texture's animation start frame [0, 128].
- @type start: int
- @ivar end: Texture's animation end frame [0, 128].
- @type end: int
- @ivar speed: Texture's animation speed [1, 100].
- @type speed: int
- @ivar packed: True when the Texture is packed (readonly).
- @type packed: boolean
- @ivar has_data: True when the image has pixel data (readonly).
- @type has_data: boolean
- @ivar fields: enable or disable the fields option for this image.
- @type fields: boolean
- @ivar fields_odd: enable or disable the odd fields option for this image.
- @type fields_odd: boolean
- @ivar antialias: enable or disable the antialias option for this image.
- @type antialias: boolean
- @ivar bindcode: Texture's bind code (readonly).
- @type bindcode: int
- @ivar source: Image source type. See L{the Sources dictionary<Sources>} .
- @type source: int
- @ivar clampX: When true the image will not tile horizontally.
- @type clampX: bool
- @ivar clampY: When true the image will not tile vertically.
- @type clampY: bool
- """
-
- def getName():
- """
- Get the name of this Image object.
- @rtype: string
- """
-
- def getFilename():
- """
- Get the filename of the image file loaded into this Image object.
- @rtype: string
- """
-
- def getSize():
- """
- Get the [width, height] dimensions (in pixels) of this image.
- @rtype: list of 2 ints
- """
-
- def getDepth():
- """
- Get the pixel depth of this image.
- @rtype: int
- """
-
- def getPixelF(x, y):
- """
- Get the the colors of the current pixel in the form [r,g,b,a].
- Returned values are floats normalized to 0.0 - 1.0.
- Pixel coordinates are in the range from 0 to N-1. See L{getMaxXY}
- @returns: [ r, g, b, a]
- @rtype: list of 4 floats
- @type x: int
- @type y: int
- @param x: the x coordinate of pixel.
- @param y: the y coordinate of pixel.
- """
- def getPixelI(x, y):
- """
- Get the the colors of the current pixel in the form [r,g,b,a].
- Returned values are ints normalized to 0 - 255.
- Pixel coordinates are in the range from 0 to N-1. See L{getMaxXY}
- @returns: [ r, g, b, a]
- @rtype: list of 4 ints
- @type x: int
- @type y: int
- @param x: the x coordinate of pixel.
- @param y: the y coordinate of pixel.
- """
-
- def getMaxXY():
- """
- Get the x & y size for the image. Image coordinates range from 0 to size-1.
- @returns: [x, y]
- @rtype: list of 2 ints
- """
-
- def getMinXY():
- """
- Get the x & y origin for the image. Image coordinates range from 0 to size-1.
- @returns: [x, y]
- @rtype: list of 2 ints
- """
-
- def getXRep():
- """
- Get the number of repetitions in the x (horizontal) axis for this Image.
- This is for texture tiling.
- @rtype: int
- """
-
- def getYRep():
- """
- Get the number of repetitions in the y (vertical) axis for this Image.
- This is for texture tiling.
- @rtype: int
- """
-
- def getBindCode():
- """
- Get the Image's bindcode. This is for texture loading using BGL calls.
- See, for example, L{BGL.glBindTexture} and L{glLoad}.
- @rtype: int
- """
-
- def getStart():
- """
- Get the Image's start frame. Used for animated textures.
- @rtype: int
- """
-
- def getEnd():
- """
- Get the Image's end frame. Used for animated textures.
- @rtype: int
- """
-
- def getSpeed():
- """
- Get the Image's speed (fps). Used for animated textures.
- @rtype: int
- """
-
- def reload():
- """
- Reloads this image from the filesystem. If used within a loop you need to
- redraw the Window to see the change in the image, e.g. with
- Window.RedrawAll().
- @warn: if the image file is corrupt or still being written, it will be
- replaced by a blank image in Blender, but no error will be returned.
- @returns: None
- """
-
- def glLoad():
- """
- Load this image's data into OpenGL texture memory, if it is not already
- loaded (image.bindcode is 0 if it is not loaded yet).
- @note: Usually you don't need to call this method. It is only necessary
- if you want to draw textured objects in the Scripts window and the
- image's bind code is zero at that moment, otherwise Blender itself can
- take care of binding / unbinding textures. Calling this method for an
- image with nonzero bind code simply returns the image's bind code value
- (see L{getBindCode}).
- @rtype: int
- @returns: the texture's bind code.
- """
-
- def glFree():
- """
- Delete this image's data from OpenGL texture memory, only (the image itself
- is not removed from Blender's memory). Internally, glDeleteTextures (see
- L{BGL.glDeleteTextures}) is used, but this method also updates Blender's
- Image object so that its bind code is set to 0. See also L{Image.glLoad},
- L{Image.getBindCode}.
- """
-
- def setName(name):
- """
- Set the name of this Image object.
- @type name: string
- @param name: The new name.
- """
-
- def setFilename(name):
- """
- Change the filename of this Image object.
- @type name: string
- @param name: The new full filename.
- @warn: use this with caution and note that the filename is truncated if
- larger than 160 characters.
- """
-
- def setXRep(xrep):
- """
- Texture tiling: set the number of x repetitions for this Image.
- @type xrep: int
- @param xrep: The new value in [1, 16].
- """
-
- def setYRep(yrep):
- """
- Texture tiling: set the number of y repetitions for this Image.
- @type yrep: int
- @param yrep: The new value in [1, 16].
- """
-
- def setStart(start):
- """
- Get the Image's start frame. Used for animated textures.
- @type start: int
- @param start: The new value in [0, 128].
- """
-
- def setEnd(end):
- """
- Set the Image's end frame. Used for animated textures.
- @type end: int
- @param end: The new value in [0, 128].
- """
-
- def setSpeed(speed):
- """
- Set the Image's speed (fps). Used for animated textures.
- @type speed: int
- @param speed: The new value in [1, 100].
- """
-
- def setPixelF(x, y, (r, g, b,a )):
- """
- Set the the colors of the current pixel in the form [r,g,b,a].
- Color values must be floats in the range 0.0 - 1.0.
- Pixel coordinates are in the range from 0 to N-1. See L{getMaxXY}
- @type x: int
- @type y: int
- @type r: float
- @type g: float
- @type b: float
- @type a: float
- @returns: nothing
- @rtype: none
- """
-
- def setPixelI(x, y, (r, g, b, a)):
- """
- Set the the colors of the current pixel in the form [r,g,b,a].
- Color values must be ints in the range 0 - 255.
- Pixel coordinates are in the range from 0 to N-1. See L{getMaxXY}
- @type x: int
- @type y: int
- @type r: int
- @type g: int
- @type b: int
- @type a: int
- @returns: nothing
- @rtype: none
- """
-
- def save():
- """
- Saves the current image to L{filename}
- @note: Saving to a directory that doent exist will raise an error.
- @note: Saving a packed image will make a unique (numbered) name if the file alredy exists. Remove the file first to be sure it will not be renamed.
- @returns: None
- """
-
- def pack():
- """
- Packs the image into the current blend file.
-
- Since 2.44 new images without valid filenames can be packed.
-
- If the image is alredy packed, it will be repacked.
-
- @returns: nothing
- @rtype: none
- """
-
- def unpack(mode):
- """
- Unpacks the image to the images filename.
- @param mode: One of the values in L{Blender.UnpackModes}.
- @note: An error will be raised if the image is not packed or the filename path does not exist.
- @returns: nothing
- @rtype: none
- @type mode: int
- """
- def makeCurrent():
- """
- Set the currently displayed Image from Blenders UV/Image window.
- When multiple images are displayed, the last active UV/Image windows image is used.
- @warn: Deprecated, set bpy.data.images.active = image instead.
- @rtype: bool
- @return: True if the current image could be set, if no window was available, return False.
- """
-import id_generics
-Image.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/Ipo.py b/source/blender/python/api2_2x/doc/Ipo.py
deleted file mode 100644
index b8c472b371a..00000000000
--- a/source/blender/python/api2_2x/doc/Ipo.py
+++ /dev/null
@@ -1,437 +0,0 @@
-# Blender.Ipo module and the Ipo PyType object
-
-"""
-The Blender.Ipo submodule
-
-B{New}:
- - Ipo updates to both the program and Bpython access.
- - access to Blender's new Ipo driver capabilities.
- - Ipo now supports the mapping operator [] to access IpoCurves
-
-This module provides access to the Ipo Data in Blender. An Ipo is composed of
-several IpoCurves, and an IpoCurve is composed of several BezTriples.
-
-Example::
- from Blender import Ipo
-
- ipo = Ipo.Get('ObIpo') # retrieves an Ipo object
- ipo.name = 'ipo1' # change the Ipo's name
- icu = ipo[Ipo.OB_LOCX] # request X Location Ipo curve
- if icu != None and len(icu.bezierPoints) > 0: # if curve exists and has BezTriple points
- val = icu[2.5] # get the curve's value at time 2.5
- ipo[Ipo.OB_LOCX] = None # delete the Ipo curve
-
-Each type of Ipo has different types Ipocurves. With the exception of Shape
-Key Ipos, constants are used to specify all Ipocurves. There are two ways
-to tell which Ipo curves go with which Ipo type:
- - all constants start with a two-character identifier for their Ipo type;
- for example, "OB_LOCX" is the LocX curve for an Object Ipo
- - each Ipo now has a read-only attribute L{Ipo.curveConsts}, which returns
- the valid Ipo curve types for that specific Ipo
-
-The valid IpoCurve constants are:
- 1. Material Ipo: MA_R, MA_G, MA_B, MA_SPECR, MA_SPECG, MA_SPECB,
- MA_MIRR, MA_MIRG, MA_MIRB, MA_REF, MA_ALPHA, MA_EMIT, MA_AMB,
- MA_SPEC, MA_HARD, MA_SPTRA, MA_IOR, MA_MODE, MA_HASIZE, MA_TRANSLU,
- MA_RAYMIR, MA_FRESMIR, MA_FRESMIRI, MA_FRESTRA, MA_FRESTRAI,
- MA_TRAGLOW, MA_OFSX, MA_OFSY, MA_OFSZ, MA_SIZEX, MA_SIZEY, MA_SIZEZ,
- MA_TEXR, MA_TEXG, MA_TEXB, MA_DEFVAR, MA_COL, MA_NOR, MA_VAR, MA_DISP
- 2. Lamp Ipo: LA_ENERG, LA_R, LA_G, LA_B, LA_DIST, LA_SPOSI, LA_SPOBL,
- LA_QUAD1, LA_QUAD2, LA_HAINT, LA_OFSX, LA_OFSY, LA_OFSZ, LA_SIZEX,
- LA_SIZEY, LA_SIZEZ, LA_TEXR, LA_TEXG, LA_TEXB, LA_DEFVAR, LA_COL
- 3. World Ipo: WO_HORR, WO_HORG, WO_HORB, WO_ZENR, WO_ZENG, WO_ZENB,
- WO_EXPOS, WO_MISI, WO_MISDI, WO_MISSTA, WO_MISHI, WO_STARR,
- WO_STARB, WO_STARG, WO_STARDI, WO_STARSI, WO_OFSX, WO_OFSY,
- WO_OFSZ, WO_SIZEX, WO_SIZEY, WO_SIZEZ, WO_TEXR, WO_TEXG,
- WO_TEXB, WO_DEFVAR, WO_COL, WO_NOR, WO_VAR
- 4. Camera Ipo: CA_LENS, CA_CLSTA, CA_CLEND, CA_APERT, CA_FDIST
- 5. Object Ipo: OB_LOCX, OB_LOCY, OB_LOCZ, OB_DLOCX, OB_DLOCY, OB_DLOCZ,
- OB_ROTX, OB_ROTY, OB_ROTZ, OB_DROTX, OB_DROTY, OB_DROTZ,
- OB_SIZEX, OB_SIZEY, OB_SIZEZ, OB_DSIZEX, OB_DSIZEY, OB_DSIZEZ,
- OB_LAYER, OB_TIME, OB_COLR, OB_COLG, OB_COLB, OB_COLA,
- OB_FSTRENG, OB_FFALL, OB_RDAMP, OB_DAMPING, OB_PERM
- 6. Curve Ipo: CU_SPEED
- 7. Constraint Ipo: CO_INF
- 8. Texture Ipo: TE_NSIZE, TE_NDEPTH, TE_NTYPE, TE_TURB, TE_VNW1, TE_VNW2,
- TE_VNW3, TE_VNW4, TE_MINKMEXP, TE_DISTM, TE_COLT, TE_ISCALE,
- TE_DISTA, TE_MGTYPE, TE_MGH, TE_LACU, TE_OCT, TE_MGOFF,
- TE_MGGAIN, TE_NBASE1, TE_NBASE2, TE_COLR, TE_COLG, TE_COLB,
- TE_BRIGHT, TE_CONTRAS
- 9. Pose/Action Ipo: PO_LOCX, PO_LOCY, PO_LOCZ, PO_SIZEX, PO_SIZEY,
- PO_SIZEZ, PO_QUATW, PO_QUATX, PO_QUATY, PO_QUATZ
- 10. Sequence Ipo: SQ_FAC
-
-Shape Key Ipos are handled differently from other Ipos. The user can rename
-the curves, so string are used to access them instead of constants. The
-L{Ipo.curveConsts} attribute for Shape Key Ipos returns a list of all defined
-key names.
-"""
-
-def New (type, name):
- """
- Creates a new Ipo.
- @type type: string
- @type name: string
- @param type: The Ipo's blocktype. Depends on the object the Ipo will be
- linked to. Currently supported types are Object, Camera, World,
- Material, Texture, Lamp, Action, Constraint, Sequence, Curve, Key.
- @param name: The name for this Ipo.
- @rtype: Blender Ipo
- @return: The created Ipo.
- """
-
-def Get (name = None):
- """
- Get the Ipo from Blender.
- @type name: string
- @param name: The name of the requested Ipo, or nothing.
- @rtype: Blender Ipo or a list of Blender Ipos
- @return: It depends on the 'name' parameter:
- - (name): The Ipo with the given name;
- - (): A list with all Ipos in the current scene.
- """
-
-class Ipo:
- """
- The Ipo object
- ==============
- This object gives access to Ipo data from all objects in Blender.
- @Note: Blender Materials, Lamps and Worlds have I{texture channels} which
- allow the user to assign textures to them. The Blender Ipo Window allows
- the user to access the IpoCurves for these channels by specifying a number
- between 0 and 9 (the number appears next to the Ipo type in the window
- header). Prior to Version 2.42, the BPy API did not allow users to access
- these texture channels in a predictable manner. A new attribute named
- L{channel} was added to the API in Version 2.42 to correct this problem.
-
- The current channel setting has an effect on the operators B{[]}, B{len()}
- and others. For example, suppose a Material has three IpoCurves
- (R, G, and B), and two texture channels (numbered 0 and 1), and furthermore
- channel 0 has one Ipocurve (Col). The IpoCurve Col can only be
- "seen" through the API when B{ipo.channel} is 0. Setting B{ipo.channel} to
- 1 will cause this curve to be ignored by B{len(ipo)}::
-
- from Blender import Ipo
-
- ipo = Ipo.Get('MatIpo')
- for channel in xrange(2):
- ipo.channel = channel
- print 'channel is',channel
- print ' len is',len(ipo)
- names = dict([(x[1],x[0]) for x in ipo.curveConsts.items()])
- for curve in [Ipo.MA_R,Ipo.MA_COL]:
- print ' ',names[curve],'is',curve in ipo
-
- will output::
- channel is 0
- len is 4
- MA_R is True
- MA_COL is True
- channel is 1
- len is 3
- MA_R is True
- MA_COL is False
-
- @ivar curves: Ipo curves currently defined for the Ipo.
- @type curves: list of Ipocurves.
- @ivar curveConsts: The valid Ipo curves for this Ipo. These can be used
- by the [] mapping operator. The value
- depends on the Ipo curve type. If the Ipo is any type other than a Key or
- Shape Ipo, this attribute returns a set of constants that can be
- used to specify a particular curve. For Key or Shape Ipos, the attribute
- returns a list of all defined keys by name.
- @type curveConsts: constant or list of strings. Read-only.
- @ivar channel: the current texture channel for Blender object which support
- textures (materials, lamps and worlds). Returns None if the Ipo does
- not support texture channels. Value must be in the range [0,9].
- @type channel: int or None
- """
-
- def __contains__():
- """
- The "in" operator for Ipos. It returns B{True} if the specified
- IpoCurve exists for the Ipo. This operator B{should not} be used to
- test for whether a curve constant is valid for a particular Ipo type.
- Many constants for different Ipo types have the same value, and it is
- the constant's value used internally.
- No exceptions are raised if the argument is not a valid curve constant or
- or string, nor does the operator return B{True} when the curve
- constant is valid but does not currently exist. As such, it should only be
- used to test for specific curves when the Ipo type is known::
- ipo = Object.Get('Cube').ipo # get Object-type Ipo
- if ipo:
- print Ipo.OB_LOCX in ipo # prints "True" if 'LocX' curve exists
- print Ipo.MA_R in ipo # also prints "True" since MA_R and OB_LOCX are have the same value
- print 'hiccup' in ipo # always prints "False" since argument is not a constant
-
- @return: see above.
- @rtype: Boolean
- """
-
- def __getitem__():
- """
- This operator is similar to the Python dictionary mapping operator [],
- except that the user cannot assign arbitrary keys. Each Ipo type has
- a pre-defined set of IpoCurves which may or may not exist at a given time. This operator
- will either return an IpoCurve object if the specified curve exists,
- return None if the curve does not exists, or throws a KeyError exception
- if the curve is not valid for this Ipo type.
- @return: an IpoCurve object if it exists
- @rtype: IpoCurve or None
- @raise KeyError: an undefined IpoCurve was specified for the Ipo
- """
-
- def __iter__():
- """
- Iterator for Ipos. It returns all the defined IpoCurve objects associated
- with the Ipo. For example::
- from Blender import Ipo
-
- ipo = Ipo.Get()
- if len(ipo) > 0:
- ipo = ipo[0]
- print 'ipo name is',ipo.name
- for icu in ipo:
- print ' curve name is',icu.name
- might result in::
- ipo name is ObIpo
- curve name is LocX
- curve name is LocY
- curve name is LocZ
-
- @return: an IpoCurve object
- @rtype: IpoCurve
- """
-
- def __len__():
- """
- Returns the number of curves defined for the Ipo.
- @return: number of defined IpoCurves
- @rtype: int
- """
-
- def getName():
- """
- Gets the name of the Ipo (B{deprecated}). See the L{name} attribute.
- @rtype: string
- @return: the name of the Ipo.
- """
-
- def setName(newname):
- """
- Sets the name of the Ipo (B{deprecated}). See the L{name} attribute.
- @type newname: string
- @rtype: None
- @return: None
- """
-
- def getCurves():
- """
- Gets all the IpoCurves of the Ipo (B{deprecated}). Use the
- L{iterator operator []<__iter__>} instead.
- @rtype: list of IpoCurves
- @return: A list (possibly empty) containing all the IpoCurves associated
- to the Ipo object.
- """
-
- def getCurve(curve):
- """
- Return the specified IpoCurve (B{deprecated}). Use the L{mapping
- operator B{[]}<__getitem__>} instead.
- If the curve does not exist in the Ipo,
- None is returned. I{curve} can be either a string or an integer,
- denoting either the name of the Ipo curve or its internal adrcode.
- The possible Ipo curve names are:
-
- 1. Camera Ipo: Lens, ClSta, ClEnd, Apert, FDist.
- 2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref,
- Alpha, Emit, Amb, Spec, Hard, SpTra, Ior, Mode, HaSize, Translu,
- RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow, OfsX, OfsY,
- OfsZ, SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var,
- Disp.
- 3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ,
- dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ,
- Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFall, Damping,
- RDamp, Perm.
- 4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaInt.
- 5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi,
- MisSta, MisHi, StaR, StaG, StaB, StarDi, StarSi, OfsX, OfsY, OfsZ,
- SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var.
- 5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi,
- MisSta, MisHi, StarR, StarB, StarG, StarDi, StarSi, OfsX, OfsY, OfsZ,i
- SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var.
- 6. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4,
- MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct,
- MgOff, MgGain, NBase1, NBase2.
- 7. Curve Ipo: Speed.
- 8. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ, QuatX, QuatY,
- QuatZ, QuatW.
- 9. Sequence Ipo: Fac.
- 10. Constraint Ipo: Inf.
-
- The adrcode for the Ipo curve can also be given; this is useful for
- accessing curves for Shape Key Ipos. The adrcodes for Shape Key Ipo are
- numbered consecutively starting at 0.
- @type curve : string or int
- @rtype: IpoCurve object
- @return: the corresponding IpoCurve, or None.
- @raise ValueError: I{curve} is not a valid name or adrcode for this Ipo
- type.
- """
-
- def addCurve(curvename):
- """
- Add a new curve to the Ipo object. The possible values for I{curvename} are:
- 1. Camera Ipo: Lens, ClSta, ClEnd, Apert, FDist.
- 2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref,
- Alpha, Emit, Amb, Spec, Hard, SpTra, Ior, Mode, HaSize, Translu,
- RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow, OfsX, OfsY,
- OfsZ, SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var,
- Disp.
- 3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ,
- dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ,
- Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFall, Damping,
- RDamp, Perm.
- 4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaInt.
- 5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi,
- MisSta, MisHi, StaR, StaG, StaB, StarDi, StarSi, OfsX, OfsY, OfsZ,
- SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var.
- 5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi,
- MisSta, MisHi, StarR, StarB, StarG, StarDi, StarSi, OfsX, OfsY, OfsZ,i
- SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var.
- 6. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4,
- MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct,
- MgOff, MgGain, NBase1, NBase2.
- 7. Curve Ipo: Speed.
- 8. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ, QuatX, QuatY,
- QuatZ, QuatW.
- 9. Sequence Ipo: Fac.
- 10. Constraint Ipo: Inf.
-
- For Key IPOs, the name must be an existing KeyBlock name. Use
- L{curveConsts} to determine the set of valid names.
-
- @type curvename : string
- @rtype: IpoCurve object
- @return: the corresponding IpoCurve, or None.
- @raise ValueError: I{curvename} is not valid or already exists
- """
-
- def delCurve(curvename):
- """
- Delete an existing curve from the Ipo object (B{deprecated}).
- Use the L{mapping operator B{[]}<__getitem__>} instead::
- from Blender import Ipo
-
- ipo = Ipo.Get('ObIpo')
- ipo[Ipo.LOCX] = None
-
- @type curvename : string
- @rtype: None
- @return: None.
- """
-
- def getBlocktype():
- """
- Gets the blocktype of the Ipo.
- @rtype: int
- @return: the blocktype of the Ipo.
- """
-
- def setBlocktype(newblocktype):
- """
- Sets the blocktype of the Ipo.
- @type newblocktype: int
- @rtype: None
- @return: None
- @warn: 'newblocktype' should not be changed unless you really know what
- you are doing ...
- """
-
- def getRctf():
- """
- Gets the rctf of the Ipo.
- Kind of bounding box...
- @rtype: list of floats
- @return: the rctf of the Ipo.
- """
-
- def setRctf(newrctf):
- """
- Sets the rctf of the Ipo.
- @type newrctf: four floats.
- @rtype: None
- @return: None
- @warn: rctf should not be changed unless you really know what you are
- doing ...
- """
-
- def getNcurves():
- """
- Gets the number of curves of the Ipo (B{deprecated}). Use
- L{len(ipo)<__len__>} instead.
- @rtype: int
- @return: the number of curve of the Ipo.
- """
-
- def getCurveBP(curvepos):
- """
- This method is unsupported. BPoint Ipo curves are not implemented.
- Calling this method throws a NotImplementedError exception.
- @raise NotImplementedError: this method B{always} raises an exception
- """
-
- def getBeztriple(curvepos,pointpos):
- """
- Gets a beztriple of the Ipo (B{deprecated}). B{Note}:
- Use L{IpoCurve.bezierPoints<IpoCurve.IpoCurve.bezierPoints>} instead.
- @type curvepos: int
- @param curvepos: the position of the curve in the Ipo.
- @type pointpos: int
- @param pointpos: the position of the point in the curve.
- @rtype: list of 9 floats
- @return: the beztriple of the Ipo, or an error is raised.
- """
-
- def setBeztriple(curvepos,pointpos,newbeztriple):
- """
- Sets the beztriple of the Ipo (B{deprecated}). B{Note}: use
- L{IpoCurve.bezierPoints<IpoCurve.IpoCurve.bezierPoints>} to get a
- BezTriple point, then use the
- L{BezTriple} API to set the point's attributes.
- @type curvepos: int
- @param curvepos: the position of the curve in the Ipo.
- @type pointpos: int
- @param pointpos: the position of the point in the curve.
- @type newbeztriple: list of 9 floats
- @param newbeztriple: the new value for the point
- @rtype: None
- @return: None
- """
-
- def getCurveCurval(curvepos):
- """
- Gets the current value of a curve of the Ipo (B{deprecated}). B{Note}:
- new scripts should use L{IpoCurve.evaluate()<IpoCurve.IpoCurve.evaluate>}.
- @type curvepos: int or string
- @param curvepos: the position of the curve in the Ipo or the name of the
- curve
- @rtype: float
- @return: the current value of the selected curve of the Ipo.
- """
-
- def EvaluateCurveOn(curvepos,time):
- """
- Gets the value at a specific time of a curve of the Ipo (B{deprecated}).
- B{Note}: new scripts should use
- L{IpoCurve.evaluate()<IpoCurve.IpoCurve.evaluate>}.
- @type curvepos: int
- @param curvepos: the position of the curve in the Ipo.
- @type time: float
- @param time: the desired time.
- @rtype: float
- @return: the current value of the selected curve of the Ipo at the given
- time.
- """
-import id_generics
-Ipo.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/IpoCurve.py b/source/blender/python/api2_2x/doc/IpoCurve.py
deleted file mode 100644
index 873888cffb4..00000000000
--- a/source/blender/python/api2_2x/doc/IpoCurve.py
+++ /dev/null
@@ -1,226 +0,0 @@
-# Blender.IpoCurve module and the IpoCurve PyType object
-
-"""
-The Blender.IpoCurve submodule
-
-B{New}:
- - IpoCurves supports the operator [], which accesses the value of
- curves at a given time.
-
-This module provides access to the IpoCurve data in Blender. An Ipo is
-composed of several IpoCurves, and an IpoCurve are composed of several
-BezTriples.
-
-Example::
- import Blender
- ipo = Blender.Ipo.Get('ObIpo') # retrieves an Ipo object
- ipo.name = 'ipo1' # change the Ipo's name
- icu = ipo[Blender.Ipo.OB_LOCX] # request X Location Ipo curve object
- if icu != None and len(icu.bezierPoints) > 0: # if curve exists and has BezTriple points
- val = icu[2.5] # get the curve's value at time 2.5
-
-@type ExtendTypes: readonly dictionary
-@var ExtendTypes: The available IpoCurve extend types.
- - CONST - curve is constant beyond first and last knots
- - EXTRAP - curve maintains same slope beyond first and last knots
- - CYCLIC - curve values repeat beyond first and last knots
- - CYCLIC_EXTRAP - curve values repeat beyond first and last knots,
- but while retaining continuity
-
-@type InterpTypes: readonly dictionary
-@var InterpTypes: The available IpoCurve interpolation types.
- - CONST - curve remains constant from current BezTriple knot
- - LINEAR - curve is linearly interpolated between adjacent knots
- - BEZIER - curve is interpolated by a Bezier curve between adjacent knots
-"""
-
-class IpoCurve:
- """
- The IpoCurve object
- ===================
- This object gives access to generic data from all Ipo curves objects
- in Blender.
-
- Important Notes for Rotation Ipo Curves:\n
- For the rotation Ipo curves, the y values for points are in units of 10
- degrees. For example, 45.0 degrees is stored as 4.50 degrees. These are the
- same numbers you see in the Transform Properties pop-up menu ( NKey ) in
- the IPO Curve Editor window. Positive rotations are in a counter-clockwise
- direction, following the standard convention.
-
- @ivar driver: Status of the driver. 1= on, 0= object, 2= python expression.
- @type driver: int
- @ivar driverObject: Object used to drive the Ipo curve.
- @type driverObject: Blender Object or None
- @ivar driverExpression: Python expression used to drive the Ipo curve. [0 - 127 chars]
- @type driverExpression: string
- @ivar sel: The selection state of this curve.
- @type sel: bool
- @ivar driverChannel: Object channel used to drive the Ipo curve.
- Use module constants: IpoCurve.LOC_X, IpoCurve.LOC_Y, IpoCurve.LOC_Z,
- IpoCurve.ROT_X, IpoCurve.ROT_Y, IpoCurve.ROT_Z, IpoCurve.SIZE_X,
- IpoCurve.SIZE_Y, IpoCurve.SIZE_Z
- @type driverChannel: int
- @ivar name: The IpoCurve data name.
- @type name: string
- @ivar bezierPoints: The list of the curve's bezier points.
- @type bezierPoints: list of BezTriples.
- @ivar interpolation: The curve's interpolation mode. See L{InterpTypes} for
- values.
- @type interpolation: int
- @ivar extend: The curve's extend mode. See L{ExtendTypes} for values.
-
- B{Note}: Cyclic Ipo curves never reach the end value. If the first and
- last bezier points do not have the same y coordinate, the value of the
- curve when it "cycles" is that of the first point. If a user wants to
- get the value of the final curve point, read the final point from the
- curve::
-
- ipo = Blender.Object.Get('Cube').ipo
- icu = ipo['LocX']
- endtime,endvalue = icu.bezierPoints[-1].pt
- @type extend: int
- """
-
- def __getitem__ (time):
- """
- Returns the value of the curve at a particular time.
- @type time: float
- @param time: time (Vertex X) on the curve
- @rtype: float
- @return: value (Vertex Y) corresponding to the given time
- """
-
- def __setitem__ (time):
- """
- Sets the value (Vertex Y) of the curve at a particular time.
- @type time: float
- @param time: time (Vertex X) on the curve
- """
-
- def setExtrapolation(extendmode):
- """
- Sets the extend mode of the curve (B{deprecated}). B{Note}: new scripts
- should use the L{extend} attribute instead.
- @type extendmode: string
- @param extendmode: the extend mode of the curve.
- Can be Constant, Extrapolation, Cyclic or Cyclic_extrapolation.
- @rtype: None
- @return: None
- """
-
- def getExtrapolation():
- """
- Gets the extend mode of the curve (B{deprecated}). B{Note}: new scripts
- should use the L{extend} attribute instead.
- @rtype: string
- @return: the extend mode of the curve. Can be Constant, Extrapolation, Cyclic or Cyclic_extrapolation.
- """
-
- def setInterpolation(interpolationtype):
- """
- Sets the interpolation type of the curve (B{deprecated}). B{Note}:
- new scripts should use the L{interpolation} attribute instead.
- @type interpolationtype: string
- @param interpolationtype: the interpolation type of the curve. Can be Constant, Bezier, or Linear.
- @rtype: None
- @return: None
- """
-
- def getInterpolation():
- """
- Gets the interpolation type of the curve (B{deprecated}). B{Note}:
- new scripts should use the L{interpolation} attribute instead.
- @rtype: string
- @return: the interpolation type of the curve. Can be Constant, Bezier, or Linear.
- """
-
- def append(point):
- """
- Adds a Bezier point to a IpoCurve.
- @type point: BezTriple or tuple of 2 floats
- @param point: Can either be a BezTriple, or the x and y coordinates of
- the Bezier knot point.
- @rtype: None
- @return: None
- """
-
- def addBezier(coordlist):
- """
- Adds a Bezier point to a curve B{deprecated}). B{Note}: new scripts
- should use L{append} instead.
- @type coordlist: tuple of (at least) 2 floats
- @param coordlist: the x and y coordinates of the new Bezier point.
- @rtype: None
- @return: None
- """
-
- def delBezier(index):
- """
- Deletes a Bezier point from a curve.
- @type index: integer
- @param index: the index of the Bezier point. Negative values index from the end of the list.
- @rtype: None
- @return: None
- """
-
- def recalc():
- """
- Recomputes the curve after changes to control points.
- @rtype: None
- @return: None
- """
-
- def getName():
- """
- Returns the name of the Ipo curve (B{deprecated}). B{Note}:
- new scripts should use the L{name} attribute instead.
- The name can be:
- 1. Camera Ipo: Lens, ClSta, ClEnd, Apert, FDist.
- 2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref,
- Alpha, Emit, Amb, Spec, Hard, SpTra, Ior, Mode, HaSize, Translu,
- RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow, OfsX, OfsY,
- OfsZ, SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var,
- Disp.
- 3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ,
- dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ,
- Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFall, Damping,
- RDamp, Perm.
- 4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaInt.
- 5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi,
- MisSta, MisHi, StaR, StaG, StaB, StarDi, StarSi, OfsX, OfsY, OfsZ,
- SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var.
- 5. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi,
- MisSta, MisHi, StarR, StarB, StarG, StarDi, StarSi, OfsX, OfsY, OfsZ,i
- SizeX, SizeY, SizeZ, texR, texG, texB, DefVar, Col, Nor, Var.
- 6. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4,
- MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct,
- MgOff, MgGain, NBase1, NBase2.
- 7. Curve Ipo: Speed.
- 8. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ, QuatX, QuatY,
- QuatZ, QuatW.
- 9. Sequence Ipo: Fac.
- 10. Constraint Ipo: Inf.
-
- @rtype: string
- @return: the name of the Ipo curve.
- """
-
- def getPoints():
- """
- Returns all the points of the IpoCurve (B{deprecated}).
- B{Note}: new scripts should use the L{bezierPoints} attribute instead.
- @rtype: list of BezTriples
- @return: the points of the Ipo curve.
- """
-
- def evaluate( time ):
- """
- Compute the value of the Ipo curve at a particular time (B{deprecated}).
- B{Note}: new scripts should use L{icu[time]<__getitem__>} instead.
- @type time: float
- @param time: value along the X axis
- @rtype: float
- @return: the Y value of the curve at the given time
- """
-
diff --git a/source/blender/python/api2_2x/doc/Ipodoc.txt b/source/blender/python/api2_2x/doc/Ipodoc.txt
deleted file mode 100644
index 81d51595fa9..00000000000
--- a/source/blender/python/api2_2x/doc/Ipodoc.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-IPO Module documentation
-
-
-INTRODUCTION
-The module ipo allows you to access all the data of an ipo.
-The most important part(s) of an ipo is its ipocurve(s). The ipocurve has a set of bezier points (defined by 9 coordinates). The ipo module grants the user read/write access to these points.
-
-
-
-
-functions of the module :
-
-Get(Name:string) : returns the Ipo associated whose name is Name.
-
-get : same as Get
-
-New(Name:string , idcode:int ) : Creates and returns a new Ipo Object.
-The parameters are mandatory. If the name is already used, blender will change it to name.XXX (XXX is an integer)
-
-
-
-Ipo object member functions :
-
-getName() : Retrieves the name of the Ipo Object.
-
-setName(newname:string) : Sets the name of the Ipo Object.
-
-getBlocktype() : Retrieves the blocktype of the Ipo Object.
-
-setBlocktype(newblocktype:string) : Sets the blocktype of the Ipo Object.
-
-getShowkey() : Retrieves the showkey of the Ipo Object.
-
-setShowkey(val:int) : Sets the showkey of the Ipo Object.
-
-getPad() : Retrieves the pad of the Ipo Object.
-
-setPad(val:int) : Sets the pad of the Ipo Object.
-
-getRctf() : Retrieves the rctf of the Ipo Object.
-
-setRctf(val:int) : Sets the rctf of the Ipo Object.
-
-I do not fully understand the meaning of these parameters.
-
-
-
-getNcurves() : returns the number of ipocurves the ipo object contains.
-
-getBP() : returns the basepoint of the ipo object (generally NULL)
-
-getCurveCurval(numcurve:int) : returns the current value of the ipo curve number numcurve.
-
-getCurveBeztriple(numcurve:int,numpoint:int) : returns a list of 9 floats, which are the coordinates of the control point number numpoint of the ipocurve number numcurve.
-
-
-
-setCurveBeztriple(numcurve:int,numpoint:int,newvalues : list of 9 floats) : sets the coordinates of the control point number numpoint of the ipocurve number numcurve to newvalues. (the z coordinate should be 0, but blender does not complain if non null values are passed)
-
-
-
-Example :
-import Blender
-
-d = Blender.Ipo.Get('ObIpo') # hope there is an ipo named "ObIpo"...Else create it before.
-
diff --git a/source/blender/python/api2_2x/doc/Key.py b/source/blender/python/api2_2x/doc/Key.py
deleted file mode 100644
index 53f289d2e8b..00000000000
--- a/source/blender/python/api2_2x/doc/Key.py
+++ /dev/null
@@ -1,124 +0,0 @@
-# Blender.Key module and the Key and KeyBlock PyType objects
-
-"""
-The Blender.Key submodule.
-
-This module provides access to B{Key} objects in Blender.
-
-@type Types: readonly dictionary
-@var Types: The type of a key owner, indicating the type of data in the
-data blocks.
- - MESH - the key is a Mesh key; data blocks contain
- L{NMVert<NMesh.NMVert>} vertices.
- - CURVE - the key is a Curve key; data blocks contains either
- L{BezTriples<BezTriple.BezTriple>} or points (represented by a list of
- 3 floating point numbers).
- - LATTICE - the key is a Lattice key; data blocks contain
- BPoints, each point represented by a list of 3 floating point numbers.
-"""
-
-def Get(name = None):
- """
- Get the named Key object from Blender. If the name is omitted, it
- will retrieve a list of all keys in Blender.
- @type name: string
- @param name: the name of the requested key
- @return: If name was given, return that Key object (or None if not
- found). If a name was not given, return a list of every Key object
- in Blender.
- """
-
-class Key:
- """
- The Key object
- ==============
- An object with keyframes (L{Lattice}, L{NMesh} or
- L{Curve}) will contain a Key object representing the
- keyframe data.
-
- @ivar ipo: Key Ipo. Contains the Ipo if one is assigned to the
- object, B{None} otherwise. Setting to B{None} clears the current Ipo.
- @type ipo: Blender Ipo
- @ivar value: The value of the key. Read-only.
- @type value: float
- @ivar type: An integer from the L{Types} dictionary
- representing the Key type. Read-only.
- @type type: int
- @ivar blocks: A list of KeyBlocks for the key. Read-only.
- @type blocks: Blender KeyBlock.
- @ivar relative: Indicates whether the key is relative(=True) or normal.
- @type relative: bool
- """
-
- def getIpo():
- """
- Get the L{Ipo} object associated with this key.
- """
- def getBlocks():
- """
- Get a list of L{KeyBlock}s, containing the keyframes defined for
- this Key.
- """
-
-class KeyBlock:
- """
- The KeyBlock object
- ===================
- Each Key object has a list of KeyBlocks attached, each KeyBlock
- representing a keyframe.
-
- @ivar curval: Current value of the corresponding IpoCurve. Read-only.
- @type curval: float
- @ivar name: The name of the Keyblock. Truncated to 32 characters.
- @type name: string
- @ivar pos: The position of the keyframe.
- @type pos: float
- @ivar slidermin: The minimum value for the action slider.
- Value is clamped to the range [-10.0,10.0].
- @type slidermin: float
- @ivar slidermax: The maximum value for the action slider.
- Value is clamped to the range [-10.0,10.0].
- @type slidermax: float
- @ivar vgroup: The assigned VGroup for the Key Block.
- @type vgroup: string
- @ivar data: The data of the KeyBlock (see L{getData}). This
- attribute is read-only.
- @type data: varies
- """
-
- def getData():
- """
- Get the data of a KeyBlock, as a list of data items. Each item
- will have a different data format depending on the type of this
- Key.
-
- Note that prior to 2.45 the behaviour of this function
- was different (and very wrong). Old scripts might need to be
- updated.
-
- - Mesh keys have a list of L{Vectors<Mathutils.Vector>} objects in the data
- block.
- - Lattice keys have a list of L{Vectors<Mathutils.Vector>} objects in the data
- block.
- - Curve keys return either a list of tuples, eacn containing
- four L{Vectors<Mathutils.Vector>} (if the curve is a Bezier curve),
- or otherwise just a list of L{Vectors<Mathutils.Vector>}.
-
- For bezier keys, the first three vectors in the tuple are the Bezier
- triple vectors, while the fourth vector's first element is the curve tilt
- (the other two elements are reserved and are currently unused).
-
- For non-Bezier keys, the first three elements of the returned vector is
- the curve handle point, while the fourth element is the tilt.
-
-
- A word on relative shape keys; relative shape keys are not actually
- stored as offsets to the base shape key (like you'd expect). Instead,
- each shape key stores an entire model (actually the state of the mesh
- vertices after exiting editmode with any given key active).
-
- The additive offset for a shape key is calculated (when needed) by
- comparing the shape key with its base key, which is always the very
- first in the keyblock list.
- """
-
diff --git a/source/blender/python/api2_2x/doc/Lamp.py b/source/blender/python/api2_2x/doc/Lamp.py
deleted file mode 100644
index b65fe253530..00000000000
--- a/source/blender/python/api2_2x/doc/Lamp.py
+++ /dev/null
@@ -1,521 +0,0 @@
-# Blender.Lamp module and the Lamp PyType object
-
-"""
-The Blender.Lamp submodule.
-
-B{New}: L{Lamp.clearScriptLinks} accepts a parameter now.
-
-Lamp Data
-=========
-
-This module provides control over B{Lamp Data} objects in Blender.
-
-Example::
-
- from Blender import Lamp, Scene
- l = Lamp.New('Spot') # create new 'Spot' lamp data
- l.setMode('Square', 'Shadow') # set these two lamp mode flags
- scn = Scene.GetCurrent()
- ob = scn.objects.new(l)
-
-@type Types: read-only dictionary
-@var Types: The lamp types.
- - 'Lamp': 0
- - 'Sun' : 1
- - 'Spot': 2
- - 'Hemi': 3
- - 'Area': 4
- - 'Photon': 5
-@type Modes: read-only dictionary
-@var Modes: The lamp modes. Modes may be ORed together.
- - 'Shadows'
- - 'Halo'
- - 'Layer'
- - 'Quad'
- - 'Negative'
- - 'OnlyShadow'
- - 'Sphere'
- - 'Square'
- - 'NoDiffuse'
- - 'NoSpecular'
- - 'RayShadow'
-
- Example::
- from Blender import Lamp, Object
- # Change the mode of selected lamp objects.
- for ob in Object.GetSelected(): # Loop through the current selection
- if ob.getType() == "Lamp": # if this is a lamp.
- lamp = ob.getData() # get the lamp data.
- if lamp.type == Lamp.Types["Spot"]: # Lamp type is not a flag
- lamp.mode &= ~Lamp.Modes["RayShadow"] # Disable RayShadow.
- lamp.mode |= Lamp.Modes["Shadows"] # Enable Shadowbuffer shadows
-"""
-
-def New (type = 'Lamp', name = 'LampData'):
- """
- Create a new Lamp Data object.
- @type type: string
- @param type: The Lamp type: 'Lamp', 'Sun', 'Spot', 'Hemi', 'Area', or 'Photon'.
- @type name: string
- @param name: The Lamp Data name.
- @rtype: Blender Lamp
- @return: The created Lamp Data object.
- """
-
-def Get (name = None):
- """
- Get the Lamp Data object(s) from Blender.
- @type name: string
- @param name: The name of the Lamp Data.
- @rtype: Blender Lamp or a list of Blender Lamps
- @return: It depends on the I{name} parameter:
- - (name): The Lamp Data object with the given I{name};
- - (): A list with all Lamp Data objects in the current scene.
- """
-
-class Lamp:
- """
- The Lamp Data object
- ====================
- This object gives access to Lamp-specific data in Blender.
-
- @ivar B: Lamp color blue component.
- Value is clamped to the range [0.0,1.0].
- @type B: float
- @ivar G: Lamp color green component.
- Value is clamped to the range [0.0,1.0].
- @type G: float
- @ivar R: Lamp color red component.
- Value is clamped to the range [0.0,1.0].
- @type R: float
- @ivar bias: Lamp shadow map sampling bias.
- Value is clamped to the range [0.01,5.0].
- @type bias: float
- @ivar bufferSize: Lamp shadow buffer size.
- Value is clamped to the range [512,5120].
- @type bufferSize: int
- @ivar clipEnd: Lamp shadow map clip end.
- Value is clamped to the range [1.0,5000.0].
- @type clipEnd: float
- @ivar clipStart: Lamp shadow map clip start.
- Value is clamped to the range [0.1,1000.0].
- @type clipStart: float
- @ivar col: Lamp RGB color triplet.
- Components are clamped to the range [0.0,1.0].
- @type col: RGB tuple
- @ivar dist: Lamp clipping distance.
- Value is clamped to the range [0.1,5000.0].
- @type dist: float
- @ivar energy: Lamp light intensity.
- Value is clamped to the range [0.0,10.0].
- @type energy: float
- @ivar haloInt: Lamp spotlight halo intensity.
- Value is clamped to the range [0.0,5.0].
- @type haloInt: float
- @ivar haloStep: Lamp volumetric halo sampling frequency.
- Value is clamped to the range [0,12].
- @type haloStep: int
- @ivar ipo: Lamp Ipo.
- Contains the Ipo if one is assigned to the object, B{None} otherwise. Setting to B{None} clears the current Ipo..
- @type ipo: Blender Ipo
- @ivar mode: Lamp mode bitfield. See L{Modes} for values.
- @type mode: int
- @ivar quad1: Quad lamp linear distance attenuation.
- Value is clamped to the range [0.0,1.0].
- @type quad1: float
- @ivar quad2: Quad lamp quadratic distance attenuation.
- Value is clamped to the range [0.0,1.0].
- @type quad2: float
- @ivar samples: Lamp shadow map samples.
- Value is clamped to the range [1,16].
- @type samples: int
- @ivar raySamplesX: Lamp raytracing X samples (X is used for the Y axis with square area lamps).
- Value is clamped to the range [1,16].
- @type raySamplesX: int
- @ivar raySamplesY: Lamp raytracing Y samples (Y is only used for rectangle area lamps).
- Value is clamped to the range [1,16].
- @type raySamplesY: int
- @ivar areaSizeX: Lamp X size (X is used for the Y axis with square area lamps)
- Value is clamped to the range [0.01,100.0].
- @type areaSizeX: float
- @ivar areaSizeY: Lamp Y size (Y is only used for rectangle area lamps).
- Value is clamped to the range [0.01,100.0].
- @type areaSizeY: float
- @ivar softness: Lamp shadow sample area size.
- Value is clamped to the range [1.0,100.0].
- @type softness: float
- @ivar spotBlend: Lamp spotlight edge softness.
- Value is clamped to the range [0.0,1.0].
- @type spotBlend: float
- @ivar spotSize: Lamp spotlight beam angle (in degrees).
- Value is clamped to the range [1.0,180.0].
- @type spotSize: float
- @ivar type: Lamp type. See L{Types} for values.
- @type type: int
-
- @warning: Most member variables assume values in some [Min, Max] interval.
- When trying to set them, the given parameter will be clamped to lie in
- that range: if val < Min, then val = Min, if val > Max, then val = Max.
- """
-
- def getName():
- """
- Get the name of this Lamp Data object.
- @rtype: string
- """
-
- def setName(name):
- """
- Set the name of this Lamp Data object.
- @type name: string
- @param name: The new name.
- """
-
- def getType():
- """
- Get this Lamp's type.
- @rtype: int
- """
-
- def setType(type):
- """
- Set this Lamp's type.
- @type type: string
- @param type: The Lamp type: 'Lamp', 'Sun', 'Spot', 'Hemi', 'Area', or 'Photon'
- """
-
- def getMode():
- """
- Get this Lamp's mode flags.
- @rtype: int
- @return: B{OR'ed value}. Use the Modes dictionary to check which flags
- are 'on'.
-
- Example::
- flags = mylamp.getMode()
- if flags & mylamp.Modes['Shadows']:
- print "This lamp produces shadows"
- else:
- print "The 'Shadows' flag is off"
- """
-
- def setMode(m = None, m2 = None, m3 = None, m4 = None,
- m5 = None, m6 = None, m7 = None, m8 = None):
- """
- Set this Lamp's mode flags. Mode strings given are turned 'on'.
- Those not provided are turned 'off', so lamp.setMode() -- without
- arguments -- turns off all mode flags for Lamp lamp.
- @type m: string
- @param m: A mode flag. From 1 to 8 can be set at the same time.
- """
-
- def getSamples():
- """
- Get this lamp's samples value.
- @rtype: int
- """
-
- def setSamples(samples):
- """
- Set the samples value.
- @type samples: int
- @param samples: The new samples value.
- """
-
- def getRaySamplesX():
- """
- Get this lamp's raytracing sample value on the X axis.
- This value is only used for area lamps.
- @rtype: int
- """
-
- def setRaySamplesX():
- """
- Set the lamp's raytracing sample value on the X axis, between 1 and 16.
- This value is only used for area lamps.
- @rtype: int
- """
-
- def getRaySamplesY():
- """
- Get this lamp's raytracing sample value on the Y axis.
- This value is only used for rectangle area lamps.
- @rtype: int
- """
-
- def setRaySamplesY():
- """
- Set the lamp's raytracing sample value on the Y axis, between 1 and 16.
- This value is only used for rectangle area lamps.
- @rtype: int
- """
-
- def getAreaSizeX():
- """
- Get this lamp's size on the X axis.
- This value is only used for area lamps.
- @rtype: int
- """
-
- def setAreaSizeX():
- """
- Set this lamp's size on the X axis.
- This value is only used for area lamps.
- @rtype: int
- """
-
- def getAreaSizeY():
- """
- Get this lamp's size on the Y axis.
- This value is only used for rectangle area lamps.
- @rtype: int
- """
-
- def setAreaSizeY():
- """
- Set this lamp's size on the Y axis.
- This value is only used for rectangle area lamps.
- @rtype: int
- """
-
- def getBufferSize():
- """
- Get this lamp's buffer size.
- @rtype: int
- """
-
- def setBufferSize(bufsize):
- """
- Set the buffer size value.
- @type bufsize: int
- @param bufsize: The new buffer size value.
- """
-
- def getHaloStep():
- """
- Get this lamp's halo step value.
- @rtype: int
- """
-
- def setHaloStep(hastep):
- """
- Set the halo step value.
- @type hastep: int
- @param hastep: The new halo step value.
- """
-
- def getEnergy():
- """
- Get this lamp's energy intensity value.
- @rtype: float
- """
-
- def setEnergy(energy):
- """
- Set the energy intensity value.
- @type energy: float
- @param energy: The new energy value.
- """
-
- def getDist():
- """
- Get this lamp's distance value.
- @rtype: float
- """
-
- def setDist(distance):
- """
- Set the distance value.
- @type distance: float
- @param distance: The new distance value.
- """
-
- def getSpotSize():
- """
- Get this lamp's spot size value.
- @rtype: float
- """
-
- def setSpotSize(spotsize):
- """
- Set the spot size value.
- @type spotsize: float
- @param spotsize: The new spot size value.
- """
-
- def getSpotBlend():
- """
- Get this lamp's spot blend value.
- @rtype: float
- """
-
- def setSpotBlend(spotblend):
- """
- Set the spot blend value.
- @type spotblend: float
- @param spotblend: The new spot blend value.
- """
-
- def getClipStart():
- """
- Get this lamp's clip start value.
- @rtype: float
- """
-
- def setClipStart(clipstart):
- """
- Set the clip start value.
- @type clipstart: float
- @param clipstart: The new clip start value.
- """
-
- def getClipEnd():
- """
- Get this lamp's clip end value.
- @rtype: float
- """
-
- def setClipEnd(clipend):
- """
- Set the clip end value.
- @type clipend: float
- @param clipend: The new clip end value.
- """
-
- def getBias():
- """
- Get this lamp's bias value.
- @rtype: float
- """
-
- def setBias(bias):
- """
- Set the bias value.
- @type bias: float
- @param bias: The new bias value.
- """
-
- def getSoftness():
- """
- Get this lamp's softness value.
- @rtype: float
- """
-
- def setSoftness(softness):
- """
- Set the softness value.
- @type softness: float
- @param softness: The new softness value.
- """
-
- def getHaloInt():
- """
- Get this lamp's halo intensity value.
- @rtype: float
- """
-
- def setHaloInt(haloint):
- """
- Set the halo intensity value.
- @type haloint: float
- @param haloint: The new halo intensity value.
- """
-
- def getQuad1():
- """
- Get this lamp's quad 1 value.
- @rtype: float
- @warning: this only applies to Lamps with the 'Quad' flag on.
- """
-
- def setQuad1(quad1):
- """
- Set the quad 1 value.
- @type quad1: float
- @warning: this only applies to Lamps with the 'Quad' flag on.
- """
-
- def getQuad2():
- """
- Get this lamp's quad 2 value.
- @rtype: float
- @warning: this only applies to Lamps with the 'Quad' flag on.
- """
-
- def setQuad2(quad2):
- """
- Set the quad 2 value.
- @type quad2: float
- @param quad2: The new quad 2 value.
- @warning: this only applies to Lamps with the 'Quad' flag on.
- """
-
- def getScriptLinks (event):
- """
- Get a list with this Lamp's script links of type 'event'.
- @type event: string
- @param event: "FrameChanged", "Redraw" or "Render".
- @rtype: list
- @return: a list with Blender L{Text} names (the script links of the given
- 'event' type) or None if there are no script links at all.
- """
-
- def clearScriptLinks (links = None):
- """
- Delete script links from this Lamp. If no list is specified, all
- script links are deleted.
- @type links: list of strings
- @param links: None (default) or a list of Blender L{Text} names.
- """
-
- def addScriptLink (text, event):
- """
- Add a new script link to this Lamp.
- @type text: string
- @param text: the name of an existing Blender L{Text}.
- @type event: string
- @param event: "FrameChanged", "Redraw" or "Render".
- """
-
- def getIpo():
- """
- Get the Ipo associated with this Lamp object, if any.
- @rtype: Ipo
- @return: the wrapped ipo or None.
- """
-
- def setIpo(ipo):
- """
- Link an ipo to this Lamp object.
- @type ipo: Blender Ipo
- @param ipo: a "lamp data" ipo.
- """
-
- def clearIpo():
- """
- Unlink the ipo from this Lamp object.
- @return: True if there was an ipo linked or False otherwise.
- """
-
- def insertIpoKey(keytype):
- """
- Inserts keytype values in lamp ipo at curframe. Uses module constants.
- @type keytype: Integer
- @param keytype:
- -RGB
- -ENERGY
- -SPOTSIZE
- -OFFSET
- -SIZE
- @return: None
- """
-
- def __copy__ ():
- """
- Make a copy of this lamp
- @rtype: Lamp
- @return: a copy of this lamp
- """
-
-import id_generics
-Lamp.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/Lattice.py b/source/blender/python/api2_2x/doc/Lattice.py
deleted file mode 100644
index 8666254ec0d..00000000000
--- a/source/blender/python/api2_2x/doc/Lattice.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Blender.Lattice module and the Lattice PyType object
-
-"""
-The Blender.Lattice submodule.
-
-Lattice Object
-==============
-
-This module provides access to B{Lattice} object in Blender.
-
-Example::
- import Blender
- from Blender import Lattice, Object, Scene, Modifier
-
- # Make new lattice data
- lattice_data = Lattice.New()
- lattice_data.setPartitions(5,5,5)
- lattice_data.setKeyTypes(Lattice.LINEAR, Lattice.CARDINAL, Lattice.BSPLINE)
- lattice_data.setMode(Lattice.OUTSIDE)
-
- for y in range(125):
- vec = lattice_data.getPoint(y)
- co1 = vec[0] + vec[0] / 5
- co2 = vec[1] - vec[2] * 0.3
- co3 = vec[2] * 3
- lattice_data.setPoint(y,[co1,co2,co3])
-
- # Create a new object from the lattice in the current scene
- scn = Scene.GetCurrent()
- ob_lattice = scn.objects.new(lattice_data)
-
- # Get an object to deform with this lattice
- mySphere = Object.Get('Sphere')
-
- # Apply lattice modifier
- mod= mySphere.modifiers.append(Modifier.Type.LATTICE)
- mod[Modifier.Settings.OBJECT] = ob_lattice
- mySphere.makeDisplayList()
-
- Blender.Redraw()
-"""
-
-def New (name = None):
- """
- Create a new Lattice object.
- Passing a name to this function will name the Lattice
- datablock, otherwise the Lattice data will be given a
- default name.
- @type name: string
- @param name: The Lattice name.
- @rtype: Blender Lattice
- @return: The created Lattice Data object.
- """
-
-def Get (name = None):
- """
- Get the Lattice object(s) from Blender.
- @type name: string
- @param name: The name of the Lattice object.
- @rtype: Blender Lattice or a list of Blender Lattices
- @return: It depends on the 'name' parameter:
- - (name): The Lattice object with the given name;
- - (): A list with all Lattice objects in the current scene.
- """
-
-class Lattice:
- """
- The Lattice object
- ==================
- This object gives access to Lattices in Blender.
- @ivar width: The number of x dimension partitions.
- @ivar height: The number of y dimension partitions.
- @ivar depth: The number of z dimension partitions.
- @ivar widthType: The x dimension key type.
- @ivar heightType: The y dimension key type.
- @ivar depthType: The z dimension key type.
- @ivar mode: The current mode of the Lattice.
- @ivar latSize: The number of points in this Lattice (width*height*depth).
- @cvar key: The L{Key.Key} object associated with this Lattice or None.
- """
-
- def getName():
- """
- Get the name of this Lattice datablock.
- @rtype: string
- @return: The name of the Lattice datablock.
- """
-
- def setName(name):
- """
- Set the name of this Lattice datablock.
- @type name: string
- @param name: The new name.
- """
-
- def getPartitions():
- """
- Gets the number of 'walls' or partitions that the Lattice has
- in the x, y, and z dimensions.
- @rtype: list of ints
- @return: A list corresponding to the number of partitions: [x,y,z]
- """
-
- def setPartitions(x,y,z):
- """
- Set the number of 'walls' or partitions that the
- Lattice will be created with in the x, y, and z dimensions.
- @type x: int
- @param x: The number of partitions in the x dimension of the Lattice.
- @type y: int
- @param y: The number of partitions in the y dimension of the Lattice.
- @type z: int
- @param z: The number of partitions in the z dimension of the Lattice.
- """
-
- def getKeyTypes():
- """
- Returns the deformation key types for the x, y, and z dimensions of the
- Lattice.
- @rtype: list of strings
- @return: A list corresponding to the key types will be returned: [x,y,z]
- """
-
- def setKeyTypes(xType,yType,zType):
- """
- Sets the deformation key types for the x, y, and z dimensions of the
- Lattice.
- There are three key types possible:
- - Lattice.CARDINAL
- - Lattice.LINEAR
- - Lattice.BSPLINE
- @type xType: enum constant
- @param xType: the deformation key type for the x dimension of the Lattice
- @type yType: enum constant
- @param yType: the deformation key type for the y dimension of the Lattice
- @type zType: enum constant
- @param zType: the deformation key type for the z dimension of the Lattice
- """
-
- def getMode():
- """
- Returns the current Lattice mode
- @rtype: string
- @return: A string representing the current Lattice mode
- """
-
- def setMode(modeType):
- """
- Sets the current Lattice mode
- There are two Lattice modes possible:
- - Lattice.GRID
- - Lattice.OUTSIDE
- @type modeType: enum constant
- @param modeType: the Lattice mode
- """
-
- def getPoint(index):
- """
- Returns the coordinates of a point in the Lattice by index.
- @type index: int
- @param index: The index of the point on the Lattice you want returned
- @rtype: list of floats
- @return: The x,y,z coordiates of the Lattice point : [x,y,z]
- """
-
- def setPoint(index, position):
- """
- Sets the coordinates of a point in the Lattice by index.
- @type index: int
- @param index: The index of the point on the Lattice you want set
- @type position: list of floats
- @param position: The x,y,z coordinates that you want the point to be: [x,y,z]
- """
-
- def getKey():
- """
- Returns the L{Key.Key} object associated with this Lattice.
- @rtype: L{Key.Key}
- @return: A key object representing the keyframes of the lattice or None.
- """
-
- def insertKey(frame):
- """
- Inserts the current state of the Lattice as a new absolute keyframe
-
- B{Example}::
- for z in range(5):
- for y in range(125):
- vec = myLat.getPoint(y)
- co1 = vec[0] + vec[2]
- co2 = vec[1] - vec[2]
- co3 = vec[2] + vec[1]
- myLat.setPoint(y,[co1,co2,co3])
- w = (z + 1) * 10
- myLat.insertKey(w)
-
- @type frame: int
- @param frame: the frame at which the Lattice will be set as a keyframe
- """
-
- def __copy__ ():
- """
- Make a copy of this lattice
- @rtype: Lattice
- @return: a copy of this lattice
- """
-
-import id_generics
-Lattice.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/LibData.py b/source/blender/python/api2_2x/doc/LibData.py
deleted file mode 100644
index 7884ea50659..00000000000
--- a/source/blender/python/api2_2x/doc/LibData.py
+++ /dev/null
@@ -1,137 +0,0 @@
-# bpy.lib submodule
-
-"""
-The bpy.libraries submodule.
-
-Libraries
-=========
-
-This module provides access to objects stored in .blend files. With it scripts
-can append from Blender files to the current scene, like the File->Append
-menu entry in Blender does. It allows programmers to use .blend files as
-data files for their scripts.
-
-@warn: This module is new and being considered as a replacement for the
-L{original Library<Library>} module. Users should stay tuned to see
-which module is supported in the end.
-
-Example::
- import bpy
-
- scn= bpy.scenes.active # get current scene
- lib = bpy.libraries.load('//file.blend') # open file.blend
- ob = scn.objects.link(lib.objects.append('Cube')) # append Cube object from library to current scene
- mat = lib.objects.link('Material') # get a link to a material
- me = ob.getData(mesh=1) # get mesh data
- me.materials[0] = mat # assign linked material to mesh
-"""
-
-def load(filename):
- """
- Select an existing .blend file for use as a library. Unlike the
- Library module, multiple libraries can be defined at the same time.
-
- @type filename: string
- @param filename: The filename of a Blender file. Filenames starting with "//" will be loaded relative to the blend file's location.
- @rtype: Library
- @return: return a L{Library} object.
- """
-
-class Libraries:
- """
- The Library object
- ==================
- This class provides a unified way to access and manipulate library types
- in Blender.
- It provides access to scenes, objects, meshes, curves, metaballs,
- materials, textures, images, lattices, lamps, cameras, ipos, worlds,
- fonts, texts, sounds, groups, armatures, and actions.
- @ivar filename: The path to the library
- @type filename: string
- @ivar scenes: library L{scene<Scene.Scene>} data
- @type scenes: L{LibData}
- @ivar objects: library L{object<Object.Object>} data
- @type objects: L{LibData}
- @ivar meshes: library L{mesh<Mesh.Mesh>} data
- @type meshes: L{LibData}
- @ivar curves: library L{curve<Curve.Curve>} data
- @type curves: L{LibData}
- @ivar metaballs: library L{metaball<Metaball.Metaball>} data
- @type metaballs: L{LibData}
- @ivar materials: library L{material<Material.Material>} data
- @type materials: L{LibData}
- @ivar textures: library L{texture<Texture.Texture>} data
- @type textures: L{LibData}
- @ivar images: library L{image<Image.Image>} data
- @type images: L{LibData}
- @ivar lattices: library L{lattice<Lattice.Lattice>} data
- @type lattices: L{LibData}
- @ivar lamps: library L{lamp<Lamp.Lamp>} data
- @type lamps: L{LibData}
- @ivar cameras: library L{camera<Camera.Camera>} data
- @type cameras: L{LibData}
- @ivar ipos: library L{ipo<Ipo.Ipo>} data
- @type ipos: L{LibData}
- @ivar worlds: library L{world<World.World>} data
- @type worlds: L{LibData}
- @ivar fonts: library L{font<Font.Font>} data
- @type fonts: L{LibData}
- @ivar texts: library L{text<Text.Text>} data
- @type texts: L{LibData}
- @ivar sounds: library L{sound<Sound.Sound>} data
- @type sounds: L{LibData}
- @ivar groups: library L{group<Group.Group>} data
- @type groups: L{LibData}
- @ivar armatures: library L{armature<Armature.Armature>} data
- @type armatures: L{LibData}
- @ivar actions: library L{action<NLA.Action>} data
- @type actions: L{LibData}
- """
-
-class LibData:
- """
- Generic Library Data Access
- ===========================
- This class provides access to a specific type of library data.
- """
-
- def append(name):
- """
- Append a new datablock from a library. The new copy
- is added to the current .blend file.
-
- B{Note}: Blender Objects cannot be appended or linked without linking
- them to a scene. For this reason, lib.objects.append() returns a
- special "wrapper object" which must be passed to Scene.objects.link()
- or bpy.scenes.active.link() in order to actually create the object.
- So the following code will not create a new object::
- import bpy
-
- scn= bpy.scenes.active # get current scene
- lib = bpy.libraries.load('//file.blend') # open file.blend
- pseudoOb = lib.objects.append('Cube')) # get an object wrapper
- But this code will::
- import bpy
-
- scn= bpy.scenes.active # get current scene
- lib = bpy.libraries.load('//file.blend') # open file.blend
- pseudoOb = lib.objects.append('Cube')) # get an object wrapper
- ob = scn.objects.link(pseudoOb) # link to scene
- @rtype: Blender data
- @return: return a Blender datablock or object
- @raise IOError: library cannot be read
- @raise ValueError: library does not contain B{name}
- """
-
- def link(name):
- """
- Link a new datablock from a library. The linked data is not copied
- into the local .blend file.
-
- See L{append} for notes on special handling of Blender Objects.
- @rtype: Blender data
- @return: return a Blender datablock or object
- @raise IOError: library cannot be read
- @raise ValueError: library does not contain B{name}
- """
-
diff --git a/source/blender/python/api2_2x/doc/Library.py b/source/blender/python/api2_2x/doc/Library.py
deleted file mode 100644
index c99739d939b..00000000000
--- a/source/blender/python/api2_2x/doc/Library.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# Blender.Library submodule
-
-"""
-The Blender.Library submodule.
-
-Library
-=======
-
-This module provides access to objects stored in .blend files. With it scripts
-can append from Blender files to the current scene, like the File->Append
-menu entry in Blender does. It allows programmers to use .blend files as
-data files for their scripts.
-
-@warn: This module is being considered for deprecation. Users should
-consider using the L{new Library<LibData>} module and stay tuned to see
-which module is supported in the end.
-
-Example::
- import Blender
- from Blender import Library
-
- def f(name):
- open_library(name)
-
- def open_library(name):
- Library.Open(name)
- groups = Library.LinkableGroups()
-
- for db in groups:
- print "DATABLOCK %s:" % db
- for obname in Library.Datablocks(db):
- print obname
-
- if 'Object' in groups:
- for obname in Library.Datablocks('Object'):
- Library.Load(obname, 'Object', 0) # note the 0...
- Library.Update()
-
- Library.Close()
- b.Redraw()
-
- b.Window.FileSelector(f, "Choose Library", "*.blend")
-
-"""
-
-def Open (filename):
- """
- Open an existing .blend file. If there was already one open file, it is
- closed first.
- @type filename: string
- @param filename: The filename of a Blender file. Filenames starting with "//" will be loaded relative to the blend file's location.
- @rtype: bool
- @return: 1 if successful. An IOError exception is thrown if the file cannot be opened.
- """
-
-def Close ():
- """
- Close the currently open library file, if any.
- """
-
-def getName ():
- """
- Get the filename of the currently open library file.
- @rtype: string
- @return: The open library filename.
- """
-
-def LinkableGroups ():
- """
- Get all the linkable group names from the currently open library file. These
- are the available groups for linking with the current scene. Ex: 'Object',
- 'Mesh', 'Material', 'Text', etc.
- @rtype: list of strings
- @return: the list of linkable groups.
- """
-
-def Datablocks (group):
- """
- Get all datablock objects of the given 'group' available in the currently
- open library file.
- @type group: string
- @param group: datablock group, see L{LinkableGroups}.
- """
-
-def Load (datablock, group, update = 1, linked = 0):
- """
- Load the given datablock object from the current library file
- @type datablock: string
- @type group: string
- @type update: bool
- @type linked: bool
- @param datablock: an available object name, as returned by L{Datablocks}.
- @param group: an available group name, as returned by L{LinkableGroups}.
- @param update: defines if Blender should be updated after loading this
- object. This means linking all objects and remaking all display lists,
- so it is potentially very slow.
- @param linked: Will keep objects linked to their source blend file, the update option or later updating will unlink the data from the original blend and make it local.
-
- @warn: If you plan to load more than one object in sequence, it is
- B{definitely recommended} to set 'update' to 0 in all calls to this
- function and after them call L{Update}.
- """
-
-def Update ():
- """
- Update all links and display lists in Blender. This function should be
- called after a series of L{Load}(datablock, group, B{0}) calls to make
- everything behave nicely.
- @warn: to use this function, remember to set the third L{Load} parameter to
- zero or each loading will automatically update Blender, which will slow
- down your script and make you look like a lousy programmer.
- Enough warnings :)?
- """
-
diff --git a/source/blender/python/api2_2x/doc/Material.py b/source/blender/python/api2_2x/doc/Material.py
deleted file mode 100644
index 40207dd92c0..00000000000
--- a/source/blender/python/api2_2x/doc/Material.py
+++ /dev/null
@@ -1,1061 +0,0 @@
-# Blender.Material module and the Material PyObject
-
-"""
-The Blender.Material submodule.
-
-B{New}: access to shader data.
-
-Material
-========
-
-This module provides access to B{Material} objects in Blender.
-
-Example::
- import Blender
- from Blender import Material
- mat = Material.New('newMat') # create a new Material called 'newMat'
- print mat.rgbCol # print its rgb color triplet sequence
- mat.rgbCol = [0.8, 0.2, 0.2] # change its color
- mat.setAlpha(0.2) # mat.alpha = 0.2 -- almost transparent
- mat.emit = 0.7 # equivalent to mat.setEmit(0.8)
- mat.mode |= Material.Modes.ZTRANSP # turn on Z-Buffer transparency
- mat.setName('RedBansheeSkin') # change its name
- mat.setAdd(0.8) # make it glow
- mat.setMode('Halo') # turn 'Halo' "on" and all others "off"
-
-@type Modes: readonly dictionary
-@var Modes: The available Material Modes.
-
- B{Note}: Some Modes are only available when the 'Halo' mode is I{off} and
- others only when it is I{on}. But these two subsets of modes share the same
- numerical values in their Blender C #defines. So, for example, if 'Halo' is
- on, then 'NoMist' is actually interpreted as 'HaloShaded'. We marked all
- such possibilities in the Modes dict below: each halo-related mode that
- uses an already taken value is preceded by "+" and appear below the normal
- mode which also uses that value.
-
- - TRACEABLE - Make Material visible for shadow lamps.
- - SHADOW - Enable Material for shadows.
- - SHADOWBUF - Enable Material to cast shadows with shadow buffers.
- - SHADELESS - Make Material insensitive to light or shadow.
- - WIRE - Render only the edges of faces.
- - VCOL_LIGHT - Add vertex colors as extra light.
- - VCOL_PAINT - Replace basic colors with vertex colors.
- - HALO - Render as a halo.
- - ZTRANSP - Z-buffer transparent faces.
- - ZINVERT - Render with inverted Z-buffer.
- - + HALORINGS - Render rings over the basic halo.
- - ENV - Do not render Material.
- - + HALOLINES - Render star shaped lines over the basic halo.
- - ONLYSHADOW - Let alpha be determined on the degree of shadow.
- - + HALOXALPHA - Use extreme alpha.
- - TEXFACE - UV-Editor assigned texture gives color and texture info for faces.
- - + HALOSTAR - Render halo as a star.
- - NOMIST - Set the Material insensitive to mist.
- - + HALOSHADED - Let halo receive light.
- - HALOTEX - Give halo a texture.
- - HALOPUNO - Use the vertex normal to specify the dimension of the halo.
- - HALOFLARE - Render halo as a lens flare.
- - RAYMIRROR - Enables raytracing for mirror reflection rendering.
- - RAYTRANSP - Enables raytracing for transparency rendering.
- - RAYBIAS - Prevent ray traced shadow errors with Phong interpolated normals.
- - RAMPCOL - Status of colorband ramp for Material's diffuse color. This is a read-only bit.
- - RAMPSPEC - Status of colorband ramp for Material's specular color. This is a read-only bit.
- - TANGENTSTR - Uses direction of strands as normal for tangent-shading.
- - TRANSPSHADOW - Lets Material receive transparent shadows based on material color and alpha.
- - FULLOSA - Force rendering of all OSA samples.
- - TANGENT_V - Use the tangent vector in V direction for shading
- - NMAP_TS - Tangent space normal mapping.
- - GROUP_EXCLUSIVE - Light from this group even if the lights are on a hidden Layer.
-
-@type Shaders: readonly dictionary
-@var Shaders: The available Material Shaders.
- - DIFFUSE_LAMBERT - Make Material use the lambert diffuse shader.
- - DIFFUSE_ORENNAYAR - Make Material use the Oren-Nayer diffuse shader.
- - DIFFUSE_TOON - Make Material use the toon diffuse shader.
- - DIFFUSE_MINNAERT - Make Material use the minnaert diffuse shader.
- - SPEC_COOKTORR - Make Material use the Cook-Torr specular shader.
- - SPEC_PHONG - Make Material use the Phong specular shader.
- - SPEC_BLINN - Make Material use the Blinn specular shader.
- - SPEC_TOON - Make Material use the toon specular shader.
- - SPEC_WARDISO - Make Material use the Ward-iso specular shader.
-"""
-
-def New (name = 'Mat'):
- """
- Create a new Material object.
- @type name: string
- @param name: The Material name.
- @rtype: Blender Material
- @return: The created Material object.
- """
-
-def Get (name = None):
- """
- Get the Material object(s) from Blender.
- @type name: string
- @param name: The name of the Material.
- @rtype: Blender Material or a list of Blender Materials
- @return: It depends on the 'name' parameter:
- - (name): The Material object with the given name;
- - (): A list with all Material objects in the current scene.
- """
-
-class Material:
- """
- The Material object
- ===================
- This object gives access to Materials in Blender.
- @ivar B: Diffuse color (L{rgbCol}) blue component.
- Value is clamped to the range [0.0,1.0].
- @type B: float
- @ivar G: Diffuse color (L{rgbCol}) green component.
- Value is clamped to the range [0.0,1.0].
- @type G: float
- @ivar IOR: Angular index of refraction for raytrace.
- Value is clamped to the range [1.0,3.0].
- @type IOR: float
- @ivar R: Diffuse color (L{rgbCol}) red component.
- Value is clamped to the range [0.0,1.0].
- @type R: float
- @ivar add: Strength of the add effect.
- Value is clamped to the range [0.0,1.0].
- @type add: float
- @ivar alpha: Alpha (translucency) component of the material.
- Value is clamped to the range [0.0,1.0].
- @type alpha: float
- @ivar shadAlpha: Shadow Alpha for irregular shadow buffer.
- Value is clamped to the range [0.0,1.0].
- @type shadAlpha: float
- @ivar amb: Amount of global ambient color material receives.
- Value is clamped to the range [0.0,1.0].
- @type amb: float
- @ivar diffuseDarkness: Material's diffuse darkness ("Minnaert" diffuse shader only).
- Value is clamped to the range [0.0,2.0].
- @type diffuseDarkness: float
- @ivar diffuseShader: Diffuse shader type (see L{Shaders}).
- Value must be in the range [0,3].
- @type diffuseShader: int
- @ivar diffuseSize: Material's diffuse area size ("Toon" diffuse shader only).
- Value is clamped to the range [0.0,3.14].
- @type diffuseSize: float
- @ivar diffuseSmooth: Material's diffuse area smoothing ("Toon" diffuse shader only).
- Value is clamped to the range [0.0,1.0].
- @type diffuseSmooth: float
- @ivar emit: Amount of light the material emits.
- Value is clamped to the range [0.0,1.0].
- @type emit: float
- @ivar filter: Amount of filtering when transparent raytrace is enabled.
- Value is clamped to the range [0.0,1.0].
- @type filter: float
- @ivar flareBoost: Flare's extra strength.
- Value is clamped to the range [0.1,1.0].
- @type flareBoost: float
- @ivar flareSeed: Offset in the flare seed table.
- Value is clamped to the range [1,255].
- @type flareSeed: int
- @ivar flareSize: Ratio of flare size to halo size.
- Value is clamped to the range [0.1,25.0].
- @type flareSize: float
- @ivar fresnelDepth: Power of Fresnel for mirror reflection.
- Value is clamped to the range [0.0,5.0].
- @type fresnelDepth: float
- @ivar fresnelDepthFac: Blending factor for Fresnel mirror.
- Value is clamped to the range [1.0,5.0].
- @type fresnelDepthFac: float
- @ivar fresnelTrans: Power of Fresnel for transparency.
- Value is clamped to the range [0.0,5.0].
- @type fresnelTrans: float
- @ivar fresnelTransFac: Blending factor for Fresnel transparency.
- Value is clamped to the range [1.0,5.0].
- @type fresnelTransFac: float
- @ivar rbFriction: Rigid Body Friction coefficient.
- Value is clamped to the range [0.0,100.0].
- @type rbFriction: float
- @ivar rbRestitution: Rigid Body Friction restitution.
- Value is clamped to the range [0.0,1.0].
- @type rbRestitution: float
- @ivar haloSeed: Randomizes halo ring dimension and line location.
- Value is clamped to the range [1,255].
- @type haloSeed: int
- @ivar haloSize: Dimension of the halo.
- Value is clamped to the range [0.0,100.0].
- @type haloSize: float
- @ivar hard: Hardness of the specularity.
- Value is clamped to the range [1,255].
- @type hard: int
- @ivar ipo: Material Ipo data.
- Contains the Ipo if one is assigned to the object, None otherwise. Setting to None clears the current Ipo.
- @type ipo: Blender Ipo
-
- @ivar mirCol: Mirror RGB color triplet.
- Components are clamped to the range [0.0,1.0].
- @type mirCol: list of 3 floats
- @ivar mirB: Mirror color (L{mirCol}) blue component.
- Value is clamped to the range [0.0,1.0].
- @type mirB: float
- @ivar mirG: Mirror color (L{mirCol}) green component.
- Value is clamped to the range [0.0,1.0].
- @type mirG: float
- @ivar mirR: Mirror color (L{mirCol}) red component.
- Value is clamped to the range [0.0,1.0].
- @type mirR: float
-
- @ivar sssCol: SubSsurface scattering RGB color triplet.
- Components are clamped to the range [0.0,1.0].
- @type sssCol: list of 3 floats
- @ivar sssB: SubSsurface scattering color (L{sssCol}) blue component.
- Value is clamped to the range [0.0,1.0].
- @type sssB: float
- @ivar sssG: SubSsurface scattering color (L{sssCol}) green component.
- Value is clamped to the range [0.0,1.0].
- @type sssG: float
- @ivar sssR: SubSsurface scattering color (L{sssCol}) red component.
- Value is clamped to the range [0.0,1.0].
- @type sssR: float
-
- @ivar mode: Mode mode bitfield. See L{the Modes dictionary<Modes>} keys and descriptions.
- @type mode: int
- @ivar nFlares: Number of subflares with halo.
- Value is clamped to the range [1,32].
- @type nFlares: int
- @ivar nLines: Number of star-shaped lines with halo.
- Value is clamped to the range [0,250].
- @type nLines: int
- @ivar nRings: Number of rings with halo.
- Value is clamped to the range [0,24].
- @type nRings: int
- @ivar nStars: Number of star points with halo.
- Value is clamped to the range [3,50].
- @type nStars: int
- @ivar oopsLoc: Material OOPs location. Returns None if material not found in list.
- @type oopsLoc: list of 2 floats
- @ivar oopsSel: Material OOPs selection flag.
- Value must be in the range [0,1].
- @type oopsSel: int
- @ivar rayMirr: Mirror reflection amount for raytrace.
- Value is clamped to the range [0.0,1.0].
- @type rayMirr: float
- @ivar rayMirrDepth: Amount of raytrace inter-reflections.
- Value is clamped to the range [0,10].
- @type rayMirrDepth: int
- @ivar ref: Amount of reflections (for shader).
- Value is clamped to the range [0.0,1.0].
- @type ref: float
- @ivar refracIndex: Material's Index of Refraction (applies to the "Blinn" Specular Shader only.
- Value is clamped to the range [1.0,10.0].
- @type refracIndex: float
- @ivar rgbCol: Diffuse RGB color triplet.
- Components are clamped to the range [0.0,1.0].
- @type rgbCol: list of 3 floats
- @ivar rms: Material's surface slope standard deviation ("WardIso" specular shader only).
- Value is clamped to the range [0.0,0.4].
- @type rms: float
- @ivar roughness: Material's roughness ("Oren Nayar" diffuse shader only).
- Value is clamped to the range [0.0,3.14].
- @type roughness: float
- @ivar spec: Degree of specularity.
- Value is clamped to the range [0.0,2.0].
- @type spec: float
- @ivar specB: Specular color (L{specCol}) blue component.
- Value is clamped to the range [0.0,1.0].
- @type specB: float
- @ivar specCol: Specular RGB color triplet.
- Components are clamped to the range [0.0,1.0].
- @type specCol: list of 3 floats
- @ivar specG: Specular color (L{specCol}) green component.
- Value is clamped to the range [0.0,1.0].
- @type specG: float
- @ivar specR: Specular color (L{specCol}) red component.
- Value is clamped to the range [0.0,1.0].
- @type specR: float
- @ivar specShader: Specular shader type. See L{Shaders}.
- Value must be in the range [0,4].
- @type specShader: int
- @ivar specSize: Material's specular area size ("Toon" specular shader only).
- Value is clamped to the range [0.0,1.53].
- @type specSize: float
- @ivar specSmooth: Sets the smoothness of specular toon area.
- Value is clamped to the range [0.0,1.0].
- @type specSmooth: float
- @ivar specTransp: Makes specular areas opaque on transparent materials.
- Value is clamped to the range [0.0,1.0].
- @type specTransp: float
- @ivar subSize: Dimension of subflares, dots and circles.
- Value is clamped to the range [0.1,25.0].
- @type subSize: float
- @ivar transDepth: calculated maximal. Amount of refractions for raytrace.
- Value is clamped to the range [0,10].
- @type transDepth: int
- @ivar translucency: Amount of diffuse shading of the back side.
- Value is clamped to the range [0.0,1.0].
- @type translucency: float
- @ivar zOffset: Artificial offset in the Z buffer (for Ztransp option).
- Value is clamped to the range [0.0,10.0].
- @type zOffset: float
- @ivar lightGroup: Limits lights that affect this material to a group.
- @type lightGroup: Group or None
- @ivar uvlayer: The uv layer name to use, when UV mapping is enabled.
- @type uvlayer: string
- @ivar colorband: Material colorband, a list of colors,
- each color a list of 5 floats [0 - 1], [r,g,b,a,pos].
- The colorband can have between 1 and 31 colors.
- @type colorband: list
-
- @ivar colorbandDiffuse: Material colorband, a list of colors,
- each color a list of 5 floats [0 - 1], [r,g,b,a,pos].
- The colorband can have between 1 and 31 colors.
- @type colorbandDiffuse: list
- @ivar colorbandSpecular: Material colorband, a list of colors,
- each color a list of 5 floats [0 - 1], [r,g,b,a,pos].
- The colorband can have between 1 and 31 colors.
- @type colorbandSpecular: list
-
- @ivar enableSSS: If True, subsurface scattering will be rendered on this material.
- @type enableSSS: bool
- @ivar sssScale: If True, subsurface scattering will be rendered on this material.
- Value is clamped to the range [0.1,1000.0].
- @type sssScale: bool
- @ivar sssRadiusRed: Mean red scattering path length.
- Value is clamped to the range [0.0,10000.0].
- @type sssRadiusRed: float
- @ivar sssRadiusGreen: Mean green scattering path length.
- Value is clamped to the range [0.0,10000.0].
- @type sssRadiusGreen: float
- @ivar sssRadiusBlue: Mean blue scattering path length.
- Value is clamped to the range [0.0,10000.0].
- @type sssRadiusBlue: float
- @ivar sssIOR: Refraction index.
- Value is clamped to the range [0.1,2.0].
- @type sssIOR: float
- @ivar sssError: Error allowance for the calculation (a low value is slower).
- Value is clamped to the range [0.0,10.0].
- @type sssError: float
- @ivar sssColorBlend: Blend factor for SSS colors.
- Value is clamped to the range [0.0,1.0].
- @type sssColorBlend: float
- @ivar sssTextureScatter: Texture scattering factor.
- Value is clamped to the range [0.0,1.0].
- @type sssTextureScatter: float
- @ivar sssFront: Front scattering weight.
- Value is clamped to the range [0.0,2.0].
- @type sssFront: float
- @ivar sssBack: Back scattering weight
- Value is clamped to the range [0.0,10.0].
- @type sssBack: float
-
- @warning: Most member variables assume values in some [Min, Max] interval.
- When trying to set them, the given parameter will be clamped to lie in
- that range: if val < Min, then val = Min, if val > Max, then val = Max.
-
- """
-
- def getName():
- """
- Get the name of this Material object.
- @rtype: string
- """
-
- def setName(name):
- """
- Set the name of this Material object.
- @type name: string
- @param name: The new name.
- """
-
- def getIpo():
- """
- Get the Ipo associated with this material, if any.
- @rtype: Ipo
- @return: the wrapped ipo or None.
- """
-
- def setIpo(ipo):
- """
- Link an ipo to this material.
- @type ipo: Blender Ipo
- @param ipo: a material type ipo.
- """
-
- def clearIpo():
- """
- Unlink the ipo from this material.
- @return: True if there was an ipo linked or False otherwise.
- """
-
- def insertIpoKey(keytype):
- """
- Inserts keytype values in material ipo at curframe. Uses module constants.
- @type keytype: Integer
- @param keytype:
- -RGB
- -ALPHA
- -HALOSIZE
- -MODE
- -ALLCOLOR
- -ALLMIRROR
- -OFS
- -SIZE
- -ALLMAPPING
- @return: py_none
- """
-
- def getMode():
- """
- Get this Material's mode flags.
- @rtype: int
- @return: B{OR'ed value}. Use the Modes dictionary to check which flags
- are 'on'.
-
- Example::
- import Blender
- from Blender import Material
- flags = mymat.getMode()
- if flags & Material.Modes['HALO']:
- print "This material is rendered as a halo"
- else:
- print "Not a halo"
- """
-
- def setMode(param, stringN=None):
- """
- Set this Material's mode flags. Up to 22 mode strings can be given
- and specify the modes which are turned 'on'. Those not provided are
- turned 'off', so mat.setMode() -- without arguments -- turns off all
- mode flags for Material mat. Valid mode strings are "Traceable",
- "Shadow", "Shadeless", "Wire", "VColLight", "VColPaint", "Halo",
- "ZTransp", "ZInvert", "HaloRings", "HaloLines", "OnlyShadow",
- "HaloXAlpha", "HaloStar", "TexFace", "HaloTex", "HaloPuno", "NoMist",
- "HaloShaded", "HaloFlare", "Radio", "RayMirr", "ZTransp", "RayTransp",
- "Env"
-
- An integer can also be given, which directly sets the mode flag. The
- Modes dictionary keys can (and should) be added or ORed to specify
- which modes to turn 'on'. The value returned from getMode() can
- also be modified and input to this method.
-
- @type param: string, None or int
- @param param: A mode value (int) or flag (string). Can also be None.
- @type stringN: string
- @param stringN: A mode flag. Up to 22 flags can be set at the same time.
- """
-
- def getRGBCol():
- """
- Get the rgb color triplet sequence.
- @rtype: list of 3 floats
- @return: [r, g, b]
- """
-
- def setRGBCol(rgb = None):
- """
- Set the rgb color triplet sequence. If B{rgb} is None, set the color to black.
- @type rgb: three floats or a list of three floats
- @param rgb: The rgb color values in [0.0, 1.0] as:
- - a list of three floats: setRGBCol ([r, g, b]) B{or}
- - three floats as separate parameters: setRGBCol (r,g,b).
- """
-
- def getSpecCol():
- """
- Get the specular color triplet sequence.
- @rtype: list of 3 floats
- @return: [specR, specG, specB]
- """
-
- def setSpecCol(rgb = None):
- """
- Set the specular color triplet sequence. If B{rgb} is None, set the color to black.
- @type rgb: three floats or a list of three floats
- @param rgb: The rgb color values in [0.0, 1.0] as:
- - a list of three floats: setSpecCol ([r, g, b]) B{or}
- - three floats as separate parameters: setSpecCol (r,g,b).
- """
-
- def getMirCol():
- """
- Get the mirror color triplet sequence.
- @rtype: list of 3 floats
- @return: [mirR, mirG, mirb]
- """
-
- def setMirCol(rgb = None):
- """
- Set the mirror color triplet sequence. If B{rgb} is None, set the color to black.
- @type rgb: three floats or a list of three floats
- @param rgb: The rgb color values in [0.0, 1.0] as:
- - a list of three floats: setMirCol ([r, g, b]) B{or}
- - three floats as separate parameters: setMirCol (r,g,b).
- """
-
- def getAlpha():
- """
- Get the alpha (transparency) value.
- @rtype: float
- """
-
- def setAlpha(alpha):
- """
- Set the alpha (transparency) value.
- @type alpha: float
- @param alpha: The new value in [0.0, 1.0].
- """
-
- def getAmb():
- """
- Get the ambient color blend factor.
- @rtype: float
- """
-
- def setAmb(amb):
- """
- Set the ambient color blend factor.
- @type amb: float
- @param amb: The new value in [0.0, 1.0].
- """
-
- def getEmit():
- """
- Get the emitting light intensity.
- @rtype: float
- """
-
- def setEmit(emit):
- """
- Set the emitting light intensity.
- @type emit: float
- @param emit: The new value in [0.0, 1.0].
- """
-
- def getRef():
- """
- Get the reflectivity value.
- @rtype: float
- """
-
- def setRef(ref):
- """
- Set the reflectivity value.
- @type ref: float
- @param ref: The new value in [0.0, 1.0].
- """
-
- def getSpec():
- """
- Get the specularity value.
- @rtype: float
- """
-
- def setSpec(spec):
- """
- Set the specularity value.
- @type spec: float
- @param spec: The new value in [0.0, 2.0].
- """
-
- def getSpecTransp():
- """
- Get the specular transparency.
- @rtype: float
- """
-
- def setSpecTransp(spectransp):
- """
- Set the specular transparency.
- @type spectransp: float
- @param spectransp: The new value in [0.0, 1.0].
- """
-
- def setSpecShader(specShader):
- """
- Set the material's specular shader from one of the shaders in Material.Shaders dict.
- @type specShader: int
- @param specShader: The new value in [0, 4].
- """
-
- def getSpecShader(specShader):
- """
- Get the material's specular shader from one of the shaders in Material.Shaders dict.
- @rtype: int
- """
-
- def setDiffuseShader(diffuseShader):
- """
- Set the material's diffuse shader from one of the shaders in Material.Shaders dict.
- @type diffuseShader: int
- @param diffuseShader: The new value in [0, 3].
- """
-
- def getDiffuseShader():
- """
- Get the material's diffuse shader from one of the shaders in Material.Shaders dict.
- @rtype: int
- """
-
- def setRoughness(roughness):
- """
- Set the material's roughness (applies to the \"Oren Nayar\" Diffuse Shader only)
- @type roughness: float
- @param roughness: The new value in [0.0, 3.14].
- """
-
- def getRoughness():
- """
- Get the material's roughness (applies to the \"Oren Nayar\" Diffuse Shader only)
- @rtype: float
- """
-
- def setSpecSize(specSize):
- """
- Set the material's size of specular area (applies to the \"Toon\" Specular Shader only)
- @type specSize: float
- @param specSize: The new value in [0.0, 1.53].
- """
-
- def getSpecSize():
- """
- Get the material's size of specular area (applies to the \"Toon\" Specular Shader only)
- @rtype specSize: float
- """
-
- def setSpecSize(diffuseSize):
- """
- Set the material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)
- @type diffuseSize: float
- @param diffuseSize: The new value in [0.0, 3.14].
- """
-
- def getSpecSize():
- """
- Get the material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)
- @rtype: float
- """
-
- def setSpecSmooth(specSmooth):
- """
- Set the material's smoothing of specular area (applies to the \"Toon\" Specular Shader only)
- @type specSmooth: float
- @param specSmooth: The new value in [0.0, 1.0].
- """
-
- def getSpecSmooth():
- """
- Get the material's smoothing of specular area (applies to the \"Toon\" Specular Shader only)
- @rtype: float
- """
-
- def setDiffuseSmooth(diffuseSmooth):
- """
- Set the material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)
- @type diffuseSmooth: float
- @param diffuseSmooth: The new value in [0.0, 1.0].
- """
-
- def getDiffuseSmooth():
- """
- Get the material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)
- @rtype: float
- """
-
- def setDiffuseDarkness(diffuseDarkness):
- """
- Set the material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)
- @type diffuseDarkness: float
- @param diffuseDarkness: The new value in [0.0, 2.0].
- """
-
- def getDiffuseDarkness():
- """
- Get the material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)
- @rtype: float
- """
-
- def setRefracIndex(refracIndex):
- """
- Set the material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)
- @type refracIndex: float
- @param refracIndex: The new value in [1.0, 10.0].
- """
-
- def getRefracIndex():
- """
- Get the material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)
- @rtype: float
- """
-
- def setRms(rms):
- """
- Set the material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)
- @type rms: float
- @param rms: The new value in [0.0, 0.4].
- """
-
- def getRms():
- """
- Get the material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)
- @rtype: float
- """
-
- def setFilter(filter):
- """
- Set the material's amount of filtering when transparent raytrace is enabled
- @type filter: float
- @param filter: The new value in [0.0, 1.0].
- """
-
- def getFilter():
- """
- Get the material's amount of filtering when transparent raytrace is enabled
- @rtype: float
- """
-
- def setTranslucency(translucency):
- """
- Set the material's amount of diffuse shading of the back side
- @type translucency: float
- @param translucency: The new value in [0.0, 1.0].
- """
-
- def getTranslucency():
- """
- Get the material's amount of diffuse shading of the back side
- @rtype: float
- """
-
- def getAdd():
- """
- Get the glow factor.
- @rtype: float
- """
-
- def setAdd(add):
- """
- Set the glow factor.
- @type add: float
- @param add: The new value in [0.0, 1.0].
- """
-
- def getZOffset():
- """
- Get the artificial offset for faces with this Material.
- @rtype: float
- """
-
- def setZOffset(zoffset):
- """
- Set the artificial offset for faces with this Material.
- @type zoffset: float
- @param zoffset: The new value in [0.0, 10.0].
- """
-
- def getHaloSize():
- """
- Get the halo size.
- @rtype: float
- """
-
- def setHaloSize(halosize):
- """
- Set the halo size.
- @type halosize: float
- @param halosize: The new value in [0.0, 100.0].
- """
-
- def getHaloSeed():
- """
- Get the seed for random ring dimension and line location in halos.
- @rtype: int
- """
-
- def setHaloSeed(haloseed):
- """
- Set the seed for random ring dimension and line location in halos.
- @type haloseed: int
- @param haloseed: The new value in [0, 255].
- """
-
- def getFlareSize():
- """
- Get the ratio: flareSize / haloSize.
- @rtype: float
- """
-
- def setFlareSize(flaresize):
- """
- Set the ratio: flareSize / haloSize.
- @type flaresize: float
- @param flaresize: The new value in [0.1, 25.0].
- """
-
- def getFlareSeed():
- """
- Get flare's offset in the seed table.
- @rtype: int
- """
-
- def setFlareSeed(flareseed):
- """
- Set flare's offset in the seed table.
- @type flareseed: int
- @param flareseed: The new value in [0, 255].
- """
-
- def getFlareBoost():
- """
- Get the flare's extra strength.
- @rtype: float
- """
-
- def setFlareBoost(flareboost):
- """
- Set the flare's extra strength.
- @type flareboost: float
- @param flareboost: The new value in [0.1, 10.0].
- """
-
- def getSubSize():
- """
- Get the dimension of subflare, dots and circles.
- @rtype: float
- """
-
- def setSubSize(subsize):
- """
- Set the dimension of subflare, dots and circles.
- @type subsize: float
- @param subsize: The new value in [0.1, 25.0].
- """
-
- def getHardness():
- """
- Get the hardness of the specularity.
- @rtype: int
- """
-
- def setHardness(hardness):
- """
- Set the hardness of the specularity.
- @type hardness: int
- @param hardness: The new value in [1, 511].
- """
-
- def getNFlares():
- """
- Get the number of halo subflares.
- @rtype: int
- """
-
- def setNFlares(nflares):
- """
- Set the number of halo subflares.
- @type nflares: int
- @param nflares: The new value in [1, 32].
- """
-
- def getNStars():
- """
- Get the number of points in the halo stars.
- @rtype: int
- """
-
- def setNStars(nstars):
- """
- Set the number of points in the halo stars.
- @type nstars: int
- @param nstars: The new value in [3, 50].
- """
-
- def getNLines():
- """
- Get the number of star shaped lines on each halo.
- @rtype: int
- """
-
- def setNLines(nlines):
- """
- Set the number of star shaped lines on each halo.
- @type nlines: int
- @param nlines: The new value in [0, 250].
- """
-
- def getNRings():
- """
- Get the number of rings on each halo.
- @rtype: int
- """
-
- def setNRings(nrings):
- """
- Set the number of rings on each halo.
- @type nrings: int
- @param nrings: The new value in [0, 24].
- """
-
- def getRayMirr():
- """
- Get amount mirror reflection for raytrace.
- @rtype: float
- """
-
- def setRayMirr(nrmirr):
- """
- Set amount mirror reflection for raytrace.
- @type nrmirr: float
- @param nrmirr: The new value in [0.0, 1.0].
- """
-
- def getRayMirrDepth():
- """
- Get amount of inter-reflections calculated maximal.
- @rtype: int
- """
-
- def setRayMirrDepth(nrmirr):
- """
- Set amount mirror reflection for raytrace.
- @type nrmirr: int
- @param nrmirr: The new value in [0.0, 1.0].
- """
-
- def getFresnelMirr():
- """
- Get power of Fresnel for mirror reflection.
- @rtype: float
- """
-
- def setFresnelMirr(nrmirr):
- """
- Set power of Fresnel for mirror reflection.
- @type nrmirr: float
- @param nrmirr: The new value in [0.0, 1.0].
- """
-
- def getFresnelMirrFac():
- """
- Get the number of Ray Mirror.
- @rtype: float
- """
-
- def setFresnelMirrFac(nrmirr):
- """
- Set the number of ray mirror
- @type nrmirr: float
- @param nrmirr: The new value in [0.0, 1.0].
- """
-
- def getIOR():
- """
- Get the angular index of refraction for raytrace.
- @rtype: float
- """
-
- def setIOR(nrmirr):
- """
- Set the angular index of refraction for raytrace.
- @type nrmirr: float
- @param nrmirr: The new value in [0.0, 1.0].
- """
-
- def getTransDepth():
- """
- Get amount of refractions calculated maximal.
- @rtype: int
- """
-
- def setTransDepth(nrmirr):
- """
- Set amount of refractions calculated maximal.
- @type nrmirr: int
- @param nrmirr: The new value in [0.0, 1.0].
- """
-
- def getFresnelTrans():
- """
- Get power of Fresnel for transparency.
- @rtype: float
- """
-
- def setFresnelTrans(nrmirr):
- """
- Set power of Fresnel for transparency.
- @type nrmirr: float
- @param nrmirr: The new value in [0.0, 1.0].
- """
-
- def getFresnelTransFac():
- """
- Get blending factor for Fresnel.
- @rtype: float
- """
-
- def setFresnelTransFac(nrmirr):
- """
- Set blending factor for Fresnel.
- @type nrmirr: float
- @param nrmirr: The new value in [0.0, 1.0].
- """
-
- def setTexture(index, texture, texco, mapto):
- """
- Assign a Blender Texture object to slot number 'number'.
- @type index: int
- @param index: material's texture index in [0, 9].
- @type texture: Blender Texture
- @param texture: a Blender Texture object.
- @type texco: int
- @param texco: optional ORed bitflag -- defaults to TexCo.ORCO. See TexCo var in L{Texture}.
- @type mapto: int
- @param mapto: optional ORed bitflag -- defaults to MapTo.COL. See MapTo var in L{Texture}.
- """
-
- def clearTexture(index):
- """
- Clear the ith (given by 'index') texture channel of this material.
- @type index: int
- @param index: material's texture channel index in [0, 9].
- """
-
- def getTextures ():
- """
- Get this Material's Texture list.
- @rtype: list of MTex
- @return: a list of Blender MTex objects. None is returned for each empty
- texture slot.
- """
-
- def getScriptLinks (event):
- """
- Get a list with this Material's script links of type 'event'.
- @type event: string
- @param event: "FrameChanged" or "Redraw".
- @rtype: list
- @return: a list with Blender L{Text} names (the script links of the given
- 'event' type) or None if there are no script links at all.
- """
-
- def clearScriptLinks (links = None):
- """
- Delete script links from this Material. If no list is specified, all
- script links are deleted.
- @type links: list of strings
- @param links: None (default) or a list of Blender L{Text} names.
- """
-
- def addScriptLink (text, event):
- """
- Add a new script link to this Material.
- @type text: string
- @param text: the name of an existing Blender L{Text}.
- @type event: string
- @param event: "FrameChanged" or "Redraw".
- """
-
- def __copy__ ():
- """
- Make a copy of this material
- @rtype: Material
- @return: a copy of this material
- """
-
-import id_generics
-Material.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/Mathutils.py b/source/blender/python/api2_2x/doc/Mathutils.py
deleted file mode 100644
index 7546bb5b6d5..00000000000
--- a/source/blender/python/api2_2x/doc/Mathutils.py
+++ /dev/null
@@ -1,864 +0,0 @@
-# Blender.Mathutils module and its subtypes
-
-"""
-The Blender.Mathutils submodule.
-
-Mathutils
-=========
-
-This module provides access to matrices, eulers, quaternions and vectors.
-
-Example::
- import Blender
- from Blender import Mathutils
- from Blender.Mathutils import *
-
- vec = Vector([1,2,3])
- mat = RotationMatrix(90, 4, 'x')
- matT = TranslationMatrix(vec)
-
- matTotal = mat * matT
- matTotal.invert()
-
- mat3 = matTotal.rotationPart
- quat1 = mat.toQuat()
- quat2 = mat3.toQuat()
-
- angle = DifferenceQuats(quat1, quat2)
- print angle
-"""
-
-def Rand (high = 1, low = 0):
- """
- Return a random number within a range.
- High and low represent the range from which the random
- number must return its result.
- @type high: float
- @param high: The upper range.
- @type low: float
- @param low: The lower range.
- """
-
-def Intersect(vec1, vec2, vec3, ray, orig, clip=1):
- """
- Return the intersection between a ray and a triangle, if possible, return None otherwise.
- @type vec1: Vector object.
- @param vec1: A 3d vector, one corner of the triangle.
- @type vec2: Vector object.
- @param vec2: A 3d vector, one corner of the triangle.
- @type vec3: Vector object.
- @param vec3: A 3d vector, one corner of the triangle.
- @type ray: Vector object.
- @param ray: A 3d vector, the orientation of the ray. the length of the ray is not used, only the direction.
- @type orig: Vector object.
- @param orig: A 3d vector, the origin of the ray.
- @type clip: integer
- @param clip: if 0, don't restrict the intersection to the area of the triangle, use the infinite plane defined by the triangle.
- @rtype: Vector object
- @return: The intersection between a ray and a triangle, if possible, None otherwise.
- """
-
-def TriangleArea(vec1, vec2, vec3):
- """
- Return the area size of the 2D or 3D triangle defined.
- @type vec1: Vector object.
- @param vec1: A 2d or 3d vector, one corner of the triangle.
- @type vec2: Vector object.
- @param vec2: A 2d or 3d vector, one corner of the triangle.
- @type vec3: Vector object.
- @param vec3: A 2d or 3d vector, one corner of the triangle.
- @rtype: float
- @return: The area size of the 2D or 3D triangle defined.
- """
-
-def TriangleNormal(vec1, vec2, vec3):
- """
- Return the normal of the 3D triangle defined.
- @type vec1: Vector object.
- @param vec1: A 3d vector, one corner of the triangle.
- @type vec2: Vector object.
- @param vec2: A 3d vector, one corner of the triangle.
- @type vec3: Vector object.
- @param vec3: A 3d vector, one corner of the triangle.
- @rtype: float
- @return: The normal of the 3D triangle defined.
- """
-
-def QuadNormal(vec1, vec2, vec3, vec4):
- """
- Return the normal of the 3D quad defined.
- @type vec1: Vector object.
- @param vec1: A 3d vector, the first vertex of the quad.
- @type vec2: Vector object.
- @param vec2: A 3d vector, the second vertex of the quad.
- @type vec3: Vector object.
- @param vec3: A 3d vector, the third vertex of the quad.
- @type vec4: Vector object.
- @param vec4: A 3d vector, the fourth vertex of the quad.
- @rtype: float
- @return: The normal of the 3D quad defined.
- """
-
-def LineIntersect(vec1, vec2, vec3, vec4):
- """
- Return a tuple with the points on each line respectively closest to the other
- (when both lines intersect, both vector hold the same value).
- The lines are evaluated as infinite lines in space, the values returned may not be between the 2 points given for each line.
- @type vec1: Vector object.
- @param vec1: A 3d vector, one point on the first line.
- @type vec2: Vector object.
- @param vec2: A 3d vector, another point on the first line.
- @type vec3: Vector object.
- @param vec3: A 3d vector, one point on the second line.
- @type vec4: Vector object.
- @param vec4: A 3d vector, another point on the second line.
- @rtype: (Vector object, Vector object)
- @return: A tuple with the points on each line respectively closest to the other.
- """
-
-def CopyVec(vector):
- """
- Create a copy of the Vector object.
- @attention: B{DEPRECATED} use vector.copy() instead.
- @type vector: Vector object.
- @param vector: A 2d,3d or 4d vector to be copied.
- @rtype: Vector object.
- @return: A new vector object which is a copy of the one passed in.
- """
-
-def CrossVecs(vec1, vec2):
- """
- Return the cross product of two vectors.
- @type vec1: Vector object.
- @param vec1: A 3d vector.
- @type vec2: Vector object.
- @param vec2: A 3d vector.
- @rtype: Vector object.
- @return: A new vector representing the cross product of
- the two vectors.
- """
-
-def DotVecs(vec1, vec2):
- """
- Return the dot product of two vectors.
- @type vec1: Vector object.
- @param vec1: A 2d,3d or 4d vector.
- @type vec2: Vector object.
- @param vec2: A 2d,3d or 4d vector.
- @rtype: float
- @return: Return the scalar product of vector muliplication.
- """
-
-def AngleBetweenVecs(vec1, vec2):
- """
- Return the angle between two vectors. Zero length vectors raise an error.
- @type vec1: Vector object.
- @param vec1: A 2d or 3d vector.
- @type vec2: Vector object.
- @param vec2: A 2d or 3d vector.
- @rtype: float
- @return: The angle between the vectors in degrees.
- @raise AttributeError: When there is a zero-length vector as an argument.
- """
-
-def MidpointVecs(vec1, vec2):
- """
- Return a vector to the midpoint between two vectors.
- @type vec1: Vector object.
- @param vec1: A 2d,3d or 4d vector.
- @type vec2: Vector object.
- @param vec2: A 2d,3d or 4d vector.
- @rtype: Vector object
- @return: The vector to the midpoint.
- """
-
-def VecMultMat(vec, mat):
- """
- Multiply a vector and matrix (pre-multiply)
- Vector size and matrix column size must equal.
- @type vec: Vector object.
- @param vec: A 2d,3d or 4d vector.
- @type mat: Matrix object.
- @param mat: A 2d,3d or 4d matrix.
- @rtype: Vector object
- @return: The row vector that results from the muliplication.
- @attention: B{DEPRECATED} You should now multiply vector * matrix direcly
- Example::
- result = myVector * myMatrix
- """
-
-def ProjectVecs(vec1, vec2):
- """
- Return the projection of vec1 onto vec2.
- @type vec1: Vector object.
- @param vec1: A 2d,3d or 4d vector.
- @type vec2: Vector object.
- @param vec2: A 2d,3d or 4d vector.
- @rtype: Vector object
- @return: The parallel projection vector.
- """
-
-def RotationMatrix(angle, matSize, axisFlag, axis):
- """
- Create a matrix representing a rotation.
- @type angle: float
- @param angle: The angle of rotation desired.
- @type matSize: int
- @param matSize: The size of the rotation matrix to construct.
- Can be 2d, 3d, or 4d.
- @type axisFlag: string (optional)
- @param axisFlag: Possible values:
- - "x - x-axis rotation"
- - "y - y-axis rotation"
- - "z - z-axis rotation"
- - "r - arbitrary rotation around vector"
- @type axis: Vector object. (optional)
- @param axis: The arbitrary axis of rotation used with "R"
- @rtype: Matrix object.
- @return: A new rotation matrix.
- """
-
-def TranslationMatrix(vector):
- """
- Create a matrix representing a translation
- @type vector: Vector object
- @param vector: The translation vector
- @rtype: Matrix object.
- @return: An identity matrix with a translation.
- """
-
-def ScaleMatrix(factor, matSize, axis):
- """
- Create a matrix representing a scaling.
- @type factor: float
- @param factor: The factor of scaling to apply.
- @type matSize: int
- @param matSize: The size of the scale matrix to construct.
- Can be 2d, 3d, or 4d.
- @type axis: Vector object. (optional)
- @param axis: Direction to influence scale.
- @rtype: Matrix object.
- @return: A new scale matrix.
- """
-
-def OrthoProjectionMatrix(plane, matSize, axis):
- """
- Create a matrix to represent an orthographic projection
- @type plane: string
- @param plane: Can be any of the following:
- - "x - x projection (2D)"
- - "y - y projection (2D)"
- - "xy - xy projection"
- - "xz - xz projection"
- - "yz - yz projection"
- - "r - arbitrary projection plane"
- @type matSize: int
- @param matSize: The size of the projection matrix to construct.
- Can be 2d, 3d, or 4d.
- @type axis: Vector object. (optional)
- @param axis: Arbitrary perpendicular plane vector.
- @rtype: Matrix object.
- @return: A new projeciton matrix.
- """
-
-def ShearMatrix(plane, factor, matSize):
- """
- Create a matrix to represent an orthographic projection
- @type plane: string
- @param plane: Can be any of the following:
- - "x - x shear (2D)"
- - "y - y shear (2D)"
- - "xy - xy shear"
- - "xz - xz shear"
- - "yz - yz shear"
- @type factor: float
- @param factor: The factor of shear to apply.
- @type matSize: int
- @param matSize: The size of the projection matrix to construct.
- Can be 2d, 3d, or 4d.
- @rtype: Matrix object.
- @return: A new shear matrix.
- """
-
-def CopyMat(matrix):
- """
- Create a copy of the Matrix object.
- @type matrix: Matrix object.
- @param matrix: A 2d,3d or 4d matrix to be copied.
- @rtype: Matrix object.
- @return: A new matrix object which is a copy of the one passed in.
- @attention: B{DEPRECATED} Use the matrix copy funtion to make a copy.
- Example::
- newMat = myMat.copy()
- """
-
-def MatMultVec(mat, vec):
- """
- Multiply a matrix and a vector (post-multiply)
- Vector size and matrix row size must equal.
- @type vec: Vector object.
- @param vec: A 2d,3d or 4d vector.
- @type mat: Matrix object.
- @param mat: A 2d,3d or 4d matrix.
- @rtype: Vector object
- @return: The column vector that results from the muliplication.
- @attention: B{DEPRECATED} You should use direct muliplication on the arguments
- Example::
- result = myMatrix * myVector
- """
-
-def CopyQuat(quaternion):
- """
- Create a copy of the Quaternion object.
- @type quaternion: Quaternion object.
- @param quaternion: Quaternion to be copied.
- @rtype: Quaternion object.
- @return: A new quaternion object which is a copy of the one passed in.
- @attention: B{DEPRECATED} You should use the Quaterion() constructor directly
- to create copies of quaternions
- Example::
- newQuat = Quaternion(myQuat)
- """
-
-def CrossQuats(quat1, quat2):
- """
- Return the cross product of two quaternions.
- @type quat1: Quaternion object.
- @param quat1: Quaternion.
- @type quat2: Quaternion object.
- @param quat2: Quaternion.
- @rtype: Quaternion object.
- @return: A new quaternion representing the cross product of
- the two quaternions.
- """
-
-def DotQuats(quat1, quat2):
- """
- Return the dot product of two quaternions.
- @type quat1: Quaternion object.
- @param quat1: Quaternion.
- @type quat2: Quaternion object.
- @param quat2: Quaternion.
- @rtype: float
- @return: Return the scalar product of quaternion muliplication.
- """
-
-def DifferenceQuats(quat1, quat2):
- """
- Returns a quaternion represting the rotational difference.
- @type quat1: Quaternion object.
- @param quat1: Quaternion.
- @type quat2: Quaternion object.
- @param quat2: Quaternion.
- @rtype: Quaternion object
- @return: Return a quaternion which which represents the rotational
- difference between the two quat rotations.
- """
-
-def Slerp(quat1, quat2, factor):
- """
- Returns the interpolation of two quaternions.
- @type quat1: Quaternion object.
- @param quat1: Quaternion.
- @type quat2: Quaternion object.
- @param quat2: Quaternion.
- @type factor: float
- @param factor: The interpolation value
- @rtype: Quaternion object
- @return: The interpolated rotation.
- """
-
-def CopyEuler(euler):
- """
- Create a new euler object.
- @type euler: Euler object
- @param euler: The euler to copy
- @rtype: Euler object
- @return: A copy of the euler object passed in.
- @attention: B{DEPRECATED} You should use the Euler constructor directly
- to make copies of Euler objects
- Example::
- newEuler = Euler(myEuler)
- """
-
-def RotateEuler(euler, angle, axis):
- """
- Roatate a euler by an amount in degrees around an axis.
- @type euler: Euler object
- @param euler: Euler to rotate.
- @type angle: float
- @param angle: The amount of rotation in degrees
- @type axis: string
- @param axis: axis to rotate around:
- - "x"
- - "y"
- - "z"
- """
-
-class Vector:
- """
- The Vector object
- =================
- This object gives access to Vectors in Blender.
- @ivar x: The x value.
- @ivar y: The y value.
- @ivar z: The z value (if any).
- @ivar w: The w value (if any).
- @ivar length: The magnitude of the vector.
- @ivar magnitude: This is a synonym for length.
- @ivar wrapped: Whether or not this item is wrapped data
- @note: Comparison operators can be done on Vector classes:
- - >, >=, <, <= test the vector magnitude
- - ==, != test vector values e.g. 1,2,3 != 1,2,4 even if they are the same length
- @note: Math can be performed on Vector classes
- - vec + vec
- - vec - vec
- - vec * float/int
- - vec * matrix
- - vec * vec
- - vec * quat
- - -vec
- @note: You can access a vector object like a sequence
- - x = vector[0]
- @attention: Vector data can be wrapped or non-wrapped. When a object is wrapped it
- means that the object will give you direct access to the data inside of blender. Modification
- of this object will directly change the data inside of blender. To copy a wrapped object
- you need to use the object's constructor. If you copy and object by assignment you will not get
- a second copy but a second reference to the same data. Only certain functions will return
- wrapped data. This will be indicated in the method description.
- Example::
- wrappedObject = Object.getAttribute() #this is wrapped data
- print wrappedObject.wrapped #prints 'True'
- copyOfObject = Object(wrappedObject) #creates a copy of the object
- secondPointer = wrappedObject #creates a second pointer to the same data
- print wrappedObject.attribute #prints '5'
- secondPointer.attribute = 10
- print wrappedObject.attribute #prints '10'
- print copyOfObject.attribute #prints '5'
- """
-
- def __init__(list = None):
- """
- Create a new 2d, 3d, or 4d Vector object from a list of floating point numbers.
- @note: that python uses higher precission floating point numbers, so values assigned to a vector may have some rounding error.
-
-
- Example::
- v = Vector(1,0,0)
- v = Vector(myVec)
- v = Vector(list)
- @type list: PyList of float or int
- @param list: The list of values for the Vector object. Can be a sequence or raw numbers.
- Must be 2, 3, or 4 values. The list is mapped to the parameters as [x,y,z,w].
- @rtype: Vector object.
- @return: It depends wheter a parameter was passed:
- - (list): Vector object initialized with the given values;
- - (): An empty 3 dimensional vector.
- """
-
- def copy():
- """
- Returns a copy of this vector
- @return: a copy of itself
- """
-
- def zero():
- """
- Set all values to zero.
- @return: an instance of itself
- """
-
- def normalize():
- """
- Normalize the vector, making the length of the vector always 1.0
- @note: Normalize works for vectors of all sizes, however 4D Vectors w axis is left untouched.
- @note: Normalizing a vector where all values are zero results in all axis having a nan value (not a number).
- @return: an instance of itself
- """
-
- def negate():
- """
- Set all values to their negative.
- @return: an instance of its self
- """
-
- def resize2D():
- """
- Resize the vector to 2d.
- @return: an instance of itself
- """
-
- def resize3D():
- """
- Resize the vector to 3d. New axis will be 0.0.
- @return: an instance of itself
- """
-
- def resize4D():
- """
- Resize the vector to 4d. New axis will be 0.0.
- The last component will be 1.0, to make multiplying 3d vectors by 4x4 matrices easier.
- @return: an instance of itself
- """
-
- def toTrackQuat(track, up):
- """
- Return a quaternion rotation from the vector and the track and up axis.
- @type track: String.
- @param track: Possible values:
- - "x - x-axis up"
- - "y - y-axis up"
- - "z - z-axis up"
- - "-x - negative x-axis up"
- - "-y - negative y-axis up"
- - "-z - negative z-axis up"
- @type up: String.
- @param up: Possible values:
- - "x - x-axis up"
- - "y - y-axis up"
- - "z - z-axis up"
- @rtype: Quaternion
- @return: Return a quaternion rotation from the vector and the track and up axis.
- """
-
-class Euler:
- """
- The Euler object
- ================
- This object gives access to Eulers in Blender.
- @ivar x: The heading value in degrees.
- @ivar y: The pitch value in degrees.
- @ivar z: The roll value in degrees.
- @ivar wrapped: Whether or not this object is wrapping data directly
- @note: You can access a euler object like a sequence
- - x = euler[0]
- @note: Comparison operators can be done:
- - ==, != test numeric values within epsilon
- @attention: Euler data can be wrapped or non-wrapped. When a object is wrapped it
- means that the object will give you direct access to the data inside of blender. Modification
- of this object will directly change the data inside of blender. To copy a wrapped object
- you need to use the object's constructor. If you copy and object by assignment you will not get
- a second copy but a second reference to the same data. Only certain functions will return
- wrapped data. This will be indicated in the method description.
- Example::
- wrappedObject = Object.getAttribute() #this is wrapped data
- print wrappedObject.wrapped #prints 'True'
- copyOfObject = Object(wrappedObject) #creates a copy of the object
- secondPointer = wrappedObject #creates a second pointer to the same data
- print wrappedObject.attribute #prints '5'
- secondPointer.attribute = 10
- print wrappedObject.attribute #prints '10'
- print copyOfObject.attribute #prints '5'
- """
-
- def __init__(list = None):
- """
- Create a new euler object.
-
- Example::
- euler = Euler(45,0,0)
- euler = Euler(myEuler)
- euler = Euler(sequence)
- @type list: PyList of float/int
- @param list: 3d list to initialize euler
- @rtype: Euler object
- @return: Euler representing heading, pitch, bank.
- @note: Values are in degrees.
- """
-
- def zero():
- """
- Set all values to zero.
- @return: an instance of itself
- """
-
- def copy():
- """
- @return: a copy of this euler.
- """
-
- def unique():
- """
- Calculate a unique rotation for this euler. Avoids gimble lock.
- @return: an instance of itself
- """
-
- def toMatrix():
- """
- Return a matrix representation of the euler.
- @rtype: Matrix object
- @return: A roation matrix representation of the euler.
- """
-
- def toQuat():
- """
- Return a quaternion representation of the euler.
- @rtype: Quaternion object
- @return: Quaternion representation of the euler.
- """
-
-class Quaternion:
- """
- The Quaternion object
- =====================
- This object gives access to Quaternions in Blender.
- @ivar w: The w value.
- @ivar x: The x value.
- @ivar y: The y value.
- @ivar z: The z value.
- @ivar wrapped: Wether or not this object wraps data directly
- @ivar magnitude: The magnitude of the quaternion.
- @ivar axis: Vector representing the axis of rotation.
- @ivar angle: A scalar representing the amount of rotation
- in degrees.
- @note: Comparison operators can be done:
- - ==, != test numeric values within epsilon
- @note: Math can be performed on Quaternion classes
- - quat + quat
- - quat - quat
- - quat * float/int
- - quat * vec
- - quat * quat
- @note: You can access a quaternion object like a sequence
- - x = quat[0]
- @attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it
- means that the object will give you direct access to the data inside of blender. Modification
- of this object will directly change the data inside of blender. To copy a wrapped object
- you need to use the object's constructor. If you copy and object by assignment you will not get
- a second copy but a second reference to the same data. Only certain functions will return
- wrapped data. This will be indicated in the method description.
- Example::
- wrappedObject = Object.getAttribute() #this is wrapped data
- print wrappedObject.wrapped #prints 'True'
- copyOfObject = Object(wrappedObject) #creates a copy of the object
- secondPointer = wrappedObject #creates a second pointer to the same data
- print wrappedObject.attribute #prints '5'
- secondPointer.attribute = 10
- print wrappedObject.attribute #prints '10'
- print copyOfObject.attribute #prints '5'
- """
-
- def __init__(list, angle = None):
- """
- Create a new quaternion object from initialized values.
-
- Example::
- quat = Quaternion(1,2,3,4)
- quat = Quaternion(axis, angle)
- quat = Quaternion()
- quat = Quaternion(180, list)
-
- @type list: PyList of int/float
- @param list: A 3d or 4d list to initialize quaternion.
- 4d if intializing [w,x,y,z], 3d if used as an axis of rotation.
- @type angle: float (optional)
- @param angle: An arbitrary rotation amount around 'list'.
- List is used as an axis of rotation in this case.
- @rtype: New quaternion object.
- @return: It depends wheter a parameter was passed:
- - (list/angle): Quaternion object initialized with the given values;
- - (): An identity 4 dimensional quaternion.
- """
-
- def identity():
- """
- Set the quaternion to the identity quaternion.
- @return: an instance of itself
- """
-
- def copy():
- """
- make a copy of the quaternion.
- @return: a copy of itself
- """
-
- def negate():
- """
- Set the quaternion to its negative.
- @return: an instance of itself
- """
-
- def conjugate():
- """
- Set the quaternion to its conjugate.
- @return: an instance of itself
- """
-
- def inverse():
- """
- Set the quaternion to its inverse
- @return: an instance of itself
- """
-
- def normalize():
- """
- Normalize the quaternion.
- @return: an instance of itself
- """
-
- def toEuler():
- """
- Return Euler representation of the quaternion.
- @rtype: Euler object
- @return: Euler representation of the quaternion.
- """
-
- def toMatrix():
- """
- Return a matrix representation of the quaternion.
- @rtype: Matrix object
- @return: A rotation matrix representation of the quaternion.
- """
-
-class Matrix:
- """
- The Matrix Object
- =================
- This object gives access to Matrices in Blender.
- @ivar rowSize: The row size of the matrix.
- @ivar colSize: The column size of the matrix.
- @ivar wrapped: Whether or not this object wrapps internal data
- @note: Math can be performed on Matrix classes
- - mat + mat
- - mat - mat
- - mat * float/int
- - mat * vec
- - mat * mat
- @note: Comparison operators can be done:
- - ==, != test numeric values within epsilon
- @note: You can access a quaternion object like a 2d sequence
- - x = matrix[0][1]
- - vector = matrix[2]
- @attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it
- means that the object will give you direct access to the data inside of blender. Modification
- of this object will directly change the data inside of blender. To copy a wrapped object
- you need to use the object's constructor. If you copy and object by assignment you will not get
- a second copy but a second reference to the same data. Only certain functions will return
- wrapped data. This will be indicated in the method description.
- Example::
- wrappedObject = Object.getAttribute() #this is wrapped data
- print wrappedObject.wrapped #prints 'True'
- copyOfObject = Object(wrappedObject) #creates a copy of the object
- secondPointer = wrappedObject #creates a second pointer to the same data
- print wrappedObject.attribute #prints '5'
- secondPointer.attribute = 10
- print wrappedObject.attribute #prints '10'
- print copyOfObject.attribute #prints '5'
- """
-
- def __init__(list1 = None, list2 = None, list3 = None, list4 = None):
- """
- Create a new matrix object from initialized values.
-
- Example::
- matrix = Matrix([1,1,1],[0,1,0],[1,0,0])
- matrix = Matrix(mat)
- matrix = Matrix(seq1, seq2, vector)
-
- @type list1: PyList of int/float
- @param list1: A 2d,3d or 4d list.
- @type list2: PyList of int/float
- @param list2: A 2d,3d or 4d list.
- @type list3: PyList of int/float
- @param list3: A 2d,3d or 4d list.
- @type list4: PyList of int/float
- @param list4: A 2d,3d or 4d list.
- @rtype: New matrix object.
- @return: It depends wheter a parameter was passed:
- - (list1, etc.): Matrix object initialized with the given values;
- - (): An empty 3 dimensional matrix.
- """
-
- def zero():
- """
- Set all matrix values to 0.
- @return: an instance of itself
- """
-
-
- def copy():
- """
- Returns a copy of this matrix
- @return: a copy of itself
- """
-
- def identity():
- """
- Set the matrix to the identity matrix.
- An object with zero location and rotation, a scale of 1, will have an identity matrix.
-
- See U{http://en.wikipedia.org/wiki/Identity_matrix}
- @return: an instance of itself
- """
-
- def transpose():
- """
- Set the matrix to its transpose.
-
- See U{http://en.wikipedia.org/wiki/Transpose}
- @return: None
- """
-
- def determinant():
- """
- Return the determinant of a matrix.
-
- See U{http://en.wikipedia.org/wiki/Determinant}
- @rtype: float
- @return: Return a the determinant of a matrix.
- """
-
- def invert():
- """
- Set the matrix to its inverse.
-
- See U{http://en.wikipedia.org/wiki/Inverse_matrix}
- @return: an instance of itself.
- @raise ValueError: When matrix is singular.
- """
-
- def rotationPart():
- """
- Return the 3d submatrix corresponding to the linear term of the
- embedded affine transformation in 3d. This matrix represents rotation
- and scale. Note that the (4,4) element of a matrix can be used for uniform
- scaling, too.
- @rtype: Matrix object.
- @return: Return the 3d matrix for rotation and scale.
- """
-
- def translationPart():
- """
- Return a the translation part of a 4 row matrix.
- @rtype: Vector object.
- @return: Return a the translation of a matrix.
- """
-
- def scalePart():
- """
- Return a the scale part of a 3x3 or 4x4 matrix.
- @note: This method does not return negative a scale on any axis because it is not possible to obtain this data from the matrix alone.
- @rtype: Vector object.
- @return: Return a the scale of a matrix.
- """
-
- def resize4x4():
- """
- Resize the matrix to by 4x4
- @return: an instance of itself.
- """
-
- def toEuler():
- """
- Return an Euler representation of the rotation matrix (3x3 or 4x4 matrix only).
- @rtype: Euler object
- @return: Euler representation of the rotation matrix.
- """
-
- def toQuat():
- """
- Return a quaternion representation of the rotation matrix
- @rtype: Quaternion object
- @return: Quaternion representation of the rotation matrix
- """
-
diff --git a/source/blender/python/api2_2x/doc/Mesh.py b/source/blender/python/api2_2x/doc/Mesh.py
deleted file mode 100644
index 7e7514e8b3a..00000000000
--- a/source/blender/python/api2_2x/doc/Mesh.py
+++ /dev/null
@@ -1,1215 +0,0 @@
-# Blender.Mesh module and the Mesh PyType object
-
-"""
-The Blender.Mesh submodule.
-
-B{New}:
-
-Mesh Data
-=========
-
-This module provides access to B{Mesh Data} objects in Blender. It differs
-from the NMesh module by allowing direct access to the actual Blender data,
-so that changes are done immediately without need to update or put the data
-back into the original mesh. The result is faster operations with less memory
-usage. The example below creates a simple pyramid, and sets some of the
-face's attributes (the vertex color):
-
-Example::
- from Blender import *
- import bpy
-
- editmode = Window.EditMode() # are we in edit mode? If so ...
- if editmode: Window.EditMode(0) # leave edit mode before getting the mesh
-
- # define vertices and faces for a pyramid
- coords=[ [-1,-1,-1], [1,-1,-1], [1,1,-1], [-1,1,-1], [0,0,1] ]
- faces= [ [3,2,1,0], [0,1,4], [1,2,4], [2,3,4], [3,0,4] ]
-
- me = bpy.data.meshes.new('myMesh') # create a new mesh
-
- me.verts.extend(coords) # add vertices to mesh
- me.faces.extend(faces) # add faces to the mesh (also adds edges)
-
- me.vertexColors = 1 # enable vertex colors
- me.faces[1].col[0].r = 255 # make each vertex a different color
- me.faces[1].col[1].g = 255
- me.faces[1].col[2].b = 255
-
- scn = bpy.data.scenes.active # link object to current scene
- ob = scn.objects.new(me, 'myObj')
-
- if editmode: Window.EditMode(1) # optional, just being nice
-
-Vertices, edges and faces are added to a mesh using the .extend() methods.
-For best speed and efficiency, gather all vertices, edges or faces into a
-list and call .extend() once as in the above example. Similarly, deleting
-from the mesh is done with the .delete() methods and are most efficient when
-done once.
-
-@type Modes: readonly dictionary
-@type FaceFlags: readonly dictionary
-@type FaceModes: readonly dictionary
-@type FaceTranspModes: readonly dictionary
-@var Modes: The available mesh modes.
- - NOVNORMALSFLIP - no flipping of vertex normals during render.
- - TWOSIDED - double sided mesh.
- - AUTOSMOOTH - turn auto smoothing of faces "on".
- - note: SUBSURF and OPTIMAL have been removed, use Modifiers to apply subsurf.
-@var FaceFlags: The available *texture face* (uv face select mode) selection
- flags. Note: these refer to TexFace faces, available if mesh.faceUV
- returns true.
- - SELECT - selected (deprecated in versions after 2.43, use face.sel).
- - HIDE - hidden (deprecated in versions after 2.43, use face.hide).
- - ACTIVE - the active face, read only - Use L{mesh.activeFace<Mesh.Mesh.activeFace>} to set.
-@var FaceModes: The available *texture face* modes. Note: these are only
- meaningful if mesh.faceUV returns true, since in Blender this info is
- stored at the TexFace (TexFace button in Edit Mesh buttons) structure.
- - ALL - set all modes at once.
- - BILLBOARD - always orient after camera.
- - HALO - halo face, always point to camera.
- - DYNAMIC - respond to collisions.
- - INVISIBLE - invisible face.
- - LIGHT - dynamic lighting.
- - OBCOL - use object color instead of vertex colors.
- - SHADOW - shadow type.
- - SHAREDVERT - apparently unused in Blender.
- - SHAREDCOL - shared vertex colors (per vertex).
- - TEX - has texture image.
- - TILES - uses tiled image.
- - TWOSIDE - two-sided face.
-@var FaceTranspModes: The available face transparency modes. Note: these are
- enumerated values (enums), they can't be combined (ANDed, ORed, etc) like a bit vector.
- - SOLID - draw solid.
- - ADD - add to background (halo).
- - ALPHA - draw with transparency.
- - SUB - subtract from background.
-@var EdgeFlags: The available edge flags.
- - SELECT - selected (B{deprecated}). Use edge.sel attribute instead.
- - EDGEDRAW - edge is drawn out of edition mode.
- - EDGERENDER - edge is drawn out of edition mode.
- - SEAM - edge is a seam for UV unwrapping
- - FGON - edge is part of a F-Gon.
- - LOOSE - Edge is not a part of a face (only set on leaving editmode)
- - SHARP - Edge will be rendered sharp when used with the "Edge Split" modifier.
-@type AssignModes: readonly dictionary.
-@var AssignModes: The available vertex group assignment modes, used by
- L{mesh.assignVertsToGroup()<Mesh.Mesh.assignVertsToGroup>}.
- - ADD: if the vertex in the list is not assigned to the group
- already, this creates a new association between this vertex and the
- group with the weight specified, otherwise the weight given is added to
- the current weight of an existing association between the vertex and
- group.
- - SUBTRACT: will attempt to subtract the weight passed from a vertex
- already associated with a group, else it does nothing.\n
- - REPLACE: attempts to replace a weight with the new weight value
- for an already associated vertex/group, else it does nothing.
-@type SelectModes: readonly dictionary.
-@var SelectModes: The available edit select modes.
- - VERTEX: vertex select mode.
- - EDGE: edge select mode.
- - FACE: face select mode.
-"""
-
-AssignModes = {'REPLACE':1}
-
-def Get(name=None):
- """
- Get the mesh data object called I{name} from Blender.
- @type name: string
- @param name: The name of the mesh data object.
- @rtype: Mesh
- @return: If a name is given, it returns either the requested mesh or None.
- If no parameter is given, it returns all the meshes in the current scene.
- """
-
-def New(name='Mesh'):
- """
- Create a new mesh data object called I{name}.
- @type name: string
- @param name: The name of the mesh data object.
- @rtype: Mesh
- @return: a new Blender mesh.
- @note: if the mesh is not linked to an object, its datablock will be deleted
- when the object is deallocated.
- """
-
-def Mode(mode=0):
- """
- Get and/or set the selection modes for mesh editing. These are the modes
- visible in the 3D window when a mesh is in Edit Mode.
- @type mode: int
- @param mode: The desired selection mode. See L{SelectModes} for values.
- Modes can be combined. If omitted, the selection mode is not changed.
- @rtype: int
- @return: the current selection mode.
- @note: The selection mode is an attribute of the current scene. If the
- scene is changed, the selection mode may not be the same.
- """
-
-def Unlink(name):
- """
- Delete an unused mesh from Blender's database. The mesh must not have
- any users (i.e., it must not be linked to any object).
- @type name: string
- @param name: The name of the mesh data object.
- @rtype: None
- @note: This function may be a temporary solution; it may be replaced
- in the future by a more general unlink function for many datablock types.
- Hopefully this will be decided prior to the 2.42 release of Blender.
- """
-
-class MCol:
- """
- The MCol object
- ===============
- This object is four ints representing an RGBA color.
- @ivar r: The Red component in [0, 255].
- @type r: int
- @ivar g: The Green component in [0, 255].
- @type g: int
- @ivar b: The Blue component in [0, 255].
- @type b: int
- @ivar a: The Alpha (transparency) component in [0, 255].
- @type a: int
- """
-
-class MVert:
- """
- The MVert object
- ================
- This object holds mesh vertex data.
- @ivar co: The vertex coordinates (x, y, z).
- @type co: vector (WRAPPED DATA)
- @ivar no: The vertex's unit normal vector (x, y, z).
- B{Note}: if vertex coordinates are changed, it may be necessary to use
- L{Mesh.calcNormals()} to update the vertex normals.
- B{Note}: Vertex normals can be set, but are not wrapped so modifying a normal
- vector will not effect the verts normal. The result is only visible
- when faces have the smooth option enabled.
- Example::
- # This won't work.
- for v in me.verts:
- v.no.x= 0
- v.no.y= 0
- v.no.z= 1
- # This will work
- no= Blender.Mathutils.Vector(0,0,1)
- for v in me.verts:
- v.no= no
- @type no: vector
- @ivar uvco: The vertex texture "sticky" coordinates (x, y),
- B{Note}: These are not seen in the UV editor and they are not a part of UV a UVLayer. Use face UV's for that.
- if present. Available for MVerts only.
- Use L{Mesh.vertexUV} to test for presence before trying to access;
- otherwise an exception will may be thrown.
- (Sticky coordinates can be set when the object is in the Edit mode;
- from the Editing Panel (F9), look under the "Mesh" properties for the
- "Sticky" button).
- @type uvco: vector (WRAPPED DATA)
- @ivar index: The vertex's index within the mesh (MVerts only). Read-only.
- @type index: int
- @ivar sel: The vertex's selection state (selected=1).
- B{Note}: a Mesh will return the selection state of the mesh when EditMode
- was last exited. A Python script operating in EditMode must exit EditMode
- before getting the current selection state of the mesh.
- @type sel: int
- @ivar hide: The face's B{edit mode} visibility state (hidden=1).
- @type hide: int
- @warn: There are two kinds of UV texture coordinates in Blender: per vertex
- ("sticky") and per face vertex (UV in L{MFace}). In the first, there's
- only one UV pair of coordinates for each vertex in the mesh. In the
- second, for each face it belongs to, a vertex can have different UV
- coordinates. This makes the per face option more flexible, since two
- adjacent faces won't have to be mapped to a continuous region in an image:
- each face can be independently mapped to any part of its texture.
- """
-
- def __init__(coord):
- """
- Create a new PVert object.
-
- @note: PVert-type objects are designed to be used for creating and
- modifying a mesh's vertex list, but since they do not "wrap" any Blender
- data there are some differences. The B{index} and B{uvco} attributes
- are not defined for PVerts, and the B{no} attribute contains valid
- data only if the PVert was created from an MVert (using a slice
- operation on the mesh's vertex list.) PVerts also cannot be used as an
- argument to any method which expects data wrapping a Blender mesh, such
- as L{MVertSeq.delete()}.
-
- Example::
- v = Blender.Mesh.MVert(1,0,0)
- v = Blender.Mesh.MVert(Blender.Mathutils.Vector([1,0,0]))
-
- m = Blender.Mesh.Get('Mesh')
- vlist = m.verts[:] # slice operation also returns PVerts
-
- @type coord: three floats or a Vector object
- @param coord: the coordinate values for the new vertex
- @rtype: PVert
- @return: a new PVert object
-
- """
-
-class MVertSeq:
- """
- The MVertSeq object
- ===================
- This object provides sequence and iterator access to the mesh's vertices.
- Access and assignment of single items and slices are also supported.
- When a single item in the vertex list is accessed, the operator[] returns
- a MVert object which "wraps" the actual vertex in the mesh; changing any
- of the vertex's attributes will immediately change the data in the mesh.
- When a slice of the vertex list is accessed, however, the operator[]
- returns a list of PVert objects which are copies of the mesh's vertex
- data. Changes to these objects have no effect on the mesh; they must be
- assigned back to the mesh's vertex list.
-
- Slice assignments cannot change the vertex list size. The size of the
- list being assigned must be the same as the specified slice; otherwise an
- exception is thrown.
-
- Example::
- import Blender
- from Blender import Mesh
-
- me = Mesh.Get("Plane") # get the mesh data called "Plane"
- vert = me.verts[0] # vert accesses actual mesh data
- vert.co[0] += 2 # change the vertex's X location
- pvert = me.verts[-2:] # pvert is COPY of mesh's last two verts
- pvert[0].co[0] += 2 # change the vertex's X location
- pvert[1].co[0] += 2 # change the vertex's X location
- me.verts[-1] = pvert[1] # put change to second vertex into mesh
-
- @note: The mesh can be "cleared" by assigning B{None} to the mesh's vertex
- list. This does not delete the Blender mesh object, it only deletes all
- the memory allocated to the mesh. The result is equivalent to calling
- Mesh.New(). The intent is to allow users writing exporters to free memory
- after it is used in a quick and simple way.
-
- Example::
- import Blender
- from Blender import Mesh
-
- me = Mesh.Get("Plane") # get the mesh data called "Plane"
- me.verts = None # delete all the mesh's attributes
-
- """
-
- def extend(coords):
- """
- Append zero or more vertices to the mesh. Unlike L{MEdgeSeq.extend()} and
- L{MFaceSeq.extend()} no attempt is made to check for duplicate vertices in
- the parameter list, or for vertices already in the mesh.
- @note: Since Blender 2.44 all new verts are selected.
-
- Example::
- import Blender
- from Blender import Mesh
- from Blender.Mathutils import Vector
-
- me = Mesh.Get("Plane") # get the mesh data called "Plane"
- me.verts.extend(1,1,1) # add one vertex
- l=[(.1,.1,.1),Vector([2,2,.5])]
- me.verts.extend(l) # add multiple vertices
-
- @type coords: sequences(s) of floats or vectors
- @param coords: coords can be
- - a sequence of three floats,
- - a 3D vector, or
- - a sequence (list or tuple) of either of the above.
- """
-
- def delete(verts):
- """
- Deletes one or more vertices from the mesh. Any edge or face which
- uses the specified vertices are also deleted.
-
- @type verts: multiple ints or MVerts
- @param verts: can be
- - a single MVert belonging to the mesh (B{note:} will not work with
- PVerts)
- - a single integer, specifying an index into the mesh's vertex list
- - a sequence (list or tuple) containing two or more of either of
- the above.
- """
-
- def selected():
- """
- Get selected vertices.
- @return: a list of the indices for all vertices selected in edit mode.
- @rtype: list of ints
- """
-
-class MEdge:
- """
- The MEdge object
- ================
- This object holds mesh edge data.
- @ivar v1: The first vertex of the edge.
- @type v1: MVert
- @ivar v2: The second vertex of the edge.
- @type v2: MVert
- @ivar length: The length of the edge, same as (ed.v1.co-ed.v2.co).length where "ed" is an MEdge.
- @type length: float
- @ivar crease: The crease value of the edge. It is in the range [0,255].
- @type crease: int
- @ivar flag: The bitfield describing edge properties. See L{EdgeFlags}.
- Example::
- # This script counts fgon and non fgon edges
- from Blender import Scene, Mesh
- scn= Scene.GetCurrent() # Current scene, important to be scene aware
- ob= scn.objects.active # last selected object
- me= ob.getData(mesh=1) # thin wrapper doesn't copy mesh data like nmesh
-
- total_fgon_eds= total_nor_eds= 0
-
- # Look through the edges and find any fgon edges, then print the findings to the console
- for ed in me.edges: # all meshes have edge data now
- if ed.flag & Mesh.EdgeFlags.FGON:
- total_fgon_eds+=1
- else:
- total_nor_eds+=1
-
- print 'Blender has', total_fgon_eds, 'fgon edges and', total_nor_eds, 'non fgon edges'
- @type flag: int
- @ivar index: The edge's index within the mesh. Read-only.
- @type index: int
- @ivar sel: The edge's B{edit mode} selection state (selected=1). B{Note}:
- changing the select state of an edge changes the select state of the edge's
- vertices.
- @type sel: int
- @ivar key: The edge's vert indices in an ordered tuple, which can be used
- as a dictionary key. Read-only.
- This is the same as (min(ed.v1.index, ed.v2.index), max(ed.v1.index, ed.v2.index))
- @type key: tuple
- """
-
- def __iter__():
- """
- Iterator for MEdge. It iterates over the MVerts of the edge, returning
- v1 then v2.
- @return: one of the edge's vertices
- @rtype: MVert
- """
-
-class MEdgeSeq:
- """
- The MEdgeSeq object
- ===================
- This object provides sequence and iterator access to the mesh's edges.
- """
-
- def extend(vertseq):
- """
- Add zero or more edges to the mesh. Edges which already exist in the
- mesh or with both vertices the same are ignored. If three or four verts
- are specified in any sequence, an edge is also created between the first
- and last vertices (this is useful when adding faces).
- @note: Since Blender 2.44 all new edges are selected.
-
- Example::
- import Blender
- from Blender import Mesh
-
- me = Mesh.Get("Plane") # get the mesh data called "Plane"
- v = me.verts # get vertices
- if len(v) >= 6: # if there are enough vertices...
- me.edges.extend(v[0],v[1]) # add a single edge
- l=[(v[1],v[2],v[3]),[0,2,4,5]]
- me.edges.extend(l) # add multiple edges
-
- @type vertseq: sequence(s) of ints or MVerts
- @param vertseq: either two to four ints or MVerts, or sequence
- (list or tuple) of sequences each containing two to four ints or MVerts.
- """
-
- def delete(edges):
- """
- Deletes one or more edges from the mesh. In addition, also delete:
- - any faces which uses the specified edge(s)
- - any "orphan" vertices (belonging only to specified edge(s))
-
- @type edges: multiple ints or MEdges
- @param edges: can be
- - a single MEdge belonging to the mesh
- - a single integer, specifying an index into the mesh's edge list
- - a sequence (list or tuple) containing two or more of either of
- the above.
- """
-
- def selected():
- """
- Get selected edges.
- Selected edges are those for which both vertices are selected.
- @return: a list of the indices for all edges selected in edit mode.
- @rtype: list of ints
- """
-
-class MFace:
- """
- The MFace object
- ================
- This object holds mesh face data.
-
- Example::
- import Blender
- from Blender import Mesh, Window
-
- in_emode = Window.EditMode()
- if in_emode: Window.EditMode(0)
-
- me = Mesh.Get("Mesh")
- faces = me.faces
-
- ## Example for editmode faces selection:
- selected_faces = []
- for f in faces:
- if f.sel:
- selected_faces.append(f)
- # ... unselect selected and select all the others:
- for f in faces:
- f.sel = not f.sel # 1 becomes 0, 0 becomes 1
-
- ## Example for UV textured faces selection:
- selected_faces = []
- SEL = Mesh.FaceFlags['SELECT']
- # get selected faces:
- for f in faces:
- if f.flag & SEL:
- selected_faces.append(f)
- # ... unselect selected and select all the others:
- for f in faces:
- if f.flag & SEL:
- f.flag &= ~SEL # unselect these
- else:
- f.flag |= SEL # and select these
-
- if in_emode: Window.EditMode(1)
- Blender.Redraw()
-
- @ivar verts: The face's vertices. Each face has 3 or 4 vertices.
- @type verts: list of MVerts
- @ivar v: Same as L{verts}. This attribute is only for compatibility with
- NMesh scripts and will probably be deprecated in the future.
- @ivar sel: The face's B{edit mode} selection state (selected=1).
- This is not the same as the selection state of the textured faces
- (see L{flag}). B{Note}: changing the select state of a face changes
- the select state of the face's vertices.
- @type sel: int
- @ivar hide: The face's B{edit mode} visibility state (hidden=1).
- This is not the same as the visibility state of
- the textured faces (see L{flag}).
- @type hide: int
- @ivar smooth: If set, the vertex normals are averaged to make this
- face look smooth. (This is the same as choosing "Set Smooth" in the
- Editing Panel (F9) under "Link and Material" properties).
- @type smooth: int
- @ivar col: The face's vertex colors, if defined. Each vertex has its own
- color.
- Will throw an exception if L{Mesh.vertexColors} is False.
-
- Example::
- # This example uses vertex normals to apply normal colors to each face.
- import bpy
- from Blender import Window
- scn= bpy.scenes.active # Current scene, important to be scene aware
- ob= scn.objects.active # last selected object
- me= ob.getData(mesh=1) # thin wrapper doesn't copy mesh data like nmesh
- me.vertexColors= True # Enable face, vertex colors
- for f in me.faces:
- for i, v in enumerate(f):
- no= v.no
- col= f.col[i]
- col.r= int((no.x+1)*128)
- col.g= int((no.y+1)*128)
- col.b= int((no.z+1)*128)
- Window.RedrawAll()
- @type col: tuple of MCols
- @ivar mat: The face's index into the mesh's materials
- list. It is in the range [0,15].
- @type mat: int
- @ivar image: The Image used as a texture for this face.
- Setting this attribute will create UV faces if they do not exist.
- Getting this attribute throw an exception if the mesh does not have
- UV faces; use L{Mesh.faceUV} to test.
- Assigning an image will automatically set the TEX attribute of the
- L{mode} bitfield. Use "del f.image" or "f.image = None" to clear the
- image assigned to the face.
- @type image: Image
- @ivar mode: The texture mode bitfield (see L{FaceModes}).
- Will throw an exception if the mesh does not have UV faces; use
- L{Mesh.faceUV} to test.
- @type mode: int
- @ivar index: The face's index within the mesh. Read-only.
- @type index: int
-
- @ivar flag: The face's B{texture mode} flags; indicates the selection,
- active , and visibility states of a textured face (see
- L{FaceFlags} for values).
- This is not the same as the selection or visibility states of
- the faces in edit mode (see L{sel} and L{hide}).
- To set the active face, use
- the L{Mesh.activeFace} attribute instead.
- Will throw an exception if the mesh does not have UV faces; use
- L{Mesh.faceUV} to test.
-
- @ivar transp: Transparency mode. It is one of the values in
- L{FaceTranspModes}).
- Will throw an exception if the mesh does not have UV faces; use
- L{Mesh.faceUV} to test.
- @type transp: int
-
- @ivar uv: The face's UV coordinates. Each vertex has its own UV coordinate.
- Setting this attribute will create UV faces if they do not exist.
- Getting this attribute throw an exception if the mesh does not have
- UV faces; use L{Mesh.faceUV} to test.
- @type uv: tuple of vectors (WRAPPED DATA)
- @ivar uvSel: The face's UV coordinates selection state; a 1 indicates the
- vertex is selected. Each vertex has its own UV coordinate select state
- (this is not the same as the vertex's edit mode selection state).
- Setting this attribute will create UV faces if they do not exist.
- Getting this attribute throw an exception if the mesh does not have
- UV faces; use L{Mesh.faceUV} to test.
- @type uvSel: tuple of ints
- @ivar no: The face's normal vector (x, y, z). Read-only.
- @type no: vector
- @ivar cent: The center of the face. Read-only.
- @type cent: vector
- @ivar area: The area of the face. Read-only.
- @type area: float
- @ivar edge_keys: A tuple, each item a key that can reference an edge by its
- ordered indices. Read-only. This is useful for building connectivity data.
- Example::
- from Blender import Mesh
- me = Mesh.Get('Cube')
- # a dictionary where the edge is the key, and a list of faces that use it are the value
- edge_faces = dict([(ed.key, []) for ed in me.edges])
-
- # Add the faces to the dict
- for f in me.faces:
- for key in f.edge_keys:
- edge_faces[key].append(f) # add this face to the edge as a user
-
- # Print the edges and the number of face users
- for key, face_users in edge_faces.iteritems():
- print 'Edge:', key, 'uses:', len(face_users),'faces'
-
- @type edge_keys: tuple
- @note: there are regular faces and textured faces in Blender, both currently
- with their own selection and visibility states, due to a mix of old and new
- code. To (un)select or (un)hide regular faces (visible in EditMode), use
- L{MFace.sel} and L{MFace.hide} attributes. For textured faces (UV Face
- Select and Paint modes in Blender) use the L{MFace.flag} attribute.
- Check the example above and note L{Window.EditMode}.
- @note: Assigning UV textures to mesh faces in Blender works like this:
- 1. Select your mesh.
- 2. Enter face select mode (press f) and select at least some face(s).
- 3. In the UV/Image Editor window, load / select an image.
- 4. Play in both windows (better split the screen to see both at the same
- time) until the UV coordinates are where you want them. Hint: in the
- 3D window, the 'u' key opens a menu of default UV choices and the 'r'
- key lets you rotate the UV coords.
- 5. Leave face select mode (press f).
- """
-
- def __iter__():
- """
- Iterator for MVert. It iterates over the MVerts of the face, returning
- v1, v2, v3 (and optionally v4);
- @return: one of the face's vertices
- @rtype: MVert
- """
-
- def __len__():
- """
- len for MVert. It returns the number of vertices in the face.
- @rtype: int
- """
-
-class MFaceSeq:
- """
- The MFaceSeq object
- ===================
- This object provides sequence and iterator access to the mesh's faces.
- """
-
- def extend(vertseq,ignoreDups=True,indexList=True):
- """
- Add zero or more faces and edges to the mesh. Faces which already exist
- in the mesh, or faces which contain the same vertex multiple times are
- ignored. Sequences of two vertices are accepted, but no face will be
- created.
- @note: Since Blender 2.44 all new faces are selected.
-
- Example::
- import Blender
- from Blender import Mesh
-
- me = Mesh.Get("Plane") # get the mesh data called "Plane"
- v = me.verts # get vertices
- if len(v) >= 6: # if there are enough vertices...
- me.faces.extend(v[1],v[2],v[3]) # add a single edge
- l=[(v[0],v[1]),[0,2,4,5]]
- me.faces.extend(l) # add another face
-
- @type vertseq: sequence(s) of MVerts
- @param vertseq: either two to four ints or MVerts, or sequence (list or
- tuple) of sequences each containing two to four ints or MVerts.
- @type ignoreDups: boolean
- @param ignoreDups: keyword parameter (default is False). If supplied and
- True, do not check the input list or mesh for duplicate faces. This can
- speed up scripts but can prossibly produce undesirable effects. Only
- use if you know what you're doing.
- @type indexList: boolean
- @param indexList: keyword parameter (default is False). If supplied and
- True, the method will return a list representing the new index for each
- face in the input list. If faces are removed as duplicates, None is
- inserted in place of the index.
- @warning: Faces using the first vertex at the 3rd or 4th location in the
- face's vertex list will have their order rotated so that the zero index
- on in the first or second location in the face. When creating face data
- with UVs or vertex colors, you may need to work around this, either by
- checking for zero indices yourself or by adding a dummy first vertex to
- the mesh that can be removed when your script has finished.
- """
-
- def delete(deledges, faces):
- """
- Deletes one or more faces (and optionally the edges associated with
- the face(s)) from the mesh.
-
- @type deledges: int
- @param deledges: controls whether just the faces (deledges=0)
- or the faces and edges (deledges=1) are deleted. These correspond to the
- "Only Faces" and "Edges & Faces" options in the Edit Mode pop-up menu
- @type faces: multiple ints or MFaces
- @param faces: a sequence (list or tuple) containing one or more of:
- - an MEdge belonging to the mesh
- - a integer, specifying an index into the mesh's face list
- """
-
- def sort():
- """
- Sorts the faces using exactly the same syntax as pythons own list sorting function.
-
- Example::
- import Blender
- from Blender import Mesh
- me = Mesh.Get('mymesh')
-
- me.faces.sort(key=lambda f: f.area)
-
- me.faces.sort(key=lambda f: f.cent)
-
- @note: Internally faces only refer to their index, so after sorting, faces you alredy have will not have their index changed to match the new sorted order.
- """
-
- def selected():
- """
- Get selected faces.
- @return: a list of the indices for all faces selected in edit mode.
- @rtype: list of ints
- """
-
-from IDProp import IDGroup, IDArray
-class Mesh:
- """
- The Mesh Data object
- ====================
- This object gives access to mesh data in Blender.
-
- @note: the verts, edges and faces attributes are implemented as sequences.
- The operator[] and len() are defined for these sequences. You cannot
- assign to an item in the sequence, but you can assign to most of the
- attributes of individual items.
- @ivar edges: The mesh's edges.
- @type edges: sequence of MEdges
- @ivar faces: The mesh's faces.
- @type faces: sequence of MFaces
- @ivar verts: The mesh's vertices.
- @type verts: sequence of MVerts
-
- @ivar materials: The mesh's materials. Each mesh can reference up to
- 16 materials. Empty slots in the mesh's list are represented by B{None}.
- B{Note}: L{Object.colbits<Object.Object.colbits>} needs to be set correctly
- for each object in order for these materials to be used instead of
- the object's materials.
- B{Note}: Making the material list shorter does not change the face's material indices.
- Take care when using the face's material indices to reference a material in this list.
- B{Note}: The list that's returned is I{not} linked to the original mesh.
- mesh.materials.append(material) won't do anything.
- Use mesh.materials += [material] instead.
- @type materials: list of L{Material}s
- @ivar degr: The max angle for auto smoothing in [1,80].
- @type degr: int
- @ivar maxSmoothAngle: Same as L{degr}. This attribute is only for
- compatibility with NMesh scripts and will probably be deprecated in
- the future.
- @ivar mode: The mesh's mode bitfield. See L{Modes}.
- @type mode: int
- @ivar sel: Sets selection status for all vertices, edges and faces in the
- mesh (write only).
- @type sel: boolean
- @ivar hide: Sets hidden status for all vertices, edges and faces in the
- mesh (write only).
- @type hide: boolean
- @ivar subDivLevels: The [display, rendering] subdivision levels in [1, 6].
- @type subDivLevels: list of 2 ints
- @ivar faceUV: The mesh contains UV-mapped textured faces.
- @type faceUV: bool
- @ivar vertexColors: The mesh contains vertex colors. Set True to add vertex colors.
- @type vertexColors: bool
- @ivar vertexUV: The mesh contains "sticky" per-vertex UV coordinates.
- @type vertexUV: bool
- @ivar activeFace: Index of the mesh's active face in UV Face Select and
- Paint modes. Only one face can be active at a time. Note that this is
- independent of the selected faces in Face Select and Edit modes.
- Will throw an exception if the mesh does not have UV faces; use
- L{faceUV} to test.
- @type activeFace: int
- @ivar activeGroup: The mesh's active vertex group. The mesh must be
- linked to an object (read the comment in L{addVertGroup} for more info).
- @type activeGroup: string or None
- @ivar texMesh: The mesh's texMesh setting, used so coordinates from another
- mesh can be used for rendering textures.
- @type texMesh: Mesh or None
- @ivar key: The L{Key<Key.Key>} object containing the keyframes for this mesh, if any.
- @type key: Key or None
- @ivar activeUVLayer: The mesh's active UV/Image layer. None if there is no UV/Image layers.
-
- B{Note}: After setting this value, call L{update} so the result can be seen the the 3d view.
- @type activeUVLayer: string
- @ivar activeColorLayer: The mesh's active Vertex Color layer. None if there is no UV/Image layers.
-
- B{Note}: After setting this value, call L{update} so the result can be seen the the 3d view.
- @type activeColorLayer: string
-
- @ivar renderUVLayer: The mesh's rendered UV/Image layer. None if there is no UV/Image layers.
- @type renderUVLayer: string
- @ivar renderColorLayer: The mesh's rendered Vertex Color layer. None if there is no UV/Image layers.
- @type renderColorLayer: string
-
- @ivar multires: The mesh has multires data, set True to add multires data.
- Will throw an exception if the mesh has shape keys; use L{key} to test.
- @type multires: bool
- @ivar multiresLevelCount: The mesh has multires data. (read only)
- @type multiresLevelCount: int
- @ivar multiresDrawLevel: The multires level to display in the 3dview in [1 - multiresLevelCount].
- @type multiresDrawLevel: int
- @ivar multiresEdgeLevel: The multires level edge display in the 3dview [1 - multiresLevelCount].
- @type multiresEdgeLevel: int
- @ivar multiresPinLevel: The multires pin level, used for applying modifiers [1 - multiresLevelCount].
- @type multiresPinLevel: int
- @ivar multiresRenderLevel: The multires level to render [1 - multiresLevelCount].
- @type multiresRenderLevel: int
-
-
- """
-
- def getFromObject(object, cage=0, render=0):
- """
- Replace the mesh's existing data with the raw mesh data from a Blender
- Object. This method supports all the geometry based objects (mesh, text,
- curve, surface, and meta). If the object has modifiers, they will be
- applied before to the object before extracting the vertex data unless
- the B{cage} parameter is 1.
- @note: The mesh coordinates are in I{local space}, not the world space of
- its object. For world space vertex coordinates, each vertex location must
- be multiplied by the object's 4x4 transform matrix (see L{transform}).
- @note: The objects materials will not be copied into the existing mesh,
- however the face material indices will match the material list of the original data.
- @type object: blender object or string
- @param object: The Blender object or its name, which contains the geometry data.
- @type cage: int
- @param cage: determines whether the original vertices or derived vertices
- @type render: int
- @param render: determines whether the render setting for modifiers will be used or not.
- (for objects with modifiers) are used. The default is derived vertices.
- """
-
- def calcNormals():
- """
- Recalculates the vertex normals using face data.
- """
-
- def pointInside(point, selected_only=False):
- """
- @type point: vector
- @param point: Test if this point is inside the mesh
- @type selected_only: bool
- @param selected_only: if True or 1, only the selected faces are taken into account.
- Returns true if vector is inside the mesh.
- @note: Only returns a valid result for mesh data that has no holes.
- @note: Bubbles in the mesh work as expect.
- """
-
- def transform(matrix, recalc_normals = False, selected_only=False):
- """
- Transforms the mesh by the specified 4x4 matrix (such as returned by
- L{Object.Object.getMatrix}). The matrix should be invertible.
- Ideal usage for this is exporting to an external file where
- global vertex locations are required for each object.
- Sometimes external renderers or file formats do not use vertex normals.
- In this case, you can skip transforming the vertex normals by leaving
- the optional parameter recalc_normals as False or 0 (the default value).
-
- Example::
- # This script outputs deformed meshes worldspace vertex locations
- # for a selected object without changing the object
- import Blender
- from Blender import Mesh, Object
-
- ob = Object.GetSelected()[0] # Get the first selected object
- me = Mesh.New() # Create a new mesh
- me.getFromObject(ob.name) # Get the object's mesh data
- verts = me.verts[:] # Save a copy of the vertices
- me.transform(ob.matrix) # Convert verts to world space
- for v in me.verts:
- print 'worldspace vert', v.co
- me.verts = verts # Restore the original verts
-
- @type matrix: Py_Matrix
- @param matrix: 4x4 Matrix which can contain location, scale and rotation.
- @type recalc_normals: int
- @param recalc_normals: if True or 1, also transform vertex normals.
- @type selected_only: bool
- @param selected_only: if True or 1, only the selected verts will be transformed.
- @warn: unlike L{NMesh.transform()<NMesh.NMesh.transform>}, this method
- I{will immediately modify the mesh data} when it is used. If you
- transform the mesh using the object's matrix to get the vertices'
- world positions, the result will be a "double transform". To avoid
- this you either need to set the object's matrix to the identity
- matrix, perform the inverse transform after outputting the transformed
- vertices, or make a copy of the vertices prior to using this method
- and restore them after outputting the transformed vertices (as shown
- in the example).
- """
-
- def vertexShade(object):
- """
- Colors vertices based on the current lighting setup, like when there
- are no vertex colors and no textured faces and a user enters Vertex Paint
- Mode in Blender (only lamps in visible layers account). An exception is
- thrown if called while in EditMode.
- @type object: Object
- @param object: The Blender Object linked to the mesh.
- """
-
- def update(key=None):
- """
- Update display lists after changes to mesh. B{Note}: with changes taking
- place for using a directed acyclic graph (DAG) for scene and object
- updating, this method may be only temporary and may be removed in future
- releases.
- @type key: string
- @param key: Use this optional argument to write the current vertex
- locations to the a shape key. the name must match an existing shape key for this mesh
- See L{Mesh.Mesh.key} and L{Key.Key.blocks} to get a list of the named shape keys, setting the active keys is
- done from the object with L{Object.Object.pinShape}, L{Object.Object.activeShape}.
-
-
-
- @warn: Since Blender 2.42 this function has changed; now it won't recalculate
- vertex normals (seen when faces are smooth). See L{Mesh.calcNormals()}.
- """
-
- def findEdges(edges):
- """
- Quickly search for the location of an edges.
- @type edges: sequence(s) of ints or MVerts
- @param edges: can be tuples of MVerts or integer indexes (B{note:} will
- not work with PVerts) or a sequence (list or tuple) containing two or
- more sequences.
- @rtype: int, None or list
- @return: if an edge is found, its index is returned; otherwise None is
- returned. If a sequence of edges is passed, a list is returned.
- """
-
- def addVertGroup(group):
- """
- Add a named and empty vertex (deform) group to the object this mesh is
- linked to. The mesh must first be linked to an object (with object.link()
- or object.getData() ) so the method knows which object to update.
- This is because vertex groups in Blender are stored in I{the object} --
- not in the mesh, which may be linked to more than one object.
- @type group: string
- @param group: the name for the new group.
- """
-
- def removeVertGroup(group):
- """
- Remove a named vertex (deform) group from the object linked to this mesh.
- All vertices assigned to the group will be removed (just from the group,
- not deleted from the mesh), if any. If this mesh was newly created, it
- must first be linked to an object (read the comment in L{addVertGroup} for
- more info).
- @type group: string
- @param group: the name of a vertex group.
- """
-
- def assignVertsToGroup(group, vertList, weight, assignmode = AssignModes['REPLACE']):
- """
- Adds an array (a Python list) of vertex points to a named vertex group
- associated with a mesh. The vertex list is a list of vertex indices from
- the mesh. You should assign vertex points to groups only when the mesh has
- all its vertex points added to it and is already linked to an object.
-
- I{B{Example:}}
- The example here adds a new set of vertex indices to a sphere primitive::
- import Blender
- sphere = Blender.Object.Get('Sphere')
- replace = Blender.Mesh.AssignModes.REPLACE
- mesh = sphere.getData(mesh=True)
- mesh.addVertGroup('firstGroup')
- vertList = []
- for x in range(300):
- if x % 3 == 0:
- vertList.append(x)
- mesh.assignVertsToGroup('firstGroup', vertList, 0.5, replace)
-
- @type group: string
- @param group: the name of the group.
- @type vertList: list of ints
- @param vertList: a list of vertex indices.
- @type weight: float
- @param weight: the deform weight for (which means: the amount of influence
- the group has over) the given vertices. It should be in the range
- [0.0, 1.0]. If weight <= 0, the given vertices are removed from the
- group. If weight > 1, it is clamped.
- @type assignmode: module constant
- @param assignmode: Three choices: REPLACE, ADD or SUBTRACT.
- See L{AssignModes} for a complete description.
- """
-
- def removeVertsFromGroup(group, vertList = None):
- """
- Remove a list of vertices from the given group. If this mesh was newly
- created, it must first be linked to an object (check L{addVertGroup}).
- @type group: string
- @param group: the name of a vertex group
- @type vertList: list of ints
- @param vertList: a list of vertex indices to be removed from I{group}.
- If None, all vertices are removed -- the group is emptied.
- """
-
- def getVertsFromGroup(group, weightsFlag = 0, vertList = None):
- """
- Return a list of vertex indices associated with the passed group. This
- method can be used to test whether a vertex index is part of a group and
- if so, what its weight is.
-
- I{B{Example:}}
- Append this to the example from L{assignVertsToGroup}::
- # ...
- print "Vertex indices from group %s :" % groupName
- print mesh.getVertsFromGroup('firstGroup')
- print "Again, with weights:"
- print mesh.getVertsFromGroup('firstGroup',1)
- print "Again, with weights and restricted to the given indices:"
- print mesh.getVertsFromGroup('firstGroup',1,[1,2,3,4,5,6])
-
- @type group: string
- @param group: the group name.
- @type weightsFlag: bool
- @param weightsFlag: if 1, each item in the list returned contains a
- tuple pair (index, weight), the weight is a float between 0.0 and 1.0.
- @type vertList: list of ints
- @param vertList: if given, only those vertex points that are both in the
- list and group passed in are returned.
- """
-
- def renameVertGroup(groupName, newName):
- """
- Renames a vertex group.
- @type groupName: string
- @param groupName: the vertex group name to be renamed.
- @type newName: string
- @param newName: the name to replace the old name.
- """
-
- def getVertGroupNames():
- """
- Return a list of all vertex group names.
- @rtype: list of strings
- @return: returns a list of strings representing all vertex group
- associated with the mesh's object
- """
-
- def getUVLayerNames():
- """
- Return a list of all UV layer names
- @rtype: list of strings
- @return: returns a list of strings representing all UV layers
- associated with the mesh's object
- """
-
- def getColorLayerNames():
- """
- Return a list of all color layer names
- @rtype: list of strings
- @return: returns a list of strings representing all color layers
- associated with the mesh's object
- """
-
- def getVertexInfluences(index):
- """
- Get the bone influences for a specific vertex.
- @type index: int
- @param index: The index of a vertex.
- @rtype: list of lists
- @return: List of pairs [name, weight], where name is the bone name (string)
- and weight is a float value.
- """
-
- def removeAllKeys():
- """
- Remove all mesh keys stored in this mesh.
- @rtype: bool
- @return: True if successful or False if the Mesh has no keys.
- """
-
- def insertKey(frame = None, type = 'relative'):
- """
- Insert a mesh key at the given frame.
- @type frame: int
- @type type: string
- @param frame: The Scene frame where the mesh key should be inserted. If
- None or the arg is not given, the current frame is used.
- @param type: The mesh key type: 'relative' or 'absolute'. This is only
- relevant on meshes with no keys.
- @warn: This and L{removeAllKeys} were included in this release only to
- make accessing vertex keys possible, but may not be a proper solution
- and may be substituted by something better later. For example, it
- seems that 'frame' should be kept in the range [1, 100]
- (the curves can be manually tweaked in the Ipo Curve Editor window in
- Blender itself later).
- @warn: Will throw an error if the mesh has multires. use L{multires} to check.
- """
-
- def addUVLayer(name):
- """
- Adds a new UV/Image layer to this mesh, it will always be the last layer but not made active.
- @type name: string
- @param name: The name of the new UV layer, 31 characters max.
- """
-
- def addColorLayer(name):
- """
- Adds a new Vertex Color layer to this mesh, it will always be the last layer but not made active.
- @type name: string
- @param name: The name of the new Color layer, 31 characters max.
- """
-
- def removeUVLayer(name):
- """
- Removes the active UV/Image layer.
- @type name: string
- @param name: The name of the UV layer to remove.
- """
-
- def removeColorLayer(name):
- """
- Removes the active Vertex Color layer.
- @type name: string
- @param name: The name of the Color layer to remove.
- """
-
- def renameUVLayer(name, newname):
- """
- Renames the UV layer called name to newname.
- @type name: string
- @param name: The UV layer to rename.
- @type newname: string
- @param newname: The new name of the UV layer, will be made unique.
- """
-
- def renameColorLayer(name, newname):
- """
- Renames the color layer called name to newname.
- @type name: string
- @param name: The Color layer to rename.
- @type newname: string
- @param newname: The new name of the Color layer, will be made unique.
- """
-
- def smooth():
- """
- Flattens angle of selected faces. Experimental mesh tool.
- An exception is thrown if called while in EditMode.
- """
-
- def flipNormals():
- """
- Toggles the direction of selected face's normals. Experimental mesh tool.
- An exception is thrown if called while in EditMode.
- """
-
- def toSphere():
- """
- Moves selected vertices outward in a spherical shape. Experimental mesh
- tool.
- An exception is thrown if called while in EditMode.
- """
-
- def fill():
- """
- Scan fill a closed selected edge loop. Experimental mesh tool.
- An exception is thrown if called while in EditMode.
- """
-
- def triangleToQuad():
- """
- Convert selected triangles to quads. Experimental mesh tool.
- An exception is thrown if called while in EditMode.
- """
-
- def quadToTriangle(mode=0):
- """
- Convert selected quads to triangles. Experimental mesh tool.
- An exception is thrown if called while in EditMode.
- @type mode: int
- @param mode: specifies whether a to add the new edge between the
- closest (=0) or farthest(=1) vertices.
- """
-
- def subdivide(beauty=0):
- """
- Subdivide selected edges in a mesh. Experimental mesh tool.
- An exception is thrown if called while in EditMode.
- @type beauty: int
- @param beauty: specifies whether a "beauty" subdivide should be
- enabled (disabled is default). Value must be in the range [0,1].
- """
-
- def remDoubles(limit):
- """
- Removes duplicates from selected vertices. Experimental mesh tool.
- An exception is thrown if called while in EditMode.
- @type limit: float
- @param limit: specifies the maximum distance considered for vertices
- to be "doubles". Value is clamped to the range [0.0,1.0].
- @rtype: int
- @return: the number of vertices deleted
- """
-
- def recalcNormals(direction=0):
- """
- Recalculates inside or outside normals for selected faces. Experimental
- mesh tool.
- An exception is thrown if called while in EditMode.
- @type direction: int
- @param direction: specifies outward (0) or inward (1) normals. Outward
- is the default. Value must be in the range [0,1].
- """
-
- def __copy__ ():
- """
- Make a copy of this mesh
- @rtype: Mesh
- @return: a copy of this mesh
- """
-
-import id_generics
-Mesh.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/MeshPrimitives.py b/source/blender/python/api2_2x/doc/MeshPrimitives.py
deleted file mode 100644
index 4fb53ab4536..00000000000
--- a/source/blender/python/api2_2x/doc/MeshPrimitives.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# Blender.Mesh.Primitives module
-
-"""
-The Blender.Mesh.Primitives submodule.
-
-B{New}:
-
-Mesh Primitive Data
-===================
-
-This submodule provides access Blender's mesh primitives. Each module
-function returns a BPy_Mesh object which wraps the mesh data. This data can
-then be manipulated using the L{Mesh} API.
-
-Example::
-
- from Blender import *
-
- me = Mesh.Primitives.Cube(2.0) # create a new cube of size 2
- sc = Scene.GetCurrent() # get current scene
- sc.objects.new(me,'Mesh') # add a new mesh-type object to the scene
- Window.RedrawAll() # update windows
-"""
-
-def Plane(size=2.0):
- """
- Construct a filled planar mesh with 4 vertices. The default size
- creates a 2 by 2 Blender unit plane, identical to the Blender UI.
- @type size: float
- @param size: optional size of the plane.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
-def Cube(size=2.0):
- """
- Construct a cube mesh. The default size creates a cube with each face
- 2 by 2 Blender units, identical to the Blender UI.
- @type size: float
- @param size: optional size of the cube.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
-def Circle(verts=32,diameter=2.0):
- """
- Construct a circle mesh. The defaults create a circle with a
- diameter of 2 Blender units, identical to the Blender UI.
- @type verts: int
- @param verts: optional number of vertices for the circle.
- Value must be in the range [3,100].
- @type diameter: float
- @param diameter: optional diameter of the circle.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
-def Cylinder(verts=32, diameter=2.0, length=2.0):
- """
- Construct a cylindrical mesh (ends filled). The defaults create a
- cylinder with a diameter of 2 Blender units and length 2 units,
- identical to the Blender UI.
- @type verts: int
- @param verts: optional number of vertices in the cylinder's perimeter.
- Value must be in the range [3,100].
- @type diameter: float
- @param diameter: optional diameter of the cylinder.
- @type length: float
- @param length: optional length of the cylinder.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
-def Tube(verts=32, diameter=2.0, length=2.0):
- """
- Construct a cylindrical mesh (ends not filled). The defaults create a
- cylinder with a diameter of 2 Blender units and length 2 units, identical
- to the Blender UI.
- @type verts: int
- @param verts: optional number of vertices in the tube's perimeter.
- Value must be in the range [3,100].
- @type diameter: float
- @param diameter: optional diameter of the tube.
- @type length: float
- @param length: optional length of the tube.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
-def Cone(verts=32, diameter=2.0, length=2.0):
- """
- Construct a conic mesh (ends filled). The defaulte create a cone with a
- base diameter of 2 Blender units and length 2 units, identical to
- the Blender UI.
- @type verts: int
- @param verts: optional number of vertices in the cone's perimeter.
- Value must be in the range [3,100].
- @type diameter: float
- @param diameter: optional diameter of the cone.
- @type length: float
- @param length: optional length of the cone.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
-def Grid(xres=32, yres=32, size=2.0):
- """
- Construct a grid mesh. The defaults create a 32 by 32 mesh of size 2
- Blender units, identical to the Blender UI.
- @type xres: int
- @param xres: optional grid size in the x direction.
- Value must be in the range [2,100].
- @type yres: int
- @param yres: optional grid size in the y direction.
- Value must be in the range [2,100].
- @type size: float
- @param size: optional size of the grid.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
-def UVsphere(segments=32, rings=32, diameter=2.0):
- """
- Construct a UV sphere mesh. The defaults create a 32 by 32 sphere with
- a diameter of 2 Blender units, identical to the Blender UI.
- @type segments: int
- @param segments: optional number of longitudinal divisions.
- Value must be in the range [3,100].
- @type rings: int
- @param rings: optional number of latitudinal divisions.
- Value must be in the range [3,100].
- @type diameter: float
- @param diameter: optional diameter of the sphere.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
-def Icosphere(subdivisions=2, diameter=2.0):
- """
- Construct a Icosphere mesh. The defaults create sphere with 2 subdivisions
- and diameter of 2 Blender units, identical to the Blender UI.
- @type subdivisions: int
- @param subdivisions: optional number of subdivisions.
- Value must be in the range [2,5].
- @type diameter: float
- @param diameter: optional diameter of the sphere.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
-def Monkey():
- """
- Construct a Suzanne mesh.
- @rtype: L{BPy_Mesh<Mesh>}
- @return: returns a mesh object.
- """
-
diff --git a/source/blender/python/api2_2x/doc/Metaball.py b/source/blender/python/api2_2x/doc/Metaball.py
deleted file mode 100644
index 69bcbedafae..00000000000
--- a/source/blender/python/api2_2x/doc/Metaball.py
+++ /dev/null
@@ -1,246 +0,0 @@
-# Blender.Metaball module and the Metaball PyType metaball
-
-"""
-The Blender.Metaball submodule
-
-This module provides access to B{Metaball} data in Blender and the elements they contain.
-
-
-Example::
- import Blender
- mb = Blender.Metaball.New()
- for i in xrange(20):
- element= mb.elements.add()
- element.co = Blender.Mathutils.Vector(i, 0, 0)
- sce = Blender.Scene.GetCurrent()
- sce.objects.new(mb)
-
-
-
-Example::
- # Converts the active armature into metaballs
- from Blender import *
- def main():
-
- scn= Scene.GetCurrent()
- ob_arm= scn.objects.active
- if not ob_arm or ob_arm.type!='Armature':
- Draw.PupMenu('No Armature Selected')
- return
- arm= ob_arm.data
-
- res= Draw.PupFloatInput('res:', 0.2, 0.05, 2.0)
- if not res:
- return
-
- # Make a metaball
- mb= Metaball.New()
- mb.wiresize= res
-
- # Link to the Scene
- ob_mb = scn.objects.new(ob_mb)
- ob_arm.sel= 0
- ob_mb.setMatrix(ob_arm.matrixWorld)
-
-
- meta_type= 0 # all elemts are ball type
- meta_stiffness= 2.0 # Volume
-
- for bone in arm.bones.values():
- print bone
-
- # Find out how many metaballs to add based on bone length, 4 min
- length= bone.length
- if length < res:
- mballs= 4
- else:
- mballs= int(length/res)
- if mballs < 4:
- mballs = 4
-
- print 'metaball count', mballs
-
- # get the bone properties
- head_rad= bone.headRadius
- tail_rad= bone.tailRadius
-
- head_loc= bone.head['ARMATURESPACE']
- tail_loc= bone.tail['ARMATURESPACE']
-
-
- for i in range(mballs):
- f= float(i)
-
- w1= f/mballs # weighting of this position on the bone for rad and loc
- w2= 1-w1
-
- loc= head_loc*w1 + tail_loc*w2
- rad= (head_rad*w1 + tail_rad*w2) * 1.3
-
- # Add the metaball
- ml= mb.elements.add()
- ml.co= loc
- ml.radius= rad
- ml.stiffness= meta_stiffness
-
-
- Window.RedrawAll()
-
- main()
-
-@type Types: readonly dictionary
-@var Types: MeteElement types.
- - BALL
- - TUBE
- - PLANE
- - ELIPSOID
- - CUBE
-
-@type Update: readonly dictionary
-@var Update: MeteElement types.
- - ALWAYS
- - HALFRES
- - FAST
- - NEVER
-
-"""
-
-
-def New (name):
- """
- Creates a new Metaball.
- @type name: string
- @param name: The name of the metaball. If this parameter is not given (or not valid) blender will assign a name to the metaball.
- @rtype: Blender Metaball
- @return: The created Metaball.
- """
-
-def Get (name):
- """
- Get the Metaball from Blender.
- @type name: string
- @param name: The name of the requested Metaball.
- @rtype: Blender Metaball or a list of Blender Metaballs
- @return: It depends on the 'name' parameter:
- - (name): The Metaball with the given name;
- - (): A list with all Metaballs in the current scene.
- """
-
-class Metaball:
- """
- The Metaball object
- ===================
- This metaball gives access to generic data from all metaballs in Blender.
- @ivar elements: Element iterator of MetaElemSeq type.
- @type elements: MetaElemSeq
- @ivar wiresize: display resolution.
- Value clamped between 0.05 and 1.0.
-
- A lower value results in more polygons.
- @type wiresize: float
- @ivar rendersize: render resolution.
- Value clamped between 0.05 and 1.0.
-
- A lower value results in more polygons.
- @type rendersize: float
- @ivar thresh: Threshold setting for this metaball.
- Value clamped between 0.0 and 5.0.
- @type thresh: float
- @ivar materials: List of up to 16 Materials or None types
- Only the first material of the mother-ball used at the moment.
- @type materials: list
- @ivar update: The update method to use for this metaball.
- @type update: int
- """
-
- def __copy__():
- """
- Return a copy of this metaball object data.
- @rtype: Metaball
- @return: Metaball
- """
-
-import id_generics
-Metaball.__doc__ += id_generics.attributes
-
-
-class MetaElemSeq:
- """
- The MetaElemSeq object
- ======================
- This object provides sequence and iterator access to the metaballs elements.
- The elements accessed within this iterator "wraps" the actual metaball elements; changing any
- of the elements's attributes will immediately change the data in the metaball.
-
- This iterator is most like pythons 'set' type.
- """
-
- def add():
- """
- Append a new element to the metaball.
- no arguments are taken, instead a new metaelement is
- added to the metaball data and returned.
- This new element can then be modified.
-
- @return: a new meta element.
- @rtype: Metaelement
- """
-
- def remove(element):
- """
- remove an element from the metaball data.
-
- if the element is not a part of the metaball data, an error will be raised.
-
- @return: None
- @rtype: None
- """
-
- def __iter__():
- """
- Iterate over elements in this metaball.
-
- @return: One of the metaelem in this metaball.
- @rtype: Metaelem
- """
-
- def __len__():
- """
- Iterate over elements in this metaball.
-
- @return: The number of elements in this metaball
- @rtype: int
- """
-
-class Metaelem:
- """
- The Metaelem object
- ===================
- This gives direct access to meta element data within a metaball.
- @ivar type: The type of the metaball.
- Values must be from L{Types}
-
- Example::
- from Blender import Metaball
- mb= Metaball.Get('mb')
- for el in mb.elements:
- el.type= Metaball.Types.CUBE
- @type type: int
- @ivar co: The location of this element.
- @type co: Vector
- @ivar dims: Element dimensions.
- Values clamped between 0 and 20 on all axies.
- @type dims: Vector
- @ivar quat: Element rotation.
- @type quat: Quaternion
- @ivar stiffness: Element stiffness.
- Value clamped between 0 and 10.
- @type stiffness: float
- @ivar radius: Element radius.
- Value clamped between 0 and 5000.
- @type radius: float
- @ivar negative: Element negative volume status.
- @type negative: bool
- @ivar hide: Element hidden status.
- @type hide: bool
- """
diff --git a/source/blender/python/api2_2x/doc/Metaballdoc.txt b/source/blender/python/api2_2x/doc/Metaballdoc.txt
deleted file mode 100644
index 2c64a43571e..00000000000
--- a/source/blender/python/api2_2x/doc/Metaballdoc.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-METABALL Module documentation
-
-
-INTRODUCTION
-The metaball module effect allows you to access all the data of an metaball.
-A metaball consists of several (maybe only one) metaelems, which are spheres, interacting with each other, thus creating soft organic volumes.
-
-
-
-functions of the module :
-New(name) : creates ans returns a metaball object.
-Get(opt : name) : if the parameter name is given, returns the metaball object whose name has been passed, or Py_None, if no such metaball exists in the current scene. If no parameter is given, returns a list of all the metaballs in the current scene.
-get : alias for Get
-
-Metaball object member functions :
-
-getName()Return Metaball name
-setName(string newname) - Sets Metaball name
-getWiresize() - Return Metaball wire size
-setWiresize(float val) - Sets Metaball wire size
-getRendersize() - Return Metaball render size
-setRendersize(float newval- Sets Metaball render size
-getThresh()- Return Metaball threshold
-setThresh(float newval)- Sets Metaball threshold
-getBbox,- Return Metaball bounding box(a list of eight lists of three elements)
-getNMetaElems() Returns the number of Metaelems (basic spheres)
-getMetatype(int num_metaelem): returns the type of the metaelem number num_metaelem.
-0 : ball
-1 : tubex
-2 : tubey
-3 : tubez
-setMetatype(int num_metaelem,int newtype) : sets the type of the metaelem number num_metaelem.
-getMetadata(field_name,int num_metaelem) gets Metaball MetaData. Explained later.
-setMetadata(field_name,int num_metaelem,newval) sets Metaball MetaData. Explained later.
-getMetalay(int num_metaelem)
-getMetax(int num_metaelem) : gets the x coordinate of the metaelement
-setMetax(int num_metaelem,float newval) : sets the x coordinate of the metaelement
-getMetay(int num_metaelem) : gets the y coordinate of the metaelement
-setMetay(int num_metaelem,float newval) : sets the y coordinate of the metaelement
-getMetaz(int num_metaelem) : gets the z coordinate of the metaelement
-setMetaz(int num_metaelem,float newval) : sets the z coordinate of the metaelement
-getMetas(int num_metaelem) : gets the s coordinate of the metaelement
-setMetas(int num_metaelem,float newval) : sets the s coordinate of the metaelement
-getMetalen(int num_metaelem) : gets the length of the metaelement. Important for tubes.
-setMetalen(int num_metaelem,float newval) : sets the length of the metaelement. Important for tubes.
-getloc, - Gets Metaball loc values
-setloc, (f f f) - Sets Metaball loc values
-getrot, () - Gets Metaball rot values
-setrot,, (f f f) - Sets Metaball rot values
-getsize,() - Gets Metaball size values
-setsize,(f f f) - Sets Metaball size values
-
-
-
-
-The Object.attribute syntax
-
-The attribute can take these values : seed,nabla,sta,end,lifetime,normfac,obfac,randfac,texfac,randlife,vectsize,totpart,force,mult,life,child,mat,defvec. \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/Modifier.py b/source/blender/python/api2_2x/doc/Modifier.py
deleted file mode 100644
index 1d7d2e121c9..00000000000
--- a/source/blender/python/api2_2x/doc/Modifier.py
+++ /dev/null
@@ -1,226 +0,0 @@
-# Blender.Modifier module and the Modifier PyType object
-
-"""
-The Blender.Modifier submodule
-
-B{New}:
- - Supports the new Cast and Smooth modifiers.
-
-This module provides access to the Modifier Data in Blender.
-
-Example::
- from Blender import *
-
- ob = Object.Get('Cube') # retrieve an object
- mods = ob.modifiers # get the object's modifiers
- for mod in mods:
- print mod,mod.name # print each modifier and its name
- mod = mods.append(Modifier.Types.SUBSURF) # add a new subsurf modifier
- mod[Modifier.Settings.LEVELS] = 3 # set subsurf subdivision levels to 3
-
-
-Example::
- # Apply a lattice to an object and get the deformed object
- # Uses an object called 'Cube' and a lattice called 'Lattice'
-
- from Blender import *
- ob_mesh= Object.Get('Cube')
- ob_lattice= Object.Get('Lattice')
-
- myMeshMod = ob_mesh.modifiers
- mod = myMeshMod.append(Modifier.Types.LATTICE)
- mod[Modifier.Settings.OBJECT] = ob_lattice
-
- ob_mesh.makeDisplayList() # Needed to apply the modifier
-
- Window.RedrawAll() # View the change
-
- deformed_mesh= Mesh.New()
- deformed_mesh.getFromObject(ob_mesh.name)
-
-
- # Print the deformed locations
- for v in deformed_mesh.verts:
- print v.co
-
-
-
-@type Types: readonly dictionary
-@var Types: Constant Modifier dict used for L{ModSeq.append} to a
- modifier sequence and comparing with L{Modifier.type}:
- - ARMATURE - type value for Armature modifiers
- - ARRAY - type value for Array modifiers
- - BOOLEAN - type value for Boolean modifiers
- - BUILD - type value for Build modifiers
- - CURVE - type value for Curve modifiers
- - MIRROR - type value for Mirror modifiers
- - DECIMATE - type value for Decimate modifiers
- - LATTICE - type value for Lattice modifiers
- - SUBSURF - type value for Subsurf modifiers
- - WAVE - type value for Wave modifiers
- - EDGESPLIT - type value for Edge Split modifiers
- - DISPLACE - type value for Displace modifiers
- - SMOOTH - type value for Smooth modifiers
- - CAST - type value for Cast modifiers
-
-@type Settings: readonly dictionary
-@var Settings: Constant Modifier dict used for changing modifier settings.
- - RENDER - Used for all modifiers (bool) If true, the modifier is enabled for rendering.
- - REALTIME - Used for all modifiers (bool) If true, the modifier is enabled for interactive display.
- - EDITMODE - Used for all modifiers (bool) If both REALTIME and EDITMODE are true, the modifier is enabled for interactive display while the object is in edit mode.
- - ONCAGE - Used for all modifiers (bool) If true, the modifier is enabled for the editing cage during edit mode.
-
- - OBJECT - Used for Armature, Lattice, Curve, Boolean and Array (Object)
- - VERTGROUP - Used for Armature, Lattice, Curve, Smooth and Cast (String)
- - LIMIT - Array and Mirror (float [0.0 - 1.0])
- - FLAG - Mirror and Wave (int)
- - COUNT - Decimator Polycount (readonly) and Array (int)
- - LENGTH - Build [1.0-300000.0] and Array [0.0 - 10000.0] (float)
- - FACTOR - Smooth [-10.0, 10.0] and Cast [-10.0, 10.0] (float)
- - ENABLE_X = Smooth and Cast (bool, default: True)
- - ENABLE_Y = Smooth and Cast (bool, default: True)
- - ENABLE_Z = Smooth and Cast (bool, default: True)
- - TYPES - Subsurf and Cast. For Subsurf it determines the subdivision algorithm - (int): 0 = Catmull-Clark; 1 = simple subdivision. For Cast it determines the shape to deform to = (int): 0 = Sphere; 1 = Cylinder; 2 = Cuboid
-
- - LEVELS - Used for Subsurf only (int [0 - 6]). The number of subdivision levels used for interactive display.
- - RENDLEVELS - Used for Subsurf only (int [0 - 6]). The number of subdivision levels used for rendering.
- - OPTIMAL - Used for Subsurf only (bool). Enables Optimal Draw.
- - UV - Used for Subsurf only (bool). Enables Subsurf UV.
-
- - OBJECT_OFFSET - Used for Array only (Object)
- - OBJECT_CURVE - Used for Array only (Curve Object)
- - OFFSET_VEC - Used for Array only (3d Vector)
- - SCALE_VEC - Used for Array only (3d Vector)
- - MERGE_DIST - Used for Array only (float)
-
- - ENVELOPES - Used for Armature only (bool)
-
- - START - Used for Build only (int)
- - SEED - Used for Build only (int)
- - RANDOMIZE - Used for Build only (bool)
-
- - AXIS_X - Used for Mirror only (bool)
- - AXIS_Y - Used for Mirror only (bool)
- - AXIS_Z - Used for Mirror only (bool)
-
- - RATIO - Used for Decimate only (float [0.0 - 1.0])
-
- - STARTX - Used for Wave only (float [-100.0 - 100.0])
- - STARTY - Used for Wave only (float [-100.0 - 100.0])
- - HEIGHT - Used for Wave only (float [-2.0 - 2.0])
- - WIDTH - Used for Wave only (float [0.0 - 5.0])
- - NARROW - Used for Wave only (float [0.0 - 10.0])
- - SPEED - Used for Wave only (float [-2.0 - 2.0])
- - DAMP - Used for Wave only (float [-MAXFRAME - MAXFRAME])
- - LIFETIME - Used for Wave only (float [-MAXFRAME - MAXFRAME])
- - TIMEOFFS - Used for Wave only (float [-MAXFRAME - MAXFRAME])
-
- - OPERATION - Used for boolean only (int 0,1,2 : Intersect, Union, Difference)
-
- - EDGESPLIT_ANGLE - Used for edge split only (float 0.0 - 180)
- - EDGESPLIT_FROM_ANGLE - Used for edge split only, should the modifier use the edge angle (bool)
- - EDGESPLIT_FROM_SHARP - Used for edge split only, should the modifier use the edge sharp flag (bool)
-
- - UVLAYER - Used for Displace only
- - MID_LEVEL - Used for Displace only (float [0.0, 1.0], default: 0.5)
- - STRENGTH - Used for Displace only (float [-1000.0, 1000.0, default: 1.0)
- - TEXTURE - Used for Displace only (string)
- - MAPPING - Used for Displace only
- - DIRECTION - Used for Displace only
-
- - REPEAT - Used for Smooth only (int [0, 30], default: 1)
-
- - RADIUS - Used for Cast only (float [0.0, 100.0], default: 0.0)
- - SIZE - Used for Cast only (float [0.0, 100.0], default: 0.0)
- - SIZE_FROM_RADIUS - Used for Cast only (bool, default: True)
- - USE_OB_TRANSFORM - Used for Cast only (bool, default: False)
-"""
-
-class ModSeq:
- """
- The ModSeq object
- =================
- This object provides access to list of L{modifiers<Modifier.Modifier>} for a particular object.
- Only accessed from L{Object.Object.modifiers}.
- """
-
- def __getitem__(index):
- """
- This operator returns one of the object's modifiers.
- @type index: int
- @return: an Modifier object
- @rtype: Modifier
- @raise KeyError: index was out of range
- """
-
- def __len__():
- """
- Returns the number of modifiers in the object's modifier stack.
- @return: number of Modifiers
- @rtype: int
- """
-
- def append(type):
- """
- Appends a new modifier to the end of the object's modifier stack.
- @type type: a constant specifying the type of modifier to create. as from L{Types}
- @rtype: Modifier
- @return: the new Modifier
- """
-
- def remove(modifier):
- """
- Remove a modifier from this objects modifier sequence.
- @type modifier: a modifier from this sequence to remove.
- @note: Accessing attributes of the modifier after removing will raise an error.
- """
-
- def moveUp(modifier):
- """
- Moves the modifier up in the object's modifier stack.
- @type modifier: a modifier from this sequence to remove.
- @rtype: None
- @raise RuntimeError: request to move above another modifier requiring
- original data
- @note: Accessing attributes of the modifier after removing will raise an error.
- """
-
- def moveDown(modifier):
- """
- Moves the modifier down in the object's modifier stack.
- @type modifier: a modifier from this sequence to remove.
- @rtype: None
- @raise RuntimeError: request to move modifier beyond a non-deforming
- modifier
- @note: Accessing attributes of the modifier after removing will raise an error.
- """
-
-class Modifier:
- """
- The Modifier object
- ===================
- This object provides access to a modifier for a particular object accessed
- from L{ModSeq}.
- @ivar name: The name of this modifier. 31 chars max.
- @type name: string
- @ivar type: The type of this modifier. Read-only. The returned value
- matches the types in L{Types}.
- @type type: int
- """
-
- def __getitem__(key):
- """
- This operator returns one of the modifier's data attributes.
- @type key: value from modifier's L{Modifier.Settings} constant
- @return: the requested data
- @rtype: varies
- @raise KeyError: the key does not exist for the modifier
- """
-
- def __setitem__(key):
- """
- This operator modifiers one of the modifier's data attributes.
- @type key: value from modifier's L{Modifier.Settings} constant
- @raise KeyError: the key does not exist for the modifier
- """
-
diff --git a/source/blender/python/api2_2x/doc/NLA.py b/source/blender/python/api2_2x/doc/NLA.py
deleted file mode 100644
index adfcf77d965..00000000000
--- a/source/blender/python/api2_2x/doc/NLA.py
+++ /dev/null
@@ -1,245 +0,0 @@
-# Blender.Armature.NLA module and the Action PyType object
-
-"""
-The Blender.Armature.NLA submodule.
-
-NLA
-===
-
-This module provides access to B{Action} objects in Blender. Actions are a
-series of keyframes/Ipo curves that define the movement of a bone.
-Actions are linked to objects of type armature.
-
-@type Flags: readonly dictionary
-@var Flags: Constant dict used by the L{ActionStrip.flag} attribute.
-It is a bitmask and settings are ORed together.
- - SELECT: action strip is selected in NLA window
- - STRIDE_PATH: play action based on path position and stride.
- - HOLD: continue displaying the last frame past the end of the strip
- - ACTIVE: action strip is active in NLA window
- - LOCK_ACTION: action start/end are automatically mapped to strip duration
-
-@type StrideAxes: readonly dictionary
-@var StrideAxes: Constant dict used by the L{ActionStrip.strideAxis} attribute.
-Values are STRIDEAXIS_X, STRIDEAXIS_Y, and STRIDEAXIS_Z.
-
-@type Modes: readonly dictionary
-@var Modes: Constant dict used by the L{ActionStrip.mode} attribute.
-Currently the only value is MODE_ADD.
-"""
-
-def NewAction (name = 'DefaultAction'):
- """
- Create a new Action object.
- @type name: string
- @param name: The Action name.
- @rtype: PyAction
- """
-
-def CopyAction (action):
- """
- Copy an action and it's keyframes
- @type action: PyAction
- @param action: The action to be copied.
- @rtype: PyAction
- @return: A copied action
- """
-
-def GetActions ():
- """
- Get all actions and return them as a Key : Value Dictionary.
- @rtype: Dictionary of PyActions
- @return: All the actions in blender
- """
-
-class Action:
- """
- The Action object
- =================
- This object gives access to Action-specific data in Blender.
- """
-
- def getName():
- """
- Get the name of this Action.
- @rtype: string
- """
-
- def setName(name):
- """
- Set the name of this Action.
- @type name: string
- @param name: The new name
- """
-
- def setActive(object):
- """
- Set this action as the current action for an object.
- @type object: PyObject
- @param object: The object whose action is to be set
- """
-
- def getChannelIpo(channel):
- """
- Get the Ipo for the named channel in this action
- @type channel: string
- @param channel: The name of a channel in this action
- @rtype: PyIpo or None
- @return: the Ipo for the channel
- """
-
- def getFrameNumbers():
- """
- Gets the frame numbers at which a key was inserted into this action
- @rtype: PyList
- @return: a list of ints
- """
-
- def removeChannel(channel):
- """
- Remove a named channel from this action
- @type channel: string
- @param channel: The name of a channel in this action to be removed
- """
-
- def getAllChannelIpos():
- """
- Get the all the Ipos for this action
- @rtype: Dictionary [channel : PyIpo or None]
- @return: the Ipos for all the channels in the action
- """
-
- def getChannelNames():
- """
- Returns a list of channel names
- @rtype: list
- @return: the channel names that match bone and constraint names.
- """
-
- def renameChannel(nameFrom, nameTo):
- """
- rename an existing channel to a new name.
-
- if the nameFrom channel dosnt exist or the nameTo exists, an error will be raised.
- @return: None
- """
-
-import id_generics
-Action.__doc__ += id_generics.attributes
-
-
-class ActionStrips:
- """
- The ActionStrips object
- =======================
- This object gives access to sequence of L{ActionStrip} objects for
- a particular Object.
- """
-
- def __getitem__(index):
- """
- This operator returns one of the action strips in the stack.
- @type index: int
- @return: an action strip object
- @rtype: ActionStrip
- @raise KeyError: index was out of range
- """
-
- def __len__():
- """
- Returns the number of action strips for the object.
- @return: number of action strips
- @rtype: int
- """
-
- def append(action):
- """
- Appends a new action to the end of the action strip sequence.
- @type action: L{Action<NLA.Action>}
- @param action: the action to use in the action strip
- @rtype: ActionStrip
- @return: the new action strip
- """
-
- def remove(actionstrip):
- """
- Remove an action strip from this object's actionstrip sequence.
- @type actionstrip: an action strip from this sequence to remove.
- @note: Accessing attributes of the action strip after it is removed will
- throw an exception.
- """
-
- def moveDown(actionstrip):
- """
- Move the action strip down in the object's actionstrip sequence.
- @type actionstrip: an action strip from this sequence.
- """
-
- def moveUp(actionstrip):
- """
- Move the action strip up in the object's actionstrip sequence.
- @type actionstrip: an action strip from this sequence.
- """
-
-class ActionStrip:
- """
- The ActionStrip object
- ======================
- This object gives access to a particular action strip.
- @ivar action: Action associated with the strip.
- @type action: BPy Action object
- @ivar stripStart: Starting frame of the strip.
- @type stripStart: float
- @ivar stripEnd: Ending frame of the strip.
- @type stripEnd: float
- @ivar actionStart: Starting frame of the action.
- @type actionStart: float
- @ivar actionEnd: Ending frame of the action.
- @type actionEnd: float
- @ivar repeat: The number of times to repeat the action range.
- @type repeat: float
- @ivar mode: Controls the ActionStrip mode. See L{Modes} for
- valid values.
- @type mode: int
- @ivar flag: Controls various ActionStrip attributes. Values can be ORed.
- See L{Flags} for valid values.
- @type flag: int
- @ivar strideAxis: Dominant axis for stride bone. See L{StrideAxes} for
- valid values.
- @type strideAxis: int
- @ivar strideLength: Distance covered by one complete cycle of the action
- specified in the Action Range.
- @type strideLength: float
- @ivar strideBone: Name of Bone used for stride
- @type strideBone: string
- @ivar groupTarget: Armature object within DupliGroup for local animation
- @type groupTarget: object
- @ivar blendIn: Number of frames of motion blending.
- @type blendIn: float
- @ivar blendOut: Number of frames of ease-out.
- @type blendOut: float
- """
-
- def resetActionLimits():
- """
- Activates the functionality found in NLA Strip menu under "Reset Action
- Start/End". This method restores the values of ActionStart and
- ActionEnd to their defaults, usually the first and last frames within
- an action that contain keys.
- @rtype: None
- """
-
- def resetStripSize():
- """
- Activates the functionality found in NLA Strip menu under "Reset Strip
- Size". This method resets the action strip size to its creation values.
- @rtype: None
- """
-
- def snapToFrame():
- """
- Activates the functionality found in NLA Strip menu under "Snap to Frame".
- This function snaps the ends of the action strip to the nearest whole
- numbered frame.
- @rtype: None
- """
diff --git a/source/blender/python/api2_2x/doc/NMesh.py b/source/blender/python/api2_2x/doc/NMesh.py
deleted file mode 100644
index e6d779aebb8..00000000000
--- a/source/blender/python/api2_2x/doc/NMesh.py
+++ /dev/null
@@ -1,823 +0,0 @@
-# Blender.NMesh module and the NMesh PyType object
-
-"""
-The Blender.NMesh submodule.
-
-B{Deprecated}:
-This module is now maintained but not actively developed.
-
-Access to data such as properties, library, UVLayers and ColorLayers is not available
-further more, a mesh modified with NMesh will destroy inactive UV and Color layers
-so writing tools that use NMesh is discouraged.
-
-Use L{Mesh} instead.
-
-Mesh Data
-=========
-
-This module provides access to B{Mesh Data} objects in Blender.
-
-Example::
-
- import Blender
- from Blender import NMesh, Material, Window
-
- editmode = Window.EditMode() # are we in edit mode? If so ...
- if editmode: Window.EditMode(0) # leave edit mode before getting the mesh
-
- me = NMesh.GetRaw("Plane") # get the mesh data called "Plane"
-
- if not me.materials: # if there are no materials ...
- newmat = Material.New() # create one ...
- me.materials.append(newmat) # and append it to the mesh's list of mats
-
- print me.materials # print the list of materials
- mat = me.materials[0] # grab the first material in the list
- mat.R = 1.0 # redefine its red component
- for v in me.verts: # loop the list of vertices
- v.co[0] *= 2.5 # multiply the coordinates
- v.co[1] *= 5.0
- v.co[2] *= 2.5
- me.update() # update the real mesh in Blender
-
- if editmode: Window.EditMode(1) # optional, just being nice
-
-@type Modes: readonly dictionary
-@type FaceFlags: readonly dictionary
-@type FaceModes: readonly dictionary
-@type FaceTranspModes: readonly dictionary
-@var Modes: The available mesh modes.
- - NOVNORMALSFLIP - no flipping of vertex normals during render.
- - TWOSIDED - double sided mesh.
- - AUTOSMOOTH - turn auto smoothing of faces "on".
-@var FaceFlags: The available *texture face* (uv face select mode) selection
- flags. Note: these refer to TexFace faces, available if nmesh.hasFaceUV()
- returns true.
- - SELECT - selected (deprecated after 2.43 release, use face.sel).
- - HIDE - hidden (deprecated after 2.43 release, use face.sel).
- - ACTIVE - the active face.
-@var FaceModes: The available *texture face* modes. Note: these are only
- meaningful if nmesh.hasFaceUV() returns true, since in Blender this info is
- stored at the TexFace (TexFace button in Edit Mesh buttons) structure.
- - ALL - set all modes at once.
- - BILLBOARD - always orient after camera.
- - HALO - halo face, always point to camera.
- - DYNAMIC - respond to collisions.
- - INVISIBLE - invisible face.
- - LIGHT - dynamic lighting.
- - OBCOL - use object color instead of vertex colors.
- - SHADOW - shadow type.
- - SHAREDVERT - apparently unused in Blender.
- - SHAREDCOL - shared vertex colors (per vertex).
- - TEX - has texture image.
- - TILES - uses tiled image.
- - TWOSIDE - two-sided face.
-@var FaceTranspModes: The available face transparency modes. Note: these are
- enumerated values (enums), they can't be combined (ANDed, ORed, etc) like a bit vector.
- - SOLID - draw solid.
- - ADD - add to background (halo).
- - ALPHA - draw with transparency.
- - SUB - subtract from background.
-@var EdgeFlags: The available edge flags.
- - SELECT - selected.
- - EDGEDRAW - edge is drawn out of edition mode.
- - SEAM - edge is a seam for UV unwrapping
- - FGON - edge is part of a F-Gon.
-"""
-
-def Col(col = [255, 255, 255, 255]):
- """
- Get a new mesh rgba color.
- @type col: list
- @param col: A list [red, green, blue, alpha] of integer values in [0, 255].
- @rtype: NMCol
- @return: A new NMCol (mesh rgba color) object.
- """
-
-def Vert(x = 0, y = 0, z = 0):
- """
- Get a new vertex object.
- @type x: float
- @type y: float
- @type z: float
- @param x: The x coordinate of the vertex.
- @param y: The y coordinate of the vertex.
- @param z: The z coordinate of the vertex.
- @rtype: NMVert
- @return: A new NMVert object.
- """
-
-def Face(vertexList = None):
- """
- Get a new face object.
- @type vertexList: list
- @param vertexList: A list of B{up to 4} NMVerts (mesh vertex
- objects).
- @rtype: NMFace
- @return: A new NMFace object.
- """
-
-def New(name = 'Mesh'):
- """
- Create a new mesh object.
- @type name: string
- @param name: An optional name for the created mesh.
- rtype: NMesh
- @return: A new (B{empty}) NMesh object.
- """
-
-def GetRaw(name = None):
- """
- Get the mesh data object called I{name} from Blender.
- @type name: string
- @param name: The name of the mesh data object.
- @rtype: NMesh
- @return: It depends on the 'name' parameter:
- - (name) - The NMesh wrapper of the mesh called I{name},
- None if not found.
- - () - A new (empty) NMesh object.
- """
-
-def GetNames():
- """
- Get a list with the names of all available meshes in Blender.
- @rtype: list of strings
- @return: a list of mesh names.
- @note: to get actual mesh data, pass a mesh name to L{GetRaw}.
- """
-
-def GetRawFromObject(name):
- """
- Get the raw mesh data object from the Object in Blender called I{name}.\n
- Note: The mesh coordinates are in local space, not the world space of its Object.\n
- For world space vertex coordinates, each vertex location must be multiplied by the object's 4x4 matrix.
- This function support all the geometry based objects: Mesh, Text, Surface, Curve, Meta.
- @type name: string
- @param name: The name of an Object.
- @rtype: NMesh
- @return: The NMesh wrapper of the mesh data from the Object called I{name}.
- @note: For "subsurfed" meshes, it's the B{display} level of subdivision that
- matters, the rendering one is only processed at the rendering pre-stage
- and is not available for scripts. This is not a problem at all, since
- you can get and set the subdivision levels via scripting, too (see
- L{NMesh.NMesh.getSubDivLevels}, L{NMesh.NMesh.setSubDivLevels}).
- @note: Meshes extracted from curve based objects (Font/2D filled curves)
- contain both the filled surfaces and the outlines of the shapes.
- @warn: This function gets I{deformed} mesh data, already modified for
- displaying (think "display list"). It also doesn't let you overwrite the
- original mesh in Blender, so if you try to update it, a new mesh will
- be created.
- @warn: For Meta Object's, this function will only return a NMesh with some geometry
- when called on the base element (the one with the shortest name).
- """
-
-def PutRaw(nmesh, name = None, recalc_normals = 1, store_edges = 0):
- """
- Put a BPython NMesh object as a mesh data object in Blender.
- @note: if there is already a mesh with the given 'name', its contents are
- freed and the new data is put in it. Also, if this mesh is not linked to any
- object, a new object for it is created. Reminder: in Blender an object is
- composed of the base object and linked object data (mesh, metaball, camera,
- etc. etc).
- @type nmesh: NMesh
- @type name: string
- @type recalc_normals: int
- @type store_edges: int
- @param name: The name of the mesh data object in Blender which will receive
- this nmesh data. It can be an existing mesh data object or a new one.
- @param recalc_normals: If non-zero, the vertex normals for the mesh will
- be recalculated.
- @param store_edges: deprecated, edges are always stored now.
- @rtype: None or Object
- @return: It depends on the 'name' parameter:
- - I{name} refers to an existing mesh data obj already linked to an
- object: return None.
- - I{name} refers to a new mesh data obj or an unlinked (no users) one:
- return the created Blender Object wrapper.
- """
-
-class NMCol:
- """
- The NMCol object
- ================
- This object is a list of ints: [r, g, b, a] representing an
- rgba color.
- @ivar r: The Red component in [0, 255].
- @ivar g: The Green component in [0, 255].
- @ivar b: The Blue component in [0, 255].
- @ivar a: The Alpha (transparency) component in [0, 255].
- """
-
-class NMVert:
- """
- The NMVert object
- =================
- This object holds mesh vertex data.
- @type co: 3D Vector object. (WRAPPED DATA)
- @ivar co: The vertex coordinates (x, y, z).
- @type no: 3D Vector object. (unit length) (WRAPPED DATA)
- @ivar no: The vertex normal vector (x, y, z).
- @type uvco: 3D Vector object. (WRAPPED DATA)
- @ivar uvco: The vertex texture "sticky" coordinates. The Z value of the Vector is ignored.
- @type index: int
- @ivar index: The vertex index, if owned by a mesh.
- @type sel: int
- @ivar sel: The selection state (selected:1, unselected:0) of this vertex.\n
- Note: An NMesh will return the selection state of the mesh when EditMod was last exited. A python script operating in EditMode must exit edit mode, before getting the current selection state of the mesh.
- @warn: There are two kinds of uv texture coordinates in Blender: per vertex
- ("sticky") and per face vertex (uv in L{NMFace}). In the first, there's
- only one uv pair of coordinates for each vertex in the mesh. In the
- second, for each face it belongs to, a vertex can have different uv
- coordinates. This makes the per face option more flexible, since two
- adjacent faces won't have to be mapped to a continuous region in an image:
- each face can be independently mapped to any part of its texture.
- """
-
-class NMEdge:
- """
- The NMEdge object
- =================
- This object holds mesh edge data.
- @type v1: NMVert
- @ivar v1: The first vertex of the edge.
- @type v2: NMVert
- @ivar v2: The second vertex of the edge.
- @type crease: int
- @ivar crease: The crease value of the edge. It is in the range [0,255].
- @type flag: int
- @ivar flag: The bitmask describing edge properties. See L{NMesh.EdgeFlags<EdgeFlags>}.
- """
-
-class NMFace:
- """
- The NMFace object
- =================
- This object holds mesh face data.
-
- Example::
- import Blender
- from Blender import NMesh, Window
-
- in_emode = Window.EditMode()
- if in_emode: Window.EditMode(0)
-
- me = NMesh.GetRaw("Mesh")
- faces = me.faces
-
- ## Example for editmode faces selection:
- selected_faces = []
- for f in faces:
- if f.sel:
- selected_faces.append(f)
- # ... unselect selected and select all the others:
- for f in faces:
- f.sel = 1 - f.sel # 1 becomes 0, 0 becomes 1
-
- ## Example for uv textured faces selection:
- selected_faces = []
- SEL = NMesh.FaceFlags['SELECT']
- # get selected faces:
- for f in faces:
- if f.flag & SEL:
- selected_faces.append(f)
- # ... unselect selected and select all the others:
- for f in faces:
- if f.flag & SEL:
- f.flag &=~SEL # unselect these
- else: f.flag |= SEL # and select these
-
- me.update()
- if in_emode: Window.EditMode(1)
- Blender.Redraw()
-
- @type v: list
- @ivar v: The list of face vertices (B{up to 4}).
- @type sel: bool
- @ivar sel: The selection state (1: selected, 0: unselected) of this NMesh's
- faces *in edit mode*. This is not the same as the selection state of
- the textured faces (see L{flag}).
- @type hide: bool
- @ivar hide: The visibility state (1: hidden, 0: visible) of this NMesh's
- faces *in edit mode*. This is not the same as the visibility state of
- the textured faces (see L{flag}).
- @ivar col: The list of vertex colors.
- @ivar mat: Same as I{materialIndex} below.
- @ivar materialIndex: The index of this face's material in its NMesh materials
- list.
- @ivar smooth: If non-zero, the vertex normals are averaged to make this
- face look smooth.
- @ivar image: The Image used as a texture for this face.
- @ivar mode: The display mode (see L{Mesh.FaceModes<FaceModes>})
- @ivar flag: Bit vector specifying selection / visibility flags for uv
- textured faces (visible in Face Select mode, see
- L{NMesh.FaceFlags<FaceFlags>}).
- @ivar transp: Transparency mode bit vector
- (see L{NMesh.FaceTranspModes<FaceTranspModes>}).
- @ivar uv: List of per-face UV coordinates: [(u0, v0), (u1, v1), ...].
- @ivar normal: (or just B{no}) The normal vector for this face: [x,y,z].
- @note: there are normal faces and textured faces in Blender, both currently
- with their own selection and visibility states, due to a mix of old and new
- code. To (un)select or (un)hide normal faces (visible in editmode), use
- L{sel} and L{hide} variables. For textured faces (Face Select
- mode in Blender) use the old L{flag} bitflag. Also check the
- example above and note L{Window.EditMode}.
- @note: Assigning uv textures to mesh faces in Blender works like this:
- 1. Select your mesh.
- 2. Enter face select mode (press f) and select at least some face(s).
- 3. In the UV/Image Editor window, load / select an image.
- 4. Play in both windows (better split the screen to see both at the same
- time) until the uv coordinates are where you want them. Hint: in the
- 3d window, the 'u' key opens a menu of default uv choices and the 'r'
- key lets you rotate the uv coordinates.
- 5. Leave face select mode (press f).
- """
-
- def append(vertex):
- """
- Append a vertex to this face's vertex list.
- @type vertex: NMVert
- @param vertex: An NMVert object.
- """
-
-from IDProp import IDGroup, IDArray
-class NMesh:
- """
- The NMesh Data object
- =====================
- This object gives access to mesh data in Blender. We refer to mesh as the
- object in Blender and NMesh as its Python counterpart.
- @ivar properties: Returns an L{IDGroup<IDProp.IDGroup>} reference to this
- object's ID Properties.
- @type properties: L{IDGroup<IDProp.IDGroup>}
- @ivar name: The NMesh name. It's common to use this field to store extra
- data about the mesh (to be exported to another program, for example).
- @ivar materials: The list of materials used by this NMesh. See
- L{getMaterials} for important details.
- @ivar verts: The list of NMesh vertices (NMVerts).
- @ivar users: The number of Objects using (linked to) this mesh.
- @ivar faces: The list of NMesh faces (NMFaces).
- @ivar edges: A list of L{NMEdge} edges.
- @ivar mode: The mode flags for this mesh. See L{setMode}.
- @ivar subDivLevels: The [display, rendering] subdivision levels in [1, 6].
- @ivar maxSmoothAngle: The max angle for auto smoothing. See L{setMode}.
- @cvar key: The L{Key.Key} object attached to this mesh, if any.
- """
-
- def addEdge(v1, v2):
- """
- Create an edge between two vertices.
- If an edge already exists between those vertices, it is returned.
- Created edge is automatically added to edges list.
- You can only call this method if mesh has edge data.
- @note: In Blender only zero or one edge can link two vertices.
- @type v1: NMVert
- @param v1: the first vertex of the edge.
- @type v2: NMVert
- @param v2: the second vertex of the edge.
- @rtype: NMEdge
- @return: The created or already existing edge.
- """
-
- def findEdge(v1, v2):
- """
- Try to find an edge between two vertices.
- If no edge exists between v1 and v2, None is returned.
- You can only call this method if mesh has edge data.
- @type v1: NMVert
- @param v1: the first vertex of the edge.
- @type v2: NMVert
- @param v2: the second vertex of the edge.
- @rtype: NMEdge
- @return: The found edge. None if no edge was found.
- """
-
- def removeEdge(v1, v2):
- """
- Remove an edge between two vertices.
- All faces using this edge are removed from faces list.
- You can only call this method if mesh has edge data.
- @type v1: NMVert
- @param v1: the first vertex of the edge.
- @type v2: NMVert
- @param v2: the second vertex of the edge.
- """
-
- def addFace(face):
- """
- Add a face to face list and add to edge list (if edge data exists) necessary edges.
- @type face: NMFace
- @param face: the face to add to the mesh.
- @rtype: list of NMEdge
- @return: If mesh has edge data, return the list of face edges.
- """
-
- def removeFace(face):
- """
- Remove a face for face list and remove edges no more used by any other face (if edge data exists).
- @type face: NMFace
- @param face: the face to add to the mesh.
- """
-
- def addMaterial(material):
- """
- Add a new material to this NMesh's list of materials. This method is the
- slower but safer way to add materials, since it checks if the argument
- given is really a material, imposes a limit of 16 materials and only adds
- the material if it wasn't already in the list.
- @type material: Blender Material
- @param material: A Blender Material.
- """
-
- def getMaterials(what = -1):
- """
- Get this NMesh's list of materials.
- @type what: int
- @param what: determines the list's contents:
- - -1: return the current NMesh's list;
- - 0: retrieve a fresh list from the Blender mesh -- eventual
- modifications made by the script not included, unless
- L{update} is called before this method;
- - 1: like 0, but empty slots are not ignored, they are returned as
- None's.
- @note: what >= 0 also updates nmesh.materials attribute.
- @rtype: list of materials
- @return: the requested list of materials.
- @note: if a user goes to the material buttons window and removes some
- mesh's link to a material, that material slot becomes empty.
- Previously such materials were ignored.
- @note: L{Object.colbits<Object.Object.colbits>} needs to be set correctly
- for each object in order for these materials to be used instead of
- the object's materials.
- """
-
- def setMaterials(matlist):
- """
- Set this NMesh's list of materials. This method checks the consistency of
- the passed list: must only have materials or None's and can't contain more
- than 16 entries.
- @type matlist: list of materials
- @param matlist: a list with materials, None's also accepted (they become
- empty material slots in Blender.
- @note: L{Object.colbits<Object.Object.colbits>} needs to be set correctly
- for each object in order for these materials to be used instead of
- the object's materials.
- """
-
- def hasVertexColours(flag = None):
- """
- Get (and optionally set) if this NMesh has vertex colors.
- @type flag: int
- @param flag: If given and non-zero, the "vertex color" flag for this NMesh
- is turned I{on}.
- @rtype: bool
- @return: The current value of the "vertex color" flag.
- @warn: If a mesh has both vertex colors and textured faces, this function
- will return False. This is due to the way Blender deals internally with
- the vertex colors array (if there are textured faces, it is copied to
- the textured face structure and the original array is freed/deleted).
- If you want to know if a mesh has both textured faces and vertex
- colors, set *in Blender* the "VCol Paint" flag for each material that
- covers an area that was also vertex painted and then check in your
- Python script if that material flag is set. Of course also tell others
- who use your script to do the same. The "VCol Paint" material mode flag
- is the way to tell Blender itself to render with vertex colors, too, so
- it's a natural solution.
- """
-
- def hasFaceUV(flag = None):
- """
- Get (and optionally set) if this NMesh has UV-mapped textured faces.
- @type flag: int
- @param flag: If given and non-zero, the "textured faces" flag for this
- NMesh is turned I{on}.
- @rtype: bool
- @return: The current value of the "textured faces" flag.
- """
-
- def hasVertexUV(flag = None):
- """
- Get (and optionally set) the "sticky" flag that controls if a mesh has
- per vertex UV coordinates.
- @type flag: int
- @param flag: If given and non-zero, the "sticky" flag for this NMesh is
- turned I{on}.
- @rtype: bool
- @return: The current value of the "sticky" flag.
- """
-
- def getActiveFace():
- """
- Get the index of the active face.
- @rtype: int
- @return: The index of the active face.
- """
-
- def getSelectedFaces(flag = None):
- """
- Get list of selected faces.
- @type flag: int
- @param flag: If given and non-zero, the list will have indices instead of
- the NMFace objects themselves.
- @rtype: list
- @return: It depends on the I{flag} parameter:
- - if None or zero: List of NMFace objects.
- - if non-zero: List of indices to NMFace objects.
- @warn: this method exists to speed up retrieving of selected faces from
- the actual mesh in Blender. So, if you make changes to the nmesh, you
- need to L{update} it before using this method.
- """
-
- def getVertexInfluences(index):
- """
- Get influences of bones in a specific vertex.
- @type index: int
- @param index: The index of a vertex.
- @rtype: list of lists
- @return: List of pairs (name, weight), where name is the bone name (string)
- and its weight is a float value.
- """
-
- def getKey():
- """
- Get the Key object representing the Vertex Keys (absolute or
- relative) assigned to this mesh.
- @rtype: L{Key.Key} object or None
- """
-
- def insertKey(frame = None, type = 'relative'):
- """
- Insert a mesh key at the given frame. Remember to L{update} the nmesh
- before doing this, or changes in the vertices won't be updated in the
- Blender mesh.
- @type frame: int
- @type type: string
- @param frame: The Scene frame where the mesh key should be inserted. If
- None, the current frame is used.
- @param type: The mesh key type: 'relative' or 'absolute'. This is only
- relevant on the first call to insertKey for each nmesh (and after all
- keys were removed with L{removeAllKeys}, of course).
- @warn: This and L{removeAllKeys} were included in this release only to
- make accessing vertex keys possible, but may not be a proper solution
- and may be substituted by something better later. For example, it
- seems that 'frame' should be kept in the range [1, 100]
- (the curves can be manually tweaked in the Ipo Curve Editor window in
- Blender itself later).
- """
-
- def removeAllKeys():
- """
- Remove all mesh keys stored in this mesh.
- @rtype: bool
- @return: True if successful or False if this NMesh wasn't linked to a real
- Blender Mesh yet (or was, but the Mesh had no keys).
- @warn: Currently the mesh keys from meshes that are grabbed with
- NMesh.GetRaw() or .GetRawFromObject() are preserved, so if you want to
- clear them or don't want them at all, remember to call this method. Of
- course NMeshes created with NMesh.New() don't have mesh keys until you
- add them.
- """
-
- def update(recalc_normals = 0, store_edges = 0, vertex_shade = 0):
- """
- Update the mesh in Blender. The changes made are put back to the mesh in
- Blender, if available, or put in a newly created mesh if this NMesh wasn't
- already linked to one.
- @type recalc_normals: int (bool)
- @param recalc_normals: if nonzero the vertex normals are recalculated.
- @type store_edges: int (bool)
- @param store_edges: deprecated, edges are always stored now.
- @type vertex_shade: int (bool)
- @param vertex_shade: if nonzero vertices are colored based on the
- current lighting setup, like when there are no vertex colors and no
- textured faces and a user enters Vertex Paint Mode in Blender (only
- lamps in visible layers account). To use this functionality, be out of
- edit mode or else an error will be returned.
- @warn: edit mesh and normal mesh are two different structures in Blender,
- synchronized upon leaving or entering edit mode. Always remember to
- leave edit mode (L{Window.EditMode}) before calling this update
- method, or your changes will be lost. Even better: for the same reason
- programmers should leave EditMode B{before} getting a mesh, or changes
- made to the editmesh in Blender may not be visible to your script
- (check the example at the top of NMesh module doc).
- @warn: unlike the L{PutRaw} function, this method doesn't check validity of
- vertex, face and material lists, because it is meant to be as fast as
- possible (and already performs many tasks). So programmers should make
- sure they only feed proper data to the nmesh -- a good general
- recommendation, of course. It's also trivial to write code to check
- all data before updating, for example by comparing each item's type
- with the actual L{Types}, if you need to.
- @note: this method also redraws the 3d view and -- if 'vertex_shade' is
- nonzero -- the edit buttons window.
- @note: if your mesh disappears after it's updated, try
- L{Object.Object.makeDisplayList}. 'Subsurf' meshes (see L{getMode},
- L{setMode}) need their display lists updated, too.
- """
-
- def transform(matrix, recalc_normals = False):
- """
- Transforms the mesh by the specified 4x4 matrix, as returned by
- L{Object.Object.getMatrix}, though this will work with any invertible 4x4
- matrix type. Ideal usage for this is exporting to an external file where
- global vertex locations are required for each object.
- Sometimes external renderers or file formats do not use vertex normals.
- In this case, you can skip transforming the vertex normals by leaving
- the optional parameter recalc_normals as False or 0 ( the default value ).
-
- Example::
- # This script outputs deformed meshes worldspace vertex locations
- # for a selected object
- import Blender
- from Blender import NMesh, Object
-
- ob = Object.GetSelected()[0] # Get the first selected object
- me = NMesh.GetRawFromObject(ob.name) # Get the objects deformed mesh data
- me.transform(ob.matrix)
-
- for v in me.verts:
- print 'worldspace vert', v.co
-
- @type matrix: Py_Matrix
- @param matrix: 4x4 Matrix which can contain location, scale and rotation.
- @type recalc_normals: int (bool)
- @param recalc_normals: if True or 1, transform normals as well as vertex coordinates.
- @warn: if you call this method and later L{update} the mesh, the new
- vertex positions will be passed back to Blender, but the object
- matrix of each object linked to this mesh won't be automatically
- updated. You need to set the object transformations (rotation,
- translation and scaling) to identities, then, or the mesh data will
- be changed ("transformed twice").
- """
-
- def getMode():
- """
- Get this mesh's mode flags.
- @rtype: int
- @return: ORed value. See L{Modes}.
- """
-
- def setMode(m=None, m1=None, m2=None):
- """
- Set the mode flags for this mesh. Given mode strings turn the mode "on".
- Modes not passed in are turned "off", so setMode() (without arguments)
- unsets all mode flags.
- @type m: string or int (bitflag)
- @param m: mode string or int. An int (see L{Modes}) or from none to 3
- strings can be given:
- - "NoVNormalsFlip"
- - "TwoSided"
- - "AutoSmooth"
- """
-
- def addVertGroup(group):
- """
- Add a named and empty vertex (deform) group to the object this nmesh is
- linked to. If this nmesh was newly created or accessed with GetRaw, it must
- first be linked to an object (with object.link or NMesh.PutRaw) so the
- method knows which object to update.\n
- This is because vertex groups in Blender are stored in I{the object} --
- not in the mesh, which may be linked to more than one object. For this
- reason, it's better to use "mesh = object.getData()" than
- "mesh = NMesh.GetRaw(meshName)" to access an existing mesh.
- @type group: string
- @param group: the name for the new group.
- """
-
- def removeVertGroup(group):
- """
- Remove a named vertex (deform) group from the object linked to this nmesh.
- All vertices assigned to the group will be removed (just from the group,
- not deleted from the mesh), if any. If this nmesh was newly created, it
- must first be linked to an object (read the comment in L{addVertGroup} for
- more info).
- @type group: string
- @param group: the name of a vertex group.
- """
-
- def assignVertsToGroup(group, vertList, weight, assignmode = 'replace'):
- """
- Adds an array (a python list) of vertex points to a named vertex group
- associated with a mesh. The vertex list is a list of vertex indices from
- the mesh. You should assign vertex points to groups only when the mesh has
- all its vertex points added to it and is already linked to an object.
-
- I{B{Example:}}
- The example here adds a new set of vertex indices to a sphere primitive::
- import Blender
- sphere = Blender.Object.Get('Sphere')
- mesh = sphere.getData()
- mesh.addVertGroup('firstGroup')
- vertList = []
- for x in range(300):
- if x % 3 == 0:
- vertList.append(x)
- mesh.assignVertsToGroup('firstGroup', vertList, 0.5, 'add')
-
- @type group: string
- @param group: the name of the group.
- @type vertList: list of ints
- @param vertList: a list of vertex indices.
- @type weight: float
- @param weight: the deform weight for (which means: the amount of influence
- the group has over) the given vertices. It should be in the range
- [0.0, 1.0]. If weight <= 0, the given vertices are removed from the
- group. If weight > 1, it is clamped.
- @type assignmode: string
- @param assignmode: Three choices:
- - 'add'
- - 'subtract'
- - 'replace'\n
-
- 'B{add}': if the vertex in the list is not assigned to the group
- already, this creates a new association between this vertex and the
- group with the weight specified, otherwise the weight given is added to
- the current weight of an existing association between the vertex and
- group.\n
- 'B{subtract}' will attempt to subtract the weight passed from a vertex
- already associated with a group, else it does nothing.\n
- 'B{replace}' attempts to replace a weight with the new weight value
- for an already associated vertex/group, else it does nothing.
- """
-
- def removeVertsFromGroup(group, vertList = None):
- """
- Remove a list of vertices from the given group. If this nmesh was newly
- created, it must first be linked to an object (check L{addVertGroup}).
- @type group: string
- @param group: the name of a vertex group
- @type vertList: list of ints
- @param vertList: a list of vertex indices to be removed from the given
- 'group'. If None, all vertices are removed -- the group is emptied.
- """
-
- def getVertsFromGroup(group, weightsFlag = 0, vertList = None):
- """
- Return a list of vertex indices associated with the passed group. This
- method can be used to test whether a vertex index is part of a group and
- if so, what its weight is.
-
- I{B{Example:}}
- Append this to the example from L{assignVertsToGroup}::
- # ...
- print "Vertex indices from group %s :" % groupName
- print mesh.getVertsFromGroup('firstGroup')
- print "Again, with weights:"
- print mesh.getVertsFromGroup('firstGroup',1)
- print "Again, with weights and restricted to the given indices:"
- print mesh.getVertsFromGroup('firstGroup',1,[1,2,3,4,5,6])
-
- @type group: string
- @param group: the group name.
- @type weightsFlag: bool
- @param weightsFlag: if 1, the weight is returned along with the index.
- @type vertList: list of ints
- @param vertList: if given, only those vertex points that are both in the
- list and group passed in are returned.
- """
-
- def renameVertGroup(groupName, newName):
- """
- Renames a vertex group.
- @type groupName: string
- @param groupName: the vertex group name to be renamed.
- @type newName: string
- @param newName: the name to replace the old name.
- """
-
- def getVertGroupNames():
- """
- Return a list of all vertex group names.
- @rtype: list of strings
- @return: returns a list of strings representing all vertex group
- associated with the mesh's object
- """
-
- def getMaxSmoothAngle():
- """
- Get the max angle for auto smoothing.
- Note: This will only affect smoothing generated at render time.
- Smoothing can also be set per face which is visible in Blenders 3D View.
- @return: The value in degrees.
- """
-
- def setMaxSmoothAngle(angle):
- """
- Set the max angle for auto smoothing.
- @type angle: int
- @param angle: The new value in degrees -- it's clamped to [1, 80].
- """
-
- def getSubDivLevels():
- """
- Get the mesh subdivision levels for realtime display and rendering.
- @return: list of ints: [display, render].
- """
-
- def setSubDivLevels(subdiv):
- """
- Set the mesh subdivision levels for realtime display and rendering.
- @type subdiv: list of 2 ints
- @param subdiv: new subdiv levels: [display, render]. Both are clamped to
- lie in the range [1, 6].
- """
-
-
diff --git a/source/blender/python/api2_2x/doc/Noise.py b/source/blender/python/api2_2x/doc/Noise.py
deleted file mode 100644
index 5a246031fd0..00000000000
--- a/source/blender/python/api2_2x/doc/Noise.py
+++ /dev/null
@@ -1,300 +0,0 @@
-# Blender.Noise submodule
-
-"""
-The Blender.Noise submodule.
-
-Noise and Turbulence
-====================
-
-This module can be used to generate noise of various types. This can be used
-for terrain generation, to create textures, make animations more 'animated',
-object deformation, etc. As an example, this code segment when scriptlinked
-to a framechanged event, will make the camera sway randomly about, by changing
-parameters this can look like anything from an earthquake to a very nervous or
-maybe even drunk cameraman... (the camera needs an ipo with at least one Loc &
-Rot key for this to work!):
-
-Example::
- from Blender import Get, Scene, Noise
- ####################################################
- # This controls jitter speed
- sl = 0.025
- # This controls the amount of position jitter
- sp = 0.1
- # This controls the amount of rotation jitter
- sr = 0.25
- ####################################################
-
- time = Get('curtime')
- ob = Scene.GetCurrent().getCurrentCamera()
- ps = (sl*time, sl*time, sl*time)
- # To add jitter only when the camera moves, use this next line instead
- #ps = (sl*ob.LocX, sl*ob.LocY, sl*ob.LocZ)
- rv = Noise.vTurbulence(ps, 3, 0, Noise.NoiseTypes.NEWPERLIN)
- ob.dloc = (sp*rv[0], sp*rv[1], sp*rv[2])
- ob.drot = (sr*rv[0], sr*rv[1], sr*rv[2])
-
-@type NoiseTypes: readonly dictionary
-@var NoiseTypes: The available noise types.
- - BLENDER
- - STDPERLIN
- - NEWPERLIN
- - VORONOI_F1
- - VORONOI_F2
- - VORONOI_F3
- - VORONOI_F4
- - VORONOI_F2F1
- - VORONOI_CRACKLE
- - CELLNOISE
-
-@type DistanceMetrics: readonly dictionary
-@var DistanceMetrics: The available distance metrics values for Voronoi.
- - DISTANCE
- - DISTANCE_SQUARED
- - MANHATTAN
- - CHEBYCHEV
- - MINKOVSKY_HALF
- - MINKOVSKY_FOUR
- - MINKOVISKY
-"""
-
-NoiseTypes = {'BLENDER':0, 'STDPERLIN':1}
-
-DistanceMetrics = {'DISTANCE':0}
-
-def random ():
- """
- Returns a random floating point number."
- @rtype: float
- @return: a random number in [0, 1).
- """
-
-def randuvec ():
- """
- Returns a random unit vector.
- @rtype: 3-float list
- @return: a list of three floats.
- """
-
-def setRandomSeed (seed):
- """
- Initializes the random number generator.
- @type seed: int
- @param seed: the seed for the random number generator. If seed = 0, the
- current time will be used as seed, instead.
- """
-
-def noise (xyz, type = NoiseTypes['STDPERLIN']):
- """
- Returns general noise of the optional specified type.
- @type xyz: tuple of 3 floats
- @param xyz: (x,y,z) float values.
- @type type: int
- @param type: the type of noise to return. See L{NoiseTypes}.
- @rtype: float
- @return: the generated noise value.
- """
-
-def vNoise (xyz, type = NoiseTypes['STDPERLIN']):
- """
- Returns noise vector of the optional specified type.
- @type xyz: tuple of 3 floats
- @param xyz: (x,y,z) float values.
- @type type: int
- @param type: the type of noise to return. See L{NoiseTypes}.
- @rtype: 3-float list
- @return: the generated noise vector.
- """
-
-def turbulence (xyz, octaves, hard, basis = NoiseTypes['STDPERLIN'],
- ampscale = 0.5, freqscale = 2.0):
- """
- Returns general turbulence value using the optional specified noise 'basis'
- function.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @type octaves: int
- @param octaves: number of noise values added.
- @type hard: bool
- @param hard: noise hardness: 0 - soft noise; 1 - hard noise. (Returned value
- is always positive.)
- @type basis: int
- @param basis: type of noise used for turbulence, see L{NoiseTypes}.
- @type ampscale: float
- @param ampscale: amplitude scale value of the noise frequencies added.
- @type freqscale: float
- @param freqscale: frequency scale factor.
- @rtype: float
- @return: the generated turbulence value.
- """
-
-def vTurbulence (xyz, octaves, hard, basis = NoiseTypes['STDPERLIN'],
- ampscale = 0.5, freqscale = 2.0):
- """
- Returns general turbulence vector using the optional specified noise basis
-function.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @type octaves: int
- @param octaves: number of noise values added.
- @type hard: bool
- @param hard: noise hardness: 0 - soft noise; 1 - hard noise. (Returned
- vector is always positive.)
- @type basis: int
- @param basis: type of noise used for turbulence, see L{NoiseTypes}.
- @type ampscale: float
- @param ampscale: amplitude scale value of the noise frequencies added.
- @type freqscale: float
- @param freqscale: frequency scale factor.
- @rtype: 3-float list
- @return: the generated turbulence vector.
- """
-
-def fBm (xyz, H, lacunarity, octaves, basis = NoiseTypes['STDPERLIN']):
- """
- Returns Fractal Brownian Motion noise value (fBm).
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @type H: float
- @param H: the fractal increment parameter.
- @type lacunarity: float
- @param lacunarity: the gap between successive frequencies.
- @type octaves: float
- @param octaves: the number of frequencies in the fBm.
- @type basis: int
- @param basis: type of noise used for the turbulence, see L{NoiseTypes}.
- @rtype: float
- @return: the generated noise value.
- """
-
-def multiFractal (xyz, H, lacunarity, octaves, basis = NoiseTypes['STDPERLIN']):
- """
- Returns Multifractal noise value.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @type H: float
- @param H: the highest fractal dimension.
- @type lacunarity: float
- @param lacunarity: the gap between successive frequencies.
- @type octaves: float
- @param octaves: the number of frequencies in the fBm.
- @type basis: int
- @param basis: type of noise used for the turbulence, see L{NoiseTypes}.
- @rtype: float
- @return: the generated noise value.
- """
-
-def vlNoise (xyz, distortion, type1 = NoiseTypes['STDPERLIN'],
- type2 = NoiseTypes['STDPERLIN']):
- """
- Returns Variable Lacunarity Noise value, a distorted variety of noise.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @type distortion: float
- @param distortion: the amount of distortion.
- @type type1: int
- @type type2: int
- @param type1: sets the noise type to distort.
- @param type2: sets the noise type used for the distortion.
- @rtype: float
- @return: the generated noise value.
- """
-
-def heteroTerrain (xyz, H, lacunarity, octaves, offset,
- basis = NoiseTypes['STDPERLIN']):
- """
- Returns Heterogeneous Terrain value.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @type H: float
- @param H: fractal dimension of the roughest areas.
- @type lacunarity: float
- @param lacunarity: gap between successive frequencies.
- @type octaves: float
- @param octaves: number of frequencies in the fBm.
- @type offset: float
- @param offset: it raises the terrain from 'sea level'.
- @type basis: int
- @param basis: noise basis determines the type of noise used for the
- turbulence, see L{NoiseTypes}.
- @rtype: float
- @return: the generated value.
- """
-
-def hybridMFractal (xyz, H, lacunarity, octaves, offset, gain,
- basis = NoiseTypes['STDPERLIN']):
- """
- Returns Hybrid Multifractal value.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @type H: float
- @param H: fractal dimension of the roughest areas.
- @type lacunarity: float
- @param lacunarity: gap between successive frequencies.
- @type octaves: float
- @param octaves: number of frequencies in the fBm.
- @type offset: float
- @param offset: it raises the terrain from 'sea level'.
- @type gain: float
- @param gain: scale factor.
- @type basis: int
- @param basis: noise basis determines the type of noise used for the
- turbulence, see L{NoiseTypes}.
- @rtype: float
- @return: the generated value.
- """
-
-def ridgedMFractal (xyz, H, lacunarity, octaves, offset, gain,
- basis = NoiseTypes['STDPERLIN']):
- """
- Returns Ridged Multifractal value.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @type H: float
- @param H: fractal dimension of the roughest areas.
- @type lacunarity: float
- @param lacunarity: gap between successive frequencies.
- @type octaves: float
- @param octaves: number of frequencies in the fBm.
- @type offset: float
- @param offset: it raises the terrain from 'sea level'.
- @type gain: float
- @param gain: scale factor.
- @type basis: int
- @param basis: noise basis determines the type of noise used for the
- turbulence, see L{NoiseTypes}.
- @rtype: float
- @return: the generated value.
- """
-
-def voronoi(xyz, distance_metric = DistanceMetrics['DISTANCE'], exponent = 2.5):
- """
- Returns Voronoi diagrams-related data.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @type distance_metric: int
- @param distance_metric: see L{DistanceMetrics}
- @type exponent: float
- @param exponent: only used with MINKOVSKY, default is 2.5.
- @rtype: list
- @return: a list containing a list of distances in order of closest feature,
- and a list containing the positions of the four closest features.
- """
-
-def cellNoise (xyz):
- """
- Returns cellnoise.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @rtype: float
- @return: the generated value.
- """
-
-def cellNoiseV (xyz):
- """
- Returns cellnoise vector/point/color.
- @type xyz: 3-float tuple
- @param xyz: (x,y,z) float values.
- @rtype: 3-float list
- @return: the generated vector.
- """
diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py
deleted file mode 100644
index 4228f6de1a8..00000000000
--- a/source/blender/python/api2_2x/doc/Object.py
+++ /dev/null
@@ -1,1757 +0,0 @@
-# Blender.Object module and the Object PyType object
-
-"""
-The Blender.Object submodule
-
-B{New}:
- - Addition of attributes for particle deflection, softbodies, and
- rigidbodies.
- - Objects now increment the Blender user count when they are created and
- decremented it when they are destroyed. This means Python scripts can
- keep the object "alive" if it is deleted in the Blender GUI.
- - L{Object.getData} now accepts two optional bool keyword argument to
- define (1) if the user wants the data object or just its name
- and (2) if a mesh object should use NMesh or Mesh.
- - L{Object.clearScriptLinks} accepts a parameter now.
- - Object attributes: renamed Layer to L{Layers<Object.Object.Layers>} and
- added the easier L{layers<Object.Object.layers>}. The old form "Layer"
- will continue to work.
-
-
-Object
-======
-
-This module provides access to the B{Objects} in Blender.
-
-Example::
-
- import Blender
- scn = Blender.Scene.GetCurrent() # get the current scene
- cam = Blender.Camera.New('ortho') # make ortho camera data object
- ob = scn.objects.new(cam) # make a new object in this scene using the camera data
- ob.setLocation (0.0, -5.0, 1.0) # position the object in the scene
-
- Blender.Redraw() # redraw the scene to show the updates.
-
-@type DrawModes: readonly dictionary
-@var DrawModes: Constant dict used for with L{Object.drawMode} bitfield
- attribute. Values can be ORed together. Individual bits can also
- be set/cleared with boolean attributes.
- - AXIS: Enable display of active object's center and axis.
- - TEXSPACE: Enable display of active object's texture space.
- - NAME: Enable display of active object's name.
- - WIRE: Enable the active object's wireframe over solid drawing.
- - XRAY: Enable drawing the active object in front of others.
- - TRANSP: Enable transparent materials for the active object (mesh only).
-
-@type DrawTypes: readonly dictionary
-@var DrawTypes: Constant dict used for with L{Object.drawType} attribute.
- Only one type can be selected at a time.
- - BOUNDBOX: Only draw object with bounding box
- - WIRE: Draw object in wireframe
- - SOLID: Draw object in solid
- - SHADED: Draw object with shaded or textured
-
-@type ParentTypes: readonly dictionary
-@var ParentTypes: Constant dict used for with L{Object.parentType} attribute.
- - OBJECT: Object parent type.
- - CURVE: Curve deform parent type.
- - LATTICE: Lattice deform parent type. Note: This is the same as ARMATURE, 2.43 was released with LATTICE as an invalid value.
- - ARMATURE: Armature deform parent type.
- - VERT1: 1 mesh vert parent type.
- - VERT3: 1 mesh verts parent type.
- - BONE: Armature bone parent type.
-
-
-@type ProtectFlags: readonly dictionary
-@var ProtectFlags: Constant dict used for with L{Object.protectFlags} attribute.
- Values can be ORed together.
- - LOCX, LOCY, LOCZ: lock x, y or z location individually
- - ROTX, ROTY, ROTZ: lock x, y or z rotation individually
- - SCALEX, SCALEY, SCALEZ: lock x, y or z scale individually
- - LOC, ROT, SCALE: lock all 3 attributes for location, rotation or scale
-
-@type PITypes: readonly dictionary
-@var PITypes: Constant dict used for with L{Object.piType} attribute.
- Only one type can be selected at a time.
- - NONE: No force influence on particles
- - FORCE: Object center attracts or repels particles ("Spherical")
- - VORTEX: Particles swirl around Z-axis of the object
- - WIND: Constant force applied in direction of object Z axis
- - GUIDE: Use a Curve Path to guide particles
-
-@type RBFlags: readonly dictionary
-@var RBFlags: Constant dict used for with L{Object.rbFlags} attribute.
- Values can be ORed together.
- - SECTOR: All game elements should be in the Sector boundbox
- - PROP: An Object fixed within a sector
- - BOUNDS: Specify a bounds object for physics
- - ACTOR: Enables objects that are evaluated by the engine
- - DYNAMIC: Enables motion defined by laws of physics (requires ACTOR)
- - GHOST: Enable objects that don't restitute collisions (requires ACTOR)
- - MAINACTOR: Enables MainActor (requires ACTOR)
- - RIGIDBODY: Enable rolling physics (requires ACTOR, DYNAMIC)
- - COLLISION_RESPONSE: Disable auto (de)activation (requires ACTOR, DYNAMIC)
- - USEFH: Use Fh settings in Materials (requires ACTOR, DYNAMIC)
- - ROTFH: Use face normal to rotate Object (requires ACTOR, DYNAMIC)
- - ANISOTROPIC: Enable anisotropic friction (requires ACTOR, DYNAMIC)
- - CHILD: reserved
-
-@type IpoKeyTypes: readonly dictionary
-@var IpoKeyTypes: Constant dict used for with L{Object.insertIpoKey} attribute.
- Values can be ORed together.
- - LOC
- - ROT
- - SIZE
- - LOCROT
- - LOCROTSIZE
- - LAYER
- - PI_STRENGTH
- - PI_FALLOFF
- - PI_SURFACEDAMP
- - PI_RANDOMDAMP
- - PI_PERM
-
-@type RBShapes: readonly dictionary
-@var RBShapes: Constant dict used for with L{Object.rbShapeBoundType}
- attribute. Only one type can be selected at a time. Values are
- BOX, SPHERE, CYLINDER, CONE, and POLYHEDERON
-
-"""
-
-def New (type, name='type'):
- """
- Creates a new Object. Deprecated; instead use Scene.objects.new().
- @type type: string
- @param type: The Object type: 'Armature', 'Camera', 'Curve', 'Lamp', 'Lattice',
- 'Mball', 'Mesh', 'Surf' or 'Empty'.
- @type name: string
- @param name: The name of the object. By default, the name will be the same
- as the object type.
- If the name is already in use, this new object will have a number at the end of the name.
- @return: The created Object.
-
- I{B{Example:}}
-
- The example below creates a new Lamp object and puts it at the default
- location (0, 0, 0) in the current scene::
- import Blender
-
- object = Blender.Object.New('Lamp')
- lamp = Blender.Lamp.New('Spot')
- object.link(lamp)
- sce = Blender.Scene.GetCurrent()
- sce.link(object)
-
- Blender.Redraw()
- @Note: if an object is created but is not linked to object data, and the
- object is not linked to a scene, it will be deleted when the Python
- object is deallocated. This is because Blender does not allow objects
- to exist without object data unless they are Empty objects. Scene.link()
- will automatically create object data for an object if it has none.
- """
-
-def Get (name = None):
- """
- Get the Object from Blender.
- @type name: string
- @param name: The name of the requested Object.
- @return: It depends on the 'name' parameter:
- - (name): The Object with the given name;
- - (): A list with all Objects in the current scene.
-
- I{B{Example 1:}}
-
- The example below works on the default scene. The script returns the plane object and prints the location of the plane::
- import Blender
-
- object = Blender.Object.Get ('plane')
- print object.getLocation()
-
- I{B{Example 2:}}
-
- The example below works on the default scene. The script returns all objects
- in the scene and prints the list of object names::
- import Blender
-
- objects = Blender.Object.Get ()
- print objects
- @note: Get will return objects from all scenes.
- Most user tools should only operate on objects from the current scene - Blender.Scene.GetCurrent().getChildren()
- """
-
-def GetSelected ():
- """
- Get the user selection. If no objects are selected, an empty list will be returned.
-
- @return: A list of all selected Objects in the current scene.
-
- I{B{Example:}}
-
- The example below works on the default scene. Select one or more objects and
- the script will print the selected objects::
- import Blender
-
- objects = Blender.Object.GetSelected()
- print objects
- @note: The active object will always be the first object in the list (if selected).
- @note: The user selection is made up of selected objects from Blender's current scene only.
- @note: The user selection is limited to objects on visible layers;
- if the user's last active 3d view is in localview then the selection will be limited to the objects in that localview.
- """
-
-
-def Duplicate (mesh=0, surface=0, curve=0, text=0, metaball=0, armature=0, lamp=0, material=0, texture=0, ipo=0):
- """
- Duplicate selected objects on visible layers from Blenders current scene,
- de-selecting the currently visible, selected objects and making a copy where all new objects are selected.
- By default no data linked to the object is duplicated; use the keyword arguments to change this.
- L{Object.GetSelected()<GetSelected>} will return the list of objects resulting from duplication.
-
- B{Note}: This command will raise an error if used from the command line (background mode) because it uses the 3D view context.
-
- @type mesh: bool
- @param mesh: When non-zero, mesh object data will be duplicated with the objects.
- @type surface: bool
- @param surface: When non-zero, surface object data will be duplicated with the objects.
- @type curve: bool
- @param curve: When non-zero, curve object data will be duplicated with the objects.
- @type text: bool
- @param text: When non-zero, text object data will be duplicated with the objects.
- @type metaball: bool
- @param metaball: When non-zero, metaball object data will be duplicated with the objects.
- @type armature: bool
- @param armature: When non-zero, armature object data will be duplicated with the objects.
- @type lamp: bool
- @param lamp: When non-zero, lamp object data will be duplicated with the objects.
- @type material: bool
- @param material: When non-zero, materials used by the object or its object data will be duplicated with the objects.
- @type texture: bool
- @param texture: When non-zero, texture data used by the object's materials will be duplicated with the objects.
- @type ipo: bool
- @param ipo: When non-zero, Ipo data linked to the object will be duplicated with the objects.
-
- I{B{Example:}}
-
- The example below creates duplicates the active object 10 times
- and moves each object 1.0 on the X axis::
- import Blender
-
- scn = Scene.GetCurrent()
- ob_act = scn.objects.active
-
- # Unselect all
- scn.objects.selected = []
- ob_act.sel = 1
-
- for x in xrange(10):
- Blender.Object.Duplicate() # Duplicate linked
- ob_act = scn.objects.active
- ob_act.LocX += 1
- Blender.Redraw()
- """
-
-from IDProp import IDGroup, IDArray
-class Object:
- """
- The Object object
- =================
- This object gives access to generic data from all objects in Blender.
-
- B{Note}:
- When dealing with properties and functions such as LocX/RotY/getLocation(), getSize() and getEuler(),
- keep in mind that these transformation properties are relative to the object's parent (if any).
-
- To get these values in worldspace (taking into account vertex parents, constraints, etc.)
- pass the argument 'worldspace' to these functions.
-
- @ivar restrictDisplay: Don't display this object in the 3D view: disabled by default, use the outliner to toggle.
- @type restrictDisplay: bool
- @ivar restrictSelect: Don't select this object in the 3D view: disabled by default, use the outliner to toggle.
- @type restrictSelect: bool
- @ivar restrictRender: Don't render this object: disabled by default, use the outliner to toggle.
- @type restrictRender: bool
- @ivar LocX: The X location coordinate of the object.
- @type LocX: float
- @ivar LocY: The Y location coordinate of the object.
- @type LocY: float
- @ivar LocZ: The Z location coordinate of the object.
- @type LocZ: float
- @ivar loc: The (X,Y,Z) location coordinates of the object.
- @type loc: tuple of 3 floats
- @ivar dLocX: The delta X location coordinate of the object.
- This variable applies to IPO Objects only.
- @type dLocX: float
- @ivar dLocY: The delta Y location coordinate of the object.
- This variable applies to IPO Objects only.
- @type dLocY: float
- @ivar dLocZ: The delta Z location coordinate of the object.
- This variable applies to IPO Objects only.
- @type dLocZ: float
- @ivar dloc: The delta (X,Y,Z) location coordinates of the object (vector).
- This variable applies to IPO Objects only.
- @type dloc: tuple of 3 floats
- @ivar RotX: The X rotation angle (in radians) of the object.
- @type RotX: float
- @ivar RotY: The Y rotation angle (in radians) of the object.
- @type RotY: float
- @ivar RotZ: The Z rotation angle (in radians) of the object.
- @type RotZ: float
- @ivar rot: The (X,Y,Z) rotation angles (in radians) of the object.
- @type rot: euler (Py_WRAPPED)
- @ivar dRotX: The delta X rotation angle (in radians) of the object.
- This variable applies to IPO Objects only.
- @type dRotX: float
- @ivar dRotY: The delta Y rotation angle (in radians) of the object.
- This variable applies to IPO Objects only.
- @type dRotY: float
- @ivar dRotZ: The delta Z rotation angle (in radians) of the object.
- This variable applies to IPO Objects only.
- @type dRotZ: float
- @ivar drot: The delta (X,Y,Z) rotation angles (in radians) of the object.
- This variable applies to IPO Objects only.
- @type drot: tuple of 3 floats
- @ivar SizeX: The X size of the object.
- @type SizeX: float
- @ivar SizeY: The Y size of the object.
- @type SizeY: float
- @ivar SizeZ: The Z size of the object.
- @type SizeZ: float
- @ivar size: The (X,Y,Z) size of the object.
- @type size: tuple of 3 floats
- @ivar dSizeX: The delta X size of the object.
- @type dSizeX: float
- @ivar dSizeY: The delta Y size of the object.
- @type dSizeY: float
- @ivar dSizeZ: The delta Z size of the object.
- @type dSizeZ: float
- @ivar dsize: The delta (X,Y,Z) size of the object.
- @type dsize: tuple of 3 floats
- @ivar Layers: The object layers (also check the newer attribute
- L{layers<layers>}). This value is a bitmask with at
- least one position set for the 20 possible layers starting from the low
- order bit. The easiest way to deal with these values in in hexadecimal
- notation.
- Example::
- ob.Layer = 0x04 # sets layer 3 ( bit pattern 0100 )
- After setting the Layer value, call Blender.Redraw( -1 ) to update
- the interface.
- @type Layers: integer (bitmask)
- @type layers: list of integers
- @ivar layers: The layers this object is visible in (also check the older
- attribute L{Layers<Layers>}). This returns a list of
- integers in the range [1, 20], each number representing the respective
- layer. Setting is done by passing a list of ints or an empty list for
- no layers.
- Example::
- ob.layers = [] # object won't be visible
- ob.layers = [1, 4] # object visible only in layers 1 and 4
- ls = o.layers
- ls.append([10])
- o.layers = ls
- print ob.layers # will print: [1, 4, 10]
- B{Note}: changes will only be visible after the screen (at least
- the 3d View and Buttons windows) is redrawn.
- @ivar parent: The parent object of the object (if defined). Read-only.
- @type parent: Object or None
- @ivar data: The Datablock object linked to this object. Read-only.
- @type data: varies
- @ivar ipo: Contains the Ipo if one is assigned to the object, B{None}
- otherwise. Setting to B{None} clears the current Ipo.
- @type ipo: Ipo
- @ivar mat: The matrix of the object in world space (absolute, takes vertex parents, tracking
- and Ipos into account). Read-only.
- @type mat: Matrix
- @ivar matrix: Same as L{mat}. Read-only.
- @type matrix: Matrix
- @ivar matrixLocal: The matrix of the object relative to its parent; if there is no parent,
- returns the world matrix (L{matrixWorld<Object.Object.matrixWorld>}).
- @type matrixLocal: Matrix
- @ivar matrixParentInverse: The inverse if the parents local matrix, set when the objects parent is set (wrapped).
- @type matrixParentInverse: Matrix
- @ivar matrixOldWorld: Old-type worldspace matrix (prior to Blender 2.34).
- Read-only.
- @type matrixOldWorld: Matrix
- @ivar matrixWorld: Same as L{mat}. Read-only.
- @type matrixWorld: Matrix
- @ivar colbits: The Material usage mask. A set bit #n means: the Material
- #n in the Object's material list is used. Otherwise, the Material #n
- of the Objects Data material list is displayed.
- Example::
- object.colbits = (1<<0) + (1<<5) # use mesh materials 0 (1<<0) and 5 (1<<5)
- # use object materials for all others
- @ivar sel: The selection state of the object in the current scene.
- True is selected, False is unselected. Setting makes the object active.
- @type sel: boolean
- @ivar effects: The list of particle effects associated with the object.
- Read-only.
- @type effects: list of Effect objects
- @ivar parentbonename: The string name of the parent bone (if defined).
- This can be set to another bone in the armature if the object already has a bone parent.
- @type parentbonename: string or None
- @ivar protectFlags: The "transform locking" bitfield flags for the object.
- See L{ProtectFlags} const dict for values.
- @type protectFlags: int
- @ivar DupGroup: The DupliGroup Animation Property. Assign a group to
- DupGroup to make this object an instance of that group.
- This does not enable or disable the DupliGroup option, for that use
- L{enableDupGroup}.
- The attribute returns None when this object does not have a dupliGroup,
- and setting the attrbute to None deletes the object from the group.
- @type DupGroup: Group or None
- @ivar DupObjects: The Dupli object instances. Read-only.
- Returns of list of tuples for object duplicated
- by dupliframe, dupliverts dupligroups and other animation properties.
- The first tuple item is the original object that is duplicated,
- the second is the 4x4 worldspace dupli-matrix.
- Example::
- import Blender
- from Blender import Object, Scene, Mathutils
-
- ob= Object.Get('Cube')
- dupe_obs= ob.DupObjects
- scn= Scene.GetCurrent()
- for dupe_ob, dupe_matrix in dupe_obs:
- print dupe_ob.name
- empty_ob = scn.objects.new('Empty')
- empty_ob.setMatrix(dupe_matrix)
- Blender.Redraw()
- @type DupObjects: list of tuples containing (object, matrix)
- @ivar enableNLAOverride: Whether the object uses NLA or active Action for animation.
- @type enableNLAOverride: boolean
- @ivar enableDupVerts: The DupliVerts status of the object.
- Does not indicate that this object has any dupliVerts,
- (as returned by L{DupObjects}) just that dupliVerts are enabled.
- @type enableDupVerts: boolean
- @ivar enableDupFaces: The DupliFaces status of the object.
- Does not indicate that this object has any dupliFaces,
- (as returned by L{DupObjects}) just that dupliFaces are enabled.
- @type enableDupFaces: boolean
- @ivar enableDupFacesScale: The DupliFacesScale status of the object.
- @type enableDupFacesScale: boolean
- @ivar dupFacesScaleFac: Scale factor for dupliface instance, 1.0 by default.
- @type dupFacesScaleFac: float
- @ivar enableDupFrames: The DupliFrames status of the object.
- Does not indicate that this object has any dupliFrames,
- (as returned by L{DupObjects}) just that dupliFrames are enabled.
- @type enableDupFrames: boolean
- @ivar enableDupGroup: The DupliGroup status of the object.
- Set True to make this object an instance of the object's L{DupGroup},
- and set L{DupGroup} to a group for this to take effect,
- Use L{DupObjects} to get the object data from this instance.
- @type enableDupGroup: boolean
- @ivar enableDupRot: The DupliRot status of the object.
- Use with L{enableDupVerts} to rotate each instance
- by the vertex normal.
- @type enableDupRot: boolean
- @ivar enableDupNoSpeed: The DupliNoSpeed status of the object.
- Use with L{enableDupFrames} to ignore dupliFrame speed.
- @type enableDupNoSpeed: boolean
- @ivar DupSta: The DupliFrame starting frame. Use with L{enableDupFrames}.
- Value clamped to [1,32767].
- @type DupSta: int
- @ivar DupEnd: The DupliFrame end frame. Use with L{enableDupFrames}.
- Value clamped to [1,32767].
- @type DupEnd: int
- @ivar DupOn: The DupliFrames in succession between DupOff frames.
- Value is clamped to [1,1500].
- Use with L{enableDupFrames} and L{DupOff} > 0.
- @type DupOn: int
- @ivar DupOff: The DupliFrame removal of every Nth frame for this object.
- Use with L{enableDupFrames}. Value is clamped to [0,1500].
- @type DupOff: int
- @ivar passIndex: Index # for the IndexOB render pass.
- Value is clamped to [0,1000].
- @type passIndex: int
- @ivar activeMaterial: The active material index for this object.
-
- The active index is used to select the material to edit in the material buttons,
- new data created will also use the active material.
-
- Value is clamped to [1,len(ob.materials)]. - [0,0] when there is no materials applied to the object.
- @type activeMaterial: int
- @ivar activeShape: The active shape key index for this object.
-
- The active index is used to select the material to edit in the material buttons,
- new data created will also use the active material.
-
- Value is clamped to [1,len(ob.data.key.blocks)]. - [0,0] when there are no keys.
-
- @type activeShape: int
-
- @ivar pinShape: If True, only the activeShape will be displayed.
- @type pinShape: bool
- @ivar drawSize: The size to display the Empty.
- Value clamped to [0.01,10.0].
- @type drawSize: float
- @ivar modifiers: The modifiers associated with the object.
- Example::
- # copy the active objects modifiers to all other visible selected objects
- from Blender import *
- scn = Scene.GetCurrent()
- ob_act = scn.objects.active
- for ob in scn.objects.context:
- # Cannot copy modifiers to an object of a different type
- if ob.type == ob_act.type:
- ob.modifiers = ob_act.modifiers
- @type modifiers: L{Modifier Sequence<Modifier.ModSeq>}
- @ivar constraints: a L{sequence<Constraint.Constraints>} of
- L{constraints<Constraint.Constraint>} for the object. Read-only.
- @type constraints: Constraint Sequence
- @ivar actionStrips: a L{sequence<NLA.ActionStrips>} of
- L{action strips<NLA.ActionStrip>} for the object. Read-only.
- @type actionStrips: BPy_ActionStrips
- @ivar action: The action associated with this object (if defined).
- @type action: L{Action<NLA.Action>} or None
- @ivar oopsLoc: Object's (X,Y) OOPs location. Returns None if object
- is not found in list.
- @type oopsLoc: tuple of 2 floats
- @ivar oopsSel: Object OOPs selection flag.
- @type oopsSel: boolean
- @ivar game_properties: The object's properties. Read-only.
- @type game_properties: list of Properties.
- @ivar timeOffset: The time offset of the object's animation.
- Value clamped to [-300000.0,300000.0].
- @type timeOffset: float
- @ivar track: The object's tracked object. B{None} is returned if no
- object is tracked. Also, assigning B{None} clear the tracked object.
- @type track: Object or None
- @ivar type: The object's type. Read-only.
- @type type: string
- @ivar boundingBox: The bounding box of this object. Read-only.
- @type boundingBox: list of 8 3D vectors
- @ivar drawType: The object's drawing type.
- See L{DrawTypes} constant dict for values.
- @type drawType: int
- @ivar parentType: The object's parent type. Read-only.
- See L{ParentTypes} constant dict for values.
- @type parentType: int
- @ivar axis: Enable display of active object's center and axis.
- Also see B{AXIS} bit in L{drawMode} attribute.
- @type axis: boolean
- @ivar texSpace: Enable display of active object's texture space.
- Also see B{TEXSPACE} bit in L{drawMode} attribute.
- @type texSpace: boolean
- @ivar nameMode: Enable display of active object's name.
- Also see B{NAME} bit in L{drawMode} attribute.
- @type nameMode: boolean
- @ivar wireMode: Enable the active object's wireframe over solid drawing.
- Also see B{WIRE} bit in L{drawMode} attribute.
- @type wireMode: boolean
- @ivar xRay: Enable drawing the active object in front of others.
- Also see B{XRAY} bit in L{drawMode} attribute.
- @type xRay: boolean
- @ivar transp: Enable transparent materials for the active object
- (mesh only). Also see B{TRANSP} bit in L{drawMode} attribute.
- @type transp: boolean
- @ivar drawMode: The object's drawing mode bitfield.
- See L{DrawModes} constant dict for values.
- @type drawMode: int
-
- @ivar piType: Type of particle interaction.
- See L{PITypes} constant dict for values.
- @type piType: int
- @ivar piFalloff: The particle interaction falloff power.
- Value clamped to [0.0,10.0].
- @type piFalloff: float
- @ivar piMaxDist: Max distance for the particle interaction field to work.
- Value clamped to [0.0,1000.0].
- @type piMaxDist: float
- @ivar piPermeability: Probability that a particle will pass through the
- mesh. Value clamped to [0.0,1.0].
- @type piPermeability: float
- @ivar piRandomDamp: Random variation of particle interaction damping.
- Value clamped to [0.0,1.0].
- @type piRandomDamp: float
- @ivar piSoftbodyDamp: Damping factor for softbody deflection.
- Value clamped to [0.0,1.0].
- @type piSoftbodyDamp: float
- @ivar piSoftbodyIThick: Inner face thickness for softbody deflection.
- Value clamped to [0.001,1.0].
- @type piSoftbodyIThick: float
- @ivar piSoftbodyOThick: Outer face thickness for softbody deflection.
- Value clamped to [0.001,1.0].
- @type piSoftbodyOThick: float
- @ivar piStrength: Particle interaction force field strength.
- Value clamped to [0.0,1000.0].
- @type piStrength: float
- @ivar piSurfaceDamp: Amount of damping during particle collision.
- Value clamped to [0.0,1.0].
- @type piSurfaceDamp: float
- @ivar piUseMaxDist: Use a maximum distance for the field to work.
- @type piUseMaxDist: boolean
-
- @ivar isSoftBody: True if object is a soft body. Read-only.
- @type isSoftBody: boolean
- @ivar SBDefaultGoal: Default softbody goal value, when no vertex group used.
- Value clamped to [0.0,1.0].
- @type SBDefaultGoal: float
- @ivar SBErrorLimit: Softbody Runge-Kutta ODE solver error limit (low values give more precision).
- Value clamped to [0.01,1.0].
- @type SBErrorLimit: float
- @ivar SBFriction: General media friction for softbody point movements.
- Value clamped to [0.0,10.0].
- @type SBFriction: float
- @ivar SBGoalFriction: Softbody goal (vertex target position) friction.
- Value clamped to [0.0,10.0].
- @type SBGoalFriction: float
- @ivar SBGoalSpring: Softbody goal (vertex target position) spring stiffness.
- Value clamped to [0.0,0.999].
- @type SBGoalSpring: float
- @ivar SBGrav: Apply gravitation to softbody point movement.
- Value clamped to [0.0,10.0].
- @type SBGrav: float
- @ivar SBInnerSpring: Softbody edge spring stiffness.
- Value clamped to [0.0,0.999].
- @type SBInnerSpring: float
- @ivar SBInnerSpringFrict: Softbody edge spring friction.
- Value clamped to [0.0,10.0].
- @type SBInnerSpringFrict: float
- @ivar SBMass: Softbody point mass (heavier is slower).
- Value clamped to [0.001,50.0].
- @type SBMass: float
- @ivar SBMaxGoal: Softbody goal maximum (vertex group weights scaled to
- match this range). Value clamped to [0.0,1.0].
- @type SBMaxGoal: float
- @ivar SBMinGoal: Softbody goal minimum (vertex group weights scaled to
- match this range). Value clamped to [0.0,1.0].
- @type SBMinGoal: float
- @ivar SBSpeed: Tweak timing for physics to control softbody frequency and
- speed. Value clamped to [0.0,10.0].
- @type SBSpeed: float
- @ivar SBStiffQuads: Softbody adds diagonal springs on 4-gons enabled.
- @type SBStiffQuads: boolean
- @ivar SBUseEdges: Softbody use edges as springs enabled.
- @type SBUseEdges: boolean
- @ivar SBUseGoal: Softbody forces for vertices to stick to animated position enabled.
- @type SBUseGoal: boolean
-
- @ivar rbFlags: Rigid body bitfield. See L{RBFlags} for valid values.
- @type rbFlags: int
- @ivar rbMass: Rigid body mass. Must be a positive value.
- @type rbMass: float
- @ivar rbRadius: Rigid body bounding sphere size. Must be a positive
- value.
- @type rbRadius: float
- @ivar rbShapeBoundType: Rigid body shape bound type. See L{RBShapes}
- const dict for values.
- @type rbShapeBoundType: int
- """
-
- def buildParts():
- """
- Recomputes the particle system. This method only applies to an Object of
- the type Effect.
- """
-
- def insertShapeKey():
- """
- Insert a Shape Key in the current object. It applies to Objects of
- the type Mesh, Lattice, or Curve.
- """
-
- def getPose():
- """
- Gets the current Pose of the object.
- @rtype: Pose object
- @return: the current pose object
- """
-
- def evaluatePose(framenumber):
- """
- Evaluates the Pose based on its currently bound action at a certain frame.
- @type framenumber: Int
- @param framenumber: The frame number to evaluate to.
- """
-
- def clearIpo():
- """
- Unlinks the ipo from this object.
- @return: True if there was an ipo linked or False otherwise.
- """
-
- def clrParent(mode = 0, fast = 0):
- """
- Clears parent object.
- @type mode: Integer
- @type fast: Integer
- @param mode: A mode flag. If mode flag is 2, then the object transform will
- be kept. Any other value, or no value at all will update the object
- transform.
- @param fast: If the value is 0, the scene hierarchy will not be updated. Any
- other value, or no value at all will update the scene hierarchy.
- """
-
- def getData(name_only=False, mesh=False):
- """
- Returns the Datablock object (Mesh, Lamp, Camera, etc.) linked to this
- Object. If the keyword parameter B{name_only} is True, only the Datablock
- name is returned as a string. It the object is of type Mesh, then the
- B{mesh} keyword can also be used; the data return is a Mesh object if
- True, otherwise it is an NMesh object (the default).
- The B{mesh} keyword is ignored for non-mesh objects.
- @type name_only: bool
- @param name_only: This is a keyword parameter. If True (or nonzero),
- only the name of the data object is returned.
- @type mesh: bool
- @param mesh: This is a keyword parameter. If True (or nonzero),
- a Mesh data object is returned.
- @rtype: specific Object type or string
- @return: Depends on the type of Datablock linked to the Object. If
- B{name_only} is True, it returns a string.
- @note: Mesh is faster than NMesh because Mesh is a thin wrapper.
- @note: This function is different from L{NMesh.GetRaw} and L{Mesh.Get}
- because it keeps a link to the original mesh, which is needed if you are
- dealing with Mesh weight groups.
- @note: Make sure the object you are getting the data from isn't in
- EditMode before calling this function; otherwise you'll get the data
- before entering EditMode. See L{Window.EditMode}.
- """
-
- def getParentBoneName():
- """
- Returns None, or the 'sub-name' of the parent (eg. Bone name)
- @return: string
- """
-
- def getDeltaLocation():
- """
- Returns the object's delta location in a list (x, y, z)
- @rtype: A vector triple
- @return: (x, y, z)
- """
-
- def getDrawMode():
- """
- Returns the object draw mode.
- @rtype: Integer
- @return: a sum of the following:
- - 2 - axis
- - 4 - texspace
- - 8 - drawname
- - 16 - drawimage
- - 32 - drawwire
- - 64 - xray
- """
-
- def getDrawType():
- """
- Returns the object draw type
- @rtype: Integer
- @return: One of the following:
- - 1 - Bounding box
- - 2 - Wire
- - 3 - Solid
- - 4 - Shaded
- - 5 - Textured
- """
-
- def getEuler(space):
- """
- @type space: string
- @param space: The desired space for the size:
- - localspace: (default) relative to the object's parent;
- - worldspace: absolute, taking vertex parents, tracking and
- Ipo's into account;
- Returns the object's localspace rotation as Euler rotation vector (rotX, rotY, rotZ). Angles are in radians.
- @rtype: Py_Euler
- @return: A python Euler. Data is wrapped when euler is present.
- """
-
- def getInverseMatrix():
- """
- Returns the object's inverse matrix.
- @rtype: Py_Matrix
- @return: A python matrix 4x4
- """
-
- def getIpo():
- """
- Returns the Ipo associated to this object or None if there's no linked ipo.
- @rtype: Ipo
- @return: the wrapped ipo or None.
- """
- def isSelected():
- """
- Returns the objects selection state in the current scene as a boolean value True or False.
- @rtype: Boolean
- @return: Selection state as True or False
- """
-
- def getLocation(space):
- """
- @type space: string
- @param space: The desired space for the location:
- - localspace: (default) relative to the object's parent;
- - worldspace: absolute, taking vertex parents, tracking and
- Ipo's into account;
- Returns the object's location (x, y, z).
- @return: (x, y, z)
-
- I{B{Example:}}
-
- The example below works on the default scene. It retrieves all objects in
- the scene and prints the name and location of each object::
- import Blender
-
- sce = Blender.Scene.GetCurrent()
-
- for ob in sce.objects:
- print obj.name
- print obj.loc
- @note: the worldspace location is the same as ob.matrixWorld[3][0:3]
- """
-
- def getAction():
- """
- Returns an action if one is associated with this object (only useful for armature types).
- @rtype: Py_Action
- @return: a python action.
- """
-
- def getMaterials(what = 0):
- """
- Returns a list of materials assigned to the object.
- @type what: int
- @param what: if nonzero, empty slots will be returned as None's instead
- of being ignored (default way). See L{NMesh.NMesh.getMaterials}.
- @rtype: list of Material Objects
- @return: list of Material Objects assigned to the object.
- """
-
- def getMatrix(space = 'worldspace'):
- """
- Returns the object matrix.
- @type space: string
- @param space: The desired matrix:
- - worldspace (default): absolute, taking vertex parents, tracking and
- Ipo's into account;
- - localspace: relative to the object's parent (returns worldspace
- matrix if the object doesn't have a parent);
- - old_worldspace: old behavior, prior to Blender 2.34, where eventual
- changes made by the script itself were not taken into account until
- a redraw happened, either called by the script or upon its exit.
- Returns the object matrix.
- @rtype: Py_Matrix (WRAPPED DATA)
- @return: a python 4x4 matrix object. Data is wrapped for 'worldspace'
- """
-
- def getName():
- """
- Returns the name of the object
- @return: The name of the object
-
- I{B{Example:}}
-
- The example below works on the default scene. It retrieves all objects in
- the scene and prints the name of each object::
- import Blender
-
- sce= Blender.Scene.GetCurrent()
-
- for ob in sce.objects:
- print ob.getName()
- """
-
- def getParent():
- """
- Returns the object's parent object.
- @rtype: Object
- @return: The parent object of the object. If not available, None will be
- returned.
- """
-
- def getSize(space):
- """
- @type space: string
- @param space: The desired space for the size:
- - localspace: (default) relative to the object's parent;
- - worldspace: absolute, taking vertex parents, tracking and
- Ipo's into account;
- Returns the object's size.
- @return: (SizeX, SizeY, SizeZ)
- @note: the worldspace size will not return negative (flipped) scale values.
- """
-
- def getParentBoneName():
- """
- Returns the object's parent object's sub name, or None.
- For objects parented to bones, this is the name of the bone.
- @rtype: String
- @return: The parent object sub-name of the object.
- If not available, None will be returned.
- """
-
- def getTimeOffset():
- """
- Returns the time offset of the object's animation.
- @return: TimeOffset
- """
-
- def getTracked():
- """
- Returns the object's tracked object.
- @rtype: Object
- @return: The tracked object of the object. If not available, None will be
- returned.
- """
-
- def getType():
- """
- Returns the type of the object in 'Armature', 'Camera', 'Curve', 'Lamp', 'Lattice',
- 'Mball', 'Mesh', 'Surf', 'Empty', 'Wave' (deprecated) or 'unknown' in exceptional cases.
-
- I{B{Example:}}
-
- The example below works on the default scene. It retrieves all objects in
- the scene and updates the location and rotation of the camera. When run,
- the camera will rotate 180 degrees and moved to the opposite side of the X
- axis. Note that the number 'pi' in the example is an approximation of the
- true number 'pi'. A better, less error-prone value of pi is math.pi from the python math module.::
- import Blender
-
- sce = Blender.Scene.GetCurrent()
-
- for obj in sce.objects:
- if obj.type == 'Camera':
- obj.LocY = -obj.LocY
- obj.RotZ = 3.141592 - obj.RotZ
-
- Blender.Redraw()
-
- @return: The type of object.
- @rtype: String
- """
-
- def insertIpoKey(keytype):
- """
- Inserts keytype values in object ipo at curframe.
- @type keytype: int
- @param keytype: A constant from L{IpoKeyTypes<Object.IpoKeyTypes>}
- @return: None
- """
-
- def link(datablock):
- """
- Links Object with ObData datablock provided in the argument. The data must match the
- Object's type, so you cannot link a Lamp to a Mesh type object.
- @type datablock: Blender ObData datablock
- @param datablock: A Blender datablock matching the objects type.
- """
-
- def makeParent(objects, noninverse = 0, fast = 0):
- """
- Makes the object the parent of the objects provided in the argument which
- must be a list of valid Objects.
- @type objects: Sequence of Blender Object
- @param objects: The children of the parent
- @type noninverse: Integer
- @param noninverse:
- 0 - make parent with inverse
- 1 - make parent without inverse
- @type fast: Integer
- @param fast:
- 0 - update scene hierarchy automatically
- 1 - don't update scene hierarchy (faster). In this case, you must
- explicitely update the Scene hierarchy.
- @warn: objects must first be linked to a scene before they can become
- parents of other objects. Calling this makeParent method for an
- unlinked object will result in an error.
- """
-
- def join(objects):
- """
- Uses the object as a base for all of the objects in the provided list to join into.
-
- @type objects: Sequence of Blender Object
- @param objects: A list of objects matching the object's type.
- @note: Objects in the list will not be removed from the scene.
- To avoid overlapping data you may want to remove them manually after joining.
- @note: Join modifies the base object's data in place so that
- other objects are joined into it. No new object or data is created.
- @note: Join will only work for object types Mesh, Armature, Curve and Surface;
- an excption will be raised if the object is not of these types.
- @note: Objects in the list will be ignored if they to not match the base object.
- @note: The base object must be in the current scene to be joined.
- @note: This function will not work in background mode (no user interface).
- @note: An error in the function input will raise a TypeError or AttributeError,
- otherwise an error in the data input will raise a RuntimeError.
- For situations where you don't have tight control on the data that is being joined,
- you should handle the RuntimeError error, letting the user know the data can't be joined.
- """
-
- def makeParentDeform(objects, noninverse = 0, fast = 0):
- """
- Makes the object the deformation parent of the objects provided in the argument
- which must be a list of valid Objects.
- The parent object must be a Curve or Armature.
- @type objects: Sequence of Blender Object
- @param objects: The children of the parent
- @type noninverse: Integer
- @param noninverse:
- 0 - make parent with inverse
- 1 - make parent without inverse
- @type fast: Integer
- @param fast:
- 0 - update scene hierarchy automatically
- 1 - don't update scene hierarchy (faster). In this case, you must
- explicitely update the Scene hierarchy.
- @warn: objects must first be linked to a scene before they can become
- parents of other objects. Calling this makeParent method for an
- unlinked object will result in an error.
- @warn: child objects must be of mesh type to deform correctly. Other object
- types will fall back to normal parenting silently.
- """
-
- def makeParentVertex(objects, indices, noninverse = 0, fast = 0):
- """
- Makes the object the vertex parent of the objects provided in the argument
- which must be a list of valid Objects.
- The parent object must be a Mesh, Curve or Surface.
- @type objects: Sequence of Blender Object
- @param objects: The children of the parent
- @type indices: Tuple of Integers
- @param indices: The indices of the vertices you want to parent to (1 or 3 values)
- @type noninverse: Integer
- @param noninverse:
- 0 - make parent with inverse
- 1 - make parent without inverse
- @type fast: Integer
- @param fast:
- 0 - update scene hierarchy automatically
- 1 - don't update scene hierarchy (faster). In this case, you must
- explicitely update the Scene hierarchy.
- @warn: objects must first be linked to a scene before they can become
- parents of other objects. Calling this makeParent method for an
- unlinked object will result in an error.
- """
- def makeParentBone(objects, bonename, noninverse = 0, fast = 0):
- """
- Makes one of the object's bones the parent of the objects provided in the argument
- which must be a list of valid objects. The parent object must be an Armature.
- @type objects: Sequence of Blender Object
- @param objects: The children of the parent
- @type bonename: string
- @param bonename: a valid bone name from the armature
- @type noninverse: integer
- @param noninverse:
- 0 - make parent with inverse
- 1 - make parent without inverse
- @type fast: integer
- @param fast:
- 0 - update scene hierarchy automatically
- 1 - don't update scene hierarchy (faster). In this case, you must
- explicitly update the Scene hierarchy.
- @warn: Objects must first be linked to a scene before they can become
- parents of other objects. Calling this method for an
- unlinked object will result in an exception.
- """
-
- def setDeltaLocation(delta_location):
- """
- Sets the object's delta location which must be a vector triple.
- @type delta_location: A vector triple
- @param delta_location: A vector triple (x, y, z) specifying the new
- location.
- """
-
- def setDrawMode(drawmode):
- """
- Sets the object's drawing mode. The drawing mode can be a mix of modes. To
- enable these, add up the values.
- @type drawmode: Integer
- @param drawmode: A sum of the following:
- - 2 - axis
- - 4 - texspace
- - 8 - drawname
- - 16 - drawimage
- - 32 - drawwire
- - 64 - xray
- """
-
- def setDrawType(drawtype):
- """
- Sets the object's drawing type.
- @type drawtype: Integer
- @param drawtype: One of the following:
- - 1 - Bounding box
- - 2 - Wire
- - 3 - Solid
- - 4 - Shaded
- - 5 - Textured
- """
-
- def setEuler(euler):
- """
- Sets the object's localspace rotation according to the specified Euler angles.
- @type euler: Py_Euler or a list of floats
- @param euler: a python Euler or x,y,z rotations as floats
- """
-
- def setIpo(ipo):
- """
- Links an ipo to this object.
- @type ipo: Blender Ipo
- @param ipo: an object type ipo.
- """
-
- def setLocation(x, y, z):
- """
- Sets the object's location relative to the parent object (if any).
- @type x: float
- @param x: The X coordinate of the new location.
- @type y: float
- @param y: The Y coordinate of the new location.
- @type z: float
- @param z: The Z coordinate of the new location.
- """
-
- def setMaterials(materials):
- """
- Sets the materials. The argument must be a list 16 items or less. Each
- list element is either a Material or None. Also see L{colbits}.
- @type materials: Materials list
- @param materials: A list of Blender material objects.
- @note: Materials are assigned to the object's data by default. Unless
- you know the material is applied to the object or are changing the
- object's L{colbits}, you need to look at the object data's materials.
- """
-
- def setMatrix(matrix):
- """
- Sets the object's matrix and updates its transformation. If the object
- has a parent, the matrix transform is relative to the parent.
- @type matrix: Py_Matrix 3x3 or 4x4
- @param matrix: a 3x3 or 4x4 Python matrix. If a 3x3 matrix is given,
- it is extended to a 4x4 matrix.
- @Note: This method is "bad": when called it changes the location,
- rotation and size attributes of the object (since Blender uses these
- values to calculate the object's transformation matrix). Ton is
- not happy having a method which "pretends" to do a matrix operation.
- In the future, this method may be replaced with other methods which
- make it easier for the user to determine the correct loc/rot/size values
- for necessary for the object.
- """
-
- def setName(name):
- """
- Sets the name of the object. A string longer than 20 characters will be shortened.
- @type name: String
- @param name: The new name for the object.
- """
-
- def setSize(x, y, z):
- """
- Sets the object's size, relative to the parent object (if any), clamped
- @type x: float
- @param x: The X size multiplier.
- @type y: float
- @param y: The Y size multiplier.
- @type z: float
- @param z: The Z size multiplier.
- """
-
- def setTimeOffset(timeOffset):
- """
- Sets the time offset of the object's animation.
- @type timeOffset: float
- @param timeOffset: The new time offset for the object's animation.
- """
-
- def shareFrom(object):
- """
- Link data of a specified argument with this object. This works only
- if both objects are of the same type.
- @type object: Blender Object
- @param object: A Blender Object of the same type.
- @note: This function is faster than using L{getData()} and setData()
- because it skips making a Python object from the object's data.
- """
-
- def select(boolean):
- """
- Sets the object's selection state in the current scene.
- setting the selection will make this object the active object of this scene.
- @type boolean: Integer
- @param boolean:
- - 0 - unselected
- - 1 - selected
- """
-
- def getBoundBox():
- """
- Returns the worldspace bounding box of this object. This works for meshes (out of
- edit mode) and curves.
- @rtype: list of 8 (x,y,z) float coordinate vectors (WRAPPED DATA)
- @return: The coordinates of the 8 corners of the bounding box. Data is wrapped when
- bounding box is present.
- """
-
- def makeDisplayList():
- """
- Updates this object's display list. Blender uses display lists to store
- already transformed data (like a mesh with its vertices already modified
- by coordinate transformations and armature deformation). If the object
- isn't modified, there's no need to recalculate this data. This method is
- here for the *few cases* where a script may need it, like when toggling
- the "SubSurf" mode for a mesh:
-
- Example::
- import Blender
-
- scn = Blender.Scene.GetCurrent()
- object = scn.objects.active
- object.modifiers.append(Blender.Modifier.Type.SUBSURF)
- object.makeDisplayList()
- Blender.Window.RedrawAll()
-
- If you try this example without the line to update the display list, the
- object will disappear from the screen until you press "SubSurf".
- @warn: If after running your script objects disappear from the screen or
- are not displayed correctly, try this method function. But if the script
- works properly without it, there's no reason to use it.
- """
-
- def getScriptLinks (event):
- """
- Get a list with this Object's script links of type 'event'.
- @type event: string
- @param event: "FrameChanged", "Redraw" or "Render".
- @rtype: list
- @return: a list with Blender L{Text} names (the script links of the given
- 'event' type) or None if there are no script links at all.
- """
-
- def clearScriptLinks (links = None):
- """
- Delete script links from this Object. If no list is specified, all
- script links are deleted.
- @type links: list of strings
- @param links: None (default) or a list of Blender L{Text} names.
- """
-
- def addScriptLink (text, event):
- """
- Add a new script link to this Object.
- @type text: string
- @param text: the name of an existing Blender L{Text}.
- @type event: string
- @param event: "FrameChanged", "Redraw" or "Render".
- """
-
- def makeTrack (tracked, fast = 0):
- """
- Make this Object track another.
- @type tracked: Blender Object
- @param tracked: the object to be tracked.
- @type fast: int (bool)
- @param fast: if zero, the scene hierarchy is updated automatically. If
- you set 'fast' to a nonzero value, don't forget to update the scene
- yourself (see L{Scene.Scene.update}).
- @note: you also need to clear the rotation (L{setEuler}) of this object
- if it was not (0,0,0) already.
- """
-
- def clearTrack (mode = 0, fast = 0):
- """
- Make this Object not track another anymore.
- @type mode: int (bool)
- @param mode: if nonzero the matrix transformation used for tracking is kept.
- @type fast: int (bool)
- @param fast: if zero, the scene hierarchy is updated automatically. If
- you set 'fast' to a nonzero value, don't forget to update the scene
- yourself (see L{Scene.Scene.update}).
- """
-
- def getAllProperties ():
- """
- Return a list of all game properties from this object.
- @rtype: PyList
- @return: List of Property objects.
- """
-
- def getProperty (name):
- """
- Return a game property from this object matching the name argument.
- @type name: string
- @param name: the name of the property to get.
- @rtype: Property object
- @return: The first property that matches name.
- """
-
- def addProperty (name_or_property, data, type):
- """
- Add or create a game property for an object. If called with only a
- property object, the property is assigned to the object. If called
- with a property name string and data object, a new property is
- created and added to the object.
- @type name_or_property: string or Property object
- @param name_or_property: the property name, or a property object.
- @type data: string, int or float
- @param data: Only valid when I{name_or_property} is a string.
- Value depends on what is passed in:
- - string: string type property
- - int: integer type property
- - float: float type property
- @type type: string (optional)
- @param type: Only valid when I{name_or_property} is a string.
- Can be the following:
- - 'BOOL'
- - 'INT'
- - 'FLOAT'
- - 'TIME'
- - 'STRING'
- @warn: If a type is not declared string data will
- become string type, int data will become int type
- and float data will become float type. Override type
- to declare bool type, and time type.
- @warn: A property object can be added only once to an object;
- you must remove the property from an object to add it elsewhere.
- """
-
- def removeProperty (property):
- """
- Remove a game property from an object.
- @type property: Property object or string
- @param property: Property object or property name to be removed.
- """
-
- def removeAllProperties():
- """
- Removes all game properties from an object.
- """
-
- def copyAllPropertiesTo (object):
- """
- Copies all game properties from one object to another.
- @type object: Object object
- @param object: Object that will receive the properties.
- """
-
- def getPIStregth():
- """
- Get the Object's Particle Interaction Strength.
- @rtype: float
- """
-
- def setPIStrength(strength):
- """
- Set the Object's Particle Interaction Strength.
- Values between -1000.0 to 1000.0
- @rtype: None
- @type strength: float
- @param strength: the Object's Particle Interaction New Strength.
- """
-
- def getPIFalloff():
- """
- Get the Object's Particle Interaction falloff.
- @rtype: float
- """
-
- def setPIFalloff(falloff):
- """
- Set the Object's Particle Interaction falloff.
- Values between 0 to 10.0
- @rtype: None
- @type falloff: float
- @param falloff: the Object's Particle Interaction New falloff.
- """
-
- def getPIMaxDist():
- """
- Get the Object's Particle Interaction MaxDist.
- @rtype: float
- """
-
- def setPIMaxDist(MaxDist):
- """
- Set the Object's Particle Interaction MaxDist.
- Values between 0 to 1000.0
- @rtype: None
- @type MaxDist: float
- @param MaxDist: the Object's Particle Interaction New MaxDist.
- """
-
- def getPIType():
- """
- Get the Object's Particle Interaction Type.
- @rtype: int
- """
-
- def setPIType(type):
- """
- Set the Object's Particle Interaction type.
- Use Module Constants
- - NONE
- - WIND
- - FORCE
- - VORTEX
- - MAGNET
- @rtype: None
- @type type: int
- @param type: the Object's Particle Interaction Type.
- """
-
- def getPIUseMaxDist():
- """
- Get the Object's Particle Interaction if using MaxDist.
- @rtype: int
- """
-
- def setPIUseMaxDist(status):
- """
- Set the Object's Particle Interaction MaxDist.
- 0 = Off, 1 = on
- @rtype: None
- @type status: int
- @param status: the new status
- """
-
- def getPIDeflection():
- """
- Get the Object's Particle Interaction Deflection Setting.
- @rtype: int
- """
-
- def setPIDeflection(status):
- """
- Set the Object's Particle Interaction Deflection Setting.
- 0 = Off, 1 = on
- @rtype: None
- @type status: int
- @param status: the new status
- """
-
- def getPIPermf():
- """
- Get the Object's Particle Interaction Permeability.
- @rtype: float
- """
-
- def setPIPerm(perm):
- """
- Set the Object's Particle Interaction Permeability.
- Values between 0 to 10.0
- @rtype: None
- @type perm: float
- @param perm: the Object's Particle Interaction New Permeability.
- """
-
- def getPIRandomDamp():
- """
- Get the Object's Particle Interaction RandomDamp.
- @rtype: float
- """
-
- def setPIRandomDamp(damp):
- """
- Set the Object's Particle Interaction RandomDamp.
- Values between 0 to 10.0
- @rtype: None
- @type damp: float
- @param damp: the Object's Particle Interaction New RandomDamp.
- """
-
- def getPISurfaceDamp():
- """
- Get the Object's Particle Interaction SurfaceDamp.
- @rtype: float
- """
-
- def setPISurfaceDamp(damp):
- """
- Set the Object's Particle Interaction SurfaceDamp.
- Values between 0 to 10.0
- @rtype: None
- @type damp: float
- @param damp: the Object's Particle Interaction New SurfaceDamp.
- """
-
- def getSBMass():
- """
- Get the Object's SoftBody Mass.
- @rtype: float
- """
-
- def setSBMass(mass):
- """
- Set the Object's SoftBody Mass.
- Values between 0 to 50.0
- @rtype: None
- @type mass: float
- @param mass: the Object's SoftBody New mass.
- """
-
- def getSBGravity():
- """
- Get the Object's SoftBody Gravity.
- @rtype: float
- """
-
- def setSBGravity(grav):
- """
- Set the Object's SoftBody Gravity.
- Values between 0 to 10.0
- @rtype: None
- @type grav: float
- @param grav: the Object's SoftBody New Gravity.
- """
-
- def getSBFriction():
- """
- Get the Object's SoftBody Friction.
- @rtype: float
- """
-
- def setSBFriction(frict):
- """
- Set the Object's SoftBody Friction.
- Values between 0 to 10.0
- @rtype: None
- @type frict: float
- @param frict: the Object's SoftBody New Friction.
- """
-
- def getSBErrorLimit():
- """
- Get the Object's SoftBody ErrorLimit.
- @rtype: float
- """
-
- def setSBErrorLimit(err):
- """
- Set the Object's SoftBody ErrorLimit.
- Values between 0 to 1.0
- @rtype: None
- @type err: float
- @param err: the Object's SoftBody New ErrorLimit.
- """
-
- def getSBGoalSpring():
- """
- Get the Object's SoftBody GoalSpring.
- @rtype: float
- """
-
- def setSBGoalSpring(gs):
- """
- Set the Object's SoftBody GoalSpring.
- Values between 0 to 0.999
- @rtype: None
- @type gs: float
- @param gs: the Object's SoftBody New GoalSpring.
- """
-
- def getSBGoalFriction():
- """
- Get the Object's SoftBody GoalFriction.
- @rtype: float
- """
-
- def setSBGoalFriction(gf):
- """
- Set the Object's SoftBody GoalFriction.
- Values between 0 to 10.0
- @rtype: None
- @type gf: float
- @param gf: the Object's SoftBody New GoalFriction.
- """
-
- def getSBMinGoal():
- """
- Get the Object's SoftBody MinGoal.
- @rtype: float
- """
-
- def setSBMinGoal(mg):
- """
- Set the Object's SoftBody MinGoal.
- Values between 0 to 1.0
- @rtype: None
- @type mg: float
- @param mg: the Object's SoftBody New MinGoal.
- """
-
- def getSBMaxGoal():
- """
- Get the Object's SoftBody MaxGoal.
- @rtype: float
- """
-
- def setSBMaxGoal(mg):
- """
- Set the Object's SoftBody MaxGoal.
- Values between 0 to 1.0
- @rtype: None
- @type mg: float
- @param mg: the Object's SoftBody New MaxGoal.
- """
-
- def getSBInnerSpring():
- """
- Get the Object's SoftBody InnerSpring.
- @rtype: float
- """
-
- def setSBInnerSpring(sprr):
- """
- Set the Object's SoftBody InnerSpring.
- Values between 0 to 0.999
- @rtype: None
- @type sprr: float
- @param sprr: the Object's SoftBody New InnerSpring.
- """
-
- def getSBInnerSpringFriction():
- """
- Get the Object's SoftBody InnerSpringFriction.
- @rtype: float
- """
-
- def setSBInnerSpringFriction(sprf):
- """
- Set the Object's SoftBody InnerSpringFriction.
- Values between 0 to 10.0
- @rtype: None
- @type sprf: float
- @param sprf: the Object's SoftBody New InnerSpringFriction.
- """
-
- def getSBDefaultGoal():
- """
- Get the Object's SoftBody DefaultGoal.
- @rtype: float
- """
-
- def setSBDefaultGoal(goal):
- """
- Set the Object's SoftBody DefaultGoal.
- Values between 0 to 1.0
- @rtype: None
- @type goal: float
- @param goal: the Object's SoftBody New DefaultGoal.
- """
-
- def isSB():
- """
- Returns the Object's SoftBody enabled state.
- @rtype: boolean
- """
-
- def getSBPostDef():
- """
- get SoftBodies PostDef option
- @rtype: int
- """
-
- def setSBPostDef(switch):
- """
- Enable / Disable SoftBodies PostDef option
- 1: on
- 0: off
- @rtype: None
- @type switch: int
- @param switch: the Object's SoftBody New PostDef Value.
- """
-
- def getSBUseGoal():
- """
- get SoftBodies UseGoal option
- @rtype: int
- """
-
- def setSBUseGoal(switch):
- """
- Enable / Disable SoftBodies UseGoal option
- 1: on
- 0: off
- @rtype: None
- @type switch: int
- @param switch: the Object's SoftBody New UseGoal Value.
- """
- def getSBUseEdges():
- """
- get SoftBodies UseEdges option
- @rtype: int
- """
-
- def setSBUseEdges(switch):
- """
- Enable / Disable SoftBodies UseEdges option
- 1: on
- 0: off
- @rtype: None
- @type switch: int
- @param switch: the Object's SoftBody New UseEdges Value.
- """
-
- def getSBStiffQuads():
- """
- get SoftBodies StiffQuads option
- @rtype: int
- """
-
- def setSBStiffQuads(switch):
- """
- Enable / Disable SoftBodies StiffQuads option
- 1: on
- 0: off
- @rtype: None
- @type switch: int
- @param switch: the Object's SoftBody New StiffQuads Value.
- """
-
-
-class Property:
- """
- The Property object
- ===================
- This property gives access to object property data in Blender, used by the game engine.
- @ivar name: The property name.
- @ivar data: Data for this property. Depends on property type.
- @ivar type: The property type.
- @warn: Comparisons between properties will only be true when
- both the name and data pairs are the same.
- """
-
- def getName ():
- """
- Get the name of this property.
- @rtype: string
- @return: The property name.
- """
-
- def setName (name):
- """
- Set the name of this property.
- @type name: string
- @param name: The new name of the property
- """
-
- def getData():
- """
- Get the data for this property.
- @rtype: string, int, or float
- """
-
- def setData(data):
- """
- Set the data for this property.
- @type data: string, int, or float
- @param data: The data to set for this property.
- @warn: See object.setProperty(). Changing data
- which is of a different type then the property is
- set to (i.e. setting an int value to a float type'
- property) will change the type of the property
- automatically.
- """
-
- def getType ():
- """
- Get the type for this property.
- @rtype: string
- """
-
-import id_generics
-Object.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/Pose.py b/source/blender/python/api2_2x/doc/Pose.py
deleted file mode 100644
index ad1b44da5e2..00000000000
--- a/source/blender/python/api2_2x/doc/Pose.py
+++ /dev/null
@@ -1,245 +0,0 @@
-# Blender.Object.Pose module
-
-"""
-The Blender.Object.Pose submodule.
-
-Pose
-====
-
-This module provides access to B{Pose} objects in Blender. This Pose is the
-current object-level (as opposed to armature-data level) transformation.
-
-Example::
- import Blender
- from Blender import *
-
-
- scn= Scene.GetCurrent()
-
- # New Armature
- arm_data= Armature.New('myArmature')
- print arm_data
- arm_ob = scn.objects.new(arm_data)
- arm_data.makeEditable()
-
-
- # Add 4 bones
- ebones = [Armature.Editbone(), Armature.Editbone(), Armature.Editbone(), Armature.Editbone()]
-
- # Name the editbones
- ebones[0].name = 'Bone.001'
- ebones[1].name = 'Bone.002'
- ebones[2].name = 'Bone.003'
- ebones[3].name = 'Bone.004'
-
- # Assign the editbones to the armature
- for eb in ebones:
- arm_data.bones[eb.name]= eb
-
- # Set the locations of the bones
- ebones[0].head= Mathutils.Vector(0,0,0)
- ebones[0].tail= Mathutils.Vector(0,0,1)
- ebones[1].head= Mathutils.Vector(0,0,1)
- ebones[1].tail= Mathutils.Vector(0,0,2)
- ebones[2].head= Mathutils.Vector(0,0,2)
- ebones[2].tail= Mathutils.Vector(0,0,3)
- ebones[3].head= Mathutils.Vector(0,0,3)
- ebones[3].tail= Mathutils.Vector(0,0,4)
-
- ebones[1].parent= ebones[0]
- ebones[2].parent= ebones[1]
- ebones[3].parent= ebones[2]
-
- arm_data.update()
- # Done with editing the armature
-
-
- # Assign the pose animation
- pose = arm_ob.getPose()
-
- act = arm_ob.getAction()
- if not act: # Add a pose action if we dont have one
- act = Armature.NLA.NewAction()
- act.setActive(arm_ob)
-
- xbones=arm_ob.data.bones.values()
- pbones = pose.bones.values()
- print xbones
- print pbones
-
-
- frame = 1
- for pbone in pbones: # set bones to no rotation
- pbone.quat[:] = 1.000,0.000,0.000,0.0000
- pbone.insertKey(arm_ob, frame, Object.Pose.ROT)
-
- # Set a different rotation at frame 25
- pbones[0].quat[:] = 1.000,0.1000,0.2000,0.20000
- pbones[1].quat[:] = 1.000,0.6000,0.5000,0.40000
- pbones[2].quat[:] = 1.000,0.1000,0.3000,0.40000
- pbones[3].quat[:] = 1.000,-0.2000,-0.3000,0.30000
-
- frame = 25
- for i in xrange(4):
- pbones[i].insertKey(arm_ob, frame, Object.Pose.ROT)
-
- pbones[0].quat[:] = 1.000,0.000,0.000,0.0000
- pbones[1].quat[:] = 1.000,0.000,0.000,0.0000
- pbones[2].quat[:] = 1.000,0.000,0.000,0.0000
- pbones[3].quat[:] = 1.000,0.000,0.000,0.0000
-
-
- frame = 50
- for pbone in pbones: # set bones to no rotation
- pbone.quat[:] = 1.000,0.000,0.000,0.0000
- pbone.insertKey(arm_ob, frame, Object.Pose.ROT)
-
-
-
-@var ROT:
-@type ROT: Constant
-@var LOC:
-@type LOC: Constant
-@var SIZE:
-@type SIZE: Constant
-"""
-
-class Pose:
- """
- The Pose object
- ===============
- This object gives access to Pose-specific data in Blender.
- @ivar bones: A Dictionary of PosePoseBones (PoseDict) that make up this Pose.
- @type bones: PoseDict Object
- """
-
- def update():
- """
- Save all changes and update the Pose.
- @rtype: None
- """
-
-class PoseBonesDict:
- """
- The PoseBonesDict object
- ========================
- This object gives dictionary like access to the PoseBones in a Pose.
- It is internal to blender but is called as 'Pose.bones'
- """
-
- def items():
- """
- Return the key, value pairs in this dictionary
- @rtype: string, PosePoseBone
- @return: All strings, and PosePoseBones in the Pose (in that order)
- """
-
- def keys():
- """
- Return the keys in this dictionary
- @rtype: string
- @return: All strings representing the PosePoseBone names
- """
-
- def values():
- """
- Return the values in this dictionary
- @rtype: BPy_PoseBone
- @return: All PosePoseBones in this dictionary
- """
-
-class PoseBone:
- """
- The PoseBone object
- ===================
- This object gives access to PoseBone-specific data in Blender.
- @ivar name: The name of this PoseBone.
- @type name: String
- @ivar loc: The change in location for this PoseBone. this is the equivilent of bone.getLoc() in the old 2.3x python api.
- @type loc: Vector object
- @ivar size: The change in size for this PoseBone (no change is 1,1,1)
- @type size: Vector object
- @ivar quat: The change in rotation for this PoseBone.
- @type quat: Quaternion object
- @ivar head: The final head location for this PoseBone. (not settable)
- @type head: Vector object
- @ivar tail: The final tail location for this PoseBone. (not settable)
- @type tail: Vector object
- @ivar sel: The selection state of this bone
- @type sel: Boolean
- @ivar parent: The parent of this posebone (not settable)
- @type parent: posebone or None
- @ivar displayObject: The object to display in place of the bone. (custom bones)
- @type displayObject: Object or None
- @ivar localMatrix: The matrix combination of rot/size/loc.
- @type localMatrix: Matrix object
- @ivar poseMatrix: The total transformation of this PoseBone including constraints.
-
- This matrix is in armature space, for the current worldspace location of this pose bone, multiply
- it with its objects worldspace matrix.
-
- eg. pose_bone.poseMatrix * object.matrixWorld
-
- Setting the poseMatrix only sets the loc/size/rot, before constraints are applied (similar to actions).
- After setting pose matrix, run pose.update() to re-evaluate the pose and see the changes in the 3d view.
-
- @type poseMatrix: Matrix object
- @type constraints: BPy_ConstraintSeq
- @ivar constraints: a sequence of constraints for the object
- @type limitmin: 3-item sequence
- @ivar limitmin: The x,y,z minimum limits on rotation when part of an IK
- @type limitmax: 3-item sequence
- @ivar limitmax: The x,y,z maximum limits on rotation when part of an IK
-
- @type hasIK: bool
- @ivar hasIK: True if this pose bone is a part of an IK (readonly), when False, other IK related values have no affect.
-
- @type stretch: float
- @ivar stretch: The amount to stretch to the ik target when part of an IK [0.0 - 1.0]
-
- @type stiffX: float
- @ivar stiffX: The x stiffness when part of an IK [0.0 - 0.990]
- @type stiffY: float
- @ivar stiffY: The x stiffness when part of an IK [0.0 - 0.990]
- @type stiffZ: float
- @ivar stiffZ: The x stiffness when part of an IK [0.0 - 0.990]
-
- @type limitX: bool
- @ivar limitX: Limit rotation over X axis when part of an IK.
- @type limitY: bool
- @ivar limitY: Limit rotation over Y axis when part of an IK.
- @type limitZ: bool
- @ivar limitZ: Limit rotation over Z axis when part of an IK.
-
- @type lockXRot: bool
- @ivar lockXRot: Disable X DoF when part of an IK.
- @type lockYRot: bool
- @ivar lockYRot: Disable Y DoF when part of an IK.
- @type lockZRot: bool
- @ivar lockZRot: Disable Z DoF when part of an IK.
- @ivar layerMask: Layer bitmask
- Example::
- # set bone to layers 14 and 16
- bone.layerMask = (1<<13) + (1<<15)
- @type layerMask: Int
- """
-
- def insertKey(parentObject, frameNumber, type = "[Pose.LOC, Pose.ROT, Pose.SIZE]", fast = False):
- """
- Insert a pose key for this PoseBone at a frame.
- @type parentObject: Object object
- @param parentObject: The object the pose came from.
- @type frameNumber: integer
- @param frameNumber: The frame number to insert the pose key on.
- @type type: Constant object
- @param type: Optional argumentm.
- Can be any combination of 3 Module constants:
- - Pose.LOC
- - Pose.ROT (This adds keyframes to the quat ipo, since quaternions are used for pose bone rotation)
- - Pose.SIZE
- If this argument is omitted all keys will be added.
- @type fast: Bool
- @param fast: If enabled, the IPOs will not be recalculated, speeds up adding many keyframes at once.
- @rtype: None
- """
-
diff --git a/source/blender/python/api2_2x/doc/Radio.py b/source/blender/python/api2_2x/doc/Radio.py
deleted file mode 100644
index f336ea56765..00000000000
--- a/source/blender/python/api2_2x/doc/Radio.py
+++ /dev/null
@@ -1,351 +0,0 @@
-# Blender.Scene.Radio module and the Radiosity PyType object
-
-"""
-The Blender.Scene.Radio submodule.
-
-Radio
-=====
-
-This module gives access to B{Scene Radiosity Contexts} in Blender.
-
-Example::
- import Blender
- from Blender import Scene
-
- # Only the current scene has a radiosity context.
- # Naturally, any scene can be made the current one
- # with scene.makeCurrent()
-
- scn = Scene.GetCurrent()
-
- # this is the only way to access the radiosity object:
-
- radio = scn.getRadiosityContext()
-
- radio.setDrawType('Gouraud')
- radio.setMode('ShowLimits', 'Z')
-
- radio.collectMeshes() # prepare patches
- radio.go() # calculate radiosity
- Blender.Redraw(-1)
-
-
-@type Modes: readonly dictionary
-@var Modes:
- - ShowLimits
- - Z
-
-@type DrawTypes: readonly dictionary
-@var DrawTypes:
- - Wire
- - Solid
- - Gouraud
-"""
-
-class Radio:
- """
- The Radiosity object
- ====================
- This object wraps the current Scene's radiosity context in Blender.
- """
-
- def go():
- """
- Start the radiosity simulation. It is necessary to call L{collectMeshes}
- first.
- """
-
- def collectMeshes():
- """
- Convert B{selected} visible meshes to patches for radiosity calculation.
- @note: L{Object.Object.select} can be used to (un)select objects via
- bpython.
- """
-
- def freeData():
- """
- Release all memory used by radiosity.
- """
-
- def addMesh():
- """
- Add the new mesh created by the radiosity simulation (see L{go}) to
- Blender. The radiosity results are stored in this mesh's vertex colors.
- @note: see L{replaceMeshes} for a destructive alternative.
- """
-
- def replaceMeshes():
- """
- Replace the original input meshes with the B{one} calculated by the
- radiosity simulation. The radiosity results are stored in this mesh's
- vertex colors.
- @note: see L{addMesh} for a non-destructive alternative.
- """
-
- def limitSubdivide():
- """
- Subdivide patches (optional, it may improve results).
- """
-
- def filterFaces():
- """
- Force an extra smoothing. This method can be called only after the
- simulation has been calculated (L{go}).
- """
-
- def filterElems():
- """
- Filter elements to remove aliasing artifacts. This method can be called
- only after the simulation has been calculated (L{go}).
- """
-
- def subdividePatches():
- """
- Pre-subdivision: detect high-energy patches and subdivide them
- (optional, it may improve results).
- """
-
- def subdivideElems():
- """
- Pre-subdivision: detect high-energy elements (nodes) and subdivide them
- (optional, it may improve results).
- """
-
- def removeDoubles():
- """
- Join elements (nodes) which differ less than the defined element limit.
- This method can be called only after the simulation has been calculated
- (L{go}).
- """
-
- def getHemiRes():
- """
- Get hemicube size.
- @rtype: int
- @return: the current hemicube size.
- """
-
- def setHemiRes(ival):
- """
- Set hemicube size. The range is [100, 1000].
- @type ival: int
- @param ival: the new size.
- """
-
- def getMaxIter():
- """
- Get maximum number of radiosity rounds.
- @rtype: int
- @return: the current maxiter value.
- """
-
- def setMaxIter(ival):
- """
- Set maximum number of radiosity rounds. The range is [0, 10000].
- @type ival: int
- @param ival: the maxiter new value.
- """
-
- def getSubShPatch():
- """
- Get maximum number of times the environment is tested to detect patches.
- @rtype: int
- @return: the current value.
- """
-
- def setSubShPatch(ival):
- """
- Set the maximum number of times the environment is tested to detect
- patches. The range is [0, 10].
- @type ival: int
- @param ival: the new value.
- """
-
- def getSubShElem():
- """
- Get the number of times the environment is tested to detect elements.
- @rtype: int
- @return: the current value.
- """
-
- def setSubShElem(ival):
- """
- Set number of times the environment is tested to detect elements. The
- range is [0, 10].
- @type ival: int
- @param ival: the new value.
- """
-
- def getElemLimit():
- """
- Get the range for removing doubles.
- @rtype: int
- @return: the current value.
- """
-
- def setElemLimit(ival):
- """
- Set the range for removing doubles. The range is [0, 50].
- @type ival: int
- @param ival: the new value.
- """
-
- def getMaxSubdivSh():
- """
- Get the maximum number of initial shoot patches evaluated.
- @rtype: int
- @return: the current value.
- """
-
- def setMaxSubdivSh(ival):
- """
- Set the maximum number of initial shoot patches evaluated. The range is
- [1, 250].
- @type ival: int
- @param ival: the new value.
- """
-
- def getPatchMax():
- """
- Get the maximum size of a patch.
- @rtype: int
- @return: the current value.
- """
-
- def setPatchMax(ival):
- """
- Set the maximum size of a patch. The range is [10, 1000].
- @type ival: int
- @param ival: the new value.
- """
-
- def getPatchMin():
- """
- Get the minimum size of a patch.
- @rtype: int
- @return: the current value.
- """
-
- def setPatchMin(ival):
- """
- Set the minimum size of a patch. The range is [10, 1000].
- @type ival: int
- @param ival: the new value.
- """
-
- def getElemMax():
- """
- Get the maximum size of an element.
- @rtype: int
- @return: the current value.
- """
-
- def setElemMax(ival):
- """
- Set the maximum size of an element. The range is [1, 100].
- @type ival: int
- @param ival: the new value.
- """
-
- def getElemMin():
- """
- Get the minimum size of an element. The range is [1, 100].
- @rtype: int
- @return: the current value.
- """
-
- def setElemMin(ival):
- """
- Set the minimum size of an element. The range is [1, 100].
- @type ival: int
- @param ival: the new value.
- """
-
- def getMaxElems():
- """
- Get the maximum number of elements.
- @rtype: int
- @return: the current value.
- """
-
- def setMaxElems(ival):
- """
- Set the maximum number of elements. The range is [1, 250000].
- @type ival: int
- @param ival: the new value.
- """
-
- def getConvergence():
- """
- Get lower thresholdo of unshot energy.
- @rtype: float
- @return: the current value.
- """
-
- def setConvergence(fval):
- """
- Set lower threshold of unshot energy. The range is [0.0, 1.0].
- @type fval: float
- @param fval: the new value.
- """
-
- def getMult():
- """
- Get the energy value multiplier.
- @rtype: float
- @return: the current value.
- """
-
- def setMult (fval):
- """
- Set the energy value multiplier. The range is [0.001, 250.0].
- @type fval: float
- @param fval: the new value.
- """
-
- def getGamma():
- """
- Get change in the contrast of energy values.
- @rtype: float
- @return: the current value.
- """
-
- def setGamma (fval):
- """
- Set change in the contrast of energy values. The range is [0.2, 10.0].
- @type fval: float
- @param fval: the new value.
- """
-
- def getDrawType():
- """
- Get the draw type: Wire, Solid or Gouraud as an int value, see L{DrawTypes}.
- @rtype: int
- @return: the current draw type.
- """
-
- def setDrawType (dt):
- """
- Set the draw type.
- @type dt: string or int
- @param dt: either 'Wire', 'Solid' or 'Gouraud' or the equivalent entry in
- the L{DrawTypes} dictionary.
- """
-
- def getMode():
- """
- Get mode as an int (or'ed bitflags), see L{Modes} dictionary.
- @rtype: int
- @return: the current value.
- """
-
- def setMode (mode1 = None, mode2 = None):
- """
- Set mode flags as strings: 'ShowLimits' and 'Z'. To set one give it as
- only argument. Strings not passed in are unset, so setMode() unsets
- both.
- @type mode1: string
- @param mode1: optional mode string.
- @type mode2: string
- @param mode2: optional mode string.
- """
diff --git a/source/blender/python/api2_2x/doc/Registry.py b/source/blender/python/api2_2x/doc/Registry.py
deleted file mode 100644
index 02ac30e71ac..00000000000
--- a/source/blender/python/api2_2x/doc/Registry.py
+++ /dev/null
@@ -1,122 +0,0 @@
-# Blender.Registry module
-
-"""
-The Blender.Registry submodule.
-
-B{New}: L{GetKey} and L{SetKey} have been updated to save and load scripts
-*configuration data* to files.
-
-Registry
-========
-
-This module provides a way to create, retrieve and edit B{persistent data} in
-Blender.
-
-When a script is executed it has its own private global dictionary,
-which is deleted when the script exits. This is done to avoid problems with
-name clashes and garbage collecting. But because of this, the data created by
-a script isn't kept after it leaves: the data is not persistent. The Registry
-module was created to give programmers a way around this limitation.
-
-Possible uses:
- - saving arbitrary data from a script that itself or another one will need
- to access later.
- - saving configuration data for a script: users can view and edit this data
- using the "Scripts Configuration Editor" script.
- - saving the current state of a script's GUI (its button values) to restore it
- when the script is executed again.
-
-Example::
-
- import Blender
- from Blender import Registry
-
- # this function updates the Registry when we need to:
- def update_Registry():
- d = {}
- d['myvar1'] = myvar1
- d['myvar2'] = myvar2
- d['mystr'] = mystr
- # cache = True: data is also saved to a file
- Blender.Registry.SetKey('MyScript', d, True)
-
- # first declare global variables that should go to the Registry:
- myvar1 = 0
- myvar2 = 3.2
- mystr = "hello"
-
- # then check if they are already there (saved on a
- # previous execution of this script):
- rdict = Registry.GetKey('MyScript', True) # True to check on disk also
- if rdict: # if found, get the values saved there
- try:
- myvar1 = rdict['myvar1']
- myvar2 = rdict['myvar2']
- mystr = rdict['mystr']
- except: update_Registry() # if data isn't valid rewrite it
-
- # ...
- # here goes the main part of the script ...
- # ...
-
- # if at some point the data is changed, we update the Registry:
- update_Registry()
-
-@note: In Python terms, the Registry holds a dictionary of dictionaries.
- Technically any Python or BPython object can be stored: there are no
- restrictions, but ...
-
-@note: We have a few recommendations:
-
- Data saved to the Registry is kept in memory, so if you decide to store large
- amounts your script users should be clearly informed about it --
- always keep in mind that you have no idea about their resources and the
- applications they are running at a given time (unless you are the only
- user), so let them decide.
-
- There are restrictions to the data that gets automatically saved to disk by
- L{SetKey}(keyname, dict, True): this feature is only meant for simple data
- (bools, ints, floats, strings and dictionaries or sequences of these types).
-
- For more demanding needs, it's of course trivial to save data to another
- file or to a L{Blender Text<Text>}.
-"""
-
-def Keys ():
- """
- Get all keys currently in the Registry's dictionary.
- """
-
-def GetKey (key, cached = False):
- """
- Get key 'key' from the Registry.
- @type key: string
- @param key: a key from the Registry dictionary.
- @type cached: bool
- @param cached: if True and the requested key isn't already loaded in the
- Registry, it will also be searched on the user or default scripts config
- data dir (config subdir in L{Blender.Get}('datadir')).
- @return: the dictionary called 'key'.
- """
-
-def SetKey (key, dict, cache = False):
- """
- Store a new entry in the Registry.
- @type key: string
- @param key: the name of the new entry, tipically your script's name.
- @type dict: dictionary
- @param dict: a dict with all data you want to save in the Registry.
- @type cache: bool
- @param cache: if True the given key data will also be saved as a file
- in the config subdir of the scripts user or default data dir (see
- L{Blender.Get}).
- @warn: as stated in the notes above, there are restrictions to what can
- be automatically stored in config files.
- """
-
-def RemoveKey (key):
- """
- Remove the dictionary with key 'key' from the Registry.
- @type key: string
- @param key: the name of an existing Registry key.
- """
diff --git a/source/blender/python/api2_2x/doc/Render.py b/source/blender/python/api2_2x/doc/Render.py
deleted file mode 100644
index d75e07de8e3..00000000000
--- a/source/blender/python/api2_2x/doc/Render.py
+++ /dev/null
@@ -1,1192 +0,0 @@
-# Blender.Scene.Render module and the RenderData PyType object
-
-"""
-The Blender.Scene.Render submodule.
-
-Scene.Render
-============
-
-This module provides access to B{Scene Rendering Contexts} in Blender.
-
-Example::
- import Blender
- from Blender import *
- from Blender.Scene import Render
-
- scn = Scene.GetCurrent()
- context = scn.getRenderingContext()
-
- Render.EnableDispWin()
- context.extensions = True
- context.renderPath = "//myRenderdir/"
- context.sizePreset(Render.PC)
- context.imageType = Render.AVIRAW
- context.sFrame = 2
- context.eFrame = 10
- context.renderAnim()
-
- context.imageType = Render.TARGA
- context.fps = 15
- context.sFrame = 15
- context.eFrame = 22
- context.renderAnim()
-
- Render.CloseRenderWindow()
- print context.fps
- print context.cFrame
-
-@type Modes: readonly dictionary
-@var Modes: Constant dict used for with L{RenderData.mode} bitfield attribute.
-Values can be ORed together. Individual bits can also be set/cleared with
-boolean attributes.
- - OSA: Oversampling (anti-aliasing) enabled
- - SHADOW: Shadow calculation enabled
- - GAMMA: Gamma correction enabled
- - ENVMAP: Environment map rendering enabled
- - TOONSHADING: Toon edge shading enabled
- - FIELDRENDER: Field rendering enabled
- - FIELDTIME: Time difference in field calculations I{disabled}
- - RADIOSITY: Radiosity rendering enabled
- - BORDER_RENDER: Small cut-out rendering enabled
- - PANORAMA: Panorama rendering enabled
- - CROP: Crop image during border renders
- - ODDFIELD: Odd field first rendering enabled
- - MBLUR: Motion blur enabled
- - UNIFIED: Unified Renderer enabled
- - RAYTRACING: Ray tracing enabled
- - THREADS: Render in two threads enabled (Deprecated, use L{RenderData.threads})
-
-@type SceModes: readonly dictionary
-@var SceModes: Constant dict used for with L{RenderData.sceneMode} bitfield attribute.
-Values can be ORed together. Individual bits can also be set/cleared with
-boolean attributes.
- - SEQUENCER: Enables sequencer output rendering.
- - EXTENSION: Adds extensions to the output when rendering animations.
- - SAVE_BUFFERS: Save render tiles to disk to save memory.
- - FREE_IMAGES: Free images used by textures after each render.
-
-@type FramingModes: readonly dictionary
-@var FramingModes: Constant dict used for with L{RenderData.gameFrame}
-attribute. One of the following modes can be active:
- - BARS: Show the entire viewport in the display window, using bar
- horizontally or vertically.
- - EXTEND: Show the entire viewport in the display window, viewing more
- horizontally or vertically
- - SCALE: Stretch or squeeze the viewport to fill the display window.
-
-@var INTERNAL: The internal rendering engine. Use with setRenderer()
-@var YAFRAY: Yafray rendering engine. Use with setRenderer()
-
-@var AVIRAW: Output format. Use with renderdata.imageType / setImageType()
-@var AVIJPEG: Output format. Use with renderdata.imageType / setImageType()
-@var AVICODEC: Output format. Use with renderdata.imageType / setImageType()
-@var QUICKTIME: Output format. Use with renderdata.imageType / setImageType()
-@var TARGA: Output format. Use with renderdata.imageType / setImageType()
-@var RAWTGA: Output format. Use with renderdata.imageType / setImageType()
-@var HDR: Output format. Use with renderdata.imageType / setImageType()
-@var PNG: Output format. Use with renderdata.imageType / setImageType()
-@var BMP: Output format. Use with renderdata.imageType / setImageType()
-@var JPEG: Output format. Use with renderdata.imageType / setImageType()
-@var HAMX: Output format. Use with renderdata.imageType / setImageType()
-@var IRIS: Output format. Use with renderdata.imageType / setImageType()
-@var IRISZ: Output format. Use with renderdata.imageType / setImageType()
-@var FTYPE: Output format. Use with renderdata.imageType / setImageType()
-@var OPENEXR: Output format. Use with renderdata.imageType / setImageType()
-@var TIFF: Output format. Use with renderdata.imageType / setImageType()
-@var FFMPEG: Output format. Use with renderdata.imageType / setImageType()
-@var CINEON: Output format. Use with renderdata.imageType / setImageType()
-@var DPX: Output format. Use with renderdata.imageType / setImageType()
-
-@var PAL: Output format. Use with renderdata.sizePreset()
-@var NTSC: Output format. Use with renderdata.sizePreset()
-@var DEFAULT: Output format. Use with renderdata.sizePreset()
-@var PREVIEW: Output format. Use with renderdata.sizePreset()
-@var PC: Output format. Use with renderdata.sizePreset()
-@var PAL169: Output format. Use with renderdata.sizePreset()
-@var B_PR_FULL: Output format. Use with renderdata.sizePreset()
-
-@var NONE: Yafray GI Quality / Method. Use with renderdata.setYafrayGIQuality()
-@var LOW: Yafray GI Quality. Use with renderdata.setYafrayGIQuality()
-@var MEDIUM: Yafray GI Quality. Use with renderdata.setYafrayGIQuality()
-@var HIGH: Yafray GI Quality. Use with renderdata.setYafrayGIQuality()
-@var HIGHER: Yafray GI Quality. Use with renderdata.setYafrayGIQuality()
-@var BEST: Yafray GI Quality. Use with renderdata.setYafrayGIQuality()
-@var USEAOSETTINGS: Yafray GI Quality. Use with renderdata.setYafrayGIQuality()
-@var SKYDOME: Yafray GI Method. Use with renderdata.setYafrayGIMethod()
-@var GIFULL: Yafray GI Method. Use with renderdata.setYafrayGIMethod()
-"""
-
-def CloseRenderWindow():
- """
- Closes the rendering window.
- """
-
-def EnableDispView():
- """
- Render in the 3d View area. B{Note} this method is deprecated;
- use the l{displayMode} attribute instead.
- """
-
-def EnableDispWin():
- """
- Render in Render window.
- B{Note} this method is deprecated; use the l{displayMode} attribute instead.
- """
-
-def SetRenderWinPos(locationList):
- """
- Set the position of the Render window on the screen.
- Possible values are:
- - S = south
- - N = north
- - W = west
- - E = east
- - C = center
- - ne = northeast
- - nw = northwest
- - se = southeast
- - sw = southwest
- @type locationList: PyList of strings
- @param locationList: a list of strings that together define
- the location of the Render window on the screen.
- """
-
-def EnableEdgeShift():
- """
- Globally with the unified renderer enabled the outlines of the render
- are shifted a bit.
- """
-
-def EnableEdgeAll():
- """
- Globally consider transparent faces for edge-rendering with the unified renderer.
- """
-
-class RenderData:
- """
- The RenderData object
- =====================
- This object gives access to Scene rendering contexts in Blender.
- @ivar unified: Unified Renderer enabled.
- Also see B{UNIFIED} in L{Modes} constant dict.
- @type unified: boolean
- @ivar renderwinSize: Size of the rendering window. Valid values are 25, 50,
- 75, or 100.
- @type renderwinSize: int
- @ivar xParts: Number of horizontal parts for image render.
- Values are clamped to the range [2,512].
- @type xParts: int
- @ivar fieldRendering: Field rendering enabled.
- Also see B{FIELDRENDER} in L{Modes} constant dict.
- @type fieldRendering: boolean
- @ivar gammaCorrection: Gamma correction enabled.
- Also see B{GAMMA} in L{Modes} constant dict.
- @type gammaCorrection: boolean
- @ivar eFrame: Ending frame for rendering.
- Values are clamped to the range [1,MAXFRAME].
- @type eFrame: int
- @ivar radiosityRender: Radiosity rendering enabled.
- @type radiosityRender: boolean
- @ivar sizeX: Image width (in pixels).
- Values are clamped to the range [4,10000].
- @type sizeX: int
- @ivar shadow: Shadow calculation enabled.
- Also see B{SHADOW} in L{Modes} constant dict.
- @type shadow: boolean
- @ivar aspectX: Horizontal aspect ratio.
- Values are clamped to the range [1,200].
- @type aspectX: int
- @ivar mode: Mode bitfield. See L{Modes} constant dict for values.
- @type mode: bitfield
- @ivar fieldTimeDisable: Time difference in field calculations I{disabled}.
- @type fieldTimeDisable: int
- @ivar cFrame: The current frame for rendering.
- Values are clamped to the range [1,MAXFRAME].
- @type cFrame: int
- @ivar crop: Crop image during border renders.
- Also see B{CROP} in L{Modes} constant dict.
- @type crop: boolean
- @ivar sFrame: Starting frame for rendering.
- Values are clamped to the range [1,MAXFRAME].
- @type sFrame: int
- @ivar backbuf: Backbuffer image enabled.
- @type backbuf: boolean
- @ivar OSALevel: Oversampling (anti-aliasing) level. Valid values are
- 5, 8, 11, or 16.
- @type OSALevel: int
- @ivar displayMode: Render output in separate window or 3D view.
- Valid values are 0 (display in image editor view), 1 (display in render
- window), or 2 (display full screen).
- @type displayMode: int
- @ivar threads: Number of threads to render, clamed [1-8]
- @type threads: int
- @ivar backbufPath: Path to a background image (setting loads image).
- @type backbufPath: string
- @ivar toonShading: Toon edge shading enabled.
- Also see B{TOONSHADING} in L{Modes} constant dict.
- @type toonShading: boolean
- @ivar sceneMode: Scene mode bitfield. See L{SceModes} constant dict for
- values.
- @type sceneMode: bitfield
- @ivar gameFrameColor: RGB color triplet for bars.
- Values are clamped in the range [0.0,1.0].
- @type gameFrameColor: list of RGB 3 floats
- @ivar sizeY: Image height (in pixels).
- Values are clamped to the range [4,10000].
- @type sizeY: int
- @ivar renderer: Rendering engine choice.
- Valid values are 0 (internal) or 1 (Yafray).
- @type renderer: int
-
- @ivar sequencer: Enables sequencer output rendering.
- Also see B{SEQUENCER} in L{SceModes} constant dict.
- @type sequencer: boolean
- @ivar extensions: Add extensions to output (when rendering animations).
- Also see B{EXTENSION} in L{SceModes} constant dict.
- @type extensions: boolean
- @ivar compositor: 'Do Compositor' enabled.
- @type compositor: boolean
- @ivar freeImages: 'Do Compositor' enabled.
- @type freeImages: boolean
- @ivar singleLayer: Only render the active layer.
- @type singleLayer: boolean
- @ivar saveBuffers: Save render buffers to disk while rendering, saves memory.
- @type saveBuffers: boolean
- @ivar compositeFree: Free nodes that are not used while composite.
- @type compositeFree: boolean
-
- @ivar panorama: Panorama rendering enabled.
- Also see B{PANORAMA} in L{Modes} constant dict.
- @type panorama: boolean
- @ivar rayTracing: Ray tracing enabled.
- Also see B{RAYTRACING} in L{Modes} constant dict.
- @type rayTracing: boolean
- @ivar renderPath: The path to output the rendered images.
- @type renderPath: string
- @ivar gameFrame: Game framing type. See L{FramingModes} constant dict.
- @type gameFrame: int
- @ivar aspectY: Vertical aspect ratio.
- Values are clamped to the range [1,200].
- @type aspectY: int
- @ivar imageType: File format for saving images. See the module's constants
- for values.
- @type imageType: int
- @ivar ftypePath: The path to Ftype file.
- @type ftypePath: string
- @ivar border: The border for border rendering. The format is
- [xmin,ymin,xmax,ymax]. Values are clamped to [0.0,1.0].
- @type border: list of 4 floats.
- @ivar edgeColor: RGB color triplet for edges in Toon shading (unified
- renderer).
- Values are clamped in the range [0.0,1.0].
- @type edgeColor: list of 3 RGB floats
- @ivar yParts: Number of vertical parts for image render.
- Values are clamped to the range [2,512].
- @type yParts: int
- @ivar imagePlanes: Image depth in bits. Valid values are 8, 24, or 32.
- @type imagePlanes: int
- @ivar borderRender: Small cut-out rendering enabled.
- Also see B{BORDER_RENDER} in L{Modes} constant dict.
- @type borderRender: boolean
- @ivar oversampling: Oversampling (anti-aliasing) enabled.
- Also see B{OSA} in L{Modes} constant dict.
- @type oversampling: boolean
- @ivar fps: Frames per second.
- Values are clamped to the range [1,120].
- @ivar fpsBase: Frames per second base: used to generate fractional frames
- per second values. For example, setting fps to 30 and fps_base to 1.001
- will approximate the NTSC frame rate of 29.97 fps.
- Values are clamped to the range [1,120].
- @type fpsBase: float
- @ivar timeCode: Get the current frame in HH:MM:SS:FF format. Read-only.
- @type timeCode: string
- @ivar environmentMap: Environment map rendering enabled.
- Also see B{ENVMAP} in L{Modes} constant dict.
- @type environmentMap: boolean
- @ivar motionBlur: Motion blur enabled.
- Also see B{MBLUR} in L{Modes} constant dict.
- @type motionBlur: boolean
- @ivar oddFieldFirst: Odd field first rendering enabled.
- Also see B{ODDFIELD} in L{Modes} constant dict.
- @type oddFieldFirst: boolean
- @ivar alphaMode: Setting for sky/background. Valid values are 0 (fill
- background with sky), 1 (multiply alpha in advance), or 2 (alpha and color
- values remain unchanged).
- @type alphaMode: int
- @ivar gaussFilter: Gauss filter size.
- Values are clamped to the range [0.5,1.5].
- @type gaussFilter: float
- @ivar mblurFactor: Motion blur factor.
- Values are clamped to the range [0.01,5.0].
- @type mblurFactor: float
- @ivar mapOld: Number of frames the Map Old will last
- Values are clamped to the range [1,900].
- @type mapOld: int
- @ivar mapNew: New mapping value (in frames).
- Values are clamped to the range [1,900].
- @type mapNew: int
- @ivar set: The scene linked as a set to this scene. Values are an existing
- scene or None (setting to None clears the set). The scene argument cannot
- cause a circular link.
- @type set: BPy_Scene or None
- @ivar yafrayGIMethod: Global Illumination method.
- Valid values are NONE (0), SKYDOME (1) or FULL (2).
- @type yafrayGIMethod: int {NONE (0), SKYDOME (1), GIFULL (2)}
- @ivar yafrayGIQuality: Global Illumination quality.
- @type yafrayGIQuality: int {NONE (0), LOW (1), MEDIUM (2), HIGH (3), HIGHER (4), BEST (5), USEAOSETTINGS (6)}
- @ivar yafrayExportToXML: If true export to an xml file and call yafray instead of plugin.
- @type yafrayExportToXML: boolean
- @ivar yafrayAutoAntiAliasing: Automatic anti-aliasing enabled/disabled.
- @type yafrayAutoAntiAliasing: boolean
- @ivar yafrayClampRGB: Clamp RGB enabled/disabled.
- @type yafrayClampRGB: boolean
- @ivar yafrayAntiAliasingPasses: Number of anti-aliasing passes (0 is no Anti-Aliasing).
- @type yafrayAntiAliasingPasses: int [0, 64]
- @ivar yafrayAntiAliasingSamples: Number of samples per pass.
- @type yafrayAntiAliasingSamples: int [0, 2048]
- @ivar yafrayAntiAliasingPixelSize: Anti-aliasing pixel filter size.
- @type yafrayAntiAliasingPixelSize: float [1.0, 2.0]
- @ivar yafrayAntiAliasingThreshold: Anti-aliasing threshold.
- @type yafrayAntiAliasingThreshold: float [0.05, 1.0]
- @ivar yafrayNumberOfProcessors: Number of processors to use.
- @type yafrayNumberOfProcessors: int [1, 8]
- @ivar yafrayGICache: Cache occlusion/irradiance samples (faster).
- @type yafrayGICache: boolean
- @ivar yafrayGICacheBumpNormals: Enable/disable bumpnormals for cache.
- @type yafrayGICacheBumpNormals: boolean
- @ivar yafrayGICacheShadowQuality: Shadow quality, keep it under 0.95 :-).
- @type yafrayGICacheShadowQuality: float [0.01, 1.0]
- @ivar yafrayGICachePixelsPerSample: Maximum number of pixels without samples, the lower the better and slower.
- @type yafrayGICachePixelsPerSample: int [1, 50]
- @ivar yafrayGICacheRefinement: Threshold to refine shadows EXPERIMENTAL. 1 = no refinement.
- @type yafrayGICacheRefinement: float [0.001, 1.0]
- @ivar yafrayGIPhotons: Enable/disable use of global photons to help in GI.
- @type yafrayGIPhotons: boolean
- @ivar yafrayGITunePhotons: If true the photonmap is shown directly in the render for tuning.
- @type yafrayGITunePhotons: boolean
- """
-
- def currentFrame(frame = None):
- """
- Get/set the current frame.
- @type frame: int (optional)
- @param frame: must be between 1 - 30000
- @rtype: int (if prototype is empty)
- @return: Current frame for the scene.
- """
-
- def render():
- """
- Render the scene.
- """
-
- def renderAnim():
- """
- Render a series of frames to an output directory.
- """
-
- def saveRenderedImage(filename, zbuffer=0):
- """
- Saves the image rendered using RenderData.render() to the filename and path
- given in the variable 'filename'.
-
- Make sure the filename you provide makes a valid path when added to the "render path"
- (setRenderPath/getRenderPath) to make up the absolute path.
- If you want to render to a new absolute path just set the renderpath to an
- empty string and use the absolute path as the filename.
- @param filename: The path+filename for the rendered image.
- @type zbuffer: int
- @param zbuffer: Whether or not to render the zbuffer along with the image.
- @type filename: string
- @since: 2.40
- @requires: You must have an image currently rendered before calling this method
- """
-
- def play():
- """
- play animation of rendered images/avi (searches Pics: field).
- """
-
- def getTimeCode():
- """
- Get the current frame as a string in HH:MM:SS:FF format
- @rtype: string
- @return: current frame as a string in HH:MM:SS:FF format
- """
-
- def setRenderPath(path):
- """
- Set the path to where the renderer will write to.
- @type path: string
- @param path: A directory for that the renderer searches for
- both playback and output from the renderAnim function.
- """
-
- def getRenderPath():
- """
- Get the path to where the renderer will write to.
- @rtype: string
- @return: Returns the directory that is used to playback and store rendered
- sequences.
- """
-
- def setBackbufPath(path):
- """
- Set the path to a background image and load it.
- @type path: string
- @param path: The path to a background image for loading.
- """
-
- def getBackbufPath():
- """
- Get the path to the background image.
- @rtype: string
- @return: The path to a background image.
- """
-
- def enableBackbuf(toggle):
- """
- Enable/disable the backbuf image.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def setFtypePath(path):
- """
- Set the path to Ftype file.
- @type path: string
- @param path: Path to Ftype Image type.
- """
-
- def getFtypePath():
- """
- Get the path to the Ftype file
- @rtype: string
- @return: Path to FtypeImage type.
- """
-
- def enableExtensions(toggle):
- """
- Enable/disable windows extensions for output files.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableSequencer(toggle):
- """
- Enable/disable Do Sequence.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableRenderDaemon(toggle):
- """
- Enable/disable Scene daemon.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableToonShading(toggle):
- """
- Enable/disable Edge rendering.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def edgeIntensity(intensity = None):
- """
- Get/set edge intensity for toon shading.
- @type intensity: int (optional)
- @param intensity: must be between 0 - 255
- @rtype: int (if prototype is empty)
- @return: Current edge intensity for the scene.
- """
-
- def setEdgeColor(red, green, blue):
- """
- Set the edge color for toon shading.
- @type red: float
- @param red: must be between 0 - 1.0
- @type green: float
- @param green: must be between 0 - 1.0
- @type blue: float
- @param blue: must be between 0 - 1.0
- """
-
- def getEdgeColor():
- """
- Get the edge color for toon shading.
- @rtype: string
- @return: A string representing the edge color.
- """
-
- def edgeAntiShift(intensity = None):
- """
- With the unified renderer, reduce intensity on boundaries.
- @type intensity: int (optional)
- @param intensity: must be between 0 - 255
- @rtype: int (if prototype is empty)
- @return: Current edge antishift for the scene.
- """
-
- def enableOversampling(toggle):
- """
- Enable/disable oversampling (anti-aliasing).
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def setOversamplingLevel(level):
- """
- Set the level of over-sampling (anti-aliasing).
- @type level: int
- @param level: can be either 5, 8, 11, or 16
- """
-
- def enableMotionBlur(toggle):
- """
- Enable/disable MBlur.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def motionBlurLevel(level = None):
- """
- Get/set the length of shutter time for motion blur.
- @type level: float (optional)
- @param level: must be between 0.01 - 5.0
- @rtype: float (if prototype is empty)
- @return: Current MBlur for the scene.
- """
-
- def partsX(parts = None):
- """
- Get/set the number of parts to divide the render in the X direction.
- @type parts: int (optional)
- @param parts: must be between 1 - 64
- @rtype: int (if prototype is empty)
- @return: Current number of parts in the X for the scene.
- """
-
- def partsY(parts = None):
- """
- Get/set the number of parts to divide the render in the Y direction.
- @type parts: int (optional)
- @param parts: must be between 1 - 64
- @rtype: int (if prototype is empty)
- @return: Current number of parts in the Y for the scene.
- """
-
- def enableSky():
- """
- Enable render background with sky.
- """
-
- def enablePremultiply():
- """
- Enable premultiply alpha.
- """
-
- def enableKey():
- """
- Enable alpha and color values remain unchanged.
- """
-
- def enableShadow(toggle):
- """
- Enable/disable shadow calculation.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableEnvironmentMap(toggle):
- """
- Enable/disable environment map rendering.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableRayTracing(toggle):
- """
- Enable/disable ray tracing.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableRadiosityRender(toggle):
- """
- Enable/disable radiosity rendering.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enablePanorama(toggle):
- """
- Enable/disable panorama rendering (output width is multiplied by Xparts).
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def setRenderWinSize(size):
- """
- Set the size of the render window.
- @type size: int
- @param size: can be 25, 50, 75 or 100 (percent).
- """
-
- def getRenderWinSize():
- """
- Get the size of the render window.
- @rtype: int
- @return: window size; can be 25, 50, 75 or 100 (percent).
- """
-
- def enableFieldRendering(toggle):
- """
- Enable/disable field rendering
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableOddFieldFirst(toggle):
- """
- Enable/disable Odd field first rendering (Default: Even field).
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableFieldTimeDisable(toggle):
- """
- Enable/disable time difference in field calculations.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableGaussFilter(toggle):
- """
- Enable/disable Gauss sampling filter for anti-aliasing.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableBorderRender(toggle):
- """
- Enable/disable small cut-out rendering.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def setBorder(left,bottom,right,top):
- """
- Set a border for rendering from cameras in the scene.
- The left,bottom coordinates and right,top coordinates
- define the size of the border. (0,0,1,1) will set the border
- to the whole camera. (0,0) lower left and (1,1) upper right.
- @type left: float
- @param left: float between 0 and 1
- @type right: float
- @param right: float between 0 and 1
- @type bottom: float
- @param bottom: float between 0 and 1
- @type top: float
- @param top: float between 0 and 1
- """
-
- def enableGammaCorrection(toggle):
- """
- Enable/disable gamma correction.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def gaussFilterSize(size = None):
- """
- Get/sets the Gauss filter size.
- @type size: float (optional)
- @param size: must be between 0.5 - 1.5
- @rtype: float (if prototype is empty)
- @return: Current gauss filter size for the scene.
- """
-
- def startFrame(frame = None):
- """
- Get/set the starting frame for sequence rendering.
- @type frame: int (optional)
- @param frame: must be between 1 - 18000
- @rtype: int (if prototype is empty)
- @return: Current starting frame for the scene.
- """
-
- def endFrame(frame = None):
- """
- Get/set the ending frame for sequence rendering.
- @type frame: int (optional)
- @param frame: must be between 1 - 18000
- @rtype: int (if prototype is empty)
- @return: Current ending frame for the scene.
- """
-
- def imageSizeX(size = None):
- """
- Get/set the image width in pixels.
- @type size: int (optional)
- @param size: must be between 4 - 10000
- @rtype: int (if prototype is empty)
- @return: Current image width for the scene.
- """
-
- def imageSizeY(size = None):
- """
- Get/set the image height in pixels.
- @type size: int (optional)
- @param size: must be between 4 - 10000
- @rtype: int (if prototype is empty)
- @return: Current image height for the scene.
- """
-
- def aspectRatioX(ratio = None):
- """
- Get/set the horizontal aspect ratio.
- @type ratio: int (optional)
- @param ratio: must be between 1 - 200
- @rtype: int (if prototype is empty)
- @return: Current horizontal aspect ratio for the scene.
- """
-
- def aspectRatioY(ratio = None):
- """
- Get/set the vertical aspect ratio.
- @type ratio: int (optional)
- @param ratio: must be between 1 - 200
- @rtype: int (if prototype is empty)
- @return: Current vertical aspect ratio for the scene.
- """
-
- def setRenderer(type):
- """
- Get/set which renderer to render the output.
- @type type: enum constant
- @param type: must be one of 2 constants:
- - INTERN: Blender's internal renderer
- - YAFRAY: Yafray renderer
- """
-
- def enableCropping(toggle):
- """
- Enable/disable exclusion of border rendering from total image.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def setImageType(type):
- """
- Set the type of image to output from the render.
- @type type: enum constant
- @param type: must be one of 13 constants:
- - AVIRAW: Uncompressed AVI files. AVI is a commonly used format on Windows platforms
- - AVIJPEG: AVI movie w/ JPEG images
- - AVICODEC: AVI using win32 codec
- - QUICKTIME: Quicktime movie (if enabled)
- - TARGA: Targa files
- - RAWTGA: Raw Targa files
- - PNG: Png files
- - BMP: Bitmap files
- - JPEG90: JPEG files
- - HAMX: Hamx files
- - IRIS: Iris files
- - IRIZ: Iris + z-buffer files
- - FTYPE: Ftype file
- """
-
- def quality(qual = None):
- """
- Get/set quality get/setting for JPEG images, AVI JPEG and SGI movies.
- @type qual: int (optional)
- @param qual: must be between 10 - 100
- @rtype: int (if prototype is empty)
- @return: Current image quality for the scene.
- """
-
- def framesPerSec(qual = None):
- """
- Get/set frames per second.
- @type qual: int (optional)
- @param qual: must be between 1 - 120
- @rtype: int (if prototype is empty)
- @return: Current frames per second for the scene.
- """
-
- def enableGrayscale():
- """
- Images are saved with black and white (grayscale) data.
- """
-
- def enableRGBColor():
- """
- Images are saved with RGB (color) data.
- """
-
- def enableRGBAColor():
- """
- Images are saved with RGB and Alpha data (if supported).
- """
-
- def sizePreset(type):
- """
- Set the renderer to one of a few presets.
- @type type: enum constant
- @param type: must be one of 8 constants:
- - PAL: The European video standard: 720 x 576 pixels, 54 x 51 aspect.
- - FULL: For large screens: 1280 x 1024 pixels.
- - PREVIEW: For preview rendering: 320 x 256 pixels.
- - PAL169: Wide-screen PAL.
- - DEFAULT: Like "PAL", but here the render settings are also set.
- - PANO: Panorama render.
- - NTSC: For TV playback.
- - PC: For standard PC graphics: 640 x 480 pixels.
- """
-
- def enableUnifiedRenderer(toggle):
- """
- Use the unified renderer.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def setYafrayGIQuality(type):
- """
- Set yafray global Illumination quality.
- @type type: enum constant
- @param type: must be one of 6 constants:
- - NONE
- - LOW
- - MEDIUM
- - HIGH
- - HIGHER
- - BEST
- - USEAOSETTINGS
- """
-
- def getYafrayGIQuality():
- """
- Get yafray global Illumination quality.
- @rtype: enum constant
- @return: one of 6 constants:
- - NONE
- - LOW
- - MEDIUM
- - HIGH
- - HIGHER
- - BEST
- - USEAOSETTINGS
- """
-
- def setYafrayGIMethod(type):
- """
- Set yafray global Illumination method.
- @type type: enum constant
- @param type: must be one of 3 constants:
- - NONE: Do not use GI illumination
- - SKYDOME: Use Skydome method
- - GIFULL: Use Full method
- """
-
- def getYafrayGIMethod():
- # (dietrich) 2007/06/01
- """
- Get yafray global Illumination method.
- @rtype: enum constant -
- @return: Current yafray global illumination method:
- - NONE: Do not use GI illumination
- - SKYDOME: Use Skydome method
- - GIFULL: Use Full method
- """
-
- def yafrayGIPower(power = None):
- """
- Get/set GI lighting intensity scale.
- YafrayMethod must be either SKYDOME or GIFULL.
- @type power: float (optional)
- @param power: must be between 0.01 - 100.0
- @rtype: float (if prototype is empty)
- @return: Current yafray global illumination intensity for the scene.
- """
-
- def yafrayGIIndirPower(power = None):
- """
- Get/set GI indirect lighting intensity scale.
- @type power: float (optional)
- @param power: must be between 0.01 - 100.0
- @rtype: float (if prototype is empty)
- @return: Current yafray indirect illumination intensity for the scene.
- """
-
- def yafrayGIDepth(depth = None):
- """
- Get/set number of bounces of the indirect light.
- YafrayMethod must be GIFULL.
- @type depth: int (optional)
- @param depth: must be between 1 - 8
- @rtype: int (if prototype is empty)
- @return: Current yafray global illumination light bounces for the scene.
- """
-
- def yafrayGICDepth(depth = None):
- """
- Get/set number of bounces inside objects (for caustics).
- YafrayMethod must be GIFULL.
- @type depth: int (optional)
- @param depth: must be between 1 - 8
- @rtype: int (if prototype is empty)
- @return: Current yafray global illumination inside light bounces for the scene.
- """
-
- def enableYafrayGICache(toggle):
- """
- Enable/disable cache irradiance samples (faster).
- YafrayMethod must be GIFULL.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def enableYafrayGIPhotons(toggle):
- """
- Enable/disable use of global photons to help in GI.
- YafrayMethod must be GIFULL.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def yafrayGIPhotonCount(count = None):
- """
- Get/set number of photons to shoot.
- YafrayMethod must be GIFULL and Photons enabled.
- @type count: int (optional)
- @param count: must be between 0 - 10000000
- @rtype: int (if prototype is empty)
- @return: Current number of photons to shoot for the scene.
- """
-
-
- def yafrayGIPhotonRadius(radius = None):
- """
- Get/set radius to search for photons to mix (blur).
- YafrayMethod must be GIFULL and Photons enabled.
- @type radius: float (optional)
- @param radius: must be between 0.00001 - 100.0
- @rtype: float (if prototype is empty)
- @return: Current photon search radius for the scene.
- """
-
-
- def yafrayGIPhotonMixCount(count = None):
- """
- Get/set number of photons to keep inside radius.
- YafrayMethod must be GIFULL and Photons enabled.
- @type count: int (optional)
- @param count: must be between 0 - 1000
- @rtype: int (if prototype is empty)
- @return: Current number of photons to keep inside radius for the scene.
- """
-
- def enableYafrayGITunePhotons(toggle):
- """
- Enable/disable show the photon map directly in the render for tuning.
- YafrayMethod must be GIFULL and Photons enabled.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def yafrayGIShadowQuality(qual = None):
- """
- Get/set the shadow quality, keep it under 0.95.
- YafrayMethod must be GIFULL and Cache enabled.
- @type qual: float (optional)
- @param qual: must be between 0.01 - 1.0
- @rtype: float (if prototype is empty)
- @return: Current shadow quality for the scene.
- """
-
- def yafrayGIPixelsPerSample(pixels = None):
- """
- Get/set maximum number of pixels without samples, the lower the better and slower.
- YafrayMethod must be GIFULL and Cache enabled.
- @type pixels: int (optional)
- @param pixels: must be between 1 - 50
- @rtype: int (if prototype is empty)
- @return: Current number of pixels without samples for the scene.
- """
-
- def enableYafrayGIGradient(toggle):
- """
- Enable/disable try to smooth lighting using a gradient.
- YafrayMethod must be GIFULL and Cache enabled.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def yafrayGIRefinement(refine = None):
- """
- Get/set threshold to refine shadows EXPERIMENTAL. 1 = no refinement.
- YafrayMethod must be GIFULL and Cache enabled.
- @type refine: float (optional)
- @param refine: must be between 0.001 - 1.0
- @rtype: float (if prototype is empty)
- @return: Current threshold to refine shadows for the scene.
- """
-
- def yafrayRayBias(bias = None):
- """
- Get/set shadow ray bias to avoid self shadowing.
- @type bias: float (optional)
- @param bias: must be between 0 - 10.0
- @rtype: float (if prototype is empty)
- @return: Current ray bias for the scene.
- """
-
- def yafrayRayDepth(depth = None):
- """
- Get/set maximum render ray depth from the camera.
- @type depth: int (optional)
- @param depth: must be between 1 - 80
- @rtype: int (if prototype is empty)
- @return: Current ray depth for the scene.
- """
-
- def yafrayGamma(gamma = None):
- """
- Get/set gamma correction, 1 is off.
- @type gamma: float (optional)
- @param gamma: must be between 0.001 - 5.0
- @rtype: float (if prototype is empty)
- @return: Current gamma correction for the scene.
- """
-
- def yafrayExposure(expose = None):
- """
- Get/set exposure adjustment, 0 is off.
- @type expose: float (optional)
- @param expose: must be between 0 - 10.0
- @rtype: float (if prototype is empty)
- @return: Current exposure adjustment for the scene.
- """
-
- def yafrayProcessorCount(count = None):
- """
- Get/set number of processors to use.
- @type count: int (optional)
- @param count: must be between 1 - 8
- @rtype: int (if prototype is empty)
- @return: Current number of processors for the scene.
- """
-
- def enableGameFrameStretch():
- """
- Enable stretch or squeeze the viewport to fill the display window.
- """
-
- def enableGameFrameExpose():
- """
- Enable show the entire viewport in the display window, viewing more
- horizontally or vertically.
- """
-
- def enableGameFrameBars():
- """
- Enable show the entire viewport in the display window, using bar
- horizontally or vertically.
- """
-
- def setGameFrameColor(red, green, blue):
- """
- Set the red, green, blue component of the bars.
- @type red: float
- @param red: must be between 0 - 1.0
- @type green: float
- @param green: must be between 0 - 1.0
- @type blue: float
- @param blue: must be between 0 - 1.0
- """
-
- def getGameFrameColor():
- """
- Set the red, green, blue component of the bars.
- @rtype: string
- @return: A string representing the color component of the bars.
- """
-
- def gammaLevel(level = None):
- """
- Get/set the gamma value for blending oversampled images (1.0 = no correction).
- Unified renderer must be enabled.
- @type level: float (optional)
- @param level: must be between 0.2 - 5.0
- @rtype: float (if prototype is empty)
- @return: Current gamma value for the scene.
- """
-
- def postProcessAdd(add = None):
- """
- Get/set post processing add.
- Unified renderer must be enabled.
- @type add: float (optional)
- @param add: must be between -1.0 - 1.0
- @rtype: float (if prototype is empty)
- @return: Current processing add value for the scene.
- """
-
- def postProcessMultiply(mult = None):
- """
- Get/set post processing multiply.
- Unified renderer must be enabled.
- @type mult: float (optional)
- @param mult: must be between 0.01 - 4.0
- @rtype: float (if prototype is empty)
- @return: Current processing multiply value for the scene.
- """
-
- def postProcessGamma(gamma = None):
- """
- Get/set post processing gamma.
- Unified renderer must be enabled.
- @type gamma: float (optional)
- @param gamma: must be between 0.2 - 2.0
- @rtype: float (if prototype is empty)
- @return: Current processing gamma value for the scene.
- """
-
- def SGIMaxsize(size = None):
- """
- Get/set maximum size per frame to save in an SGI movie.
- SGI must be defined on your machine.
- @type size: int (optional)
- @param size: must be between 0 - 500
- @rtype: int (if prototype is empty)
- @return: Current SGI maximum size per frame for the scene.
- """
-
- def enableSGICosmo(toggle):
- """
- Enable/disable attempt to save SGI movies using Cosmo hardware
- SGI must be defined on your machine.
- @type toggle: int
- @param toggle: pass 1 for on / 0 for off
- """
-
- def oldMapValue(value = None):
- """
- Get/set specify old map value in frames.
- @type value: int (optional)
- @param value: must be between 1 - 900
- @rtype: int (if prototype is empty)
- @return: Current old map value for the scene.
- """
-
- def newMapValue(value = None):
- """
- Get/set specify new map value in frames.
- @type value: int (optional)
- @param value: must be between 1 - 900
- @rtype: int (if prototype is empty)
- @return: Current new map value for the scene.
- """
diff --git a/source/blender/python/api2_2x/doc/Scene.py b/source/blender/python/api2_2x/doc/Scene.py
deleted file mode 100644
index 77e33e143f5..00000000000
--- a/source/blender/python/api2_2x/doc/Scene.py
+++ /dev/null
@@ -1,392 +0,0 @@
-# Blender.Scene module and the Scene PyType object
-
-"""
-The Blender.Scene submodule.
-
-B{New}:
- - L{Scene.clearScriptLinks<Scene.Scene.clearScriptLinks>} accepts a parameter now.
- - acess methods L{Scene.getLayers<Scene.Scene.getLayers>}, L{Scene.setLayers<Scene.Scene.setLayers>} via lists to complement the layers and
- Layers Scene attributes which use bitmasks.
-
-Scene
-=====
-
-This module provides access to B{Scenes} in Blender.
-
-Example::
- import Blender
- from Blender import Scene, Object, Camera
- #
- camdata = Camera.New('persp') # create new camera data
- camdata.name = 'newCam'
- camdata.lens = 16.0
- scene = Scene.New('NewScene') # create a new scene
- scene.objects.new(camdata,'Camera') # add a new object to the scene with newly-created data
- scene.makeCurrent() # make this the current scene
-
-@warn: B{scene.objects.new} is the preferred way to add new objects to a scene.
- The older way is to create an object with B{Object.New()}, link the
- data to the new object, then link the object to the scene. This way is
- not recommended since a forgotten step or run-time error in the script can
- cause bad things to be done to Blender's database.
-
- If you use this older method, it's recommended to always perform the
- operations in this order. This is because if
- there is no object data linked to an object B{ob}, B{scene.link(ob)} will
- automatically create the missing data. This is OK on its own, but I{if
- after that} object B{ob} is linked to obdata, the automatically created one
- will be discarded -- as expected -- but will stay in Blender's memory
- space until the program is exited, since Blender doesn't really get rid of
- most kinds of data. So first linking ObData to object, then object to
- scene is a tiny tiny bit faster than the other way around and also saves
- some realtime memory (if many objects are created from scripts, the
- savings become important).
-"""
-
-def New (name = 'Scene'):
- """
- Create a new Scene in Blender.
- @type name: string
- @param name: The Scene name.
- @rtype: Blender Scene
- @return: The created Scene.
- """
-
-def Get (name = None):
- """
- Get the Scene(s) from Blender.
- @type name: string
- @param name: The name of a Scene.
- @rtype: Blender Scene or a list of Blender Scenes
- @return: It depends on the I{name} parameter:
- - (name): The Scene with the given I{name};
- - (): A list with all Scenes currently in Blender.
- """
-
-def GetCurrent():
- """
- Get the currently active Scene in Blender.
- @rtype: Blender Scene
- @return: The currently active Scene.
- """
-
-def Unlink(scene):
- """
- Unlink (delete) a Scene from Blender.
- @type scene: Blender Scene
- @param scene: The Scene to be unlinked.
- """
-
-from IDProp import IDGroup, IDArray
-class Scene:
- """
- The Scene object
- ================
- This object gives access to Scene data in Blender.
- @type Layers: integer (bitmask)
- @ivar Layers: The Scene layers (check also the easier to use
- L{layers}). This value is a bitmask with at least
- one position set for the 20 possible layers starting from the low order
- bit. The easiest way to deal with these values in in hexadecimal
- notation.
- Example::
- scene.Layers = 0x04 # sets layer 3 ( bit pattern 0100 )
- scene.Layers |= 0x01
- print scene.Layers # will print: 5 ( meaning bit pattern 0101)
- After setting the Layers value, the interface (at least the 3d View and
- the Buttons window) needs to be redrawn to show the changes.
- @type layers: list of integers
- @ivar layers: The Scene layers (check also L{Layers}).
- This attribute accepts and returns a list of integer values in the
- range [1, 20].
- Example::
- scene.layers = [3] # set layer 3
- scene.layers = scene.layers.append(1)
- print scene.layers # will print: [1, 3]
- @type objects: sequence of objects
- @ivar objects: The scene's objects. The sequence supports the methods .link(ob), .unlink(ob), and .new(obdata), and can be iterated over.
- @type cursor: Vector (wrapped)
- @ivar cursor: the 3d cursor location for this scene.
- @type camera: Camera or None
- @ivar camera: The active camera for this scene (can be set)
- @type world: World or None
- @ivar world: The world that this scene uses (if any)
- @type timeline: Timeline
- @ivar timeline: The L{timeline<TimeLine.TimeLine>} for this scene, named markers are stored here. (read only)
- @type render: RenderData
- @ivar render: The scenes L{render<Render.RenderData>} settings. (read only)
- @type radiosity: RenderData
- @ivar radiosity: The scenes L{radiosity<Radio>} settings. (read only)
- """
-
- def getName():
- """
- Get the name of this Scene.
- @rtype: string
- """
-
- def setName(name):
- """
- Set the name of this Scene.
- @type name: string
- @param name: The new name.
- """
-
- def getLayers():
- """
- Get the layers set for this Scene.
- @rtype: list of integers
- @return: a list where each number means the layer with that number is set.
- """
-
- def setLayers(layers):
- """
- Set the visible layers for this scene.
- @type layers: list of integers
- @param layers: a list of integers in the range [1, 20], where each available
- index makes the layer with that number visible.
- @note: if this Scene is the current one, the 3D View layers are also
- updated, but the screen needs to be redrawn (at least 3D Views and
- Buttons windows) for the changes to be seen.
- """
-
- def copy(duplicate_objects = 1):
- """
- Make a copy of this Scene.
- @type duplicate_objects: int
- @param duplicate_objects: Defines how the Scene children are duplicated:
- - 0: Link Objects;
- - 1: Link Object Data;
- - 2: Full copy.
- @rtype: Scene
- @return: The copied Blender Scene.
- """
-
- def makeCurrent():
- """
- Make this Scene the currently active one in Blender.
- """
-
- def update(full = 0):
- """
- Update this Scene in Blender.
- @type full: int
- @param full: A bool to control the level of updating:
- - 0: sort the base list of objects.
- - 1: sort and also regroup, do ipos, keys, script links, etc.
- @warn: When in doubt, try with I{full = 0} first, since it is faster.
- The "full" update is a recent addition to this method.
- """
-
- def getRenderingContext():
- """
- Get the rendering context for this scene, see L{Render}.
- @rtype: RenderData
- @return: the render data object for this scene.
- """
-
- def getRadiosityContext():
- """
- Get the radiosity context for this scene, see L{Radio}.
- @rtype: Blender Radiosity
- @return: the radiosity object for this scene.
- @note: only the current scene can return a radiosity context.
- """
-
- def getChildren():
- """
- Get all objects linked to this Scene. (B{deprecated}). B{Note}: new scripts
- should use the L{objects} attribute instead. In cases where a list is
- required use list(scn.objects).
- @rtype: list of Blender Objects
- @return: A list with all Blender Objects linked to this Scene.
- @note: L{Object.Get} will return all objects currently in Blender, which
- means all objects from all available scenes. In most cases (exporter
- scripts, for example), it's probably better to use this
- scene.GetChildren instead, since it will only access objects from this
- particular scene.
- @warn: Depricated! use scene.objects instead.
- """
-
- def getActiveObject():
- """
- Get this scene's active object.
- @note: the active object, if selected, can also be retrieved with
- L{Object.GetSelected} -- it is the first item in the returned
- list. But even when no object is selected in Blender, there can be
- an active one (if the user enters editmode, for example, this is the
- object that should become available for edition). So what makes this
- scene method different from C{Object.GetSelected()[0]} is that it can
- return the active object even when no objects are selected.
- @rtype: Blender Object or None
- @return: the active object or None if not available.
- @warn: Depricated! use scene.objects.active instead.
- """
-
- def getCurrentCamera():
- """
- Get the currently active Camera for this Scene.
- @note: The active camera can be any object type, not just a camera object.
- @rtype: Blender Object
- @return: The currently active Camera object.
- """
-
- def setCurrentCamera(camera):
- """
- Set the currently active Camera in this Scene.
- @type camera: Blender Camera
- @param camera: The new active Camera.
- """
-
- def link(object):
- """
- Link an Object to this Scene.
- @type object: Blender Object
- @param object: A Blender Object.
- """
-
- def unlink(object):
- """
- Unlink an Object from this Scene.
- @type object: Blender Object
- @param object: A Blender Object.
- @rtype: boolean
- @return: true if object was found in the scene.
- """
-
- def getScriptLinks (event):
- """
- Get a list with this Scene's script links of type 'event'.
- @type event: string
- @param event: "FrameChanged", "OnLoad", "OnSave", "Redraw" or "Render".
- @rtype: list
- @return: a list with Blender L{Text} names (the script links of the given
- 'event' type) or None if there are no script links at all.
- """
-
- def clearScriptLinks (links = None):
- """
- Delete script links from this Scene. If no list is specified, all
- script links are deleted.
- @type links: list of strings
- @param links: None (default) or a list of Blender L{Text} names.
- """
-
- def addScriptLink (text, event):
- """
- Add a new script link to this Scene.
-
- Using OpenGL functions within a scene ScriptLink will draw graphics over the 3D view.
- There is an issue with the zoom of the floating panels also scaling graphics drawn by your scriptlink.
- This makes matching OpenGL graphics to mouse location impossible.
- Make sure that you use floating point for operations that you would usually use int functions for: glRasterPos2f rather then glRasterPos2i.
-
- The following example shows how you can use the OpenGL model view matrix to obtain the scale value.
-
- Example::
- from Blender import BGL
- view_matrix = BGL.Buffer(BGL.GL_FLOAT, 16)
- BGL.glGetFloatv(BGL.GL_MODELVIEW_MATRIX, view_matrix)
- gl_scale = 1/viewMatrix[0]
-
- # Now that we have the scale we can draw to the correct scale.
- BGL.glRect2f(10*gl_scale, 10*gl_scale, 110*gl_scale, 110*gl_scale)
-
-
- @type text: string
- @param text: the name of an existing Blender L{Text}.
- @type event: string
- @param event: "FrameChanged", "OnLoad", "OnSave", "Redraw" or "Render".
- """
-
- def play (mode = 0, win = '<VIEW3D>'):
- """
- Play a realtime animation. This is the "Play Back Animation" function in
- Blender, different from playing a sequence of rendered images (for that
- check L{Render.RenderData.play}).
- @type mode: int
- @param mode: controls playing:
- - 0: keep playing in the biggest 'win' window;
- - 1: keep playing in all 'win', VIEW3D and SEQ windows;
- - 2: play once in the biggest VIEW3D;
- - 3: play once in all 'win', VIEW3D and SEQ windows.
- @type win: int
- @param win: window type, see L{Window.Types}. Only some of them are
- meaningful here: VIEW3D, SEQ, IPO, ACTION, NLA, SOUND. But the others
- are also accepted, since this function can be used simply as an
- interruptible timer. If 'win' is not visible or invalid, VIEW3D is
- tried, then any bigger visible window.
- @rtype: bool
- @return: 0 on normal exit or 1 when play back is canceled by user input.
- """
-
-import id_generics
-Scene.__doc__ += id_generics.attributes
-
-
-class SceneObjects:
- """
- The SceneObjects (Scene ObjectSeq) object
- =========================================
- This object gives access to the Objects in a Scene in Blender.
-
- Example::
- from Blender import Scene
- scn = Scene.GetCurrent()
-
- scn.objects.selected = [] # select none
- scn.objects.selected = scn.objects # select all
- scn.objects.context = scn.objects # select all and move into the scenes display layer
-
- # get a list of mesh objects
- obs = [ob for ob in scn.objects if ob.type == 'Mesh']
-
- # Select only these mesh objects
- scn.objects.selected = obs
-
- # print all object names
- for ob in scn.objects: print ob.name
-
- # make a list of objects that you can add and remove to
- # will not affect the current scene
- scene_obs = list(scn.objects)
-
- @ivar selected: an iterator over all the selected objects in a scene.
- @type selected: sequence of L{Object}
- @ivar context: an iterator over all the visible selected objects in a scene.
- @type context: sequence of L{Object}
- @ivar active: the active object in the scene.
- @type active: L{Object}
- @ivar camera: the active camera in the scene.
- @type camera: L{Object}
- """
-
- def new(data):
- """
- Adds a new object to the scene. Data is either object data such as a
- L{Mesh} or L{Curve}, or the string "Empty" for an Empty object. The
- type of the object is determined by the type of the data.
- @type data: string or object data
- @param data: the object data for the new object
- @return: the new object.
- @rtype: L{Object}
- """
-
- def link(object):
- """
- Adds an existing object to the scene. If the object is already linked
- to the scene, no action is taken and no exception is raised.
- @type object: L{Object}
- @param object: the object
- @rtype: None
- """
-
- def unlink(object):
- """
- Removes an object from the scene. If the object is not linked
- to the scene, no action is taken and no exception is raised.
- @type object: L{Object}
- @param object: the object
- @rtype: None
- """
-
diff --git a/source/blender/python/api2_2x/doc/Sound.py b/source/blender/python/api2_2x/doc/Sound.py
deleted file mode 100644
index bc3a929ec15..00000000000
--- a/source/blender/python/api2_2x/doc/Sound.py
+++ /dev/null
@@ -1,147 +0,0 @@
-# Blender.Sound module and the Sound PyType object
-
-"""
-The Blender.Sound submodule.
-
-Sound
-=====
-
-This module provides access to B{Sound} objects in Blender.
-
-Example::
- import Blender
- from Blender import Sound
- #
- sound = Sound.Load("/path/to/my/sound.wav") # load a sound file
- print "Sound from", sound.filename,
- print "loaded to obj", sound.name
- print "All Sounds available now:", Sound.Get()
-
-No way to get the actual audio data is provided by this library,
-but it is included in the Python standard library (module audioop).
-Note that using that module requires a full/normal Python installation.
-"""
-
-def Load (filename):
- """
- Load the sound called 'filename' into a Sound object.
- @type filename: string
- @param filename: The full path to the sound file.
- @rtype: Blender Sound
- @return: A Blender Sound object with the data from I{filename}.
- """
-
-def Get (name = None):
- """
- Get the Sound object(s) from Blender.
- @type name: string
- @param name: The name of the Sound object.
- @rtype: Blender Sound or a list of Blender Sounds
- @return: It depends on the I{name} parameter:
- - (name): The Sound object called I{name}, None if not found;
- - (): A list with all Sound objects in the current scene.
- """
-
-
-class Sound:
- """
- The Sound object
- ================
- This object gives access to Sounds in Blender.
- @ivar filename: The filename (path) to the sound file loaded into this Sound
- @ivar packed: Boolean, True when the sample is packed (readonly).
- """
-
- def getName():
- """
- Get the name of this Sound object.
- @rtype: string
- """
-
- def getFilename():
- """
- Get the filename of the sound file loaded into this Sound object.
- @rtype: string
- """
-
- def setName():
- """
- Set the name of this Sound object.
- @rtype: None
- """
-
- def setFilename():
- """
- Set the filename of the sound file loaded into this Sound object.
- @rtype: None
- """
-
- def setCurrent():
- """
- Make this the active sound in the sound buttons window (also redraws).
- """
-
- def play():
- """
- Play this sound.
- """
-
- def getVolume():
- """
- Get this sound's volume.
- rtype: float
- """
-
- def setVolume(f):
- """
- Set this sound's volume.
- @type f: float
- @param f: the new volume value in the range [0.0, 1.0].
- """
-
- def getAttenuation():
- """
- Get this sound's attenuation value.
- rtype: float
- """
-
- def setAttenuation(f):
- """
- Set this sound's attenuation.
- @type f: float
- @param f: the new attenuation value in the range [0.0, 5.0].
- """
-
- def getPitch():
- """
- Get this sound's pitch value.
- rtype: float
- """
-
- def setPitch(f):
- """
- Set this sound's pitch.
- @type f: float
- @param f: the new pitch value in the range [-12.0, 12.0].
- """
-
- def pack():
- """
- Packs the sound into the current blend file.
- @note: An error will be raised if the sound is already packed or the filename path does not exist.
- @returns: nothing
- @rtype: none
- """
-
- def unpack(mode):
- """
- Unpacks the sound to the samples filename.
- @param mode: One of the values in Blender.Unpackmodes dict.
- @note: An error will be raised if the sound is not packed or the filename path does not exist.
- @returns: nothing
- @rtype: none
- @type mode: int
- """
-
-import id_generics
-Sound.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/Sys.py b/source/blender/python/api2_2x/doc/Sys.py
deleted file mode 100644
index f1efeeb2344..00000000000
--- a/source/blender/python/api2_2x/doc/Sys.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Blender.sys module
-
-"""
-The Blender.sys submodule.
-
-sys
-===
-
-B{New}: L{expandpath}.
-
-This module provides a minimal set of helper functions and data. Its purpose
-is to avoid the need for the standard Python module 'os', in special 'os.path',
-though it is only meant for the simplest cases.
-
-Example::
-
- import Blender
-
- filename = ""
- def f(name): # file selector callback
- global filename
- filename = name
-
- Blender.Window.FileSelector(f)
-
- if filename:
- print 'basename:', Blender.sys.basename(filename)
- print 'dirname:', Blender.sys.dirname(filename)
- print 'splitext:', Blender.sys.splitext(filename)
-
- # what would basename(splitext(filename)[0]) print?
-
-@type sep: char
-@var sep: the platform-specific dir separator for this Blender: '/'
- everywhere, except on Win systems, that use '\\'.
-@type dirsep: char
-@var dirsep: same as L{sep}.
-@type progname: string
-@var progname: the Blender executable (argv[0]).
-
-@attention: The module is called sys, not Sys.
-"""
-
-def basename (path):
- """
- Get the base name (filename stripped from dir info) of 'path'.
- @type path: string
- @param path: a path name
- @rtype: string
- @return: the base name
- """
-
-def dirname (path):
- """
- Get the dir name (dir path stripped from filename) of 'path'.
- @type path: string
- @param path: a path name
- @rtype: string
- @return: the dir name
- """
-
-def join (dir, file):
- """
- Join the given dir and file paths, using the proper separator for each
- platform.
- @type dir: string
- @type file: string
- @param dir: the dir name, like returned from L{dirname}.
- @param file: the bare filename, like returned from L{basename}.
- @rtype: string
- @return: the resulting filename.
- @warn: this simple function isn't intended to be a complete replacement for
- the standard os.path.join() one, which handles more general cases.
- """
-
-def splitext (path):
- """
- Split 'path' into (root, ext), where 'ext' is a file extension including the full stop.
-
- Example::
-
- import Blender
- file, ext= Blender.sys.splitext('/tmp/foobar.blend')
- print file, ext
- # ('/tmp/foobar', '.blend')
-
- @type path: string
- @param path: a path name
- @rtype: tuple of two strings
- @return: (root, ext)
- @note: This function will raise an error if the path is longer then 80 characters.
- """
-
-def makename (path = "Blender.Get('filename')", ext = "", strip = 0):
- """
- Remove extension from 'path', append extension 'ext' (if given)
- to the result and return it. If 'strip' is non-zero, also remove
- dirname from path.
-
- Example::
- import Blender
- from Blender.sys import *
- print makename('/path/to/myfile.txt','.abc', 1) # returns 'myfile.abc'
-
- print makename('/path/to/myfile.obj', '-01.obj') # '/path/to/myfile-01.obj'
-
- print makename('/path/to/myfile.txt', strip = 1) # 'myfile'
-
- # note that:
- print makename(ext = '.txt')
- # is equivalent to:
- print sys.splitext(Blender.Get('filename'))[0]) + '.txt'
-
- @type path: string
- @param path: a path name or Blender.Get('filename'), if not given.
- @type ext: string
- @param ext: an extension to append. For flexibility, a dot ('.') is
- not automatically included.
- @rtype: string
- @return: the resulting string
- """
-
-def exists(path):
- """
- Tell if the given pathname (file or dir) exists.
- @rtype: int
- @return:
- - 0: path does not exist;
- - 1: path is an existing filename;
- - 2: path is an existing dirname;
- - -1: path exists but is neither a regular file nor a dir.
- """
-
-def time ():
- """
- Get the current time in seconds since a fixed value. Successive calls to
- this function are guaranteed to return values greater than the previous call.
- @rtype: float
- @return: the elapsed time in seconds.
- """
-
-def sleep (millisecs = 10):
- """
- Sleep for the specified amount of time.
- @type millisecs: int
- @param millisecs: the amount of time in milliseconds to sleep. The default
- is 10 which is 0.1 seconds.
- """
-
-def expandpath (path):
- """
- Expand the given Blender 'path' into an absolute and valid path.
- Internally, Blender recognizes two special character sequences in paths:
- - '//' (used at the beginning): means base path -- the current .blend file's
- dir;
- - '#' (used at the end): means current frame number.
- The expanded string can be passed to generic python functions that don't
- understand Blender's internal relative paths.
- @note: this function is also useful for obtaining the name of the image
- that will be saved when rendered.
- @note: if the passed string doesn't contain the special characters it is
- returned unchanged.
- @type path: string
- @param path: a path name.
- @rtype: string
- @return: the expanded (if necessary) path.
- """
diff --git a/source/blender/python/api2_2x/doc/Text.py b/source/blender/python/api2_2x/doc/Text.py
deleted file mode 100644
index 98ecb664b71..00000000000
--- a/source/blender/python/api2_2x/doc/Text.py
+++ /dev/null
@@ -1,129 +0,0 @@
-# Blender.Text module and the Text PyType object
-
-"""
-The Blender.Text submodule.
-
-Text Objects
-============
-
-This module provides access to B{Text} objects in Blender.
-
-Example::
- import Blender
- from Blender import Text
- #
- txt = Text.New("MyText") # create a new Text object
- print Text.Get() # current list of Texts in Blender
- txt.write("Appending some ") # appending text
- txt.write("text to my\\n") # '\\n' inserts new-line markers
- txt.write("text buffer.")
- print txt.asLines() # retrieving the buffer as a list of lines
- Text.unlink(txt) # removing a Text object
-"""
-
-def New (name = None, follow_cursor = 0):
- """
- Create a new Text object.
- @type name: string
- @param name: The Text name.
- @type follow_cursor: int
- @param follow_cursor: The text follow flag: if 1, the text display always
- follows the cursor.
- @rtype: Blender Text
- @return: The created Text Data object.
- """
-
-def Get (name = None):
- """
- Get the Text object(s) from Blender.
- @type name: string
- @param name: The name of the Text object.
- @rtype: Blender Text or a list of Blender Texts
- @return: It depends on the 'name' parameter:
- - (name): The Text object with the given name;
- - (): A list with all Text objects in the current scene.
- """
-
-def Load (filename):
- """
- Load a file into a Blender Text object.
- @type filename: string
- @param filename: The name of the file to load.
- @rtype: Blender Text
- @return: A Text object with the contents of the loaded file.
- """
-
-def unlink(textobj):
- """
- Unlink (remove) the given Text object from Blender.
- @type textobj: Blender Text
- @param textobj: The Text object to be deleted.
- """
-
-class Text:
- """
- The Text object
- ===============
- This object gives access to Texts in Blender.
- @ivar filename: The filename of the file loaded into this Text.
- @ivar mode: The follow_mode flag: if 1 it is 'on'; if 0, 'off'.
- @ivar nlines: The number of lines in this Text.
- """
-
- def getName():
- """
- Get the name of this Text object.
- @rtype: string
- """
-
- def setName(name):
- """
- Set the name of this Text object.
- @type name: string
- @param name: The new name.
- """
-
- def getFilename():
- """
- Get the filename of the file loaded into this Text object.
- @rtype: string
- """
-
- def getNLines():
- """
- Get the number of lines in this Text buffer.
- @rtype: int
- """
-
- def clear():
- """
- Clear this Text object: its buffer becomes empty.
- """
-
- def set(attribute, value):
- """
- Set this Text's attributes.
- @type attribute: string
- @param attribute: The attribute to change:
- currently, 'follow_cursor' is the only one available. It can be
- turned 'on' with value = 1 and 'off' with value = 0.
- @type value: int
- @param value: The new attribute value.
- """
-
- def write(data):
- """
- Append a string to this Text buffer.
- @type data: string
- @param data: The string to append to the text buffer.
- """
-
- def asLines():
- """
- Retrieve the contents of this Text buffer as a list of strings.
- @rtype: list of strings
- @return: A list of strings, one for each line in the buffer
- """
-
-import id_generics
-Text.__doc__ += id_generics.attributes \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/Text3d.py b/source/blender/python/api2_2x/doc/Text3d.py
deleted file mode 100644
index a7d8c585078..00000000000
--- a/source/blender/python/api2_2x/doc/Text3d.py
+++ /dev/null
@@ -1,302 +0,0 @@
-# Blender.Text3d module and the Text3d PyType object
-
-"""
-The Blender.Text3d submodule.
-
-Text3d Objects
-==============
-
-This module provides access to B{Font} objects in Blender.
-
-Example::
- import Blender
- from Blender import Curve, Object, Scene, Text3d
- txt = Text3d.New("MyText") # create a new Text3d object called MyText
- scn = Scene.GetCurrent() # get current scene
- ob = scn.objects.new(txt) # create an object from the obdata in the current scene
- ob.makeDisplayList() # rebuild the display list for this object
- Window.RedrawAll()
-"""
-
-def New (name = None):
- """
- Create a new Text3d object.
- @type name: string
- @param name: The name for the new object..
- @rtype: Blender Text3d
- @return: The created Text3d Data object.
- """
-
-def Get (name = None):
- """
- Get the Text3d object(s) from Blender.
- @type name: string
- @param name: The name of the Text3d object.
- @rtype: Blender Text3d or a list of Blender Text3d's
- @return: It depends on the 'name' parameter:
- - (name): The Text3d object with the given name;
- - (): A list with all Text3d objects in the current scene.
- """
-class Text3d:
- """
- The Text3d object
- =================
- This object gives access Blender's B{Font} objects
- @ivar frameWidth: The width of the active frame [0.0 - 50.0]
- @ivar frameHeight: The height of the active frame [0.0 - 50.0]
- @ivar frameX: The X position of the active frame [0.0 - 50.0]
- @ivar frameY: The Y position of the active frame [0.0 - 50.0]
-
- @ivar totalFrames: The total number of text frames (read only)
- @ivar activeFrame: The active frame for this text data.
- """
-
- def getName():
- """
- Get the name of this Text3d object.
- @rtype: string
- """
-
- def setName( name ):
- """
- Set the name of this Text3d object.
- @type name: string
- @param name: The new name.
- @returns: None
- """
-
- def getText():
- """
- Get text string for this object
- @rtype: string
- """
-
- def setText( name ):
- """
- Set the text string in this Text3d object
- @type name: string
- @param name: The new text string for this object.
- @returns: None
- """
-
- def getDrawMode():
- """
- Get the drawing mode (3d, front, and/or back)
- Gets the text3d's drawing modes. Uses module constants
- - DRAW3D : "3D" is set
- - DRAWFRONT : "Front" is set
- - DRAWBACK : "Back" is set
- @rtype: tuple of module constants
- """
-
- def setDrawMode(val):
- """
- Set the text3d's drawing mode. Uses module constants
- - DRAW3D
- - DRAWFRONT
- - DRAWBACK
- @rtype: None
- @type val: single module constant or tuple of module constants
- @param val : The Text3d's modes. See L{getDrawMode} for the meaning of
- the constants.
- """
-
- def getUVordco():
- """
- Return whether UV coords are used for Texture mapping
- """
-
- def setUVordco(val):
- """
- Set the font to use UV coords for Texture mapping
- """
-
- def getBevelAmount():
- """
- Get the Text3d's bevel resolution value.
- @rtype: float
- """
-
- def setBevelAmount(bevelresol):
- """
- Set the Text3d's bevel resolution value.
- @rtype: None
- @type bevelresol: float
- @param bevelresol: The new Curve's bevel resolution value.
- """
-
- def getDefaultResolution():
- """
- Return Default text resolution.
- @rtype: float
- """
-
- def setDefaultResolution(resolu):
- """
- Sets Default text Resolution.
- @rtype: None
- @type resolu: float
- @param resolu: The new Curve's U-resolution value.
- """
-
- def getWidth():
- """
- Get the Text3d's width value.
- @rtype: float
- """
-
- def setWidth(width):
- """
- Set the Text3d's width value.
- @rtype: None
- @type width: float
- @param width: The new text3d's width value.
- """
-
- def getExtrudeDepth():
- """
- Get the text3d's ext1 value.
- @rtype: float
- """
-
- def setExtrudeDepth(ext1):
- """
- Set the text3d's ext1 value.
- @rtype: None
- @type ext1: float
- @param ext1: The new text3d's ext1 value.
- """
-
- def getExtrudeBevelDepth():
- """
- Get the text3d's ext2 value.
- @rtype: float
- """
-
- def setExtrudeBevelDepth(ext2):
- """
- Set the text3d's ext2 value.
- @rtype: None
- @type ext2: float
- @param ext2: The new text3d's ext2 value.
- """
-
- def getShear():
- """
- Get the text3d's shear value.
- @rtype: float
- """
-
- def setShear(shear):
- """
- Set the text3d's shear value.
- @rtype: None
- @type shear: float
- @param shear: The new text3d's shear value.
- """
-
- def getSize():
- """
- Get the text3d's size value.
- @rtype: float
- """
-
- def setSize(size):
- """
- Set the text3d's size value.
- @rtype: None
- @type size: float
- @param size: The new text3d's size value.
- """
-
- def getLineSeparation():
- """
- Get the text3d's ext2 value.
- @rtype: float
- """
-
- def setLineSeparation(sep):
- """
- Set the text3d's ext2 value.
- @rtype: None
- @type sep: float
- @param sep: The new text3d's separation value.
- """
-
- def getSpacing():
- """
- Get the text3d's spacing value.
- @rtype: float
- """
-
- def setSpacing(spacing):
- """
- Set the text3d's spacing value.
- @rtype: None
- @type spacing: float
- @param spacing: The new text3d's spacing value.
- """
-
- def getXoffset():
- """
- Get the text3d's Xoffset value.
- @rtype: float
- """
-
- def setXoffset(xof):
- """
- Set the text3d's Xoffset value.
- @rtype: None
- @type xof: float
- @param xof: The new text3d's Xoffset value.
- """
-
- def getYoffset():
- """
- Get the text3d's Yoffset value.
- @rtype: float
- """
-
- def setYoffset(yof):
- """
- Set the text3d's Yoffset value.
- @rtype: None
- @type yof: float
- @param yof: The new text3d's Yoffset value.
- """
-
- def getAlignment():
- """
- Get the text3d's alignment value. Uses module constants
- - LEFT
- - RIGHT
- - MIDDLE
- - FLUSH
- @rtype: module constant
- """
-
- def setAlignment(align):
- """
- Set the text3d's Alignment value. Uses module constants
- - LEFT
- - RIGHT
- - MIDDLE
- - FLUSH
- @rtype: None
- @type align: module constant
- @param align: The new text3d's Alignment value.
- """
-
- def addFrame():
- """
- Adds a text frame. maximum number of frames is 255.
- @rtype: None
- """
-
- def removeFrame(index):
- """
- Removed the frame at this index
- @rtype: None
- """
-import id_generics
-Text3d.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/Texture.py b/source/blender/python/api2_2x/doc/Texture.py
deleted file mode 100644
index dfba93c9978..00000000000
--- a/source/blender/python/api2_2x/doc/Texture.py
+++ /dev/null
@@ -1,557 +0,0 @@
-#
-# Blender.Texture module and the Texture PyType object
-#
-# Written by Alex Mole
-#
-
-"""
-The Blender.Texture submodule.
-
-B{New}:
- - many new attributes in L{MTex} submodule
- - new dictionaries (L{Texture.BlendModes}, L{Texture.Mappings}, L{Texture.Proj}) to use for the values of some of the new L{MTex} attributes.
-
-Texture
-=======
-
-This module provides access to B{Texture} objects in Blender.
-
-Example::
-
- from Blender import Texture,Image,Material
-
- footex = Texture.Get('foo') # get texture named 'foo'
- footex.setType('Image') # make foo be an image texture
- img = Image.Load('test.png') # load an image
- footex.image = img # link the image to the texture
-
- mat = Material.Get('bar') # get a material
- mtextures = mat.getTextures() # get a list of the MTex objects
- for mtex in mtextures:
- if mtex.tex.type == Texture.Types.IMAGE:
- print mtex.tex.image.filename # print the filenames of all the
- # images in textures linked to "bar"
-
- mat.setTexture(0, footex) # set the material's first texture
- # to be our texture
-
-
-@type Types: readonly dictionary
-@var Types: The available texture types:
- - NONE - No texture
- - CLOUDS - Clouds texture
- - WOOD - Wood texture
- - MARBLE - Marble texture
- - MAGIC - Magic texture
- - BLEND - Blend texture
- - STUCCI - Stucci texture
- - NOISE - Noise texture
- - IMAGE - Image texture
- - PLUGIN - Plugin texture
- - ENVMAP - EnvMap texture
- - MUSGRAVE - Musgrave procedural texture
- - VORONOI - Voronoi procedural texture
- - DISTNOISE - Distorted noise texture
-
-@type Flags: readonly dictionary
-@var Flags: The available Texture flags:
- - FLIPBLEND - Flips the blend texture's X and Y directions
- - NEGALPHA - Reverse the alpha value
- - CHECKER_ODD - Fill the "odd" checkerboard tiles
- - CHECKER_EVEN - Fill the "even" checkerboard tiles
- - COLORBAND - Enable colorband for this texture
- - PREVIEW_ALPHA - Show alpha in preview
- - REPEAT_XMIR - Mirrors X direction repeat
- - REPEAT_YMIR - Mirrors Y direction repeat
-
-@type ImageFlags: readonly dictionary
-@var ImageFlags: The available image flags for Texture.imageFlags:
- - INTERPOL - Interpolate pixels of the image
- - USEALPHA - Use the alpha layer
- - MIPMAP - Enable mipmapping [cannot be used with FIELDS]
- - FIELDS - Work with field images [cannot be used with MIPMAP]
- - ROT90 - Rotate the image 90 degrees when rendering
- - CALCALPHA - Calculate an alpha from the RGB
- - STFIELD - Denotes this is a standard field
- - MOVIE - Use a movie for an image
- - CYCLIC - Repeat animation image
- - ANTI - Use anti-aliasing
- - NORMALMAP - Use image RGB values for normal mapping
-
-@type ExtendModes: readonly dictionary
-@var ExtendModes: Extend, clip, repeat or checker modes for image textures
- - EXTEND - Extends the colour of the edge
- - CLIP - Return alpha 0.0 outside image
- - CLIPCUBE - Return alpha 0.0 around cube-shaped area around image
- - REPEAT - Repeat image vertically and horizontally
- - CHECKER - Repeat image in checkerboard pattern
-
-@type Noise: readonly dictionary
-@var Noise: Noise types and bases. SINE, SAW and TRI are only used for
- marble and wood textures, while the remainder are used for all textures
- which has a noise basis function (for these textures, the constant should
- be used with the second noise basis setting).
- - SINE - Produce bands using sine wave (marble, wood textures)
- - SAW - Produce bands using saw wave (marble, wood textures)
- - TRI - Produce bands using triangle wave (marble, wood textures)
- - BLENDER - Original Blender algorithm
- - PERLIN - Ken Perlin's original (1985) algorithm
- - IMPROVEDPERLIN - Ken Perlin's newer (2002) algorithm
- - VORONOIF1 - none
- - VORONOIF2 - none
- - VORONOIF3 - none
- - VORONOIF4 - none
- - VORONOIF2F1 - none
- - VORONOICRACKLE - none
- - CELLNOISE - Steven Worley's cellular basis algorithm (1996)
-
-@type BlendModes: readonly dictionary
-@var BlendModes: The available texture blending modes:
- - MIX - mix texture with value
- - MULTIPLY - multiply texture with value
- - ADD - add texture to value
- - SUBTRACT - subtract texture from value
- - DIVIDE - divide value by texture
- - DARKEN - replace value with texture if texture is darker
- - DIFFERENCE - difference of texture from value
- - LIGHTEN - replace value with texture if texture is lighter
- - SCREEN - 'screen' mode
-
-@type Mappings: readonly dictionary
-@var Mappings: The available 2D texture coordinate mappings for images:
- - FLAT - flat projection
- - CUBE - cube projection
- - TUBE - cylindrical projection
- - SPHERE - spherical projection
-
-@type Proj: readonly dictionary
-@var Proj: The available projections per axis:
- - NONE - axis isn't used
- - X - axis is used as final x axis
- - Y - axis is used as final y axis
- - Z - axis is used as final z axis
-
-@type STypes: readonly dictionary
-@var STypes: Texture-type specific data. Depending on the value of
- Texture.type, certain groups will make sense. For instance, when a texture
- is of type CLOUD, the CLD_xxx stypes can be used. Note that the first
- value in each group is the default.
- 1. Clouds type
- - CLD_DEFAULT - Monochromatic noise
- - CLD_COLOR - RGB noise
- 2. Wood type
- - WOD_BANDS - Use standard wood texture
- - WOD_RINGS - Use wood rings
- - WOD_BANDNOISE - Add noise to standard wood
- - WOD_RINGNOISE - Add noise to rings
- 3. Magic type
- - MAG_DEFAULT - Magic has no STypes
- 4. Marble type
- - MBL_SOFT - Use soft marble
- - MBL_SHARP - Use more clearly defined marble
- - MBL_SHARPER - Use very clearly dfefined marble
- 5. Blend type
- - BLN_LIN - Use a linear progression
- - BLN_QUAD - Use a quadratic progression
- - BLN_EASE - Uses a more complicated blend function
- - BLN_DIAG - Use a diagonal progression
- - BLN_SPHERE - Use a progression with the shape of a sphere
- - BLN_HALO - Use a quadratic progression with the shape of a sphere
- 6. Stucci type
- - STC_PLASTIC - Standard stucci
- - STC_WALLIN - Creates dimples
- - STC_WALLOUT - Creates ridges
- 7. Noise type
- - NSE_DEFAULT - Noise has no STypes
- 8. Image type
- - IMG_DEFAULT - Image has no STypes
- 9. Plugin type
- - PLG_DEFAULT - Plugin has no STypes
- 10. Envmap type
- - ENV_STATIC - Calculate map only once
- - ENV_ANIM - Calculate map each rendering
- - ENV_LOAD - Load map from disk
- 11. Musgrave type
- - MUS_MFRACTAL - Hetero Multifractal
- - MUS_RIDGEDMF - Ridged Multifractal
- - MUS_HYBRIDMF - Hybrid Multifractal
- - MUS_FBM - Fractal Brownian Motion
- - MUS_HTERRAIN - Hetero Terrain
- 12. Voronoi type
- - VN_INT - Only calculate intensity
- - VN_COL1 - Color cells by position
- - VN_COL2 - Same as Col1 plus outline based on F2-F1
- - VN_COL3 - Same as Col2 multiplied by intensity
- 13. Distorted noise type
- - DN_BLENDER - Original Blender algorithm
- - DN_PERLIN - Ken Perlin's original (1985) algorithm
- - DN_IMPROVEDPERLIN - Ken Perlin's newer (2002) algorithm
- - DN_VORONOIF1 - none
- - DN_VORONOIF2 - none
- - DN_VORONOIF3 - none
- - DN_VORONOIF4 - none
- - DN_VORONOIF2F1 - none
- - DN_VORONOICRACKLE - none
- - DN_CELLNOISE - Steven Worley's cellular basis algorithm (1996)
-
-@var TexCo: Flags for MTex.texco.
- - ORCO - Use the original coordinates of the mesh
- - REFL - Use reflection vector as texture coordinates
- - NOR - Use normal vector as texture coordinates
- - GLOB - Use global coordinates for the texture coordinates
- - UV - Use UV coordinates for texture coordinates
- - OBJECT - Use linked object's coordinates for texture coordinates
- - WIN - Use screen coordinates as texture coordinates
- - VIEW - Pass camera view vector on to the texture (World texture only!)
- - STICK - Use mesh sticky coordinates for the texture coordinates
- - STRESS - Use mesh stress coordinates for the texture coordinates
- - TANGENT - Use mesh tangent coordinates for the texture coordinates
-@type TexCo: readonly dictionary
-
-@var MapTo: Flags for MTex.mapto.
- - COL - Make the texture affect the basic colour of the material
- - NOR - Make the texture affect the rendered normal
- - CSP - Make the texture affect the specularity colour
- - CMIR - Make the texture affect the mirror colour
- - REF - Make the texture affect the diffuse reflectivity value
- - SPEC - Make the texture affect the specularity value
- - HARD - Make the texture affect the hardness value
- - ALPHA - Make the texture affect the alpha value
- - EMIT - Make the texture affect the emit value
- - RAYMIR - Make the texture affect the mirror reflectivity value
- - DISP - Make the texture displace the mesh
- - TRANSLU - Make the texture affect the translucency value
- - AMB - Make the texture affect the ambient value
- - WARP - Make the texture affect texture coordinates for the following textures
-@type MapTo: readonly dictionary
-
-"""
-
-def New (name = 'Tex'):
- """
- Create a new Texture object.
- @type name: string
- @param name: The Texture name.
- @rtype: Blender Texture
- @return: The created Texture object.
- """
-
-def Get (name = None):
- """
- Get the Texture object(s) from Blender.
- @type name: string
- @param name: The name of the Texture.
- @rtype: Blender Texture or a list of Blender Textures
- @return: It depends on the I{name} parameter:
- - (name): The Texture object with the given I{name};
- - (): A list with all Texture objects in the current scene.
- """
-
-from IDProp import IDGroup, IDArray
-class Texture:
- """
- The Texture object
- ==================
- This object gives access to Texture-specific data in Blender.
-
- Note that many of the attributes of this object are only relevant for
- specific texture types.
-
- @ivar animFrames: Number of frames of a movie to use.
- Value is clamped to the range [0,300000].
- @type animFrames: int
- @ivar animOffset: Offsets the number of the first movie frame to use.
- Value is clamped to the range [-300000,300000].
- @type animOffset: int
- @ivar animStart: Starting frame of the movie to use.
- Value is clamped to the range [1,300000].
- @type animStart: int
- @ivar anti: Image anti-aliasing enabled. Also see L{ImageFlags}.
- @type anti: int
- @ivar brightness: Changes the brightness of a texture's color.
- Value is clamped to the range [0.0,2.0].
- @type brightness: float
- @ivar calcAlpha: Calculation of image's alpha channel enabled. Also see L{ImageFlags}.
- @type calcAlpha: int
- @ivar contrast: Changes the contrast of a texture's color.
- Value is clamped to the range [0.01,5.0].
- @type contrast: float
- @ivar crop: Sets the cropping extents (for image textures).
- @type crop: tuple of 4 ints
- @ivar cyclic: Looping of animated frames enabled. Also see L{ImageFlags}.
- @type cyclic: boolean
- @ivar distAmnt: Amount of distortion (for distorted noise textures).
- Value is clamped to the range [0.0,10.0].
- @type distAmnt: float
- @ivar distMetric: The distance metric (for Voronoi textures).
- @type distMetric: int
- @ivar exp: Minkovsky exponent (for Minkovsky Voronoi textures).
- Value is clamped to the range [0.01,10.0].
- @type exp: float
- @ivar extend: Texture's 'Extend' mode (for image textures). See L{ExtendModes}.
- @type extend: int
- @ivar fields: Use of image's fields enabled. Also see L{ImageFlags}.
- @type fields: int
- @ivar fieldsPerImage: Number of fields per rendered frame.
- Value is clamped to the range [1,200].
- @type fieldsPerImage: int
- @ivar filterSize: The filter size (for image and envmap textures).
- Value is clamped to the range [0.1,25.0].
- @type filterSize: float
- @ivar flags: Texture's 'Flag' bitfield. See L{Flags}.
- bitmask.
- @type flags: int
- @ivar hFracDim: Highest fractional dimension (for Musgrave textures).
- Value is clamped to the range [0.0001,2.0].
- @type hFracDim: float
- @ivar iScale: Intensity output scale (for Musgrave and Voronoi textures).
- Value is clamped to the range [0.0,10.0].
- @type iScale: float
- @ivar image: Texture's image object.
- @type image: Blender Image (or None)
- @ivar imageFlags: Texture's 'ImageFlags' bits.
- @type imageFlags: int
- @ivar interpol: Interpolate image's pixels to fit texture mapping enabled. Also see L{ImageFlags}.
- @type interpol: int
- @ivar ipo: Texture Ipo data.
- Contains the Ipo if one is assigned to the object, B{None} otherwise. Setting to B{None} clears the current Ipo..
- @type ipo: Blender Ipo
- @ivar lacunarity: Gap between succesive frequencies (for Musgrave textures).
- Value is clamped to the range [0.0,6.0].
- @type lacunarity: float
- @ivar mipmap: Mipmaps enabled. Also see L{ImageFlags}.
- @type mipmap: int
- @ivar movie: Movie frames as images enabled. Also see L{ImageFlags}.
- @type movie: int
- @ivar noiseBasis: Noise basis type (wood, stucci, marble, clouds,
- Musgrave, distorted). See L{Noise} dictionary.
- @type noiseBasis: int
- @ivar noiseBasis2: Additional noise basis type (wood, marble, distorted
- noise). See L{Noise} dictionary.
- @type noiseBasis2: int
- @ivar noiseDepth: Noise depth (magic, marble, clouds).
- Value is clamped to the range [0,6].
- @type noiseDepth: int
- @ivar noiseSize: Noise size (wood, stucci, marble, clouds, Musgrave,
- distorted noise).
- Value is clamped to the range [0.0001,2.0].
- @type noiseSize: float
- @ivar noiseType: Noise type (for wood, stucci, marble, clouds textures). Valid values are 'hard' or 'soft'.
- @type noiseType: string
- @ivar normalMap: Use of image RGB values for normal mapping enabled.
- Also see L{ImageFlags}.
- @type normalMap: int
- @ivar octs: Number of frequencies (for Musgrave textures).
- Value is clamped to the range [0.0,8.0].
- @type octs: float
- @ivar repeat: Repetition multiplier (for image textures).
- @type repeat: tuple of 2 ints
- @ivar rgbCol: RGB color tuple.
- @type rgbCol: tuple of 3 floats
- @ivar rot90: X/Y flip for rendering enabled. Also see L{ImageFlags}.
- @type rot90: int
- @ivar saw: Produce bands using saw wave (marble, wood textures). Also see L{Noise}.
- @type saw: int
- @ivar sine: Produce bands using sine wave (marble, wood textures). Also see L{Noise}.
- @type sine: int
- @ivar stField: Standard field deinterlacing enabled. Also see L{ImageFlags}.
- @type stField: int
- @ivar stype: Texture's 'SType' mode. See L{STypes}.
- @type stype: int
- @ivar tri: Produce bands using triangle wave (marble, wood textures). Also see L{Noise}.
- @type tri: int
- @ivar turbulence: Turbulence (for magic, wood, stucci, marble textures).
- Value is clamped to the range [0.0,200.0].
- @type turbulence: float
- @ivar type: Texture's 'Type' mode. See L{Types}.
- Value must be in the range [0,13].
- @type type: int
- @ivar useAlpha: Use of image's alpha channel enabled. Also see L{ImageFlags}.
- @type useAlpha: int
- @ivar weight1: Weight 1 (for Voronoi textures).
- Value is clamped to the range [-2.0,2.0].
- @type weight1: float
- @ivar weight2: Weight 2 (for Voronoi textures).
- Value is clamped to the range [-2.0,2.0].
- @type weight2: float
- @ivar weight3: Weight 3 (for Voronoi textures).
- Value is clamped to the range [-2.0,2.0].
- @type weight3: float
- @ivar weight4: Weight 4 (for Voronoi textures).
- Value is clamped to the range [-2.0,2.0].
- @type weight4: float
- @ivar colorband: Texture colorband, a list of colors,
- each color a list of 5 floats [0 - 1], [r,g,b,a,pos].
- The colorband can have between 1 and 31 colors.
- @type colorband: list
- @ivar autoRefresh: Refresh image on frame changes enabled.
- @type autoRefresh: boolean
- """
-
- def getExtend():
- """
- Get the extend mode of the texture. See L{setExtend}.
- @rtype: string.
- """
-
- def getImage():
- """
- Get the Image associated with this texture (or None).
- @rtype: Blender Image
- """
-
- def getName():
- """
- Get the name of this Texture object.
- @rtype: string
- """
-
- def getType():
- """
- Get this Texture's type. See L{setType}.
- @rtype: string
- """
-
- def setExtend(extendmode):
- """
- Set the extend mode of this texture (only used for IMAGE textures)
- @param extendmode: The new extend mode. One of:
- 'Extend', 'Clip', 'ClipCube' and 'Repeat'
- @type extendmode: string
- """
-
- def setFlags(f1=None, f2=None, f3=None, f4=None):
- """
- Set this object's flags.
- @param f1,f2,f3,f4: Flags to be set (omitted flags are cleared). Can be any of
- 'FlipBlendXY', 'NegAlpha', 'CheckerOdd', and 'CheckerEven'
- @type f1,f2,f3,f4: string
- """
-
- def setImage(image):
- """
- Set the Image of this texture.
- @param image: The new Image.
- @type image: Blender Image
- @warning: This sets the texture's type to 'Image' if it is not already.
- """
-
- def setImageFlags(f1=None, f2=None, f3=None, etc=None):
- """
- Set the Image flags (only makes sense for IMAGE textures). Omitted
- flags are cleared.
- @param f1, f2, f3, etc: Flag to set. See L{ImageFlags} for their meanings. Can be
- any of: 'InterPol', 'UseAlpha', 'MipMap', 'Fields', 'Rot90',
- 'CalcAlpha', 'Cyclic', 'Movie', 'StField', 'Anti' and 'NormalMap'
- @type f1, f2, f3, etc: string
- """
-
- def setName(name):
- """
- Set the name of this Texture object.
- @param name: The new name.
- @type name: string
- """
-
- def setSType(stype):
- """
- Set the SType.
- @param stype: The new stype. This can be any of the values listed in
- L{STypes} or 'Default' which sets the stype to the default value.
- @type stype: string
-
- @note: the set of valid parameters is dependent on the current
- texture type. Be sure to always set the texture type B{before}
- setting the texture's stype; otherwise an exception might occur.
- """
-
- def setType(type):
- """
- Set this Texture's type.
- @param type: The new type. Possible options are:
- 'None', 'Clouds', 'Wood', 'Marble', 'Magic', 'Blend', 'Stucci',
- 'Noise', 'Image', 'Plugin', 'EnvMap', 'Musgrave', 'Voronoi'
- and 'DistNoise'
- @type type: string
- """
- def evaluate(coord):
- """
- Evaluates the texture at this location and returns the result.
-
- The return value is a 4D vector where (x,y,z,w) are (red, green, blue, intensity)
- For greyscale textures, often intensity only will be used.
- @type coord: vector or tuple of 3 numbers
- """
-
-import id_generics
-Texture.__doc__ += id_generics.attributes
-
-class MTex:
- """
- The MTex Object
- ===============
-
- This object links a material to a texture. It allows the same texture to be
- used in several different ways.
-
- @ivar tex: The Texture this is linked to.
- @type tex: Blender Texture
- @ivar texco: Texture coordinates ("Map input"). See L{TexCo}
- @ivar mapto: "Map to" field of texture. OR'd values of L{MapTo}
- @ivar object: Object whose space to use when texco is Object
- @type object: Blender Object
- @ivar col: Color that the texture blends with
- @ivar dvar: Value that the texture blends with when not blending colors
- @ivar blendmode: Texture blending mode. L{BlendModes}
- @ivar colfac: Factor by which texture affects color
- @ivar norfac: Factor by which texture affects normal
- @ivar varfac: Factor by which texture affects most variables
- @ivar dispfac: Factor by which texture affects displacement
- @ivar warpfac: Factor by which texture affects warp
- @ivar ofs: Offset to adjust texture space
- @ivar size: Size to scale texture space
- @ivar mapping: Mapping of texture coordinates (flat, cube, etc.). L{Mappings}
- @ivar stencil: Stencil mode
- @ivar neg: Negate texture values mode
- @ivar noRGB: Convert texture RGB values to intensity values
- @ivar correctNor: Correct normal mapping for Texture space and Object space
- @ivar xproj: Projection of X axis to Texture space. L{Proj}
- @ivar yproj: Projection of Y axis to Texture space. L{Proj}
- @ivar zproj: Projection of Z axis to Texture space. L{Proj}
- @ivar mtCol: How texture maps to color
- @ivar mtNor: How texture maps to normals
- @ivar mtCsp: How texture maps to specularity color
- @ivar mtCmir: How texture maps to mirror color
- @ivar mtRef: How texture maps to reflectivity
- @ivar mtSpec: How texture maps to specularity
- @ivar mtEmit: How texture maps to emit value
- @ivar mtAlpha: How texture maps to alpha value
- @ivar mtHard: How texture maps to hardness
- @ivar mtRayMir: How texture maps to RayMir value
- @ivar mtTranslu: How texture maps to translucency
- @ivar mtAmb: How texture maps to ambient value
- @ivar mtDisp: How texture maps to displacement
- @ivar mtWarp: How texture maps to warp
- @ivar uvlayer: The name of the UV Layer this texture is mapped to (when left blank uses render layer)
- @type uvlayer: string
- """
-
- def getIpo():
- """
- Get the Ipo associated with this texture object, if any.
- @rtype: Ipo
- @return: the wrapped ipo or None.
- """
-
- def setIpo(ipo):
- """
- Link an ipo to this texture object.
- @type ipo: Blender Ipo
- @param ipo: a "texture data" ipo.
- """
-
- def clearIpo():
- """
- Unlink the ipo from this texture object.
- @return: True if there was an ipo linked or False otherwise.
- """
diff --git a/source/blender/python/api2_2x/doc/Theme.py b/source/blender/python/api2_2x/doc/Theme.py
deleted file mode 100644
index 90d0f8395a3..00000000000
--- a/source/blender/python/api2_2x/doc/Theme.py
+++ /dev/null
@@ -1,211 +0,0 @@
-# Blender.Window.Theme submodule and the Theme PyType object
-
-"""
-The Blender.Window.Theme submodule.
-
-Theme
-=====
-
-This module provides access to B{Theme} objects in Blender.
-
-Example::
- # this is a simplified version of the save_theme.py script
- # shipped with Blender:
- import Blender
- from Blender.Window import Theme, FileSelector
-
- theme = Theme.Get()[0] # get current theme
-
- def write_theme(filename):
- "Write the current theme as a BPython script"
-
- f = file(filename, "w")
-
- f.write("import Blender")
- f.write("from Blender.Window import Theme")
- f.write("theme = Theme.New('%s')" % theme.name)
-
- for tsp in theme.get(): # write each theme space
- command = "\\n%s = theme.get('%s')" % (tsp, tsp)
- f.write(command + "\\n")
- exec(command)
- exec("vars = dir(%s)" % tsp)
- vars.remove('theme')
-
- for var in vars: # write each variable from each theme space
- v = "%s.%s" % (tsp, var)
- exec("value = %s" % v)
- f.write("%s = %s\\n" % (v, value))
-
- f.write('\\nBlender.Redraw(-1)') # redraw to update the screen
- f.close()
-
- FileSelector(write_theme, "Save Current Theme", default_fname)
-"""
-
-def New (name = "New Theme", theme = '<default>'):
- """
- Create a new Theme object.
- @type name: string
- @param name: The name of the new theme.
- @type theme: Blender Theme
- @param theme: a base theme to copy all data from. It defaults to the current
- one.
- @rtype: Blender Theme
- @return: A new Blender Theme object.
- """
-
-def Get (name = None):
- """
- Get the Theme object(s) from Blender.
- @type name: string
- @param name: The name of the Theme object.
- @rtype: Blender Theme or a list of Blender Themes
- @return: It depends on the I{name} parameter:
- - (name): The Theme object called I{name}, None if not found;
- - (): A list with all Theme objects currently in Blender.
- """
-
-
-class Theme:
- """
- The Theme object
- ================
- This object gives access to Themes in Blender. Each Theme object is
- composed of one UI (Use Interface) theme and many Space themes
- (3d view, Text Editor, Buttons window, etc).
- @ivar name: The name of this Theme object.
- """
-
- def getName():
- """
- Get the name of this Theme object.
- @rtype: string
- @return: the name of this Theme object.
- """
-
- def setName(s):
- """
- Rename this theme.
- @type s: string
- @param s: the new name.
- """
-
- def get(t = None):
- """
- Get a space or the ui (sub)theme from this Theme.
- @type t: string, int or None
- @param t: the wanted sub-theme as either:
- - int: -1 for UI or the types in L{Window.Types<Window.Types>} for the others;
- - string: use get() to know them (they are case insensitive);
- - nothing: as written above, get() returns a list of names.
- @rtype: Blender ThemeSpace or ThemeUI or list of sub-theme types as strings.
- @return: It depends on the given parameter:
- - (): a list with all available types, as strings;
- - (type): the chosen sub-theme.
- """
-
-class ThemeUI:
- """
- The User Interface sub-theme
- ============================
- This can be accessed with theme.get(t), where t can be 'ui' or -1.
- The available variables follow the internal (C coded) ThemeUI struct in
- Blender. Most of them represent rgba (red, green, blue, alpha) colors,
- with each component in the range [0, 255]. There is more than one way to
- access them.
-
- Examples::
- print outline.R
- outline.r = 180 # it's case insensitive
- outline[0] = 94 # 0 for red, 1 for green, ...
- outline = [200, 200, 200, 255] # setting all components at once
- @type theme: string
- @ivar theme: the parent Theme for this object.
- @ivar outline: theme rgba var.
- @ivar neutral: theme rgba var.
- @ivar action: theme rgba var.
- @ivar setting: theme rgba var.
- @ivar setting1: theme rgba var.
- @ivar setting2: theme rgba var.
- @ivar num: theme rgba var.
- @ivar textfield: theme rgba var.
- @ivar textfield_hi: theme rgba var.
- @ivar popup: theme rgba var.
- @ivar text: theme rgba var.
- @ivar text_hi: theme rgba var.
- @ivar menu_back: theme rgba var.
- @ivar menu_item: theme rgba var.
- @ivar menu_hilite: theme rgba var.
- @ivar menu_text: theme rgba var.
- @ivar menu_text_hi: theme rgba var.
- @type drawType: int
- @ivar drawType: the draw type (minimal, rounded, etc) in the range [1, 4].
- @type iconTheme: string
- @ivar iconTheme: the filename (without path) for the icon theme PNG in .blender/icons/
- """
-
-class ThemeSpace:
- """
- The Space sub-themes
- ====================
- There is a sub-theme for each space in Blender (except for the Scripts
- window, but it will be added soon). Please read the information about
- L{Theme.ThemeUI}, since it is also relevant here. In Blender,
- all theme spaces share the same C structure. For this reason, all of
- them here share the same variables, event though some spaces only use
- a few of them. This lower-level access is acceptable because generally
- users will prefer to use the interface to change single theme options
- and only use scripting to save or restore themes. But anyway, checking
- the Themes tab in the User Preferences space in Blender and using the
- bundled "Save current theme" script (or its simplified version written
- on the top of this page) can help you finding out any specific info you
- may need.
- @type theme: string
- @ivar theme: the parent Theme for this object.
- @ivar back: theme rgba var.
- @ivar text: theme rgba var.
- @ivar text_hi: theme rgba var.
- @ivar header: theme rgba var.
- @ivar panel: theme rgba var.
- @ivar shade1: theme rgba var.
- @ivar shade2: theme rgba var.
- @ivar hilite: theme rgba var.
- @ivar grid: theme rgba var.
- @ivar wire: theme rgba var.
- @ivar select: theme rgba var.
- @ivar active: theme rgba var.
- @ivar transform: theme rgba var.
- @ivar vertex: theme rgba var.
- @ivar vertex_select: theme rgba var.
- @ivar edge: theme rgba var.
- @ivar edge_select: theme rgba var.
- @ivar edge_seam: theme rgba var.
- @ivar edge_facesel: theme rgba var.
- @ivar face: theme rgba var.
- @ivar face_select: theme rgba var.
- @ivar face_dot: theme rgba var.
- @ivar normal: theme rgba var.
- @ivar bone_solid: theme rgba var.
- @ivar bon_pose: theme rgba var.
- @ivar strip: theme rgba var.
- @ivar strip_select: theme rgba var.
- @ivar syntaxl: theme rgba var.
- @ivar syntaxn: theme rgba var.
- @ivar syntaxb: theme rgba var.
- @ivar syntaxv: theme rgba var.
- @ivar syntaxc: theme rgba var.
- @ivar movie: theme rgba var.
- @ivar image: theme rgba var.
- @ivar scene: theme rgba var.
- @ivar audio: theme rgba var.
- @ivar effect: theme rgba var.
- @ivar plugin: theme rgba var.
- @ivar transition: theme rgba var.
- @ivar meta: theme rgba var.
- @type vertex_size: int
- @ivar vertex_size: size of the vertices dots on screen in the range [1, 10].
- @type facedot_size: int
- @ivar facedot_size: size of the face dots on screen in the range [1, 10].
- """
-
diff --git a/source/blender/python/api2_2x/doc/TimeLine.py b/source/blender/python/api2_2x/doc/TimeLine.py
deleted file mode 100644
index 0f456189767..00000000000
--- a/source/blender/python/api2_2x/doc/TimeLine.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# Blender.Scene.TimeLine module
-
-"""
-The Blender.Scene.TimeLine submodule.
-
-TimeLine
-========
-
-This module gives access to B{Scene TimeLine Contexts} in Blender.
-
-Example::
- import Blender
- from Blender import Scene
-
- # Only the current scene has a radiosity context.
- # Naturally, any scene can be made the current one
- # with scene.makeCurrent()
-
- scn = Scene.GetCurrent()
-
- # this is the only way to access the radiosity object:
-
- time_line = scn.getTimeLine ()
- time_line.add (50)
- time_line.add (100)
- time_line.setName (50, 'first')
- time_line.setName (100, 'second')
-
- Blender.Redraw(-1)
-"""
-
-class TimeLine:
- """
- The TimeLine object
- ===================
- This object wraps the current Scene's time line context in Blender.
- """
-
- def add(ival):
- """
- add new marker to time line
- @type ival: int
- @param ival: the frame number.
- """
-
- def delete(ival):
- """
- delete frame.
- @type ival: int
- @param ival: the frame number.
- """
-
- def setName(ival, sval):
- """
- set name of frame.
- @type ival: int
- @type sval: string
- @param ival: the frame number.
- @param sval: the frame name.
- """
-
- def getName(ival):
- """
- Get name of frame.
- @type ival: int
- @param ival: the frame number.
- @rtype: string
- @return: the frame name.
- """
-
- def getMarked(ival):
- """
- Get name of frame.
- @type ival: int
- @param ival: the frame number.
- @rtype: int|string
- @return: the list of frame number or name.
-
- """
-
diff --git a/source/blender/python/api2_2x/doc/Types.py b/source/blender/python/api2_2x/doc/Types.py
deleted file mode 100644
index a08226e46ee..00000000000
--- a/source/blender/python/api2_2x/doc/Types.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# The Blender.Types submodule
-
-"""
-The Blender.Types submodule
-===========================
-
-This module is a dictionary of Blender Python types, for type checking.
-
-Example::
- import Blender
- from Blender import Types, Object, NMesh, Camera, Lamp
- #
- objs = Object.Get() # a list of all objects in the current scene
- for o in objs:
- print
- print o, type(o)
- data = o.getData()
- print type(data)
- if type(data) == Types.NMeshType:
- if len(data.verts):
- print "its vertices are obviously of type:", type(data.verts[0])
- print "and its faces:", Types.NMFaceType
- elif type(data) == Types.CameraType:
- print "It's a Camera."
- elif type(data) == Types.LampType:
- print "Let there be light!"
-
-@var ObjectType: Blender Object. The base object, linked to its specific data
- at its .data member variable.
-@var GroupType: Blender Group. A Group that references a list of objects that are a part of this group.
-@var NMeshType: Blender NMesh. The mesh structure.
-@var NMFaceType: Blender NMFace. A mesh face, with one (a point), two (an edge),
- three (a triangular face) or four (a quad face) vertices.
-@var NMVertType: Blender NMVert. A mesh vertex.
-@var NMColType: Blender NMCol. A mesh rgba color.
-@var MeshType: Blender Mesh. The mesh structure.
-@var MFaceType: Blender MFace. A mesh face, with
- three (a triangular face) or four (a quad face) vertices.
-@var MEdgeType: Blender MEdge. A mesh edge, with two vertices
-@var MVertType: Blender MVert. A mesh vertex which wraps a Blender mesh vertex
- (typically an object returned from the mesh.verts sequence).
-@var PVertType: Blender MVert. A mesh vertex which does not wrap a Blender
- mesh vertex (returned from L{Blender.Mesh.MVert()<Mesh.MVert.__init__>}).
-@var MColType: Blender MCol. A mesh rgba color.
-@var ArmatureType: Blender Armature. The "skeleton", for animating and deforming
-objects.
-@var BoneType: Blender Bone. Bones are, obviously, the "pieces" of an Armature.
-@var CurveType: Blender Curve.
-@var IpoType: Blender Ipo.
-@var MetaballType: Blender Metaball.
-@var CameraType: Blender Camera.
-@var ImageType: Blender Image.
-@var LampType: Blender Lamp.
-@var TextType: Blender Text.
-@var Text3dType: Blender Text3d.
-@var MaterialType: Blender Material.
-@var SceneType: A Blender Scene. Container of all other objects.
-@var ButtonType: Blender Button. One of the Draw widgets.
-@var vectorType: Blender vector. Used in NMesh, Mesh and elsewhere.
-@var matrix_Type: Blender matrix.
-@var quaternionType: Blender quaternion. Used in armatures.
-@var eulerType: Blender euler.
-@var bufferType: Blender buffer. A contiguous piece of storage, used in BGL.
-@var constantType: Blender constant. A constant dictionary.
-@var rgbTupleType: Blender rgbTuple. A (red, green, blue) triplet.
-@var TextureType: Blender Texture.
-@var MTexType: Blender MTex. Links materials to a texture.
-@var IDGroupType: Blender IDProperty Group type.
-@var IDArrayType: Blender IDProperty Array type.
-"""
diff --git a/source/blender/python/api2_2x/doc/Window.py b/source/blender/python/api2_2x/doc/Window.py
deleted file mode 100644
index 7fceeb757de..00000000000
--- a/source/blender/python/api2_2x/doc/Window.py
+++ /dev/null
@@ -1,538 +0,0 @@
-# Blender.Window module and the Window PyType object
-
-"""
-The Blender.Window submodule.
-
-B{New}: renamed ViewLayer to L{ViewLayers} (actually added an alias, so both
-forms will work).
-
-Window
-======
-
-This module provides access to B{Window} functions in Blender.
-
-Example:
---------
-
-FileSelector::
-
- import Blender
- from Blender import Window
- #
- def my_callback(filename): # callback for the FileSelector
- print "You chose the file:", filename # do something with the chosen file
- #
- Window.FileSelector (my_callback, "Choose one!")
-
-Example:
---------
-
-DrawProgressBar::
-
- import Blender
- from Blender.Window import DrawProgressBar
- #
- # substitute the bogus_*() function calls for your own, of course.
- #
- DrawProgressBar (0.0, "Importing data ...")
- bogus_importData()
- DrawProgressBar (0.3, "Building something")
- bogus_build()
- DrawProgressBar (0.8, "Updating Blender")
- bogus_update()
- DrawProgressBar (1.0, "Finished")
- #
- # another example:
- #
- number = 1
- while number < 20:
- file = filename + "00%d" % number
- DrawProgressBar (number / 20.0, "Loading texture: %s" % file)
- Blender.Image.Load(file)
- number += 1
-
- DrawProgressBar (1.0, "Finished loading")
-
-
-@type Types: readonly dictionary
-@var Types: The available Window Types.
- - ACTION
- - BUTS
- - FILE
- - IMAGE
- - IMASEL
- - INFO
- - IPO
- - NLA
- - OOPS
- - SCRIPT
- - SEQ
- - SOUND
- - TEXT
- - VIEW3D
-
-@type Qual: readonly dictionary
-@var Qual: Qualifier keys (shift, control, alt) bitmasks.
- - LALT: left ALT key
- - RALT: right ALT key
- - ALT: any ALT key, ...
- - LCTRL
- - RCTRL
- - CTRL
- - LSHIFT
- - RSHIFT
- - SHIFT
-
-@type MButs: readonly dictionary
-@var MButs: Mouse buttons.
- - L: left mouse button
- - M: middle mouse button
- - R: right mouse button
-
-@warn: The event system in Blender needs a rewrite, though we don't know when that will happen. Until then, event related functions here (L{QAdd}, L{QRead},
-L{QHandle}, etc.) can be used, but they are actually experimental and can be
-substituted for a better method when the rewrite happens. In other words, use
-them at your own risk, because though they should work well and allow many
-interesting and powerful possibilities, they can be deprecated in some future
-version of Blender / Blender Python.
-"""
-
-def Redraw (spacetype = '<Types.VIEW3D>'):
- """
- Force a redraw of a specific space type.
- @type spacetype: int
- @param spacetype: the space type, see L{Types}. By default the 3d Views are
- redrawn. If spacetype < 0, all currently visible spaces are redrawn.
- """
-
-def RedrawAll ():
- """
- Redraw all windows.
- """
-
-def QRedrawAll ():
- """
- Redraw all windows by queue event.
- """
-
-def FileSelector (callback, title = 'SELECT FILE', filename = '<default>'):
- """
- Open the file selector window in Blender. After the user selects a filename,
- it is passed as parameter to the function callback given to FileSelector().
- Example::
- import Blender
- #
- def my_function(filename):
- print 'The selected file was:', filename
- #
- Blender.Window.FileSelector (my_function, 'SAVE FILE')
- @type callback: function that accepts a string: f(str)
- @param callback: The function that must be provided to FileSelector() and
- will receive the selected filename as parameter.
- @type title: string
- @param title: The string that appears in the button to confirm the selection
- and return from the file selection window.
- @type filename: string
- @param filename: A filename. This defaults to Blender.Get('filename').
- @warn: script links are not allowed to call the File / Image Selectors. This
- is because script links global dictionaries are removed when they finish
- execution and the File Selector needs the passed callback to stay around.
- An alternative is calling the File Selector from another script (see
- L{Blender.Run}).
- """
-
-def ImageSelector (callback, title = 'SELECT IMAGE', filename = '<default>'):
- """
- Open the image selector window in Blender. After the user selects a filename,
- it is passed as parameter to the function callback given to ImageSelector().
- Example::
- import Blender
- #
- def my_function(imagename):
- print 'The selected image was:', imagename
- #
- Blender.Window.ImageSelector (my_function, 'LOAD IMAGE')
- @type callback: function that accepts a string: f(str)
- @param callback: The function that must be provided to ImageSelector() and
- will receive the selected filename as parameter.
- @type title: string
- @param title: The string that appears in the button to confirm the selection
- and return from the image selection window.
- @type filename: string
- @param filename: A filename. This defaults to L{Blender.Get}('filename').
- @warn: script links are not allowed to call the File / Image Selectors. This
- is because script links global dictionaries are removed when they finish
- execution and the File Selector needs the passed callback to stay around.
- An alternative is calling the File Selector from another script (see
- L{Blender.Run}).
- """
-
-def DrawProgressBar (done, text):
- """
- Draw a progress bar in the upper right corner of the screen. To cancel it
- prematurely, users can press the "Esc" key. Start it with done = 0 and end
- it with done = 1.
- @type done: float
- @param done: A float in [0.0, 1.0] that tells the advance in the progress
- bar.
- @type text: string
- @param text: Info about what is currently being done "behind the scenes".
- """
-
-def GetCursorPos ():
- """
- Get the current 3d cursor position.
- @rtype: list of three floats
- @return: the current position: [x, y, z].
- """
-
-def GetActiveLayer ():
- """
- Get the bitmask for the active layer.
- @note: if there is no 3d view it will return zero.
- @rtype: int
- @return: layer bitmask
- """
-
-def SetActiveLayer(layermask):
- """
- Set the bitmask for the active layer.
- @type layermask: int
- @param layermask: An integer bitmask, to use humanly readable values do (1<<0) for the first layer, (1<<19) for the last layer.
- """
-
-def SetCursorPos (coords):
- """
- Change the 3d cursor position.
- @type coords: 3 floats or a list of 3 floats
- @param coords: The new x, y, z coordinates.
- @note: if visible, the 3d View must be redrawn to display the change. This
- can be done with L{Redraw}.
- """
-
-def GetPivot ():
- """
- Get the pivot for the active 3D view.
- @rtype: int
- @return: constant - Window.PivotTypes
- """
-
-def SetPivot (pivot):
- """
- Set the pivot on the active 3D view.
- @type pivot: int
- @param pivot: constant - Window.PivotTypes
- """
-
-def WaitCursor (bool):
- """
- Set cursor to wait or back to normal mode.
-
- Example::
- Blender.Window.WaitCursor(1)
- Blender.sys.sleep(2000) # do something that takes some time
- Blender.Window.WaitCursor(0) # back
-
- @type bool: int (bool)
- @param bool: if nonzero the cursor is set to wait mode, otherwise to normal
- mode.
- @note: when the script finishes execution, the cursor is set to normal by
- Blender itself.
- """
-
-def GetViewVector ():
- """
- Get the current 3d view vector.
- @rtype: list of three floats
- @return: the current vector: [x, y, z].
- """
-
-def GetViewMatrix ():
- """
- Get the current 3d view matrix.
- @rtype: 4x4 float matrix (WRAPPED DATA)
- @return: the current matrix.
- """
-
-def GetPerspMatrix ():
- """
- Get the current 3d perspective matrix.
- @rtype: 4x4 float matrix (WRAPPED DATA)
- @return: the current matrix.
- """
-
-def EditMode(enable = -1, undo_msg = 'From script', undo = 1):
- """
- Get and optionally set the current edit mode status: in or out.
-
- Example::
- in_editmode = Window.EditMode()
- # MUST leave edit mode before changing an active mesh:
- if in_editmode: Window.EditMode(0)
- # ...
- # make changes to the mesh
- # ...
- # be nice to the user and return things to how they were:
- if in_editmode: Window.EditMode(1)
- @type enable: int
- @param enable: get/set current status:
- - -1: just return current status (default);
- - 0: leave edit mode;
- - 1: enter edit mode.
-
- It's not an error to try to change to a state that is already the
- current one, the function simply ignores the request.
- @type undo_msg: string
- @param undo_msg: only needed when exiting edit mode (EditMode(0)). This
- string is used as the undo message in the Mesh->Undo History submenu in
- the 3d view header. Max length is 63, strings longer than that get
- clamped.
- @param undo: don't save Undo information (only needed when exiting edit
- mode).
- @type undo: int
- @rtype: int (bool)
- @return: 0 if Blender is not in edit mode right now, 1 otherwise.
- @warn: this is an important function. NMesh operates on normal Blender
- meshes, not edit mode ones. If a script changes an active mesh while in
- edit mode, when the user leaves the mode the changes will be lost,
- because the normal mesh will be rebuilt based on its unchanged edit mesh.
- """
-
-def PoseMode(enable = -1):
- """
- Get and optionally set the current pose mode status: in or out.
- @type enable: int
- @param enable: get/set current status:
- - -1: just return current status (default);
- - 0: leave edit mode;
- - 1: enter edit mode.
-
- @return: 0 if Blender is not in edit mode right now, 1 otherwise.
- @warn: This uses the active armature objects posemode status, enabling pose
- mode for non armature objects will always fail.
- """
-
-def ViewLayers (layers = [], winid = None):
- """
- Get and optionally set the currently visible layers in all 3d Views.
- @type layers: list of ints
- @param layers: a list with indexes of the layers that will be visible. Each
- index must be in the range [1, 20]. If not given or equal to [], the
- function simply returns the visible ones without changing anything.
- @type winid: window id from as redurned by GetScreenInfo
- @param winid: An optional argument to set the layer of a window
- rather then setting the scene layers. For this to display in the 3d view
- the layer lock must be disabled (unlocked).
- @rtype: list of ints
- @return: the currently visible layers.
- """
-
-def GetViewQuat ():
- """
- Get the current VIEW3D view quaternion values.
- @rtype: list of floats
- @return: the quaternion as a list of four float values.
- """
-
-def SetViewQuat (quat):
- """
- Set the current VIEW3D view quaternion.
- @type quat: floats or list of floats
- @param quat: four floats or a list of four floats.
- """
-
-def GetViewOffset ():
- """
- Get the current VIEW3D offset values.
- @rtype: list of floats
- @return: a list with three floats: [x,y,z].
- @note: The 3 values returned are flipped in comparison object locations.
- """
-
-def SetViewOffset (ofs):
- """
- Set the current VIEW3D offset values.
- @type ofs: 3 floats or list of 3 floats
- @param ofs: the new view offset values.
- @note: The value you give flipped in comparison object locations.
- """
-
-def CameraView (camtov3d = 0):
- """
- Set the current VIEW3D view to the active camera's view. If there's no
- active object or it is not of type 'Camera', the active camera for the
- current scene is used instead.
- @type camtov3d: int (bool)
- @param camtov3d: if nonzero it's the camera that gets positioned at the
- current view, instead of the view being changed to that of the camera.
- """
-
-def QTest ():
- """
- Check if there are pending events in the event queue.
- @rtype: int
- @return: 0 if there are no pending events, non-zero otherwise.
- """
-
-def QRead ():
- """
- Get the next pending event from the event queue.
-
- Example::
- # let's catch all events and move the 3D Cursor when user presses
- # the left mouse button.
- from Blender import Draw, Window
-
- v3d = Window.GetScreenInfo(Window.Types.VIEW3D)
- id = v3d[0]['id'] # get the (first) VIEW3D's id
-
- done = 0
-
- while not done: # enter a 'get event' loop
- evt, val = Window.QRead() # catch next event
- if evt in [Draw.MOUSEX, Draw.MOUSEY]:
- continue # speeds things up, ignores mouse movement
- elif evt in [Draw.ESCKEY, Draw.QKEY]: done = 1 # end loop
- elif evt == Draw.SPACEKEY:
- Draw.PupMenu("Hey!|What did you expect?")
- elif evt == Draw.Redraw: # catch redraw events to handle them
- Window.RedrawAll() # redraw all areas
- elif evt == Draw.LEFTMOUSE: # left button pressed
- Window.QAdd(id, evt, 1) # add the caught mouse event to our v3d
- # actually we should check if the event happened inside that area,
- # using Window.GetMouseCoords() and v3d[0]['vertices'] values.
- Window.QHandle(id) # process the event
- # do something fancy like putting some object where the
- # user positioned the 3d cursor, then:
- Window.Redraw() # show the change in the VIEW3D areas.
-
- @rtype: list
- @return: [event, val], where:
- - event: int - the key or mouse event (see L{Draw});
- - val: int - 1 for a key press, 0 for a release, new x or y coordinates
- for mouse movement events.
- """
-
-def QAdd (win, event, val, after = 0):
- """
- Add an event to some window's (actually called areas in Blender) event queue.
- @type win: int
- @param win: the window id, see L{GetScreenInfo}.
- @type event: positive int
- @param event: the event to add, see events in L{Draw}.
- @type val: int
- @param val: 1 for a key press, 0 for a release.
- @type after: int (bool)
- @param after: if nonzero the event is put after the current queue and added
- later.
- """
-
-def QHandle (winId):
- """
- Process immediately all pending events for the given window (area).
- @type winId: int
- @param winId: the window id, see L{GetScreenInfo}.
- @note: see L{QAdd} for how to send events to a particular window.
- """
-
-def GetMouseCoords ():
- """
- Get mouse's current screen coordinates.
- @rtype: list with two ints
- @return: a [x, y] list with the coordinates.
- """
-
-def SetMouseCoords (coords):
- """
- Set mouse's current screen coordinates.
- @type coords: (list of) two ints
- @param coords: can be passed as x, y or [x, y] and are clamped to stay inside
- the screen. If not given they default to the coordinates of the middle
- of the screen.
- """
-
-def GetMouseButtons ():
- """
- Get the current mouse button state (see / compare against L{MButs}).
- @rtype: int
- @return: an OR'ed flag with the currently pressed buttons.
- """
-
-def GetKeyQualifiers ():
- """
- Get the current qualifier keys state (see / compare against L{Qual}).
- @rtype: int
- @return: an OR'ed combination of values in L{Qual}.
- """
-
-def SetKeyQualifiers (qual):
- """
- Fake qualifier keys state. This is useful because some key events require
- one or more qualifiers to be active (see L{QAdd}).
- @type qual: int
- @param qual: an OR'ed combination of values in L{Qual}.
- @rtype: int
- @return: the current state, that should be equal to 'qual'.
- @warn: remember to reset the qual keys to 0 once they are not necessary
- anymore.
- """
-
-def GetAreaID ():
- """
- Get the current area's ID.
- """
-
-def GetAreaSize ():
- """
- Get the current area's size.
- @rtype: list with two ints
- @return: a [width, height] list.
- @note: the returned values are 1 pixel bigger than what L{GetScreenInfo}
- returns for the 'vertices' of the same area.
- """
-
-def GetScreenSize ():
- """
- Get Blender's screen size.
- @rtype: list with two ints
- @return: a [width, height] list.
- """
-
-def GetScreens ():
- """
- Get the names of all available screens.
- @rtype: list of strings
- @return: a list of names that can be passed to L{SetScreen}.
- """
-
-def SetScreen (name):
- """
- Set as current screen the one with the given name.
- @type name: string
- @param name: the name of an existing screen. Use L{GetScreens} to get
- a list with all screen names.
- """
-
-def GetScreenInfo (type = -1, rect = 'win', screen = ''):
- """
- Get info about the current screen setup.
- @type type: int
- @param type: the space type (see L{Types}) to restrict the
- results to. If -1 (the default), info is reported about all available
- areas.
- @type rect: string
- @param rect: the rectangle of interest. This defines if the corner
- coordinates returned will refer to:
- - the whole area: 'total'
- - only the header: 'header'
- - only the window content part (default): 'win'
- @type screen: string
- @param screen: the name of an available screen. The current one is used by
- default.
- @rtype: list of dictionaries
- @return: a list of dictionaries, one for each area in the screen. Each
- dictionary has these keys (all values are ints):
- - 'vertices': [xmin, ymin, xmax, ymax] area corners;
- - 'win': window type, see L{Types};
- - 'id': this area's id.
- """
diff --git a/source/blender/python/api2_2x/doc/World.py b/source/blender/python/api2_2x/doc/World.py
deleted file mode 100644
index d9e9bae750d..00000000000
--- a/source/blender/python/api2_2x/doc/World.py
+++ /dev/null
@@ -1,351 +0,0 @@
-# Blender.World module and the World PyType
-
-"""
-The Blender.World submodule
-
-B{New}: L{World.clearScriptLinks} accepts a parameter now.
-
-World
-=====
-
-The module world allows you to access all the data of a Blender World.
-
-Example::
- import Blender
- w = Blender.Get('World') #assume there exists a world named "world"
- print w.getName()
- w.hor = [1,1,.2]
- print w.getHor()
-
-Example::
- import Blender
- from Blender import *
-
- AllWorlds = Blender.World.Get() # returns a list of created world objects
- AvailWorlds = len(AllWorlds) # returns the number of available world objects
- PropWorld = dir(AllWorlds[0]) # returns the properties of the class world
- NameWorld = AllWorlds[0].getName() # get name of the first world object
-
- MiType = AllWorlds[0].getMistype() # get kind of mist from the first world object
- MiParam = AllWorlds[0].getMist() # get the parameters intensity, start, end and height of the mist
-
- HorColor = AllWorlds[0].getHor() # horizon color of the first world object
- HorColorR = HorColor[0] # get the red channel (RGB) of the horizon color
-
- ZenColor = AllWorlds[0].getZen() # zenith color of the first world object
- ZenColorB = ZenColor[2] # get the blue channel (RGB) of the Zenith color
-
- blending = AllWorlds[0].getSkytype() # get the blending modes (real, blend, paper) of the first world object
-"""
-
-def New (name):
- """
- Creates a new World.
- @type name: string
- @param name: World's name (optional).
- @rtype: Blender World
- @return: The created World. If the "name" parameter has not been provided, it will be automatically be set by blender.
- """
-
-def Get (name):
- """
- Get an World from Blender.
- @type name: string
- @param name: The name of the world to retrieve.
- @rtype: Blender World or a list of Blender Worlds
- @return:
- - (name): The World corresponding to the name
- - (): A list with all Worlds in the current scene.
- """
-
-
-def GetCurrent ():
- """
- Get the active world of the scene.
- @rtype: Blender World or None
- """
-
-class World:
- """
- The World object
- ================
- This object gives access to generic data from all worlds in Blender.
- Its attributes depend upon its type.
-
- @ivar skytype: type of the sky. Bit 0 : Blend; Bit 1 : Real; Bit 2 : paper.
- @ivar mode:
- @ivar mistype: type of mist : O : quadratic; 1 : linear; 2 : square
- @ivar hor: the horizon color of a world object.
- @ivar zen: the zenith color of a world object.
- @ivar amb: the ambient color of a world object.
- @ivar star: the star parameters of a world object. See getStar for the semantics of these parameters.
- @ivar mist: the mist parameters of a world object. See getMist for the semantics of these parameters.
- @type ipo: Blender Ipo
- @ivar ipo: The world type ipo linked to this world object.
- """
-
- def getRange():
- """
- Retrieves the range parameter of a world object.
- @rtype: float
- @return: the range
- """
-
- def setRange(range):
- """
- Sets the range parameter of a world object.
- @type range: float
- @param range: the new range parameter
- @rtype: None
- @return: None
- """
-
- def getName():
- """
- Retrieves the name of a world object
- @rtype: string
- @return: the name of the world object.
- """
-
- def setName(name):
- """
- Sets the name of a world object.
- @type name: string
- @param name : the new name.
- @rtype: None
- @return: None
- """
-
- def getIpo():
- """
- Get the Ipo associated with this world object, if any.
- @rtype: Ipo
- @return: the wrapped ipo or None.
- """
-
- def setIpo(ipo):
- """
- Link an ipo to this world object.
- @type ipo: Blender Ipo
- @param ipo: a "camera data" ipo.
- """
-
- def clearIpo():
- """
- Unlink the ipo from this world object.
- @return: True if there was an ipo linked or False otherwise.
- """
-
- def getSkytype():
- """
- Retrieves the skytype of a world object.
- The skytype is a combination of 3 bits : Bit 0 : Blend; Bit 1 : Real; Bit 2 : paper.
- @rtype: int
- @return: the skytype of the world object.
- """
-
- def setSkytype(skytype):
- """
- Sets the skytype of a world object.
- See getSkytype for the semantics of the parameter.
- @type skytype: int
- @param skytype : the new skytype.
- @rtype: None
- @return: None
- """
-
- def getMode():
- """
- Retrieves the mode of a world object.
- The mode is a combination of 5 bits:
- - Bit 0 : mist simulation
- - Bit 1 : starfield simulation
- - Bit 2,3 : reserved
- - Bit 4 : ambient occlusion
- @rtype: int
- @return: the mode of the world object.
- """
-
- def setMode(mode):
- """
- Sets the mode of a world object.
- See getMode for the semantics of the parameter.
- @type mode: int
- @param mode : the new mode.
- @rtype: None
- @return: None
- """
-
- def getMistype():
- """
- Retrieves the mist type of a world object.
- The mist type is an integer 0 : quadratic; 1 : linear; 2 : square.
- @rtype: int
- @return: the mistype of the world object.
- """
-
- def setMistype(mistype):
- """
- Sets the mist type of a world object.
- See getMistype for the semantics of the parameter.
- @type mistype: int
- @param mistype : the new mist type.
- @rtype: None
- @return: None
- """
-
- def getHor():
- """
- Retrieves the horizon color of a world object.
- This color is a list of 3 floats.
- @rtype: list of three floats
- @return: the horizon color of the world object.
- """
-
- def setHor(hor):
- """
- Sets the horizon color of a world object.
- @type hor: list of three floats
- @param hor : the new hor.
- @rtype: None
- @return: None
- """
-
- def getZen():
- """
- Retrieves the zenith color of a world object.
- This color is a list of 3 floats.
- @rtype: list of three floats
- @return: the zenith color of the world object.
- """
-
- def setZen(zen):
- """
- Sets the zenith color of a world object.
- @type zen: list of three floats
- @param zen : the new zenith color.
- @rtype: None
- @return: None
- """
-
- def getAmb():
- """
- Retrieves the ambient color of a world object.
- This color is a list of 3 floats.
- @rtype: list of three floats
- @return: the ambient color of the world object.
- """
-
- def setAmb(amb):
- """
- Sets the ambient color of a world object.
- @type amb: list of three floats
- @param amb : the new ambient color.
- @rtype: None
- @return: None
- """
-
- def getStar():
- """
- Retrieves the star parameters of a world object.
- It is a list of nine floats :
- red component of the color
- green component of the color
- blue component of the color
- size of the stars
- minimal distance between the stars
- average distance between the stars
- variations of the stars color
- @rtype: list of nine floats
- @return: the star parameters
- """
-
- def setStar(star):
- """
- Sets the star parameters of a world object.
- See getStar for the semantics of the parameter.
- @type star: list of 9 floats
- @param star : the new star parameters.
- @rtype: None
- @return: None
- """
-
- def getMist():
- """
- Retrieves the mist parameters of a world object.
- It is a list of four floats :
- intensity of the mist
- start of the mist
- end of the mist
- height of the mist
- @rtype: list of four floats
- @return: the mist parameters
- """
-
- def setMist(mist):
- """
- Sets the mist parameters of a world object.
- See getMist for the semantics of the parameter.
- @type mist: list of 4 floats
- @param mist : the new mist parameters.
- @rtype: None
- @return: None
- """
-
- def getScriptLinks (event):
- """
- Get a list with this World's script links of type 'event'.
- @type event: string
- @param event: "FrameChanged", "Redraw", "Render".
- @rtype: list
- @return: a list with Blender L{Text} names (the script links of the given
- 'event' type) or None if there are no script links at all.
- """
-
- def clearScriptLinks (links = None):
- """
- Delete script links from this World :). If no list is specified, all
- script links are deleted.
- @type links: list of strings
- @param links: None (default) or a list of Blender L{Text} names.
- """
-
- def addScriptLink (text, event):
- """
- Add a new script link to this World.
- @type text: string
- @param text: the name of an existing Blender L{Text}.
- @type event: string
- @param event: "FrameChanged", "Redraw" or "Render".
- """
-
- def setCurrent ():
- """
- Make this world active in the current scene.
- @rtype: None
- @return: None
- """
-
- def insertIpoKey(keytype):
- """
- Inserts keytype values in world ipo at curframe. Uses module constants.
- @type keytype: Integer
- @param keytype:
- -ZENTIH
- -HORIZON
- -MIST
- -STARS
- -OFFSET
- -SIZE
- @return: py_none
- """
-
- def __copy__ ():
- """
- Make a copy of this world
- @rtype: World
- @return: a copy of this world
- """
-
-import id_generics
-World.__doc__ += id_generics.attributes
diff --git a/source/blender/python/api2_2x/doc/Worlddoc.txt b/source/blender/python/api2_2x/doc/Worlddoc.txt
deleted file mode 100644
index 78e325fd7ce..00000000000
--- a/source/blender/python/api2_2x/doc/Worlddoc.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-METABALL Module documentation
-
-INTRODUCTION
-The metaball module effect allows you to access all the data of an metaball.
-A metaball consists of several (maybe only one) metaelems, which are spheres, interacting with each other, thus creating soft organic volumes.
-
-functions of the module :
-New(name) : creates ans returns a metaball object.
-Get(opt : name) : if the parameter name is given, returns the metaball object whose name has been passed, or Py_None, if no such metaball exists in the current scene. If no parameter is given, returns a list of all the metaballs in the current scene.
-get : alias for Get
-
-Metaball object member functions :
-
-getName()Return Metaball name
-setName(string newname) - Sets Metaball name
-getWiresize() - Return Metaball wire size
-setWiresize(float val) - Sets Metaball wire size
-getRendersize() - Return Metaball render size
-setRendersize(float newval- Sets Metaball render size
-getThresh()- Return Metaball threshold
-setThresh(float newval)- Sets Metaball threshold
-getBbox,- Return Metaball bounding box(a list of eight lists of three elements)
-getNMetaElems() Returns the number of Metaelems (basic spheres)
-getMetatype(int num_metaelem): returns the type of the metaelem number num_metaelem.
-0 : ball
-1 : tubex
-2 : tubey
-3 : tubez
-setMetatype(int num_metaelem,int newtype) : sets the type of the metaelem number num_metaelem.
-getMetadata(field_name,int num_metaelem) gets Metaball MetaData. Explained later.
-setMetadata(field_name,int num_metaelem,newval) sets Metaball MetaData. Explained later.
-getMetalay(int num_metaelem)
-getMetax(int num_metaelem) : gets the x coordinate of the metaelement
-setMetax(int num_metaelem,float newval) : sets the x coordinate of the metaelement
-getMetay(int num_metaelem) : gets the y coordinate of the metaelement
-setMetay(int num_metaelem,float newval) : sets the y coordinate of the metaelement
-getMetaz(int num_metaelem) : gets the z coordinate of the metaelement
-setMetaz(int num_metaelem,float newval) : sets the z coordinate of the metaelement
-getMetas(int num_metaelem) : gets the s coordinate of the metaelement
-setMetas(int num_metaelem,float newval) : sets the s coordinate of the metaelement
-getMetalen(int num_metaelem) : gets the length of the metaelement. Important for tubes.
-setMetalen(int num_metaelem,float newval) : sets the length of the metaelement. Important for tubes.
-getloc, - Gets Metaball loc values
-setloc, (f f f) - Sets Metaball loc values
-getrot, () - Gets Metaball rot values
-setrot,, (f f f) - Sets Metaball rot values
-getsize,() - Gets Metaball size values
-setsize,(f f f) - Sets Metaball size values
-
-
-
-
-The Object.attribute syntax
-
-The attribute can take these values : seed,nabla,sta,end,lifetime,normfac,obfac,randfac,texfac,randlife,vectsize,totpart,force,mult,life,child,mat,defvec. \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/epy_docgen-3.sh b/source/blender/python/api2_2x/doc/epy_docgen-3.sh
deleted file mode 100644
index bec7653b152..00000000000
--- a/source/blender/python/api2_2x/doc/epy_docgen-3.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-# epy_docgen.sh
-# generates blender python doc using epydoc
-# requires epydoc in your PATH.
-# run from the doc directory containing the .py files
-# usage: sh epy_docgen.sh
-
-# set posix locale so regex works properly for [A-Z]*.py
-LC_ALL=POSIX
-
-epydoc -o BPY_API --url "http://www.blender.org" --top API_intro \
- --name "Blender" --no-private --no-frames \
-$( ls [A-Z]*.py )
diff --git a/source/blender/python/api2_2x/doc/epy_docgen.sh b/source/blender/python/api2_2x/doc/epy_docgen.sh
deleted file mode 100644
index d709ee73190..00000000000
--- a/source/blender/python/api2_2x/doc/epy_docgen.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-# epy_docgen.sh
-# generates blender python doc using epydoc
-# requires epydoc in your PATH.
-# run from the doc directory containing the .py files
-# usage: sh epy_docgen.sh
-
-# set posix locale so regex works properly for [A-Z]*.py
-LC_ALL=POSIX
-
-epydoc -o BPY_API --url "http://www.blender.org" -t API_intro.py \
- -n "Blender" --no-private --no-frames \
-$( ls [A-Z]*.py )
diff --git a/source/blender/python/api2_2x/doc/id_generics.py b/source/blender/python/api2_2x/doc/id_generics.py
deleted file mode 100644
index 30c7e5d6a3c..00000000000
--- a/source/blender/python/api2_2x/doc/id_generics.py
+++ /dev/null
@@ -1,30 +0,0 @@
-attributes = """
- @ivar name: unique name within each blend file.
-
- The name is case sensitive and 21 characters maximum length.
-
- B{Note}: a blend file may have naming collisions when external library data is used,
- be sure to check the value of L{lib}.
-
- B{Note}: Setting a value longer then 21 characters will be shortened
- @type name: string
- @ivar lib: path to the blend file this datablock is stored in (readonly).
-
- lib will be None unless you are using external blend files with (File, Append/Link)
-
- B{Note}: the path may be relative, to get the full path use L{Blender.sys.expandpath<Sys.expandpath>}
- @type lib: string or None
-
- @ivar fakeUser: When set to True, this datablock wont be removed, even if nothing is using it.
- All data has this disabled by default except for Actions.
- @type fakeUser: bool
- @ivar tag: A temporary tag that to flag data as being used within a loop.
- always set all tags to True or False before using since blender uses this flag for its own internal operations.
- @type tag: bool
- @ivar users: The number of users this datablock has. (readonly)
- Zero user datablocks are de-allocated after reloading and saving.
- @type users: int
- @ivar properties: Returns an L{IDGroup<IDProp.IDGroup>} reference to this
- datablocks's ID Properties.
- @type properties: L{IDGroup<IDProp.IDGroup>}
-""" \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/testbgl.py b/source/blender/python/api2_2x/doc/testbgl.py
deleted file mode 100644
index e895d01df69..00000000000
--- a/source/blender/python/api2_2x/doc/testbgl.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# Testing the BGL module
-
-import Blender
-from Blender.BGL import *
-from Blender import Draw
-
-R = G = B = 0
-A = 1
-
-instructions = "Hold mouse buttons to change the background color."
-quitting = " Press ESC or q to quit."
-
-def show_win():
- glClearColor(R,G,B,A) # define color used to clear buffers
- glClear(GL_COLOR_BUFFER_BIT) # use it to clear the color buffer
- glColor3f(1,1,1) # change default color
- glRasterPos2i(50,100) # move cursor to x = 50, y = 100
- Draw.Text("Testing BGL + Draw") # draw this text there
- glRasterPos2i(350,20) # move cursor again
- Draw.Text(instructions + quitting) # draw another msg
- glBegin(GL_LINE_LOOP) # begin a vertex-data list
- glVertex2i(46,92)
- glVertex2i(120,92)
- glVertex2i(120,115)
- glVertex2i(46,115)
- glEnd() # close this list
- glColor3f(0.35,0.18,0.92) # change default color again
- glBegin(GL_POLYGON) # another list, for a polygon
- glVertex2i(315, 292)
- glVertex2i(412, 200)
- glVertex2i(264, 256)
- glEnd()
- Draw.Redraw(1) # make changes visible.
-
-def ev(evt, val): # this is a callback for Draw.Register()
- global R,G,B,A # it handles input events
- if evt == Draw.ESCKEY or evt == Draw.QKEY:
- Draw.Exit() # this quits the script
- elif evt == Draw.LEFTMOUSE: R = 1 - R
- elif evt == Draw.MIDDLEMOUSE: G = 1 - G
- elif evt == Draw.RIGHTMOUSE: B = 1 - B
- else:
- Draw.Register(show_win, ev, None)
-
-Draw.Register(show_win, ev, None) # start the main loop
diff --git a/source/blender/python/api2_2x/doc/testcamera.py b/source/blender/python/api2_2x/doc/testcamera.py
deleted file mode 100644
index a84b3ac5b15..00000000000
--- a/source/blender/python/api2_2x/doc/testcamera.py
+++ /dev/null
@@ -1,137 +0,0 @@
-# Blender.Camera module and Camera PyType test file
-# This also works with Lamp and Material, simply uncomment the right
-# line below
-
-MODULE = "Camera"
-#MODULE = "Lamp"
-#MODULE = "Material"
-BPY_OBJECT = MODULE
-
-LONG_STRING = "Supercalifragilisticspialidous"
-
-import types, sys
-import Blender
-exec ("from Blender import %s" % MODULE)
-
-def PRINT_HEADER(header, sep):
- print "\n", sep * 79
- print header
- print sep * 79
-
-def PRINT_UNDERLINED(str):
- print "\n", str
- print "-" * len(str)
-
-def PRINT_AND_RM(arg, branch, d):
- for a in arg:
- if a in d:
- d.remove(a)
- print "\n%s.%s:" % (branch, a),
- exec("print %s.%s" % (branch, a))
-
-PRINT_HEADER("Testing the Blender.%s module" % MODULE, '=')
-
-exec ("Module_dir = dir (%s)" % MODULE)
-print "\ndir (%s):" % MODULE
-print Module_dir
-
-PRINT_AND_RM (["__name__", "__doc__"], MODULE, Module_dir)
-
-for item in Module_dir:
- hooked = 0
- branch = "%s.%s" % (MODULE, item)
- PRINT_HEADER(branch, "-")
- exec ("item_type = type (%s)" % branch)
- print item_type
- exec ("sub_dir = dir(%s)" % branch)
- PRINT_AND_RM (["__name__", "__doc__"], branch, sub_dir)
- if item_type == types.BuiltinFunctionType:
- PRINT_UNDERLINED ("Executing %s:" % branch)
- exec ("result = %s()" % branch)
- print "Returned value is: ", result
- if item in ["Get", "get"] and not hooked:
- if len(result):
- obj = result[0]
- hooked = 1
-
-if hooked:
- PRINT_HEADER(obj, "=")
- exec ("obj_dir = dir(obj)")
- print "\ndir():"
- print obj_dir
-
- methods = []
- member_vars = []
-
- for item in obj_dir:
- exec ("item_type = type (obj.%s)" % item)
- if item_type == types.BuiltinMethodType:
- methods.append(item)
- else:
- member_vars.append(item)
-
- PRINT_HEADER("%s Methods" % BPY_OBJECT, '-')
- if methods: print methods
- else: print "XXX No methods found in %s" % BPY_OBJECT
-
- PRINT_HEADER("%s Member Variables" % BPY_OBJECT, '-')
- if member_vars:
- for m in member_vars:
- PRINT_UNDERLINED(m)
- exec ("mvalue = obj.%s" % m)
- exec ("mtype = type (obj.%s)" % m)
- mtype = str(mtype).split("'")[1]
- print "%s: %s" % (mtype, mvalue)
-
- M = m[0].upper() + m[1:]
- setM = "set%s" % M
- getM = "get%s" % M
- if setM in methods:
- print "There is a .%s() method." % setM
- methods.remove(setM)
- if mtype == 'str':
- try:
- print "Trying to set string to %s" % LONG_STRING
- exec("obj.%s('%s')" % (setM, LONG_STRING))
- exec("get_str = obj.%s()" % getM)
- print "It returned:", get_str
- len_str = len(get_str)
- if len_str < 100:
- print "It correctly clamped the string to %s chars." % len_str
- except:
- PRINT_HEADER("FAILED in .%s()" % setM, "X")
- print sys.exc_info()[0]
- elif mtype == 'float':
- try:
- exec("obj.%s(%d)" % (setM, -999999))
- exec("result = obj.%s()" % getM)
- print "%s's minimum value is %f" % (m, result)
- exec("obj.%s(%d)" % (setM, 999999))
- exec("result = obj.%s()" % getM)
- print "%s's maximum value is %f" % (m, result)
- except:
- PRINT_HEADER("FAILED in %s or %s" % (setM, getM), "X")
- print sys.exc_info()[0]
- elif mtype == 'int':
- try:
- dict = M+"s"
- if dict in member_vars:
- exec("key = obj.%s.keys()[1]" % dict)
- exec("obj.%s('%s')" % (setM, key))
- exec("result = obj.%s()" % getM)
- except:
- PRINT_HEADER("FAILED in %s or %s" % (setM, getM), "X")
- print sys.exc_info()[0]
-
- if getM in methods:
- print "There is a .%s() method." % getM,
- methods.remove(getM)
- exec("result = obj.%s()" % getM)
- print "It returned:", result
-
- else: print "XXX No member variables found in %s" % BPY_OBJECT
-
-else: # the module .Get() function found nothing
- PRINT_HEADER("Failed trying to %s.Get() a %s object"
- % (MODULE, BPY_OBJECT), 'X')
-
diff --git a/source/blender/python/api2_2x/doc/testcurve.py b/source/blender/python/api2_2x/doc/testcurve.py
deleted file mode 100644
index 1db037bc385..00000000000
--- a/source/blender/python/api2_2x/doc/testcurve.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import Blender
-
-
-list = Blender.Curve.Get()
-
-print list
-
-cur = Blender.Curve.Get('Curve')
-
-
-for prop in ["Name","PathLen","Totcol","Flag","Bevresol","Resolu","Resolv","Width","Ext1","Ext2","Loc","Rot","Size"]:
- value = eval("cur.get%s()"%prop)
- print prop,"-->",value
- exec("cur.set%s(value)"%prop)
-
-
-
-for attr in [ "name","pathlen","totcol","flag","bevresol","resolu","resolv","width","ext1","ext2","loc","rot","size"]:
- value = eval("cur.%s"%attr)
- exec("cur.%s = value"%attr) \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/testeffect.py b/source/blender/python/api2_2x/doc/testeffect.py
deleted file mode 100644
index 5d9b65c36be..00000000000
--- a/source/blender/python/api2_2x/doc/testeffect.py
+++ /dev/null
@@ -1,65 +0,0 @@
-import Blender
-
-################## WARNING ########################
-#
-# this script tests the Effect module, and its submodules : Wave, Build and Particle
-# an object name "Plane" must be created, with three effects attached to it.
-# the first effect must be a "Build" effect
-# the second effect must be a "Wave" effect
-# the third effect must be a "Particle" effect
-#
-########################################################
-
-
-
-effect = Blender.Effect.New()
-print effect
-
-
-
-build = Blender.Effect.Get('Plane',0)
-
-
-for param in ['Type','Flag','Len','Sfra'] :
- value = eval("build.get%s()"%param)
- print param,value
- value1 = eval("build.set%s(%s)"%(param,value))
- print value1
-
-for param in ["sfra","len"]:
- str = "build.%s"%param
- value = eval(str)
- print str,value
- exec("build.%s = value"%param)
-
-
-
-wave = Blender.Effect.Get('Plane',1)
-for param in ['Type','Flag','Startx','Starty','Height', 'Width', 'Narrow', 'Speed', 'Minfac', 'Damp', 'Timeoffs' ,'Lifetime'] :
- value = eval("wave.get%s()"%param)
- print param,value
- value1 = eval("wave.set%s(%s)"%(param,value))
- print value1
-
-
-for param in ["lifetime","timeoffs","damp","minfac","speed","narrow","width","height","startx","starty"]:
- str = "wave.%s"%param
- value = eval(str)
- print str,value
- exec("wave.%s = value"%param)
-
-
-
-
-particle = Blender.Effect.Get('Plane',2)
-for param in ['Type','Flag','StartTime','EndTime','Lifetime','Normfac','Obfac','Randfac','Texfac','Randlife','Nabla','Totpart','Totkey','Seed','Force','Mult','Life','Child','Mat','Defvec'] :
- value = eval("particle.get%s()"%param)
- print param,value
- value1 = eval("particle.set%s(%s)"%(param,value))
- print value1
-
-for param in ['seed','nabla','sta','end','lifetime','normfac','obfac','randfac','texfac','randlife','vectsize','totpart','force','mult','life','child','mat','defvec']:
- str = "particle.%s"%param
- value = eval(str)
- print str,value
- exec("particle.%s = value"%param) \ No newline at end of file
diff --git a/source/blender/python/api2_2x/doc/testipo.py b/source/blender/python/api2_2x/doc/testipo.py
deleted file mode 100644
index 89db92f03c2..00000000000
--- a/source/blender/python/api2_2x/doc/testipo.py
+++ /dev/null
@@ -1,24 +0,0 @@
-import Blender
-
-ipo = Blender.Ipo.Get()
-print "Available ipos : ",ipo
-
-ipo = Blender.Ipo.Get('ObIpo')# hope there is an ipo named "ObIpo"...
-
-
-for prop in ["Name","Blocktype","Showkey","Pad","Rctf"]:
- val = eval("ipo.get%s()"%prop)
- print prop,"-->",val
- #exec("ipo.set%s(%s)"%(prop,val))
-
-try :
- val = ipo.getCurveBP(0)
- print "CurveBP -->",val
-except : print "error BP"
-val = ipo.getNcurves()
-print "NCurves -->",val
-
-curvebeztriple = ipo.getCurveBeztriple(0,0)
-print "curvebeztriple",curvebeztriple
-ipo.setCurveBeztriple(0,0,[1,2,3,4,5,6,7,8,9])
-print ipo.getCurveBeztriple(0,0)
diff --git a/source/blender/python/api2_2x/doc/testmball.py b/source/blender/python/api2_2x/doc/testmball.py
deleted file mode 100644
index 41c8377193f..00000000000
--- a/source/blender/python/api2_2x/doc/testmball.py
+++ /dev/null
@@ -1,37 +0,0 @@
-import Blender
-
-
-
-
-d = Blender.Metaball.Get('Meta')
-
-for prop in ["Name","Wiresize","Thresh","Rendersize","loc","rot","size"]:
- str = "d.get%s()"%prop
- val = eval(str)
- print str,"-->",val
- str1 = "d.set%s(%s)"%(prop,repr(val))
- val1 = eval(str1)
- print str1,"-->",val1
-
-
-
-nelem = d.getNMetaElems()
-print "getNMetaElems",nelem
-
-
-for prop in ['lay','type','selcol','flag','pad','x','y','z','expx','expy','expz','rad','rad2','s','len','maxrad2']:
- str = "d.getMeta%s(0)"%prop
- value = eval(str)
- print str,"-->",value
- str1 = "d.setMeta%s(0,%s)"%(prop,repr(value))
- value1 = eval(str1)
- print str1,"-->",value1
-print;print
-
-for field in ["name","loc","rot","size"]:
- str = "d.%s"%field
- val = eval(str)
- print str,"-->",val
- exec("d.%s = val"%field)
-
-
diff --git a/source/blender/python/api2_2x/doc/testtext.py b/source/blender/python/api2_2x/doc/testtext.py
deleted file mode 100644
index 3e3fd1a5b01..00000000000
--- a/source/blender/python/api2_2x/doc/testtext.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Test Blender.Text
-
-import Blender
-from Blender import Text
-
-txt = Text.New("MyText")
-all_texts = Text.Get()
-
-for i in [1,4,7]:
- txt.write("%d\n%d\n%d little indians\n" % (i, i+1, i+2))
-
-x = txt.getNLines()
-
-txt.write("%d little indian boys!" % x)
-
-lines = txt.asLines()
-
-txt.clear()
-txt.write("... Yo-ho-ho! And a bottle of rum!")
-
-for s in lines:
- print s
-
-print all_texts
-print txt.asLines()
-
-Text.unlink(txt)
-
-print all_texts
diff --git a/source/blender/python/api2_2x/doc/testworld.py b/source/blender/python/api2_2x/doc/testworld.py
deleted file mode 100644
index 171855f66c9..00000000000
--- a/source/blender/python/api2_2x/doc/testworld.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import Blender
-#testfile
-list = Blender.World.Get()
-print "available worlds",list
-
-w = Blender.World.Get("World")
-
-for param in ["Name","Colormodel","Fastcol","Skytype","Mode","Totex","Texact","Mistype","Hor","Zen","Amb","Star","Dof","Mist"]:
- val = eval("w.get%s()"%param)
- print param,val
- val1 = eval("w.set%s(val)"%param)
- print val1
-
-
-for param in ["name","colormodel","fastcol","skytype","mode","totex","texact","mistype","hor","zen","amb","star","dof","mist"]:
- exec("val = w.%s"%param)
- print param,val
- exec ("w.%s = val"%param)
-
-
-
diff --git a/source/blender/python/api2_2x/euler.c b/source/blender/python/api2_2x/euler.c
deleted file mode 100644
index acbc2b4e680..00000000000
--- a/source/blender/python/api2_2x/euler.c
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * $Id: euler.c 12314 2007-10-20 20:24:09Z 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 *****
- */
-
-#include "Mathutils.h"
-
-#include "BLI_arithb.h"
-#include "BKE_utildefines.h"
-#include "BLI_blenlib.h"
-#include "gen_utils.h"
-
-
-//-------------------------DOC STRINGS ---------------------------
-char Euler_Zero_doc[] = "() - set all values in the euler to 0";
-char Euler_Unique_doc[] ="() - sets the euler rotation a unique shortest arc rotation - tests for gimbal lock";
-char Euler_ToMatrix_doc[] = "() - returns a rotation matrix representing the euler rotation";
-char Euler_ToQuat_doc[] = "() - returns a quaternion representing the euler rotation";
-char Euler_Rotate_doc[] = "() - rotate a euler by certain amount around an axis of rotation";
-char Euler_copy_doc[] = "() - returns a copy of the euler.";
-//-----------------------METHOD DEFINITIONS ----------------------
-struct PyMethodDef Euler_methods[] = {
- {"zero", (PyCFunction) Euler_Zero, METH_NOARGS, Euler_Zero_doc},
- {"unique", (PyCFunction) Euler_Unique, METH_NOARGS, Euler_Unique_doc},
- {"toMatrix", (PyCFunction) Euler_ToMatrix, METH_NOARGS, Euler_ToMatrix_doc},
- {"toQuat", (PyCFunction) Euler_ToQuat, METH_NOARGS, Euler_ToQuat_doc},
- {"rotate", (PyCFunction) Euler_Rotate, METH_VARARGS, Euler_Rotate_doc},
- {"__copy__", (PyCFunction) Euler_copy, METH_VARARGS, Euler_copy_doc},
- {"copy", (PyCFunction) Euler_copy, METH_VARARGS, Euler_copy_doc},
- {NULL, NULL, 0, NULL}
-};
-//-----------------------------METHODS----------------------------
-//----------------------------Euler.toQuat()----------------------
-//return a quaternion representation of the euler
-PyObject *Euler_ToQuat(EulerObject * self)
-{
- float eul[3], quat[4];
- int x;
-
- for(x = 0; x < 3; x++) {
- eul[x] = self->eul[x] * ((float)Py_PI / 180);
- }
- EulToQuat(eul, quat);
- return newQuaternionObject(quat, Py_NEW);
-}
-//----------------------------Euler.toMatrix()---------------------
-//return a matrix representation of the euler
-PyObject *Euler_ToMatrix(EulerObject * self)
-{
- float eul[3];
- float mat[9] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
- int x;
-
- for(x = 0; x < 3; x++) {
- eul[x] = self->eul[x] * ((float)Py_PI / 180);
- }
- EulToMat3(eul, (float (*)[3]) mat);
- return newMatrixObject(mat, 3, 3 , Py_NEW);
-}
-//----------------------------Euler.unique()-----------------------
-//sets the x,y,z values to a unique euler rotation
-PyObject *Euler_Unique(EulerObject * self)
-{
- double heading, pitch, bank;
- double pi2 = Py_PI * 2.0f;
- double piO2 = Py_PI / 2.0f;
- double Opi2 = 1.0f / pi2;
-
- //radians
- heading = self->eul[0] * (float)Py_PI / 180;
- pitch = self->eul[1] * (float)Py_PI / 180;
- bank = self->eul[2] * (float)Py_PI / 180;
-
- //wrap heading in +180 / -180
- pitch += Py_PI;
- pitch -= floor(pitch * Opi2) * pi2;
- pitch -= Py_PI;
-
-
- if(pitch < -piO2) {
- pitch = -Py_PI - pitch;
- heading += Py_PI;
- bank += Py_PI;
- } else if(pitch > piO2) {
- pitch = Py_PI - pitch;
- heading += Py_PI;
- bank += Py_PI;
- }
- //gimbal lock test
- if(fabs(pitch) > piO2 - 1e-4) {
- heading += bank;
- bank = 0.0f;
- } else {
- bank += Py_PI;
- bank -= (floor(bank * Opi2)) * pi2;
- bank -= Py_PI;
- }
-
- heading += Py_PI;
- heading -= (floor(heading * Opi2)) * pi2;
- heading -= Py_PI;
-
- //back to degrees
- self->eul[0] = (float)(heading * 180 / (float)Py_PI);
- self->eul[1] = (float)(pitch * 180 / (float)Py_PI);
- self->eul[2] = (float)(bank * 180 / (float)Py_PI);
-
- return EXPP_incr_ret((PyObject*)self);
-}
-//----------------------------Euler.zero()-------------------------
-//sets the euler to 0,0,0
-PyObject *Euler_Zero(EulerObject * self)
-{
- self->eul[0] = 0.0;
- self->eul[1] = 0.0;
- self->eul[2] = 0.0;
-
- return EXPP_incr_ret((PyObject*)self);
-}
-//----------------------------Euler.rotate()-----------------------
-//rotates a euler a certain amount and returns the result
-//should return a unique euler rotation (i.e. no 720 degree pitches :)
-PyObject *Euler_Rotate(EulerObject * self, PyObject *args)
-{
- float angle = 0.0f;
- char *axis;
- int x;
-
- if(!PyArg_ParseTuple(args, "fs", &angle, &axis)){
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "euler.rotate():expected angle (float) and axis (x,y,z)");
- }
- if(!STREQ3(axis,"x","y","z")){
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "euler.rotate(): expected axis to be 'x', 'y' or 'z'");
- }
-
- //covert to radians
- angle *= ((float)Py_PI / 180);
- for(x = 0; x < 3; x++) {
- self->eul[x] *= ((float)Py_PI / 180);
- }
- euler_rot(self->eul, angle, *axis);
- //convert back from radians
- for(x = 0; x < 3; x++) {
- self->eul[x] *= (180 / (float)Py_PI);
- }
-
- return EXPP_incr_ret((PyObject*)self);
-}
-//----------------------------Euler.rotate()-----------------------
-// return a copy of the euler
-PyObject *Euler_copy(EulerObject * self, PyObject *args)
-{
- return newEulerObject(self->eul, Py_NEW);
-}
-
-
-//----------------------------dealloc()(internal) ------------------
-//free the py_object
-static void Euler_dealloc(EulerObject * self)
-{
- //only free py_data
- if(self->data.py_data){
- PyMem_Free(self->data.py_data);
- }
- PyObject_DEL(self);
-}
-//----------------------------getattr()(internal) ------------------
-//object.attribute access (get)
-static PyObject *Euler_getattr(EulerObject * self, char *name)
-{
- if(STREQ(name,"x")){
- return PyFloat_FromDouble(self->eul[0]);
- }else if(STREQ(name, "y")){
- return PyFloat_FromDouble(self->eul[1]);
- }else if(STREQ(name, "z")){
- return PyFloat_FromDouble(self->eul[2]);
- }
- if(STREQ(name, "wrapped")){
- if(self->wrapped == Py_WRAP)
- return EXPP_incr_ret((PyObject *)Py_True);
- else
- return EXPP_incr_ret((PyObject *)Py_False);
- }
- return Py_FindMethod(Euler_methods, (PyObject *) self, name);
-}
-//----------------------------setattr()(internal) ------------------
-//object.attribute access (set)
-static int Euler_setattr(EulerObject * self, char *name, PyObject * e)
-{
- PyObject *f = NULL;
-
- f = PyNumber_Float(e);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnIntError(PyExc_TypeError,
- "euler.attribute = x: argument not a number\n");
- }
-
- if(STREQ(name,"x")){
- self->eul[0] = (float)PyFloat_AS_DOUBLE(f);
- }else if(STREQ(name, "y")){
- self->eul[1] = (float)PyFloat_AS_DOUBLE(f);
- }else if(STREQ(name, "z")){
- self->eul[2] = (float)PyFloat_AS_DOUBLE(f);
- }else{
- Py_DECREF(f);
- return EXPP_ReturnIntError(PyExc_AttributeError,
- "euler.attribute = x: unknown attribute\n");
- }
-
- Py_DECREF(f);
- return 0;
-}
-//----------------------------print object (internal)--------------
-//print the object to screen
-static PyObject *Euler_repr(EulerObject * self)
-{
- int i;
- char buffer[48], str[1024];
-
- BLI_strncpy(str,"[",1024);
- for(i = 0; i < 3; i++){
- if(i < (2)){
- sprintf(buffer, "%.6f, ", self->eul[i]);
- strcat(str,buffer);
- }else{
- sprintf(buffer, "%.6f", self->eul[i]);
- strcat(str,buffer);
- }
- }
- strcat(str, "](euler)");
-
- return PyString_FromString(str);
-}
-//------------------------tp_richcmpr
-//returns -1 execption, 0 false, 1 true
-static PyObject* Euler_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type)
-{
- EulerObject *eulA = NULL, *eulB = NULL;
- int result = 0;
-
- if (!EulerObject_Check(objectA) || !EulerObject_Check(objectB)){
- if (comparison_type == Py_NE){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
- }
- eulA = (EulerObject*)objectA;
- eulB = (EulerObject*)objectB;
-
- switch (comparison_type){
- case Py_EQ:
- result = EXPP_VectorsAreEqual(eulA->eul, eulB->eul, 3, 1);
- break;
- case Py_NE:
- result = EXPP_VectorsAreEqual(eulA->eul, eulB->eul, 3, 1);
- if (result == 0){
- result = 1;
- }else{
- result = 0;
- }
- break;
- default:
- printf("The result of the comparison could not be evaluated");
- break;
- }
- if (result == 1){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
-}
-//------------------------tp_doc
-static char EulerObject_doc[] = "This is a wrapper for euler objects.";
-//---------------------SEQUENCE PROTOCOLS------------------------
-//----------------------------len(object)------------------------
-//sequence length
-static int Euler_len(EulerObject * self)
-{
- return 3;
-}
-//----------------------------object[]---------------------------
-//sequence accessor (get)
-static PyObject *Euler_item(EulerObject * self, int i)
-{
- if(i < 0 || i >= 3)
- return EXPP_ReturnPyObjError(PyExc_IndexError,
- "euler[attribute]: array index out of range\n");
-
- return PyFloat_FromDouble(self->eul[i]);
-
-}
-//----------------------------object[]-------------------------
-//sequence accessor (set)
-static int Euler_ass_item(EulerObject * self, int i, PyObject * ob)
-{
- PyObject *f = NULL;
-
- f = PyNumber_Float(ob);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnIntError(PyExc_TypeError,
- "euler[attribute] = x: argument not a number\n");
- }
-
- if(i < 0 || i >= 3){
- Py_DECREF(f);
- return EXPP_ReturnIntError(PyExc_IndexError,
- "euler[attribute] = x: array assignment index out of range\n");
- }
- self->eul[i] = (float)PyFloat_AS_DOUBLE(f);
- Py_DECREF(f);
- return 0;
-}
-//----------------------------object[z:y]------------------------
-//sequence slice (get)
-static PyObject *Euler_slice(EulerObject * self, int begin, int end)
-{
- PyObject *list = NULL;
- int count;
-
- CLAMP(begin, 0, 3);
- if (end<0) end= 4+end;
- CLAMP(end, 0, 3);
- begin = MIN2(begin,end);
-
- list = PyList_New(end - begin);
- for(count = begin; count < end; count++) {
- PyList_SetItem(list, count - begin,
- PyFloat_FromDouble(self->eul[count]));
- }
-
- return list;
-}
-//----------------------------object[z:y]------------------------
-//sequence slice (set)
-static int Euler_ass_slice(EulerObject * self, int begin, int end,
- PyObject * seq)
-{
- int i, y, size = 0;
- float eul[3];
- PyObject *e, *f;
-
- CLAMP(begin, 0, 3);
- if (end<0) end= 4+end;
- CLAMP(end, 0, 3);
- begin = MIN2(begin,end);
-
- size = PySequence_Length(seq);
- if(size != (end - begin)){
- return EXPP_ReturnIntError(PyExc_TypeError,
- "euler[begin:end] = []: size mismatch in slice assignment\n");
- }
-
- for (i = 0; i < size; i++) {
- e = PySequence_GetItem(seq, i);
- if (e == NULL) { // Failed to read sequence
- return EXPP_ReturnIntError(PyExc_RuntimeError,
- "euler[begin:end] = []: unable to read sequence\n");
- }
-
- f = PyNumber_Float(e);
- if(f == NULL) { // parsed item not a number
- Py_DECREF(e);
- return EXPP_ReturnIntError(PyExc_TypeError,
- "euler[begin:end] = []: sequence argument not a number\n");
- }
-
- eul[i] = (float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(f,e);
- }
- //parsed well - now set in vector
- for(y = 0; y < 3; y++){
- self->eul[begin + y] = eul[y];
- }
- return 0;
-}
-//-----------------PROTCOL DECLARATIONS--------------------------
-static PySequenceMethods Euler_SeqMethods = {
- (inquiry) Euler_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Euler_item, /* sq_item */
- (intintargfunc) Euler_slice, /* sq_slice */
- (intobjargproc) Euler_ass_item, /* sq_ass_item */
- (intintobjargproc) Euler_ass_slice, /* sq_ass_slice */
-};
-//------------------PY_OBECT DEFINITION--------------------------
-PyTypeObject euler_Type = {
- PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "euler", //tp_name
- sizeof(EulerObject), //tp_basicsize
- 0, //tp_itemsize
- (destructor)Euler_dealloc, //tp_dealloc
- 0, //tp_print
- (getattrfunc)Euler_getattr, //tp_getattr
- (setattrfunc) Euler_setattr, //tp_setattr
- 0, //tp_compare
- (reprfunc) Euler_repr, //tp_repr
- 0, //tp_as_number
- &Euler_SeqMethods, //tp_as_sequence
- 0, //tp_as_mapping
- 0, //tp_hash
- 0, //tp_call
- 0, //tp_str
- 0, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
- EulerObject_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- (richcmpfunc)Euler_richcmpr, //tp_richcompare
- 0, //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- 0, //tp_methods
- 0, //tp_members
- 0, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- 0, //tp_init
- 0, //tp_alloc
- 0, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-//------------------------newEulerObject (internal)-------------
-//creates a new euler object
-/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
- (i.e. it was allocated elsewhere by MEM_mallocN())
- pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
- (i.e. it must be created here with PyMEM_malloc())*/
-PyObject *newEulerObject(float *eul, int type)
-{
- EulerObject *self;
- int x;
-
- self = PyObject_NEW(EulerObject, &euler_Type);
- self->data.blend_data = NULL;
- self->data.py_data = NULL;
-
- if(type == Py_WRAP){
- self->data.blend_data = eul;
- self->eul = self->data.blend_data;
- self->wrapped = Py_WRAP;
- }else if (type == Py_NEW){
- self->data.py_data = PyMem_Malloc(3 * sizeof(float));
- self->eul = self->data.py_data;
- if(!eul) { //new empty
- for(x = 0; x < 3; x++) {
- self->eul[x] = 0.0f;
- }
- }else{
- for(x = 0; x < 3; x++){
- self->eul[x] = eul[x];
- }
- }
- self->wrapped = Py_NEW;
- }else{ //bad type
- return NULL;
- }
- return (PyObject *) self;
-}
-
diff --git a/source/blender/python/api2_2x/euler.h b/source/blender/python/api2_2x/euler.h
deleted file mode 100644
index d992d61b402..00000000000
--- a/source/blender/python/api2_2x/euler.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * $Id: euler.h 8367 2006-08-22 09:13:44Z 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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- *
- */
-
-#ifndef EXPP_euler_h
-#define EXPP_euler_h
-
-#include <Python.h>
-
-extern PyTypeObject euler_Type;
-
-#define EulerObject_Check(v) ((v)->ob_type == &euler_Type)
-
-typedef struct {
- PyObject_VAR_HEAD
- struct{
- float *py_data; //python managed
- float *blend_data; //blender managed
- }data;
- float *eul; //1D array of data (alias)
- int wrapped; //is wrapped data?
-} EulerObject;
-
-/*struct data contains a pointer to the actual data that the
-object uses. It can use either PyMem allocated data (which will
-be stored in py_data) or be a wrapper for data allocated through
-blender (stored in blend_data). This is an either/or struct not both*/
-
-//prototypes
-PyObject *Euler_Zero( EulerObject * self );
-PyObject *Euler_Unique( EulerObject * self );
-PyObject *Euler_ToMatrix( EulerObject * self );
-PyObject *Euler_ToQuat( EulerObject * self );
-PyObject *Euler_Rotate( EulerObject * self, PyObject *args );
-PyObject *Euler_copy( EulerObject * self, PyObject *args );
-PyObject *newEulerObject( float *eul, int type );
-
-#endif /* EXPP_euler_h */
diff --git a/source/blender/python/api2_2x/gen_library.c b/source/blender/python/api2_2x/gen_library.c
deleted file mode 100644
index 8673fefdbb5..00000000000
--- a/source/blender/python/api2_2x/gen_library.c
+++ /dev/null
@@ -1,332 +0,0 @@
-#include "gen_library.h"
-#include "gen_utils.h" /*This must come first*/
-
-/* use for GenericLib_getProperties */
-#include "BKE_idprop.h"
-#include "IDProp.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_library.h"
-#include "BKE_curve.h"
-
-/* GenericLib */
-#include "World.h"
-#include "Font.h"
-#include "Metaball.h"
-#include "Curve.h"
-#include "Camera.h"
-#include "NLA.h"
-#include "Lattice.h"
-#include "Armature.h"
-#include "Lamp.h"
-#include "Text.h"
-#include "Text3d.h"
-#include "Sound.h"
-#include "Scene.h"
-#include "Mesh.h"
-#include "Group.h"
-#include "Object.h"
-#include "Texture.h"
-#include "Ipo.h"
-#include "DNA_object_types.h"
-#include "DNA_ipo_types.h"
-
-
-/* Generic get/set attrs */
-PyObject *GenericLib_getName( void *self )
-{
- ID *id = ((BPy_GenericLib *)self)->id;
- if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
- return PyString_FromString( id->name + 2 );
-}
-
-int GenericLib_setName( void *self, PyObject *value )
-{
- ID *id = ((BPy_GenericLib *)self)->id;
- char *name = NULL;
- if (!id) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "data has been removed" ) );
-
- name = PyString_AsString ( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string argument" );
-
- rename_id( id, name );
-
- return 0;
-}
-
-PyObject *GenericLib_getFakeUser( void *self )
-{
- ID *id = ((BPy_GenericLib *)self)->id;
- if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
- if (id->flag & LIB_FAKEUSER)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-int GenericLib_setFakeUser( void *self, PyObject *value )
-{
- int param;
- ID *id = ((BPy_GenericLib *)self)->id;
- if (!id) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "data has been removed" ) );
-
- param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if (param) {
- if (!(id->flag & LIB_FAKEUSER)) {
- id->flag |= LIB_FAKEUSER;
- id_us_plus(id);
- }
- } else {
- if (id->flag & LIB_FAKEUSER) {
- id->flag &= ~LIB_FAKEUSER;
- id->us--;
- }
- }
- return 0;
-}
-
-PyObject *GenericLib_getTag( void *self )
-{
- ID *id = ((BPy_GenericLib *)self)->id;
- if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
- if (id->flag & LIB_DOIT)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-int GenericLib_setTag( void *self, PyObject *value )
-{
- int param;
- ID *id = ((BPy_GenericLib *)self)->id;
- if (!id) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "data has been removed" ) );
-
- param = PyObject_IsTrue( value );
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument in range [0,1]" );
-
- if (param)
- id->flag |= LIB_DOIT;
- else
- id->flag &= ~LIB_DOIT;
- return 0;
-}
-
-
-/* read only */
-PyObject *GenericLib_getLib( void *self )
-{
- ID *id = ((BPy_GenericLib *)self)->id;
- if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
-
- if (id->lib)
- return PyString_FromString(id->lib->name);
- else
- return EXPP_incr_ret( Py_None );
-}
-
-PyObject *GenericLib_getUsers( void *self )
-{
- ID *id = ((BPy_GenericLib *)self)->id;
- if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
- return PyInt_FromLong(id->us);
-}
-
-PyObject *GenericLib_getProperties( void *self )
-{
- ID *id = ((BPy_GenericLib *)self)->id;
- if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
- return BPy_Wrap_IDProperty( id, IDP_GetProperties(id, 1), NULL );
-}
-
-/* use for any.setName("name")*/
-PyObject * GenericLib_setName_with_method( void *self, PyObject *args )
-{
- return EXPP_setterWrapper( (void *)self, args, (setter)GenericLib_setName );
-}
-
-
-/*
- * returns the Blender lib type code from a PyObject
- * -1 for no match, only give this function libdata
- *
- * At the moment this is only used by GenericLib_assignData
- * so not all types are needed.
- */
-short GenericLib_getType(PyObject * pydata)
-{
- //~ if (BPy_Scene_Check(pydata)) return ID_SCE;
- if (BPy_Object_Check(pydata)) return ID_OB;
- if (BPy_Mesh_Check(pydata)) return ID_ME;
- //~ if (BPy_Curve_Check(pydata)) return ID_CU;
- //~ if (BPy_Metaball_Check(pydata)) return ID_MB;
- //~ if (BPy_Material_Check(pydata)) return ID_MA;
- if (BPy_Texture_Check(pydata)) return ID_TE;
- //~ if (BPy_Image_Check(pydata)) return ID_IM;
- //~ //if (BPy_Lattice_Check(pydata)) return ID_LT;
- //~ if (BPy_Lamp_Check(pydata)) return ID_LA;
- //~ if (BPy_Camera_Check(pydata)) return ID_CA;
- if (BPy_Ipo_Check(pydata)) return ID_IP;
- if (BPy_World_Check(pydata)) return ID_WO;
- //~ //if (BPy_Font_Check(pydata)) return ID_VF;
- //~ if (BPy_Text_Check(pydata)) return ID_TXT;
- //~ if (BPy_Sound_Check(pydata)) return ID_SO;
- if (BPy_Group_Check(pydata)) return ID_GR;
- //~ if (BPy_Armature_Check(pydata)) return ID_AR;
- if (BPy_Action_Check(pydata)) return ID_AC;
-
- return -1;
-}
-
-
-/*
- * This function is used to assign a PyObject representing
- * blender libdata to a pointer.
- *
- * Python examples of this are...
- * ob.DupGroup = dupliGroup
- * mesh.texMesh = texme
- * ob.ipo = None
- *
- * This function deals with type checking, data usercounts,
- * and raising errors.
- *
- * value - python value
- * data - Blender pointer to assign value to
- * ndata - Use this if there is a value data cannot be.
- * for instance, a curve's curve modifier cant point to its self.
- * refcount - non zero values will modify blenders user count.
- * type - ID type.
- * subtype - used only for objects and IPO's to stop the wrong types of obs/ipos
- * being assigned.
- *
- */
-int GenericLib_assignData(PyObject *value, void **data, void **ndata, short refcount, short type, short subtype)
-{
- ID *id= NULL;
-
- if (*data) {
- id = ((ID*)*data);
-
- if (ndata && *data == *ndata) {
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Cannot set this data to its self" );
- }
- }
-
- if (value == Py_None) {
- *data = NULL;
- if (refcount && id) id->us--;
- } else if (GenericLib_getType(value) == type) {
-
- /* object subtypes */
- if (subtype != 0) {
- if (type == ID_OB) {
- Object *ob= (Object *)(((BPy_GenericLib *)value)->id);
- if (ob->type != subtype)
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Object type not supported" );
- }
-
- if (type == ID_IP) {
- Ipo *ipo = (Ipo *)(((BPy_GenericLib *)value)->id);
- if (ipo->blocktype != subtype)
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Ipo type does is not compatible" );
- }
-
-
- }
- if (refcount && id) id->us--;
- id = ((BPy_GenericLib *)value)->id;
- id->us++;
- *data = id;
- } else {
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Could not assign Python Type - None or Library Object" );
- }
- return 0;
-}
-
-
-/*
- * returns the ID of the object with given name
- * from a given list.
- */
-ID *GetIdFromList( ListBase * list, char *name )
-{
- ID *id = list->first;
-
- while( id ) {
- if( strcmp( name, id->name + 2 ) == 0 )
- break;
- id = id->next;
- }
-
- return id;
-}
-
-
-PyObject *GetPyObjectFromID( ID * id )
-{
- switch ( MAKE_ID2( id->name[0], id->name[1] ) ) {
- case ID_SCE:
- return Scene_CreatePyObject( ( Scene *) id );
- case ID_OB:
- return Object_CreatePyObject( (Object *) id );
- case ID_ME:
- return Mesh_CreatePyObject( (Mesh *)id, NULL );
- case ID_CU:
- switch (curve_type((Curve *)id)) {
- case OB_FONT:
- return Text3d_CreatePyObject( (Text3d *)id );
- default:
- return Curve_CreatePyObject( (Curve *)id );
- }
- case ID_MB:
- return Metaball_CreatePyObject((MetaBall *)id);
- case ID_MA:
- return Material_CreatePyObject((Material *)id);
- case ID_TE:
- return Texture_CreatePyObject((Tex *)id);
- case ID_IM:
- return Image_CreatePyObject((Image *)id);
- case ID_LT:
- return Lattice_CreatePyObject((Lattice *)id);
- case ID_LA:
- return Lamp_CreatePyObject((Lamp *)id);
- case ID_CA:
- return Camera_CreatePyObject((Camera *)id);
- case ID_IP:
- return Ipo_CreatePyObject((Ipo *)id);
- case ID_WO:
- return World_CreatePyObject((World *)id);
- case ID_VF:
- return Font_CreatePyObject((VFont *)id);
- case ID_TXT:
- return Text_CreatePyObject((Text *)id);
- case ID_SO:
- return Sound_CreatePyObject((bSound *)id);
- case ID_GR:
- return Group_CreatePyObject((Group *)id);
- case ID_AR:
- return Armature_CreatePyObject((bArmature *)id);
- case ID_AC:
- return Action_CreatePyObject((bAction *)id);
- }
- Py_RETURN_NONE;
-}
-
-long GenericLib_hash(BPy_GenericLib * pydata)
-{
- return (long)pydata->id;
-}
-
diff --git a/source/blender/python/api2_2x/gen_library.h b/source/blender/python/api2_2x/gen_library.h
deleted file mode 100644
index ea182ad1a29..00000000000
--- a/source/blender/python/api2_2x/gen_library.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * $Id: gen_library.h 11877 2007-08-29 03:09:22Z 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, Willian P. Germano, Alex Mole, Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#ifndef EXPP_gen_library_h
-#define EXPP_gen_library_h
-
-#include <Python.h>
-
-#include "DNA_ID.h"
-#include "DNA_listBase.h"
-
-/* ID functions for all libdata */
-#define GENERIC_LIB_GETSETATTR \
- {"name",\
- (getter)GenericLib_getName, (setter)GenericLib_setName,\
- "name",\
- NULL},\
- {"lib",\
- (getter)GenericLib_getLib, (setter)NULL,\
- "external library path",\
- NULL},\
- {"users",\
- (getter)GenericLib_getUsers, (setter)NULL,\
- "user count",\
- NULL},\
- {"fakeUser",\
- (getter)GenericLib_getFakeUser, (setter)GenericLib_setFakeUser,\
- "fake user state",\
- NULL},\
- {"properties",\
- (getter)GenericLib_getProperties, (setter)NULL,\
- "properties",\
- NULL},\
- {"tag",\
- (getter)GenericLib_getTag, (setter)GenericLib_setTag,\
- "temproary tag",\
- NULL}
-
-/* Dummy struct for getting the ID from a libdata BPyObject */
-typedef struct {
- PyObject_HEAD /* required python macro */
- ID *id;
-} BPy_GenericLib;
-
-int GenericLib_setName( void *self, PyObject *value );
-PyObject *GenericLib_getName( void *self );
-PyObject *GenericLib_getFakeUser( void *self );
-int GenericLib_setFakeUser( void *self, PyObject *value );
-PyObject *GenericLib_getTag( void *self );
-int GenericLib_setTag( void *self, PyObject *value );
-PyObject *GenericLib_getLib( void *self );
-PyObject *GenericLib_getUsers( void *self );
-PyObject *GenericLib_getProperties( void *self );
-
-/* use this for oldstyle somedata.getName("name") */
-PyObject * GenericLib_setName_with_method( void *self, PyObject *value );
-
-int GenericLib_assignData(PyObject *value, void **data, void **ndata, short refcount, short type, short subtype);
-short GenericLib_getType(PyObject * pydata);
-
-/* Other ID functions */
-ID *GetIdFromList( ListBase * list, char *name );
-PyObject *GetPyObjectFromID( ID * id );
-long GenericLib_hash(BPy_GenericLib * pydata);
-#endif /* EXPP_gen_library_h */
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
deleted file mode 100644
index f05be1ba68b..00000000000
--- a/source/blender/python/api2_2x/gen_utils.c
+++ /dev/null
@@ -1,948 +0,0 @@
-/*
- * $Id: gen_utils.c 11932 2007-09-03 17: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): Michel Selten, Willian P. Germano, Alex Mole, Ken Hughes,
- * Campbell Barton
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include "gen_utils.h" /*This must come first*/
-
-#include "DNA_text_types.h"
-#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
-#include "BIF_space.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_library.h"
-
-#include "Mathutils.h"
-
-#include "constant.h"
-
-/*---------------------- EXPP_FloatsAreEqual -------------------------
- Floating point comparisons
- floatStep = number of representable floats allowable in between
- float A and float B to be considered equal. */
-int EXPP_FloatsAreEqual(float A, float B, int floatSteps)
-{
- int a, b, delta;
- assert(floatSteps > 0 && floatSteps < (4 * 1024 * 1024));
- a = *(int*)&A;
- if (a < 0)
- a = 0x80000000 - a;
- b = *(int*)&B;
- if (b < 0)
- b = 0x80000000 - b;
- delta = abs(a - b);
- if (delta <= floatSteps)
- return 1;
- return 0;
-}
-/*---------------------- EXPP_VectorsAreEqual -------------------------
- Builds on EXPP_FloatsAreEqual to test vectors */
-int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps){
-
- int x;
- for (x=0; x< size; x++){
- if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0)
- return 0;
- }
- return 1;
-}
-/*---------------------- EXPP_GetModuleConstant -------------------------
- Helper function for returning a module constant */
-PyObject *EXPP_GetModuleConstant(char *module, char *constant)
-{
- PyObject *py_module = NULL, *py_dict = NULL, *py_constant = NULL;
-
- /*Careful to pass the correct Package.Module string here or
- * else you add a empty module somewhere*/
- py_module = PyImport_AddModule(module);
- if(!py_module){ /*null = error returning module*/
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "error encountered with returning module constant..." ) );
- }
- py_dict = PyModule_GetDict(py_module); /*never fails*/
-
- py_constant = PyDict_GetItemString(py_dict, constant);
- if(!py_constant){ /*null = key not found*/
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "error encountered with returning module constant..." ) );
- }
-
- return EXPP_incr_ret(py_constant);
-}
-
-/*****************************************************************************/
-/* Description: This function clamps an int to the given interval */
-/* [min, max]. */
-/*****************************************************************************/
-int EXPP_ClampInt( int value, int min, int max )
-{
- if( value < min )
- return min;
- else if( value > max )
- return max;
- return value;
-}
-
-/*****************************************************************************/
-/* Description: This function clamps a float to the given interval */
-/* [min, max]. */
-/*****************************************************************************/
-float EXPP_ClampFloat( float value, float min, float max )
-{
- if( value < min )
- return min;
- else if( value > max )
- return max;
- return value;
-}
-
-/*****************************************************************************/
-/* Description: This function returns true if both given strings are equal, */
-/* otherwise it returns false. */
-/*****************************************************************************/
-int StringEqual( const char *string1, const char *string2 )
-{
- return ( strcmp( string1, string2 ) == 0 );
-}
-
-
-/*****************************************************************************/
-/* Description: These functions set an internal string with the given type */
-/* and error_msg arguments. */
-/*****************************************************************************/
-
-PyObject *EXPP_ReturnPyObjError( PyObject * type, char *error_msg )
-{ /* same as above, just to change its name smoothly */
- PyErr_SetString( type, error_msg );
- return NULL;
-}
-
-int EXPP_ReturnIntError( PyObject * type, char *error_msg )
-{
- PyErr_SetString( type, error_msg );
- return -1;
-}
-
-int EXPP_intError(PyObject *type, const char *format, ...)
-{
- PyObject *error;
- va_list vlist;
-
- va_start(vlist, format);
- error = PyString_FromFormatV(format, vlist);
- va_end(vlist);
-
- PyErr_SetObject(type, error);
- Py_DECREF(error);
- return -1;
-}
-/*Like EXPP_ReturnPyObjError but takes a printf format string and multiple arguments*/
-PyObject *EXPP_objError(PyObject *type, const char *format, ...)
-{
- PyObject *error;
- va_list vlist;
-
- va_start(vlist, format);
- error = PyString_FromFormatV(format, vlist);
- va_end(vlist);
-
- PyErr_SetObject(type, error);
- Py_DECREF(error);
- return NULL;
-}
-
-/*****************************************************************************/
-/* Description: This function increments the reference count of the given */
-/* Python object (usually Py_None) and returns it. */
-/*****************************************************************************/
-
-PyObject *EXPP_incr_ret( PyObject * object )
-{
- Py_INCREF( object );
- return ( object );
-}
-
-/* return Py_False - to avoid warnings, we use the fact that
- * 0 == False in Python: */
-PyObject *EXPP_incr_ret_False()
-{
- return Py_BuildValue("i", 0);
-}
-
-/* return Py_True - to avoid warnings, we use the fact that
- * 1 == True in Python: */
-PyObject *EXPP_incr_ret_True()
-{
- return Py_BuildValue("i", 1);
-}
-
-void EXPP_incr2( PyObject * ob1, PyObject * ob2 )
-{
- Py_INCREF( ob1 );
- Py_INCREF( ob2 );
-}
-
-void EXPP_incr3( PyObject * ob1, PyObject * ob2, PyObject * ob3 )
-{
- Py_INCREF( ob1 );
- Py_INCREF( ob2 );
- Py_INCREF( ob3 );
-}
-
-void EXPP_decr2( PyObject * ob1, PyObject * ob2 )
-{
- Py_DECREF( ob1 );
- Py_DECREF( ob2 );
-}
-
-void EXPP_decr3( PyObject * ob1, PyObject * ob2, PyObject * ob3 )
-{
- Py_DECREF( ob1 );
- Py_DECREF( ob2 );
- Py_DECREF( ob3 );
-}
-/*****************************************************************************/
-/* Description: This function maps the event identifier to a string. */
-/*****************************************************************************/
-char *event_to_name( short event )
-{
- switch ( event ) {
- case SCRIPT_FRAMECHANGED:
- return "FrameChanged";
- case SCRIPT_ONLOAD:
- return "OnLoad";
- case SCRIPT_ONSAVE:
- return "OnSave";
- case SCRIPT_REDRAW:
- return "Redraw";
- case SCRIPT_RENDER:
- return "Render";
- case SCRIPT_POSTRENDER:
- return "PostRender";
- default:
- return "Unknown";
- }
-}
-
-/*****************************************************************************/
-/* Description: Checks whether all objects in a PySequence are of a same */
-/* given type. Returns 0 if not, 1 on success. */
-/*****************************************************************************/
-int EXPP_check_sequence_consistency( PyObject * seq, PyTypeObject * against )
-{
- PyObject *ob;
- int len = PySequence_Length( seq );
- int i, result = 1;
-
- for( i = 0; i < len; i++ ) {
- ob = PySequence_GetItem( seq, i );
- if( ob == Py_None )
- result = 2;
- else if( ob->ob_type != against ) {
- Py_DECREF( ob );
- return 0;
- }
- Py_DECREF( ob );
- }
- return result; /* 1 if all of 'against' type, 2 if there are (also) Nones */
-}
-
-PyObject *EXPP_tuple_repr( PyObject * self, int size )
-{
- PyObject *repr, *item;
- int i;
-
-/*@ note: a value must be built because the list is decrefed!
- * otherwise we have nirvana pointers inside python.. */
-
- repr = PyString_FromString( "" );
- if( !repr )
- return 0;
-
- item = PySequence_GetItem( self, 0 );
- PyString_ConcatAndDel( &repr, PyObject_Repr( item ) );
- Py_DECREF( item );
-
- for( i = 1; i < size; i++ ) {
- item = PySequence_GetItem( self, i );
- PyString_ConcatAndDel( &repr, PyObject_Repr( item ) );
- Py_DECREF( item );
- }
-
- return repr;
-}
-
-/****************************************************************************/
-/* Description: searches through a map for a pair with a given name. If the */
-/* pair is present, its ival is stored in *ival and nonzero is */
-/* returned. If the pair is absent, zero is returned. */
-/****************************************************************************/
-int EXPP_map_getIntVal( const EXPP_map_pair * map, const char *sval,
- int *ival )
-{
- while( map->sval ) {
- if( StringEqual( sval, map->sval ) ) {
- *ival = map->ival;
- return 1;
- }
- ++map;
- }
- return 0;
-}
-
-/* same as above, but string case is ignored */
-int EXPP_map_case_getIntVal( const EXPP_map_pair * map, const char *sval,
- int *ival )
-{
- while( map->sval ) {
- if( !BLI_strcasecmp( sval, map->sval ) ) {
- *ival = map->ival;
- return 1;
- }
- ++map;
- }
- return 0;
-}
-
-/****************************************************************************/
-/* Description: searches through a map for a pair with a given name. If the */
-/* pair is present, its ival is stored in *ival and nonzero is */
-/* returned. If the pair is absent, zero is returned. */
-/* note: this function is identical to EXPP_map_getIntVal except that the */
-/* output is stored in a short value. */
-/****************************************************************************/
-int EXPP_map_getShortVal( const EXPP_map_pair * map,
- const char *sval, short *ival )
-{
- while( map->sval ) {
- if( StringEqual( sval, map->sval ) ) {
- *ival = (short)map->ival;
- return 1;
- }
- ++map;
- }
- return 0;
-}
-
-/****************************************************************************/
-/* Description: searches through a map for a pair with a given ival. If the */
-/* pair is present, a pointer to its name is stored in *sval */
-/* and nonzero is returned. If the pair is absent, zero is */
-/* returned. */
-/****************************************************************************/
-int EXPP_map_getStrVal( const EXPP_map_pair * map, int ival,
- const char **sval )
-{
- while( map->sval ) {
- if( ival == map->ival ) {
- *sval = map->sval;
- return 1;
- }
- ++map;
- }
- return 0;
-}
-
-/* Redraw wrappers */
-
-/* this queues redraws if we're not in background mode: */
-void EXPP_allqueue(unsigned short event, short val)
-{
- if (!G.background) allqueue(event, val);
-}
-
-/************************************************************************/
-/* Scriptlink-related functions, used by scene, object, etc. bpyobjects */
-/************************************************************************/
-PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * value,
- int is_scene )
-{
- PyObject *list = NULL, *tmpstr;
- char *eventname = PyString_AsString(value);
- int i, event = 0;
-
-
- if( !eventname )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected event name (string) as argument" );
-
- list = PyList_New( 0 );
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList!" );
-
- /* actually !scriptlink shouldn't happen ... */
- if( !slink || !slink->totscript )
- return list;
-
- if( !strcmp( eventname, "FrameChanged" ) )
- event = SCRIPT_FRAMECHANGED;
- else if( !strcmp( eventname, "Redraw" ) )
- event = SCRIPT_REDRAW;
- else if( !strcmp( eventname, "Render" ) )
- event = SCRIPT_RENDER;
- else if( is_scene && !strcmp( eventname, "OnLoad" ) )
- event = SCRIPT_ONLOAD;
- else if( is_scene && !strcmp( eventname, "OnSave" ) )
- event = SCRIPT_ONSAVE;
- else {
- Py_DECREF(list);
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "invalid event name" );
- }
-
- for( i = 0; i < slink->totscript; i++ ) {
- if( ( slink->flag[i] == event ) && slink->scripts[i] ) {
- tmpstr =PyString_FromString( slink->scripts[i]->name + 2 );
- PyList_Append( list, tmpstr );
- Py_DECREF(tmpstr);
- }
- }
-
- return list;
-}
-
-PyObject *EXPP_clearScriptLinks( ScriptLink * slink, PyObject * args )
-{
- int i, j, totLinks, deleted = 0;
- PyObject *seq = NULL;
- ID **stmp = NULL;
- short *ftmp = NULL;
-
- /* check for an optional list of strings */
- if( !PyArg_ParseTuple( args, "|O", &seq ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected no arguments or a list of strings" ) );
-
-
- /* if there was a parameter, handle it */
- if ( seq != NULL ) {
- /* check that parameter IS list of strings */
- if ( !PyList_Check ( seq ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected a list of strings" ) );
-
- totLinks = PyList_Size ( seq );
- for ( i = 0 ; i < totLinks ; ++i ) {
- if ( !PyString_Check ( PySequence_GetItem( seq, i ) ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected list to contain strings" ) );
- }
-
- /*
- parameters OK: now look for each script, and delete
- its link as we find it (this handles multiple links)
- */
- for ( i = 0 ; i < totLinks ; ++i )
- {
- char *str;
- str = PyString_AsString ( PySequence_GetItem( seq, i ) );
- for ( j = 0 ; j < slink->totscript ; ++j ) {
- if ( slink->scripts[j] && !strcmp( slink->scripts[j]->name+2, str ) )
- slink->scripts[j] = NULL;
- if( !slink->scripts[j] )
- ++deleted;
- }
- }
- }
- /* if no parameter, then delete all scripts */
- else {
- deleted = slink->totscript;
- }
-
- /*
- if not all scripts deleted, create new lists and copy remaining
- links to them
- */
-
- if ( slink->totscript > deleted ) {
- slink->totscript = slink->totscript - (short)deleted;
-
- stmp = slink->scripts;
- slink->scripts =
- MEM_mallocN( sizeof( ID * ) * ( slink->totscript ),
- "bpySlinkL" );
-
- ftmp = slink->flag;
- slink->flag =
- MEM_mallocN( sizeof( short * ) * ( slink->totscript ),
- "bpySlinkF" );
-
- for ( i = 0, j = 0 ; i < slink->totscript ; ++j ) {
- if ( stmp[j] != NULL ) {
- memcpy( slink->scripts+i, stmp+j, sizeof( ID * ) );
- memcpy( slink->flag+i, ftmp+j, sizeof( short ) );
- ++i;
- }
- }
- MEM_freeN( stmp );
- MEM_freeN( ftmp );
-
- /*EXPP_allqueue (REDRAWBUTSSCRIPT, 0 );*/
- slink->actscript = 1;
- } else {
-
- /* all scripts deleted, so delete entire list and free memory */
-
- if( slink->scripts )
- MEM_freeN( slink->scripts );
- if( slink->flag )
- MEM_freeN( slink->flag );
-
- slink->scripts = NULL;
- slink->flag = NULL;
- slink->totscript = slink->actscript = 0;
- }
-
- return EXPP_incr_ret( Py_None );
-}
-
-
-PyObject *EXPP_addScriptLink(ScriptLink *slink, PyObject *args, int is_scene)
-{
- int event = 0, found_txt = 0;
- void *stmp = NULL, *ftmp = NULL;
- Text *bltxt = G.main->text.first;
- char *textname = NULL;
- char *eventname = NULL;
-
- /* !scriptlink shouldn't happen ... */
- if( !slink ) {
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "internal error: no scriptlink!" );
- }
-
- if( !PyArg_ParseTuple( args, "ss", &textname, &eventname ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected two strings as arguments" );
-
- while( bltxt ) {
- if( !strcmp( bltxt->id.name + 2, textname ) ) {
- found_txt = 1;
- break;
- }
- bltxt = bltxt->id.next;
- }
-
- if( !found_txt )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "no such Blender Text" );
-
- if( !strcmp( eventname, "FrameChanged" ) )
- event = SCRIPT_FRAMECHANGED;
- else if( !strcmp( eventname, "Redraw" ) )
- event = SCRIPT_REDRAW;
- else if( !strcmp( eventname, "Render" ) )
- event = SCRIPT_RENDER;
- else if( is_scene && !strcmp( eventname, "OnLoad" ) )
- event = SCRIPT_ONLOAD;
- else if( is_scene && !strcmp( eventname, "OnSave" ) )
- event = SCRIPT_ONSAVE;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "invalid event name" );
-
- stmp = slink->scripts;
- slink->scripts =
- MEM_mallocN( sizeof( ID * ) * ( slink->totscript + 1 ),
- "bpySlinkL" );
-
- ftmp = slink->flag;
- slink->flag =
- MEM_mallocN( sizeof( short * ) * ( slink->totscript + 1 ),
- "bpySlinkF" );
-
- if( slink->totscript ) {
- memcpy( slink->scripts, stmp,
- sizeof( ID * ) * ( slink->totscript ) );
- MEM_freeN( stmp );
-
- memcpy( slink->flag, ftmp,
- sizeof( short ) * ( slink->totscript ) );
- MEM_freeN( ftmp );
- }
-
- slink->scripts[slink->totscript] = ( ID * ) bltxt;
- slink->flag[slink->totscript] = (short)event;
-
- slink->totscript++;
-
- if( slink->actscript < 1 )
- slink->actscript = 1;
-
- return EXPP_incr_ret (Py_None); /* normal exit */
-}
-
-/*
- * Utility routines to clamp and store various datatypes. The object type
- * is checked and a exception is raised if it's not the correct type.
- *
- * Inputs:
- * value: PyObject containing the new value
- * param: pointer to destination variable
- * max, min: range of values for clamping
- * type: kind of pointer and data (uses the same characters as
- * PyArgs_ParseTuple() and Py_BuildValue()
- *
- * Return 0 on success, -1 on error.
- */
-
-int EXPP_setFloatClamped( PyObject *value, float *param,
- float min, float max )
-{
- if( !PyNumber_Check ( value ) ) {
- char errstr[128];
- sprintf ( errstr, "expected float argument in [%f,%f]", min, max );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
-
- *param = EXPP_ClampFloat( (float)PyFloat_AsDouble( value ), min, max );
-
- return 0;
-}
-
-int EXPP_setIValueClamped( PyObject *value, void *param,
- int min, int max, char type )
-{
- int number;
-
- if( !PyInt_Check( value ) ) {
- char errstr[128];
- sprintf ( errstr, "expected int argument in [%d,%d]", min, max );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
-
- number = PyInt_AS_LONG( value );
-
- switch ( type ) {
- case 'b':
- *(char *)param = (char)EXPP_ClampInt( number, min, max );
- return 0;
- case 'h':
- *(short *)param = (short)EXPP_ClampInt( number, min, max );
- return 0;
- case 'H':
- *(unsigned short *)param = (unsigned short)EXPP_ClampInt( number, min, max );
- return 0;
- case 'i':
- *(int *)param = EXPP_ClampInt( number, min, max );
- return 0;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "EXPP_setIValueClamped(): invalid type code" );
- }
-}
-
-int EXPP_setVec3Clamped( PyObject *value, float *param,
- float min, float max )
-{
- if( VectorObject_Check( value ) ) {
- VectorObject *vect = (VectorObject *)value;
- if( vect->size == 3 ) {
- param[0] = EXPP_ClampFloat( vect->vec[0], min, max );
- param[1] = EXPP_ClampFloat( vect->vec[1], min, max );
- param[2] = EXPP_ClampFloat( vect->vec[2], min, max );
- return 0;
- }
- }
-
- if (1) {
- char errstr[128];
- sprintf ( errstr, "expected vector argument in [%f,%f]", min, max );
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- }
-}
-
-
-/*
- * Utility routines to range-check and store various datatypes. The object
- * type is checked and a exception is raised if it's not the correct type.
- * An exception is also raised if the value lies outside of the specified
- * range.
- *
- * Inputs:
- * value: PyObject containing the new value
- * param: pointer to destination variable
- * max, min: valid range for value
- * type: kind of pointer and data (uses the same characters as
- * PyArgs_ParseTuple() and Py_BuildValue()
- *
- * Return 0 on success, -1 on error.
- */
-
-int EXPP_setFloatRange( PyObject *value, float *param,
- float min, float max )
-{
- char errstr[128];
- float number;
-
- sprintf ( errstr, "expected int argument in [%f,%f]", min, max );
-
- if( !PyNumber_Check ( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-
- number = (float)PyFloat_AsDouble( value );
- if ( number < min || number > max )
- return EXPP_ReturnIntError( PyExc_ValueError, errstr );
-
- *param = number;
- return 0;
-}
-
-int EXPP_setIValueRange( PyObject *value, void *param,
- int min, int max, char type )
-{
- char errstr[128];
- int number;
-
- sprintf ( errstr, "expected int argument in [%d,%d]", min, max );
-
- if( !PyInt_Check ( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-
- number = PyInt_AS_LONG( value );
- if( number < min || number > max )
- return EXPP_ReturnIntError( PyExc_ValueError, errstr );
-
- switch ( type ) {
- case 'b':
- *(char *)param = (char)number;
- return 0;
- case 'h':
- *(short *)param = (short)number;
- return 0;
- case 'H':
- *(unsigned short *)param = (unsigned short)number;
- return 0;
- case 'i':
- *(int *)param = number;
- return 0;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "EXPP_setIValueRange(): invalid type code" );
- }
-}
-
-/*
- * Utility routines to handle all attribute setters which use module
- * constants. Generic pointer to destination variable is used, and typecast
- * to the appropriate type based on the "type" specifier.
- *
- * Inputs:
- * constant: constant_Type value
- * param: pointer to destination variable
- * type: kind of pointer and data
- *
- * Return 0 on success, -1 on error.
- */
-
-int EXPP_setModuleConstant ( BPy_constant *constant, void *param, char type )
-{
- PyObject *item;
-
- if( constant->ob_type != &constant_Type )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected module constant" );
-
- item = PyDict_GetItemString( constant->dict, "value" );
- if( !item )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "module constant has no \"value\" key" );
-
- switch ( type ) {
- case 'h':
- *(short *)param = (short)PyInt_AS_LONG( item );
- return 0;
- case 'i':
- *(int *)param = PyInt_AS_LONG( item );
- return 0;
- case 'f':
- *(float *)param = (float)PyFloat_AS_DOUBLE( item );
- Py_DECREF(item); /* line above increfs */
- return 0;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "EXPP_setModuleConstant(): invalid type code" );
- }
-}
-
-/*
- * Utility routines to get/set bits in bitfields. Adapted from code in
- * sceneRender.c (thanks, ascotan!).
- *
- * Inputs:
- * param: pointer to source/destination variable
- * setting: the bit to get/set
- * type: pointer type ('h' == short, 'i' == integer)
- */
-
-PyObject *EXPP_getBitfield( void *param, int setting, char type )
-{
- switch ( type ) {
- case 'b':
- return (*(char *)param & setting)
- ? EXPP_incr_ret_True() : EXPP_incr_ret_False();
- case 'h':
- return (*(short *)param & setting)
- ? EXPP_incr_ret_True() : EXPP_incr_ret_False();
- case 'i':
- return (*(int *)param & setting)
- ? EXPP_incr_ret_True() : EXPP_incr_ret_False();
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "EXPP_getBit(): invalid type code" );
- }
-}
-
-int EXPP_setBitfield( PyObject * value, void *param, int setting, char type )
-{
- int param_bool = PyObject_IsTrue( value );
-
- if( param_bool == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- switch ( type ) {
- case 'b':
- if ( param_bool )
- *(char *)param |= setting;
- else
- *(char *)param &= ~setting;
- return 0;
- case 'h':
- if ( param_bool )
- *(short *)param |= setting;
- else
- *(short *)param &= ~setting;
- return 0;
- case 'i':
- if ( param_bool )
- *(int *)param |= setting;
- else
- *(int *)param &= ~setting;
- return 0;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "EXPP_setBit(): invalid type code" );
- }
-}
-
-/*
- * Procedure to handle older setStuff() methods. Assumes that argument
- * is a tuple with one object, and so grabs the object and passes it to
- * the specified tp_getset setter for the corresponding attribute.
- */
-
-PyObject *EXPP_setterWrapper ( PyObject * self, PyObject * args,
- setter func)
-{
- int error;
-
- if ( !PyTuple_Check( args ) || PyTuple_Size( args ) != 1 )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "expected tuple of one item" );
-
- error = func ( self, PyTuple_GET_ITEM( args, 0 ), NULL );
- if ( !error ) {
- Py_INCREF( Py_None );
- return Py_None;
- } else
- return NULL;
-}
-
-/*
- * Procedure to handle older setStuff() methods. Assumes that argument
- * is a tuple, so just passes it to the specified tp_getset setter for
- * the corresponding attribute.
- */
-
-PyObject *EXPP_setterWrapperTuple ( PyObject * self, PyObject * args,
- setter func)
-{
- int error;
-
- if ( !PyTuple_Check( args ) )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "expected tuple" );
-
- error = func ( self, args, NULL );
- if ( !error ) {
- Py_INCREF( Py_None );
- return Py_None;
- } else
- return NULL;
-}
-
-/*
- * Helper to keep dictionaries from causing memory leaks. When some object
- * is just created to be added to the dictionary, its reference count needs
- * to be decremented so it can be reclaimed.
- */
-
-int EXPP_dict_set_item_str( PyObject *dict, char *key, PyObject *value)
-{
- /* add value to dictionary */
- int ret = PyDict_SetItemString(dict, key, value);
- Py_DECREF( value ); /* delete original */
- return ret;
-}
-
-/*
- * Helper function for subtypes that what the base types methods.
- * The command below needs to have args modified to have 'self' added at the start
- * ret = PyObject_Call(PyDict_GetItemString(PyList_Type.tp_dict, "sort"), newargs, keywds);
- *
- * This is not easy with the python API so adding a function here,
- * remember to Py_DECREF the tuple after
- */
-
-PyObject * EXPP_PyTuple_New_Prepend(PyObject *tuple, PyObject *value)
-{
- PyObject *item;
- PyObject *new_tuple;
- int i;
-
- i = PyTuple_Size(tuple);
- new_tuple = PyTuple_New(i+1);
- PyTuple_SetItem(new_tuple, 0, value);
- Py_INCREF(value);
- while (i) {
- i--;
- item = PyTuple_GetItem(tuple, i);
- PyTuple_SetItem(new_tuple, i+1, item);
- Py_INCREF(item);
- }
- return new_tuple;
-}
diff --git a/source/blender/python/api2_2x/gen_utils.h b/source/blender/python/api2_2x/gen_utils.h
deleted file mode 100644
index 3ff1517b86c..00000000000
--- a/source/blender/python/api2_2x/gen_utils.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * $Id: gen_utils.h 11732 2007-08-20 10:08:59Z 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, Willian P. Germano, Alex Mole, Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#ifndef EXPP_gen_utils_h
-#define EXPP_gen_utils_h
-
-#include <Python.h>
-#include "DNA_ID.h"
-#include "DNA_scriptlink_types.h"
-#include "DNA_listBase.h"
-
-#include "constant.h"
-
-#define Py_PI 3.14159265358979323846
-#define Py_WRAP 1024
-#define Py_NEW 2048
-
-/*
- Py_RETURN_NONE
- Python 2.4 macro.
- defined here until we switch to 2.4
-*/
-#ifndef Py_RETURN_NONE
-#define Py_RETURN_NONE return Py_BuildValue("O", Py_None)
-#endif
-#ifndef Py_RETURN_FALSE
-#define Py_RETURN_FALSE return PyBool_FromLong(0)
-#endif
-#ifndef Py_RETURN_TRUE
-#define Py_RETURN_TRUE return PyBool_FromLong(1)
-#endif
-
-/* Py 2.5 adds a new Py_ssize_t type for 64 bit support */
-/* #if'ed for your compiling pleasure */
-#if 1
-
-/* for pre Py 2.5 */
-#if PY_VERSION_HEX < 0x02050000
-typedef int Py_ssize_t;
-#define PY_SSIZE_T_MAX INT_MAX
-#define PY_SSIZE_T_MIN INT_MIN
-#else
-/* Py 2.5 and later */
-#define intargfunc ssizeargfunc
-#define intintargfunc ssizessizeargfunc
-#endif
-
-#endif
-
-/* name of list of Armature weak refs built into __main__ */
-#define ARM_WEAKREF_LIST_NAME "__arm_weakrefs"
-
-int EXPP_FloatsAreEqual(float A, float B, int floatSteps);
-int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps);
-
-PyObject *EXPP_GetModuleConstant(char *module, char *constant);
-
-int StringEqual( const char *string1, const char *string2 );
-
-PyObject *PythonReturnErrorObject( PyObject * type, char *error_msg );
-PyObject *PythonIncRef( PyObject * object );
-
-char *event_to_name( short event );
-
-float EXPP_ClampFloat( float value, float min, float max );
-int EXPP_ClampInt( int value, int min, int max );
-
-void EXPP_incr2( PyObject * ob1, PyObject * ob2 );
-void EXPP_incr3( PyObject * ob1, PyObject * ob2, PyObject * ob3 );
-void EXPP_decr2( PyObject * ob1, PyObject * ob2 );
-void EXPP_decr3( PyObject * ob1, PyObject * ob2, PyObject * ob3 );
-PyObject *EXPP_incr_ret( PyObject * object );
-PyObject *EXPP_incr_ret_True(void);
-PyObject *EXPP_incr_ret_False(void);
-PyObject *EXPP_ReturnPyObjError( PyObject * type, char *error_msg );
-int EXPP_ReturnIntError( PyObject * type, char *error_msg );
-
-PyObject *EXPP_objError(PyObject *type, const char *format, ...);
-int EXPP_intError(PyObject *type, const char *format, ...);
-
-int EXPP_check_sequence_consistency( PyObject * seq, PyTypeObject * against );
-PyObject *EXPP_tuple_repr( PyObject * self, int size );
-
-/* mapping utilities - see Texture.c for an example of how to use these */
-typedef struct {
- const char *sval;
- int ival;
-} EXPP_map_pair;
-
-/* maps must end with a pair that has NULL as sval */
-int EXPP_map_getIntVal( const EXPP_map_pair * map,
- const char *sval, int *ival );
-int EXPP_map_case_getIntVal( const EXPP_map_pair * map,
- const char *sval, int *ival );
-int EXPP_map_getShortVal( const EXPP_map_pair * map,
- const char *sval, short *ival );
-int EXPP_map_getStrVal( const EXPP_map_pair * map,
- int ival, const char **sval );
-
-/* clamping and range-checking utilities */
-
-int EXPP_setIValueClamped( PyObject *value, void *param,
- int min, int max, char type );
-int EXPP_setFloatClamped ( PyObject *value, float *param,
- float min, float max);
-int EXPP_setVec3Clamped ( PyObject *value, float *param,
- float min, float max);
-int EXPP_setIValueRange( PyObject *value, void *param,
- int min, int max, char type );
-int EXPP_setFloatRange ( PyObject *value, float *param,
- float min, float max);
-
-/* utility routine for PyType attributes setters with module constant */
-
-int EXPP_setModuleConstant ( BPy_constant *constant, void *param,
- char type );
-
-/* utilities to get/set bits in bitfields */
-
-PyObject *EXPP_getBitfield( void *param, int setting, char type );
-int EXPP_setBitfield( PyObject * value, void *param, int setting, char type );
-
-/*
- * Procedures to handle older setStuff() methods, which now access
- * a PyType's setter attributes using the tp_getset mechanism.
- */
-
-PyObject *EXPP_setterWrapper ( PyObject * self, PyObject * args,
- setter func);
-
-PyObject *EXPP_setterWrapperTuple ( PyObject * self, PyObject * args,
- setter func);
-
-/* scriplinks-related: */
-PyObject *EXPP_getScriptLinks(ScriptLink *slink, PyObject *value, int is_scene);
-PyObject *EXPP_addScriptLink(ScriptLink *slink, PyObject *args, int is_scene);
-PyObject *EXPP_clearScriptLinks(ScriptLink *slink, PyObject *args);
-
-/* this queues redraws if we're not in background mode: */
-void EXPP_allqueue(unsigned short event, short val);
-
-/* helper to keep dictionaries from causing memory leaks */
-int EXPP_dict_set_item_str( PyObject *dict, char *key, PyObject *value);
-PyObject * EXPP_PyTuple_New_Prepend(PyObject *tuple, PyObject *value);
-
-#endif /* EXPP_gen_utils_h */
-
diff --git a/source/blender/python/api2_2x/logic.c b/source/blender/python/api2_2x/logic.c
deleted file mode 100644
index 6e0813be8f3..00000000000
--- a/source/blender/python/api2_2x/logic.c
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * $Id: logic.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): Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include "logic.h" /*This must come first*/
-
-#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
-#include "gen_utils.h"
-
-//--------------- Python BPy_Property methods declarations:---------------
-static PyObject *Property_getName( BPy_Property * self );
-static PyObject *Property_setName( BPy_Property * self, PyObject * value );
-static PyObject *Property_getData( BPy_Property * self );
-static PyObject *Property_setData( BPy_Property * self, PyObject * args );
-static PyObject *Property_getType( BPy_Property * self );
-//--------------- Python BPy_Property methods table:----------------------
-static PyMethodDef BPy_Property_methods[] = {
- {"getName", ( PyCFunction ) Property_getName, METH_NOARGS,
- "() - return Property name"},
- {"setName", ( PyCFunction ) Property_setName, METH_O,
- "() - set the name of this Property"},
- {"getData", ( PyCFunction ) Property_getData, METH_NOARGS,
- "() - return Property data"},
- {"setData", ( PyCFunction ) Property_setData, METH_VARARGS,
- "() - set the data of this Property"},
- {"getType", ( PyCFunction ) Property_getType, METH_NOARGS,
- "() - return Property type"},
- {NULL, NULL, 0, NULL}
-};
-//--------------- Python TypeProperty callback function prototypes--------
-static void Property_dealloc( BPy_Property * Property );
-static PyObject *Property_getAttr( BPy_Property * Property, char *name );
-static int Property_setAttr( BPy_Property * Property, char *name,
- PyObject * v );
-static PyObject *Property_repr( BPy_Property * Property );
-static int Property_compare( BPy_Property * a1, BPy_Property * a2 );
-//--------------- Python TypeProperty structure definition----------------
-PyTypeObject property_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
- "Blender Property", /* tp_name */
- sizeof( BPy_Property ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- ( destructor ) Property_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) Property_getAttr, /* tp_getattr */
- ( setattrfunc ) Property_setAttr, /* tp_setattr */
- ( cmpfunc ) Property_compare, /* tp_compare */
- ( reprfunc ) Property_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0, 0, 0, 0, 0, 0,
- 0, /* tp_doc */
- 0, 0, 0, 0, 0, 0,
- BPy_Property_methods, /* tp_methods */
- 0, /* tp_members */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-//--------------- Property module internal callbacks-------------------
-
-//--------------- updatePyProperty-------------------------------------
-int updatePyProperty( BPy_Property * self )
-{
- if( !self->property ) {
- return 0; //nothing to update - not linked
- } else {
- BLI_strncpy( self->name, self->property->name, 32 );
- self->type = self->property->type;
- if( self->property->type == PROP_BOOL ) {
- if( *( ( int * ) &self->property->poin ) ) {
- self->data = EXPP_incr_ret_True();
- } else {
- self->data = EXPP_incr_ret_False();
- }
- } else if( self->property->type == PROP_INT ) {
- self->data = PyInt_FromLong( self->property->data );
- } else if( self->property->type == PROP_FLOAT ) {
- self->data =
- PyFloat_FromDouble( *
- ( ( float * ) &self->
- property->data ) );
- } else if( self->property->type == PROP_TIME ) {
- self->data =
- PyFloat_FromDouble( *
- ( ( float * ) &self->
- property->data ) );
- } else if( self->property->type == PROP_STRING ) {
- self->data =
- PyString_FromString( self->property->poin );
- }
- return 1;
- }
-}
-
-//--------------- updatePropertyData------------------------------------
-int updateProperyData( BPy_Property * self )
-{
- if( !self->property ) {
- //nothing to update - not linked
- return 0;
- } else {
- BLI_strncpy( self->property->name, self->name, 32 );
- self->property->type = self->type;
- if( PyInt_Check( self->data ) ) {
- *( ( int * ) &self->property->data ) =
- ( int ) PyInt_AsLong( self->data );
- } else if( PyFloat_Check( self->data ) ) {
- *( ( float * ) &self->property->data ) =
- ( float ) PyFloat_AsDouble( self->data );
- } else if( PyString_Check( self->data ) ) {
- BLI_strncpy( self->property->poin,
- PyString_AsString( self->data ),
- MAX_PROPSTRING );
- }
- return 1;
- }
-}
-
-//--------------- checkValidData_ptr--------------------------------
-static int checkValidData_ptr( BPy_Property * self )
-{
- int length;
- /* test pointer to see if data was removed (oops) */
- /* WARNING!!! - MEMORY LEAK HERE, why not free this??? */
- length = MEM_allocN_len( self->property );
- if( length != sizeof( bProperty ) ) { //data was freed
- self->property = NULL;
- return 0;
- } else { //it's ok as far as we can tell
- return 1;
- }
-}
-
-//---------------BPy_Property internal callbacks/methods------------
-
-//--------------- dealloc-------------------------------------------
-static void Property_dealloc( BPy_Property * self )
-{
- PyMem_Free( self->name );
- PyObject_DEL( self );
-}
-
-//---------------getattr--------------------------------------------
-static PyObject *Property_getAttr( BPy_Property * self, char *name )
-{
- checkValidData_ptr( self );
- if( strcmp( name, "name" ) == 0 )
- return Property_getName( self );
- else if( strcmp( name, "data" ) == 0 )
- return Property_getData( self );
- else if( strcmp( name, "type" ) == 0 )
- return Property_getType( self );
- else if( strcmp( name, "__members__" ) == 0 ) {
- return Py_BuildValue( "[s,s,s]", "name", "data", "type" );
- }
-
- return Py_FindMethod( BPy_Property_methods, ( PyObject * ) self, name );
-}
-
-//--------------- setattr-------------------------------------------
-static int
-Property_setAttr( BPy_Property * self, char *name, PyObject * value )
-{
- PyObject *error = NULL;
-
- checkValidData_ptr( self );
-
- if( strcmp( name, "name" ) == 0 ) {
- error = Property_setName( self, value );
- } else if( strcmp( name, "data" ) == 0 ) {
- PyObject *valtuple = Py_BuildValue( "(O)", value );
- if( !valtuple )
- return EXPP_ReturnIntError( PyExc_MemoryError,
- "PropertySetAttr: couldn't create tuple" );
-
- error = Property_setData( self, valtuple );
- Py_DECREF( valtuple );
- } else {
- return ( EXPP_ReturnIntError
- ( PyExc_KeyError, "attribute not found" ) );
- }
-
-
- if( error != Py_None )
- return -1;
-
- Py_DECREF( Py_None );
- return 0;
-}
-
-//--------------- repr----------------------------------------------
-static PyObject *Property_repr( BPy_Property * self )
-{
- checkValidData_ptr( self );
- if( self->property ) {
- return PyString_FromFormat( "[Property \"%s\"]",
- self->property->name );
- } else {
- return PyString_FromFormat( "[Property \"%s\"]", self->name );
- }
-}
-
-//--------------- compare-------------------------------------------
-//compares property.name and property.data
-static int Property_compare( BPy_Property * a, BPy_Property * b )
-{
- BPy_Property *py_propA, *py_propB;
- int retval = -1;
-
- checkValidData_ptr( a );
- checkValidData_ptr( b );
- //2 python objects
- if( !a->property && !b->property ) {
- if( a->type != b->type )
- retval = -1;
- if( BLI_streq( a->name, b->name ) ) {
- retval = PyObject_Compare( a->data, b->data );
- } else
- retval = -1;
- } else if( a->property && b->property ) { //2 real properties
- if( a->property->type != b->property->type )
- retval = -1;
- if( BLI_streq( a->property->name, b->property->name ) ) {
- if( a->property->type == PROP_BOOL
- || a->property->type == PROP_INT ) {
- if( a->property->data == b->property->data )
- retval = 0;
- else
- retval = -1;
- } else if( a->property->type == PROP_FLOAT
- || a->property->type == PROP_TIME ) {
- if( *( ( float * ) &a->property->data ) ==
- *( ( float * ) &b->property->data ) )
- retval = 0;
- else
- retval = -1;
- } else if( a->property->type == PROP_STRING ) {
- if( BLI_streq
- ( a->property->poin, b->property->poin ) )
- retval = 0;
- else
- retval = -1;
- }
- } else
- retval = -1;
- } else { //1 real 1 python
- if( !a->property ) {
- py_propA = a;
- py_propB = b;
- } else {
- py_propA = b;
- py_propB = a;
- }
- if( py_propB->property->type != py_propA->type )
- retval = -1;
- if( BLI_streq( py_propB->property->name, py_propA->name ) ) {
- if( py_propB->property->type == PROP_BOOL ||
- py_propB->property->type == PROP_INT ) {
- retval = PyObject_Compare( py_propA->data,
- PyInt_FromLong
- ( py_propB->
- property->
- data ) );
- } else if( py_propB->property->type == PROP_FLOAT
- || py_propB->property->type == PROP_TIME ) {
- retval = PyObject_Compare( py_propA->data,
- PyFloat_FromDouble
- ( *
- ( ( float * )
- &py_propB->
- property->
- data ) ) );
- } else if( py_propB->property->type == PROP_STRING ) {
- PyObject *tmpstr = PyString_FromString( py_propB->property->poin );
- retval = PyObject_Compare( py_propA->data, tmpstr );
- Py_DECREF(tmpstr);
- }
- } else
- retval = -1;
- }
- return retval;
-}
-
-//--------------- Property visible functions------------------------
-//--------------- Property_CreatePyObject---------------------------
-PyObject *Property_CreatePyObject( struct bProperty * Property )
-{
- BPy_Property *py_property;
-
- py_property =
- ( BPy_Property * ) PyObject_NEW( BPy_Property,
- &property_Type );
-
- //set the struct flag
- py_property->property = Property;
-
- //allocate space for python vars
- py_property->name = PyMem_Malloc( 32 );
-
- if( !updatePyProperty( py_property ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError, "Property struct empty" ) );
-
- return ( ( PyObject * ) py_property );
-}
-
-//--------------- Property_FromPyObject-----------------------------
-struct bProperty *Property_FromPyObject( PyObject * py_obj )
-{
- BPy_Property *py_property;
-
- py_property = ( BPy_Property * ) py_obj;
- if( !py_property->property )
- return NULL;
- else
- return ( py_property->property );
-}
-
-//--------------- newPropertyObject()-------------------------------
-PyObject *newPropertyObject( char *name, PyObject * data, int type )
-{
- BPy_Property *py_property;
-
- py_property =
- ( BPy_Property * ) PyObject_NEW( BPy_Property,
- &property_Type );
- py_property->name = PyMem_Malloc( 32 );
- py_property->property = NULL;
-
- BLI_strncpy( py_property->name, name, 32 );
- py_property->data = data;
- py_property->type = (short)type;
-
- return ( PyObject * ) py_property;
-}
-
-//--------------- Python BPy_Property methods-----------------------
-//--------------- BPy_Property.getName()----------------------------
-static PyObject *Property_getName( BPy_Property * self )
-{
- if( !self->property )
- return PyString_FromString( self->name );
- else
- return PyString_FromString( self->property->name );
-}
-
-//--------------- BPy_Property.setName()----------------------------
-static PyObject *Property_setName( BPy_Property * self, PyObject * value )
-{
- char *name = PyString_AsString(value);
-
- if( !name )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected string argument" ) );
-
- if( !self->property ) {
- BLI_strncpy( self->name, name, 32 );
- } else {
- BLI_strncpy( self->property->name, name, 32 );
- updatePyProperty( self );
- }
-
- Py_RETURN_NONE;
-}
-
-//--------------- BPy_Property.getData()----------------------------
-static PyObject *Property_getData( BPy_Property * self )
-{
- PyObject *attr = NULL;
-
- if( !self->property ) {
- attr = EXPP_incr_ret( self->data );
- } else {
- if( self->property->type == PROP_BOOL ) {
- if( self->property->data )
- attr = EXPP_incr_ret_True();
- else
- attr = EXPP_incr_ret_False();
- } else if( self->property->type == PROP_INT ) {
- attr = PyInt_FromLong( self->property->data );
- } else if( self->property->type == PROP_FLOAT ||
- self->property->type == PROP_TIME ) {
- attr = PyFloat_FromDouble( *
- ( ( float * ) &self->
- property->data ) );
- } else if( self->property->type == PROP_STRING ) {
- attr = PyString_FromString( self->property->poin );
- }
- }
- if( attr )
- return attr;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Property.data attribute" ) );
-}
-
-//--------------- BPy_Property.setData()----------------------------
-static PyObject *Property_setData( BPy_Property * self, PyObject * args )
-{
- PyObject *data;
- char *type_str = NULL;
- int type = -1;
- short *p_type = NULL;
-
- if( !PyArg_ParseTuple( args, "O|s", &data, &type_str ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected object and optional string argument" ) );
-
- if( !PyInt_Check( data ) && !PyFloat_Check( data )
- && !PyString_Check( data ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_RuntimeError,
- "float, int, or string expected as data" ) );
-
- //parse property name
- if( type_str ) {
- if( BLI_streq( type_str, "BOOL" ) )
- type = PROP_BOOL;
- else if( BLI_streq( type_str, "INT" ) )
- type = PROP_INT;
- else if( BLI_streq( type_str, "FLOAT" ) )
- type = PROP_FLOAT;
- else if( BLI_streq( type_str, "TIME" ) )
- type = PROP_TIME;
- else if( BLI_streq( type_str, "STRING" ) )
- type = PROP_STRING;
- else
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "BOOL, INT, FLOAT, TIME or STRING expected" ) );
- }
- //get pointer to type
- if( self->property )
- p_type = &self->property->type;
- else
- p_type = &self->type;
-
- //set the type
- if( PyInt_Check( data ) ) {
- if( type == -1 || type == PROP_INT )
- *p_type = PROP_INT;
- else
- *p_type = PROP_BOOL;
- } else if( PyFloat_Check( data ) ) {
- if( type == -1 || type == PROP_FLOAT )
- *p_type = PROP_FLOAT;
- else
- *p_type = PROP_TIME;
- } else if( PyString_Check( data ) ) {
- if( type == -1 || type == PROP_STRING )
- *p_type = PROP_STRING;
- } else {
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cant set unknown data type" ) );
- }
-
- //set the data
- if( self->property ) {
- if( PyInt_Check( data ) ) {
- *( ( int * ) &self->property->data ) =
- ( int ) PyInt_AsLong( data );
- } else if( PyFloat_Check( data ) ) {
- *( ( float * ) &self->property->data ) =
- ( float ) PyFloat_AsDouble( data );
- } else if( PyString_Check( data ) ) {
- BLI_strncpy( self->property->poin,
- PyString_AsString( data ),
- MAX_PROPSTRING );
- }
- updatePyProperty( self );
- } else {
- self->data = data;
- }
- Py_RETURN_NONE;
-}
-
-//--------------- BPy_Property.getType()----------------------------
-static PyObject *Property_getType( BPy_Property * self )
-{
- int type;
-
- if( self->property )
- type = self->property->type;
- else
- type = self->type;
-
- if( type == PROP_BOOL )
- return PyString_FromString( "BOOL" );
- else if( type == PROP_INT )
- return PyString_FromString( "INT" );
- else if( type == PROP_FLOAT )
- return PyString_FromString( "FLOAT" );
- else if( type == PROP_STRING )
- return PyString_FromString( "STRING" );
- else if( type == PROP_TIME )
- return PyString_FromString( "TIME" );
- Py_RETURN_NONE;
-}
diff --git a/source/blender/python/api2_2x/logic.h b/source/blender/python/api2_2x/logic.h
deleted file mode 100644
index ea415d06a0a..00000000000
--- a/source/blender/python/api2_2x/logic.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * $Id: logic.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_LOGIC_H
-#define EXPP_LOGIC_H
-
-#include <Python.h>
-#include "DNA_property_types.h"
-
-extern PyTypeObject property_Type;
-
-#define BPy_Property_Check(v) ((v)->ob_type == &property_Type)
-
-//--------------------------Python BPy_Property structure definition.----
-typedef struct {
- PyObject_HEAD
- //reference to property data if object linked
- bProperty * property;
- //list of vars that define the property
- char *name;
- PyObject *data;
- short type;
-} BPy_Property;
-
-//------------------------------visible prototypes-----------------------
-PyObject *Property_CreatePyObject( struct bProperty *prop );
-bProperty *Property_FromPyObject( PyObject * py_obj );
-PyObject *newPropertyObject( char *name, PyObject * data, int type );
-int updatePyProperty( BPy_Property * self );
-int updateProperyData( BPy_Property * self );
-
-#endif
diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c
deleted file mode 100644
index d52318e93bf..00000000000
--- a/source/blender/python/api2_2x/matrix.c
+++ /dev/null
@@ -1,975 +0,0 @@
-/*
- * $Id: matrix.c 11958 2007-09-07 07:55:36Z 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): Michel Selten & Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Mathutils.h"
-
-#include "BKE_utildefines.h"
-#include "BLI_arithb.h"
-#include "BLI_blenlib.h"
-#include "gen_utils.h"
-
-/*-------------------------DOC STRINGS ---------------------------*/
-char Matrix_Zero_doc[] = "() - set all values in the matrix to 0";
-char Matrix_Identity_doc[] = "() - set the square matrix to it's identity matrix";
-char Matrix_Transpose_doc[] = "() - set the matrix to it's transpose";
-char Matrix_Determinant_doc[] = "() - return the determinant of the matrix";
-char Matrix_Invert_doc[] = "() - set the matrix to it's inverse if an inverse is possible";
-char Matrix_TranslationPart_doc[] = "() - return a vector encompassing the translation of the matrix";
-char Matrix_RotationPart_doc[] = "() - return a vector encompassing the rotation of the matrix";
-char Matrix_scalePart_doc[] = "() - convert matrix to a 3D vector";
-char Matrix_Resize4x4_doc[] = "() - resize the matrix to a 4x4 square matrix";
-char Matrix_toEuler_doc[] = "() - convert matrix to a euler angle rotation";
-char Matrix_toQuat_doc[] = "() - convert matrix to a quaternion rotation";
-char Matrix_copy_doc[] = "() - return a copy of the matrix";
-/*-----------------------METHOD DEFINITIONS ----------------------*/
-struct PyMethodDef Matrix_methods[] = {
- {"zero", (PyCFunction) Matrix_Zero, METH_NOARGS, Matrix_Zero_doc},
- {"identity", (PyCFunction) Matrix_Identity, METH_NOARGS, Matrix_Identity_doc},
- {"transpose", (PyCFunction) Matrix_Transpose, METH_NOARGS, Matrix_Transpose_doc},
- {"determinant", (PyCFunction) Matrix_Determinant, METH_NOARGS, Matrix_Determinant_doc},
- {"invert", (PyCFunction) Matrix_Invert, METH_NOARGS, Matrix_Invert_doc},
- {"translationPart", (PyCFunction) Matrix_TranslationPart, METH_NOARGS, Matrix_TranslationPart_doc},
- {"rotationPart", (PyCFunction) Matrix_RotationPart, METH_NOARGS, Matrix_RotationPart_doc},
- {"scalePart", (PyCFunction) Matrix_scalePart, METH_NOARGS, Matrix_scalePart_doc},
- {"resize4x4", (PyCFunction) Matrix_Resize4x4, METH_NOARGS, Matrix_Resize4x4_doc},
- {"toEuler", (PyCFunction) Matrix_toEuler, METH_NOARGS, Matrix_toEuler_doc},
- {"toQuat", (PyCFunction) Matrix_toQuat, METH_NOARGS, Matrix_toQuat_doc},
- {"copy", (PyCFunction) Matrix_copy, METH_NOARGS, Matrix_copy_doc},
- {"__copy__", (PyCFunction) Matrix_copy, METH_NOARGS, Matrix_copy_doc},
- {NULL, NULL, 0, NULL}
-};
-/*-----------------------------METHODS----------------------------*/
-/*---------------------------Matrix.toQuat() ---------------------*/
-PyObject *Matrix_toQuat(MatrixObject * self)
-{
- float quat[4];
-
- /*must be 3-4 cols, 3-4 rows, square matrix*/
- if(self->colSize < 3 || self->rowSize < 3 || (self->colSize != self->rowSize)) {
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix.toQuat(): inappropriate matrix size - expects 3x3 or 4x4 matrix\n");
- }
- if(self->colSize == 3){
- Mat3ToQuat((float (*)[3])*self->matrix, quat);
- }else{
- Mat4ToQuat((float (*)[4])*self->matrix, quat);
- }
-
- return newQuaternionObject(quat, Py_NEW);
-}
-/*---------------------------Matrix.toEuler() --------------------*/
-PyObject *Matrix_toEuler(MatrixObject * self)
-{
- float eul[3];
-
- int x;
-
- /*must be 3-4 cols, 3-4 rows, square matrix*/
- if(self->colSize ==3 && self->rowSize ==3) {
- Mat3ToEul((float (*)[3])*self->matrix, eul);
- }else if (self->colSize ==4 && self->rowSize ==4) {
- float tempmat3[3][3];
- Mat3CpyMat4(tempmat3, (float (*)[4])*self->matrix);
- Mat3ToEul(tempmat3, eul);
- }else
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix.toEuler(): inappropriate matrix size - expects 3x3 or 4x4 matrix\n");
-
- /*have to convert to degrees*/
- for(x = 0; x < 3; x++) {
- eul[x] *= (float) (180 / Py_PI);
- }
- return newEulerObject(eul, Py_NEW);
-}
-/*---------------------------Matrix.resize4x4() ------------------*/
-PyObject *Matrix_Resize4x4(MatrixObject * self)
-{
- int x, first_row_elem, curr_pos, new_pos, blank_columns, blank_rows, index;
-
- if(self->data.blend_data){
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "cannot resize wrapped data - only python matrices\n");
- }
-
- self->data.py_data = PyMem_Realloc(self->data.py_data, (sizeof(float) * 16));
- if(self->data.py_data == NULL) {
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "matrix.resize4x4(): problem allocating pointer space\n\n");
- }
- self->contigPtr = self->data.py_data; /*force*/
- self->matrix = PyMem_Realloc(self->matrix, (sizeof(float *) * 4));
- if(self->matrix == NULL) {
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "matrix.resize4x4(): problem allocating pointer space\n\n");
- }
- /*set row pointers*/
- for(x = 0; x < 4; x++) {
- self->matrix[x] = self->contigPtr + (x * 4);
- }
- /*move data to new spot in array + clean*/
- for(blank_rows = (4 - self->rowSize); blank_rows > 0; blank_rows--){
- for(x = 0; x < 4; x++){
- index = (4 * (self->rowSize + (blank_rows - 1))) + x;
- if (index == 10 || index == 15){
- self->contigPtr[index] = 1.0f;
- }else{
- self->contigPtr[index] = 0.0f;
- }
- }
- }
- for(x = 1; x <= self->rowSize; x++){
- first_row_elem = (self->colSize * (self->rowSize - x));
- curr_pos = (first_row_elem + (self->colSize -1));
- new_pos = (4 * (self->rowSize - x )) + (curr_pos - first_row_elem);
- for(blank_columns = (4 - self->colSize); blank_columns > 0; blank_columns--){
- self->contigPtr[new_pos + blank_columns] = 0.0f;
- }
- for(curr_pos = curr_pos; curr_pos >= first_row_elem; curr_pos--){
- self->contigPtr[new_pos] = self->contigPtr[curr_pos];
- new_pos--;
- }
- }
- self->rowSize = 4;
- self->colSize = 4;
- return EXPP_incr_ret((PyObject*)self);
-}
-/*---------------------------Matrix.translationPart() ------------*/
-PyObject *Matrix_TranslationPart(MatrixObject * self)
-{
- float vec[4];
-
- if(self->colSize < 3 || self->rowSize < 4){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix.translationPart: inappropriate matrix size\n");
- }
-
- vec[0] = self->matrix[3][0];
- vec[1] = self->matrix[3][1];
- vec[2] = self->matrix[3][2];
-
- return newVectorObject(vec, 3, Py_NEW);
-}
-/*---------------------------Matrix.rotationPart() ---------------*/
-PyObject *Matrix_RotationPart(MatrixObject * self)
-{
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
-
- if(self->colSize < 3 || self->rowSize < 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix.rotationPart: inappropriate matrix size\n");
- }
-
- mat[0] = self->matrix[0][0];
- mat[1] = self->matrix[0][1];
- mat[2] = self->matrix[0][2];
- mat[3] = self->matrix[1][0];
- mat[4] = self->matrix[1][1];
- mat[5] = self->matrix[1][2];
- mat[6] = self->matrix[2][0];
- mat[7] = self->matrix[2][1];
- mat[8] = self->matrix[2][2];
-
- return newMatrixObject(mat, 3, 3, Py_NEW);
-}
-/*---------------------------Matrix.scalePart() --------------------*/
-PyObject *Matrix_scalePart(MatrixObject * self)
-{
- float scale[3], rot[3];
- float mat[3][3], imat[3][3], tmat[3][3];
-
- /*must be 3-4 cols, 3-4 rows, square matrix*/
- if(self->colSize == 4 && self->rowSize == 4)
- Mat3CpyMat4(mat, (float (*)[4])*self->matrix);
- else if(self->colSize == 3 && self->rowSize == 3)
- Mat3CpyMat3(mat, (float (*)[3])*self->matrix);
- else
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix.scalePart(): inappropriate matrix size - expects 3x3 or 4x4 matrix\n");
-
- /* functionality copied from editobject.c apply_obmat */
- Mat3ToEul(mat, rot);
- EulToMat3(rot, tmat);
- Mat3Inv(imat, tmat);
- Mat3MulMat3(tmat, imat, mat);
-
- scale[0]= tmat[0][0];
- scale[1]= tmat[1][1];
- scale[2]= tmat[2][2];
- return newVectorObject(scale, 3, Py_NEW);
-}
-/*---------------------------Matrix.invert() ---------------------*/
-PyObject *Matrix_Invert(MatrixObject * self)
-{
-
- int x, y, z = 0;
- float det = 0.0f;
- PyObject *f = NULL;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
-
- if(self->rowSize != self->colSize){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix.invert(ed): only square matrices are supported\n");
- }
-
- /*calculate the determinant*/
- f = Matrix_Determinant(self);
- det = (float)PyFloat_AS_DOUBLE(f); /*Increfs, so we need to decref*/
- Py_DECREF(f);
-
- if(det != 0) {
- /*calculate the classical adjoint*/
- if(self->rowSize == 2) {
- mat[0] = self->matrix[1][1];
- mat[1] = -self->matrix[1][0];
- mat[2] = -self->matrix[0][1];
- mat[3] = self->matrix[0][0];
- } else if(self->rowSize == 3) {
- Mat3Adj((float (*)[3]) mat,(float (*)[3]) *self->matrix);
- } else if(self->rowSize == 4) {
- Mat4Adj((float (*)[4]) mat, (float (*)[4]) *self->matrix);
- }
- /*divide by determinate*/
- for(x = 0; x < (self->rowSize * self->colSize); x++) {
- mat[x] /= det;
- }
- /*set values*/
- for(x = 0; x < self->rowSize; x++) {
- for(y = 0; y < self->colSize; y++) {
- self->matrix[x][y] = mat[z];
- z++;
- }
- }
- /*transpose
- Matrix_Transpose(self);*/
- } else {
- return EXPP_ReturnPyObjError(PyExc_ValueError,
- "matrix does not have an inverse");
- }
- return EXPP_incr_ret((PyObject*)self);
-}
-
-
-/*---------------------------Matrix.determinant() ----------------*/
-PyObject *Matrix_Determinant(MatrixObject * self)
-{
- float det = 0.0f;
-
- if(self->rowSize != self->colSize){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix.determinant: only square matrices are supported\n");
- }
-
- if(self->rowSize == 2) {
- det = Det2x2(self->matrix[0][0], self->matrix[0][1],
- self->matrix[1][0], self->matrix[1][1]);
- } else if(self->rowSize == 3) {
- det = Det3x3(self->matrix[0][0], self->matrix[0][1],
- self->matrix[0][2], self->matrix[1][0],
- self->matrix[1][1], self->matrix[1][2],
- self->matrix[2][0], self->matrix[2][1],
- self->matrix[2][2]);
- } else {
- det = Det4x4((float (*)[4]) *self->matrix);
- }
-
- return PyFloat_FromDouble( (double) det );
-}
-/*---------------------------Matrix.transpose() ------------------*/
-PyObject *Matrix_Transpose(MatrixObject * self)
-{
- float t = 0.0f;
-
- if(self->rowSize != self->colSize){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix.transpose(d): only square matrices are supported\n");
- }
-
- if(self->rowSize == 2) {
- t = self->matrix[1][0];
- self->matrix[1][0] = self->matrix[0][1];
- self->matrix[0][1] = t;
- } else if(self->rowSize == 3) {
- Mat3Transp((float (*)[3])*self->matrix);
- } else {
- Mat4Transp((float (*)[4])*self->matrix);
- }
-
- return EXPP_incr_ret((PyObject*)self);
-}
-
-
-/*---------------------------Matrix.zero() -----------------------*/
-PyObject *Matrix_Zero(MatrixObject * self)
-{
- int row, col;
-
- for(row = 0; row < self->rowSize; row++) {
- for(col = 0; col < self->colSize; col++) {
- self->matrix[row][col] = 0.0f;
- }
- }
- return EXPP_incr_ret((PyObject*)self);
-}
-/*---------------------------Matrix.identity(() ------------------*/
-PyObject *Matrix_Identity(MatrixObject * self)
-{
- if(self->rowSize != self->colSize){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix.identity: only square matrices are supported\n");
- }
-
- if(self->rowSize == 2) {
- self->matrix[0][0] = 1.0f;
- self->matrix[0][1] = 0.0f;
- self->matrix[1][0] = 0.0f;
- self->matrix[1][1] = 1.0f;
- } else if(self->rowSize == 3) {
- Mat3One((float (*)[3]) *self->matrix);
- } else {
- Mat4One((float (*)[4]) *self->matrix);
- }
-
- return EXPP_incr_ret((PyObject*)self);
-}
-
-/*---------------------------Matrix.inverted() ------------------*/
-PyObject *Matrix_copy(MatrixObject * self)
-{
- return (PyObject*)(MatrixObject*)newMatrixObject((float (*))*self->matrix, self->rowSize, self->colSize, Py_NEW);
-}
-
-/*----------------------------dealloc()(internal) ----------------*/
-/*free the py_object*/
-static void Matrix_dealloc(MatrixObject * self)
-{
- Py_XDECREF(self->coerced_object);
- PyMem_Free(self->matrix);
- /*only free py_data*/
- if(self->data.py_data){
- PyMem_Free(self->data.py_data);
- }
- PyObject_DEL(self);
-}
-/*----------------------------getattr()(internal) ----------------*/
-/*object.attribute access (get)*/
-static PyObject *Matrix_getattr(MatrixObject * self, char *name)
-{
- if(STREQ(name, "rowSize")) {
- return PyInt_FromLong((long) self->rowSize);
- } else if(STREQ(name, "colSize")) {
- return PyInt_FromLong((long) self->colSize);
- }
- if(STREQ(name, "wrapped")){
- if(self->wrapped == Py_WRAP)
- return EXPP_incr_ret((PyObject *)Py_True);
- else
- return EXPP_incr_ret((PyObject *)Py_False);
- }
- return Py_FindMethod(Matrix_methods, (PyObject *) self, name);
-}
-/*----------------------------setattr()(internal) ----------------*/
-/*object.attribute access (set)*/
-static int Matrix_setattr(MatrixObject * self, char *name, PyObject * v)
-{
- /* This is not supported. */
- return (-1);
-}
-/*----------------------------print object (internal)-------------*/
-/*print the object to screen*/
-static PyObject *Matrix_repr(MatrixObject * self)
-{
- int x, y;
- char buffer[48], str[1024];
-
- BLI_strncpy(str,"",1024);
- for(x = 0; x < self->rowSize; x++){
- sprintf(buffer, "[");
- strcat(str,buffer);
- for(y = 0; y < (self->colSize - 1); y++) {
- sprintf(buffer, "%.6f, ", self->matrix[x][y]);
- strcat(str,buffer);
- }
- if(x < (self->rowSize-1)){
- sprintf(buffer, "%.6f](matrix [row %d])\n", self->matrix[x][y], x);
- strcat(str,buffer);
- }else{
- sprintf(buffer, "%.6f](matrix [row %d])", self->matrix[x][y], x);
- strcat(str,buffer);
- }
- }
-
- return PyString_FromString(str);
-}
-/*------------------------tp_richcmpr*/
-/*returns -1 execption, 0 false, 1 true*/
-static PyObject* Matrix_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type)
-{
- MatrixObject *matA = NULL, *matB = NULL;
- int result = 0;
-
- if (!MatrixObject_Check(objectA) || !MatrixObject_Check(objectB)){
- if (comparison_type == Py_NE){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
- }
- matA = (MatrixObject*)objectA;
- matB = (MatrixObject*)objectB;
-
- if (matA->colSize != matB->colSize || matA->rowSize != matB->rowSize){
- if (comparison_type == Py_NE){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
- }
-
- switch (comparison_type){
- case Py_EQ:
- /*contigPtr is basically a really long vector*/
- result = EXPP_VectorsAreEqual(matA->contigPtr, matB->contigPtr,
- (matA->rowSize * matA->colSize), 1);
- break;
- case Py_NE:
- result = EXPP_VectorsAreEqual(matA->contigPtr, matB->contigPtr,
- (matA->rowSize * matA->colSize), 1);
- if (result == 0){
- result = 1;
- }else{
- result = 0;
- }
- break;
- default:
- printf("The result of the comparison could not be evaluated");
- break;
- }
- if (result == 1){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
-}
-/*------------------------tp_doc*/
-static char MatrixObject_doc[] = "This is a wrapper for matrix objects.";
-/*---------------------SEQUENCE PROTOCOLS------------------------
- ----------------------------len(object)------------------------
- sequence length*/
-static int Matrix_len(MatrixObject * self)
-{
- return (self->colSize * self->rowSize);
-}
-/*----------------------------object[]---------------------------
- sequence accessor (get)
- the wrapped vector gives direct access to the matrix data*/
-static PyObject *Matrix_item(MatrixObject * self, int i)
-{
- if(i < 0 || i >= self->rowSize)
- return EXPP_ReturnPyObjError(PyExc_IndexError,
- "matrix[attribute]: array index out of range\n");
-
- return newVectorObject(self->matrix[i], self->colSize, Py_WRAP);
-}
-/*----------------------------object[]-------------------------
- sequence accessor (set)*/
-static int Matrix_ass_item(MatrixObject * self, int i, PyObject * ob)
-{
- int y, x, size = 0;
- float vec[4];
- PyObject *m, *f;
-
- if(i >= self->rowSize || i < 0){
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix[attribute] = x: bad row\n");
- }
-
- if(PySequence_Check(ob)){
- size = PySequence_Length(ob);
- if(size != self->colSize){
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix[attribute] = x: bad sequence size\n");
- }
- for (x = 0; x < size; x++) {
- m = PySequence_GetItem(ob, x);
- if (m == NULL) { /*Failed to read sequence*/
- return EXPP_ReturnIntError(PyExc_RuntimeError,
- "matrix[attribute] = x: unable to read sequence\n");
- }
-
- f = PyNumber_Float(m);
- if(f == NULL) { /*parsed item not a number*/
- Py_DECREF(m);
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix[attribute] = x: sequence argument not a number\n");
- }
-
- vec[x] = (float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(m, f);
- }
- /*parsed well - now set in matrix*/
- for(y = 0; y < size; y++){
- self->matrix[i][y] = vec[y];
- }
- return 0;
- }else{
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix[attribute] = x: expects a sequence of column size\n");
- }
-}
-/*----------------------------object[z:y]------------------------
- sequence slice (get)*/
-static PyObject *Matrix_slice(MatrixObject * self, int begin, int end)
-{
-
- PyObject *list = NULL;
- int count;
-
- CLAMP(begin, 0, self->rowSize);
- CLAMP(end, 0, self->rowSize);
- begin = MIN2(begin,end);
-
- list = PyList_New(end - begin);
- for(count = begin; count < end; count++) {
- PyList_SetItem(list, count - begin,
- newVectorObject(self->matrix[count], self->colSize, Py_WRAP));
- }
-
- return list;
-}
-/*----------------------------object[z:y]------------------------
- sequence slice (set)*/
-static int Matrix_ass_slice(MatrixObject * self, int begin, int end,
- PyObject * seq)
-{
- int i, x, y, size, sub_size = 0;
- float mat[16];
- PyObject *subseq;
- PyObject *m, *f;
-
- CLAMP(begin, 0, self->rowSize);
- CLAMP(end, 0, self->rowSize);
- begin = MIN2(begin,end);
-
- if(PySequence_Check(seq)){
- size = PySequence_Length(seq);
- if(size != (end - begin)){
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix[begin:end] = []: size mismatch in slice assignment\n");
- }
- /*parse sub items*/
- for (i = 0; i < size; i++) {
- /*parse each sub sequence*/
- subseq = PySequence_GetItem(seq, i);
- if (subseq == NULL) { /*Failed to read sequence*/
- return EXPP_ReturnIntError(PyExc_RuntimeError,
- "matrix[begin:end] = []: unable to read sequence\n");
- }
-
- if(PySequence_Check(subseq)){
- /*subsequence is also a sequence*/
- sub_size = PySequence_Length(subseq);
- if(sub_size != self->colSize){
- Py_DECREF(subseq);
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix[begin:end] = []: size mismatch in slice assignment\n");
- }
- for (y = 0; y < sub_size; y++) {
- m = PySequence_GetItem(subseq, y);
- if (m == NULL) { /*Failed to read sequence*/
- Py_DECREF(subseq);
- return EXPP_ReturnIntError(PyExc_RuntimeError,
- "matrix[begin:end] = []: unable to read sequence\n");
- }
-
- f = PyNumber_Float(m);
- if(f == NULL) { /*parsed item not a number*/
- EXPP_decr2(m, subseq);
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix[begin:end] = []: sequence argument not a number\n");
- }
-
- mat[(i * self->colSize) + y] = (float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(f, m);
- }
- }else{
- Py_DECREF(subseq);
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix[begin:end] = []: illegal argument type for built-in operation\n");
- }
- Py_DECREF(subseq);
- }
- /*parsed well - now set in matrix*/
- for(x = 0; x < (size * sub_size); x++){
- self->matrix[begin + (int)floor(x / self->colSize)][x % self->colSize] = mat[x];
- }
- return 0;
- }else{
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix[begin:end] = []: illegal argument type for built-in operation\n");
- }
-}
-/*------------------------NUMERIC PROTOCOLS----------------------
- ------------------------obj + obj------------------------------*/
-static PyObject *Matrix_add(PyObject * m1, PyObject * m2)
-{
- int x, y;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
- MatrixObject *mat1 = NULL, *mat2 = NULL;
-
- mat1 = (MatrixObject*)m1;
- mat2 = (MatrixObject*)m2;
-
- if(mat1->coerced_object || mat2->coerced_object){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix addition: arguments not valid for this operation....\n");
- }
- if(mat1->rowSize != mat2->rowSize || mat1->colSize != mat2->colSize){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix addition: matrices must have the same dimensions for this operation\n");
- }
-
- for(x = 0; x < mat1->rowSize; x++) {
- for(y = 0; y < mat1->colSize; y++) {
- mat[((x * mat1->colSize) + y)] = mat1->matrix[x][y] + mat2->matrix[x][y];
- }
- }
-
- return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW);
-}
-/*------------------------obj - obj------------------------------
- subtraction*/
-static PyObject *Matrix_sub(PyObject * m1, PyObject * m2)
-{
- int x, y;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
- MatrixObject *mat1 = NULL, *mat2 = NULL;
-
- mat1 = (MatrixObject*)m1;
- mat2 = (MatrixObject*)m2;
-
- if(mat1->coerced_object || mat2->coerced_object){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix addition: arguments not valid for this operation....\n");
- }
- if(mat1->rowSize != mat2->rowSize || mat1->colSize != mat2->colSize){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix addition: matrices must have the same dimensions for this operation\n");
- }
-
- for(x = 0; x < mat1->rowSize; x++) {
- for(y = 0; y < mat1->colSize; y++) {
- mat[((x * mat1->colSize) + y)] = mat1->matrix[x][y] - mat2->matrix[x][y];
- }
- }
-
- return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW);
-}
-/*------------------------obj * obj------------------------------
- mulplication*/
-static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
-{
- int x, y, z;
- float scalar;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
- double dot = 0.0f;
- MatrixObject *mat1 = NULL, *mat2 = NULL;
- PyObject *f = NULL;
- PointObject *pt = NULL;
-
- mat1 = (MatrixObject*)m1;
- mat2 = (MatrixObject*)m2;
-
- if(mat1->coerced_object){
- if (PyFloat_Check(mat1->coerced_object) ||
- PyInt_Check(mat1->coerced_object)){ /*FLOAT/INT * MATRIX*/
- f = PyNumber_Float(mat1->coerced_object);
- if(f == NULL) { /*parsed item not a number*/
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Matrix multiplication: arguments not acceptable for this operation\n");
- }
-
- scalar = (float)PyFloat_AS_DOUBLE(f);
- Py_DECREF(f);
- for(x = 0; x < mat2->rowSize; x++) {
- for(y = 0; y < mat2->colSize; y++) {
- mat[((x * mat2->colSize) + y)] = scalar * mat2->matrix[x][y];
- }
- }
- return newMatrixObject(mat, mat2->rowSize, mat2->colSize, Py_NEW);
- }
- }else{
- if(mat2->coerced_object){
- /* MATRIX * VECTOR operation is now being done by vector */
- /*if(VectorObject_Check(mat2->coerced_object)){
- vec = (VectorObject*)mat2->coerced_object;
- return column_vector_multiplication(mat1, vec);
- }else */
- if(PointObject_Check(mat2->coerced_object)){ /*MATRIX * POINT*/
- pt = (PointObject*)mat2->coerced_object;
- return column_point_multiplication(mat1, pt);
- }else if (PyFloat_Check(mat2->coerced_object) ||
- PyInt_Check(mat2->coerced_object)){ /*MATRIX * FLOAT/INT*/
- f = PyNumber_Float(mat2->coerced_object);
- if(f == NULL) { /*parsed item not a number*/
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Matrix multiplication: arguments not acceptable for this operation\n");
- }
-
- scalar = (float)PyFloat_AS_DOUBLE(f);
- Py_DECREF(f);
- for(x = 0; x < mat1->rowSize; x++) {
- for(y = 0; y < mat1->colSize; y++) {
- mat[((x * mat1->colSize) + y)] = scalar * mat1->matrix[x][y];
- }
- }
- return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW);
- }
- }else{ /*MATRIX * MATRIX*/
- if(mat1->colSize != mat2->rowSize){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Matrix multiplication: matrix A rowsize must equal matrix B colsize\n");
- }
- for(x = 0; x < mat1->rowSize; x++) {
- for(y = 0; y < mat2->colSize; y++) {
- for(z = 0; z < mat1->colSize; z++) {
- dot += (mat1->matrix[x][z] * mat2->matrix[z][y]);
- }
- mat[((x * mat1->rowSize) + y)] = (float)dot;
- dot = 0.0f;
- }
- }
- return newMatrixObject(mat, mat1->rowSize, mat2->colSize, Py_NEW);
- }
- }
-
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Matrix multiplication: arguments not acceptable for this operation\n");
-}
-PyObject* Matrix_inv(MatrixObject *self)
-{
- return Matrix_Invert(self);
-}
-/*------------------------coerce(obj, obj)-----------------------
- coercion of unknown types to type MatrixObject for numeric protocols.
-
- Coercion() is called whenever a math operation has 2 operands that
- it doesn't understand how to evaluate. 2+Matrix for example. We want to
- evaluate some of these operations like: (vector * 2), however, for math
- to proceed, the unknown operand must be cast to a type that python math will
- understand. (e.g. in the case above case, 2 must be cast to a vector and
- then call vector.multiply(vector, scalar_cast_as_vector)*/
-static int Matrix_coerce(PyObject ** m1, PyObject ** m2)
-{
- if(VectorObject_Check(*m2) || PyFloat_Check(*m2) || PyInt_Check(*m2) ||
- PointObject_Check(*m2)) {
- PyObject *coerced = EXPP_incr_ret(*m2);
- *m2 = newMatrixObject(NULL,3,3,Py_NEW);
- ((MatrixObject*)*m2)->coerced_object = coerced;
- Py_INCREF (*m1);
- return 0;
- }
-
- return EXPP_ReturnIntError(PyExc_TypeError,
- "matrix.coerce(): unknown operand - can't coerce for numeric protocols");
-}
-/*-----------------PROTOCOL DECLARATIONS--------------------------*/
-static PySequenceMethods Matrix_SeqMethods = {
- (inquiry) Matrix_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Matrix_item, /* sq_item */
- (intintargfunc) Matrix_slice, /* sq_slice */
- (intobjargproc) Matrix_ass_item, /* sq_ass_item */
- (intintobjargproc) Matrix_ass_slice, /* sq_ass_slice */
-};
-static PyNumberMethods Matrix_NumMethods = {
- (binaryfunc) Matrix_add, /* __add__ */
- (binaryfunc) Matrix_sub, /* __sub__ */
- (binaryfunc) Matrix_mul, /* __mul__ */
- (binaryfunc) 0, /* __div__ */
- (binaryfunc) 0, /* __mod__ */
- (binaryfunc) 0, /* __divmod__ */
- (ternaryfunc) 0, /* __pow__ */
- (unaryfunc) 0, /* __neg__ */
- (unaryfunc) 0, /* __pos__ */
- (unaryfunc) 0, /* __abs__ */
- (inquiry) 0, /* __nonzero__ */
- (unaryfunc) Matrix_inv, /* __invert__ */
- (binaryfunc) 0, /* __lshift__ */
- (binaryfunc) 0, /* __rshift__ */
- (binaryfunc) 0, /* __and__ */
- (binaryfunc) 0, /* __xor__ */
- (binaryfunc) 0, /* __or__ */
- (coercion) Matrix_coerce, /* __coerce__ */
- (unaryfunc) 0, /* __int__ */
- (unaryfunc) 0, /* __long__ */
- (unaryfunc) 0, /* __float__ */
- (unaryfunc) 0, /* __oct__ */
- (unaryfunc) 0, /* __hex__ */
-};
-/*------------------PY_OBECT DEFINITION--------------------------*/
-PyTypeObject matrix_Type = {
- PyObject_HEAD_INIT(NULL) /*tp_head*/
- 0, /*tp_internal*/
- "matrix", /*tp_name*/
- sizeof(MatrixObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Matrix_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- (getattrfunc)Matrix_getattr, /*tp_getattr*/
- (setattrfunc) Matrix_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc) Matrix_repr, /*tp_repr*/
- &Matrix_NumMethods, /*tp_as_number*/
- &Matrix_SeqMethods, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- MatrixObject_doc, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- (richcmpfunc)Matrix_richcmpr, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- 0, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0 /*tp_del*/
-};
-
-/*------------------------newMatrixObject (internal)-------------
-creates a new matrix object
-self->matrix self->contiguous_ptr (reference to data.xxx)
- [0]------------->[0]
- [1]
- [2]
- [1]------------->[3]
- [4]
- [5]
- ....
-self->matrix[1][1] = self->contiguous_ptr[4] = self->data.xxx_data[4]*/
-
-/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
- (i.e. it was allocated elsewhere by MEM_mallocN())
- pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
- (i.e. it must be created here with PyMEM_malloc())*/
-PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type)
-{
- MatrixObject *self;
- int x, row, col;
-
- /*matrix objects can be any 2-4row x 2-4col matrix*/
- if(rowSize < 2 || rowSize > 4 || colSize < 2 || colSize > 4){
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "matrix(): row and column sizes must be between 2 and 4\n");
- }
-
- self = PyObject_NEW(MatrixObject, &matrix_Type);
- self->data.blend_data = NULL;
- self->data.py_data = NULL;
- self->rowSize = rowSize;
- self->colSize = colSize;
- self->coerced_object = NULL;
-
- if(type == Py_WRAP){
- self->data.blend_data = mat;
- self->contigPtr = self->data.blend_data;
- /*create pointer array*/
- self->matrix = PyMem_Malloc(rowSize * sizeof(float *));
- if(self->matrix == NULL) { /*allocation failure*/
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "matrix(): problem allocating pointer space\n");
- }
- /*pointer array points to contigous memory*/
- for(x = 0; x < rowSize; x++) {
- self->matrix[x] = self->contigPtr + (x * colSize);
- }
- self->wrapped = Py_WRAP;
- }else if (type == Py_NEW){
- self->data.py_data = PyMem_Malloc(rowSize * colSize * sizeof(float));
- if(self->data.py_data == NULL) { /*allocation failure*/
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "matrix(): problem allocating pointer space\n");
- }
- self->contigPtr = self->data.py_data;
- /*create pointer array*/
- self->matrix = PyMem_Malloc(rowSize * sizeof(float *));
- if(self->matrix == NULL) { /*allocation failure*/
- PyMem_Free(self->data.py_data);
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "matrix(): problem allocating pointer space\n");
- }
- /*pointer array points to contigous memory*/
- for(x = 0; x < rowSize; x++) {
- self->matrix[x] = self->contigPtr + (x * colSize);
- }
- /*parse*/
- if(mat) { /*if a float array passed*/
- for(row = 0; row < rowSize; row++) {
- for(col = 0; col < colSize; col++) {
- self->matrix[row][col] = mat[(row * colSize) + col];
- }
- }
- } else if (rowSize == colSize ) { /*or if no arguments are passed return identity matrix for square matrices */
- Matrix_Identity(self);
- Py_DECREF(self);
- }
- self->wrapped = Py_NEW;
- }else{ /*bad type*/
- return NULL;
- }
- return (PyObject *) self;
-}
diff --git a/source/blender/python/api2_2x/matrix.h b/source/blender/python/api2_2x/matrix.h
deleted file mode 100644
index b830038bfcc..00000000000
--- a/source/blender/python/api2_2x/matrix.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * $Id: matrix.h 8363 2006-08-21 13:52:32Z 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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- *
- */
-
-#ifndef EXPP_matrix_h
-#define EXPP_matrix_h
-
-#include <Python.h>
-
-extern PyTypeObject matrix_Type;
-
-#define MatrixObject_Check(v) ((v)->ob_type == &matrix_Type)
-
-typedef float **ptRow;
-typedef struct _Matrix {
- PyObject_VAR_HEAD
- struct{
- float *py_data; /*python managed*/
- float *blend_data; /*blender managed*/
- }data;
- ptRow matrix; /*ptr to the contigPtr (accessor)*/
- float *contigPtr; /*1D array of data (alias)*/
- int rowSize;
- int colSize;
- int wrapped; /*is wrapped data?*/
- PyObject *coerced_object;
-} MatrixObject;
-/*coerced_object is a pointer to the object that it was
-coerced from when a dummy vector needs to be created from
-the coerce() function for numeric protocol operations*/
-
-/*struct data contains a pointer to the actual data that the
-object uses. It can use either PyMem allocated data (which will
-be stored in py_data) or be a wrapper for data allocated through
-blender (stored in blend_data). This is an either/or struct not both*/
-
-/*prototypes*/
-PyObject *Matrix_Zero( MatrixObject * self );
-PyObject *Matrix_Identity( MatrixObject * self );
-PyObject *Matrix_Transpose( MatrixObject * self );
-PyObject *Matrix_Determinant( MatrixObject * self );
-PyObject *Matrix_Invert( MatrixObject * self );
-PyObject *Matrix_TranslationPart( MatrixObject * self );
-PyObject *Matrix_RotationPart( MatrixObject * self );
-PyObject *Matrix_scalePart( MatrixObject * self );
-PyObject *Matrix_Resize4x4( MatrixObject * self );
-PyObject *Matrix_toEuler( MatrixObject * self );
-PyObject *Matrix_toQuat( MatrixObject * self );
-PyObject *Matrix_copy( MatrixObject * self );
-PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type);
-
-#endif /* EXPP_matrix_H */
diff --git a/source/blender/python/api2_2x/meshPrimitive.c b/source/blender/python/api2_2x/meshPrimitive.c
deleted file mode 100644
index 754f4986646..00000000000
--- a/source/blender/python/api2_2x/meshPrimitive.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * $Id: meshPrimitive.c 10773 2007-05-24 15:00:10Z 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, partially based on NMesh.c API.
- *
- * Contributor(s): Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Mesh.h" /*This must come first*/
-
-#include "DNA_scene_types.h"
-#include "BDR_editobject.h"
-#include "BIF_editmesh.h"
-#include "BKE_global.h"
-#include "BKE_object.h"
-#include "BKE_scene.h"
-#include "BKE_library.h"
-#include "blendef.h"
-
-#include "gen_utils.h"
-
-/*
- * local helper procedure which does the dirty work of messing with the
- * edit mesh, active objects, etc.
- */
-
-static PyObject *make_mesh( int type, char *name, short tot, short seg,
- short subdiv, float dia, float height, short ext, short fill )
-{
- float cent[3] = {0,0,0};
- float imat[3][3]={{1,0,0},{0,1,0},{0,0,1}};
- Mesh *me;
- BPy_Mesh *obj;
- Object *ob;
- Base *base;
-
- /* remember active object (if any) for later, so we can re-activate */
- base = BASACT;
-
- /* make a new object, "copy" to the editMesh structure */
- ob = add_object(OB_MESH);
- me = (Mesh *)ob->data;
- G.obedit = BASACT->object;
- make_editMesh( );
-
- /* create the primitive in the edit mesh */
-
- make_prim( type, imat, /* mesh type, transform matrix */
- tot, seg, /* total vertices, segments */
- subdiv, /* subdivisions (for Icosphere only) */
- dia, -height, /* diameter-ish, height */
- ext, fill, /* extrude, fill end faces */
- cent ); /* location of center */
-
- /* copy primitive back to the real mesh */
- load_editMesh( );
- free_editMesh( G.editMesh );
- G.obedit = NULL;
-
- /* remove object link to the data, then delete the object */
- ob->data = NULL;
- me->id.us = 0;
- free_and_unlink_base(BASACT);
-
- /* if there was an active object, reactivate it */
- if( base )
- scene_select_base(G.scene, base);
-
- /* create the BPy_Mesh that wraps this mesh */
- obj = (BPy_Mesh *)PyObject_NEW( BPy_Mesh, &Mesh_Type );
-
- rename_id( &me->id, name );
- obj->mesh = me;
- obj->object = NULL;
- obj->new = 1;
- return (PyObject *) obj;
-}
-
-static PyObject *M_MeshPrim_Plane( PyObject *self_unused, PyObject *args )
-{
- float size = 2.0;
-
- if( !PyArg_ParseTuple( args, "|f", &size ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected optional float arg" );
-
- size *= (float)(sqrt(2.0)/2.0);
- return make_mesh( 0, "Plane", 4, 0, 0, size, -size, 0, 1 );
-}
-
-static PyObject *M_MeshPrim_Cube( PyObject *self_unused, PyObject *args )
-{
- float height = 2.0;
- float dia;
-
- if( !PyArg_ParseTuple( args, "|f", &height ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected optional float arg" );
-
- height /= 2.0;
- dia = height * (float)sqrt(2.0);
- return make_mesh( 1, "Cube", 4, 32, 2, dia, -height, 1, 1 );
-}
-
-static PyObject *M_MeshPrim_Circle( PyObject *self_unused, PyObject *args )
-{
- int tot = 32;
- float size = 2;
-
- if( !PyArg_ParseTuple( args, "|if", &tot, &size ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int and optional float arg" );
- if( tot < 3 || tot > 100 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "number of vertices must be in the range [3:100]" );
-
- size /= 2.0;
- return make_mesh( 4, "Circle", tot, 0, 0, size, -size, 0, 0 );
-}
-
-static PyObject *M_MeshPrim_Cylinder( PyObject *self_unused, PyObject *args )
-{
- int tot = 32;
- float size = 2.0;
- float len = 2.0;
-
- if( !PyArg_ParseTuple( args, "|iff", &tot, &size, &len ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int and optional float arg" );
- if( tot < 3 || tot > 100 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "number of vertices must be in the range [3:100]" );
-
- return make_mesh( 5, "Cylinder", tot, 0, 0, size/2.0, -len/2.0, 1, 1 );
-}
-
-static PyObject *M_MeshPrim_Tube( PyObject *self_unused, PyObject *args )
-{
- int tot = 32;
- float size = 2.0;
- float len = 2.0;
-
- if( !PyArg_ParseTuple( args, "|iff", &tot, &size, &len ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int and optional float arg" );
- if( tot < 3 || tot > 100 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "number of vertices must be in the range [3:100]" );
-
- return make_mesh( 6, "Tube", tot, 0, 0, size/2.0, -len/2.0, 1, 0 );
-}
-
-static PyObject *M_MeshPrim_Cone( PyObject *self_unused, PyObject *args )
-{
- int tot = 32;
- float size = 2.0;
- float len = 2.0;
-
- if( !PyArg_ParseTuple( args, "|iff", &tot, &size, &len ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int and optional float arg" );
- if( tot < 3 || tot > 100 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "number of vertices must be in the range [3:100]" );
-
- return make_mesh( 7, "Cone", tot, 0, 0, size/2.0, -len/2.0, 0, 1 );
-}
-
-static PyObject *M_MeshPrim_Grid( PyObject *self_unused, PyObject *args )
-{
- int xres = 32;
- int yres = 32;
- float size = 2.0;
-
- if( !PyArg_ParseTuple( args, "|iif", &xres, &yres, &size ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected two ints and an optional float arg" );
- if( xres < 2 || xres > 100 || yres < 2 || yres > 100 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "resolution must be in the range [2:100]" );
-
- size /= 2.0;
- return make_mesh( 10, "Grid", xres, yres, 0, size, -size, 0, 0 );
-}
-
-static PyObject *M_MeshPrim_UVsphere( PyObject *self_unused, PyObject *args )
-{
- int segs = 32;
- int rings = 32;
- float size = 2.0;
-
- if( !PyArg_ParseTuple( args, "|iif", &segs, &rings, &size ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected two ints and an optional float arg" );
- if( segs < 3 || segs > 100 || rings < 3 || rings > 100 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "segments and rings must be in the range [3:100]" );
-
- size /= 2.0;
- return make_mesh( 11, "UVsphere", segs, rings, 0, size, -size, 0, 0 );
-}
-
-static PyObject *M_MeshPrim_Icosphere( PyObject *self_unused, PyObject *args )
-{
- int subdiv = 2;
- float size = 2.0;
-
- if( !PyArg_ParseTuple( args, "|if", &subdiv, &size ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int and an optional float arg" );
- if( subdiv < 1 || subdiv > 5 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "subdivisions must be in the range [1:5]" );
-
- size /= 2.0;
- return make_mesh( 12, "Icosphere", 0, 0, subdiv, size, -size, 0, 0 );
-}
-
-static PyObject *M_MeshPrim_Suzanne( PyObject *self_unused, PyObject *args )
-{
- return make_mesh( 13, "Monkey", 0, 0, 0, 0, 0, 0, 0 );
-}
-
-static struct PyMethodDef M_MeshPrim_methods[] = {
- {"Plane", (PyCFunction)M_MeshPrim_Plane, METH_VARARGS,
- "Create a plane mesh"},
- {"Cube", (PyCFunction)M_MeshPrim_Cube, METH_VARARGS,
- "Create a cube mesh"},
- {"Circle", (PyCFunction)M_MeshPrim_Circle, METH_VARARGS,
- "Create a circle mesh"},
- {"Cylinder", (PyCFunction)M_MeshPrim_Cylinder, METH_VARARGS,
- "Create a cylindrical mesh"},
- {"Tube", (PyCFunction)M_MeshPrim_Tube, METH_VARARGS,
- "Create a tube mesh"},
- {"Cone", (PyCFunction)M_MeshPrim_Cone, METH_VARARGS,
- "Create a conic mesh"},
- {"Grid", (PyCFunction)M_MeshPrim_Grid, METH_VARARGS,
- "Create a 2D grid mesh"},
- {"UVsphere", (PyCFunction)M_MeshPrim_UVsphere, METH_VARARGS,
- "Create a UV sphere mesh"},
- {"Icosphere", (PyCFunction)M_MeshPrim_Icosphere, METH_VARARGS,
- "Create a Ico sphere mesh"},
- {"Monkey", (PyCFunction)M_MeshPrim_Suzanne, METH_NOARGS,
- "Create a Suzanne mesh"},
- {NULL, NULL, 0, NULL},
-};
-
-static char M_MeshPrim_doc[] = "The Blender.Mesh.Primitives submodule";
-
-PyObject *MeshPrimitives_Init( void )
-{
- return Py_InitModule3( "Blender.Mesh.Primitives",
- M_MeshPrim_methods, M_MeshPrim_doc );
-}
-
diff --git a/source/blender/python/api2_2x/meshPrimitive.h b/source/blender/python/api2_2x/meshPrimitive.h
deleted file mode 100644
index e864ffd0d17..00000000000
--- a/source/blender/python/api2_2x/meshPrimitive.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * $Id: meshPrimitive.h 7512 2006-05-25 16:45:24Z 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): Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef EXPP_MESHPRIMITIVES_H
-#define EXPP_MESHPRIMITIVES_H
-
-#include <Python.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* PROTOS */
-
-PyObject *MeshPrimitives_Init( void );
-
-#endif /* EXPP_MESHPRIMITIVES_H */
diff --git a/source/blender/python/api2_2x/modules.h b/source/blender/python/api2_2x/modules.h
deleted file mode 100644
index 81e138da798..00000000000
--- a/source/blender/python/api2_2x/modules.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * $Id: modules.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, Nathan Letwory,
- * Stephen Swaney
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#ifndef EXPP_modules_h
-#define EXPP_modules_h
-
-/************************************************************
-Certain bpy module files ( BPY_interface.c, Blender.c, and Object.c )
-need to know about almost every other module. This file is a
-convenient way to include almost all the necessary declarations.
-
-The #includes commented out below currently do not exist.
-Their *_Init() method declarations are hacked in down below.
-************************************************************/
-
-#include <Python.h>
-
-/*****************************************************************************/
-/* Global variables */
-/*****************************************************************************/
-
-/****************************************************************************
-Module Init functions for modules without a .h file.
-BGL is a special case. It still has data declarations in the .h file
-and cannot be #included until it is cleaned up.
-****************************************************************************/
-
-PyObject *BGL_Init( void );
-
-PyObject *Library_Init( void );
-PyObject *Noise_Init( void );
-
-
-
-#endif /* EXPP_modules_h */
diff --git a/source/blender/python/api2_2x/point.c b/source/blender/python/api2_2x/point.c
deleted file mode 100644
index 969fe2d53af..00000000000
--- a/source/blender/python/api2_2x/point.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * $Id: point.c 10782 2007-05-26 04:39:31Z 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 "Mathutils.h"
-
-#include "BLI_blenlib.h"
-#include "BKE_utildefines.h"
-#include "gen_utils.h"
-
-//-------------------------DOC STRINGS ---------------------------
-char Point_Zero_doc[] = "() - set all values in the point to 0";
-char Point_toVector_doc[] = "() - create a vector representation of this point";
-//-----------------------METHOD DEFINITIONS ----------------------
-struct PyMethodDef Point_methods[] = {
- {"zero", (PyCFunction) Point_Zero, METH_NOARGS, Point_Zero_doc},
- {"toVector", (PyCFunction) Point_toVector, METH_NOARGS, Point_toVector_doc},
- {NULL, NULL, 0, NULL}
-};
-//-----------------------------METHODS----------------------------
-//--------------------------Vector.toPoint()----------------------
-//create a new point object to represent this vector
-PyObject *Point_toVector(PointObject * self)
-{
- float vec[3];
- int x;
-
- for(x = 0; x < self->size; x++){
- vec[x] = self->coord[x];
- }
-
- return newVectorObject(vec, self->size, Py_NEW);
-}
-//----------------------------Point.zero() ----------------------
-//set the point data to 0,0,0
-PyObject *Point_Zero(PointObject * self)
-{
- int x;
- for(x = 0; x < self->size; x++) {
- self->coord[x] = 0.0f;
- }
- return EXPP_incr_ret((PyObject*)self);
-}
-//----------------------------dealloc()(internal) ----------------
-//free the py_object
-static void Point_dealloc(PointObject * self)
-{
- Py_XDECREF(self->coerced_object);
- //only free py_data
- if(self->data.py_data){
- PyMem_Free(self->data.py_data);
- }
- PyObject_DEL(self);
-}
-//----------------------------getattr()(internal) ----------------
-//object.attribute access (get)
-static PyObject *Point_getattr(PointObject * self, char *name)
-{
- if(STREQ(name,"x")){
- return PyFloat_FromDouble(self->coord[0]);
- }else if(STREQ(name, "y")){
- return PyFloat_FromDouble(self->coord[1]);
- }else if(STREQ(name, "z")){
- if(self->size > 2){
- return PyFloat_FromDouble(self->coord[2]);
- }else{
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "point.z: illegal attribute access\n");
- }
- }
- if(STREQ(name, "wrapped")){
- if(self->wrapped == Py_WRAP)
- return EXPP_incr_ret((PyObject *)Py_True);
- else
- return EXPP_incr_ret((PyObject *)Py_False);
- }
- return Py_FindMethod(Point_methods, (PyObject *) self, name);
-}
-//----------------------------setattr()(internal) ----------------
-//object.attribute access (set)
-static int Point_setattr(PointObject * self, char *name, PyObject * v)
-{
- PyObject *f = NULL;
-
- f = PyNumber_Float(v);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnIntError(PyExc_TypeError,
- "point.attribute = x: argument not a number\n");
- }
-
- if(STREQ(name,"x")){
- self->coord[0] = (float)PyFloat_AS_DOUBLE(f);
- }else if(STREQ(name, "y")){
- self->coord[1] = (float)PyFloat_AS_DOUBLE(f);
- }else if(STREQ(name, "z")){
- if(self->size > 2){
- self->coord[2] = (float)PyFloat_AS_DOUBLE(f);
- }else{
- Py_DECREF(f);
- return EXPP_ReturnIntError(PyExc_AttributeError,
- "point.z = x: illegal attribute access\n");
- }
- }else{
- Py_DECREF(f);
- return EXPP_ReturnIntError(PyExc_AttributeError,
- "point.attribute = x: unknown attribute\n");
- }
-
- Py_DECREF(f);
- return 0;
-}
-//----------------------------print object (internal)-------------
-//print the object to screen
-static PyObject *Point_repr(PointObject * self)
-{
- int i;
- char buffer[48], str[1024];
-
- BLI_strncpy(str,"[",1024);
- for(i = 0; i < self->size; i++){
- if(i < (self->size - 1)){
- sprintf(buffer, "%.6f, ", self->coord[i]);
- strcat(str,buffer);
- }else{
- sprintf(buffer, "%.6f", self->coord[i]);
- strcat(str,buffer);
- }
- }
- strcat(str, "](point)");
-
- return PyString_FromString(str);
-}
-//---------------------SEQUENCE PROTOCOLS------------------------
-//----------------------------len(object)------------------------
-//sequence length
-static int Point_len(PointObject * self)
-{
- return self->size;
-}
-//----------------------------object[]---------------------------
-//sequence accessor (get)
-static PyObject *Point_item(PointObject * self, int i)
-{
- if(i < 0 || i >= self->size)
- return EXPP_ReturnPyObjError(PyExc_IndexError,
- "point[attribute]: array index out of range\n");
-
- return PyFloat_FromDouble( (double)self->coord[i] );
-
-}
-//----------------------------object[]-------------------------
-//sequence accessor (set)
-static int Point_ass_item(PointObject * self, int i, PyObject * ob)
-{
- PyObject *f = NULL;
-
- f = PyNumber_Float(ob);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnIntError(PyExc_TypeError,
- "point[attribute] = x: argument not a number\n");
- }
-
- if(i < 0 || i >= self->size){
- Py_DECREF(f);
- return EXPP_ReturnIntError(PyExc_IndexError,
- "point[attribute] = x: array assignment index out of range\n");
- }
- self->coord[i] = (float)PyFloat_AS_DOUBLE(f);
- Py_DECREF(f);
- return 0;
-}
-//----------------------------object[z:y]------------------------
-//sequence slice (get)
-static PyObject *Point_slice(PointObject * self, int begin, int end)
-{
- PyObject *list = NULL;
- int count;
-
- CLAMP(begin, 0, self->size);
- CLAMP(end, 0, self->size);
- begin = MIN2(begin,end);
-
- list = PyList_New(end - begin);
- for(count = begin; count < end; count++) {
- PyList_SetItem(list, count - begin,
- PyFloat_FromDouble(self->coord[count]));
- }
-
- return list;
-}
-//----------------------------object[z:y]------------------------
-//sequence slice (set)
-static int Point_ass_slice(PointObject * self, int begin, int end,
- PyObject * seq)
-{
- int i, y, size = 0;
- float coord[3];
- PyObject *v, *f;
-
- CLAMP(begin, 0, self->size);
- CLAMP(end, 0, self->size);
- begin = MIN2(begin,end);
-
- size = PySequence_Length(seq);
- if(size != (end - begin)){
- return EXPP_ReturnIntError(PyExc_TypeError,
- "point[begin:end] = []: size mismatch in slice assignment\n");
- }
-
- for (i = 0; i < size; i++) {
- v = PySequence_GetItem(seq, i);
- if (v == NULL) { // Failed to read sequence
- return EXPP_ReturnIntError(PyExc_RuntimeError,
- "point[begin:end] = []: unable to read sequence\n");
- }
- f = PyNumber_Float(v);
- if(f == NULL) { // parsed item not a number
- Py_DECREF(v);
- return EXPP_ReturnIntError(PyExc_TypeError,
- "point[begin:end] = []: sequence argument not a number\n");
- }
-
- coord[i] = (float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(f,v);
- }
- //parsed well - now set in point
- for(y = 0; y < size; y++){
- self->coord[begin + y] = coord[y];
- }
- return 0;
-}
-//------------------------NUMERIC PROTOCOLS----------------------
-//------------------------obj + obj------------------------------
-//addition
-static PyObject *Point_add(PyObject * v1, PyObject * v2)
-{
- int x, size;
- float coord[3];
- PointObject *coord1 = NULL, *coord2 = NULL;
- VectorObject *vec = NULL;
-
- coord1 = (PointObject*)v1;
- coord2 = (PointObject*)v2;
-
- if(!coord1->coerced_object){
- if(coord2->coerced_object){
- if(VectorObject_Check(coord2->coerced_object)){ //POINT + VECTOR
- //Point translation
- vec = (VectorObject*)coord2->coerced_object;
- size = coord1->size;
- if(vec->size == size){
- for(x = 0; x < size; x++){
- coord[x] = coord1->coord[x] + vec->vec[x];
- }
- }else{
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Point addition: arguments are the wrong size....\n");
- }
- return newPointObject(coord, size, Py_NEW);
- }
- }else{ //POINT + POINT
- size = coord1->size;
- if(coord2->size == size){
- for(x = 0; x < size; x++) {
- coord[x] = coord1->coord[x] + coord2->coord[x];
- }
- }else{
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Point addition: arguments are the wrong size....\n");
- }
- return newPointObject(coord, size, Py_NEW);
- }
- }
-
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Point addition: arguments not valid for this operation....\n");
-}
-//------------------------obj - obj------------------------------
-//subtraction
-static PyObject *Point_sub(PyObject * v1, PyObject * v2)
-{
- int x, size;
- float coord[3];
- PointObject *coord1 = NULL, *coord2 = NULL;
-
- coord1 = (PointObject*)v1;
- coord2 = (PointObject*)v2;
-
- if(coord1->coerced_object || coord2->coerced_object){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Point subtraction: arguments not valid for this operation....\n");
- }
- if(coord1->size != coord2->size){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Point subtraction: points must have the same dimensions for this operation\n");
- }
-
- size = coord1->size;
- for(x = 0; x < size; x++) {
- coord[x] = coord1->coord[x] - coord2->coord[x];
- }
-
- //Point - Point = Vector
- return newVectorObject(coord, size, Py_NEW);
-}
-//------------------------obj * obj------------------------------
-//mulplication
-static PyObject *Point_mul(PyObject * p1, PyObject * p2)
-{
- int x, size;
- float coord[3], scalar;
- PointObject *coord1 = NULL, *coord2 = NULL;
- PyObject *f = NULL;
- MatrixObject *mat = NULL;
- QuaternionObject *quat = NULL;
-
- coord1 = (PointObject*)p1;
- coord2 = (PointObject*)p2;
-
- if(coord1->coerced_object){
- if (PyFloat_Check(coord1->coerced_object) ||
- PyInt_Check(coord1->coerced_object)){ // FLOAT/INT * POINT
- f = PyNumber_Float(coord1->coerced_object);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Point multiplication: arguments not acceptable for this operation\n");
- }
-
- scalar = (float)PyFloat_AS_DOUBLE(f);
- size = coord2->size;
- for(x = 0; x < size; x++) {
- coord[x] = coord2->coord[x] * scalar;
- }
- Py_DECREF(f);
- return newPointObject(coord, size, Py_NEW);
- }
- }else{
- if(coord2->coerced_object){
- if (PyFloat_Check(coord2->coerced_object) ||
- PyInt_Check(coord2->coerced_object)){ // POINT * FLOAT/INT
- f = PyNumber_Float(coord2->coerced_object);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Point multiplication: arguments not acceptable for this operation\n");
- }
-
- scalar = (float)PyFloat_AS_DOUBLE(f);
- size = coord1->size;
- for(x = 0; x < size; x++) {
- coord[x] = coord1->coord[x] * scalar;
- }
- Py_DECREF(f);
- return newPointObject(coord, size, Py_NEW);
- }else if(MatrixObject_Check(coord2->coerced_object)){ //POINT * MATRIX
- mat = (MatrixObject*)coord2->coerced_object;
- return row_point_multiplication(coord1, mat);
- }else if(QuaternionObject_Check(coord2->coerced_object)){ //POINT * QUATERNION
- quat = (QuaternionObject*)coord2->coerced_object;
- if(coord1->size != 3){
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Point multiplication: only 3D point rotations (with quats) currently supported\n");
- }
- return quat_rotation((PyObject*)coord1, (PyObject*)quat);
- }
- }
- }
-
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Point multiplication: arguments not acceptable for this operation\n");
-}
-//-------------------------- -obj -------------------------------
-//returns the negative of this object
-static PyObject *Point_neg(PointObject *self)
-{
- int x;
- float coord[3];
-
- for(x = 0; x < self->size; x++)
- coord[x] = -self->coord[x];
-
- return newPointObject(coord, self->size, Py_NEW);
-}
-
-//------------------------coerce(obj, obj)-----------------------
-//coercion of unknown types to type PointObject for numeric protocols
-/*Coercion() is called whenever a math operation has 2 operands that
- it doesn't understand how to evaluate. 2+Matrix for example. We want to
- evaluate some of these operations like: (vector * 2), however, for math
- to proceed, the unknown operand must be cast to a type that python math will
- understand. (e.g. in the case above case, 2 must be cast to a vector and
- then call vector.multiply(vector, scalar_cast_as_vector)*/
-static int Point_coerce(PyObject ** p1, PyObject ** p2)
-{
- if(VectorObject_Check(*p2) || PyFloat_Check(*p2) || PyInt_Check(*p2) ||
- MatrixObject_Check(*p2) || QuaternionObject_Check(*p2)) {
- PyObject *coerced = EXPP_incr_ret(*p2);
- *p2 = newPointObject(NULL,3,Py_NEW);
- ((PointObject*)*p2)->coerced_object = coerced;
- Py_INCREF (*p1);
- return 0;
- }
-
- return EXPP_ReturnIntError(PyExc_TypeError,
- "point.coerce(): unknown operand - can't coerce for numeric protocols");
-}
-//-----------------PROTOCOL DECLARATIONS--------------------------
-static PySequenceMethods Point_SeqMethods = {
- (inquiry) Point_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Point_item, /* sq_item */
- (intintargfunc) Point_slice, /* sq_slice */
- (intobjargproc) Point_ass_item, /* sq_ass_item */
- (intintobjargproc) Point_ass_slice, /* sq_ass_slice */
-};
-static PyNumberMethods Point_NumMethods = {
- (binaryfunc) Point_add, /* __add__ */
- (binaryfunc) Point_sub, /* __sub__ */
- (binaryfunc) Point_mul, /* __mul__ */
- (binaryfunc) 0, /* __div__ */
- (binaryfunc) 0, /* __mod__ */
- (binaryfunc) 0, /* __divmod__ */
- (ternaryfunc) 0, /* __pow__ */
- (unaryfunc) Point_neg, /* __neg__ */
- (unaryfunc) 0, /* __pos__ */
- (unaryfunc) 0, /* __abs__ */
- (inquiry) 0, /* __nonzero__ */
- (unaryfunc) 0, /* __invert__ */
- (binaryfunc) 0, /* __lshift__ */
- (binaryfunc) 0, /* __rshift__ */
- (binaryfunc) 0, /* __and__ */
- (binaryfunc) 0, /* __xor__ */
- (binaryfunc) 0, /* __or__ */
- (coercion) Point_coerce, /* __coerce__ */
- (unaryfunc) 0, /* __int__ */
- (unaryfunc) 0, /* __long__ */
- (unaryfunc) 0, /* __float__ */
- (unaryfunc) 0, /* __oct__ */
- (unaryfunc) 0, /* __hex__ */
-
-};
-//------------------PY_OBECT DEFINITION--------------------------
-PyTypeObject point_Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size */
- "point", /*tp_name */
- sizeof(PointObject), /*tp_basicsize */
- 0, /*tp_itemsize */
- (destructor) Point_dealloc, /*tp_dealloc */
- (printfunc) 0, /*tp_print */
- (getattrfunc) Point_getattr, /*tp_getattr */
- (setattrfunc) Point_setattr, /*tp_setattr */
- 0, /*tp_compare */
- (reprfunc) Point_repr, /*tp_repr */
- &Point_NumMethods, /*tp_as_number */
- &Point_SeqMethods, /*tp_as_sequence */
-};
-//------------------------newPointObject (internal)-------------
-//creates a new point object
-/*pass Py_WRAP - if point is a WRAPPER for data allocated by BLENDER
- (i.e. it was allocated elsewhere by MEM_mallocN())
- pass Py_NEW - if point is not a WRAPPER and managed by PYTHON
- (i.e. it must be created here with PyMEM_malloc())*/
-PyObject *newPointObject(float *coord, int size, int type)
-{
- PointObject *self;
- int x;
-
- point_Type.ob_type = &PyType_Type;
- self = PyObject_NEW(PointObject, &point_Type);
- self->data.blend_data = NULL;
- self->data.py_data = NULL;
- if(size > 3 || size < 2)
- return NULL;
- self->size = size;
- self->coerced_object = NULL;
-
- if(type == Py_WRAP){
- self->data.blend_data = coord;
- self->coord = self->data.blend_data;
- self->wrapped = Py_WRAP;
- }else if (type == Py_NEW){
- self->data.py_data = PyMem_Malloc(size * sizeof(float));
- self->coord = self->data.py_data;
- if(!coord) { //new empty
- for(x = 0; x < size; x++){
- self->coord[x] = 0.0f;
- }
- }else{
- for(x = 0; x < size; x++){
- self->coord[x] = coord[x];
- }
- }
- self->wrapped = Py_NEW;
- }else{ //bad type
- return NULL;
- }
- return (PyObject *) self;
-}
diff --git a/source/blender/python/api2_2x/point.h b/source/blender/python/api2_2x/point.h
deleted file mode 100644
index 4ecceb64491..00000000000
--- a/source/blender/python/api2_2x/point.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * $Id: point.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): Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#ifndef EXPP_point_h
-#define EXPP_point_h
-
-#include <Python.h>
-
-extern PyTypeObject point_Type;
-
-#define PointObject_Check(v) ((v)->ob_type == &point_Type)
-
-typedef struct {
- PyObject_VAR_HEAD
- struct{
- float *py_data; //python managed
- float *blend_data; //blender managed
- }data;
- float *coord; //1D array of data (alias)
- int size;
- int wrapped; //is wrapped data?
- PyObject *coerced_object;
-} PointObject;
-/*coerced_object is a pointer to the object that it was
-coerced from when a dummy vector needs to be created from
-the coerce() function for numeric protocol operations*/
-
-/*struct data contains a pointer to the actual data that the
-object uses. It can use either PyMem allocated data (which will
-be stored in py_data) or be a wrapper for data allocated through
-blender (stored in blend_data). This is an either/or struct not both*/
-
-//prototypes
-PyObject *Point_Zero( PointObject * self );
-PyObject *Point_toVector(PointObject * self);
-PyObject *newPointObject(float *coord, int size, int type);
-
-#endif /* EXPP_point_h */
diff --git a/source/blender/python/api2_2x/quat.c b/source/blender/python/api2_2x/quat.c
deleted file mode 100644
index 19e749f187c..00000000000
--- a/source/blender/python/api2_2x/quat.c
+++ /dev/null
@@ -1,668 +0,0 @@
-/*
- * $Id: quat.c 12314 2007-10-20 20:24:09Z 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 *****
- */
-
-#include "Mathutils.h"
-
-#include "BLI_arithb.h"
-#include "BKE_utildefines.h"
-#include "BLI_blenlib.h"
-#include "gen_utils.h"
-
-
-//-------------------------DOC STRINGS ---------------------------
-char Quaternion_Identity_doc[] = "() - set the quaternion to it's identity (1, vector)";
-char Quaternion_Negate_doc[] = "() - set all values in the quaternion to their negative";
-char Quaternion_Conjugate_doc[] = "() - set the quaternion to it's conjugate";
-char Quaternion_Inverse_doc[] = "() - set the quaternion to it's inverse";
-char Quaternion_Normalize_doc[] = "() - normalize the vector portion of the quaternion";
-char Quaternion_ToEuler_doc[] = "() - return a euler rotation representing the quaternion";
-char Quaternion_ToMatrix_doc[] = "() - return a rotation matrix representing the quaternion";
-char Quaternion_copy_doc[] = "() - return a copy of the quat";
-//-----------------------METHOD DEFINITIONS ----------------------
-struct PyMethodDef Quaternion_methods[] = {
- {"identity", (PyCFunction) Quaternion_Identity, METH_NOARGS, Quaternion_Identity_doc},
- {"negate", (PyCFunction) Quaternion_Negate, METH_NOARGS, Quaternion_Negate_doc},
- {"conjugate", (PyCFunction) Quaternion_Conjugate, METH_NOARGS, Quaternion_Conjugate_doc},
- {"inverse", (PyCFunction) Quaternion_Inverse, METH_NOARGS, Quaternion_Inverse_doc},
- {"normalize", (PyCFunction) Quaternion_Normalize, METH_NOARGS, Quaternion_Normalize_doc},
- {"toEuler", (PyCFunction) Quaternion_ToEuler, METH_NOARGS, Quaternion_ToEuler_doc},
- {"toMatrix", (PyCFunction) Quaternion_ToMatrix, METH_NOARGS, Quaternion_ToMatrix_doc},
- {"__copy__", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc},
- {"copy", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc},
- {NULL, NULL, 0, NULL}
-};
-//-----------------------------METHODS------------------------------
-//----------------------------Quaternion.toEuler()------------------
-//return the quat as a euler
-PyObject *Quaternion_ToEuler(QuaternionObject * self)
-{
- float eul[3];
- int x;
-
- QuatToEul(self->quat, eul);
- for(x = 0; x < 3; x++) {
- eul[x] *= (180 / (float)Py_PI);
- }
- return newEulerObject(eul, Py_NEW);
-}
-//----------------------------Quaternion.toMatrix()------------------
-//return the quat as a matrix
-PyObject *Quaternion_ToMatrix(QuaternionObject * self)
-{
- float mat[9] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
- QuatToMat3(self->quat, (float (*)[3]) mat);
-
- return newMatrixObject(mat, 3, 3, Py_NEW);
-}
-//----------------------------Quaternion.normalize()----------------
-//normalize the axis of rotation of [theta,vector]
-PyObject *Quaternion_Normalize(QuaternionObject * self)
-{
- NormalQuat(self->quat);
- return EXPP_incr_ret((PyObject*)self);
-}
-//----------------------------Quaternion.inverse()------------------
-//invert the quat
-PyObject *Quaternion_Inverse(QuaternionObject * self)
-{
- double mag = 0.0f;
- int x;
-
- for(x = 1; x < 4; x++) {
- self->quat[x] = -self->quat[x];
- }
- for(x = 0; x < 4; x++) {
- mag += (self->quat[x] * self->quat[x]);
- }
- mag = sqrt(mag);
- for(x = 0; x < 4; x++) {
- self->quat[x] /= (float)(mag * mag);
- }
-
- return EXPP_incr_ret((PyObject*)self);
-}
-//----------------------------Quaternion.identity()-----------------
-//generate the identity quaternion
-PyObject *Quaternion_Identity(QuaternionObject * self)
-{
- self->quat[0] = 1.0;
- self->quat[1] = 0.0;
- self->quat[2] = 0.0;
- self->quat[3] = 0.0;
-
- return EXPP_incr_ret((PyObject*)self);
-}
-//----------------------------Quaternion.negate()-------------------
-//negate the quat
-PyObject *Quaternion_Negate(QuaternionObject * self)
-{
- int x;
- for(x = 0; x < 4; x++) {
- self->quat[x] = -self->quat[x];
- }
- return EXPP_incr_ret((PyObject*)self);
-}
-//----------------------------Quaternion.conjugate()----------------
-//negate the vector part
-PyObject *Quaternion_Conjugate(QuaternionObject * self)
-{
- int x;
- for(x = 1; x < 4; x++) {
- self->quat[x] = -self->quat[x];
- }
- return EXPP_incr_ret((PyObject*)self);
-}
-//----------------------------Quaternion.copy()----------------
-//return a copy of the quat
-PyObject *Quaternion_copy(QuaternionObject * self)
-{
- return newQuaternionObject(self->quat, Py_NEW);
-}
-
-//----------------------------dealloc()(internal) ------------------
-//free the py_object
-static void Quaternion_dealloc(QuaternionObject * self)
-{
- Py_XDECREF(self->coerced_object);
- //only free py_data
- if(self->data.py_data){
- PyMem_Free(self->data.py_data);
- }
- PyObject_DEL(self);
-}
-//----------------------------getattr()(internal) ------------------
-//object.attribute access (get)
-static PyObject *Quaternion_getattr(QuaternionObject * self, char *name)
-{
- int x;
- double mag = 0.0f;
- float vec[3];
-
- if(STREQ(name,"w")){
- return PyFloat_FromDouble(self->quat[0]);
- }else if(STREQ(name, "x")){
- return PyFloat_FromDouble(self->quat[1]);
- }else if(STREQ(name, "y")){
- return PyFloat_FromDouble(self->quat[2]);
- }else if(STREQ(name, "z")){
- return PyFloat_FromDouble(self->quat[3]);
- }
- if(STREQ(name, "magnitude")) {
- for(x = 0; x < 4; x++) {
- mag += self->quat[x] * self->quat[x];
- }
- mag = sqrt(mag);
- return PyFloat_FromDouble(mag);
- }
- if(STREQ(name, "angle")) {
- mag = self->quat[0];
- mag = 2 * (acos(mag));
- mag *= (180 / Py_PI);
- return PyFloat_FromDouble(mag);
- }
- if(STREQ(name, "axis")) {
- mag = self->quat[0] * (Py_PI / 180);
- mag = 2 * (acos(mag));
- mag = sin(mag / 2);
- for(x = 0; x < 3; x++) {
- vec[x] = (float)(self->quat[x + 1] / mag);
- }
- Normalize(vec);
- //If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations
- if( EXPP_FloatsAreEqual(vec[0], 0.0f, 10) &&
- EXPP_FloatsAreEqual(vec[1], 0.0f, 10) &&
- EXPP_FloatsAreEqual(vec[2], 0.0f, 10) ){
- vec[0] = 1.0f;
- }
- return (PyObject *) newVectorObject(vec, 3, Py_NEW);
- }
- if(STREQ(name, "wrapped")){
- if(self->wrapped == Py_WRAP)
- return EXPP_incr_ret((PyObject *)Py_True);
- else
- return EXPP_incr_ret((PyObject *)Py_False);
- }
-
- return Py_FindMethod(Quaternion_methods, (PyObject *) self, name);
-}
-//----------------------------setattr()(internal) ------------------
-//object.attribute access (set)
-static int Quaternion_setattr(QuaternionObject * self, char *name, PyObject * q)
-{
- PyObject *f = NULL;
-
- f = PyNumber_Float(q);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnIntError(PyExc_TypeError,
- "quaternion.attribute = x: argument not a number\n");
- }
-
- if(STREQ(name,"w")){
- self->quat[0] = (float)PyFloat_AS_DOUBLE(f);
- }else if(STREQ(name, "x")){
- self->quat[1] = (float)PyFloat_AS_DOUBLE(f);
- }else if(STREQ(name, "y")){
- self->quat[2] = (float)PyFloat_AS_DOUBLE(f);
- }else if(STREQ(name, "z")){
- self->quat[3] = (float)PyFloat_AS_DOUBLE(f);
- }else{
- Py_DECREF(f);
- return EXPP_ReturnIntError(PyExc_AttributeError,
- "quaternion.attribute = x: unknown attribute\n");
- }
-
- Py_DECREF(f);
- return 0;
-}
-//----------------------------print object (internal)--------------
-//print the object to screen
-static PyObject *Quaternion_repr(QuaternionObject * self)
-{
- int i;
- char buffer[48], str[1024];
-
- BLI_strncpy(str,"[",1024);
- for(i = 0; i < 4; i++){
- if(i < (3)){
- sprintf(buffer, "%.6f, ", self->quat[i]);
- strcat(str,buffer);
- }else{
- sprintf(buffer, "%.6f", self->quat[i]);
- strcat(str,buffer);
- }
- }
- strcat(str, "](quaternion)");
-
- return PyString_FromString(str);
-}
-//------------------------tp_richcmpr
-//returns -1 execption, 0 false, 1 true
-static PyObject* Quaternion_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type)
-{
- QuaternionObject *quatA = NULL, *quatB = NULL;
- int result = 0;
-
- if (!QuaternionObject_Check(objectA) || !QuaternionObject_Check(objectB)){
- if (comparison_type == Py_NE){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
- }
- quatA = (QuaternionObject*)objectA;
- quatB = (QuaternionObject*)objectB;
-
- switch (comparison_type){
- case Py_EQ:
- result = EXPP_VectorsAreEqual(quatA->quat, quatB->quat, 4, 1);
- break;
- case Py_NE:
- result = EXPP_VectorsAreEqual(quatA->quat, quatB->quat, 4, 1);
- if (result == 0){
- result = 1;
- }else{
- result = 0;
- }
- break;
- default:
- printf("The result of the comparison could not be evaluated");
- break;
- }
- if (result == 1){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
-}
-//------------------------tp_doc
-static char QuaternionObject_doc[] = "This is a wrapper for quaternion objects.";
-//---------------------SEQUENCE PROTOCOLS------------------------
-//----------------------------len(object)------------------------
-//sequence length
-static int Quaternion_len(QuaternionObject * self)
-{
- return 4;
-}
-//----------------------------object[]---------------------------
-//sequence accessor (get)
-static PyObject *Quaternion_item(QuaternionObject * self, int i)
-{
- if(i < 0 || i >= 4)
- return EXPP_ReturnPyObjError(PyExc_IndexError,
- "quaternion[attribute]: array index out of range\n");
- return PyFloat_FromDouble(self->quat[i]);
-
-}
-//----------------------------object[]-------------------------
-//sequence accessor (set)
-static int Quaternion_ass_item(QuaternionObject * self, int i, PyObject * ob)
-{
- PyObject *f = NULL;
-
- f = PyNumber_Float(ob);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnIntError(PyExc_TypeError,
- "quaternion[attribute] = x: argument not a number\n");
- }
-
- if(i < 0 || i >= 4){
- Py_DECREF(f);
- return EXPP_ReturnIntError(PyExc_IndexError,
- "quaternion[attribute] = x: array assignment index out of range\n");
- }
- self->quat[i] = (float)PyFloat_AS_DOUBLE(f);
- Py_DECREF(f);
- return 0;
-}
-//----------------------------object[z:y]------------------------
-//sequence slice (get)
-static PyObject *Quaternion_slice(QuaternionObject * self, int begin, int end)
-{
- PyObject *list = NULL;
- int count;
-
- CLAMP(begin, 0, 4);
- if (end<0) end= 5+end;
- CLAMP(end, 0, 4);
- begin = MIN2(begin,end);
-
- list = PyList_New(end - begin);
- for(count = begin; count < end; count++) {
- PyList_SetItem(list, count - begin,
- PyFloat_FromDouble(self->quat[count]));
- }
-
- return list;
-}
-//----------------------------object[z:y]------------------------
-//sequence slice (set)
-static int Quaternion_ass_slice(QuaternionObject * self, int begin, int end,
- PyObject * seq)
-{
- int i, y, size = 0;
- float quat[4];
- PyObject *q, *f;
-
- CLAMP(begin, 0, 4);
- if (end<0) end= 5+end;
- CLAMP(end, 0, 4);
- begin = MIN2(begin,end);
-
- size = PySequence_Length(seq);
- if(size != (end - begin)){
- return EXPP_ReturnIntError(PyExc_TypeError,
- "quaternion[begin:end] = []: size mismatch in slice assignment\n");
- }
-
- for (i = 0; i < size; i++) {
- q = PySequence_GetItem(seq, i);
- if (q == NULL) { // Failed to read sequence
- return EXPP_ReturnIntError(PyExc_RuntimeError,
- "quaternion[begin:end] = []: unable to read sequence\n");
- }
-
- f = PyNumber_Float(q);
- if(f == NULL) { // parsed item not a number
- Py_DECREF(q);
- return EXPP_ReturnIntError(PyExc_TypeError,
- "quaternion[begin:end] = []: sequence argument not a number\n");
- }
-
- quat[i] = (float)PyFloat_AS_DOUBLE(f);
- EXPP_decr2(f,q);
- }
- //parsed well - now set in vector
- for(y = 0; y < size; y++){
- self->quat[begin + y] = quat[y];
- }
- return 0;
-}
-//------------------------NUMERIC PROTOCOLS----------------------
-//------------------------obj + obj------------------------------
-//addition
-static PyObject *Quaternion_add(PyObject * q1, PyObject * q2)
-{
- int x;
- float quat[4];
- QuaternionObject *quat1 = NULL, *quat2 = NULL;
-
- quat1 = (QuaternionObject*)q1;
- quat2 = (QuaternionObject*)q2;
-
- if(quat1->coerced_object || quat2->coerced_object){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Quaternion addition: arguments not valid for this operation....\n");
- }
- for(x = 0; x < 4; x++) {
- quat[x] = quat1->quat[x] + quat2->quat[x];
- }
-
- return newQuaternionObject(quat, Py_NEW);
-}
-//------------------------obj - obj------------------------------
-//subtraction
-static PyObject *Quaternion_sub(PyObject * q1, PyObject * q2)
-{
- int x;
- float quat[4];
- QuaternionObject *quat1 = NULL, *quat2 = NULL;
-
- quat1 = (QuaternionObject*)q1;
- quat2 = (QuaternionObject*)q2;
-
- if(quat1->coerced_object || quat2->coerced_object){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Quaternion addition: arguments not valid for this operation....\n");
- }
- for(x = 0; x < 4; x++) {
- quat[x] = quat1->quat[x] - quat2->quat[x];
- }
-
- return newQuaternionObject(quat, Py_NEW);
-}
-//------------------------obj * obj------------------------------
-//mulplication
-static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2)
-{
- int x;
- float quat[4], scalar;
- double dot = 0.0f;
- QuaternionObject *quat1 = NULL, *quat2 = NULL;
- PyObject *f = NULL;
- VectorObject *vec = NULL;
- PointObject *pt = NULL;
-
- quat1 = (QuaternionObject*)q1;
- quat2 = (QuaternionObject*)q2;
-
- if(quat1->coerced_object){
- if (PyFloat_Check(quat1->coerced_object) ||
- PyInt_Check(quat1->coerced_object)){ // FLOAT/INT * QUAT
- f = PyNumber_Float(quat1->coerced_object);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Quaternion multiplication: arguments not acceptable for this operation\n");
- }
-
- scalar = (float)PyFloat_AS_DOUBLE(f);
- Py_DECREF(f);
- for(x = 0; x < 4; x++) {
- quat[x] = quat2->quat[x] * scalar;
- }
- return newQuaternionObject(quat, Py_NEW);
- }
- }else{
- if(quat2->coerced_object){
- if (PyFloat_Check(quat2->coerced_object) ||
- PyInt_Check(quat2->coerced_object)){ // QUAT * FLOAT/INT
- f = PyNumber_Float(quat2->coerced_object);
- if(f == NULL) { // parsed item not a number
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Quaternion multiplication: arguments not acceptable for this operation\n");
- }
-
- scalar = (float)PyFloat_AS_DOUBLE(f);
- Py_DECREF(f);
- for(x = 0; x < 4; x++) {
- quat[x] = quat1->quat[x] * scalar;
- }
- return newQuaternionObject(quat, Py_NEW);
- }else if(VectorObject_Check(quat2->coerced_object)){ //QUAT * VEC
- vec = (VectorObject*)quat2->coerced_object;
- if(vec->size != 3){
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Quaternion multiplication: only 3D vector rotations currently supported\n");
- }
- return quat_rotation((PyObject*)quat1, (PyObject*)vec);
- }else if(PointObject_Check(quat2->coerced_object)){ //QUAT * POINT
- pt = (PointObject*)quat2->coerced_object;
- if(pt->size != 3){
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Quaternion multiplication: only 3D point rotations currently supported\n");
- }
- return quat_rotation((PyObject*)quat1, (PyObject*)pt);
- }
- }else{ //QUAT * QUAT (dot product)
- for(x = 0; x < 4; x++) {
- dot += quat1->quat[x] * quat1->quat[x];
- }
- return PyFloat_FromDouble(dot);
- }
- }
-
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Quaternion multiplication: arguments not acceptable for this operation\n");
-}
-//------------------------coerce(obj, obj)-----------------------
-//coercion of unknown types to type QuaternionObject for numeric protocols
-/*Coercion() is called whenever a math operation has 2 operands that
- it doesn't understand how to evaluate. 2+Matrix for example. We want to
- evaluate some of these operations like: (vector * 2), however, for math
- to proceed, the unknown operand must be cast to a type that python math will
- understand. (e.g. in the case above case, 2 must be cast to a vector and
- then call vector.multiply(vector, scalar_cast_as_vector)*/
-static int Quaternion_coerce(PyObject ** q1, PyObject ** q2)
-{
- if(VectorObject_Check(*q2) || PyFloat_Check(*q2) || PyInt_Check(*q2) ||
- PointObject_Check(*q2)) {
- PyObject *coerced = EXPP_incr_ret(*q2);
- *q2 = newQuaternionObject(NULL,Py_NEW);
- ((QuaternionObject*)*q2)->coerced_object = coerced;
- Py_INCREF (*q1);
- return 0;
- }
-
- return EXPP_ReturnIntError(PyExc_TypeError,
- "quaternion.coerce(): unknown operand - can't coerce for numeric protocols");
-}
-//-----------------PROTOCOL DECLARATIONS--------------------------
-static PySequenceMethods Quaternion_SeqMethods = {
- (inquiry) Quaternion_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Quaternion_item, /* sq_item */
- (intintargfunc) Quaternion_slice, /* sq_slice */
- (intobjargproc) Quaternion_ass_item, /* sq_ass_item */
- (intintobjargproc) Quaternion_ass_slice, /* sq_ass_slice */
-};
-static PyNumberMethods Quaternion_NumMethods = {
- (binaryfunc) Quaternion_add, /* __add__ */
- (binaryfunc) Quaternion_sub, /* __sub__ */
- (binaryfunc) Quaternion_mul, /* __mul__ */
- (binaryfunc) 0, /* __div__ */
- (binaryfunc) 0, /* __mod__ */
- (binaryfunc) 0, /* __divmod__ */
- (ternaryfunc) 0, /* __pow__ */
- (unaryfunc) 0, /* __neg__ */
- (unaryfunc) 0, /* __pos__ */
- (unaryfunc) 0, /* __abs__ */
- (inquiry) 0, /* __nonzero__ */
- (unaryfunc) 0, /* __invert__ */
- (binaryfunc) 0, /* __lshift__ */
- (binaryfunc) 0, /* __rshift__ */
- (binaryfunc) 0, /* __and__ */
- (binaryfunc) 0, /* __xor__ */
- (binaryfunc) 0, /* __or__ */
- (coercion) Quaternion_coerce, /* __coerce__ */
- (unaryfunc) 0, /* __int__ */
- (unaryfunc) 0, /* __long__ */
- (unaryfunc) 0, /* __float__ */
- (unaryfunc) 0, /* __oct__ */
- (unaryfunc) 0, /* __hex__ */
-
-};
-//------------------PY_OBECT DEFINITION--------------------------
-PyTypeObject quaternion_Type = {
-PyObject_HEAD_INIT(NULL) //tp_head
- 0, //tp_internal
- "quaternion", //tp_name
- sizeof(QuaternionObject), //tp_basicsize
- 0, //tp_itemsize
- (destructor)Quaternion_dealloc, //tp_dealloc
- 0, //tp_print
- (getattrfunc)Quaternion_getattr, //tp_getattr
- (setattrfunc) Quaternion_setattr, //tp_setattr
- 0, //tp_compare
- (reprfunc) Quaternion_repr, //tp_repr
- &Quaternion_NumMethods, //tp_as_number
- &Quaternion_SeqMethods, //tp_as_sequence
- 0, //tp_as_mapping
- 0, //tp_hash
- 0, //tp_call
- 0, //tp_str
- 0, //tp_getattro
- 0, //tp_setattro
- 0, //tp_as_buffer
- Py_TPFLAGS_DEFAULT, //tp_flags
- QuaternionObject_doc, //tp_doc
- 0, //tp_traverse
- 0, //tp_clear
- (richcmpfunc)Quaternion_richcmpr, //tp_richcompare
- 0, //tp_weaklistoffset
- 0, //tp_iter
- 0, //tp_iternext
- 0, //tp_methods
- 0, //tp_members
- 0, //tp_getset
- 0, //tp_base
- 0, //tp_dict
- 0, //tp_descr_get
- 0, //tp_descr_set
- 0, //tp_dictoffset
- 0, //tp_init
- 0, //tp_alloc
- 0, //tp_new
- 0, //tp_free
- 0, //tp_is_gc
- 0, //tp_bases
- 0, //tp_mro
- 0, //tp_cache
- 0, //tp_subclasses
- 0, //tp_weaklist
- 0 //tp_del
-};
-//------------------------newQuaternionObject (internal)-------------
-//creates a new quaternion object
-/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
- (i.e. it was allocated elsewhere by MEM_mallocN())
- pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
- (i.e. it must be created here with PyMEM_malloc())*/
-PyObject *newQuaternionObject(float *quat, int type)
-{
- QuaternionObject *self;
- int x;
-
- self = PyObject_NEW(QuaternionObject, &quaternion_Type);
- self->data.blend_data = NULL;
- self->data.py_data = NULL;
- self->coerced_object = NULL;
-
- if(type == Py_WRAP){
- self->data.blend_data = quat;
- self->quat = self->data.blend_data;
- self->wrapped = Py_WRAP;
- }else if (type == Py_NEW){
- self->data.py_data = PyMem_Malloc(4 * sizeof(float));
- self->quat = self->data.py_data;
- if(!quat) { //new empty
- Quaternion_Identity(self);
- Py_DECREF(self);
- }else{
- for(x = 0; x < 4; x++){
- self->quat[x] = quat[x];
- }
- }
- self->wrapped = Py_NEW;
- }else{ //bad type
- return NULL;
- }
- return (PyObject *) self;
-}
diff --git a/source/blender/python/api2_2x/quat.h b/source/blender/python/api2_2x/quat.h
deleted file mode 100644
index c66300de498..00000000000
--- a/source/blender/python/api2_2x/quat.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * $Id: quat.h 8367 2006-08-22 09:13:44Z 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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- *
- */
-
-#ifndef EXPP_quat_h
-#define EXPP_quat_h
-
-#include <Python.h>
-
-extern PyTypeObject quaternion_Type;
-
-#define QuaternionObject_Check(v) ((v)->ob_type == &quaternion_Type)
-
-typedef struct {
- PyObject_VAR_HEAD
- struct{
- float *py_data; //python managed
- float *blend_data; //blender managed
- }data;
- float *quat; //1D array of data (alias)
- int wrapped; //is wrapped data?
- PyObject *coerced_object;
-} QuaternionObject;
-/*coerced_object is a pointer to the object that it was
-coerced from when a dummy vector needs to be created from
-the coerce() function for numeric protocol operations*/
-
-/*struct data contains a pointer to the actual data that the
-object uses. It can use either PyMem allocated data (which will
-be stored in py_data) or be a wrapper for data allocated through
-blender (stored in blend_data). This is an either/or struct not both*/
-
-//prototypes
-PyObject *Quaternion_Identity( QuaternionObject * self );
-PyObject *Quaternion_Negate( QuaternionObject * self );
-PyObject *Quaternion_Conjugate( QuaternionObject * self );
-PyObject *Quaternion_Inverse( QuaternionObject * self );
-PyObject *Quaternion_Normalize( QuaternionObject * self );
-PyObject *Quaternion_ToEuler( QuaternionObject * self );
-PyObject *Quaternion_ToMatrix( QuaternionObject * self );
-PyObject *Quaternion_copy( QuaternionObject * self );
-PyObject *newQuaternionObject( float *quat, int type );
-
-#endif /* EXPP_quat_h */
diff --git a/source/blender/python/api2_2x/rgbTuple.c b/source/blender/python/api2_2x/rgbTuple.c
deleted file mode 100644
index 85fa26433fc..00000000000
--- a/source/blender/python/api2_2x/rgbTuple.c
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * $Id: rgbTuple.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
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include "rgbTuple.h" /*This must come first */
-
-#include "gen_utils.h"
-
-/* This file is heavily based on the old bpython Constant object code in
- Blender */
-
-/*****************************************************************************/
-/* Python rgbTuple_Type callback function prototypes: */
-/*****************************************************************************/
-static PyObject *rgbTuple_getAttr( BPy_rgbTuple * self, char *name );
-static int rgbTuple_setAttr( BPy_rgbTuple * self, char *name, PyObject * v );
-static PyObject *rgbTuple_repr( BPy_rgbTuple * self );
-
-static int rgbTupleLength( void );
-
-static PyObject *rgbTupleSubscript( BPy_rgbTuple * self, PyObject * key );
-static int rgbTupleAssSubscript( BPy_rgbTuple * self, PyObject * who,
- PyObject * cares );
-
-static PyObject *rgbTupleItem( BPy_rgbTuple * self, int i );
-static int rgbTupleAssItem( BPy_rgbTuple * self, int i, PyObject * ob );
-static PyObject *rgbTupleSlice( BPy_rgbTuple * self, int begin, int end );
-static int rgbTupleAssSlice( BPy_rgbTuple * self, int begin, int end,
- PyObject * seq );
-
-/*****************************************************************************/
-/* Python rgbTuple_Type Mapping Methods table: */
-/*****************************************************************************/
-static PyMappingMethods rgbTupleAsMapping = {
- ( inquiry ) rgbTupleLength, /* mp_length */
- ( binaryfunc ) rgbTupleSubscript, /* mp_subscript */
- ( objobjargproc ) rgbTupleAssSubscript, /* mp_ass_subscript */
-};
-
-/*****************************************************************************/
-/* Python rgbTuple_Type Sequence Methods table: */
-/*****************************************************************************/
-static PySequenceMethods rgbTupleAsSequence = {
- ( inquiry ) rgbTupleLength, /* sq_length */
- ( binaryfunc ) 0, /* sq_concat */
- ( intargfunc ) 0, /* sq_repeat */
- ( intargfunc ) rgbTupleItem, /* sq_item */
- ( intintargfunc ) rgbTupleSlice, /* sq_slice */
- ( intobjargproc ) rgbTupleAssItem, /* sq_ass_item */
- ( intintobjargproc ) rgbTupleAssSlice, /* sq_ass_slice */
- 0,0,0
-};
-
-/*****************************************************************************/
-/* Python rgbTuple_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject rgbTuple_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
- "rgbTuple", /* tp_name */
- sizeof( BPy_rgbTuple ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) rgbTuple_getAttr, /* tp_getattr */
- ( setattrfunc ) rgbTuple_setAttr, /* tp_setattr */
- 0, /* tp_compare */
- ( reprfunc ) rgbTuple_repr, /* tp_repr */
- 0, /* tp_as_number */
- &rgbTupleAsSequence, /* tp_as_sequence */
- &rgbTupleAsMapping, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0, 0, 0, 0, 0, Py_TPFLAGS_DEFAULT,
- 0, /* tp_doc */
- 0, 0, 0, 0, 0, 0,
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* 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
-};
-
-/*****************************************************************************/
-/* Function: rgbTuple_New */
-/*****************************************************************************/
-PyObject *rgbTuple_New( float *rgb[3] )
-{
- BPy_rgbTuple *rgbTuple = PyObject_NEW( BPy_rgbTuple, &rgbTuple_Type );
-
- if( rgbTuple == NULL )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create rgbTuple object" );
-
- rgbTuple->rgb[0] = rgb[0];
- rgbTuple->rgb[1] = rgb[1];
- rgbTuple->rgb[2] = rgb[2];
-
- return ( PyObject * ) rgbTuple;
-}
-
-/*****************************************************************************/
-/* Functions: rgbTuple_getCol and rgbTuple_setCol */
-/* Description: These functions get/set rgb color triplet values. The */
-/* get function returns a tuple, the set one accepts three */
-/* floats (separated or in a tuple) as arguments. */
-/*****************************************************************************/
-PyObject *rgbTuple_getCol( BPy_rgbTuple * self )
-{
- return Py_BuildValue( "[fff]", *(self->rgb[0]),
- *(self->rgb[1]), *(self->rgb[2]));
-}
-
-int rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args )
-{
- int ok = 0;
- int i;
- float num[3]={0,0,0};
-
- /*
- * since rgbTuple_getCol() returns a list, be sure we accept a list
- * as valid input
- */
-
- if( PyObject_Length( args ) == 3 ) {
- if ( PyList_Check ( args ) ) {
- ok = 1;
- for( i = 0; i < 3; ++i ) {
- PyObject *tmp = PyList_GET_ITEM( args, i );
- if( !PyNumber_Check ( tmp ) ) {
- ok = 0;
- break;
- }
- num[i] = (float)PyFloat_AsDouble( tmp );
- }
- } else
- ok = PyArg_ParseTuple( args, "fff", &num[0], &num[1], &num[2] );
- } else
- ok = PyArg_ParseTuple( args, "|(fff)", &num[0], &num[1], &num[2] );
-
- if( !ok )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected [f,f,f], (f,f,f) or f,f,f as arguments (or nothing)" );
-
- for( i = 0; i < 3; ++i )
- *( self->rgb[i] ) = EXPP_ClampFloat( num[i], 0.0, 1.0 );
-
- return 0;
-}
-
-/*****************************************************************************/
-/* Function: rgbTuple_getAttr */
-/* Description: This is a callback function for the BPy_rgbTuple type. It is */
-/* the function that accesses BPy_rgbTuple member variables and */
-/* methods. */
-/*****************************************************************************/
-static PyObject *rgbTuple_getAttr( BPy_rgbTuple * self, char *name )
-{
- int i;
-
- if( strcmp( name, "__members__" ) == 0 )
- return Py_BuildValue( "[s,s,s]", "R", "G", "B" );
-
- else if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
- i = 0;
- else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
- i = 1;
- else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
- i = 2;
- else
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "attribute not found" ) );
-
- return PyFloat_FromDouble( (double)(*( self->rgb[i] )) );
-}
-
-/*****************************************************************************/
-/* Function: rgbTuple_setAttr */
-/* Description: This is a callback function for the BPy_rgbTuple type. It is */
-/* the function that changes BPy_rgbTuple member variables. */
-/*****************************************************************************/
-static int rgbTuple_setAttr( BPy_rgbTuple * self, char *name, PyObject * v )
-{
- float value;
-
- if( !PyArg_Parse( v, "f", &value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
-
- value = EXPP_ClampFloat( value, 0.0, 1.0 );
-
- if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
- *( self->rgb[0] ) = value;
-
- else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
- *( self->rgb[1] ) = value;
-
- else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
- *( self->rgb[2] ) = value;
-
- else
- return ( EXPP_ReturnIntError( PyExc_AttributeError,
- "attribute not found" ) );
-
- return 0;
-}
-
-/*****************************************************************************/
-/* Section: rgbTuple as Mapping */
-/* These functions provide code to access rgbTuple objects as */
-/* mappings. */
-/*****************************************************************************/
-static int rgbTupleLength( void )
-{
- return 3;
-}
-
-static PyObject *rgbTupleSubscript( BPy_rgbTuple * self, PyObject * key )
-{
- char *name = NULL;
- int i;
-
- if( PyNumber_Check( key ) )
- return rgbTupleItem( self, ( int ) PyInt_AsLong( key ) );
-
- if( !PyArg_ParseTuple( key, "s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int or string argument" );
-
- if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
- i = 0;
- else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
- i = 1;
- else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
- i = 2;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
-
- return PyFloat_FromDouble( (double)(*( self->rgb[i] )) );
-}
-
-static int rgbTupleAssSubscript( BPy_rgbTuple * self, PyObject * key,
- PyObject * v )
-{
- char *name = NULL;
- int i;
-
- if( !PyNumber_Check( v ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "value to assign must be a number" );
-
- if( PyNumber_Check( key ) )
- return rgbTupleAssItem( self, ( int ) PyInt_AsLong( key ), v );
-
- if( !PyArg_Parse( key, "s", &name ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int or string argument" );
-
- if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
- i = 0;
- else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
- i = 1;
- else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
- i = 2;
- else
- return EXPP_ReturnIntError( PyExc_AttributeError, name );
-
- *( self->rgb[i] ) = EXPP_ClampFloat( (float)PyFloat_AsDouble( v ), 0.0, 1.0 );
-
- return 0;
-}
-
-/*****************************************************************************/
-/* Section: rgbTuple as Sequence */
-/* These functions provide code to access rgbTuple objects as */
-/* sequences. */
-/*****************************************************************************/
-static PyObject *rgbTupleItem( BPy_rgbTuple * self, int i )
-{
- if( i < 0 || i >= 3 )
- return EXPP_ReturnPyObjError( PyExc_IndexError,
- "array index out of range" );
-
- return PyFloat_FromDouble( (long)(*( self->rgb[i] )) );
-}
-
-static PyObject *rgbTupleSlice( BPy_rgbTuple * self, int begin, int end )
-{
- PyObject *list;
- int count;
-
- if( begin < 0 )
- begin = 0;
- if( end > 3 )
- end = 3;
- if( begin > end )
- begin = end;
-
- list = PyList_New( end - begin );
-
- for( count = begin; count < end; count++ )
- PyList_SetItem( list, count - begin,
- PyFloat_FromDouble( *( self->rgb[count] ) ) );
-
- return list;
-}
-
-static int rgbTupleAssItem( BPy_rgbTuple * self, int i, PyObject * ob )
-{
- if( i < 0 || i >= 3 )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "array assignment index out of range" );
-
- if( !PyNumber_Check( ob ) )
- return EXPP_ReturnIntError( PyExc_IndexError,
- "color component must be a number" );
-/* XXX this check above is probably ... */
- *( self->rgb[i] ) =
- EXPP_ClampFloat( (float)PyFloat_AsDouble( ob ), 0.0, 1.0 );
-
- return 0;
-}
-
-static int rgbTupleAssSlice( BPy_rgbTuple * self, int begin, int end,
- PyObject * seq )
-{
- int count;
-
- if( begin < 0 )
- begin = 0;
- if( end > 3 )
- end = 3;
- if( begin > end )
- begin = end;
-
- if( !PySequence_Check( seq ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "illegal argument type for built-in operation" );
-
- if( PySequence_Length( seq ) != ( end - begin ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "size mismatch in slice assignment" );
-
- for( count = begin; count < end; count++ ) {
- float value;
- PyObject *ob = PySequence_GetItem( seq, count );
-
- if( !PyArg_Parse( ob, "f", &value ) ) {
- Py_DECREF( ob );
- return -1;
- }
-
- *( self->rgb[count] ) = EXPP_ClampFloat( value, 0.0, 1.0 );
-
- Py_DECREF( ob );
- }
-
- return 0;
-}
-
-/*****************************************************************************/
-/* Function: rgbTuple_repr */
-/* Description: This is a callback function for the BPy_rgbTuple type. It */
-/* builds a meaninful string to represent rgbTuple objects. */
-/*****************************************************************************/
-static PyObject *rgbTuple_repr( BPy_rgbTuple * self )
-{
- float r, g, b;
-
- r = *( self->rgb[0] );
- g = *( self->rgb[1] );
- b = *( self->rgb[2] );
-
- return PyString_FromFormat( "[%f, %f, %f]", r, g, b );
-}
diff --git a/source/blender/python/api2_2x/rgbTuple.h b/source/blender/python/api2_2x/rgbTuple.h
deleted file mode 100644
index 59c0f02643f..00000000000
--- a/source/blender/python/api2_2x/rgbTuple.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * $Id: rgbTuple.h 5317 2005-09-21 19:48: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 *****
-*/
-
-#ifndef EXPP_rgbTuple_H
-#define EXPP_rgbTuple_H
-
-#include <Python.h>
-
-/* Objects of <type 'rgbTuple'> are used inside other Blender Python
- * objects, so this header file must contain only 'public' declarations */
-
-/*****************************************************************************/
-/* Python BPy_rgbTuple structure definition: */
-/*****************************************************************************/
-typedef struct {
- PyObject_HEAD float *rgb[3]; /* array of three pointers to floats */
-
-} BPy_rgbTuple;
-
-/*****************************************************************************/
-/* Python API function prototypes for the rgbTuple helper module. */
-/*****************************************************************************/
-PyObject *rgbTuple_New( float *rgb[3] );
-PyObject *rgbTuple_getCol( BPy_rgbTuple * self );
-int rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args );
-
-#endif /* EXPP_rgbTuple_H */
diff --git a/source/blender/python/api2_2x/sceneRadio.c b/source/blender/python/api2_2x/sceneRadio.c
deleted file mode 100644
index a39186b8e28..00000000000
--- a/source/blender/python/api2_2x/sceneRadio.c
+++ /dev/null
@@ -1,893 +0,0 @@
-/*
- * $Id: sceneRadio.c 10270 2007-03-15 01:47: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): Willian P. Germano
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#include "sceneRadio.h" /*This must come first*/
-
-#include "BKE_global.h"
-#include "BKE_object.h" /* disable_where_script() */
-#include "gen_utils.h"
-#include "constant.h"
-#include "radio.h"
-
-
-/* bitflags */
-#define EXPP_RADIO_flag_SHOWLIM 1
-#define EXPP_RADIO_flag_Z 2
-/* shorts */
-#define EXPP_RADIO_hemires_MIN 100
-#define EXPP_RADIO_hemires_MAX 1000
-#define EXPP_RADIO_maxiter_MIN 0
-#define EXPP_RADIO_maxiter_MAX 10000
-#define EXPP_RADIO_subshootp_MIN 0
-#define EXPP_RADIO_subshootp_MAX 10
-#define EXPP_RADIO_subshoote_MIN 0
-#define EXPP_RADIO_subshoote_MAX 10
-#define EXPP_RADIO_nodelim_MIN 0
-#define EXPP_RADIO_nodelim_MAX 50
-#define EXPP_RADIO_maxsublamp_MIN 1
-#define EXPP_RADIO_maxsublamp_MAX 250
-#define EXPP_RADIO_pama_MIN 10
-#define EXPP_RADIO_pama_MAX 1000
-#define EXPP_RADIO_pami_MIN 10
-#define EXPP_RADIO_pami_MAX 1000
-#define EXPP_RADIO_elma_MIN 1
-#define EXPP_RADIO_elma_MAX 500
-#define EXPP_RADIO_elmi_MIN 1
-#define EXPP_RADIO_elmi_MAX 100
-/* ints */
-#define EXPP_RADIO_maxnode_MIN 1
-#define EXPP_RADIO_maxnode_MAX 250000
-/* floats */
-#define EXPP_RADIO_convergence_MIN 0.0
-#define EXPP_RADIO_convergence_MAX 0.1f
-#define EXPP_RADIO_radfac_MIN 0.001f
-#define EXPP_RADIO_radfac_MAX 250.0
-#define EXPP_RADIO_gamma_MIN 0.2f
-#define EXPP_RADIO_gamma_MAX 10.0
-/* drawtypes */
-#define EXPP_RADIO_drawtype_WIRE 0
-#define EXPP_RADIO_drawtype_SOLID 1
-#define EXPP_RADIO_drawtype_GOURAUD 2
-
-static int EXPP_check_scene( Scene * scene )
-{
- if( scene != G.scene ) {
- PyErr_SetString( PyExc_EnvironmentError,
- "\nradiosity only works on the current scene, check scene.makeCurrent()." );
- return 0;
- } else if( !scene->radio ) {
- PyErr_SetString( PyExc_EnvironmentError,
- "\nradiosity data was deleted from scene!" );
- return 0;
- }
-
- return 1;
-}
-
-static PyObject *Radio_collectMeshes( BPy_Radio * self );
-static PyObject *Radio_go( BPy_Radio * self );
-static PyObject *Radio_freeData( BPy_Radio * self );
-static PyObject *Radio_replaceMeshes( BPy_Radio * self );
-static PyObject *Radio_addMesh( BPy_Radio * self );
-static PyObject *Radio_filterFaces( BPy_Radio * self );
-static PyObject *Radio_filterElems( BPy_Radio * self );
-static PyObject *Radio_limitSubdivide( BPy_Radio * self );
-static PyObject *Radio_subdividePatches( BPy_Radio * self );
-static PyObject *Radio_subdivideElems( BPy_Radio * self );
-static PyObject *Radio_removeDoubles( BPy_Radio * self );
-
-static PyObject *Radio_repr( BPy_Radio * self );
-
-static PyObject *EXPP_create_ret_PyInt( int value )
-{
- PyObject *pyval = PyInt_FromLong( value );
-
- if( !pyval )
- PyErr_SetString( PyExc_MemoryError,
- "couldn't create py int!" );
-
- return pyval;
-}
-
-static PyObject *EXPP_create_ret_PyFloat( float value )
-{
- PyObject *pyval = PyFloat_FromDouble( ( double ) value );
-
- if( !pyval )
- PyErr_SetString( PyExc_MemoryError,
- "couldn't create py int!" );
-
- return pyval;
-}
-
-static PyObject *Radio_get_hemires( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->hemires );
-}
-
-static PyObject *Radio_get_maxiter( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->maxiter );
-}
-
-static PyObject *Radio_get_subshootp( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->subshootp );
-}
-
-static PyObject *Radio_get_subshoote( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->subshoote );
-}
-
-static PyObject *Radio_get_nodelim( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->nodelim );
-}
-
-static PyObject *Radio_get_maxsublamp( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->maxsublamp );
-}
-
-static PyObject *Radio_get_pama( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->pama );
-}
-
-static PyObject *Radio_get_pami( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->pami );
-}
-
-static PyObject *Radio_get_elma( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->elma );
-}
-
-static PyObject *Radio_get_elmi( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->elmi );
-}
-
-static PyObject *Radio_get_drawtype( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->drawtype );
-}
-
-static PyObject *Radio_get_flag( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->flag );
-}
-
-static PyObject *Radio_get_maxnode( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyInt( ( int ) self->scene->radio->maxnode );
-}
-
-static PyObject *Radio_get_convergence( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyFloat( self->scene->radio->convergence );
-}
-
-static PyObject *Radio_get_radfac( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyFloat( self->scene->radio->radfac );
-}
-
-static PyObject *Radio_get_gamma( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_create_ret_PyFloat( self->scene->radio->gamma );
-}
-
-static PyObject *EXPP_unpack_set_int( PyObject * args, int *ptr,
- int min, int max )
-{
- int value;
-
- if( !PyArg_ParseTuple( args, "i", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
-
- *ptr = EXPP_ClampInt( value, min, max );
-
- return EXPP_incr_ret( Py_None );
-}
-
-/* could merge with set_int, but is cleaner this way */
-static PyObject *EXPP_unpack_set_short( PyObject * args, short *ptr,
- short min, short max )
-{
- int value;
-
- if( !PyArg_ParseTuple( args, "i", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
-
- *ptr = ( short ) EXPP_ClampInt( value, min, max );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *EXPP_unpack_set_float( PyObject * args, float *ptr,
- float min, float max )
-{
- float value;
-
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected float argument" );
-
- *ptr = EXPP_ClampFloat( value, min, max );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_set_hemires( BPy_Radio * self, PyObject * args )
-{
- PyObject *ret;
-
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- ret = EXPP_unpack_set_short( args, &self->scene->radio->hemires,
- EXPP_RADIO_hemires_MIN,
- EXPP_RADIO_hemires_MAX );
-
- if( ret )
- rad_setlimits( );
-
- return ret;
-}
-
-static PyObject *Radio_set_maxiter( BPy_Radio * self, PyObject * args )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_unpack_set_short( args, &self->scene->radio->maxiter,
- EXPP_RADIO_maxiter_MIN,
- EXPP_RADIO_maxiter_MAX );
-}
-
-static PyObject *Radio_set_subshootp( BPy_Radio * self, PyObject * args )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_unpack_set_short( args, &self->scene->radio->subshootp,
- EXPP_RADIO_subshootp_MIN,
- EXPP_RADIO_subshootp_MAX );
-}
-
-static PyObject *Radio_set_subshoote( BPy_Radio * self, PyObject * args )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_unpack_set_short( args, &self->scene->radio->subshoote,
- EXPP_RADIO_subshoote_MIN,
- EXPP_RADIO_subshoote_MAX );
-}
-
-static PyObject *Radio_set_nodelim( BPy_Radio * self, PyObject * args )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_unpack_set_short( args, &self->scene->radio->nodelim,
- EXPP_RADIO_nodelim_MIN,
- EXPP_RADIO_nodelim_MAX );
-}
-
-static PyObject *Radio_set_maxsublamp( BPy_Radio * self, PyObject * args )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_unpack_set_short( args, &self->scene->radio->maxsublamp,
- EXPP_RADIO_maxsublamp_MIN,
- EXPP_RADIO_maxsublamp_MAX );
-}
-
-static PyObject *Radio_set_pama( BPy_Radio * self, PyObject * args )
-{
- PyObject *ret;
-
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- ret = EXPP_unpack_set_short( args, &self->scene->radio->pama,
- EXPP_RADIO_pama_MIN,
- EXPP_RADIO_pama_MAX );
-
- if( ret )
- rad_setlimits( );
-
- return ret;
-}
-
-static PyObject *Radio_set_pami( BPy_Radio * self, PyObject * args )
-{
- PyObject *ret;
-
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- ret = EXPP_unpack_set_short( args, &self->scene->radio->pami,
- EXPP_RADIO_pami_MIN,
- EXPP_RADIO_pami_MAX );
-
- if( ret )
- rad_setlimits( );
-
- return ret;
-}
-
-static PyObject *Radio_set_elma( BPy_Radio * self, PyObject * args )
-{
- PyObject *ret;
-
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- ret = EXPP_unpack_set_short( args, &self->scene->radio->elma,
- EXPP_RADIO_elma_MIN,
- EXPP_RADIO_elma_MAX );
-
- if( ret )
- rad_setlimits( );
-
- return ret;
-}
-
-static PyObject *Radio_set_elmi( BPy_Radio * self, PyObject * args )
-{
- PyObject *ret;
-
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- ret = EXPP_unpack_set_short( args, &self->scene->radio->elmi,
- EXPP_RADIO_elmi_MIN,
- EXPP_RADIO_elmi_MAX );
-
- if( ret )
- rad_setlimits( );
-
- return ret;
-}
-
-static PyObject *Radio_set_drawtype( BPy_Radio * self, PyObject * args )
-{
- PyObject *pyob = NULL;
- char *str = NULL;
- short dt = EXPP_RADIO_drawtype_WIRE;
-
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( !PyArg_ParseTuple( args, "O", &pyob ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int or string and another optional int as arguments" );
-
- if( PyString_Check( pyob ) ) {
- str = PyString_AsString( pyob );
- if( !str )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create py string!" );
- else if( !strcmp( str, "Wire" ) )
- dt = EXPP_RADIO_drawtype_WIRE;
- else if( !strcmp( str, "Solid" ) )
- dt = EXPP_RADIO_drawtype_SOLID;
- else if( !strcmp( str, "Gouraud" ) )
- dt = EXPP_RADIO_drawtype_GOURAUD;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown drawtype string" );
- } else if( PyInt_Check( pyob ) ) {
- dt = ( short ) EXPP_ClampInt( PyInt_AsLong( pyob ),
- EXPP_RADIO_drawtype_WIRE,
- EXPP_RADIO_drawtype_GOURAUD );
- } else
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int or string as argument" );
-
- self->scene->radio->drawtype = dt;
-
- set_radglobal( ); /* needed to update 3d view(s) */
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_set_flag( BPy_Radio * self, PyObject * args )
-{
- int i, imode = 0;
- char *mode[2] = { NULL, NULL };
-
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( !PyArg_ParseTuple( args, "|ss", &mode[0], &mode[1] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string arguments (or nothing)" );
-
- for( i = 0; i < 2; i++ ) {
- if( !mode[i] )
- break;
- else if( !strcmp( mode[i], "ShowLimits" ) )
- imode |= EXPP_RADIO_flag_SHOWLIM;
- else if( !strcmp( mode[i], "Z" ) )
- imode |= EXPP_RADIO_flag_Z;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown mode string" );
- }
-
- self->scene->radio->flag = ( short ) EXPP_ClampInt( imode, 0, 3 );
-
- set_radglobal( ); /* needed to update 3d view(s) */
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_set_maxnode( BPy_Radio * self, PyObject * args )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_unpack_set_int( args, &self->scene->radio->maxnode,
- EXPP_RADIO_maxnode_MIN,
- EXPP_RADIO_maxnode_MAX );
-}
-
-static PyObject *Radio_set_convergence( BPy_Radio * self, PyObject * args )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_unpack_set_float( args, &self->scene->radio->convergence,
- EXPP_RADIO_convergence_MIN,
- EXPP_RADIO_convergence_MAX );
-}
-
-static PyObject *Radio_set_radfac( BPy_Radio * self, PyObject * args )
-{
- PyObject *ret;
-
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- ret = EXPP_unpack_set_float( args, &self->scene->radio->radfac,
- EXPP_RADIO_radfac_MIN,
- EXPP_RADIO_radfac_MAX );
-
- if( ret ) {
- set_radglobal( );
- if( rad_phase( ) & RAD_PHASE_FACES )
- make_face_tab( );
- else
- make_node_display( );
- }
-
- return ret;
-}
-
-static PyObject *Radio_set_gamma( BPy_Radio * self, PyObject * args )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
- return EXPP_unpack_set_float( args, &self->scene->radio->gamma,
- EXPP_RADIO_gamma_MIN,
- EXPP_RADIO_gamma_MAX );
-}
-
-static PyMethodDef BPy_Radio_methods[] = {
- {"collectMeshes", ( PyCFunction ) Radio_collectMeshes, METH_NOARGS,
- "() - Convert selected meshes to patches."},
- {"go", ( PyCFunction ) Radio_go, METH_NOARGS,
- "() - Start radiosity calculations."},
- {"freeData", ( PyCFunction ) Radio_freeData, METH_NOARGS,
- "() - Free all memory used by radiosity."},
- {"addMesh", ( PyCFunction ) Radio_addMesh, METH_NOARGS,
- "() - Add a new mesh with the radio values as vertex colors to Blender."},
- {"replaceMeshes", ( PyCFunction ) Radio_replaceMeshes, METH_NOARGS,
- "() - Replace input meshes with the one created by radiosity simulation."},
- {"limitSubdivide", ( PyCFunction ) Radio_limitSubdivide, METH_NOARGS,
- "() - Subdivide patches."},
- {"filterFaces", ( PyCFunction ) Radio_filterFaces, METH_NOARGS,
- "() - Force an extra smoothing."},
- {"filterElems", ( PyCFunction ) Radio_filterElems, METH_NOARGS,
- "() - Filter elements to remove aliasing artifacts."},
- {"subdividePatches", ( PyCFunction ) Radio_subdividePatches,
- METH_NOARGS,
- "() - Pre-subdivision: detect high-energy patches and subdivide them."},
- {"subdivideElems", ( PyCFunction ) Radio_subdivideElems, METH_NOARGS,
- "() - Pre-subdivision: detect high-energy elements and subdivide them."},
- {"removeDoubles", ( PyCFunction ) Radio_removeDoubles, METH_NOARGS,
- "() - Join elements which differ less than the defined node limit."},
- {"getHemiRes", ( PyCFunction ) Radio_get_hemires, METH_NOARGS,
- "() - Get hemicube size."},
- {"setHemiRes", ( PyCFunction ) Radio_set_hemires, METH_VARARGS,
- "(int) - Set hemicube size, the range is [100, 1000]."},
- {"getMaxIter", ( PyCFunction ) Radio_get_maxiter, METH_NOARGS,
- "() - Get maximum number of radiosity rounds."},
- {"setMaxIter", ( PyCFunction ) Radio_set_maxiter, METH_VARARGS,
- "(i) - Set maximum number of radiosity rounds in [0, 10000]."},
- {"getSubShPatch", ( PyCFunction ) Radio_get_subshootp, METH_NOARGS,
- "() - Get max number of times environment is tested to detect patches."},
- {"setSubShPatch", ( PyCFunction ) Radio_set_subshootp, METH_VARARGS,
- "(i) - Set max number of times environment is tested to detect patches.\n\
- Range is [0, 10]."},
- {"getSubShElem", ( PyCFunction ) Radio_get_subshoote, METH_NOARGS,
- "() - Get number of times environment is tested to detect elements."},
- {"setSubShElem", ( PyCFunction ) Radio_set_subshoote, METH_VARARGS,
- "(i) - Set number of times environment is tested to detect elements.\n\
- Range is [0, 10]."},
- {"getElemLimit", ( PyCFunction ) Radio_get_nodelim, METH_NOARGS,
- "() - Get the range for removing doubles."},
- {"setElemLimit", ( PyCFunction ) Radio_set_nodelim, METH_VARARGS,
- "(i) - Set the range for removing doubles in [0, 50]."},
- {"getMaxSubdivSh", ( PyCFunction ) Radio_get_maxsublamp, METH_NOARGS,
- "() - Get max number of initial shoot patches evaluated."},
- {"setMaxSubdivSh", ( PyCFunction ) Radio_set_maxsublamp, METH_VARARGS,
- "(i) - Set max number of initial shoot patches evaluated in [1, 250]."},
- {"getPatchMax", ( PyCFunction ) Radio_get_pama, METH_NOARGS,
- "() - Get max size of a patch."},
- {"setPatchMax", ( PyCFunction ) Radio_set_pama, METH_VARARGS,
- "(i) - Set max size of a patch in [10, 1000]."},
- {"getPatchMin", ( PyCFunction ) Radio_get_pami, METH_NOARGS,
- "() - Get minimum size of a patch."},
- {"setPatchMin", ( PyCFunction ) Radio_set_pami, METH_VARARGS,
- "(i) - Set minimum size of a patch in [10, 1000]."},
- {"getElemMax", ( PyCFunction ) Radio_get_elma, METH_NOARGS,
- "() - Get max size of an element."},
- {"setElemMax", ( PyCFunction ) Radio_set_elma, METH_VARARGS,
- "(i) - Set max size of an element in [1, 100]."},
- {"getElemMin", ( PyCFunction ) Radio_get_elmi, METH_NOARGS,
- "() - Get minimum size of an element."},
- {"setElemMin", ( PyCFunction ) Radio_set_elmi, METH_VARARGS,
- "(i) - Set minimum size of an element in [1, 100]."},
- {"getMaxElems", ( PyCFunction ) Radio_get_maxnode, METH_NOARGS,
- "() - Get maximum number of elements."},
- {"setMaxElems", ( PyCFunction ) Radio_set_maxnode, METH_VARARGS,
- "(i) - Set maximum nunber of elements in [1, 250000]."},
- {"getConvergence", ( PyCFunction ) Radio_get_convergence, METH_NOARGS,
- "() - Get lower threshold of unshot energy."},
- {"setConvergence", ( PyCFunction ) Radio_set_convergence, METH_VARARGS,
- "(f) - Set lower threshold of unshot energy in [0.0, 1.0]."},
- {"getMult", ( PyCFunction ) Radio_get_radfac, METH_NOARGS,
- "() - Get energy value multiplier."},
- {"setMult", ( PyCFunction ) Radio_set_radfac, METH_VARARGS,
- "(f) - Set energy value multiplier in [0.001, 250.0]."},
- {"getGamma", ( PyCFunction ) Radio_get_gamma, METH_NOARGS,
- "() - Get change in the contrast of energy values."},
- {"setGamma", ( PyCFunction ) Radio_set_gamma, METH_VARARGS,
- "(f) - Set change in the contrast of energy values in [0.2, 10.0]."},
- {"getDrawType", ( PyCFunction ) Radio_get_drawtype, METH_NOARGS,
- "() - Get the draw type: Wire, Solid or Gouraud as an int value."},
- {"setDrawType", ( PyCFunction ) Radio_set_drawtype, METH_VARARGS,
- "(i or s) - Set the draw type: wire, solid (default) or gouraud."},
- {"getMode", ( PyCFunction ) Radio_get_flag, METH_NOARGS,
- "() - Get mode as int (or'ed bitflags), see Radio.Modes dict."},
- {"setMode", ( PyCFunction ) Radio_set_flag, METH_VARARGS,
- "(|ss) - Set mode flags as strings: 'ShowLimits', 'Z'."},
- {NULL, NULL, 0, NULL}
-};
-
-static PyTypeObject Radio_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /*ob_size */
- "Blender Radiosity", /*tp_name */
- sizeof( BPy_Radio ), /*tp_basicsize */
- 0, /*tp_itemsize */
- NULL, /*tp_dealloc */
- 0, /*tp_print */
- 0, /*tp_getattr */
- 0, /*tp_setattr */
- 0, /*tp_compare */
- ( reprfunc ) Radio_repr, /*tp_repr */
- 0, /*tp_as_number */
- 0, /*tp_as_sequence */
- 0, /*tp_as_mapping */
- 0, /*tp_hash */
- 0, /*tp_call */
- 0, /*tp_str */
- 0, /*tp_getattro */
- 0, /*tp_setattro */
- 0, /*tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags */
- "Blender radiosity", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_Radio_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, 0, 0, 0, 0, 0, 0, 0, /* up to tp_del, so we don't get a warning */
-};
-
-static PyObject *Radio_repr( BPy_Radio * self )
-{
- if( self->radio )
- return PyString_FromFormat( "[Radiosity \"%s\"]",
- self->scene->id.name + 2 );
- else
- return PyString_FromString( "NULL" );
-}
-
-PyObject *Radio_CreatePyObject( struct Scene * scene )
-{
- BPy_Radio *py_radio;
-
- if( scene != G.scene ) {
- return EXPP_ReturnPyObjError( PyExc_EnvironmentError,
- "\nradiosity only works on the current scene, check scene.makeCurrent()." );
- }
-
- py_radio = ( BPy_Radio * ) PyObject_NEW( BPy_Radio, &Radio_Type );
-
- if( !py_radio )
- return NULL;
-
- if( !scene->radio )
- add_radio( ); /* adds to G.scene */
-
- py_radio->radio = scene->radio;
- py_radio->scene = scene;
-
- return ( ( PyObject * ) py_radio );
-}
-
-static PyObject *Radio_collectMeshes( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- disable_where_script( 1 ); /* used to avoid error popups */
- rad_collect_meshes( );
- disable_where_script( 0 );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_freeData( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- delete_radio( );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_go( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( rad_phase( ) == RAD_PHASE_PATCHES )
- rad_go( );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "you need to call radio.collectMeshes() first." );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_replaceMeshes( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( rad_phase( ) & RAD_PHASE_FACES )
- rad_replacemesh( );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first." );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_addMesh( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( rad_phase( ) & RAD_PHASE_FACES )
- rad_addmesh( );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first." );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_filterFaces( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( rad_phase( ) & RAD_PHASE_FACES )
- filterFaces( );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first." );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_filterElems( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( rad_phase( ) & RAD_PHASE_FACES ) {
- set_radglobal( );
- filterNodes( );
- make_face_tab( );
- } else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first." );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_limitSubdivide( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( rad_phase( ) == RAD_PHASE_PATCHES )
- rad_limit_subdivide( );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "you need to call this before calculating the radiosity simulation." );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_subdividePatches( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( rad_phase( ) == RAD_PHASE_PATCHES )
- rad_subdivshootpatch( );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "you need to call this before calculating the radiosity simulation." );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_subdivideElems( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( rad_phase( ) == RAD_PHASE_PATCHES )
- rad_subdivshootelem( );
- else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first." );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyObject *Radio_removeDoubles( BPy_Radio * self )
-{
- if( !EXPP_check_scene( self->scene ) )
- return NULL;
-
- if( rad_phase( ) == RAD_PHASE_FACES ) {
- set_radglobal( );
- removeEqualNodes( self->scene->radio->nodelim );
- make_face_tab( );
- } else
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first." );
-
- return EXPP_incr_ret( Py_None );
-}
-
-static PyMethodDef M_Radio_methods[] = { {NULL, NULL, 0, NULL} };
-
-PyObject *Radio_Init( void )
-{
- PyObject *submodule, *Modes, *DrawTypes;
-
- if( PyType_Ready( &Radio_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Scene.Radio", M_Radio_methods,
- "The Blender Radiosity submodule" );
-
- Modes = PyConstant_New( );
- DrawTypes = PyConstant_New( );
-
- if( Modes ) {
- BPy_constant *d = ( BPy_constant * ) Modes;
-
- PyConstant_Insert( d, "ShowLimits",
- PyInt_FromLong( EXPP_RADIO_flag_SHOWLIM ) );
- PyConstant_Insert( d, "Z", PyInt_FromLong( EXPP_RADIO_flag_Z ) );
-
- PyModule_AddObject( submodule, "Modes", Modes );
- }
-
- if( DrawTypes ) {
- BPy_constant *d = ( BPy_constant * ) DrawTypes;
-
- PyConstant_Insert( d, "Wire",
- PyInt_FromLong( EXPP_RADIO_drawtype_WIRE ) );
- PyConstant_Insert( d, "Solid",
- PyInt_FromLong( EXPP_RADIO_drawtype_SOLID ) );
- PyConstant_Insert( d, "Gouraud",
- PyInt_FromLong
- ( EXPP_RADIO_drawtype_GOURAUD ) );
-
- PyModule_AddObject( submodule, "DrawTypes", DrawTypes );
- }
-
- return submodule;
-}
diff --git a/source/blender/python/api2_2x/sceneRadio.h b/source/blender/python/api2_2x/sceneRadio.h
deleted file mode 100644
index 98604d9afb2..00000000000
--- a/source/blender/python/api2_2x/sceneRadio.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * $Id: sceneRadio.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_SCENERADIO_H
-#define EXPP_SCENERADIO_H
-
-#include <Python.h>
-#include "DNA_radio_types.h"
-#include "DNA_scene_types.h"
-
-/* BPy_Radio declaration */
-typedef struct {
- PyObject_HEAD
- struct Radio *radio;
- struct Scene *scene;
-} BPy_Radio;
-
-PyObject *Radio_Init( void );
-
-PyObject *Radio_CreatePyObject( struct Scene *scene );
-
-#endif /* EXPP_SCENERADIO_H */
diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c
deleted file mode 100644
index a160db1ad22..00000000000
--- a/source/blender/python/api2_2x/sceneRender.c
+++ /dev/null
@@ -1,3216 +0,0 @@
-/*
- * $Id: sceneRender.c 12813 2007-12-07 09:51: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, Dietrich Bollmann
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-struct View3D; /* keep me up here */
-
-#include "sceneRender.h" /*This must come first*/
-
-#include "DNA_image_types.h"
-
-#include "BKE_image.h"
-#include "BKE_global.h"
-#include "BKE_screen.h"
-#include "BKE_scene.h"
-
-#include "BIF_drawscene.h"
-#include "BIF_renderwin.h"
-#include "BIF_writeimage.h"
-
-#include "BLI_blenlib.h"
-
-#include "RE_pipeline.h"
-
-#include "mydevice.h"
-#include "butspace.h"
-#include "blendef.h"
-#include "gen_utils.h"
-
-#include "Scene.h"
-
-/* local defines */
-#define PY_NONE 0
-#define PY_LOW 1
-#define PY_MEDIUM 2
-#define PY_HIGH 3
-#define PY_HIGHER 4
-#define PY_BEST 5
-#define PY_USEAOSETTINGS 6
-#define PY_SKYDOME 1
-#define PY_FULL 2
-
-enum rend_constants {
- EXPP_RENDER_ATTR_XPARTS = 0,
- EXPP_RENDER_ATTR_YPARTS,
- EXPP_RENDER_ATTR_ASPECTX,
- EXPP_RENDER_ATTR_ASPECTY,
- EXPP_RENDER_ATTR_CFRAME,
- EXPP_RENDER_ATTR_SFRAME,
- EXPP_RENDER_ATTR_EFRAME,
- EXPP_RENDER_ATTR_FPS,
- EXPP_RENDER_ATTR_FPS_BASE,
- EXPP_RENDER_ATTR_SIZEX,
- EXPP_RENDER_ATTR_SIZEY,
- EXPP_RENDER_ATTR_GAUSSFILTER,
- EXPP_RENDER_ATTR_MBLURFACTOR,
-};
-
-#define EXPP_RENDER_ATTR_CFRA 2
-#define EXPP_RENDER_ATTR_ANTISHIFT 3
-#define EXPP_RENDER_ATTR_EDGEINT 4
-#define EXPP_RENDER_ATTR_EFRA 5
-#define EXPP_RENDER_ATTR_QUALITY 11
-#define EXPP_RENDER_ATTR_GAUSS 13
-#define EXPP_RENDER_ATTR_BLURFAC 14
-
-#define EXPP_RENDER_ATTR_YF_EXPOSURE 20
-#define EXPP_RENDER_ATTR_YF_GAMMA 21
-#define EXPP_RENDER_ATTR_YF_GIDEPTH 22
-#define EXPP_RENDER_ATTR_YF_GICDEPTH 23
-#define EXPP_RENDER_ATTR_YF_GIPHOTONCOUNT 24
-#define EXPP_RENDER_ATTR_YF_GIPHOTONMIXCOUNT 25
-#define EXPP_RENDER_ATTR_YF_GIPHOTONRADIUS 26
-#define EXPP_RENDER_ATTR_YF_GIPIXPERSAMPLE 27
-#define EXPP_RENDER_ATTR_YF_GIPOWER 28
-#define EXPP_RENDER_ATTR_YF_GIREFINE 29
-#define EXPP_RENDER_ATTR_YF_GISHADOWQUAL 30
-#define EXPP_RENDER_ATTR_YF_RAYBIAS 31
-#define EXPP_RENDER_ATTR_YF_PROCCOUNT 32
-#define EXPP_RENDER_ATTR_YF_RAYDEPTH 33
-#define EXPP_RENDER_ATTR_YF_GIMETHOD 34
-#define EXPP_RENDER_ATTR_YF_GIQUALITY 35
-
-
-/* Render doc strings */
-static char M_Render_doc[] = "The Blender Render module";
-
-/* deprecated callbacks */
-static PyObject *RenderData_SetRenderPath( BPy_RenderData *self,
- PyObject *args );
-static PyObject *RenderData_SetBackbufPath( BPy_RenderData *self,
- PyObject *args );
-static PyObject *RenderData_SetFtypePath( BPy_RenderData *self,
- PyObject *args );
-static PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self,
- PyObject * args );
-static PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self,
- PyObject * args );
-static PyObject *RenderData_SetBorder( BPy_RenderData * self,
- PyObject * args );
-static PyObject *RenderData_SetRenderer( BPy_RenderData * self,
- PyObject * args );
-static PyObject *RenderData_SetImageType( BPy_RenderData * self,
- PyObject * args );
-static PyObject *RenderData_Render( BPy_RenderData * self );
-
-/* BPy_RenderData Internal Protocols */
-
-static PyObject *RenderData_repr( BPy_RenderData * self )
-{
- if( self->renderContext )
- return PyString_FromFormat( "[RenderData \"%s\"]",
- self->scene->id.name + 2 );
- else
- return PyString_FromString( "NULL" );
-}
-
-/***************************************************************************/
-/* local utility routines for manipulating data */
-/***************************************************************************/
-static PyObject *M_Render_BitToggleInt( PyObject * args, int setting,
- int *structure )
-{
- int flag;
-
- if( !PyArg_ParseTuple( args, "i", &flag ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected TRUE or FALSE (1 or 0)" ) );
-
- if( flag < 0 || flag > 1 )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected TRUE or FALSE (1 or 0)" ) );
-
- if( flag )
- *structure |= setting;
- else
- *structure &= ~setting;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-
-}
-
-static PyObject *M_Render_BitToggleShort( PyObject * args, short setting,
- short *structure )
-{
- int flag;
-
- if( !PyArg_ParseTuple( args, "i", &flag ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected TRUE or FALSE (1 or 0)" ) );
-
- if( flag < 0 || flag > 1 )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected TRUE or FALSE (1 or 0)" ) );
-
- if( flag )
- *structure |= setting;
- else
- *structure &= ~setting;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-
-}
-
-static PyObject *M_Render_GetSetAttributeFloat( PyObject * args,
- float *structure, float min,
- float max )
-{
- float property = -10.0f;
- char error[48];
-
- if( !PyArg_ParseTuple( args, "|f", &property ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError, "expected float" ) );
-
- if( property != -10.0f ) {
- if( property < min || property > max ) {
- sprintf( error, "out of range - expected %f to %f",
- min, max );
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError, error ) );
- }
-
- *structure = property;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- Py_RETURN_NONE;
- } else
- return PyFloat_FromDouble( *structure );
-}
-
-static PyObject *M_Render_GetSetAttributeShort( PyObject * args,
- short *structure, int min,
- int max )
-{
- short property = -10;
- char error[48];
-
- if( !PyArg_ParseTuple( args, "|h", &property ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int" ) );
-
- if( property != -10 ) {
- if( property < min || property > max ) {
- sprintf( error, "out of range - expected %d to %d",
- min, max );
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError, error ) );
- }
-
- *structure = property;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- Py_RETURN_NONE;
- } else
- return PyInt_FromLong( (long int)*structure );
-}
-
-static PyObject *M_Render_GetSetAttributeInt( PyObject * args, int *structure,
- int min, int max )
-{
- int property = -10;
- char error[48];
-
- if( !PyArg_ParseTuple( args, "|i", &property ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int" ) );
-
- if( property != -10 ) {
- if( property < min || property > max ) {
- sprintf( error, "out of range - expected %d to %d",
- min, max );
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError, error ) );
- }
-
- *structure = property;
-
- /* compare memory locations, not values */
- if (&G.scene->r.cfra == structure) {
- /* are we changing the current frame?
- update all objects, so python scripts can export all objects
- in a scene without worrying about the view layers */
- scene_update_for_newframe(G.scene, (1<<20) - 1);
- }
-
- /*I dont think this should be here, whatif the scene is not the current scene - campbell*/
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
- } else
- return PyInt_FromLong( *structure );
-}
-
-
-static void M_Render_DoSizePreset( BPy_RenderData * self, short xsch,
- short ysch, short xasp, short yasp,
- short size, short xparts, short yparts,
- short fps, float fps_base,
- float a, float b, float c,
- float d )
-{
- self->renderContext->xsch = xsch;
- self->renderContext->ysch = ysch;
- self->renderContext->xasp = xasp;
- self->renderContext->yasp = yasp;
- self->renderContext->size = size;
- self->renderContext->frs_sec = fps;
- self->renderContext->frs_sec_base = fps_base;
- self->renderContext->xparts = xparts;
- self->renderContext->yparts = yparts;
-
- BLI_init_rctf( &self->renderContext->safety, a, b, c, d );
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- EXPP_allqueue( REDRAWVIEWCAM, 0 );
-}
-
-/** set / get boolean */
-
-static int M_Render_setBooleanShort( BPy_RenderData * self, PyObject *value, short* var )
-{
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected boolean value" );
-
- *var = (PyInt_AsLong( value )) ? 1 : 0;
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- return 0;
-}
-
-static PyObject *M_Render_getBooleanShort( BPy_RenderData * self, short var )
-{
- return PyInt_FromLong( (long) var );
-}
-
-/** set / get float */
-
-static int M_Render_setFloat( BPy_RenderData *self, PyObject *value, float *var, float min, float max )
-{
- float val;
- char error[48];
-
- if( !PyFloat_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float value" );
-
- val = (float) PyFloat_AsDouble( value );
-
- /* check range */
- if ( val < min || val > max ) {
- sprintf( error, "out of range - expected %f to %f", min, max );
- return EXPP_ReturnIntError( PyExc_TypeError,error );
- }
-
- *var = val;
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- return 0;
-}
-
-static PyObject *M_Render_getFloat( BPy_RenderData *self, float var )
-{
- return PyFloat_FromDouble( (double) var );
-}
-
-/** set / get integer */
-
-static int M_Render_setInt( BPy_RenderData *self, PyObject *value, int *var, int min, int max )
-{
- int val;
- char error[48];
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer value" );
-
- val = (int) PyInt_AsLong( value );
-
- /* check range */
- if ( val < min || val > max ) {
- sprintf( error, "out of range - expected %d to %d", min, max );
- return EXPP_ReturnIntError( PyExc_TypeError,error );
- }
-
- *var = val;
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- return 0;
-}
-
-static PyObject *M_Render_getInt( BPy_RenderData *self, int var )
-{
- return PyInt_FromLong( (long) var );
-}
-
-/***************************************************************************/
-/* Render Module Function Definitions */
-/***************************************************************************/
-
-PyObject *M_Render_CloseRenderWindow( PyObject * self )
-{
- BIF_close_render_display( );
- Py_RETURN_NONE;
-}
-
-PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args )
-{
- PyObject *list = NULL;
- char *loc = NULL;
- int x;
-
- if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &list ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a list" ) );
-
- G.winpos = 0;
- for( x = 0; x < PyList_Size( list ); x++ ) {
- if( !PyArg_Parse( PyList_GetItem( list, x ), "s", &loc ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "python list not parseable" );
- }
- if( strcmp( loc, "SW" ) == 0 || strcmp( loc, "sw" ) == 0 )
- G.winpos |= 1;
- else if( strcmp( loc, "S" ) == 0 || strcmp( loc, "s" ) == 0 )
- G.winpos |= 2;
- else if( strcmp( loc, "SE" ) == 0 || strcmp( loc, "se" ) == 0 )
- G.winpos |= 4;
- else if( strcmp( loc, "W" ) == 0 || strcmp( loc, "w" ) == 0 )
- G.winpos |= 8;
- else if( strcmp( loc, "C" ) == 0 || strcmp( loc, "c" ) == 0 )
- G.winpos |= 16;
- else if( strcmp( loc, "E" ) == 0 || strcmp( loc, "e" ) == 0 )
- G.winpos |= 32;
- else if( strcmp( loc, "NW" ) == 0 || strcmp( loc, "nw" ) == 0 )
- G.winpos |= 64;
- else if( strcmp( loc, "N" ) == 0 || strcmp( loc, "n" ) == 0 )
- G.winpos |= 128;
- else if( strcmp( loc, "NE" ) == 0 || strcmp( loc, "ne" ) == 0 )
- G.winpos |= 256;
- else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "list contains unknown string" );
- }
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-}
-
-PyObject *M_Render_EnableDispView( PyObject * self )
-{
- G.displaymode = R_DISPLAYIMAGE;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-}
-
-PyObject *M_Render_EnableDispWin( PyObject * self )
-{
- G.displaymode = R_DISPLAYWIN;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-}
-
-
-/***************************************************************************/
-/* BPy_RenderData Function Definitions */
-/***************************************************************************/
-
-PyObject *RenderData_Render( BPy_RenderData * self )
-{
- Scene *oldsce;
-
- if (!G.background) {
- oldsce = G.scene;
- set_scene( self->scene );
- BIF_do_render( 0 );
- set_scene( oldsce );
- }
-
- else { /* background mode (blender -b file.blend -P script) */
- Render *re= RE_NewRender("Render");
-
- int end_frame = G.scene->r.efra; /* is of type short currently */
-
- if (G.scene != self->scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "scene to render in bg mode must be the active scene");
-
- G.scene->r.efra = G.scene->r.sfra;
-
- RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
-
- G.scene->r.efra = (short)end_frame;
- }
-
- Py_RETURN_NONE;
-}
-
-/*
- * This will save the rendered image to an output file path already defined.
- */
-PyObject *RenderData_SaveRenderedImage ( BPy_RenderData * self, PyObject *args )
-{
- char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2];
- char *name_str, filepath[FILE_MAXDIR+FILE_MAXFILE];
- RenderResult *rr = NULL;
- int zbuff;
-
- if( !PyArg_ParseTuple( args, "s|i", &name_str, &zbuff ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a filename (string) and optional int" );
-
- if( strlen(self->renderContext->pic) + strlen(name_str)
- >= sizeof(filepath) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "full filename too long" );
-
- if (zbuff !=0 ) zbuff = 1; /*required 1/0 */ /* removed! (ton) */
-
- BLI_strncpy( filepath, self->renderContext->pic, sizeof(filepath) );
- strcat(filepath, name_str);
-
- rr = RE_GetResult(RE_GetRender(G.scene->id.name));
- if(!rr) {
- return EXPP_ReturnPyObjError (PyExc_ValueError, "No image rendered");
- } else {
- if(G.ima[0]==0) {
- strcpy(dir, G.sce);
- BLI_splitdirstring(dir, str);
- strcpy(G.ima, dir);
- }
- BIF_save_rendered_image(filepath);
- }
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_RenderAnim( BPy_RenderData * self )
-{
- Scene *oldsce;
-
- if (!G.background) {
- oldsce = G.scene;
- set_scene( self->scene );
- BIF_do_render( 1 );
- set_scene( oldsce );
- }
- else { /* background mode (blender -b file.blend -P script) */
- Render *re= RE_NewRender("Render");
-
- if (G.scene != self->scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "scene to render in bg mode must be the active scene");
-
- if (G.scene->r.sfra > G.scene->r.efra)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "start frame must be less or equal to end frame");
-
- RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
- }
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_Play( BPy_RenderData * self )
-{
- char file[FILE_MAXDIR + FILE_MAXFILE];
- extern char bprogname[];
- char str[FILE_MAXDIR + FILE_MAXFILE];
- int pos[2], size[2];
- char txt[64];
-
-#ifdef WITH_QUICKTIME
- if( self->renderContext->imtype == R_QUICKTIME ) {
-
- strcpy( file, self->renderContext->pic );
- BLI_convertstringcode( file, (char *) self->scene,
- self->renderContext->cfra );
- BLI_make_existing_file( file );
- if( BLI_strcasecmp( file + strlen( file ) - 4, ".mov" ) ) {
- sprintf( txt, "%04d_%04d.mov",
- ( self->renderContext->sfra ),
- ( self->renderContext->efra ) );
- strcat( file, txt );
- }
- } else
-#endif
- {
-
- strcpy( file, self->renderContext->pic );
- BLI_convertstringcode( file, G.sce,
- self->renderContext->cfra );
- BLI_make_existing_file( file );
- if( BLI_strcasecmp( file + strlen( file ) - 4, ".avi" ) ) {
- sprintf( txt, "%04d_%04d.avi",
- ( self->renderContext->sfra ),
- ( self->renderContext->efra ) );
- strcat( file, txt );
- }
- }
- if( BLI_exist( file ) ) {
- calc_renderwin_rectangle(640, 480, G.winpos, pos, size);
- sprintf( str, "%s -a -p %d %d \"%s\"", bprogname, pos[0],
- pos[1], file );
- system( str );
- } else {
- BKE_makepicstring( file, G.scene->r.pic, self->renderContext->sfra, G.scene->r.imtype);
- if( BLI_exist( file ) ) {
- calc_renderwin_rectangle(640, 480, G.winpos, pos, size);
-#ifdef WIN32
- sprintf( str, "%s -a -p %d %d \"%s\"", bprogname,
- pos[0], pos[1], file );
-#else
- sprintf( str, "\"%s\" -a -p %d %d \"%s\"", bprogname,
- pos[0], pos[1], file );
-#endif
- system( str );
- } else
- sprintf( "Can't find image: %s", file );
- }
-
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_EnableBackbuf( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_BitToggleShort( args, 1,
- &self->renderContext->bufflag );
-}
-
-PyObject *RenderData_EnableExtensions( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_BitToggleShort( args, R_EXTENSION,
- &self->renderContext->scemode );
-}
-
-PyObject *RenderData_EnableSequencer( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_BitToggleShort( args, R_DOSEQ,
- &self->renderContext->scemode );
-}
-
-PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleShort( args, R_BG_RENDER,
- &self->renderContext->scemode );
-}
-
-PyObject *RenderData_EnableToonShading( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_EDGE,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_EdgeIntensity( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args,
- &self->renderContext->edgeint, 0,
- 255 );
-}
-
-PyObject *RenderData_SetEdgeColor( BPy_RenderData * self, PyObject * args )
-{
- float red, green, blue;
-
- if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected three floats" ) );
-
- if( red < 0 || red > 1 )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (red)" ) );
- if( green < 0 || green > 1 )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (green)" ) );
- if( blue < 0 || blue > 1 )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (blue)" ) );
-
- self->renderContext->edgeR = red;
- self->renderContext->edgeG = green;
- self->renderContext->edgeB = blue;
-
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_GetEdgeColor( BPy_RenderData * self )
-{
- char rgb[24];
-
- sprintf( rgb, "[%.3f,%.3f,%.3f]", self->renderContext->edgeR,
- self->renderContext->edgeG, self->renderContext->edgeB );
- return PyString_FromString( rgb );
-}
-
-PyObject *RenderData_EnableOversampling( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_OSA,
- &self->renderContext->mode );
-}
-
-static int RenderData_setOSALevel( BPy_RenderData * self,
- PyObject * value )
-{
- int level;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- level = PyInt_AsLong( value );
- if( level != 5 && level != 8 && level != 11 && level != 16 )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected 5, 8, 11, or 16" );
-
- self->renderContext->osa = (short)level;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- return 0;
-}
-
-PyObject *RenderData_EnableMotionBlur( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_MBLUR,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->blurfac,
- 0.01f, 5.0f );
-}
-
-PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args,
- &self->renderContext->xparts, 1,
- 512 );
-}
-
-PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args,
- &self->renderContext->yparts, 1,
- 64 );
-}
-
-PyObject *RenderData_EnableSky( BPy_RenderData * self )
-{
- self->renderContext->alphamode = R_ADDSKY;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_EnablePremultiply( BPy_RenderData * self )
-{
- self->renderContext->alphamode = R_ALPHAPREMUL;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_EnableKey( BPy_RenderData * self )
-{
- self->renderContext->alphamode = R_ALPHAKEY;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_EnableShadow( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_SHADOW,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_ENVMAP,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_EnablePanorama( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_PANORAMA,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_EnableRayTracing( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_RAYTRACE,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_EnableRadiosityRender( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_RADIO,
- &self->renderContext->mode );
-}
-PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_FIELDS,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_ODDFIELD,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_FIELDSTILL,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_GAUSS,
- &self->renderContext->mode );
-
- /* note, this now is obsolete (ton) */
- /* we now need a call like RenderData_SetFilter() or so */
- /* choices are listed in DNA_scene_types.h (search filtertype) */
-}
-
-PyObject *RenderData_EnableBorderRender( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_BORDER,
- &self->renderContext->mode );
-}
-
-static int RenderData_setBorder( BPy_RenderData * self, PyObject * args )
-{
- float xmin, ymin, xmax, ymax;
-
- if( PyList_Check( args ) )
- args = PySequence_Tuple( args );
- else
- Py_INCREF( args );
-
- if( !PyArg_ParseTuple( args, "ffff", &xmin, &ymin, &xmax, &ymax ) ) {
- Py_DECREF( args );
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected four floats" );
- }
-
- self->renderContext->border.xmin = EXPP_ClampFloat( xmin, 0.0, 1.0 );
- self->renderContext->border.xmax = EXPP_ClampFloat( xmax, 0.0, 1.0 );
- self->renderContext->border.ymin = EXPP_ClampFloat( ymin, 0.0, 1.0 );
- self->renderContext->border.ymax = EXPP_ClampFloat( ymax, 0.0, 1.0 );
-
- EXPP_allqueue( REDRAWVIEWCAM, 1 );
-
- Py_DECREF( args );
- return 0;
-}
-
-static PyObject *RenderData_getBorder( BPy_RenderData * self )
-{
- return Py_BuildValue( "[ffff]",
- self->renderContext->border.xmin,
- self->renderContext->border.ymin,
- self->renderContext->border.xmax,
- self->renderContext->border.ymax );
-}
-
-PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_BitToggleInt( args, R_GAMMA,
- &self->renderContext->mode );
-}
-
-PyObject *RenderData_GaussFilterSize( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->gauss,
- 0.5f, 1.5f );
-}
-
-PyObject *RenderData_StartFrame( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeInt( args, &self->renderContext->sfra,
- 1, MAXFRAME );
-}
-
-PyObject *RenderData_CurrentFrame( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeInt( args, &self->renderContext->cfra,
- 1, MAXFRAME );
-}
-
-PyObject *RenderData_EndFrame( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeInt( args, &self->renderContext->efra,
- 1, MAXFRAME );
-}
-
-PyObject *RenderData_ImageSizeX( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args, &self->renderContext->xsch,
- 4, 10000 );
-}
-
-PyObject *RenderData_ImageSizeY( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args, &self->renderContext->ysch,
- 4, 10000 );
-}
-
-PyObject *RenderData_AspectRatioX( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args, &self->renderContext->xasp,
- 1, 200 );
-}
-
-PyObject *RenderData_AspectRatioY( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args, &self->renderContext->yasp,
- 1, 200 );
-}
-
-static int RenderData_setRenderer( BPy_RenderData * self, PyObject * value )
-{
- int type;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected constant INTERNAL or YAFRAY" );
-
- type = PyInt_AsLong( value );
- if( type == R_INTERN )
- self->renderContext->renderer = R_INTERN;
- else if( type == R_YAFRAY )
- self->renderContext->renderer = R_YAFRAY;
- else
- return EXPP_ReturnIntError( PyExc_ValueError,
- "expected constant INTERNAL or YAFRAY" );
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- return 0;
-}
-
-PyObject *RenderData_EnableCropping( void )
-{
-/* return M_Render_BitToggleInt( args, R_MOVIECROP,
- &self->renderContext->mode );
-*/
- printf("cropping option is now default, obsolete\n");
- Py_RETURN_NONE;
-}
-
-
-static int RenderData_setImageType( BPy_RenderData *self, PyObject *value )
-{
- int type;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int constant" );
-
- type = PyInt_AS_LONG( value );
-
- /*
- * this same logic and more is in buttons_scene.c imagetype_pup code but
- * only in generating strings for the popup menu, no way to reuse that :(
- */
-
- switch( type ) {
- case R_AVIRAW :
- case R_AVIJPEG :
- case R_TARGA :
- case R_RAWTGA :
- case R_RADHDR :
- case R_PNG :
- case R_BMP :
- case R_JPEG90 :
- case R_HAMX :
- case R_IRIS :
- case R_IRIZ :
- case R_FTYPE :
- case R_TIFF :
- case R_CINEON :
- case R_DPX :
-#ifdef _WIN32
- case R_AVICODEC :
-#endif
-#ifdef WITH_OPENEXR
- case R_OPENEXR :
-#endif
-#ifdef WITH_FFMPEG
- case R_FFMPEG :
-#endif
- self->renderContext->imtype = type;
- break;
- case R_QUICKTIME :
- if( G.have_quicktime ) {
- self->renderContext->imtype = R_QUICKTIME;
- break;
- }
- default:
- return EXPP_ReturnIntError( PyExc_ValueError,
- "unknown constant - see modules dict for help" );
- }
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- return 0;
-}
-
-PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args,
- &self->renderContext->quality,
- 10, 100 );
-}
-
-PyObject *RenderData_FramesPerSec( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args,
- &self->renderContext->frs_sec, 1,
- 120 );
-}
-
-PyObject *RenderData_EnableGrayscale( BPy_RenderData * self )
-{
- self->renderContext->planes = R_PLANESBW;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_EnableRGBColor( BPy_RenderData * self )
-{
- self->renderContext->planes = R_PLANES24;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self )
-{
- self->renderContext->planes = R_PLANES32;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_SizePreset( BPy_RenderData * self, PyObject * args )
-{
- int type;
-
- if( !PyArg_ParseTuple( args, "i", &type ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected constant" ) );
-
- if( type == B_PR_PAL ) {
- M_Render_DoSizePreset( self, 720, 576, 54, 51, 100,
- self->renderContext->xparts,
- self->renderContext->yparts, 25, 1.0f,
- 0.1f,
- 0.9f, 0.1f, 0.9f );
- self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
- 0.9f );
- } else if( type == B_PR_NTSC ) {
- M_Render_DoSizePreset( self, 720, 480, 10, 11, 100, 1, 1,
- 30, 1.001f,
- 0.1f, 0.9f, 0.1f, 0.9f );
- self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
- 0.9f );
- } else if( type == B_PR_PRESET ) {
- M_Render_DoSizePreset( self, 720, 576, 54, 51, 100, 1, 1,
- self->renderContext->frs_sec,
- self->renderContext->frs_sec_base,
- 0.1f, 0.9f,
- 0.1f, 0.9f );
- self->renderContext->mode = R_OSA + R_SHADOW + R_FIELDS;
- self->renderContext->imtype = R_TARGA;
- BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
- 0.9f );
- } else if( type == B_PR_PRV ) {
- M_Render_DoSizePreset( self, 640, 512, 1, 1, 50, 1, 1,
- self->renderContext->frs_sec,
- self->renderContext->frs_sec_base,
- 0.1f, 0.9f,
- 0.1f, 0.9f );
- self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
- 0.9f );
- } else if( type == B_PR_PC ) {
- M_Render_DoSizePreset( self, 640, 480, 100, 100, 100, 1, 1,
- self->renderContext->frs_sec,
- self->renderContext->frs_sec_base,
- 0.0f, 1.0f,
- 0.0f, 1.0f );
- self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf( &self->renderContext->safety, 0.0f, 1.0f, 0.0f,
- 1.0f );
- } else if( type == B_PR_PAL169 ) {
- M_Render_DoSizePreset( self, 720, 576, 64, 45, 100, 1, 1,
- 25, 1.0f, 0.1f, 0.9f, 0.1f, 0.9f );
- self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
- 0.9f );
- } else if( type == B_PR_PANO ) {
- M_Render_DoSizePreset( self, 36, 176, 115, 100, 100, 16, 1,
- self->renderContext->frs_sec,
- self->renderContext->frs_sec_base,
- 0.1f, 0.9f,
- 0.1f, 0.9f );
- self->renderContext->mode |= R_PANORAMA;
- BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
- 0.9f );
- } else if( type == B_PR_FULL ) {
- M_Render_DoSizePreset( self, 1280, 1024, 1, 1, 100, 1, 1,
- self->renderContext->frs_sec,
- self->renderContext->frs_sec_base,
- 0.1f, 0.9f,
- 0.1f, 0.9f );
- self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf( &self->renderContext->safety, 0.1f, 0.9f, 0.1f,
- 0.9f );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown constant - see modules dict for help" ) );
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- Py_RETURN_NONE;
-}
-
-/*
-
-PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self,
- PyObject * args )
-{
- int type;
-
- if( !PyArg_ParseTuple( args, "i", &type ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected constant" ) );
-
- if( type == PY_NONE || type == PY_LOW ||
- type == PY_MEDIUM || type == PY_HIGH ||
- type == PY_HIGHER || type == PY_BEST ) {
- self->renderContext->GIquality = (short)type;
- } else
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown constant - see modules dict for help" ) );
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self,
- PyObject * args )
-{
- int type;
-
- if( !PyArg_ParseTuple( args, "i", &type ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected constant" ) );
-
- if( type == PY_NONE || type == PY_SKYDOME || type == PY_FULL ) {
- self->renderContext->GImethod = (short)type;
- } else
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown constant - see modules dict for help" ) );
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- Py_RETURN_NONE;
-}
-*/
-
-/* (die) beg */
-
-/* YafRay - Yafray GI Method */
-
-static int RenderData_setYafrayGIQuality( BPy_RenderData * self, PyObject * value )
-{
- long type;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected constant" );
-
- type = PyInt_AsLong( value );
-
- if( type == PY_NONE || type == PY_LOW ||
- type == PY_MEDIUM || type == PY_HIGH ||
- type == PY_HIGHER || type == PY_BEST ||
- type == PY_USEAOSETTINGS
- ) {
- self->renderContext->GIquality = (short)type;
- } else {
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected constant NONE, LOW, MEDIUM, HIGHER or BEST" );
- }
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- return 0;
-}
-
-static PyObject *RenderData_getYafrayGIQuality( BPy_RenderData * self )
-{
- return PyInt_FromLong( (long) self->renderContext->GIquality );
-}
-
-static PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self,
- PyObject * args )
-{
- return EXPP_setterWrapper( (void*) self, args,
- (setter) RenderData_setYafrayGIQuality );
-}
-
-static PyObject *RenderData_GetYafrayGIQuality( BPy_RenderData * self )
-{
- return RenderData_getYafrayGIQuality(self);
-}
-
-/* YafRay - Yafray GI Method */
-
-static int RenderData_setYafrayGIMethod( BPy_RenderData * self, PyObject * value )
-{
- int type;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected constant NONE, SKYDOME or FULL" );
-
- type = PyInt_AsLong( value );
- if( type == PY_NONE || type == PY_SKYDOME || type == PY_FULL ) {
- self->renderContext->GImethod = (short)type;
- } else {
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected constant NONE, SKYDOME or FULL" );
- }
-
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- return 0;
-}
-
-static PyObject *RenderData_getYafrayGIMethod( BPy_RenderData * self )
-{
- return PyInt_FromLong( (long)self->renderContext->GImethod );
-}
-
-static PyObject *RenderData_GetYafrayGIMethod( BPy_RenderData * self )
-{
- return RenderData_getYafrayGIMethod(self);
-}
-
-static PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self,
- PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)RenderData_setYafrayGIMethod );
-}
-
-
-/* YafRay - Export to XML */
-
-static int RenderData_setYafrayExportToXML( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setBooleanShort( self, value, &self->renderContext->YFexportxml );
-}
-
-static PyObject *RenderData_getYafrayExportToXML( BPy_RenderData * self )
-{
- return M_Render_getBooleanShort( self, self->renderContext->YFexportxml );
-}
-
-/** Auto AA */
-
-static int RenderData_setYafrayAutoAntiAliasing( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setBooleanShort( self, value, &self->renderContext->YF_AA );
-}
-
-static PyObject *RenderData_getYafrayAutoAntiAliasing( BPy_RenderData * self )
-{
- return M_Render_getBooleanShort( self, self->renderContext->YF_AA );
-}
-
-/** Clamp RGB */
-
-static int RenderData_setYafrayClampRGB( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setBooleanShort( self, value, &self->renderContext->YF_clamprgb );
-}
-
-static PyObject *RenderData_getYafrayClampRGB( BPy_RenderData * self )
-{
- return M_Render_getBooleanShort( self, self->renderContext->YF_clamprgb );
-}
-
-/** YafRay - Anti-Aliasing Passes */
-
-static int RenderData_setYafrayAntiAliasingPasses( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setInt( self, value, &self->renderContext->YF_AApasses, 0, 64 );
-}
-
-static PyObject *RenderData_getYafrayAntiAliasingPasses( BPy_RenderData * self )
-{
- return M_Render_getInt( self, self->renderContext->YF_AApasses );
-}
-
-/** YafRay - Anti-Aliasing Samples */
-
-static int RenderData_setYafrayAntiAliasingSamples( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setInt( self, value, &self->renderContext->YF_AAsamples, 0, 2048 );
-}
-
-static PyObject *RenderData_getYafrayAntiAliasingSamples( BPy_RenderData * self )
-{
- return M_Render_getInt( self, self->renderContext->YF_AAsamples );
-}
-
-/* YafRay - Anti-Aliasing Pixel Filter Size */
-
-static int RenderData_setYafrayAntiAliasingPixelSize( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setFloat( self, value, &self->renderContext->YF_AApixelsize, 1.0, 2.0 );
-}
-
-static PyObject *RenderData_getYafrayAntiAliasingPixelSize( BPy_RenderData * self )
-{
- return M_Render_getFloat( self, self->renderContext->YF_AApixelsize );
-}
-
-/* YafRay - Anti-Aliasing threshold */
-
-static int RenderData_setYafrayAntiAliasingThreshold( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setFloat( self, value, &self->renderContext->YF_AAthreshold, 0.05, 1.0 );
-}
-
-static PyObject *RenderData_getYafrayAntiAliasingThreshold( BPy_RenderData * self )
-{
- return M_Render_getFloat( self, self->renderContext->YF_AAthreshold );
-}
-
-/** YafRay - Number of processors to use */
-
-static int RenderData_setYafrayNumberOfProcessors( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setInt( self, value, &self->renderContext->YF_numprocs, 1, 8 );
-}
-
-static PyObject *RenderData_getYafrayNumberOfProcessors( BPy_RenderData * self )
-{
- return M_Render_getInt( self, self->renderContext->YF_numprocs );
-}
-
-/* YafRay - Cache occlusion/irradiance samples (faster) */
-
-static int RenderData_setYafrayGICache( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setBooleanShort( self, value, &self->renderContext->GIcache );
-}
-
-static PyObject *RenderData_getYafrayGICache( BPy_RenderData * self )
-{
- return M_Render_getBooleanShort( self, self->renderContext->GIcache );
-}
-
-/* YafRay - Enable/disable bumpnormals for cache
- (faster, but no bumpmapping in total indirectly lit areas) */
-
-static int RenderData_setYafrayGICacheBumpNormals( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setBooleanShort( self, value, &self->renderContext->YF_nobump );
-}
-
-static PyObject *RenderData_getYafrayGICacheBumpNormals( BPy_RenderData * self )
-{
- return M_Render_getBooleanShort( self, self->renderContext->YF_nobump );
-}
-
-/* YafRay - Shadow quality, keep it under 0.95 :-) */
-
-static int RenderData_setYafrayGICacheShadowQuality( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setFloat( self, value, &self->renderContext->GIshadowquality, 0.01, 1.0 );
-}
-
-static PyObject *RenderData_getYafrayGICacheShadowQuality( BPy_RenderData * self )
-{
- return M_Render_getFloat( self, self->renderContext->GIshadowquality );
-}
-
-/* YafRay - Threshold to refine shadows EXPERIMENTAL. 1 = no refinement */
-
-static int RenderData_setYafrayGICacheRefinement( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setFloat( self, value, &self->renderContext->GIrefinement, 0.001, 1.0 );
-}
-
-static PyObject *RenderData_getYafrayGICacheRefinement( BPy_RenderData * self )
-{
- return M_Render_getFloat( self, self->renderContext->GIrefinement );
-}
-
-/* YafRay - Maximum number of pixels without samples, the lower the better and slower */
-
-static int RenderData_setYafrayGICachePixelsPerSample( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setInt( self, value, &self->renderContext->GIpixelspersample, 1, 50 );
-}
-
-static PyObject *RenderData_getYafrayGICachePixelsPerSample( BPy_RenderData * self )
-{
- return M_Render_getInt( self, self->renderContext->GIpixelspersample );
-}
-
-/** YafRay - Enable/disable use of global photons to help in GI */
-
-static int RenderData_setYafrayGIPhotons( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setBooleanShort( self, value, &self->renderContext->GIphotons );
-}
-
-static PyObject *RenderData_getYafrayGIPhotons( BPy_RenderData * self )
-{
- return M_Render_getBooleanShort( self, self->renderContext->GIphotons );
-}
-
-/** YafRay - If true the photonmap is shown directly in the render for tuning */
-
-static int RenderData_setYafrayGITunePhotons( BPy_RenderData * self, PyObject * value )
-{
- return M_Render_setBooleanShort( self, value, &self->renderContext->GIdirect );
-}
-
-static PyObject *RenderData_getYafrayGITunePhotons( BPy_RenderData * self )
-{
- return M_Render_getBooleanShort( self, self->renderContext->GIdirect );
-}
-
-/* (die) end */
-
-PyObject *RenderData_YafrayGIPower( BPy_RenderData * self, PyObject * args )
-{
- if( self->renderContext->GImethod > 0 ) {
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->
- GIpower, 0.01f,
- 100.00f );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'SKYDOME' or 'FULL'" ) );
-}
-
-PyObject *RenderData_YafrayGIIndirPower( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->
- GIindirpower, 0.01f,
- 100.00f );
-}
-
-PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self, PyObject * args )
-{
- if( self->renderContext->GImethod == 2 ) {
- return M_Render_GetSetAttributeInt( args,
- &self->renderContext->
- GIdepth, 1, 100 );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL'" ) );
-}
-
-PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self, PyObject * args )
-{
- if( self->renderContext->GImethod == 2 ) {
- return M_Render_GetSetAttributeInt( args,
- &self->renderContext->
- GIcausdepth, 1, 100 );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL'" ) );
-}
-
-PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self,
- PyObject * args )
-{
- if( self->renderContext->GImethod == 2 ) {
- return M_Render_BitToggleShort( args, 1,
- &self->renderContext->
- GIcache );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL'" ) );
-}
-
-PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self,
- PyObject * args )
-{
- if( self->renderContext->GImethod == 2 ) {
- return M_Render_BitToggleShort( args, 1,
- &self->renderContext->
- GIphotons );;
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL'" ) );
-}
-
-PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self,
- PyObject * args )
-{
- if( self->renderContext->GImethod == 2
- && self->renderContext->GIphotons == 1 ) {
- return M_Render_GetSetAttributeInt( args,
- &self->renderContext->
- GIphotoncount, 100000,
- 10000000 );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
-}
-
-PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self,
- PyObject * args )
-{
- if( self->renderContext->GImethod == 2
- && self->renderContext->GIphotons == 1 ) {
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->
- GIphotonradius, 0.00001f,
- 100.0f );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
-}
-
-PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self,
- PyObject * args )
-{
- if( self->renderContext->GImethod == 2
- && self->renderContext->GIphotons == 1 ) {
- return M_Render_GetSetAttributeInt( args,
- &self->renderContext->
- GImixphotons, 100, 1000 );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
-}
-
-PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self,
- PyObject * args )
-{
- if( self->renderContext->GImethod == 2
- && self->renderContext->GIphotons == 1 ) {
- return M_Render_BitToggleShort( args, 1,
- &self->renderContext->
- GIdirect );;
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
-}
-
-PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self,
- PyObject * args )
-{
- if( self->renderContext->GImethod == 2
- && self->renderContext->GIcache == 1 ) {
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->
- GIshadowquality, 0.01f,
- 1.0f );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
-}
-
-PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self,
- PyObject * args )
-{
- if( self->renderContext->GImethod == 2
- && self->renderContext->GIcache == 1 ) {
- return M_Render_GetSetAttributeInt( args,
- &self->renderContext->
- GIpixelspersample, 1, 50 );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
-}
-
-PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self,
- PyObject * args )
-{
- if( self->renderContext->GImethod == 2
- && self->renderContext->GIcache == 1 ) {
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->
- GIrefinement, 0.001f,
- 1.0f );
- } else
- return ( EXPP_ReturnPyObjError( PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
-}
-
-PyObject *RenderData_YafrayRayBias( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->YF_raybias,
- 0.0f, 10.0f );
-}
-
-PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeInt( args,
- &self->renderContext->YF_raydepth,
- 1, 80 );
-}
-
-PyObject *RenderData_YafrayGamma( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->YF_gamma,
- 0.001f, 5.0f );
-}
-
-PyObject *RenderData_YafrayExposure( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeFloat( args,
- &self->renderContext->
- YF_exposure, 0.0f, 10.0f );
-}
-
-PyObject *RenderData_YafrayProcessorCount( BPy_RenderData * self,
- PyObject * args )
-{
- return M_Render_GetSetAttributeInt( args,
- &self->renderContext->YF_numprocs,
- 1, 8 );
-}
-
-PyObject *RenderData_EnableGameFrameStretch( BPy_RenderData * self )
-{
- self->scene->framing.type = SCE_GAMEFRAMING_SCALE;
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_EnableGameFrameExpose( BPy_RenderData * self )
-{
- self->scene->framing.type = SCE_GAMEFRAMING_EXTEND;
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_EnableGameFrameBars( BPy_RenderData * self )
-{
- self->scene->framing.type = SCE_GAMEFRAMING_BARS;
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self,
- PyObject * args )
-{
- float red = 0.0f;
- float green = 0.0f;
- float blue = 0.0f;
-
- if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected three floats" ) );
-
- if( red < 0 || red > 1 )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (red)" ) );
- if( green < 0 || green > 1 )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (green)" ) );
- if( blue < 0 || blue > 1 )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (blue)" ) );
-
- self->scene->framing.col[0] = red;
- self->scene->framing.col[1] = green;
- self->scene->framing.col[2] = blue;
-
- Py_RETURN_NONE;
-}
-
-PyObject *RenderData_GetGameFrameColor( BPy_RenderData * self )
-{
- char rgb[24];
-
- sprintf( rgb, "[%.3f,%.3f,%.3f]", self->scene->framing.col[0],
- self->scene->framing.col[1], self->scene->framing.col[2] );
- return PyString_FromString( rgb );
-}
-
-#ifdef __sgi
-PyObject *RenderData_SGIMaxsize( BPy_RenderData * self, PyObject * args )
-{
- return M_Render_GetSetAttributeShort( args,
- &self->renderContext->maximsize,
- 0, 500 );
-}
-
-PyObject *RenderData_EnableSGICosmo( BPy_RenderData *self, PyObject *args )
-{
- return M_Render_BitToggleInt( args, R_COSMO,
- &self->renderContext->mode );
-}
-#else
-PyObject *RenderData_SGIMaxsize( void )
-{
- return EXPP_ReturnPyObjError( PyExc_StandardError,
- "SGI is not defined on this machine" );
-}
-
-PyObject *RenderData_EnableSGICosmo( void )
-{
- return EXPP_ReturnPyObjError( PyExc_StandardError,
- "SGI is not defined on this machine" );
-}
-#endif
-
-PyObject *RenderData_OldMapValue( BPy_RenderData * self, PyObject * args )
-{
- PyObject *tmp = M_Render_GetSetAttributeInt(args,
- &self->renderContext->framapto, 1, 900);
- self->renderContext->framelen =
- (float)self->renderContext->framapto / self->renderContext->images;
- return tmp;
-}
-
-PyObject *RenderData_NewMapValue( BPy_RenderData * self, PyObject * args )
-{
- PyObject *tmp = M_Render_GetSetAttributeInt(args,
- &self->renderContext->images, 1, 900);
- self->renderContext->framelen =
- (float)self->renderContext->framapto / self->renderContext->images;
- return tmp;
-}
-
-static PyObject *RenderData_getTimeCode( BPy_RenderData * self) {
- char tc[12];
- int h, m, s, cfa;
- double fps;
-
- fps = (double) self->renderContext->frs_sec /
- self->renderContext->frs_sec_base;
- cfa = self->renderContext->cfra-1;
- s = cfa / fps;
- m = s / 60;
- h = m / 60;
- if( h > 99 )
- return PyString_FromString("Time Greater than 99 Hours!");
-
- sprintf( tc, "%02d:%02d:%02d:%02d", h%60, m%60, s%60,
- (int) (cfa - ((int) (cfa / fps) * fps)));
- return PyString_FromString(tc);
-}
-
-/***************************************************************************/
-/* generic handlers for getting/setting attributes */
-/***************************************************************************/
-
-/*
- * get floating point attributes
- */
-
-static PyObject *RenderData_getFloatAttr( BPy_RenderData *self, void *type )
-{
- float param;
-
- switch( (int)type ) {
- case EXPP_RENDER_ATTR_GAUSSFILTER:
- param = self->renderContext->gauss;
- break;
- case EXPP_RENDER_ATTR_MBLURFACTOR:
- param = self->renderContext->blurfac;
- break;
- case EXPP_RENDER_ATTR_FPS_BASE:
- param = self->renderContext->frs_sec_base;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type constant in RenderData_getFloatAttr" );
- }
- return PyFloat_FromDouble( param );
-}
-
-/*
- * set floating point attributes which require clamping
- */
-
-static int RenderData_setFloatAttrClamp( BPy_RenderData *self, PyObject *value,
- void *type )
-{
- float *param;
- float min, max;
-
- switch( (int)type ) {
- case EXPP_RENDER_ATTR_GAUSSFILTER:
- min = 0.5f;
- max = 1.5f;
- param = &self->renderContext->gauss;
- break;
- case EXPP_RENDER_ATTR_MBLURFACTOR:
- min = 0.01f;
- max = 5.0f;
- param = &self->renderContext->blurfac;
- break;
- case EXPP_RENDER_ATTR_FPS_BASE:
- min = 1.0f;
- max = 120.0f;
- param = &self->renderContext->frs_sec_base;
- break;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type constant in RenderData_setFloatAttrClamp" );
- }
- return EXPP_setFloatClamped( value, param, min, max );
-}
-
-/*
- * get integer attributes
- */
-
-static PyObject *RenderData_getIValueAttr( BPy_RenderData *self, void *type )
-{
- long param;
-
- switch( (int)type ) {
- case EXPP_RENDER_ATTR_XPARTS:
- param = (long)self->renderContext->xparts;
- break;
- case EXPP_RENDER_ATTR_YPARTS:
- param = (long)self->renderContext->yparts;
- break;
- case EXPP_RENDER_ATTR_ASPECTX:
- param = (long)self->renderContext->xasp;
- break;
- case EXPP_RENDER_ATTR_ASPECTY:
- param = (long)self->renderContext->yasp;
- break;
- case EXPP_RENDER_ATTR_CFRAME:
- param = (long)self->renderContext->cfra;
- break;
- case EXPP_RENDER_ATTR_EFRAME:
- param = (long)self->renderContext->efra;
- break;
- case EXPP_RENDER_ATTR_SFRAME:
- param = (long)self->renderContext->sfra;
- break;
- case EXPP_RENDER_ATTR_FPS:
- param = self->renderContext->frs_sec;
- break;
- case EXPP_RENDER_ATTR_SIZEX:
- param = self->renderContext->xsch;
- break;
- case EXPP_RENDER_ATTR_SIZEY:
- param = self->renderContext->ysch;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type constant in RenderData_setIValueAttrClamp" );
- }
- return PyInt_FromLong( param );
-}
-
-/*
- * set integer attributes which require clamping
- */
-
-static int RenderData_setIValueAttrClamp( BPy_RenderData *self, PyObject *value,
- void *type )
-{
- void *param;
- int min, max, size;
-
- switch( (int)type ) {
- case EXPP_RENDER_ATTR_XPARTS:
- min = 1;
- max = 512;
- size = 'h';
- param = &self->renderContext->xparts;
- break;
- case EXPP_RENDER_ATTR_YPARTS:
- min = 1;
- max = 64;
- size = 'h';
- param = &self->renderContext->yparts;
- break;
- case EXPP_RENDER_ATTR_ASPECTX:
- min = 1;
- max = 200;
- size = 'h';
- param = &self->renderContext->xasp;
- break;
- case EXPP_RENDER_ATTR_ASPECTY:
- min = 1;
- max = 200;
- size = 'h';
- param = &self->renderContext->yasp;
- break;
- case EXPP_RENDER_ATTR_CFRAME:
- min = 1;
- max = MAXFRAME;
- size = 'h';
- param = &self->renderContext->cfra;
- break;
- case EXPP_RENDER_ATTR_EFRAME:
- min = 1;
- max = MAXFRAME;
- size = 'h';
- param = &self->renderContext->efra;
- break;
- case EXPP_RENDER_ATTR_SFRAME:
- min = 1;
- max = MAXFRAME;
- size = 'h';
- param = &self->renderContext->sfra;
- break;
- case EXPP_RENDER_ATTR_FPS:
- min = 1;
- max = 120;
- size = 'h';
- param = &self->renderContext->frs_sec;
- break;
- case EXPP_RENDER_ATTR_SIZEX:
- min = 4;
- max = 10000;
- size = 'h';
- param = &self->renderContext->xsch;
- break;
- case EXPP_RENDER_ATTR_SIZEY:
- min = 4;
- max = 10000;
- size = 'h';
- param = &self->renderContext->ysch;
- break;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type constant in RenderData_setIValueAttrClamp" );
- }
- return EXPP_setIValueClamped( value, param, min, max, size );
-}
-
-/***************************************************************************/
-/* handlers for other getting/setting attributes */
-/***************************************************************************/
-
-static PyObject *RenderData_getModeBit( BPy_RenderData *self, void* type )
-{
- return EXPP_getBitfield( &self->renderContext->mode,
- (int)type, 'i' );
-}
-
-static int RenderData_setModeBit( BPy_RenderData* self, PyObject *value,
- void* type )
-{
- return EXPP_setBitfield( value, &self->renderContext->mode,
- (int)type, 'i' );
-}
-
-#define MODE_MASK ( R_OSA | R_SHADOW | R_GAMMA | R_ENVMAP | R_EDGE | \
- R_FIELDS | R_FIELDSTILL | R_RADIO | R_BORDER | R_PANORAMA | R_CROP | \
- R_ODDFIELD | R_MBLUR | R_RAYTRACE | R_THREADS )
-
-static PyObject *RenderData_getMode( BPy_RenderData *self )
-{
- return PyInt_FromLong( (long)(self->renderContext->mode & MODE_MASK) );
-}
-
-static int RenderData_setMode( BPy_RenderData* self, PyObject *arg )
-{
- int value;
-
- if( !PyInt_Check( arg ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- value = PyInt_AsLong( arg );
- if( value & ~MODE_MASK )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "unexpected bits set in argument" );
-
- self->renderContext->mode = (short)value;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- return 0;
-}
-
-static PyObject *RenderData_getSceModeBits( BPy_RenderData *self, void* type )
-{
- return EXPP_getBitfield( &self->renderContext->scemode, (int)type, 'h' );
-}
-
-static int RenderData_setSceModeBits( BPy_RenderData* self, PyObject *value,
- void* type )
-{
- return EXPP_setBitfield( value, &self->renderContext->scemode,
- (int)type, 'h' );
-}
-
-static PyObject *RenderData_getSceMode( BPy_RenderData *self )
-{
- return PyInt_FromLong ( (long)self->renderContext->scemode );
-}
-
-static int RenderData_setSceMode( BPy_RenderData* self, PyObject *arg )
-{
- int value;
-
- if( !PyInt_Check( arg ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected int argument" );
-
- value = PyInt_AsLong( arg );
- if( value & ~( R_EXTENSION | R_DOSEQ ) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "unexpected bits set in argument" );
-
- self->renderContext->scemode = (short)value;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- return 0;
-}
-
-static PyObject *RenderData_getFramingType( BPy_RenderData *self )
-{
- return PyInt_FromLong( (long)self->scene->framing.type );
-}
-
-static int RenderData_setFramingType( BPy_RenderData *self, PyObject *value )
-{
- return EXPP_setIValueRange( value, &self->scene->framing.type,
- SCE_GAMEFRAMING_BARS, SCE_GAMEFRAMING_SCALE, 'b' );
-}
-
-static PyObject *RenderData_getEdgeColor( BPy_RenderData * self )
-{
- return Py_BuildValue( "[fff]", self->renderContext->edgeR,
- self->renderContext->edgeG, self->renderContext->edgeB );
-}
-
-static int RenderData_setEdgeColor( BPy_RenderData * self, PyObject * args )
-{
- float red, green, blue;
-
- /* if we get a list, convert to a tuple; otherwise hope for the best */
- if( PyList_Check( args ) )
- args = PySequence_Tuple( args );
- else
- Py_INCREF( args );
-
- if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) ) {
- Py_DECREF( args );
- return EXPP_ReturnIntError( PyExc_TypeError, "expected three floats" );
- }
- Py_DECREF( args );
-
- self->renderContext->edgeR = EXPP_ClampFloat( red, 0.0, 1.0 );
- self->renderContext->edgeG = EXPP_ClampFloat( green, 0.0, 1.0 );
- self->renderContext->edgeB = EXPP_ClampFloat( blue, 0.0, 1.0 );
- return 0;
-}
-
-static PyObject *RenderData_getOSALevel( BPy_RenderData * self )
-{
- return PyInt_FromLong( (long)self->renderContext->osa );
-}
-
-static PyObject *RenderData_getRenderer( BPy_RenderData * self )
-{
- return PyInt_FromLong( (long)self->renderContext->renderer );
-}
-
-static PyObject *RenderData_getImageType( BPy_RenderData * self )
-{
- return PyInt_FromLong( (long) self->renderContext->imtype );
-}
-
-static int RenderData_setGameFrameColor( BPy_RenderData * self,
- PyObject * args )
-{
- float red, green, blue;
-
- /* if we get a list, convert to a tuple; otherwise hope for the best */
- if( PyList_Check( args ) )
- args = PySequence_Tuple( args );
- else
- Py_INCREF( args );
-
- if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) ) {
- Py_DECREF( args );
- return EXPP_ReturnIntError( PyExc_TypeError, "expected three floats" );
- }
- Py_DECREF( args );
-
- self->scene->framing.col[0] = EXPP_ClampFloat( red, 0.0, 1.0 );
- self->scene->framing.col[1] = EXPP_ClampFloat( green, 0.0, 1.0 );
- self->scene->framing.col[2] = EXPP_ClampFloat( blue, 0.0, 1.0 );
- return 0;
-}
-
-static PyObject *RenderData_getGameFrameColor( BPy_RenderData * self )
-{
- return Py_BuildValue( "[fff]", self->scene->framing.col[0],
- self->scene->framing.col[1], self->scene->framing.col[2] );
-}
-
-static PyObject *RenderData_getBackbuf( BPy_RenderData * self )
-{
- return EXPP_getBitfield( &self->renderContext->bufflag,
- R_BACKBUF, 'h' );
-}
-
-static int RenderData_setBackbuf( BPy_RenderData* self, PyObject *value )
-{
- return EXPP_setBitfield( value, &self->renderContext->bufflag,
- R_BACKBUF, 'h' );
-}
-
-static int RenderData_setImagePlanes( BPy_RenderData *self, PyObject *value )
-{
- int depth;
- char *errstr = "expected int argument of 8, 24, or 32";
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-
- depth = PyInt_AsLong( value );
- if( depth != 8 && depth != 24 && depth != 32 )
- return EXPP_ReturnIntError( PyExc_ValueError, errstr );
-
- self->renderContext->planes = (short)depth;
-
- return 0;
-}
-
-static PyObject *RenderData_getImagePlanes( BPy_RenderData * self )
-{
- return PyInt_FromLong( (long) self->renderContext->planes );
-}
-
-static int RenderData_setAlphaMode( BPy_RenderData *self, PyObject *value )
-{
- return EXPP_setIValueRange( value, &self->renderContext->alphamode,
- R_ADDSKY, R_ALPHAKEY, 'h' );
-}
-
-static PyObject *RenderData_getAlphaMode( BPy_RenderData * self )
-{
- return PyInt_FromLong( (long) self->renderContext->alphamode );
-}
-
-static PyObject *RenderData_getDisplayMode( void )
-{
- return PyInt_FromLong( (long) G.displaymode );
-}
-
-static int RenderData_setDisplayMode( BPy_RenderData *self,
- PyObject *value )
-{
- return EXPP_setIValueRange( value, &G.displaymode,
- R_DISPLAYIMAGE, R_DISPLAYSCREEN, 'h' );
-}
-
-static PyObject *RenderData_getRenderPath( BPy_RenderData * self )
-{
- return PyString_FromString( self->renderContext->pic );
-}
-
-static int RenderData_setRenderPath( BPy_RenderData * self, PyObject * value )
-{
- char *name;
-
- name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a string" );
-
- if( strlen( name ) >= sizeof(self->renderContext->pic) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "render path is too long" );
-
- strcpy( self->renderContext->pic, name );
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- return 0;
-}
-
-PyObject *RenderData_getBackbufPath( BPy_RenderData * self )
-{
- return PyString_FromString( self->renderContext->backbuf );
-}
-
-static int RenderData_setBackbufPath( BPy_RenderData *self, PyObject *value )
-{
- char *name;
- Image *ima;
-
- name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected a string" );
-
- if( strlen( name ) >= sizeof(self->renderContext->backbuf) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "backbuf path is too long" );
-
- strcpy( self->renderContext->backbuf, name );
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- ima = BKE_add_image_file( name );
- if( ima )
- BKE_image_signal( ima, NULL, IMA_SIGNAL_RELOAD );
-
- return 0;
-}
-
-PyObject *RenderData_getFtypePath( BPy_RenderData * self )
-{
- return PyString_FromString( self->renderContext->ftype );
-}
-
-static int RenderData_setFtypePath( BPy_RenderData *self, PyObject *value )
-{
- char *name;
-
- name = PyString_AsString( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected a string" );
-
- if( strlen( name ) >= sizeof(self->renderContext->ftype) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "ftype path is too long" );
-
- strcpy( self->renderContext->ftype, name );
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- return 0;
-}
-
-PyObject *RenderData_getRenderWinSize( BPy_RenderData * self )
-{
- return PyInt_FromLong( (long) self->renderContext->size );
-}
-
-static int RenderData_setRenderWinSize( BPy_RenderData *self, PyObject *value )
-{
- int size;
- char *errstr = "expected int argument of 25, 50, 75, or 100";
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-
- size = PyInt_AsLong( value );
- if( size != 25 && size != 50 && size != 75 && size != 100 )
- return EXPP_ReturnIntError( PyExc_ValueError, errstr );
-
- self->renderContext->size = (short)size;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
-
- return 0;
-}
-
-static PyObject *RenderData_getMapOld( BPy_RenderData *self )
-{
- return PyInt_FromLong( (long)self->renderContext->framapto );
-}
-
-static int RenderData_setMapOld( BPy_RenderData *self, PyObject *value )
-{
- int result = EXPP_setIValueClamped( value, &self->renderContext->framapto,
- 1, 900, 'h' );
- self->renderContext->framelen =
- (float)self->renderContext->framapto / self->renderContext->images;
- return result;
-}
-
-static PyObject *RenderData_getMapNew( BPy_RenderData *self )
-{
- return PyInt_FromLong( (long)self->renderContext->images );
-}
-
-static int RenderData_setMapNew( BPy_RenderData *self, PyObject *value )
-{
- int result = EXPP_setIValueClamped( value, &self->renderContext->images,
- 1, 900, 'h' );
- self->renderContext->framelen =
- (float)self->renderContext->framapto / self->renderContext->images;
- return result;
-}
-
-static PyObject *RenderData_getSet( BPy_RenderData *self )
-{
- if( self->scene->set )
- return Scene_CreatePyObject( self->scene->set );
- Py_RETURN_NONE;
-}
-
-static int RenderData_setSet( BPy_RenderData *self, PyObject *value )
-{
- BPy_Scene *sc;
-
- /* if "None", delete the link to the scene */
- if( value == Py_None ) {
- self->scene->set = NULL;
- return 0;
- }
-
- /* be sure argument is a Scene */
- if( !BPy_Scene_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected Scene as argument" );
-
- /* check for attempt to link to ourselves */
- sc = (BPy_Scene *)value;
- if( self->scene == sc->scene )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "cannot link a scene to itself" );
-
- /*
- * Accept the set link, then check for a circular link. If circular link
- * exists, scene_check_setscene() sets self->scene->set to NULL.
- */
-
- self->scene->set = sc->scene;
- if( !scene_check_setscene( self->scene ) )
- return EXPP_ReturnIntError( PyExc_ValueError,
- "linking scene would create a cycle" );
-
- return 0;
-}
-
-
-PyObject *RenderData_getThreads( BPy_RenderData * self )
-{
- return PyInt_FromLong( (long) self->renderContext->threads );
-}
-
-static int RenderData_setThreads( BPy_RenderData *self, PyObject *value )
-{
- int threads;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError, "Error, threads must be an int" );
-
- threads = PyInt_AsLong( value );
- if (threads<1) threads = 1;
- else if (threads>8) threads = 8;
-
- self->renderContext->threads = (short)threads;
- EXPP_allqueue( REDRAWBUTSSCENE, 0 );
- return 0;
-}
-
-/***************************************************************************/
-/* BPy_RenderData attribute def */
-/***************************************************************************/
-static PyGetSetDef BPy_RenderData_getseters[] = {
- {"oversampling",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Oversampling (anti-aliasing) enabled",
- (void *)R_OSA},
- {"shadow",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Shadow calculation enabled",
- (void *)R_SHADOW},
- {"gammaCorrection",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Gamma correction enabled",
- (void *)R_GAMMA},
-/* R_ORTHO unused */
- {"environmentMap",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Environment map rendering enabled",
- (void *)R_ENVMAP},
- {"toonShading",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Toon edge shading enabled",
- (void *)R_EDGE},
- {"fieldRendering",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Field rendering enabled",
- (void *)R_FIELDS},
- {"fieldTimeDisable",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Time difference in field calculations disabled ('X' in UI)",
- (void *)R_FIELDSTILL},
- {"radiosityRender",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Radiosity rendering enabled",
- (void *)R_RADIO},
- {"borderRender",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Small cut-out rendering enabled",
- (void *)R_BORDER},
- {"panorama",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Panorama rendering enabled",
- (void *)R_PANORAMA},
- {"crop",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Crop image during border renders",
- (void *)R_CROP},
-/* R_COSMO unsupported */
- {"oddFieldFirst",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Odd field first rendering enabled",
- (void *)R_ODDFIELD},
- {"motionBlur",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Motion blur enabled",
- (void *)R_MBLUR},
- {"rayTracing",
- (getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
- "Ray tracing enabled",
- (void *)R_RAYTRACE},
-/* R_GAUSS unused */
-/* R_FBUF unused */
-/* R_THREADS unused */
- {"threads",
- (getter)RenderData_getThreads, (setter)RenderData_setThreads,
- "Number of threads used to render",
- NULL},
-/* R_SPEED unused */
- {"mode",
- (getter)RenderData_getMode, (setter)RenderData_setMode,
- "Mode bitfield",
- NULL},
-
- /* scene modes */
- {"sequencer",
- (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
- "'Do Sequence' enabled",
- (void *)R_DOSEQ},
- {"extensions",
- (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
- "Add extensions to output (when rendering animations) enabled",
- (void *)R_EXTENSION},
- {"compositor",
- (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
- "'Do Compositor' enabled.",
- (void *)R_DOCOMP},
- {"freeImages",
- (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
- "Free texture images after render.",
- (void *)R_FREE_IMAGE},
- {"singleLayer",
- (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
- "Only render the active layer.",
- (void *)R_SINGLE_LAYER},
- {"saveBuffers",
- (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
- "Save render buffers to disk while rendering, saves memory.",
- (void *)R_EXR_TILE_FILE},
- {"compositeFree",
- (getter)RenderData_getSceModeBits, (setter)RenderData_setSceModeBits,
- "Free nodes that are not used while composite.",
- (void *)R_COMP_FREE},
-
- {"sceneMode",
- (getter)RenderData_getSceMode, (setter)RenderData_setSceMode,
- "Scene mode bitfield",
- NULL},
-/* R_BG_RENDER unused */
-
- {"gameFrame",
- (getter)RenderData_getFramingType, (setter)RenderData_setFramingType,
- "Game framing type",
- NULL},
-
- {"renderPath",
- (getter)RenderData_getRenderPath, (setter)RenderData_setRenderPath,
- "The path to output the rendered images to",
- NULL},
- {"backbufPath",
- (getter)RenderData_getBackbufPath, (setter)RenderData_setBackbufPath,
- "Path to a background image (setting loads image)",
- NULL},
- {"ftypePath",
- (getter)RenderData_getFtypePath, (setter)RenderData_setFtypePath,
- "The path to Ftype file",
- NULL},
- {"edgeColor",
- (getter)RenderData_getEdgeColor, (setter)RenderData_setEdgeColor,
- "RGB color triplet for edges in Toon shading",
- NULL},
- {"OSALevel",
- (getter)RenderData_getOSALevel, (setter)RenderData_setOSALevel,
- "Oversampling (anti-aliasing) level",
- NULL},
- {"renderwinSize",
- (getter)RenderData_getRenderWinSize, (setter)RenderData_setRenderWinSize,
- "Size of the rendering window (25, 50, 75, or 100)",
- NULL},
- {"border",
- (getter)RenderData_getBorder, (setter)RenderData_setBorder,
- "The border for border rendering",
- NULL},
- {"timeCode",
- (getter)RenderData_getTimeCode, (setter)NULL,
- "Get the current frame in HH:MM:SS:FF format",
- NULL},
- {"renderer",
- (getter)RenderData_getRenderer, (setter)RenderData_setRenderer,
- "Rendering engine choice",
- NULL},
- {"imageType",
- (getter)RenderData_getImageType, (setter)RenderData_setImageType,
- "File format for saving images",
- NULL},
- {"gameFrameColor",
- (getter)RenderData_getGameFrameColor,(setter)RenderData_setGameFrameColor,
- "RGB color triplet for bars",
- NULL},
- {"backbuf",
- (getter)RenderData_getBackbuf, (setter)RenderData_setBackbuf,
- "Backbuffer image enabled",
- NULL},
- {"imagePlanes",
- (getter)RenderData_getImagePlanes, (setter)RenderData_setImagePlanes,
- "Image depth (8, 24, or 32 bits)",
- NULL},
- {"alphaMode",
- (getter)RenderData_getAlphaMode, (setter)RenderData_setAlphaMode,
- "Setting for sky/background.",
- NULL},
- {"displayMode",
- (getter)RenderData_getDisplayMode, (setter)RenderData_setDisplayMode,
- "Render output in separate window or 3D view",
- NULL},
-
- {"xParts",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "Number of horizontal parts for image render",
- (void *)EXPP_RENDER_ATTR_XPARTS},
- {"yParts",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "Number of vertical parts for image render",
- (void *)EXPP_RENDER_ATTR_YPARTS},
- {"aspectX",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "Horizontal aspect ratio",
- (void *)EXPP_RENDER_ATTR_ASPECTX},
- {"aspectY",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "Vertical aspect ratio",
- (void *)EXPP_RENDER_ATTR_ASPECTY},
- {"cFrame",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "The current frame for rendering",
- (void *)EXPP_RENDER_ATTR_CFRAME},
- {"sFrame",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "Starting frame for rendering",
- (void *)EXPP_RENDER_ATTR_SFRAME},
- {"eFrame",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "Ending frame for rendering",
- (void *)EXPP_RENDER_ATTR_EFRAME},
- {"fps",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "Frames per second",
- (void *)EXPP_RENDER_ATTR_FPS},
- {"fpsBase",
- (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
- "Frames per second base",
- (void *)EXPP_RENDER_ATTR_FPS_BASE},
- {"sizeX",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "Image width (in pixels)",
- (void *)EXPP_RENDER_ATTR_SIZEX},
- {"sizeY",
- (getter)RenderData_getIValueAttr, (setter)RenderData_setIValueAttrClamp,
- "Image height (in pixels)",
- (void *)EXPP_RENDER_ATTR_SIZEY},
-
- {"gaussFilter",
- (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
- "Gauss filter size",
- (void *)EXPP_RENDER_ATTR_GAUSSFILTER},
- {"mblurFactor",
- (getter)RenderData_getFloatAttr, (setter)RenderData_setFloatAttrClamp,
- "Motion blur factor",
- (void *)EXPP_RENDER_ATTR_MBLURFACTOR},
- {"mapOld",
- (getter)RenderData_getMapOld, (setter)RenderData_setMapOld,
- "Number of frames the Map Old will last",
- NULL},
- {"mapNew",
- (getter)RenderData_getMapNew, (setter)RenderData_setMapNew,
- "New mapping value (in frames)",
- NULL},
- {"set",
- (getter)RenderData_getSet, (setter)RenderData_setSet,
- "Scene link 'set' value",
- NULL},
-
- {"yafrayGIMethod",
- (getter)RenderData_getYafrayGIMethod, (setter)RenderData_setYafrayGIMethod,
- "Global illumination method",
- NULL},
- {"yafrayGIQuality",
- (getter)RenderData_getYafrayGIQuality, (setter)RenderData_setYafrayGIQuality,
- "Global Illumination quality",
- NULL},
- {"yafrayExportToXML",
- (getter)RenderData_getYafrayExportToXML, (setter)RenderData_setYafrayExportToXML,
- "If true export to an xml file and call yafray instead of plugin",
- NULL},
- {"yafrayAutoAntiAliasing",
- (getter)RenderData_getYafrayAutoAntiAliasing, (setter)RenderData_setYafrayAutoAntiAliasing,
- "Automatic anti-aliasing enabled/disabled",
- NULL},
- {"yafrayClampRGB",
- (getter)RenderData_getYafrayClampRGB, (setter)RenderData_setYafrayClampRGB,
- "Clamp RGB enabled/disabled",
- NULL},
- {"yafrayAntiAliasingPasses",
- (getter)RenderData_getYafrayAntiAliasingPasses, (setter)RenderData_setYafrayAntiAliasingPasses,
- "Number of anti-aliasing passes (0 is no anti-aliasing)",
- NULL},
- {"yafrayAntiAliasingSamples",
- (getter)RenderData_getYafrayAntiAliasingSamples, (setter)RenderData_setYafrayAntiAliasingSamples,
- "Number of samples per pass",
- NULL},
- {"yafrayAntiAliasingPixelSize",
- (getter)RenderData_getYafrayAntiAliasingPixelSize, (setter)RenderData_setYafrayAntiAliasingPixelSize,
- "Anti-aliasing pixel filter size",
- NULL},
- {"yafrayAntiAliasingThreshold",
- (getter)RenderData_getYafrayAntiAliasingThreshold, (setter)RenderData_setYafrayAntiAliasingThreshold,
- "Anti-aliasing threshold",
- NULL},
- {"yafrayNumberOfProcessors",
- (getter)RenderData_getYafrayNumberOfProcessors, (setter)RenderData_setYafrayNumberOfProcessors,
- "Number of processors to use",
- NULL},
- {"yafrayGICache",
- (getter)RenderData_getYafrayGICache, (setter)RenderData_setYafrayGICache,
- "Cache occlusion/irradiance samples (faster)",
- NULL},
- {"yafrayGICacheBumpNormals",
- (getter)RenderData_getYafrayGICacheBumpNormals, (setter)RenderData_setYafrayGICacheBumpNormals,
- "Enable/disable bumpnormals for cache",
- NULL},
- {"yafrayGICacheShadowQuality",
- (getter)RenderData_getYafrayGICacheShadowQuality, (setter)RenderData_setYafrayGICacheShadowQuality,
- "Shadow quality, keep it under 0.95 :-)",
- NULL},
- {"yafrayGICachePixelsPerSample",
- (getter)RenderData_getYafrayGICachePixelsPerSample, (setter)RenderData_setYafrayGICachePixelsPerSample,
- "Maximum number of pixels without samples, the lower the better and slower",
- NULL},
- {"yafrayGICacheRefinement",
- (getter)RenderData_getYafrayGICacheRefinement, (setter)RenderData_setYafrayGICacheRefinement,
- "Threshold to refine shadows EXPERIMENTAL. 1 = no refinement",
- NULL},
- {"yafrayGIPhotons",
- (getter)RenderData_getYafrayGIPhotons, (setter)RenderData_setYafrayGIPhotons,
- "Enable/disable use of global photons to help in GI",
- NULL},
- {"yafrayGITunePhotons",
- (getter)RenderData_getYafrayGITunePhotons, (setter)RenderData_setYafrayGITunePhotons,
- "If true the photonmap is shown directly in the render for tuning",
- NULL},
-
- {NULL,NULL,NULL,NULL,NULL}
-};
-
-/***************************************************************************/
-/* BPy_RenderData method def */
-/***************************************************************************/
-static PyMethodDef BPy_RenderData_methods[] = {
- {"render", ( PyCFunction ) RenderData_Render, METH_NOARGS,
- "() - render the scene"},
- {"saveRenderedImage", (PyCFunction)RenderData_SaveRenderedImage, METH_VARARGS,
- "(filename) - save an image generated by a call to render() (set output path first)"},
- {"renderAnim", ( PyCFunction ) RenderData_RenderAnim, METH_NOARGS,
- "() - render a sequence from start frame to end frame"},
- {"play", ( PyCFunction ) RenderData_Play, METH_NOARGS,
- "() - play animation of rendered images/avi (searches Pics: field)"},
- {"setRenderPath", ( PyCFunction ) RenderData_SetRenderPath,
- METH_VARARGS,
- "(string) - get/set the path to output the rendered images to"},
- {"getRenderPath", ( PyCFunction ) RenderData_getRenderPath,
- METH_NOARGS,
- "() - get the path to directory where rendered images will go"},
- {"setBackbufPath", ( PyCFunction ) RenderData_SetBackbufPath,
- METH_VARARGS,
- "(string) - get/set the path to a background image and load it"},
- {"getBackbufPath", ( PyCFunction ) RenderData_getBackbufPath,
- METH_NOARGS,
- "() - get the path to background image file"},
- {"enableBackbuf", ( PyCFunction ) RenderData_EnableBackbuf,
- METH_VARARGS,
- "(bool) - enable/disable the backbuf image"},
- {"setFtypePath", ( PyCFunction ) RenderData_SetFtypePath, METH_VARARGS,
- "(string) - get/set the path to output the Ftype file"},
- {"getFtypePath", ( PyCFunction ) RenderData_getFtypePath, METH_NOARGS,
- "() - get the path to Ftype file"},
- {"enableExtensions", ( PyCFunction ) RenderData_EnableExtensions,
- METH_VARARGS,
- "(bool) - enable/disable windows extensions for output files"},
- {"enableSequencer", ( PyCFunction ) RenderData_EnableSequencer,
- METH_VARARGS,
- "(bool) - enable/disable Do Sequence"},
- {"enableRenderDaemon", ( PyCFunction ) RenderData_EnableRenderDaemon,
- METH_VARARGS,
- "(bool) - enable/disable Scene daemon"},
- {"enableToonShading", ( PyCFunction ) RenderData_EnableToonShading,
- METH_VARARGS,
- "(bool) - enable/disable Edge rendering"},
- {"edgeIntensity", ( PyCFunction ) RenderData_EdgeIntensity,
- METH_VARARGS,
- "(int) - get/set edge intensity for toon shading"},
- {"setEdgeColor", ( PyCFunction ) RenderData_SetEdgeColor, METH_VARARGS,
- "(f,f,f) - set the edge color for toon shading - Red,Green,Blue expected."},
- {"getEdgeColor", ( PyCFunction ) RenderData_GetEdgeColor, METH_NOARGS,
- "() - get the edge color for toon shading - Red,Green,Blue expected."},
- {"enableOversampling", ( PyCFunction ) RenderData_EnableOversampling,
- METH_VARARGS,
- "(bool) - enable/disable oversampling (anit-aliasing)."},
- {"setOversamplingLevel",
- ( PyCFunction ) RenderData_SetOversamplingLevel, METH_VARARGS,
- "(enum) - get/set the level of oversampling (anit-aliasing)."},
- {"enableMotionBlur", ( PyCFunction ) RenderData_EnableMotionBlur,
- METH_VARARGS,
- "(bool) - enable/disable MBlur."},
- {"motionBlurLevel", ( PyCFunction ) RenderData_MotionBlurLevel,
- METH_VARARGS,
- "(float) - get/set the length of shutter time for motion blur."},
- {"partsX", ( PyCFunction ) RenderData_PartsX, METH_VARARGS,
- "(int) - get/set the number of parts to divide the render in the X direction"},
- {"partsY", ( PyCFunction ) RenderData_PartsY, METH_VARARGS,
- "(int) - get/set the number of parts to divide the render in the Y direction"},
- {"enableSky", ( PyCFunction ) RenderData_EnableSky, METH_NOARGS,
- "() - enable render background with sky"},
- {"enablePremultiply", ( PyCFunction ) RenderData_EnablePremultiply,
- METH_NOARGS,
- "() - enable premultiply alpha"},
- {"enableKey", ( PyCFunction ) RenderData_EnableKey, METH_NOARGS,
- "() - enable alpha and color values remain unchanged"},
- {"enableShadow", ( PyCFunction ) RenderData_EnableShadow, METH_VARARGS,
- "(bool) - enable/disable shadow calculation"},
- {"enablePanorama", ( PyCFunction ) RenderData_EnablePanorama,
- METH_VARARGS,
- "(bool) - enable/disable panorama rendering (output width is multiplied by Xparts)"},
- {"enableEnvironmentMap",
- ( PyCFunction ) RenderData_EnableEnvironmentMap, METH_VARARGS,
- "(bool) - enable/disable environment map rendering"},
- {"enableRayTracing", ( PyCFunction ) RenderData_EnableRayTracing,
- METH_VARARGS,
- "(bool) - enable/disable ray tracing"},
- {"enableRadiosityRender",
- ( PyCFunction ) RenderData_EnableRadiosityRender, METH_VARARGS,
- "(bool) - enable/disable radiosity rendering"},
- {"getRenderWinSize", ( PyCFunction ) RenderData_getRenderWinSize,
- METH_NOARGS,
- "() - get the size of the render window"},
- {"setRenderWinSize", ( PyCFunction ) RenderData_SetRenderWinSize,
- METH_VARARGS,
- "(int) - set the size of the render window"},
- {"enableFieldRendering",
- ( PyCFunction ) RenderData_EnableFieldRendering, METH_VARARGS,
- "(bool) - enable/disable field rendering"},
- {"enableOddFieldFirst", ( PyCFunction ) RenderData_EnableOddFieldFirst,
- METH_VARARGS,
- "(bool) - enable/disable Odd field first rendering (Default: Even field)"},
- {"enableFieldTimeDisable",
- ( PyCFunction ) RenderData_EnableFieldTimeDisable, METH_VARARGS,
- "(bool) - enable/disable time difference in field calculations"},
- {"enableGaussFilter", ( PyCFunction ) RenderData_EnableGaussFilter,
- METH_VARARGS,
- "(bool) - enable/disable Gauss sampling filter for antialiasing"},
- {"enableBorderRender", ( PyCFunction ) RenderData_EnableBorderRender,
- METH_VARARGS,
- "(bool) - enable/disable small cut-out rendering"},
- {"setBorder", ( PyCFunction ) RenderData_SetBorder, METH_VARARGS,
- "(f,f,f,f) - set the border for border rendering"},
- {"gaussFilterSize", ( PyCFunction ) RenderData_GaussFilterSize,
- METH_VARARGS,
- "(float) - get/sets the Gauss filter size"},
- {"startFrame", ( PyCFunction ) RenderData_StartFrame, METH_VARARGS,
- "(int) - get/set the starting frame for rendering"},
- {"currentFrame", ( PyCFunction ) RenderData_CurrentFrame, METH_VARARGS,
- "(int) - get/set the current frame for rendering"},
- {"endFrame", ( PyCFunction ) RenderData_EndFrame, METH_VARARGS,
- "(int) - get/set the ending frame for rendering"},
- {"getTimeCode", ( PyCFunction ) RenderData_getTimeCode, METH_NOARGS,
- "get the current frame in HH:MM:SS:FF format"},
- {"imageSizeX", ( PyCFunction ) RenderData_ImageSizeX, METH_VARARGS,
- "(int) - get/set the image width in pixels"},
- {"imageSizeY", ( PyCFunction ) RenderData_ImageSizeY, METH_VARARGS,
- "(int) - get/set the image height in pixels"},
- {"aspectRatioX", ( PyCFunction ) RenderData_AspectRatioX, METH_VARARGS,
- "(int) - get/set the horizontal aspect ratio"},
- {"aspectRatioY", ( PyCFunction ) RenderData_AspectRatioY, METH_VARARGS,
- "(int) - get/set the vertical aspect ratio"},
- {"setRenderer", ( PyCFunction ) RenderData_SetRenderer, METH_VARARGS,
- "(enum) - get/set which renderer to render the output"},
- {"enableCropping", ( PyCFunction ) RenderData_EnableCropping,
- METH_VARARGS,
- "(bool) - enable/disable exclusion of border rendering from total image"},
- {"setImageType", ( PyCFunction ) RenderData_SetImageType, METH_VARARGS,
- "(enum) - get/set the type of image to output from the render"},
- {"quality", ( PyCFunction ) RenderData_Quality, METH_VARARGS,
- "(int) - get/set quality get/setting for JPEG images, AVI Jpeg and SGI movies"},
- {"framesPerSec", ( PyCFunction ) RenderData_FramesPerSec, METH_VARARGS,
- "(int) - get/set frames per second"},
- {"enableGrayscale", ( PyCFunction ) RenderData_EnableGrayscale,
- METH_NOARGS,
- "() - images are saved with BW (grayscale) data"},
- {"enableRGBColor", ( PyCFunction ) RenderData_EnableRGBColor,
- METH_NOARGS,
- "() - images are saved with RGB (color) data"},
- {"enableRGBAColor", ( PyCFunction ) RenderData_EnableRGBAColor,
- METH_NOARGS,
- "() - images are saved with RGB and Alpha data (if supported)"},
- {"sizePreset", ( PyCFunction ) RenderData_SizePreset, METH_VARARGS,
- "(enum) - get/set the render to one of a few preget/sets"},
- {"setYafrayGIQuality", ( PyCFunction ) RenderData_SetYafrayGIQuality,
- METH_VARARGS,
- "(enum) - set yafray global Illumination quality"},
- {"getYafrayGIQuality", ( PyCFunction ) RenderData_GetYafrayGIQuality,
- METH_VARARGS,
- "(enum) - get yafray global Illumination quality"},
- {"setYafrayGIMethod", ( PyCFunction ) RenderData_SetYafrayGIMethod,
- METH_VARARGS,
- "(enum) - set yafray global Illumination method"},
- {"getYafrayGIMethod", ( PyCFunction ) RenderData_GetYafrayGIMethod,
- METH_VARARGS,
- "(enum) - get yafray global Illumination method"},
- {"yafrayGIPower", ( PyCFunction ) RenderData_YafrayGIPower,
- METH_VARARGS,
- "(float) - get/set GI lighting intensity scale"},
- {"yafrayGIIndirPower", ( PyCFunction ) RenderData_YafrayGIIndirPower,
- METH_VARARGS,
- "(float) - get/set GI indifect lighting intensity scale"},
- {"yafrayGIDepth", ( PyCFunction ) RenderData_YafrayGIDepth,
- METH_VARARGS,
- "(int) - get/set number of bounces of the indirect light"},
- {"yafrayGICDepth", ( PyCFunction ) RenderData_YafrayGICDepth,
- METH_VARARGS,
- "(int) - get/set number of bounces inside objects (for caustics)"},
- {"enableYafrayGICache", ( PyCFunction ) RenderData_EnableYafrayGICache,
- METH_VARARGS,
- "(bool) - enable/disable cache irradiance samples (faster)"},
- {"enableYafrayGIPhotons",
- ( PyCFunction ) RenderData_EnableYafrayGIPhotons, METH_VARARGS,
- "(bool) - enable/disable use global photons to help in GI"},
- {"yafrayGIPhotonCount", ( PyCFunction ) RenderData_YafrayGIPhotonCount,
- METH_VARARGS,
- "(int) - get/set number of photons to shoot"},
- {"yafrayGIPhotonRadius",
- ( PyCFunction ) RenderData_YafrayGIPhotonRadius, METH_VARARGS,
- "(float) - get/set radius to search for photons to mix (blur)"},
- {"yafrayGIPhotonMixCount",
- ( PyCFunction ) RenderData_YafrayGIPhotonMixCount, METH_VARARGS,
- "(int) - get/set number of photons to mix"},
- {"enableYafrayGITunePhotons",
- ( PyCFunction ) RenderData_EnableYafrayGITunePhotons, METH_VARARGS,
- "(bool) - enable/disable show the photonmap directly in the render for tuning"},
- {"yafrayGIShadowQuality",
- ( PyCFunction ) RenderData_YafrayGIShadowQuality, METH_VARARGS,
- "(float) - get/set the shadow quality, keep it under 0.95"},
- {"yafrayGIPixelsPerSample",
- ( PyCFunction ) RenderData_YafrayGIPixelsPerSample, METH_VARARGS,
- "(int) - get/set maximum number of pixels without samples, the lower the better and slower"},
- {"yafrayGIRefinement", ( PyCFunction ) RenderData_YafrayGIRefinement,
- METH_VARARGS,
- "(float) - get/setthreshold to refine shadows EXPERIMENTAL. 1 = no refinement"},
- {"yafrayRayBias", ( PyCFunction ) RenderData_YafrayRayBias,
- METH_VARARGS,
- "(float) - get/set shadow ray bias to avoid self shadowing"},
- {"yafrayRayDepth", ( PyCFunction ) RenderData_YafrayRayDepth,
- METH_VARARGS,
- "(int) - get/set maximum render ray depth from the camera"},
- {"yafrayGamma", ( PyCFunction ) RenderData_YafrayGamma, METH_VARARGS,
- "(float) - get/set gamma correction, 1 is off"},
- {"yafrayExposure", ( PyCFunction ) RenderData_YafrayExposure,
- METH_VARARGS,
- "(float) - get/set exposure adjustment, 0 is off"},
- {"yafrayProcessorCount",
- ( PyCFunction ) RenderData_YafrayProcessorCount, METH_VARARGS,
- "(int) - get/set number of processors to use"},
- {"enableGameFrameStretch",
- ( PyCFunction ) RenderData_EnableGameFrameStretch, METH_NOARGS,
- "(l) - enble stretch or squeeze the viewport to fill the display window"},
- {"enableGameFrameExpose",
- ( PyCFunction ) RenderData_EnableGameFrameExpose, METH_NOARGS,
- "(l) - enable show the entire viewport in the display window, viewing more horizontally or vertically"},
- {"enableGameFrameBars", ( PyCFunction ) RenderData_EnableGameFrameBars,
- METH_NOARGS,
- "() - enable show the entire viewport in the display window, using bar horizontally or vertically"},
- {"setGameFrameColor", ( PyCFunction ) RenderData_SetGameFrameColor,
- METH_VARARGS,
- "(f,f,f) - set the red, green, blue component of the bars"},
- {"getGameFrameColor", ( PyCFunction ) RenderData_GetGameFrameColor,
- METH_NOARGS,
- "() - get the red, green, blue component of the bars"},
- {"SGIMaxsize", ( PyCFunction ) RenderData_SGIMaxsize, METH_VARARGS,
- "(int) - get/set maximum size per frame to save in an SGI movie"},
- {"enableSGICosmo", ( PyCFunction ) RenderData_EnableSGICosmo,
- METH_VARARGS,
- "(bool) - enable/disable attempt to save SGI movies using Cosmo hardware"},
- {"oldMapValue", ( PyCFunction ) RenderData_OldMapValue, METH_VARARGS,
- "(int) - get/set specify old map value in frames"},
- {"newMapValue", ( PyCFunction ) RenderData_NewMapValue, METH_VARARGS,
- "(int) - get/set specify new map value in frames"},
- {NULL, NULL, 0, NULL}
-};
-
-/*------------------------------------BPy_RenderData Type defintion------ */
-PyTypeObject RenderData_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender RenderData", /* char *tp_name; */
- sizeof( BPy_RenderData ), /* 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 ) RenderData_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_RenderData_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_RenderData_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
-};
-
-/***************************************************************************/
-/* Render method def */
-/***************************************************************************/
-struct PyMethodDef M_Render_methods[] = {
- {"CloseRenderWindow", ( PyCFunction ) M_Render_CloseRenderWindow,
- METH_NOARGS,
- "() - close the rendering window"},
- {"EnableDispView", ( PyCFunction ) M_Render_EnableDispView,
- METH_NOARGS,
- "(bool) - enable Sceneing in view"},
- {"EnableDispWin", ( PyCFunction ) M_Render_EnableDispWin, METH_NOARGS,
- "(bool) - enable Sceneing in new window"},
- {"SetRenderWinPos", ( PyCFunction ) M_Render_SetRenderWinPos,
- METH_VARARGS,
- "([string list]) - position the rendering window in around the edge of the screen"},
- {NULL, NULL, 0, NULL}
-};
-
-static PyObject *M_Render_ModesDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "OSA", PyInt_FromLong( R_OSA ) );
- PyConstant_Insert( d, "SHADOW", PyInt_FromLong( R_SHADOW ) );
- PyConstant_Insert( d, "GAMMA", PyInt_FromLong( R_GAMMA ) );
- PyConstant_Insert( d, "ENVMAP", PyInt_FromLong( R_ENVMAP ) );
- PyConstant_Insert( d, "TOONSHADING", PyInt_FromLong( R_EDGE ) );
- PyConstant_Insert( d, "FIELDRENDER", PyInt_FromLong( R_FIELDS ) );
- PyConstant_Insert( d, "FIELDTIME", PyInt_FromLong( R_FIELDSTILL ) );
- PyConstant_Insert( d, "RADIOSITY", PyInt_FromLong( R_RADIO ) );
- PyConstant_Insert( d, "BORDER_RENDER", PyInt_FromLong( R_BORDER ) );
- PyConstant_Insert( d, "PANORAMA", PyInt_FromLong( R_PANORAMA ) );
- PyConstant_Insert( d, "CROP", PyInt_FromLong( R_CROP ) );
- PyConstant_Insert( d, "ODDFIELD", PyInt_FromLong( R_ODDFIELD ) );
- PyConstant_Insert( d, "MBLUR", PyInt_FromLong( R_MBLUR ) );
- PyConstant_Insert( d, "RAYTRACING", PyInt_FromLong( R_RAYTRACE ) );
- PyConstant_Insert( d, "THREADS", PyInt_FromLong( R_THREADS ) );
- }
- return M;
-}
-
-static PyObject *M_Render_SceModesDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "SEQUENCER", PyInt_FromLong( R_DOSEQ ) );
- PyConstant_Insert( d, "EXTENSION", PyInt_FromLong( R_EXTENSION ) );
- }
- return M;
-}
-
-static PyObject *M_Render_GameFramingDict( void )
-{
- PyObject *M = PyConstant_New( );
-
- if( M ) {
- BPy_constant *d = ( BPy_constant * ) M;
- PyConstant_Insert( d, "BARS",
- PyInt_FromLong( SCE_GAMEFRAMING_BARS ) );
- PyConstant_Insert( d, "EXTEND",
- PyInt_FromLong( SCE_GAMEFRAMING_EXTEND ) );
- PyConstant_Insert( d, "SCALE",
- PyInt_FromLong( SCE_GAMEFRAMING_SCALE ) );
- }
- return M;
-}
-
-/***************************************************************************/
-/* Render Module Init */
-/***************************************************************************/
-PyObject *Render_Init( void )
-{
- PyObject *submodule;
- PyObject *ModesDict = M_Render_ModesDict( );
- PyObject *SceModesDict = M_Render_SceModesDict( );
- PyObject *GFramingDict = M_Render_GameFramingDict( );
-
- if( PyType_Ready( &RenderData_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Scene.Render",
- M_Render_methods, M_Render_doc );
-
- if( ModesDict )
- PyModule_AddObject( submodule, "Modes", ModesDict );
- if( SceModesDict )
- PyModule_AddObject( submodule, "SceModes", SceModesDict );
- if( GFramingDict )
- PyModule_AddObject( submodule, "FramingModes", GFramingDict );
-
- /* ugh: why aren't these in a constant dict? */
-
- PyModule_AddIntConstant( submodule, "INTERNAL", R_INTERN );
- PyModule_AddIntConstant( submodule, "YAFRAY", R_YAFRAY );
- PyModule_AddIntConstant( submodule, "AVIRAW", R_AVIRAW );
- PyModule_AddIntConstant( submodule, "AVIJPEG", R_AVIJPEG );
- PyModule_AddIntConstant( submodule, "AVICODEC", R_AVICODEC );
- PyModule_AddIntConstant( submodule, "QUICKTIME", R_QUICKTIME );
- PyModule_AddIntConstant( submodule, "TARGA", R_TARGA );
- PyModule_AddIntConstant( submodule, "RAWTGA", R_RAWTGA );
- PyModule_AddIntConstant( submodule, "HDR", R_RADHDR );
- PyModule_AddIntConstant( submodule, "PNG", R_PNG );
- PyModule_AddIntConstant( submodule, "BMP", R_BMP );
- PyModule_AddIntConstant( submodule, "JPEG", R_JPEG90 );
- PyModule_AddIntConstant( submodule, "HAMX", R_HAMX );
- PyModule_AddIntConstant( submodule, "IRIS", R_IRIS );
- PyModule_AddIntConstant( submodule, "IRISZ", R_IRIZ );
- PyModule_AddIntConstant( submodule, "FTYPE", R_FTYPE );
- PyModule_AddIntConstant( submodule, "PAL", B_PR_PAL );
- PyModule_AddIntConstant( submodule, "NTSC", B_PR_NTSC );
- PyModule_AddIntConstant( submodule, "DEFAULT", B_PR_PRESET );
- PyModule_AddIntConstant( submodule, "PREVIEW", B_PR_PRV );
- PyModule_AddIntConstant( submodule, "PC", B_PR_PC );
- PyModule_AddIntConstant( submodule, "PAL169", B_PR_PAL169 );
- PyModule_AddIntConstant( submodule, "PANO", B_PR_PANO );
- PyModule_AddIntConstant( submodule, "FULL", B_PR_FULL );
- PyModule_AddIntConstant( submodule, "NONE", PY_NONE );
- PyModule_AddIntConstant( submodule, "LOW", PY_LOW );
- PyModule_AddIntConstant( submodule, "MEDIUM", PY_MEDIUM );
- PyModule_AddIntConstant( submodule, "HIGH", PY_HIGH );
- PyModule_AddIntConstant( submodule, "HIGHER", PY_HIGHER );
- PyModule_AddIntConstant( submodule, "BEST", PY_BEST );
- PyModule_AddIntConstant( submodule, "USEAOSETTINGS", PY_USEAOSETTINGS );
- PyModule_AddIntConstant( submodule, "SKYDOME", PY_SKYDOME );
- PyModule_AddIntConstant( submodule, "GIFULL", PY_FULL );
- PyModule_AddIntConstant( submodule, "OPENEXR", R_OPENEXR );
- PyModule_AddIntConstant( submodule, "TIFF", R_TIFF );
- PyModule_AddIntConstant( submodule, "FFMPEG", R_FFMPEG );
- PyModule_AddIntConstant( submodule, "CINEON", R_CINEON );
- PyModule_AddIntConstant( submodule, "DPX", R_DPX );
-
- return ( submodule );
-}
-
-/***************************************************************************/
-/* BPy_RenderData Callbacks */
-/***************************************************************************/
-
-PyObject *RenderData_CreatePyObject( struct Scene * scene )
-{
- BPy_RenderData *py_renderdata;
-
- py_renderdata =
- ( BPy_RenderData * ) PyObject_NEW( BPy_RenderData,
- &RenderData_Type );
-
- if( py_renderdata == NULL ) {
- return ( NULL );
- }
- py_renderdata->renderContext = &scene->r;
- py_renderdata->scene = scene;
-
- return ( ( PyObject * ) py_renderdata );
-}
-
-/* #####DEPRECATED###### */
-
-static PyObject *RenderData_SetRenderPath( BPy_RenderData *self,
- PyObject *args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)RenderData_setRenderPath );
-}
-
-static PyObject *RenderData_SetBackbufPath( BPy_RenderData *self,
- PyObject *args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)RenderData_setBackbufPath );
-}
-
-static PyObject *RenderData_SetFtypePath( BPy_RenderData *self,
- PyObject *args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)RenderData_setFtypePath );
-}
-
-static PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self,
- PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)RenderData_setOSALevel );
-}
-
-static PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self,
- PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)RenderData_setRenderWinSize );
-}
-
-static PyObject *RenderData_SetBorder( BPy_RenderData * self,
- PyObject * args )
-{
- return EXPP_setterWrapperTuple( (void *)self, args,
- (setter)RenderData_setBorder );
-}
-
-static PyObject *RenderData_SetRenderer( BPy_RenderData * self,
- PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)RenderData_setRenderer );
-}
-
-static PyObject *RenderData_SetImageType( BPy_RenderData * self,
- PyObject * args )
-{
- return EXPP_setterWrapper( (void *)self, args,
- (setter)RenderData_setImageType );
-}
diff --git a/source/blender/python/api2_2x/sceneRender.h b/source/blender/python/api2_2x/sceneRender.h
deleted file mode 100644
index df9e59b73e1..00000000000
--- a/source/blender/python/api2_2x/sceneRender.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * $Id: sceneRender.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_SCENERENDER_H
-#define EXPP_SCENERENDER_H
-
-#include <Python.h>
-#include "DNA_scene_types.h"
-
-#define BPy_RenderData_Check(v) ((v)->ob_type == &RenderData_Type)
-
-//------------------------------------Struct definitions-------
-typedef struct {
- PyObject_HEAD
- struct RenderData *renderContext;
- Scene *scene;
-} BPy_RenderData;
-//------------------------------------Visible prototypes-------
-PyObject *Render_Init( void );
-
-PyObject *RenderData_CreatePyObject( struct Scene *scene );
-
-#endif /* EXPP_SCENERENDER_H */
diff --git a/source/blender/python/api2_2x/sceneSequence.c b/source/blender/python/api2_2x/sceneSequence.c
deleted file mode 100644
index 86e36655c28..00000000000
--- a/source/blender/python/api2_2x/sceneSequence.c
+++ /dev/null
@@ -1,1163 +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 "sceneSequence.h" /* This must come first */
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_sequence_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 "BIF_editseq.h" /* get_last_seq */
-#include "BLI_blenlib.h"
-#include "BSE_sequence.h"
-#include "Ipo.h"
-#include "blendef.h" /* CLAMP */
-#include "BKE_utildefines.h"
-#include "Scene.h"
-#include "Sound.h"
-#include "gen_utils.h"
-
-enum seq_consts {
- EXPP_SEQ_ATTR_TYPE = 0,
- EXPP_SEQ_ATTR_CHAN,
- EXPP_SEQ_ATTR_LENGTH,
- EXPP_SEQ_ATTR_START,
- EXPP_SEQ_ATTR_STARTOFS,
- EXPP_SEQ_ATTR_ENDOFS,
- EXPP_SEQ_ATTR_STARTSTILL,
- EXPP_SEQ_ATTR_ENDSTILL
-};
-
-
-/*****************************************************************************/
-/* Python API function prototypes for the Blender module. */
-/*****************************************************************************/
-/*PyObject *M_Sequence_Get( PyObject * self, PyObject * args );*/
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Object module: */
-/*****************************************************************************/
-/*struct PyMethodDef M_Sequence_methods[] = {
- {"Get", ( PyCFunction ) M_Sequence_Get, METH_VARARGS,
-"(name) - return the sequence with the name 'name',\
-returns None if notfound.\nIf 'name' is not specified, it returns a list of all sequences."},
- {NULL, NULL, 0, NULL}
-};*/
-
-/*****************************************************************************/
-/* Python BPy_Sequence methods table: */
-/*****************************************************************************/
-static PyObject *Sequence_copy( BPy_Sequence * self );
-static PyObject *Sequence_new( BPy_Sequence * self, PyObject * args );
-static PyObject *Sequence_remove( BPy_Sequence * self, PyObject * args );
-
-static PyObject *SceneSeq_new( BPy_SceneSeq * self, PyObject * args );
-static PyObject *SceneSeq_remove( BPy_SceneSeq * self, PyObject * args );
-static void intern_pos_update(Sequence * seq);
-
-static PyMethodDef BPy_Sequence_methods[] = {
- /* name, method, flags, doc */
- {"new", ( PyCFunction ) Sequence_new, METH_VARARGS,
- "(data) - Return a new sequence."},
- {"remove", ( PyCFunction ) Sequence_remove, METH_VARARGS,
- "(data) - Remove a strip."},
- {"__copy__", ( PyCFunction ) Sequence_copy, METH_NOARGS,
- "() - Return a copy of the sequence containing the same objects."},
- {"copy", ( PyCFunction ) Sequence_copy, METH_NOARGS,
- "() - Return a copy of the sequence containing the same objects."},
- {NULL, NULL, 0, NULL}
-};
-
-static PyMethodDef BPy_SceneSeq_methods[] = {
- /* name, method, flags, doc */
- {"new", ( PyCFunction ) SceneSeq_new, METH_VARARGS,
- "(data) - Return a new sequence."},
- {"remove", ( PyCFunction ) SceneSeq_remove, METH_VARARGS,
- "(data) - Remove a strip."},
- {NULL, NULL, 0, NULL}
-};
-
-/* use to add a sequence to a scene or its listbase */
-static PyObject *NewSeq_internal(ListBase *seqbase, PyObject * args, Scene *sce)
-{
- PyObject *py_data = NULL;
-
- Sequence *seq;
- int a;
- Strip *strip;
- StripElem *se;
- int start, machine;
-
- if( !PyArg_ParseTuple( args, "Oii", &py_data, &start, &machine ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expect sequence data then 2 ints - (seqdata, start, track)" );
-
- seq = alloc_sequence(seqbase, start, machine); /* warning, this sets last */
-
- if (PyTuple_Check(py_data)) {
- /* Image */
- PyObject *list;
- char *name;
-
- if (!PyArg_ParseTuple( py_data, "sO!", &name, &PyList_Type, &list)) {
- BLI_remlink(seqbase, seq);
- MEM_freeN(seq);
-
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "images data needs to be a tuple of a string and a list of images - (path, [filenames...])" );
- }
-
- seq->type= SEQ_IMAGE;
-
- seq->len = PyList_Size( list );
-
-
- /* strip and stripdata */
- seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
- strip->len= seq->len;
- strip->us= 1;
- strncpy(strip->dir, name, FILE_MAXDIR-1);
- strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
-
- for(a=0; a<seq->len; a++) {
- name = PyString_AsString(PyList_GetItem( list, a ));
- strncpy(se->name, name, FILE_MAXFILE-1);
- se++;
- }
-
- } else if (BPy_Sound_Check(py_data)) {
- /* sound */
- int totframe;
- bSound *sound = (( BPy_Sound * )py_data)->sound;
-
-
- seq->type= SEQ_RAM_SOUND;
- seq->sound = sound;
-
- totframe= (int) ( ((float)(sound->streamlen-1)/( (float)sce->audio.mixrate*4.0 ))* (float)sce->r.frs_sec / sce->r.frs_sec_base);
-
- sound->flags |= SOUND_FLAGS_SEQUENCE;
-
-
- /* strip and stripdata */
- seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
- strip->len= totframe;
- strip->us= 1;
- strncpy(strip->dir, sound->name, FILE_MAXDIR-1);
- strip->stripdata= se= MEM_callocN(sizeof(StripElem), "stripelem");
-
- /* name sound in first strip */
- strncpy(se->name, sound->name, FILE_MAXFILE-1);
-
- } else if (BPy_Scene_Check(py_data)) {
- /* scene */
- Scene *sce = ((BPy_Scene *)py_data)->scene;
-
- seq->type= SEQ_SCENE;
- seq->scene= sce;
-
- /*seq->sfra= sce->r.sfra;*/
- seq->len= sce->r.efra - sce->r.sfra + 1;
-
- seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
- strncpy(seq->name + 2, sce->id.name + 2,
- sizeof(seq->name) - 2);
- strip->len= seq->len;
- strip->us= 1;
- } else {
- /* movie, pydata is a path to a movie file */
- char *name = PyString_AsString ( py_data );
- if (!name) {
- /* only free these 2 because other stuff isnt set */
- BLI_remlink(seqbase, seq);
- MEM_freeN(seq);
-
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expects a string for chan/bone name and an int for the frame where to put the new key" );
- }
-
- seq->type= SEQ_MOVIE;
- }
- strncpy(seq->name+2, "Untitled", 21);
- intern_pos_update(seq);
- return Sequence_CreatePyObject(seq, NULL, sce);
-}
-
-static PyObject *Sequence_new( BPy_Sequence * self, PyObject * args )
-{
- return NewSeq_internal(&self->seq->seqbase, args, self->scene);
-}
-
-static PyObject *SceneSeq_new( BPy_SceneSeq * self, PyObject * args )
-{
- return NewSeq_internal( &((Editing *)self->scene->ed)->seqbase, args, self->scene);
-}
-
-static void del_seq__internal(Sequence *seq)
-{
- if(seq->ipo) seq->ipo->id.us--;
-
- if(seq->type==SEQ_RAM_SOUND && seq->sound)
- seq->sound->id.us--;
- free_sequence(seq);
-}
-
-static void recurs_del_seq(ListBase *lb)
-{
- Sequence *seq, *seqn;
-
- seq= lb->first;
- while(seq) {
- seqn= seq->next;
- BLI_remlink(lb, seq);
- if(seq->type==SEQ_META) recurs_del_seq(&seq->seqbase);
- del_seq__internal(seq);
- seq= seqn;
- }
-}
-
-static PyObject *RemoveSeq_internal(ListBase *seqbase, PyObject * args, Scene *sce)
-{
- BPy_Sequence *bpy_seq = NULL;
-
- if( !PyArg_ParseTuple( args, "O!", &Sequence_Type, &bpy_seq ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "expects a sequence object" );
-
- /* quick way to tell if we dont have the seq */
- if (sce != bpy_seq->scene)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Sequence does not exist here, cannot remove" );
-
- recurs_del_seq(&bpy_seq->seq->seqbase);
- del_seq__internal(bpy_seq->seq);
- clear_last_seq(); /* just incase */
- Py_RETURN_NONE;
-}
-
-static PyObject *Sequence_remove( BPy_Sequence * self, PyObject * args )
-{
- return RemoveSeq_internal(&self->seq->seqbase, args, self->scene);
-}
-
-static PyObject *SceneSeq_remove( BPy_SceneSeq * self, PyObject * args )
-{
- return RemoveSeq_internal( &((Editing *)self->scene->ed)->seqbase, args, self->scene);
-}
-
-
-static PyObject *Sequence_copy( BPy_Sequence * self )
-{
- printf("Sequence Copy not implimented yet!\n");
- Py_RETURN_NONE;
-}
-
-/*****************************************************************************/
-/* PythonTypeObject callback function prototypes */
-/*****************************************************************************/
-static PyObject *Sequence_repr( BPy_Sequence * obj );
-static PyObject *SceneSeq_repr( BPy_SceneSeq * obj );
-static int Sequence_compare( BPy_Sequence * a, BPy_Sequence * b );
-static int SceneSeq_compare( BPy_SceneSeq * a, BPy_SceneSeq * b );
-
-/*****************************************************************************/
-/* Python BPy_Sequence methods: */
-/*****************************************************************************/
-
-
-static PyObject *Sequence_getIter( BPy_Sequence * self )
-{
- Sequence *iter = self->seq->seqbase.first;
-
- if (!self->iter) {
- self->iter = iter;
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- return Sequence_CreatePyObject(self->seq, iter, self->scene);
- }
-}
-
-static PyObject *SceneSeq_getIter( BPy_SceneSeq * self )
-{
- Sequence *iter = ((Editing *)self->scene->ed)->seqbase.first;
-
- if (!self->iter) {
- self->iter = iter;
- return EXPP_incr_ret ( (PyObject *) self );
- } else {
- return SceneSeq_CreatePyObject(self->scene, iter);
- }
-}
-
-
-/*
- * Return next Seq
- */
-static PyObject *Sequence_nextIter( BPy_Sequence * self )
-{
- PyObject *object;
- if( !(self->iter) ) {
- self->iter = NULL; /* so we can add objects again */
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- object= Sequence_CreatePyObject( self->iter, NULL, self->scene );
- self->iter= self->iter->next;
- return object;
-}
-
-
-/*
- * Return next Seq
- */
-static PyObject *SceneSeq_nextIter( BPy_Sequence * self )
-{
- PyObject *object;
- if( !(self->iter) ) {
- self->iter = NULL; /* so we can add objects again */
- return EXPP_ReturnPyObjError( PyExc_StopIteration,
- "iterator at end" );
- }
-
- object= Sequence_CreatePyObject( self->iter, NULL, self->scene );
- self->iter= self->iter->next;
- return object;
-}
-
-
-
-static PyObject *Sequence_getName( BPy_Sequence * self )
-{
- return PyString_FromString( self->seq->name+2 );
-}
-
-static int Sequence_setName( BPy_Sequence * self, PyObject * value )
-{
- char *name = NULL;
-
- name = PyString_AsString ( value );
- if( !name )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string argument" );
-
- strncpy(self->seq->name+2, name, 21);
- return 0;
-}
-
-
-static PyObject *Sequence_getSound( BPy_Sequence * self )
-{
- if (self->seq->type == SEQ_RAM_SOUND && self->seq->sound)
- return Sound_CreatePyObject(self->seq->sound);
- Py_RETURN_NONE;
-}
-
-static PyObject *Sequence_getIpo( BPy_Sequence * self )
-{
- struct Ipo *ipo;
-
- ipo = self->seq->ipo;
-
- if( ipo )
- return Ipo_CreatePyObject( ipo );
- Py_RETURN_NONE;
-}
-
-
-static PyObject *SceneSeq_getActive( BPy_SceneSeq * self )
-{
- Sequence *last_seq = NULL, *seq;
- Editing *ed = self->scene->ed;
-
- if (!ed)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "scene has no sequence data to edit" );
-
- seq = ed->seqbasep->first;
-
- while (seq) {
- if (seq->flag & SELECT)
- last_seq = seq;
-
- seq = seq->next;
- }
- if (last_seq)
- return Sequence_CreatePyObject(last_seq, NULL, self->scene );
-
- Py_RETURN_NONE;
-}
-
-static PyObject *SceneSeq_getMetaStrip( BPy_SceneSeq * self )
-{
- Sequence *seq = NULL;
- Editing *ed = self->scene->ed;
- MetaStack *ms;
- if (!ed)
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "scene has no sequence data to edit" );
-
- ms = ed->metastack.last;
- if (!ms)
- Py_RETURN_NONE;
-
- seq = ms->parseq;
- return Sequence_CreatePyObject(seq, NULL, self->scene);
-}
-
-
-/*
- * this should accept a Py_None argument and just delete the Ipo link
- * (as Object_clearIpo() does)
- */
-
-static int Sequence_setIpo( BPy_Sequence * self, PyObject * value )
-{
- Ipo *ipo = NULL;
- Ipo *oldipo;
- ID *id;
-
- oldipo = self->seq->ipo;
-
- /* if parameter is not None, check for valid Ipo */
-
- if ( value != Py_None ) {
- if ( !BPy_Ipo_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected an Ipo object" );
-
- ipo = Ipo_FromPyObject( value );
-
- if( !ipo )
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "null ipo!" );
-
- if( ipo->blocktype != ID_SEQ )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Ipo is not a sequence data Ipo" );
- }
-
- /* if already linked to Ipo, delete link */
-
- if ( oldipo ) {
- id = &oldipo->id;
- if( id->us > 0 )
- id->us--;
- }
-
- /* assign new Ipo and increment user count, or set to NULL if deleting */
-
- self->seq->ipo = ipo;
- if ( ipo )
- id_us_plus(&ipo->id);
-
- return 0;
-}
-
-static PyObject *Sequence_getScene( BPy_Sequence * self )
-{
- struct Scene *scene;
-
- scene = self->seq->scene;
-
- if( scene )
- return Scene_CreatePyObject( scene );
- Py_RETURN_NONE;
-}
-
-
-static PyObject *Sequence_getImages( BPy_Sequence * self )
-{
- Strip *strip;
- StripElem *se;
- int i;
- PyObject *list, *ret;
-
- if (self->seq->type != SEQ_IMAGE) {
- list = PyList_New(0);
- ret= Py_BuildValue( "sO", "", list);
- Py_DECREF(list);
- return ret;
- }
-
- /*return EXPP_ReturnPyObjError( PyExc_TypeError,
- "Sequence is not an image type" );*/
-
-
- strip = self->seq->strip;
- se = strip->stripdata;
- list = PyList_New(strip->len);
-
- for (i=0; i<strip->len; i++, se++) {
- PyList_SetItem( list, i, PyString_FromString(se->name) );
- }
-
- ret= Py_BuildValue( "sO", strip->dir, list);
- Py_DECREF(list);
- return ret;
-}
-
-static int Sequence_setImages( BPy_Sequence * self, PyObject *value )
-{
- Strip *strip;
- StripElem *se;
- int i;
- PyObject *list;
- char *basepath, *name;
-
- if (self->seq->type != SEQ_IMAGE) {
- return EXPP_ReturnIntError( PyExc_TypeError,
- "Sequence is not an image type" );
- }
-
- if( !PyArg_ParseTuple
- ( value, "sO!", &basepath, &PyList_Type, &list ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string and optional list argument" );
-
- strip = self->seq->strip;
- se = strip->stripdata;
-
- /* for now dont support different image list sizes */
- if (PyList_Size(list) != strip->len) {
- return EXPP_ReturnIntError( PyExc_TypeError,
- "at the moment only image lista with the same number of images as the strip are supported" );
- }
-
- strncpy(strip->dir, basepath, sizeof(strip->dir));
-
- for (i=0; i<strip->len; i++, se++) {
- name = PyString_AsString(PyList_GetItem(list, i));
- if (name) {
- strncpy(se->name, name, sizeof(se->name));
- } else {
- PyErr_Clear();
- }
- }
-
- return 0;
-}
-
-/*
- * get floating point attributes
- */
-static PyObject *getIntAttr( BPy_Sequence *self, void *type )
-{
- int param;
- struct Sequence *seq= self->seq;
-
- /*printf("%i %i %i %i %i %i %i %i %i\n", seq->len, seq->start, seq->startofs, seq->endofs, seq->startstill, seq->endstill, seq->startdisp, seq->enddisp, seq->depth );*/
- switch( (int)type ) {
- case EXPP_SEQ_ATTR_TYPE:
- param = seq->type;
- break;
- case EXPP_SEQ_ATTR_CHAN:
- param = seq->machine;
- break;
- case EXPP_SEQ_ATTR_LENGTH:
- param = seq->len;
- break;
- case EXPP_SEQ_ATTR_START:
- param = seq->start;
- break;
- case EXPP_SEQ_ATTR_STARTOFS:
- param = seq->startofs;
- break;
- case EXPP_SEQ_ATTR_ENDOFS:
- param = seq->endofs;
- break;
- case EXPP_SEQ_ATTR_STARTSTILL:
- param = seq->startstill;
- break;
- case EXPP_SEQ_ATTR_ENDSTILL:
- param = seq->endstill;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "undefined type in getIntAttr" );
- }
-
- return PyInt_FromLong( param );
-}
-
-/* internal functions for recursivly updating metastrip locatons */
-static void intern_pos_update(Sequence * seq) {
- /* update startdisp and enddisp */
- calc_sequence_disp(seq);
-}
-
-void intern_recursive_pos_update(Sequence * seq, int offset) {
- Sequence *iterseq;
- intern_pos_update(seq);
- if (seq->type != SEQ_META) return;
-
- for (iterseq = seq->seqbase.first; iterseq; iterseq= iterseq->next) {
- iterseq->start -= offset;
- intern_recursive_pos_update(iterseq, offset);
- }
-}
-
-
-static int setIntAttrClamp( BPy_Sequence *self, PyObject *value, void *type )
-{
- struct Sequence *seq= self->seq;
- int number, origval=0;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError, "expected an int value" );
-
- number = PyInt_AS_LONG( value );
-
- switch( (int)type ) {
- case EXPP_SEQ_ATTR_CHAN:
- CLAMP(number, 1, 1024);
- seq->machine = number;
- break;
- case EXPP_SEQ_ATTR_START:
- if (self->seq->type == SEQ_EFFECT)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "cannot set the location of an effect directly" );
- CLAMP(number, -MAXFRAME, MAXFRAME);
- origval = seq->start;
- seq->start = number;
- break;
-
- case EXPP_SEQ_ATTR_STARTOFS:
- if (self->seq->type == SEQ_EFFECT)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This property dosnt apply to an effect" );
- CLAMP(number, 0, seq->len - seq->endofs);
- seq->startofs = number;
- break;
- case EXPP_SEQ_ATTR_ENDOFS:
- if (self->seq->type == SEQ_EFFECT)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This property dosnt apply to an effect" );
- CLAMP(number, 0, seq->len - seq->startofs);
- seq->endofs = number;
- break;
- case EXPP_SEQ_ATTR_STARTSTILL:
- if (self->seq->type == SEQ_EFFECT)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This property dosnt apply to an effect" );
- CLAMP(number, 1, MAXFRAME);
- seq->startstill = number;
- break;
- case EXPP_SEQ_ATTR_ENDSTILL:
- if (self->seq->type == SEQ_EFFECT)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "This property dosnt apply to an effect" );
- CLAMP(number, seq->startstill+1, MAXFRAME);
- seq->endstill = number;
- break;
- case EXPP_SEQ_ATTR_LENGTH:
- if (self->seq->type == SEQ_EFFECT)
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "cannot set the length of an effect directly" );
- CLAMP(number, 1, MAXFRAME);
- origval = seq->len;
- seq->start = number;
- break;
- default:
- return EXPP_ReturnIntError( PyExc_RuntimeError,
- "undefined type in setFloatAttrClamp" );
- }
-
- intern_pos_update(seq);
-
- if ((int)type == EXPP_SEQ_ATTR_START && number != origval )
- intern_recursive_pos_update(seq, origval - seq->start);
-
- return 0;
-}
-
-
-static PyObject *getFlagAttr( BPy_Sequence *self, void *type )
-{
- if (self->seq->flag & (int)type)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-
-/*
- * set floating point attributes which require clamping
- */
-
-static int setFlagAttr( BPy_Sequence *self, PyObject *value, void *type )
-{
- int t = (int)type;
- int param = PyObject_IsTrue( value );
-
- if( param == -1 )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected True/False or 0/1" );
-
- if (param)
- self->seq->flag |= t;
- else {
- /* dont allow leftsel and rightsel when its not selected */
- if (t == SELECT)
- t = t + SEQ_LEFTSEL + SEQ_RIGHTSEL;
-
- self->seq->flag &= ~t;
- }
- return 0;
-}
-
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_Sequence_getseters[] = {
- {"name",
- (getter)Sequence_getName, (setter)Sequence_setName,
- "Sequence name",
- NULL},
- {"ipo",
- (getter)Sequence_getIpo, (setter)Sequence_setIpo,
- "Sequence ipo",
- NULL},
-
- {"scene",
- (getter)Sequence_getScene, (setter)NULL,
- "Sequence scene",
- NULL},
- {"sound",
- (getter)Sequence_getSound, (setter)NULL,
- "Sequence name",
- NULL},
- {"images",
- (getter)Sequence_getImages, (setter)Sequence_setImages,
- "Sequence scene",
- NULL},
-
- {"type",
- (getter)getIntAttr, (setter)NULL,
- "",
- (void *) EXPP_SEQ_ATTR_TYPE},
- {"channel",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "",
- (void *) EXPP_SEQ_ATTR_CHAN},
-
- {"length",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "",
- (void *) EXPP_SEQ_ATTR_LENGTH},
- {"start",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "",
- (void *) EXPP_SEQ_ATTR_START},
- {"startOffset",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "",
- (void *) EXPP_SEQ_ATTR_STARTOFS},
- {"endOffset",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "",
- (void *) EXPP_SEQ_ATTR_ENDOFS},
- {"startStill",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "",
- (void *) EXPP_SEQ_ATTR_STARTSTILL},
- {"endStill",
- (getter)getIntAttr, (setter)setIntAttrClamp,
- "",
- (void *) EXPP_SEQ_ATTR_ENDSTILL},
-
- {"sel",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "Sequence audio mute option",
- (void *)SELECT},
- {"selLeft",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "",
- (void *)SEQ_LEFTSEL},
- {"selRight",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "",
- (void *)SEQ_RIGHTSEL},
- {"filtery",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "",
- (void *)SEQ_FILTERY},
- {"mute",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "",
- (void *)SEQ_MUTE},
- {"premul",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "",
- (void *)SEQ_MAKE_PREMUL},
- {"reversed",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "",
- (void *)SEQ_REVERSE_FRAMES},
- {"ipoLocked",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "",
- (void *)SEQ_IPO_FRAME_LOCKED},
- {"ipoLocked",
- (getter)getFlagAttr, (setter)setFlagAttr,
- "",
- (void *)SEQ_IPO_FRAME_LOCKED},
-
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef BPy_SceneSeq_getseters[] = {
- {"active",
- (getter)SceneSeq_getActive, (setter)NULL,
- "the active strip",
- NULL},
- {"metastrip",
- (getter)SceneSeq_getMetaStrip, (setter)NULL,
- "The currently active metastrip the user is editing",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-/*****************************************************************************/
-/* Python TypeSequence structure definition: */
-/*****************************************************************************/
-PyTypeObject Sequence_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Sequence", /* char *tp_name; */
- sizeof( BPy_Sequence ), /* 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 ) Sequence_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) Sequence_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 */
- ( getiterfunc ) Sequence_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) Sequence_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_Sequence_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_Sequence_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
-};
-
-
-
-/*****************************************************************************/
-/* Python TypeSequence structure definition: */
-/*****************************************************************************/
-PyTypeObject SceneSeq_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender SceneSeq", /* char *tp_name; */
- sizeof( BPy_Sequence ), /* 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 ) SceneSeq_compare, /* cmpfunc tp_compare; */
- ( reprfunc ) SceneSeq_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 */
- ( getiterfunc ) SceneSeq_getIter, /* getiterfunc tp_iter; */
- ( iternextfunc ) SceneSeq_nextIter, /* iternextfunc tp_iternext; */
-
- /*** Attribute descriptor and subclassing stuff ***/
- BPy_SceneSeq_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- BPy_SceneSeq_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_Sequence_Get */
-/* Python equivalent: Blender.Sequence.Get */
-/*****************************************************************************/
-/*
-PyObject *M_Sequence_Get( PyObject * self, PyObject * args )
-{
- return SceneSeq_CreatePyObject( G.scene, NULL );
-}
-*/
-
-/*****************************************************************************/
-/* Function: initObject */
-/*****************************************************************************/
-PyObject *Sequence_Init( void )
-{
- PyObject *submodule;
- if( PyType_Ready( &Sequence_Type ) < 0 )
- return NULL;
- if( PyType_Ready( &SceneSeq_Type ) < 0 )
- return NULL;
-
- /* NULL was M_Sequence_methods*/
- submodule = Py_InitModule3( "Blender.Scene.Sequence", NULL,
-"The Blender Sequence module\n\n\
-This module provides access to **Sequence Data** in Blender.\n" );
-
- /*Add SUBMODULES to the module*/
- /*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); //creates a *new* module*/
- return submodule;
-}
-
-
-/*****************************************************************************/
-/* Function: Sequence_CreatePyObject */
-/* Description: This function will create a new BlenObject from an existing */
-/* Object structure. */
-/*****************************************************************************/
-PyObject *Sequence_CreatePyObject( struct Sequence * seq, struct Sequence * iter, struct Scene *sce)
-{
- BPy_Sequence *pyseq;
-
- if( !seq )
- Py_RETURN_NONE;
-
- pyseq =
- ( BPy_Sequence * ) PyObject_NEW( BPy_Sequence, &Sequence_Type );
-
- if( pyseq == NULL ) {
- return ( NULL );
- }
- pyseq->seq = seq;
- pyseq->iter = iter;
- pyseq->scene = sce;
-
- return ( ( PyObject * ) pyseq );
-}
-
-/*****************************************************************************/
-/* Function: SceneSeq_CreatePyObject */
-/* Description: This function will create a new BlenObject from an existing */
-/* Object structure. */
-/*****************************************************************************/
-PyObject *SceneSeq_CreatePyObject( struct Scene * scn, struct Sequence * iter)
-{
- BPy_SceneSeq *pysceseq;
-
- if( !scn )
- Py_RETURN_NONE;
-
- pysceseq =
- ( BPy_SceneSeq * ) PyObject_NEW( BPy_SceneSeq, &SceneSeq_Type );
-
- if( pysceseq == NULL ) {
- return ( NULL );
- }
- pysceseq->scene = scn;
- pysceseq->iter = iter;
-
- return ( ( PyObject * ) pysceseq );
-}
-
-/*****************************************************************************/
-/* Function: Sequence_FromPyObject */
-/* Description: This function returns the Blender sequence from the given */
-/* PyObject. */
-/*****************************************************************************/
-struct Sequence *Sequence_FromPyObject( PyObject * py_seq )
-{
- BPy_Sequence *blen_seq;
-
- blen_seq = ( BPy_Sequence * ) py_seq;
- return ( blen_seq->seq );
-}
-
-/*****************************************************************************/
-/* Function: Sequence_compare */
-/* Description: This is a callback function for the BPy_Sequence type. It */
-/* compares two Sequence_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 Sequence_compare( BPy_Sequence * a, BPy_Sequence * b )
-{
- Sequence *pa = a->seq, *pb = b->seq;
- return ( pa == pb ) ? 0 : -1;
-}
-
-static int SceneSeq_compare( BPy_SceneSeq * a, BPy_SceneSeq * b )
-{
-
- Scene *pa = a->scene, *pb = b->scene;
- return ( pa == pb ) ? 0 : -1;
-}
-
-/*****************************************************************************/
-/* Function: Sequence_repr / SceneSeq_repr */
-/* Description: This is a callback function for the BPy_Sequence type. It */
-/* builds a meaninful string to represent object objects. */
-/*****************************************************************************/
-static PyObject *Sequence_repr( BPy_Sequence * self )
-{
- return PyString_FromFormat( "[Sequence Strip \"%s\"]",
- self->seq->name + 2 );
-}
-static PyObject *SceneSeq_repr( BPy_SceneSeq * self )
-{
- return PyString_FromFormat( "[Scene Sequence \"%s\"]",
- self->scene->id.name + 2 );
-}
-
diff --git a/source/blender/python/api2_2x/sceneSequence.h b/source/blender/python/api2_2x/sceneSequence.h
deleted file mode 100644
index 2d8431fae80..00000000000
--- a/source/blender/python/api2_2x/sceneSequence.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * $Id: sceneSequence.h 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): Michel Selten
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
-*/
-
-#ifndef EXPP_SEQUENCE_H
-#define EXPP_SEQUENCE_H
-
-#include <Python.h>
-#include "DNA_sequence_types.h"
-
-/* The Sequence PyTypeObject defined in Sequence.c */
-extern PyTypeObject Sequence_Type;
-extern PyTypeObject SceneSeq_Type;
-
-#define BPy_Sequence_Check(v) ((v)->ob_type == &Sequence_Type)
-#define BPy_SceneSeq_Check(v) ((v)->ob_type == &SceneSeq_Type)
-
-
-/*****************************************************************************/
-/* Python BPy_Sequence structure definition. */
-/*****************************************************************************/
-typedef struct {
- PyObject_HEAD /* required python macro */
-
- /*one of the folowing must be NULL*/
- struct Sequence *seq;/* if not NULL, this sequence is a Metaseq */
-
- /* used for looping over the scene or the strips strips */
- struct Sequence *iter;/* if not NULL, this sequence is a Metaseq */
-
- struct Scene *scene;
-
-} BPy_Sequence;
-
-
-
-/*****************************************************************************/
-/* Python BPy_Sequence structure definition. */
-/*****************************************************************************/
-typedef struct {
- PyObject_HEAD /* required python macro */
-
- /*one of the folowing must be NULL*/
- struct Scene *scene; /* if not NULL, this sequence is the root sequence for the scene*/
-
- /* used for looping over the scene or the strips strips */
- struct Sequence *iter;/* if not NULL, this sequence is a Metaseq */
-} BPy_SceneSeq;
-
-PyObject *Sequence_Init( void );
-PyObject *Sequence_CreatePyObject( struct Sequence * seq, struct Sequence * iter, struct Scene * scn);
-PyObject *SceneSeq_CreatePyObject( struct Scene * scn, struct Sequence * iter);
-struct Sequence *Sequence_FromPyObject( PyObject * py_obj );
-
-#endif /* EXPP_SEQUENCE_H */
diff --git a/source/blender/python/api2_2x/sceneTimeLine.c b/source/blender/python/api2_2x/sceneTimeLine.c
deleted file mode 100644
index 9feba1eb462..00000000000
--- a/source/blender/python/api2_2x/sceneTimeLine.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* $Id: sceneTimeLine.c 10778 2007-05-25 16:43:25Z 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 *****
-*/
-
-#include <BLI_blenlib.h>
-#include "Scene.h"
-
-#include <stdio.h>
-#include <MEM_guardedalloc.h> /* for MEM_callocN */
-
-#include "gen_utils.h"
-#include "sceneTimeLine.h"
-
-// static PyObject *TimeLine_New (PyObject *self);
-static PyObject *M_TimeLine_Get (PyObject *self, PyObject *args);
-
-static char M_TimeLine_Get_doc[]= "Return the Scene.TimeLine.";
-
-//----------------------Scene.TimeMarker subsubmodule method def----------------------------
-struct PyMethodDef M_TimeLine_methods[]= {
-// {"New", (PyCFunction) M_TimeMarker_New, METH_NOVAR,
-// M_TimeLine_New_doc},
- {"Get", (PyCFunction) M_TimeLine_Get, METH_VARARGS,
- M_TimeLine_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-static PyObject *TimeLine_addMarker (BPy_TimeLine *self, PyObject *args);
-static PyObject *TimeLine_delMarker (BPy_TimeLine *self, PyObject *args);
-static PyObject *TimeLine_setNameMarker (BPy_TimeLine *self, PyObject *args);
-static PyObject *TimeLine_getNameMarker (BPy_TimeLine *self, PyObject *args);
-static PyObject *TimeLine_getFramesMarked (BPy_TimeLine *self, PyObject *args);
-
-static PyObject *TimeLine_repr (BPy_TimeLine *self) {
-
- return PyString_FromFormat ("[TimeLine]");
-}
-
-static PyMethodDef BPy_TimeLine_methods[] = {
- {"add", (PyCFunction) TimeLine_addMarker,
- METH_VARARGS,
- "() - Add timemarker"},
- {"delete", (PyCFunction) TimeLine_delMarker,
- METH_VARARGS,
- "() - delete timemarker"},
- {"setName", (PyCFunction) TimeLine_setNameMarker,
- METH_VARARGS,
- "() - Get timemarker name"},
- {"getName", (PyCFunction) TimeLine_getNameMarker,
- METH_VARARGS,
- "() - Set timemarker name"},
- {"getMarked", (PyCFunction) TimeLine_getFramesMarked,
- METH_VARARGS,
- "() - Get frames timemarked"},
- {NULL, NULL, 0, NULL}
-};
-
-/*-----------------------dealloc----------------------------------------*/
-static void TimeLine_dealloc( BPy_TimeLine * self )
-{
- PyObject_DEL( self );
-}
-
-/*-----------------------getattr----------------------------------------*/
-static PyObject *TimeLine_getattr (BPy_TimeLine *self, char *name) {
- return Py_FindMethod( BPy_TimeLine_methods, ( PyObject * ) self, name );
-}
-
-/*-----------------------setattr----------------------------------------*/
-static int TimeLine_setattr (BPy_TimeLine *self, char *name, PyObject *value) {
- PyObject *valtuple;
- PyObject *error= NULL;
-
- valtuple= Py_BuildValue ("(O)", value);
-
- if (!valtuple)
- return EXPP_ReturnIntError( PyExc_MemoryError,
- "TimeLineSetAttr: couldn't create tuple" );
- if( strcmp( name, "name" ) == 0 )
- error = TimeLine_setNameMarker (self, valtuple);
- Py_DECREF (valtuple);
- if (error != Py_None)
- return -1;
-
- Py_DECREF (Py_None);
- return 0;
-}
-
-//-----------------------BPy_Scene method def------------------------------
-PyTypeObject TimeLine_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "TimeLine", /* tp_name */
- sizeof (BPy_TimeLine), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- ( destructor ) TimeLine_dealloc, /* tp_dealloc */
- (printfunc) 0, /* tp_print */
- (getattrfunc) TimeLine_getattr, /* tp_getattr */
- (setattrfunc) TimeLine_setattr, /* tp_setattr */
- 0,
- (reprfunc) TimeLine_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0,0,0,0,0,0,0,0,0,
- BPy_TimeLine_methods,
- 0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-
-PyObject *TimeLine_Init (void)
-{
- PyObject *submodule;
-
- if (PyType_Ready (&TimeLine_Type) < 0)
- return NULL;
- submodule= Py_InitModule3 ("Blender.Scene.TimeLine", M_TimeLine_methods,
- "The Blender TimeLine subsubmodule");
-
- return submodule;
-}
-
-PyObject *TimeLine_CreatePyObject (BPy_TimeLine *tl) {
- BPy_TimeLine *bl_tl;
-
- bl_tl= (BPy_TimeLine *) PyObject_NEW (BPy_TimeLine, &TimeLine_Type);
-
- return (( PyObject * ) bl_tl);
-}
-
-
-PyObject *M_TimeLine_Get (PyObject *self, PyObject *args) {
-
- return EXPP_incr_ret (Py_None);
-}
-
-static PyObject *TimeLine_getFramesMarked (BPy_TimeLine *self, PyObject *args) {
-
- PyObject *marker_dict= NULL;
- TimeMarker *marker_it= NULL;
- PyObject *tmarker= NULL, *pyo= NULL, *tmpstr;
-
- if (!PyArg_ParseTuple (args, "|O", &tmarker))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected nothing, string or int as arguments.");
- if (tmarker) {
- char s[64];
- int frm= 0;
-
- if (PyString_Check (tmarker) && (BLI_strncpy(s, PyString_AsString (tmarker), 64)) ) {
- for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next)
- if (!strcmp (marker_it->name, s)) {
- frm= (int)marker_it->frame;
- break;
- }
- }
- else if (PyInt_Check (tmarker))
- frm= (int)PyInt_AS_LONG (tmarker);
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected nothing, string or int as arguments.");
- if (frm>0) {
- marker_dict= PyDict_New ();
- for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next){
- if (marker_it->frame==frm) {
- pyo= PyDict_GetItem ((PyObject*)marker_dict, PyInt_FromLong ((long int)marker_it->frame));
- tmpstr = PyString_FromString(marker_it->name);
- if (pyo) {
- PyList_Append (pyo, tmpstr);
- Py_INCREF(pyo);
- }else{
- pyo = PyList_New(0);
- PyList_Append (pyo, tmpstr);
- }
- Py_DECREF(tmpstr);
-
- PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo);
- if (pyo) {
- Py_DECREF (pyo);
- pyo= NULL;
- }
- }
- }
- }
-
- }else {
- marker_dict= PyDict_New ();
- for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) {
- pyo=PyDict_GetItem ((PyObject*)marker_dict, PyInt_FromLong ((long int)marker_it->frame));
- tmpstr = PyString_FromString(marker_it->name);
- if (pyo) {
- PyList_Append (pyo, tmpstr);
- Py_INCREF (pyo);
- }else{
- pyo= PyList_New (0);
- PyList_Append (pyo, tmpstr);
- }
- Py_DECREF(tmpstr);
-
- PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo);
- if (pyo) {
- Py_DECREF (pyo);
- pyo= NULL;
- }
- }
- }
-
- return marker_dict;
-}
-
-static PyObject *TimeLine_addMarker (BPy_TimeLine *self, PyObject *args) {
- int frame= 0;
- TimeMarker *marker= NULL, *marker_it= NULL;
-
- if (!PyArg_ParseTuple( args, "i", &frame ))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int as argument.");
- /* two markers can't be at the same place */
- for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) {
- if (marker_it->frame==frame)
- return EXPP_incr_ret (Py_None);
- }
- if (frame<self->sfra || frame>self->efra)
- return EXPP_ReturnPyObjError (PyExc_TypeError, "frame out of range.");
- marker= MEM_callocN (sizeof(TimeMarker), "TimeMarker");
- if (!marker) return EXPP_incr_ret (Py_None);
- marker->frame= frame;
- BLI_addtail (self->marker_list, marker);
- return EXPP_incr_ret (Py_None);
-}
-
-static PyObject *TimeLine_delMarker (BPy_TimeLine *self, PyObject *args) {
- int frame= 0;
- TimeMarker *marker= NULL;
-
- if (!PyArg_ParseTuple (args, "|i", &frame))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int as argument.");
-
- for (marker= self->marker_list->first; marker; marker= marker->next) {
- if (!frame)
- BLI_freelinkN (self->marker_list, marker);
- else if (marker->frame == frame) {
- BLI_freelinkN (self->marker_list, marker);
- return EXPP_incr_ret (Py_None);
- }
- }
-
- return EXPP_incr_ret (Py_None);
-}
-
-static PyObject *TimeLine_setNameMarker (BPy_TimeLine *self, PyObject *args) {
- char *buf;
- char name[64];
- int frame= 0;
- TimeMarker *marker= NULL;
-
- if (!PyArg_ParseTuple( args, "is", &frame, &buf))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int as argument.");
- PyOS_snprintf (name, sizeof (name), "%s", buf);
- for (marker= self->marker_list->first; marker; marker= marker->next) {
- if (marker->frame == frame) {
- BLI_strncpy(marker->name, name, sizeof(marker->name));
- return EXPP_incr_ret (Py_None);
- }
- }
-
- return EXPP_ReturnPyObjError (PyExc_TypeError, "frame not marked.");
-}
-
-static PyObject *TimeLine_getNameMarker (BPy_TimeLine *self, PyObject *args) {
- int frame= 0;
- TimeMarker *marker;
-
- if (!PyArg_ParseTuple (args, "i", &frame))
- return EXPP_ReturnPyObjError (PyExc_TypeError, "expected int as argument.");
-
- for (marker= self->marker_list->first; marker; marker= marker->next) {
- if (marker->frame == frame)
- return PyString_FromString (marker->name);
- }
-
- return EXPP_ReturnPyObjError (PyExc_TypeError, "frame not marked.");
-}
-
-
diff --git a/source/blender/python/api2_2x/sceneTimeLine.h b/source/blender/python/api2_2x/sceneTimeLine.h
deleted file mode 100644
index 0a3aa62b571..00000000000
--- a/source/blender/python/api2_2x/sceneTimeLine.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * $Id: sceneTimeLine.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_TIMELINE_H
-#define EXPP_TIMELINE_H
-
-#include <Python.h>
-#include <DNA_scene_types.h>
-
-extern PyTypeObject TimeLine_Type;
-#define BPy_TimeLine_Check (v) \
- ((v)->ob_type == &TimeLine_Type)
-
-typedef struct {
- PyObject_HEAD
- ListBase *marker_list;
- int sfra, efra;
-} BPy_TimeLine;
-
-//---------------------------Python BPy_TimeLine visible prototypes-----------
-// Python TimeLine_Type helper functions needed by Blender (the Init function) and Object modules.
-
-
-PyObject *TimeLine_Init (void);
-PyObject *TimeLine_CreatePyObject (BPy_TimeLine *tl);
-BPy_TimeLine *TimeLine_FromPyObject (PyObject * pyobj);
-
-#endif /* EXPP_TMARKER_H */
-
diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c
deleted file mode 100644
index 45ad36d0093..00000000000
--- a/source/blender/python/api2_2x/vector.c
+++ /dev/null
@@ -1,1264 +0,0 @@
-/*
- * $Id: vector.c 12314 2007-10-20 20:24:09Z 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): Willian P. Germano & Joseph Gilbert, Ken Hughes
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include "Mathutils.h"
-
-#include "BLI_blenlib.h"
-#include "BKE_utildefines.h"
-#include "BLI_arithb.h"
-#include "gen_utils.h"
-
-
-/*-------------------------DOC STRINGS ---------------------------*/
-char Vector_Zero_doc[] = "() - set all values in the vector to 0";
-char Vector_Normalize_doc[] = "() - normalize the vector";
-char Vector_Negate_doc[] = "() - changes vector to it's additive inverse";
-char Vector_Resize2D_doc[] = "() - resize a vector to [x,y]";
-char Vector_Resize3D_doc[] = "() - resize a vector to [x,y,z]";
-char Vector_Resize4D_doc[] = "() - resize a vector to [x,y,z,w]";
-char Vector_toPoint_doc[] = "() - create a new Point Object from this vector";
-char Vector_ToTrackQuat_doc[] = "(track, up) - extract a quaternion from the vector and the track and up axis";
-char Vector_copy_doc[] = "() - return a copy of the vector";
-/*-----------------------METHOD DEFINITIONS ----------------------*/
-struct PyMethodDef Vector_methods[] = {
- {"zero", (PyCFunction) Vector_Zero, METH_NOARGS, Vector_Zero_doc},
- {"normalize", (PyCFunction) Vector_Normalize, METH_NOARGS, Vector_Normalize_doc},
- {"negate", (PyCFunction) Vector_Negate, METH_NOARGS, Vector_Negate_doc},
- {"resize2D", (PyCFunction) Vector_Resize2D, METH_NOARGS, Vector_Resize2D_doc},
- {"resize3D", (PyCFunction) Vector_Resize3D, METH_NOARGS, Vector_Resize2D_doc},
- {"resize4D", (PyCFunction) Vector_Resize4D, METH_NOARGS, Vector_Resize2D_doc},
- {"toPoint", (PyCFunction) Vector_toPoint, METH_NOARGS, Vector_toPoint_doc},
- {"toTrackQuat", ( PyCFunction ) Vector_ToTrackQuat, METH_VARARGS, Vector_ToTrackQuat_doc},
- {"copy", (PyCFunction) Vector_copy, METH_NOARGS, Vector_copy_doc},
- {"__copy__", (PyCFunction) Vector_copy, METH_NOARGS, Vector_copy_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*-----------------------------METHODS----------------------------
- --------------------------Vector.toPoint()----------------------
- create a new point object to represent this vector */
-PyObject *Vector_toPoint(VectorObject * self)
-{
- float coord[3];
- int i;
-
- if(self->size < 2 || self->size > 3) {
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector.toPoint(): inappropriate vector size - expects 2d or 3d vector\n");
- }
- for(i = 0; i < self->size; i++){
- coord[i] = self->vec[i];
- }
-
- return newPointObject(coord, self->size, Py_NEW);
-}
-/*----------------------------Vector.zero() ----------------------
- set the vector data to 0,0,0 */
-PyObject *Vector_Zero(VectorObject * self)
-{
- int i;
- for(i = 0; i < self->size; i++) {
- self->vec[i] = 0.0f;
- }
- return EXPP_incr_ret((PyObject*)self);
-}
-/*----------------------------Vector.normalize() -----------------
- normalize the vector data to a unit vector */
-PyObject *Vector_Normalize(VectorObject * self)
-{
- int i;
- float norm = 0.0f;
-
- for(i = 0; i < self->size; i++) {
- norm += self->vec[i] * self->vec[i];
- }
- norm = (float) sqrt(norm);
- for(i = 0; i < self->size; i++) {
- self->vec[i] /= norm;
- }
- return EXPP_incr_ret((PyObject*)self);
-}
-
-
-/*----------------------------Vector.resize2D() ------------------
- resize the vector to x,y */
-PyObject *Vector_Resize2D(VectorObject * self)
-{
- if(self->wrapped==Py_WRAP)
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "vector.resize2d(): cannot resize wrapped data - only python vectors\n");
-
- self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2));
- if(self->vec == NULL)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "vector.resize2d(): problem allocating pointer space\n\n");
-
- self->size = 2;
- return EXPP_incr_ret((PyObject*)self);
-}
-/*----------------------------Vector.resize3D() ------------------
- resize the vector to x,y,z */
-PyObject *Vector_Resize3D(VectorObject * self)
-{
- if (self->wrapped==Py_WRAP)
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "vector.resize3d(): cannot resize wrapped data - only python vectors\n");
-
- self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3));
- if(self->vec == NULL)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "vector.resize3d(): problem allocating pointer space\n\n");
-
- if(self->size == 2)
- self->vec[2] = 0.0f;
-
- self->size = 3;
- return EXPP_incr_ret((PyObject*)self);
-}
-/*----------------------------Vector.resize4D() ------------------
- resize the vector to x,y,z,w */
-PyObject *Vector_Resize4D(VectorObject * self)
-{
- if(self->wrapped==Py_WRAP)
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "vector.resize4d(): cannot resize wrapped data - only python vectors\n");
-
- self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4));
- if(self->vec == NULL)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "vector.resize4d(): problem allocating pointer space\n\n");
-
- if(self->size == 2){
- self->vec[2] = 0.0f;
- self->vec[3] = 1.0f;
- }else if(self->size == 3){
- self->vec[3] = 1.0f;
- }
- self->size = 4;
- return EXPP_incr_ret((PyObject*)self);
-}
-/*----------------------------Vector.toTrackQuat(track, up) ----------------------
- extract a quaternion from the vector and the track and up axis */
-PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args )
-{
- float vec[3];
- char *strack, *sup;
- short track = 2, up = 1;
-
- if( !PyArg_ParseTuple ( args, "|ss", &strack, &sup ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected optional two strings\n" );
- }
- if (self->size != 3) {
- return EXPP_ReturnPyObjError( PyExc_TypeError, "only for 3D vectors\n" );
- }
-
- if (strack) {
- if (strlen(strack) == 2) {
- if (strack[0] == '-') {
- switch(strack[1]) {
- case 'X':
- case 'x':
- track = 3;
- break;
- case 'Y':
- case 'y':
- track = 4;
- break;
- case 'z':
- case 'Z':
- track = 5;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "only X, -X, Y, -Y, Z or -Z for track axis\n" );
- }
- }
- else {
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "only X, -X, Y, -Y, Z or -Z for track axis\n" );
- }
- }
- else if (strlen(strack) == 1) {
- switch(strack[0]) {
- case '-':
- case 'X':
- case 'x':
- track = 0;
- break;
- case 'Y':
- case 'y':
- track = 1;
- break;
- case 'z':
- case 'Z':
- track = 2;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "only X, -X, Y, -Y, Z or -Z for track axis\n" );
- }
- }
- else {
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "only X, -X, Y, -Y, Z or -Z for track axis\n" );
- }
- }
-
- if (sup) {
- if (strlen(sup) == 1) {
- switch(*sup) {
- case 'X':
- case 'x':
- up = 0;
- break;
- case 'Y':
- case 'y':
- up = 1;
- break;
- case 'z':
- case 'Z':
- up = 2;
- break;
- default:
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "only X, Y or Z for up axis\n" );
- }
- }
- else {
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "only X, Y or Z for up axis\n" );
- }
- }
-
- if (track == up) {
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Can't have the same axis for track and up\n" );
- }
-
- /*
- flip vector around, since vectoquat expect a vector from target to tracking object
- and the python function expects the inverse (a vector to the target).
- */
- vec[0] = -self->vec[0];
- vec[1] = -self->vec[1];
- vec[2] = -self->vec[2];
-
- return newQuaternionObject(vectoquat(vec, track, up), Py_NEW);
-}
-
-
-
-/*----------------------------Vector.copy() --------------------------------------
- return a copy of the vector */
-PyObject *Vector_copy(VectorObject * self)
-{
- return newVectorObject(self->vec, self->size, Py_NEW);
-}
-
-/*----------------------------dealloc()(internal) ----------------
- free the py_object */
-static void Vector_dealloc(VectorObject * self)
-{
- /* only free non wrapped */
- if(self->wrapped != Py_WRAP){
- PyMem_Free(self->vec);
- }
- PyObject_DEL(self);
-}
-
-/*----------------------------print object (internal)-------------
- print the object to screen */
-static PyObject *Vector_repr(VectorObject * self)
-{
- int i;
- char buffer[48], str[1024];
-
- BLI_strncpy(str,"[",1024);
- for(i = 0; i < self->size; i++){
- if(i < (self->size - 1)){
- sprintf(buffer, "%.6f, ", self->vec[i]);
- strcat(str,buffer);
- }else{
- sprintf(buffer, "%.6f", self->vec[i]);
- strcat(str,buffer);
- }
- }
- strcat(str, "](vector)");
-
- return PyString_FromString(str);
-}
-/*---------------------SEQUENCE PROTOCOLS------------------------
- ----------------------------len(object)------------------------
- sequence length*/
-static int Vector_len(VectorObject * self)
-{
- return self->size;
-}
-/*----------------------------object[]---------------------------
- sequence accessor (get)*/
-static PyObject *Vector_item(VectorObject * self, int i)
-{
- if(i < 0 || i >= self->size)
- return EXPP_ReturnPyObjError(PyExc_IndexError,
- "vector[index]: out of range\n");
-
- return PyFloat_FromDouble(self->vec[i]);
-
-}
-/*----------------------------object[]-------------------------
- sequence accessor (set)*/
-static int Vector_ass_item(VectorObject * self, int i, PyObject * ob)
-{
-
- if(!(PyNumber_Check(ob))) { /* parsed item not a number */
- return EXPP_ReturnIntError(PyExc_TypeError,
- "vector[index] = x: index argument not a number\n");
- }
-
- if(i < 0 || i >= self->size){
- return EXPP_ReturnIntError(PyExc_IndexError,
- "vector[index] = x: assignment index out of range\n");
- }
- self->vec[i] = (float)PyFloat_AsDouble(ob);
- return 0;
-}
-
-/*----------------------------object[z:y]------------------------
- sequence slice (get) */
-static PyObject *Vector_slice(VectorObject * self, int begin, int end)
-{
- PyObject *list = NULL;
- int count;
-
- CLAMP(begin, 0, self->size);
- if (end<0) end= self->size+end+1;
- CLAMP(end, 0, self->size);
- begin = MIN2(begin,end);
-
- list = PyList_New(end - begin);
- for(count = begin; count < end; count++) {
- PyList_SetItem(list, count - begin,
- PyFloat_FromDouble(self->vec[count]));
- }
-
- return list;
-}
-/*----------------------------object[z:y]------------------------
- sequence slice (set) */
-static int Vector_ass_slice(VectorObject * self, int begin, int end,
- PyObject * seq)
-{
- int i, y, size = 0;
- float vec[4];
- PyObject *v;
-
- CLAMP(begin, 0, self->size);
- if (end<0) end= self->size+end+1;
- CLAMP(end, 0, self->size);
- begin = MIN2(begin,end);
-
- size = PySequence_Length(seq);
- if(size != (end - begin)){
- return EXPP_ReturnIntError(PyExc_TypeError,
- "vector[begin:end] = []: size mismatch in slice assignment\n");
- }
-
- for (i = 0; i < size; i++) {
- v = PySequence_GetItem(seq, i);
- if (v == NULL) { /* Failed to read sequence */
- return EXPP_ReturnIntError(PyExc_RuntimeError,
- "vector[begin:end] = []: unable to read sequence\n");
- }
-
- if(!PyNumber_Check(v)) { /* parsed item not a number */
- Py_DECREF(v);
- return EXPP_ReturnIntError(PyExc_TypeError,
- "vector[begin:end] = []: sequence argument not a number\n");
- }
-
- vec[i] = (float)PyFloat_AsDouble(v);
- Py_DECREF(v);
- }
- /*parsed well - now set in vector*/
- for(y = 0; y < size; y++){
- self->vec[begin + y] = vec[y];
- }
- return 0;
-}
-/*------------------------NUMERIC PROTOCOLS----------------------
- ------------------------obj + obj------------------------------
- addition*/
-static PyObject *Vector_add(PyObject * v1, PyObject * v2)
-{
- int i;
- float vec[4];
-
- VectorObject *vec1 = NULL, *vec2 = NULL;
-
- if VectorObject_Check(v1)
- vec1= (VectorObject *)v1;
-
- if VectorObject_Check(v2)
- vec2= (VectorObject *)v2;
-
- /* make sure v1 is always the vector */
- if (vec1 && vec2 ) {
- /*VECTOR + VECTOR*/
- if(vec1->size != vec2->size)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector addition: vectors must have the same dimensions for this operation\n");
-
- for(i = 0; i < vec1->size; i++) {
- vec[i] = vec1->vec[i] + vec2->vec[i];
- }
- return newVectorObject(vec, vec1->size, Py_NEW);
- }
-
- if(PointObject_Check(v2)){ /*VECTOR + POINT*/
- /*Point translation*/
- PointObject *pt = (PointObject*)v2;
-
- if(pt->size == vec1->size){
- for(i = 0; i < vec1->size; i++){
- vec[i] = vec1->vec[i] + pt->coord[i];
- }
- }else{
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector addition: arguments are the wrong size....\n");
- }
- return newPointObject(vec, vec1->size, Py_NEW);
- }
-
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector addition: arguments not valid for this operation....\n");
-}
-
-/* ------------------------obj += obj------------------------------
- addition in place */
-static PyObject *Vector_iadd(PyObject * v1, PyObject * v2)
-{
- int i;
-
- VectorObject *vec1 = NULL, *vec2 = NULL;
-
- if VectorObject_Check(v1)
- vec1= (VectorObject *)v1;
-
- if VectorObject_Check(v2)
- vec2= (VectorObject *)v2;
-
- /* make sure v1 is always the vector */
- if (vec1 && vec2 ) {
- /*VECTOR + VECTOR*/
- if(vec1->size != vec2->size)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector addition: vectors must have the same dimensions for this operation\n");
-
- for(i = 0; i < vec1->size; i++) {
- vec1->vec[i] += vec2->vec[i];
- }
- Py_INCREF( v1 );
- return v1;
- }
-
- if(PointObject_Check(v2)){ /*VECTOR + POINT*/
- /*Point translation*/
- PointObject *pt = (PointObject*)v2;
-
- if(pt->size == vec1->size){
- for(i = 0; i < vec1->size; i++){
- vec1->vec[i] += pt->coord[i];
- }
- }else{
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector addition: arguments are the wrong size....\n");
- }
- Py_INCREF( v1 );
- return v1;
- }
-
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector addition: arguments not valid for this operation....\n");
-}
-
-/*------------------------obj - obj------------------------------
- subtraction*/
-static PyObject *Vector_sub(PyObject * v1, PyObject * v2)
-{
- int i;
- float vec[4];
- VectorObject *vec1 = NULL, *vec2 = NULL;
-
- if (!VectorObject_Check(v1) || !VectorObject_Check(v2))
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector subtraction: arguments not valid for this operation....\n");
-
- vec1 = (VectorObject*)v1;
- vec2 = (VectorObject*)v2;
-
- if(vec1->size != vec2->size)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector subtraction: vectors must have the same dimensions for this operation\n");
-
- for(i = 0; i < vec1->size; i++) {
- vec[i] = vec1->vec[i] - vec2->vec[i];
- }
-
- return newVectorObject(vec, vec1->size, Py_NEW);
-}
-
-/*------------------------obj -= obj------------------------------
- subtraction*/
-static PyObject *Vector_isub(PyObject * v1, PyObject * v2)
-{
- int i, size;
- VectorObject *vec1 = NULL, *vec2 = NULL;
-
- if (!VectorObject_Check(v1) || !VectorObject_Check(v2))
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector subtraction: arguments not valid for this operation....\n");
-
- vec1 = (VectorObject*)v1;
- vec2 = (VectorObject*)v2;
-
- if(vec1->size != vec2->size)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector subtraction: vectors must have the same dimensions for this operation\n");
-
- size = vec1->size;
- for(i = 0; i < vec1->size; i++) {
- vec1->vec[i] = vec1->vec[i] - vec2->vec[i];
- }
-
- Py_INCREF( v1 );
- return v1;
-}
-
-/*------------------------obj * obj------------------------------
- mulplication*/
-static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
-{
- VectorObject *vec1 = NULL, *vec2 = NULL;
-
- if VectorObject_Check(v1)
- vec1= (VectorObject *)v1;
-
- if VectorObject_Check(v2)
- vec2= (VectorObject *)v2;
-
- /* make sure v1 is always the vector */
- if (vec1 && vec2 ) {
- int i;
- double dot = 0.0f;
-
- if(vec1->size != vec2->size)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "Vector multiplication: vectors must have the same dimensions for this operation\n");
-
- /*dot product*/
- for(i = 0; i < vec1->size; i++) {
- dot += vec1->vec[i] * vec2->vec[i];
- }
- return PyFloat_FromDouble(dot);
- }
-
- /*swap so vec1 is always the vector */
- if (vec2) {
- vec1= vec2;
- v2= v1;
- }
-
- if (PyNumber_Check(v2)) {
- /* VEC * NUM */
- int i;
- float vec[4];
- float scalar = (float)PyFloat_AsDouble( v2 );
-
- for(i = 0; i < vec1->size; i++) {
- vec[i] = vec1->vec[i] * scalar;
- }
- return newVectorObject(vec, vec1->size, Py_NEW);
-
- } else if (MatrixObject_Check(v2)) {
- /* VEC * MATRIX */
- if (v1==v2) /* mat*vec, we have swapped the order */
- return column_vector_multiplication((MatrixObject*)v2, vec1);
- else /* vec*mat */
- return row_vector_multiplication(vec1, (MatrixObject*)v2);
- } else if (QuaternionObject_Check(v2)) {
- QuaternionObject *quat = (QuaternionObject*)v2;
- if(vec1->size != 3)
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Vector multiplication: only 3D vector rotations (with quats) currently supported\n");
-
- return quat_rotation((PyObject*)vec1, (PyObject*)quat);
- }
-
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Vector multiplication: arguments not acceptable for this operation\n");
-}
-
-/*------------------------obj *= obj------------------------------
- in place mulplication */
-static PyObject *Vector_imul(PyObject * v1, PyObject * v2)
-{
- VectorObject *vec = (VectorObject *)v1;
- int i;
-
- /* only support vec*=float and vec*=mat
- vec*=vec result is a float so that wont work */
- if (PyNumber_Check(v2)) {
- /* VEC * NUM */
- float scalar = (float)PyFloat_AsDouble( v2 );
-
- for(i = 0; i < vec->size; i++) {
- vec->vec[i] *= scalar;
- }
-
- Py_INCREF( v1 );
- return v1;
-
- } else if (MatrixObject_Check(v2)) {
- float vecCopy[4];
- int x,y, size = vec->size;
- MatrixObject *mat= (MatrixObject*)v2;
-
- if(mat->colSize != size){
- if(mat->rowSize == 4 && vec->size != 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "vector * matrix: matrix column size and the vector size must be the same");
- } else {
- vecCopy[3] = 1.0f;
- }
- }
-
- for(i = 0; i < size; i++){
- vecCopy[i] = vec->vec[i];
- }
-
- size = MIN2(size, mat->colSize);
-
- /*muliplication*/
- for(x = 0, i = 0; x < size; x++, i++) {
- double dot = 0.0f;
- for(y = 0; y < mat->rowSize; y++) {
- dot += mat->matrix[y][x] * vecCopy[y];
- }
- vec->vec[i] = (float)dot;
- }
- Py_INCREF( v1 );
- return v1;
- }
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Vector multiplication: arguments not acceptable for this operation\n");
-}
-
-/*------------------------obj / obj------------------------------
- divide*/
-static PyObject *Vector_div(PyObject * v1, PyObject * v2)
-{
- int i, size;
- float vec[4], scalar;
- VectorObject *vec1 = NULL;
-
- if(!VectorObject_Check(v1)) /* not a vector */
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Vector division: Vector must be divided by a float\n");
-
- vec1 = (VectorObject*)v1; /* vector */
-
- if(!PyNumber_Check(v2)) /* parsed item not a number */
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Vector division: Vector must be divided by a float\n");
-
- scalar = (float)PyFloat_AsDouble(v2);
-
- if(scalar==0.0) /* not a vector */
- return EXPP_ReturnPyObjError(PyExc_ZeroDivisionError,
- "Vector division: divide by zero error.\n");
-
- size = vec1->size;
- for(i = 0; i < size; i++) {
- vec[i] = vec1->vec[i] / scalar;
- }
- return newVectorObject(vec, size, Py_NEW);
-}
-
-/*------------------------obj / obj------------------------------
- divide*/
-static PyObject *Vector_idiv(PyObject * v1, PyObject * v2)
-{
- int i, size;
- float scalar;
- VectorObject *vec1 = NULL;
-
- /*if(!VectorObject_Check(v1))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "Vector division: Vector must be divided by a float\n");*/
-
- vec1 = (VectorObject*)v1; /* vector */
-
- if(!PyNumber_Check(v2)) /* parsed item not a number */
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "Vector division: Vector must be divided by a float\n");
-
- scalar = (float)PyFloat_AsDouble(v2);
-
- if(scalar==0.0) /* not a vector */
- return EXPP_ReturnPyObjError(PyExc_ZeroDivisionError,
- "Vector division: divide by zero error.\n");
-
- size = vec1->size;
- for(i = 0; i < size; i++) {
- vec1->vec[i] /= scalar;
- }
- Py_INCREF( v1 );
- return v1;
-}
-
-/*-------------------------- -obj -------------------------------
- returns the negative of this object*/
-static PyObject *Vector_neg(VectorObject *self)
-{
- int i;
- float vec[4];
- for(i = 0; i < self->size; i++){
- vec[i] = -self->vec[i];
- }
-
- return newVectorObject(vec, self->size, Py_NEW);
-}
-/*------------------------coerce(obj, obj)-----------------------
- coercion of unknown types to type VectorObject for numeric protocols
- Coercion() is called whenever a math operation has 2 operands that
- it doesn't understand how to evaluate. 2+Matrix for example. We want to
- evaluate some of these operations like: (vector * 2), however, for math
- to proceed, the unknown operand must be cast to a type that python math will
- understand. (e.g. in the case above case, 2 must be cast to a vector and
- then call vector.multiply(vector, scalar_cast_as_vector)*/
-
-
-static int Vector_coerce(PyObject ** v1, PyObject ** v2)
-{
- /* Just incref, each functon must raise errors for bad types */
- Py_INCREF (*v1);
- Py_INCREF (*v2);
- return 0;
-}
-
-
-/*------------------------tp_doc*/
-static char VectorObject_doc[] = "This is a wrapper for vector objects.";
-/*------------------------vec_magnitude_nosqrt (internal) - for comparing only */
-static double vec_magnitude_nosqrt(float *data, int size)
-{
- double dot = 0.0f;
- int i;
-
- for(i=0; i<size; i++){
- dot += data[i];
- }
- /*return (double)sqrt(dot);*/
- /* warning, line above removed because we are not using the length,
- rather the comparing the sizes and for this we do not need the sqrt
- for the actual length, the dot must be sqrt'd */
- return (double)dot;
-}
-
-
-/*------------------------tp_richcmpr
- returns -1 execption, 0 false, 1 true */
-PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type)
-{
- VectorObject *vecA = NULL, *vecB = NULL;
- int result = 0;
- float epsilon = .000001f;
- double lenA,lenB;
-
- if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)){
- if (comparison_type == Py_NE){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
- }
- vecA = (VectorObject*)objectA;
- vecB = (VectorObject*)objectB;
-
- if (vecA->size != vecB->size){
- if (comparison_type == Py_NE){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
- }
-
- switch (comparison_type){
- case Py_LT:
- lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
- lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
- if( lenA < lenB ){
- result = 1;
- }
- break;
- case Py_LE:
- lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
- lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
- if( lenA < lenB ){
- result = 1;
- }else{
- result = (((lenA + epsilon) > lenB) && ((lenA - epsilon) < lenB));
- }
- break;
- case Py_EQ:
- result = EXPP_VectorsAreEqual(vecA->vec, vecB->vec, vecA->size, 1);
- break;
- case Py_NE:
- result = EXPP_VectorsAreEqual(vecA->vec, vecB->vec, vecA->size, 1);
- if (result == 0){
- result = 1;
- }else{
- result = 0;
- }
- break;
- case Py_GT:
- lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
- lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
- if( lenA > lenB ){
- result = 1;
- }
- break;
- case Py_GE:
- lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size);
- lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size);
- if( lenA > lenB ){
- result = 1;
- }else{
- result = (((lenA + epsilon) > lenB) && ((lenA - epsilon) < lenB));
- }
- break;
- default:
- printf("The result of the comparison could not be evaluated");
- break;
- }
- if (result == 1){
- return EXPP_incr_ret(Py_True);
- }else{
- return EXPP_incr_ret(Py_False);
- }
-}
-/*-----------------PROTCOL DECLARATIONS--------------------------*/
-static PySequenceMethods Vector_SeqMethods = {
- (inquiry) Vector_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Vector_item, /* sq_item */
- (intintargfunc) Vector_slice, /* sq_slice */
- (intobjargproc) Vector_ass_item, /* sq_ass_item */
- (intintobjargproc) Vector_ass_slice, /* sq_ass_slice */
-};
-
-
-/* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all
- arguments are guaranteed to be of the object's type (modulo
- coercion hacks -- i.e. if the type's coercion function
- returns other types, then these are allowed as well). Numbers that
- have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both*
- arguments for proper type and implement the necessary conversions
- in the slot functions themselves. */
-
-static PyNumberMethods Vector_NumMethods = {
- (binaryfunc) Vector_add, /* __add__ */
- (binaryfunc) Vector_sub, /* __sub__ */
- (binaryfunc) Vector_mul, /* __mul__ */
- (binaryfunc) Vector_div, /* __div__ */
- (binaryfunc) NULL, /* __mod__ */
- (binaryfunc) NULL, /* __divmod__ */
- (ternaryfunc) NULL, /* __pow__ */
- (unaryfunc) Vector_neg, /* __neg__ */
- (unaryfunc) NULL, /* __pos__ */
- (unaryfunc) NULL, /* __abs__ */
- (inquiry) NULL, /* __nonzero__ */
- (unaryfunc) NULL, /* __invert__ */
- (binaryfunc) NULL, /* __lshift__ */
- (binaryfunc) NULL, /* __rshift__ */
- (binaryfunc) NULL, /* __and__ */
- (binaryfunc) NULL, /* __xor__ */
- (binaryfunc) NULL, /* __or__ */
- (coercion) Vector_coerce, /* __coerce__ */
- (unaryfunc) NULL, /* __int__ */
- (unaryfunc) NULL, /* __long__ */
- (unaryfunc) NULL, /* __float__ */
- (unaryfunc) NULL, /* __oct__ */
- (unaryfunc) NULL, /* __hex__ */
-
- /* Added in release 2.0 */
- (binaryfunc) Vector_iadd, /*__iadd__*/
- (binaryfunc) Vector_isub, /*__isub__*/
- (binaryfunc) Vector_imul, /*__imul__*/
- (binaryfunc) Vector_idiv, /*__idiv__*/
- (binaryfunc) NULL, /*__imod__*/
- (ternaryfunc) NULL, /*__ipow__*/
- (binaryfunc) NULL, /*__ilshift__*/
- (binaryfunc) NULL, /*__irshift__*/
- (binaryfunc) NULL, /*__iand__*/
- (binaryfunc) NULL, /*__ixor__*/
- (binaryfunc) NULL, /*__ior__*/
-
- /* Added in release 2.2 */
- /* The following require the Py_TPFLAGS_HAVE_CLASS flag */
- (binaryfunc) NULL, /*__floordiv__ __rfloordiv__*/
- (binaryfunc) NULL, /*__truediv__ __rfloordiv__*/
- (binaryfunc) NULL, /*__ifloordiv__*/
- (binaryfunc) NULL, /*__itruediv__*/
-};
-/*------------------PY_OBECT DEFINITION--------------------------*/
-
-/*
- * vector axis, vector.x/y/z/w
- */
-
-static PyObject *Vector_getAxis( VectorObject * self, void *type )
-{
- switch( (long)type ) {
- case 'X': /* these are backwards, but that how it works */
- return PyFloat_FromDouble(self->vec[0]);
- case 'Y':
- return PyFloat_FromDouble(self->vec[1]);
- case 'Z': /* these are backwards, but that how it works */
- if(self->size < 3)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "vector.z: error, cannot get this axis for a 2D vector\n");
- else
- return PyFloat_FromDouble(self->vec[2]);
- case 'W':
- if(self->size < 4)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "vector.w: error, cannot get this axis for a 3D vector\n");
-
- return PyFloat_FromDouble(self->vec[3]);
- default:
- {
- char errstr[1024];
- sprintf( errstr, "undefined type '%d' in Vector_getAxis",
- (int)((long)type & 0xff));
- return EXPP_ReturnPyObjError( PyExc_RuntimeError, errstr );
- }
- }
-}
-
-static int Vector_setAxis( VectorObject * self, PyObject * value, void * type )
-{
- float param;
-
- if (!PyNumber_Check(value))
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a number for the vector axis" );
-
- param= (float)PyFloat_AsDouble( value );
-
- switch( (long)type ) {
- case 'X': /* these are backwards, but that how it works */
- self->vec[0]= param;
- break;
- case 'Y':
- self->vec[1]= param;
- break;
- case 'Z': /* these are backwards, but that how it works */
- if(self->size < 3)
- return EXPP_ReturnIntError(PyExc_AttributeError,
- "vector.z: error, cannot get this axis for a 2D vector\n");
- self->vec[2]= param;
- break;
- case 'W':
- if(self->size < 4)
- return EXPP_ReturnIntError(PyExc_AttributeError,
- "vector.w: error, cannot get this axis for a 3D vector\n");
-
- self->vec[3]= param;
- break;
- default:
- {
- char errstr[1024];
- sprintf( errstr, "undefined type '%d' in Vector_setAxis",
- (int)((long)type & 0xff));
- return EXPP_ReturnIntError( PyExc_RuntimeError, errstr );
- }
- }
-
- return 0;
-}
-
-/* vector.length */
-static PyObject *Vector_getLength( VectorObject * self, void *type )
-{
- double dot = 0.0f;
- int i;
-
- for(i = 0; i < self->size; i++){
- dot += (self->vec[i] * self->vec[i]);
- }
- return PyFloat_FromDouble(sqrt(dot));
-}
-
-static int Vector_setLength( VectorObject * self, PyObject * value )
-{
- double dot = 0.0f, param;
- int i;
-
- if (!PyNumber_Check(value))
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a number for the vector axis" );
-
- param= PyFloat_AsDouble( value );
-
- if (param < 0)
- return EXPP_ReturnIntError( PyExc_TypeError,
- "cannot set a vectors length to a negative value" );
-
- if (param==0) {
- for(i = 0; i < self->size; i++){
- self->vec[i]= 0;
- }
- return 0;
- }
-
- for(i = 0; i < self->size; i++){
- dot += (self->vec[i] * self->vec[i]);
- }
-
- if (!dot) /* cant sqrt zero */
- return 0;
-
- dot = sqrt(dot);
-
- if (dot==param)
- return 0;
-
- dot= dot/param;
-
- for(i = 0; i < self->size; i++){
- self->vec[i]= self->vec[i] / (float)dot;
- }
-
- return 0;
-}
-
-static PyObject *Vector_getWrapped( VectorObject * self, void *type )
-{
- if (self->wrapped == Py_WRAP)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-
-/*****************************************************************************/
-/* Python attributes get/set structure: */
-/*****************************************************************************/
-static PyGetSetDef Vector_getseters[] = {
- {"x",
- (getter)Vector_getAxis, (setter)Vector_setAxis,
- "Vector X axis",
- (void *)'X'},
- {"y",
- (getter)Vector_getAxis, (setter)Vector_setAxis,
- "Vector Y axis",
- (void *)'Y'},
- {"z",
- (getter)Vector_getAxis, (setter)Vector_setAxis,
- "Vector Z axis",
- (void *)'Z'},
- {"w",
- (getter)Vector_getAxis, (setter)Vector_setAxis,
- "Vector Z axis",
- (void *)'W'},
- {"length",
- (getter)Vector_getLength, (setter)Vector_setLength,
- "Vector Length",
- NULL},
- {"magnitude",
- (getter)Vector_getLength, (setter)Vector_setLength,
- "Vector Length",
- NULL},
- {"wrapped",
- (getter)Vector_getWrapped, (setter)NULL,
- "Vector Length",
- NULL},
- {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
-};
-
-
-
-/* Note
- Py_TPFLAGS_CHECKTYPES allows us to avoid casting all types to Vector when coercing
- but this means for eg that
- vec*mat and mat*vec both get sent to Vector_mul and it neesd to sort out the order
-*/
-
-PyTypeObject vector_Type = {
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
- /* For printing, in format "<module>.<name>" */
- "Blender Vector", /* char *tp_name; */
- sizeof( VectorObject ), /* int tp_basicsize; */
- 0, /* tp_itemsize; For allocation */
-
- /* Methods to implement standard operations */
-
- ( destructor ) Vector_dealloc,/* destructor tp_dealloc; */
- NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- NULL, /* cmpfunc tp_compare; */
- ( reprfunc ) Vector_repr, /* reprfunc tp_repr; */
-
- /* Method suites for standard classes */
-
- &Vector_NumMethods, /* PyNumberMethods *tp_as_number; */
- &Vector_SeqMethods, /* 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 | Py_TPFLAGS_CHECKTYPES, /* long tp_flags; */
-
- VectorObject_doc, /* 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 ***/
- (richcmpfunc)Vector_richcmpr, /* 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 ***/
- Vector_methods, /* struct PyMethodDef *tp_methods; */
- NULL, /* struct PyMemberDef *tp_members; */
- Vector_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
-};
-
-
-/*------------------------newVectorObject (internal)-------------
- creates a new vector object
- pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
- (i.e. it was allocated elsewhere by MEM_mallocN())
- pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
- (i.e. it must be created here with PyMEM_malloc())*/
-PyObject *newVectorObject(float *vec, int size, int type)
-{
- int i;
- VectorObject *self = PyObject_NEW(VectorObject, &vector_Type);
-
- if(size > 4 || size < 2)
- return NULL;
- self->size = size;
-
- if(type == Py_WRAP) {
- self->vec = vec;
- self->wrapped = Py_WRAP;
- } else if (type == Py_NEW) {
- self->vec = PyMem_Malloc(size * sizeof(float));
- if(!vec) { /*new empty*/
- for(i = 0; i < size; i++){
- self->vec[i] = 0.0f;
- }
- if(size == 4) /* do the homogenous thing */
- self->vec[3] = 1.0f;
- }else{
- for(i = 0; i < size; i++){
- self->vec[i] = vec[i];
- }
- }
- self->wrapped = Py_NEW;
- }else{ /*bad type*/
- return NULL;
- }
- return (PyObject *) self;
-}
-
-/*
- #############################DEPRECATED################################
- #######################################################################
- ----------------------------Vector.negate() --------------------
- set the vector to it's negative -x, -y, -z */
-PyObject *Vector_Negate(VectorObject * self)
-{
- int i;
- for(i = 0; i < self->size; i++) {
- self->vec[i] = -(self->vec[i]);
- }
- /*printf("Vector.negate(): Deprecated: use -vector instead\n");*/
- return EXPP_incr_ret((PyObject*)self);
-}
-/*###################################################################
- ###########################DEPRECATED##############################*/
-
diff --git a/source/blender/python/api2_2x/vector.h b/source/blender/python/api2_2x/vector.h
deleted file mode 100644
index 040f1ba5594..00000000000
--- a/source/blender/python/api2_2x/vector.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* $Id: vector.h 10313 2007-03-20 12:07: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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Willian P. Germano & Joseph Gilbert
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- *
- */
-
-#ifndef EXPP_vector_h
-#define EXPP_vector_h
-
-#include <Python.h>
-
-extern PyTypeObject vector_Type;
-
-#define VectorObject_Check(v) ((v)->ob_type == &vector_Type)
-
-typedef struct {
- PyObject_VAR_HEAD
- float *vec; /*1D array of data (alias), wrapped status depends on wrapped status */
- short size; /* vec size 2,3 or 4 */
- short wrapped; /* is wrapped data? */
-} VectorObject;
-
-/*prototypes*/
-PyObject *Vector_Zero( VectorObject * self );
-PyObject *Vector_Normalize( VectorObject * self );
-PyObject *Vector_Negate( VectorObject * self );
-PyObject *Vector_Resize2D( VectorObject * self );
-PyObject *Vector_Resize3D( VectorObject * self );
-PyObject *Vector_Resize4D( VectorObject * self );
-PyObject *Vector_toPoint( VectorObject * self );
-PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args );
-PyObject *Vector_copy( VectorObject * self );
-PyObject *newVectorObject(float *vec, int size, int type);
-
-#endif /* EXPP_vector_h */
diff --git a/source/blender/python/api2_2x/windowTheme.c b/source/blender/python/api2_2x/windowTheme.c
deleted file mode 100644
index 98894c9a0ec..00000000000
--- a/source/blender/python/api2_2x/windowTheme.c
+++ /dev/null
@@ -1,828 +0,0 @@
-/*
- * $Id: windowTheme.c 12139 2007-09-25 03:31:12Z 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 "windowTheme.h" /*This must come first*/
-
-#include "BLI_blenlib.h"
-#include "BIF_interface_icons.h"
-#include "BIF_resources.h"
-#include "MEM_guardedalloc.h"
-#include "charRGBA.h"
-#include "gen_utils.h"
-
-
-#define EXPP_THEME_VTX_SIZE_MIN 1
-#define EXPP_THEME_VTX_SIZE_MAX 10
-#define EXPP_THEME_FDOT_SIZE_MIN 1
-#define EXPP_THEME_FDOT_SIZE_MAX 10
-#define EXPP_THEME_DRAWTYPE_MIN 1
-#define EXPP_THEME_DRAWTYPE_MAX 4
-
-#define EXPP_THEME_NUMBEROFTHEMES 16
-static const EXPP_map_pair themes_map[] = {
- {"ui", -1},
- {"buts", SPACE_BUTS},
- {"view3d", SPACE_VIEW3D},
- {"file", SPACE_FILE},
- {"ipo", SPACE_IPO},
- {"info", SPACE_INFO},
- {"sound", SPACE_SOUND},
- {"action", SPACE_ACTION},
- {"nla", SPACE_NLA},
- {"seq", SPACE_SEQ},
- {"image", SPACE_IMAGE},
- {"imasel", SPACE_IMASEL},
- {"text", SPACE_TEXT},
- {"oops", SPACE_OOPS},
- {"time", SPACE_TIME},
- {"node", SPACE_NODE},
- {NULL, 0}
-};
-
-static PyObject *M_Theme_New( PyObject * self, PyObject * args );
-static PyObject *M_Theme_Get( PyObject * self, PyObject * args );
-
-static char M_Theme_doc[] = "The Blender Theme module\n\n\
-This module provides access to UI Theme data in Blender";
-
-static char M_Theme_New_doc[] = "Theme.New (name = 'New Theme',\
-theme = <default>):\n\
- Return a new Theme Data object.\n\
-(name) - string: the Theme's name, it defaults to 'New Theme';\n\
-(theme) - bpy Theme: a base Theme to copy all data from, it defaults to the\n\
-current one.";
-
-static char M_Theme_Get_doc[] = "Theme.Get (name = None):\n\
- Return the theme data with the given 'name', None if not found, or\n\
- Return a list with all Theme Data objects if no argument was given.";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Theme module: */
-/*****************************************************************************/
-struct PyMethodDef M_Theme_methods[] = {
- {"New", M_Theme_New, METH_VARARGS, M_Theme_New_doc},
- {"Get", M_Theme_Get, METH_VARARGS, M_Theme_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-static void ThemeSpace_dealloc( BPy_ThemeSpace * self );
-static int ThemeSpace_compare( BPy_ThemeSpace * a, BPy_ThemeSpace * b );
-static PyObject *ThemeSpace_repr( BPy_ThemeSpace * self );
-static PyObject *ThemeSpace_getAttr( BPy_ThemeSpace * self, char *name );
-static int ThemeSpace_setAttr( BPy_ThemeSpace * self, char *name,
- PyObject * val );
-
-static PyMethodDef BPy_ThemeSpace_methods[] = {
- {NULL, NULL, 0, NULL}
-};
-
-PyTypeObject ThemeSpace_Type = {
- PyObject_HEAD_INIT( NULL ) 0, /* ob_size */
- "Blender Space Theme", /* tp_name */
- sizeof( BPy_ThemeSpace ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- ( destructor ) ThemeSpace_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) ThemeSpace_getAttr, /* tp_getattr */
- ( setattrfunc ) ThemeSpace_setAttr, /* tp_setattr */
- ( cmpfunc ) ThemeSpace_compare, /* tp_compare */
- ( reprfunc ) ThemeSpace_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0, 0, 0, 0, 0, 0,
- 0, /* tp_doc */
- 0, 0, 0, 0, 0, 0,
- 0, //BPy_ThemeSpace_methods, /* tp_methods */
- 0, /* tp_members */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-
-static void ThemeSpace_dealloc( BPy_ThemeSpace * self )
-{
- PyObject_DEL( self );
-}
-
-#define ELSEIF_TSP_RGBA(attr)\
- else if (!strcmp(name, #attr))\
- attrib = charRGBA_New(&tsp->attr[0]);
-
-/* Example: ELSEIF_TSP_RGBA(back) becomes:
- * else if (!strcmp(name, "back")
- * attrib = charRGBA_New(&tsp->back[0])
- */
-
-static PyObject *ThemeSpace_getAttr( BPy_ThemeSpace * self, char *name )
-{
- PyObject *attrib = Py_None;
- ThemeSpace *tsp = self->tsp;
-
- if( !strcmp( name, "theme" ) )
- attrib = PyString_FromString( self->theme->name );
- ELSEIF_TSP_RGBA( back )
- ELSEIF_TSP_RGBA( text )
- ELSEIF_TSP_RGBA( text_hi )
- ELSEIF_TSP_RGBA( header )
- ELSEIF_TSP_RGBA( panel )
- ELSEIF_TSP_RGBA( shade1 )
- ELSEIF_TSP_RGBA( shade2 )
- ELSEIF_TSP_RGBA( hilite )
- ELSEIF_TSP_RGBA( grid )
- ELSEIF_TSP_RGBA( wire )
- ELSEIF_TSP_RGBA( select )
- ELSEIF_TSP_RGBA( lamp )
- ELSEIF_TSP_RGBA( active )
- ELSEIF_TSP_RGBA( group )
- ELSEIF_TSP_RGBA( group_active )
- ELSEIF_TSP_RGBA( transform )
- ELSEIF_TSP_RGBA( vertex )
- ELSEIF_TSP_RGBA( vertex_select )
- ELSEIF_TSP_RGBA( edge )
- ELSEIF_TSP_RGBA( edge_select )
- ELSEIF_TSP_RGBA( edge_seam )
- ELSEIF_TSP_RGBA( edge_sharp )
- ELSEIF_TSP_RGBA( editmesh_active )
- ELSEIF_TSP_RGBA( edge_facesel )
- ELSEIF_TSP_RGBA( face )
- ELSEIF_TSP_RGBA( face_select )
- ELSEIF_TSP_RGBA( face_dot )
- ELSEIF_TSP_RGBA( normal )
- ELSEIF_TSP_RGBA( bone_solid )
- ELSEIF_TSP_RGBA( bone_pose )
- ELSEIF_TSP_RGBA( strip )
- ELSEIF_TSP_RGBA( strip_select )
- ELSEIF_TSP_RGBA( syntaxl )
- ELSEIF_TSP_RGBA( syntaxn )
- ELSEIF_TSP_RGBA( syntaxb )
- ELSEIF_TSP_RGBA( syntaxv )
- ELSEIF_TSP_RGBA( syntaxc )
- ELSEIF_TSP_RGBA( movie )
- ELSEIF_TSP_RGBA( image )
- ELSEIF_TSP_RGBA( scene )
- ELSEIF_TSP_RGBA( audio )
- ELSEIF_TSP_RGBA( effect )
- ELSEIF_TSP_RGBA( plugin )
- ELSEIF_TSP_RGBA( transition )
- ELSEIF_TSP_RGBA( meta )
- else if( !strcmp( name, "vertex_size" ) )
- attrib = Py_BuildValue( "i", tsp->vertex_size );
- else if( !strcmp( name, "facedot_size" ) )
- attrib = Py_BuildValue( "i", tsp->facedot_size );
- else if( !strcmp( name, "__members__" ) )
- attrib = Py_BuildValue("[ssssssssssssssssssssssssssssssssssssssssssssssss]", "theme",
- "back", "text", "text_hi", "header",
- "panel", "shade1", "shade2", "hilite",
- "grid", "wire", "select", "lamp", "active",
- "group", "group_active",
- "transform", "vertex", "vertex_select",
- "edge", "edge_select", "edge_seam", "edge_sharp", "editmesh_active",
- "edge_facesel", "face", "face_select",
- "face_dot", "normal", "bone_solid", "bone_pose",
- "strip", "strip_select",
- "syntaxl", "syntaxn", "syntaxb", "syntaxv", "syntaxc",
- "movie", "image", "scene", "audio", "effect", "plugin",
- "transition", "meta",
- "vertex_size", "facedot_size" );
-
- if( attrib != Py_None )
- return attrib;
-
- return Py_FindMethod( BPy_ThemeSpace_methods, ( PyObject * ) self,
- name );
-}
-
-static int ThemeSpace_setAttr( BPy_ThemeSpace * self, char *name,
- PyObject * value )
-{
- PyObject *attrib = NULL;
- ThemeSpace *tsp = self->tsp;
- int ret = -1;
-
- if( !strcmp( name, "back" ) )
- attrib = charRGBA_New( &tsp->back[0] );
- ELSEIF_TSP_RGBA( text )
- ELSEIF_TSP_RGBA( text_hi )
- ELSEIF_TSP_RGBA( header )
- ELSEIF_TSP_RGBA( panel )
- ELSEIF_TSP_RGBA( shade1 )
- ELSEIF_TSP_RGBA( shade2 )
- ELSEIF_TSP_RGBA( hilite )
- ELSEIF_TSP_RGBA( grid )
- ELSEIF_TSP_RGBA( wire )
- ELSEIF_TSP_RGBA( select )
- ELSEIF_TSP_RGBA( lamp )
- ELSEIF_TSP_RGBA( active )
- ELSEIF_TSP_RGBA( group )
- ELSEIF_TSP_RGBA( group_active )
- ELSEIF_TSP_RGBA( transform )
- ELSEIF_TSP_RGBA( vertex )
- ELSEIF_TSP_RGBA( vertex_select )
- ELSEIF_TSP_RGBA( edge )
- ELSEIF_TSP_RGBA( edge_select )
- ELSEIF_TSP_RGBA( edge_seam )
- ELSEIF_TSP_RGBA( edge_sharp )
- ELSEIF_TSP_RGBA( edge_facesel )
- ELSEIF_TSP_RGBA( face )
- ELSEIF_TSP_RGBA( face_select )
- ELSEIF_TSP_RGBA( face_dot )
- ELSEIF_TSP_RGBA( normal )
- ELSEIF_TSP_RGBA( bone_solid )
- ELSEIF_TSP_RGBA( bone_pose )
- ELSEIF_TSP_RGBA( strip )
- ELSEIF_TSP_RGBA( strip_select )
- ELSEIF_TSP_RGBA( syntaxl )
- ELSEIF_TSP_RGBA( syntaxn )
- ELSEIF_TSP_RGBA( syntaxb )
- ELSEIF_TSP_RGBA( syntaxv )
- ELSEIF_TSP_RGBA( syntaxc )
- ELSEIF_TSP_RGBA( movie )
- ELSEIF_TSP_RGBA( image )
- ELSEIF_TSP_RGBA( scene )
- ELSEIF_TSP_RGBA( audio )
- ELSEIF_TSP_RGBA( effect )
- ELSEIF_TSP_RGBA( plugin )
- ELSEIF_TSP_RGBA( transition )
- ELSEIF_TSP_RGBA( meta )
- else if( !strcmp( name, "vertex_size" ) ) {
- int val;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer value" );
-
- val = ( int ) PyInt_AsLong( value );
- tsp->vertex_size = (char)EXPP_ClampInt( val,
- EXPP_THEME_VTX_SIZE_MIN,
- EXPP_THEME_VTX_SIZE_MAX );
- ret = 0;
- }
- else if( !strcmp( name, "facedot_size" ) ) {
- int val;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer value" );
-
- val = ( int ) PyInt_AsLong( value );
- tsp->vertex_size = (char)EXPP_ClampInt( val,
- EXPP_THEME_FDOT_SIZE_MIN,
- EXPP_THEME_FDOT_SIZE_MAX );
- ret = 0;
- } else
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "attribute not found" );
-
- if( attrib ) {
- PyObject *pyret = NULL;
- PyObject *valtuple = Py_BuildValue( "(O)", value );
-
- if( !valtuple )
- return EXPP_ReturnIntError( PyExc_MemoryError,
- "couldn't create tuple!" );
-
- pyret = charRGBA_setCol( ( BPy_charRGBA * ) attrib, valtuple );
- Py_DECREF( valtuple );
-
- if( pyret == Py_None ) {
- Py_DECREF( Py_None ); /* was increfed by charRGBA_setCol */
- ret = 0;
- }
-
- Py_DECREF( attrib ); /* we're done with it */
- }
-
- return ret; /* 0 if all went well */
-}
-
-static int ThemeSpace_compare( BPy_ThemeSpace * a, BPy_ThemeSpace * b )
-{
- ThemeSpace *pa = a->tsp, *pb = b->tsp;
- return ( pa == pb ) ? 0 : -1;
-}
-
-static PyObject *ThemeSpace_repr( BPy_ThemeSpace * self )
-{
- return PyString_FromFormat( "[Space theme from theme \"%s\"]",
- self->theme->name );
-}
-
-static void ThemeUI_dealloc( BPy_ThemeUI * self );
-static int ThemeUI_compare( BPy_ThemeUI * a, BPy_ThemeUI * b );
-static PyObject *ThemeUI_repr( BPy_ThemeUI * self );
-static PyObject *ThemeUI_getAttr( BPy_ThemeUI * self, char *name );
-static int ThemeUI_setAttr( BPy_ThemeUI * self, char *name, PyObject * val );
-
-static PyMethodDef BPy_ThemeUI_methods[] = {
- {NULL, NULL, 0, NULL}
-};
-
-PyTypeObject ThemeUI_Type = {
- PyObject_HEAD_INIT( NULL ) 0, /* ob_size */
- "Blender UI Theme", /* tp_name */
- sizeof( BPy_ThemeUI ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- ( destructor ) ThemeUI_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) ThemeUI_getAttr, /* tp_getattr */
- ( setattrfunc ) ThemeUI_setAttr, /* tp_setattr */
- ( cmpfunc ) ThemeUI_compare, /* tp_compare */
- ( reprfunc ) ThemeUI_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0, 0, 0, 0, 0, 0,
- 0, /* tp_doc */
- 0, 0, 0, 0, 0, 0,
- 0, //BPy_ThemeUI_methods, /* tp_methods */
- 0, /* tp_members */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-
-static void ThemeUI_dealloc( BPy_ThemeUI * self )
-{
- PyObject_DEL( self );
-}
-
-#define ELSEIF_TUI_RGBA(attr)\
- else if (!strcmp(name, #attr))\
- attrib = charRGBA_New(&tui->attr[0]);
-
-/* Example: ELSEIF_TUI_RGBA(outline) becomes:
- * else if (!strcmp(name, "outline")
- * attr = charRGBA_New(&tui->outline[0])
- */
-
-static PyObject *ThemeUI_getAttr( BPy_ThemeUI * self, char *name )
-{
- PyObject *attrib = Py_None;
- ThemeUI *tui = self->tui;
-
- if( !strcmp( name, "theme" ) )
- attrib = PyString_FromString( self->theme->name );
- ELSEIF_TUI_RGBA( outline )
- ELSEIF_TUI_RGBA( neutral )
- ELSEIF_TUI_RGBA( action )
- ELSEIF_TUI_RGBA( setting )
- ELSEIF_TUI_RGBA( setting1 )
- ELSEIF_TUI_RGBA( setting2 )
- ELSEIF_TUI_RGBA( num )
- ELSEIF_TUI_RGBA( textfield )
- ELSEIF_TUI_RGBA( textfield_hi )
- ELSEIF_TUI_RGBA( popup )
- ELSEIF_TUI_RGBA( text )
- ELSEIF_TUI_RGBA( text_hi )
- ELSEIF_TUI_RGBA( menu_back )
- ELSEIF_TUI_RGBA( menu_item )
- ELSEIF_TUI_RGBA( menu_hilite )
- ELSEIF_TUI_RGBA( menu_text )
- ELSEIF_TUI_RGBA( menu_text_hi )
- else if( !strcmp( name, "drawType" ) )
- attrib = PyInt_FromLong( ( char ) tui->but_drawtype );
- else if( !strcmp( name, "iconTheme" ) )
- attrib = PyString_FromString( tui->iconfile );
- else if( !strcmp( name, "__members__" ) )
- attrib = Py_BuildValue( "[ssssssssssssssssssss]", "theme",
- "outline", "neutral", "action",
- "setting", "setting1", "setting2",
- "num", "textfield", "textfield_hi", "popup", "text",
- "text_hi", "menu_back", "menu_item",
- "menu_hilite", "menu_text",
- "menu_text_hi", "drawType", "iconTheme" );
-
- if( attrib != Py_None )
- return attrib;
-
- return Py_FindMethod( BPy_ThemeUI_methods, ( PyObject * ) self, name );
-}
-
-static int ThemeUI_setAttr( BPy_ThemeUI * self, char *name, PyObject * value )
-{
- PyObject *attrib = NULL;
- ThemeUI *tui = self->tui;
- int ret = -1;
-
- if( !strcmp( name, "outline" ) )
- attrib = charRGBA_New( &tui->outline[0] );
- ELSEIF_TUI_RGBA( neutral )
- ELSEIF_TUI_RGBA( action )
- ELSEIF_TUI_RGBA( setting )
- ELSEIF_TUI_RGBA( setting1 )
- ELSEIF_TUI_RGBA( setting2 )
- ELSEIF_TUI_RGBA( num )
- ELSEIF_TUI_RGBA( textfield )
- ELSEIF_TUI_RGBA( textfield_hi )
- ELSEIF_TUI_RGBA( popup )
- ELSEIF_TUI_RGBA( text )
- ELSEIF_TUI_RGBA( text_hi )
- ELSEIF_TUI_RGBA( menu_back )
- ELSEIF_TUI_RGBA( menu_item )
- ELSEIF_TUI_RGBA( menu_hilite )
- ELSEIF_TUI_RGBA( menu_text )
- ELSEIF_TUI_RGBA( menu_text_hi )
- else if( !strcmp( name, "drawType" ) ) {
- int val;
-
- if( !PyInt_Check( value ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer value" );
-
- val = ( int ) PyInt_AsLong( value );
- tui->but_drawtype = (char)EXPP_ClampInt( val,
- EXPP_THEME_DRAWTYPE_MIN,
- EXPP_THEME_DRAWTYPE_MAX );
- ret = 0;
- } else if ( !strcmp( name, "iconTheme" ) ) {
- if ( !PyString_Check(value) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected string value" );
- BLI_strncpy(tui->iconfile, PyString_AsString(value), 80);
-
- BIF_icons_free();
- BIF_icons_init(BIFICONID_LAST+1);
-
- ret = 0;
- } else
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "attribute not found" );
-
- if( attrib ) {
- PyObject *pyret = NULL;
- PyObject *valtuple = Py_BuildValue( "(O)", value );
-
- if( !valtuple )
- return EXPP_ReturnIntError( PyExc_MemoryError,
- "couldn't create tuple!" );
-
- pyret = charRGBA_setCol( ( BPy_charRGBA * ) attrib, valtuple );
- Py_DECREF( valtuple );
-
- if( pyret == Py_None ) {
- Py_DECREF( Py_None ); /* was increfed by charRGBA_setCol */
- ret = 0;
- }
-
- Py_DECREF( attrib ); /* we're done with it */
- }
-
- return ret; /* 0 if all went well */
-}
-
-
-static int ThemeUI_compare( BPy_ThemeUI * a, BPy_ThemeUI * b )
-{
- ThemeUI *pa = a->tui, *pb = b->tui;
- return ( pa == pb ) ? 0 : -1;
-}
-
-static PyObject *ThemeUI_repr( BPy_ThemeUI * self )
-{
- return PyString_FromFormat( "[UI theme from theme \"%s\"]",
- self->theme->name );
-}
-
-static void Theme_dealloc( BPy_Theme * self );
-static int Theme_compare( BPy_Theme * a, BPy_Theme * b );
-static PyObject *Theme_getAttr( BPy_Theme * self, char *name );
-static PyObject *Theme_repr( BPy_Theme * self );
-
-static PyObject *Theme_get( BPy_Theme * self, PyObject * args );
-static PyObject *Theme_getName( BPy_Theme * self );
-static PyObject *Theme_setName( BPy_Theme * self, PyObject * value );
-
-static PyMethodDef BPy_Theme_methods[] = {
- {"get", ( PyCFunction ) Theme_get, METH_VARARGS,
- "(param) - Return UI or Space theme object.\n\
-(param) - the chosen theme object as an int or a string:\n\
-- () - default: UI;\n\
-- (i) - int: an entry from the Blender.Window.Types dictionary;\n\
-- (s) - string: 'UI' or a space name, like 'VIEW3D', etc."},
- {"getName", ( PyCFunction ) Theme_getName, METH_NOARGS,
- "() - Return Theme name"},
- {"setName", ( PyCFunction ) Theme_setName, METH_O,
- "(s) - Set Theme name"},
- {NULL, NULL, 0, NULL}
-};
-
-PyTypeObject Theme_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
- "Blender Theme", /* tp_name */
- sizeof( BPy_Theme ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- ( destructor ) Theme_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) Theme_getAttr, /* tp_getattr */
- 0, //(setattrfunc) Theme_setAttr, /* tp_setattr */
- ( cmpfunc ) Theme_compare, /* tp_compare */
- ( reprfunc ) Theme_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0, 0, 0, 0, 0, 0,
- 0, /* tp_doc */
- 0, 0, 0, 0, 0, 0,
- 0, /*BPy_Theme_methods,*/ /* tp_methods */
- 0, /* tp_members */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-
-static PyObject *M_Theme_New( PyObject * self, PyObject * args )
-{
- char *name = "New Theme";
- BPy_Theme *pytheme = NULL, *base_pytheme = NULL;
- bTheme *btheme = NULL, *newtheme = NULL;
-
- if( !PyArg_ParseTuple
- ( args, "|sO!", &name, &Theme_Type, &base_pytheme ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected nothing or a name and optional theme object as arguments" );
-
- if( base_pytheme )
- btheme = base_pytheme->theme;
- if( !btheme )
- btheme = U.themes.first;
-
- newtheme = MEM_callocN( sizeof( bTheme ), "theme" );
-
- if( newtheme )
- pytheme = PyObject_New( BPy_Theme, &Theme_Type );
- if( !pytheme )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't create Theme Data in Blender" );
-
- memcpy( newtheme, btheme, sizeof( bTheme ) );
- BLI_addhead( &U.themes, newtheme );
- BLI_strncpy( newtheme->name, name, 32 );
-
- pytheme->theme = newtheme;
-
- return ( PyObject * ) pytheme;
-}
-
-static PyObject *M_Theme_Get( PyObject * self, PyObject * args )
-{
- char *name = NULL;
- bTheme *iter;
- PyObject *ret;
-
- if( !PyArg_ParseTuple( args, "|s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument (or nothing)" );
-
- iter = U.themes.first;
-
- if( name ) { /* (name) - return requested theme */
- BPy_Theme *wanted = NULL;
-
- while( iter ) {
- if( strcmp( name, iter->name ) == 0 ) {
- wanted = PyObject_New( BPy_Theme,
- &Theme_Type );
- wanted->theme = iter;
- break;
- }
- iter = iter->next;
- }
-
- if( !wanted ) {
- char emsg[64];
- PyOS_snprintf( emsg, sizeof( emsg ),
- "Theme \"%s\" not found", name );
- return EXPP_ReturnPyObjError( PyExc_NameError, emsg );
- }
-
- ret = ( PyObject * ) wanted;
- }
-
- else { /* () - return list with all themes */
- int index = 0;
- PyObject *list = NULL;
- BPy_Theme *pytheme = NULL;
-
- list = PyList_New( BLI_countlist( &( U.themes ) ) );
-
- if( !list )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyList" );
-
- while( iter ) {
- pytheme = PyObject_New( BPy_Theme, &Theme_Type );
- pytheme->theme = iter;
-
- if( !pytheme ) {
- Py_DECREF(list);
- return EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "couldn't create Theme PyObject" );
- }
- PyList_SET_ITEM( list, index, ( PyObject * ) pytheme );
-
- iter = iter->next;
- index++;
- }
-
- ret = list;
- }
-
- return ret;
-}
-
-static PyObject *Theme_get( BPy_Theme * self, PyObject * args )
-{
- bTheme *btheme = self->theme;
- ThemeUI *tui = NULL;
- ThemeSpace *tsp = NULL;
- PyObject *pyob = NULL;
- BPy_ThemeUI *retUI = NULL;
- BPy_ThemeSpace *retSpc = NULL;
- int type;
-
- if( !PyArg_ParseTuple( args, "|O", &pyob ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string or int argument or nothing" );
-
- if( !pyob ) { /* (): return list with all names */
- PyObject *ret = PyList_New( EXPP_THEME_NUMBEROFTHEMES );
-
- if( !ret )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create pylist!" );
-
- type = 0; /* using as a counter only */
-
- while( type < EXPP_THEME_NUMBEROFTHEMES ) {
- PyList_SET_ITEM( ret, type,
- PyString_FromString( themes_map[type].sval ) );
- type++;
- }
-
- return ret;
- }
-
- else if( PyInt_Check( pyob ) ) /* (int) */
- type = ( int ) PyInt_AsLong( pyob );
- else if( PyString_Check( pyob ) ) { /* (str) */
- char *str = PyString_AsString( pyob );
- if( !EXPP_map_case_getIntVal( themes_map, str, &type ) )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unknown string argument" );
- } else
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string or int argument or nothing" );
-
- switch ( type ) {
- case -1: /* UI */
- tui = &btheme->tui;
- break;
- case SPACE_BUTS:
- tsp = &btheme->tbuts;
- break;
- case SPACE_VIEW3D:
- tsp = &btheme->tv3d;
- break;
- case SPACE_FILE:
- tsp = &btheme->tfile;
- break;
- case SPACE_IPO:
- tsp = &btheme->tipo;
- break;
- case SPACE_INFO:
- tsp = &btheme->tinfo;
- break;
- case SPACE_SOUND:
- tsp = &btheme->tsnd;
- break;
- case SPACE_ACTION:
- tsp = &btheme->tact;
- break;
- case SPACE_NLA:
- tsp = &btheme->tnla;
- break;
- case SPACE_SEQ:
- tsp = &btheme->tseq;
- break;
- case SPACE_IMAGE:
- tsp = &btheme->tima;
- break;
- case SPACE_IMASEL:
- tsp = &btheme->timasel;
- break;
- case SPACE_TEXT:
- tsp = &btheme->text;
- break;
- case SPACE_OOPS:
- tsp = &btheme->toops;
- break;
- case SPACE_TIME:
- tsp = &btheme->ttime;
- break;
- case SPACE_NODE:
- tsp = &btheme->tnode;
- break;
- }
-
- if( tui ) {
- retUI = PyObject_New( BPy_ThemeUI, &ThemeUI_Type );
- retUI->theme = btheme;
- retUI->tui = tui;
- return ( PyObject * ) retUI;
- } else if( tsp ) {
- retSpc = PyObject_New( BPy_ThemeSpace, &ThemeSpace_Type );
- retSpc->theme = btheme;
- retSpc->tsp = tsp;
- return ( PyObject * ) retSpc;
- } else
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "invalid parameter" );
-}
-
-static PyObject *Theme_getName( BPy_Theme * self )
-{
- return PyString_FromString( self->theme->name );
-}
-
-static PyObject *Theme_setName( BPy_Theme * self, PyObject * value )
-{
- char *name = PyString_AsString(value);
-
- if( !name )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- BLI_strncpy( self->theme->name, name, 32 );
-
- return EXPP_incr_ret( Py_None );
-}
-
-PyObject *Theme_Init( void )
-{
- PyObject *submodule;
-
- Theme_Type.ob_type = &PyType_Type;
-
- submodule = Py_InitModule3( "Blender.Window.Theme",
- M_Theme_methods, M_Theme_doc );
-
- return submodule;
-}
-
-static void Theme_dealloc( BPy_Theme * self )
-{
- PyObject_DEL( self );
-}
-
-static PyObject *Theme_getAttr( BPy_Theme * self, char *name )
-{
- if( !strcmp( name, "name" ) )
- return PyString_FromString( self->theme->name );
- else if( !strcmp( name, "__members__" ) )
- return Py_BuildValue( "[s]", "name" );
-
- return Py_FindMethod( BPy_Theme_methods, ( PyObject * ) self, name );
-}
-
-static int Theme_compare( BPy_Theme * a, BPy_Theme * b )
-{
- bTheme *pa = a->theme, *pb = b->theme;
- return ( pa == pb ) ? 0 : -1;
-}
-
-static PyObject *Theme_repr( BPy_Theme * self )
-{
- return PyString_FromFormat( "[Theme \"%s\"]", self->theme->name );
-}
diff --git a/source/blender/python/api2_2x/windowTheme.h b/source/blender/python/api2_2x/windowTheme.h
deleted file mode 100644
index 45900830706..00000000000
--- a/source/blender/python/api2_2x/windowTheme.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * $Id: windowTheme.h 8774 2006-11-07 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) 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_WINDOWTHEME_H
-#define EXPP_WINDOWTHEME_H
-
-#include <Python.h>
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
-#include "DNA_userdef_types.h"
-
-typedef struct {
- PyObject_HEAD struct bTheme *theme;
- struct ThemeUI *tui;
-
-} BPy_ThemeUI;
-
-typedef struct {
- PyObject_HEAD struct bTheme *theme;
- struct ThemeSpace *tsp;
-
-} BPy_ThemeSpace;
-
-typedef struct {
- PyObject_HEAD struct bTheme *theme;
-
-} BPy_Theme;
-
-PyObject *Theme_Init( void );
-
-#endif /* EXPP_WINDOWTHEME_H */