More pruning
This commit is contained in:
parent
7a8ac2650b
commit
1f9f579663
11 changed files with 104 additions and 302 deletions
|
@ -57,21 +57,21 @@ public class ModelAludel extends ModelBase {
|
|||
float sumU = 0F;
|
||||
float sumV = 0F;
|
||||
|
||||
for (int i = 0; i < face.getTextures().length; ++i) {
|
||||
sumU += face.getTextures()[i].getU();
|
||||
sumV += face.getTextures()[i].getV();
|
||||
for (int i = 0; i < face.getTextureCoordinates().length; ++i) {
|
||||
sumU += face.getTextureCoordinates()[i].u;
|
||||
sumV += face.getTextureCoordinates()[i].v;
|
||||
}
|
||||
|
||||
for (int i = 0; i < face.getVertices().length; ++i) {
|
||||
float offsetU = Reference.MODEL_TEXTURE_OFFSET;
|
||||
float offsetV = Reference.MODEL_TEXTURE_OFFSET;
|
||||
if (face.getTextures()[i].getU() > sumU / face.getTextures().length) {
|
||||
if (face.getTextureCoordinates()[i].u > sumU / face.getTextureCoordinates().length) {
|
||||
offsetU = -offsetU;
|
||||
}
|
||||
if (face.getTextures()[i].getV() > sumV / face.getTextures().length) {
|
||||
if (face.getTextureCoordinates()[i].v > sumV / face.getTextureCoordinates().length) {
|
||||
offsetV = -offsetV;
|
||||
}
|
||||
tessellator.addVertexWithUV(face.getVertices()[i].getX() * scale, face.getVertices()[i].getY() * scale, face.getVertices()[i].getZ() * scale, face.getTextures()[i].getU() + offsetU, face.getTextures()[i].getV() + offsetV);
|
||||
tessellator.addVertexWithUV(face.getVertices()[i].x * scale, face.getVertices()[i].y * scale, face.getVertices()[i].z * scale, face.getTextureCoordinates()[i].u + offsetU, face.getTextureCoordinates()[i].v + offsetV);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
|
|
|
@ -57,21 +57,21 @@ public class ModelCalcinator extends ModelBase {
|
|||
float sumU = 0F;
|
||||
float sumV = 0F;
|
||||
|
||||
for (int i = 0; i < face.getTextures().length; ++i) {
|
||||
sumU += face.getTextures()[i].getU();
|
||||
sumV += face.getTextures()[i].getV();
|
||||
for (int i = 0; i < face.getTextureCoordinates().length; ++i) {
|
||||
sumU += face.getTextureCoordinates()[i].u;
|
||||
sumV += face.getTextureCoordinates()[i].v;
|
||||
}
|
||||
|
||||
for (int i = 0; i < face.getVertices().length; ++i) {
|
||||
float offsetU = Reference.MODEL_TEXTURE_OFFSET;
|
||||
float offsetV = Reference.MODEL_TEXTURE_OFFSET;
|
||||
if (face.getTextures()[i].getU() > sumU / face.getTextures().length) {
|
||||
if (face.getTextureCoordinates()[i].u > sumU / face.getTextureCoordinates().length) {
|
||||
offsetU = -offsetU;
|
||||
}
|
||||
if (face.getTextures()[i].getV() > sumV / face.getTextures().length) {
|
||||
if (face.getTextureCoordinates()[i].v > sumV / face.getTextureCoordinates().length) {
|
||||
offsetV = -offsetV;
|
||||
}
|
||||
tessellator.addVertexWithUV(face.getVertices()[i].getX() * scale, face.getVertices()[i].getY() * scale, face.getVertices()[i].getZ() * scale, face.getTextures()[i].getU() + offsetU, face.getTextures()[i].getV() + offsetV);
|
||||
tessellator.addVertexWithUV(face.getVertices()[i].x * scale, face.getVertices()[i].y * scale, face.getVertices()[i].z * scale, face.getTextureCoordinates()[i].u + offsetU, face.getTextureCoordinates()[i].v + offsetV);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
|
|
|
@ -6,18 +6,19 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class Face {
|
||||
|
||||
public int[] vertIndices;
|
||||
public int[] normIndices;
|
||||
public int[] texIndices;
|
||||
public int[] vertexIndices;
|
||||
public int[] vertexNormalIndices;
|
||||
public int[] textureCoordinateIndices;
|
||||
|
||||
private Vertex[] vertices;
|
||||
private Vertex[] normals;
|
||||
private TextureCoordinate[] textures;
|
||||
private Vertex[] vertexNormals;
|
||||
private TextureCoordinate[] textureCoordinates;
|
||||
|
||||
private int glDrawingMode;
|
||||
|
||||
public int[] getIndices() {
|
||||
public int[] getVertexIndices() {
|
||||
|
||||
return vertIndices;
|
||||
return vertexIndices;
|
||||
}
|
||||
|
||||
public Vertex[] getVertices() {
|
||||
|
@ -25,9 +26,9 @@ public class Face {
|
|||
return vertices;
|
||||
}
|
||||
|
||||
public void setIndices(int[] indices) {
|
||||
public void setVertexIndices(int[] vertexIndices) {
|
||||
|
||||
vertIndices = indices;
|
||||
this.vertexIndices = vertexIndices;
|
||||
}
|
||||
|
||||
public void setVertices(Vertex[] vertices) {
|
||||
|
@ -45,23 +46,23 @@ public class Face {
|
|||
this.glDrawingMode = glDrawingMode;
|
||||
}
|
||||
|
||||
public Vertex[] getNormals() {
|
||||
public Vertex[] getVertexNormals() {
|
||||
|
||||
return normals;
|
||||
return vertexNormals;
|
||||
}
|
||||
|
||||
public void setNormals(Vertex[] normals) {
|
||||
public void setVertexNormals(Vertex[] vertexNormals) {
|
||||
|
||||
this.normals = normals;
|
||||
this.vertexNormals = vertexNormals;
|
||||
}
|
||||
|
||||
public TextureCoordinate[] getTextures() {
|
||||
public TextureCoordinate[] getTextureCoordinates() {
|
||||
|
||||
return textures;
|
||||
return textureCoordinates;
|
||||
}
|
||||
|
||||
public void setTextures(TextureCoordinate[] textures) {
|
||||
public void setTextureCoordinates(TextureCoordinate[] textureCoordinates) {
|
||||
|
||||
this.textures = textures;
|
||||
this.textureCoordinates = textureCoordinates;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ public class Group {
|
|||
|
||||
public ArrayList<Integer> indices = new ArrayList<Integer>();
|
||||
public ArrayList<Vertex> vertices = new ArrayList<Vertex>();
|
||||
public ArrayList<Vertex> normals = new ArrayList<Vertex>();
|
||||
public ArrayList<TextureCoordinate> texcoords = new ArrayList<TextureCoordinate>();
|
||||
public ArrayList<Vertex> vertexNormals = new ArrayList<Vertex>();
|
||||
public ArrayList<TextureCoordinate> textureCoordinates = new ArrayList<TextureCoordinate>();
|
||||
public int indexCount;
|
||||
|
||||
public Group(String name) {
|
||||
|
@ -40,14 +40,14 @@ public class Group {
|
|||
currentFace = faces.get(i);
|
||||
for (int j = 0; j < currentFace.getVertices().length; j++) {
|
||||
currentVertex = currentFace.getVertices()[j];
|
||||
if (Math.abs(currentVertex.getX()) > minX) {
|
||||
minX = Math.abs(currentVertex.getX());
|
||||
if (Math.abs(currentVertex.x) > minX) {
|
||||
minX = Math.abs(currentVertex.x);
|
||||
}
|
||||
if (Math.abs(currentVertex.getY()) > minY) {
|
||||
minY = Math.abs(currentVertex.getY());
|
||||
if (Math.abs(currentVertex.y) > minY) {
|
||||
minY = Math.abs(currentVertex.y);
|
||||
}
|
||||
if (Math.abs(currentVertex.getZ()) > minZ) {
|
||||
minZ = Math.abs(currentVertex.getZ());
|
||||
if (Math.abs(currentVertex.z) > minZ) {
|
||||
minZ = Math.abs(currentVertex.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,38 +6,5 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class TextureCoordinate {
|
||||
|
||||
private float u;
|
||||
private float v;
|
||||
private float w;
|
||||
|
||||
public float getU() {
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
public void setU(float u) {
|
||||
|
||||
this.u = u;
|
||||
}
|
||||
|
||||
public float getV() {
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public void setV(float v) {
|
||||
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
public float getW() {
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
public void setW(float w) {
|
||||
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public float u, v, w;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class Vertex {
|
||||
|
||||
private float x;
|
||||
private float y;
|
||||
private float z;
|
||||
public float x, y, z;
|
||||
|
||||
public Vertex() {
|
||||
|
||||
|
@ -21,159 +19,15 @@ public class Vertex {
|
|||
this.z = z;
|
||||
}
|
||||
|
||||
public Vertex(int i, int j) {
|
||||
public Vertex(Vertex vertex) {
|
||||
|
||||
setX(i);
|
||||
setY(j);
|
||||
this.x = vertex.x;
|
||||
this.y = vertex.y;
|
||||
this.z = vertex.z;
|
||||
}
|
||||
|
||||
public Vertex(Vertex position) {
|
||||
|
||||
setX(position.getX());
|
||||
setY(position.getY());
|
||||
setZ(position.getZ());
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(float x) {
|
||||
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(float y) {
|
||||
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public float getZ() {
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(float z) {
|
||||
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public double norm() {
|
||||
|
||||
return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
|
||||
}
|
||||
|
||||
public void normalize() {
|
||||
|
||||
double norm = norm();
|
||||
|
||||
setX(getX() / (float) norm);
|
||||
setY(getY() / (float) norm);
|
||||
setZ(getZ() / (float) norm);
|
||||
}
|
||||
|
||||
public double distanceFrom(Vertex to) {
|
||||
|
||||
return Math.sqrt(this.getX() * to.getX() + this.getY() + to.getY() + this.getZ() * to.getZ());
|
||||
}
|
||||
|
||||
public Vertex rotateZ(double angle) {
|
||||
|
||||
float savedX = getX();
|
||||
x = (float) (x * Math.cos(angle) + y * Math.sin(angle));
|
||||
y = (float) (savedX * -Math.sin(angle) + y * Math.cos(angle));
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public Vertex rotateX(double angle) {
|
||||
|
||||
// Rotation matrix on X is
|
||||
// 1 0 0
|
||||
// 0 cos(x) sin(x)
|
||||
// 0 -sin(x) cos(x)
|
||||
float savedY = y;
|
||||
y = (float) (y * Math.cos(angle) + z * -Math.sin(angle));
|
||||
z = (float) (savedY * Math.sin(angle) + z * Math.cos(angle));
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public Vertex copyAndRotateZ(float angle) {
|
||||
|
||||
float newX = (float) (x * Math.cos(angle) + y * Math.sin(angle));
|
||||
float newY = (float) (x * -Math.sin(angle) + y * Math.cos(angle));
|
||||
|
||||
return new Vertex(newX, newY, z);
|
||||
|
||||
}
|
||||
|
||||
public void add(Vertex offSet) {
|
||||
|
||||
x += offSet.getX();
|
||||
y += offSet.getY();
|
||||
z += offSet.getZ();
|
||||
}
|
||||
|
||||
public Vertex copyAndAdd(Vertex offSet) {
|
||||
|
||||
return new Vertex(getX() + offSet.getX(), getY() + offSet.getY(), getZ() + offSet.getZ());
|
||||
}
|
||||
|
||||
public Vertex mult(Vertex offSet) {
|
||||
|
||||
return new Vertex(getX() * offSet.getX(), getY() * offSet.getY(), getZ() * offSet.getZ());
|
||||
}
|
||||
|
||||
public Vertex mult(double factor) {
|
||||
|
||||
return mult((float) factor);
|
||||
}
|
||||
|
||||
public Vertex mult(float factor) {
|
||||
|
||||
return new Vertex(getX() * factor, getY() * factor, getZ() * factor);
|
||||
}
|
||||
|
||||
public Vertex copyAndSub(Vertex v) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return new Vertex(getX() - v.getX(), getY() - v.getY(), getZ() - v.getZ());
|
||||
}
|
||||
|
||||
public Vertex copyAndMult(float coef) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return new Vertex(getX() * coef, getY() * coef, getZ() * coef);
|
||||
}
|
||||
|
||||
public float dot(Vertex v) {
|
||||
|
||||
return v.x * x + v.y * y;//+ v.z * z;
|
||||
}
|
||||
|
||||
public float perpDot(Vertex v) {
|
||||
|
||||
return x * v.y - y * v.x;
|
||||
}
|
||||
|
||||
public void subFrom(Vertex position) {
|
||||
|
||||
setX(position.getX() - getX());
|
||||
setY(position.getY() - getY());
|
||||
setZ(position.getZ() - getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "x=" + x + ",y=" + y + ",z=" + z;
|
||||
return "x: " + x + ", y: " + y + ", z: " + z;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
public class WavefrontObject {
|
||||
|
||||
private ArrayList<Vertex> vertices = new ArrayList<Vertex>();
|
||||
private ArrayList<Vertex> normals = new ArrayList<Vertex>();
|
||||
private ArrayList<Vertex> vertexNormals = new ArrayList<Vertex>();
|
||||
private ArrayList<TextureCoordinate> textureCoordinates = new ArrayList<TextureCoordinate>();
|
||||
private ArrayList<Group> groups = new ArrayList<Group>();
|
||||
private Hashtable<String, Group> groupsDirectAccess = new Hashtable<String, Group>();
|
||||
|
@ -68,26 +68,12 @@ public class WavefrontObject {
|
|||
this.zScale = zScale;
|
||||
|
||||
parse(fileName);
|
||||
|
||||
calculateRadius();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("Error, could not load obj:" + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateRadius() {
|
||||
|
||||
double currentNorm = 0;
|
||||
for (Vertex vertex : vertices) {
|
||||
currentNorm = vertex.norm();
|
||||
if (currentNorm > radius) {
|
||||
radius = currentNorm;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void parse(String fileName) {
|
||||
|
||||
BufferedReader reader = null;
|
||||
|
@ -128,9 +114,9 @@ public class WavefrontObject {
|
|||
}
|
||||
}
|
||||
|
||||
public void setTextureCoordinates(ArrayList<TextureCoordinate> textures) {
|
||||
public void setTextureCoordinates(ArrayList<TextureCoordinate> textureCoordinates) {
|
||||
|
||||
textureCoordinates = textures;
|
||||
this.textureCoordinates = textureCoordinates;
|
||||
}
|
||||
|
||||
public ArrayList<TextureCoordinate> getTextureCoordinates() {
|
||||
|
@ -148,14 +134,14 @@ public class WavefrontObject {
|
|||
return vertices;
|
||||
}
|
||||
|
||||
public void setNormals(ArrayList<Vertex> normals) {
|
||||
public void setVertexNormals(ArrayList<Vertex> vertexNormals) {
|
||||
|
||||
this.normals = normals;
|
||||
this.vertexNormals = vertexNormals;
|
||||
}
|
||||
|
||||
public ArrayList<Vertex> getNormals() {
|
||||
public ArrayList<Vertex> getVertexNormals() {
|
||||
|
||||
return normals;
|
||||
return vertexNormals;
|
||||
}
|
||||
|
||||
public ArrayList<Group> getGroups() {
|
||||
|
@ -190,25 +176,25 @@ public class WavefrontObject {
|
|||
Vertex currentVertex = null;
|
||||
for (int i = 0; i < getVertices().size(); i++) {
|
||||
currentVertex = getVertices().get(i);
|
||||
if (currentVertex.getX() > maxX) {
|
||||
maxX = currentVertex.getX();
|
||||
if (currentVertex.x > maxX) {
|
||||
maxX = currentVertex.x;
|
||||
}
|
||||
if (currentVertex.getX() < minX) {
|
||||
minX = currentVertex.getX();
|
||||
if (currentVertex.x < minX) {
|
||||
minX = currentVertex.x;
|
||||
}
|
||||
|
||||
if (currentVertex.getY() > maxY) {
|
||||
maxY = currentVertex.getY();
|
||||
if (currentVertex.y > maxY) {
|
||||
maxY = currentVertex.y;
|
||||
}
|
||||
if (currentVertex.getY() < minY) {
|
||||
minY = currentVertex.getY();
|
||||
if (currentVertex.y < minY) {
|
||||
minY = currentVertex.y;
|
||||
}
|
||||
|
||||
if (currentVertex.getZ() > maxZ) {
|
||||
maxZ = currentVertex.getZ();
|
||||
if (currentVertex.z > maxZ) {
|
||||
maxZ = currentVertex.z;
|
||||
}
|
||||
if (currentVertex.getZ() < minZ) {
|
||||
minZ = currentVertex.getZ();
|
||||
if (currentVertex.z < minZ) {
|
||||
minZ = currentVertex.z;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class FaceParser extends LineParser {
|
|||
currentValue = Integer.parseInt(rawFaces[2]);
|
||||
|
||||
nindices[i - 1] = currentValue - 1;
|
||||
normals[i - 1] = object.getNormals().get(currentValue - 1); // -1 because references starts at 1
|
||||
normals[i - 1] = object.getVertexNormals().get(currentValue - 1); // -1 because references starts at 1
|
||||
}
|
||||
//System.out.println("");
|
||||
}
|
||||
|
@ -124,23 +124,23 @@ public class FaceParser extends LineParser {
|
|||
group.vertices.add(vertices[0]);
|
||||
group.vertices.add(vertices[1]);
|
||||
group.vertices.add(vertices[2]);
|
||||
group.normals.add(normals[0]);
|
||||
group.normals.add(normals[1]);
|
||||
group.normals.add(normals[2]);
|
||||
group.texcoords.add(textures[0]);
|
||||
group.texcoords.add(textures[1]);
|
||||
group.texcoords.add(textures[2]);
|
||||
group.vertexNormals.add(normals[0]);
|
||||
group.vertexNormals.add(normals[1]);
|
||||
group.vertexNormals.add(normals[2]);
|
||||
group.textureCoordinates.add(textures[0]);
|
||||
group.textureCoordinates.add(textures[1]);
|
||||
group.textureCoordinates.add(textures[2]);
|
||||
group.indices.add(group.indexCount++);
|
||||
group.indices.add(group.indexCount++);
|
||||
group.indices.add(group.indexCount++); // create index list for current object
|
||||
|
||||
face.vertIndices = vindices;
|
||||
face.normIndices = nindices;
|
||||
face.texIndices = tindices;
|
||||
face.setNormals(normals);
|
||||
face.setNormals(normals);
|
||||
face.vertexIndices = vindices;
|
||||
face.vertexNormalIndices = nindices;
|
||||
face.textureCoordinateIndices = tindices;
|
||||
face.setVertexNormals(normals);
|
||||
face.setVertexNormals(normals);
|
||||
face.setVertices(vertices);
|
||||
face.setTextures(textures);
|
||||
face.setTextureCoordinates(textures);
|
||||
|
||||
wavefrontObject.getCurrentGroup().addFace(face);
|
||||
}
|
||||
|
@ -151,26 +151,26 @@ public class FaceParser extends LineParser {
|
|||
group.vertices.add(vertices[1]);
|
||||
group.vertices.add(vertices[2]);
|
||||
group.vertices.add(vertices[3]);
|
||||
group.normals.add(normals[0]);
|
||||
group.normals.add(normals[1]);
|
||||
group.normals.add(normals[2]);
|
||||
group.normals.add(normals[3]);
|
||||
group.texcoords.add(textures[0]);
|
||||
group.texcoords.add(textures[1]);
|
||||
group.texcoords.add(textures[2]);
|
||||
group.texcoords.add(textures[3]);
|
||||
group.vertexNormals.add(normals[0]);
|
||||
group.vertexNormals.add(normals[1]);
|
||||
group.vertexNormals.add(normals[2]);
|
||||
group.vertexNormals.add(normals[3]);
|
||||
group.textureCoordinates.add(textures[0]);
|
||||
group.textureCoordinates.add(textures[1]);
|
||||
group.textureCoordinates.add(textures[2]);
|
||||
group.textureCoordinates.add(textures[3]);
|
||||
group.indices.add(group.indexCount++);
|
||||
group.indices.add(group.indexCount++);
|
||||
group.indices.add(group.indexCount++);
|
||||
group.indices.add(group.indexCount++); // create index list for current object
|
||||
|
||||
face.vertIndices = vindices;
|
||||
face.normIndices = nindices;
|
||||
face.texIndices = tindices;
|
||||
face.setNormals(normals);
|
||||
face.setNormals(normals);
|
||||
face.vertexIndices = vindices;
|
||||
face.vertexNormalIndices = nindices;
|
||||
face.textureCoordinateIndices = tindices;
|
||||
face.setVertexNormals(normals);
|
||||
face.setVertexNormals(normals);
|
||||
face.setVertices(vertices);
|
||||
face.setTextures(textures);
|
||||
face.setTextureCoordinates(textures);
|
||||
|
||||
wavefrontObject.getCurrentGroup().addFace(face);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@ public class NormalParser extends LineParser {
|
|||
Vertex vertex = null;
|
||||
|
||||
public NormalParser() {
|
||||
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,9 +19,9 @@ public class NormalParser extends LineParser {
|
|||
vertex = new Vertex();
|
||||
|
||||
try {
|
||||
vertex.setX(Float.parseFloat(words[1]));
|
||||
vertex.setY(Float.parseFloat(words[2]));
|
||||
vertex.setZ(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");
|
||||
|
@ -34,8 +32,6 @@ public class NormalParser extends LineParser {
|
|||
@Override
|
||||
public void incoporateResults(WavefrontObject wavefrontObject) {
|
||||
|
||||
wavefrontObject.getNormals().add(vertex);
|
||||
|
||||
wavefrontObject.getVertexNormals().add(vertex);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,15 +20,15 @@ public class TextureCoordinateParser extends LineParser {
|
|||
coordinate = new TextureCoordinate();
|
||||
try {
|
||||
if (words.length >= 2) {
|
||||
coordinate.setU(Float.parseFloat(words[1]));
|
||||
coordinate.u = (Float.parseFloat(words[1]));
|
||||
}
|
||||
|
||||
if (words.length >= 3) {
|
||||
coordinate.setV(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.setW(Float.parseFloat(words[3]));
|
||||
coordinate.w = (Float.parseFloat(words[3]));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,5 @@ public class TextureCoordinateParser extends LineParser {
|
|||
public void incoporateResults(WavefrontObject wavefrontObject) {
|
||||
|
||||
wavefrontObject.getTextureCoordinates().add(coordinate);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ public class VertexParser extends LineParser {
|
|||
vertex = new Vertex();
|
||||
|
||||
try {
|
||||
vertex.setX(Float.parseFloat(words[1]));
|
||||
vertex.setY(Float.parseFloat(words[2]));
|
||||
vertex.setZ(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.setX((vertex.getX() + wavefrontObject.translate.getX()) * wavefrontObject.xScale);
|
||||
vertex.setY((vertex.getY() + wavefrontObject.translate.getY()) * wavefrontObject.yScale);
|
||||
vertex.setZ((vertex.getZ() + wavefrontObject.translate.getZ()) * 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue