Blender V2.61 - r43446

engine.py

Go to the documentation of this file.
00001 #
00002 # Copyright 2011, Blender Foundation.
00003 #
00004 # This program is free software; you can redistribute it and/or
00005 # modify it under the terms of the GNU General Public License
00006 # as published by the Free Software Foundation; either version 2
00007 # of the License, or (at your option) any later version.
00008 #
00009 # This program is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 # GNU General Public License for more details.
00013 #
00014 # You should have received a copy of the GNU General Public License
00015 # along with this program; if not, write to the Free Software Foundation,
00016 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 #
00018 
00019 # <pep8 compliant>
00020 
00021 import bpy
00022 
00023 
00024 def init():
00025     import _cycles
00026     import os.path
00027 
00028     path = os.path.dirname(__file__)
00029     user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', '')))
00030 
00031     _cycles.init(path, user_path)
00032 
00033 
00034 def create(engine, data, scene, region=0, v3d=0, rv3d=0):
00035     import _cycles
00036 
00037     data = data.as_pointer()
00038     userpref = bpy.context.user_preferences.as_pointer()
00039     scene = scene.as_pointer()
00040     if region:
00041         region = region.as_pointer()
00042     if v3d:
00043         v3d = v3d.as_pointer()
00044     if rv3d:
00045         rv3d = rv3d.as_pointer()
00046 
00047     engine.session = _cycles.create(engine.as_pointer(), userpref, data, scene, region, v3d, rv3d)
00048 
00049 
00050 def free(engine):
00051     if hasattr(engine, "session"):
00052         if engine.session:
00053             import _cycles
00054             _cycles.free(engine.session)
00055         del engine.session
00056 
00057 
00058 def render(engine):
00059     import _cycles
00060     if hasattr(engine, "session"):
00061         _cycles.render(engine.session)
00062 
00063 
00064 def update(engine, data, scene):
00065     import _cycles
00066     _cycles.sync(engine.session)
00067 
00068 
00069 def draw(engine, region, v3d, rv3d):
00070     import _cycles
00071     v3d = v3d.as_pointer()
00072     rv3d = rv3d.as_pointer()
00073 
00074     # draw render image
00075     _cycles.draw(engine.session, v3d, rv3d)
00076 
00077 
00078 def available_devices():
00079     import _cycles
00080     return _cycles.available_devices()
00081 
00082 
00083 def with_osl():
00084     import _cycles
00085     return _cycles.with_osl