Adjust visibility of the parseObj method, add a URL based constructor, modified renderAll for further performance optimizations
This commit is contained in:
parent
30a8bdcb94
commit
fedf87c304
2 changed files with 32 additions and 6 deletions
|
@ -47,4 +47,14 @@ public class GroupObject {
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void render(Tessellator tessellator) {
|
||||||
|
|
||||||
|
if (faces.size() > 0) {
|
||||||
|
|
||||||
|
for (Face face : faces) {
|
||||||
|
face.addFaceForRender(tessellator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
@ -28,21 +30,24 @@ public class WavefrontObject {
|
||||||
public ArrayList<Vertex> vertexNormals = new ArrayList<Vertex>();
|
public ArrayList<Vertex> vertexNormals = new ArrayList<Vertex>();
|
||||||
public ArrayList<TextureCoordinate> textureCoordinates = new ArrayList<TextureCoordinate>();
|
public ArrayList<TextureCoordinate> textureCoordinates = new ArrayList<TextureCoordinate>();
|
||||||
public ArrayList<GroupObject> groupObjects = new ArrayList<GroupObject>();
|
public ArrayList<GroupObject> groupObjects = new ArrayList<GroupObject>();
|
||||||
public String fileName;
|
|
||||||
private GroupObject currentGroupObject;
|
private GroupObject currentGroupObject;
|
||||||
|
|
||||||
public WavefrontObject(String fileName) {
|
public WavefrontObject(String fileName) {
|
||||||
|
|
||||||
this.fileName = fileName;
|
|
||||||
parseObjModel(fileName);
|
parseObjModel(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WavefrontObject(URL fileURL) {
|
||||||
|
|
||||||
|
parseObjModel(fileURL);
|
||||||
|
}
|
||||||
|
|
||||||
public void parseObjModel(String fileName) {
|
private void parseObjModel(String fileName) {
|
||||||
|
|
||||||
parseObjModel(this.getClass().getResource(fileName));
|
parseObjModel(this.getClass().getResource(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void parseObjModel(URL fileURL) {
|
private void parseObjModel(URL fileURL) {
|
||||||
|
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
|
@ -118,9 +123,20 @@ public class WavefrontObject {
|
||||||
|
|
||||||
public void renderAll() {
|
public void renderAll() {
|
||||||
|
|
||||||
for (GroupObject groupObject : groupObjects) {
|
Tessellator tessellator = Tessellator.instance;
|
||||||
groupObject.render();
|
|
||||||
|
if (currentGroupObject != null) {
|
||||||
|
tessellator.startDrawing(currentGroupObject.glDrawingMode);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
tessellator.startDrawing(GL11.GL_TRIANGLES);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (GroupObject groupObject : groupObjects) {
|
||||||
|
groupObject.render(tessellator);
|
||||||
|
}
|
||||||
|
|
||||||
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderOnly(String ... groupNames) {
|
public void renderOnly(String ... groupNames) {
|
||||||
|
|
Loading…
Reference in a new issue