Skip to content

Commit 9553314

Browse files
committed
implemented working with PBR in the scene editor.
1 parent b4d4086 commit 9553314

File tree

14 files changed

+188
-16
lines changed

14 files changed

+188
-16
lines changed

app.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.11
1+
0.9.12

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ apply plugin: 'idea'
1313
apply plugin: 'org.junit.platform.gradle.plugin'
1414

1515
group = 'com.spaceshift'
16-
version = '0.9.11'
16+
version = '0.9.12'
1717

1818
sourceCompatibility = 1.8
1919
targetCompatibility = 1.8
@@ -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:jme3-spaceshift-extension:1.4.2') {
128+
compile ('com.github.JavaSaBr:jme3-spaceshift-extension:1.5.0') {
129129
exclude group: 'org.jmonkeyengine'
130130
}
131131
compile ('com.github.JavaSaBr:tonegodemitter:2.3.0') {

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

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jme3.environment.LightProbeFactory;
1414
import com.jme3.environment.generation.JobProgressAdapter;
1515
import com.jme3.font.BitmapFont;
16+
import com.jme3.light.LightList;
1617
import com.jme3.light.LightProbe;
1718
import com.jme3.material.Material;
1819
import com.jme3.material.TechniqueDef;
@@ -258,7 +259,7 @@ public Camera getCamera() {
258259
@Override
259260
public void simpleInitApp() {
260261
renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePass);
261-
renderManager.setSinglePassLightBatchSize(5);
262+
renderManager.setSinglePassLightBatchSize(15);
262263

263264
assetManager.registerLoader(XbufLoader.class, FileExtensions.MODEL_XBUF);
264265

@@ -325,7 +326,7 @@ public void simpleInitApp() {
325326
stateManager.attach(previewEnvironmentCamera);
326327
}
327328

328-
createProbe();
329+
createLightProbes();
329330

330331
new EditorThread(new ThreadGroup("JavaFX"), JFXApplication::start, "JavaFX Launch").start();
331332
}
@@ -430,9 +431,9 @@ public FilterPostProcessor getPostProcessor() {
430431
}
431432

432433
/**
433-
* Create the light probe for the PBR render.
434+
* Create the light probes for the PBR render.
434435
*/
435-
private void createProbe() {
436+
private void createLightProbes() {
436437

437438
final EnvironmentCamera environmentCamera = getEnvironmentCamera();
438439
final EnvironmentCamera previewEnvironmentCamera = getPreviewEnvironmentCamera();
@@ -443,7 +444,7 @@ private void createProbe() {
443444

444445
if (environmentCamera.getApplication() == null) {
445446
final JMEThreadExecutor gameThreadExecutor = JMEThreadExecutor.getInstance();
446-
gameThreadExecutor.addToExecute(this::createProbe);
447+
gameThreadExecutor.addToExecute(this::createLightProbes);
447448
return;
448449
}
449450

@@ -465,7 +466,7 @@ private void createProbe() {
465466
*
466467
* @param progressAdapter the progress adapter
467468
*/
468-
public void updateProbe(@NotNull final JobProgressAdapter<LightProbe> progressAdapter) {
469+
public void updateLightProbe(@NotNull final JobProgressAdapter<LightProbe> progressAdapter) {
469470

470471
final LightProbe lightProbe = getLightProbe();
471472
final EnvironmentCamera environmentCamera = getEnvironmentCamera();
@@ -478,12 +479,46 @@ public void updateProbe(@NotNull final JobProgressAdapter<LightProbe> progressAd
478479
LightProbeFactory.updateProbe(lightProbe, environmentCamera, rootNode, progressAdapter);
479480
}
480481

482+
/**
483+
* Disable PBR Light probe.
484+
*/
485+
public void disableLightProbe() {
486+
487+
final LightProbe lightProbe = getLightProbe();
488+
489+
if (lightProbe != null) {
490+
rootNode.removeLight(lightProbe);
491+
}
492+
}
493+
494+
/**
495+
* Enable PBR Light probe.
496+
*/
497+
public void enableLightProbe() {
498+
499+
final LightProbe lightProbe = getLightProbe();
500+
501+
if (lightProbe == null) {
502+
return;
503+
}
504+
505+
final LightList lightList = rootNode.getLocalLightList();
506+
507+
for (int i = 0; i < lightList.size(); i++) {
508+
if (lightList.get(i) == lightProbe) {
509+
return;
510+
}
511+
}
512+
513+
rootNode.addLight(lightProbe);
514+
}
515+
481516
/**
482517
* Update the light probe.
483518
*
484519
* @param progressAdapter the progress adapter
485520
*/
486-
public void updatePreviewProbe(@NotNull final JobProgressAdapter<LightProbe> progressAdapter) {
521+
public void updatePreviewLightProbe(@NotNull final JobProgressAdapter<LightProbe> progressAdapter) {
487522

488523
final LightProbe lightProbe = getPreviewLightProbe();
489524
final EnvironmentCamera environmentCamera = getPreviewEnvironmentCamera();

src/main/java/com/ss/editor/config/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public abstract class Config {
3636
* The constant APP_VERSION.
3737
*/
3838
@NotNull
39-
public static final Version APP_VERSION = new Version("0.9.11");
39+
public static final Version APP_VERSION = new Version("0.9.12");
4040

4141
/**
4242
* The constant STRING_VERSION.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ protected void controlUpdate(final float tpf) {
191191

192192
if (frame == 2) {
193193
final Editor editor = Editor.getInstance();
194-
editor.updatePreviewProbe(probeHandler);
194+
editor.updatePreviewLightProbe(probeHandler);
195195
}
196196

197197
frame++;

src/main/java/com/ss/editor/state/editor/impl/material/MaterialEditor3DState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ private void updateLightEnabledImpl(boolean enabled) {
409409
public void update(float tpf) {
410410
super.update(tpf);
411411

412-
if (frame == 2) EDITOR.updateProbe(probeHandler);
412+
if (frame == 2) EDITOR.updateLightProbe(probeHandler);
413413

414414
final Geometry testQuad = getTestQuad();
415415

src/main/java/com/ss/editor/state/editor/impl/model/ModelEditor3DState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void update(final float tpf) {
165165
final Array<Spatial> customSky = getCustomSky();
166166
customSky.forEach(spatial -> customSkyNode.attachChild(spatial.clone(false)));
167167

168-
EDITOR.updateProbe(probeHandler);
168+
EDITOR.updateLightProbe(probeHandler);
169169
}
170170

171171
frame++;

src/main/java/com/ss/editor/state/editor/impl/scene/SceneEditor3DState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected void redo() {
6666
}
6767

6868
@Override
69-
protected void attachModel(final @NotNull SceneNode model, @NotNull final Node modelNode) {
69+
protected void attachModel(@NotNull final SceneNode model, @NotNull final Node modelNode) {
7070
}
7171

7272
@Override

src/main/java/com/ss/editor/ui/component/editor/impl/scene/AbstractSceneFileEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ private void notifyTransformedImpl(@NotNull final Spatial spatial) {
15081508

15091509
Object toUpdate = spatial;
15101510

1511-
if(spatial instanceof WrapperNode) {
1511+
if (spatial instanceof WrapperNode) {
15121512
toUpdate = ((WrapperNode) spatial).getWrappedObject();
15131513
}
15141514

src/main/java/com/ss/editor/ui/component/editor/impl/scene/SceneFileEditor.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,20 @@ public void notifyChangedFilter(@NotNull final SceneFilter sceneFilter) {
685685
getFilterList().fill(getCurrentModel());
686686
}
687687

688+
@FXThread
689+
@Override
690+
public void notifyHided() {
691+
super.notifyHided();
692+
EXECUTOR_MANAGER.addJMETask(EDITOR::enableLightProbe);
693+
}
694+
695+
@FXThread
696+
@Override
697+
public void notifyShowed() {
698+
super.notifyShowed();
699+
EXECUTOR_MANAGER.addJMETask(EDITOR::disableLightProbe);
700+
}
701+
688702
@Override
689703
public String toString() {
690704
return "SceneFileEditor{} " + super.toString();

0 commit comments

Comments
 (0)