Skip to content

Commit

Permalink
Progress update for mesh import
Browse files Browse the repository at this point in the history
  • Loading branch information
sercero committed Mar 22, 2023
1 parent 87b7059 commit 99f3110
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ filepath="D:\\tmp\\NormalsExport\\Suzanne.mesh",

# General
IM_SWAP_AXIS='xz-y', # Axis swapping mode
IM_V2_MESH_TOOL_VERSION='', # Specify Ogre version format to read
IM_V2_MESH_TOOL_VERSION='v2', # Specify Ogre version format to read
IM_XML_DELETE=True, # Remove the generated xml files after binary conversion.

# Mesh
Expand Down
28 changes: 26 additions & 2 deletions io_ogre/ogre/ogre_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ def GetValidBlenderName(name):
return newname

def xOpenFile(filename):
logger.info("* Parsing file: %s ..." % filename)
start = time.time()

xml_file = open(filename)
try:
xml_doc = minidom.parse(xml_file)
Expand All @@ -173,6 +176,9 @@ def xOpenFile(filename):
Report.errors.append("File %s is not valid XML!" % filename)
output = 'None'
xml_file.close()

logger.info('- Done at %s seconds' % util.timer_diff_str(start))

return output


Expand All @@ -197,7 +203,23 @@ def xCollectVertexData(data):
for vb in data.childNodes:
if vb.localName == 'vertexbuffer':
if vb.hasAttribute('positions'):

progressScale = 1.0 / len(vb.getElementsByTagName('vertex'))
bpy.context.window_manager.progress_begin(0, 100)
index = 0

for vertex in vb.getElementsByTagName('vertex'):

# Update progress in console
percent = (index + 1) * progressScale
sys.stdout.write( "\r + Vertices [" + '=' * int(percent * 50) + '>' + '.' * int(50 - percent * 50) + "] " + str(int(percent * 10000) / 100.0) + "% ")
sys.stdout.flush()

# Update progress through Blender cursor
bpy.context.window_manager.progress_update(percent)

index = index + 1

for vp in vertex.childNodes:
if vp.localName == 'position':
x = float(vp.getAttributeNode('x').value)
Expand All @@ -206,6 +228,8 @@ def xCollectVertexData(data):
vertices.append([x, y, z])
vertexdata['positions'] = vertices

sys.stdout.write("\n")

if vb.hasAttribute('normals') and config.get('IMPORT_NORMALS'):
for vertex in vb.getElementsByTagName('vertex'):
for vn in vertex.childNodes:
Expand Down Expand Up @@ -237,7 +261,7 @@ def xCollectVertexData(data):
for vt in vertex.childNodes:
if vt.localName == 'texcoord':
u = float(vt.getAttributeNode('u').value)
v = -float(vt.getAttributeNode('v').value)+1.0
v = -float(vt.getAttributeNode('v').value) + 1.0
uvcoords.append([u, v])

if len(uvcoords) > 0:
Expand Down Expand Up @@ -1323,7 +1347,7 @@ def load(filepath):
fps = xAnalyseFPS(xDocSkeletonData)
if(fps and config.get('ROUND_FRAMES')):
logger.info(" * Setting FPS to %s" % fps)
bpy.context.scene.render.fps = fps
bpy.context.scene.render.fps = int(fps)
xCollectAnimations(meshData, xDocSkeletonData)

else:
Expand Down

0 comments on commit 99f3110

Please sign in to comment.