File: __init__.py

package info (click to toggle)
soya 0.9.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 11,860 kB
  • ctags: 20,187
  • sloc: ansic: 13,953; python: 4,755; makefile: 16
file content (635 lines) | stat: -rw-r--r-- 23,497 bytes parent folder | download
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
# Soya 3D
# Copyright (C) 2001-2004 Jean-Baptiste LAMY -- jiba@tuxfamily.org
#
# 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

import sys, os, os.path, weakref,cPickle as  pickle

if os.path.exists(os.path.join(__path__[0], "build")):
  # We are using a source directory.
  # We need to get the binary library in "./build/xxx"
  import distutils.util
  __path__.append(os.path.join(__path__[0], "build", "lib.%s-%s" % (distutils.util.get_platform(), sys.version[0:3]), "soya"))

from soya._soya import *
from soya._soya import _CObj

#from soya import _soya

_soya = sys.modules["soya._soya"]

#from soya import opengl
#from soya import sdlconst

# For file compatibility
sys.modules["soyapyrex"] = _soya

def set_root_widget(widget):
  global root_widget
  root_widget = widget
  _soya.set_root_widget(widget)
  

def coalesce_motion_event(events):
  """coalesce_motion_event(events) -> sequence

Prunes from EVENTS all mouse motion events except the last one.
This is usefull since only the last one is usually releavant (Though
be carrefull if you use the relative mouse coordinate !).

EVENTS should be a list of events, as returned by soya.process_event().
The returned list has the same structure."""
  import soya.sdlconst
  
  events = list(events)
  events.reverse()
  
  def keep_last(event):
    if event[0] == soya.sdlconst.MOUSEMOTION:
      if keep_last.last_found: return 0
      else: keep_last.last_found = 1
    return 1
  keep_last.last_found = 0
  
  events = filter(keep_last, events)
  events.reverse()
  return events


DATADIR = os.path.join(os.path.dirname(__file__), "data")
if not os.path.exists(DATADIR):
  DATADIR = "/usr/share/soya"
  if not os.path.exists(DATADIR):
    DATADIR = "/usr/local/share/soya"
    if not os.path.exists(DATADIR):
      DATADIR = "/usr/share/python-soya"
      if not os.path.exists(DATADIR):
        DATADIR = os.path.join(os.getcwd(), "data")
        if not os.path.exists(DATADIR):
          import warnings
          warnings.warn("Soya's data directory cannot be found !")
          
        
path = []

_SAVING = None # The object currently being saved. XXX not thread-safe, hackish

def _loader(klass, filename): return klass.load(filename)
def _getter(klass, filename): return klass.get (filename)

class SavedInAPath(object):
  """SavedInAPath

Base class for all objects that can be saved in a path, such as Material,
World,..."""
  DIRNAME = ""
  
  def _check_export(klass, exported_filename, filename, *source_dirnames):
    """_check_export(FILENAME, *(SOURCE_DIRNAME, SOURCE_FILENAME)) -> (SOURCE_DIRNAME, SOURCE_FULL_FILENAME, FULL_FILENAME)

Search soya.path for a file FILENAME.data in the self.DIRNAME directory,
and check if the file needs to be re-exporter from any of the SOURCE_DIRNAMES directory.

Returned tuple :
FULL_FILENAME is the complete filename of the object.
If SOURCE_DIRNAME is None, the exported object is up-to-date.
If SOURCE_DIRNAME is one of SOURCE_DIRNAMES, the source object of this directory have been
modified more recently that the exported one, and SOURCE_FULL_FILENAME is the complete
filename of the source that needs to be re-exported."""
    filename        = filename.replace("/", os.sep)
    #source_filename = filename[:filename.index("@")]
    for p in path:
      file        = os.path.join(p, klass.DIRNAME , exported_filename)
      
      if   os.path.exists(file):
        for source_dirname, source_filename in source_dirnames:
          source_file = os.path.join(p, source_dirname, source_filename)
          if os.path.exists(source_file) and (os.path.getmtime(file) < os.path.getmtime(source_file)):
            print "* Soya * Converting %s to %s..." % (source_file, klass.__name__)
            return source_dirname, source_file, file
        return None, None, file
      else:
        for source_dirname, source_filename in source_dirnames:
          source_file = os.path.join(p, source_dirname, source_filename)
          if os.path.exists(source_file):
            print "* Soya * Converting %s to %s..." % (source_file, klass.__name__)
            return source_dirname, source_file, file
          
    raise ValueError("No %s or %s named %s" % (klass.__name__, source_dirname, filename))
  _check_export = classmethod(_check_export)
  
  def get(klass, filename):
    """SavedInAPath.get(filename)

Gets the object of this class with the given FILENAME attribute.
The object is loaded from the path if it is not already loaded.
If it is already loaded, the SAME object is returned.
Raise ValueError if the file is not found in soya.path."""
    return klass._alls.get(filename) or klass._alls.setdefault(filename, klass.load(filename))
  get = classmethod(get)
  
  def load(klass, filename):
    """SavedInAPath.get(filename)

Loads the object of this class with the given FILENAME attribute.
Contrary to get, load ALWAYS returns a new object.
Raise ValueError if the file is not found in soya.path."""
    filename = filename.replace("/", os.sep)
    for p in path:
      file = os.path.join(p, klass.DIRNAME, filename + ".data")
      if os.path.exists(file):
        obj = klass._alls[filename] = pickle.loads(open(file, "rb").read())
        return obj
    raise ValueError("No %s named %s" % (klass.__name__, filename))
  load = classmethod(load)
  
  def save(self, filename = None):
    """SavedInAPath.save(filename = None)

Saves this object. If no FILENAME is given, the object is saved in the path,
using its filename attribute. If FILENAME is given, it is saved at this
location."""
    global _SAVING
    _SAVING = self # Hack !!
    #pickle.dump(self, open(filename or os.path.join(path[0], self.DIRNAME, self.filename.replace("/", os.sep)) + ".data", "wb"), 1)
    # Avoid destroying the file if the serialization causes an error.
    data = pickle.dumps(self, 1)
    open(filename or os.path.join(path[0], self.DIRNAME, self.filename.replace("/", os.sep)) + ".data", "wb").write(data)
    _SAVING = None
    
  def __reduce__(self):
    if (not _SAVING is self) and self._filename: # self is saved in another file, save filename only
      if isinstance(self, CoordSyst): return (_loader, (self.__class__, self.filename)) # not shareable
      else:                           return (_getter, (self.__class__, self.filename)) # can be shared
    return _CObj.__reduce__(self)
  
  def get_filename(self): return self._filename
  def set_filename(self, filename):
    if self._filename:
      try: del self._alls[self.filename]
      except KeyError: pass
    if filename: self._alls[filename] = self
    self._filename = filename
  filename = property(get_filename, set_filename)
  
  def availables(klass):
    """SavedInAPath.availables() -> list

Returns the list of the filename all the objects available in the current path."""
    import dircache
    filenames = dict(klass._alls)
    for p in path:
      for filename in dircache.listdir(os.path.join(p, klass.DIRNAME)):
        if filename.endswith(".data"): filenames[filename[:-5]] = 1
    filenames = filenames.keys()
    filenames.sort()
    return filenames
  availables = classmethod(availables)
  
  def __setstate__(self, state):
    super(SavedInAPath, self).__setstate__(state)

# We MUST extends all Pyrex classes in Python,
# at least for weakref-ing their instance.

class Image(SavedInAPath, _soya._Image):
  """A Soya image, suitable for e.g. texturing.

Attributes are:

 - pixels : the raw image data (e.g. in a form suitable for PIL).

 - width.

 - height.

 - nb_color: the number of color channels (1 => monochrome, 3 => RGB, 4 => RGBA).
"""
  DIRNAME = "images"
  _alls = weakref.WeakValueDictionary()
  def __reduce__(self): return _CObj.__reduce__(self)
  
  def load(klass, filename):
    filename = filename.replace("/", os.sep)
    for p in path:
      file = os.path.join(p, klass.DIRNAME, filename)
      if os.path.exists(file): return open_image(file)
    raise ValueError("No %s named %s" % (klass.__name__, filename))
  load = classmethod(load)
  
  def save(klass, filename = None): raise NotImplementedError("Soya cannot save image.")
  
  def availables(klass):
    """SavedInAPath.availables() -> list

Returns the list of the filename all the objects available in the current path."""
    import dircache
    filenames = dict(klass._alls)
    for p in path:
      for filename in dircache.listdir(os.path.join(p, klass.DIRNAME)):
        filenames[filename] = 1
    filenames = filenames.keys()
    filenames.sort()
    return filenames
  availables = classmethod(availables)

  
class Material(SavedInAPath, _soya._Material):
  """Material

A material regroups all the surface attributes, like colors, shininess and
texture. You should NEVER use None as a material, use soya._DEFAULT_MATERIAL instead.

Attributes are:

- diffuse: the diffuse color.

- specular: the specular color; used for shiny part of the surface.

- emissive: the emissive color; this color is applied even in the dark.

- separate_specular: set it to true to enable separate specular; this usually
  results in a more shiny specular effect.

- shininess: the shininess ranges from 0.0 to 128.0; 0.0 is the most metallic / shiny
  and 128.0 is the most plastic.

- texture: the texture (a soya.Image object, or None if no texture).

- clamp: set it to true if you don't want to repeat the texture when the texture
  coordinates are out of the range 0 - 1.0.

- additive_blending: set it to true for additive blending. For semi-transparent surfaces
  (=alpha blended) only. Usefull for special effect (Ray, Sprite,...).
"""

  DIRNAME = "materials"
  _alls = weakref.WeakValueDictionary()
  
  def load(klass, filename):
    need_export, image_file, file = klass._check_export(filename + ".data", filename, (Image.DIRNAME, filename + ".png"), (Image.DIRNAME, filename + ".jpeg"))
    if need_export:
      image = Image.get(os.path.basename(image_file))
      if os.path.exists(file): material = pickle.loads(open(file, "rb").read())
      else:
        material = Material()
        material._filename = filename
      material.texture = image
      try: material.save()
      except:
        sys.excepthook(*sys.exc_info())
        print "* Soya * WARNING : can't save material %s!" % filename
      return material
    else:
      return pickle.loads(open(file, "rb").read())
  load = classmethod(load)
  
class Shape(SavedInAPath, _soya._Shape):
  DIRNAME = "shapes"
  _alls = weakref.WeakValueDictionary()
  
  def load(klass, filename):
    need_export, world_file, file = klass._check_export(filename + ".data", filename, (World.DIRNAME, filename + ".data"), ("blender", filename.split("@")[0] + ".blend"), ("obj", filename + ".obj"), ("obj", filename + ".mtl"), ("3ds", filename + ".3ds"))
    if need_export:
      shape = World.get(filename).shapify()
      shape._filename = filename
      try: shape.save()
      except:
        sys.excepthook(*sys.exc_info())
        print "* Soya * WARNING : can't save compiled shape %s!" % filename
      return shape
    else:
      return pickle.loads(open(file, "rb").read())
  load = classmethod(load)
  
  def availables(klass): return World.availables()
  availables = classmethod(availables)
  
  
class SimpleShape(Shape, _soya._SimpleShape):
  pass
  
class TreeShape(Shape, _soya._TreeShape):
  pass

class CellShadingShape(Shape, _soya._CellShadingShape):
  pass


class Point(_soya._Point):
  """A Point is just a 3D position. It is used for math computation, but it DOESN'T display
anything."""

class Vector(_soya._Vector):
  """A Vector is a 3D vector (and not a kind of list or sequence ;-). Vectors are
useful for 3D math computation. 

Most of the math operators, such as +, -, *, /, abs,... work on Vectors and do
what they are intended to do ;-)"""

class Vertex(_soya._Vertex):
  """Vertex

A Vertex is a subclass of Point, which is used for building Faces.
A Vertex doesn't display anything ; you MUST put it inside a Face.

Attributes are (see also Point for inherited attributes):

# - diffuse: the vertex diffuse color (also aliased to 'color' for compatibility)
# - emissive: the vertex emissive color (lighting-independant color)
# - tex_x, tex_y: the text
ure coordinates (sometime called U and V).
"""
  
  
class Volume(_soya._Volume):
  """Volume

A Volume is a Soya 3D object that display a Shape. The Volume contains data about the
position, the orientation and the scaling, and the Shape contains the geometric data.

This separation allows to use several time the same Shape at different position, without
dupplicating the geometric data.

Attributes are (see also CoordSyst for inherited attributes):

 - shape : the Shape (a Shape object, defaults to None).
"""
  pass

def do_cmd(cmd):
  print "* Soya * Running '%s'..." % cmd
  os.system(cmd)
  
class World(SavedInAPath, _soya._World, Volume):
  """World

A World is a Soya 3D object that can contain other Soya 3D objects, including other Worlds.
Worlds are used to group 3D objects ; when a World is moved, all the objects it contains
are moved too, since they are part of the World.
Mostly for historical reasons, World is a subclass of Volume, and thus can display a Shape.

Worlds can be saved in the "worlds" directory ; see SavedInAPath.

Attributes are (see also Volume, CoordSyst and SavedInAPath for inherited attributes):

 - children : the list of 3D object contained in the World (default to an empty list).
   use World.add(coordsyst) and World.remove(coordsyst) for additions and removals.
 - atmosphere : the atmosphere specifies atmospheric properties of the World (see
   Atmosphere). Default is None.
 - shapifier : the shapifier specifies how the World is compiled into Shape.
   Default is None, which result in the use of the default Shapifier, which is
   SimpleShapifier().
"""

  DIRNAME = "worlds"
  _alls = weakref.WeakValueDictionary()
  
  def load(klass, filename):
    need_export, source_file, file = klass._check_export(filename + ".data", filename, ("blender", filename.split("@")[0] + ".blend"), ("obj", filename + ".obj"), ("obj", filename + ".mtl"), ("3ds", filename + ".3ds"))
    if need_export:
      if   need_export == "blender":
        extra = ""
        
        if "@" in filename:
          extra += "CONFIG_TEXT=%s" % filename[filename.index("@") + 1:]
            
        do_cmd("blender %s -P %s --blender2soya FILENAME=%s %s" % (
          source_file,
          os.path.join(os.path.dirname(__file__), "blender2soya.py"),
          filename,
          extra,
          ))
        
      elif need_export == "obj":
        import soya.objmtl2soya
        world = soya.objmtl2soya.loadObj(os.path.splitext(source_file)[0] + ".obj")
        world.filename = filename
        world.save()
        return world
      
      elif need_export == "3ds":
        import soya._3DS2soya
        world = soya._3DS2soya.load_3ds(os.path.splitext(source_file)[0] + ".3ds")
        world.filename = filename
        world.save()
        return world
      
    return pickle.loads(open(file, "rb").read())
  load = classmethod(load)
  

class Light(_soya._Light):
  """Light

A Light is a 3D object that enlights the other objects.

Attributes are (see also CoordSyst for inherited attributes):

 - directional : True for a directional light (e.g. like the sun), instead of a
   positional light. The position of a directional light doesn't matter, and only
   the constant component of the attenuation is used. Default is false.
 - constant, linear and quadratic : the 3 components of the light attenuation. Constant
   reduces the light independently of the distance, linear increase with the distance,
   and quadratic increase the squared distance. Default is 1.0, 0.0 and 0.0.
 - cast_shadow : True if the light cast shadows on Shapes that have shadows enabled.
   Default is true.
 - shadow_color : the color of the shadow . Default is a semi-transparent black
   (0.0, 0.0, 0.0, 0.5).
 - top_level : XXX ???
 - static : True if the light can be used for static lighting when compiling a World into
   a Shape. Default is true.
 - ambient : the light's ambient color, which is not affected by the light's orientation
   or attenuation. Default is black (no ambient).
 - diffuse : the light's color. Default is white.
 - specular : the light's specular color. Default is white.
"""

class Camera(_soya._Camera):
  """Camera

The Camera specifies from where the scene is viewed.

Attributes are (see also CoordSyst and Widget for inherited attributes):

 - front, back : objects whose distance from the camera is not between front and back
   are clipped. Front defaults to 0.1 and back to 100.0.
   If the back / front ratio is too big, you loose precision in the depth buffer.
 - fov : the field of vision (or FOV), in degrees. Default is 60.0.
 - to_render : the world that is rendered by the camera. Default is None, which means
   the root scene (as returned by get_root()).
 - left, top, width, height : the viewport rectangle, in pixel. Use it if you want to
   render only on a part of the screen. It defaults to the whole screen.
 - ortho : True for orthogonal rendering, instead of perspective. Default is false.
 - partial : XXX ???.
"""

class Face(_soya._Face):
  """Face

A Face displays a polygon composed of several Vertices (see the Vertex class).
Notice that Face are SLOW ; Faces are normally used for building model but not for
rendering them. To get a fast rendering, you should put several Faces in a World, and
then compile the World into a Shape (see the modeling-X.py tutorial series).

According to the number of Vertices, the result differs:
- 1 Vertex => Plot
- 2        => Line
- 3        => Triangle
- 4        => Quad

All the vertices are expected to be coplannar.

Interesting properties are:

- vertices: the list of Vertices
- material: the material used to draw the face's surface
- double_sided: true if you want to see both sides of the Face. Default is false.
- solid: true to enable the use of this Face for raypicking. Default is true.
- lit: true to enable lighting on the Face. Default is true.

The following options are used when compiling the Face into a Shape,
but does not affect the rendering of the Face itself:

- static_lit: true to enable static lighting (faster). If true, when compiling the Face
  into a Shape, all Lights available will be applied as static lighting. Default is true.
- smooth_lit: true to compute per-vertex normal vectors, instead of per-face normal vector.
  This makes the Shape looking smooth (see tutorial modeling-smoothlit-1.py).
  Notice that Soya automatically disable smooth_lit between 2 faces that makes a sharp
  angle (see Shapifier.max_face_angle attribute).
  Default is false.
"""

class Atmosphere(_soya._Atmosphere):
  pass

class NoBackgroundAtmosphere(_soya._NoBackgroundAtmosphere, Atmosphere):
  pass

class SkyAtmosphere(_soya._SkyAtmosphere, Atmosphere):
  pass

class Sprite(_soya._Sprite):
  pass

class CylinderSprite(_soya._CylinderSprite, Sprite):
  pass

class Particles(_soya._Particles):
  pass

class Bonus(_soya._Bonus):
  pass

class Portal(_soya._Portal):
  # Implement in Python due to the lambda
  def pass_through(self, coordsyst):
    """Portal.pass_though(self, coordsyst)

Makes COORDSYST pass through the portal. If needed (=if coordsyst.parent is self.parent),
it removes COORDSYST from its current parent and add it in the new one,
at the right location.
If coordsyst is a camera, it change the 'to_render' attribute too.

The passing through does NOT occur immediately, but after the beginning of the round
(this is usually what you need, in order to avoid that moving COORDSYST from a parent
to another makes it plays twice)."""
    def do_it():
      if isinstance(coordsyst, Camera) and coordsyst.to_render:
        coordsyst.to_render = self.beyond
      if coordsyst.parent is self.parent:
        self.beyond.add(coordsyst)
    IDLER.next_round_tasks.append(do_it)
    
    
class Land(_soya._Land):
  pass

class WaterCube(_soya._WaterCube):
  pass

class TravelingCamera(_soya._TravelingCamera):
  pass

class ThirdPersonTraveling(_soya._ThirdPersonTraveling):
  pass

class FixTraveling(_soya._FixTraveling):
  pass

class Cal3dVolume(_soya._Cal3dVolume):
  pass

class Cal3dShape(Shape, _soya._Cal3dShape):
  def load(klass, filename):
    need_export, source_file, file = klass._check_export(os.path.join(filename, filename + ".cfg"), filename, ("blender", filename + ".blend"))
    if need_export:
      if need_export == "blender":
        do_cmd("blender %s -P %s --blender2cal3d FILENAME=%s EXPORT_FOR_SOYA=1 XML=0" % (
          source_file,
          os.path.join(os.path.dirname(__file__), "blender2cal3d.py"),
          os.path.join(os.path.dirname(source_file), "..", "shapes", filename, filename + ".cfg"),
          ))
      
    return parse_cal3d_cfg_file(file)
  load = classmethod(load)

_soya.Image            = Image
_soya.Material         = Material
_soya.Shape            = Shape
_soya.SimpleShape      = SimpleShape
_soya.TreeShape        = TreeShape
_soya.CellShadingShape = CellShadingShape
_soya.Point            = Point
_soya.Vector           = Vector
_soya.Camera           = Camera
_soya.Light            = Light
_soya.Volume           = Volume
_soya.World            = World
_soya.Cal3dVolume      = Cal3dVolume
_soya.Cal3dShape       = Cal3dShape
_soya.Face             = Face
_soya.Atmosphere       = Atmosphere
_soya.Portal           = Portal
_soya.Land             = Land
_soya.WaterCube        = WaterCube
_soya.Particles        = Particles

DEFAULT_MATERIAL = Material()
DEFAULT_MATERIAL.filename  = "__DEFAULT_MATERIAL__"
DEFAULT_MATERIAL.shininess = 128.0
_soya._set_default_material(DEFAULT_MATERIAL)

PARTICLE_DEFAULT_MATERIAL = pickle.load(open(os.path.join(DATADIR, "particle_default.data"), "rb"))
PARTICLE_DEFAULT_MATERIAL.filename = "__PARTICLE_DEFAULT_MATERIAL__"
# PARTICLE_DEFAULT_MATERIAL = Material()
# PARTICLE_DEFAULT_MATERIAL.additive_blending = 1
# PARTICLE_DEFAULT_MATERIAL.texture = open_image(os.path.join(DATADIR, "fx.png"))
# PARTICLE_DEFAULT_MATERIAL.filename = "__PARTICLE_DEFAULT_MATERIAL__"
# PARTICLE_DEFAULT_MATERIAL.diffuse = (1.0, 1.0, 1.0, 1.0)
# PARTICLE_DEFAULT_MATERIAL.save("/home/jiba/src/soya/data/particle_default.data")
_soya._set_particle_default_material(PARTICLE_DEFAULT_MATERIAL)

SHADER_DEFAULT_MATERIAL = pickle.load(open(os.path.join(DATADIR, "shader_default.data"), "rb"))
SHADER_DEFAULT_MATERIAL.filename = "__SHADER_DEFAULT_MATERIAL__"
#SHADER_DEFAULT_MATERIAL = Material()
#SHADER_DEFAULT_MATERIAL.texture = open_image(os.path.join(DATADIR, "shader.png"))
#SHADER_DEFAULT_MATERIAL.filename = "__SHADER_DEFAULT_MATERIAL__"
#SHADER_DEFAULT_MATERIAL.diffuse = (1.0, 1.0, 1.0, 1.0)
#SHADER_DEFAULT_MATERIAL.save("/home/jiba/src/soya/data/shader_default.data")
_soya._set_shader_default_material(SHADER_DEFAULT_MATERIAL)


inited = 0