4 * License : The MIT License
5 * Copyright(c) 2010 MikuToga Partners
8 package jp.sourceforge.mikutoga.pmd.model;
10 import jp.sourceforge.mikutoga.pmd.model.BoneInfo;
11 import jp.sourceforge.mikutoga.corelib.SerialNumbered;
12 import jp.sourceforge.mikutoga.pmd.Pos2d;
13 import jp.sourceforge.mikutoga.pmd.Pos3d;
14 import jp.sourceforge.mikutoga.pmd.Vec3d;
19 public class Vertex implements SerialNumbered {
21 private static final int MIN_WEIGHT = 0;
22 private static final int MAX_WEIGHT = 100;
24 private final Pos3d position = new Pos3d();
25 private final Vec3d normal = new Vec3d();
27 private final Pos2d uvPosition = new Pos2d();
29 private BoneInfo boneA = null;
30 private BoneInfo boneB = null;
32 private int boneWeight = 50;
34 private boolean edgeAppearance = true;
36 private int serialNo = -1;
50 public Pos3d getPosition(){
58 public Vec3d getNormal(){
66 public Pos2d getUVPosition(){
67 return this.uvPosition;
74 * @throws NullPointerException 引数がnull
76 public void setBonePair(BoneInfo boneA, BoneInfo boneB)
77 throws NullPointerException{
78 if(boneA == null || boneB == null) throw new NullPointerException();
88 public BoneInfo getBoneA(){
96 public BoneInfo getBoneB(){
102 * @param weight ウェイト値。0(影響小)-100(影響大)
103 * @throws IllegalArgumentException ウェイト値が範囲外
105 public void setWeightA(int weight) throws IllegalArgumentException{
106 if( weight < MIN_WEIGHT
107 || MAX_WEIGHT < weight ){
108 throw new IllegalArgumentException();
110 this.boneWeight = weight;
116 * @param weight ウェイト値。0(影響小)-100(影響大)
117 * @throws IllegalArgumentException ウェイト値が範囲外
119 public void setWeightB(int weight) throws IllegalArgumentException{
120 setWeightA(MAX_WEIGHT - weight);
128 public int getWeightA(){
129 return this.boneWeight;
136 public int getWeightB(){
137 int result = MAX_WEIGHT - this.boneWeight;
143 * @return ウェイト率。0.0(影響小)-1.0(影響大)
145 public float getWeightRatioA(){
146 return ((float)this.boneWeight) / (float)MAX_WEIGHT;
151 * @return ウェイト率。0.0(影響小)-1.0(影響大)
153 public float getWeightRatioB(){
154 return ((float)MAX_WEIGHT - (float)this.boneWeight)
160 * マテリアル材質単位の設定より優先度は高い。
161 * @param show 表示するならtrue
163 public void setEdgeAppearance(boolean show){
164 this.edgeAppearance = show;
170 * マテリアル材質単位の設定より優先度は高い。
173 public boolean getEdgeAppearance(){
174 return this.edgeAppearance;
179 * @param num {@inheritDoc}
182 public void setSerialNumber(int num){
189 * @return {@inheritDoc}
192 public int getSerialNumber(){
193 return this.serialNo;
198 * @return {@inheritDoc}
201 public String toString(){
202 StringBuilder result = new StringBuilder();
204 result.append("Vertex(").append(this.serialNo).append(") ");
205 result.append(this.position).append(' ');
206 result.append(this.normal).append(' ');
207 result.append("UV").append(this.uvPosition).append(' ');
210 .append(this.boneA.getBoneName())
212 .append(this.boneB.getBoneName())
215 result.append("weight=").append(this.boneWeight).append(' ');
217 if(this.edgeAppearance) result.append("showEdge");
218 else result.append("hideEdge");
220 return result.toString();