Tree leaves shape
This commit is contained in:
parent
d17c660482
commit
e1f5779b0f
1 changed files with 21 additions and 14 deletions
|
@ -20,6 +20,7 @@ import ru.betterend.util.SplineHelper;
|
||||||
import ru.betterend.util.sdf.SDF;
|
import ru.betterend.util.sdf.SDF;
|
||||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||||
import ru.betterend.util.sdf.operator.SDFScale3D;
|
import ru.betterend.util.sdf.operator.SDFScale3D;
|
||||||
|
import ru.betterend.util.sdf.operator.SDFSubtraction;
|
||||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||||
|
|
||||||
|
@ -35,10 +36,11 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
||||||
SplineHelper.offsetParts(spline, random, 0.7F, 0, 0.7F);
|
SplineHelper.offsetParts(spline, random, 0.7F, 0, 0.7F);
|
||||||
Vector3f last = spline.get(spline.size() - 1);
|
Vector3f last = spline.get(spline.size() - 1);
|
||||||
|
|
||||||
int depth = 3;//MHelper.floor((size - 10F) * 3F / 10F + 1F);
|
int depth = MHelper.floor((size - 10F) * 3F / 10F + 1F);
|
||||||
branch(last.getX(), last.getY(), last.getZ(), size * 1.5F, MHelper.randRange(0, MHelper.PI2, random), random, depth, world, pos);
|
float bsize = (10F - (size - 10F)) / 10F + 1.5F;
|
||||||
|
branch(last.getX(), last.getY(), last.getZ(), size * bsize, MHelper.randRange(0, MHelper.PI2, random), random, depth, world, pos);
|
||||||
|
|
||||||
SDF function = SplineHelper.buildSDF(spline, 1.5F, 0.8F, (bpos) -> {
|
SDF function = SplineHelper.buildSDF(spline, 1.7F, 1.1F, (bpos) -> {
|
||||||
return BlockRegistry.PYTHADENDRON.bark.getDefaultState();
|
return BlockRegistry.PYTHADENDRON.bark.getDefaultState();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -51,8 +53,8 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
||||||
private void branch(float x, float y, float z, float size, float angle, Random random, int depth, StructureWorldAccess world, BlockPos pos) {
|
private void branch(float x, float y, float z, float size, float angle, Random random, int depth, StructureWorldAccess world, BlockPos pos) {
|
||||||
if (depth == 0) return;
|
if (depth == 0) return;
|
||||||
|
|
||||||
float dx = (float) Math.cos(angle) * size * 0.2F;
|
float dx = (float) Math.cos(angle) * size * 0.15F;
|
||||||
float dz = (float) Math.sin(angle) * size * 0.2F;
|
float dz = (float) Math.sin(angle) * size * 0.15F;
|
||||||
|
|
||||||
float x1 = x + dx;
|
float x1 = x + dx;
|
||||||
float z1 = z + dz;
|
float z1 = z + dz;
|
||||||
|
@ -74,21 +76,23 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
||||||
boolean s2 = SplineHelper.fillSpline(spline, world, BlockRegistry.PYTHADENDRON.bark.getDefaultState(), pos, REPLACE);
|
boolean s2 = SplineHelper.fillSpline(spline, world, BlockRegistry.PYTHADENDRON.bark.getDefaultState(), pos, REPLACE);
|
||||||
|
|
||||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||||
if (depth == 1) {
|
if (depth < 3) {
|
||||||
if (s1) {
|
if (s1) {
|
||||||
SDF sphere = new SDFSphere().setRadius(MHelper.randRange(4.5F, 6.5F, random)).setBlock(BlockRegistry.PYTHADENDRON_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
float radius = MHelper.randRange(4.5F, 6.5F, random);
|
||||||
sphere = new SDFScale3D().setScale(1, 0.4F, 1).setSource(sphere);
|
SDF sphere = new SDFSphere().setRadius(radius).setBlock(BlockRegistry.PYTHADENDRON_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
||||||
//sphere = new SDFTranslate().setTranslate(pos1.getX() + pos.getX(), pos1.getY() + pos.getY(), pos1.getZ() + pos.getZ()).setSource(sphere);
|
sphere = new SDFScale3D().setScale(1, 0.6F, 1).setSource(sphere);
|
||||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||||
sphere.setReplaceFunction(REPLACE);
|
sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere);
|
||||||
|
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||||
sphere.fillRecursive(world, new BlockPos(pos1.getX() + pos.getX(), pos1.getY() + pos.getY() + 1, pos1.getZ() + pos.getZ()));
|
sphere.fillRecursive(world, new BlockPos(pos1.getX() + pos.getX(), pos1.getY() + pos.getY() + 1, pos1.getZ() + pos.getZ()));
|
||||||
}
|
}
|
||||||
if (s2) {
|
if (s2) {
|
||||||
SDF sphere = new SDFSphere().setRadius(MHelper.randRange(4.5F, 6.5F, random)).setBlock(BlockRegistry.PYTHADENDRON_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
float radius = MHelper.randRange(4.5F, 6.5F, random);
|
||||||
sphere = new SDFScale3D().setScale(1, 0.4F, 1).setSource(sphere);
|
SDF sphere = new SDFSphere().setRadius(radius).setBlock(BlockRegistry.PYTHADENDRON_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
||||||
//sphere = new SDFTranslate().setTranslate(pos2.getX() + pos.getX(), pos2.getY() + pos.getY(), pos2.getZ() + pos.getZ()).setSource(sphere);
|
sphere = new SDFScale3D().setScale(1, 0.6F, 1).setSource(sphere);
|
||||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||||
sphere.setReplaceFunction(REPLACE);
|
sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere);
|
||||||
|
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||||
sphere.fillRecursive(world, new BlockPos(pos2.getX() + pos.getX(), pos2.getY() + pos.getY() + 1, pos2.getZ() + pos.getZ()));
|
sphere.fillRecursive(world, new BlockPos(pos2.getX() + pos.getX(), pos2.getY() + pos.getY() + 1, pos2.getZ() + pos.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +115,9 @@ public class PythadendronTreeFeature extends DefaultFeature {
|
||||||
if (state.isIn(BlockTagRegistry.END_GROUND)) {
|
if (state.isIn(BlockTagRegistry.END_GROUND)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (state.getBlock() == BlockRegistry.PYTHADENDRON_LEAVES) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (state.getMaterial().equals(Material.PLANT)) {
|
if (state.getMaterial().equals(Material.PLANT)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue