|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
VertexData.java | - | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
|
|
3 |
VRMoo Common - Virtual Reality Object Oriented MUD Common Code
|
|
4 |
Copyright (C) 2003 VRMoo Development Team
|
|
5 |
|
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or modify
|
|
8 |
it under the terms of the GNU General Public License as published by
|
|
9 |
the Free Software Foundation; either version 2 of the License, or
|
|
10 |
(at your option) any later version.
|
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful,
|
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 |
GNU General Public License for more details.
|
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License
|
|
18 |
along with this program; if not, write to the Free Software
|
|
19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20 |
|
|
21 |
|
|
22 |
For information about VRMoo and its authors, please visit the website:
|
|
23 |
http://www.vrmoo.org/
|
|
24 |
|
|
25 |
*/
|
|
26 |
|
|
27 |
package org.vrmoo.common.data;
|
|
28 |
|
|
29 |
import org.vrmoo.common.exception.VRMooParseException;
|
|
30 |
import org.vrmoo.common.util.ParserUtility;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Stores the 3D data for one Vertex of a more complex structure. Also contains
|
|
34 |
* functionality for writing out the data into a text format, and parsing that
|
|
35 |
* same text format.
|
|
36 |
*
|
|
37 |
*@author Jeff Weston
|
|
38 |
*@created October 12, 2003
|
|
39 |
*/
|
|
40 |
public class VertexData { |
|
41 |
/**
|
|
42 |
* Contains the X coordinate of the point data.
|
|
43 |
*/
|
|
44 |
private float pointX; |
|
45 |
|
|
46 |
/**
|
|
47 |
* Contains the Y coordinate of the point data.
|
|
48 |
*/
|
|
49 |
private float pointY; |
|
50 |
|
|
51 |
/**
|
|
52 |
* Contains the Z coordinate of the point data.
|
|
53 |
*/
|
|
54 |
private float pointZ; |
|
55 |
|
|
56 |
/**
|
|
57 |
* Contans the X coordinate of the texture coordinates for this point.
|
|
58 |
*/
|
|
59 |
private float texCoordX; |
|
60 |
|
|
61 |
/**
|
|
62 |
* Contans the Y coordinate of the texture coordinates for this point.
|
|
63 |
*/
|
|
64 |
private float texCoordY; |
|
65 |
|
|
66 |
/**
|
|
67 |
* Contains the X coordinate of the normal for this point. Normals point
|
|
68 |
* from 0, 0, 0 to this coordinate.
|
|
69 |
*/
|
|
70 |
private float normalX; |
|
71 |
|
|
72 |
/**
|
|
73 |
* Contains the Y coordinate of the normal for this point.
|
|
74 |
*/
|
|
75 |
private float normalY; |
|
76 |
|
|
77 |
/**
|
|
78 |
* Contains the Z coordinate of the normal for this point
|
|
79 |
*/
|
|
80 |
private float normalZ; |
|
81 |
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Construct an instance of this class using paramaterized values for the
|
|
85 |
* point and texture coordinate data.
|
|
86 |
*
|
|
87 |
*@param pointX the X coordinate of the point data
|
|
88 |
*@param pointY the Y coordinate of the point data
|
|
89 |
*@param pointZ the Z coordinate of the point data
|
|
90 |
*@param texCoordX the X coordinate of the texture coordinates for this
|
|
91 |
* point
|
|
92 |
*@param texCoordY the Y coordinate of the texture coordinates for this
|
|
93 |
* point
|
|
94 |
* @param normalX the X coordinate of the normal for this point
|
|
95 |
* @param normalY the Y coordinate of the normal for this point
|
|
96 |
* @param normalZ the Z coordinate of the normal for this point
|
|
97 |
*/
|
|
98 | 0 |
public VertexData( float pointX, float pointY, float pointZ, |
99 |
float texCoordX, float texCoordY, |
|
100 |
float normalX, float normalY, float normalZ) { |
|
101 | 0 |
this.pointX = pointX;
|
102 | 0 |
this.pointY = pointY;
|
103 | 0 |
this.pointZ = pointZ;
|
104 |
|
|
105 | 0 |
this.texCoordX = texCoordX;
|
106 | 0 |
this.texCoordY = texCoordY;
|
107 |
|
|
108 | 0 |
this.normalX = normalX;
|
109 | 0 |
this.normalY = normalY;
|
110 | 0 |
this.normalZ = normalZ;
|
111 |
} |
|
112 |
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Construct an instance of this class using text representing an encoded
|
|
116 |
* Vertex for a more complex structure.
|
|
117 |
*
|
|
118 |
*@param data the encoded Vertex
|
|
119 |
*@exception VRMooParseException Description of the Exception
|
|
120 |
*@throws VRMooParseException for any parsing errors that occur
|
|
121 |
*/
|
|
122 | 0 |
public VertexData( String data )
|
123 |
throws VRMooParseException {
|
|
124 | 0 |
float f[] = ParserUtility.parseFloatArray( data, 8 );
|
125 | 0 |
pointX = f[0]; |
126 | 0 |
pointY = f[1]; |
127 | 0 |
pointZ = f[2]; |
128 | 0 |
texCoordX = f[3]; |
129 | 0 |
texCoordY = f[4]; |
130 | 0 |
normalX = f[5]; |
131 | 0 |
normalY = f[6]; |
132 | 0 |
normalZ = f[7]; |
133 |
} |
|
134 |
|
|
135 |
|
|
136 |
/**
|
|
137 |
* Get the X coordinate of the Point data.
|
|
138 |
*
|
|
139 |
*@return the X coordinate of the Point data
|
|
140 |
*/
|
|
141 | 0 |
public float getPointX() { |
142 | 0 |
return pointX;
|
143 |
} |
|
144 |
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Get the Y coordinate of the Point data.
|
|
148 |
*
|
|
149 |
*@return the Y coordinate of the Point data
|
|
150 |
*/
|
|
151 | 0 |
public float getPointY() { |
152 | 0 |
return pointY;
|
153 |
} |
|
154 |
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Get the Z coordinate of the Point data.
|
|
158 |
*
|
|
159 |
*@return the Z coordinate of the Point data
|
|
160 |
*/
|
|
161 | 0 |
public float getPointZ() { |
162 | 0 |
return pointZ;
|
163 |
} |
|
164 |
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Get the X coordinate of the texture coordinates for this point.
|
|
168 |
*
|
|
169 |
*@return X coordinate of the texture coordinates for this point
|
|
170 |
*/
|
|
171 | 0 |
public float getTexCoordX() { |
172 | 0 |
return texCoordX;
|
173 |
} |
|
174 |
|
|
175 |
|
|
176 |
/**
|
|
177 |
* Get the Y coordinate of the texture coordinates for this point.
|
|
178 |
*
|
|
179 |
*@return Y coordinate of the texture coordinates for this point
|
|
180 |
*/
|
|
181 | 0 |
public float getTexCoordY() { |
182 | 0 |
return texCoordY;
|
183 |
} |
|
184 |
|
|
185 |
/**
|
|
186 |
* Get the X coordinate of the normal. The normal points from 0, 0, 0
|
|
187 |
* to this point.
|
|
188 |
*
|
|
189 |
* @return X coordinate of the normal for this point
|
|
190 |
*/
|
|
191 | 0 |
public float getNormalX() { |
192 | 0 |
return normalX;
|
193 |
} |
|
194 |
|
|
195 |
/**
|
|
196 |
* Get the Y coordinate of the normal
|
|
197 |
*
|
|
198 |
* @return Y coordinate of the normal for this point
|
|
199 |
*/
|
|
200 | 0 |
public float getNormalY() { |
201 | 0 |
return normalY;
|
202 |
} |
|
203 |
|
|
204 |
/**
|
|
205 |
* Get the Z coordinate of the normal
|
|
206 |
*
|
|
207 |
* @return Z coordinate of the normal for this point
|
|
208 |
*/
|
|
209 | 0 |
public float getNormalZ() { |
210 | 0 |
return normalZ;
|
211 |
} |
|
212 |
|
|
213 |
/**
|
|
214 |
* Convert this class to its <code>String</code> representation.
|
|
215 |
*
|
|
216 |
*@return the converted <code>String</code>
|
|
217 |
*/
|
|
218 | 0 |
public String toEncodedString() {
|
219 | 0 |
return "( " + pointX + ", " + pointY + ", " + pointZ + ", " + |
220 |
texCoordX + ", " + texCoordY + ", " + |
|
221 |
normalX + ", " + normalY + ", " + normalZ + " )"; |
|
222 |
} |
|
223 |
} |
|
224 |
|
|