Added prerequisites for future Camera Tilt feature
This commit is contained in:
@@ -657,7 +657,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
private void addPlaceKeyframe() {
|
||||
Entity cam = mc.getRenderViewEntity();
|
||||
if(cam == null) return;
|
||||
ReplayHandler.addKeyframe(new PositionKeyframe(ReplayHandler.getRealTimelineCursor(), new Position(cam.posX, cam.posY, cam.posZ, cam.rotationPitch, cam.rotationYaw)));
|
||||
ReplayHandler.addKeyframe(new PositionKeyframe(ReplayHandler.getRealTimelineCursor(), new Position(cam.posX, cam.posY, cam.posZ, cam.rotationPitch, cam.rotationYaw, ReplayHandler.getCameraTilt())));
|
||||
}
|
||||
|
||||
private void addTimeKeyframe() {
|
||||
@@ -677,7 +677,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
|
||||
private boolean isClick() {
|
||||
if(Mouse.isButtonDown(0)) {
|
||||
boolean bef = new Boolean(mouseDwn);
|
||||
boolean bef = mouseDwn;
|
||||
mouseDwn = true;
|
||||
return !bef;
|
||||
} else {
|
||||
|
||||
@@ -104,6 +104,14 @@ public class KeyInputHandler {
|
||||
|
||||
public void handleCustomKeybindings(KeyBinding kb, boolean found, int keyCode) {
|
||||
//Custom registered handlers
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROTATE_CLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !found) {
|
||||
ReplayHandler.addCameraTilt(1);
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROTATE_COUNTERCLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !found) {
|
||||
ReplayHandler.addCameraTilt(-1);
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_THUMBNAIL) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !found) {
|
||||
TickAndRenderListener.requestScreenshot();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ public class Position {
|
||||
|
||||
private double x, y, z;
|
||||
private float pitch, yaw;
|
||||
private float rotation = 0;
|
||||
|
||||
public Position(Entity e) {
|
||||
this.x = e.posX;
|
||||
@@ -16,6 +17,15 @@ public class Position {
|
||||
this.yaw = e.rotationYaw;
|
||||
}
|
||||
|
||||
public Position(double x, double y, double z, float pitch, float yaw, float rotation) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.pitch = pitch;
|
||||
this.yaw = yaw;
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
public Position(double x, double y, double z, float pitch, float yaw) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -64,6 +74,10 @@ public class Position {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public float getRotation() { return rotation; }
|
||||
|
||||
public void setRotation(float rotation) { this.rotation = rotation; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X=" + x + ", Y=" + y + ", Z=" + z + ", Yaw=" + yaw + ", Pitch=" + pitch;
|
||||
@@ -85,6 +99,7 @@ public class Position {
|
||||
.append(z)
|
||||
.append(pitch)
|
||||
.append(yaw)
|
||||
.append(rotation)
|
||||
.toHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,13 @@ public class SplinePoint extends BasicSpline {
|
||||
private Vector<Cubic> zCubics;
|
||||
private Vector<Cubic> pitchCubics;
|
||||
private Vector<Cubic> yawCubics;
|
||||
private Vector<Cubic> rotCubics;
|
||||
private Field vectorX;
|
||||
private Field vectorY;
|
||||
private Field vectorZ;
|
||||
private Field vectorPitch;
|
||||
private Field vectorYaw;
|
||||
private Field vectorRot;
|
||||
|
||||
public SplinePoint() {
|
||||
this.points = new Vector<Position>();
|
||||
@@ -28,6 +30,7 @@ public class SplinePoint extends BasicSpline {
|
||||
this.zCubics = new Vector<Cubic>();
|
||||
this.pitchCubics = new Vector<Cubic>();
|
||||
this.yawCubics = new Vector<Cubic>();
|
||||
this.rotCubics = new Vector<Cubic>();
|
||||
|
||||
try {
|
||||
vectorX = Position.class.getDeclaredField("x");
|
||||
@@ -35,11 +38,13 @@ public class SplinePoint extends BasicSpline {
|
||||
vectorZ = Position.class.getDeclaredField("z");
|
||||
vectorPitch = Position.class.getDeclaredField("pitch");
|
||||
vectorYaw = Position.class.getDeclaredField("yaw");
|
||||
vectorRot = Position.class.getDeclaredField("rotation");
|
||||
vectorX.setAccessible(true);
|
||||
vectorY.setAccessible(true);
|
||||
vectorZ.setAccessible(true);
|
||||
vectorPitch.setAccessible(true);
|
||||
vectorYaw.setAccessible(true);
|
||||
vectorRot.setAccessible(true);
|
||||
} catch(SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch(NoSuchFieldException e) {
|
||||
@@ -62,6 +67,7 @@ public class SplinePoint extends BasicSpline {
|
||||
calcNaturalCubic(points, vectorZ, zCubics);
|
||||
calcNaturalCubic(points, vectorPitch, pitchCubics);
|
||||
calcNaturalCubic(points, vectorYaw, yawCubics);
|
||||
calcNaturalCubic(points, vectorRot, rotCubics);
|
||||
} catch(IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch(IllegalAccessException e) {
|
||||
@@ -80,7 +86,8 @@ public class SplinePoint extends BasicSpline {
|
||||
yCubics.get(cubicNum).eval(cubicPos),
|
||||
zCubics.get(cubicNum).eval(cubicPos),
|
||||
(float) pitchCubics.get(cubicNum).eval(cubicPos),
|
||||
(float) yawCubics.get(cubicNum).eval(cubicPos));
|
||||
(float) yawCubics.get(cubicNum).eval(cubicPos),
|
||||
(float) rotCubics.get(cubicNum).eval(cubicPos));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ public class KeybindRegistry {
|
||||
public static final String KEY_CLEAR_KEYFRAMES = "replaymod.input.clearkeyframes";
|
||||
public static final String KEY_SYNC_TIMELINE = "replaymod.input.synctimeline";
|
||||
public static final String KEY_KEYFRAME_PRESETS = "replaymod.input.keyframerepository";
|
||||
public static final String KEY_ROTATE_CLOCKWISE = "replaymod.input.rotateclockwise";
|
||||
public static final String KEY_ROTATE_COUNTERCLOCKWISE = "replaymod.input.rotatecounterclockwise";
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static void initialize() {
|
||||
@@ -27,6 +29,8 @@ public class KeybindRegistry {
|
||||
bindings.add(new KeyBinding(KEY_SYNC_TIMELINE, Keyboard.KEY_V, "replaymod.title"));
|
||||
bindings.add(new KeyBinding(KEY_CLEAR_KEYFRAMES, Keyboard.KEY_C, "replaymod.title"));
|
||||
bindings.add(new KeyBinding(KEY_KEYFRAME_PRESETS, Keyboard.KEY_X, "replaymod.title"));
|
||||
bindings.add(new KeyBinding(KEY_ROTATE_CLOCKWISE, Keyboard.KEY_L, "replaymod.title"));
|
||||
bindings.add(new KeyBinding(KEY_ROTATE_COUNTERCLOCKWISE, Keyboard.KEY_K, "replaymod.title"));
|
||||
|
||||
mc.gameSettings.keyBindings = bindings.toArray(new KeyBinding[bindings.size()]);
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ public class ReplayHandler {
|
||||
private static Entity currentEntity = null;
|
||||
private static Position lastPosition = null;
|
||||
|
||||
private static float cameraTilt = 0;
|
||||
|
||||
private static KeyframeSet[] keyframeRepository = new KeyframeSet[]{};
|
||||
|
||||
public static KeyframeSet[] getKeyframeRepository() {
|
||||
@@ -102,6 +104,18 @@ public class ReplayHandler {
|
||||
spectateCamera();
|
||||
}
|
||||
|
||||
public static float getCameraTilt() {
|
||||
return cameraTilt;
|
||||
}
|
||||
|
||||
public static void setCameraTilt(float tilt) {
|
||||
cameraTilt = tilt;
|
||||
}
|
||||
|
||||
public static void addCameraTilt(float tilt) {
|
||||
cameraTilt += tilt;
|
||||
}
|
||||
|
||||
public static void sortKeyframes() {
|
||||
Collections.sort(keyframes, new KeyframeComparator());
|
||||
}
|
||||
@@ -281,6 +295,8 @@ public class ReplayHandler {
|
||||
channel.close();
|
||||
}
|
||||
|
||||
setCameraTilt(0);
|
||||
|
||||
networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND);
|
||||
INetHandlerPlayClient pc = new NetHandlerPlayClient(mc, null, networkManager, new GameProfile(UUID.randomUUID(), "Player"));
|
||||
networkManager.setNetHandler(pc);
|
||||
|
||||
@@ -21,6 +21,7 @@ replaymod.api.unknownlang=This language has not been translated
|
||||
replaymod.api.zippingerror=An error occured while zipping the language files
|
||||
replaymod.api.usernameexists=This username is already taken
|
||||
replaymod.api.mailexists=This email address is already linked to an account
|
||||
replaymod.api.invalidmail=Invalid e-Mail Address
|
||||
|
||||
|
||||
#All of the chat messages
|
||||
@@ -97,7 +98,6 @@ replaymod.gui.register.confirmpw=Confirm Password
|
||||
replaymod.gui.register.error.nomatch=Passwords don't match
|
||||
replaymod.gui.register.error.shortusername=Username has to be at least 5 characters long
|
||||
replaymod.gui.register.error.shortpw=Password has to be at least 5 characters long
|
||||
replaymod.gui.register.error.invalidmail=Invalid e-Mail Address
|
||||
|
||||
|
||||
#Replay Viewer GUI
|
||||
@@ -187,6 +187,8 @@ replaymod.input.spectate=Spectate Players
|
||||
replaymod.input.clearkeyframes=Clear Keyframes
|
||||
replaymod.input.synctimeline=Synchronize Timeline
|
||||
replaymod.input.keyframerepository=Open Keyframe Presets
|
||||
replaymod.input.rotateclockwise=Rotate Clockwise
|
||||
replaymod.input.rotatecounterclockwise=Rotate Counterclockwise
|
||||
|
||||
#Keyframe Presets GUI
|
||||
replaymod.gui.keyframerepository.title=Keyframe Repository
|
||||
|
||||
Reference in New Issue
Block a user