~jtaylor/ubuntu/oneiric/soya/fix-780305

« back to all changes in this revision

Viewing changes to c_src/python/i_cal3d4p3.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Dequènes (Duck)
  • Date: 2005-01-30 09:55:06 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050130095506-f21p6v6cgaobhn5j
Tags: 0.9.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * P3 python wrapper
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
7
 
 * (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
 */
18
 
 
19
 
/*********************************************************
20
 
 * i_cal3d4p3.c : use Cal3D (http://cal3d.sourceforge.net)
21
 
 *              rocking animation lib with Soya
22
 
 * Copyright (C) 2003 Jean-Baptiste 'Jiba' LAMY
23
 
 *********************************************************/
24
 
 
25
 
//#include "../cal3d_wrapper.h" //#include <cal3d/cal3d_wrapper.h> // Buggous file ?
26
 
 
27
 
/*=============+
28
 
 | CAL3D SHAPE |
29
 
 +=============*/
30
 
 
31
 
static int PyP3Cal3DShape_Traverse (P3_cal3d_shape* self, visitproc visit, void* arg) {
32
 
        int err;
33
 
  int i;
34
 
  if (self->nb_materials > 0) {
35
 
    for (i = 0; i < self->nb_materials; i++) {
36
 
      err = visit ((PyObject*) self->materials[i], arg);
37
 
      if (err) { return err; }
38
 
    }
39
 
  }
40
 
        return 0;
41
 
}
42
 
 
43
 
static int PyP3Cal3DShape_Clear (P3_cal3d_shape* self) {
44
 
  int i;
45
 
  if (self->nb_materials > 0) {
46
 
    for( i = 0; i < self->nb_materials; i++) {
47
 
      Py_DECREF (self->materials[i]);
48
 
    }
49
 
    self->nb_materials = 0;
50
 
    free (self->materials);
51
 
  }
52
 
  return 0;
53
 
}
54
 
 
55
 
static void PyP3Cal3DShape_Dealloc (P3_cal3d_shape* self) {
56
 
  int i;
57
 
  PyObject_GC_UnTrack ((PyObject*) self);
58
 
  if (self->nb_materials > 0) {
59
 
    for (i = 0; i < self->nb_materials; i++) {
60
 
      Py_DECREF (self->materials[i]);
61
 
    }
62
 
    self->nb_materials = 0;
63
 
    free (self->materials);
64
 
  }
65
 
  CalCoreModel_Destroy (self->core_model);
66
 
  CalCoreModel_Delete  (self->core_model);
67
 
  self->ob_type->tp_free ((PyObject*) self);
68
 
}
69
 
 
70
 
static int PyP3Cal3DShape_Init (PyObject* self, PyObject* args, PyObject* kwds) {
71
 
  P3_cal3d_shape_new ((P3_cal3d_shape*) self);
72
 
        return 0;
73
 
}
74
 
 
75
 
static PyObject* PyP3Cal3DShape_LoadSkeleton (P3_cal3d_shape* self, PyObject* arg) {
76
 
  if (!CalCoreModel_LoadCoreSkeleton (self->core_model, PyString_AS_STRING (arg))) {
77
 
    P3_error (CalError_GetLastErrorDescription());
78
 
    P3_error ("CalCoreModel_LoadCoreSkeleton failed!");
79
 
    return PyInt_FromLong (0);
80
 
  }
81
 
  return PyInt_FromLong (1);
82
 
}
83
 
 
84
 
static PyObject* PyP3Cal3DShape_LoadMesh (P3_cal3d_shape* self, PyObject* arg) {
85
 
  int id = CalCoreModel_LoadCoreMesh (self->core_model, PyString_AS_STRING (arg));
86
 
  if (id == -1) { 
87
 
    P3_error (CalError_GetLastErrorDescription ()); 
88
 
    P3_error ("CalCoreModel_LoadCoreMesh failed!"); 
89
 
  }
90
 
  return PyInt_FromLong (id);
91
 
}
92
 
 
93
 
static PyObject* PyP3Cal3DShape_LoadMaterial (P3_cal3d_shape* self, PyObject* arg) {
94
 
  int id = CalCoreModel_LoadCoreMaterial (self->core_model, PyString_AS_STRING (arg));
95
 
  if (id == -1) { 
96
 
    P3_error (CalError_GetLastErrorDescription ()); 
97
 
    P3_error ("CalCoreModel_LoadCoreMaterial failed!"); 
98
 
  }
99
 
  return PyInt_FromLong (id);
100
 
}
101
 
 
102
 
static PyObject* PyP3Cal3DShape_LoadAnimation (P3_cal3d_shape* self, PyObject* arg) {
103
 
  int id = CalCoreModel_LoadCoreAnimation (self->core_model, PyString_AS_STRING (arg));
104
 
  if (id == -1) { 
105
 
    P3_error (CalError_GetLastErrorDescription()); 
106
 
    P3_error ("CalCoreModel_LoadCoreAnimation failed!"); 
107
 
  }
108
 
  return PyInt_FromLong (id);
109
 
}
110
 
 
111
 
static PyObject* PyP3Cal3DShape_BuildMaterials (P3_cal3d_shape* shape) {
112
 
  int i;
113
 
  struct CalCoreMaterial* material;
114
 
  
115
 
  if (shape->nb_materials > 0) {
116
 
    for (i = 0; i < shape->nb_materials; i++) { Py_DECREF (shape->materials[i]); }
117
 
    free (shape->materials);
118
 
  }
119
 
  if (shape->core_model == NULL) { 
120
 
    Py_INCREF (Py_None);
121
 
    return Py_None; 
122
 
  }
123
 
  
124
 
  shape->nb_materials = CalCoreModel_GetCoreMaterialCount (shape->core_model);
125
 
  shape->materials    = (P3_material**) malloc (shape->nb_materials * sizeof (P3_material*));
126
 
  for (i = 0; i < shape->nb_materials; i++) {
127
 
    CalCoreModel_CreateCoreMaterialThread (shape->core_model, i);
128
 
    CalCoreModel_SetCoreMaterialId (shape->core_model, i, 0, i);
129
 
    
130
 
    material = CalCoreModel_GetCoreMaterial (shape->core_model, i);
131
 
    CalCoreMaterial_SetUserData (material, (CalUserData) i);
132
 
    
133
 
    shape->materials[i] = (P3_material*) PyObject_CallMethod
134
 
      ((PyObject*) shape, "_get_material_4_cal3d", "sfffffffff",
135
 
       CalCoreMaterial_GetMapFilename (material, 0),
136
 
       1.0, // It seems that the Cal3D C version
137
 
       1.0, // does not support yet the
138
 
       1.0, // CalCoreMaterial_Get*Color functions.
139
 
       1.0,
140
 
       1.0,
141
 
       1.0,
142
 
       1.0,
143
 
       1.0,
144
 
       CalCoreMaterial_GetShininess (material));
145
 
    Py_INCREF (shape->materials[i]);
146
 
  }
147
 
  
148
 
  Py_INCREF (Py_None);
149
 
  return Py_None;
150
 
}
151
 
 
152
 
static PyObject* PyP3Cal3DShape_SetCellShading (P3_cal3d_shape* a, PyObject* args) {
153
 
  P3_material* shader;
154
 
  PyObject* tuple;
155
 
  GLfloat color[4];
156
 
  tuple = PySequence_Fast_GET_ITEM (args, 1);
157
 
  PY_TUPLE_FLOAT_TO_ARRAY_4 (color, tuple);
158
 
  shader = (P3_material*) PySequence_Fast_GET_ITEM (args, 0);
159
 
  if ((PyObject*) shader == Py_None) { shader = NULL; }
160
 
  P3_cal3d_shape_set_cell_shading (a, shader, color, (GLfloat) PyFloat_AS_DOUBLE (PySequence_Fast_GET_ITEM (args, 2)));
161
 
  Py_INCREF (Py_None);
162
 
  return Py_None;
163
 
}
164
 
 
165
 
PY_GET_SET_ON_OPTION (Cal3DShape, P3_cal3d_shape*, ShadowCast, P3_CAL3D_SHADOW_CAST)
166
 
 
167
 
static PyGetSetDef PyP3Cal3DShape_GetSets[] = {
168
 
  { "shadow_cast", (getter) PyP3Cal3DShape_GetShadowCast, (setter) PyP3Cal3DShape_SetShadowCast, NULL },
169
 
  { NULL }
170
 
};
171
 
 
172
 
static PyMethodDef PyP3Cal3DShape_Methods[] = {
173
 
  { "set_cell_shading",      (PyCFunction) PyP3Cal3DShape_SetCellShading, METH_VARARGS },
174
 
  { "_load_skeleton",        (PyCFunction) PyP3Cal3DShape_LoadSkeleton,   METH_O },
175
 
  { "_load_mesh",            (PyCFunction) PyP3Cal3DShape_LoadMesh,       METH_O },
176
 
  { "_load_material",        (PyCFunction) PyP3Cal3DShape_LoadMaterial,   METH_O },
177
 
  { "_load_animation",       (PyCFunction) PyP3Cal3DShape_LoadAnimation,  METH_O },
178
 
  { "_build_materials",      (PyCFunction) PyP3Cal3DShape_BuildMaterials, METH_NOARGS },
179
 
  { NULL, NULL }
180
 
};
181
 
 
182
 
PyTypeObject PyP3Cal3DShape_Type = {
183
 
  PyObject_HEAD_INIT(NULL)
184
 
  0,
185
 
  "_soya._Cal3DShape",
186
 
  sizeof(P3_cal3d_shape),
187
 
  0,
188
 
  (destructor) PyP3Cal3DShape_Dealloc,/* tp_dealloc */
189
 
  0,/* tp_print */
190
 
  0,/* tp_getattr */
191
 
  0,/* tp_setattr */
192
 
  0,/* tp_compare */
193
 
  0,/* tp_repr */
194
 
  0,/* tp_as_number */
195
 
  0,/* tp_as_sequence */
196
 
  0,/* tp_as_mapping */
197
 
  0,/* tp_hash */
198
 
  0,/* tp_call */
199
 
  0,/* tp_str */
200
 
  PYP3_GENERIC_GETATTR,/* tp_getattro */
201
 
  0,/* tp_setattro */
202
 
  0,/* tp_as_buffer */
203
 
  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,/* tp_flags */
204
 
  0,/* tp_doc */
205
 
  (traverseproc) PyP3Cal3DShape_Traverse,/* tp_traverse */
206
 
  (inquiry) PyP3Cal3DShape_Clear,/* tp_clear */
207
 
  0,/* tp_richcompare */
208
 
  0,/* tp_weaklistoffset */
209
 
  0,/* tp_iter */
210
 
  0,/* tp_iternext */
211
 
  (PyMethodDef*) &PyP3Cal3DShape_Methods,/* tp_methods */
212
 
  0,/* tp_members */
213
 
  (PyGetSetDef*) &PyP3Cal3DShape_GetSets,/* tp_getset */
214
 
  0,/* tp_base */
215
 
  0,/* tp_dict */
216
 
  0,/* tp_descr_get */
217
 
  0,/* tp_descr_set */
218
 
  0,/* tp_dictoffset */
219
 
  (initproc) PyP3Cal3DShape_Init,/* tp_init */
220
 
  PYP3_GENERIC_ALLOC,/* tp_alloc */
221
 
  (newfunc) PyP3Object_New,/* tp_new */
222
 
  PYP3_GENERIC_GC_FREE,/* tp_free */
223
 
};
224
 
 
225
 
 
226
 
/*==============+
227
 
 | CAL3D VOLUME |
228
 
 +==============*/
229
 
 
230
 
static int PyP3Cal3DVolume_Init (PyObject* self, PyObject* args, PyObject* kwds) {
231
 
  P3_cal3d_volume_new ((P3_cal3d_volume*) self);
232
 
        return 0;
233
 
}
234
 
 
235
 
static int PyP3Cal3DVolume_Traverse (P3_cal3d_volume* w, visitproc visit, void* arg) {
236
 
        int err;
237
 
  if (w->shape != NULL) {
238
 
    err = visit ((PyObject*) w->shape, arg);
239
 
    if (err) { return err; }
240
 
  }
241
 
  if (w->parent != NULL) {
242
 
    err = visit ((PyObject*) w->parent, arg);
243
 
    if (err) { return err; }
244
 
  }
245
 
  if (w->attached_coordsys != NULL) {
246
 
    err = visit ((PyObject*) w->attached_coordsys, arg);
247
 
    if (err) { return err; }
248
 
  }
249
 
        return 0;
250
 
}
251
 
 
252
 
static int PyP3Cal3DVolume_Clear (P3_cal3d_volume* self) {
253
 
  Py_XDECREF (self->shape);
254
 
  Py_XDECREF (self->parent);
255
 
  Py_XDECREF (self->attached_coordsys);
256
 
  self->shape = NULL;
257
 
  self->parent = NULL;
258
 
  self->attached_coordsys = NULL;
259
 
  return 0;
260
 
}
261
 
 
262
 
static void PyP3Cal3DVolume_Dealloc (P3_cal3d_volume* self) {
263
 
  Py_XDECREF (self->shape);
264
 
  Py_XDECREF (self->parent);
265
 
  Py_XDECREF (self->attached_coordsys);
266
 
 
267
 
  P3_cal3d_volume_dealloc (self);
268
 
  
269
 
  PyObject_GC_UnTrack ((PyObject*) self);
270
 
  self->ob_type->tp_free ((PyObject*) self);
271
 
}
272
 
 
273
 
static PyObject* PyP3Cal3DVolume_GetShape (P3_cal3d_volume* volume, void* context) {
274
 
  if (volume->shape == NULL) {
275
 
    Py_INCREF (Py_None);
276
 
    return Py_None;
277
 
  } else {
278
 
    Py_INCREF ((PyObject*) volume->shape);
279
 
    return (PyObject*) volume->shape;
280
 
  }
281
 
}
282
 
static PyObject* PyP3Cal3DVolume_SetShape (P3_cal3d_volume* volume, PyObject* arg) {
283
 
  Py_XDECREF ((PyObject*) volume->shape);
284
 
  if (arg == Py_None || arg == NULL) {
285
 
    P3_cal3d_volume_set_shape (volume, NULL);
286
 
  } else {
287
 
    Py_INCREF (arg);
288
 
    P3_cal3d_volume_set_shape (volume, (P3_cal3d_shape*) arg);
289
 
  }
290
 
  Py_INCREF (Py_None);
291
 
  return Py_None;
292
 
}
293
 
 
294
 
static PyObject* PyP3Cal3DVolume_Update (P3_cal3d_volume* volume, PyObject* arg) {
295
 
  volume->delta_time += (float) PyFloat_AS_DOUBLE(arg);
296
 
  Py_INCREF (Py_None);
297
 
  return Py_None;
298
 
}
299
 
 
300
 
static PyObject* PyP3Cal3DVolume_SetAttached (P3_cal3d_volume* volume, PyObject* args) {
301
 
  P3_cal3d_volume_set_attached (volume, 
302
 
                                (int) PyInt_AS_LONG (PySequence_Fast_GET_ITEM (args, 0)), 
303
 
                                (int) PyInt_AS_LONG (PySequence_Fast_GET_ITEM (args, 1)));
304
 
  Py_INCREF (Py_None);
305
 
  return Py_None;
306
 
}
307
 
 
308
 
static PyObject* PyP3Cal3DVolume_IsAttached (P3_cal3d_volume* volume, PyObject* arg) {
309
 
  return PyInt_FromLong ((long) volume->attached_states[(int) PyInt_AS_LONG (arg)]);
310
 
}
311
 
 
312
 
static PyObject* PyP3Cal3DVolume_AttachAll (P3_cal3d_volume* volume) {
313
 
  P3_cal3d_volume_attach_all (volume);
314
 
  Py_INCREF (Py_None);
315
 
  return Py_None;
316
 
}
317
 
 
318
 
static PyObject* PyP3Cal3DVolume_SetLodLevel (P3_cal3d_volume* volume, PyObject* arg) {
319
 
  if (volume->model != NULL) { 
320
 
    CalModel_SetLodLevel (volume->model, (float) PyFloat_AS_DOUBLE(arg)); 
321
 
  }
322
 
  Py_INCREF (Py_None);
323
 
  return Py_None;
324
 
}
325
 
 
326
 
static PyObject* PyP3Cal3DVolume_BuildSubshapes (P3_cal3d_volume* volume) {
327
 
  P3_cal3d_volume_build_submeshes (volume);
328
 
  Py_INCREF (Py_None);
329
 
  return Py_None;
330
 
}
331
 
 
332
 
static PyObject* PyP3Cal3DVolume_AnimateClearCycle (P3_cal3d_volume* volume, PyObject* args) {
333
 
  CalMixer_ClearCycle (CalModel_GetMixer (volume->model),
334
 
                       (int) PyInt_AS_LONG (PySequence_Fast_GET_ITEM (args, 0)),
335
 
                       (float) PyFloat_AS_DOUBLE (PySequence_Fast_GET_ITEM (args, 1)));
336
 
  Py_INCREF (Py_None);
337
 
  return Py_None;
338
 
}
339
 
 
340
 
static PyObject* PyP3Cal3DVolume_AnimateBlendCycle (P3_cal3d_volume* volume, PyObject* args) {
341
 
  CalMixer_BlendCycle (CalModel_GetMixer (volume->model),
342
 
                       (int) PyInt_AS_LONG (PySequence_Fast_GET_ITEM (args, 0)),
343
 
                       (float) PyFloat_AS_DOUBLE (PySequence_Fast_GET_ITEM (args, 1)),
344
 
                       (float) PyFloat_AS_DOUBLE (PySequence_Fast_GET_ITEM (args, 2)));
345
 
  Py_INCREF (Py_None);
346
 
  return Py_None;
347
 
}
348
 
 
349
 
static PyObject* PyP3Cal3DVolume_AnimateExecuteAction (P3_cal3d_volume* volume, PyObject* args) {
350
 
  CalMixer_ExecuteAction (CalModel_GetMixer (volume->model),
351
 
                          (int) PyInt_AS_LONG (PySequence_Fast_GET_ITEM (args, 0)),
352
 
                          (float) PyFloat_AS_DOUBLE (PySequence_Fast_GET_ITEM (args, 1)),
353
 
                          (float) PyFloat_AS_DOUBLE (PySequence_Fast_GET_ITEM (args, 2)));
354
 
  Py_INCREF (Py_None);
355
 
  return Py_None;
356
 
}
357
 
 
358
 
static PyObject* PyP3Cal3DVolume_GetState (P3_cal3d_volume* w) {
359
 
  P3_chunk* chunk = P3_chunk_new ();
360
 
  PyObject* attached_states;
361
 
  PyObject* tuple;
362
 
  int i;
363
 
  P3_cal3d_volume_get_data (w, chunk);
364
 
  tuple = PyTuple_New (4);
365
 
  PyTuple_SET_ITEM (tuple, 0, PyString_FromStringAndSize ((char*) chunk->content, chunk->nb));
366
 
  if (w->shape == NULL) {
367
 
    Py_INCREF (Py_None);
368
 
    PyTuple_SET_ITEM (tuple, 1, Py_None);
369
 
    Py_INCREF (Py_None);
370
 
    PyTuple_SET_ITEM (tuple, 2, Py_None);
371
 
  } else {
372
 
    Py_INCREF ((PyObject*) w->shape);
373
 
    PyTuple_SET_ITEM (tuple, 1, (PyObject*) w->shape);
374
 
// TO DO put in C ?
375
 
    attached_states = PyTuple_New (w->nb_attached_states);
376
 
    for (i = 0; i < w->nb_attached_states; i++) {
377
 
      PyTuple_SET_ITEM (attached_states, i, PyInt_FromLong((long) w->attached_states[i]));
378
 
    }
379
 
    PyTuple_SET_ITEM (tuple, 2, attached_states);
380
 
  }
381
 
  
382
 
  Py_INCREF ((PyObject*) w->attached_coordsys);
383
 
  PyTuple_SET_ITEM (tuple, 3, (PyObject*) w->attached_coordsys);
384
 
  
385
 
  P3_chunk_dealloc (chunk);
386
 
  return tuple;
387
 
}
388
 
 
389
 
static PyObject* PyP3Cal3DVolume_SetState (P3_cal3d_volume* w, PyObject* args) {
390
 
  P3_chunk* chunk = P3_chunk_new ();
391
 
  PyObject* attached_states;
392
 
  PyObject* s;
393
 
  int i;
394
 
  s = PySequence_Fast_GET_ITEM (args, 0);
395
 
  chunk->content = PyString_AS_STRING (s);
396
 
  P3_cal3d_volume_set_data (w, chunk);
397
 
  s = PySequence_Fast_GET_ITEM (args, 1);
398
 
  if (s == Py_None) {
399
 
    w->shape = NULL;
400
 
  } else {
401
 
    w->shape = (P3_cal3d_shape*) s;
402
 
    Py_INCREF ((PyObject*) w->shape);
403
 
    w->model = CalModel_New ();
404
 
    CalModel_Create (w->model, w->shape->core_model);
405
 
    attached_states = PySequence_Fast_GET_ITEM (args, 2);
406
 
    w->nb_attached_states = PySequence_Size (attached_states);
407
 
    w->attached_states = malloc (w->nb_attached_states * sizeof(int));
408
 
    for (i = 0; i < w->nb_attached_states; i++) {
409
 
      w->attached_states[i] = (int) PyInt_AS_LONG (PySequence_Fast_GET_ITEM (attached_states, i));
410
 
      if (w->attached_states[i] == 1) {
411
 
        CalModel_AttachMesh (w->model, i);
412
 
      }
413
 
    }
414
 
    P3_cal3d_volume_build_submeshes (w);
415
 
  }
416
 
  
417
 
  w->attached_coordsys = (P3_children) PySequence_Fast_GET_ITEM (args, 3);
418
 
  Py_INCREF ((PyObject*) w->attached_coordsys);
419
 
  
420
 
  free (chunk);
421
 
  Py_INCREF (Py_None);
422
 
  return Py_None;
423
 
}
424
 
 
425
 
static PyObject* PyP3Cal3DVolume_BoneId (P3_cal3d_volume* w, PyObject* arg) {
426
 
  char* name;
427
 
  int i;
428
 
  struct CalCoreSkeleton* core_skeleton;
429
 
  struct CalCoreBone*     core_bone;
430
 
  
431
 
  name = PyString_AS_STRING(arg);
432
 
  core_skeleton = CalSkeleton_GetCoreSkeleton(CalModel_GetSkeleton(w->model));
433
 
  i = 0;
434
 
  while(1) {
435
 
    core_bone = CalCoreSkeleton_GetCoreBone(core_skeleton, i);
436
 
    if (core_bone == NULL) {
437
 
      PyErr_SetString(PyExc_ValueError, "No bone with this name.");
438
 
      return NULL;
439
 
    }
440
 
    if (strcmp(name, CalCoreBone_GetName(core_bone)) == 0) {
441
 
      return PyInt_FromLong((long) i);
442
 
    }
443
 
    i++;
444
 
  }
445
 
}
446
 
 
447
 
static PyObject* PyP3Cal3DVolume_MoveToBone (P3_cal3d_volume* w, PyObject* args) {
448
 
  struct CalBone* bone;
449
 
  P3_instance* instance;
450
 
  float* trans;
451
 
  
452
 
  instance = ((P3_instance*) PySequence_Fast_GET_ITEM(args, 0));
453
 
  
454
 
  bone = CalSkeleton_GetBone(CalModel_GetSkeleton(w->model), (int) PyInt_AS_LONG(PySequence_Fast_GET_ITEM(args, 1)));
455
 
  
456
 
  P3_matrix_from_quaternion(instance->m, CalQuaternion_Get(CalBone_GetRotationAbsolute(bone)));
457
 
  
458
 
  trans = CalVector_Get(CalBone_GetTranslationAbsolute(bone));
459
 
  P3_matrix_translate(instance->m, trans[0], trans[1], trans[2]);
460
 
  
461
 
  Py_INCREF (Py_None);
462
 
  return Py_None;
463
 
}
464
 
 
465
 
PY_GET_SET_ON_OBJECT (Cal3DVolume, P3_cal3d_volume*, AttachedCoordsys, attached_coordsys, PyObject*)
466
 
 
467
 
PY_GET_SET_ON_FLOAT_ARRAY (Cal3DVolume, P3_cal3d_volume*, Sphere, sphere, 4)
468
 
 
469
 
static PyGetSetDef PyP3Cal3DVolume_GetSets[] = {
470
 
  PYP3_VISIBLE_GETSETS,
471
 
  PYP3_CHILD_GETSETS,
472
 
  PYP3_COORDSYS_GETSETS,
473
 
  { "shape",             (getter) PyP3Cal3DVolume_GetShape,            0,                                              NULL },
474
 
  { "attached_coordsys", (getter) PyP3Cal3DVolume_GetAttachedCoordsys, (setter) PyP3Cal3DVolume_SetAttachedCoordsys,   NULL },
475
 
  { "sphere",            (getter) PyP3Cal3DVolume_GetSphere,           (setter) PyP3Cal3DVolume_SetSphere,             NULL },
476
 
  { NULL }
477
 
};
478
 
 
479
 
static PyMethodDef PyP3Cal3DVolume_Methods[] = {
480
 
  PYP3_COORDSYS_FUNCS,
481
 
  { "_set_lod_level",            (PyCFunction) PyP3Cal3DVolume_SetLodLevel,             METH_O },
482
 
  { "set_shape",                 (PyCFunction) PyP3Cal3DVolume_SetShape,                METH_O },
483
 
  { "_update",                   (PyCFunction) PyP3Cal3DVolume_Update,                  METH_O },
484
 
  { "_set_attached",             (PyCFunction) PyP3Cal3DVolume_SetAttached,             METH_VARARGS },
485
 
  { "_is_attached",              (PyCFunction) PyP3Cal3DVolume_IsAttached,              METH_O },
486
 
  { "attach_all",                (PyCFunction) PyP3Cal3DVolume_AttachAll,               METH_NOARGS },
487
 
  { "_build_subshapes",          (PyCFunction) PyP3Cal3DVolume_BuildSubshapes,          METH_NOARGS },
488
 
  { "_animate_clear_cycle",      (PyCFunction) PyP3Cal3DVolume_AnimateClearCycle,       METH_VARARGS },
489
 
  { "_animate_blend_cycle",      (PyCFunction) PyP3Cal3DVolume_AnimateBlendCycle,       METH_VARARGS },
490
 
  { "_animate_execute_action",   (PyCFunction) PyP3Cal3DVolume_AnimateExecuteAction,    METH_VARARGS },
491
 
  { "_getstate",                 (PyCFunction) PyP3Cal3DVolume_GetState,                METH_NOARGS },
492
 
  { "_setstate",                 (PyCFunction) PyP3Cal3DVolume_SetState,                METH_O },
493
 
  { "_bone_id",                  (PyCFunction) PyP3Cal3DVolume_BoneId,                  METH_O },
494
 
  { "_move_to_bone",             (PyCFunction) PyP3Cal3DVolume_MoveToBone,              METH_VARARGS },
495
 
  { NULL, NULL }
496
 
};
497
 
 
498
 
PyTypeObject PyP3Cal3DVolume_Type = {
499
 
  PyObject_HEAD_INIT(NULL)
500
 
  0,
501
 
  "_soya._Cal3DVolume",
502
 
  sizeof(P3_cal3d_volume),
503
 
  0,
504
 
  (destructor) PyP3Cal3DVolume_Dealloc,/* tp_dealloc */
505
 
  0,/* tp_print */
506
 
  0,/* tp_getattr */
507
 
  0,/* tp_setattr */
508
 
  0,/* tp_compare */
509
 
  0,/* tp_repr */
510
 
  0,/* tp_as_number */
511
 
  0,/* tp_as_sequence */
512
 
  0,/* tp_as_mapping */
513
 
  0,/* tp_hash */
514
 
  0,/* tp_call */
515
 
  0,/* tp_str */
516
 
  PYP3_GENERIC_GETATTR,/* tp_getattro */
517
 
  0,/* tp_setattro */
518
 
  0,/* tp_as_buffer */
519
 
  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,/* tp_flags */
520
 
  0,/* tp_doc */
521
 
  (traverseproc) PyP3Cal3DVolume_Traverse,/* tp_traverse */
522
 
  (inquiry) PyP3Cal3DVolume_Clear,/* tp_clear */
523
 
  0,/* tp_richcompare */
524
 
  0,/* tp_weaklistoffset */
525
 
  0,/* tp_iter */
526
 
  0,/* tp_iternext */
527
 
  (PyMethodDef*) &PyP3Cal3DVolume_Methods,/* tp_methods */
528
 
  0,/* tp_members */
529
 
  (PyGetSetDef*) &PyP3Cal3DVolume_GetSets,/* tp_getset */
530
 
  0,/* tp_base */
531
 
  0,/* tp_dict */
532
 
  0,/* tp_descr_get */
533
 
  0,/* tp_descr_set */
534
 
  0,/* tp_dictoffset */
535
 
  (initproc) PyP3Cal3DVolume_Init,/* tp_init */
536
 
  PYP3_GENERIC_ALLOC,/* tp_alloc */
537
 
  (newfunc) PyP3Object_New,/* tp_new */
538
 
  PYP3_GENERIC_GC_FREE,/* tp_free */
539
 
};
540
 
 
541
 
 
542
 
 
543