feat: 100% ready

This commit is contained in:
gdamms 2022-05-17 18:25:20 +02:00
parent cc2197174c
commit e9824aa78c
2 changed files with 46 additions and 9 deletions

View file

@ -141,15 +141,6 @@ public class Camera extends JavaPlugin implements Listener {
point.getPitch(), point.getYaw());
}
// public static String prettyLocation(ExtendedLocation point) {
// return String.format(
// "X=%05.2f, Y=%05.2f, Z=%05.2f, P=%05.2f, Y=%05.2f, R=%05.2f, w=%05.2f,
// x=%05.2f, y=%05.2f, z=%05.2f",
// point.getX(), point.getY(), point.getZ(),
// point.getPitch(), point.getYaw(), point.roll,
// point.qw, point.qx, point.qy, point.qz);
// }
public static void broadlog(String msg) {
Camera.logger.log(Level.INFO, msg);
Bukkit.broadcastMessage(msg);

View file

@ -1,5 +1,6 @@
package com.tocard.cam;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
@ -24,6 +25,9 @@ public class NewPoint implements CommandExecutor {
case "set":
set(args, new ExtendedLocation(player.getLocation()), player.getWorld());
break;
case "fix":
fix(args, null, null);
break;
default:
break;
}
@ -111,6 +115,9 @@ public class NewPoint implements CommandExecutor {
int n = Camera.controlPoints.size();
int index = Integer.parseInt(args[1]);
if (index > 0)
location.patchYaw(Camera.controlPoints.get(index - 1));
if (n <= 4) {
setPoint(index, location, world);
return;
@ -170,4 +177,43 @@ public class NewPoint implements CommandExecutor {
}
}
public static void fix(String[] args, ExtendedLocation location, World world) {
int n = Camera.controlPoints.size();
int index = Integer.parseInt(args[1]);
if (n <= 4 || index < 2 || index > n - 3) {
return;
}
ExtendedLocation P0, P1, P2;
switch (index % 3) {
case 0:
// Anchor point
P0 = Camera.controlPoints.get(index - 1);
P2 = Camera.controlPoints.get(index + 1);
P1 = P0.clone().add(P2).multiply(0.5);
setPoint(index, P1, P1.getWorld());
break;
case 1:
// Control point after an anchor
P0 = Camera.controlPoints.get(index - 2);
P1 = Camera.controlPoints.get(index - 1);
P2 = P1.clone().multiply(2).subtract(P0);
setPoint(index, P2, P2.getWorld());
break;
case 2:
// Control point before an anchor
P1 = Camera.controlPoints.get(index + 1);
P2 = Camera.controlPoints.get(index + 2);
P0 = P1.clone().multiply(2).subtract(P2);
setPoint(index, P0, P0.getWorld());
break;
}
}
}