2013-03-15 03:14:02 +01:00
|
|
|
package net.minecraftforge.client.model.obj;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2013-03-19 03:37:03 +01:00
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
2013-03-15 03:14:02 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class Group {
|
|
|
|
|
|
|
|
private String name;
|
|
|
|
private Vertex min = null;
|
|
|
|
private ArrayList<Face> faces = new ArrayList<Face>();
|
|
|
|
|
|
|
|
public ArrayList<Integer> indices = new ArrayList<Integer>();
|
|
|
|
public ArrayList<Vertex> vertices = new ArrayList<Vertex>();
|
2013-03-15 20:18:01 +01:00
|
|
|
public ArrayList<Vertex> vertexNormals = new ArrayList<Vertex>();
|
|
|
|
public ArrayList<TextureCoordinate> textureCoordinates = new ArrayList<TextureCoordinate>();
|
2013-03-15 03:14:02 +01:00
|
|
|
public int indexCount;
|
|
|
|
|
|
|
|
public Group(String name) {
|
|
|
|
|
|
|
|
indexCount = 0;
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addFace(Face face) {
|
|
|
|
|
|
|
|
faces.add(face);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void pack() {
|
|
|
|
|
|
|
|
float minX = 0;
|
|
|
|
float minY = 0;
|
|
|
|
float minZ = 0;
|
|
|
|
Face currentFace = null;
|
|
|
|
Vertex currentVertex = null;
|
|
|
|
for (int i = 0; i < faces.size(); i++) {
|
|
|
|
currentFace = faces.get(i);
|
2013-03-19 03:37:03 +01:00
|
|
|
for (int j = 0; j < currentFace.vertices.length; j++) {
|
|
|
|
currentVertex = currentFace.vertices[j];
|
2013-03-15 20:18:01 +01:00
|
|
|
if (Math.abs(currentVertex.x) > minX) {
|
|
|
|
minX = Math.abs(currentVertex.x);
|
2013-03-15 03:14:02 +01:00
|
|
|
}
|
2013-03-15 20:18:01 +01:00
|
|
|
if (Math.abs(currentVertex.y) > minY) {
|
|
|
|
minY = Math.abs(currentVertex.y);
|
2013-03-15 03:14:02 +01:00
|
|
|
}
|
2013-03-15 20:18:01 +01:00
|
|
|
if (Math.abs(currentVertex.z) > minZ) {
|
|
|
|
minZ = Math.abs(currentVertex.z);
|
2013-03-15 03:14:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
min = new Vertex(minX, minY, minZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayList<Face> getFaces() {
|
|
|
|
|
|
|
|
return faces;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Vertex getMin() {
|
|
|
|
|
|
|
|
return min;
|
|
|
|
}
|
2013-03-19 03:37:03 +01:00
|
|
|
|
|
|
|
public void render(Tessellator tessellator, float scale) {
|
|
|
|
|
|
|
|
for (Face face : faces) {
|
|
|
|
face.render(tessellator, 0F, scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void render(Tessellator tessellator, float textureOffset, float scale) {
|
|
|
|
|
|
|
|
for (Face face : faces) {
|
|
|
|
face.render(tessellator, textureOffset, scale);
|
|
|
|
}
|
|
|
|
}
|
2013-03-15 03:14:02 +01:00
|
|
|
}
|