Dragon tree feature prototype

This commit is contained in:
paulevsGitch 2020-11-01 15:11:11 +03:00
parent 3691e4b67e
commit 063e3fe465
18 changed files with 273 additions and 81 deletions

View file

@ -1,5 +1,6 @@
package ru.betterend.util;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
@ -208,4 +209,34 @@ public class SplineHelper {
float z = MathHelper.lerp(delta, p1.getZ(), p2.getZ());
return new Vector3f(x, y, z);
}
public static void rotateSpline(List<Vector3f> spline, float angle) {
for (Vector3f v: spline) {
float sin = (float) Math.sin(angle);
float cos = (float) Math.cos(angle);
float x = v.getX() * cos + v.getZ() * sin;
float z = v.getX() * sin + v.getZ() * cos;
v.set(x, v.getY(), z);
}
}
public static List<Vector3f> copySpline(List<Vector3f> spline) {
List<Vector3f> result = new ArrayList<Vector3f>(spline.size());
for (Vector3f v: spline) {
result.add(v.copy());
}
return result;
}
public static void scale(List<Vector3f> spline, float scale) {
for (Vector3f v: spline) {
v.set(v.getX() * scale, v.getY() * scale, v.getZ() * scale);
}
}
public static void offset(List<Vector3f> spline, Vector3f offset) {
for (Vector3f v: spline) {
v.add(offset);
}
}
}