use of javafx.scene.transform.Translate in project FXyzLib by Birdasaur.
the class Drag3DObject method loadControls.
private void loadControls(Scene scene) {
//First person shooter keyboard movement
scene.setOnKeyPressed(event -> {
double change = 10.0;
if (event.isShiftDown()) {
change = 50.0;
}
KeyCode keycode = event.getCode();
if (keycode == KeyCode.W) {
camera.setTranslateZ(camera.getTranslateZ() + change);
}
if (keycode == KeyCode.S) {
camera.setTranslateZ(camera.getTranslateZ() - change);
}
if (keycode == KeyCode.A) {
camera.setTranslateX(camera.getTranslateX() - change);
}
if (keycode == KeyCode.D) {
camera.setTranslateX(camera.getTranslateX() + change);
}
});
scene.setOnMousePressed((MouseEvent me) -> {
mousePosX = me.getSceneX();
mousePosY = me.getSceneY();
mouseOldX = me.getSceneX();
mouseOldY = me.getSceneY();
PickResult pr = me.getPickResult();
if (pr != null && pr.getIntersectedNode() != null && pr.getIntersectedNode() instanceof Sphere) {
distance = pr.getIntersectedDistance();
s = (Sphere) pr.getIntersectedNode();
isPicking = true;
vecIni = unProjectDirection(mousePosX, mousePosY, scene.getWidth(), scene.getHeight());
}
});
scene.setOnMouseDragged((MouseEvent me) -> {
mouseOldX = mousePosX;
mouseOldY = mousePosY;
mousePosX = me.getSceneX();
mousePosY = me.getSceneY();
mouseDeltaX = (mousePosX - mouseOldX);
mouseDeltaY = (mousePosY - mouseOldY);
if (RUN_JASON) {
//objPos += mouseMovementx*scale*RightAxis
if (isPicking) {
if (mousePosX < mouseOldX) {
System.out.println("moving left");
Point3D pos = CameraHelper.pickProjectPlane(camera, mousePosX, mousePosY);
s.setTranslateX(s.getTranslateX() + (pos.getX() - mouseOldX) * camera.getNearClip());
return;
} else if (mousePosX > mouseOldX) {
System.err.println("moving right");
Point3D pos = CameraHelper.pickProjectPlane(camera, mousePosX, mousePosY);
s.setTranslateX(s.getTranslateX() - (pos.getX() - mouseOldX) * camera.getNearClip());
return;
}
if (mousePosY < mouseOldY) {
System.out.println("moving up");
} else if (mousePosY > mouseOldY) {
System.err.println("moving down");
}
return;
}
} else {
if (isPicking) {
double modifier = (me.isControlDown() ? 0.2 : me.isAltDown() ? 2.0 : 1) * (30d / camera.getFieldOfView());
modifier *= (30d / camera.getFieldOfView());
vecPos = unProjectDirection(mousePosX, mousePosY, scene.getWidth(), scene.getHeight());
Point3D p = new Point3D(distance * (vecPos.x - vecIni.x), distance * (vecPos.y - vecIni.y), distance * (vecPos.z - vecIni.z));
s.getTransforms().add(new Translate(modifier * p.getX(), 0, modifier * p.getZ()));
vecIni = vecPos;
} else {
double modifier = 10.0;
double modifierFactor = 0.1;
if (me.isControlDown()) {
modifier = 0.1;
}
if (me.isShiftDown()) {
modifier = 50.0;
}
if (me.isPrimaryButtonDown()) {
// +
cameraTransform.ry.setAngle(((cameraTransform.ry.getAngle() + mouseDeltaX * modifierFactor * modifier * 2.0) % 360 + 540) % 360 - 180);
// -
cameraTransform.rx.setAngle(((cameraTransform.rx.getAngle() - mouseDeltaY * modifierFactor * modifier * 2.0) % 360 + 540) % 360 - 180);
} else if (me.isSecondaryButtonDown()) {
double z = camera.getTranslateZ();
double newZ = z + mouseDeltaX * modifierFactor * modifier;
camera.setTranslateZ(newZ);
} else if (me.isMiddleButtonDown()) {
// -
cameraTransform.t.setX(cameraTransform.t.getX() + mouseDeltaX * modifierFactor * modifier * 0.3);
// -
cameraTransform.t.setY(cameraTransform.t.getY() + mouseDeltaY * modifierFactor * modifier * 0.3);
}
}
}
});
scene.setOnMouseReleased((MouseEvent me) -> {
if (isPicking) {
isPicking = false;
}
});
}
use of javafx.scene.transform.Translate in project FXyzLib by Birdasaur.
the class SpheroidTest method start.
@Override
public void start(Stage stage) {
Group spheroidGroup = new Group();
for (int i = 0; i < 50; i++) {
Random r = new Random();
//A lot of magic numbers in here that just artificially constrain the math
float randomMajorRadius = (float) ((r.nextFloat() * 300) + 50);
float randomMinorRadius = (float) ((r.nextFloat() * 300) + 50);
int randomDivisions = (int) ((r.nextFloat() * 64) + 1);
Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
Spheroid sm = new Spheroid(randomDivisions, randomMajorRadius, randomMinorRadius, randomColor);
sm.setDrawMode(DrawMode.LINE);
double translationX = Math.random() * 1024 * 1.95;
if (Math.random() >= 0.5) {
translationX *= -1;
}
double translationY = Math.random() * 1024 * 1.95;
if (Math.random() >= 0.5) {
translationY *= -1;
}
double translationZ = Math.random() * 1024 * 1.95;
if (Math.random() >= 0.5) {
translationZ *= -1;
}
Translate translate = new Translate(translationX, translationY, translationZ);
Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);
sm.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
spheroidGroup.getChildren().add(sm);
}
root.getChildren().add(spheroidGroup);
System.out.println(spheroidGroup.getChildren().size());
camera = new PerspectiveCamera(true);
cameraTransform.setTranslate(0, 0, 0);
cameraTransform.getChildren().addAll(camera);
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setFieldOfView(42);
camera.setTranslateZ(cameraDistance);
cameraTransform.ry.setAngle(-45.0);
cameraTransform.rx.setAngle(-10.0);
//add a Point Light for better viewing of the grid coordinate system
PointLight light = new PointLight(Color.WHITE);
cameraTransform.getChildren().add(light);
light.setTranslateX(camera.getTranslateX());
light.setTranslateY(camera.getTranslateY());
light.setTranslateZ(camera.getTranslateZ());
root.getChildren().add(cameraTransform);
Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
scene.setCamera(camera);
scene.setFill(Color.BLACK);
initFirstPersonControls(scene);
stage.setTitle("Hello World!");
stage.setScene(scene);
stage.show();
}
use of javafx.scene.transform.Translate in project FXyzLib by Birdasaur.
the class TorusTest method start.
@Override
public void start(Stage primaryStage) throws Exception {
Group sceneRoot = new Group();
Scene scene = new Scene(sceneRoot, sceneWidth, sceneHeight, true, SceneAntialiasing.BALANCED);
scene.setFill(Color.BLACK);
//Setup camera and scatterplot cubeviewer
camera = new PerspectiveCamera(true);
//setup camera transform for rotational support
cameraTransform.setTranslate(0, 0, 0);
cameraTransform.getChildren().add(camera);
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setTranslateZ(-5000);
cameraTransform.ry.setAngle(-45.0);
cameraTransform.rx.setAngle(-10.0);
//add a Point Light for better viewing of the grid coordinate system
PointLight light = new PointLight(Color.WHITE);
cameraTransform.getChildren().add(light);
light.setTranslateX(camera.getTranslateX());
light.setTranslateY(camera.getTranslateY());
light.setTranslateZ(camera.getTranslateZ());
scene.setCamera(camera);
//Make a bunch of semi random Torusesessses(toroids?) and stuff
Group torusGroup = new Group();
torusGroup.getChildren().add(cameraTransform);
for (int i = 0; i < 30; i++) {
Random r = new Random();
//A lot of magic numbers in here that just artificially constrain the math
float randomRadius = (float) ((r.nextFloat() * 300) + 50);
float randomTubeRadius = (float) ((r.nextFloat() * 100) + 1);
int randomTubeDivisions = (int) ((r.nextFloat() * 64) + 1);
int randomRadiusDivisions = (int) ((r.nextFloat() * 64) + 1);
Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
Torus torus = new Torus(randomTubeDivisions, randomRadiusDivisions, randomRadius, randomTubeRadius, randomColor);
double translationX = Math.random() * sceneWidth * 1.95;
if (Math.random() >= 0.5)
translationX *= -1;
double translationY = Math.random() * sceneWidth * 1.95;
if (Math.random() >= 0.5)
translationY *= -1;
double translationZ = Math.random() * sceneWidth * 1.95;
if (Math.random() >= 0.5)
translationZ *= -1;
Translate translate = new Translate(translationX, translationY, translationZ);
Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);
torus.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
//torus.getTransforms().add(translate);
torusGroup.getChildren().add(torus);
}
sceneRoot.getChildren().addAll(torusGroup);
//First person shooter keyboard movement
scene.setOnKeyPressed(event -> {
double change = 10.0;
if (event.isShiftDown()) {
change = 50.0;
}
KeyCode keycode = event.getCode();
if (keycode == KeyCode.W) {
camera.setTranslateZ(camera.getTranslateZ() + change);
}
if (keycode == KeyCode.S) {
camera.setTranslateZ(camera.getTranslateZ() - change);
}
if (keycode == KeyCode.A) {
camera.setTranslateX(camera.getTranslateX() - change);
}
if (keycode == KeyCode.D) {
camera.setTranslateX(camera.getTranslateX() + change);
}
});
scene.setOnMousePressed((MouseEvent me) -> {
mousePosX = me.getSceneX();
mousePosY = me.getSceneY();
mouseOldX = me.getSceneX();
mouseOldY = me.getSceneY();
});
scene.setOnMouseDragged((MouseEvent me) -> {
mouseOldX = mousePosX;
mouseOldY = mousePosY;
mousePosX = me.getSceneX();
mousePosY = me.getSceneY();
mouseDeltaX = (mousePosX - mouseOldX);
mouseDeltaY = (mousePosY - mouseOldY);
double modifier = 10.0;
double modifierFactor = 0.1;
if (me.isControlDown()) {
modifier = 0.1;
}
if (me.isShiftDown()) {
modifier = 50.0;
}
if (me.isPrimaryButtonDown()) {
// +
cameraTransform.ry.setAngle(((cameraTransform.ry.getAngle() + mouseDeltaX * modifierFactor * modifier * 2.0) % 360 + 540) % 360 - 180);
// -
cameraTransform.rx.setAngle(((cameraTransform.rx.getAngle() - mouseDeltaY * modifierFactor * modifier * 2.0) % 360 + 540) % 360 - 180);
} else if (me.isSecondaryButtonDown()) {
double z = camera.getTranslateZ();
double newZ = z + mouseDeltaX * modifierFactor * modifier;
camera.setTranslateZ(newZ);
} else if (me.isMiddleButtonDown()) {
// -
cameraTransform.t.setX(cameraTransform.t.getX() + mouseDeltaX * modifierFactor * modifier * 0.3);
// -
cameraTransform.t.setY(cameraTransform.t.getY() + mouseDeltaY * modifierFactor * modifier * 0.3);
}
});
primaryStage.setTitle("F(X)yz TorusTest");
primaryStage.setScene(scene);
primaryStage.show();
}
use of javafx.scene.transform.Translate in project FXyzLib by Birdasaur.
the class TrapezoidTest method generateShapes.
private void generateShapes() {
for (int i = 0; i < 50; i++) {
Random r = new Random();
//A lot of magic numbers in here that just artificially constrain the math
double randomSmallSize = (double) ((r.nextDouble() * 50) + 10);
double randomBigSize = (double) ((r.nextDouble() * 100) + 50);
double randomHeight = (double) ((r.nextDouble() * 50) + 25);
double randomDepth = (double) ((r.nextDouble() * 50) + 25);
Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
Trapezoid trapezoid = new Trapezoid(randomSmallSize, randomBigSize, randomHeight, randomDepth, randomColor);
// Trapezoid trapezoid = new Trapezoid(50, 100, 50, 50, randomColor);
trapezoid.setEmissiveLightingColor(randomColor);
trapezoid.setEmissiveLightingOn(r.nextBoolean());
trapezoid.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
double translationX = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationX *= -1;
}
double translationY = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationY *= -1;
}
double translationZ = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationZ *= -1;
}
Translate translate = new Translate(translationX, translationY, translationZ);
Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);
trapezoid.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
shapeGroup.getChildren().add(trapezoid);
}
}
use of javafx.scene.transform.Translate in project FXyzLib by Birdasaur.
the class FrustumMesh method createFrustum.
private TriangleMesh createFrustum(float majorRadius, float minorRadius, float height, int level) {
TriangleMesh m0 = null;
if (level > 0) {
m0 = createFrustum(majorRadius, minorRadius, height, level - 1);
}
if (level == 0) {
a = new Affine();
int div = DEFAULT_DIVISIONS > 3 ? DEFAULT_DIVISIONS : 3;
if (getSectionType() != TriangleMeshHelper.SectionType.CIRCLE) {
div = getSectionType().getSides() * ((int) (div / getSectionType().getSides()) + 1);
}
if (getAxisOrigin() != null && getAxisEnd() != null) {
Point3D dir = getAxisEnd().substract(getAxisOrigin()).crossProduct(new Point3D(0, -1, 0));
double angle = Math.acos(getAxisEnd().substract(getAxisOrigin()).normalize().dotProduct(new Point3D(0, -1, 0)));
a = a.createConcatenation(new Translate(getAxisOrigin().x, getAxisOrigin().y - height / 2d, getAxisOrigin().z)).createConcatenation(new Rotate(-Math.toDegrees(angle), 0d, height / 2d, 0d, new javafx.geometry.Point3D(dir.x, -dir.y, dir.z)));
}
int nPoints = 2 * div + 2;
float rBase = majorRadius;
float rTop = minorRadius;
float h = height;
final float[] baseVertices = new float[nPoints * 3];
// base at y=h/2
for (int i = 0; i < div; i++) {
double ang = i * 2d * Math.PI / div;
double pol = polygonalSection(ang);
Point3D ta = transform(rBase * pol * Math.cos(ang), h / 2, rBase * pol * Math.sin(ang));
baseVertices[3 * i] = ta.x;
baseVertices[3 * i + 1] = ta.y;
baseVertices[3 * i + 2] = ta.z;
}
// top at y=-h/2
for (int i = div; i < 2 * div; i++) {
double ang = i * 2d * Math.PI / div;
double pol = polygonalSection(ang);
Point3D ta = transform(rTop * pol * Math.cos(ang), -h / 2, rTop * pol * Math.sin(ang));
baseVertices[3 * i] = ta.x;
baseVertices[3 * i + 1] = ta.y;
baseVertices[3 * i + 2] = ta.z;
}
Point3D ta = transform(0, h / 2, 0);
baseVertices[6 * div] = ta.x;
baseVertices[6 * div + 1] = ta.y;
baseVertices[6 * div + 2] = ta.z;
ta = transform(0, -h / 2, 0);
baseVertices[6 * div + 3] = ta.x;
baseVertices[6 * div + 4] = ta.y;
baseVertices[6 * div + 5] = ta.z;
int nTextCoords = div * 4 + 6;
float rectBase = (float) polygonalSize(rBase);
float rectTop = (float) polygonalSize(rTop);
float L = (float) (rBase + 2d * Math.PI * rBase);
float H = 2f * (rBase + rTop) + h;
final float[] baseTexCoords = new float[nTextCoords * 2];
// u right ,v up
for (int i = 0; i <= div; i++) {
baseTexCoords[2 * i] = (float) (rBase + i * rectBase / div) / L;
baseTexCoords[2 * i + 1] = (float) (2f * rTop + h) / H;
}
for (int i = 0; i <= div; i++) {
baseTexCoords[2 * div + 2 * i + 2] = (float) (rBase + i * rectTop / div) / L;
baseTexCoords[2 * div + 2 * i + 3] = (float) (2f * rTop) / H;
}
for (int i = 0; i <= div; i++) {
double ang = i * 2d * Math.PI / div;
double pol = polygonalSection(ang);
baseTexCoords[4 * div + 2 * i + 4] = (float) (rBase + rBase * pol * Math.sin(ang)) / L;
baseTexCoords[4 * div + 2 * i + 5] = (float) (2f * rTop + rBase + h - rBase * pol * Math.cos(ang)) / H;
}
for (int i = 0; i <= div; i++) {
double ang = i * 2d * Math.PI / div;
double pol = polygonalSection(ang);
baseTexCoords[6 * div + 2 * i + 6] = (float) (rBase + rTop * pol * Math.sin(ang)) / L;
baseTexCoords[6 * div + 2 * i + 7] = (float) (rTop + rTop * pol * Math.cos(ang)) / H;
}
baseTexCoords[8 * div + 8] = rBase / L;
baseTexCoords[8 * div + 9] = (2f * rTop + rBase + h) / H;
baseTexCoords[8 * div + 10] = rBase / L;
baseTexCoords[8 * div + 11] = rTop / H;
int nFaces = div * 4;
final int[] baseTexture = new int[nFaces * 3];
final int[] baseFaces = new int[nFaces * 3];
for (int i = 0; i < div; i++) {
int p1 = i + 1;
int p2 = i + div;
int p3 = i + div + 1;
baseFaces[6 * i] = i;
baseFaces[6 * i + 1] = p1 == div ? 0 : p1;
baseFaces[6 * i + 2] = p2;
baseFaces[6 * i + 3] = p3 % div == 0 ? p3 - div : p3;
baseFaces[6 * i + 4] = p2;
baseFaces[6 * i + 5] = p1 == div ? 0 : p1;
baseTexture[6 * i] = i;
baseTexture[6 * i + 1] = p1;
baseTexture[6 * i + 2] = p2 + 1;
baseTexture[6 * i + 3] = p3 + 1;
baseTexture[6 * i + 4] = p2 + 1;
baseTexture[6 * i + 5] = p1;
}
for (int i = 0; i < div; i++) {
int p1 = div * 2;
int p2 = i + 1;
baseFaces[6 * div + 3 * i] = i;
baseFaces[6 * div + 3 * i + 1] = p1;
baseFaces[6 * div + 3 * i + 2] = p2 == div ? 0 : p2;
baseTexture[6 * div + 3 * i] = (div + 1) * 2 + i;
baseTexture[6 * div + 3 * i + 1] = (div + 1) * 4;
baseTexture[6 * div + 3 * i + 2] = (div + 1) * 2 + i + 1;
}
for (int i = 0; i < div; i++) {
int p1 = div * 2 + 1;
int p2 = i + 1 + div;
baseFaces[9 * div + 3 * i] = i + div;
baseFaces[9 * div + 3 * i + 1] = p2 % div == 0 ? p2 - div : p2;
baseFaces[9 * div + 3 * i + 2] = p1;
baseTexture[9 * div + 3 * i] = (div + 1) * 3 + i;
baseTexture[9 * div + 3 * i + 1] = (div + 1) * 3 + i + 1;
baseTexture[9 * div + 3 * i + 2] = (div + 1) * 4 + 1;
}
points0 = baseVertices;
numVertices = baseVertices.length / 3;
texCoord0 = baseTexCoords;
numTexCoords = baseTexCoords.length / 2;
faces0 = IntStream.range(0, baseFaces.length / 3).mapToObj(i -> IntStream.of(baseFaces[3 * i], baseTexture[3 * i], baseFaces[3 * i + 1], baseTexture[3 * i + 1], baseFaces[3 * i + 2], baseTexture[3 * i + 2])).flatMapToInt(i -> i).toArray();
numFaces = baseFaces.length / 3;
} else if (m0 != null) {
points0 = new float[numVertices * m0.getPointElementSize()];
m0.getPoints().toArray(points0);
}
final float h = height;
List<Point3D> points1 = IntStream.range(0, numVertices).mapToObj(i -> {
Point3D p = new Point3D(points0[3 * i], points0[3 * i + 1], points0[3 * i + 2]);
p.f = (h / 2 - unTransform(p).y) / h;
return p;
}).collect(Collectors.toList());
if (level > 0 && m0 != null) {
texCoord0 = new float[numTexCoords * m0.getTexCoordElementSize()];
m0.getTexCoords().toArray(texCoord0);
}
texCoord1 = IntStream.range(0, numTexCoords).mapToObj(i -> new Point2D(texCoord0[2 * i], texCoord0[2 * i + 1])).collect(Collectors.toList());
if (level > 0 && m0 != null) {
faces0 = new int[numFaces * m0.getFaceElementSize()];
m0.getFaces().toArray(faces0);
}
List<Face3> faces1 = IntStream.range(0, numFaces).mapToObj(i -> new Face3(faces0[6 * i], faces0[6 * i + 2], faces0[6 * i + 4])).collect(Collectors.toList());
index.set(points1.size());
map.clear();
listVertices.clear();
listFaces.clear();
listVertices.addAll(points1);
faces1.forEach(face -> {
int v1 = face.p0;
int v2 = face.p1;
int v3 = face.p2;
if (level > 0) {
int a = getMiddle(v1, points1.get(v1), v2, points1.get(v2));
int b = getMiddle(v2, points1.get(v2), v3, points1.get(v3));
int c = getMiddle(v3, points1.get(v3), v1, points1.get(v1));
listFaces.add(new Face3(v1, a, c));
listFaces.add(new Face3(v2, b, a));
listFaces.add(new Face3(v3, c, b));
listFaces.add(new Face3(a, b, c));
} else {
listFaces.add(new Face3(v1, v2, v3));
}
});
map.clear();
numVertices = listVertices.size();
numFaces = listFaces.size();
List<Face3> textures1;
if (level == 0) {
textures1 = IntStream.range(0, faces0.length / 6).mapToObj(i -> new Face3(faces0[6 * i + 1], faces0[6 * i + 3], faces0[6 * i + 5])).collect(Collectors.toList());
} else {
textures1 = listTextures.stream().map(t -> t).collect(Collectors.toList());
}
index.set(texCoord1.size());
listTextures.clear();
AtomicInteger kk = new AtomicInteger();
textures1.forEach(face -> {
int v1 = face.p0;
int v2 = face.p1;
int v3 = face.p2;
if (level > 0) {
int a = getMiddle(v1, texCoord1.get(v1), v2, texCoord1.get(v2));
int b = getMiddle(v2, texCoord1.get(v2), v3, texCoord1.get(v3));
int c = getMiddle(v3, texCoord1.get(v3), v1, texCoord1.get(v1));
listTextures.add(new Face3(v1, a, c));
listTextures.add(new Face3(v2, b, a));
listTextures.add(new Face3(v3, c, b));
listTextures.add(new Face3(a, b, c));
} else {
listTextures.add(new Face3(v1, v2, v3));
}
});
map.clear();
texCoord0 = texCoord1.stream().flatMapToDouble(p -> DoubleStream.of(p.getX(), p.getY())).collect(() -> new FloatCollector(texCoord1.size() * 2), FloatCollector::add, FloatCollector::join).toArray();
numTexCoords = texCoord0.length / 2;
textureCoords = texCoord0;
if (level == getLevel()) {
areaMesh.setWidth(majorRadius + 2f * Math.PI * majorRadius);
areaMesh.setHeight(height + 2f * (minorRadius + majorRadius));
smoothingGroups = IntStream.range(0, listFaces.size()).map(i -> {
if (getSectionType() != TriangleMeshHelper.SectionType.CIRCLE) {
return 0;
}
if (i < listFaces.size() / 2) {
return 1;
} else if (i < 3 * listFaces.size() / 4) {
return 2;
}
return 4;
}).toArray();
}
return createMesh();
}
Aggregations