1 package eu.mihosoft.vrl.v3d;
3 import java.util.Arrays;
6 import javafx.scene.shape.TriangleMesh;
14 TriangleMesh mesh =
new TriangleMesh();
16 double minX = Double.POSITIVE_INFINITY;
17 double minY = Double.POSITIVE_INFINITY;
18 double minZ = Double.POSITIVE_INFINITY;
20 double maxX = Double.NEGATIVE_INFINITY;
21 double maxY = Double.NEGATIVE_INFINITY;
22 double maxZ = Double.NEGATIVE_INFINITY;
26 if (p.vertices.size() >= 3) {
33 Vertex firstVertex = p.vertices.get(0);
34 for (
int i = 0; i < p.vertices.size() - 2; i++) {
36 if (firstVertex.
pos.
x < minX) {
37 minX = firstVertex.
pos.
x;
39 if (firstVertex.
pos.
y < minY) {
40 minY = firstVertex.
pos.
y;
42 if (firstVertex.
pos.
z < minZ) {
43 minZ = firstVertex.
pos.
z;
46 if (firstVertex.
pos.
x > maxX) {
47 maxX = firstVertex.
pos.
x;
49 if (firstVertex.
pos.
y > maxY) {
50 maxY = firstVertex.
pos.
y;
52 if (firstVertex.
pos.
z > maxZ) {
53 maxZ = firstVertex.
pos.
z;
56 mesh.getPoints().addAll((
float) firstVertex.
pos.
x, (
float) firstVertex.
pos.
y,
57 (
float) firstVertex.
pos.
z);
59 mesh.getTexCoords().addAll(0);
60 mesh.getTexCoords().addAll(0);
62 Vertex secondVertex = p.vertices.get(i + 1);
64 if (secondVertex.
pos.
x < minX) {
65 minX = secondVertex.
pos.
x;
67 if (secondVertex.
pos.
y < minY) {
68 minY = secondVertex.
pos.
y;
70 if (secondVertex.
pos.
z < minZ) {
71 minZ = secondVertex.
pos.
z;
74 if (secondVertex.
pos.
x > maxX) {
75 maxX = firstVertex.
pos.
x;
77 if (secondVertex.
pos.
y > maxY) {
78 maxY = firstVertex.
pos.
y;
80 if (secondVertex.
pos.
z > maxZ) {
81 maxZ = firstVertex.
pos.
z;
84 mesh.getPoints().addAll((
float) secondVertex.
pos.
x, (
float) secondVertex.
pos.
y,
85 (
float) secondVertex.
pos.
z);
87 mesh.getTexCoords().addAll(0);
88 mesh.getTexCoords().addAll(0);
90 Vertex thirdVertex = p.vertices.get(i + 2);
92 mesh.getPoints().addAll((
float) thirdVertex.
pos.
x, (
float) thirdVertex.
pos.
y,
93 (
float) thirdVertex.
pos.
z);
95 if (thirdVertex.
pos.
x < minX) {
96 minX = thirdVertex.
pos.
x;
98 if (thirdVertex.
pos.
y < minY) {
99 minY = thirdVertex.
pos.
y;
101 if (thirdVertex.
pos.
z < minZ) {
102 minZ = thirdVertex.
pos.
z;
105 if (thirdVertex.
pos.
x > maxX) {
106 maxX = firstVertex.
pos.
x;
108 if (thirdVertex.
pos.
y > maxY) {
109 maxY = firstVertex.
pos.
y;
111 if (thirdVertex.
pos.
z > maxZ) {
112 maxZ = firstVertex.
pos.
z;
115 mesh.getTexCoords().addAll(0);
116 mesh.getTexCoords().addAll(0);
118 mesh.getFaces().addAll(counter,
static MeshContainer meshFromPolygon(Polygon... poly)
static MeshContainer meshFromPolygon(List< Polygon > poly)
static Vector3d y(double y)
static Vector3d z(double z)
static Vector3d x(double x)