public void validate(Mesh mesh) {
if (!(mesh instanceof TriangleMesh)) {
throw new AssertionError("Mesh is not TriangleMesh: " + mesh.getClass() + ", mesh = " + mesh);
}
TriangleMesh tMesh = (TriangleMesh) mesh;
int numPoints = tMesh.getPoints().size() / tMesh.getPointElementSize();
int numTexCoords = tMesh.getTexCoords().size() / tMesh.getTexCoordElementSize();
int numFaces = tMesh.getFaces().size() / tMesh.getFaceElementSize();
if (numPoints == 0 || numPoints * tMesh.getPointElementSize() != tMesh.getPoints().size()) {
throw new AssertionError("Points array size is not correct: " + tMesh.getPoints().size());
}
if (numTexCoords == 0 || numTexCoords * tMesh.getTexCoordElementSize() != tMesh.getTexCoords().size()) {
throw new AssertionError("TexCoords array size is not correct: " + tMesh.getPoints().size());
}
if (numFaces == 0 || numFaces * tMesh.getFaceElementSize() != tMesh.getFaces().size()) {
throw new AssertionError("Faces array size is not correct: " + tMesh.getPoints().size());
}
if (numFaces != tMesh.getFaceSmoothingGroups().size() && tMesh.getFaceSmoothingGroups().size() > 0) {
throw new AssertionError("FaceSmoothingGroups array size is not correct: " + tMesh.getPoints().size() + ", numFaces = " + numFaces);
}
ObservableIntegerArray faces = tMesh.getFaces();
for (int i = 0; i < faces.size(); i += 2) {
int pIndex = faces.get(i);
if (pIndex < 0 || pIndex > numPoints) {
throw new AssertionError("Incorrect point index: " + pIndex + ", numPoints = " + numPoints);
}
int tcIndex = faces.get(i + 1);
if (tcIndex < 0 || tcIndex > numTexCoords) {
throw new AssertionError("Incorrect texCoord index: " + tcIndex + ", numTexCoords = " + numTexCoords);
}
}
// System.out.println("Validation successfull of " + mesh);
}
Validator.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:FX3DAndroid
作者:
评论列表
文章目录