Skip to content

Commit 43ac603

Browse files
committed
Merge remote-tracking branch 'jMonkeyEngine/master' into feature/issue-611
2 parents 7a37b3b + 7a10475 commit 43ac603

File tree

21 files changed

+758
-56
lines changed

21 files changed

+758
-56
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ netbeans/*
2525
*/nbproject/private/*
2626
ant-jme/dist
2727
dist/
28+
/.nb-gradle/MATERIAL_EDITOR_CHANGES.md
2829
/.nb-gradle/
2930
jdks/downloads/
3031
installers/downloads/
@@ -33,5 +34,4 @@ installers/linux-x64/jdk-x64_linux.tar.gz
3334
installers/macos-x64/jdk-x64_macos.tar.gz
3435
installers/windows-x64/jdk-x64_windows.zip
3536
installers/macos-aarch64/jdk-aarch64_macos.tar.gz
36-
3737
installers/linux-aarch64/jdk-aarch64_linux.tar.gz

gradlew

100644100755
File mode changed.

jme3-assetbrowser/src/com/jme3/gde/assetbrowser/widgets/AssetPreviewWidget.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2023 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -154,11 +154,6 @@ public String getAssetName() {
154154
return assetNameLabel.getText();
155155
}
156156

157-
@Override
158-
public void setAssetName(String name) {
159-
assetNameLabel.setText(name);
160-
}
161-
162157
public void setEditable(boolean editable) {
163158
this.editable = editable;
164159
}

jme3-core/src/com/jme3/gde/core/assets/AssetDataNode.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2010 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,7 @@
3232
package com.jme3.gde.core.assets;
3333

3434
import com.jme3.asset.AssetKey;
35+
import com.jme3.gde.core.dnd.AssetNameHolder;
3536
import com.jme3.gde.core.util.PropertyUtils;
3637
import java.beans.PropertyDescriptor;
3738
import java.lang.reflect.Field;
@@ -48,7 +49,7 @@
4849
* @author normenhansen
4950
*/
5051
@SuppressWarnings({"unchecked", "rawtypes"})
51-
public class AssetDataNode extends DataNode {
52+
public class AssetDataNode extends DataNode implements AssetNameHolder {
5253

5354
public AssetDataNode(DataObject obj, Children ch) {
5455
super(obj, ch);
@@ -69,7 +70,7 @@ protected Sheet createSheet() {
6970
if (key == null) {
7071
return sheet;
7172
}
72-
73+
7374
Sheet.Set set = Sheet.createPropertiesSet();
7475
set.setName("AssetKey");
7576
set.setDisplayName("Conversion Settings");
@@ -89,4 +90,14 @@ protected Sheet createSheet() {
8990
sheet.put(set);
9091
return sheet;
9192
}
93+
94+
@Override
95+
public String getAssetName() {
96+
AssetData data = getLookup().lookup(AssetData.class);
97+
if (data != null && data.getAssetKey() != null) {
98+
return data.getAssetKey().getName();
99+
}
100+
return null;
101+
}
102+
92103
}
Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
/*
2-
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3-
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
2+
* Copyright (c) 2009-2025 jMonkeyEngine
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
431
*/
532
package com.jme3.gde.core.dnd;
633

@@ -11,6 +38,4 @@
1138
public interface AssetNameHolder {
1239

1340
String getAssetName();
14-
15-
void setAssetName(String name);
1641
}

jme3-core/src/com/jme3/gde/core/dnd/SceneViewerDropTargetListener.java

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,37 @@
11
/*
2-
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3-
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
2+
* Copyright (c) 2009-2025 jMonkeyEngine
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
431
*/
532
package com.jme3.gde.core.dnd;
633

34+
import com.jme3.gde.core.assets.AssetDataNode;
735
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
836
import com.jme3.math.Vector2f;
937
import java.awt.Cursor;
@@ -19,8 +47,9 @@
1947
import java.util.logging.Logger;
2048

2149
/**
22-
* Handles dropping Materials or Spatial from the AssetBrowser to the
23-
* SceneViewer
50+
* Handles dropping Materials or Spatial from the AssetBrowser and Projects tab
51+
* to the SceneViewer
52+
*
2453
* @author rickard
2554
*/
2655
public class SceneViewerDropTargetListener implements DropTargetListener {
@@ -57,8 +86,7 @@ public void dragExit(final DropTargetEvent dte) {
5786
@Override
5887
public void drop(final DropTargetDropEvent dtde) {
5988
this.rootPanel.setCursor(Cursor.getDefaultCursor());
60-
61-
AssetNameHolder transferableObj = null;
89+
String assetKey = null;
6290
Transferable transferable = null;
6391
DataFlavor flavor = null;
6492

@@ -69,26 +97,51 @@ public void drop(final DropTargetDropEvent dtde) {
6997
flavor = flavors[0];
7098
// What does the Transferable support
7199
if (transferable.isDataFlavorSupported(flavor)) {
72-
transferableObj = (AssetNameHolder) dtde.getTransferable().getTransferData(flavor);
100+
Object o = dtde.getTransferable().getTransferData(flavor);
101+
if (o instanceof AssetNameHolder assetNameHolder) {
102+
assetKey = assetNameHolder.getAssetName();
103+
} else if (o instanceof AssetDataNode assetDataNode) {
104+
assetKey = assetDataNode.getAssetName();
105+
}
73106
}
74107

75108
} catch (UnsupportedFlavorException | IOException ex) {
76109
Logger.getLogger(SceneViewerDropTargetListener.class.getName()).log(Level.WARNING, "Non-supported flavor {0}", transferable);
77110
}
78111

79-
if (transferable == null || transferableObj == null) {
112+
if (transferable == null || assetKey == null) {
80113
return;
81114
}
82115

83116
final int dropYLoc = dtde.getLocation().y;
84117
final int dropXLoc = dtde.getLocation().x;
85118

86-
if (flavor instanceof SpatialDataFlavor) {
87-
rootPanel.addModel(transferableObj.getAssetName(), new Vector2f(dropXLoc, dropYLoc));
88-
} else if (flavor instanceof MaterialDataFlavor) {
89-
rootPanel.applyMaterial(transferableObj.getAssetName(), new Vector2f(dropXLoc, dropYLoc));
119+
if (flavor instanceof SpatialDataFlavor || isModelExtension(assetKey)) {
120+
rootPanel.addModel(assetKey, new Vector2f(dropXLoc, dropYLoc));
121+
} else if (flavor instanceof MaterialDataFlavor || isMaterialExtension(assetKey)) {
122+
rootPanel.applyMaterial(assetKey, new Vector2f(dropXLoc, dropYLoc));
90123
}
91124

92125
}
93126

127+
/**
128+
* Determines if the asset key represents a model/spatial asset by checking its file extension.
129+
*
130+
* @param assetKey The asset key (typically a filename or path); this method checks if it ends with the model file extension.
131+
* @return true if the asset key is for model files
132+
*/
133+
private boolean isModelExtension(String assetKey) {
134+
return assetKey.endsWith("j3o");
135+
}
136+
137+
/**
138+
* Determines if the asset key represents a material asset by checking its file extension.
139+
*
140+
* @param assetKey The asset key (typically a filename or path); this method checks if it ends with the material file extension.
141+
* @return true if the asset key is for material files
142+
*/
143+
private boolean isMaterialExtension(String assetKey) {
144+
return assetKey.endsWith("j3m");
145+
}
146+
94147
}

jme3-glsl-highlighter/src/com/jme3/gde/glsl/highlighter/editor/GlslIndentTask.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ public void reindent() throws BadLocationException {
5555
context.setCaretOffset(1);
5656
final Document doc = context.document();
5757
int indentModifier = 0;
58+
59+
int startOffset = context.startOffset();
60+
int startOffsetBounded = Math.max(startOffset - 1, 0);
5861

5962
//Check if previous line ends with a {
60-
int previousLineLength = context.startOffset() - 1 - context.lineStartOffset(context.startOffset() - 1);
61-
String previousLine = doc.getText(context.lineStartOffset(context.startOffset() - 1), previousLineLength);
63+
int previousLineLength = Math.max(startOffsetBounded - context.lineStartOffset(startOffsetBounded), 0);
64+
String previousLine = doc.getText(context.lineStartOffset(startOffsetBounded), previousLineLength);
6265

6366
//Hook other reasons for changes in indentation into this for loop
6467
for (int i = previousLineLength - 1; i >= 0; i--) {
@@ -69,8 +72,8 @@ public void reindent() throws BadLocationException {
6972
break;
7073
}
7174
}
72-
int previousLineIndent = context.lineIndent(context.lineStartOffset(context.startOffset() - 1));
73-
context.modifyIndent(context.startOffset(), previousLineIndent + indentModifier);
75+
int previousLineIndent = context.lineIndent(context.lineStartOffset(startOffsetBounded));
76+
context.modifyIndent(startOffset, previousLineIndent + indentModifier);
7477
}
7578

7679
@Override
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
MaterialDef ${name} {
2+
3+
MaterialParameters {
4+
}
5+
6+
Technique {
7+
VertexShader GLSL100: ${name}.vert
8+
FragmentShader GLSL100: ${name}.frag
9+
10+
WorldParameters {
11+
WorldViewProjectionMatrix
12+
}
13+
}
14+
15+
}

jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatPanel.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
public class MatPanel extends JPanel implements MouseListener, ComponentListener {
5353
private final MaterialPreviewRenderer renderer;
5454
private Material mat;
55+
private boolean animationEnabled = false;
5556
/**
5657
* Creates new form PreviewPanel
5758
*/
@@ -64,6 +65,7 @@ public MatPanel() {
6465
}
6566

6667
public void cleanup() {
68+
animationTimer.stop();
6769
renderer.cleanUp();
6870
}
6971

@@ -366,6 +368,15 @@ public void actionPerformed(ActionEvent e) {
366368
}
367369
});
368370

371+
private final Timer animationTimer = new Timer(20, new ActionListener() {
372+
@Override
373+
public void actionPerformed(ActionEvent e) {
374+
if (animationEnabled && mat != null) {
375+
renderer.refreshOnly();
376+
}
377+
}
378+
});
379+
369380
@Override
370381
public void mouseExited(MouseEvent e) {
371382
t.restart();
@@ -399,4 +410,24 @@ private void refresh() {
399410
renderer.showMaterial(mat);
400411
}
401412
}
413+
414+
/**
415+
* Enable or disable animation rendering
416+
* @param enabled true to enable continuous rendering, false to disable
417+
*/
418+
public void setAnimationEnabled(boolean enabled) {
419+
this.animationEnabled = enabled;
420+
if (enabled) {
421+
animationTimer.start();
422+
} else {
423+
animationTimer.stop();
424+
}
425+
}
426+
427+
/**
428+
* @return true if animation rendering is enabled
429+
*/
430+
public boolean isAnimationEnabled() {
431+
return animationEnabled;
432+
}
402433
}

jme3-materialeditor/src/com/jme3/gde/materialdefinition/package-info.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
32-
@TemplateRegistration(folder = "Material", content = "MatDef.j3md", displayName="Material Definition Template")
32+
@TemplateRegistrations({
33+
@TemplateRegistration(folder = "Material", content = "MatDef.j3md", displayName="Material Definition Template (Shader Nodes)"),
34+
@TemplateRegistration(folder = "Material", content = "CodeBasedMatDef.j3md", displayName="Material Definition Template (Code Based)",
35+
position = 100, scriptEngine = "freemarker"),
36+
})
3337
package com.jme3.gde.materialdefinition;
3438

3539
import org.netbeans.api.templates.TemplateRegistration;
40+
import org.netbeans.api.templates.TemplateRegistrations;

0 commit comments

Comments
 (0)