aboutsummaryrefslogtreecommitdiffstats
path: root/blender_render.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2012-12-01 20:16:15 -0600
committerChristopher Allan Webber <cwebber@dustycloud.org>2012-12-03 14:40:48 -0600
commit39c340f2807a72a2f255bc9461da1054ba0941b1 (patch)
tree69ae7a912b3e8cb4b71d1814fee11eac5ab45d10 /blender_render.py
parent8bef424f24fce5b8e1119a1bf5d7045fcfc6d407 (diff)
downloadmediagoblin-39c340f2807a72a2f255bc9461da1054ba0941b1.tar.lz
mediagoblin-39c340f2807a72a2f255bc9461da1054ba0941b1.tar.xz
mediagoblin-39c340f2807a72a2f255bc9461da1054ba0941b1.zip
Moving blender render files to be accessed via pkg_resources
Previously the .blend and .py files had to be in the same directory mediagoblin/celery launched from. This is now fixed so it pulls them out of the package proper.
Diffstat (limited to 'blender_render.py')
-rw-r--r--blender_render.py84
1 files changed, 0 insertions, 84 deletions
diff --git a/blender_render.py b/blender_render.py
deleted file mode 100644
index 99d5fa31..00000000
--- a/blender_render.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# GNU MediaGoblin -- federated, autonomous media hosting
-# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-import bpy, json, os
-
-
-try:
- CONFIG = json.loads(os.environ["RENDER_SETUP"])
- MODEL_EXT = CONFIG["model_ext"]
- MODEL_PATH = CONFIG["model_path"]
- CAMERA_COORD = CONFIG["camera_coord"]
- CAMERA_FOCUS = CONFIG["camera_focus"]
- CAMERA_CLIP = CONFIG["camera_clip"]
- CAMERA_TYPE = CONFIG["projection"]
- CAMERA_ORTHO = CONFIG["greatest"] * 1.5
- RENDER_WIDTH = CONFIG["width"]
- RENDER_HEIGHT = CONFIG["height"]
- RENDER_FILE = CONFIG["out_file"]
-except KeyError:
- print("Failed to load RENDER_SETUP environment variable.")
- exit(1)
-
-
-# add and setup camera
-bpy.ops.object.camera_add(view_align=False, enter_editmode=False,
- location = CAMERA_COORD)
-camera_ob = bpy.data.objects[0]
-camera = bpy.data.cameras[0]
-camera.clip_end = CAMERA_CLIP
-camera.ortho_scale = CAMERA_ORTHO
-camera.type = CAMERA_TYPE
-
-
-
-# add an empty for focusing the camera
-bpy.ops.object.add(location=CAMERA_FOCUS)
-target = bpy.data.objects[1]
-bpy.ops.object.select_all(action="SELECT")
-bpy.ops.object.track_set(type="TRACKTO")
-bpy.ops.object.select_all(action="DESELECT")
-
-
-if MODEL_EXT == 'stl':
- # import an stl model
- bpy.ops.import_mesh.stl(filepath=MODEL_PATH)
-
-elif MODEL_EXT == 'obj':
- # import an obj model
- bpy.ops.import_scene.obj(
- filepath=MODEL_PATH,
- use_smooth_groups=False,
- use_image_search=False,
- axis_forward="Y",
- axis_up="Z")
-
-
-# rotate the imported objects with meshes in the scene
-if CAMERA_TYPE == "PERSP":
- for obj in bpy.data.objects[2:]:
- obj.rotation_euler[2]=-.3
-
-
-# attempt to render
-scene = bpy.data.scenes.values()[0]
-scene.camera = camera_ob
-scene.render.filepath = RENDER_FILE
-scene.render.resolution_x = RENDER_WIDTH
-scene.render.resolution_y = RENDER_HEIGHT
-scene.render.resolution_percentage = 100
-bpy.ops.render.render(write_still=True)