-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from sketchfab/feature/cycles
Feature/cycles
- Loading branch information
Showing
22 changed files
with
1,423 additions
and
898 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (C) 2008 Cedric Pinson | ||
# | ||
# 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. | ||
# | ||
# Authors: | ||
# Cedric Pinson <[email protected]> | ||
|
||
SET ( DATA_SOURCE ${PROJECT_SOURCE_DIR}/data/car/BMW-MikePan2.blend ) | ||
SET ( DATA_TARGET car ) | ||
BUILD_DATA() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (C) 2014 Cedric Pinson | ||
# | ||
# 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. | ||
# | ||
# Authors: | ||
# Cedric Pinson <[email protected]> | ||
|
||
|
||
SET ( DATA_SOURCE ${PROJECT_SOURCE_DIR}/data/cycles/cycles.blend ) | ||
SET ( DATA_TARGET cycles ) | ||
BUILD_DATA() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,17 @@ | |
# | ||
# ##### END GPL LICENSE BLOCK ##### | ||
|
||
import imp | ||
import sys | ||
import os | ||
import bpy | ||
import pickle | ||
import argparse | ||
|
||
|
||
bl_info = { | ||
"name": "Export OSG format (.osgt)", | ||
"author": "Cedric Pinson, Jeremy Moles, Peter Amstutz", | ||
"version": (0,14,2), | ||
"version": (0, 14, 2), | ||
"blender": (2, 6, 3), | ||
"email": "[email protected], [email protected], [email protected]", | ||
"api": 36339, | ||
|
@@ -36,32 +37,32 @@ | |
"tracker_url": "http://github.com/cedricpinson/osgexport", | ||
"category": "Import-Export"} | ||
|
||
__url__ = bl_info["wiki_url"] | ||
__email__ = bl_info["email"] | ||
__author__ = bl_info["author"] | ||
__bpydoc__ = bl_info["description"] | ||
__version__ = bl_info["version"] | ||
__author__ = bl_info["author"] | ||
__email__ = bl_info["email"] | ||
__url__ = bl_info["wiki_url"] | ||
__bpydoc__ = bl_info["description"] | ||
|
||
sys.path.insert(0, "./") | ||
BlenderExporterDir = os.getenv("BlenderExporter", os.path.join(bpy.context.user_preferences.filepaths.script_directory,"blenderExporter")) | ||
BlenderExporterDir = os.getenv("BlenderExporter", | ||
os.path.join(bpy.context.user_preferences.filepaths.script_directory, | ||
"blenderExporter")) | ||
print("BlenderExporter directory ", BlenderExporterDir) | ||
sys.path.insert(0,BlenderExporterDir) | ||
sys.path.insert(0, BlenderExporterDir) | ||
|
||
import bpy | ||
import osg | ||
from osg import osgdata | ||
from osg import osgconf | ||
|
||
|
||
def OpenSceneGraphExport(config=None): | ||
export = osg.osgdata.Export(config) | ||
print("....................", config.filename) | ||
export.process() | ||
export.write() | ||
|
||
def main(): | ||
import sys # to get command line args | ||
import argparse # to parse options for us and print a nice help message | ||
|
||
def main(): | ||
# get the args passed to blender after "--", all of which are ignored by | ||
# blender so scripts may receive their own arguments | ||
argv = sys.argv | ||
|
@@ -72,44 +73,55 @@ def main(): | |
argv = argv[argv.index("--") + 1:] # get all args after "--" | ||
|
||
# When --help or no args are given, print this help | ||
usage_text = \ | ||
"Run blender in background mode with this script:" | ||
" blender --background --python " + __file__ + " -- [options]" | ||
usage_text = "Run blender in background mode with this script:" \ | ||
"blender --background --python {} -- [options]".format(__file__) | ||
|
||
parser = argparse.ArgumentParser(description=usage_text) | ||
|
||
# Example utility, add some text and renders or saves it (with options) | ||
# Possible types are: string, int, long, choice, float and complex. | ||
parser.add_argument("-o", "--output", dest="save_path", metavar='FILE|PATH', help="Save the generated file to the specified path") | ||
parser.add_argument("-a", "--enable-animation", dest="enable_animation", action="store_const", const=True, default=False, help="Enable saving of animations") | ||
parser.add_argument("-m", "--apply-modifiers", dest="apply_modifiers", action="store_const", const=True, default=False, help="Apply modifiers before exporting") | ||
parser.add_argument("-o", "--output", dest="save_path", metavar='FILE|PATH', | ||
help="Save the generated file to the specified path") | ||
parser.add_argument("-a", "--enable-animation", dest="enable_animation", action="store_true", default=False, | ||
help="Enable saving of animations") | ||
parser.add_argument("-m", "--apply-modifiers", dest="apply_modifiers", action="store_true", default=False, | ||
help="Apply modifiers before exporting") | ||
parser.add_argument("-j", "--json-materials", dest="json_materials", action="store_true", default=False, | ||
help="Store materials into JSON format") | ||
parser.add_argument("-s", "--json-shaders", dest="json_shaders", action="store_true", default=False, | ||
help="Store shader graphs into JSON format") | ||
|
||
args = parser.parse_args(argv) # In this example we wont use the args | ||
|
||
if args.save_path == None: | ||
if args.save_path is None: | ||
print("\n*** No output filename specified (use -o)") | ||
else: | ||
config = osgconf.Config() | ||
config.initFilePaths(args.save_path) | ||
config.export_anim = args.enable_animation | ||
config.apply_modifiers = args.apply_modifiers | ||
config.scene = bpy.context.scene | ||
config.json_materials = args.json_materials | ||
config.json_shaders = args.json_shaders | ||
OpenSceneGraphExport(config) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
||
|
||
def menu_export_osg_model(self, context): | ||
#import os | ||
#default_path = os.path.splitext(bpy.data.filepath)[0] + "_" + bpy.context.scene.name | ||
#default_path = default_path.replace('.', '_') | ||
#self.layout.operator(OSGGUI.bl_idname, text="OSG Model(.osg)").filepath = default_path | ||
self.layout.operator(OSGGUI.bl_idname, text="OSG Model(.osgt)") | ||
# import os | ||
# default_path = os.path.splitext(bpy.data.filepath)[0] + "_" + bpy.context.scene.name | ||
# default_path = default_path.replace('.', '_') | ||
# self.layout.operator(OSGGUI.bl_idname, text="OSG Model(.osg)").filepath = default_path | ||
self.layout.operator(OSGGUI.bl_idname, text="OSG Model(.osgt)") | ||
|
||
|
||
def register(): | ||
bpy.utils.register_module(__name__) | ||
bpy.types.INFO_MT_file_export.append(menu_export_osg_model) | ||
|
||
|
||
def unregister(): | ||
bpy.utils.unregister_module(__name__) | ||
bpy.types.INFO_MT_file_export.remove(menu_export_osg_model) | ||
|
@@ -121,17 +133,17 @@ def unregister(): | |
print("Use old import path - your blender is not the latest version") | ||
except: | ||
from bpy_extras.io_utils import ExportHelper | ||
#print("Use new import path") | ||
# print("Use new import path") | ||
|
||
|
||
build = 'unknown' | ||
if hasattr(bpy.app, 'build_hash'): | ||
build = bpy.app.build_hash | ||
# Property subtype constant changed with r50938 | ||
if "FILE_PATH" in bpy.types.Property.bl_rna.properties['subtype'].enum_items.keys(): | ||
FILE_NAME = "FILE_PATH" | ||
elif "FILE_NAME" in bpy.types.Property.bl_rna.properties['subtype'].enum_items.keys(): | ||
FILE_NAME = "FILE_NAME" | ||
else: | ||
build = bpy.app.build_revision | ||
FILE_NAME = "FILENAME" | ||
|
||
# Property subtype constant changed with r50938 | ||
FILE_NAME = "FILE_NAME" if build >= b'50938' else "FILENAME" | ||
|
||
class OSGGUI(bpy.types.Operator, ExportHelper): | ||
'''Export model data to an OpenSceneGraph file''' | ||
|
@@ -152,6 +164,8 @@ class OSGGUI(bpy.types.Operator, ExportHelper): | |
EXPORTANIM = BoolProperty(name="Export animations", description="Export animation yes/no", default=True) | ||
APPLYMODIFIERS = BoolProperty(name="Apply Modifiers", description="Apply modifiers before exporting yes/no", default=True) | ||
LOG = BoolProperty(name="Write log", description="Write log file yes/no", default=False) | ||
JSON_MATERIALS = BoolProperty(name="JSON Materials", description="Export materials into JSON userdata.", default=False) | ||
JSON_SHADERS = BoolProperty(name="JSON shaders", description="Export shader graphs into JSON userdata.", default=False) | ||
BAKE_CONSTRAINTS = BoolProperty(name="Bake Constraints", description="Bake constraints into actions", default=True) | ||
BAKE_FRAME_STEP = IntProperty(name="Bake frame step", description="Frame step when baking actions", default=1, min=1, max=30) | ||
OSGCONV_TO_IVE = BoolProperty(name="Convert to IVE (uses osgconv)", description="Use osgconv to convert to IVE", default=False) | ||
|
@@ -176,6 +190,8 @@ def draw(self, context): | |
layout.row(align=True).prop(self, "APPLYMODIFIERS") | ||
layout.row(align=True).prop(self, "BAKE_CONSTRAINTS") | ||
layout.row(align=True).prop(self, "LOG") | ||
layout.row(align=True).prop(self, "JSON_MATERIALS") | ||
layout.row(align=True).prop(self, "JSON_SHADERS") | ||
layout.row(align=True).prop(self, "ZERO_TRANSLATIONS") | ||
layout.row(align=True).prop(self, "ANIMFPS") | ||
layout.row(align=True).prop(self, "BAKE_FRAME_STEP") | ||
|
@@ -220,6 +236,8 @@ def invoke(self, context, event): | |
self.OSGCONV_EMBED_TEXTURES = self.config.osgconv_embed_textures | ||
self.OSGCONV_PATH = self.config.osgconv_path | ||
self.OSGCONV_CLEANUP = self.config.osgconv_cleanup | ||
self.JSON_MATERIALS = self.config.json_materials | ||
self.JSON_SHADERS = self.config.json_shaders | ||
|
||
self.RUN_VIEWER = self.config.run_viewer | ||
self.VIEWER_PATH = self.config.viewer_path | ||
|
@@ -245,7 +263,7 @@ def execute(self, context): | |
self.config.selected = "ALL" | ||
self.config.indent = self.INDENT | ||
self.config.only_visible = self.ONLY_VISIBLE | ||
self.config.float_precision = self.FLOATPRE | ||
self.config.float_precision = self.FLOATPRE | ||
self.config.anim_fps = self.ANIMFPS | ||
self.config.export_anim = self.EXPORTANIM | ||
self.config.apply_modifiers = self.APPLYMODIFIERS | ||
|
Oops, something went wrong.