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;
52 public MkPos3D getPosition(){
60 public MkVec3D getNormal(){
68 public MkPos2D getUVPosition(){
69 return this.uvPosition;
74 * @param boneAArg ボーンA
75 * @param boneBArg ボーンB
76 * @throws NullPointerException 引数がnull
78 public void setBonePair(BoneInfo boneAArg, BoneInfo boneBArg)
79 throws NullPointerException{
80 if(boneAArg == null || boneBArg == null)
81 throw new NullPointerException();
83 this.boneA = boneAArg;
84 this.boneB = boneBArg;
93 public BoneInfo getBoneA(){
101 public BoneInfo getBoneB(){
107 * @param weight ウェイト値。0(影響小)-100(影響大)
108 * @throws IllegalArgumentException ウェイト値が範囲外
110 public void setWeightA(int weight) throws IllegalArgumentException{
111 if( weight < MIN_WEIGHT
112 || MAX_WEIGHT < weight ){
113 throw new IllegalArgumentException();
115 this.boneWeight = weight;
121 * @param weight ウェイト値。0(影響小)-100(影響大)
122 * @throws IllegalArgumentException ウェイト値が範囲外
124 public void setWeightB(int weight) throws IllegalArgumentException{
125 setWeightA(MAX_WEIGHT - weight);
133 public int getWeightA(){
134 return this.boneWeight;
141 public int getWeightB(){
142 int result = MAX_WEIGHT - this.boneWeight;
148 * @return ウェイト率。0.0(影響小)-1.0(影響大)
150 public float getWeightRatioA(){
151 return ((float)this.boneWeight) / (float)MAX_WEIGHT;
156 * @return ウェイト率。0.0(影響小)-1.0(影響大)
158 public float getWeightRatioB(){
159 return ((float)MAX_WEIGHT - (float)this.boneWeight)
165 * マテリアル材質単位の設定より優先度は高い。
166 * @param show 表示するならtrue
168 public void setEdgeAppearance(boolean show){
169 this.edgeAppearance = show;
175 * マテリアル材質単位の設定より優先度は高い。
178 public boolean getEdgeAppearance(){
179 return this.edgeAppearance;
184 * @param num {@inheritDoc}
187 public void setSerialNumber(int num){
188 this.vertexSerialNo = num;
194 * @return {@inheritDoc}
197 public int getSerialNumber(){
198 return this.vertexSerialNo;
203 * @return {@inheritDoc}
206 public String toString(){
207 StringBuilder result = new StringBuilder();
209 result.append("Vertex(").append(this.vertexSerialNo).append(") ");
210 result.append(this.position).append(' ');
211 result.append(this.normal).append(' ');
212 result.append("UV").append(this.uvPosition).append(' ');
215 .append(this.boneA.getBoneName())
217 .append(this.boneB.getBoneName())
220 result.append("weight=").append(this.boneWeight).append(' ');
222 if(this.edgeAppearance) result.append("showEdge");
223 else result.append("hideEdge");
225 return result.toString();