Skip to content

Commit

Permalink
model fixes
Browse files Browse the repository at this point in the history
- Fixed rotations on several models caused by the new render.
- Fixed a utility method for changing rotations in model files.
- Cleanup of some model render stuff.
  • Loading branch information
EternalBlueFlame committed Dec 20, 2023
1 parent a60d025 commit 95a4cfc
Show file tree
Hide file tree
Showing 21 changed files with 132 additions and 258 deletions.
108 changes: 54 additions & 54 deletions src/main/java/fexcraft/tmt/slim/ModelBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
import train.common.core.handlers.ConfigHandler;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Similar to 'FlansMod'-type Models, for a fast convert.
* @Author Ferdinand Calo' (FEX___96)
*/
* Similar to 'FlansMod'-type Models, for a fast convert.
* @Author Ferdinand Calo' (FEX___96)
*/
public class ModelBase extends ArrayList<ModelRendererTurbo> {

@Deprecated //box list for static parts should be completley unnecessary by making a displaylist of it as a whole.
Expand All @@ -32,14 +33,14 @@ public class ModelBase extends ArrayList<ModelRendererTurbo> {
public static Map<String,Integer> staticPartMap = new HashMap<>();
public Integer localGLID = null;

public static boolean disableCache=false;
public static boolean EnableAnimations=false;

public int textureWidth=512, textureHeight=512;

public boolean disableCache=false, EnableAnimations=true;

public void render(){
if(init){
initAllParts();
initAllParts();
}

if(disableCache) {
Expand Down Expand Up @@ -167,7 +168,7 @@ public void render(List<ModelRendererTurbo> model){
public void render(Object type, Entity ent){render(); }

public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {render();}


public void translateAll(float x, float y, float z){
translate(base, x, y, z);
Expand Down Expand Up @@ -207,35 +208,34 @@ public void rotateAll(float x, float y, float z){
rotate(boxList,x,y,z);
rotate(namedList,x,y,z);
}
public void flipAll(){
flip(base);
flip(open);
flip(closed);
flip(r0);
flip(r1);
flip(r2);
flip(r3);
flip(r4);
flip(r5);
flip(r6);
flip(r7);
flip(r8);
flip(r9);
public void flipAll(){
flip(base);
flip(open);
flip(closed);
flip(r0);
flip(r1);
flip(r2);
flip(r3);
flip(r4);
flip(r5);
flip(r6);
flip(r7);
flip(r8);
flip(r9);
flip(bodyModel);
flip(boxList);
flip(namedList);
}
}


protected final void fixRotation(ModelRendererTurbo[] model, boolean flipX, boolean flipY, boolean flipZ){
bodyModel=model.clone();
model= new ModelRendererTurbo[]{};
for(ModelRendererTurbo p : bodyModel){
p.rotateAngleX*= CommonUtil.degreesF;
p.rotateAngleY*= CommonUtil.degreesF;
p.rotateAngleZ*= CommonUtil.degreesF;
if(!flipX && !flipY && !flipZ){return;}
for(ModelRendererTurbo mod : model){
if(mod==null){continue;}
if(flipX){mod.rotateAngleX = -mod.rotateAngleX;}
if(flipY){mod.rotateAngleY = -mod.rotateAngleY;}
if(flipZ){mod.rotateAngleZ = -mod.rotateAngleZ;}
}

}

protected final void fixRotation(ModelRendererTurbo[] parts){
Expand Down Expand Up @@ -285,15 +285,15 @@ protected void rotate(List<ModelRendererTurbo> model, float x, float y, float z)
}
}

public void flip(ModelRendererTurbo[] model) {
if(model==null){return;}
public void flip(ModelRendererTurbo[] model) {
if(model==null){return;}
for(ModelRendererTurbo mod : model){
if(mod==null){continue;}
mod.rotateAngleY = -mod.rotateAngleY * 57.29578F;
mod.rotateAngleZ = -mod.rotateAngleZ * 57.29578F;
mod.rotateAngleX *= 57.29578F;
}
}
}
public void flip(List<ModelRendererTurbo> model) {
if(model==null){return;}
for(ModelRendererTurbo sub : model){
Expand Down Expand Up @@ -326,28 +326,28 @@ public void addToCreators(String s){


public void initAllParts(){
base=initList(base);
open=initList(open);
closed=initList(closed);
bodyModel=initList(bodyModel);
r0=initList(r0);
r1=initList(r1);
r2=initList(r2);
r3=initList(r3);
r4=initList(r4);
r5=initList(r5);
r6=initList(r6);
r7=initList(r7);
r8=initList(r8);
r9=initList(r9);
init=false;
}
base=initList(base);
open=initList(open);
closed=initList(closed);
bodyModel=initList(bodyModel);
r0=initList(r0);
r1=initList(r1);
r2=initList(r2);
r3=initList(r3);
r4=initList(r4);
r5=initList(r5);
r6=initList(r6);
r7=initList(r7);
r8=initList(r8);
r9=initList(r9);
init=false;
}

public ModelRendererTurbo[] initList(ModelRendererTurbo[] list){
if(list==null){return null;}
for(ModelRendererTurbo model : list){
addPart(model);
}
return null;
}
if(list==null){return null;}
for(ModelRendererTurbo model : list){
addPart(model);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,17 @@ public Model100TonHopper()

fixRotation(model100tonhopperModel, false, true, true);

fixRotation(model100tonhopperModel);
bodyModel=model100tonhopperModel;

}
private ModelFreightTruckM fronttrucks = new ModelFreightTruckM();
private ModelFreightTruckM backtrucks = new ModelFreightTruckM();

@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
for(int i = 0; i < 48; i++)
{
model100tonhopperModel[i].render(f5);
}
super.render(entity, f, f1, f2, f3, f4, f5);
Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, "textures/trains/freighttruckm.png"));

GL11.glPushMatrix();
Expand Down
30 changes: 12 additions & 18 deletions src/main/java/train/client/render/models/ModelClass85.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ public ModelClass85()
class85Model[27] = new ModelRendererTurbo(this, 81, 17, textureX, textureY); // 28
class85Model[28] = new ModelRendererTurbo(this, 481, 1, textureX, textureY); // 29
class85Model[29] = new ModelRendererTurbo(this, 49, 9, textureX, textureY); // 30
class85Model[30] = new ModelRendererTurbo(this, 465, 1, textureX, textureY); // 31
class85Model[31] = new ModelRendererTurbo(this, 505, 1, textureX, textureY); // 32
class85Model[30] = new ModelRendererTurbo(this, 465, 1, textureX, textureY, "lamp"); // 31
class85Model[31] = new ModelRendererTurbo(this, 505, 1, textureX, textureY, "lamp"); // 32
class85Model[32] = new ModelRendererTurbo(this, 177, 9, textureX, textureY); // 33
class85Model[33] = new ModelRendererTurbo(this, 345, 9, textureX, textureY); // 34
class85Model[34] = new ModelRendererTurbo(this, 201, 9, textureX, textureY); // 35
class85Model[35] = new ModelRendererTurbo(this, 209, 9, textureX, textureY); // 36
class85Model[34] = new ModelRendererTurbo(this, 201, 9, textureX, textureY, "lamp"); // 35
class85Model[35] = new ModelRendererTurbo(this, 209, 9, textureX, textureY, "lamp"); // 36
class85Model[36] = new ModelRendererTurbo(this, 3, 99, textureX, textureY); // 37
class85Model[37] = new ModelRendererTurbo(this, 369, 9, textureX, textureY); // 38
class85Model[38] = new ModelRendererTurbo(this, 465, 9, textureX, textureY); // 39
class85Model[39] = new ModelRendererTurbo(this, 489, 9, textureX, textureY); // 42
class85Model[40] = new ModelRendererTurbo(this, 497, 9, textureX, textureY); // 43
class85Model[37] = new ModelRendererTurbo(this, 369, 9, textureX, textureY, "lamp"); // 38
class85Model[38] = new ModelRendererTurbo(this, 465, 9, textureX, textureY, "lamp"); // 39
class85Model[39] = new ModelRendererTurbo(this, 489, 9, textureX, textureY, "lamp"); // 42
class85Model[40] = new ModelRendererTurbo(this, 497, 9, textureX, textureY, "lamp"); // 43
class85Model[41] = new ModelRendererTurbo(this, 225, 17, textureX, textureY); // 44
class85Model[42] = new ModelRendererTurbo(this, 505, 9, textureX, textureY); // 45
class85Model[43] = new ModelRendererTurbo(this, 49, 17, textureX, textureY); // 46
Expand Down Expand Up @@ -831,6 +831,9 @@ public ModelClass85()

fixRotation(class85Model, false, true, true);

fixRotation(class85Model);
bodyModel=class85Model;


}
private ModelDeiticBogie fronttrucks = new ModelDeiticBogie();
Expand All @@ -839,16 +842,7 @@ public ModelClass85()
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
for(int i = 0; i < 193; i++)
{
if (i==30 || i==31 || i==37 || i== 38 || i==39 || i==40 || i==35 || i ==34){
Minecraft.getMinecraft().entityRenderer.disableLightmap(1D);
}
class85Model[i].render(f5);
if (i==30 || i==31 || i==37 || i== 38 || i==39 || i==40 || i==35 || i ==34){
Minecraft.getMinecraft().entityRenderer.enableLightmap(1D);
}
}
super.render(entity, f, f1, f2, f3, f4, f5);

Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, "textures/trains/Class85_Bogie.png"));
GL11.glPushMatrix();
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/train/client/render/models/ModelEMDF3.java
Original file line number Diff line number Diff line change
Expand Up @@ -700,23 +700,17 @@ public ModelEMDF3()
emdf3Model[163].setRotationPoint(-21.01F, -15.25F, 0F);

fixRotation(emdf3Model, true, true, true);

fixRotation(emdf3Model);
bodyModel=emdf3Model;
}

private ModelBloombergTrucks fronttrucks = new ModelBloombergTrucks();
private ModelBloombergTrucks backtrucks = new ModelBloombergTrucks();
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
for (int i = 0; i < 164; i++)
{
if (emdf3Model[i].boxName != null && emdf3Model[i].boxName.equals("lamp")) {
Minecraft.getMinecraft().entityRenderer.disableLightmap(1D);
emdf3Model[i].render(f5);
Minecraft.getMinecraft().entityRenderer.enableLightmap(1D);
} else {
emdf3Model[i].render(f5);
}
}
super.render(entity, f, f1, f2, f3, f4, f5);

Tessellator.bindTexture(new ResourceLocation(Info.modID, "textures/trains/Blomberg_b_trucks.png"));
GL11.glPushMatrix();
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/train/client/render/models/ModelEMDF7.java
Original file line number Diff line number Diff line change
Expand Up @@ -747,23 +747,17 @@ public ModelEMDF7()
emdf7Model[175].setRotationPoint(12F, -25.75F, -3F);
fixRotation(emdf7Model, false, true, true);

fixRotation(emdf7Model);
bodyModel=emdf7Model;

}

private ModelBloombergTrucks fronttrucks = new ModelBloombergTrucks();
private ModelBloombergTrucks backtrucks = new ModelBloombergTrucks();
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
for (int i = 0; i < 176; i++)
{
if (emdf7Model[i].boxName != null && emdf7Model[i].boxName.equals("lamp")) {
Minecraft.getMinecraft().entityRenderer.disableLightmap(1D);
emdf7Model[i].render(f5);
Minecraft.getMinecraft().entityRenderer.enableLightmap(1D);
} else {
emdf7Model[i].render(f5);
}
}
super.render(entity, f, f1, f2, f3, f4, f5);

Tessellator.bindTexture(new ResourceLocation(Info.modID, "textures/trains/Blomberg_b_trucks.png"));
GL11.glPushMatrix();
Expand Down
30 changes: 12 additions & 18 deletions src/main/java/train/client/render/models/ModelEWSClass66.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public ModelEWSClass66()
ewsclass66Model[4] = new ModelRendererTurbo(this, 49, 1, textureX, textureY); // 06
ewsclass66Model[5] = new ModelRendererTurbo(this, 245, 250, textureX, textureY); // 07
ewsclass66Model[6] = new ModelRendererTurbo(this, 57, 1, textureX, textureY); // 08
ewsclass66Model[7] = new ModelRendererTurbo(this, 73, 1, textureX, textureY); // 09
ewsclass66Model[8] = new ModelRendererTurbo(this, 145, 1, textureX, textureY); // 10
ewsclass66Model[7] = new ModelRendererTurbo(this, 73, 1, textureX, textureY, "lamp"); // 09
ewsclass66Model[8] = new ModelRendererTurbo(this, 145, 1, textureX, textureY, "lamp"); // 10
ewsclass66Model[9] = new ModelRendererTurbo(this, 233, 17, textureX, textureY); // 11
ewsclass66Model[10] = new ModelRendererTurbo(this, 169, 1, textureX, textureY); // 12
ewsclass66Model[11] = new ModelRendererTurbo(this, 33, 1, textureX, textureY); // 13
Expand All @@ -53,14 +53,14 @@ public ModelEWSClass66()
ewsclass66Model[24] = new ModelRendererTurbo(this, 313, 1, textureX, textureY); // 26
ewsclass66Model[25] = new ModelRendererTurbo(this, 329, 1, textureX, textureY); // 27
ewsclass66Model[26] = new ModelRendererTurbo(this, 345, 1, textureX, textureY); // 28
ewsclass66Model[27] = new ModelRendererTurbo(this, 249, 1, textureX, textureY); // 32
ewsclass66Model[27] = new ModelRendererTurbo(this, 249, 1, textureX, textureY, "lamp"); // 32
ewsclass66Model[28] = new ModelRendererTurbo(this, 462, 1, textureX, textureY); // 33
ewsclass66Model[29] = new ModelRendererTurbo(this, 281, 1, textureX, textureY); // 34
ewsclass66Model[30] = new ModelRendererTurbo(this, 297, 1, textureX, textureY); // 35
ewsclass66Model[31] = new ModelRendererTurbo(this, 153, 17, textureX, textureY); // 36
ewsclass66Model[32] = new ModelRendererTurbo(this, 97, 9, textureX, textureY); // 37
ewsclass66Model[33] = new ModelRendererTurbo(this, 1, 17, textureX, textureY); // 38
ewsclass66Model[34] = new ModelRendererTurbo(this, 257, 1, textureX, textureY); // 39
ewsclass66Model[34] = new ModelRendererTurbo(this, 257, 1, textureX, textureY, "lamp"); // 39
ewsclass66Model[35] = new ModelRendererTurbo(this, 97, 25, textureX, textureY); // 40
ewsclass66Model[36] = new ModelRendererTurbo(this, 377, 1, textureX, textureY); // 41
ewsclass66Model[37] = new ModelRendererTurbo(this, 401, 1, textureX, textureY); // 42
Expand All @@ -72,14 +72,14 @@ public ModelEWSClass66()
ewsclass66Model[43] = new ModelRendererTurbo(this, 441, 1, textureX, textureY); // 48
ewsclass66Model[44] = new ModelRendererTurbo(this, 281, 25, textureX, textureY); // 49
ewsclass66Model[45] = new ModelRendererTurbo(this, 1, 9, textureX, textureY); // 50
ewsclass66Model[46] = new ModelRendererTurbo(this, 313, 1, textureX, textureY); // 51
ewsclass66Model[47] = new ModelRendererTurbo(this, 17, 9, textureX, textureY); // 53
ewsclass66Model[46] = new ModelRendererTurbo(this, 313, 1, textureX, textureY, "lamp"); // 51
ewsclass66Model[47] = new ModelRendererTurbo(this, 17, 9, textureX, textureY, "lamp"); // 53
ewsclass66Model[48] = new ModelRendererTurbo(this, 377, 9, textureX, textureY); // 54
ewsclass66Model[49] = new ModelRendererTurbo(this, 73, 17, textureX, textureY); // 55
ewsclass66Model[49] = new ModelRendererTurbo(this, 73, 17, textureX, textureY, "lamp"); // 55
ewsclass66Model[50] = new ModelRendererTurbo(this, 65, 9, textureX, textureY); // 56
ewsclass66Model[51] = new ModelRendererTurbo(this, 377, 25, textureX, textureY); // 57
ewsclass66Model[52] = new ModelRendererTurbo(this, 425, 25, textureX, textureY); // 58
ewsclass66Model[53] = new ModelRendererTurbo(this, 329, 1, textureX, textureY); // 59
ewsclass66Model[53] = new ModelRendererTurbo(this, 329, 1, textureX, textureY, "lamp"); // 59
ewsclass66Model[54] = new ModelRendererTurbo(this, 281, 17, textureX, textureY); // 60
ewsclass66Model[55] = new ModelRendererTurbo(this, 401, 9, textureX, textureY); // 61
ewsclass66Model[56] = new ModelRendererTurbo(this, 345, 1, textureX, textureY); // 62
Expand Down Expand Up @@ -644,23 +644,17 @@ public ModelEWSClass66()

fixRotation(ewsclass66Model, false, true, true);

fixRotation(ewsclass66Model);
bodyModel=ewsclass66Model;

}
private ModelEWSClass66_Bogie fronttrucks = new ModelEWSClass66_Bogie();
private ModelEWSClass66_Bogie backtrucks = new ModelEWSClass66_Bogie();

@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
for(int i = 0; i < 141; i++)
{
if (i==53 || i==46 || i== 27 || i==34 || i==8 || i==7 || i==47 || i==49){
Minecraft.getMinecraft().entityRenderer.disableLightmap(1D);
}
ewsclass66Model[i].render(f5);
if (i==53 || i==46 || i== 27 || i==34 || i==8 || i==7 || i==47 || i==49){
Minecraft.getMinecraft().entityRenderer.enableLightmap(1D);
}
}
super.render(entity, f, f1, f2, f3, f4, f5);

Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, "textures/trains/Class66Bogie.png"));
GL11.glPushMatrix();
Expand Down
Loading

0 comments on commit 95a4cfc

Please sign in to comment.