Skip to content

Commit

Permalink
Exporter resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristian Sons committed Dec 8, 2014
1 parent 1f8049b commit 6b9c66b
Show file tree
Hide file tree
Showing 33 changed files with 6,626 additions and 46 deletions.
27 changes: 26 additions & 1 deletion addons/io_scene_xml3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,32 @@ class ExportXML3D(bpy.types.Operator, ExportHelper):
default=False,
)

template_selection = EnumProperty(
name="Template",
items=(('html', "HTML", ""),
('xml3d', "XML3D only", ""),
('preview', "Blender Preview", ""),
),
default='preview',
)

xml3djs_selection = EnumProperty(
name="xml3d.js Version",
items=(('xml3d', "Latest Stable", ""),
('xml3d-dev', "Development", ""),
('xml3d-4.7', "4.7", ""),
('xml3d-4.6', "4.6", ""),
),
default='xml3d',
)

xml3d_minimzed = BoolProperty(
name="Minimized",
description="Uses minimized version of xml3d.js",
default=False,
)


axis_forward = EnumProperty(
name="Forward",
items=(('X', "X Forward", ""),
Expand Down Expand Up @@ -97,7 +123,6 @@ def execute(self, context):
to_up=self.axis_up,
).to_4x4()
keywords["global_matrix"] = global_matrix

return export_xml3d.save(self, context, **keywords)


Expand Down
3 changes: 1 addition & 2 deletions addons/io_scene_xml3d/export_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def add_material(self, material):
def addMesh(self, meshObject, derivedObject):
if derivedObject:
for obj, mat in derivedObject:
print(obj, mat)
if obj.type not in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META'}:
continue

Expand Down Expand Up @@ -79,6 +78,7 @@ def addMeshData(self, mesh):

# print("Faces: %i" % len(mesh.polygons))

# TODO: Support for UV coordinates
uvTexture = mesh.uv_textures.active
if uvTexture :
pass
Expand Down Expand Up @@ -160,7 +160,6 @@ def addMeshData(self, mesh):


for materialIndex, material in enumerate(mesh.materials if materialCount else [None]) :
print(materialIndex)
if len(indices[materialIndex]) == 0:
continue

Expand Down
21 changes: 17 additions & 4 deletions addons/io_scene_xml3d/export_xml3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from . import xml_writer, export_asset
from bpy_extras.io_utils import create_derived_objects, free_derived_objects
from .tools import Stats, isIdentity
from shutil import copytree

ASSETDIR = "assets"

Expand Down Expand Up @@ -203,6 +204,9 @@ def save(operator,
context, filepath="",
use_selection=True,
global_matrix=None,
template_selection="preview",
xml3djs_selection = "",
xml3d_minimzed = False
):

import bpy
Expand All @@ -214,19 +218,28 @@ def save(operator,

"""Save the Blender scene to a XML3D/HTML file."""

# Time the export
time1 = time.clock()
# TODO: Time the export
# time1 = time.clock()

version = "%s%s.js" % (xml3djs_selection, "-min" if xml3d_minimzed else "")

dirName = os.path.dirname(__file__)
templatePath = os.path.join(dirName, 'templates\\index.html')
outputDir = os.path.dirname(filepath)
templatePath = os.path.join(dirName, 'templates\\%s.html' % template_selection)
#TODO: Handle case if template file does not exist
with open (templatePath, "r") as templateFile:
data=Template(templateFile.read())
file = open(filepath, 'w')
xml3d_exporter = XML3DExporter(context, os.path.dirname(filepath))
scene = xml3d_exporter.scene()
file.write(data.substitute(title=context.scene.name,xml3d=scene))
file.write(data.substitute(title=context.scene.name,xml3d=scene,version=version))
file.close()

# TODO: Write out stats (optionally)
print(xml3d_exporter._stats.to_JSON())

publicDir = os.path.join(outputDir, "public")
if not os.path.exists(publicDir):
copytree(os.path.join(dirName, "public"), publicDir)

return {'FINISHED'}
10 changes: 10 additions & 0 deletions addons/io_scene_xml3d/public/scripts/foundation.min.js

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions addons/io_scene_xml3d/public/scripts/vendor/jquery.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions addons/io_scene_xml3d/public/scripts/vendor/modernizr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6b9c66b

Please sign in to comment.