Skip to content

Commit 68e8926

Browse files
committed
Finish import_wizard
2 parents d6184f7 + ab2b462 commit 68e8926

File tree

45 files changed

+1244
-438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1244
-438
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ dependencies {
125125
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
126126

127127
// extensions
128-
compile ('com.github.JavaSaBr:jmonkeybuilder-extension:1.8.0') {
128+
compile ('com.github.JavaSaBr:jmonkeybuilder-extension:1.9.3') {
129129
exclude group: 'org.jmonkeyengine'
130130
}
131131
compile ('com.github.JavaSaBr:tonegodemitter:2.4.0') {
38 Bytes
Binary file not shown.

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jme3.environment.EnvironmentCamera;
1414
import com.jme3.environment.LightProbeFactory;
1515
import com.jme3.environment.generation.JobProgressAdapter;
16+
import com.jme3.environment.util.EnvMapUtils;
1617
import com.jme3.font.BitmapFont;
1718
import com.jme3.light.LightList;
1819
import com.jme3.light.LightProbe;
@@ -32,6 +33,8 @@
3233
import com.ss.editor.analytics.google.GAnalytics;
3334
import com.ss.editor.annotation.FromAnyThread;
3435
import com.ss.editor.annotation.JMEThread;
36+
import com.ss.editor.asset.locator.FileSystemAssetLocator;
37+
import com.ss.editor.asset.locator.FolderAssetLocator;
3538
import com.ss.editor.config.Config;
3639
import com.ss.editor.config.EditorConfig;
3740
import com.ss.editor.executor.impl.JMEThreadExecutor;
@@ -275,6 +278,7 @@ public void simpleInitApp() {
275278

276279
final AssetManager assetManager = getAssetManager();
277280
assetManager.registerLocator("", FolderAssetLocator.class);
281+
assetManager.registerLocator("", FileSystemAssetLocator.class);
278282
assetManager.addAssetEventListener(EditorConfig.getInstance());
279283

280284
final AudioRenderer audioRenderer = getAudioRenderer();
@@ -468,8 +472,8 @@ private void createLightProbes() {
468472
return;
469473
}
470474

471-
lightProbe = makeProbe(environmentCamera, rootNode, EMPTY_JOB_ADAPTER);
472-
previewLightProbe = makeProbe(previewEnvironmentCamera, previewNode, EMPTY_JOB_ADAPTER);
475+
lightProbe = makeProbe(environmentCamera, rootNode, EnvMapUtils.GenerationType.Fast, EMPTY_JOB_ADAPTER);
476+
previewLightProbe = makeProbe(previewEnvironmentCamera, previewNode, EnvMapUtils.GenerationType.Fast, EMPTY_JOB_ADAPTER);
473477

474478
BoundingSphere bounds = (BoundingSphere) lightProbe.getBounds();
475479
bounds.setRadius(100);
@@ -497,7 +501,7 @@ public void updateLightProbe(@NotNull final JobProgressAdapter<LightProbe> progr
497501
return;
498502
}
499503

500-
LightProbeFactory.updateProbe(lightProbe, environmentCamera, rootNode, progressAdapter);
504+
LightProbeFactory.updateProbe(lightProbe, environmentCamera, rootNode, EnvMapUtils.GenerationType.Fast, progressAdapter);
501505
}
502506

503507
/**
@@ -552,7 +556,7 @@ public void updatePreviewLightProbe(@NotNull final JobProgressAdapter<LightProbe
552556
return;
553557
}
554558

555-
LightProbeFactory.updateProbe(lightProbe, environmentCamera, previewNode, progressAdapter);
559+
LightProbeFactory.updateProbe(lightProbe, environmentCamera, previewNode, EnvMapUtils.GenerationType.Fast, progressAdapter);
556560
}
557561

558562
/**

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

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.ss.rlib.util.array.ConcurrentArray;
4343
import javafx.application.Application;
4444
import javafx.application.Platform;
45+
import javafx.beans.value.ChangeListener;
4546
import javafx.collections.ObservableList;
4647
import javafx.scene.image.Image;
4748
import javafx.stage.Stage;
@@ -55,6 +56,7 @@
5556
import java.io.IOException;
5657
import java.io.PrintStream;
5758
import java.nio.file.Paths;
59+
import java.util.Collection;
5860

5961
/**
6062
* The starter of the JavaFX application.
@@ -179,6 +181,36 @@ private static void startJMEApplication(@NotNull final JmeToJFXApplication appli
179181
}
180182
}
181183

184+
/**
185+
* Create a new focus listener.
186+
*
187+
* @return the new focus listener.
188+
*/
189+
@FXThread
190+
private static @NotNull ChangeListener<Boolean> makeFocusedListener() {
191+
return (observable, oldValue, newValue) -> {
192+
193+
final Editor editor = Editor.getInstance();
194+
final Stage stage = notNull(JFXApplication.getStage());
195+
196+
if (newValue || stage.isFocused()) {
197+
editor.setPaused(false);
198+
return;
199+
}
200+
201+
final EditorConfig editorConfig = EditorConfig.getInstance();
202+
if (!editorConfig.isStopRenderOnLostFocus()) {
203+
editor.setPaused(false);
204+
return;
205+
}
206+
207+
final JFXApplication application = JFXApplication.getInstance();
208+
final Window window = ArrayUtils.getInReadLock(application.openedWindows, windows -> windows.search(Window::isFocused));
209+
210+
editor.setPaused(window == null);
211+
};
212+
}
213+
182214
/**
183215
* Start.
184216
*/
@@ -236,7 +268,8 @@ public JFXApplication() {
236268
*/
237269
@FXThread
238270
public void addWindow(@NotNull final Window window) {
239-
ArrayUtils.runInWriteLock(openedWindows, window, Array::add);
271+
window.focusedProperty().addListener(makeFocusedListener());
272+
ArrayUtils.runInWriteLock(openedWindows, window, Collection::add);
240273
}
241274

242275
/**
@@ -418,10 +451,7 @@ private void createSceneProcessor(@NotNull final EditorFXScene scene, @NotNull f
418451
this.sceneProcessor = sceneProcessor;
419452

420453
final Stage stage = notNull(getStage());
421-
stage.focusedProperty().addListener((observable, oldValue, newValue) -> {
422-
final EditorConfig editorConfig = EditorConfig.getInstance();
423-
editor.setPaused(editorConfig.isStopRenderOnLostFocus() && !newValue);
424-
});
454+
stage.focusedProperty().addListener(makeFocusedListener());
425455

426456
Platform.runLater(scene::notifyFinishBuild);
427457
}

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class Messages {
4848
public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE_BY_EXTERNAL_EDITOR;
4949
public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE_BY_SYSTEM_EXPLORER;
5050
public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_RENAME_FILE;
51+
public static final String ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_IMPORT_MODEL;
5152

5253
public static final String FILE_EDITOR_ACTION_SAVE;
5354

@@ -532,6 +533,8 @@ public class Messages {
532533
public static final String SIMPLE_DIALOG_BUTTON_ADD;
533534
public static final String SIMPLE_DIALOG_BUTTON_SAVE;
534535
public static final String SIMPLE_DIALOG_BUTTON_GENERATE;
536+
public static final String SIMPLE_DIALOG_BUTTON_CONVERT;
537+
public static final String SIMPLE_DIALOG_BUTTON_IMPORT;
535538
public static final String SIMPLE_DIALOG_BUTTON_CREATE;
536539
public static final String SIMPLE_DIALOG_BUTTON_APPLY;
537540
public static final String SIMPLE_DIALOG_BUTTON_CANCEL;
@@ -622,6 +625,7 @@ public class Messages {
622625
public static final String CREATE_PARTICLE_EMITTER_QUAD_SHAPE_DIALOG_TITLE;
623626
public static final String CREATE_PARTICLE_EMITTER_TORUS_SHAPE_DIALOG_TITLE;
624627
public static final String CREATE_PARTICLE_EMITTER_TRIANGLE_SHAPE_DIALOG_TITLE;
628+
625629
public static final String EDITING_COMPONENT_BRUSH_SIZE;
626630
public static final String EDITING_COMPONENT_BRUSH_POWER;
627631
public static final String EDITING_COMPONENT_SMOOTHLY;
@@ -643,7 +647,11 @@ public class Messages {
643647
public static final String MODEL_CONVERTER_DIALOG_EXPORT_MATERIALS;
644648
public static final String MODEL_CONVERTER_DIALOG_MATERIAL_FOLDER;
645649
public static final String MODEL_CONVERTER_DIALOG_OVERWRITE_MATERIALS;
646-
public static final String MODEL_CONVERTER_DIALOG_BUTTON_OK;
650+
651+
public static final String IMPORT_MODEL_DIALOG_TITLE;
652+
public static final String IMPORT_MODEL_DIALOG_EXTERNAL_FILE;
653+
public static final String IMPORT_MODEL_DIALOG_TEXTURES_FOLDER;
654+
public static final String IMPORT_MODEL_DIALOG_OVERWRITE_TEXTURES;
647655

648656
public static final String FILE_DELETE_HANDLER_DELETE_MATERIALS;
649657

@@ -716,6 +724,7 @@ public class Messages {
716724
ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE_BY_EXTERNAL_EDITOR = bundle.getString("AssetComponentResourceTreeContextMenuOpenFileByExternalEditor");
717725
ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_OPEN_FILE_BY_SYSTEM_EXPLORER = bundle.getString("AssetComponentResourceTreeContextMenuOpenFileBySystemExplorer");
718726
ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_RENAME_FILE = bundle.getString("AssetComponentResourceTreeContextMenuRenameFile");
727+
ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_IMPORT_MODEL = bundle.getString("AssetComponentResourceTreeContextMenuImportModel");
719728

720729
FILE_EDITOR_ACTION_SAVE = bundle.getString("FileEditorActionSave");
721730

@@ -1204,6 +1213,8 @@ public class Messages {
12041213
SIMPLE_DIALOG_BUTTON_CLOSE = bundle.getString("SimpleDialogButtonClose");
12051214
SIMPLE_DIALOG_BUTTON_YES = bundle.getString("SimpleDialogButtonYes");
12061215
SIMPLE_DIALOG_BUTTON_NO = bundle.getString("SimpleDialogButtonNo");
1216+
SIMPLE_DIALOG_BUTTON_CONVERT = bundle.getString("SimpleDialogConvert");
1217+
SIMPLE_DIALOG_BUTTON_IMPORT = bundle.getString("SimpleDialogImport");
12071218

12081219
EMPTY_MODEL_CREATOR_DESCRIPTION = bundle.getString("EmptyModelCreatorDescription");
12091220
EMPTY_MODEL_CREATOR_TITLE = bundle.getString("EmptyModelCreatorTitle");
@@ -1310,7 +1321,11 @@ public class Messages {
13101321
MODEL_CONVERTER_DIALOG_EXPORT_MATERIALS = bundle.getString("ModelConverterDialogExportMaterials");
13111322
MODEL_CONVERTER_DIALOG_MATERIAL_FOLDER = bundle.getString("ModelConverterDialogMaterialsFolder");
13121323
MODEL_CONVERTER_DIALOG_OVERWRITE_MATERIALS = bundle.getString("ModelConverterDialogOverwriteMaterials");
1313-
MODEL_CONVERTER_DIALOG_BUTTON_OK = bundle.getString("ModelConverterDialogButtonOk");
1324+
1325+
IMPORT_MODEL_DIALOG_TITLE = bundle.getString("ImportModelDialogTitle");
1326+
IMPORT_MODEL_DIALOG_EXTERNAL_FILE = bundle.getString("ImportModelDialogExternalFile");
1327+
IMPORT_MODEL_DIALOG_TEXTURES_FOLDER = bundle.getString("ImportModelDialogTexturesFolder");
1328+
IMPORT_MODEL_DIALOG_OVERWRITE_TEXTURES = bundle.getString("ImportModelDialogOverwriteTextures");
13141329

13151330
FILE_DELETE_HANDLER_DELETE_MATERIALS = bundle.getString("FileDeleteHandlerDeleteMaterials");
13161331

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.ss.editor.asset.locator;
2+
3+
import com.jme3.asset.AssetInfo;
4+
import com.jme3.asset.AssetKey;
5+
import com.jme3.asset.AssetLocator;
6+
import com.jme3.asset.AssetManager;
7+
import com.ss.editor.Editor;
8+
import com.ss.editor.annotation.FromAnyThread;
9+
import com.ss.rlib.util.ArrayUtils;
10+
import com.ss.rlib.util.array.ArrayFactory;
11+
import com.ss.rlib.util.array.ConcurrentArray;
12+
import org.jetbrains.annotations.NotNull;
13+
14+
import java.nio.file.Files;
15+
import java.nio.file.Path;
16+
import java.nio.file.Paths;
17+
import java.util.Collection;
18+
19+
/**
20+
* The implementation of asset locator to use file system as asset folder.
21+
*
22+
* @author JavaSaBr
23+
*/
24+
public class FileSystemAssetLocator implements AssetLocator {
25+
26+
@NotNull
27+
private static final ConcurrentArray<AssetKey<?>> LOCATED_KEYS = ArrayFactory.newConcurrentStampedLockArray(AssetKey.class);
28+
29+
/**
30+
* Clear all located objects from this locator.
31+
*/
32+
@FromAnyThread
33+
public static void clear() {
34+
final long stamp = LOCATED_KEYS.writeLock();
35+
try {
36+
37+
final Editor editor = Editor.getInstance();
38+
final AssetManager assetManager = editor.getAssetManager();
39+
40+
LOCATED_KEYS.forEach(assetManager, (assetKey, manager) -> manager.deleteFromCache(assetKey));
41+
42+
} finally {
43+
LOCATED_KEYS.writeUnlock(stamp);
44+
}
45+
}
46+
47+
@Override
48+
public void setRootPath(@NotNull final String rootPath) {
49+
}
50+
51+
@Override
52+
public AssetInfo locate(@NotNull final AssetManager manager, @NotNull final AssetKey key) {
53+
54+
final Path absoluteFile = Paths.get(key.getName());
55+
if (!Files.exists(absoluteFile)) return null;
56+
57+
ArrayUtils.runInWriteLock(LOCATED_KEYS, key, Collection::add);
58+
59+
return new FolderAssetLocator.PathAssetInfo(manager, key, absoluteFile);
60+
}
61+
}

src/main/java/com/ss/editor/FolderAssetLocator.java renamed to src/main/java/com/ss/editor/asset/locator/FolderAssetLocator.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.ss.editor;
1+
package com.ss.editor.asset.locator;
22

33
import com.jme3.asset.AssetInfo;
44
import com.jme3.asset.AssetKey;
@@ -12,6 +12,7 @@
1212
import java.io.InputStream;
1313
import java.nio.file.Files;
1414
import java.nio.file.Path;
15+
import java.nio.file.Paths;
1516
import java.nio.file.StandardOpenOption;
1617

1718
/**
@@ -21,14 +22,30 @@
2122
*/
2223
public class FolderAssetLocator implements AssetLocator {
2324

25+
@NotNull
26+
private static final ThreadLocal<Boolean> IGNORE_LOCAL = ThreadLocal.withInitial(() -> false);
27+
28+
/**
29+
* Set the flag of ignoring this locator.
30+
*
31+
* @param ignore true if need to ignore this locator.
32+
*/
33+
public static void setIgnore(final boolean ignore) {
34+
IGNORE_LOCAL.set(false);
35+
}
36+
2437
@Override
2538
@JMEThread
2639
public void setRootPath(@NotNull final String rootPath) {
2740
}
2841

2942
@Override
3043
@JMEThread
31-
public AssetInfo locate(final AssetManager manager, final AssetKey key) {
44+
public AssetInfo locate(@NotNull final AssetManager manager, @NotNull final AssetKey key) {
45+
if (IGNORE_LOCAL.get() == Boolean.TRUE) return null;
46+
47+
final Path absoluteFile = Paths.get(key.getName());
48+
if (Files.exists(absoluteFile)) return null;
3249

3350
final EditorConfig editorConfig = EditorConfig.getInstance();
3451
final Path currentAsset = editorConfig.getCurrentAsset();
@@ -41,13 +58,13 @@ public AssetInfo locate(final AssetManager manager, final AssetKey key) {
4158
return new PathAssetInfo(manager, key, resolve);
4259
}
4360

44-
private class PathAssetInfo extends AssetInfo {
61+
public static class PathAssetInfo extends AssetInfo {
4562

4663
@NotNull
4764
private final Path path;
4865

49-
private PathAssetInfo(@NotNull final AssetManager manager, @NotNull final AssetKey key,
50-
@NotNull final Path path) {
66+
public PathAssetInfo(@NotNull final AssetManager manager, @NotNull final AssetKey key,
67+
@NotNull final Path path) {
5168
super(manager, key);
5269
this.path = path;
5370
}

0 commit comments

Comments
 (0)