forked from bartvdbraak/blender
add x3d/vrml importer into the menu.
This commit is contained in:
parent
ac64114d1b
commit
792bf1535f
@ -27,7 +27,20 @@ if "bpy" in locals():
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
from bpy.props import *
|
from bpy.props import *
|
||||||
from io_utils import ExportHelper
|
from io_utils import ImportHelper, ExportHelper
|
||||||
|
|
||||||
|
|
||||||
|
class ImportX3D(bpy.types.Operator, ImportHelper):
|
||||||
|
'''Load a BVH motion capture file'''
|
||||||
|
bl_idname = "import_scene.x3d"
|
||||||
|
bl_label = "Import X3D/VRML"
|
||||||
|
|
||||||
|
filename_ext = ".x3d"
|
||||||
|
filter_glob = StringProperty(default="*.x3d;*.wrl", options={'HIDDEN'})
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
from . import import_x3d
|
||||||
|
return import_x3d.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||||
|
|
||||||
|
|
||||||
class ExportX3D(bpy.types.Operator, ExportHelper):
|
class ExportX3D(bpy.types.Operator, ExportHelper):
|
||||||
@ -47,16 +60,22 @@ class ExportX3D(bpy.types.Operator, ExportHelper):
|
|||||||
return export_x3d.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))
|
return export_x3d.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))
|
||||||
|
|
||||||
|
|
||||||
def menu_func(self, context):
|
def menu_func_import(self, context):
|
||||||
|
self.layout.operator(ImportX3D.bl_idname, text="X3D Extensible 3D (.x3d/.wrl)")
|
||||||
|
|
||||||
|
|
||||||
|
def menu_func_export(self, context):
|
||||||
self.layout.operator(ExportX3D.bl_idname, text="X3D Extensible 3D (.x3d)")
|
self.layout.operator(ExportX3D.bl_idname, text="X3D Extensible 3D (.x3d)")
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.types.INFO_MT_file_export.append(menu_func)
|
bpy.types.INFO_MT_file_import.append(menu_func_import)
|
||||||
|
bpy.types.INFO_MT_file_export.append(menu_func_export)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
bpy.types.INFO_MT_file_export.remove(menu_func)
|
bpy.types.INFO_MT_file_import.remove(menu_func_import)
|
||||||
|
bpy.types.INFO_MT_file_export.remove(menu_func_export)
|
||||||
|
|
||||||
# NOTES
|
# NOTES
|
||||||
# - blender version is hardcoded
|
# - blender version is hardcoded
|
||||||
|
@ -2632,89 +2632,11 @@ def load_web3d(path, PREF_FLAT=False, PREF_CIRCLE_DIV=16, HELPER_FUNC=None):
|
|||||||
del child_dict
|
del child_dict
|
||||||
|
|
||||||
|
|
||||||
def load_ui(path):
|
def load(operator, context, filepath=""):
|
||||||
Draw = Blender.Draw
|
|
||||||
PREF_HIERARCHY = Draw.Create(0)
|
|
||||||
PREF_CIRCLE_DIV = Draw.Create(16)
|
|
||||||
|
|
||||||
# Get USER Options
|
load_web3d(filepath,
|
||||||
pup_block = [ \
|
PREF_FLAT=True,
|
||||||
'Import...',\
|
PREF_CIRCLE_DIV=16,
|
||||||
('Hierarchy', PREF_HIERARCHY, 'Import transform nodes as empties to create a parent/child hierarchy'),\
|
)
|
||||||
('Circle Div:', PREF_CIRCLE_DIV, 3, 128, 'Number of divisions to use for circular primitives')
|
|
||||||
]
|
|
||||||
|
|
||||||
if not Draw.PupBlock('Import X3D/VRML...', pup_block):
|
return {'FINISHED'}
|
||||||
return
|
|
||||||
|
|
||||||
Window.WaitCursor(1)
|
|
||||||
|
|
||||||
load_web3d(path,\
|
|
||||||
(not PREF_HIERARCHY.val),\
|
|
||||||
PREF_CIRCLE_DIV.val,\
|
|
||||||
)
|
|
||||||
|
|
||||||
Window.WaitCursor(0)
|
|
||||||
|
|
||||||
|
|
||||||
# Testing stuff
|
|
||||||
|
|
||||||
# load_web3d('/test.x3d')
|
|
||||||
# load_web3d('/_Cylinder.x3d')
|
|
||||||
|
|
||||||
# Testing below
|
|
||||||
# load_web3d('m:\\root\\Desktop\\_Cylinder.wrl')
|
|
||||||
# load_web3d('/_Cylinder.wrl')
|
|
||||||
# load_web3d('/fe/wrl/Vrml/EGS/BCKGD.WRL')
|
|
||||||
|
|
||||||
# load_web3d('/fe/wrl/Vrml/EGS/GRNDPLNE.WRL')
|
|
||||||
# load_web3d('/fe/wrl/Vrml/EGS/INDEXFST.WRL')
|
|
||||||
# load_web3d('/fe/wrl/panel1c.wrl')
|
|
||||||
# load_web3d('/test.wrl')
|
|
||||||
# load_web3d('/fe/wrl/dulcimer.wrl')
|
|
||||||
# load_web3d('/fe/wrl/rccad/Ju-52.wrl') # Face index out of range
|
|
||||||
# load_web3d('/fe/wrl/16lat.wrl') # spotlight
|
|
||||||
# load_web3d('/fe/wrl/Vrml/EGS/FOG.WRL') # spotlight
|
|
||||||
# load_web3d('/fe/wrl/Vrml/EGS/LOD.WRL') # vcolor per face
|
|
||||||
|
|
||||||
# load_web3d('/fe/wrl/new/daybreak_final.wrl') # no faces in mesh, face duplicate error
|
|
||||||
# load_web3d('/fe/wrl/new/earth.wrl')
|
|
||||||
# load_web3d('/fe/wrl/new/hendrix.ei.dtu.dk/vrml/talairach/fourd/TalaDruryRight.wrl') # define/use fields
|
|
||||||
load_web3d('/fe/wrl/new/imac.wrl') # extrusion and define/use fields, face index is a float somehow
|
|
||||||
# load_web3d('/fe/wrl/new/www.igs.net/~mascott/vrml/vrml2/mcastle.wrl')
|
|
||||||
# load_web3d('/fe/wrl/new/www.igs.net/~mascott/vrml/vrml2/tower.wrl')
|
|
||||||
# load_web3d('/fe/wrl/new/www.igs.net/~mascott/vrml/vrml2/temple.wrl')
|
|
||||||
# load_web3d('/fe/wrl/brain.wrl') # field define test 'a IS b'
|
|
||||||
# load_web3d('/fe/wrl/new/coaster.wrl') # fields that are confusing to read.
|
|
||||||
|
|
||||||
# X3D
|
|
||||||
|
|
||||||
# load_web3d('/fe/x3d/www.web3d.org/x3d/content/examples/Basic/StudentProjects/PlayRoom.x3d') # invalid UVs
|
|
||||||
|
|
||||||
def test():
|
|
||||||
import os
|
|
||||||
|
|
||||||
files = os.popen('find /fe/wrl -iname "*.wrl"').readlines()
|
|
||||||
# files = os.popen('find /fe/x3d -iname "*.x3d"').readlines()
|
|
||||||
# files = os.popen('find /fe/x3d/X3dExamplesSavage -iname "*.x3d"').readlines()
|
|
||||||
|
|
||||||
files.sort()
|
|
||||||
tot = len(files)
|
|
||||||
for i, f in enumerate(files):
|
|
||||||
if i < 9:
|
|
||||||
continue
|
|
||||||
|
|
||||||
#if i != 1068:
|
|
||||||
# continue
|
|
||||||
|
|
||||||
#if i != 12686:
|
|
||||||
# continue
|
|
||||||
|
|
||||||
f = f.strip()
|
|
||||||
print(f, i, tot)
|
|
||||||
sce = bpy.data.scenes.new(str(i) + '_' + f.split('/')[-1])
|
|
||||||
# bpy.context.scene = sce # XXX25
|
|
||||||
# Window.
|
|
||||||
load_web3d(f, PREF_FLAT=False)
|
|
||||||
|
|
||||||
# test()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user