4 * License : The MIT License
5 * Copyright(c) 2010 MikuToga Partners
8 package jp.sfjp.mikutoga.pmd.model;
10 import jp.sfjp.mikutoga.corelib.I18nText;
11 import jp.sfjp.mikutoga.math.MkPos3D;
12 import jp.sfjp.mikutoga.pmd.BoneType;
17 public class BoneInfo implements SerialNumbered {
19 private static final String NO_BONE = "NONE";
21 private final I18nText boneName = new I18nText();
22 private BoneType boneType;
24 private BoneInfo prevBone;
25 private BoneInfo nextBone;
26 private BoneInfo srcBone;
28 private final MkPos3D position = new MkPos3D();
30 private int rotationRatio;
32 private int boneSerialNo = -1;
48 public I18nText getBoneName(){
55 * @throws NullPointerException 引数がnull
57 public void setBoneType(BoneType type) throws NullPointerException{
58 if(type == null) throw new NullPointerException();
67 public BoneType getBoneType(){
73 * @param prevBone 前ボーン。ない場合はnullを指定。
75 public void setPrevBone(BoneInfo prevBone){
76 this.prevBone = prevBone;
82 * @return 前ボーン。ない場合はnullを返す。
84 public BoneInfo getPrevBone(){
92 * @param nextBone 次ボーン。ない場合はnullを指定。
94 public void setNextBone(BoneInfo nextBone){
95 this.nextBone = nextBone;
101 * 捩りボーンでは軸方向に位置するボーン、
103 * @return 次ボーン。ない場合はnullを返す。
105 public BoneInfo getNextBone(){
106 return this.nextBone;
110 * このボーンが影響を受けるIK元、回転元のソースボーンを設定する。
111 * @param ikBoneArg ソースボーン。ない場合はnullを指定。
113 public void setSrcBone(BoneInfo ikBoneArg){
114 this.srcBone = ikBoneArg;
119 * このボーンが影響を受けるIK元、回転元のソースボーンを返す。
120 * @return ソースボーン。ない場合はnull
122 public BoneInfo getSrcBone(){
130 public MkPos3D getPosition(){
131 return this.position;
139 public int getRotationRatio(){
140 return this.rotationRatio;
146 * @param ratio 回転連動の影響度
148 public void setRotationRatio(int ratio){
149 this.rotationRatio = ratio;
154 * @param num {@inheritDoc}
157 public void setSerialNumber(int num){
158 this.boneSerialNo = num;
164 * @return {@inheritDoc}
167 public int getSerialNumber(){
168 return this.boneSerialNo;
173 * @return {@inheritDoc}
176 public String toString(){
177 StringBuilder result = new StringBuilder();
179 result.append("Bone")
180 .append(this.boneSerialNo)
182 .append(this.boneName.getPrimaryText())
185 result.append(" type=")
186 .append(this.boneType);
188 result.append(" prev=");
189 if(this.prevBone != null) result.append(this.prevBone.getBoneName());
190 else result.append(NO_BONE);
192 result.append(" next=");
193 if(this.nextBone != null) result.append(this.nextBone.getBoneName());
194 else result.append(NO_BONE);
196 if(this.boneType == BoneType.LINKEDROT){
197 result.append(" rotraio=").append(this.rotationRatio);
199 result.append(" ik=");
200 if(this.srcBone != null){
201 result.append(this.srcBone.getBoneName());
203 result.append(NO_BONE);
207 result.append(" ").append(this.position);
209 return result.toString();