Commits

Pang Lih-Hern  committed 907b635

- Added apply modifiers option.
- Updated help documentation.

  • Participants
  • Parent commits d4b6d3d
  • Branches v1-6

Comments (0)

Files changed (4)

File Tools/BlenderExport/ogrehelp/images/meshesexporter.png

Old
Old image
New
New image

File Tools/BlenderExport/ogrehelp/ogremeshesexporter.html

   <dt>Fix Up Axis to Y</dt>
   <dd>Blender uses Z as up axis. This toggle switch allows changing the mesh to use Y as up axis.</dd>
 
+  <dt>Require Materials</dt>
+  <dd>Generate Error message when part of a mesh is not assigned with a material.</dd>
+
   <dt>Skeleton name follow mesh</dt>
   <dd>Force skeleton name to follow mesh name. Uncheck to make it use armature name instead.</dd>
 
+  <dt>Apply Modifiers</dt>
+  <dd>Apply mesh modifiers before export. This option is slow and may break vert order for morph targets. Not recommended for animated meshes.</dd>
+
   <dt>OgreXMLConverter</dt>
   <dd>Convert the XML files to binary files via the OgreXMLConverter. The exporter must be able to find the converter executable. You can specify its location in the preferences.</dd>
 
 	<li>[textureName]._tex_address_mode</li>
 	<li>[textureName]._filtering</li>
 	<li>[textureName]._colour_op</li>
-	<li>[textureName]._sizeX</li>
-	<li>[textureName]._sizeY</li>
-	<li>[textureName]._sizeZ</li>
-	<li>[textureName]._offsetX</li>
-	<li>[textureName]._offsetY</li>
-	<li>[textureName]._offsetZ</li>
 </ul>
 
 <p>

File Tools/BlenderExport/ogremeshesexporter.py

 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 __author__ = 'Michael Reimpell (Maintainer: Lih-Hern Pang)'
-__version__ = '1.1'
+__version__ = '1.3'
 __url__ = ["Help, http://www.ogre3d.org/phpBB2/search.php", "Ogre3D, http://www.ogre3d.org"]
 __bpydoc__ = "Please see the external documentation that comes with the script."
 
 				for proxyManager in self.armatureAnimationProxyManagerDict.values():
 					proxyManager.savePackageSettings()
 				return
-			def export(self, exportPath, exportMaterial, materialScriptName, customMaterial, customMaterialTplPath, colouredAmbient, gameEngineMaterials, exportMesh, fixUpAxis, skeletonUseMeshName, convertXML, copyTextures, requireFaceMats):
+			def export(self, exportPath, exportMaterial, materialScriptName, customMaterial, customMaterialTplPath, colouredAmbient, gameEngineMaterials, exportMesh, fixUpAxis, skeletonUseMeshName, applyModifiers, convertXML, copyTextures, requireFaceMats):
 				# create MaterialManager
 				if len(self.selectedList):
 					materialManager = MaterialManager(exportPath, materialScriptName, gameEngineMaterials, customMaterial, customMaterialTplPath, requireFaceMats)
 						if self.armatureAnimationProxyManagerDict.has_key(name):
 							self.armatureAnimationProxyManagerDict[name].toAnimations(meshExporter.getArmatureExporter())
 						# export
-						meshExporter.export(exportPath, materialManager, fixUpAxis, exportMesh, colouredAmbient, convertXML)
+						meshExporter.export(exportPath, materialManager, fixUpAxis, exportMesh, colouredAmbient, applyModifiers, convertXML)
 					# export materials
 					if (exportMaterial):
 						materialManager.export(exportPath, materialScriptName, copyTextures)
 				self.copyTextures = ToggleModel(0)
 				self.requireFaceMats = ToggleModel(True)
 				self.skeletonUseMeshName = ToggleModel(1)
+				self.applyModifiers = ToggleModel(0)
 
 				matTglGrp = ToggleGroup()
 				matTglGrp.addToggle(self.renderingMaterial)
 				ToggleView(globalSettingLayout1, Size([Size.INFINITY, 20], [150, 20]), self.skeletonUseMeshName, T("Skeleton name follow mesh"), \
 					T("Use mesh name for the exported skeleton name instead of the armature name."))
 				globalSettingLayout2 = HorizontalLayout(globalSettingLayout)
+				ToggleView(globalSettingLayout2, Size([Size.INFINITY, 20], [150, 20]), self.applyModifiers, T("Apply Modifiers"), \
+					T("Apply mesh modifier before export. This option is slow and may break vert order for morph targets."))
 				ToggleView(globalSettingLayout2, Size([Size.INFINITY, 20], [100, 20]), self.convertXML, T("OgreXMLConverter"), \
 					T("Run OgreXMLConverter on the exported XML files."))
 				## buttons
 				skeletonUseMeshName = PackageSettings.getSingleton().getSetting('skeletonUseMeshName')
 				if skeletonUseMeshName is not None:
 					self.skeletonUseMeshName.setValue(skeletonUseMeshName)
+				applyModifiers = PackageSettings.getSingleton().getSetting('applyModifiers')
+				if applyModifiers is not None:
+					self.applyModifiers.setValue(applyModifiers)
 				convertXML = PackageSettings.getSingleton().getSetting('convertXML')
 				if convertXML is not None:
 					self.convertXML.setValue(convertXML)
 				PackageSettings.getSingleton().setSetting('exportMesh', self.exportMesh.getValue())
 				PackageSettings.getSingleton().setSetting('fixUpAxis', self.fixUpAxis.getValue())
 				PackageSettings.getSingleton().setSetting('skeletonUseMeshName', self.skeletonUseMeshName.getValue())
+				PackageSettings.getSingleton().setSetting('applyModifiers', self.applyModifiers.getValue())
 				PackageSettings.getSingleton().setSetting('convertXML', self.convertXML.getValue())
 				PackageSettings.getSingleton().setSetting('exportPath', self.exportPath.getValue())
 				PackageSettings.getSingleton().save()
 						self.app.exportMesh.getValue(), \
 						self.app.fixUpAxis.getValue(), \
 						self.app.skeletonUseMeshName.getValue(), \
+						self.app.applyModifiers.getValue(), \
 						self.app.convertXML.getValue(), \
 						self.app.copyTextures.getValue(), \
 						self.app.requireFaceMats.getValue(), \

File Tools/BlenderExport/ogrepkg/meshexport.py

 		# populated on export
 		self.submeshManager = None
 		return
-	def export(self, dir, materialManager, fixUpAxis=True, exportMesh=True, colouredAmbient=False, convertXML=False):
+	def export(self, dir, materialManager, fixUpAxis=True, exportMesh=True, colouredAmbient=False, applyModifiers=False, convertXML=False):
 		# leave editmode
 		editmode = Blender.Window.EditMode()
 		if editmode:
 				self.armatureExporter.export(dir, fixUpAxis, convertXML)
 
 		## export meshdata
-		self._generateSubmeshes(fixUpAxis, materialManager, colouredAmbient, exportMesh)
+		self._generateSubmeshes(fixUpAxis, materialManager, colouredAmbient, applyModifiers, exportMesh)
 
 		if exportMesh:
 			## export vertex animations
 		return self.armatureExporter
 	def getSubmeshManager(self):
 		return self.submeshManager
-	def _generateSubmeshes(self, fixUpAxis, materialManager, colouredAmbient, exportMesh):
+	def _generateSubmeshes(self, fixUpAxis, materialManager, colouredAmbient, applyModifiers, exportMesh):
 		"""Generates submeshes of the mesh.
 		"""
 		#NMesh# Blender.Mesh.Mesh does not provide access to mesh shape keys, use Blender.NMesh.NMesh
-		bMesh = self.bObject.getData(mesh=True)
+		if applyModifiers:
+			bMesh = Blender.Mesh.New('tmp')
+			bMesh.getFromObject(self.bObject)
+		else:
+			bMesh = self.bObject.getData(mesh=True)
 		self.submeshManager = SubmeshManager(bMesh, fixUpAxis, self.armatureExporter)
 		for bMFace in bMesh.faces:
 			faceMaterial = materialManager.getMaterial(bMesh, bMFace, colouredAmbient, self.name)