~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/python/api2_2x/Wave.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
 
2
 * $Id: Wave.c,v 1.7 2005/03/09 19:45:55 lukep Exp $
2
3
 *
3
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
4
5
 *
32
33
#include "Wave.h"
33
34
#include "Effect.h"
34
35
 
 
36
/******* prototypes **********/
 
37
PyObject *Wave_Init( void );
35
38
 
36
39
/*****************************************************************************/
37
 
/* Python BPy_Wave methods table:                                              */
 
40
/* Python BPy_Wave methods table:                                            */
38
41
/*****************************************************************************/
39
42
static PyMethodDef BPy_Wave_methods[] = {
40
 
        {"getType", (PyCFunction)Effect_getType,
41
 
         METH_NOARGS,"() - Return Effect type"},
42
 
  {"setType", (PyCFunction)Effect_setType, 
43
 
   METH_VARARGS,"() - Set Effect type"},
44
 
  {"getFlag", (PyCFunction)Effect_getFlag, 
45
 
   METH_NOARGS,"() - Return Effect flag"},
46
 
  {"setFlag", (PyCFunction)Effect_setFlag, 
47
 
   METH_VARARGS,"() - Set Effect flag"},
48
 
  {"getStartx",(PyCFunction)Wave_getStartx,
49
 
         METH_NOARGS,"()-Return Wave startx"},
50
 
  {"setStartx",(PyCFunction)Wave_setStartx, METH_VARARGS,
 
43
        {"getType", ( PyCFunction ) Effect_getType,
 
44
         METH_NOARGS, "() - Return Effect type"},
 
45
        {"setType", ( PyCFunction ) Effect_setType,
 
46
         METH_VARARGS, "() - Set Effect type"},
 
47
        {"getFlag", ( PyCFunction ) Effect_getFlag,
 
48
         METH_NOARGS, "() - Return Effect flag"},
 
49
        {"setFlag", ( PyCFunction ) Effect_setFlag,
 
50
         METH_VARARGS, "() - Set Effect flag"},
 
51
        {"getStartx", ( PyCFunction ) Wave_getStartx,
 
52
         METH_NOARGS, "()-Return Wave startx"},
 
53
        {"setStartx", ( PyCFunction ) Wave_setStartx, METH_VARARGS,
51
54
         "()- Sets Wave startx"},
52
 
  {"getStarty",(PyCFunction)Wave_getStarty,
53
 
         METH_NOARGS,"()-Return Wave starty"},
54
 
  {"setStarty",(PyCFunction)Wave_setStarty, METH_VARARGS,
 
55
        {"getStarty", ( PyCFunction ) Wave_getStarty,
 
56
         METH_NOARGS, "()-Return Wave starty"},
 
57
        {"setStarty", ( PyCFunction ) Wave_setStarty, METH_VARARGS,
55
58
         "()- Sets Wave starty"},
56
 
  {"getHeight",(PyCFunction)Wave_getHeight,
57
 
         METH_NOARGS,"()-Return Wave height"},
58
 
  {"setHeight",(PyCFunction)Wave_setHeight, METH_VARARGS,
 
59
        {"getHeight", ( PyCFunction ) Wave_getHeight,
 
60
         METH_NOARGS, "()-Return Wave height"},
 
61
        {"setHeight", ( PyCFunction ) Wave_setHeight, METH_VARARGS,
59
62
         "()- Sets Wave height"},
60
 
  {"getWidth",(PyCFunction)Wave_getWidth,
61
 
         METH_NOARGS,"()-Return Wave width"},
62
 
  {"setWidth",(PyCFunction)Wave_setWidth, METH_VARARGS,
 
63
        {"getWidth", ( PyCFunction ) Wave_getWidth,
 
64
         METH_NOARGS, "()-Return Wave width"},
 
65
        {"setWidth", ( PyCFunction ) Wave_setWidth, METH_VARARGS,
63
66
         "()- Sets Wave width"},
64
 
  {"getNarrow",(PyCFunction)Wave_getNarrow,
65
 
         METH_NOARGS,"()-Return Wave narrow"},
66
 
  {"setNarrow",(PyCFunction)Wave_setNarrow, METH_VARARGS,
 
67
        {"getNarrow", ( PyCFunction ) Wave_getNarrow,
 
68
         METH_NOARGS, "()-Return Wave narrow"},
 
69
        {"setNarrow", ( PyCFunction ) Wave_setNarrow, METH_VARARGS,
67
70
         "()- Sets Wave narrow"},
68
 
  {"getSpeed",(PyCFunction)Wave_getSpeed,
69
 
         METH_NOARGS,"()-Return Wave speed"},
70
 
  {"setSpeed",(PyCFunction)Wave_setSpeed, METH_VARARGS,
 
71
        {"getSpeed", ( PyCFunction ) Wave_getSpeed,
 
72
         METH_NOARGS, "()-Return Wave speed"},
 
73
        {"setSpeed", ( PyCFunction ) Wave_setSpeed, METH_VARARGS,
71
74
         "()- Sets Wave speed"},
72
 
  {"getMinfac",(PyCFunction)Wave_getMinfac,
73
 
         METH_NOARGS,"()-Return Wave minfac"},
74
 
  {"setMinfac",(PyCFunction)Wave_setMinfac, METH_VARARGS,
 
75
        {"getMinfac", ( PyCFunction ) Wave_getMinfac,
 
76
         METH_NOARGS, "()-Return Wave minfac"},
 
77
        {"setMinfac", ( PyCFunction ) Wave_setMinfac, METH_VARARGS,
75
78
         "()- Sets Wave minfac"},
76
 
  {"getDamp",(PyCFunction)Wave_getDamp,
77
 
         METH_NOARGS,"()-Return Wave damp"},
78
 
  {"setDamp",(PyCFunction)Wave_setDamp, METH_VARARGS,
 
79
        {"getDamp", ( PyCFunction ) Wave_getDamp,
 
80
         METH_NOARGS, "()-Return Wave damp"},
 
81
        {"setDamp", ( PyCFunction ) Wave_setDamp, METH_VARARGS,
79
82
         "()- Sets Wave damp"},
80
 
  {"getTimeoffs",(PyCFunction)Wave_getTimeoffs,
81
 
         METH_NOARGS,"()-Return Wave timeoffs"},
82
 
  {"setTimeoffs",(PyCFunction)Wave_setTimeoffs, METH_VARARGS,
 
83
        {"getTimeoffs", ( PyCFunction ) Wave_getTimeoffs,
 
84
         METH_NOARGS, "()-Return Wave timeoffs"},
 
85
        {"setTimeoffs", ( PyCFunction ) Wave_setTimeoffs, METH_VARARGS,
83
86
         "()- Sets Wave timeoffs"},
84
 
  {"getLifetime",(PyCFunction)Wave_getLifetime,
85
 
         METH_NOARGS,"()-Return Wave lifetime"},
86
 
  {"setLifetime",(PyCFunction)Wave_setLifetime, METH_VARARGS,
 
87
        {"getLifetime", ( PyCFunction ) Wave_getLifetime,
 
88
         METH_NOARGS, "()-Return Wave lifetime"},
 
89
        {"setLifetime", ( PyCFunction ) Wave_setLifetime, METH_VARARGS,
87
90
         "()- Sets Wave lifetime"},
88
 
        {0}
 
91
        {NULL, NULL, 0, NULL}
89
92
};
90
93
 
91
94
 
94
97
/*****************************************************************************/
95
98
/* Python Wave_Type structure definition:                                    */
96
99
/*****************************************************************************/
97
 
PyTypeObject Wave_Type =
98
 
{
99
 
  PyObject_HEAD_INIT(NULL)
100
 
  0,                                     
101
 
  "Wave",                              
102
 
  sizeof (BPy_Wave),                   
103
 
  0,                                    
104
 
  /* methods */
105
 
  (destructor)WaveDeAlloc,              /* tp_dealloc */
106
 
  (printfunc)WavePrint,                 /* tp_print */
107
 
  (getattrfunc)WaveGetAttr,             /* tp_getattr */
108
 
  (setattrfunc)WaveSetAttr,             /* tp_setattr */
109
 
  0,                                      /* tp_compare */
110
 
  (reprfunc)WaveRepr,                   /* tp_repr */
111
 
  0,                                      /* tp_as_number */
112
 
  0,                                      /* tp_as_sequence */
113
 
  0,                                      /* tp_as_mapping */
114
 
  0,                                      /* tp_as_hash */
115
 
  0,0,0,0,0,0,
116
 
  0,                                      /* tp_doc */ 
117
 
  0,0,0,0,0,0,
118
 
  BPy_Wave_methods,                       /* tp_methods */
119
 
  0,                                      /* tp_members */
 
100
PyTypeObject Wave_Type = {
 
101
        PyObject_HEAD_INIT( NULL )
 
102
        0,
 
103
        "Wave",
 
104
        sizeof( BPy_Wave ),
 
105
        0,
 
106
        /* methods */
 
107
        ( destructor ) WaveDeAlloc,     /* tp_dealloc */
 
108
        ( printfunc ) WavePrint,        /* tp_print */
 
109
        ( getattrfunc ) WaveGetAttr,    /* tp_getattr */
 
110
        ( setattrfunc ) WaveSetAttr,    /* tp_setattr */
 
111
        0,                      /* tp_compare */
 
112
        ( reprfunc ) WaveRepr,  /* tp_repr */
 
113
        0,                      /* tp_as_number */
 
114
        0,                      /* tp_as_sequence */
 
115
        0,                      /* tp_as_mapping */
 
116
        0,                      /* tp_as_hash */
 
117
        0, 0, 0, 0, 0, 0,
 
118
        0,                      /* tp_doc */
 
119
        0, 0, 0, 0, 0, 0,
 
120
        BPy_Wave_methods,       /* tp_methods */
 
121
        0,                      /* tp_members */
120
122
};
121
123
 
122
124
 
131
133
        New(opt name) : creates a new wave object with the given name (optional)\n\
132
134
        Get(name) : retreives a wave  with the given name (mandatory)\n\
133
135
        get(name) : same as Get. Kept for compatibility reasons";
134
 
static char M_Wave_New_doc[] ="";
135
 
static char M_Wave_Get_doc[] ="xxx";
 
136
static char M_Wave_New_doc[] = "";
 
137
static char M_Wave_Get_doc[] = "xxx";
136
138
/*****************************************************************************/
137
139
/* Python method structure definition for Blender.Wave module:               */
138
140
/*****************************************************************************/
139
141
struct PyMethodDef M_Wave_methods[] = {
140
 
  {"New",(PyCFunction)M_Wave_New, METH_VARARGS,M_Wave_New_doc},
141
 
  {"Get",         M_Wave_Get,         METH_VARARGS, M_Wave_Get_doc},
142
 
  {"get",         M_Wave_Get,         METH_VARARGS, M_Wave_Get_doc},
143
 
  {NULL, NULL, 0, NULL}
 
142
        {"New", ( PyCFunction ) M_Wave_New, METH_VARARGS, M_Wave_New_doc},
 
143
        {"Get", M_Wave_Get, METH_VARARGS, M_Wave_Get_doc},
 
144
        {"get", M_Wave_Get, METH_VARARGS, M_Wave_Get_doc},
 
145
        {NULL, NULL, 0, NULL}
144
146
};
145
147
 
146
148
 
160
162
/* Function:              M_Wave_New                                         */
161
163
/* Python equivalent:     Blender.Effect.Wave.New                            */
162
164
/*****************************************************************************/
163
 
PyObject *M_Wave_New(PyObject *self, PyObject *args)
 
165
PyObject *M_Wave_New( PyObject * self, PyObject * args )
164
166
{
165
 
int type =   EFF_WAVE;
166
 
  BPy_Effect    *pyeffect;
167
 
  Effect      *bleffect = 0; 
168
 
  
169
 
  bleffect = add_effect(type); 
170
 
  if (bleffect == NULL) 
171
 
    return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
172
 
             "couldn't create Effect Data in Blender"));
173
 
 
174
 
  pyeffect = (BPy_Effect *)PyObject_NEW(BPy_Effect, &Effect_Type);
175
 
 
176
 
     
177
 
  if (pyeffect == NULL) return (EXPP_ReturnPyObjError (PyExc_MemoryError,
178
 
                     "couldn't create Effect Data object"));
179
 
 
180
 
  pyeffect->effect = bleffect; 
181
 
 
182
 
  return (PyObject *)pyeffect;
183
 
  return 0;
 
167
        int type = EFF_WAVE;
 
168
        BPy_Effect *pyeffect;
 
169
        Effect *bleffect = 0;
 
170
 
 
171
        bleffect = add_effect( type );
 
172
        if( bleffect == NULL )
 
173
                return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
 
174
                                                "couldn't create Effect Data in Blender" ) );
 
175
 
 
176
        pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
 
177
 
 
178
 
 
179
        if( pyeffect == NULL )
 
180
                return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
 
181
                                                "couldn't create Effect Data object" ) );
 
182
 
 
183
        pyeffect->effect = bleffect;
 
184
 
 
185
        return ( PyObject * ) pyeffect;
 
186
        return 0;
184
187
}
185
188
 
186
189
/*****************************************************************************/
187
190
/* Function:              M_Wave_Get                                         */
188
191
/* Python equivalent:     Blender.Effect.Wave.Get                            */
189
192
/*****************************************************************************/
190
 
PyObject *M_Wave_Get(PyObject *self, PyObject *args)
 
193
PyObject *M_Wave_Get( PyObject * self, PyObject * args )
191
194
{
192
 
  /*arguments : string object name
193
 
    int : position of effect in the obj's effect list  */
194
 
  char     *name = 0;
195
 
  Object   *object_iter;
196
 
  Effect *eff;
197
 
  BPy_Wave *wanted_eff;
198
 
  int num,i;
199
 
 
200
 
  if (!PyArg_ParseTuple(args, "si", &name, &num ))
201
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
202
 
                                 "expected string int argument"));
203
 
 
204
 
  object_iter = G.main->object.first;
205
 
  if (!object_iter)return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
206
 
                                                "Scene contains no object"));
207
 
 
208
 
  while (object_iter)
209
 
    {
210
 
      if (strcmp(name,object_iter->id.name+2))
211
 
        {
212
 
          object_iter = object_iter->id.next;
213
 
          continue;
214
 
        }
215
 
 
216
 
      
217
 
      if (object_iter->effect.first != NULL)
218
 
        {
219
 
          eff = object_iter->effect.first;
220
 
          for(i = 0;i<num;i++)
221
 
            {
222
 
              if (eff->type != EFF_WAVE)continue;
223
 
              eff = eff->next;
224
 
              if (!eff)
225
 
                return(EXPP_ReturnPyObjError(PyExc_AttributeError,"bject"));
226
 
            }
227
 
          wanted_eff = (BPy_Wave *)PyObject_NEW(BPy_Wave, &Wave_Type);
228
 
          wanted_eff->wave = eff;
229
 
          return (PyObject*)wanted_eff;  
230
 
        }
231
 
      object_iter = object_iter->id.next;
232
 
    }
233
 
  Py_INCREF(Py_None);
234
 
  return Py_None;
 
195
        /*arguments : string object name
 
196
           int : position of effect in the obj's effect list  */
 
197
        char *name = 0;
 
198
        Object *object_iter;
 
199
        Effect *eff;
 
200
        BPy_Wave *wanted_eff;
 
201
        int num, i;
 
202
 
 
203
        if( !PyArg_ParseTuple( args, "si", &name, &num ) )
 
204
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
205
                                                "expected string int argument" ) );
 
206
 
 
207
        object_iter = G.main->object.first;
 
208
        if( !object_iter )
 
209
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
210
                                                "Scene contains no object" ) );
 
211
 
 
212
        while( object_iter ) {
 
213
                if( strcmp( name, object_iter->id.name + 2 ) ) {
 
214
                        object_iter = object_iter->id.next;
 
215
                        continue;
 
216
                }
 
217
 
 
218
 
 
219
                if( object_iter->effect.first != NULL ) {
 
220
                        eff = object_iter->effect.first;
 
221
                        for( i = 0; i < num; i++ ) {
 
222
                                if( eff->type != EFF_WAVE )
 
223
                                        continue;
 
224
                                eff = eff->next;
 
225
                                if( !eff )
 
226
                                        return ( EXPP_ReturnPyObjError
 
227
                                                 ( PyExc_AttributeError,
 
228
                                                   "bject" ) );
 
229
                        }
 
230
                        wanted_eff =
 
231
                                ( BPy_Wave * ) PyObject_NEW( BPy_Wave,
 
232
                                                             &Wave_Type );
 
233
                        wanted_eff->wave = eff;
 
234
                        return ( PyObject * ) wanted_eff;
 
235
                }
 
236
                object_iter = object_iter->id.next;
 
237
        }
 
238
        Py_INCREF( Py_None );
 
239
        return Py_None;
235
240
}
236
241
 
237
242
/*****************************************************************************/
238
243
/* Function:              Wave_Init                                          */
239
244
/*****************************************************************************/
240
 
PyObject *Wave_Init (void)
241
 
{
242
 
  PyObject  *submodule;
243
 
 
244
 
  Wave_Type.ob_type = &PyType_Type;
245
 
  submodule = Py_InitModule3("Blender.Wave",M_Wave_methods, M_Wave_doc);
246
 
  return (submodule);
247
 
}
248
 
 
249
 
/*****************************************************************************/
250
 
/* Python BPy_Wave methods:                                                    */
251
 
/*****************************************************************************/
252
 
 
253
 
PyObject *Wave_getStartx(BPy_Wave *self)
254
 
{
255
 
  WaveEff*ptr = (WaveEff*)self->wave;
256
 
  return PyFloat_FromDouble(ptr->startx);
257
 
}
258
 
 
259
 
PyObject *Wave_setStartx(BPy_Wave *self,PyObject *args)
260
 
261
 
  WaveEff*ptr = (WaveEff*)self->wave;
262
 
  float val = 0;
263
 
if (!PyArg_ParseTuple(args, "f", &val ))
264
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
265
 
                                 "expected float argument"));
266
 
  ptr->startx = val;
267
 
  Py_INCREF(Py_None);
268
 
  return Py_None;
269
 
}
270
 
 
271
 
PyObject *Wave_getStarty(BPy_Wave *self)
272
 
{
273
 
  WaveEff*ptr = (WaveEff*)self->wave;
274
 
  return PyFloat_FromDouble(ptr->starty);
275
 
}
276
 
 
277
 
PyObject *Wave_setStarty(BPy_Wave *self,PyObject *args)
278
 
279
 
  WaveEff*ptr = (WaveEff*)self->wave;
280
 
  float val = 0;
281
 
if (!PyArg_ParseTuple(args, "f", &val ))
282
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
283
 
                                 "expected float argument"));
284
 
  ptr->starty = val;
285
 
  Py_INCREF(Py_None);
286
 
  return Py_None;
287
 
}
288
 
 
289
 
PyObject *Wave_getHeight(BPy_Wave *self)
290
 
{
291
 
  WaveEff*ptr = (WaveEff*)self->wave;
292
 
  return PyFloat_FromDouble(ptr->height);
293
 
}
294
 
 
295
 
PyObject *Wave_setHeight(BPy_Wave *self,PyObject *args)
296
 
297
 
  WaveEff*ptr = (WaveEff*)self->wave;
298
 
  float val = 0;
299
 
if (!PyArg_ParseTuple(args, "f", &val ))
300
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
301
 
                                 "expected float argument"));
302
 
  ptr->height = val;
303
 
  Py_INCREF(Py_None);
304
 
  return Py_None;
305
 
}
306
 
 
307
 
PyObject *Wave_getWidth(BPy_Wave *self)
308
 
{
309
 
  WaveEff*ptr = (WaveEff*)self->wave;
310
 
  return PyFloat_FromDouble(ptr->width);
311
 
}
312
 
 
313
 
PyObject *Wave_setWidth(BPy_Wave *self,PyObject *args)
314
 
315
 
  float val = 0;
316
 
  WaveEff*ptr;
317
 
if (!PyArg_ParseTuple(args, "f", &val ))
318
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
319
 
                                 "expected float argument"));
320
 
  ptr = (WaveEff*)self->wave;
321
 
  ptr->width = val;
322
 
  Py_INCREF(Py_None);
323
 
  return Py_None;
324
 
}
325
 
 
326
 
PyObject *Wave_getNarrow(BPy_Wave *self)
327
 
{
328
 
  WaveEff*ptr = (WaveEff*)self->wave;
329
 
  return PyFloat_FromDouble(ptr->narrow);
330
 
}
331
 
 
332
 
PyObject *Wave_setNarrow(BPy_Wave *self,PyObject *args)
333
 
334
 
  float val = 0;
335
 
  WaveEff*ptr;
336
 
if (!PyArg_ParseTuple(args, "f", &val ))
337
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
338
 
                                 "expected float argument"));
339
 
  ptr = (WaveEff*)self->wave;
340
 
  ptr->narrow = val;
341
 
  Py_INCREF(Py_None);
342
 
  return Py_None;
343
 
}
344
 
 
345
 
PyObject *Wave_getSpeed(BPy_Wave *self)
346
 
{
347
 
  WaveEff*ptr = (WaveEff*)self->wave;
348
 
  return PyFloat_FromDouble(ptr->speed);
349
 
}
350
 
 
351
 
PyObject *Wave_setSpeed(BPy_Wave *self,PyObject *args)
352
 
353
 
  float val = 0;
354
 
  WaveEff*ptr;
355
 
if (!PyArg_ParseTuple(args, "f", &val ))
356
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
357
 
                                 "expected float argument"));
358
 
  ptr = (WaveEff*)self->wave;
359
 
  ptr->speed = val;
360
 
  Py_INCREF(Py_None);
361
 
  return Py_None;
362
 
}
363
 
 
364
 
PyObject *Wave_getMinfac(BPy_Wave *self)
365
 
{
366
 
  WaveEff*ptr = (WaveEff*)self->wave;
367
 
  return PyFloat_FromDouble(ptr->minfac);
368
 
}
369
 
 
370
 
PyObject *Wave_setMinfac(BPy_Wave *self,PyObject *args)
371
 
372
 
  float val = 0;
373
 
  WaveEff*ptr;
374
 
if (!PyArg_ParseTuple(args, "f", &val ))
375
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
376
 
                                 "expected float argument"));
377
 
  ptr = (WaveEff*)self->wave;
378
 
  ptr->minfac = val;
379
 
  Py_INCREF(Py_None);
380
 
  return Py_None;
381
 
}
382
 
 
383
 
 
384
 
 
385
 
PyObject *Wave_getDamp(BPy_Wave *self)
386
 
{
387
 
  WaveEff*ptr = (WaveEff*)self->wave;
388
 
  return PyFloat_FromDouble(ptr->damp);
389
 
}
390
 
 
391
 
PyObject *Wave_setDamp(BPy_Wave *self,PyObject *args)
392
 
393
 
  WaveEff*ptr;
394
 
  float val = 0;
395
 
if (!PyArg_ParseTuple(args, "f", &val ))
396
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
397
 
                                 "expected float argument"));
398
 
  ptr = (WaveEff*)self->wave;
399
 
  ptr->damp = val;
400
 
  Py_INCREF(Py_None);
401
 
  return Py_None;
402
 
}
403
 
 
404
 
PyObject *Wave_getTimeoffs(BPy_Wave *self)
405
 
{
406
 
  WaveEff*ptr = (WaveEff*)self->wave;
407
 
  return PyFloat_FromDouble(ptr->timeoffs);
408
 
}
409
 
 
410
 
PyObject *Wave_setTimeoffs(BPy_Wave *self,PyObject *args)
411
 
412
 
  float val = 0;
413
 
  WaveEff*ptr;
414
 
if (!PyArg_ParseTuple(args, "f", &val ))
415
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
416
 
                                 "expected float argument"));
417
 
  ptr = (WaveEff*)self->wave;
418
 
  ptr->timeoffs = val;
419
 
  Py_INCREF(Py_None);
420
 
  return Py_None;
421
 
}
422
 
 
423
 
PyObject *Wave_getLifetime(BPy_Wave *self)
424
 
{
425
 
  WaveEff*ptr = (WaveEff*)self->wave;
426
 
  return PyFloat_FromDouble(ptr->lifetime);
427
 
}
428
 
 
429
 
PyObject *Wave_setLifetime(BPy_Wave *self,PyObject *args)
430
 
431
 
  float val = 0;
432
 
  WaveEff*ptr;
433
 
if (!PyArg_ParseTuple(args, "f", &val ))
434
 
    return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
435
 
                                 "expected float argument"));
436
 
  ptr = (WaveEff*)self->wave;
437
 
  ptr->lifetime = val;
438
 
  Py_INCREF(Py_None);
439
 
  return Py_None;
440
 
}
 
245
PyObject *Wave_Init( void )
 
246
{
 
247
        PyObject *submodule;
 
248
 
 
249
        Wave_Type.ob_type = &PyType_Type;
 
250
        submodule =
 
251
                Py_InitModule3( "Blender.Wave", M_Wave_methods, M_Wave_doc );
 
252
        return ( submodule );
 
253
}
 
254
 
 
255
/*****************************************************************************/
 
256
/* Python BPy_Wave methods:                                                  */
 
257
/*****************************************************************************/
 
258
 
 
259
PyObject *Wave_getStartx( BPy_Wave * self )
 
260
{
 
261
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
262
        return PyFloat_FromDouble( ptr->startx );
 
263
}
 
264
 
 
265
PyObject *Wave_setStartx( BPy_Wave * self, PyObject * args )
 
266
{
 
267
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
268
        float val = 0;
 
269
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
270
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
271
                                                "expected float argument" ) );
 
272
        ptr->startx = val;
 
273
        Py_INCREF( Py_None );
 
274
        return Py_None;
 
275
}
 
276
 
 
277
PyObject *Wave_getStarty( BPy_Wave * self )
 
278
{
 
279
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
280
        return PyFloat_FromDouble( ptr->starty );
 
281
}
 
282
 
 
283
PyObject *Wave_setStarty( BPy_Wave * self, PyObject * args )
 
284
{
 
285
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
286
        float val = 0;
 
287
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
288
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
289
                                                "expected float argument" ) );
 
290
        ptr->starty = val;
 
291
        Py_INCREF( Py_None );
 
292
        return Py_None;
 
293
}
 
294
 
 
295
PyObject *Wave_getHeight( BPy_Wave * self )
 
296
{
 
297
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
298
        return PyFloat_FromDouble( ptr->height );
 
299
}
 
300
 
 
301
PyObject *Wave_setHeight( BPy_Wave * self, PyObject * args )
 
302
{
 
303
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
304
        float val = 0;
 
305
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
306
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
307
                                                "expected float argument" ) );
 
308
        ptr->height = val;
 
309
        Py_INCREF( Py_None );
 
310
        return Py_None;
 
311
}
 
312
 
 
313
PyObject *Wave_getWidth( BPy_Wave * self )
 
314
{
 
315
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
316
        return PyFloat_FromDouble( ptr->width );
 
317
}
 
318
 
 
319
PyObject *Wave_setWidth( BPy_Wave * self, PyObject * args )
 
320
{
 
321
        float val = 0;
 
322
        WaveEff *ptr;
 
323
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
324
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
325
                                                "expected float argument" ) );
 
326
        ptr = ( WaveEff * ) self->wave;
 
327
        ptr->width = val;
 
328
        Py_INCREF( Py_None );
 
329
        return Py_None;
 
330
}
 
331
 
 
332
PyObject *Wave_getNarrow( BPy_Wave * self )
 
333
{
 
334
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
335
        return PyFloat_FromDouble( ptr->narrow );
 
336
}
 
337
 
 
338
PyObject *Wave_setNarrow( BPy_Wave * self, PyObject * args )
 
339
{
 
340
        float val = 0;
 
341
        WaveEff *ptr;
 
342
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
343
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
344
                                                "expected float argument" ) );
 
345
        ptr = ( WaveEff * ) self->wave;
 
346
        ptr->narrow = val;
 
347
        Py_INCREF( Py_None );
 
348
        return Py_None;
 
349
}
 
350
 
 
351
PyObject *Wave_getSpeed( BPy_Wave * self )
 
352
{
 
353
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
354
        return PyFloat_FromDouble( ptr->speed );
 
355
}
 
356
 
 
357
PyObject *Wave_setSpeed( BPy_Wave * self, PyObject * args )
 
358
{
 
359
        float val = 0;
 
360
        WaveEff *ptr;
 
361
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
362
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
363
                                                "expected float argument" ) );
 
364
        ptr = ( WaveEff * ) self->wave;
 
365
        ptr->speed = val;
 
366
        Py_INCREF( Py_None );
 
367
        return Py_None;
 
368
}
 
369
 
 
370
PyObject *Wave_getMinfac( BPy_Wave * self )
 
371
{
 
372
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
373
        return PyFloat_FromDouble( ptr->minfac );
 
374
}
 
375
 
 
376
PyObject *Wave_setMinfac( BPy_Wave * self, PyObject * args )
 
377
{
 
378
        float val = 0;
 
379
        WaveEff *ptr;
 
380
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
381
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
382
                                                "expected float argument" ) );
 
383
        ptr = ( WaveEff * ) self->wave;
 
384
        ptr->minfac = val;
 
385
        Py_INCREF( Py_None );
 
386
        return Py_None;
 
387
}
 
388
 
 
389
 
 
390
 
 
391
PyObject *Wave_getDamp( BPy_Wave * self )
 
392
{
 
393
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
394
        return PyFloat_FromDouble( ptr->damp );
 
395
}
 
396
 
 
397
PyObject *Wave_setDamp( BPy_Wave * self, PyObject * args )
 
398
{
 
399
        WaveEff *ptr;
 
400
        float val = 0;
 
401
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
402
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
403
                                                "expected float argument" ) );
 
404
        ptr = ( WaveEff * ) self->wave;
 
405
        ptr->damp = val;
 
406
        Py_INCREF( Py_None );
 
407
        return Py_None;
 
408
}
 
409
 
 
410
PyObject *Wave_getTimeoffs( BPy_Wave * self )
 
411
{
 
412
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
413
        return PyFloat_FromDouble( ptr->timeoffs );
 
414
}
 
415
 
 
416
PyObject *Wave_setTimeoffs( BPy_Wave * self, PyObject * args )
 
417
{
 
418
        float val = 0;
 
419
        WaveEff *ptr;
 
420
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
421
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
422
                                                "expected float argument" ) );
 
423
        ptr = ( WaveEff * ) self->wave;
 
424
        ptr->timeoffs = val;
 
425
        Py_INCREF( Py_None );
 
426
        return Py_None;
 
427
}
 
428
 
 
429
PyObject *Wave_getLifetime( BPy_Wave * self )
 
430
{
 
431
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
432
        return PyFloat_FromDouble( ptr->lifetime );
 
433
}
 
434
 
 
435
PyObject *Wave_setLifetime( BPy_Wave * self, PyObject * args )
 
436
{
 
437
        float val = 0;
 
438
        WaveEff *ptr;
 
439
        if( !PyArg_ParseTuple( args, "f", &val ) )
 
440
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 
441
                                                "expected float argument" ) );
 
442
        ptr = ( WaveEff * ) self->wave;
 
443
        ptr->lifetime = val;
 
444
        Py_INCREF( Py_None );
 
445
        return Py_None;
 
446
}
 
447
 
441
448
/*****************************************************************************/
442
449
/* Function:    WaveDeAlloc                                                  */
443
 
/* Description: This is a callback function for the BPy_Wave type. It is       */
 
450
/* Description: This is a callback function for the BPy_Wave type. It is     */
444
451
/*              the destructor function.                                     */
445
452
/*****************************************************************************/
446
 
void WaveDeAlloc (BPy_Wave *self)
 
453
void WaveDeAlloc( BPy_Wave * self )
447
454
{
448
 
  WaveEff*ptr = (WaveEff*)self->wave;
449
 
  PyObject_DEL (ptr);
 
455
        WaveEff *ptr = ( WaveEff * ) self->wave;
 
456
        PyObject_DEL( ptr );
450
457
}
451
458
 
452
459
/*****************************************************************************/
453
460
/* Function:    WaveGetAttr                                                  */
454
 
/* Description: This is a callback function for the BPy_Wave type. It is       */
455
 
/*              the function that accesses BPy_Wave "member variables" and     */
 
461
/* Description: This is a callback function for the BPy_Wave type. It is     */
 
462
/*              the function that accesses BPy_Wave "member variables" and   */
456
463
/*              methods.                                                     */
457
464
/*****************************************************************************/
458
465
 
459
 
PyObject *WaveGetAttr (BPy_Wave *self, char *name)
 
466
PyObject *WaveGetAttr( BPy_Wave * self, char *name )
460
467
{
461
 
        if (!strcmp(name,"lifetime"))return Wave_getLifetime( self);
462
 
        else if (!strcmp(name,"timeoffs"))return Wave_getTimeoffs( self);
463
 
        else if (!strcmp(name,"damp"))return Wave_getDamp( self);
464
 
        else if (!strcmp(name,"minfac"))return Wave_getMinfac( self);
465
 
        else if (!strcmp(name,"speed"))return Wave_getSpeed( self);
466
 
        else if (!strcmp(name,"narrow"))return Wave_getNarrow( self);
467
 
        else if (!strcmp(name,"width"))return Wave_getWidth( self);
468
 
        else if (!strcmp(name,"height"))return Wave_getHeight( self);
469
 
        else if (!strcmp(name,"startx"))return Wave_getStartx( self);
470
 
        else if (!strcmp(name,"starty"))return Wave_getStarty( self);
471
 
  return Py_FindMethod(BPy_Wave_methods, (PyObject *)self, name);
 
468
        if( !strcmp( name, "lifetime" ) )
 
469
                return Wave_getLifetime( self );
 
470
        else if( !strcmp( name, "timeoffs" ) )
 
471
                return Wave_getTimeoffs( self );
 
472
        else if( !strcmp( name, "damp" ) )
 
473
                return Wave_getDamp( self );
 
474
        else if( !strcmp( name, "minfac" ) )
 
475
                return Wave_getMinfac( self );
 
476
        else if( !strcmp( name, "speed" ) )
 
477
                return Wave_getSpeed( self );
 
478
        else if( !strcmp( name, "narrow" ) )
 
479
                return Wave_getNarrow( self );
 
480
        else if( !strcmp( name, "width" ) )
 
481
                return Wave_getWidth( self );
 
482
        else if( !strcmp( name, "height" ) )
 
483
                return Wave_getHeight( self );
 
484
        else if( !strcmp( name, "startx" ) )
 
485
                return Wave_getStartx( self );
 
486
        else if( !strcmp( name, "starty" ) )
 
487
                return Wave_getStarty( self );
 
488
        return Py_FindMethod( BPy_Wave_methods, ( PyObject * ) self, name );
472
489
}
473
490
 
474
491
/*****************************************************************************/
475
492
/* Function:    WaveSetAttr                                                  */
476
 
/* Description: This is a callback function for the BPy_Wave type. It is the   */
 
493
/* Description: This is a callback function for the BPy_Wave type. It is the */
477
494
/*              function that sets Wave Data attributes (member variables).  */
478
495
/*****************************************************************************/
479
 
int WaveSetAttr (BPy_Wave *self, char *name, PyObject *value)
 
496
int WaveSetAttr( BPy_Wave * self, char *name, PyObject * value )
480
497
{
481
 
  PyObject *valtuple; 
482
 
  PyObject *error = NULL;
483
 
 
484
 
  valtuple = Py_BuildValue("(N)", value);
485
 
 
486
 
  if (!valtuple)
487
 
    return EXPP_ReturnIntError(PyExc_MemoryError,
488
 
                                                                                                                         "ParticleSetAttr: couldn't create PyTuple");
489
 
 
490
 
        if (!strcmp(name,"lifetime"))error = Wave_setLifetime( self,valtuple);
491
 
        else if (!strcmp(name,"timeoffs"))error = Wave_setTimeoffs( self,valtuple);
492
 
        else if (!strcmp(name,"damp"))    error = Wave_setDamp( self,valtuple);
493
 
        else if (!strcmp(name,"minfac"))  error = Wave_setMinfac( self,valtuple);
494
 
        else if (!strcmp(name,"speed"))   error = Wave_setSpeed( self,valtuple);
495
 
        else if (!strcmp(name,"narrow"))  error = Wave_setNarrow( self,valtuple);
496
 
        else if (!strcmp(name,"width"))   error = Wave_setWidth( self,valtuple);
497
 
        else if (!strcmp(name,"height"))  error = Wave_setHeight( self,valtuple);
498
 
        else if (!strcmp(name,"startx"))  error = Wave_setStartx( self,valtuple);
499
 
        else if (!strcmp(name,"starty"))  error = Wave_setStarty( self,valtuple);
500
 
 
501
 
 
502
 
  else { 
503
 
    Py_DECREF(valtuple);
504
 
 
505
 
    if ((strcmp (name, "Types") == 0) ||
506
 
        (strcmp (name, "Modes") == 0))  
507
 
      return (EXPP_ReturnIntError (PyExc_AttributeError,
508
 
                                                                                                                                         "constant dictionary -- cannot be changed"));
509
 
 
510
 
    else 
511
 
      return (EXPP_ReturnIntError (PyExc_KeyError,
512
 
                                                                                                                                         "attribute not found"));
513
 
  }
514
 
 
515
 
  /*Py_DECREF(valtuple);*/
516
 
 
517
 
  if (error != Py_None) return -1;
518
 
 
519
 
  Py_DECREF(Py_None);
520
 
  return 0; 
 
498
        PyObject *valtuple;
 
499
        PyObject *error = NULL;
 
500
 
 
501
        valtuple = Py_BuildValue( "(N)", value );
 
502
 
 
503
        if( !valtuple )
 
504
                return EXPP_ReturnIntError( PyExc_MemoryError,
 
505
                                            "ParticleSetAttr: couldn't create PyTuple" );
 
506
 
 
507
        if( !strcmp( name, "lifetime" ) )
 
508
                error = Wave_setLifetime( self, valtuple );
 
509
        else if( !strcmp( name, "timeoffs" ) )
 
510
                error = Wave_setTimeoffs( self, valtuple );
 
511
        else if( !strcmp( name, "damp" ) )
 
512
                error = Wave_setDamp( self, valtuple );
 
513
        else if( !strcmp( name, "minfac" ) )
 
514
                error = Wave_setMinfac( self, valtuple );
 
515
        else if( !strcmp( name, "speed" ) )
 
516
                error = Wave_setSpeed( self, valtuple );
 
517
        else if( !strcmp( name, "narrow" ) )
 
518
                error = Wave_setNarrow( self, valtuple );
 
519
        else if( !strcmp( name, "width" ) )
 
520
                error = Wave_setWidth( self, valtuple );
 
521
        else if( !strcmp( name, "height" ) )
 
522
                error = Wave_setHeight( self, valtuple );
 
523
        else if( !strcmp( name, "startx" ) )
 
524
                error = Wave_setStartx( self, valtuple );
 
525
        else if( !strcmp( name, "starty" ) )
 
526
                error = Wave_setStarty( self, valtuple );
 
527
 
 
528
 
 
529
        else {
 
530
                Py_DECREF( valtuple );
 
531
 
 
532
                if( ( strcmp( name, "Types" ) == 0 ) ||
 
533
                    ( strcmp( name, "Modes" ) == 0 ) )
 
534
                        return ( EXPP_ReturnIntError( PyExc_AttributeError,
 
535
                                                      "constant dictionary -- cannot be changed" ) );
 
536
 
 
537
                else
 
538
                        return ( EXPP_ReturnIntError( PyExc_KeyError,
 
539
                                                      "attribute not found" ) );
 
540
        }
 
541
 
 
542
        /*Py_DECREF(valtuple); */
 
543
 
 
544
        if( error != Py_None )
 
545
                return -1;
 
546
 
 
547
        Py_DECREF( Py_None );
 
548
        return 0;
521
549
}
522
550
 
523
551
/*****************************************************************************/
524
552
/* Function:    WavePrint                                                    */
525
 
/* Description: This is a callback function for the BPy_Wave type. It          */
 
553
/* Description: This is a callback function for the BPy_Wave type. It        */
526
554
/*              builds a meaninful string to 'print' wave objects.           */
527
555
/*****************************************************************************/
528
 
int WavePrint(BPy_Wave *self, FILE *fp, int flags)
529
 
 
556
int WavePrint( BPy_Wave * self, FILE * fp, int flags )
 
557
{
530
558
 
531
 
  printf("I'm a wave...Cool, no?");     
532
 
  return 0;
 
559
        printf( "I'm a wave...Cool, no?" );
 
560
        return 0;
533
561
}
534
562
 
535
563
/*****************************************************************************/
536
564
/* Function:    WaveRepr                                                     */
537
 
/* Description: This is a callback function for the BPy_Wave type. It          */
 
565
/* Description: This is a callback function for the BPy_Wave type. It        */
538
566
/*              builds a meaninful string to represent wave objects.         */
539
567
/*****************************************************************************/
540
 
PyObject *WaveRepr (BPy_Wave *self) 
541
 
{
542
 
  return 0;
543
 
}
544
 
 
545
 
PyObject* WaveCreatePyObject (struct Effect *wave)
546
 
{
547
 
 BPy_Wave    * blen_object;
548
 
 
549
 
 
550
 
    blen_object = (BPy_Wave*)PyObject_NEW (BPy_Wave, &Wave_Type);
551
 
 
552
 
    if (blen_object == NULL)
553
 
    {
554
 
        return (NULL);
555
 
    }
556
 
    blen_object->wave = wave;
557
 
    return ((PyObject*)blen_object);
558
 
 
559
 
}
560
 
 
561
 
int WaveCheckPyObject (PyObject *py_obj)
562
 
{
563
 
return (py_obj->ob_type == &Wave_Type);
564
 
}
565
 
 
566
 
 
567
 
struct Wave* WaveFromPyObject (PyObject *py_obj)
568
 
{
569
 
 BPy_Wave    * blen_obj;
570
 
 
571
 
    blen_obj = (BPy_Wave*)py_obj;
572
 
    return ((struct Wave*)blen_obj->wave);
573
 
 
574
 
}
575
 
 
 
568
PyObject *WaveRepr( BPy_Wave * self )
 
569
{
 
570
        return 0;
 
571
}
 
572
 
 
573
PyObject *WaveCreatePyObject( struct Effect * wave )
 
574
{
 
575
        BPy_Wave *blen_object;
 
576
 
 
577
 
 
578
        blen_object = ( BPy_Wave * ) PyObject_NEW( BPy_Wave, &Wave_Type );
 
579
 
 
580
        if( blen_object == NULL ) {
 
581
                return ( NULL );
 
582
        }
 
583
        blen_object->wave = wave;
 
584
        return ( ( PyObject * ) blen_object );
 
585
 
 
586
}
 
587
 
 
588
int WaveCheckPyObject( PyObject * py_obj )
 
589
{
 
590
        return ( py_obj->ob_type == &Wave_Type );
 
591
}
 
592
 
 
593
 
 
594
struct Wave *WaveFromPyObject( PyObject * py_obj )
 
595
{
 
596
        BPy_Wave *blen_obj;
 
597
 
 
598
        blen_obj = ( BPy_Wave * ) py_obj;
 
599
        return ( ( struct Wave * ) blen_obj->wave );
 
600
 
 
601
}