4 * License : The MIT License
5 * Copyright(c) 2010 MikuToga Partners
8 package jp.sourceforge.mikutoga.pmd;
10 import jp.sourceforge.mikutoga.corelib.SerialNumbered;
15 public class Vertex implements SerialNumbered {
17 private static final int MIN_WEIGHT = 0;
18 private static final int MAX_WEIGHT = 100;
20 private final Pos3d position = new Pos3d();
21 private final Vec3d normal = new Vec3d();
23 private final Pos2d uvPosition = new Pos2d();
25 private BoneInfo boneA = null;
26 private BoneInfo boneB = null;
28 private int boneWeight = 50;
30 private boolean edgeAppearance = true;
32 private int serialNo = -1;
46 public Pos3d getPosition(){
54 public Vec3d getNormal(){
62 public Pos2d getUVPosition(){
63 return this.uvPosition;
70 * @throws NullPointerException 引数がnull
72 public void setBonePair(BoneInfo boneA, BoneInfo boneB)
73 throws NullPointerException{
74 if(boneA == null || boneB == null) throw new NullPointerException();
84 public BoneInfo getBoneA(){
92 public BoneInfo getBoneB(){
98 * @param weight ウェイト値。0(影響小)-100(影響大)
99 * @throws IllegalArgumentException ウェイト値が範囲外
101 public void setWeightA(int weight) throws IllegalArgumentException{
102 if( weight < MIN_WEIGHT
103 || MAX_WEIGHT < weight ){
104 throw new IllegalArgumentException();
106 this.boneWeight = weight;
112 * @param weight ウェイト値。0(影響小)-100(影響大)
113 * @throws IllegalArgumentException ウェイト値が範囲外
115 public void setWeightB(int weight) throws IllegalArgumentException{
116 setWeightA(MAX_WEIGHT - weight);
124 public int getWeightA(){
125 return this.boneWeight;
132 public int getWeightB(){
133 int result = MAX_WEIGHT - this.boneWeight;
139 * @return ウェイト率。0.0(影響小)-1.0(影響大)
141 public float getWeightRatioA(){
142 return ((float)this.boneWeight) / (float)MAX_WEIGHT;
147 * @return ウェイト率。0.0(影響小)-1.0(影響大)
149 public float getWeightRatioB(){
150 return ((float)MAX_WEIGHT - (float)this.boneWeight)
156 * マテリアル材質単位の設定より優先度は高い。
157 * @param show 表示するならtrue
159 public void setEdgeAppearance(boolean show){
160 this.edgeAppearance = show;
166 * マテリアル材質単位の設定より優先度は高い。
169 public boolean getEdgeAppearance(){
170 return this.edgeAppearance;
175 * @param num {@inheritDoc}
178 public void setSerialNumber(int num){
185 * @return {@inheritDoc}
188 public int getSerialNumber(){
189 return this.serialNo;
194 * @return {@inheritDoc}
197 public String toString(){
198 StringBuilder result = new StringBuilder();
200 result.append("Vertex(").append(this.serialNo).append(") ");
201 result.append(this.position).append(' ');
202 result.append(this.normal).append(' ');
203 result.append("UV").append(this.uvPosition).append(' ');
206 .append(this.boneA.getBoneName())
208 .append(this.boneB.getBoneName())
211 result.append("weight=").append(this.boneWeight).append(' ');
213 if(this.edgeAppearance) result.append("showEdge");
214 else result.append("hideEdge");
216 return result.toString();