diff --git a/src/main/java/train/client/render/CustomModelRenderer.java b/src/main/java/train/client/render/CustomModelRenderer.java index bbc06e9ed3..5a19ba0e48 100644 --- a/src/main/java/train/client/render/CustomModelRenderer.java +++ b/src/main/java/train/client/render/CustomModelRenderer.java @@ -7,90 +7,90 @@ import java.util.ArrayList; public class CustomModelRenderer extends ModelRendererTurbo { - public CustomModelRenderer(ModelBase m, int i, int j, int w, int h) { - super(m, i, j, w, h); - } - @Override - public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int k) { - addBox(f, f1, f2, i, j, k, 0.0f); - return this; - } - // For some odd reason the boxes seem inside out normally, so it's likely the values are reversed - @Override - public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int k, float f3) { - faces = new ArrayList<>(); - float f4 = f + i + f3; - float f5 = f1 + j + f3; - float f6 = f2 + k + f3; + public CustomModelRenderer(ModelBase m, int i, int j, int w, int h) { + super(m,i,j,w,h); + } + + @Override + public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int k) { + addBox(f, f1, f2, i, j, k, 0.0f); + return this; + } + + //for some odd reason the boxes seem inside out normally, so it's likely the values are reversed + @Override + public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int k, float f3) { + faces = new ArrayList(); + float f4 = f + i +f3; + float f5 = f1 + j +f3; + float f6 = f2 + k +f3; + f -= f3; + f1 -= f3; + f2 -= f3; + TexturedVertex TexturedVertex = new TexturedVertex(f, f1, f2, 0.0F, 0.0F); + TexturedVertex TexturedVertex1 = new TexturedVertex(f4, f1, f2, 0.0F, 8F); + TexturedVertex TexturedVertex2 = new TexturedVertex(f4, f5, f2, 8F, 8F); + TexturedVertex TexturedVertex3 = new TexturedVertex(f, f5, f2, 8F, 0.0F); + TexturedVertex TexturedVertex4 = new TexturedVertex(f, f1, f6, 0.0F, 0.0F); + TexturedVertex TexturedVertex5 = new TexturedVertex(f4, f1, f6, 0.0F, 8F); + TexturedVertex TexturedVertex6 = new TexturedVertex(f4, f5, f6, 8F, 8F); + TexturedVertex TexturedVertex7 = new TexturedVertex(f, f5, f6, 8F, 0.0F); + faces.add(generateFaces(new TexturedVertex[] { TexturedVertex5, TexturedVertex1, TexturedVertex2, TexturedVertex6 }, textureOffsetX + k + i, textureOffsetY + k, textureOffsetX + k + i + k, textureOffsetY + k + j, textureWidth, textureHeight)); + faces.add(generateFaces(new TexturedVertex[] { TexturedVertex, TexturedVertex4, TexturedVertex7, TexturedVertex3 }, textureOffsetX, textureOffsetY + k, textureOffsetX + k, textureOffsetY + k + j, textureWidth, textureHeight)); + faces.add(generateFaces(new TexturedVertex[] { TexturedVertex5, TexturedVertex4, TexturedVertex, TexturedVertex1 }, textureOffsetX + k, textureOffsetY, textureOffsetX + k + i, textureOffsetY + k, textureWidth, textureHeight)); + faces.add(generateFaces(new TexturedVertex[] { TexturedVertex2, TexturedVertex3, TexturedVertex7, TexturedVertex6 }, textureOffsetX + k + i, textureOffsetY, textureOffsetX + k + i + i, textureOffsetY + k, textureWidth, textureHeight)); + faces.add(generateFaces(new TexturedVertex[] { TexturedVertex1, TexturedVertex, TexturedVertex3, TexturedVertex2 }, textureOffsetX + k, textureOffsetY + k, textureOffsetX + k + i, textureOffsetY + k + j, textureWidth, textureHeight)); + faces.add(generateFaces(new TexturedVertex[] { TexturedVertex4, TexturedVertex5, TexturedVertex6, TexturedVertex7 }, textureOffsetX + k + i + k, textureOffsetY + k, textureOffsetX + k + i + k + i, textureOffsetY + k + j, textureWidth, textureHeight)); + return this; + } + + private static TexturedPolygon generateFaces(TexturedVertex aPositionTransformVertex[], int i, int j, int k, int l, float textureWidth, float textureHeight) { + aPositionTransformVertex[0] = new TexturedVertex(aPositionTransformVertex[0].vector3F, (float) k / textureWidth - 0.0015625F, (float) j / textureHeight + 0.003125F); + aPositionTransformVertex[1] = new TexturedVertex(aPositionTransformVertex[1].vector3F,(float) i / textureWidth + 0.0015625F, (float) j / textureHeight + 0.003125F); + aPositionTransformVertex[2] = new TexturedVertex(aPositionTransformVertex[2].vector3F,(float) i / textureWidth + 0.0015625F, (float) l / textureHeight - 0.003125F); + aPositionTransformVertex[3] = new TexturedVertex(aPositionTransformVertex[3].vector3F,(float) k / textureWidth - 0.0015625F, (float) l / textureHeight - 0.003125F); + return new TexturedPolygon(aPositionTransformVertex); + } + + private static final float degreesF = (float)(180D/Math.PI); + + //same as super, but old models have inverse Y rotations and I don't even understand the Z rotation + public void render(float worldScale) { + + if(!showModel) { + return; + } + if (rotateAngleX != 0.0F || rotateAngleY != 0.0F || rotateAngleZ != 0.0F) { + GL11.glPushMatrix(); + GL11.glTranslatef(rotationPointX * worldScale, rotationPointY * worldScale, rotationPointZ *worldScale); + if (rotateAngleZ != 0.0F) { + GL11.glRotatef(rotateAngleZ * degreesF, 0.0F, 0.0F, 1.0F); + } + if (rotateAngleY != 0.0F) { + GL11.glRotatef(rotateAngleY * degreesF, 0.0F, 1.0F, 0.0F); + } + if (rotateAngleX != 0.0F) { + GL11.glRotatef(rotateAngleX * degreesF, 1.0F, 0.0F, 0.0F); + } + for (TexturedPolygon poly : faces) { + Tessellator.getInstance().drawTexturedVertsWithNormal(poly, worldScale); + } + GL11.glPopMatrix(); + } + else if (rotationPointX != 0.0F || rotationPointY != 0.0F || rotationPointZ != 0.0F) { + GL11.glTranslatef(rotationPointX * worldScale, rotationPointY * worldScale, rotationPointZ * worldScale); + for (TexturedPolygon poly : faces) { + Tessellator.getInstance().drawTexturedVertsWithNormal(poly, worldScale); + } + GL11.glTranslatef(-rotationPointX * worldScale, -rotationPointY * worldScale, -rotationPointZ * worldScale); + } + else { + for (TexturedPolygon poly : faces) { + Tessellator.getInstance().drawTexturedVertsWithNormal(poly, worldScale); + } + } + } - f -= f3; - f1 -= f3; - f2 -= f3; - - TexturedVertex TexturedVertex = new TexturedVertex(f, f1, f2, 0.0F, 0.0F); - TexturedVertex TexturedVertex1 = new TexturedVertex(f4, f1, f2, 0.0F, 8F); - TexturedVertex TexturedVertex2 = new TexturedVertex(f4, f5, f2, 8F, 8F); - TexturedVertex TexturedVertex3 = new TexturedVertex(f, f5, f2, 8F, 0.0F); - TexturedVertex TexturedVertex4 = new TexturedVertex(f, f1, f6, 0.0F, 0.0F); - TexturedVertex TexturedVertex5 = new TexturedVertex(f4, f1, f6, 0.0F, 8F); - TexturedVertex TexturedVertex6 = new TexturedVertex(f4, f5, f6, 8F, 8F); - TexturedVertex TexturedVertex7 = new TexturedVertex(f, f5, f6, 8F, 0.0F); - - faces.add(generateFaces(new TexturedVertex[]{TexturedVertex5, TexturedVertex1, TexturedVertex2, TexturedVertex6}, textureOffsetX + k + i, textureOffsetY + k, textureOffsetX + k + i + k, textureOffsetY + k + j, textureWidth, textureHeight)); - faces.add(generateFaces(new TexturedVertex[]{TexturedVertex, TexturedVertex4, TexturedVertex7, TexturedVertex3}, textureOffsetX, textureOffsetY + k, textureOffsetX + k, textureOffsetY + k + j, textureWidth, textureHeight)); - faces.add(generateFaces(new TexturedVertex[]{TexturedVertex5, TexturedVertex4, TexturedVertex, TexturedVertex1}, textureOffsetX + k, textureOffsetY, textureOffsetX + k + i, textureOffsetY + k, textureWidth, textureHeight)); - faces.add(generateFaces(new TexturedVertex[]{TexturedVertex2, TexturedVertex3, TexturedVertex7, TexturedVertex6}, textureOffsetX + k + i, textureOffsetY, textureOffsetX + k + i + i, textureOffsetY + k, textureWidth, textureHeight)); - faces.add(generateFaces(new TexturedVertex[]{TexturedVertex1, TexturedVertex, TexturedVertex3, TexturedVertex2}, textureOffsetX + k, textureOffsetY + k, textureOffsetX + k + i, textureOffsetY + k + j, textureWidth, textureHeight)); - faces.add(generateFaces(new TexturedVertex[]{TexturedVertex4, TexturedVertex5, TexturedVertex6, TexturedVertex7}, textureOffsetX + k + i + k, textureOffsetY + k, textureOffsetX + k + i + k + i, textureOffsetY + k + j, textureWidth, textureHeight)); - return this; - } - - private static TexturedPolygon generateFaces(TexturedVertex aPositionTransformVertex[], int i, int j, int k, int l, float textureWidth, float textureHeight) { - aPositionTransformVertex[0] = new TexturedVertex(aPositionTransformVertex[0].vector3F, (float) k / textureWidth - 0.0015625F, (float) j / textureHeight + 0.003125F); - aPositionTransformVertex[1] = new TexturedVertex(aPositionTransformVertex[1].vector3F, (float) i / textureWidth + 0.0015625F, (float) j / textureHeight + 0.003125F); - aPositionTransformVertex[2] = new TexturedVertex(aPositionTransformVertex[2].vector3F, (float) i / textureWidth + 0.0015625F, (float) l / textureHeight - 0.003125F); - aPositionTransformVertex[3] = new TexturedVertex(aPositionTransformVertex[3].vector3F, (float) k / textureWidth - 0.0015625F, (float) l / textureHeight - 0.003125F); - return new TexturedPolygon(aPositionTransformVertex); - } - - private static final float degreesF = (float) (180D / Math.PI); - - // Same as super, but old models have inverse Y rotations and I don't even understand the Z rotation - public void render(float worldScale, boolean invertYZ) { - if (!showModel) { - return; - } - - if (!compiled) { - compileDisplayList(worldScale); - return; - } - - if (rotateAngleX != 0.0F || rotateAngleY != 0.0F || rotateAngleZ != 0.0F) { - GL11.glPushMatrix(); - GL11.glTranslatef(rotationPointX * worldScale, rotationPointY * worldScale, rotationPointZ * worldScale); - if (rotateAngleZ != 0.0F) { - GL11.glRotatef(rotateAngleZ * degreesF, 0.0F, 0.0F, 1.0F); - } - - if (rotateAngleY != 0.0F) { - GL11.glRotatef(rotateAngleY * degreesF, 0.0F, 1.0F, 0.0F); - } - - if (rotateAngleX != 0.0F) { - GL11.glRotatef(rotateAngleX * degreesF, 1.0F, 0.0F, 0.0F); - } - - callDisplayList(); - GL11.glPopMatrix(); - } else if (rotationPointX != 0.0F || rotationPointY != 0.0F || rotationPointZ != 0.0F) { - GL11.glTranslatef(rotationPointX * worldScale, rotationPointY * worldScale, rotationPointZ * worldScale); - callDisplayList(); - GL11.glTranslatef(-rotationPointX * worldScale, -rotationPointY * worldScale, -rotationPointZ * worldScale); - } else { - callDisplayList(); - } - } } diff --git a/src/main/java/train/client/render/ItemRenderBook.java b/src/main/java/train/client/render/ItemRenderBook.java index 8dcb3d97d4..7853ae3491 100644 --- a/src/main/java/train/client/render/ItemRenderBook.java +++ b/src/main/java/train/client/render/ItemRenderBook.java @@ -68,7 +68,7 @@ public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { private void renderBook(float left, float up, float right, float rotation, float x, float y, float z, float scale) { Tessellator tesselator = Tessellator.instance; - tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.modelTexPrefix + "book2.png")); + fexcraft.tmt.slim.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.modelTexPrefix + "book2.png")); GL11.glPushMatrix(); GL11.glTranslatef(left, up, right); GL11.glRotatef(rotation, x, y, z); @@ -93,7 +93,7 @@ private void rotateBook(float left, float up, float right, float rotation, float // down = false; // } //System.out.println(w/10); - tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.modelTexPrefix + "book2.png")); + fexcraft.tmt.slim.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.modelTexPrefix + "book2.png")); GL11.glPushMatrix(); GL11.glTranslatef(left, up, right); GL11.glTranslatef(0.5f, 1.f, -0.5f); diff --git a/src/main/java/train/client/render/ItemRenderGeneratorDiesel.java b/src/main/java/train/client/render/ItemRenderGeneratorDiesel.java index 2297714aca..3d28b3d658 100644 --- a/src/main/java/train/client/render/ItemRenderGeneratorDiesel.java +++ b/src/main/java/train/client/render/ItemRenderGeneratorDiesel.java @@ -58,7 +58,7 @@ public void renderItem(ItemRenderType type, ItemStack item, Object... data) { } private void renderGenerator(float f, float g, float h) { - tmt.Tessellator.bindTexture(texture); + fexcraft.tmt.slim.Tessellator.bindTexture(texture); GL11.glPushMatrix(); GL11.glTranslatef(f, g, h); GL11.glScalef(0.7F, 0.7F, 0.7F); diff --git a/src/main/java/train/client/render/ItemRenderLantern.java b/src/main/java/train/client/render/ItemRenderLantern.java index e8ab573853..476b886216 100644 --- a/src/main/java/train/client/render/ItemRenderLantern.java +++ b/src/main/java/train/client/render/ItemRenderLantern.java @@ -52,7 +52,7 @@ private void renderLantern(float x, float y, float z, float scale) { GL11.glTranslatef(x, y, z); GL11.glScalef(scale, scale, scale); - tmt.Tessellator.bindTexture(texture); + fexcraft.tmt.slim.Tessellator.bindTexture(texture); float f2 = (float) (0x4f4e4a >> 16 & 255) / 255.0F; float f3 = (float) (0x4f4e4a >> 8 & 255) / 255.0F; float f4 = (float) (0x4f4e4a & 255) / 255.0F; diff --git a/src/main/java/train/client/render/ItemRenderSignal.java b/src/main/java/train/client/render/ItemRenderSignal.java index 4cb157545b..91db34a46f 100644 --- a/src/main/java/train/client/render/ItemRenderSignal.java +++ b/src/main/java/train/client/render/ItemRenderSignal.java @@ -54,7 +54,7 @@ public void renderItem(ItemRenderType type, ItemStack item, Object... data) { } private void renderSignal(float f, float g, float h, float rotation, float scale) { - tmt.Tessellator.bindTexture(texture); + fexcraft.tmt.slim.Tessellator.bindTexture(texture); GL11.glPushMatrix(); //start GL11.glTranslatef(f, g, h); //size GL11.glRotatef(rotation, f, g, h); diff --git a/src/main/java/train/client/render/ItemRenderStopper.java b/src/main/java/train/client/render/ItemRenderStopper.java index 2ef506ba54..5d38e45729 100644 --- a/src/main/java/train/client/render/ItemRenderStopper.java +++ b/src/main/java/train/client/render/ItemRenderStopper.java @@ -53,7 +53,7 @@ public void renderItem(ItemRenderType type, ItemStack item, Object... data) { } private void renderStopper(float f, float g, float h, float rotation) { - tmt.Tessellator.bindTexture(texture); + fexcraft.tmt.slim.Tessellator.bindTexture(texture); GL11.glPushMatrix(); //start GL11.glTranslatef(f, g, h); //size GL11.glRotatef(rotation, f, g, h); diff --git a/src/main/java/train/client/render/ItemRenderWaterWheel.java b/src/main/java/train/client/render/ItemRenderWaterWheel.java index d0e256f768..f64524a935 100644 --- a/src/main/java/train/client/render/ItemRenderWaterWheel.java +++ b/src/main/java/train/client/render/ItemRenderWaterWheel.java @@ -53,7 +53,7 @@ private void renderWaterWheel(float x, float y, float z, float scale) { GL11.glScalef(0.36F, 0.36F, 1F); GL11.glRotatef(180f, 0f, 1f, 0f); - tmt.Tessellator.bindTexture(texture); + fexcraft.tmt.slim.Tessellator.bindTexture(texture); float f2 = (float) (0x331D14 >> 16 & 255) / 255.0F; float f3 = (float) (0x331D14 >> 8 & 255) / 255.0F; float f4 = (float) (0x331D14 & 255) / 255.0F; diff --git a/src/main/java/train/client/render/ItemRenderWindMill.java b/src/main/java/train/client/render/ItemRenderWindMill.java index 5b275fa051..44946b852a 100644 --- a/src/main/java/train/client/render/ItemRenderWindMill.java +++ b/src/main/java/train/client/render/ItemRenderWindMill.java @@ -54,7 +54,7 @@ private void renderWindMill(float x, float y, float z, float scale) { GL11.glTranslatef(x, y, z); GL11.glScalef(scale, scale, scale); - tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.modelTexPrefix + "water_wheel_uv.png")); + fexcraft.tmt.slim.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.modelTexPrefix + "water_wheel_uv.png")); float f2 = (float) (0x331D14 >> 16 & 255) / 255.0F; float f3 = (float) (0x331D14 >> 8 & 255) / 255.0F; float f4 = (float) (0x331D14 & 255) / 255.0F; diff --git a/src/main/java/train/client/render/RenderGeneratorDiesel.java b/src/main/java/train/client/render/RenderGeneratorDiesel.java index b653fbdd92..48f9652cc5 100644 --- a/src/main/java/train/client/render/RenderGeneratorDiesel.java +++ b/src/main/java/train/client/render/RenderGeneratorDiesel.java @@ -27,7 +27,7 @@ public void render(TileEntity var1, double x, double y, double z) { GL11.glPushMatrix(); GL11.glTranslated(x, y, z); - tmt.Tessellator.bindTexture(texture); + fexcraft.tmt.slim.Tessellator.bindTexture(texture); //System.out.println(((TileStopper) var1).getFacing()); GL11.glTranslatef(0.5F, 0.0F, 0.5F); diff --git a/src/main/java/train/client/render/RenderStopper.java b/src/main/java/train/client/render/RenderStopper.java index 80946e4e87..376d4ae61a 100644 --- a/src/main/java/train/client/render/RenderStopper.java +++ b/src/main/java/train/client/render/RenderStopper.java @@ -27,7 +27,7 @@ public void render(TileEntity tile, double x, double y, double z) { GL11.glPushMatrix(); GL11.glTranslated(x, y, z); - tmt.Tessellator.bindTexture(texture); + fexcraft.tmt.slim.Tessellator.bindTexture(texture); GL11.glTranslatef(0.5F, 0.0F, 0.5F); modelStopper.render(0.0625F, ((TileStopper) tile).getFacing()); diff --git a/src/main/java/train/client/render/models/ModelBP4.java b/src/main/java/train/client/render/models/ModelBP4.java index 6f9828460e..31ab34f79f 100644 --- a/src/main/java/train/client/render/models/ModelBP4.java +++ b/src/main/java/train/client/render/models/ModelBP4.java @@ -1005,6 +1005,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f GL11.glTranslatef(3.1f,0f,0); bogie.render(entity, f, f1, f2, f3, f4, f5); + GL11.glScalef(1f,1f,1f); GL11.glPopMatrix(); } diff --git a/src/main/java/train/client/render/models/ModelLocoDieselIC4_DSB_FH.java b/src/main/java/train/client/render/models/ModelLocoDieselIC4_DSB_FH.java index a2bffebfc0..dfb6515fb6 100644 --- a/src/main/java/train/client/render/models/ModelLocoDieselIC4_DSB_FH.java +++ b/src/main/java/train/client/render/models/ModelLocoDieselIC4_DSB_FH.java @@ -489,7 +489,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f GL11.glTranslated(0,-1.4f,-2.6); GL11.glScaled(0.7,0.9,1); super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); + //setRotationAngles(f, f1, f2, f3, f4, f5, entity); Left1.render(f5); Left2.render(f5); Left3.render(f5); diff --git a/tmt/Angle3D.java b/tmt/Angle3D.java deleted file mode 100644 index 1fe7a1c8b4..0000000000 --- a/tmt/Angle3D.java +++ /dev/null @@ -1,93 +0,0 @@ -package tmt; - -/** - * This class handles angles. Basically all it does it store angles. You can - * directly alter the angles. - * @author GaryCXJk - * - */ -public class Angle3D { - - public float angleX; - public float angleY; - public float angleZ; - - /** - * The constructor to create a new Angle3D. - * @param x the x-rotation - * @param y the y-rotation - * @param z the z-rotation - */ - public Angle3D(float x, float y, float z){ - angleX = x; - angleY = y; - angleZ = z; - } - - /** - * Adds the given angles to the current angles. - * @param x the x-rotation - * @param y the y-rotation - * @param z the z-rotation - */ - public void addAngles(float x, float y, float z){ - angleX+= x; - angleY+= y; - angleZ+= z; - } - - /** - * Adds the angles of another Angle3D to the current angles. - * @param angles the Angle3D - */ - public void addAngles(Angle3D angles){ - angleX+= angles.angleX; - angleY+= angles.angleY; - angleZ+= angles.angleZ; - } - - /** - * Multiplies the angles with the given angles. - * @param x the x-rotation - * @param y the y-rotation - * @param z the z-rotation - */ - public void multiplyAngles(float x, float y, float z){ - angleX*= x; - angleY*= y; - angleZ*= z; - } - - /** - * Multiplies the angles with a given Angle3D. - * @param angles the Angle3D - */ - public void multiplyAngles(Angle3D angles){ - angleX*= angles.angleX; - angleY*= angles.angleY; - angleZ*= angles.angleZ; - } - - /** - * Gets the center angle between two angles. - * @param angles1 the first Angle3D - * @param angles2 the second Angle3D - * @return the center Angle3D - */ - public static Angle3D getCenter(Angle3D angles1, Angle3D angles2){ - Angle3D angles = new Angle3D(0, 0, 0); - angles.addAngles(angles1); - angles.addAngles(angles2); - angles.multiplyAngles(0.5F, 0.5F, 0.5F); - return angles; - } - - /** - * Copies the current Angle3D over to a new Angle3D instance. - * @return a copy of the Angle3D instance - */ - public Angle3D copy(){ - return new Angle3D(angleX, angleY, angleZ); - } - -} diff --git a/tmt/Coord2D.java b/tmt/Coord2D.java deleted file mode 100644 index 7acfecfa47..0000000000 --- a/tmt/Coord2D.java +++ /dev/null @@ -1,30 +0,0 @@ -package tmt; - -/** - * This class represents a coordinate space and its UV coordinates. This allows for - * easier flat shape planning. - * @author GaryCXJk - * - */ -public class Coord2D { - - public float xCoord; - public float yCoord; - public int uCoord; - public int vCoord; - - public Coord2D(float x, float y){ - xCoord = x; - yCoord = y; - uCoord = (int)Math.floor(x); - vCoord = (int)Math.floor(y); - } - - - public Coord2D(float x, float y, int u, int v){ - this(x, y); - uCoord = u; - vCoord = v; - } - -} diff --git a/tmt/CylinderBuilder.java b/tmt/CylinderBuilder.java deleted file mode 100644 index 6e2a6699ea..0000000000 --- a/tmt/CylinderBuilder.java +++ /dev/null @@ -1,281 +0,0 @@ -package tmt; - -import java.util.ArrayList; - -import static tmt.ModelRendererTurbo.*; - - -/** - * Cylinder Builder Tool, to prevent the need of XYZ amount of chained methods. - * @author Ferdinand Calo' (FEX___96) - */ -public class CylinderBuilder { - - private ModelRendererTurbo root; - private float x, y, z, radius, radius2, length, base_scale, top_scale; - private int segments, seglimit, direction, texDiameterW, texDiameterH, texHeight; - private Vec3f topoff = new Vec3f(); - private boolean[] togglesides = new boolean[]{false,false,false,false}; - private Vec3f toprot; - // - private boolean radialtexture = false; - private float seg_width, seg_height; - - public CylinderBuilder(ModelRendererTurbo root){ - this.root = root == null ? new ModelRendererTurbo("") : root; - } - - public CylinderBuilder setPosition(float x, float y, float z){ - this.x = x; this.y = y; this.z = z; return this; - } - - public CylinderBuilder setRadius(float first, float second){ - this.radius = first; this.radius2 = second; - texDiameterW = (int)Math.floor(radius * 2F); texDiameterH = (int)Math.floor(radius * 2F); return this; - } - - /** Use AFTER `setRadius`, else values will get overriden. */ - public CylinderBuilder setTextureDiameter(int width, int height){ - texDiameterW = width; texDiameterH = height; return this; - } - - public CylinderBuilder setLength(float length){ - this.length = length; texHeight = (int)Math.floor(length); return this; - } - - /** Use AFTER `setLength`, else value will get overriden. */ - public CylinderBuilder setTextureHeight(int height){ - texHeight = height; return this; - } - - public CylinderBuilder setTopOffset(float x, float y, float z){ - topoff = new Vec3f(x, y, z); return this; - } - - public CylinderBuilder setTopOffset(Vec3f vec){ - topoff = vec; return this; - } - - public CylinderBuilder setSidesVisible(boolean[] arr){ - this.togglesides = arr; return this; - } - - public CylinderBuilder setSidesVisible(boolean base, boolean top, boolean outer, boolean inner){ - this.togglesides = new boolean[]{ base, top, outer, inner }; return this; - } - - /** Currently no support for hollow-less cylinders to be segmented. */ - public CylinderBuilder setSegments(int amount, int limit){ - this.segments = amount; this.seglimit = limit; return this; - } - - public CylinderBuilder setScale(float base, float top){ - this.base_scale = base; this.top_scale = top; return this; - } - - /** Currently no support for hollow-less cylinders to be radial-textured. */ - public CylinderBuilder setRadialTexture(float seg_width, float seg_height){ - if(seg_width==0 && seg_height==0){ - return this; - } - radialtexture = true; this.seg_width = seg_width; this.seg_height = seg_height; return this; - } - - public CylinderBuilder setDirection(int dir){ - this.direction = dir; return this; - } - - public CylinderBuilder setTopRotation(float x, float y, float z){ - toprot = new Vec3f(x,y,z); - return this; - } - - public CylinderBuilder setTopRotation(Vec3f vec){ - return setTopRotation(vec.xCoord, vec.yCoord, vec.zCoord); - } - - public CylinderBuilder removePolygon(int index){ - if(index >= 0 && index < 4){ - togglesides[index] = true; - } - return this; - } - - public CylinderBuilder removePolygons(int... poly_indices){ - for(int index : poly_indices){ - if(index >= 0 && index < 4){ - togglesides[index] = true; - } - } - return this; - } - - public CylinderBuilder removePolygons(boolean... sides){ - for(int index = 0; index < 4; index++){ - if(sides.length >= (index + 1) && sides[index]){ - togglesides[index] = true; - } - } - return this; - } - - public ModelRendererTurbo build(){ - if(radius2 == 0f && toprot == null){ - return root.addCylinder(x, y, z, radius, length, segments, base_scale, top_scale, direction, texDiameterW, texDiameterH, texHeight, topoff); - } - if(radius < 1){ texDiameterW = 2; texDiameterH = 2; } if(length < 1){ texHeight = 2; } - // - boolean dirTop = (direction == MR_TOP || direction == MR_BOTTOM); - boolean dirSide = (direction == MR_RIGHT || direction == MR_LEFT); - boolean dirFront = (direction == MR_FRONT || direction == MR_BACK); - boolean dirMirror = (direction == MR_LEFT || direction == MR_BOTTOM || direction == MR_BACK); - if(base_scale == 0) base_scale = 1f; if(top_scale == 0) top_scale = 1f; - if(segments < 3) segments = 3; if(seglimit <= 0) seglimit = segments; boolean segl = seglimit < segments; - ArrayList polis = new ArrayList(); - //Vertex - float xLength = (dirSide ? length : 0), yLength = (dirTop ? length : 0), zLength = (dirFront ? length : 0); - float xStart = (dirMirror ? x + xLength : x); - float yStart = (dirMirror ? y + yLength : y); - float zStart = (dirMirror ? z + zLength : z); - float xEnd = (!dirMirror ? x + xLength : x) + (topoff == null ? 0 : topoff.xCoord); - float yEnd = (!dirMirror ? y + yLength : y) + (topoff == null ? 0 : topoff.yCoord); - float zEnd = (!dirMirror ? z + zLength : z) + (topoff == null ? 0 : topoff.zCoord); - float xCur = xStart, yCur = yStart, zCur = zStart, sCur = base_scale; - //Texture - float uScale = 1.0F / root.textureWidth, vScale = 1.0F / root.textureHeight; - float uOffset = uScale / 20.0F, vOffset = vScale / 20.0F; - float uCircle = texDiameterW * uScale; - float vCircle = texDiameterH * vScale; - float uCircle2 = ((int)Math.floor(radius2 * 2F)) * uScale; - float vCircle2 = ((int)Math.floor(radius2 * 2F)) * vScale; - float uWidth = (uCircle * 2F - uOffset * 2F) / segments; - float vHeight = texHeight * vScale - uOffset * 2f; - float uStart = root.textureOffsetX * uScale, vStart = root.textureOffsetY * vScale; - //Temporary Arrays - ArrayList verts0 = new ArrayList(); - ArrayList verts1 = new ArrayList(); - ArrayList verts2 = new ArrayList(); - ArrayList verts3 = new ArrayList(); - float xSize,ySize,zSize,xPlace,yPlace,zPlace; - for(int repeat = 0; repeat < 2; repeat++){//top/base faces - for(int index = 0; index < segments; index++){ - xSize = (float)((root.mirror ^ dirMirror ? -1 : 1) * Math.sin((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius * sCur); - zSize = (float)(-Math.cos((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius * sCur); - xPlace = xCur + (!dirSide ? xSize : 0); - yPlace = yCur + (!dirTop ? zSize : 0); - zPlace = zCur + (dirSide ? xSize : (dirTop ? zSize : 0)); - verts0.add(new TexturedVertex(xPlace, yPlace, zPlace, 0, 0)); - if(index == segments - 1){ - verts0.add(new TexturedVertex(verts0.get(0))); - } - // - xSize = (float)((root.mirror ^ dirMirror ? -1 : 1) * Math.sin((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius2 * sCur); - zSize = (float)(-Math.cos((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius2 * sCur); - xPlace = xCur + (!dirSide ? xSize : 0); - yPlace = yCur + (!dirTop ? zSize : 0); - zPlace = zCur + (dirSide ? xSize : (dirTop ? zSize : 0)); - verts1.add(new TexturedVertex(xPlace, yPlace, zPlace, 0, 0)); - if(index == segments - 1){ - verts1.add(new TexturedVertex(verts1.get(0))); - } - } - if(repeat == 0){ - verts2.addAll(verts0); - verts2.addAll(verts1); - } else{ - verts3.addAll(verts0); - verts3.addAll(verts1); - } - float mul = radialtexture ? repeat == 0 ? 0 : seg_height : repeat == 0 ? 0.5f : 1.5f; - if((repeat == 0 && !togglesides[0]) || (repeat == 1 && !togglesides[1])){ - for(int i = 0; i < verts0.size(); i++){ - if(i >= (verts0.size() - 1) || i >= seglimit){ - if(repeat != 0 && toprot != null){ - verts0.get(i).vector3F = toprot.getRelativeVector(verts0.get(i).vector3F); - verts1.get(i).vector3F = toprot.getRelativeVector(verts1.get(i).vector3F); - } - break; - } - TexturedVertex[] arr = new TexturedVertex[4]; - if(!radialtexture){ - xSize = (float)(Math.sin((ModelRendererTurbo.pi / segments) * i * 2F + (!dirTop ? 0 : ModelRendererTurbo.pi)) * (0.5F * uCircle - 2F * uOffset)); - ySize = (float)(Math.cos((ModelRendererTurbo.pi / segments) * i * 2F + (!dirTop ? 0 : ModelRendererTurbo.pi)) * (0.5F * vCircle - 2F * vOffset)); - arr[0] = verts0.get(i).setTexturePosition(uStart + mul * uCircle + xSize, vStart + 0.5F * vCircle + ySize); - // - xSize = (float)(Math.sin((ModelRendererTurbo.pi / segments) * i * 2F + (!dirTop ? 0 : ModelRendererTurbo.pi)) * (0.5F * uCircle2 - 2F * uOffset)); - ySize = (float)(Math.cos((ModelRendererTurbo.pi / segments) * i * 2F + (!dirTop ? 0 : ModelRendererTurbo.pi)) * (0.5F * vCircle2 - 2F * vOffset)); - arr[1] = verts1.get(i).setTexturePosition(uStart + mul * uCircle + xSize, vStart + 0.5F * vCircle + ySize); - // - xSize = (float)(Math.sin((ModelRendererTurbo.pi / segments) * (i + 1) * 2F + (!dirTop ? 0 : ModelRendererTurbo.pi)) * (0.5F * uCircle2 - 2F * uOffset)); - ySize = (float)(Math.cos((ModelRendererTurbo.pi / segments) * (i + 1) * 2F + (!dirTop ? 0 : ModelRendererTurbo.pi)) * (0.5F * vCircle2 - 2F * vOffset)); - arr[2] = verts1.get(i + 1).setTexturePosition(uStart + mul * uCircle + xSize, vStart + 0.5F * vCircle + ySize); - // - xSize = (float)(Math.sin((ModelRendererTurbo.pi / segments) * (i + 1) * 2F + (!dirTop ? 0 : ModelRendererTurbo.pi)) * (0.5F * uCircle - 2F * uOffset)); - ySize = (float)(Math.cos((ModelRendererTurbo.pi / segments) * (i + 1) * 2F + (!dirTop ? 0 : ModelRendererTurbo.pi)) * (0.5F * vCircle - 2F * vOffset)); - arr[3] = verts0.get(i + 1).setTexturePosition(uStart + mul * uCircle + xSize, vStart + 0.5F * vCircle + ySize); - } - else { - float diff = (radius - radius2) * uScale / 4; - arr[0] = verts0.get(i).setTexturePosition(uStart + (i * seg_width) * uScale, vStart + (mul * vScale)); - arr[1] = verts1.get(i).setTexturePosition(uStart + (i * seg_width) * uScale + diff, vStart + ((seg_height + mul) * vScale)); - arr[2] = verts1.get(i + 1).setTexturePosition(uStart + ((i + 1) * seg_width) * uScale - diff, vStart + ((seg_height + mul) * vScale)); - arr[3] = verts0.get(i + 1).setTexturePosition(uStart + ((i + 1) * seg_width) * uScale, vStart + (mul * vScale)); - } - if(repeat != 0 && toprot != null){ - arr[0].vector3F = verts0.get(i).vector3F = toprot.getRelativeVector(arr[0].vector3F); - arr[1].vector3F = verts1.get(i).vector3F = toprot.getRelativeVector(arr[1].vector3F); - arr[2].vector3F = /*verts1.get(i + 1).vector3F =*/ toprot.getRelativeVector(arr[2].vector3F); - arr[3].vector3F = /*verts0.get(i + 1).vector3F =*/ toprot.getRelativeVector(arr[3].vector3F); - } - polis.add(new TexturedPolygon(arr)); - if((repeat == 0) != dirFront) { - polis.get(polis.size() - 1 ).flipFace(); - } - } - } - verts0.clear(); verts1.clear(); xCur = xEnd; yCur = yEnd; zCur = zEnd; sCur = top_scale; - } - int halfv2 = verts2.size() / 2; - if(radialtexture){ vCircle = (seg_height + seg_height) * vScale; } - for(int i = 0; i < halfv2; i++){ - if(i >= seglimit && segl){ - TexturedVertex[] arr = new TexturedVertex[4]; float xpos = uStart + uOffset + (uCircle * 2f); - arr[0] = verts2.get(0).setTexturePosition(xpos, vStart + vOffset + vCircle); - arr[1] = verts3.get(0).setTexturePosition(xpos, vStart + vOffset + vCircle + vHeight); - arr[2] = verts3.get(halfv2).setTexturePosition(xpos + ((radius - radius2) * uScale), vStart + vOffset + vCircle + vHeight); - arr[3] = verts2.get(halfv2).setTexturePosition(xpos + ((radius - radius2) * uScale), vStart + vOffset + vCircle); - polis.add(new TexturedPolygon(arr)); - if(!dirFront) polis.get(polis.size() - 1 ).flipFace(); - arr = new TexturedVertex[4]; - arr[0] = verts2.get(seglimit).setTexturePosition(xpos, vStart + vOffset + vCircle + vHeight); - arr[1] = verts3.get(seglimit).setTexturePosition(xpos, vStart + vOffset + vCircle + vHeight + vHeight); - arr[2] = verts3.get(seglimit + halfv2).setTexturePosition(xpos + ((radius - radius2) * uScale), vStart + vOffset + vCircle + vHeight + vHeight); - arr[3] = verts2.get(seglimit + halfv2).setTexturePosition(xpos + ((radius - radius2) * uScale), vStart + vOffset + vCircle + vHeight); - polis.add(new TexturedPolygon(arr)); - if(dirFront) polis.get(polis.size() - 1 ).flipFace(); - break; - } - if(i >= (halfv2 - 1)) break; - TexturedVertex[] arr = new TexturedVertex[4]; - if(!togglesides[2]){ - arr[0] = verts2.get(i + 0).setTexturePosition(uStart + uOffset + uWidth * (i + 0), vStart + vOffset + vCircle); - arr[1] = verts3.get(i + 0).setTexturePosition(uStart + uOffset + uWidth * (i + 0), vStart + vOffset + vCircle + vHeight); - arr[2] = verts3.get(i + 1).setTexturePosition(uStart + uOffset + uWidth * (i + 1), vStart + vOffset + vCircle + vHeight); - arr[3] = verts2.get(i + 1).setTexturePosition(uStart + uOffset + uWidth * (i + 1), vStart + vOffset + vCircle); - polis.add(new TexturedPolygon(arr)); - if(dirFront) polis.get(polis.size() - 1 ).flipFace(); - } - if(!togglesides[3]){ - arr = new TexturedVertex[4]; - arr[0] = verts2.get(i + halfv2 + 0).setTexturePosition(uStart + uOffset + uWidth * (i + 0), vStart + vOffset + vCircle + vHeight); - arr[1] = verts3.get(i + halfv2 + 0).setTexturePosition(uStart + uOffset + uWidth * (i + 0), vStart + vOffset + vCircle + vHeight + vHeight); - arr[2] = verts3.get(i + halfv2 + 1).setTexturePosition(uStart + uOffset + uWidth * (i + 1), vStart + vOffset + vCircle + vHeight + vHeight); - arr[3] = verts2.get(i + halfv2 + 1).setTexturePosition(uStart + uOffset + uWidth * (i + 1), vStart + vOffset + vCircle + vHeight); - polis.add(new TexturedPolygon(arr)); - if(!dirFront) polis.get(polis.size() - 1 ).flipFace(); - } - } - return root.copyTo(null, polis.toArray(new TexturedPolygon[0])); - } - -} \ No newline at end of file diff --git a/tmt/FVTMFormatBase.java b/tmt/FVTMFormatBase.java deleted file mode 100644 index b90eff6ae4..0000000000 --- a/tmt/FVTMFormatBase.java +++ /dev/null @@ -1,48 +0,0 @@ -package tmt; - -import java.util.ArrayList; - -import net.minecraft.entity.Entity; - -/** - * Basic Compatiblity class for FVTM Format Models - * - * @author Ferdinand (FEX___96) - * - */ -public class FVTMFormatBase extends ModelBase { - - protected int textureX, textureY; - public ArrayList groups = new ArrayList(); - - public void addToCreators(String author){ - // - } - - @SuppressWarnings("serial") - public static class TurboList extends ArrayList{ - - public final String name; - - public TurboList(String groupname){ - this.name = groupname; - } - - } - - @Override - public void render(){ - for(TurboList list : groups){ - for(ModelRendererTurbo turbo : list) turbo.render(); - } - } - - - @Override - public void render(Entity entity, float f0, float f1, float f2, float f3, float f4, float scale){ - for(TurboList list : groups){ - for(ModelRendererTurbo turbo : list) turbo.render(); - } - } - -} diff --git a/tmt/JsonToTMT.java b/tmt/JsonToTMT.java deleted file mode 100644 index 6cc0c58262..0000000000 --- a/tmt/JsonToTMT.java +++ /dev/null @@ -1,142 +0,0 @@ -package tmt; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - - -/** -* Tool to parse `ModelRendererTurbo` objects from JSON. -* @Author Ferdinand Calo' (FEX___96) -*/ -public class JsonToTMT { - - //def - public static final float def = 0f; - public static final int idef = 0; - //common - public static final String[] format = new String[]{"format", "form", "f"};//1.1f - public static final String[] width = new String[]{"width", "wid", "w"}; - public static final String[] height = new String[]{"height", "hgt", "h"}; - public static final String[] depth = new String[]{"depth", "dep", "d"}; - public static final String[] offx = new String[]{"offset_x", "off_x", "offx", "ox"}; - public static final String[] offy = new String[]{"offset_y", "off_y", "offy", "oy"}; - public static final String[] offz = new String[]{"offset_z", "off_z", "offz", "oz"}; - public static final String[] expansion = new String[]{"expansion", "exp", "e"}; - public static final String[] scale = new String[]{"scale", "s"}; - public static final String[] texturex = new String[]{"texture_x", "texturex", "tex_x", "tx"}; - public static final String[] texturey = new String[]{"texture_y", "texturey", "tex_y", "ty"}; - // - public static final String[] posx = new String[]{"rotation_point_x", "pos_x", "posx", "px", "x"}; - public static final String[] posy = new String[]{"rotation_point_y", "pos_y", "posy", "py", "y"}; - public static final String[] posz = new String[]{"rotation_point_z", "pos_z", "posz", "pz", "z"}; - public static final String[] rotx = new String[]{"rotation_angle_x", "rotangle_x", "rotanglex", "rot_x", "rx"}; - public static final String[] roty = new String[]{"rotation_angle_y", "rotangle_y", "rotangley", "rot_y", "ry"}; - public static final String[] rotz = new String[]{"rotation_angle_z", "rotangle_z", "rotanglez", "rot_z", "rz"}; - //settings - public static final String[] oldrot = new String[]{"old_ration", "old_rotation_order", "oro"}; - public static final String[] mirror = new String[]{"mirror", "mir", "m"}; - public static final String[] flip = new String[]{"flip", "fl", "usd"}; - //cyl - public static final String[] radius = new String[]{"radius", "rad", "r"}; - public static final String[] length = new String[]{"length", "len", "l"}; - public static final String[] segments = new String[]{"segments", "seg", "sg"}; - public static final String[] basescale = new String[]{"base_scale", "basescale", "bs"}; - public static final String[] topscale = new String[]{"top_scale", "topscale", "ts"}; - public static final String[] direction = new String[]{"direction", "dir", "facing"}; - - - public final static ModelRendererTurbo parse(net.minecraft.client.model.ModelBase base, JsonObject obj, int tx, int ty){ - ModelRendererTurbo model = new ModelRendererTurbo(base, get(texturex, obj, idef), get(texturey, obj, idef), tx, ty); - // - float x = get(offx, obj, def); - float y = get(offy, obj, def); - float z = get(offz, obj, def); - int w = get(width, obj, idef); - int h = get(height, obj, idef); - int d = get(depth, obj, idef); - //Eternal edit: changed the switch to if statements because java6 cant switch on a string. - String s = obj.get("type").getAsString(); - if (s.equals("box") || s.equals("cube") || s.equals("s")){ - model.addBox(x, y, z, w, h, d, get(expansion, obj, def)); - } else if (s.equals("shapebox") || s.equals("sbox") || s.equals("sb")){ - model.addShapeBox(x, y, z, w, h, d, get(scale, obj, def), - get("x0", obj, def), get("y0", obj, def), get("z0", obj, def), - get("x1", obj, def), get("y1", obj, def), get("z1", obj, def), - get("x2", obj, def), get("y2", obj, def), get("z2", obj, def), - get("x3", obj, def), get("y3", obj, def), get("z3", obj, def), - get("x4", obj, def), get("y4", obj, def), get("z4", obj, def), - get("x5", obj, def), get("y5", obj, def), get("z5", obj, def), - get("x6", obj, def), get("y6", obj, def), get("z6", obj, def), - get("x7", obj, def), get("y7", obj, def), get("z7", obj, def) - ); - } else if (s.equals("cylinder") || s.equals("c")){ - model.addCylinder(x, y, z, get(radius, obj, 1f), get(length, obj, 1f), get(segments, obj, 16), get(basescale, obj, 1f), get(topscale, obj, 1f), get(direction, obj, 4)); - } else if (s.equals("cone") || s.equals("cn")){ - model.addCone(x, y, z, get(radius, obj, 1f), get(length, obj, 1f), get(segments, obj, 12), get(basescale, obj, 1f), get(direction, obj, 4)); - } - /* import unavailable: net.fexcraft.mod.lib.util.json.JsonUtil; - model.rotorder = JsonUtil.getIfExists(obj, oldrot, model.rotorder); - model.mirror = JsonUtil.getIfExists(obj, mirror, false); - model.flip = JsonUtil.getIfExists(obj, flip, false); - */ - model.rotateAngleX = get(rotx, obj, def); - model.rotateAngleY = get(roty, obj, def); - model.rotateAngleZ = get(rotz, obj, def); - // - model.setRotationPoint(get(posx, obj, def), get(posy, obj, def), get(posz, obj, def)); - return model; - } - - public final static ModelRendererTurbo[] parse(net.minecraft.client.model.ModelBase base, JsonArray array, int tx, int ty){ - if(array != null){ - ModelRendererTurbo[] model = new ModelRendererTurbo[array.size()]; - for(int i = 0; i < array.size(); i++){ - model[i] = parse(base, array.get(i).getAsJsonObject(), tx, ty); - } - return model; - } - return new ModelRendererTurbo[0]; - } - - public final static ModelRendererTurbo[] parse(net.minecraft.client.model.ModelBase base, String string, JsonObject object, int tx, int ty){ - if(base == null){ - /*unavailable import, could be easily replaced with generic debugger later on - if(Static.dev()){ - Static.halt(); - } - else{ - Print.log("Provided Modelbase is NULL, expect errors!", object); - }*/ - } - if(object.has(string) && object.get(string).isJsonArray()){ - return parse(base, object.get(string).getAsJsonArray(), tx, ty); - } - return new ModelRendererTurbo[0]; - } - - public static final float get(String s, JsonObject obj, float def){ - if(obj.has(s)){ - return obj.get(s).getAsFloat(); - } - return def; - } - - public static final float get(String[] s, JsonObject obj, float def){ - for(String str : s){ - if(obj.has(str)){ - return obj.get(str).getAsFloat(); - } - } - return 0; - } - - public static final int get(String[] s, JsonObject obj, int def){ - for(String str : s){ - if(obj.has(str)){ - return obj.get(str).getAsInt(); - } - } - return 0; - } - -} \ No newline at end of file diff --git a/tmt/Model.java b/tmt/Model.java deleted file mode 100644 index 1c56764ccf..0000000000 --- a/tmt/Model.java +++ /dev/null @@ -1,92 +0,0 @@ -package tmt; - -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; - -/** -* Replaces the old `ModelBase` in this package. -* @Author Ferdinand Calo' (FEX___96) -*/ - -public abstract class Model extends net.minecraft.client.model.ModelBase { - - public static final Model EMPTY; - static { - EMPTY = new Model(){ - @Override public void render(){} - @Override public void render(Object type, Entity element){} - @Override public void translateAll(float x, float y, float z){} - @Override public void rotateAll(float x, float y, float z){} - }; - } - - /** render whole model */ - public abstract void render(); - - /** render sub-model array */ - public void render(ModelRendererTurbo[] model){ - for(ModelRendererTurbo sub : model){ - if(sub.boxName.contains("lamp")) { - Minecraft.getMinecraft().entityRenderer.disableLightmap(1D); - sub.render(); - Minecraft.getMinecraft().entityRenderer.enableLightmap(1D); - } else { - sub.render(); - } - } - } - - public void render(ModelRendererTurbo[] model, float scale, boolean rotorder){ - for(ModelRendererTurbo sub : model){ - if(sub.boxName.contains("lamp")) { - Minecraft.getMinecraft().entityRenderer.disableLightmap(1D); - sub.render(); - Minecraft.getMinecraft().entityRenderer.enableLightmap(1D); - } else { - sub.render(); - } - } - } - - /** render whole model based on data and entity */ - public abstract void render(T type, Entity entity); - - protected void translate(ModelRendererTurbo[] model, float x, float y, float z){ - for(ModelRendererTurbo mod : model){ - mod.rotationPointX += x; - mod.rotationPointY += y; - mod.rotationPointZ += z; - } - } - - public abstract void translateAll(float x, float y, float z); - - protected void rotate(ModelRendererTurbo[] model, float x, float y, float z) { - for(ModelRendererTurbo mod : model){ - mod.rotateAngleX += x; - mod.rotateAngleY += y; - mod.rotateAngleZ += z; - } - } - - public abstract void rotateAll(float x, float y, float z); - - protected final void fixRotation(ModelRendererTurbo[] model, boolean... bools){ - if(bools.length >= 1 && bools[0]){ - for(ModelRendererTurbo mod : model){ - mod.rotateAngleX = -mod.rotateAngleX; - } - } - if(bools.length >= 2 && bools[1]){ - for(ModelRendererTurbo mod : model){ - mod.rotateAngleY = -mod.rotateAngleY; - } - } - if(bools.length >= 3 && bools[2]){ - for(ModelRendererTurbo mod : model){ - mod.rotateAngleZ = -mod.rotateAngleZ; - } - } - } - -} \ No newline at end of file diff --git a/tmt/ModelBase.java b/tmt/ModelBase.java deleted file mode 100644 index 26a7ffaa1a..0000000000 --- a/tmt/ModelBase.java +++ /dev/null @@ -1,80 +0,0 @@ -package tmt; - -import net.minecraft.entity.Entity; - -/** -* Similar to 'FlansMod'-type Models, for a fast convert. -* @Author Ferdinand Calo' (FEX___96) -*/ -public class ModelBase extends Model { - - public ModelRendererTurbo base[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo open[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo closed[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r1[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r2[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r3[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r4[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r5[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r6[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r7[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r8[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r9[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo r0[] = new ModelRendererTurbo[0]; - - public void render(){ - render(base); - render(open); - render(closed); - render(r0); - render(r1); - render(r2); - render(r3); - render(r4); - render(r5); - render(r6); - render(r7); - render(r8); - render(r9); - } - - @Override - public void render(Object type, Entity ent){ - render(); - } - - @Override - public void translateAll(float x, float y, float z){ - translate(base, x, y, z); - translate(open, x, y, z); - translate(closed, x, y, z); - translate(r0, x, y, z); - translate(r1, x, y, z); - translate(r2, x, y, z); - translate(r3, x, y, z); - translate(r4, x, y, z); - translate(r5, x, y, z); - translate(r6, x, y, z); - translate(r7, x, y, z); - translate(r8, x, y, z); - translate(r9, x, y, z); - } - - @Override - public void rotateAll(float x, float y, float z){ - rotate(base, x, y, z); - rotate(open, x, y, z); - rotate(closed, x, y, z); - rotate(r0, x, y, z); - rotate(r1, x, y, z); - rotate(r2, x, y, z); - rotate(r3, x, y, z); - rotate(r4, x, y, z); - rotate(r5, x, y, z); - rotate(r6, x, y, z); - rotate(r7, x, y, z); - rotate(r8, x, y, z); - rotate(r9, x, y, z); - } - -} diff --git a/tmt/ModelConverter.java b/tmt/ModelConverter.java deleted file mode 100644 index c4bc87df68..0000000000 --- a/tmt/ModelConverter.java +++ /dev/null @@ -1,150 +0,0 @@ -package tmt; - -import net.minecraft.entity.Entity; - -/** -* Converter to use Flansmod-Type vehicle models. -* @Author Ferdinand Calo' (FEX___96) -*/ -public class ModelConverter extends ModelBase { - - public ModelRendererTurbo bodyModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo model[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo bodyDoorOpenModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo bodyDoorCloseModel[] = new ModelRendererTurbo[0]; - - public ModelRendererTurbo turretModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo barrelModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo frontWheelModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo backWheelModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo leftFrontWheelModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo rightFrontWheelModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo leftBackWheelModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo rightBackWheelModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo rightTrackModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo leftTrackModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo rightTrackWheelModels[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo leftTrackWheelModels[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo trailerModel[] = new ModelRendererTurbo[0]; - public ModelRendererTurbo steeringWheelModel[] = new ModelRendererTurbo[0]; - - public void render(){ - render(bodyModel); - render(model); - render(bodyDoorCloseModel); - render(turretModel); - render(barrelModel); - render(frontWheelModel); - render(backWheelModel); - render(leftFrontWheelModel); - render(rightFrontWheelModel); - render(leftBackWheelModel); - render(rightBackWheelModel); - render(rightTrackModel); - render(leftTrackModel); - render(rightTrackWheelModels); - render(leftTrackWheelModels); - render(trailerModel); - render(steeringWheelModel); - } - @Override - public void render(Entity entity,float f0, float f1, float f2, float f3, float f4, float scale){ - render(bodyModel, scale,false); - render(model, scale,false); - render(bodyDoorCloseModel, scale,false); - render(turretModel, scale,false); - render(barrelModel, scale,false); - render(frontWheelModel, scale,false); - render(backWheelModel, scale,false); - render(leftFrontWheelModel, scale,false); - render(rightFrontWheelModel, scale,false); - render(leftBackWheelModel, scale,false); - render(rightBackWheelModel, scale,false); - render(rightTrackModel, scale,false); - render(leftTrackModel, scale,false); - render(rightTrackWheelModels, scale,false); - render(leftTrackWheelModels, scale,false); - render(trailerModel, scale,false); - render(steeringWheelModel, scale,false); - - } - - @Override - public void render(Object type, Entity ent){ - render(); - } - - public void translateAll(float x, float y, float z){ - translate(bodyModel, x, y, z); - translate(model, x, y, z); - translate(bodyDoorOpenModel, x, y, z); - translate(bodyDoorCloseModel, x, y, z); - translate(turretModel, x, y, z); - translate(barrelModel, x, y, z); - translate(frontWheelModel, x, y, z); - translate(backWheelModel, x, y, z); - translate(leftFrontWheelModel, x, y, z); - translate(rightFrontWheelModel, x, y, z); - translate(leftBackWheelModel, x, y, z); - translate(rightBackWheelModel, x, y, z); - translate(rightTrackModel, x, y, z); - translate(leftTrackModel, x, y, z); - translate(rightTrackWheelModels, x, y, z); - translate(leftTrackWheelModels, x, y, z); - translate(trailerModel, x, y, z); - translate(steeringWheelModel, x, y, z); - } - - @Override - public void rotateAll(float x, float y, float z){ - rotate(bodyModel, x, y, z); - rotate(model, x, y, z); - rotate(bodyDoorOpenModel, x, y, z); - rotate(bodyDoorCloseModel, x, y, z); - rotate(turretModel, x, y, z); - rotate(barrelModel, x, y, z); - rotate(frontWheelModel, x, y, z); - rotate(backWheelModel, x, y, z); - rotate(leftFrontWheelModel, x, y, z); - rotate(rightFrontWheelModel, x, y, z); - rotate(leftBackWheelModel, x, y, z); - rotate(rightBackWheelModel, x, y, z); - rotate(rightTrackModel, x, y, z); - rotate(leftTrackModel, x, y, z); - rotate(rightTrackWheelModels, x, y, z); - rotate(leftTrackWheelModels, x, y, z); - rotate(trailerModel, x, y, z); - rotate(steeringWheelModel, x, y, z); - } - - public void flipAll(){ - flip(bodyModel); - flip(model); - flip(bodyDoorOpenModel); - flip(bodyDoorCloseModel); - flip(turretModel); - flip(barrelModel); - flip(frontWheelModel); - flip(backWheelModel); - flip(leftFrontWheelModel); - flip(rightFrontWheelModel); - flip(leftBackWheelModel); - flip(rightBackWheelModel); - flip(rightTrackModel); - flip(leftTrackModel); - flip(rightTrackWheelModels); - flip(leftTrackWheelModels); - flip(trailerModel); - flip(steeringWheelModel); - } - - private void flip(ModelRendererTurbo[] model) { - //for(ModelRendererTurbo sub : model){ - // sub.doMirror(false, true, true); - // sub.setRotationPoint(sub.rotationPointX, -sub.rotationPointY, -sub.rotationPointZ); - //} - - fixRotation(model, false, true, true); - } - -} diff --git a/tmt/ModelPool.java b/tmt/ModelPool.java deleted file mode 100644 index 91243e247f..0000000000 --- a/tmt/ModelPool.java +++ /dev/null @@ -1,93 +0,0 @@ -package tmt; - -import cpw.mods.fml.common.Loader; -import org.apache.commons.io.IOUtils; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -public class ModelPool { - - public static ModelPoolEntry addFile(String file, Class modelClass, Map textureGroup){ - ModelPoolEntry entry = null; - if(modelMap.containsKey(file)){ - entry = modelMap.get(file); - entry.applyGroups(textureGroup); - return entry; - } - try{ - entry = (ModelPoolEntry)modelClass.newInstance(); - } - catch(Exception e){ - System.out.println("A new " + entry.getClass().getName() + " could not be initialized."); - System.out.println(e.getMessage()); - return null; - } - File modelFile = null; - for(int i = 0; i < resourceDir.length && (modelFile == null || !modelFile.exists()); i++){ - String absPath = new File(Loader.instance().getConfigDir().getParent(), resourceDir[i]).getAbsolutePath(); - if(!absPath.endsWith("/") || !absPath.endsWith("\\")) - absPath+= "/"; - modelFile = entry.checkValidPath(absPath + file); - } - if(modelFile == null || !modelFile.exists()){ - System.out.println("The model with the name " + file + " does not exist."); - return null; - } - entry.textures = new HashMap(); - entry.name = file; - entry.setTextureGroup("0"); - entry.getModel(modelFile); - entry.applyGroups(textureGroup); - modelMap.put(file, entry); - return entry; - } - - public static ModelPoolEntry addFileF(String file, Class modelClass, Map textureGroup) throws IOException{ - ModelPoolEntry entry = null; - if(modelMap.containsKey(file)){ - entry = modelMap.get(file); - entry.applyGroups(textureGroup); - return entry; - } - try{ - entry = (ModelPoolEntry)modelClass.newInstance(); - } - catch(Exception e){ - System.out.println("A new " + entry.getClass().getName() + " could not be initialized."); - System.out.println(e.getMessage()); - return null; - } - File modelFile = null; - InputStream in = entry.getClass().getResourceAsStream("/assets/" + file + ".obj"); - File tempfile = File.createTempFile(file, ".obj"); - FileOutputStream out = new FileOutputStream(tempfile); - tempfile.deleteOnExit(); - IOUtils.copy(in, out); - System.out.println("RENDER: " + tempfile.getPath().toString()); - modelFile = tempfile; - if(modelFile == null || !modelFile.exists()){ - System.out.println("The model with the name " + file + " does not exist."); - return null; - } - entry.textures = new HashMap(); - entry.name = file; - entry.setTextureGroup("0"); - entry.getModel(modelFile); - entry.applyGroups(textureGroup); - modelMap.put(file, entry); - return entry; - } - - private static Map modelMap = new HashMap(); - private static String[] resourceDir = new String[] { - "minecraft/resources/models/", - "minecraft/resources/mod/models/" - }; - public static final Class OBJ = ModelPoolObjEntry.class; - -} diff --git a/tmt/ModelPoolEntry.java b/tmt/ModelPoolEntry.java deleted file mode 100644 index ba10de7c26..0000000000 --- a/tmt/ModelPoolEntry.java +++ /dev/null @@ -1,65 +0,0 @@ -package tmt; - -import java.io.File; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -public abstract class ModelPoolEntry { - - public String name; - public TexturedVertex[] vertices; - public TexturedPolygon[] faces; - public Map textures; - protected TextureGroup texture; - protected String[] fileExtensions; - - public File checkValidPath(String path){ - File file = null; - for(int index = 0; index < fileExtensions.length && (file == null || !file.exists()); index++){ - String absPath = path; - if(!path.endsWith("." + fileExtensions[index])){ - absPath+= "." + fileExtensions[index]; - } - file = new File(absPath); - } - if(file == null || !file.exists()){ - return null; - } - return file; - } - - public abstract void getModel(File file); - - /** - * Sets the current texture group, which is used to switch the - * textures on a per-model base. Do note that any model that is - * rendered afterwards will use the same texture. To counter it, - * set a default texture, either at initialization or before - * rendering. - * @param groupName The name of the texture group. If the texture - * group doesn't exist, it creates a new group automatically. - */ - protected void setTextureGroup(String groupName){ - if(textures.size() == 0 || !textures.containsKey(groupName)){ - textures.put(groupName, new TextureGroup()); - } - texture = textures.get(groupName); - } - - protected void applyGroups( Map texturesMap){ - Collection texturesCol = textures.keySet(); - Iterator texturesItr = texturesCol.iterator(); - while(texturesItr.hasNext()){ - int nameIdx = 0; - String groupKey = texturesItr.next(); - String currentGroup = name + "_" + nameIdx + ":" + groupKey; - while(texturesMap.containsKey(currentGroup)){ - nameIdx++; - currentGroup = name + "_" + nameIdx + ":" + groupKey; - } - texturesMap.put(currentGroup, textures.get(groupKey)); - } - } - -} diff --git a/tmt/ModelPoolObjEntry.java b/tmt/ModelPoolObjEntry.java deleted file mode 100644 index 9ac9534197..0000000000 --- a/tmt/ModelPoolObjEntry.java +++ /dev/null @@ -1,195 +0,0 @@ -package tmt; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.ArrayList; - -public class ModelPoolObjEntry extends ModelPoolEntry { - - public ModelPoolObjEntry(){ - fileExtensions = new String[] {"obj"}; - } - - public void getModel(File file){ - try{ - BufferedReader in = new BufferedReader(new FileReader(file)); - String s; - ArrayList verts = new ArrayList(); - ArrayList uvs = new ArrayList(); - ArrayList normals = new ArrayList(); - ArrayList face = new ArrayList(); - while((s = in.readLine()) != null){ - if(s.contains("#")){ - s = s.substring(0, s.indexOf("#")); - } - s = s.trim(); - if(s.equals("")){ - continue; - } - if(s.startsWith("g ")){ - setTextureGroup(s.substring(s.indexOf(" ") + 1).trim()); - continue; - } - if(s.startsWith("v ")){ - s = s.substring(s.indexOf(" ") + 1).trim(); - float[] v = new float[3]; - for(int i = 0; i < 3; i++){ - int ind = s.indexOf(" "); - if(ind > -1){ - v[i] = Float.parseFloat(s.substring(0, ind)); - } - else{ - v[i] = Float.parseFloat(s.substring(0)); - } - s = s.substring(s.indexOf(" ") + 1).trim(); - } - float flt = v[2]; - v[2] = -v[1]; - v[1] = flt; - verts.add(new TexturedVertex(v[0], v[1], v[2], 0, 0)); - continue; - } - if(s.startsWith("vt ")){ - s = s.substring(s.indexOf(" ") + 1).trim(); - float[] v = new float[2]; - for(int i = 0; i < 2; i++){ - int ind = s.indexOf(" "); - if(ind > -1){ - v[i] = Float.parseFloat(s.substring(0, ind)); - } - else{ - v[i] = Float.parseFloat(s.substring(0)); - } - s = s.substring(s.indexOf(" ") + 1).trim(); - } - uvs.add(new float[] {v[0], 1F - v[1]}); - continue; - } - if(s.startsWith("vn ")){ - s = s.substring(s.indexOf(" ") + 1).trim(); - float[] v = new float[3]; - for(int i = 0; i < 3; i++){ - int ind = s.indexOf(" "); - if(ind > -1){ - v[i] = Float.parseFloat(s.substring(0, ind)); - } - else{ - v[i] = Float.parseFloat(s.substring(0)); - } - s = s.substring(s.indexOf(" ") + 1).trim(); - } - float flt = v[2]; - v[2] = v[1]; - v[1] = flt; - normals.add(new float[] {v[0], v[1], v[2]}); - continue; - } - if(s.startsWith("f ")){ - s = s.substring(s.indexOf(" ") + 1).trim(); - ArrayList v = new ArrayList(); - String s1; - int finalPhase = 0; - float[] normal = new float[] {0F, 0F, 0F}; - ArrayList iNormal = new ArrayList(); - do{ - int vInt; - float[] curUV; - float[] curNormals; - int ind = s.indexOf(" "); - s1 = s; - if(ind > -1){ - s1 = s.substring(0, ind); - } - if(s1.indexOf("/") > -1){ - String[] f = s1.split("/"); - vInt = Integer.parseInt(f[0]) - 1; - if(f[1].equals("")){ - f[1] = f[0]; - } - int vtInt = Integer.parseInt(f[1]) - 1; - if(uvs.size() > vtInt){ - curUV = uvs.get(vtInt); - } - else{ - curUV = new float[] {0, 0}; - } - int vnInt = 0; - if(f.length == 3){ - if(f[2].equals("")){ - f[2] = f[0]; - } - vnInt = Integer.parseInt(f[2]) - 1; - } - else{ - vnInt = Integer.parseInt(f[0]) - 1; - } - if(normals.size() > vnInt){ - curNormals = normals.get(vnInt); - } - else{ - curNormals = new float[] {0, 0, 0}; - } - } - else{ - vInt = Integer.parseInt(s1) - 1; - if(uvs.size() > vInt){ - curUV = uvs.get(vInt); - } - else{ - curUV = new float[] {0, 0}; - } - if(normals.size() > vInt){ - curNormals = normals.get(vInt); - } - else{ - curNormals = new float[] {0, 0, 0}; - } - } - iNormal.add(new Vec3f(curNormals[0], curNormals[1], curNormals[2])); - normal[0]+= curNormals[0]; - normal[1]+= curNormals[1]; - normal[2]+= curNormals[2]; - if(vInt < verts.size()){ - v.add(verts.get(vInt).setTexturePosition(curUV[0], curUV[1])); - } - if(ind > -1){ - s = s.substring(s.indexOf(" ") + 1).trim(); - } - else{ - finalPhase++; - } - } - while(finalPhase < 1); - float d = (float)Math.sqrt(normal[0] * normal[0] + normal[1] * normal[1] + normal[2] * normal[2]); - normal[0]/= d; - normal[1]/= d; - normal[2]/= d; - TexturedVertex[] vToArr = new TexturedVertex[v.size()]; - for(int i = 0; i < v.size(); i++){ - vToArr[i] = v.get(i); - } - TexturedPolygon poly = new TexturedPolygon(vToArr); - poly.setNormals(normal[0], normal[1], normal[2]); - poly.setNormals(iNormal); - face.add(poly); - texture.addPoly(poly); - continue; - } - } - vertices = new TexturedVertex[verts.size()]; - for(int i = 0; i < verts.size(); i++){ - vertices[i] = verts.get(i); - } - faces = new TexturedPolygon[face.size()]; - for(int i = 0; i < face.size(); i++){ - faces[i] = face.get(i); - } - in.close(); - } - catch(Throwable e){ - // - } - } - -} diff --git a/tmt/ModelRendererTurbo.java b/tmt/ModelRendererTurbo.java deleted file mode 100644 index 8efccb4417..0000000000 --- a/tmt/ModelRendererTurbo.java +++ /dev/null @@ -1,1840 +0,0 @@ -package tmt; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.lwjgl.opengl.GL11; - -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.GLAllocation; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -/** - * An extension to the ModelRenderer class. It basically is a copy to ModelRenderer, - * however, it contains various new methods to make your models. - *

- * Since the ModelRendererTurbo class gets loaded during startup, the models made - * can be very complex. This is why I can afford to add, for example, Wavefont OBJ - * support or have the addSprite method, methods that add a lot of vertices and - * polygons. - * - * This version of TMT was updated, maintened, as well as extended for 1.8 and newer Minecraft versions by FEX___96 - * - * @author GaryCXJk, Ferdinand (FEX___96) - * @license http://fexcraft.net/license?id=tmt - * - */ -public class ModelRendererTurbo { - - public List faces = new ArrayList(); - public float rotationPointX, rotationPointY, rotationPointZ; - public float rotateAngleX, rotateAngleY, rotateAngleZ; - public int textureOffsetX, textureWidth; - public int textureOffsetY, textureHeight; - public boolean compiled; - private int displayList; - private int displayListArray[]; - public Map textureGroup; - private TextureGroup currentTextureGroup; - public boolean mirror; - public boolean flip; - public boolean rotorder = false; - public boolean showModel; - public boolean field_1402_i; - public boolean forcedRecompile; - public boolean useLegacyCompiler; - public List childModels; - public String boxName; - public boolean isShape = false; - - private String defaultTexture; - - public static final int MR_FRONT = 0; - public static final int MR_BACK = 1; - public static final int MR_LEFT = 2; - public static final int MR_RIGHT = 3; - public static final int MR_TOP = 4; - public static final int MR_BOTTOM = 5; - - //Eternal: added scaling to boxes for use with animator. - public float xScale; - public float yScale; - public float zScale; - - public static final float pi = (float)Math.PI; - - public ModelRendererTurbo(Object Object, String s){ - flip = false; - compiled = false; - displayList = 0; - mirror = false; - showModel = true; - field_1402_i = false; - faces = new ArrayList(); - forcedRecompile = false; - textureGroup = new HashMap(); - textureGroup.put("0", new TextureGroup()); - currentTextureGroup = textureGroup.get("0"); - boxName = s; - defaultTexture = ""; - useLegacyCompiler = true; - } - - public ModelRendererTurbo(Object Object){ - this(Object, ""); - } - - /** - * Creates a new ModelRenderTurbo object. It requires the coordinates of the - * position of the texture. - * @param Object - * @param textureX the x-coordinate on the texture - * @param textureY the y-coordinate on the texture - */ - public ModelRendererTurbo(Object Object, int textureX, int textureY){ - this(Object, textureX, textureY, 64, 32); - } - - /** - * Creates a new ModelRenderTurbo object. It requires the coordinates of the - * position of the texture, but also allows you to specify the width and height - * of the texture, allowing you to use bigger textures instead. - * @param Object - * @param textureX - * @param textureY - * @param textureU - * @param textureV - */ - public ModelRendererTurbo(Object Object, int textureX, int textureY, int textureU, int textureV){ - this(Object); - textureOffsetX = textureX; - textureOffsetY = textureY; - textureWidth = textureU; - textureHeight = textureV; - } - - /** - * ETERNAL: new object initialization method for animator support - * Creates a new ModelRenderTurbo object with a name. It requires the coordinates of the - * position of the texture, but also allows you to specify the width and height - * of the texture, allowing you to use bigger textures instead. - * It also requires a string to define the name of the box, this is used for animation - * @param Object the shape. - * @param textureX the texture left position - * @param textureY the texture top position - * @param textureU the texture width - * @param textureV the texture heught - * @param boxName the name of the shape. - */ - public ModelRendererTurbo(Object Object, int textureX, int textureY, int textureU, int textureV, String boxName) { - this(Object, boxName); - textureOffsetX = textureX; - textureOffsetY = textureY; - textureWidth = textureU; - textureHeight = textureV; - } - - /** - * Creates a new polygon. - * @param verts an array of vertices - */ - public void addPolygon(TexturedVertex[] verts){ - copyTo(verts, new TexturedPolygon[] {new TexturedPolygon(verts)}); - } - - /** - * Creates a new polygon, and adds UV mapping to it. - * @param verts an array of vertices - * @param uv an array of UV coordinates - */ - public void addPolygon(TexturedVertex[] verts, int[][] uv){ - try{ - for(int i = 0; i < verts.length; i++){ - verts[i] = verts[i].setTexturePosition(uv[i][0] / textureWidth, uv[i][1] / textureHeight); - } - } - finally{ - addPolygon(verts); - } - } - - /** - * Creates a new polygon with a given UV. - * @param verts an array of vertices - * @param u1 - * @param v1 - * @param u2 - * @param v2 - */ - public void addPolygon(TexturedVertex[] verts, int u1, int v1, int u2, int v2){ - copyTo(verts, new TexturedPolygon[] {addPolygonReturn(verts, u1, v1, u2, v2)}); - } - - private TexturedPolygon addPolygonReturn(TexturedVertex[] verts, float f, float g, float h, float j){ - if(verts.length < 3){ - return null; - } - float uOffs = 1.0F / (textureWidth * 10.0F); - float vOffs = 1.0F / (textureHeight * 10.0F); - if(verts.length < 4){ - float xMin = -1; - float yMin = -1; - float xMax = 0; - float yMax = 0; - for(int i = 0; i < verts.length; i++){ - float xPos = verts[i].textureX; - float yPos = verts[i].textureY; - xMax = Math.max(xMax, xPos); - xMin = (xMin < -1 ? xPos : Math.min(xMin, xPos)); - yMax = Math.max(yMax, yPos); - yMin = (yMin < -1 ? yPos : Math.min(yMin, yPos)); - } - float uMin = f / textureWidth + uOffs; - float vMin = g / textureHeight + vOffs; - float uSize = (h - f) / textureWidth - uOffs * 2; - float vSize = (j - g) / textureHeight - vOffs * 2; - float xSize = xMax - xMin; - float ySize = yMax - yMin; - for(int i = 0; i < verts.length; i++){ - float xPos = verts[i].textureX; - float yPos = verts[i].textureY; - xPos = (xPos - xMin) / xSize; - yPos = (yPos - yMin) / ySize; - verts[i] = verts[i].setTexturePosition(uMin + (xPos * uSize), vMin + (yPos * vSize)); - } - } - else{ - verts[0] = verts[0].setTexturePosition(h / textureWidth - uOffs, g / textureHeight + vOffs); - verts[1] = verts[1].setTexturePosition(f / textureWidth + uOffs, g / textureHeight + vOffs); - verts[2] = verts[2].setTexturePosition(f / textureWidth + uOffs, j / textureHeight - vOffs); - verts[3] = verts[3].setTexturePosition(h / textureWidth - uOffs, j / textureHeight - vOffs); - } - return new TexturedPolygon(verts); - } - - /** - * Adds a rectangular shape. Basically, you can make any eight-pointed shape you want, - * as the method requires eight vector coordinates. - * @param v a float array with three values, the x, y and z coordinates of the vertex - * @param v1 a float array with three values, the x, y and z coordinates of the vertex - * @param v2 a float array with three values, the x, y and z coordinates of the vertex - * @param v3 a float array with three values, the x, y and z coordinates of the vertex - * @param v4 a float array with three values, the x, y and z coordinates of the vertex - * @param v5 a float array with three values, the x, y and z coordinates of the vertex - * @param v6 a float array with three values, the x, y and z coordinates of the vertex - * @param v7 a float array with three values, the x, y and z coordinates of the vertex - * @param w the width of the shape, used in determining the texture - * @param h the height of the shape, used in determining the texture - * @param d the depth of the shape, used in determining the texture - * @return - */ - public ModelRendererTurbo addRectShape(float[] v, float[] v1, float[] v2, float[] v3, float[] v4, float[] v5, float[] v6, float[] v7, float w, float h, float d){ - return addRectShape(v, v1, v2, v3, v4, v5, v6, v7, w, h, d, null); - } - - /** Updated to match the addRectShape method from FCL at 18.Jul.2021 @author Ferdinand (FEX___96) */ - public ModelRendererTurbo addRectShape(float[] v0, float[] v1, float[] v2, float[] v3, float[] v4, float[] v5, float[] v6, float[] v7, float w, float h, float d, boolean[] sides){ - TexturedPolygon[] poly = new TexturedPolygon[6]; - TexturedVertex tv0 = new TexturedVertex(v0[0], v0[1], v0[2], 0.0F, 0.0F); - TexturedVertex tv1 = new TexturedVertex(v1[0], v1[1], v1[2], 0.0F, 8.0F); - TexturedVertex tv2 = new TexturedVertex(v2[0], v2[1], v2[2], 8.0F, 8.0F); - TexturedVertex tv3 = new TexturedVertex(v3[0], v3[1], v3[2], 8.0F, 0.0F); - TexturedVertex tv4 = new TexturedVertex(v4[0], v4[1], v4[2], 0.0F, 0.0F); - TexturedVertex tv5 = new TexturedVertex(v5[0], v5[1], v5[2], 0.0F, 8.0F); - TexturedVertex tv6 = new TexturedVertex(v6[0], v6[1], v6[2], 8.0F, 8.0F); - TexturedVertex tv7 = new TexturedVertex(v7[0], v7[1], v7[2], 8.0F, 0.0F); - //if(w % 1 != 0) w = w < 1 ? 1 : (int)w + (w % 1 > 0.5f ? 1 : 0); - //if(h % 1 != 0) h = h < 1 ? 1 : (int)h + (h % 1 > 0.5f ? 1 : 0); - //if(d % 1 != 0) d = d < 1 ? 1 : (int)d + (d % 1 > 0.5f ? 1 : 0); - if(sides == null){ - poly[0] = addPolygonReturn(new TexturedVertex[] { tv5, tv1, tv2, tv6 }, textureOffsetX + d + w, textureOffsetY + d, textureOffsetX + d + w + d, textureOffsetY + d + h); - poly[1] = addPolygonReturn(new TexturedVertex[] { tv0, tv4, tv7, tv3 }, textureOffsetX + 0, textureOffsetY + d, textureOffsetX + d, textureOffsetY + d + h); - poly[2] = addPolygonReturn(new TexturedVertex[] { tv5, tv4, tv0, tv1 }, textureOffsetX + d, textureOffsetY + 0, textureOffsetX + d + w, textureOffsetY + d); - poly[3] = addPolygonReturn(new TexturedVertex[] { tv2, tv3, tv7, tv6 }, textureOffsetX + d + w, textureOffsetY + 0, textureOffsetX + d + w + w, textureOffsetY + d); - poly[4] = addPolygonReturn(new TexturedVertex[] { tv1, tv0, tv3, tv2 }, textureOffsetX + d, textureOffsetY + d, textureOffsetX + d + w, textureOffsetY + d + h); - poly[5] = addPolygonReturn(new TexturedVertex[] { tv4, tv5, tv6, tv7 }, textureOffsetX + d + w + d, textureOffsetY + d, textureOffsetX + d + w + d + w, textureOffsetY + d + h); - } - else{ - float yp = sides[2] && sides[3] ? 0 : d; - float x0 = sides[1] ? 0 : d; - float x1 = sides[2] ? 0 : w; - float x2 = sides[4] ? 0 : w; - float x3 = sides[0] ? 0 : d; - if(sides.length > 0 && !sides[0]) poly[0] = addPolygonReturn(new TexturedVertex[] { tv5, tv1, tv2, tv6 }, textureOffsetX + x0 + x2, textureOffsetY + yp, textureOffsetX + x0 + x2 + d, textureOffsetY + yp + h); - if(sides.length > 1 && !sides[1]) poly[1] = addPolygonReturn(new TexturedVertex[] { tv0, tv4, tv7, tv3 }, textureOffsetX + 0, textureOffsetY + yp, textureOffsetX + d, textureOffsetY + yp + h); - if(sides.length > 2 && !sides[2]) poly[2] = addPolygonReturn(new TexturedVertex[] { tv5, tv4, tv0, tv1 }, textureOffsetX + x0, textureOffsetY + 0, textureOffsetX + x0 + w, textureOffsetY + d); - if(sides.length > 3 && !sides[3]) poly[3] = addPolygonReturn(new TexturedVertex[] { tv2, tv3, tv7, tv6 }, textureOffsetX + x0 + x1, textureOffsetY + 0, textureOffsetX + x0 + x1 + w, textureOffsetY + d); - if(sides.length > 4 && !sides[4]) poly[4] = addPolygonReturn(new TexturedVertex[] { tv1, tv0, tv3, tv2 }, textureOffsetX + x0, textureOffsetY + yp, textureOffsetX + x0 + w, textureOffsetY + yp + h); - if(sides.length > 5 && !sides[5]) poly[5] = addPolygonReturn(new TexturedVertex[] { tv4, tv5, tv6, tv7 }, textureOffsetX + x0 + x2 + x3, textureOffsetY + yp, textureOffsetX + x0 + x2 + x3 + w, textureOffsetY + yp + h); - } - if(mirror ^ flip){ - for(int l = 0; l < poly.length; l++){ - poly[l].flipFace(); - } - } - if(sides != null){ - int polis = 0, processed = 0; - for(int i = 0; i < poly.length; i++) if(poly[i] != null) polis++; - TexturedPolygon[] polygons = new TexturedPolygon[polis]; - for(int i = 0; i < poly.length; i++){ - if(poly[i] != null){ - polygons[processed] = poly[i]; - processed++; - } - } - poly = polygons; - } - return copyTo(null, poly); - } - - /** - * Adds a new box to the model. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param w the width (over the x-direction) - * @param h the height (over the y-direction) - * @param d the depth (over the z-direction) - */ - public ModelRendererTurbo addBox(float x, float y, float z, int w, int h, int d){ - return addBox(x, y, z, w, h, d, 0.0F); - } - - /** - * Adds a new box to the model. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param w the width (over the x-direction) - * @param h the height (over the y-direction) - * @param d the depth (over the z-direction) - * @param expansion the expansion of the box. It increases the size in each direction by that many. - */ - public ModelRendererTurbo addBox(float x, float y, float z, int w, int h, int d, float expansion){ - return addBox(x, y, z, w, h, d, expansion, 1F); - } - - /** - * Adds a new box to the model. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param w the width (over the x-direction) - * @param h the height (over the y-direction) - * @param d the depth (over the z-direction) - * @param expansion the expansion of the box. It increases the size in each direction by that many. It's independent from the scale. - * @param scale - */ - public ModelRendererTurbo addBox(float x, float y, float z, float w, float h, float d, float expansion, float scale){ - return addBox(x, y, z, w, h, d, expansion, scale, null); - } - - public ModelRendererTurbo addBox(float x, float y, float z, float w, float h, float d, float expansion, float scale, boolean[] sides){ - if(w <1){ - w=0.01F; - x-=0.005F; - } - if(h <1){ - h=0.01F; - y-=0.005F; - } - if(d <1){ - d=0.01F; - z-=0.005F; - } - - xScale = w * scale; - yScale = h * scale; - zScale = d * scale; - - float x1 = x + xScale; - float y1 = y + yScale; - float z1 = z + zScale; - - float expX = expansion + xScale - w; - float expY = expansion + yScale - h; - float expZ = expansion + zScale - d; - - x -= expX; - y -= expY; - z -= expZ; - x1 += expansion; - y1 += expansion; - z1 += expansion; - if(mirror){ - float xTemp = x1; - x1 = x; - x = xTemp; - } - - float[] v = {x, y, z}; - float[] v1 = {x1, y, z}; - float[] v2 = {x1, y1, z}; - float[] v3 = {x, y1, z}; - float[] v4 = {x, y, z1}; - float[] v5 = {x1, y, z1}; - float[] v6 = {x1, y1, z1}; - float[] v7 = {x, y1, z1}; - return addRectShape(v, v1, v2, v3, v4, v5, v6, v7, w, h, d, sides); - } - - /** - * Adds a trapezoid-like shape. It's achieved by expanding the shape on one side. - * You can use the static variables MR_RIGHT, MR_LEFT, - * MR_FRONT, MR_BACK, MR_TOP and - * MR_BOTTOM. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param w the width (over the x-direction) - * @param h the height (over the y-direction) - * @param d the depth (over the z-direction) - * @param scale the "scale" of the box. It only increases the size in each direction by that many. - * @param bottomScale the "scale" of the bottom - * @param dir the side the scaling is applied to - */ - public void addTrapezoid(float x, float y, float z, int w, int h, int d, float scale, float bottomScale, int dir){ - float f4 = x + w; - float f5 = y + h; - float f6 = z + d; - x -= scale; - y -= scale; - z -= scale; - f4 += scale; - f5 += scale; - f6 += scale; - - int m = (mirror ? -1 : 1); - if(mirror){ - float f7 = f4; - f4 = x; - x = f7; - } - float[] v = {x, y, z}; - float[] v1 = {f4, y, z}; - float[] v2 = {f4, f5, z}; - float[] v3 = {x, f5, z}; - float[] v4 = {x, y, f6}; - float[] v5 = {f4, y, f6}; - float[] v6 = {f4, f5, f6}; - float[] v7 = {x, f5, f6}; - - switch(dir){ - case MR_RIGHT: - v[1] -= bottomScale; - v[2] -= bottomScale; - v3[1] += bottomScale; - v3[2] -= bottomScale; - v4[1] -= bottomScale; - v4[2] += bottomScale; - v7[1] += bottomScale; - v7[2] += bottomScale; - break; - case MR_LEFT: - v1[1] -= bottomScale; - v1[2] -= bottomScale; - v2[1] += bottomScale; - v2[2] -= bottomScale; - v5[1] -= bottomScale; - v5[2] += bottomScale; - v6[1] += bottomScale; - v6[2] += bottomScale; - break; - case MR_FRONT: - v[0] -= m * bottomScale; - v[1] -= bottomScale; - v1[0] += m * bottomScale; - v1[1] -= bottomScale; - v2[0] += m * bottomScale; - v2[1] += bottomScale; - v3[0] -= m * bottomScale; - v3[1] += bottomScale; - break; - case MR_BACK: - v4[0] -= m * bottomScale; - v4[1] -= bottomScale; - v5[0] += m * bottomScale; - v5[1] -= bottomScale; - v6[0] += m * bottomScale; - v6[1] += bottomScale; - v7[0] -= m * bottomScale; - v7[1] += bottomScale; - break; - case MR_TOP: - v[0] -= m * bottomScale; - v[2] -= bottomScale; - v1[0] += m * bottomScale; - v1[2] -= bottomScale; - v4[0] -= m * bottomScale; - v4[2] += bottomScale; - v5[0] += m * bottomScale; - v5[2] += bottomScale; - break; - case MR_BOTTOM: - v2[0] += m * bottomScale; - v2[2] -= bottomScale; - v3[0] -= m * bottomScale; - v3[2] -= bottomScale; - v6[0] += m * bottomScale; - v6[2] += bottomScale; - v7[0] -= m * bottomScale; - v7[2] += bottomScale; - break; - } - addRectShape(v, v1, v2, v3, v4, v5, v6, v7, w, h, d); - } - - /** - * Adds a trapezoid-like shape. It's achieved by expanding the shape on one side. - * You can use the static variables MR_RIGHT, MR_LEFT, - * MR_FRONT, MR_BACK, MR_TOP and - * MR_BOTTOM. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param w the width (over the x-direction) - * @param h the height (over the y-direction) - * @param d the depth (over the z-direction) - * @param scale the "scale" of the box. It only increases the size in each direction by that many. - * @param bScale1 the "scale" of the bottom - Top - * @param bScale2 the "scale" of the bottom - Bottom - * @param bScale3 the "scale" of the bottom - Left - * @param bScale4 the "scale" of the bottom - Right - * @param fScale1 the "scale" of the top - Left - * @param fScale2 the "scale" of the top - Right - * @param dir the side the scaling is applied to - */ - public void addFlexTrapezoid(float x, float y, float z, int w, int h, int d, float scale, float bScale1, float bScale2, float bScale3, float bScale4, float fScale1, float fScale2, int dir) - { - float f4 = x + w; - float f5 = y + h; - float f6 = z + d; - x -= scale; - y -= scale; - z -= scale; - f4 += scale; - f5 += scale; - f6 += scale; - - int m = (mirror ? -1 : 1); - if(mirror) - { - float f7 = f4; - f4 = x; - x = f7; - } - - float[] v = {x, y, z}; - float[] v1 = {f4, y, z}; - float[] v2 = {f4, f5, z}; - float[] v3 = {x, f5, z}; - float[] v4 = {x, y, f6}; - float[] v5 = {f4, y, f6}; - float[] v6 = {f4, f5, f6}; - float[] v7 = {x, f5, f6}; - - - switch(dir) - { - case MR_RIGHT: - v[2] -= fScale1; - v1[2] -= fScale1; - v4[2] += fScale2; - v5[2] += fScale2; - - v[1] -= bScale1; - v[2] -= bScale3; - v3[1] += bScale2; - v3[2] -= bScale3; - v4[1] -= bScale1; - v4[2] += bScale4; - v7[1] += bScale2; - v7[2] += bScale4; - break; - case MR_LEFT: - v[2] -= fScale1; - v1[2] -= fScale1; - v4[2] += fScale2; - v5[2] += fScale2; - - v1[1] -= bScale1; - v1[2] -= bScale3; - v2[1] += bScale2; - v2[2] -= bScale3; - v5[1] -= bScale1; - v5[2] += bScale4; - v6[1] += bScale2; - v6[2] += bScale4; - break; - case MR_FRONT: - v1[1] -= fScale1; - v5[1] -= fScale1; - v2[1] += fScale2; - v6[1] += fScale2; - - v[0] -= m * bScale4; - v[1] -= bScale1; - v1[0] += m * bScale3; - v1[1] -= bScale1; - v2[0] += m * bScale3; - v2[1] += bScale2; - v3[0] -= m * bScale4; - v3[1] += bScale2; - break; - case MR_BACK: - v1[1] -= fScale1; - v5[1] -= fScale1; - v2[1] += fScale2; - v6[1] += fScale2; - - v4[0] -= m * bScale4; - v4[1] -= bScale1; - v5[0] += m * bScale3; - v5[1] -= bScale1; - v6[0] += m * bScale3; - v6[1] += bScale2; - v7[0] -= m * bScale4; - v7[1] += bScale2; - break; - case MR_TOP: - v1[2] -= fScale1; - v2[2] -= fScale1; - v5[2] += fScale2; - v6[2] += fScale2; - - v[0] -= m * bScale1; - v[2] -= bScale3; - v1[0] += m * bScale2; - v1[2] -= bScale3; - v4[0] -= m * bScale1; - v4[2] += bScale4; - v5[0] += m * bScale2; - v5[2] += bScale4; - break; - case MR_BOTTOM: - v1[2] -= fScale1; - v2[2] -= fScale1; - v5[2] += fScale2; - v6[2] += fScale2; - - v2[0] += m * bScale2; - v2[2] -= bScale3; - v3[0] -= m * bScale1; - v3[2] -= bScale3; - v6[0] += m * bScale2; - v6[2] += bScale4; - v7[0] -= m * bScale1; - v7[2] += bScale4; - break; - } - - addRectShape(v, v1, v2, v3, v4, v5, v6, v7, w, h, d); - } - - /** - * Creates a shape from a 2D vector shape. - * @param x the starting x position - * @param y the starting y position - * @param z the starting z position - * @param coordinates an array of coordinates that form the shape - * @param depth the depth of the shape - * @param shapeTextureWidth the width of the texture of one side of the shape - * @param shapeTextureHeight the height of the texture the shape - * @param sideTextureWidth the width of the texture of the side of the shape - * @param sideTextureHeight the height of the texture of the side of the shape - * @param direction the direction the starting point of the shape is facing - */ - public ModelRendererTurbo addShape3D(float x, float y, float z, Coord2D[] coordinates, float depth, int shapeTextureWidth, int shapeTextureHeight, int sideTextureWidth, int sideTextureHeight, int direction){ - return addShape3D(x, y, z, coordinates, depth, shapeTextureWidth, shapeTextureHeight, sideTextureWidth, sideTextureHeight, direction, null); - } - - /** - * Creates a shape from a 2D vector shape. - * @param x the starting x position - * @param y the starting y position - * @param z the starting z position - * @param coordinates an array of coordinates that form the shape - * @param depth the depth of the shape - * @param shapeTextureWidth the width of the texture of one side of the shape - * @param shapeTextureHeight the height of the texture the shape - * @param sideTextureWidth the width of the texture of the side of the shape - * @param sideTextureHeight the height of the texture of the side of the shape - * @param direction the direction the starting point of the shape is facing - * @param faceLengths An array with the length of each face. Used to set - * the texture width of each face on the side manually. - * @return - */ - public ModelRendererTurbo addShape3D(float x, float y, float z, Coord2D[] coordinates, float depth, int shapeTextureWidth, int shapeTextureHeight, int sideTextureWidth, int sideTextureHeight, int direction, float[] faceLengths){ - return addShape3D(x, y, z, new Shape2D(coordinates), depth, shapeTextureWidth, shapeTextureHeight, sideTextureWidth, sideTextureHeight, direction, faceLengths); - } - - /** - * Creates a shape from a 2D vector shape. - * @param x the starting x position - * @param y the starting y position - * @param z the starting z position - * @param coordinates an ArrayList of coordinates that form the shape - * @param depth the depth of the shape - * @param shapeTextureWidth the width of the texture of one side of the shape - * @param shapeTextureHeight the height of the texture the shape - * @param sideTextureWidth the width of the texture of the side of the shape - * @param sideTextureHeight the height of the texture of the side of the shape - * @param direction the direction the starting point of the shape is facing - */ - public void addShape3D(float x, float y, float z, ArrayList coordinates, float depth, int shapeTextureWidth, int shapeTextureHeight, int sideTextureWidth, int sideTextureHeight, int direction){ - addShape3D(x, y, z, coordinates, depth, shapeTextureWidth, shapeTextureHeight, sideTextureWidth, sideTextureHeight, direction, null); - } - - /** - * Creates a shape from a 2D vector shape. - * @param x the starting x position - * @param y the starting y position - * @param z the starting z position - * @param coordinates an ArrayList of coordinates that form the shape - * @param depth the depth of the shape - * @param shapeTextureWidth the width of the texture of one side of the shape - * @param shapeTextureHeight the height of the texture the shape - * @param sideTextureWidth the width of the texture of the side of the shape - * @param sideTextureHeight the height of the texture of the side of the shape - * @param direction the direction the starting point of the shape is facing - * @param faceLengths An array with the length of each face. Used to set - * the texture width of each face on the side manually. - */ - public void addShape3D(float x, float y, float z, ArrayList coordinates, float depth, int shapeTextureWidth, int shapeTextureHeight, int sideTextureWidth, int sideTextureHeight, int direction, float[] faceLengths){ - addShape3D(x, y, z, new Shape2D(coordinates), depth, shapeTextureWidth, shapeTextureHeight, sideTextureWidth, sideTextureHeight, direction, faceLengths); - } - - /** - * Creates a shape from a 2D vector shape. - * @param x the starting x position - * @param y the starting y position - * @param z the starting z position - * @param shape a Shape2D which contains the coordinates of the shape points - * @param depth the depth of the shape - * @param shapeTextureWidth the width of the texture of one side of the shape - * @param shapeTextureHeight the height of the texture the shape - * @param sideTextureWidth the width of the texture of the side of the shape - * @param sideTextureHeight the height of the texture of the side of the shape - * @param direction the direction the starting point of the shape is facing - */ - public void addShape3D(float x, float y, float z, Shape2D shape, float depth, int shapeTextureWidth, int shapeTextureHeight, int sideTextureWidth, int sideTextureHeight, int direction){ - addShape3D(x, y, z, shape, depth, shapeTextureWidth, shapeTextureHeight, sideTextureWidth, sideTextureHeight, direction, null); - } - - /** - * Creates a shape from a 2D vector shape. - * @param x the starting x position - * @param y the starting y position - * @param z the starting z position - * @param shape a Shape2D which contains the coordinates of the shape points - * @param depth the depth of the shape - * @param shapeTextureWidth the width of the texture of one side of the shape - * @param shapeTextureHeight the height of the texture the shape - * @param sideTextureWidth the width of the texture of the side of the shape - * @param sideTextureHeight the height of the texture of the side of the shape - * @param direction the direction the starting point of the shape is facing - * @param faceLengths An array with the length of each face. Used to set - * the texture width of each face on the side manually. - * @return - */ - public ModelRendererTurbo addShape3D(float x, float y, float z, Shape2D shape, float depth, int shapeTextureWidth, int shapeTextureHeight, int sideTextureWidth, int sideTextureHeight, int direction, float[] faceLengths){ - float rotX = 0; - float rotY = 0; - float rotZ = 0; - switch(direction){ - case MR_LEFT: - rotY = pi / 2; - break; - case MR_RIGHT: - rotY = -pi / 2; - break; - case MR_TOP: - rotX = pi / 2; - break; - case MR_BOTTOM: - rotX = -pi / 2; - break; - case MR_FRONT: - rotY = pi; - break; - case MR_BACK: - break; - } - return addShape3D(x, y, z, shape, depth, shapeTextureWidth, shapeTextureHeight, sideTextureWidth, sideTextureHeight, rotX, rotY, rotZ, faceLengths); - } - - /** - * Creates a shape from a 2D vector shape. - * @param x the starting x position - * @param y the starting y position - * @param z the starting z position - * @param shape a Shape2D which contains the coordinates of the shape points - * @param depth the depth of the shape - * @param shapeTextureWidth the width of the texture of one side of the shape - * @param shapeTextureHeight the height of the texture the shape - * @param sideTextureWidth the width of the texture of the side of the shape - * @param sideTextureHeight the height of the texture of the side of the shape - * @param rotX the rotation around the x-axis - * @param rotY the rotation around the y-axis - * @param rotZ the rotation around the z-axis - */ - public void addShape3D(float x, float y, float z, Shape2D shape, float depth, int shapeTextureWidth, int shapeTextureHeight, int sideTextureWidth, int sideTextureHeight, float rotX, float rotY, float rotZ){ - addShape3D(x, y, z, shape, depth, shapeTextureWidth, shapeTextureHeight, sideTextureWidth, sideTextureHeight, rotX, rotY, rotZ, null); - } - - /** - * Eternal: the check for flip was removed, shapes always need to be flipped., added a boolean to define if it's a shape or not so we can properly fix rotations - * NOTE: `x` and `z` are inverted to prevent "Toolbox" or "Flansmod"-type models from being rendered wrong. - * There is currently no other commonly used editor for such models, so let's leave it that way for now. - * NOTE2: Also let's rotate by 180 degrees for whatever reason. - * @return - * @Ferdinand - */ - public ModelRendererTurbo addShape3D(float x, float y, float z, Shape2D shape, float depth, int shapeTextureWidth, int shapeTextureHeight, int sideTextureWidth, int sideTextureHeight, float rotX, float rotY, float rotZ, float[] faceLengths){ - Shape3D shape3D = shape.extrude(-x, y, -z, rotX, rotY, rotZ, depth, textureOffsetX, textureOffsetY, textureWidth, textureHeight, shapeTextureWidth, shapeTextureHeight, sideTextureWidth, sideTextureHeight, faceLengths); - for(int idx = 0; idx < shape3D.faces.length; idx++){ - shape3D.faces[idx].flipFace(); - } - isShape = true; - return copyTo(shape3D.vertices, shape3D.faces); - } - - /** - * Adds a cube the size of one pixel. It will take a pixel from the texture and - * uses that as the texture of said cube. The accurate name would actually be - * "addVoxel". This method has been added to make it more compatible with Techne, - * and allows for easy single-colored boxes. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param width the width of the box - * @param height the height of the box - * @param length the length of the box - */ - public void addPixel(float x, float y, float z, float width, float height, float length){ - addPixel(x, y, z, new float[] {width, height, length}, textureOffsetX, textureOffsetY); - } - - /** - * Adds a cube the size of one pixel. It will take a pixel from the texture and - * uses that as the texture of said cube. The accurate name would actually be - * "addVoxel". It will not overwrite the model data, but rather, it will add to - * the model. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param scale the "scale" of the cube, where scale is a float integer consisting of three values - * @param w the x-coordinate on the texture - * @param h the y-coordinate on the texture - */ - public void addPixel(float x, float y, float z, float[] scale, int w, int h){ - TexturedVertex[] verts = new TexturedVertex[8]; - TexturedPolygon[] poly = new TexturedPolygon[6]; - float x1 = x + scale[0]; - float y1 = y + scale[1]; - float z1 = z + scale[2]; - float[] f = {x, y, z}; - float[] f1 = {x1, y, z}; - float[] f2 = {x1, y1, z}; - float[] f3 = {x, y1, z}; - float[] f4 = {x, y, z1}; - float[] f5 = {x1, y, z1}; - float[] f6 = {x1, y1, z1}; - float[] f7 = {x, y1, z1}; - TexturedVertex positionTexturevertex = new TexturedVertex(f[0], f[1], f[2], 0.0F, 0.0F); - TexturedVertex positionTexturevertex1 = new TexturedVertex(f1[0], f1[1], f1[2], 0.0F, 8F); - TexturedVertex positionTexturevertex2 = new TexturedVertex(f2[0], f2[1], f2[2], 8F, 8F); - TexturedVertex positionTexturevertex3 = new TexturedVertex(f3[0], f3[1], f3[2], 8F, 0.0F); - TexturedVertex positionTexturevertex4 = new TexturedVertex(f4[0], f4[1], f4[2], 0.0F, 0.0F); - TexturedVertex positionTexturevertex5 = new TexturedVertex(f5[0], f5[1], f5[2], 0.0F, 8F); - TexturedVertex positionTexturevertex6 = new TexturedVertex(f6[0], f6[1], f6[2], 8F, 8F); - TexturedVertex positionTexturevertex7 = new TexturedVertex(f7[0], f7[1], f7[2], 8F, 0.0F); - verts[0] = positionTexturevertex; - verts[1] = positionTexturevertex1; - verts[2] = positionTexturevertex2; - verts[3] = positionTexturevertex3; - verts[4] = positionTexturevertex4; - verts[5] = positionTexturevertex5; - verts[6] = positionTexturevertex6; - verts[7] = positionTexturevertex7; - poly[0] = addPolygonReturn(new TexturedVertex[] { - positionTexturevertex5, positionTexturevertex1, positionTexturevertex2, positionTexturevertex6 - }, w, h, w + 1, h + 1); - poly[1] = addPolygonReturn(new TexturedVertex[] { - positionTexturevertex, positionTexturevertex4, positionTexturevertex7, positionTexturevertex3 - }, w, h, w + 1, h + 1); - poly[2] = addPolygonReturn(new TexturedVertex[] { - positionTexturevertex5, positionTexturevertex4, positionTexturevertex, positionTexturevertex1 - }, w, h, w + 1, h + 1); - poly[3] = addPolygonReturn(new TexturedVertex[] { - positionTexturevertex2, positionTexturevertex3, positionTexturevertex7, positionTexturevertex6 - }, w, h, w + 1, h + 1); - poly[4] = addPolygonReturn(new TexturedVertex[] { - positionTexturevertex1, positionTexturevertex, positionTexturevertex3, positionTexturevertex2 - }, w, h, w + 1, h + 1); - poly[5] = addPolygonReturn(new TexturedVertex[] { - positionTexturevertex4, positionTexturevertex5, positionTexturevertex6, positionTexturevertex7 - }, w, h, w + 1, h + 1); - copyTo(verts, poly); - } - - /** - * Creates a model shaped like the exact image on the texture. Note that this method will - * increase the amount of quads on your model, which could effectively slow down your - * PC, so unless it is really a necessity to use it, I'd suggest you avoid using this - * method to create your model. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param w the width of the sprite - * @param h the height of the sprite - * @param expansion the expansion of the sprite. It only increases the size in each direction by that many. - */ - public void addSprite(float x, float y, float z, int w, int h, float expansion){ - addSprite(x, y, z, w, h, 1, false, false, false, false, false, expansion); - } - - /** - * Creates a model shaped like the exact image on the texture. Note that this method will - * increase the amount of quads on your model, which could effectively slow down your - * PC, so unless it is really a necessity to use it, I'd suggest you avoid using this - * method to create your model. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param w the width of the sprite - * @param h the height of the sprite - * @param rotX a boolean to define if it rotates 90 degrees around its yaw-axis - * @param rotY a boolean to define if it rotates 90 degrees around its pitch-axis - * @param rotZ a boolean to define if it rotates 90 degrees around its roll-axis - * @param mirrorX a boolean to define if the sprite should be mirrored - * @param mirrorY a boolean to define if the sprite should be flipped - * @param expansion the expansion of the sprite. It only increases the size in each direction by that many. - */ - public void addSprite(float x, float y, float z, int w, int h, boolean rotX, boolean rotY, boolean rotZ, boolean mirrorX, boolean mirrorY, float expansion){ - addSprite(x, y, z, w, h, 1, rotX, rotY, rotZ, mirrorX, mirrorY, expansion); - } - - /** - * Creates a model shaped like the exact image on the texture. Note that this method will - * increase the amount of quads on your model, which could effectively slow down your - * PC, so unless it is really a necessity to use it, I'd suggest you avoid using this - * method to create your model. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param w the width of the sprite - * @param h the height of the sprite - * @param d the depth of the shape itself - * @param rotX a boolean to define if it rotates 90 degrees around its yaw-axis - * @param rotY a boolean to define if it rotates 90 degrees around its pitch-axis - * @param rotZ a boolean to define if it rotates 90 degrees around its roll-axis - * @param mirrorX a boolean to define if the sprite should be mirrored - * @param mirrorY a boolean to define if the sprite should be flipped - * @param expansion the expansion of the sprite. It only increases the size in each direction by that many. - */ - public void addSprite(float x, float y, float z, int w, int h, int d, boolean rotX, boolean rotY, boolean rotZ, boolean mirrorX, boolean mirrorY, float expansion){ - addSprite(x, y, z, w, h, d, 1.0F, rotX, rotY, rotZ, mirrorX, mirrorY, expansion); - } - - /** - * Creates a model shaped like the exact image on the texture. Note that this method will - * increase the amount of quads on your model, which could effectively slow down your - * PC, so unless it is really a necessity to use it, I'd suggest you avoid using this - * method to create your model. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param w the width of the sprite - * @param h the height of the sprite - * @param d the depth of the shape itself - * @param pixelScale the scale of each individual pixel - * @param rotX a boolean to define if it rotates 90 degrees around its yaw-axis - * @param rotY a boolean to define if it rotates 90 degrees around its pitch-axis - * @param rotZ a boolean to define if it rotates 90 degrees around its roll-axis - * @param mirrorX a boolean to define if the sprite should be mirrored - * @param mirrorY a boolean to define if the sprite should be flipped - * @param expansion the expansion of the sprite. It only increases the size in each direction by that many. - */ - public void addSprite(float x, float y, float z, int w, int h, int d, float pixelScale, boolean rotX, boolean rotY, boolean rotZ, boolean mirrorX, boolean mirrorY, float expansion){ - String[] mask = new String[h]; - char[] str = new char[w]; - Arrays.fill(str, '1'); - Arrays.fill(mask, new String(str)); - addSprite(x, y, z, mask, d, pixelScale, rotX, rotY, rotZ, mirrorX, mirrorY, expansion); - } - - /** - * Creates a model shaped like the exact image on the texture. Note that this method will - * increase the amount of quads on your model, which could effectively slow down your - * PC, so unless it is really a necessity to use it, I'd suggest you avoid using this - * method to create your model. - *

- * This method uses a mask string. This way you can reduce the amount of quads used. To - * use this, create a String array, where you use a 1 to signify that the pixel will be - * drawn. Any other character will cause that pixel to not be drawn. - * @param x the starting x-position - * @param y the starting y-position - * @param z the starting z-position - * @param mask an array with the mask string - * @param d the depth of the shape itself - * @param pixelScale the scale of each individual pixel - * @param rotX a boolean to define if it rotates 90 degrees around its yaw-axis - * @param rotY a boolean to define if it rotates 90 degrees around its pitch-axis - * @param rotZ a boolean to define if it rotates 90 degrees around its roll-axis - * @param mirrorX a boolean to define if the sprite should be mirrored - * @param mirrorY a boolean to define if the sprite should be flipped - * @param expansion the expansion of the sprite. It only increases the size in each direction by that many. - */ - public void addSprite(float x, float y, float z, String[] mask, int d, float pixelScale, boolean rotX, boolean rotY, boolean rotZ, boolean mirrorX, boolean mirrorY, float expansion){ - int w = mask[0].length(); - int h = mask.length; - float x1 = x - expansion; - float y1 = y - expansion; - float z1 = z - expansion; - int wDir = 0; - int hDir = 0; - int dDir = 0; - float wScale = 1F + (expansion / ( w * pixelScale)); - float hScale = 1F + (expansion / ( h * pixelScale)); - if(!rotX){ - if(!rotY){ - if(!rotZ){ - wDir = 0; - hDir = 1; - dDir = 2; - } - else{ - wDir = 1; - hDir = 0; - dDir = 2; - } - } - else{ - if(!rotZ){ - wDir = 2; - hDir = 1; - dDir = 0; - } - else{ - wDir = 2; - hDir = 0; - dDir = 1; - } - } - } - else{ - if(!rotY){ - if(!rotZ){ - wDir = 0; - hDir = 2; - dDir = 1; - } - else{ - wDir = 1; - hDir = 2; - dDir = 0; - } - } - else{ - if(!rotZ){ - wDir = 2; - hDir = 0; - dDir = 1; - } - else{ - wDir = 2; - hDir = 1; - dDir = 0; - } - } - } - int texStartX = textureOffsetX + (mirrorX ? w * 1 - 1 : 0); - int texStartY = textureOffsetY + (mirrorY ? h * 1 - 1 : 0); - int texDirX = (mirrorX ? -1 : 1); - int texDirY = (mirrorY ? -1 : 1); - float wVoxSize = getPixelSize(wScale, hScale, d * pixelScale + expansion * 2, 0, 1, wDir, 1, 1); - float hVoxSize = getPixelSize(wScale, hScale, d * pixelScale + expansion * 2, 0, 1, hDir, 1, 1); - float dVoxSize = getPixelSize(wScale, hScale, d * pixelScale + expansion * 2, 0, 1, dDir, 1, 1); - for(int i = 0; i < w; i++){ - for(int j = 0; j < h; j++){ - if(mask[j].charAt(i) == '1'){ - addPixel(x1 + getPixelSize(wScale, hScale, 0, wDir, hDir, 0, i, j), - y1 + getPixelSize(wScale, hScale, 0, wDir, hDir, 1, i, j), - z1 + getPixelSize(wScale, hScale, 0, wDir, hDir, 2, i, j), - new float[] {wVoxSize, hVoxSize, dVoxSize}, texStartX + texDirX * i, texStartY + texDirY * j); - } - } - } - } - - private float getPixelSize(float wScale, float hScale, float dScale, int wDir, int hDir, int checkDir, int texPosX, int texPosY){ - return (wDir == checkDir ? wScale * texPosX : (hDir == checkDir ? hScale * texPosY : dScale)); - } - - /** - * Adds a spherical shape. - * @param x - * @param y - * @param z - * @param r - * @param segs - * @param rings - * @param textureW - * @param textureH - */ - public ModelRendererTurbo addSphere(float x, float y, float z, float r, int segs, int rings, int textureW, int textureH){ - if(segs < 3){ - segs = 3; - } - rings++; - TexturedVertex[] tempVerts = new TexturedVertex[segs * (rings - 1) + 2]; - TexturedPolygon[] poly = new TexturedPolygon[segs * rings]; - tempVerts[0] = new TexturedVertex(x, y - r, z, 0, 0); - tempVerts[tempVerts.length - 1] = new TexturedVertex(x, y + r, z, 0, 0); - float uOffs = 1.0F / ( textureWidth * 10.0F); - float vOffs = 1.0F / ( textureHeight * 10.0F); - float texW = textureW / textureWidth - 2F * uOffs; - float texH = textureH / textureHeight - 2F * vOffs; - float segW = texW / segs; - float segH = texH / rings; - float startU = textureOffsetX / textureWidth; - float startV = textureOffsetY / textureHeight; - int currentFace = 0; - for(int j = 1; j < rings; j++){ - for(int i = 0; i < segs; i++){ - float yWidth = MathHelper.cos(-pi / 2 + (pi / rings) * j); - float yHeight = MathHelper.sin(-pi / 2 + (pi / rings) * j); - float xSize = MathHelper.sin((pi / segs) * i * 2F + pi) * yWidth; - float zSize = -MathHelper.cos((pi / segs) * i * 2F + pi) * yWidth; - int curVert = 1 + i + segs * (j - 1); - tempVerts[curVert] = new TexturedVertex(x + xSize * r, y + yHeight * r, z + zSize * r, 0, 0); - if(i > 0){ - TexturedVertex[] verts; - if(j == 1){ - verts = new TexturedVertex[4]; - verts[0] = tempVerts[curVert].setTexturePosition(startU + segW * i, startV + segH * j); - verts[1] = tempVerts[curVert - 1].setTexturePosition(startU + segW * (i - 1), startV + segH * j); - verts[2] = tempVerts[0].setTexturePosition(startU + segW * (i - 1), startV); - verts[3] = tempVerts[0].setTexturePosition(startU + segW + segW * i, startV); - } - else{ - verts = new TexturedVertex[4]; - verts[0] = tempVerts[curVert].setTexturePosition(startU + segW * i, startV + segH * j); - verts[1] = tempVerts[curVert - 1].setTexturePosition(startU + segW * (i - 1), startV + segH * j); - verts[2] = tempVerts[curVert - 1 - segs].setTexturePosition(startU + segW * (i - 1), startV + segH * (j - 1)); - verts[3] = tempVerts[curVert - segs].setTexturePosition(startU + segW * i, startV + segH * (j - 1)); - } - poly[currentFace] = new TexturedPolygon(verts); - currentFace++; - } - } - TexturedVertex[] verts; - if(j == 1){ - verts = new TexturedVertex[4]; - verts[0] = tempVerts[1].setTexturePosition(startU + segW * segs, startV + segH * j); - verts[1] = tempVerts[segs].setTexturePosition(startU + segW * (segs - 1), startV + segH * j); - verts[2] = tempVerts[0].setTexturePosition(startU + segW * (segs - 1), startV); - verts[3] = tempVerts[0].setTexturePosition(startU + segW * segs, startV); - } - else{ - verts = new TexturedVertex[4]; - verts[0] = tempVerts[1 + segs * (j - 1)].setTexturePosition(startU + texW, startV + segH * j); - verts[1] = tempVerts[segs * (j - 1) + segs].setTexturePosition(startU + texW - segW, startV + segH * j); - verts[2] = tempVerts[segs * (j - 1)].setTexturePosition(startU + texW - segW, startV + segH * (j - 1)); - verts[3] = tempVerts[1 + segs * (j - 1) - segs].setTexturePosition(startU + texW, startV + segH * (j - 1)); - } - poly[currentFace] = new TexturedPolygon(verts); - currentFace++; - } - for(int i = 0; i < segs; i++){ - TexturedVertex[] verts = new TexturedVertex[3]; - int curVert = tempVerts.length - (segs + 1); - verts[0] = tempVerts[tempVerts.length - 1].setTexturePosition(startU + segW * (i + 0.5F), startV + texH); - verts[1] = tempVerts[curVert + i].setTexturePosition(startU + segW * i, startV + texH - segH); - verts[2] = tempVerts[curVert + ((i + 1) % segs)].setTexturePosition(startU + segW * (i + 1), startV + texH - segH); - poly[currentFace] = new TexturedPolygon(verts); - currentFace++; - } - return copyTo(tempVerts, poly); - } - - /** - * Adds a cone. - * @param x the x-position of the base - * @param y the y-position of the base - * @param z the z-position of the base - * @param radius the radius of the cylinder - * @param length the length of the cylinder - * @param segments the amount of segments the cylinder is made of - */ - public ModelRendererTurbo addCone(float x, float y, float z, float radius, float length, int segments){ - return addCone(x, y, z, radius, length, segments, 1F); - } - - /** - * Adds a cone. - * - * baseScale cannot be zero. If it is, it will automatically be set to 1F. - * - * @param x the x-position of the base - * @param y the y-position of the base - * @param z the z-position of the base - * @param radius the radius of the cylinder - * @param length the length of the cylinder - * @param segments the amount of segments the cylinder is made of - * @param baseScale the scaling of the base. Can be negative. - */ - public ModelRendererTurbo addCone(float x, float y, float z, float radius, float length, int segments, float baseScale){ - return addCone(x, y, z, radius, length, segments, baseScale, MR_TOP); - } - - /** - * Adds a cone. - * - * baseScale cannot be zero. If it is, it will automatically be set to 1F. - * - * Setting the baseDirection to either MR_LEFT, MR_BOTTOM or MR_BACK will result in - * the top being placed at the (x,y,z). - * - * @param x the x-position of the base - * @param y the y-position of the base - * @param z the z-position of the base - * @param radius the radius of the cylinder - * @param length the length of the cylinder - * @param segments the amount of segments the cylinder is made of - * @param baseScale the scaling of the base. Can be negative. - * @param baseDirection the direction it faces - */ - public ModelRendererTurbo addCone(float x, float y, float z, float radius, float length, int segments, float baseScale, int baseDirection){ - return addCone(x, y, z, radius, length, segments, baseScale, baseDirection, (int)Math.floor(radius * 2F), (int)Math.floor(radius * 2F)); - } - - /** - * Adds a cone. - * - * baseScale cannot be zero. If it is, it will automatically be set to 1F. - * - * Setting the baseDirection to either MR_LEFT, MR_BOTTOM or MR_BACK will result in - * the top being placed at the (x,y,z). - * - * The textures for the sides are placed next to each other. - * - * @param x the x-position of the base - * @param y the y-position of the base - * @param z the z-position of the base - * @param radius the radius of the cylinder - * @param length the length of the cylinder - * @param segments the amount of segments the cylinder is made of - * @param baseScale the scaling of the base. Can be negative. - * @param baseDirection the direction it faces - * @param textureCircleDiameterW the diameter width of the circle on the texture - * @param textureCircleDiameterH the diameter height of the circle on the texture - */ - public ModelRendererTurbo addCone(float x, float y, float z, float radius, float length, int segments, float baseScale, int baseDirection, int textureCircleDiameterW, int textureCircleDiameterH){ - return addCylinder(x, y, z, radius, length, segments, baseScale, 0.0F, baseDirection, textureCircleDiameterW, textureCircleDiameterH, 1); - } - - /** - * Adds a cylinder. - * @param x the x-position of the base - * @param y the y-position of the base - * @param z the z-position of the base - * @param radius the radius of the cylinder - * @param length the length of the cylinder - * @param segments the amount of segments the cylinder is made of - */ - public ModelRendererTurbo addCylinder(float x, float y, float z, float radius, float length, int segments){ - return addCylinder(x, y, z, radius, length, segments, 1F, 1F); - } - - /** - * Adds a cylinder. - * - * You can make cones by either setting baseScale or topScale to zero. Setting both - * to zero will set the baseScale to 1F. - * - * @param x the x-position of the base - * @param y the y-position of the base - * @param z the z-position of the base - * @param radius the radius of the cylinder - * @param length the length of the cylinder - * @param segments the amount of segments the cylinder is made of - * @param baseScale the scaling of the base. Can be negative. - * @param topScale the scaling of the top. Can be negative. - */ - public ModelRendererTurbo addCylinder(float x, float y, float z, float radius, float length, int segments, float baseScale, float topScale){ - return addCylinder(x, y, z, radius, length, segments, baseScale, topScale, MR_TOP); - } - - /** - * Adds a cylinder. - * - * You can make cones by either setting baseScale or topScale to zero. Setting both - * to zero will set the baseScale to 1F. - * - * Setting the baseDirection to either MR_LEFT, MR_BOTTOM or MR_BACK will result in - * the top being placed at the (x,y,z). - * - * @param x the x-position of the base - * @param y the y-position of the base - * @param z the z-position of the base - * @param radius the radius of the cylinder - * @param length the length of the cylinder - * @param segments the amount of segments the cylinder is made of - * @param baseScale the scaling of the base. Can be negative. - * @param topScale the scaling of the top. Can be negative. - * @param baseDirection the direction it faces - */ - public ModelRendererTurbo addCylinder(float x, float y, float z, float radius, float length, int segments, float baseScale, float topScale, int baseDirection){ - return addCylinder(x, y, z, radius, length, segments, baseScale, topScale, baseDirection, (int)Math.floor(radius * 2F), (int)Math.floor(radius * 2F), (int)Math.floor(length), null); - } - - public ModelRendererTurbo addCylinder(float x, float y, float z, float radius, float length, int segments, float baseScale, float topScale, int baseDirection, Vec3f topoff){ - return addCylinder(x, y, z, radius, length, segments, baseScale, topScale, baseDirection, (int)Math.floor(radius * 2F), (int)Math.floor(radius * 2F), (int)Math.floor(length), topoff); - } - - /** - * Adds a cylinder. - * - * You can make cones by either setting baseScale or topScale to zero. Setting both - * to zero will set the baseScale to 1F. - * - * Setting the baseDirection to either MR_LEFT, MR_BOTTOM or MR_BACK will result in - * the top being placed at the (x,y,z). - * - * The textures for the base and top are placed next to each other, while the body - * will be placed below the circles. - * - * @param x the x-position of the base - * @param y the y-position of the base - * @param z the z-position of the base - * @param radius the radius of the cylinder - * @param length the length of the cylinder - * @param segments the amount of segments the cylinder is made of - * @param baseScale the scaling of the base. Can be negative. - * @param topScale the scaling of the top. Can be negative. - * @param baseDirection the direction it faces - * @param textureCircleDiameterW the diameter width of the circle on the texture - * @param textureCircleDiameterH the diameter height of the circle on the texture - * @param textureH the height of the texture of the body - */ - public ModelRendererTurbo addCylinder(float x, float y, float z, float radius, float length, int segments, float baseScale, float topScale, int baseDirection, int textureCircleDiameterW, int textureCircleDiameterH, int textureH){ - return addCylinder(x, y, z, radius, length, segments, baseScale, topScale, baseDirection, textureCircleDiameterW, textureCircleDiameterH, textureH, null); - } - - public ModelRendererTurbo addCylinder(float x, float y, float z, float radius, float length, int segments, float baseScale, float topScale, int baseDirection, int textureCircleDiameterW, int textureCircleDiameterH, int textureH, Vec3f topoff){ - if(radius < 1){ - int rad = radius < 0.5 ? 1 : 2; - if(textureCircleDiameterW < rad) textureCircleDiameterW = rad; - if(textureCircleDiameterH < rad) textureCircleDiameterH = rad; - } - if(length < 1) textureH = 1; - else if(length % 1 != 0){ - textureH = (int)length + (length % 1 > 0.5f ? 1 : 0); - } - boolean dirTop = (baseDirection == MR_TOP || baseDirection == MR_BOTTOM); - boolean dirSide = (baseDirection == MR_RIGHT || baseDirection == MR_LEFT); - boolean dirFront = (baseDirection == MR_FRONT || baseDirection == MR_BACK); - boolean dirMirror = (baseDirection == MR_LEFT || baseDirection == MR_BOTTOM || baseDirection == MR_BACK); - boolean coneBase = (baseScale == 0); - boolean coneTop = (topScale == 0); - if(coneBase && coneTop){ baseScale = 1F; coneBase = false; } - TexturedVertex[] tempVerts = new TexturedVertex[segments * (coneBase || coneTop ? 1 : 2) + 2]; - TexturedPolygon[] poly = new TexturedPolygon[segments * (coneBase || coneTop ? 2 : 3)]; - float xLength = (dirSide ? length : 0); - float yLength = (dirTop ? length : 0); - float zLength = (dirFront ? length : 0); - float xStart = (dirMirror ? x + xLength : x); - float yStart = (dirMirror ? y + yLength : y); - float zStart = (dirMirror ? z + zLength : z); - float xEnd = (!dirMirror ? x + xLength : x) + (topoff == null ? 0 : topoff.xCoord); - float yEnd = (!dirMirror ? y + yLength : y) + (topoff == null ? 0 : topoff.yCoord); - float zEnd = (!dirMirror ? z + zLength : z) + (topoff == null ? 0 : topoff.zCoord); - tempVerts[0] = new TexturedVertex(xStart, yStart, zStart, 0, 0); - tempVerts[tempVerts.length - 1] = new TexturedVertex(xEnd, yEnd, zEnd, 0, 0); - float xCur = xStart; - float yCur = yStart; - float zCur = zStart; - float sCur = (coneBase ? topScale : baseScale); - for(int repeat = 0; repeat < (coneBase || coneTop ? 1 : 2); repeat++){ - for(int index = 0; index < segments; index++){ - float xSize = (float)((mirror ^ dirMirror ? -1 : 1) * Math.sin((pi / segments) * index * 2F + pi) * radius * sCur); - float zSize = (float)(-Math.cos((pi / segments) * index * 2F + pi) * radius * sCur); - float xPlace = xCur + (!dirSide ? xSize : 0); - float yPlace = yCur + (!dirTop ? zSize : 0); - float zPlace = zCur + (dirSide ? xSize : (dirTop ? zSize : 0)); - tempVerts[1 + index + repeat * segments] = new TexturedVertex(xPlace, yPlace, zPlace, 0, 0 ); - } - xCur = xEnd; yCur = yEnd; zCur = zEnd; sCur = topScale; - } - float uScale = 1.0F / textureWidth; - float vScale = 1.0F / textureHeight; - float uOffset = 0;//uScale / 20.0F; - float vOffset = 0;//vScale / 20.0F; - float uCircle = textureCircleDiameterW * uScale; - float vCircle = textureCircleDiameterH * vScale; - float uWidth = (uCircle * 2F - uOffset * 2F) / segments; - float vHeight = textureH * vScale - uOffset * 2f; - float uStart = textureOffsetX * uScale; - float vStart = textureOffsetY * vScale; - TexturedVertex[] vert; - for(int index = 0; index < segments; index++){ - int index2 = (index + 1) % segments; - float uSize = (float)(Math.sin((pi / segments) * index * 2F + (!dirTop ? 0 : pi)) * (0.5F * uCircle - 2F * uOffset)); - float vSize = (float)(Math.cos((pi / segments) * index * 2F + (!dirTop ? 0 : pi)) * (0.5F * vCircle - 2F * vOffset)); - float uSize1 = (float)(Math.sin((pi / segments) * index2 * 2F + (!dirTop ? 0 : pi)) * (0.5F * uCircle - 2F * uOffset)); - float vSize1 = (float)(Math.cos((pi / segments) * index2 * 2F + (!dirTop ? 0 : pi)) * (0.5F * vCircle - 2F * vOffset)); - vert = new TexturedVertex[3]; - vert[0] = tempVerts[0].setTexturePosition(uStart + 0.5F * uCircle, vStart + 0.5F * vCircle); - vert[1] = tempVerts[1 + index2].setTexturePosition(uStart + 0.5F * uCircle + uSize1, vStart + 0.5F * vCircle + vSize1); - vert[2] = tempVerts[1 + index].setTexturePosition(uStart + 0.5F * uCircle + uSize, vStart + 0.5F * vCircle + vSize); - poly[index] = new TexturedPolygon(vert); - if(!dirFront || mirror){ - poly[index].flipFace(); - } - if(!coneBase && !coneTop){ - vert = new TexturedVertex[4]; - vert[0] = tempVerts[1 + index].setTexturePosition(uStart + uOffset + uWidth * index, vStart + vOffset + vCircle); - vert[1] = tempVerts[1 + index2].setTexturePosition(uStart + uOffset + uWidth * (index + 1), vStart + vOffset + vCircle); - vert[2] = tempVerts[1 + segments + index2].setTexturePosition(uStart + uOffset + uWidth * (index + 1), vStart + vOffset + vCircle + vHeight); - vert[3] = tempVerts[1 + segments + index].setTexturePosition(uStart + uOffset + uWidth * index, vStart + vOffset + vCircle + vHeight); - poly[index + segments] = new TexturedPolygon(vert); - if(!dirFront || mirror){ - poly[index + segments].flipFace(); - } - } - vert = new TexturedVertex[3]; - vert[0] = tempVerts[tempVerts.length - 1].setTexturePosition(uStart + 1.5F * uCircle, vStart + 0.5F * vCircle); - vert[1] = tempVerts[tempVerts.length - 2 - index].setTexturePosition(uStart + 1.5F * uCircle + uSize1, vStart + 0.5F * vCircle + vSize1); - vert[2] = tempVerts[tempVerts.length - (1 + segments) + ((segments - index) % segments)].setTexturePosition(uStart + 1.5F * uCircle + uSize, vStart + 0.5F * vCircle + vSize); - poly[poly.length - segments + index] = new TexturedPolygon(vert); - if(!dirFront || mirror){ - poly[poly.length - segments + index].flipFace(); - } - } - return copyTo(null, poly); - } - - /** - * Adds a Waveform .obj file as a model. Model files use the entire texture file. - * @param file the location of the .obj file. The location is relative to the base directories, - * which are either resources/models or resources/mods/models. - */ - public ModelRendererTurbo addObj(String file){ - useLegacyCompiler = false; - addModel(file, ModelPool.OBJ); - return this; - } - - public void addObjF(String file){ - try{ - useLegacyCompiler = false; - addModelF(file, ModelPool.OBJ); - } - catch(IOException e) { - e.printStackTrace(); - } - } - - /** - * Adds model format support. Model files use the entire texture file. - * @param file the location of the model file. The location is relative to the base directories, - * which are either resources/models or resources/mods/models. - * @param modelFormat the class of the model format interpreter - */ - public void addModel(String file, Class modelFormat){ - ModelPoolEntry entry = ModelPool.addFile(file, modelFormat, textureGroup); - if(entry == null){ - return; - } - TexturedVertex[] verts = Arrays.copyOf(entry.vertices, entry.vertices.length); - TexturedPolygon[] poly = Arrays.copyOf(entry.faces, entry.faces.length); - if(flip){ - for (TexturedPolygon face : faces) { - face.flipFace(); - } - } - copyTo(verts, poly, false); - } - - public void addModelF(String file, Class modelFormat) throws IOException{ - ModelPoolEntry entry = ModelPool.addFileF(file, modelFormat, textureGroup); - if(entry == null){ - return; - } - TexturedVertex[] verts = Arrays.copyOf(entry.vertices, entry.vertices.length); - TexturedPolygon[] poly = Arrays.copyOf(entry.faces, entry.faces.length); - if(flip){ - for (TexturedPolygon face : faces) { - face.flipFace(); - } - } - copyTo(verts, poly, false); - } - - /** - * Sets a new position for the texture offset. - * @param x the x-coordinate of the texture start - * @param y the y-coordinate of the texture start - */ - public ModelRendererTurbo setTextureOffset(int x, int y){ - textureOffsetX = x; - textureOffsetY = y; - return this; - } - - /** - * Sets the position of the shape, relative to the model's origins. Note that changing - * the offsets will not change the pivot of the model. - * @param x the x-position of the shape - * @param y the y-position of the shape - * @param z the z-position of the shape - * @return - */ - public ModelRendererTurbo setPosition(float x, float y, float z){ - rotationPointX = x; - rotationPointY = y; - rotationPointZ = z; - return this; - } - - /** - * Mirrors the model in any direction. - * @param x whether the model should be mirrored in the x-direction - * @param y whether the model should be mirrored in the y-direction - * @param z whether the model should be mirrored in the z-direction - */ - public void doMirror(boolean x, boolean y, boolean z){ - for(TexturedPolygon face : faces){ - TexturedVertex[] verts = face.vertices; - for(TexturedVertex vert : verts){ - vert.vector3F.addVector( - vert.vector3F.xCoord * (x ? -1 : 1), - vert.vector3F.xCoord * (y ? -1 : 1), - vert.vector3F.xCoord * (z ? -1 : 1)); - } - if(x^y^z){ - face.flipFace(); - } - } - } - - /** - * Sets whether the shape is mirrored or not. This has effect on the way the textures - * get displayed. When working with addSprite, addPixel and addObj, it will be ignored. - * @param isMirrored a boolean to define whether the shape is mirrored - */ - public void setMirrored(boolean isMirrored){ - mirror = isMirrored; - } - - /** - * Sets whether the shape's faces are flipped or not. When GL_CULL_FACE is enabled, - * it won't render the back faces, effectively giving you the possibility to make - * "hollow" shapes. When working with addSprite and addPixel, it will be ignored. - * @param isFlipped a boolean to define whether the shape is flipped - */ - public void setFlipped(boolean isFlipped){ - flip = isFlipped; - } - - /** - * Clears the current shape. Since all shapes are stacked into one shape, you can't - * just replace a shape by overwriting the shape with another one. In this case you - * would need to clear the shape first. - */ - public void clear(){ - faces = new ArrayList(); - } - - /** - * Copies an array of vertices and polygons to the current shape. This mainly is - * used to copy each shape to the main class, but you can just use it to copy - * your own shapes, for example from other classes, into the current class. - * @param verts the array of vertices you want to copy - * @param poly the array of polygons you want to copy - * @return - */ - public ModelRendererTurbo copyTo(TexturedVertex[] verts, TexturedPolygon[] poly){ - return copyTo(verts, poly, true); - } - - public ModelRendererTurbo copyTo(TexturedVertex[] verts, TexturedPolygon[] poly, boolean copyGroup){ - faces = new ArrayList(); - faces.addAll(Arrays.asList(poly)); - return this; - } - - /** - * Sets the current texture group, which is used to switch the - * textures on a per-model base. Do note that any model that is - * rendered afterwards will use the same texture. To counter it, - * set a default texture, either at initialization or before - * rendering. - * @param groupName The name of the texture group. If the texture - * group doesn't exist, it creates a new group automatically. - */ - public void setTextureGroup(String groupName){ - if(!textureGroup.containsKey(groupName)){ - textureGroup.put(groupName, new TextureGroup()); - } - currentTextureGroup = textureGroup.get(groupName); - } - - /** - * Gets the current texture group. - * @return a TextureGroup object. - */ - public TextureGroup getTextureGroup(){ - return currentTextureGroup; - } - - /** - * Gets the texture group with the given name. - * @param groupName the name of the texture group to return - * @return a TextureGroup object. - */ - public TextureGroup getTextureGroup(String groupName){ - if(!textureGroup.containsKey(groupName)) - return null; - return textureGroup.get(groupName); - } - - /** - * Sets the texture of the current texture group. - * @param s the filename - */ - public void setGroupTexture(String s){ - currentTextureGroup.texture = s; - } - - /** - * Sets the default texture. When left as an empty string, - * it will use the texture that has been set previously. - * Note that this will also move on to other rendered models - * of the same entity. - * @param s the filename - */ - public void setDefaultTexture(String s){ - defaultTexture = s; - } - - - - /** - * Instances a new FMT CylinderBuilder - */ - public CylinderBuilder newCylinderBuilder(){ - return new CylinderBuilder(this); - } - - - - public void render(){ - render(0.0625F, rotorder); - } - - //Eternal: why was this removed....? - public void render(float scale){ - render(scale, rotorder); - } - - /** - * Renders the shape. - * @param scale the scale of the shape. Usually is 0.0625. - */ - public void render(float scale, boolean bool){ - if(field_1402_i){ - return; - } - if(!showModel){ - return; - } - if(!compiled || forcedRecompile){ - compileDisplayList(scale); - } - if(rotateAngleX != 0.0F || rotateAngleY != 0.0F || rotateAngleZ != 0.0F){ - GL11.glPushMatrix(); - GL11.glTranslatef(rotationPointX * scale, rotationPointY * scale, rotationPointZ * scale); - if(bool){ - if(rotateAngleZ != 0.0F){ - GL11.glRotatef(rotateAngleZ * 57.29578F, 0.0F, 0.0F, 1.0F); - } - if(rotateAngleY != 0.0F){ - GL11.glRotatef(rotateAngleY * 57.29578F, 0.0F, 1.0F, 0.0F); - } - } - else{ - if(rotateAngleY != 0.0F){ - GL11.glRotatef(rotateAngleY * 57.29578F, 0.0F, 1.0F, 0.0F); - } - if(rotateAngleZ != 0.0F){ - GL11.glRotatef(rotateAngleZ * 57.29578F, 0.0F, 0.0F, 1.0F); - } - } - if(rotateAngleX != 0.0F){ - GL11.glRotatef(rotateAngleX * 57.29578F, 1.0F, 0.0F, 0.0F); - } - callDisplayList(); - if(childModels != null){ - for(Object child : childModels){ - ((ModelRenderer)child).render(scale); - } - } - GL11.glPopMatrix(); - } else - if(rotationPointX != 0.0F || rotationPointY != 0.0F || rotationPointZ != 0.0F){ - GL11.glTranslatef(rotationPointX * scale, rotationPointY * scale, rotationPointZ * scale); - callDisplayList(); - if(childModels != null){ - for(Object child : childModels){ - ((ModelRenderer)child).render(scale); - } - } - GL11.glTranslatef(-rotationPointX * scale, -rotationPointY * scale, -rotationPointZ * scale); - } - else{ - callDisplayList(); - if(childModels != null){ - for(Object child : childModels){ - ((ModelRenderer)child).render(scale); - } - } - } - } - - - public void callDisplayList(){ - if(useLegacyCompiler){ - if(GL11.glIsList(displayList)) { - GL11.glCallList(displayList); - } else { - compiled=false; - } - } - else{ - Iterator itr = textureGroup.values().iterator(); - for(int i = 0; itr.hasNext(); i++){ - if(GL11.glIsList(displayListArray[i])) { - TextureGroup curTexGroup = itr.next(); - curTexGroup.loadTexture(); - GL11.glCallList(displayListArray[i]); - if(!defaultTexture.equals("")){ - Tessellator.bindTexture(new ResourceLocation("", defaultTexture)); - } - } else { - compiled=false; - } - } - } - } - - public void compileDisplayList(float scale){ - if(useLegacyCompiler){ - compileLegacyDisplayList(scale); - } - else{ - Iterator itr = textureGroup.values().iterator(); - displayListArray = new int[textureGroup.size()]; - for(int i = 0; itr.hasNext(); i++){ - displayListArray[i] = GLAllocation.generateDisplayLists(1); - GL11.glNewList(displayListArray[i], GL11.GL_COMPILE); - Tessellator tessellator = Tessellator.getInstance(); - TextureGroup usedGroup = itr.next(); - for(int j = 0; j < usedGroup.poly.size(); j++){ - usedGroup.poly.get(j).draw(tessellator, scale); - } - GL11.glEndList(); - } - } - compiled = true; - } - - private void compileLegacyDisplayList(float scale){ - displayList = GLAllocation.generateDisplayLists(1); - GL11.glNewList(displayList, GL11.GL_COMPILE); - Tessellator tessellator = Tessellator.getInstance(); - for(TexturedPolygon poly : faces){ - poly.draw(tessellator, scale); - } - GL11.glEndList(); - } - - //ETERNAL: changed w/h/d to floats for better support of the custom render on the rails. - public ModelRendererTurbo addShapeBox(float x, float y, float z, float w, float h, float d, float scale, float x0, float y0, float z0, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, float x5, float y5, float z5, float x6, float y6, float z6, float x7, float y7, float z7){ - w+=w<1?0.0015f:0.001F; - h+=h<1?0.0015f:0.001F; - d+=d<1?0.0015f:0.001F; - x-=w<1?0.001f:0.0005F; - y-=h<1?0.001f:0.0005F; - z-=d<1?0.001f:0.0005F; - float f4 = x + w, f5 = y + h, f6 = z + d; - x -= scale; y -= scale; z -= scale; - f4 += scale; f5 += scale; f6 += scale; - if(mirror){ - float f7 = f4; f4 = x; x = f7; - } - - float[][] v = {{x - x0, y - y0, z - z0}, {f4 + x1, y - y1, z - z1},{f4 + x5, f5 + y5, z - z5}, {x - x4, f5 + y4, z - z4}, {x - x3, y - y3, f6 + z3}, {f4 + x2, y - y2, f6 + z2},{f4 + x6, f5 + y6, f6 + z6}, {x - x7, f5 + y7, f6 + z7}}; - return addRectShape(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], w, h, d); - } - - public final ModelRendererTurbo setOldRotationOrder(boolean bool){ - this.rotorder = bool; - return this; - } - - public String toString(String alt){ - String str = this.toString(); - return str == null || str.equals("") ? alt : str; - } - - public static void filterGeometry(float size, float... params ){ - int param=0; - boolean wasChanged = false; - for(int i=0; i -Modified TMT from https://github.com/Fexcraft/FCL -Original branch version tbis was copied from: https://github.com/Fexcraft/FCL/tree/9331a66cda097e55e743f2590b3dc6cf1b78f137 -
-

Primary license:

-This version of TMT was updated, maintened, as well as extended for 1.8 and newer Minecraft versions by FEX___96 - - @author GaryCXJk, Ferdinand (FEX___96) - @license http://fexcraft.net/license?id=tmt - -
-

Eternal's notes and license:

-This version is a clone of the one in TrainsInMotion: https://github.com/EternalBlueFlame/Trains-In-Motion/tree/4f1f8e4b91e2045b4a095ab352c8c161bce51c63 - - This version of TMT is heavily modified to fix some bugs in my own way, and attempt to improve performance overall. - - TC special change: because TC is written for java 6 and not 7, JsonToTMT had to be reworked because of that. - - for performance reasons, the legacy render mode is used by default since we don't expect multiple textures to be used across the same model. - - The bones system has been fully removed and replaced with some minor support functionality for my static model animator. - - For performance and typesafe reasons PositionTransformVertex has been fully reworked to no longer extend or require the variables from PositionTextureVertex. - - For performance reasons TexturedPolygon has been fully reworked to no longer require TexturedQuad. - - Because of the reworked classes mentioned above, Tessellator has been reworked so it uses floats rather than doubles for performance reasons. - - public void copyTo(PositionTextureVertex[] verts, TexturedQuad[] quad) was removed since the new reworks make it fully obsolete. - - You are free to use any of my changes to this system in any way you want with no restrictions. \ No newline at end of file diff --git a/tmt/Shape2D.java b/tmt/Shape2D.java deleted file mode 100644 index 376577631b..0000000000 --- a/tmt/Shape2D.java +++ /dev/null @@ -1,129 +0,0 @@ -package tmt; - -import net.minecraft.util.MathHelper; - -import java.util.ArrayList; - - -public class Shape2D { - - public ArrayList coords; - - public Shape2D(){ - coords = new ArrayList(); - } - - public Shape2D(Coord2D[] coordArray){ - coords = new ArrayList(); - for(Coord2D coord : coordArray){ - coords.add(coord); - } - } - - public Shape2D(ArrayList coordList){ - coords = coordList; - } - - public Coord2D[] getCoordArray(){ - return (Coord2D[])coords.toArray(); - } - - public Shape3D extrude(float x, float y, float z, float rotX, float rotY, float rotZ, float depth, int u, int v, float textureWidth, float textureHeight, int shapeTextureWidth, int shapeTextureHeight, int sideTextureWidth, int sideTextureHeight, float[] faceLengths){ - TexturedVertex[] verts = new TexturedVertex[coords.size() * 2]; - TexturedVertex[] vertsTop = new TexturedVertex[coords.size()]; - TexturedVertex[] vertsBottom = new TexturedVertex[coords.size()]; - TexturedPolygon[] poly = new TexturedPolygon[coords.size() + 2]; - Vec3f extrudeVector = new Vec3f(0, 0, depth); - - setVectorRotations(extrudeVector, rotX, rotY, rotZ); - - if(faceLengths != null && faceLengths.length < coords.size()){ - faceLengths = null; - } - float totalLength = 0; - for(int idx = 0; idx < coords.size(); idx++){ - Coord2D curCoord = coords.get(idx); - Coord2D nextCoord = coords.get((idx + 1) % coords.size()); - float texU1 = ((float)(curCoord.uCoord + u) / (float)textureWidth); - float texU2 = ((float)(shapeTextureWidth * 2 - curCoord.uCoord + u) / (float)textureWidth); - float texV = ((float)(curCoord.vCoord + v) / (float)textureHeight); - Vec3f vecCoord = new Vec3f(curCoord.xCoord, curCoord.yCoord, 0); - setVectorRotations(vecCoord, rotX, rotY, rotZ); - verts[idx] = new TexturedVertex( - x + vecCoord.xCoord, - y + vecCoord.yCoord, - z + vecCoord.zCoord, texU1, texV); - verts[idx + coords.size()] = new TexturedVertex( - x + vecCoord.xCoord - extrudeVector.xCoord, - y + vecCoord.yCoord - extrudeVector.yCoord, - z + vecCoord.zCoord - extrudeVector.zCoord, texU2, texV); - vertsTop[idx] = new TexturedVertex(verts[idx].vector3F, verts[idx].textureX, verts[idx].textureY); - vertsBottom[coords.size() - idx - 1] = new TexturedVertex(verts[idx + coords.size()].vector3F,verts[idx + coords.size()].textureX,verts[idx + coords.size()].textureY); - if(faceLengths != null){ - totalLength+= faceLengths[idx]; - } - else{ - totalLength+= Math.sqrt(Math.pow(curCoord.xCoord - nextCoord.xCoord, 2) + Math.pow(curCoord.yCoord - nextCoord.yCoord, 2)); - } - } - poly[coords.size()] = new TexturedPolygon(vertsTop); - poly[coords.size() + 1] = new TexturedPolygon(vertsBottom); - float currentLengthPosition = totalLength; - - for(int idx = 0; idx < coords.size(); idx++){ - Coord2D curCoord = coords.get(idx); - Coord2D nextCoord = coords.get((idx + 1) % coords.size()); - float currentLength = (float)Math.sqrt(Math.pow(curCoord.xCoord - nextCoord.xCoord, 2) + Math.pow(curCoord.yCoord - nextCoord.yCoord, 2)); - if(faceLengths != null){ - currentLength = faceLengths[faceLengths.length - idx - 1]; - } - float ratioPosition = currentLengthPosition / totalLength; - float ratioLength = (currentLengthPosition - currentLength) / totalLength; - float texU1 = ((float)(ratioLength * (float)sideTextureWidth + u) / (float)textureWidth); - float texU2 = ((float)(ratioPosition * (float)sideTextureWidth + u) / (float)textureWidth); - float texV1 = (((float)v + (float)shapeTextureHeight) / (float)textureHeight); - float texV2 = (((float)v + (float)shapeTextureHeight + (float)sideTextureHeight) / (float)textureHeight); - TexturedVertex[] polySide = new TexturedVertex[4]; - polySide[0] = new TexturedVertex(verts[idx].vector3F, texU2, texV1); - polySide[1] = new TexturedVertex(verts[coords.size() + idx].vector3F, texU2, texV2); - polySide[2] = new TexturedVertex(verts[coords.size() + ((idx + 1) % coords.size())].vector3F, texU1, texV2); - polySide[3] = new TexturedVertex(verts[(idx + 1) % coords.size()].vector3F, texU1, texV1); - poly[idx] = new TexturedPolygon(polySide); - currentLengthPosition -= currentLength; - } - return new Shape3D(verts, poly); - } - - protected Vec3f setVectorRotations(Vec3f extrudeVector, float xRot, float yRot, float zRot){ - float x = xRot; - float y = yRot; - float z = zRot; - float xC = MathHelper.cos(x); - float xS = MathHelper.sin(x); - float yC = MathHelper.cos(y); - float yS = MathHelper.sin(y); - float zC = MathHelper.cos(z); - float zS = MathHelper.sin(z); - - double xVec = extrudeVector.xCoord; - double yVec = extrudeVector.yCoord; - double zVec = extrudeVector.zCoord; - - // rotation around x - double xy = xC*yVec - xS*zVec; - double xz = xC*zVec + xS*yVec; - // rotation around y - double yz = yC*xz - yS*xVec; - double yx = yC*xVec + yS*xz; - // rotation around z - double zx = zC*yx - zS*xy; - double zy = zC*xy + zS*yx; - - xVec = zx; - yVec = zy; - zVec = yz; - - return new Vec3f((float) xVec, (float) yVec, (float) zVec); - } - -} diff --git a/tmt/Shape3D.java b/tmt/Shape3D.java deleted file mode 100644 index 610bf358c5..0000000000 --- a/tmt/Shape3D.java +++ /dev/null @@ -1,13 +0,0 @@ -package tmt; - -public class Shape3D { - - public TexturedVertex[] vertices; - public TexturedPolygon[] faces; - - public Shape3D(TexturedVertex[] verts, TexturedPolygon[] poly){ - vertices = verts; - faces = poly; - } - -} diff --git a/tmt/Tessellator.java b/tmt/Tessellator.java deleted file mode 100644 index cd1953718d..0000000000 --- a/tmt/Tessellator.java +++ /dev/null @@ -1,167 +0,0 @@ -package tmt; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GLAllocation; -import net.minecraft.client.renderer.texture.ITextureObject; -import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import train.common.Traincraft; -import train.common.core.CommonProxy; -import train.common.core.handlers.ConfigHandler; - -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.util.Arrays; -import java.util.List; - -import static org.lwjgl.opengl.ARBBufferObject.glBindBufferARB; -import static org.lwjgl.opengl.ARBPixelBufferObject.GL_PIXEL_UNPACK_BUFFER_ARB; -import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D; - -/** -* @Author Ferdinand (FEX___96) -* -*/ -@SideOnly(Side.CLIENT) -public class Tessellator{ - - private static ByteBuffer bbuf = GLAllocation.createDirectByteBuffer(0x200000 * 4); - private int rbs = 0, verts = 0, /*br, c,*/ rbi = 0, /*vertices = 0,*/ dm, n, vtc, o; - private boolean ht = false, in = false, drawing = false; - public static Tessellator INSTANCE = new Tessellator(); - private static FloatBuffer fbuf = bbuf.asFloatBuffer(); - private static IntBuffer ibuf = bbuf.asIntBuffer(); - private float u, v, w, x, y, z; - private int[] rb; - - public static Tessellator getInstance(){ - return INSTANCE; - } - - public Tessellator(){ - super(); - } - - public void startDrawing(int i){ - if(!drawing){ - drawing = true; dm = i; - in = ht = false; - reset(); - GL11.glColor4f(1f, 1f, 1f, 1f); - } - } - - public int draw(){ - if(drawing){ - drawing = false; o = 0; - while(o < verts){ - vtc = Math.min(verts - o, 0x200000 >> 5); - ibuf.clear(); ibuf.put(rb, o * 10, vtc * 10); bbuf.position(0); bbuf.limit(vtc * 40); o += vtc; - if(ht){ - fbuf.position(3); - GL11.glTexCoordPointer(4, 40, fbuf); - GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); - } - if(in){ - bbuf.position(32); - GL11.glNormalPointer(40, bbuf); - GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); - } - fbuf.position(0); - GL11.glVertexPointer(3, 40, fbuf); - GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); - GL11.glDrawArrays(dm, 0, vtc); - GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); - if(ht){ - GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); - } - if(in){ - GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY); - } - } - if(rbs > 0x20000 && rbi < (rbs << 3)){ - rbs = 0; rb = null; - } - reset(); - } - - return 0; - } - - private void reset(){ - verts = rbi = 0;//vertices = 0; - - bbuf.clear(); - } - - public void addVertex(float par1, float par3, float par5){ - if(rbi >= rbs - 40) { - if(rbs == 0){rbs = 0x10000; rb = new int[rbs];} - else{rbs *= 2; rb = Arrays.copyOf(rb, rbs);} - } - if(ht){ - rb[rbi + 3] = Float.floatToRawIntBits(u); rb[rbi + 4] = Float.floatToRawIntBits(v); - rb[rbi + 5] = Float.floatToRawIntBits(0.0F); rb[rbi + 6] = Float.floatToRawIntBits(w); - } - if(in){rb[rbi + 8] = n;} - rb[rbi] = Float.floatToRawIntBits((par1 + x)); - rb[rbi + 1] = Float.floatToRawIntBits((par3 + y)); - rb[rbi + 2] = Float.floatToRawIntBits((par5 + z)); - rbi += 10; verts++; //vertices++; - } - - public void addVertexWithUV(float i, float j, float k, float l, float m){ - this.setTextureUV(l, m); this.addVertex(i, j, k); - } - - public void addVertexWithUVW(float i, float j, float k, float l, float m, float n){ - this.setTextureUVW(l, m, n); this.addVertex(i, j, k); - } - - public void setNormal(float x, float y, float z){ - in = true; - byte b0 = (byte)((int)(x * 127.0F)); byte b1 = (byte)((int)(y * 127.0F)); byte b2 = (byte)((int)(z * 127.0F)); - n = b0 & 255 | (b1 & 255) << 8 | (b2 & 255) << 16; - } - - public void setTextureUV(float i, float j){ - this.ht = true; this.u = i; this.v = j; this.w = 1.0F; - } - - public void setTextureUVW(float i, float j, float k){ - this.ht = true; this.u = i; this.v = j; this.w = k; - } - - public void setTranslation(float x, float y, float z){ - this.x = x; this.y = y; this.z = z; - } - - public void addTranslation(float x, float y, float z){ - this.x += x; this.y += y; this.z += z; - } - - - /** - * Eternal: custom texture binding method, generally same as vanilla, but possible to improve performance later. - * @param textureURI - */ - public static void bindTexture(ResourceLocation textureURI) { - if (ConfigHandler.FORCE_TEXTURE_BINDING) { - Minecraft.getMinecraft().renderEngine.bindTexture(textureURI); - } else { - ITextureObject object = Minecraft.getMinecraft().getTextureManager().getTexture(textureURI); - if (object == null) { - object = new SimpleTexture(textureURI); - Minecraft.getMinecraft().getTextureManager().loadTexture(textureURI, object); - } - if(GL11.glGetInteger(GL11.GL_TEXTURE_2D) != object.getGlTextureId()) { - GL11.glBindTexture(GL_TEXTURE_2D, object.getGlTextureId()); - } - } - } - -} diff --git a/tmt/TextureGroup.java b/tmt/TextureGroup.java deleted file mode 100644 index 0553138fca..0000000000 --- a/tmt/TextureGroup.java +++ /dev/null @@ -1,37 +0,0 @@ -package tmt; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.util.ResourceLocation; - -import java.util.ArrayList; - -public class TextureGroup { - - public ArrayList poly; - public String texture; - - public TextureGroup(){ - poly = new ArrayList(); - texture = ""; - } - - public void addPoly(TexturedPolygon quad){ - poly.add(quad); - } - - public void loadTexture(){ - loadTexture(-1); - } - - public void loadTexture(int defaultTexture){ - if(!texture.equals("")){ - TextureManager renderengine = Minecraft.getMinecraft().renderEngine; - renderengine.bindTexture(new ResourceLocation("", texture)); - } - else if(defaultTexture > -1){ - Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("", "")); - } - } - -} diff --git a/tmt/TexturedPolygon.java b/tmt/TexturedPolygon.java deleted file mode 100644 index 6f34a7c9e9..0000000000 --- a/tmt/TexturedPolygon.java +++ /dev/null @@ -1,76 +0,0 @@ -package tmt; - -import org.lwjgl.opengl.GL11; - -import java.util.ArrayList; - - -public class TexturedPolygon { - - private float[] normals; - private ArrayList iNormals; - public TexturedVertex[] vertices; - - public TexturedPolygon(TexturedVertex apositionTexturevertex[]){ - normals = new float[0]; - iNormals = new ArrayList(); - vertices = apositionTexturevertex; - } - - - public void setNormals(float x, float y, float z){ - normals = new float[] {x, y, z}; - } - - public void setNormals(ArrayList iNormal){ - iNormals = iNormal; - } - - public void draw(Tessellator tessellator, float f){ - if(vertices.length == 3){ - tessellator.startDrawing(GL11.GL_TRIANGLES); - } - else if (vertices.length == 4){ - tessellator.startDrawing(GL11.GL_QUADS); - } - else{ - tessellator.startDrawing(GL11.GL_POLYGON); - } - - if(iNormals.size() == 0){ - if(normals.length == 3){ - tessellator.setNormal(normals[0], normals[1], normals[2]); - } - else if(vertices.length >= 3){ - Vec3f Vec3d2 = - vertices[1].vector3F.subtract(vertices[2].vector3F) - .crossProduct(vertices[1].vector3F.subtract(vertices[0].vector3F)) - .normalize(); - tessellator.setNormal(Vec3d2.xCoord, Vec3d2.yCoord, Vec3d2.zCoord); - } - else{ - return; - } - } - for(int i = 0; i < vertices.length; i++){ - TexturedVertex positionTexturevertex = vertices[i]; - if(i < iNormals.size()){ - tessellator.setNormal(iNormals.get(i).xCoord, iNormals.get(i).yCoord, iNormals.get(i).zCoord); - } - tessellator.addVertexWithUV(positionTexturevertex.vector3F.xCoord * f, positionTexturevertex.vector3F.yCoord * f, positionTexturevertex.vector3F.zCoord * f, positionTexturevertex.textureX, positionTexturevertex.textureY); - } - tessellator.draw(); - } - - - public void flipFace() { - TexturedVertex[] apositiontexturevertex = new TexturedVertex[this.vertices.length]; - - for (int i = 0; i < this.vertices.length; ++i) { - apositiontexturevertex[i] = this.vertices[this.vertices.length - i - 1]; - } - - this.vertices = apositiontexturevertex; - } - -} diff --git a/tmt/TexturedVertex.java b/tmt/TexturedVertex.java deleted file mode 100644 index e6c78b0ccb..0000000000 --- a/tmt/TexturedVertex.java +++ /dev/null @@ -1,37 +0,0 @@ -package tmt; - -import net.minecraft.client.model.PositionTextureVertex; - -//TexturedVertex sounds cooler and is shorter than PositionTextureVertex -public class TexturedVertex { - - public Vec3f vector3F; - public float textureX; - public float textureY; - - public TexturedVertex(float x, float y, float z, float u, float v){ - this(new Vec3f(x, y, z), u, v); - } - - @Deprecated - public TexturedVertex(PositionTextureVertex vertex, float u, float v){ - vector3F = new Vec3f(vertex.vector3D); - textureX = u; - textureY = v; - } - - public TexturedVertex(Vec3f vector, float u, float v){ - vector3F = new Vec3f(vector.xCoord, vector.yCoord, vector.zCoord); - textureX = u; - textureY = v; - } - public TexturedVertex(TexturedVertex vert){ - this(vert.vector3F, vert.textureX, vert.textureY); - } - - public TexturedVertex setTexturePosition(float p_78240_1_, float p_78240_2_) { - return new TexturedVertex(vector3F, p_78240_1_, p_78240_2_); - } - - -} diff --git a/tmt/Vec3d.java b/tmt/Vec3d.java deleted file mode 100644 index 95a6e604c2..0000000000 --- a/tmt/Vec3d.java +++ /dev/null @@ -1,28 +0,0 @@ -package tmt; - -import net.minecraft.util.Vec3; - -/** - * @author EternalBlueFlame - *

Vector 3d

- * this is intended to replicate the Vec3d from minecraft 1.8+ - * mostly it just makes handling vector 3's simpler. - */ -public class Vec3d extends Vec3 { - - public Vec3d(double x, double y, double z){ - super(x,y,z); - } - - public Vec3d(Vec3 vec){super(vec.xCoord, vec.yCoord, vec.zCoord);} - - public void add(Vec3d vec2){ - xCoord += vec2.xCoord; - yCoord += vec2.yCoord; - zCoord += vec2.zCoord; - } - - public Vec3d subtract(Vec3d vec2){ - return new Vec3d(xCoord-vec2.xCoord,yCoord-vec2.yCoord,zCoord-vec2.zCoord); - } -} diff --git a/tmt/Vec3f.java b/tmt/Vec3f.java deleted file mode 100644 index f280ad96b7..0000000000 --- a/tmt/Vec3f.java +++ /dev/null @@ -1,77 +0,0 @@ -package tmt; - -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; -import org.lwjgl.util.vector.Matrix4f; -import org.lwjgl.util.vector.Vector3f; - -/** - * basically the same as Vec3D, but a float. Usually used for storing rotations. - * @author Ferdinand - */ - -public class Vec3f { - - public float xCoord; - public float yCoord; - public float zCoord; - - public Vec3f(){ - xCoord = 0; - yCoord = 0; - zCoord = 0; - } - - public Vec3f(Vec3 v){ - xCoord = (float)v.xCoord; - yCoord = (float)v.yCoord; - zCoord= (float)v.zCoord; - } - - public Vec3f(float f, float g, float h){ - xCoord = f; - yCoord = g; - zCoord = h; - } - - public Vec3f(double x, double y, double z){ - xCoord = (float) x; - yCoord = (float) y; - zCoord = (float) z; - } - - public Vec3f crossProduct(Vec3f p_72431_1_) { - return new Vec3f(this.yCoord * p_72431_1_.zCoord - this.zCoord * p_72431_1_.yCoord, this.zCoord * p_72431_1_.xCoord - this.xCoord * p_72431_1_.zCoord, this.xCoord * p_72431_1_.yCoord - this.yCoord * p_72431_1_.xCoord); - } - - public Vec3f normalize() { - float d0 = MathHelper.sqrt_double(this.xCoord * this.xCoord + this.yCoord * this.yCoord + this.zCoord * this.zCoord); - return d0 < 1.0E-4D ? new Vec3f(0.0F, 0.0F, 0.0F) : new Vec3f(this.xCoord / d0, this.yCoord / d0, this.zCoord / d0); - } - - public void add(Vec3f vec){ - xCoord+=vec.xCoord; - yCoord+=vec.yCoord; - zCoord+=vec.zCoord; - } - public Vec3f addVector(float x, float y, float z){ - return new Vec3f(xCoord + x,yCoord + y,zCoord + z); - } - - public Vec3f subtract(Vec3f vec){ - return new Vec3f(xCoord-vec.xCoord, - yCoord-vec.yCoord, - zCoord-vec.zCoord); - } - - - //this could be moved to vec3f - public Vec3f getRelativeVector(Vec3f vec){ - Matrix4f mat = new Matrix4f(); - mat.m00 = vec.xCoord; mat.m10 = vec.yCoord; mat.m20 = vec.zCoord; - Matrix4f.rotate(zCoord * 3.14159265F / 180, new Vector3f(1F, 0F, 0F), mat, mat); - Matrix4f.rotate(yCoord * 3.14159265F / 180, new Vector3f(0F, 0F, 1F), mat, mat); - Matrix4f.rotate(xCoord * 3.14159265F / 180, new Vector3f(0F, 1F, 0F), mat, mat); - return new Vec3f(mat.m00, mat.m10, mat.m20); - } -}