32 package eu.mihosoft.vrl.v3d.ext.openjfx.importers;
34 import javafx.collections.ObservableIntegerArray;
35 import javafx.scene.Node;
36 import javafx.scene.Parent;
37 import javafx.scene.shape.Mesh;
38 import javafx.scene.shape.MeshView;
39 import javafx.scene.shape.TriangleMesh;
53 if (node instanceof MeshView) {
54 MeshView meshView = (MeshView) node;
56 }
else if (node instanceof Parent) {
57 for (Node child : ((Parent) node).getChildrenUnmodifiable()) {
69 if (!(mesh instanceof TriangleMesh)) {
70 throw new AssertionError(
"Mesh is not TriangleMesh: " + mesh.getClass() +
", mesh = " + mesh);
72 TriangleMesh tMesh = (TriangleMesh) mesh;
73 int numPoints = tMesh.getPoints().size() / tMesh.getPointElementSize();
74 int numTexCoords = tMesh.getTexCoords().size() / tMesh.getTexCoordElementSize();
75 int numFaces = tMesh.getFaces().size() / tMesh.getFaceElementSize();
76 if (numPoints == 0 || numPoints * tMesh.getPointElementSize() != tMesh.getPoints().size()) {
77 throw new AssertionError(
"Points array size is not correct: " + tMesh.getPoints().size());
79 if (numTexCoords == 0 || numTexCoords * tMesh.getTexCoordElementSize() != tMesh.getTexCoords().size()) {
80 throw new AssertionError(
"TexCoords array size is not correct: " + tMesh.getPoints().size());
82 if (numFaces == 0 || numFaces * tMesh.getFaceElementSize() != tMesh.getFaces().size()) {
83 throw new AssertionError(
"Faces array size is not correct: " + tMesh.getPoints().size());
85 if (numFaces != tMesh.getFaceSmoothingGroups().size() && tMesh.getFaceSmoothingGroups().size() > 0) {
86 throw new AssertionError(
"FaceSmoothingGroups array size is not correct: " + tMesh.getPoints().size() +
", numFaces = " + numFaces);
88 ObservableIntegerArray faces = tMesh.getFaces();
89 for (
int i = 0; i < faces.size(); i += 2) {
90 int pIndex = faces.get(i);
91 if (pIndex < 0 || pIndex > numPoints) {
92 throw new AssertionError(
"Incorrect point index: " + pIndex +
", numPoints = " + numPoints);
94 int tcIndex = faces.get(i + 1);
95 if (tcIndex < 0 || tcIndex > numTexCoords) {
96 throw new AssertionError(
"Incorrect texCoord index: " + tcIndex +
", numTexCoords = " + numTexCoords);