It looks better now
This commit is contained in:
parent
eb561d8369
commit
b01033edd5
|
@ -1,7 +1,10 @@
|
||||||
package awlex.ospu.polymover;
|
package awlex.ospu.polymover;
|
||||||
|
|
||||||
import Jama.Matrix;
|
import Jama.Matrix;
|
||||||
|
import itdelatrisu.opsu.objects.Circle;
|
||||||
import itdelatrisu.opsu.objects.GameObject;
|
import itdelatrisu.opsu.objects.GameObject;
|
||||||
|
import itdelatrisu.opsu.objects.Slider;
|
||||||
|
import itdelatrisu.opsu.states.Game;
|
||||||
|
|
||||||
import static java.lang.Math.*;
|
import static java.lang.Math.*;
|
||||||
|
|
||||||
|
@ -36,17 +39,39 @@ public class ArcMover extends PolyMover {
|
||||||
alpha = atan2(p1.end.y - ym, p1.end.x - xm);
|
alpha = atan2(p1.end.y - ym, p1.end.x - xm);
|
||||||
beta = atan2(middle.end.y - ym, middle.end.x - xm);
|
beta = atan2(middle.end.y - ym, middle.end.x - xm);
|
||||||
gamma = atan2(p2.start.y - ym, p2.start.x - xm);
|
gamma = atan2(p2.start.y - ym, p2.start.x - xm);
|
||||||
|
//fixAngles();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixAngles() {
|
||||||
|
if (alpha < gamma && gamma < beta) {
|
||||||
|
gamma += 2 * PI;
|
||||||
|
}
|
||||||
|
else if ((beta < alpha && alpha < gamma)) {
|
||||||
|
beta += 2 * PI;
|
||||||
|
gamma += 2 * PI;
|
||||||
|
}
|
||||||
|
else if (beta < gamma && gamma < alpha) {
|
||||||
|
alpha -= 2 * PI;
|
||||||
|
}
|
||||||
|
else if (gamma < alpha && alpha < beta) {
|
||||||
|
alpha -= 2 * PI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] getPointAt(int time) {
|
public double[] getPointAt(int time) {
|
||||||
double angle;
|
double angle;
|
||||||
|
double percent;
|
||||||
if (time < middle.getTime()) {
|
if (time < middle.getTime()) {
|
||||||
angle = alpha + beta * ((double) time - p1.getEndTime()) / ((middle.getTime() - p1.getEndTime()));
|
percent = ((double) time - p1.getEndTime()) / (middle.getTime() - p1.getEndTime());
|
||||||
|
angle = alpha + (beta - alpha) * percent;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
angle = beta + gamma * ((double) time - middle.getTime()) / (p2.getTime() - middle.getTime());
|
percent = ((double) time - middle.getTime()) / (p2.getTime() - middle.getTime());
|
||||||
|
angle = beta + (gamma - beta) * percent;
|
||||||
}
|
}
|
||||||
|
if (angle > PI)
|
||||||
|
angle -= PI;
|
||||||
return new double[]{
|
return new double[]{
|
||||||
xm + r * cos(angle),
|
xm + r * cos(angle),
|
||||||
ym + r * sin(angle)
|
ym + r * sin(angle)
|
||||||
|
@ -63,16 +88,32 @@ public class ArcMover extends PolyMover {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Matrix prepareMatrix(GameObject p1, GameObject middle, GameObject p2) {
|
private static Matrix prepareMatrix(GameObject p1, GameObject middle, GameObject p2) {
|
||||||
Matrix a = new Matrix(new double[][]{
|
Matrix a, b;
|
||||||
{1, -p1.end.x, -p1.end.y},
|
if (p2.isSlider()) {
|
||||||
{1, -middle.end.x, -middle.end.y},
|
Circle c = (((Slider) p2).getTickPositionCircles()[0]);
|
||||||
{1, -p2.start.x, -p2.start.y}
|
a = new Matrix(new double[][]{
|
||||||
});
|
{1, -p1.end.x, -p1.end.y},
|
||||||
Matrix b = new Matrix(new double[][]{
|
{1, -middle.start.x, -middle.start.y},
|
||||||
{-(pow(p1.end.x, 2) + pow(p1.end.y, 2))},
|
{1, -c.end.x, -c.end.y}
|
||||||
{-(pow(middle.end.x, 2) + pow(middle.end.y, 2))},
|
});
|
||||||
{-(pow(p2.start.x, 2) + pow(p2.start.y, 2))},
|
b = new Matrix(new double[][]{
|
||||||
});
|
{-(pow(p1.end.x, 2) + pow(p1.end.y, 2))},
|
||||||
|
{-(pow(middle.start.x, 2) + pow(middle.start.y, 2))},
|
||||||
|
{-(pow(c.end.x, 2) + pow(c.end.y, 2))},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
a = new Matrix(new double[][]{
|
||||||
|
{1, -p1.end.x, -p1.end.y},
|
||||||
|
{1, -middle.start.x, -middle.start.y},
|
||||||
|
{1, -p2.start.x, -p2.start.y}
|
||||||
|
});
|
||||||
|
b = new Matrix(new double[][]{
|
||||||
|
{-(pow(p1.end.x, 2) + pow(p1.end.y, 2))},
|
||||||
|
{-(pow(middle.start.x, 2) + pow(middle.start.y, 2))},
|
||||||
|
{-(pow(p2.start.x, 2) + pow(p2.start.y, 2))},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return a.solve(b);
|
return a.solve(b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import yugecin.opsudance.movers.LinearMover;
|
||||||
*/
|
*/
|
||||||
public class LineMover extends PolyMover {
|
public class LineMover extends PolyMover {
|
||||||
|
|
||||||
GameObject[] objects;
|
private GameObject[] objects;
|
||||||
|
|
||||||
public LineMover(GameObject[] objects, int startIndex, int count) {
|
public LineMover(GameObject[] objects, int startIndex, int count) {
|
||||||
this.objects = new GameObject[count];
|
this.objects = new GameObject[count];
|
||||||
|
@ -27,6 +27,6 @@ public class LineMover extends PolyMover {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameObject[] getItems() {
|
public GameObject[] getItems() {
|
||||||
return new GameObject[0];
|
return objects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package awlex.ospu.polymover.factory;
|
||||||
import awlex.ospu.polymover.ArcMover;
|
import awlex.ospu.polymover.ArcMover;
|
||||||
import awlex.ospu.polymover.LineMover;
|
import awlex.ospu.polymover.LineMover;
|
||||||
import awlex.ospu.polymover.PolyMover;
|
import awlex.ospu.polymover.PolyMover;
|
||||||
|
import itdelatrisu.opsu.objects.DummyObject;
|
||||||
import itdelatrisu.opsu.objects.GameObject;
|
import itdelatrisu.opsu.objects.GameObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +18,8 @@ public class ArcFactory implements PolyMoverFactory {
|
||||||
public double[] getPointAt(int time) {
|
public double[] getPointAt(int time) {
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
return current.getPointAt(time);
|
return current.getPointAt(time);
|
||||||
|
} else if (current == null) {
|
||||||
|
return previous.getPointAt(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
double[] point1 = current.getPointAt(time);
|
double[] point1 = current.getPointAt(time);
|
||||||
|
@ -32,23 +35,41 @@ public class ArcFactory implements PolyMoverFactory {
|
||||||
public void init(GameObject[] objects, int startIndex) {
|
public void init(GameObject[] objects, int startIndex) {
|
||||||
if (objects == null)
|
if (objects == null)
|
||||||
throw new NullPointerException("Objects musn't be null");
|
throw new NullPointerException("Objects musn't be null");
|
||||||
|
boolean b;
|
||||||
|
if (b = startIndex == -1) {
|
||||||
|
objects = new GameObject[]{
|
||||||
|
new DummyObject(),
|
||||||
|
objects[0],
|
||||||
|
objects[1]
|
||||||
|
};
|
||||||
|
startIndex++;
|
||||||
|
}
|
||||||
GameObject middle = objects[startIndex + 1];
|
GameObject middle = objects[startIndex + 1];
|
||||||
if (middle.isSlider() || middle.isSpinner() || !ArcMover.canCricleExistBetweenItems(objects[startIndex], middle, objects[startIndex + 2]))
|
if (middle.isSlider() || middle.isSpinner() || !ArcMover.canCricleExistBetweenItems(objects[startIndex], middle, objects[startIndex + 2]))
|
||||||
current = new LineMover(objects, startIndex, 3);
|
current = new LineMover(objects, startIndex, 3);
|
||||||
else
|
else
|
||||||
current = new ArcMover(objects[startIndex], middle, objects[startIndex + 2]);
|
current = new ArcMover(objects[startIndex], middle, objects[startIndex + 2]);
|
||||||
lastIndex = startIndex + 2;
|
lastIndex = startIndex + 2;
|
||||||
|
if (b)
|
||||||
|
lastIndex--;
|
||||||
previous = null;
|
previous = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(GameObject p) {
|
public void update(GameObject p) {
|
||||||
GameObject[] items = (previous == null ? current : previous).getItems();
|
GameObject[] items = current.getItems();
|
||||||
|
System.out.println(items.length);
|
||||||
GameObject last = items[items.length - 1];
|
GameObject last = items[items.length - 1];
|
||||||
if (last != p) {
|
if (last != p) {
|
||||||
if (ArcMover.canCricleExistBetweenItems(items[items.length - 2], items[items.length - 1], p)) {
|
previous = current;
|
||||||
previous = current;
|
if (!(last.isSpinner() || last.isSlider()))
|
||||||
current = new ArcMover(previous, p);
|
if (ArcMover.canCricleExistBetweenItems(items[items.length - 2], last, p)) {
|
||||||
|
current = new ArcMover(previous, p);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
current = new LineMover(items, 0, items.length);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
current = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastIndex++;
|
lastIndex++;
|
||||||
|
|
|
@ -266,10 +266,11 @@ public class Dancer {
|
||||||
double[] spinnerStartPoint = spinner.getPoint();
|
double[] spinnerStartPoint = spinner.getPoint();
|
||||||
c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);
|
c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);
|
||||||
}
|
}
|
||||||
|
// polyMoverFactory.init(gameObjects, objectIndex);
|
||||||
if (polyMoverFactory.isInitialized() && polyMoverFactory.getLatestIndex() < objectIndex + polyMoverFactory.getPrefferedBufferSize() - 1) {
|
if (polyMoverFactory.isInitialized() && polyMoverFactory.getLatestIndex() < objectIndex + polyMoverFactory.getPrefferedBufferSize() - 1) {
|
||||||
polyMoverFactory.update(gameObjects[polyMoverFactory.getPrefferedBufferSize() - 1]);
|
polyMoverFactory.update(gameObjects[polyMoverFactory.getLatestIndex()]);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
polyMoverFactory.init(gameObjects, objectIndex);
|
polyMoverFactory.init(gameObjects, objectIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user