This commit is contained in:
pahimar 2013-03-15 15:20:17 -04:00
parent 1f9f579663
commit fe153ca8bb
5 changed files with 18 additions and 16 deletions

View file

@ -21,11 +21,12 @@ public class Vertex {
public Vertex(Vertex vertex) {
this.x = vertex.x;
this.y = vertex.y;
this.z = vertex.z;
x = vertex.x;
y = vertex.y;
z = vertex.z;
}
@Override
public String toString() {
return "x: " + x + ", y: " + y + ", z: " + z;

View file

@ -11,6 +11,7 @@ public class NormalParser extends LineParser {
Vertex vertex = null;
public NormalParser() {
}
@Override
@ -19,9 +20,9 @@ public class NormalParser extends LineParser {
vertex = new Vertex();
try {
vertex.x = (Float.parseFloat(words[1]));
vertex.y = (Float.parseFloat(words[2]));
vertex.z = (Float.parseFloat(words[3]));
vertex.x = Float.parseFloat(words[1]);
vertex.y = Float.parseFloat(words[2]);
vertex.z = Float.parseFloat(words[3]);
}
catch (Exception e) {
throw new RuntimeException("NormalParser Error");

View file

@ -20,15 +20,15 @@ public class TextureCoordinateParser extends LineParser {
coordinate = new TextureCoordinate();
try {
if (words.length >= 2) {
coordinate.u = (Float.parseFloat(words[1]));
coordinate.u = Float.parseFloat(words[1]);
}
if (words.length >= 3) {
coordinate.v = (1 - Float.parseFloat(words[2])); // OBJ origin is at upper left, OpenGL origin is at lower left.
coordinate.v = 1 - Float.parseFloat(words[2]); // OBJ origin is at upper left, OpenGL origin is at lower left.
}
if (words.length >= 4) {
coordinate.w = (Float.parseFloat(words[3]));
coordinate.w = Float.parseFloat(words[3]);
}
}

View file

@ -20,9 +20,9 @@ public class VertexParser extends LineParser {
vertex = new Vertex();
try {
vertex.x = (Float.parseFloat(words[1]));
vertex.y = (Float.parseFloat(words[2]));
vertex.z = (Float.parseFloat(words[3]));
vertex.x = Float.parseFloat(words[1]);
vertex.y = Float.parseFloat(words[2]);
vertex.z = Float.parseFloat(words[3]);
}
catch (Exception e) {
throw new RuntimeException("VertexParser Error");
@ -32,9 +32,9 @@ public class VertexParser extends LineParser {
@Override
public void incoporateResults(WavefrontObject wavefrontObject) {
vertex.x = ((vertex.x + wavefrontObject.translate.x) * wavefrontObject.xScale);
vertex.y = ((vertex.y + wavefrontObject.translate.y) * wavefrontObject.yScale);
vertex.z = ((vertex.z + wavefrontObject.translate.z) * wavefrontObject.zScale);
vertex.x = (vertex.x + wavefrontObject.translate.x) * wavefrontObject.xScale;
vertex.y = (vertex.y + wavefrontObject.translate.y) * wavefrontObject.yScale;
vertex.z = (vertex.z + wavefrontObject.translate.z) * wavefrontObject.zScale;
wavefrontObject.getVertices().add(vertex);
}