Merge branch 'objTessellation' of github.com:MachineMuse/MinecraftForge into sometweaks

This commit is contained in:
Christian 2013-09-05 07:58:56 -04:00
commit e499a6d375
2 changed files with 65 additions and 10 deletions

View File

@ -5,5 +5,7 @@ package net.minecraftforge.client.model;
public interface IModelCustom { public interface IModelCustom {
String getType(); String getType();
void renderAll(); void renderAll();
void renderOnly(String... groupNames);
void renderPart(String partName); void renderPart(String partName);
void renderAllExcept(String... excludedGroupNames);
} }

View File

@ -181,13 +181,17 @@ public class WavefrontObject implements IModelCustom
{ {
tessellator.startDrawing(GL11.GL_TRIANGLES); tessellator.startDrawing(GL11.GL_TRIANGLES);
} }
tessellateAll(tessellator);
tessellator.draw();
}
public void tessellateAll(Tessellator tessellator)
{
for (GroupObject groupObject : groupObjects) for (GroupObject groupObject : groupObjects)
{ {
groupObject.render(tessellator); groupObject.render(tessellator);
} }
tessellator.draw();
} }
public void renderOnly(String... groupNames) public void renderOnly(String... groupNames)
@ -204,6 +208,19 @@ public class WavefrontObject implements IModelCustom
} }
} }
public void tessellateOnly(Tessellator tessellator, String... groupNames) {
for (GroupObject groupObject : groupObjects)
{
for (String groupName : groupNames)
{
if (groupName.equalsIgnoreCase(groupObject.name))
{
groupObject.render(tessellator);
}
}
}
}
public void renderPart(String partName) public void renderPart(String partName)
{ {
for (GroupObject groupObject : groupObjects) for (GroupObject groupObject : groupObjects)
@ -215,17 +232,53 @@ public class WavefrontObject implements IModelCustom
} }
} }
public void renderAllExcept(String... excludedGroupNames) public void tessellatePart(Tessellator tessellator, String partName) {
{
for (GroupObject groupObject : groupObjects) for (GroupObject groupObject : groupObjects)
{ {
if (partName.equalsIgnoreCase(groupObject.name))
{
groupObject.render(tessellator);
}
}
}
public void renderAllExcept(String... excludedGroupNames)
{
boolean exclude;
for (GroupObject groupObject : groupObjects)
{
exclude=false;
for (String excludedGroupName : excludedGroupNames) for (String excludedGroupName : excludedGroupNames)
{ {
if (!excludedGroupName.equalsIgnoreCase(groupObject.name)) if (excludedGroupName.equalsIgnoreCase(groupObject.name))
{ {
groupObject.render(); exclude=true;
} }
} }
if(!exclude)
{
groupObject.render();
}
}
}
public void tessellateAllExcept(Tessellator tessellator, String... excludedGroupNames)
{
boolean exclude;
for (GroupObject groupObject : groupObjects)
{
exclude=false;
for (String excludedGroupName : excludedGroupNames)
{
if (excludedGroupName.equalsIgnoreCase(groupObject.name))
{
exclude=true;
}
}
if(!exclude)
{
groupObject.render(tessellator);
}
} }
} }
@ -359,7 +412,7 @@ public class WavefrontObject implements IModelCustom
face.vertices = new Vertex[tokens.length]; face.vertices = new Vertex[tokens.length];
face.textureCoordinates = new TextureCoordinate[tokens.length]; face.textureCoordinates = new TextureCoordinate[tokens.length];
face.vertexNormals = new Vertex[tokens.length]; face.vertexNormals = new Vertex[tokens.length];
for (int i = 0; i < tokens.length; ++i) for (int i = 0; i < tokens.length; ++i)
{ {
subTokens = tokens[i].split("/"); subTokens = tokens[i].split("/");
@ -376,7 +429,7 @@ public class WavefrontObject implements IModelCustom
{ {
face.vertices = new Vertex[tokens.length]; face.vertices = new Vertex[tokens.length];
face.textureCoordinates = new TextureCoordinate[tokens.length]; face.textureCoordinates = new TextureCoordinate[tokens.length];
for (int i = 0; i < tokens.length; ++i) for (int i = 0; i < tokens.length; ++i)
{ {
subTokens = tokens[i].split("/"); subTokens = tokens[i].split("/");
@ -392,7 +445,7 @@ public class WavefrontObject implements IModelCustom
{ {
face.vertices = new Vertex[tokens.length]; face.vertices = new Vertex[tokens.length];
face.vertexNormals = new Vertex[tokens.length]; face.vertexNormals = new Vertex[tokens.length];
for (int i = 0; i < tokens.length; ++i) for (int i = 0; i < tokens.length; ++i)
{ {
subTokens = tokens[i].split("//"); subTokens = tokens[i].split("//");
@ -407,7 +460,7 @@ public class WavefrontObject implements IModelCustom
else if (isValidFace_V_Line(line)) else if (isValidFace_V_Line(line))
{ {
face.vertices = new Vertex[tokens.length]; face.vertices = new Vertex[tokens.length];
for (int i = 0; i < tokens.length; ++i) for (int i = 0; i < tokens.length; ++i)
{ {
face.vertices[i] = vertices.get(Integer.parseInt(tokens[i]) - 1); face.vertices[i] = vertices.get(Integer.parseInt(tokens[i]) - 1);