4 * License : The MIT License
5 * Copyright(c) 2010 MikuToga Partners
8 package jp.sfjp.mikutoga.pmd.model;
10 import jp.sfjp.mikutoga.math.MkPos2D;
11 import jp.sfjp.mikutoga.math.MkPos3D;
12 import jp.sfjp.mikutoga.math.MkVec3D;
17 public class Vertex implements SerialNumbered {
19 private static final int MIN_WEIGHT = 0;
20 private static final int MAX_WEIGHT = 100;
21 private static final int BALANCED = 50;
24 private final MkPos3D position = new MkPos3D();
25 private final MkVec3D normal = new MkVec3D();
27 private final MkPos2D uvPosition = new MkPos2D();
29 private BoneInfo boneA = null;
30 private BoneInfo boneB = null;
32 private int boneWeight = BALANCED;
34 private boolean edgeAppearance = true;
36 private int vertexSerialNo = -1;
53 public MkPos3D getPosition(){
62 public MkVec3D getNormal(){
71 public MkPos2D getUVPosition(){
72 return this.uvPosition;
78 * @param boneAArg ボーンA
79 * @param boneBArg ボーンB
80 * @throws NullPointerException 引数がnull
82 public void setBonePair(BoneInfo boneAArg, BoneInfo boneBArg)
83 throws NullPointerException{
84 if(boneAArg == null || boneBArg == null)
85 throw new NullPointerException();
87 this.boneA = boneAArg;
88 this.boneB = boneBArg;
98 public BoneInfo getBoneA(){
107 public BoneInfo getBoneB(){
114 * @param weight ウェイト値。0(影響小)-100(影響大)
115 * @throws IllegalArgumentException ウェイト値が範囲外
117 public void setWeightA(int weight) throws IllegalArgumentException{
118 if( weight < MIN_WEIGHT
119 || MAX_WEIGHT < weight ){
120 throw new IllegalArgumentException();
122 this.boneWeight = weight;
129 * @param weight ウェイト値。0(影響小)-100(影響大)
130 * @throws IllegalArgumentException ウェイト値が範囲外
132 public void setWeightB(int weight) throws IllegalArgumentException{
133 setWeightA(MAX_WEIGHT - weight);
142 public int getWeightA(){
143 return this.boneWeight;
151 public int getWeightB(){
152 int result = MAX_WEIGHT - this.boneWeight;
159 * @return ウェイト率。0.0(影響小)-1.0(影響大)
161 public float getWeightRatioA(){
162 return ((float)this.boneWeight) / (float)MAX_WEIGHT;
168 * @return ウェイト率。0.0(影響小)-1.0(影響大)
170 public float getWeightRatioB(){
171 return ((float)MAX_WEIGHT - (float)this.boneWeight)
177 * マテリアル材質単位の設定より優先度は高い。
179 * @param show 表示するならtrue
181 public void setEdgeAppearance(boolean show){
182 this.edgeAppearance = show;
188 * マテリアル材質単位の設定より優先度は高い。
192 public boolean getEdgeAppearance(){
193 return this.edgeAppearance;
199 * @param num {@inheritDoc}
202 public void setSerialNumber(int num){
203 this.vertexSerialNo = num;
210 * @return {@inheritDoc}
213 public int getSerialNumber(){
214 return this.vertexSerialNo;
220 * @return {@inheritDoc}
223 public String toString(){
224 StringBuilder result = new StringBuilder();
226 result.append("Vertex(").append(this.vertexSerialNo).append(") ");
227 result.append(this.position).append(' ');
228 result.append(this.normal).append(' ');
229 result.append("UV").append(this.uvPosition).append(' ');
232 .append(this.boneA.getBoneName())
234 .append(this.boneB.getBoneName())
237 result.append("weight=").append(this.boneWeight).append(' ');
239 if(this.edgeAppearance) result.append("showEdge");
240 else result.append("hideEdge");
242 return result.toString();