[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15969] trunk/blender/release/scripts/ bpymodules/colladaImEx: Collada 1.4 script, importer part:

Remigiusz Fiedler migius at 4d-vectors.de
Tue Aug 5 12:48:17 CEST 2008


Revision: 15969
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15969
Author:   migius
Date:     2008-08-05 12:48:17 +0200 (Tue, 05 Aug 2008)

Log Message:
-----------
Collada 1.4 script, importer part: 
- bugfix/refactor localTransformMatrix usage in hierarchies:
   it preserves local orientation for each child, so imported IPOs are correct working
- upgrade version nr from 0.3.159 to 0.3.160
- bugfix: tiny changes to make it work with DAE files found in differ sources

Modified Paths:
--------------
    trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py
    trunk/blender/release/scripts/bpymodules/colladaImEx/cstartup.py
    trunk/blender/release/scripts/bpymodules/colladaImEx/helperObjects.py
    trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py
    trunk/blender/release/scripts/bpymodules/colladaImEx/xmlUtils.py

Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py	2008-08-05 10:39:13 UTC (rev 15968)
+++ trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py	2008-08-05 10:48:17 UTC (rev 15969)
@@ -169,8 +169,9 @@
 	self.geometriesLibrary.GetItemCount()+
 	self.lightsLibrary.GetItemCount()+
 	##self.materialsLibrary.GetItemCount()+
-	self.nodesLibrary.GetItemCount()##+
-	##self.visualScenesLibrary.GetItemCount()
+	self.nodesLibrary.GetItemCount()+
+	##self.visualScenesLibrary.GetItemCount()+
+	0
 	)
 
 	def __str__(self):
@@ -202,10 +203,13 @@
 	def LoadFromXml(self,daeDocument, xmlNode):
 		if xmlNode is None:
 			return
-
 		self.id = xmlNode.getAttribute(DaeSyntax.ID)
 		self.name = xmlNode.getAttribute(DaeSyntax.NAME)
+		if self.id is None:
+			if debprn: print 'deb: missing Node.ID tag !!!!!****!!!!!'
+			self.id = self.name # TODO: try to repair corrupt xmlNode data
 
+
 	def SaveToXml(self, daeDocument):
 		node = super(DaeElement,self).SaveToXml(daeDocument)
 		SetAttribute(node,DaeSyntax.ID,StripString(self.id))
@@ -479,8 +483,8 @@
 		self.target = xmlUtils.ReadAttribute(xmlNode, DaeSyntax.TARGET)
 
 	def SaveToXml(self, daeDocument):
-#		print 'deb:DaeChannel() self.source=', self.source #-------
-#		print 'deb:DaeChannel() self.target=', self.target #-------
+#		if debprn: print 'deb:DaeChannel() self.source=', self.source #-------
+#		if debprn: print 'deb:DaeChannel() self.target=', self.target #-------
 		node = super(DaeChannel, self).SaveToXml(daeDocument)
 #org		SetAttribute(node, DaeSyntax.SOURCE, StripString('#'+self.source.id))
 		SetAttribute(node, DaeSyntax.SOURCE, StripString('#'+self.source))
@@ -1922,7 +1926,7 @@
 
 	VCOUNT = 'vcount'
 
-	##BIND_MATERIAL = 'bind_material'
+	BIND_MATERIAL = 'bind_material' #---
 	SKELETON = 'skeleton'
 
 	P = 'p'
@@ -2005,7 +2009,7 @@
 	ANIMATION_CLIP = 'animation_clip'
 	GEOMETRY = 'geometry'
 	IMAGE = 'image'
-	##EFFECT = 'effect'
+	EFFECT = 'effect' #---
 	VISUAL_SCENE = 'visual_scene'
 	CONTROLLER = 'controller'
 	MATERIAL = 'material'
@@ -2056,7 +2060,7 @@
 	INSTANCE_ANIMATION = 'instance_animation'
 	INSTANCE_CAMERA = 'instance_camera'
 	INSTANCE_CONTROLLER = 'instance_controller'
-	##INSTANCE_EFFECT = 'instance_effect'
+	INSTANCE_EFFECT = 'instance_effect' #---
 	INSTANCE_GEOMETRY = 'instance_geometry'
 	INSTANCE_LIGHT = 'instance_light'
 	INSTANCE_NODE = 'instance_node'
@@ -2129,20 +2133,20 @@
 	def __init__(self):
 		super(DaeFxBindVertexInput, self).__init__()
 		self.semantic = "CHANNEL1"
-		self.input_semantic = "TEXCOORD";
-		self.input_set = "1";
-		self.syntax = "bind_vertex_input";
+		self.input_semantic = "TEXCOORD"
+		self.input_set = "1"
+		self.syntax = "bind_vertex_input"
 
 	def LoadFromXml(self, daeDocument, xmlNode):
-		self.semantic = xmlUtils.ReadAttribute(xmlNode, "semantic");
-		self.input_set = xmlUtils.ReadAttribute(xmlNode, "input_semantic");
-		self.input_semantic = xmlUtils.ReadAttribute(xmlNode, "input_set");
+		self.semantic = xmlUtils.ReadAttribute(xmlNode, "semantic")
+		self.input_set = xmlUtils.ReadAttribute(xmlNode, "input_semantic")
+		self.input_semantic = xmlUtils.ReadAttribute(xmlNode, "input_set")
 
 	def SaveToXml(self, daeDocument):
 		node = super(DaeFxBindVertexInput,self).SaveToXml(daeDocument)
-		SetAttribute(node, "semantic", self.semantic);
-		SetAttribute(node, "input_semantic", self.input_semantic);
-		SetAttribute(node, "input_set", self.input_set);
+		SetAttribute(node, "semantic", self.semantic)
+		SetAttribute(node, "input_semantic", self.input_semantic)
+		SetAttribute(node, "input_set", self.input_set)
 		return node
 
 
@@ -2255,7 +2259,7 @@
 
 	def SaveToXml(self, daeDocument):
 		node = super(DaeFxSampler2D,self).SaveToXml(daeDocument)
-#		print 'deb:####class DaeFxSampler2D SaveToXml self.source=', self.source #----------
+#		if debprn: print 'deb:####class DaeFxSampler2D SaveToXml self.source=', self.source #----------
 		AppendChild(daeDocument, node, self.source) #bug----
 		AppendChild(daeDocument, node, self.minfilter);
 		AppendChild(daeDocument, node, self.maxfilter);
@@ -3475,10 +3479,10 @@
 	return True
 
 def StripString(text):
-    if text != None:
-	   return text.replace(' ','_').replace('.','_')
-    else:
-        return text;
+	if text != None:
+		return text.replace(' ','_').replace('.','_')
+	else:
+		return text;
 
 def CreateExtra(colladaInstance):
 	if isinstance(colladaInstance, DaeEntity):

Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/cstartup.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/colladaImEx/cstartup.py	2008-08-05 10:39:13 UTC (rev 15968)
+++ trunk/blender/release/scripts/bpymodules/colladaImEx/cstartup.py	2008-08-05 10:48:17 UTC (rev 15969)
@@ -23,8 +23,8 @@
 # ***** END GPL LICENCE BLOCK *****
 # --------------------------------------------------------------------------
 
-#debug = True
-debug = False
+debug = False #--- debug mode
+debprn = False #--- print debug "print 'deb: ..."
 _ERROR = False
 _PERROR = False
 
@@ -36,7 +36,7 @@
 	print "Error! Could not find Blender modules!"
 	_ERROR = True
 
-__version__ = '0.3.159'
+__version__ = '0.3.160'
 
 # Show the wait cursor in blender
 Blender.Window.WaitCursor(1)
@@ -50,13 +50,13 @@
 #defaultFileUrl = 'animation_robot.DAE'
 defaultExportUrl = ''
 
-# Check if full version of python is installed.	
+# Check if full version of python is installed.
 try:
 	import os
 except ImportError:
 	print"Error! Could not find full version of Python..."
 	_ERROR = True
-	
+
 if _ERROR:
 	from sys import version_info
 	version = '%s.%s' % version_info[0:2]
@@ -83,45 +83,45 @@
 	except NameError:
 		print "\nError! Could not find Collada Utils (cutils) module!"
 		_ERROR = True
-	
+
 	try:
 		import xmlUtils
 	except NameError:
 		print "\nError! Could not find XML module!"
 		_PERROR = True
-		
+
 	try:
 		import collada
 	except NameError:
 		print "Error! Could not find Collada(collada.py) module"
 		_PERROR = True
-		
+
 	try:
 		import translator
 	except NameError:
 		print "Error! Could not find Collada Translator (translator.py) module"
 		_PERROR = True
-		
+
 	try:
 		import helperObjects
 	except NameError:
 		print "Error! Could not find Collada helperObjects (helperObjects.py) module"
 		_PERROR = True
-	
+
 	# Try to load extra python modules
 	try:
 		import math
 	except NameError:
 		print "Error! Could not find math module"
 		_PERROR = True
-		
+
 	if _PERROR:
 		Blender.Draw.PupMenu("Cannot load plugin modules.")
 	else:
 		# A List with al the modules (in the scriptsdir) to be reloaded
 		modules = [cutils, xmlUtils, collada, helperObjects, translator]
-		
 
+
 def Main(doImp, scriptsLoc):
 	global debug, __version__, doImport, scriptsLocation, defaultFilename, valsLoaded
 	if _ERROR or _PERROR:
@@ -138,33 +138,33 @@
 			print 'Could not find a scripts path'
 	else:
 		scriptsLocation = scriptsLoc
-	
-	
+
+
 	if not ReloadModules():
 		print 'cannot reload all modules'
 		return False
 	# Clear the console
 	cutils.ClearConsole()
-	
+
 	# set the debuglevel
 	if debug:
 		cutils.Debug.SetLevel('DEBUG')
 	else:
 		cutils.Debug.SetLevel('FEEDBACK')
-	
+
 	cutils.Debug.Debug('Illusoft Collada 1.4 Plugin v%s started'%(__version__),'FEEDBACK')
 	# Create a Collada <-> Blender Translator
 	if debug:
 		print 'keep track of the time to execute this script' #---------
 		startTime = Blender.sys.time()
-		
+
 		##fileurl = scriptsDir
 		fileurl = ''
 		if doImport:
 			fileurl+= defaultFileUrl
 		else :
 			fileurl += defaultExportUrl
-		print 'deb: fileurl=',fileurl #-------
+		if debprn: print 'deb: fileurl=',fileurl #-------
 
 		useTriangles = False
 		usePolygons = False
@@ -181,37 +181,37 @@
 		onlyMainScene = False
 
 		transl = translator.Translator(doImport,__version__,debug,fileurl, useTriangles, usePolygons, bakeMatrices, exportSelection, newScene, clearScene, lookAt, usePhysics, exportCurrentScene, exportRelativePaths, useUV, sampleAnimation, onlyMainScene)
-	
-		##transl = translator.Translator(doImport,__version__,debug,fileurl)		  
-		##translator = Translator(False,__version__,debug,scriptsDir+defaultExportUrl)		  
+
+		##transl = translator.Translator(doImport,__version__,debug,fileurl)
+		##translator = Translator(False,__version__,debug,scriptsDir+defaultExportUrl)
 		##translator = Translator(True,__version__,debug,scriptsDir+defaultExportUrl)
 		# Redraw al 3D windows.
-		print 'deb: ---- the end ----' #-----
-		Blender.Window.RedrawAll()	  
-		
+		if debprn: print 'deb: ---- the end ----' #-----
+		Blender.Window.RedrawAll()
+
 		# calculate the elapsed time
 		endTime = Blender.sys.time()
 		elapsedTime = endTime - startTime
 		cutils.Debug.Debug('FINISHED - time elapsed: %.1f'%(elapsedTime),'FEEDBACK')
-		
+
 		# Hide the wait cursor in blender
 		Blender.Window.WaitCursor(0)
 	else:
 		defFilename = Blender.sys.dirname(Blender.sys.progname)+Blender.sys.sep
 		colladaReg = Blender.Registry.GetKey('collada',True)
-			
+
 		if not (colladaReg is None) and 'path' in colladaReg and Blender.sys.exists(colladaReg['path']):
 			defFilename = colladaReg['path']
 		elif not (doImport):
 			defFilename += 'untitled.dae'
-		
+
 		defaultFilename = defFilename
-		
+
 		Blender.Draw.Register(Gui, Event, ButtonEvent)	# registering the 3 callbacks
-	
-def ReloadModules():	
+
+def ReloadModules():
 	# Loop through all the modules and try to reload them
-	for module in modules:		  
+	for module in modules:
 		try:
 			reload(module)
 		except NameError:
@@ -221,13 +221,13 @@
 
 def FileSelected(fileName):
 	global doImport, fileButton
-	
+
 	if fileName != '':
 		# check if file exists
 		if Blender.sys.exists(fileName) != 1 and doImport:
 			cutils.Debug.Debug('File(%s) does not exist' % (fileName),'ERROR')
 			return False
-		
+
 		# must the file to import end with .dae or .xml?
 ##		  if doImport:
 ##			  # Check if the file has a valid extension .DAE or .XML
@@ -235,7 +235,7 @@
 ##			  if extension != 'xml' and extension != 'dae':
 ##				  cutils.Debug.Debug('File(%s) is not a .dae or .xml file' % (fileName),'ERROR')
 		fileButton.val = fileName
-		##transl = translator.Translator(doImport,__version__,debug,fileName)			
+		##transl = translator.Translator(doImport,__version__,debug,fileName)
 	else:
 		cutils.Debug.Debug('ERROR: filename is empty','ERROR')
 
@@ -258,10 +258,10 @@
 
 def LoadDefaultVals():

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list