4 * License : The MIT License
5 * Copyright(c) 2010 MikuToga Partners
8 package jp.sfjp.mikutoga.pmd.model;
10 import jp.sourceforge.mikutoga.corelib.I18nText;
11 import jp.sourceforge.mikutoga.math.MkPos3D;
12 import jp.sourceforge.mikutoga.pmd.BoneType;
17 public class BoneInfo implements SerialNumbered {
19 private final I18nText boneName = new I18nText();
20 private BoneType boneType;
22 private BoneInfo prevBone;
23 private BoneInfo nextBone;
24 private BoneInfo srcBone;
26 private final MkPos3D position = new MkPos3D();
28 private int rotationRatio;
30 private int serialNo = -1;
44 public I18nText getBoneName(){
51 * @throws NullPointerException 引数がnull
53 public void setBoneType(BoneType type) throws NullPointerException{
54 if(type == null) throw new NullPointerException();
63 public BoneType getBoneType(){
69 * @param prevBone 前ボーン。ない場合はnullを指定。
71 public void setPrevBone(BoneInfo prevBone){
72 this.prevBone = prevBone;
78 * @return 前ボーン。ない場合はnullを返す。
80 public BoneInfo getPrevBone(){
88 * @param nextBone 次ボーン。ない場合はnullを指定。
90 public void setNextBone(BoneInfo nextBone){
91 this.nextBone = nextBone;
99 * @return 次ボーン。ない場合はnullを返す。
101 public BoneInfo getNextBone(){
102 return this.nextBone;
106 * このボーンが影響を受けるIK元、回転元のソースボーンを設定する。
107 * @param ikBoneArg ソースボーン。ない場合はnullを指定。
109 public void setSrcBone(BoneInfo ikBoneArg){
110 this.srcBone = ikBoneArg;
115 * このボーンが影響を受けるIK元、回転元のソースボーンを返す。
116 * @return ソースボーン。ない場合はnull
118 public BoneInfo getSrcBone(){
126 public MkPos3D getPosition(){
127 return this.position;
135 public int getRotationRatio(){
136 return this.rotationRatio;
142 * @param ratio 回転連動の影響度
144 public void setRotationRatio(int ratio){
145 this.rotationRatio = ratio;
150 * @param num {@inheritDoc}
153 public void setSerialNumber(int num){
160 * @return {@inheritDoc}
163 public int getSerialNumber(){
164 return this.serialNo;
169 * @return {@inheritDoc}
172 public String toString(){
173 StringBuilder result = new StringBuilder();
175 result.append("Bone")
176 .append(this.serialNo)
178 .append(this.boneName.getPrimaryText())
181 result.append(" type=")
182 .append(this.boneType);
184 result.append(" prev=");
185 if(this.prevBone != null) result.append(this.prevBone.getBoneName());
186 else result.append("NONE");
188 result.append(" next=");
189 if(this.nextBone != null) result.append(this.nextBone.getBoneName());
190 else result.append("NONE");
192 if(this.boneType == BoneType.LINKEDROT){
193 result.append(" rotraio=").append(this.rotationRatio);
195 result.append(" ik=");
196 if(this.srcBone != null){
197 result.append(this.srcBone.getBoneName());
199 result.append("NONE");
203 result.append(" ").append(this.position);
205 return result.toString();