mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
now kiss
This commit is contained in:
parent
1aba934d36
commit
6401ffde19
@ -18,6 +18,7 @@ public class HbmAnimations {
|
|||||||
//animation is playing, though this will cancel the animation entirely.
|
//animation is playing, though this will cancel the animation entirely.
|
||||||
public static final Animation[][] hotbar = new Animation[9][8]; //now with 8 parallel rails per slot! time to get railed!
|
public static final Animation[][] hotbar = new Animation[9][8]; //now with 8 parallel rails per slot! time to get railed!
|
||||||
|
|
||||||
|
/** Keyframe-based animation system primarily used for guns, not to be confused with Drillgon's animloader system. */
|
||||||
public static class Animation {
|
public static class Animation {
|
||||||
|
|
||||||
//the "name" of the animation slot. if the item has a different key than
|
//the "name" of the animation slot. if the item has a different key than
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import com.hbm.animloader.AnimationWrapper.EndResult;
|
|||||||
import com.hbm.animloader.AnimationWrapper.EndType;
|
import com.hbm.animloader.AnimationWrapper.EndType;
|
||||||
import com.hbm.blocks.BlockDummyable;
|
import com.hbm.blocks.BlockDummyable;
|
||||||
import com.hbm.render.loader.IModelCustomNamed;
|
import com.hbm.render.loader.IModelCustomNamed;
|
||||||
|
import com.hbm.render.tileentity.door.IRenderDoors;
|
||||||
import com.hbm.tileentity.DoorDecl;
|
import com.hbm.tileentity.DoorDecl;
|
||||||
import com.hbm.tileentity.TileEntityDoorGeneric;
|
import com.hbm.tileentity.TileEntityDoorGeneric;
|
||||||
|
|
||||||
@ -32,86 +33,96 @@ public class RenderDoorGeneric extends TileEntitySpecialRenderer {
|
|||||||
|
|
||||||
TileEntityDoorGeneric te = (TileEntityDoorGeneric) tile;
|
TileEntityDoorGeneric te = (TileEntityDoorGeneric) tile;
|
||||||
|
|
||||||
if(buf == null){
|
if(buf == null) buf = GLAllocation.createDirectByteBuffer(8*4).asDoubleBuffer();
|
||||||
buf = GLAllocation.createDirectByteBuffer(8*4).asDoubleBuffer();
|
|
||||||
}
|
|
||||||
DoorDecl door = te.getDoorType();
|
DoorDecl door = te.getDoorType();
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslated(x+0.5, y, z+0.5);
|
GL11.glTranslated(x + 0.5, y, z+0.5);
|
||||||
|
|
||||||
switch(te.getBlockMetadata() - BlockDummyable.offset) {
|
switch(te.getBlockMetadata() - BlockDummyable.offset) {
|
||||||
case 2: GL11.glRotatef(0+90, 0F, 1F, 0F); break;
|
case 2: GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||||
case 4: GL11.glRotatef(90+90, 0F, 1F, 0F); break;
|
case 4: GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||||
case 3: GL11.glRotatef(180+90, 0F, 1F, 0F); break;
|
case 3: GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||||
case 5: GL11.glRotatef(270+90, 0F, 1F, 0F); break;
|
case 5: GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||||
}
|
|
||||||
door.doOffsetTransform();
|
|
||||||
|
|
||||||
double[][] clip = door.getClippingPlanes();
|
|
||||||
for(int i = 0; i < clip.length; i ++){
|
|
||||||
GL11.glEnable(GL11.GL_CLIP_PLANE0+i);
|
|
||||||
buf.put(clip[i]);
|
|
||||||
buf.rewind();
|
|
||||||
GL11.glClipPlane(GL11.GL_CLIP_PLANE0+i, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
IRenderDoors sednaRenderer = door.getSEDNARenderer();
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
AnimatedModel animModel = door.getAnimatedModel();
|
if(sednaRenderer != null) {
|
||||||
if(animModel != null){
|
|
||||||
Animation anim = door.getAnim();
|
|
||||||
bindTexture(door.getTextureForPart(te.getSkinIndex(), ""));
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
long startTime = te.state > 1 ? te.animStartTime : time;
|
|
||||||
boolean reverse = te.state == 1 || te.state == 2;
|
|
||||||
AnimationWrapper w = new AnimationWrapper(startTime, anim).onEnd(new EndResult(EndType.STAY));
|
|
||||||
if(reverse)
|
|
||||||
w.reverse();
|
|
||||||
animModel.controller.setAnim(w);
|
|
||||||
animModel.renderAnimated(System.currentTimeMillis());
|
|
||||||
} else {
|
|
||||||
IModelCustomNamed model = door.getModel();
|
|
||||||
|
|
||||||
long ms = System.currentTimeMillis()-te.animStartTime;
|
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||||
float openTicks = MathHelper.clamp_float(te.state == 2 || te.state == 0 ? door.timeToOpen()*50-ms : ms, 0, door.timeToOpen()*50)*0.02F;
|
sednaRenderer.render(te, buf);
|
||||||
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
for(String partName : model.getPartNames()) {
|
|
||||||
if(!door.doesRender(partName, false))
|
} else {
|
||||||
continue;
|
door.doOffsetTransform();
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
double[][] clip = door.getClippingPlanes();
|
||||||
{
|
for(int i = 0; i < clip.length; i ++){
|
||||||
bindTexture(door.getTextureForPart(te.getSkinIndex(), partName));
|
GL11.glEnable(GL11.GL_CLIP_PLANE0+i);
|
||||||
doPartTransform(door, partName, openTicks, false);
|
buf.put(clip[i]);
|
||||||
model.renderPart(partName);
|
buf.rewind();
|
||||||
|
GL11.glClipPlane(GL11.GL_CLIP_PLANE0+i, buf);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
|
||||||
|
AnimatedModel animModel = door.getAnimatedModel();
|
||||||
|
if(animModel != null){
|
||||||
|
Animation anim = door.getAnim();
|
||||||
|
bindTexture(door.getTextureForPart(te.getSkinIndex(), ""));
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
long startTime = te.state > 1 ? te.animStartTime : time;
|
||||||
|
boolean reverse = te.state == 1 || te.state == 2;
|
||||||
|
AnimationWrapper w = new AnimationWrapper(startTime, anim).onEnd(new EndResult(EndType.STAY));
|
||||||
|
if(reverse)
|
||||||
|
w.reverse();
|
||||||
|
animModel.controller.setAnim(w);
|
||||||
|
animModel.renderAnimated(System.currentTimeMillis());
|
||||||
|
} else {
|
||||||
|
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;
|
||||||
|
|
||||||
|
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 ++){
|
||||||
|
GL11.glDisable(GL11.GL_CLIP_PLANE0+i);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < clip.length; i ++){
|
|
||||||
GL11.glDisable(GL11.GL_CLIP_PLANE0+i);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
|
||||||
GL11.glShadeModel(GL11.GL_FLAT);
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,12 +131,9 @@ public class RenderDoorGeneric extends TileEntitySpecialRenderer {
|
|||||||
door.getOrigin(name, orig);
|
door.getOrigin(name, orig);
|
||||||
door.getRotation(name, openTicks, rot);
|
door.getRotation(name, openTicks, rot);
|
||||||
GL11.glTranslated(orig[0], orig[1], orig[2]);
|
GL11.glTranslated(orig[0], orig[1], orig[2]);
|
||||||
if(rot[0] != 0)
|
if(rot[0] != 0) GL11.glRotated(rot[0], 1, 0, 0);
|
||||||
GL11.glRotated(rot[0], 1, 0, 0);
|
if(rot[1] != 0) GL11.glRotated(rot[1], 0, 1, 0);
|
||||||
if(rot[1] != 0)
|
if(rot[2] != 0) GL11.glRotated(rot[2], 0, 0, 1);
|
||||||
GL11.glRotated(rot[1], 0, 1, 0);
|
|
||||||
if(rot[2] != 0)
|
|
||||||
GL11.glRotated(rot[2], 0, 0, 1);
|
|
||||||
GL11.glTranslated(-orig[0]+tran[0], -orig[1]+tran[1], -orig[2]+tran[2]);
|
GL11.glTranslated(-orig[0]+tran[0], -orig[1]+tran[1], -orig[2]+tran[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.hbm.render.tileentity.door;
|
||||||
|
|
||||||
|
import java.nio.DoubleBuffer;
|
||||||
|
|
||||||
|
import com.hbm.tileentity.TileEntityDoorGeneric;
|
||||||
|
|
||||||
|
public interface IRenderDoors {
|
||||||
|
|
||||||
|
public void render(TileEntityDoorGeneric door, DoubleBuffer buf);
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@ import com.hbm.animloader.Animation;
|
|||||||
import com.hbm.lib.Library;
|
import com.hbm.lib.Library;
|
||||||
import com.hbm.main.ResourceManager;
|
import com.hbm.main.ResourceManager;
|
||||||
import com.hbm.render.loader.IModelCustomNamed;
|
import com.hbm.render.loader.IModelCustomNamed;
|
||||||
|
import com.hbm.render.tileentity.door.IRenderDoors;
|
||||||
import com.hbm.util.BobMathUtil;
|
import com.hbm.util.BobMathUtil;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@ -1209,4 +1210,8 @@ public abstract class DoorDecl {
|
|||||||
f[2] = z;
|
f[2] = z;
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// keyframe animation system sneakily stitched into the door decl
|
||||||
|
public IRenderDoors getSEDNARenderer() { return null; }
|
||||||
|
public com.hbm.render.anim.HbmAnimations.Animation getSEDNAAnim(byte state) { return null; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.hbm.blocks.BlockDummyable;
|
|||||||
import com.hbm.blocks.generic.BlockDoorGeneric;
|
import com.hbm.blocks.generic.BlockDoorGeneric;
|
||||||
import com.hbm.lib.Library;
|
import com.hbm.lib.Library;
|
||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
|
import com.hbm.render.anim.HbmAnimations.Animation;
|
||||||
import com.hbm.sound.AudioWrapper;
|
import com.hbm.sound.AudioWrapper;
|
||||||
import com.hbm.tileentity.machine.TileEntityLockableBase;
|
import com.hbm.tileentity.machine.TileEntityLockableBase;
|
||||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
@ -21,7 +22,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityDoorGeneric extends TileEntityLockableBase {
|
public class TileEntityDoorGeneric extends TileEntityLockableBase {
|
||||||
|
|
||||||
|
public static byte STATE_CLOSED = 0;
|
||||||
|
public static byte STATE_OPEN = 1;
|
||||||
|
public static byte STATE_CLOSING = 2;
|
||||||
|
public static byte STATE_OPENING = 3;
|
||||||
|
|
||||||
//0: closed, 1: open, 2: closing, 3: opening
|
//0: closed, 1: open, 2: closing, 3: opening
|
||||||
public byte state = 0;
|
public byte state = 0;
|
||||||
@ -36,6 +42,8 @@ public class TileEntityDoorGeneric extends TileEntityLockableBase {
|
|||||||
|
|
||||||
private AudioWrapper audio;
|
private AudioWrapper audio;
|
||||||
private AudioWrapper audio2;
|
private AudioWrapper audio2;
|
||||||
|
|
||||||
|
public Animation currentAnimation;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
@ -301,6 +309,10 @@ public class TileEntityDoorGeneric extends TileEntityLockableBase {
|
|||||||
|
|
||||||
this.state = state;
|
this.state = state;
|
||||||
if(state > 1) animStartTime = System.currentTimeMillis();
|
if(state > 1) animStartTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if(state == STATE_OPENING || state == STATE_CLOSING) {
|
||||||
|
currentAnimation = this.doorType.getSEDNAAnim(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user