X-Git-Url: http://git.osdn.net/view?p=mikutoga%2FPmd2XML.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fjp%2Fsfjp%2Fmikutoga%2Fpmd%2Fxml%2FPmdXmlExporter.java;fp=src%2Fmain%2Fjava%2Fjp%2Fsfjp%2Fmikutoga%2Fpmd%2Fxml%2FPmdXmlExporter.java;h=0000000000000000000000000000000000000000;hp=e1491293f977a0074937bd2d96c01105b722fd13;hb=b12782f3ce4b78faa618062b553cca3db556b406;hpb=d74afe519c138ab46218508457298a1dee92453b
diff --git a/src/main/java/jp/sfjp/mikutoga/pmd/xml/PmdXmlExporter.java b/src/main/java/jp/sfjp/mikutoga/pmd/xml/PmdXmlExporter.java
deleted file mode 100644
index e149129..0000000
--- a/src/main/java/jp/sfjp/mikutoga/pmd/xml/PmdXmlExporter.java
+++ /dev/null
@@ -1,1425 +0,0 @@
-/*
- * pmd-xml exporter
- *
- * License : The MIT License
- * Copyright(c) 2010 MikuToga Partners
- */
-
-package jp.sfjp.mikutoga.pmd.xml;
-
-import java.awt.Color;
-import java.io.IOException;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import jp.sfjp.mikutoga.corelib.I18nText;
-import jp.sfjp.mikutoga.math.MkPos2D;
-import jp.sfjp.mikutoga.math.MkPos3D;
-import jp.sfjp.mikutoga.math.MkVec3D;
-import jp.sfjp.mikutoga.pmd.BoneType;
-import jp.sfjp.mikutoga.pmd.Deg3d;
-import jp.sfjp.mikutoga.pmd.MorphType;
-import jp.sfjp.mikutoga.pmd.Rad3d;
-import jp.sfjp.mikutoga.pmd.RigidShapeType;
-import jp.sfjp.mikutoga.pmd.TripletRange;
-import jp.sfjp.mikutoga.pmd.model.BoneGroup;
-import jp.sfjp.mikutoga.pmd.model.BoneInfo;
-import jp.sfjp.mikutoga.pmd.model.DynamicsInfo;
-import jp.sfjp.mikutoga.pmd.model.IKChain;
-import jp.sfjp.mikutoga.pmd.model.JointInfo;
-import jp.sfjp.mikutoga.pmd.model.Material;
-import jp.sfjp.mikutoga.pmd.model.MorphPart;
-import jp.sfjp.mikutoga.pmd.model.MorphVertex;
-import jp.sfjp.mikutoga.pmd.model.PmdModel;
-import jp.sfjp.mikutoga.pmd.model.RigidGroup;
-import jp.sfjp.mikutoga.pmd.model.RigidInfo;
-import jp.sfjp.mikutoga.pmd.model.RigidShape;
-import jp.sfjp.mikutoga.pmd.model.SerialNumbered;
-import jp.sfjp.mikutoga.pmd.model.ShadeInfo;
-import jp.sfjp.mikutoga.pmd.model.Surface;
-import jp.sfjp.mikutoga.pmd.model.ToonMap;
-import jp.sfjp.mikutoga.pmd.model.Vertex;
-import jp.sourceforge.mikutoga.xml.BasicXmlExporter;
-import jp.sourceforge.mikutoga.xml.XmlResourceResolver;
-
-/**
- * 101009å½¢å¼XMLã§PMDã¢ãã«ãã¼ã¿ãåºåããã
- */
-public class PmdXmlExporter extends BasicXmlExporter{
-
- private static final String TOP_COMMENT =
- " MikuMikuDance\n"
- + " model-data(*.pmd) on XML";
-
- /** æ¹è¡æåå CRã */
- private static final String CR = "\r"; // 0x0d
- /** æ¹è¡æåå LFã */
- private static final String LF = "\n"; // 0x0a
- /** æ¹è¡æåå CRLFã */
- private static final String CRLF = CR + LF; // 0x0d, 0x0a
-
- private static final String PFX_SURFACEGROUP = "sg";
- private static final String PFX_TOONFILE = "tf";
- private static final String PFX_VERTEX = "vtx";
- private static final String PFX_BONE = "bn";
- private static final String PFX_RIGID = "rd";
- private static final String PFX_RIGIDGROUP = "rg";
-
- private static final String BONETYPE_COMMENT =
- "Bone types:\n"
- + "[0 : ROTATE : Rotate : å転 :]\n"
- + "[1 : ROTMOV : Rotate/Move : å転/移å :]\n"
- + "[2 : IK : IK : IK :]\n"
- + "[3 : UNKNOWN : Unknown : ä¸æ :]\n"
- + "[4 : UNDERIK : Under IK : IKå½±é¿ä¸(å転) :]\n"
- + "[5 : UNDERROT : Under rotate : å転影é¿ä¸ :]\n"
- + "[6 : IKCONNECTED : IK connected : IKæ¥ç¶å
:]\n"
- + "[7 : HIDDEN : Hidden : é表示 :]\n"
- + "[8 : TWIST : Twist : æ©ã :]\n"
- + "[9 : LINKEDROT : Linked Rotate: å転é£å :]\n";
-
- private static final String MORPHTYPE_COMMENT =
- "Morph types:\n"
- + "[1 : EYEBROW : ã¾ã ]\n"
- + "[2 : EYE : ç® ]\n"
- + "[3 : LIP : ãªãã ]\n"
- + "[4 : EXTRA : ãã®ä» ]\n";
-
- private static final String RIGIDBEHAVIOR_COMMENT =
- "Rigid behavior types:\n"
- + "[0 : FOLLOWBONE : ãã¼ã³è¿½å¾ ]\n"
- + "[1 : ONLYDYNAMICS : ç©çæ¼ç® ]\n"
- + "[2 : BONEDDYNAMICS : ãã¼ã³ä½ç½®åãã ]\n";
-
- private static final Locale DEF_LOCALE = Locale.JAPANESE;
-
-
- private String generator = null;
-
- private XmlModelFileType xmlType = XmlModelFileType.XML_101009;
-
-
- /**
- * ã³ã³ã¹ãã©ã¯ã¿ã
- */
- public PmdXmlExporter(){
- super();
- return;
- }
-
-
- /**
- * åºåXMLãã¡ã¤ã«ç¨®å¥ãè¿ãã
- * @return ãã¡ã¤ã«ç¨®å¥
- */
- public XmlModelFileType getXmlFileType(){
- return this.xmlType;
- }
-
- /**
- * åºåXMLãã¡ã¤ã«ç¨®å¥ãè¨å®ããã
- * @param type ãã¡ã¤ã«ç¨®å¥
- */
- public void setXmlFileType(XmlModelFileType type){
- switch(type){
- case XML_101009:
- case XML_130128:
- this.xmlType = type;
- break;
- case XML_AUTO:
- this.xmlType = XmlModelFileType.XML_130128;
- break;
- default:
- throw new IllegalArgumentException();
- }
-
- assert this.xmlType == XmlModelFileType.XML_101009
- || this.xmlType == XmlModelFileType.XML_130128;
-
- return;
- }
-
- /**
- * Generatorã¡ã¿æ
å ±ãè¨å®ããã
- * @param generatorArg Generatorã¡ã¿æ
å ±ã表示ããããªãã¨ãã¯null
- */
- public void setGenerator(String generatorArg){
- this.generator = generatorArg;
- return;
- }
-
- /**
- * ä»»æã®æååãBasicLatinæåã®ã¿ããæ§æããããå¤å®ããã
- * @param seq æåå
- * @return nullãé·ã0ãããã¯BasicLatinæåã®ã¿ããæ§æããããªãtrue
- */
- public static boolean hasOnlyBasicLatin(CharSequence seq){
- if(seq == null) return true;
- int length = seq.length();
- for(int pos = 0; pos < length; pos++){
- char ch = seq.charAt(pos);
- if(ch > 0x007f) return false;
- }
- return true;
- }
-
- /**
- * {@inheritDoc}
- * @return {@inheritDoc}
- * @throws IOException {@inheritDoc}
- */
- @Override
- public PmdXmlExporter ind() throws IOException{
- super.ind();
- return this;
- }
-
- /**
- * æååç
§ã«ããã¨ã¹ã±ã¼ããè£ä½ããããã®ã³ã¡ã³ããåºåããã
- * @param seq æåå
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- protected PmdXmlExporter putUnescapedComment(CharSequence seq)
- throws IOException{
- if( ! isBasicLatinOnlyOut() ) return this;
- if(hasOnlyBasicLatin(seq)) return this;
- sp().putLineComment(seq);
- return this;
- }
-
- /**
- * å¤è¨èªåãããå種èå¥åãåºåããã
- * ãã©ã¤ããªåã¯åºå対象å¤ã
- * @param text å¤è¨èªæåå
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- protected PmdXmlExporter putI18nName(I18nText text) throws IOException{
- for(String lang639 : text.lang639CodeList()){
- if(lang639.equals(I18nText.CODE639_PRIMARY)) continue;
- String name = text.getI18nText(lang639);
- ind().putRawText("");
- putUnescapedComment(name);
- ln();
- }
- return this;
- }
-
- /**
- * çªå·ä»ããããID(IDREF)å±æ§ãåºåããã
- * @param attrName å±æ§å
- * @param prefix IDãã¬ãã£ã¯ã¹
- * @param num çªå·
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- protected PmdXmlExporter putNumberedIdAttr(CharSequence attrName,
- CharSequence prefix,
- int num )
- throws IOException{
- putRawText(attrName).putRawText("=\"");
- putRawText(prefix).putXsdInt(num);
- putRawCh('"');
- return this;
- }
-
- /**
- * çªå·ä»ããããID(IDREF)å±æ§ãåºåããã
- * @param attrName å±æ§å
- * @param prefix IDãã¬ãã£ã¯ã¹
- * @param numbered çªå·ä»ãããããªãã¸ã§ã¯ã
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- protected PmdXmlExporter putNumberedIdAttr(CharSequence attrName,
- CharSequence prefix,
- SerialNumbered numbered )
- throws IOException{
- putNumberedIdAttr(attrName, prefix, numbered.getSerialNumber());
- return this;
- }
-
- /**
- * ä½ç½®æ
å ±ãåºåããã
- * @param position ä½ç½®æ
å ±
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- protected PmdXmlExporter putPosition(MkPos3D position)
- throws IOException{
- putRawText("");
- return this;
- }
-
- /**
- * 姿å¢æ
å ±(ã©ã¸ã¢ã³)ãåºåããã
- * @param rotation 姿å¢æ
å ±
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- protected PmdXmlExporter putRadRotation(Rad3d rotation)
- throws IOException{
- putRawText("");
- return this;
- }
-
- /**
- * å¤è¨èªèå¥åå±æ§ã®ãã¼ã«ã«ãªååãã³ã¡ã³ãåºåããã
- * @param name å¤è¨èªèå¥å
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- protected PmdXmlExporter putLocalNameComment(I18nText name)
- throws IOException{
- String localName = name.getText();
- if(localName.isEmpty()){
- localName = "[NAMELESS]";
- }
- ind().putLineComment(localName);
- return this;
- }
-
- /**
- * å¤è¨èªèå¥åå±æ§ã®ãã©ã¤ããªãªååãåºåããã
- * @param attrName å±æ§å
- * @param name å¤è¨èªèå¥å
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- protected PmdXmlExporter putPrimaryNameAttr(CharSequence attrName,
- I18nText name)
- throws IOException{
- String primaryName = name.getPrimaryText();
- putAttr(attrName, primaryName);
- return this;
- }
-
- /**
- * PMDã¢ãã«ãã¼ã¿ãXMLå½¢å¼ã§åºåããã
- * @param model PMDã¢ãã«ãã¼ã¿
- * @param xmlOut XMLåºåå
- * @throws IOException åºåã¨ã©ã¼
- */
- public void putPmdModel(PmdModel model, Appendable xmlOut)
- throws IOException{
- setAppendable(xmlOut);
-
- ind().putRawText("").ln(2);
-
- ind().putBlockComment(TOP_COMMENT).ln(2);
-
- I18nText modelName = model.getModelName();
- ind().putLocalNameComment(modelName).ln();
- ind().putRawText("").ln(2);
-
- putModelInfo(model).flush();
- putMetaInfo(model).flush();
- putMaterialList(model).flush();
- putToonMap(model).flush();
- putBoneList(model).flush();
- putBoneGroupList(model).flush();
- putIKChainList(model).flush();
- putMorphList(model).flush();
- putRigidList(model).flush();
- putRigidGroupList(model).flush();
- putJointList(model).flush();
- putSurfaceGroupList(model).flush();
- putVertexList(model).flush();
-
- ind().putRawText("").ln(2);
- ind().putRawText("").ln();
-
- return;
- }
-
- /**
- * ã¢ãã«åºæ¬æ
å ±ãåºåããã
- * @param model ã¢ãã«æ
å ±
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putModelInfo(PmdModel model)
- throws IOException{
- I18nText modelName = model.getModelName();
- putI18nName(modelName);
- ln();
-
- I18nText description = model.getDescription();
- for(String lang639 : description.lang639CodeList()){
- String descText = description.getI18nText(lang639);
- putDescription(lang639, descText);
- ln();
- }
-
- return this;
- }
-
- /**
- * ã¢ãã«è©³ç´°ããã¹ããåºåããã
- * @param lang639 è¨èªã³ã¼ã
- * @param content 詳細å
容
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putDescription(CharSequence lang639,
- CharSequence content)
- throws IOException{
- String text = content.toString();
- text = text.replace(CRLF, LF);
- text = text.replace(CR, LF);
-
- ind().putRawText("").ln();
-
- putBRedContent(text);
-
- ind().putRawText("").ln();
-
- if( ! hasOnlyBasicLatin(text) && isBasicLatinOnlyOut() ){
- putBlockComment(text);
- }
-
- return this;
- }
-
- /**
- * breakè¦ç´ ãå«ãè¦ç´ å
容ãåºåããã
- * å¿
è¦ã«å¿ãã¦XMLå®ç¾©æ¸ã¿å®ä½æåãå²ãæ¯ãããæåã
- * ã³ã³ããã¼ã«ã³ã¼ããããã³éBasicLatinæåãã¨ã¹ã±ã¼ããããã
- * \nã¯brã¿ã°ã«å¤æãããã
- * @param content å
容
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- protected BasicXmlExporter putBRedContent(CharSequence content)
- throws IOException{
- int length = content.length();
-
- int startPos = 0;
-
- for(int idx = 0; idx < length; idx++){
- char ch = content.charAt(idx);
- if(ch == '\n'){
- CharSequence seq = content.subSequence(startPos, idx);
- putContent(seq).putRawText("
").ln();
- startPos = idx + 1;
- }
- }
-
- if(startPos < length){
- CharSequence seq = content.subSequence(startPos, length);
- putContent(seq).ln();
- }
-
- return this;
- }
-
- /**
- * å種ã¡ã¿æ
å ±ãåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putMetaInfo(PmdModel model) throws IOException{
- ind().putRawText("").ln();
- ind().putRawText("").ln(2);
-
- ind().putRawText("").ln();
- ind().putRawText("").ln(2);
-
- if(this.generator != null){
- ind().putRawText("").ln();
- }
-
- ind().putRawText("").ln();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * ãããªã¢ã«ç´ æä¸è¦§ãåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putMaterialList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
-
- pushNest();
- int ct = 0;
- boolean dumped = false;
- List materialList = model.getMaterialList();
- for(Material material : materialList){
- if( ! dumped ) ln();
- putMaterial(material, ct++);
- dumped = true;
- }
- popNest();
-
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * ãããªã¢ã«ç´ ææ
å ±ãåºåããã
- * @param material ãããªã¢ã«ç´ æ
- * @param no ãããªã¢ã«éãçªå·
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putMaterial(Material material, int no)
- throws IOException{
- String bool;
- if(material.getEdgeAppearance()) bool = "true";
- else bool = "false";
- I18nText name = material.getMaterialName();
- String primary = name.getPrimaryText();
- String local = name.getText();
-
- if(local != null && local.length() > 0){
- ind().putLineComment(local).ln();
- }
- ind().putRawText(" 0){
- putAttr("name", primary).sp();
- }
-
- putAttr("showEdge", bool);
- sp();
- putNumberedIdAttr("surfaceGroupIdRef", PFX_SURFACEGROUP, no);
- sp().putRawCh('>').ln();
- pushNest();
-
- putI18nName(name);
-
- float[] rgba = new float[4];
-
- Color diffuse = material.getDiffuseColor();
- diffuse.getRGBComponents(rgba);
- ind().putRawText("").ln();
-
- Color specular = material.getSpecularColor();
- specular.getRGBComponents(rgba);
- float shininess = material.getShininess();
- ind().putRawText("").ln();
-
- Color ambient = material.getAmbientColor();
- ambient.getRGBComponents(rgba);
- ind().putRawText("").ln();
-
- ShadeInfo shade = material.getShadeInfo();
- String textureFileName = shade.getTextureFileName();
- String spheremapFileName = shade.getSpheremapFileName();
-
- if(shade.isValidToonIndex()){
- ind().putRawText("");
- String toonFileName = shade.getToonFileName();
- if(toonFileName != null && toonFileName.length() > 0){
- sp().putLineComment(toonFileName);
- }
- ln();
- }
-
- if(textureFileName != null && textureFileName.length() > 0){
- ind().putRawText("").ln();
- }
-
- if(spheremapFileName != null && spheremapFileName.length() > 0){
- ind().putRawText("").ln();
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * ãã¥ã¼ã³ãã¡ã¤ã«ãããã³ã°æ
å ±ãåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putToonMap(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
- pushNest();
-
- ToonMap map = model.getToonMap();
- for(int index = 0; index <= 9; index++){
- ind().putToon(map, index).ln();
- }
-
- popNest();
- ind().putRawText("").ln(2);
- return this;
- }
-
- /**
- * åå¥ã®ãã¥ã¼ã³ãã¡ã¤ã«æ
å ±ãåºåããã
- * @param map ãã¥ã¼ã³ããã
- * @param index ã¤ã³ããã¯ã¹å¤
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putToon(ToonMap map, int index)
- throws IOException{
- putRawText("");
- putUnescapedComment(toonFile);
- return this;
- }
-
- /**
- * ãµã¼ãã§ã¤ã¹ã°ã«ã¼ããªã¹ããåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putSurfaceGroupList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
-
- pushNest();
- int ct = 0;
- boolean dumped = false;
- List materialList = model.getMaterialList();
- for(Material material : materialList){
- List surfaceList = material.getSurfaceList();
- if( ! dumped ) ln();
- putSurfaceList(surfaceList, ct++);
- dumped = true;
- }
- popNest();
-
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åå¥ã®ãµã¼ãã§ã¤ã¹ã°ã«ã¼ããåºåããã
- * @param surfaceList ãµã¼ãã§ã¤ã¹ã®ãªã¹ã
- * @param index ã°ã«ã¼ãã¤ã³ããã¯ã¹
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putSurfaceList(List surfaceList,
- int index)
- throws IOException{
- ind().putRawText("").ln();
- pushNest();
-
- for(Surface surface : surfaceList){
- putSurface(surface);
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åå¥ã®ãµã¼ãã§ã¤ã¹ãåºåããã
- * @param surface ãµã¼ãã§ã¤ã¹
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putSurface(Surface surface)
- throws IOException{
- ind().putRawText("").ln();
- return this;
- }
-
- /**
- * é ç¹ãªã¹ããåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putVertexList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
-
- pushNest();
- boolean dumped = false;
- List vertexList = model.getVertexList();
- for(Vertex vertex : vertexList){
- if( ! dumped ) ln();
- putVertex(vertex);
- dumped = true;
- }
- popNest();
-
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åå¥ã®é ç¹æ
å ±ãåºåããã
- * @param vertex é ç¹
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putVertex(Vertex vertex)
- throws IOException{
- String bool;
- if(vertex.getEdgeAppearance()) bool = "true";
- else bool = "false";
-
- ind().putRawText("").ln();
- pushNest();
-
- MkPos3D position = vertex.getPosition();
- ind().putPosition(position).ln();
-
- MkVec3D normal = vertex.getNormal();
- ind().putRawText("").ln();
-
- MkPos2D uvPos = vertex.getUVPosition();
- ind().putRawText("").ln();
-
- BoneInfo boneA = vertex.getBoneA();
- BoneInfo boneB = vertex.getBoneB();
- int weight = vertex.getWeightA();
- ind().putRawText("").ln();
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * ãã¼ã³ãªã¹ããåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putBoneList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
- pushNest();
-
- boolean dumped = false;
- for(BoneInfo bone : model.getBoneList()){
- if( ! dumped ){
- ln().putBlockComment(BONETYPE_COMMENT).ln();
- }
- putBone(bone);
- dumped = true;
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åå¥ã®ãã¼ã³æ
å ±ãåºåããã
- * @param boneããã¼ã³æ
å ±
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putBone(BoneInfo bone)
- throws IOException{
- I18nText i18nName = bone.getBoneName();
- BoneType type = bone.getBoneType();
-
- StringBuilder boneComment = new StringBuilder();
- String boneName = i18nName.getText();
- if(boneName.isEmpty()){
- boneName = "[NAMELESS]";
- }
- boneComment.append(boneName);
- String typeName = type.getGuiName(DEF_LOCALE);
- boneComment.append(" [").append(typeName).append(']');
- ind().putLineComment(boneComment.toString()).ln();
-
- ind().putRawText("").ln();
- pushNest();
-
- putI18nName(i18nName);
-
- MkPos3D position = bone.getPosition();
- ind().putPosition(position).ln();
-
- BoneInfo srcBone = bone.getSrcBone();
- if(bone.getBoneType() == BoneType.LINKEDROT){
- ind().putRawText("").ln();
- }else if(srcBone != null){
- String iktag;
- switch(getXmlFileType()){
- case XML_101009:
- iktag = " ");
- String ikBoneName = "Ref:" + srcBone.getBoneName().getText();
- putLineComment(ikBoneName);
- ln();
- }
-
- BoneInfo prev = bone.getPrevBone();
- BoneInfo next = bone.getNextBone();
-
- StringBuilder chainComment = new StringBuilder();
- if(prev != null){
- chainComment.append('[')
- .append(prev.getBoneName().getPrimaryText())
- .append(']')
- .append(" >>#");
- }
- if(next != null){
- if(chainComment.length() <= 0) chainComment.append("#");
- chainComment.append(">> ")
- .append('[')
- .append(next.getBoneName().getPrimaryText())
- .append(']');
- }
- if(chainComment.length() > 0){
- ln();
- ind().putLineComment(chainComment).ln();
- }
-
- ind().putRawText("").ln();
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * ãã¼ã³ã°ã«ã¼ããªã¹ããåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putBoneGroupList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
-
- pushNest();
- boolean dumped = false;
- List groupList = model.getBoneGroupList();
- for(BoneGroup group : groupList){
- if(group.isDefaultBoneGroup()) continue;
- if( ! dumped ) ln();
- putBoneGroup(group);
- dumped = true;
- }
- popNest();
-
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åå¥ã®ãã¼ã³ã°ã«ã¼ãæ
å ±ãåºåããã
- * @param group ãã¼ã³ã°ã«ã¼ãæ
å ±
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putBoneGroup(BoneGroup group)
- throws IOException{
- I18nText i18nName = group.getGroupName();
-
- putLocalNameComment(i18nName).ln();
- ind().putRawText("").ln();
- pushNest();
-
- putI18nName(i18nName);
-
- for(BoneInfo bone : group){
- ind().putRawText(" ");
- String boneName = "Ref:" + bone.getBoneName().getText();
- putLineComment(boneName).ln();
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * IKãã§ã¼ã³ãªã¹ããåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putIKChainList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
-
- pushNest();
- boolean dumped = false;
- List chainList = model.getIKChainList();
- for(IKChain chain : chainList){
- if( ! dumped ) ln();
- putIKChain(chain);
- dumped = true;
- }
- popNest();
-
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åå¥ã®IKãã§ã¼ã³æ
å ±ãåºåããã
- * @param chain ãã§ã¼ã³æ
å ±
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putIKChain(IKChain chain)
- throws IOException{
- int depth = chain.getIKDepth();
- float weight = chain.getIKWeight();
- BoneInfo ikBone = chain.getIkBone();
-
- ind().putLineComment("Ref:" + ikBone.getBoneName().getText()).ln();
- ind().putRawText("").ln();
- pushNest();
-
- for(BoneInfo bone : chain){
- ind().putRawText(" ");
- putLineComment("Ref:" + bone.getBoneName().getText());
- ln();
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * ã¢ã¼ããªã¹ããåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putMorphList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
- pushNest();
-
- boolean dumped = false;
- Map> morphMap = model.getMorphMap();
- for(MorphType type : MorphType.values()){
- if(type == MorphType.BASE) continue;
- List partList = morphMap.get(type);
- if(partList == null) continue;
- for(MorphPart part : partList){
- if( ! dumped ){
- ln().putBlockComment(MORPHTYPE_COMMENT).ln();
- }
- putMorphPart(part);
- dumped = true;
- }
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åå¥ã®ã¢ã¼ãæ
å ±ãåºåããã
- * @param part ã¢ã¼ãæ
å ±
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putMorphPart(MorphPart part)
- throws IOException{
- I18nText i18nName = part.getMorphName();
- String primary = i18nName.getPrimaryText();
-
- putLocalNameComment(i18nName).ln();
- ind().putRawText("");
- ln();
- pushNest();
-
- putI18nName(i18nName);
-
- for(MorphVertex mvertex : part){
- MkPos3D offset = mvertex.getOffset();
- Vertex base = mvertex.getBaseVertex();
-
- ind().putRawText("");
- ln();
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åä½ãªã¹ããåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putRigidList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
- pushNest();
-
- boolean dumped = false;
- for(RigidInfo rigid : model.getRigidList()){
- if( ! dumped ){
- ln().putBlockComment(RIGIDBEHAVIOR_COMMENT).ln();
- }
- putRigid(rigid);
- dumped = true;
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åå¥ã®åä½æ
å ±ãåºåããã
- * @param rigid åä½æ
å ±
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putRigid(RigidInfo rigid)
- throws IOException{
- BoneInfo linkedBone = rigid.getLinkedBone();
- I18nText i18nName = rigid.getRigidName();
- String primary = i18nName.getPrimaryText();
-
- putLocalNameComment(i18nName).ln();
- ind().putRawText("").ln();
- pushNest();
-
- putI18nName(i18nName);
-
- if(linkedBone != null){
- ind().putRawText(" ");
- putLineComment("Ref:" + linkedBone.getBoneName().getText());
- ln(2);
- }
-
- RigidShape shape = rigid.getRigidShape();
- putRigidShape(shape);
-
- MkPos3D position = rigid.getPosition();
- ind().putPosition(position).ln();
-
- Rad3d rotation = rigid.getRotation();
- ind().putRadRotation(rotation).ln();
-
- DynamicsInfo dynamics = rigid.getDynamicsInfo();
- putDynamics(dynamics).ln();
-
- for(RigidGroup group : rigid.getThroughGroupColl()){
- ind().putRawText("").ln();
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åä½å½¢ç¶ãåºåããã
- * @param shape åä½å½¢ç¶
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putRigidShape(RigidShape shape)
- throws IOException{
- RigidShapeType type = shape.getShapeType();
-
- switch(type){
- case BOX:
- ind().putRawText("").ln();
-
- return this;
- }
-
- /**
- * åå¦è¨å®ãåºåããã
- * @param dynamics åå¦è¨å®
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putDynamics(DynamicsInfo dynamics)
- throws IOException{
- ind().putRawText("").ln();
-
- return this;
- }
-
- /**
- * åä½ã°ã«ã¼ããªã¹ããåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putRigidGroupList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln(2);
- pushNest();
-
- boolean singleLast = false;
- for(RigidGroup group : model.getRigidGroupList()){
- List rigidList = group.getRigidList();
- if(singleLast && ! rigidList.isEmpty()){
- ln();
- }
- ind().putRawText("").ln();
- singleLast = true;
- continue;
- }
- putRawText(" >").ln();
- pushNest();
-
- for(RigidInfo rigid : rigidList){
- ind().putRawText("");
- sp();
- putLineComment("Ref:" + rigid.getRigidName().getText());
- ln();
- }
-
- popNest();
- ind().putRawText("").ln(2);
- singleLast = false;
- }
-
- if(singleLast){
- ln();
- }
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * ã¸ã§ã¤ã³ããªã¹ããåºåããã
- * @param model ã¢ãã«ãã¼ã¿
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putJointList(PmdModel model)
- throws IOException{
- ind().putRawText("").ln();
-
- pushNest();
- boolean dumped = false;
- List jointList = model.getJointList();
- for(JointInfo joint : jointList){
- if( ! dumped ) ln();
- putJoint(joint);
- dumped = true;
- }
- popNest();
-
- ind().putRawText("").ln(2);
-
- return this;
- }
-
- /**
- * åå¥ã®ã¸ã§ã¤ã³ãæ
å ±ãåºåããã
- * @param joint ã¸ã§ã¤ã³ãæ
å ±
- * @return thisæ¬ä½
- * @throws IOException åºåã¨ã©ã¼
- */
- private PmdXmlExporter putJoint(JointInfo joint)
- throws IOException{
- I18nText i18nName = joint.getJointName();
-
- putLocalNameComment(i18nName).ln();
- ind().putRawText("").ln();
- pushNest();
-
- putI18nName(i18nName);
-
- RigidInfo rigidA = joint.getRigidA();
- RigidInfo rigidB = joint.getRigidB();
-
- ind();
- putLineComment("[" + rigidA.getRigidName().getText() + "]"
- + " <=> [" + rigidB.getRigidName().getText() + "]");
- ln();
-
- ind().putRawText("").ln(2);
-
- MkPos3D position = joint.getPosition();
- ind().putPosition(position).ln();
-
- TripletRange posRange = joint.getPositionRange();
- ind().putRawText("").ln(2);
-
- Rad3d rotation = joint.getRotation();
- ind().putRadRotation(rotation).ln();
- TripletRange rotRange = joint.getRotationRange();
- ind().putRawText("").ln(2);
-
- MkPos3D elaPosition = joint.getElasticPosition();
- ind().putRawText("").ln();
-
- Deg3d elaRotation = joint.getElasticRotation();
- ind().putRawText("").ln(2);
-
- popNest();
- ind().putRawText("").ln(2);
-
- return this;
- }
-
-}