Dragon tree prototype (WIP)
This commit is contained in:
parent
30f7f53c7f
commit
3691e4b67e
21 changed files with 324 additions and 15 deletions
|
@ -197,4 +197,15 @@ public class SplineHelper {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Vector3f getPos(List<Vector3f> spline, float index) {
|
||||
int i = (int) index;
|
||||
float delta = index - i;
|
||||
Vector3f p1 = spline.get(i);
|
||||
Vector3f p2 = spline.get(i + 1);
|
||||
float x = MathHelper.lerp(delta, p1.getX(), p2.getX());
|
||||
float y = MathHelper.lerp(delta, p1.getY(), p2.getY());
|
||||
float z = MathHelper.lerp(delta, p1.getZ(), p2.getZ());
|
||||
return new Vector3f(x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
31
src/main/java/ru/betterend/util/sdf/primitive/SDFPie.java
Normal file
31
src/main/java/ru/betterend/util/sdf/primitive/SDFPie.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package ru.betterend.util.sdf.primitive;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class SDFPie extends SDFPrimitive {
|
||||
private float sin;
|
||||
private float cos;
|
||||
private float radius;
|
||||
|
||||
public SDFPie setAngle(float angle) {
|
||||
this.sin = (float) Math.sin(angle);
|
||||
this.cos = (float) Math.cos(angle);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SDFPie setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDistance(float x, float y, float z) {
|
||||
float px = Math.abs(x);
|
||||
float l = MHelper.length(px, y, z) - radius;
|
||||
float m = MHelper.dot(px, z, sin, cos);
|
||||
m = MathHelper.clamp(m, 0, radius);
|
||||
m = MHelper.length(px - sin * m, z - cos * m);
|
||||
return MHelper.max(l, m * (float) Math.signum(cos * px - sin * z));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue