4 * License : The MIT License
5 * Copyright(c) 2010 MikuToga Partners
8 package jp.sourceforge.mikutoga.pmd.model;
10 import jp.sourceforge.mikutoga.corelib.I18nText;
11 import jp.sourceforge.mikutoga.corelib.SerialNumbered;
12 import jp.sourceforge.mikutoga.pmd.BoneType;
13 import jp.sourceforge.mikutoga.pmd.Pos3d;
18 public class BoneInfo implements SerialNumbered {
20 private final I18nText boneName = new I18nText();
21 private BoneType boneType;
23 private BoneInfo prevBone;
24 private BoneInfo nextBone;
25 private BoneInfo ikBone;
27 private final Pos3d position = new Pos3d();
29 private int rotationRatio;
31 private int serialNo = -1;
45 public I18nText getBoneName(){
52 * @throws NullPointerException 引数がnull
54 public void setBoneType(BoneType type) throws NullPointerException{
55 if(type == null) throw new NullPointerException();
64 public BoneType getBoneType(){
70 * @param prevBone 前ボーン。ない場合はnullを指定。
72 public void setPrevBone(BoneInfo prevBone){
73 this.prevBone = prevBone;
79 * @return 前ボーン。ない場合はnullを返す。
81 public BoneInfo getPrevBone(){
89 * @param nextBone 次ボーン。ない場合はnullを指定。
91 public void setNextBone(BoneInfo nextBone){
92 this.nextBone = nextBone;
100 * @return 次ボーン。ない場合はnullを返す。
102 public BoneInfo getNextBone(){
103 return this.nextBone;
107 * このボーンが影響を受けるIKボーンを設定する。
108 * @param ikBoneArg IKボーン。ない場合はnullを指定。
110 public void setIKBone(BoneInfo ikBoneArg){
111 this.ikBone = ikBoneArg;
116 * このボーンが影響を受けるIKボーンを返す。
117 * @return IKボーン。ない場合はnull
119 public BoneInfo getIKBone(){
127 public Pos3d getPosition(){
128 return this.position;
136 public int getRotationRatio(){
137 return this.rotationRatio;
143 * @param ratio 回転連動の影響度
145 public void setRotationRatio(int ratio){
146 this.rotationRatio = ratio;
151 * @param num {@inheritDoc}
154 public void setSerialNumber(int num){
161 * @return {@inheritDoc}
164 public int getSerialNumber(){
165 return this.serialNo;
170 * @return {@inheritDoc}
173 public String toString(){
174 StringBuilder result = new StringBuilder();
176 result.append("Bone")
177 .append(this.serialNo)
179 .append(this.boneName.getPrimaryText())
182 result.append(" type=")
183 .append(this.boneType);
185 result.append(" prev=");
186 if(this.prevBone != null) result.append(this.prevBone.getBoneName());
187 else result.append("NONE");
189 result.append(" next=");
190 if(this.nextBone != null) result.append(this.nextBone.getBoneName());
191 else result.append("NONE");
193 if(this.boneType == BoneType.LINKEDROT){
194 result.append(" rotraio=").append(this.rotationRatio);
196 result.append(" ik=");
197 if(this.ikBone != null) result.append(this.ikBone.getBoneName());
198 else result.append("NONE");
201 result.append(" ").append(this.position);
203 return result.toString();