2011-04-27 11:58:34 +00:00
|
|
|
#
|
2013-08-18 14:16:15 +00:00
|
|
|
# Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
#
|
2013-08-18 14:16:15 +00:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
#
|
2013-08-18 14:16:15 +00:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
#
|
2013-08-18 14:16:15 +00:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License
|
2011-04-27 11:58:34 +00:00
|
|
|
#
|
|
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
# <pep8 compliant>
|
|
|
|
|
|
2013-01-15 23:17:45 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def init():
|
2012-12-13 08:45:55 +00:00
|
|
|
import bpy
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
2011-08-28 13:55:59 +00:00
|
|
|
import os.path
|
2011-09-09 12:04:39 +00:00
|
|
|
|
|
|
|
|
path = os.path.dirname(__file__)
|
|
|
|
|
user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', '')))
|
|
|
|
|
|
2011-12-24 02:47:13 +00:00
|
|
|
_cycles.init(path, user_path)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2013-01-28 17:37:51 +00:00
|
|
|
def create(engine, data, scene, region=0, v3d=0, rv3d=0, preview_osl=False):
|
2012-12-13 08:45:55 +00:00
|
|
|
import bpy
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
data = data.as_pointer()
|
2012-01-09 16:58:01 +00:00
|
|
|
userpref = bpy.context.user_preferences.as_pointer()
|
2011-08-28 13:55:59 +00:00
|
|
|
scene = scene.as_pointer()
|
|
|
|
|
if region:
|
|
|
|
|
region = region.as_pointer()
|
|
|
|
|
if v3d:
|
|
|
|
|
v3d = v3d.as_pointer()
|
|
|
|
|
if rv3d:
|
|
|
|
|
rv3d = rv3d.as_pointer()
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2013-01-28 17:37:51 +00:00
|
|
|
engine.session = _cycles.create(engine.as_pointer(), userpref, data, scene, region, v3d, rv3d, preview_osl)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def free(engine):
|
2011-11-15 02:58:01 +00:00
|
|
|
if hasattr(engine, "session"):
|
2011-08-28 13:55:59 +00:00
|
|
|
if engine.session:
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
|
|
|
|
_cycles.free(engine.session)
|
2011-08-28 13:55:59 +00:00
|
|
|
del engine.session
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-05-17 14:26:45 +00:00
|
|
|
def render(engine):
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
2011-11-27 03:49:09 +00:00
|
|
|
if hasattr(engine, "session"):
|
2011-12-24 02:47:13 +00:00
|
|
|
_cycles.render(engine.session)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
def reset(engine, data, scene):
|
|
|
|
|
import _cycles
|
|
|
|
|
data = data.as_pointer()
|
|
|
|
|
scene = scene.as_pointer()
|
|
|
|
|
_cycles.reset(engine.session, data, scene)
|
|
|
|
|
|
|
|
|
|
|
2011-05-17 14:26:45 +00:00
|
|
|
def update(engine, data, scene):
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
|
|
|
|
_cycles.sync(engine.session)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-05-17 14:26:45 +00:00
|
|
|
def draw(engine, region, v3d, rv3d):
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
2011-08-28 13:55:59 +00:00
|
|
|
v3d = v3d.as_pointer()
|
|
|
|
|
rv3d = rv3d.as_pointer()
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
# draw render image
|
2011-12-24 02:47:13 +00:00
|
|
|
_cycles.draw(engine.session, v3d, rv3d)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def available_devices():
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
|
|
|
|
return _cycles.available_devices()
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def with_osl():
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
|
|
|
|
return _cycles.with_osl
|
2014-02-13 08:51:33 +11:00
|
|
|
|
|
|
|
|
|
2013-12-07 02:29:53 +01:00
|
|
|
def with_network():
|
|
|
|
|
import _cycles
|
|
|
|
|
return _cycles.with_network
|