Skip to content

Commit f375f9c

Browse files
committed
Progress update for mesh import
1 parent 880c9ac commit f375f9c

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

Options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ filepath="D:\\tmp\\NormalsExport\\Suzanne.mesh",
198198

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

204204
# Mesh

io_ogre/ogre/ogre_import.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ def GetValidBlenderName(name):
162162
return newname
163163

164164
def xOpenFile(filename):
165+
logger.info("* Parsing file: %s ..." % filename)
166+
start = time.time()
167+
165168
xml_file = open(filename)
166169
try:
167170
xml_doc = minidom.parse(xml_file)
@@ -171,6 +174,9 @@ def xOpenFile(filename):
171174
Report.errors.append("File %s is not valid XML!" % filename)
172175
output = 'None'
173176
xml_file.close()
177+
178+
logger.info('- Done at %s seconds' % util.timer_diff_str(start))
179+
174180
return output
175181

176182

@@ -195,7 +201,23 @@ def xCollectVertexData(data):
195201
for vb in data.childNodes:
196202
if vb.localName == 'vertexbuffer':
197203
if vb.hasAttribute('positions'):
204+
205+
progressScale = 1.0 / len(vb.getElementsByTagName('vertex'))
206+
bpy.context.window_manager.progress_begin(0, 100)
207+
index = 0
208+
198209
for vertex in vb.getElementsByTagName('vertex'):
210+
211+
# Update progress in console
212+
percent = (index + 1) * progressScale
213+
sys.stdout.write( "\r + Vertices [" + '=' * int(percent * 50) + '>' + '.' * int(50 - percent * 50) + "] " + str(int(percent * 10000) / 100.0) + "% ")
214+
sys.stdout.flush()
215+
216+
# Update progress through Blender cursor
217+
bpy.context.window_manager.progress_update(percent)
218+
219+
index = index + 1
220+
199221
for vp in vertex.childNodes:
200222
if vp.localName == 'position':
201223
x = float(vp.getAttributeNode('x').value)
@@ -204,6 +226,8 @@ def xCollectVertexData(data):
204226
vertices.append([x, y, z])
205227
vertexdata['positions'] = vertices
206228

229+
sys.stdout.write("\n")
230+
207231
if vb.hasAttribute('normals') and config.get('IMPORT_NORMALS'):
208232
for vertex in vb.getElementsByTagName('vertex'):
209233
for vn in vertex.childNodes:
@@ -235,7 +259,7 @@ def xCollectVertexData(data):
235259
for vt in vertex.childNodes:
236260
if vt.localName == 'texcoord':
237261
u = float(vt.getAttributeNode('u').value)
238-
v = -float(vt.getAttributeNode('v').value)+1.0
262+
v = -float(vt.getAttributeNode('v').value) + 1.0
239263
uvcoords.append([u, v])
240264

241265
if len(uvcoords) > 0:
@@ -1397,7 +1421,7 @@ def load(filepath):
13971421
fps = xAnalyseFPS(xDocSkeletonData)
13981422
if(fps and config.get('ROUND_FRAMES')):
13991423
logger.info(" * Setting FPS to %s" % fps)
1400-
bpy.context.scene.render.fps = fps
1424+
bpy.context.scene.render.fps = int(fps)
14011425
xCollectAnimations(meshData, xDocSkeletonData)
14021426

14031427
else:

0 commit comments

Comments
 (0)