OSDN Git Service

接続ボーンを持たない剛体に対処。
[mikutoga/TogaGem.git] / src / main / java / jp / sourceforge / mikutoga / pmd / xml / Xml2PmdLoader.java
index ae48ea7..84d15c0 100644 (file)
@@ -90,7 +90,7 @@ public class Xml2PmdLoader {
      * @param elem 要素\r
      * @param attrName 属性名\r
      * @return 文字列\r
-     * @throw TogaXmlException 属性値が見つからなかった。\r
+     * @throws TogaXmlException 属性値が見つからなかった。\r
      */\r
     private static String getStringAttr(Element elem, String attrName)\r
             throws TogaXmlException{\r
@@ -102,7 +102,7 @@ public class Xml2PmdLoader {
      * @param elem 要素\r
      * @param attrName 属性名\r
      * @return 真ならtrue\r
-     * @throw TogaXmlException 属性値が見つからなかった。\r
+     * @throws TogaXmlException 属性値が見つからなかった。\r
      */\r
     private static boolean getBooleanAttr(Element elem, String attrName)\r
             throws TogaXmlException{\r
@@ -114,7 +114,7 @@ public class Xml2PmdLoader {
      * @param elem 要素\r
      * @param attrName 属性名\r
      * @return int値\r
-     * @throw TogaXmlException 属性値が見つからなかった。\r
+     * @throws TogaXmlException 属性値が見つからなかった。\r
      */\r
     private static int getIntegerAttr(Element elem, String attrName)\r
             throws TogaXmlException{\r
@@ -126,7 +126,7 @@ public class Xml2PmdLoader {
      * @param elem 要素\r
      * @param attrName 属性名\r
      * @return float値\r
-     * @throw TogaXmlException 属性値が見つからなかった。\r
+     * @throws TogaXmlException 属性値が見つからなかった。\r
      */\r
     private static float getFloatAttr(Element elem, String attrName)\r
             throws TogaXmlException{\r
@@ -139,7 +139,7 @@ public class Xml2PmdLoader {
      * @param elem 要素\r
      * @param attrName 属性名\r
      * @return ファイル名\r
-     * @throw TogaXmlException 属性値が見つからなかった。\r
+     * @throws TogaXmlException 属性値が見つからなかった。\r
      */\r
     private static String getSjisFileNameAttr(Element elem, String attrName)\r
             throws TogaXmlException{\r
@@ -151,7 +151,7 @@ public class Xml2PmdLoader {
      * @param parent 親要素\r
      * @param tagName 子要素名\r
      * @return 子要素\r
-     * @throw TogaXmlException 1つも見つからなかった\r
+     * @throws TogaXmlException 1つも見つからなかった\r
      */\r
     private static Element getChild(Element parent, String tagName)\r
             throws TogaXmlException{\r
@@ -179,6 +179,12 @@ public class Xml2PmdLoader {
         return DomUtils.getEachChild(parent, childTag);\r
     }\r
 \r
+    /**\r
+     * グローバル名を取得する。\r
+     * 元要素のname属性及びi18nNameタグを持つ子要素が検索対象\r
+     * @param parent 元要素\r
+     * @return グローバル名。なければnull\r
+     */\r
     private static String getGlobalName(Element parent){\r
         NodeList nodeList = parent.getElementsByTagName("i18nName");\r
         int length = nodeList.getLength();\r
@@ -232,6 +238,12 @@ public class Xml2PmdLoader {
         return result.toString();\r
     }\r
 \r
+    /**\r
+     * 多言語名を取得する。\r
+     * @param baseElement 元要素\r
+     * @param text 多言語名\r
+     * @throws TogaXmlException あるべき属性が存在しない。\r
+     */\r
     private static void buildI18nName(Element baseElement, I18nText text)\r
             throws TogaXmlException{\r
         String primaryText;\r
@@ -251,6 +263,14 @@ public class Xml2PmdLoader {
         return;\r
     }\r
 \r
+    /**\r
+     * XMLのパースを開始する。\r
+     * @param source XML入力\r
+     * @return モデルデータ\r
+     * @throws SAXException 構文エラー\r
+     * @throws IOException 入力エラー\r
+     * @throws TogaXmlException 構文エラー\r
+     */\r
     public PmdModel parse(InputSource source)\r
             throws SAXException, IOException, TogaXmlException{\r
         Document document = this.builder.parse(source);\r
@@ -462,7 +482,8 @@ public class Xml2PmdLoader {
         for(Element surfaceGroupElem :\r
             eachChild(surfaceGroupListElem, "surfaceGroup") ){\r
 \r
-            String groupId = getStringAttr(surfaceGroupElem, "surfaceGroupId");\r
+            String groupId =\r
+                    getStringAttr(surfaceGroupElem, "surfaceGroupId");\r
             List<Surface> surfaceList = buildSurface(surfaceGroupElem);\r
 \r
             this.surfaceGroupMap.put(groupId, surfaceList);\r
@@ -587,7 +608,8 @@ public class Xml2PmdLoader {
             ikChainList.add(ikChain);\r
 \r
             String ikBoneIdRef = getStringAttr(ikChainElem, "ikBoneIdRef");\r
-            int rucursiveDepth = getIntegerAttr(ikChainElem, "recursiveDepth");\r
+            int rucursiveDepth =\r
+                    getIntegerAttr(ikChainElem, "recursiveDepth");\r
             float weight = getFloatAttr(ikChainElem, "weight");\r
 \r
             BoneInfo ikBone = this.boneMap.get(ikBoneIdRef);\r
@@ -624,9 +646,11 @@ public class Xml2PmdLoader {
             MorphType morphType = MorphType.valueOf(type);\r
             morphPart.setMorphType(morphType);\r
 \r
-            List<MorphVertex> morphVertexList = morphPart.getMorphVertexList();\r
+            List<MorphVertex> morphVertexList =\r
+                    morphPart.getMorphVertexList();\r
 \r
-            for(Element morphVertexElem : eachChild(morphElem, "morphVertex")){\r
+            for(Element morphVertexElem\r
+                    : eachChild(morphElem, "morphVertex")){\r
                 String vtxIdRef = getStringAttr(morphVertexElem, "vtxIdRef");\r
                 Vertex baseVertex = this.vertexMap.get(vtxIdRef);\r
                 float xOff = getFloatAttr(morphVertexElem, "xOff");\r
@@ -675,15 +699,18 @@ public class Xml2PmdLoader {
         BoneGroup defaultGroup = new BoneGroup();\r
         boneGroupList.add(defaultGroup);\r
 \r
-        for(Element boneGroupElem : eachChild(boneGroupListElem, "boneGroup")){\r
+        for(Element boneGroupElem\r
+                : eachChild(boneGroupListElem, "boneGroup")){\r
             BoneGroup group = new BoneGroup();\r
             boneGroupList.add(group);\r
 \r
             I18nText name = group.getGroupName();\r
             buildI18nName(boneGroupElem, name);\r
 \r
-            for(Element boneGroupMemberElem : eachChild(boneGroupElem, "boneGroupMember")){\r
-                String boneIdRef = getStringAttr(boneGroupMemberElem, "boneIdRef");\r
+            for(Element boneGroupMemberElem\r
+                    : eachChild(boneGroupElem, "boneGroupMember")){\r
+                String boneIdRef =\r
+                        getStringAttr(boneGroupMemberElem, "boneIdRef");\r
                 BoneInfo bone = this.boneMap.get(boneIdRef);\r
                 group.getBoneList().add(bone);\r
             }\r
@@ -715,10 +742,12 @@ public class Xml2PmdLoader {
             String rigidId = getStringAttr(rigidElem, "rigidId");\r
             this.rigidMap.put(rigidId, rigid);\r
 \r
-            Element linkedBoneElem = getChild(rigidElem, "linkedBone");\r
-            String boneIdRef = getStringAttr(linkedBoneElem, "boneIdRef");\r
-            BoneInfo linkedBone = this.boneMap.get(boneIdRef);\r
-            rigid.setLinkedBone(linkedBone);\r
+            if(hasChild(rigidElem, "linkedBone")){\r
+                Element linkedBoneElem = getChild(rigidElem, "linkedBone");\r
+                String boneIdRef = getStringAttr(linkedBoneElem, "boneIdRef");\r
+                BoneInfo linkedBone = this.boneMap.get(boneIdRef);\r
+                rigid.setLinkedBone(linkedBone);\r
+            }\r
 \r
             RigidShape rigidShape = rigid.getRigidShape();\r
             if(hasChild(rigidElem, "rigidShapeSphere")){\r
@@ -773,8 +802,10 @@ public class Xml2PmdLoader {
 \r
             Element dynamicsElem = getChild(rigidElem, "dynamics");\r
             float mass = getFloatAttr(dynamicsElem, "mass");\r
-            float dampingPosition = getFloatAttr(dynamicsElem, "dampingPosition");\r
-            float dampingRotation = getFloatAttr(dynamicsElem, "dampingRotation");\r
+            float dampingPosition =\r
+                    getFloatAttr(dynamicsElem, "dampingPosition");\r
+            float dampingRotation =\r
+                    getFloatAttr(dynamicsElem, "dampingRotation");\r
             float restitution = getFloatAttr(dynamicsElem, "restitution");\r
             float friction = getFloatAttr(dynamicsElem, "friction");\r
             DynamicsInfo dynamics = rigid.getDynamicsInfo();\r
@@ -797,14 +828,17 @@ public class Xml2PmdLoader {
 \r
         List<RigidGroup> groupList = this.model.getRigidGroupList();\r
 \r
-        for(Element rigidGroupElem : eachChild(rigidGroupListElem, "rigidGroup")){\r
+        for(Element rigidGroupElem\r
+                : eachChild(rigidGroupListElem, "rigidGroup")){\r
             RigidGroup rigidGroup = new RigidGroup();\r
             groupList.add(rigidGroup);\r
 \r
-            String rigidGroupId = getStringAttr(rigidGroupElem, "rigidGroupId");\r
+            String rigidGroupId =\r
+                    getStringAttr(rigidGroupElem, "rigidGroupId");\r
             this.rigidGroupMap.put(rigidGroupId, rigidGroup);\r
 \r
-            for(Element memberElem : eachChild(rigidGroupElem, "rigidGroupMember")){\r
+            for(Element memberElem\r
+                    : eachChild(rigidGroupElem, "rigidGroupMember")){\r
                 String rigidIdRef = getStringAttr(memberElem, "rigidIdRef");\r
                 RigidInfo rigid = this.rigidMap.get(rigidIdRef);\r
                 rigidGroup.getRigidList().add(rigid);\r
@@ -832,7 +866,8 @@ public class Xml2PmdLoader {
         int serialNum = 0;\r
         for(Element rigidElem : eachChild(rigidListElem, "rigid")){\r
             RigidInfo rigid = rigidList.get(serialNum++);\r
-            for(Element groupElem : eachChild(rigidElem, "throughRigidGroup")){\r
+            for(Element groupElem\r
+                    : eachChild(rigidElem, "throughRigidGroup")){\r
                 String groupId = getStringAttr(groupElem, "rigidGroupIdRef");\r
                 RigidGroup group = this.rigidGroupMap.get(groupId);\r
                 rigid.getThroughGroupColl().add(group);\r
@@ -916,7 +951,8 @@ public class Xml2PmdLoader {
             limitRotation.setZRange(zFrom, zTo);\r
 \r
             Pos3d elasticPosition = joint.getElasticPosition();\r
-            Element elasticPositionElem = getChild(jointElem, "elasticPosition");\r
+            Element elasticPositionElem =\r
+                    getChild(jointElem, "elasticPosition");\r
             xVal = getFloatAttr(elasticPositionElem, "x");\r
             yVal = getFloatAttr(elasticPositionElem, "y");\r
             zVal = getFloatAttr(elasticPositionElem, "z");\r
@@ -925,7 +961,8 @@ public class Xml2PmdLoader {
             elasticPosition.setZPos(zVal);\r
 \r
             Deg3d elasticRotation = joint.getElasticRotation();\r
-            Element elasticRotationElem = getChild(jointElem, "elasticRotation");\r
+            Element elasticRotationElem =\r
+                    getChild(jointElem, "elasticRotation");\r
             xVal = getFloatAttr(elasticRotationElem, "xDeg");\r
             yVal = getFloatAttr(elasticRotationElem, "yDeg");\r
             zVal = getFloatAttr(elasticRotationElem, "zDeg");\r