Skip to content

Commit 3a9f40f

Browse files
committed
added gltf support.
1 parent 6595021 commit 3a9f40f

11 files changed

Lines changed: 116 additions & 6 deletions

File tree

src/main/java/com/ss/editor/FileExtensions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ public interface FileExtensions {
3737
*/
3838
String JAVA_CLASS = "class";
3939

40-
/**
41-
* The constant POST_FILTER_VIEW.
42-
*/
43-
String POST_FILTER_VIEW = "pfv";
4440

4541
/**
4642
* The constant IMAGE_PNG.
@@ -125,6 +121,10 @@ public interface FileExtensions {
125121
* The constant MODEL_FBX.
126122
*/
127123
String MODEL_FBX = "fbx";
124+
/**
125+
* The constant MODEL_GLTF.
126+
*/
127+
String MODEL_GLTF = "gltf";
128128
/**
129129
* The constant MODEL_OBJ.
130130
*/

src/main/java/com/ss/editor/Messages.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ public class Messages {
430430
* The constant BLEND_TO_J3O_FILE_CONVERTER_DESCRIPTION.
431431
*/
432432
public static final String BLEND_TO_J3O_FILE_CONVERTER_DESCRIPTION;
433+
/**
434+
* The constant GLTF_TO_J3O_FILE_CONVERTER_DESCRIPTION.
435+
*/
436+
public static final String GLTF_TO_J3O_FILE_CONVERTER_DESCRIPTION;
433437
/**
434438
* The constant FBX_TO_J3O_FILE_CONVERTER_DESCRIPTION.
435439
*/
@@ -2427,6 +2431,7 @@ public class Messages {
24272431
SETTINGS_DIALOG_ENVS_FOLDER_CHOOSER_TITLE = bundle.getString("SettingsDialogEnvsFolderChooserTitle");
24282432

24292433
BLEND_TO_J3O_FILE_CONVERTER_DESCRIPTION = bundle.getString("BlendToJ3oFileConverterDescription");
2434+
GLTF_TO_J3O_FILE_CONVERTER_DESCRIPTION = bundle.getString("GLTFToJ3oFileConverterDescription");
24302435
FBX_TO_J3O_FILE_CONVERTER_DESCRIPTION = bundle.getString("FBXToJ3oFileConverterDescription");
24312436
OBJ_TO_J3O_FILE_CONVERTER_DESCRIPTION = bundle.getString("ObjToJ3oFileConverterDescription");
24322437
SCENE_TO_J3O_FILE_CONVERTER_DESCRIPTION = bundle.getString("SceneToJ3oFileConverterDescription");

src/main/java/com/ss/editor/file/converter/FileConverterRegistry.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ private FileConverterRegistry() {
4949
register(SceneToJ3oFileConverter.DESCRIPTION);
5050
register(MeshXmlToJ3oFileConverter.DESCRIPTION);
5151
register(XBufToJ3oFileConverter.DESCRIPTION);
52+
register(GLTFToJ3oFileConverter.DESCRIPTION);
5253
}
5354

5455
/**

src/main/java/com/ss/editor/file/converter/impl/AbstractModelFileConverter.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ private void convert(@NotNull final Path source, @NotNull final ModelConverterDi
6666
final EditorFXScene scene = JFX_APPLICATION.getScene();
6767
scene.incrementLoading();
6868

69-
EXECUTOR_MANAGER.addBackgroundTask(() -> convertImpl(source, dialog));
69+
EXECUTOR_MANAGER.addBackgroundTask(() -> {
70+
try {
71+
convertImpl(source, dialog);
72+
} catch (final Exception e) {
73+
EditorUtil.handleException(LOGGER, this, e);
74+
EXECUTOR_MANAGER.addFXTask(scene::decrementLoading);
75+
}
76+
});
7077
}
7178

7279
/**
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.ss.editor.file.converter.impl;
2+
3+
import com.ss.editor.FileExtensions;
4+
import com.ss.editor.Messages;
5+
import com.ss.editor.file.converter.FileConverterDescription;
6+
import com.ss.rlib.util.array.Array;
7+
import com.ss.rlib.util.array.ArrayFactory;
8+
import org.jetbrains.annotations.NotNull;
9+
10+
/**
11+
* The implementation of {@link AbstractFileConverter} to convert .glft file to .j3o.
12+
*
13+
* @author JavaSaBr
14+
*/
15+
public class GLTFToJ3oFileConverter extends AbstractModelFileConverter {
16+
17+
@NotNull
18+
private static final Array<String> EXTENSIONS = ArrayFactory.newArray(String.class);
19+
20+
static {
21+
EXTENSIONS.add(FileExtensions.MODEL_GLTF);
22+
EXTENSIONS.asUnsafe().trimToSize();
23+
}
24+
25+
/**
26+
* The constant DESCRIPTION.
27+
*/
28+
@NotNull
29+
public static final FileConverterDescription DESCRIPTION = new FileConverterDescription();
30+
31+
static {
32+
DESCRIPTION.setDescription(Messages.GLTF_TO_J3O_FILE_CONVERTER_DESCRIPTION);
33+
DESCRIPTION.setConstructor(GLTFToJ3oFileConverter::new);
34+
DESCRIPTION.setExtensions(EXTENSIONS);
35+
}
36+
37+
private GLTFToJ3oFileConverter() {
38+
}
39+
40+
@NotNull
41+
@Override
42+
protected Array<String> getAvailableExtensions() {
43+
return EXTENSIONS;
44+
}
45+
46+
@NotNull
47+
@Override
48+
public String getTargetExtension() {
49+
return FileExtensions.JME_OBJECT;
50+
}
51+
}

src/main/java/com/ss/editor/manager/FileIconManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public class FileIconManager {
8080
EXTENSION_TO_CONTENT_TYPE.put(FileExtensions.JME_SCENE, "sse");
8181
EXTENSION_TO_CONTENT_TYPE.put(FileExtensions.JME_MATERIAL, "text");
8282
EXTENSION_TO_CONTENT_TYPE.put(FileExtensions.JME_MATERIAL_DEFINITION, "text");
83+
EXTENSION_TO_CONTENT_TYPE.put(FileExtensions.MODEL_GLTF, "cube");
8384

8485
EXTENSION_TO_CONTENT_TYPE.put("obj", "x-office-drawing");
8586
EXTENSION_TO_CONTENT_TYPE.put("blend", "application-x-blender");

src/main/resources/credits/icons.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@ ui/icons/svg/lantern.svg icon made by http://www.flaticon.com/authors/freepik fr
7272
ui/icons/svg/brightness.svg icon made by http://www.flaticon.com/authors/those-icons from www.flaticon.com
7373
ui/icons/svg/picture.svg icon made by http://www.flaticon.com/authors/madebyoliver from www.flaticon.com
7474
ui/icons/svg/document.svg icon made by http://www.flaticon.com/authors/madebyoliver from www.flaticon.com
75-
ui/icons/svg/plug-silhouette.svg icon made by http://www.flaticon.com/authors/freepik from www.flaticon.com
75+
ui/icons/svg/plug-silhouette.svg icon made by http://www.flaticon.com/authors/freepik from www.flaticon.com
76+
ui/icons/filetypes/cube.svg icon made by https://www.flaticon.com/authors/madebyoliver from www.flaticon.com

src/main/resources/messages/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ SettingsDialogEnvsFolderLabel=Environment folder
115115
SettingsDialogEnvsFolderChooserTitle=Select a folder with environment textures
116116
117117
BlendToJ3oFileConverterDescription=Convert from .blend to .j3o
118+
GLTFToJ3oFileConverterDescription=Convert from .gltf to .j3o
118119
FBXToJ3oFileConverterDescription=Convert from .fbx to .j3o
119120
ObjToJ3oFileConverterDescription=Convert from .obj to .j3o
120121
SceneToJ3oFileConverterDescription=Convert from .scene to .j3o

src/main/resources/messages/messages_de.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ SettingsDialogEnvsFolderLabel=Verzeichnis mit Umgebungstexturen
115115
SettingsDialogEnvsFolderChooserTitle=Wählen Sie Verzeichnis mit Umgebungstexturen
116116

117117
BlendToJ3oFileConverterDescription=.blend zu .j3o konvertieren
118+
GLTFToJ3oFileConverterDescription=Convert from .gltf to .j3o
118119
FBXToJ3oFileConverterDescription=.fbx zu .j3o konvertieren
119120
ObjToJ3oFileConverterDescription=.obj zu .j3o konvertieren
120121
SceneToJ3oFileConverterDescription=.scene zu .j3o konvertieren

src/main/resources/messages/messages_ru.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ SettingsDialogEnvsFolderLabel=Папка текст. окруж.
116116
SettingsDialogEnvsFolderChooserTitle=Выберите папку с текстурами окружения
117117
118118
BlendToJ3oFileConverterDescription=Конверитровать .blend в .j3o
119+
GLTFToJ3oFileConverterDescription=Конверитровать .gltf в .j3o
119120
FBXToJ3oFileConverterDescription=Конверитровать .fbx в .j3o
120121
ObjToJ3oFileConverterDescription=Конверитровать .obj в .j3o
121122
SceneToJ3oFileConverterDescription=Конверитровать .scene в .j3o

0 commit comments

Comments
 (0)