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