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

Scene.c « api2_2x « python « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eba951b88133b434ce0946e226fba18ae65ea9bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
/* 
 *
 * $Id$
 *
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 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 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_armature.h"
#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(  ) );
	PyDict_SetItemString( dict, "TimeLine", TimeLine_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 = 2;
	Scene *scene = self->scene;

	SCENE_DEL_CHECK_PY(self);

	if( !PyArg_ParseTuple( args, "|h", &dup_objs ) || dup_objs < 0 || dup_objs > 2)
		return EXPP_ReturnPyObjError( PyExc_TypeError,
					      "expected int in [0,2] or nothing as argument" );
	
	return Scene_CreatePyObject( copy_scene( scene, dup_objs+1 ) );
}

/*-----------------------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);
	return SceneSeq_CreatePyObject( self->scene, NULL );
}

/* 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 = GET_INT_FROM_POINTER(_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; base= base->next) {
			if (base->flag & SELECT) {
				if (i==index) {
					break;
				} else {
					index++;
				}
			}
		}
	}
	/* context */
	else if (self->mode==EXPP_OBSEQ_CONTEXT) {
		if (G.vd) {
			for (base= scene->base.first; base; base= base->next) {
				if (TESTBASE(base)) {
					if (i==index) {
						break;
					} else {
						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);
	} else if (object->type == OB_ARMATURE) {
		armature_rebuild_pose(object, (bArmature *)data);
	}
	
	/* 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
};