mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Fix up door rendering, moving it to a more generic interface
This commit is contained in:
parent
b9fa946440
commit
3c760ba95d
@ -9,6 +9,7 @@ import com.hbm.lib.RefStrings;
|
||||
import com.hbm.render.anim.AnimationLoader;
|
||||
import com.hbm.render.anim.BusAnimation;
|
||||
import com.hbm.render.loader.HFRWavefrontObject;
|
||||
import com.hbm.render.loader.IModelCustomNamed;
|
||||
import com.hbm.render.loader.WavefrontObjDisplayList;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@ -327,7 +328,7 @@ public class ResourceManager {
|
||||
//Doors
|
||||
public static AnimatedModel transition_seal = ColladaLoader.load(new ResourceLocation(RefStrings.MODID, "models/doors/seal.dae"), true);
|
||||
public static Animation transition_seal_anim = ColladaLoader.loadAnim(24040, new ResourceLocation(RefStrings.MODID, "models/doors/seal.dae"));
|
||||
public static final IModelCustom fire_door = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/doors/fire_door.obj")).asVBO();
|
||||
public static final IModelCustomNamed fire_door = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/doors/fire_door.obj")).asVBO();
|
||||
|
||||
//Secure Access Door
|
||||
public static final ResourceLocation secure_access_door_tex = new ResourceLocation(RefStrings.MODID, "textures/models/doors/secure_access_door.png");
|
||||
|
||||
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -16,12 +17,11 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.client.model.ModelFormatException;
|
||||
import net.minecraftforge.client.model.obj.TextureCoordinate;
|
||||
import net.minecraftforge.client.model.obj.Vertex;
|
||||
|
||||
public class HFRWavefrontObject implements IModelCustom {
|
||||
public class HFRWavefrontObject implements IModelCustomNamed {
|
||||
private static Pattern vertexPattern = Pattern.compile("(v( (\\-){0,1}\\d+(\\.\\d+)?){3,4} *\\n)|(v( (\\-){0,1}\\d+(\\.\\d+)?){3,4} *$)");
|
||||
private static Pattern vertexNormalPattern = Pattern.compile("(vn( (\\-){0,1}\\d+(\\.\\d+)?){3,4} *\\n)|(vn( (\\-){0,1}\\d+(\\.\\d+)?){3,4} *$)");
|
||||
private static Pattern textureCoordinatePattern = Pattern.compile("(vt( (\\-){0,1}\\d+\\.\\d+){2,3} *\\n)|(vt( (\\-){0,1}\\d+(\\.\\d+)?){2,3} *$)");
|
||||
@ -483,6 +483,15 @@ public class HFRWavefrontObject implements IModelCustom {
|
||||
return "obj";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPartNames() {
|
||||
List<String> names = new ArrayList<String>();
|
||||
for(S_GroupObject data : groupObjects) {
|
||||
names.add(data.name);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public WavefrontObjVBO asVBO() {
|
||||
return new WavefrontObjVBO(this);
|
||||
}
|
||||
|
||||
13
src/main/java/com/hbm/render/loader/IModelCustomNamed.java
Normal file
13
src/main/java/com/hbm/render/loader/IModelCustomNamed.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.hbm.render.loader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
public interface IModelCustomNamed extends IModelCustom {
|
||||
|
||||
// A little messy, but this is the cleanest refactor, and can be useful in the future
|
||||
|
||||
public List<String> getPartNames();
|
||||
|
||||
}
|
||||
@ -7,11 +7,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
|
||||
public class WavefrontObjDisplayList implements IModelCustom {
|
||||
public class WavefrontObjDisplayList implements IModelCustomNamed {
|
||||
|
||||
public List<Pair<String, Integer>> nameToCallList = new ArrayList<>();
|
||||
|
||||
@ -95,4 +94,13 @@ public class WavefrontObjDisplayList implements IModelCustom {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPartNames() {
|
||||
List<String> names = new ArrayList<String>();
|
||||
for(Pair<String, Integer> data : nameToCallList) {
|
||||
names.add(data.getLeft());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
}
|
||||
@ -7,13 +7,12 @@ import java.util.List;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.client.model.obj.TextureCoordinate;
|
||||
import net.minecraftforge.client.model.obj.Vertex;
|
||||
|
||||
public class WavefrontObjVBO implements IModelCustom {
|
||||
public class WavefrontObjVBO implements IModelCustomNamed {
|
||||
|
||||
class VBOBufferData {
|
||||
public class VBOBufferData {
|
||||
|
||||
String name;
|
||||
int vertices = 0;
|
||||
@ -23,7 +22,7 @@ public class WavefrontObjVBO implements IModelCustom {
|
||||
|
||||
}
|
||||
|
||||
List<VBOBufferData> groups = new ArrayList<VBOBufferData>();
|
||||
public List<VBOBufferData> groups = new ArrayList<VBOBufferData>();
|
||||
|
||||
static int VERTEX_SIZE = 3;
|
||||
static int UV_SIZE = 3;
|
||||
@ -147,4 +146,13 @@ public class WavefrontObjVBO implements IModelCustom {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPartNames() {
|
||||
List<String> names = new ArrayList<String>();
|
||||
for(VBOBufferData data : groups) {
|
||||
names.add(data.name);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,6 @@ package com.hbm.render.tileentity;
|
||||
|
||||
import java.nio.DoubleBuffer;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.animloader.AnimatedModel;
|
||||
@ -11,7 +10,7 @@ import com.hbm.animloader.AnimationWrapper;
|
||||
import com.hbm.animloader.AnimationWrapper.EndResult;
|
||||
import com.hbm.animloader.AnimationWrapper.EndType;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.render.loader.WavefrontObjDisplayList;
|
||||
import com.hbm.render.loader.IModelCustomNamed;
|
||||
import com.hbm.tileentity.DoorDecl;
|
||||
import com.hbm.tileentity.TileEntityDoorGeneric;
|
||||
|
||||
@ -19,7 +18,6 @@ import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
public class RenderDoorGeneric extends TileEntitySpecialRenderer {
|
||||
|
||||
@ -76,29 +74,36 @@ public class RenderDoorGeneric extends TileEntitySpecialRenderer {
|
||||
animModel.controller.setAnim(w);
|
||||
animModel.renderAnimated(System.currentTimeMillis());
|
||||
} else {
|
||||
// IModelCustom model = door.getModel();
|
||||
IModelCustomNamed model = door.getModel();
|
||||
|
||||
// long ms = System.currentTimeMillis()-te.animStartTime;
|
||||
// float openTicks = MathHelper.clamp_float(te.state == 2 || te.state == 0 ? door.timeToOpen()*50-ms : ms, 0, door.timeToOpen()*50)*0.02F;
|
||||
long ms = System.currentTimeMillis()-te.animStartTime;
|
||||
float openTicks = MathHelper.clamp_float(te.state == 2 || te.state == 0 ? door.timeToOpen()*50-ms : ms, 0, door.timeToOpen()*50)*0.02F;
|
||||
|
||||
// for(Pair<String, Integer> p : model.nameToCallList){
|
||||
// if(!door.doesRender(p.getLeft(), false))
|
||||
// continue;
|
||||
// GL11.glPushMatrix();
|
||||
// bindTexture(door.getTextureForPart(te.getSkinIndex(), p.getLeft()));
|
||||
// doPartTransform(door, p.getLeft(), openTicks, false);
|
||||
// GL11.glCallList(p.getRight());
|
||||
// for(String name : door.getChildren(p.getLeft())){
|
||||
// if(!door.doesRender(name, true))
|
||||
// continue;
|
||||
// GL11.glPushMatrix();
|
||||
// bindTexture(door.getTextureForPart(te.getSkinIndex(), name));
|
||||
// doPartTransform(door, name, openTicks, true);
|
||||
// model.renderPart(name);
|
||||
// GL11.glPopMatrix();
|
||||
// }
|
||||
// GL11.glPopMatrix();
|
||||
// }
|
||||
for(String partName : model.getPartNames()) {
|
||||
if(!door.doesRender(partName, false))
|
||||
continue;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
{
|
||||
bindTexture(door.getTextureForPart(te.getSkinIndex(), partName));
|
||||
doPartTransform(door, partName, openTicks, false);
|
||||
model.renderPart(partName);
|
||||
|
||||
for(String innerPartName : door.getChildren(partName)) {
|
||||
if(!door.doesRender(innerPartName, true))
|
||||
continue;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
{
|
||||
bindTexture(door.getTextureForPart(te.getSkinIndex(), innerPartName));
|
||||
doPartTransform(door, innerPartName, openTicks, true);
|
||||
model.renderPart(innerPartName);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < clip.length; i ++){
|
||||
|
||||
@ -4,13 +4,12 @@ import com.hbm.animloader.AnimatedModel;
|
||||
import com.hbm.animloader.Animation;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.loader.WavefrontObjDisplayList;
|
||||
import com.hbm.render.loader.IModelCustomNamed;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@ -92,7 +91,7 @@ public abstract class DoorDecl {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public WavefrontObjDisplayList getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@ -181,7 +180,7 @@ public abstract class DoorDecl {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IModelCustom getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return ResourceManager.fire_door;
|
||||
}
|
||||
};
|
||||
@ -269,7 +268,7 @@ public abstract class DoorDecl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WavefrontObjDisplayList getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -360,7 +359,7 @@ public abstract class DoorDecl {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public WavefrontObjDisplayList getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return ResourceManager.sliding_seal_door;
|
||||
}
|
||||
};
|
||||
@ -459,7 +458,7 @@ public abstract class DoorDecl {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public WavefrontObjDisplayList getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return ResourceManager.secure_access_door;
|
||||
}
|
||||
};
|
||||
@ -548,7 +547,7 @@ public abstract class DoorDecl {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public WavefrontObjDisplayList getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return ResourceManager.round_airlock_door;
|
||||
}
|
||||
};
|
||||
@ -631,7 +630,7 @@ public abstract class DoorDecl {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public WavefrontObjDisplayList getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return ResourceManager.qe_sliding_door;
|
||||
}
|
||||
|
||||
@ -717,7 +716,7 @@ public abstract class DoorDecl {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public WavefrontObjDisplayList getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return ResourceManager.qe_containment;
|
||||
}
|
||||
|
||||
@ -858,7 +857,7 @@ public abstract class DoorDecl {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public WavefrontObjDisplayList getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return ResourceManager.water_door;
|
||||
}
|
||||
|
||||
@ -920,7 +919,7 @@ public abstract class DoorDecl {
|
||||
@Override public int[] getDimensions() { return new int[] { 0, 0, 2, 2, 2, 2 }; }
|
||||
@Override @SideOnly(Side.CLIENT) public ResourceLocation getTextureForPart(String partName) { return ResourceManager.silo_hatch_tex; }
|
||||
@Override public ResourceLocation getTextureForPart(int skinIndex, String partName) { return ResourceManager.silo_hatch_tex; }
|
||||
@Override @SideOnly(Side.CLIENT) public WavefrontObjDisplayList getModel() { return ResourceManager.silo_hatch; }
|
||||
@Override @SideOnly(Side.CLIENT) public IModelCustomNamed getModel() { return ResourceManager.silo_hatch; }
|
||||
|
||||
};
|
||||
|
||||
@ -980,7 +979,7 @@ public abstract class DoorDecl {
|
||||
@Override public int[] getDimensions() { return new int[] { 0, 0, 3, 3, 3, 3 }; }
|
||||
@Override @SideOnly(Side.CLIENT) public ResourceLocation getTextureForPart(String partName) { return ResourceManager.silo_hatch_large_tex; }
|
||||
@Override public ResourceLocation getTextureForPart(int skinIndex, String partName) { return ResourceManager.silo_hatch_large_tex; }
|
||||
@Override @SideOnly(Side.CLIENT) public WavefrontObjDisplayList getModel() { return ResourceManager.silo_hatch_large; }
|
||||
@Override @SideOnly(Side.CLIENT) public IModelCustomNamed getModel() { return ResourceManager.silo_hatch_large; }
|
||||
|
||||
};
|
||||
|
||||
@ -1058,7 +1057,7 @@ public abstract class DoorDecl {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public WavefrontObjDisplayList getModel() {
|
||||
public IModelCustomNamed getModel() {
|
||||
return ResourceManager.large_vehicle_door;
|
||||
}
|
||||
|
||||
@ -1112,7 +1111,7 @@ public abstract class DoorDecl {
|
||||
public abstract ResourceLocation getTextureForPart(int skinIndex, String partName);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract IModelCustom getModel();
|
||||
public abstract IModelCustomNamed getModel();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AnimatedModel getAnimatedModel() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user