[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22712] trunk/blender/release/scripts/ bpymodules/colladaImEx: patch submitted by Nicolai Wojke (nicoooo)

Remigiusz Fiedler migius at gmx.net
Sun Aug 23 01:59:51 CEST 2009


Revision: 22712
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22712
Author:   migius
Date:     2009-08-23 01:59:50 +0200 (Sun, 23 Aug 2009)

Log Message:
-----------
patch submitted by Nicolai Wojke (nicoooo) 
[#19244] Collada importer fixes (for increased Sketchup interoperability and more)
It seems to be correct, i have here no right dae files for testing exactly this functionality.
migius

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

Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py	2009-08-22 17:50:10 UTC (rev 22711)
+++ trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py	2009-08-22 23:59:50 UTC (rev 22712)
@@ -108,6 +108,10 @@
 		self.physicsModelsLibrary.LoadFromXml(self, xmlUtils.FindElementByTagName(colladaNode, DaeSyntax.LIBRARY_PHYSICS_MODELS))
 		self.physicsScenesLibrary.LoadFromXml(self, xmlUtils.FindElementByTagName(colladaNode, DaeSyntax.LIBRARY_PHYSICS_SCENES))
 
+		# establish instance references in nodes library
+		for node in self.nodesLibrary.items:
+			node.LinkInstances(self)
+
 		# Get the sceneNodes
 		sceneNodes = colladaNode.getElementsByTagName(DaeSyntax.SCENE)
 
@@ -1165,6 +1169,25 @@
 		self.extras = []
 		self.syntax = DaeSyntax.NODE
 
+	def LinkInstances(self, daeDocument):
+		for iAnimation in self.iAnimations:
+			iAnimation.AssignLink(daeDocument.animationsLibrary)
+		for iCamera in self.iCameras:
+			iCamera.AssignLink(daeDocument.cameraLibrary)
+		for iController in self.iControllers:
+			iController.AssignLink(daeDocument.controllersLibrary)
+		for iGeometry in self.iGeometries:
+			iGeometry.AssignLink(daeDocument.geometriesLibrary)
+		for iLight in self.iLights:
+			iLight.AssignLink(daeDocument.lightsLibrary)
+		for iNode in self.iNodes:
+			iNode.AssignLink(daeDocument.nodesLibrary)
+		for iVisualScene in self.iVisualScenes:
+			iVisualScene.AssignLink(daeDocument.visualScenesLibrary)
+
+		for node in self.nodes:
+			node.LinkInstances(daeDocument)
+
 	def LoadFromXml(self, daeDocument, xmlNode):
 		super(DaeNode, self).LoadFromXml(daeDocument, xmlNode)
 		self.sid = xmlUtils.ReadAttribute(xmlNode, DaeSyntax.SID)
@@ -1769,6 +1792,9 @@
 		self.extras = []
 		self.object = None
 
+	def AssignLink(self, daeLibrary):
+		self.object = daeLibrary.FindObject(self.url)
+
 	def LoadFromXml(self, daeDocument, xmlNode):
 		self.url = ReadNodeUrl(xmlNode)
 		self.extras = CreateObjectsFromXml(daeDocument, xmlNode, DaeSyntax.EXTRA, DaeExtra)
@@ -1997,7 +2023,7 @@
 	LIBRARY_IMAGES = 'library_images'
 	LIBRARY_LIGHTS = 'library_lights'
 	LIBRARY_MATERIALS = 'library_materials'
-	LIBRARY_NODES = 'library_NODES'
+	LIBRARY_NODES = 'library_nodes'
 	LIBRARY_PHYSICS_MATERIALS = 'library_physics_materials'
 	LIBRARY_PHYSICS_MODELS = 'library_physics_models'
 	LIBRARY_PHYSICS_SCENES = 'library_physics_scenes'
@@ -3460,7 +3486,6 @@
 	attribute = xmlUtils.ReadAttribute(node,DaeSyntax.URL)
 	if attribute == None: return None
 	else :
-		attribute = str(attribute)
 		if attribute.startswith('#'):
 			return attribute[1:]
 	return None

Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/cstartup.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/colladaImEx/cstartup.py	2009-08-22 17:50:10 UTC (rev 22711)
+++ trunk/blender/release/scripts/bpymodules/colladaImEx/cstartup.py	2009-08-22 23:59:50 UTC (rev 22712)
@@ -36,7 +36,7 @@
 	print "Error! Could not find Blender modules!"
 	_ERROR = True
 
-__version__ = '0.3.161'
+__version__ = '0.3.162'
 
 # Show the wait cursor in blender
 Blender.Window.WaitCursor(1)

Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py	2009-08-22 17:50:10 UTC (rev 22711)
+++ trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py	2009-08-22 23:59:50 UTC (rev 22712)
@@ -6,6 +6,7 @@
 # Copyright (C) 2006: Illusoft - colladablender at illusoft.com
 #    - 2008.08: multiple bugfixes by migius (AKA Remigiusz Fiedler)
 #    - 2009.05: bugfixes by jan (AKA Jan Diederich)
+#    - 2009.08: bugfixed by nico (AKA Nicolai Wojke, Labor Bilderkennen Uni-Koblenz)
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,6 +26,14 @@
 # --------------------------------------------------------------------------
 
 # History
+# 2009.08.22 by nico:
+# - Fixed a bug where visual scene nodes containing instances of nodes in the nodes library, 
+#   which themselves instantiate geometry in the geometry library, where not imported
+#   correctly (only the node instantiation was created, not the geometry)
+# - Fixed a bug where nodes in the nodes library that have children instantiating other
+#   nodes in the nodes library where not resolved properly. Added a post-library-creation
+#   phase where DaeInstance object references are updated after the entire library is created
+# - Changed nodes library syntax from 'library_NODES' to 'library_nodes'
 # 2009.05.17 by jan:
 # - More information for the user if an error happened (wrong/missing parenting).
 # - Added a progress bar for export (bar for import already exists). 
@@ -2030,9 +2039,21 @@
 
 		childlist = []
 		for daeChild in daeNode.nodes:
-			childSceneNode = SceneNode(self.document,self)
-			object = childSceneNode.ObjectFromDae(daeChild)
-			if object: childlist.append(object)
+			try:
+				childSceneNode = SceneNode(self.document,self)
+				object = childSceneNode.ObjectFromDae(daeChild)
+				if object: childlist.append(object)
+			except NameError:
+				if debprn: print "a child of node " + daeNode.id + " has no id ? ?"
+		for iDaeChild in daeNode.iNodes:
+			try:
+				childSceneNode = SceneNode(self.document,self)
+				object = childSceneNode.ObjectFromDae(iDaeChild.object)
+				if object:
+					newObject.makeParent([object], noninverse , 1)
+					childlist.append(object)
+			except NoneType:
+				if debprn: print "a child instance of node " + daeNode.id + " has no id ? ?"
 
 		if newObject:
 			if not self.isJoint and not self.armature:





More information about the Bf-blender-cvs mailing list