Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.shade.decima.ui.data.viewer.model.dmf;

import com.shade.decima.ui.data.viewer.model.dmf.nodes.DMFNode;
import com.shade.util.NotNull;

public record DMFInstanceSource(@NotNull String uuid, @NotNull DMFNode rootNode) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Base64;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;

public class DMFInternalBuffer extends DMFBuffer {
Expand All @@ -20,7 +21,8 @@ public DMFInternalBuffer(@NotNull String name, @NotNull DataProvider provider) {
@Override
public JsonObject serialize(@NotNull DMFExporter exporter, @NotNull JsonSerializationContext context) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (OutputStream os = new DeflaterOutputStream(baos)) {
Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION);
try (OutputStream os = new DeflaterOutputStream(baos,deflater)) {
try (InputStream is = provider.openInputStream()) {
is.transferTo(os);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shade.decima.ui.data.viewer.model.dmf;

import com.shade.decima.ui.data.viewer.model.dmf.nodes.DMFNode;
import com.shade.util.NotNull;
import com.shade.util.Nullable;

Expand All @@ -17,7 +18,7 @@ public class DMFSceneFile {
public final List<DMFBuffer> buffers;
public final List<DMFMaterial> materials;
public final List<DMFTexture> textures;
public final List<DMFNode> instances;
public final List<DMFInstanceSource> instances;

public DMFSceneFile(int version) {
metadata = new DMFSceneMetaData("%s (%s, %s)".formatted(APP_TITLE, APP_VERSION, BUILD_COMMIT), version);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.shade.decima.ui.data.viewer.model.dmf.nodes;

import com.shade.decima.ui.data.viewer.model.dmf.DMFTransform;
import com.shade.util.NotNull;

public class DMFAttachment extends DMFNode {
public final String boneName;

public DMFAttachment(@NotNull String name, @NotNull String boneName, @NotNull DMFTransform transform) {
super(name, DMFNodeType.ATTACHMENT);
this.boneName = boneName;
this.transform = transform;
}

@Override
public boolean isEmpty() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shade.decima.ui.data.viewer.model.dmf;
package com.shade.decima.ui.data.viewer.model.dmf.nodes;

import com.shade.util.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shade.decima.ui.data.viewer.model.dmf;
package com.shade.decima.ui.data.viewer.model.dmf.nodes;


import com.shade.util.NotNull;
Expand All @@ -10,4 +10,9 @@ public DMFInstance(@NotNull String name, int instanceId) {
super(name, DMFNodeType.INSTANCE);
this.instanceId = instanceId;
}

@Override
public boolean isEmpty() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shade.decima.ui.data.viewer.model.dmf;
package com.shade.decima.ui.data.viewer.model.dmf.nodes;

import com.shade.util.NotNull;

Expand All @@ -17,4 +17,9 @@ public void addLod(@NotNull DMFNode model, float distance) {
}

public record Lod(@NotNull DMFNode model, int id, float distance) {}

@Override
public boolean isEmpty() {
return super.isEmpty() && lods.isEmpty();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.shade.decima.ui.data.viewer.model.dmf.nodes;

import com.shade.util.NotNull;
import org.joml.Vector2ic;
import org.joml.Vector3fc;

import java.util.HashMap;
import java.util.Map;

public class DMFMapTile extends DMFNode {
public Vector2ic gridCoordinate;
public Vector3fc bboxMin;
public Vector3fc bboxMax;
public Map<String, DMFMapTile.TileTextureInfo> textures = new HashMap<>();

public DMFMapTile(@NotNull String name) {
super(name, DMFNodeType.MAP_TILE);
}

public record TileTextureInfo(int textureId, @NotNull Map<String, TileTextureChannelInfo> channels) {
@Override
public int textureId() {
return textureId;
}

@Override
public Map<String, TileTextureChannelInfo> channels() {
return channels;
}
}

public record TileTextureChannelInfo(@NotNull String usage, float minRange, float maxRange) {
@Override
public String usage() {
return usage;
}

@Override
public float minRange() {
return minRange;
}

@Override
public float maxRange() {
return maxRange;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.shade.decima.ui.data.viewer.model.dmf;
package com.shade.decima.ui.data.viewer.model.dmf.nodes;


import com.shade.decima.ui.data.viewer.model.dmf.DMFMesh;
import com.shade.decima.ui.data.viewer.model.dmf.DMFSceneFile;
import com.shade.decima.ui.data.viewer.model.dmf.DMFSkeleton;
import com.shade.util.NotNull;

public class DMFModel extends DMFNode {
Expand All @@ -17,4 +20,9 @@ public void setSkeleton(@NotNull DMFSkeleton skeleton, @NotNull DMFSceneFile sce
scene.skeletons.add(skeleton);
skeletonId = scene.skeletons.indexOf(skeleton);
}

@Override
public boolean isEmpty() {
return super.isEmpty() && (mesh == null || mesh.primitives.isEmpty());
}
Comment thread
REDxEYE marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shade.decima.ui.data.viewer.model.dmf;
package com.shade.decima.ui.data.viewer.model.dmf.nodes;

import com.shade.util.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.shade.decima.ui.data.viewer.model.dmf;
package com.shade.decima.ui.data.viewer.model.dmf.nodes;

import com.shade.decima.ui.data.viewer.model.dmf.DMFCollection;
import com.shade.decima.ui.data.viewer.model.dmf.DMFSceneFile;
import com.shade.decima.ui.data.viewer.model.dmf.DMFTransform;
import com.shade.util.NotNull;

import java.util.ArrayList;
Expand All @@ -25,4 +28,8 @@ protected DMFNode(@NotNull String name, @NotNull DMFNodeType type) {
public void addToCollection(@NotNull DMFCollection collection, @NotNull DMFSceneFile scene) {
collectionIds.add(scene.collections.indexOf(collection));
}

public boolean isEmpty() {
return children.isEmpty();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shade.decima.ui.data.viewer.model.dmf;
package com.shade.decima.ui.data.viewer.model.dmf.nodes;


public enum DMFNodeType {
Expand All @@ -9,4 +9,5 @@ public enum DMFNodeType {
MODEL,
SKINNED_MODEL,
ATTACHMENT,
MAP_TILE,
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ public Quaternion(@NotNull double[] xyzw) {
this(xyzw[0], xyzw[1], xyzw[2], xyzw[3]);
}

@NotNull
public static Quaternion identity() {
return new Quaternion(0, 0, 0, 1);
}

@NotNull
public Quaternion add(@NotNull Quaternion other) {
return new Quaternion(x() + other.x(), y() + other.y(), z() + other.y(), w() + other.w());
Expand Down