4 * License : The MIT License
5 * Copyright(c) 2010 MikuToga Partners
8 package jp.sourceforge.mikutoga.pmd.model;
10 import jp.sourceforge.mikutoga.math.MkPos2D;
11 import jp.sourceforge.mikutoga.math.MkPos3D;
12 import jp.sourceforge.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;
22 private final MkPos3D position = new MkPos3D();
23 private final MkVec3D normal = new MkVec3D();
25 private final MkPos2D uvPosition = new MkPos2D();
27 private BoneInfo boneA = null;
28 private BoneInfo boneB = null;
30 private int boneWeight = 50;
32 private boolean edgeAppearance = true;
34 private int serialNo = -1;
48 public MkPos3D getPosition(){
56 public MkVec3D getNormal(){
64 public MkPos2D getUVPosition(){
65 return this.uvPosition;
72 * @throws NullPointerException 引数がnull
74 public void setBonePair(BoneInfo boneA, BoneInfo boneB)
75 throws NullPointerException{
76 if(boneA == null || boneB == null) throw new NullPointerException();
86 public BoneInfo getBoneA(){
94 public BoneInfo getBoneB(){
100 * @param weight ウェイト値。0(影響小)-100(影響大)
101 * @throws IllegalArgumentException ウェイト値が範囲外
103 public void setWeightA(int weight) throws IllegalArgumentException{
104 if( weight < MIN_WEIGHT
105 || MAX_WEIGHT < weight ){
106 throw new IllegalArgumentException();
108 this.boneWeight = weight;
114 * @param weight ウェイト値。0(影響小)-100(影響大)
115 * @throws IllegalArgumentException ウェイト値が範囲外
117 public void setWeightB(int weight) throws IllegalArgumentException{
118 setWeightA(MAX_WEIGHT - weight);
126 public int getWeightA(){
127 return this.boneWeight;
134 public int getWeightB(){
135 int result = MAX_WEIGHT - this.boneWeight;
141 * @return ウェイト率。0.0(影響小)-1.0(影響大)
143 public float getWeightRatioA(){
144 return ((float)this.boneWeight) / (float)MAX_WEIGHT;
149 * @return ウェイト率。0.0(影響小)-1.0(影響大)
151 public float getWeightRatioB(){
152 return ((float)MAX_WEIGHT - (float)this.boneWeight)
158 * マテリアル材質単位の設定より優先度は高い。
159 * @param show 表示するならtrue
161 public void setEdgeAppearance(boolean show){
162 this.edgeAppearance = show;
168 * マテリアル材質単位の設定より優先度は高い。
171 public boolean getEdgeAppearance(){
172 return this.edgeAppearance;
177 * @param num {@inheritDoc}
180 public void setSerialNumber(int num){
187 * @return {@inheritDoc}
190 public int getSerialNumber(){
191 return this.serialNo;
196 * @return {@inheritDoc}
199 public String toString(){
200 StringBuilder result = new StringBuilder();
202 result.append("Vertex(").append(this.serialNo).append(") ");
203 result.append(this.position).append(' ');
204 result.append(this.normal).append(' ');
205 result.append("UV").append(this.uvPosition).append(' ');
208 .append(this.boneA.getBoneName())
210 .append(this.boneB.getBoneName())
213 result.append("weight=").append(this.boneWeight).append(' ');
215 if(this.edgeAppearance) result.append("showEdge");
216 else result.append("hideEdge");
218 return result.toString();