Skip to content

Commit

Permalink
Merge pull request #14 from Gaia3D/develop
Browse files Browse the repository at this point in the history
Release mago-3d-tiler 1.5.5
  • Loading branch information
znkim authored Mar 28, 2024
2 parents 6c5f273 + 36cb1a1 commit 97e630b
Show file tree
Hide file tree
Showing 112 changed files with 3,921 additions and 702 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion core/build.gradle → common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = 'com.gaia3d'
version "1.4.1"
version "1.4.4"

project.ext.lwjglVersion = "3.3.2"
switch ( org.gradle.internal.os.OperatingSystem.current() ) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions common/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'mago-common'
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ public Path writeFile(Path path, int serial) {
File inputPathFile = new File(imagePath);
inputPathFile = ImageUtils.getChildFile(parentPath.toFile(), diffusePath);
File outputPathFile = outputPath.toFile();
if (!outputPathFile.exists()) {

if (inputPathFile == null) {
log.error("Texture Image Path is null. {}", imagePath);
} else if (outputPathFile.exists()) {
log.error("already outputPathFile exists");
} else {
FileUtils.copyFile(inputPathFile, outputPath.toFile());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public double getLongestDistance() {
return Math.sqrt(volume.x * volume.x + volume.y * volume.y + volume.z * volume.z);
}

public boolean contains(GaiaBoundingBox boundingBox) {
return minX <= boundingBox.minX && minY <= boundingBox.minY && minZ <= boundingBox.minZ
&& maxX >= boundingBox.maxX && maxY >= boundingBox.maxY && maxZ >= boundingBox.maxZ;
}

public GaiaBoundingBox clone() {
return new GaiaBoundingBox(minX, minY, minZ, maxX, maxY, maxZ, isInit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public Vector2d getRightTopPoint() {
return (maxX * maxY);
}*/

public Vector2d getCenter() {
return new Vector2d((minX + maxX) / 2, (minY + maxY) / 2);
}

public double getArea() {
return ((maxX - minX) * (maxY - minY));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,27 @@ public class GaiaPointCloud implements Serializable {
private GaiaBoundingBox gaiaBoundingBox = new GaiaBoundingBox();
List<GaiaVertex> vertices = new ArrayList<>();

// Quarter based on the bounding box
public List<GaiaPointCloud> distribute() {
double minX = gaiaBoundingBox.getMinX();
double minY = gaiaBoundingBox.getMinY();
double minZ = gaiaBoundingBox.getMinZ();
double maxX = gaiaBoundingBox.getMaxX();
double maxY = gaiaBoundingBox.getMaxY();
double maxZ = gaiaBoundingBox.getMaxZ();

double offsetX = maxX - minX;
double offsetY = maxY - minY;
double offsetZ = maxZ - minZ;

if (offsetZ < offsetX || offsetZ < offsetY) {
return distributeQuad();
} else {
return distributeOct();
}
}

// Quarter based on the bounding box
public List<GaiaPointCloud> distributeQuad() {
List<GaiaPointCloud> pointClouds = new ArrayList<>();

GaiaBoundingBox gaiaBoundingBoxA = new GaiaBoundingBox();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@NoArgsConstructor
@AllArgsConstructor
public class GaiaMesh implements Serializable {
private ArrayList<GaiaPrimitive> primitives = new ArrayList<>();
private List<GaiaPrimitive> primitives = new ArrayList<>();

public GaiaBoundingBox getBoundingBox(Matrix4d transform) {
GaiaBoundingBox boundingBox = null;
Expand All @@ -42,6 +42,14 @@ public GaiaBoundingBox getBoundingBox(Matrix4d transform) {
return boundingBox;
}

public long getTriangleCount() {
long count = 0;
for (GaiaPrimitive primitive : primitives) {
count += getIndicesCount() / 3;
}
return count;
}

public int[] getIndices() {
int[] totalIndices = new int[getIndicesCount()];
int index = 0;
Expand Down Expand Up @@ -221,7 +229,7 @@ public void translate(Vector3d translation) {

public void clear() {
this.primitives.forEach(GaiaPrimitive::clear);
this.primitives.clear();
//this.primitives.clear();
}

public GaiaMesh clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ public void toGaiaBufferSets(List<GaiaBufferDataSet> bufferSets, Matrix4d parent
}
}

public long getTriangleCount() {
long count = 0;
for (GaiaMesh mesh : this.getMeshes()) {
count += mesh.getTriangleCount();
}
for (GaiaNode child : this.getChildren()) {
count += child.getTriangleCount();
}
return count;
}

public void translate(Vector3d translation) {
for (GaiaMesh mesh : this.getMeshes()) {
mesh.translate(translation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,14 @@ public void translate(Vector3d translation) {
}

public void clear() {
this.vertices.forEach(GaiaVertex::clear);
this.surfaces.forEach(GaiaSurface::clear);
this.vertices.clear();
this.surfaces.clear();
if (this.vertices != null) {
this.vertices.forEach(GaiaVertex::clear);
this.vertices.clear();
}
if (this.surfaces != null) {
this.surfaces.forEach(GaiaSurface::clear);
this.surfaces.clear();
}
}

public GaiaPrimitive clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,12 @@ public GaiaScene clone() {
clone.setGaiaBoundingBox(this.gaiaBoundingBox);
return clone;
}

public long calcTriangleCount() {
long triangleCount = 0;
for (GaiaNode node : this.nodes) {
triangleCount += node.getTriangleCount();
}
return triangleCount;
}
}
66 changes: 66 additions & 0 deletions common/src/main/java/com/gaia3d/basic/types/FormatType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.gaia3d.basic.types;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
* Enum for the different types of formats that can be used in the application.
* Each format has a corresponding extension.
* The extension is used to determine the type of the file.
* The extension is also used to determine the type of the file that is being downloaded.
* @Author znkim
* @Since 1.0.1
* @See GaiaSet
*/
@Getter
@RequiredArgsConstructor
public enum FormatType {
// 3D Formats
KML("kml", "kml", false),
GLTF("gltf", "glb", false),
GLB("glb", "gltf", false),
COLLADA("dae", "dae", true),
MAX_3DS("3ds", "3ds",false),
MAX_ASE("ase", "ase", false),
FBX("fbx", "fbx", true),
OBJ("obj","obj", false),
IFC("ifc", "ifc",false),
CITYGML("gml","xml", false),
INDOORGML("gml","xml", false),
MODO("lxo", "lxo", false),
LWO("lwo", "lwo", false),
LWS("lws", "lws", false),
DirectX("x", "x", false),
// 2D Formats,
SHP("shp", "shp",false),
GEOJSON("geojson", "json", false),
//JSON("json", "", false),
LAS("las", "laz", false),
LAZ("laz", "las", false),
// OUTPUT Formats
B3DM("b3dm", "gltf", true),
I3DM("i3dm", "gltf",true),
PNTS("pnts", "gltf",true),
TEMP("tmp", "tmp", false);

private final String extension;
private final String subExtension;
private final boolean yUpAxis;

public static FormatType fromExtension(String extension) {
if (extension == null || extension.isEmpty()) {
return null;
}
return Arrays.stream(FormatType.values())
.filter((type) -> {
boolean compareName = type.name().equalsIgnoreCase(extension);
boolean compareExtension = type.getExtension().equals(extension.toLowerCase());
boolean compareSubExtension = type.getSubExtension().equals(extension.toLowerCase());
return compareName || compareExtension || compareSubExtension;
})
.findFirst()
.orElse(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ImageResizer {
public BufferedImage resizeImageGraphic2D(BufferedImage originalImage, int width, int height) {
BufferedImage outputImage = new BufferedImage(width, height, originalImage.getType());
Graphics2D graphics2D = outputImage.createGraphics();
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); // RenderingHints.VALUE_INTERPOLATION_BILINEAR
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); // RenderingHints.VALUE_INTERPOLATION_BILINEAR
graphics2D.setComposite(AlphaComposite.Src);
graphics2D.drawImage(originalImage, 0, 0, width, height, null);
return outputImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.Optional;
import java.util.Vector;
import java.util.stream.Collectors;

@Slf4j
public class StringUtils {
Expand Down Expand Up @@ -53,4 +54,12 @@ public static Optional<String> getExtensionByStringHandling(String filename) {
// https://www.baeldung.com/java-file-extension
return Optional.ofNullable(filename).filter(f -> f.contains(".")).map(f -> f.substring(filename.lastIndexOf(".") + 1));
}

public static String convertUTF8(String ascii) {
return ascii.chars()
.mapToObj(c -> (char) c)
.map(c -> c < 128 ? c : '_')
.map(String::valueOf)
.collect(Collectors.joining());
}
}
71 changes: 71 additions & 0 deletions common/src/main/java/com/gaia3d/util/VectorUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.gaia3d.util;

import com.gaia3d.basic.geometry.GaiaBoundingBox;
import com.gaia3d.basic.geometry.GaiaRectangle;
import lombok.extern.slf4j.Slf4j;
import org.joml.Vector2d;
import org.joml.Vector3d;

@Slf4j
public class VectorUtils {
public static double cross(Vector2d v1, Vector2d v2, Vector2d v3) {
Vector2d v1v2 = v1.sub(v2, new Vector2d());
v1v2.normalize();
Vector2d v2v3 = v2.sub(v3, new Vector2d());
v2v3.normalize();
return cross(v1v2, v2v3);
}

public static double cross(Vector2d a, Vector2d b) {
return (a.x * b.y) - (a.y * b.x);
}

public static boolean isIntersection(Vector2d a, Vector2d b, Vector2d u, Vector2d v) {
GaiaRectangle rect1 = new GaiaRectangle(a, b);
GaiaRectangle rect2 = new GaiaRectangle(u, v);
if (!rect1.intersects(rect2, 0.0)) {
// Intersection check with bounding box
return false;
} else if (a.equals(u) && b.equals(v) || a.equals(v) && b.equals(u)){
// Same line case;
return true;
} else if (a.equals(u) || a.equals(v) || b.equals(u) || b.equals(v)) {
// Same point case;
return false;
}


double cross1 = cross(a, b, u);
double cross2 = cross(a, b, v);
if (cross1 == 0 && cross2 == 0) {
return true;
}
boolean isIntersectA = cross1 * cross2 < 0;

double cross3 = cross(u, v, a);
double cross4 = cross(u, v, b);
if (cross3 == 0 && cross4 == 0) {
return true;
}
boolean isIntersectB = cross3 * cross4 < 0;
return isIntersectA == isIntersectB;
}

public static boolean isIntersection(Vector2d v1, Vector2d v2, Vector2d v3) {
if (v1.equals(v3) || v2.equals(v3)) {
return false;
}
double cross1 = cross(v1, v2, v3);
return cross1 == 0;
}

public static double calcAngle(Vector2d a, Vector2d b, Vector2d c) {
Vector2d v1 = new Vector2d();
Vector2d v2 = new Vector2d();
b.sub(a, v1);
c.sub(b, v2);
v1.normalize();
v2.normalize();
return Math.toDegrees(v1.angle(v2));
}
}
1 change: 0 additions & 1 deletion core/settings.gradle

This file was deleted.

59 changes: 0 additions & 59 deletions core/src/main/java/com/gaia3d/basic/types/FormatType.java

This file was deleted.

Loading

0 comments on commit 97e630b

Please sign in to comment.