Revision: 20190 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20190 Author: migius Date: 2009-05-14 01:28:53 +0200 (Thu, 14 May 2009)
Log Message: ----------- Collada scripts updated, patch commited by Jan Smith (collad) [#18726] COLLADA export doesn_t convert names correctly to valid COLLADA id_s: # 2009.05.11 by jan: # - Perfected the id renaming to fulfill at 100.0% the COLLADA standard for allowed UTF-8 # chars. The new renaming method is also much faster then the old one (benchmarked with # Python 2.5). # - Fixed the skeleton/joint controller! # (Corrected the referencing of the # "<skin><source><technique_common>,<accessor source="...">" # attribute. It pointed to its <source> node, and not the array in <source>.) Modified Paths: -------------- trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py trunk/blender/release/scripts/bpymodules/colladaImEx/cutils.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-05-13 22:52:31 UTC (rev 20189) +++ trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py 2009-05-13 23:28:53 UTC (rev 20190) @@ -3485,8 +3485,16 @@ return True def StripString(text): + ''' + Ensures the id names are valid COLLADA ids. + Dots (.) are evaluated as member accessors in COLLADA. + Therefore the renaming from "." to "_" is very important. + See "COLLADA Specification, Schema Concepts 3-3, COLLADA + Target Adressing". + See also cutily.py, translateMap variable docu. + ''' if text != None: - return text.replace(' ','_').replace('.','_') + return MakeIDXMLConform(text) else: return text; Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/cutils.py =================================================================== --- trunk/blender/release/scripts/bpymodules/colladaImEx/cutils.py 2009-05-13 22:52:31 UTC (rev 20189) +++ trunk/blender/release/scripts/bpymodules/colladaImEx/cutils.py 2009-05-13 23:28:53 UTC (rev 20190) @@ -27,7 +27,52 @@ import os import Blender from Blender.Mathutils import * +import string +''' +Translation map. +Used to translate every COLLADA id to a valid id, no matter what "wrong" letters may be +included. Look at the IDREF XSD declaration for more. +Follows strictly the COLLADA XSD declaration which explicitly allows non-english chars, +like special chars (e.g. micro sign), umlauts and so on. +The COLLADA spec also allows additional chars for member access ('.'), these +must obviously be removed too, otherwise they would be heavily misinterpreted. +''' +translateMap = "" + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(45) + chr(95) + chr(95) + \ + chr(48) + chr(49) + chr(50) + chr(51) + chr(52) + chr(53) + chr(54) + chr(55) + \ + chr(56) + chr(57) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(65) + chr(66) + chr(67) + chr(68) + chr(69) + chr(70) + chr(71) + \ + chr(72) + chr(73) + chr(74) + chr(75) + chr(76) + chr(77) + chr(78) + chr(79) + \ + chr(80) + chr(81) + chr(82) + chr(83) + chr(84) + chr(85) + chr(86) + chr(87) + \ + chr(88) + chr(89) + chr(90) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(97) + chr(98) + chr(99) + chr(100) + chr(101) + chr(102) + chr(103) + \ + chr(104) + chr(105) + chr(106) + chr(107) + chr(108) + chr(109) + chr(110) + chr(111) + \ + chr(112) + chr(113) + chr(114) + chr(115) + chr(116) + chr(117) + chr(118) + chr(119) + \ + chr(120) + chr(121) + chr(122) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(183) + \ + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + chr(95) + \ + chr(192) + chr(193) + chr(194) + chr(195) + chr(196) + chr(197) + chr(198) + chr(199) + \ + chr(200) + chr(201) + chr(202) + chr(203) + chr(204) + chr(205) + chr(206) + chr(207) + \ + chr(208) + chr(209) + chr(210) + chr(211) + chr(212) + chr(213) + chr(214) + chr(95) + \ + chr(216) + chr(217) + chr(218) + chr(219) + chr(220) + chr(221) + chr(222) + chr(223) + \ + chr(224) + chr(225) + chr(226) + chr(227) + chr(228) + chr(229) + chr(230) + chr(231) + \ + chr(232) + chr(233) + chr(234) + chr(235) + chr(236) + chr(237) + chr(238) + chr(239) + \ + chr(240) + chr(241) + chr(242) + chr(243) + chr(244) + chr(245) + chr(246) + chr(95) + \ + chr(248) + chr(249) + chr(250) + chr(251) + chr(252) + chr(253) + chr(254) + chr(255) + + #---Classes--- class Debug(object): @@ -316,9 +361,21 @@ print name,"euler: ", newMat.toEuler() print name,"scale: ", newMat.scalePart() +def MakeIDXMLConform(id): + ''' + Make the name/id COLLADA XML/XSD conform. + See StripString and translateMap docu for more information. + ''' + if (len(id) > 0 and id[0] == '#'): + return '#' + string.translate(id[1:], translateMap) + else: + return string.translate(id, translateMap) + def AdjustName(adjustedName): - '''Adjust every name to fit to collada.py's StripString renaming (. -> _) and making - sure the name starts with a letter.''' + ''' + Make the name/id COLLADA XML/XSD conform. + See StripString and translateMap docu for more information. + ''' if len(adjustedName) > 0 and not adjustedName[0].isalpha(): adjustedName = "i"+adjustedName - return adjustedName.replace('.', '_') + return MakeIDXMLConform(adjustedName) Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py =================================================================== --- trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py 2009-05-13 22:52:31 UTC (rev 20189) +++ trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py 2009-05-13 23:28:53 UTC (rev 20190) @@ -24,6 +24,14 @@ # -------------------------------------------------------------------------- # History +# 2009.05.11 by jan: +# - Perfected the id renaming to fulfill at 100.0% the COLLADA standard for allowed UTF-8 +# chars. The new renaming method is also much faster then the old one (benchmarked with +# Python 2.5). +# - Fixed the skeleton/joint controller! +# (Corrected the referencing of the +# "<skin><source><technique_common>,<accessor source="...">" +# attribute. It pointed to its <source> node, and not the array in <source>.) # 2009.04.16 by jan: # - Added the possibility to export models with modifiers (mirrors, transformers, etc.). # - Added helpful messages for users in case something goes wrong, so they know how and @@ -1007,7 +1015,7 @@ jointSourceArray.id = self.document.CreateID(jointSource.id, "-array") jointSource.techniqueCommon.accessor = jointAccessor = collada.DaeAccessor() jointAccessor.AddParam("JOINT",collada.DaeSyntax.IDREF) - jointAccessor.source = jointSource.id + jointAccessor.source = jointSourceArray.id daeSkin.sources.append(jointSource) # And the input for the joints jointInput = collada.DaeInput() @@ -1028,7 +1036,7 @@ weightSourceArray.id = self.document.CreateID(weightSource.id, "-array") weightSource.techniqueCommon.accessor = weightAccessor = collada.DaeAccessor() weightAccessor.AddParam("WEIGHT","float") - weightAccessor.source = weightSource.id + weightAccessor.source = weightSourceArray.id daeSkin.sources.append(weightSource) # And the input for the weights weightInput = collada.DaeInput() @@ -1048,7 +1056,7 @@ poseSource.techniqueCommon.accessor = poseAccessor = collada.DaeAccessor() poseAccessor.AddParam("","float4x4") poseAccessor.stride = 16 - poseAccessor.source = poseSource.id + poseAccessor.source = poseSourceArray.id daeSkin.sources.append(poseSource) # Add the input for the poses poseInput = collada.DaeInput() _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs