Advanced Model Loader available server-side for data driven models. To be cleanuped and re-evaluated in 1.8. Closes #773

This commit is contained in:
Lex Manos committed 2014-04-01 15:02:06 -07:00
1 parent d9a1c718bf
commit aa0c902d22
8 files changed
+56 -12

No files matched your search

@@ -1,4 +1,5 @@
package net.minecraftforge.client.model;
// TODO: Move this package to net.minecraftforge.model in 1.8
import java.util.Collection;
import java.util.Map;
@@ -1,11 +1,17 @@
package net.minecraftforge.client.model;
import static cpw.mods.fml.relauncher.Side.CLIENT;
import cpw.mods.fml.relauncher.SideOnly;
public interface IModelCustom {
public interface IModelCustom
{
String getType();
@SideOnly(CLIENT)
void renderAll();
@SideOnly(CLIENT)
void renderOnly(String... groupNames);
@SideOnly(CLIENT)
void renderPart(String partName);
@SideOnly(CLIENT)
void renderAllExcept(String... excludedGroupNames);
}
@@ -5,20 +5,20 @@ import net.minecraft.util.Vec3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class Face
{
public Vertex[] vertices;
public Vertex[] vertexNormals;
public Vertex faceNormal;
public TextureCoordinate[] textureCoordinates;
@SideOnly(Side.CLIENT)
public void addFaceForRender(Tessellator tessellator)
{
addFaceForRender(tessellator, 0.0005F);
}
@SideOnly(Side.CLIENT)
public void addFaceForRender(Tessellator tessellator, float textureOffset)
{
if (faceNormal == null)
@@ -6,10 +6,8 @@ import net.minecraft.client.renderer.Tessellator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GroupObject
{
public String name;
public ArrayList<Face> faces = new ArrayList<Face>();
public int glDrawingMode;
@@ -30,6 +28,7 @@ public class GroupObject
this.glDrawingMode = glDrawingMode;
}
@SideOnly(Side.CLIENT)
public void render()
{
if (faces.size() > 0)
@@ -41,6 +40,7 @@ public class GroupObject
}
}
@SideOnly(Side.CLIENT)
public void render(Tessellator tessellator)
{
if (faces.size() > 0)
@@ -3,10 +3,8 @@ package net.minecraftforge.client.model.obj;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class TextureCoordinate
{
public float u, v, w;
public TextureCoordinate(float u, float v)
@@ -3,10 +3,8 @@ package net.minecraftforge.client.model.obj;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class Vertex
{
public float x, y, z;
public Vertex(float x, float y)
@@ -24,10 +24,8 @@ import cpw.mods.fml.relauncher.SideOnly;
* Wavefront Object importer
* Based heavily off of the specifications found at http://en.wikipedia.org/wiki/Wavefront_.obj_file
*/
@SideOnly(Side.CLIENT)
public class WavefrontObject implements IModelCustom
{
private static Pattern vertexPattern = Pattern.compile("(v( (\\-){0,1}\\d+\\.\\d+){3,4} *\\n)|(v( (\\-){0,1}\\d+\\.\\d+){3,4} *$)");
private static Pattern vertexNormalPattern = Pattern.compile("(vn( (\\-){0,1}\\d+\\.\\d+){3,4} *\\n)|(vn( (\\-){0,1}\\d+\\.\\d+){3,4} *$)");
private static Pattern textureCoordinatePattern = Pattern.compile("(vt( (\\-){0,1}\\d+\\.\\d+){2,3} *\\n)|(vt( (\\-){0,1}\\d+\\.\\d+){2,3} *$)");
@@ -173,6 +171,7 @@ public class WavefrontObject implements IModelCustom
}
@Override
@SideOnly(Side.CLIENT)
public void renderAll()
{
Tessellator tessellator = Tessellator.instance;
@@ -190,6 +189,7 @@ public class WavefrontObject implements IModelCustom
tessellator.draw();
}
@SideOnly(Side.CLIENT)
public void tessellateAll(Tessellator tessellator)
{
for (GroupObject groupObject : groupObjects)
@@ -199,6 +199,7 @@ public class WavefrontObject implements IModelCustom
}
@Override
@SideOnly(Side.CLIENT)
public void renderOnly(String... groupNames)
{
for (GroupObject groupObject : groupObjects)
@@ -213,6 +214,7 @@ public class WavefrontObject implements IModelCustom
}
}
@SideOnly(Side.CLIENT)
public void tessellateOnly(Tessellator tessellator, String... groupNames) {
for (GroupObject groupObject : groupObjects)
{
@@ -227,6 +229,7 @@ public class WavefrontObject implements IModelCustom
}
@Override
@SideOnly(Side.CLIENT)
public void renderPart(String partName)
{
for (GroupObject groupObject : groupObjects)
@@ -238,6 +241,7 @@ public class WavefrontObject implements IModelCustom
}
}
@SideOnly(Side.CLIENT)
public void tessellatePart(Tessellator tessellator, String partName) {
for (GroupObject groupObject : groupObjects)
{
@@ -249,6 +253,7 @@ public class WavefrontObject implements IModelCustom
}
@Override
@SideOnly(Side.CLIENT)
public void renderAllExcept(String... excludedGroupNames)
{
for (GroupObject groupObject : groupObjects)
@@ -268,6 +273,7 @@ public class WavefrontObject implements IModelCustom
}
}
@SideOnly(Side.CLIENT)
public void tessellateAllExcept(Tessellator tessellator, String... excludedGroupNames)
{
boolean exclude;