Merge branch 'master' into PBRisComing
This commit is contained in:
commit
fcff7f6933
@ -176,7 +176,7 @@ public class NewtMouseInput implements MouseInput, MouseListener {
|
|||||||
|
|
||||||
// invert DY
|
// invert DY
|
||||||
int actualX = lastKnownLocation.getX();
|
int actualX = lastKnownLocation.getX();
|
||||||
int actualY = component.getHeight() - lastKnownLocation.getY();
|
int actualY = component.getSurfaceHeight() - lastKnownLocation.getY();
|
||||||
MouseMotionEvent evt = new MouseMotionEvent(actualX, actualY,
|
MouseMotionEvent evt = new MouseMotionEvent(actualX, actualY,
|
||||||
newX - lastEventX,
|
newX - lastEventX,
|
||||||
lastEventY - newY,
|
lastEventY - newY,
|
||||||
@ -215,7 +215,7 @@ public class NewtMouseInput implements MouseInput, MouseListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent newtEvt) {
|
public void mousePressed(MouseEvent newtEvt) {
|
||||||
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(newtEvt), true, newtEvt.getX(), newtEvt.getY());
|
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(newtEvt), true, newtEvt.getX(), component.getSurfaceHeight() - newtEvt.getY());
|
||||||
evt.setTime(newtEvt.getWhen());
|
evt.setTime(newtEvt.getWhen());
|
||||||
synchronized (eventQueue) {
|
synchronized (eventQueue) {
|
||||||
eventQueue.add(evt);
|
eventQueue.add(evt);
|
||||||
@ -224,7 +224,7 @@ public class NewtMouseInput implements MouseInput, MouseListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent awtEvt) {
|
public void mouseReleased(MouseEvent awtEvt) {
|
||||||
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(awtEvt), false, awtEvt.getX(), awtEvt.getY());
|
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(awtEvt), false, awtEvt.getX(), component.getSurfaceHeight() - awtEvt.getY());
|
||||||
evt.setTime(awtEvt.getWhen());
|
evt.setTime(awtEvt.getWhen());
|
||||||
synchronized (eventQueue) {
|
synchronized (eventQueue) {
|
||||||
eventQueue.add(evt);
|
eventQueue.add(evt);
|
||||||
@ -285,8 +285,8 @@ public class NewtMouseInput implements MouseInput, MouseListener {
|
|||||||
private void recenterMouse(final GLWindow component) {
|
private void recenterMouse(final GLWindow component) {
|
||||||
eventsSinceRecenter = 0;
|
eventsSinceRecenter = 0;
|
||||||
isRecentering = true;
|
isRecentering = true;
|
||||||
centerLocation.setX(component.getWidth() / 2);
|
centerLocation.setX(component.getSurfaceWidth() / 2);
|
||||||
centerLocation.setY(component.getHeight() / 2);
|
centerLocation.setY(component.getSurfaceHeight() / 2);
|
||||||
centerLocationOnScreen.setX(centerLocation.getX());
|
centerLocationOnScreen.setX(centerLocation.getX());
|
||||||
centerLocationOnScreen.setY(centerLocation.getY());
|
centerLocationOnScreen.setY(centerLocation.getY());
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
</Properties>
|
</Properties>
|
||||||
<SyntheticProperties>
|
<SyntheticProperties>
|
||||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
|
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||||
</SyntheticProperties>
|
</SyntheticProperties>
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||||
|
@ -31,9 +31,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.gde.core.properties;
|
package com.jme3.gde.core.properties;
|
||||||
|
|
||||||
import com.jme3.asset.TextureKey;
|
|
||||||
import com.jme3.gde.core.assets.ProjectAssetManager;
|
import com.jme3.gde.core.assets.ProjectAssetManager;
|
||||||
import com.jme3.gde.core.properties.preview.DDSPreview;
|
import com.jme3.gde.core.properties.preview.TexturePreview;
|
||||||
import com.jme3.gde.core.util.TreeUtil;
|
import com.jme3.gde.core.util.TreeUtil;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
@ -42,6 +41,7 @@ import java.awt.event.WindowListener;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.DefaultListSelectionModel;
|
import javax.swing.DefaultListSelectionModel;
|
||||||
@ -52,8 +52,6 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
|||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
import javax.swing.tree.TreeSelectionModel;
|
import javax.swing.tree.TreeSelectionModel;
|
||||||
import jme3tools.converters.ImageToAwt;
|
|
||||||
import org.openide.util.ImageUtilities;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays all textures in the ProjectAssetManager,
|
* Displays all textures in the ProjectAssetManager,
|
||||||
@ -68,7 +66,7 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection
|
|||||||
|
|
||||||
private ProjectAssetManager assetManager;
|
private ProjectAssetManager assetManager;
|
||||||
private TexturePropertyEditor editor;
|
private TexturePropertyEditor editor;
|
||||||
private DDSPreview ddsPreview;
|
private TexturePreview texPreview;
|
||||||
private Preferences prefs;
|
private Preferences prefs;
|
||||||
private static final String PREF_LAST_SELECTED = "lastSelectedTexture";
|
private static final String PREF_LAST_SELECTED = "lastSelectedTexture";
|
||||||
|
|
||||||
@ -234,8 +232,8 @@ private void noTexturebuttonActionPerformed(java.awt.event.ActionEvent evt) {//G
|
|||||||
if (node != null && node.isLeaf()) {
|
if (node != null && node.isLeaf()) {
|
||||||
String selected = TreeUtil.getPath(node.getUserObjectPath());
|
String selected = TreeUtil.getPath(node.getUserObjectPath());
|
||||||
selected = selected.substring(0, selected.lastIndexOf("/"));
|
selected = selected.substring(0, selected.lastIndexOf("/"));
|
||||||
Texture tex = assetManager.loadTexture(selected);
|
// Texture tex = assetManager.loadTexture(selected);
|
||||||
editor.setValue(tex);
|
// editor.setValue(tex);
|
||||||
editor.setAsText(selected);
|
editor.setAsText(selected);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -270,7 +268,7 @@ private void noTexturebuttonActionPerformed(java.awt.event.ActionEvent evt) {//G
|
|||||||
|
|
||||||
private void setSelectedTexture(Texture texture) {
|
private void setSelectedTexture(Texture texture) {
|
||||||
if (texture != null) {
|
if (texture != null) {
|
||||||
Logger.getLogger(TextureBrowser.class.getName()).finer("Looking for Texture: " + texture.getName());
|
Logger.getLogger(TextureBrowser.class.getName()).log(Level.FINER, "Looking for Texture: {0}", texture.getName());
|
||||||
String[] path = ("/" + texture.getName()).split("/");
|
String[] path = ("/" + texture.getName()).split("/");
|
||||||
TreePath parent = new TreePath((TreeNode) jTree1.getModel().getRoot());
|
TreePath parent = new TreePath((TreeNode) jTree1.getModel().getRoot());
|
||||||
TreePath selectedTreePath = TreeUtil.buildTreePath(jTree1, parent, path, 0, true);
|
TreePath selectedTreePath = TreeUtil.buildTreePath(jTree1, parent, path, 0, true);
|
||||||
@ -287,6 +285,7 @@ private void noTexturebuttonActionPerformed(java.awt.event.ActionEvent evt) {//G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void valueChanged(TreeSelectionEvent e) {
|
public void valueChanged(TreeSelectionEvent e) {
|
||||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
|
||||||
|
|
||||||
@ -295,25 +294,14 @@ private void noTexturebuttonActionPerformed(java.awt.event.ActionEvent evt) {//G
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Object nodeInfo = node.getUserObject();
|
|
||||||
if (node.isLeaf()) {
|
if (node.isLeaf()) {
|
||||||
String selected = TreeUtil.getPath(node.getUserObjectPath());
|
String selected = TreeUtil.getPath(node.getUserObjectPath());
|
||||||
selected = selected.substring(0, selected.lastIndexOf("/"));
|
selected = selected.substring(0, selected.lastIndexOf("/"));
|
||||||
Icon newicon = null;
|
Icon newicon = null;
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
if (texPreview == null) {
|
||||||
if (ddsPreview == null) {
|
texPreview = new TexturePreview(assetManager);
|
||||||
ddsPreview = new DDSPreview(assetManager);
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, (String) node.getUserObject(), 450, 450, imagePreviewLabel, infoLabel);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Texture tex = assetManager.loadTexture(selected);
|
|
||||||
newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
|
||||||
assetManager.deleteFromCache(new TextureKey(selected));
|
|
||||||
imagePreviewLabel.setIcon(newicon);
|
|
||||||
infoLabel.setText(" " + node.getUserObject() + " w : " + newicon.getIconWidth() + " h : " + newicon.getIconHeight());
|
|
||||||
}
|
}
|
||||||
|
texPreview.requestPreview(selected, (String) node.getUserObject(), 450, 450, imagePreviewLabel, infoLabel);
|
||||||
prefs.put(PREF_LAST_SELECTED, selected);
|
prefs.put(PREF_LAST_SELECTED, selected);
|
||||||
} else {
|
} else {
|
||||||
imagePreviewLabel.setIcon(null);
|
imagePreviewLabel.setIcon(null);
|
||||||
@ -323,27 +311,34 @@ private void noTexturebuttonActionPerformed(java.awt.event.ActionEvent evt) {//G
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void windowOpened(WindowEvent e) {
|
public void windowOpened(WindowEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
if (ddsPreview != null) {
|
if (texPreview != null) {
|
||||||
ddsPreview.cleanUp();
|
texPreview.cleanUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void windowIconified(WindowEvent e) {
|
public void windowIconified(WindowEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void windowDeiconified(WindowEvent e) {
|
public void windowDeiconified(WindowEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void windowActivated(WindowEvent e) {
|
public void windowActivated(WindowEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void windowDeactivated(WindowEvent e) {
|
public void windowDeactivated(WindowEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,14 @@ public class TexturePropertyEditor implements PropertyEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
|
if(texture == null && assetKey != null){
|
||||||
|
if (manager == null){
|
||||||
|
manager = SceneApplication.getApplication().getAssetManager();
|
||||||
|
}
|
||||||
|
texture = manager.loadTexture(assetKey);
|
||||||
|
}
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,140 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009-2010 jMonkeyEngine
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package com.jme3.gde.core.properties.preview;
|
|
||||||
|
|
||||||
import com.jme3.asset.TextureKey;
|
|
||||||
import com.jme3.gde.core.assets.ProjectAssetManager;
|
|
||||||
import com.jme3.gde.core.scene.PreviewRequest;
|
|
||||||
import com.jme3.gde.core.scene.SceneApplication;
|
|
||||||
import com.jme3.gde.core.scene.SceneListener;
|
|
||||||
import com.jme3.gde.core.scene.SceneRequest;
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.Vector2f;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Geometry;
|
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import com.jme3.scene.shape.Quad;
|
|
||||||
import com.jme3.texture.Texture;
|
|
||||||
import com.jme3.util.SkyFactory;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Nehon
|
|
||||||
*/
|
|
||||||
public class DDSPreview implements SceneListener {
|
|
||||||
|
|
||||||
private final ProjectAssetManager assetManager;
|
|
||||||
private JComponent picPreview;
|
|
||||||
private final Geometry quad;
|
|
||||||
private final Geometry quad3D;
|
|
||||||
private final Material material;
|
|
||||||
private final Material material3D;
|
|
||||||
|
|
||||||
public DDSPreview(ProjectAssetManager assetManager) {
|
|
||||||
this.assetManager = assetManager;
|
|
||||||
|
|
||||||
Quad quadMesh = new Quad(4.5f, 4.5f);
|
|
||||||
Quad quadMesh3D = new Quad(4.5f, 4.5f);
|
|
||||||
quadMesh3D.scaleTextureCoordinates(new Vector2f(4, 4));
|
|
||||||
quad = new Geometry("previewQuad", quadMesh);
|
|
||||||
quad.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));
|
|
||||||
quad3D = new Geometry("previewQuad", quadMesh3D);
|
|
||||||
quad3D.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));
|
|
||||||
material3D = new Material(assetManager, "com/jme3/gde/core/properties/preview/tex3DThumb.j3md");
|
|
||||||
material3D.setFloat("InvDepth", 1f / 16f);
|
|
||||||
material3D.setInt("Rows", 4);
|
|
||||||
material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
|
||||||
SceneApplication.getApplication().addSceneListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void requestPreview(String textureName, String displayName, int width, int height, JComponent picLabel, JLabel infoLabel) {
|
|
||||||
TextureKey key = new TextureKey(textureName);
|
|
||||||
picPreview = picLabel;
|
|
||||||
assetManager.deleteFromCache(key);
|
|
||||||
Texture t = assetManager.loadTexture(key);
|
|
||||||
Spatial geom = quad;
|
|
||||||
if (key.getTextureTypeHint() == Texture.Type.TwoDimensional) {
|
|
||||||
material.setTexture("ColorMap", t);
|
|
||||||
geom.setMaterial(material);
|
|
||||||
if (infoLabel != null) {
|
|
||||||
infoLabel.setText(" " + displayName + " w : " + t.getImage().getWidth() + " h : " + t.getImage().getHeight());
|
|
||||||
}
|
|
||||||
} else if (key.getTextureTypeHint() == Texture.Type.ThreeDimensional) {
|
|
||||||
geom = quad3D;
|
|
||||||
assetManager.deleteFromCache(key);
|
|
||||||
key.setTextureTypeHint(Texture.Type.ThreeDimensional);
|
|
||||||
t = assetManager.loadTexture(key);
|
|
||||||
material3D.setTexture("Texture", t);
|
|
||||||
geom.setMaterial(material3D);
|
|
||||||
if (infoLabel != null) {
|
|
||||||
infoLabel.setText(" " + displayName + " (Texture3D) w : " + t.getImage().getWidth() + " h : " + t.getImage().getHeight() + " d : " + t.getImage().getDepth());
|
|
||||||
}
|
|
||||||
} else if (key.getTextureTypeHint() == Texture.Type.CubeMap) {
|
|
||||||
assetManager.deleteFromCache(key);
|
|
||||||
geom = SkyFactory.createSky(assetManager, textureName, SkyFactory.EnvMapType.CubeMap);
|
|
||||||
if (infoLabel != null) {
|
|
||||||
infoLabel.setText(" " + displayName + " (CubeMap) w : " + t.getImage().getWidth() + " h : " + t.getImage().getHeight());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PreviewRequest request = new PreviewRequest(this, geom, width, height);
|
|
||||||
request.getCameraRequest().setLocation(new Vector3f(0, 0, 5.3f));
|
|
||||||
request.getCameraRequest().setLookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y.mult(-1));
|
|
||||||
SceneApplication.getApplication().createPreview(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cleanUp() {
|
|
||||||
SceneApplication.getApplication().removeSceneListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sceneOpened(SceneRequest request) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sceneClosed(SceneRequest request) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void previewCreated(PreviewRequest request) {
|
|
||||||
if (request.getRequester() == this) {
|
|
||||||
final ImageIcon icon = new ImageIcon(request.getImage());
|
|
||||||
if (picPreview instanceof JLabel) {
|
|
||||||
((JLabel) picPreview).setIcon(icon);
|
|
||||||
}
|
|
||||||
if (picPreview instanceof JButton) {
|
|
||||||
((JButton) picPreview).setIcon(icon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,179 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2010 jMonkeyEngine
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package com.jme3.gde.core.properties.preview;
|
||||||
|
|
||||||
|
import com.jme3.asset.TextureKey;
|
||||||
|
import com.jme3.gde.core.assets.ProjectAssetManager;
|
||||||
|
import com.jme3.gde.core.scene.PreviewRequest;
|
||||||
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
|
import com.jme3.gde.core.scene.SceneListener;
|
||||||
|
import com.jme3.gde.core.scene.SceneRequest;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
|
import com.jme3.scene.shape.Quad;
|
||||||
|
import com.jme3.texture.Texture;
|
||||||
|
import com.jme3.util.SkyFactory;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Nehon
|
||||||
|
*/
|
||||||
|
public class TexturePreview implements SceneListener {
|
||||||
|
|
||||||
|
private final ProjectAssetManager assetManager;
|
||||||
|
private JComponent picPreview;
|
||||||
|
private final Geometry quad;
|
||||||
|
private final Geometry quad3D;
|
||||||
|
private final Material material;
|
||||||
|
private final Material material3D;
|
||||||
|
|
||||||
|
public TexturePreview(ProjectAssetManager assetManager) {
|
||||||
|
this.assetManager = assetManager;
|
||||||
|
|
||||||
|
Quad quadMesh = new Quad(4.5f, 4.5f);
|
||||||
|
Quad quadMesh3D = new Quad(4.5f, 4.5f);
|
||||||
|
quadMesh3D.scaleTextureCoordinates(new Vector2f(4, 4));
|
||||||
|
quad = new Geometry("previewQuad", quadMesh);
|
||||||
|
quad.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));
|
||||||
|
quad3D = new Geometry("previewQuad", quadMesh3D);
|
||||||
|
quad3D.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));
|
||||||
|
material3D = new Material(assetManager, "com/jme3/gde/core/properties/preview/tex3DThumb.j3md");
|
||||||
|
material3D.setFloat("InvDepth", 1f / 16f);
|
||||||
|
material3D.setInt("Rows", 4);
|
||||||
|
material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
SceneApplication.getApplication().addSceneListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void requestPreview(final String textureName, final String displayName, final int width, final int height, final JComponent picLabel, final JLabel infoLabel) {
|
||||||
|
|
||||||
|
picPreview = picLabel;
|
||||||
|
clearPreview();
|
||||||
|
if (infoLabel != null) {
|
||||||
|
infoLabel.setText(" Creating preview...");
|
||||||
|
}
|
||||||
|
|
||||||
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void call() throws Exception {
|
||||||
|
TextureKey key = new TextureKey(textureName);
|
||||||
|
Texture t = assetManager.loadTexture(key);
|
||||||
|
Spatial geom = quad;
|
||||||
|
if (key.getTextureTypeHint() == Texture.Type.TwoDimensional) {
|
||||||
|
material.setTexture("ColorMap", t);
|
||||||
|
geom.setMaterial(material);
|
||||||
|
setLabel(infoLabel, displayName, t.getImage().getWidth(), t.getImage().getHeight(), -1);
|
||||||
|
} else if (key.getTextureTypeHint() == Texture.Type.ThreeDimensional) {
|
||||||
|
geom = quad3D;
|
||||||
|
material3D.setTexture("Texture", t);
|
||||||
|
geom.setMaterial(material3D);
|
||||||
|
setLabel(infoLabel, displayName + " (Texture3D)", t.getImage().getWidth(), t.getImage().getHeight(), t.getImage().getDepth());
|
||||||
|
|
||||||
|
} else if (key.getTextureTypeHint() == Texture.Type.CubeMap) {
|
||||||
|
geom = SkyFactory.createSky(assetManager, textureName, SkyFactory.EnvMapType.CubeMap);
|
||||||
|
setLabel(infoLabel, displayName + " (CubeMap)", t.getImage().getWidth(), t.getImage().getHeight(), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreviewRequest request = new PreviewRequest(TexturePreview.this, geom, width, height);
|
||||||
|
request.getCameraRequest().setLocation(new Vector3f(0, 0, 5.3f));
|
||||||
|
request.getCameraRequest().setLookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y.mult(-1));
|
||||||
|
SceneApplication.getApplication().createPreview(request);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
SceneApplication.getApplication().removeSceneListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sceneOpened(SceneRequest request) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sceneClosed(SceneRequest request) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLabel(final JLabel label, final String text, final int width, final int height, final int depth) {
|
||||||
|
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (label != null) {
|
||||||
|
String labText = " " + text + " w : " + width + " h : " + height;
|
||||||
|
if (depth > 0) {
|
||||||
|
labText += " d : " + depth;
|
||||||
|
}
|
||||||
|
label.setText(labText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearPreview() {
|
||||||
|
if (picPreview instanceof JLabel) {
|
||||||
|
((JLabel) picPreview).setIcon(null);
|
||||||
|
}
|
||||||
|
if (picPreview instanceof JButton) {
|
||||||
|
((JButton) picPreview).setIcon(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void previewCreated(final PreviewRequest request) {
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (request.getRequester() == TexturePreview.this) {
|
||||||
|
final ImageIcon icon = new ImageIcon(request.getImage());
|
||||||
|
if (picPreview instanceof JLabel) {
|
||||||
|
((JLabel) picPreview).setIcon(icon);
|
||||||
|
}
|
||||||
|
if (picPreview instanceof JButton) {
|
||||||
|
((JButton) picPreview).setIcon(icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -5,10 +5,9 @@ uniform float m_InvDepth;
|
|||||||
varying vec2 texCoord;
|
varying vec2 texCoord;
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
float depthx=floor(texCoord.x);
|
float depthx = floor(texCoord.x);
|
||||||
float depthy=(m_Rows-1.0) - floor(texCoord.y);
|
float depthy = (float(m_Rows) - 1.0) - floor(texCoord.y);
|
||||||
//vec3 texC=vec3(texCoord.x,texCoord.y ,0.7);//
|
|
||||||
|
|
||||||
vec3 texC=vec3(fract(texCoord.x),fract(texCoord.y),(depthy*m_Rows+depthx)*m_InvDepth);//
|
vec3 texC = vec3(fract(texCoord.x), fract(texCoord.y), (depthy * float(m_Rows) + depthx) * m_InvDepth);//
|
||||||
gl_FragColor= texture3D(m_Texture,texC);
|
gl_FragColor = texture3D(m_Texture, texC);
|
||||||
}
|
}
|
@ -6,6 +6,6 @@ attribute vec3 inPosition;
|
|||||||
varying vec2 texCoord;
|
varying vec2 texCoord;
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition,1.0);
|
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
|
||||||
texCoord=inTexCoord;
|
texCoord = inTexCoord;
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ package com.jme3.gde.materials.multiview.widgets;
|
|||||||
import com.jme3.asset.AssetNotFoundException;
|
import com.jme3.asset.AssetNotFoundException;
|
||||||
import com.jme3.gde.core.assets.ProjectAssetManager;
|
import com.jme3.gde.core.assets.ProjectAssetManager;
|
||||||
import com.jme3.gde.core.properties.TexturePropertyEditor;
|
import com.jme3.gde.core.properties.TexturePropertyEditor;
|
||||||
import com.jme3.gde.core.properties.preview.DDSPreview;
|
import com.jme3.gde.core.properties.preview.TexturePreview;
|
||||||
import com.jme3.gde.materials.MaterialProperty;
|
import com.jme3.gde.materials.MaterialProperty;
|
||||||
import com.jme3.gde.materials.multiview.MaterialEditorTopComponent;
|
import com.jme3.gde.materials.multiview.MaterialEditorTopComponent;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
@ -39,7 +39,7 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|||||||
private boolean flip = false;
|
private boolean flip = false;
|
||||||
private boolean repeat = false;
|
private boolean repeat = false;
|
||||||
private String textureName = null;
|
private String textureName = null;
|
||||||
private DDSPreview ddsPreview;
|
private TexturePreview texPreview;
|
||||||
private final ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
|
private final ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
|
||||||
|
|
||||||
/** Creates new form SelectionPanel */
|
/** Creates new form SelectionPanel */
|
||||||
@ -53,22 +53,13 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|||||||
if (!"".equals(textureName)) {
|
if (!"".equals(textureName)) {
|
||||||
exec.execute(new Runnable() {
|
exec.execute(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try{
|
try{
|
||||||
Texture tex = manager.loadTexture(textureName);
|
if (texPreview == null) {
|
||||||
if (textureName.toLowerCase().endsWith(".dds")) {
|
texPreview = new TexturePreview(manager);
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview(manager);
|
|
||||||
}
|
}
|
||||||
ddsPreview.requestPreview(textureName, "", 80, 80, texturePreview, null);
|
texPreview.requestPreview(textureName, "", 80, 25, texturePreview, null);
|
||||||
} else {
|
|
||||||
final Icon newicon = ImageUtilities.image2Icon(resizeImage(ImageToAwt.convert(tex.getImage(), false, true, 0)));
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
texturePreview.setIcon(newicon);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (AssetNotFoundException a) {
|
} catch (AssetNotFoundException a) {
|
||||||
Logger.getLogger(MaterialEditorTopComponent.class.getName()).log(Level.WARNING, "Could not load texture {0}", textureName);
|
Logger.getLogger(MaterialEditorTopComponent.class.getName()).log(Level.WARNING, "Could not load texture {0}", textureName);
|
||||||
}
|
}
|
||||||
@ -318,8 +309,8 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
if (ddsPreview != null) {
|
if (texPreview != null) {
|
||||||
ddsPreview.cleanUp();
|
texPreview.cleanUp();
|
||||||
}
|
}
|
||||||
exec.shutdownNow();
|
exec.shutdownNow();
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ package com.jme3.gde.terraineditor;
|
|||||||
import com.jme3.gde.core.assets.AssetDataObject;
|
import com.jme3.gde.core.assets.AssetDataObject;
|
||||||
import com.jme3.gde.core.assets.ProjectAssetManager;
|
import com.jme3.gde.core.assets.ProjectAssetManager;
|
||||||
import com.jme3.gde.core.properties.TexturePropertyEditor;
|
import com.jme3.gde.core.properties.TexturePropertyEditor;
|
||||||
import com.jme3.gde.core.properties.preview.DDSPreview;
|
import com.jme3.gde.core.properties.preview.TexturePreview;
|
||||||
import com.jme3.gde.core.scene.PreviewRequest;
|
import com.jme3.gde.core.scene.PreviewRequest;
|
||||||
import com.jme3.gde.core.scene.SceneApplication;
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
import com.jme3.gde.core.scene.SceneListener;
|
import com.jme3.gde.core.scene.SceneListener;
|
||||||
@ -122,7 +122,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
|
|||||||
//private TerrainNodeListener terrainDeletedNodeListener;
|
//private TerrainNodeListener terrainDeletedNodeListener;
|
||||||
private boolean availableNormalTextures;
|
private boolean availableNormalTextures;
|
||||||
private HelpCtx ctx = new HelpCtx("sdk.terrain_editor");
|
private HelpCtx ctx = new HelpCtx("sdk.terrain_editor");
|
||||||
private DDSPreview ddsPreview;
|
private TexturePreview texPreview;
|
||||||
private Map<String, JButton> buttons = new HashMap<String, JButton>();
|
private Map<String, JButton> buttons = new HashMap<String, JButton>();
|
||||||
private JPanel insideToolSettings;
|
private JPanel insideToolSettings;
|
||||||
|
|
||||||
@ -153,35 +153,29 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
|
|||||||
private float max = 0;
|
private float max = 0;
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
|
||||||
|
@Override
|
||||||
public void incrementProgress(float f) {
|
public void incrementProgress(float f) {
|
||||||
progress += f;
|
progress += f;
|
||||||
progressHandle.progress((int) progress);
|
progressHandle.progress((int) progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMonitorMax(float f) {
|
public void setMonitorMax(float f) {
|
||||||
max = f;
|
max = f;
|
||||||
// java.awt.EventQueue.invokeLater(new Runnable() {
|
|
||||||
// public void run() {
|
|
||||||
// synchronized(lock){
|
|
||||||
if (progressHandle == null) {
|
if (progressHandle == null) {
|
||||||
progressHandle = ProgressHandleFactory.createHandle("Calculating terrain entropies...");
|
progressHandle = ProgressHandleFactory.createHandle("Calculating terrain entropies...");
|
||||||
progressHandle.start((int) max);
|
progressHandle.start((int) max);
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float getMonitorMax() {
|
public float getMonitorMax() {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void progressComplete() {
|
public void progressComplete() {
|
||||||
// SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
// public void run() {
|
|
||||||
progressHandle.finish();
|
progressHandle.finish();
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1632,6 +1626,13 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
|
|||||||
|
|
||||||
protected abstract boolean supportsNullTexture();
|
protected abstract boolean supportsNullTexture();
|
||||||
|
|
||||||
|
private TexturePreview getTexturePreview(){
|
||||||
|
if (texPreview == null) {
|
||||||
|
texPreview = new TexturePreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
||||||
|
}
|
||||||
|
return texPreview;
|
||||||
|
}
|
||||||
|
|
||||||
private JButton getButton(Object value, final int row, final int column) {
|
private JButton getButton(Object value, final int row, final int column) {
|
||||||
|
|
||||||
JButton button = buttons.get(row + "-" + column);
|
JButton button = buttons.get(row + "-" + column);
|
||||||
@ -1656,21 +1657,9 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
|
|||||||
}
|
}
|
||||||
|
|
||||||
Texture tex = getTextureFromModel(index); // delegate to sub-class
|
Texture tex = getTextureFromModel(index); // delegate to sub-class
|
||||||
|
|
||||||
//Texture tex = SceneApplication.getApplication().getAssetManager().loadTexture((String)value);
|
|
||||||
if (tex != null) {
|
if (tex != null) {
|
||||||
String selected = tex.getKey().getName();
|
String selected = tex.getKey().getName();
|
||||||
|
getTexturePreview().requestPreview(selected, "", 80, 80, lbl, null);
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, "", 80, 80, lbl, null);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Icon icon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
|
||||||
lbl.setIcon(icon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1694,24 +1683,17 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
|
|||||||
TexturePropertyEditor editor = new TexturePropertyEditor(selectedTex);
|
TexturePropertyEditor editor = new TexturePropertyEditor(selectedTex);
|
||||||
Component view = editor.getCustomEditor();
|
Component view = editor.getCustomEditor();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
Texture tex = (Texture) editor.getValue();
|
|
||||||
if (editor.getValue() != null) {
|
|
||||||
String selected = tex.getKey().getName();
|
|
||||||
|
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
if (editor.getAsText() != null) {
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, "", 80, 80, lbl, null);
|
|
||||||
|
|
||||||
} else {
|
String selected = editor.getAsText();
|
||||||
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
getTexturePreview().requestPreview(selected, "", 80, 80, lbl, null);
|
||||||
lbl.setIcon(newicon);
|
Texture tex = SceneApplication.getApplication().getAssetManager().loadTexture(selected);
|
||||||
}
|
setTextureInModel(row, tex);
|
||||||
} else if (supportsNullTexture()) {
|
} else if (supportsNullTexture()) {
|
||||||
lbl.setIcon(null);
|
lbl.setIcon(null);
|
||||||
}
|
}
|
||||||
setTextureInModel(row, tex);
|
|
||||||
} finally {
|
} finally {
|
||||||
alreadyChoosing = false;
|
alreadyChoosing = false;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,6 @@ public class TerrainToolController extends SceneToolController {
|
|||||||
*/
|
*/
|
||||||
void doTerrainEditToolActionEnded() {
|
void doTerrainEditToolActionEnded() {
|
||||||
if (terrainTool != null) {
|
if (terrainTool != null) {
|
||||||
System.out.println("undo tagged");
|
|
||||||
terrainTool.actionEnded(jmeRootNode, editorController.getCurrentDataObject());
|
terrainTool.actionEnded(jmeRootNode, editorController.getCurrentDataObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,16 +33,14 @@ package com.jme3.gde.terraineditor.sky;
|
|||||||
|
|
||||||
import com.jme3.gde.core.assets.ProjectAssetManager;
|
import com.jme3.gde.core.assets.ProjectAssetManager;
|
||||||
import com.jme3.gde.core.properties.TexturePropertyEditor;
|
import com.jme3.gde.core.properties.TexturePropertyEditor;
|
||||||
import com.jme3.gde.core.properties.preview.DDSPreview;
|
import com.jme3.gde.core.properties.preview.TexturePreview;
|
||||||
import com.jme3.gde.core.scene.SceneApplication;
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.jme3.util.SkyFactory;
|
import com.jme3.util.SkyFactory;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import javax.swing.ComboBoxModel;
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import jme3tools.converters.ImageToAwt;
|
import jme3tools.converters.ImageToAwt;
|
||||||
@ -50,7 +48,7 @@ import org.openide.util.ImageUtilities;
|
|||||||
|
|
||||||
public final class SkyboxVisualPanel2 extends JPanel {
|
public final class SkyboxVisualPanel2 extends JPanel {
|
||||||
|
|
||||||
private DDSPreview ddsPreview;
|
private TexturePreview texPreview;
|
||||||
|
|
||||||
/** Creates new form SkyboxVisualPanel2 */
|
/** Creates new form SkyboxVisualPanel2 */
|
||||||
public SkyboxVisualPanel2() {
|
public SkyboxVisualPanel2() {
|
||||||
@ -111,6 +109,14 @@ public final class SkyboxVisualPanel2 extends JPanel {
|
|||||||
return editorWest;
|
return editorWest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private TexturePreview getTexturePreview(){
|
||||||
|
if (texPreview == null) {
|
||||||
|
texPreview = new TexturePreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
||||||
|
}
|
||||||
|
return texPreview;
|
||||||
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
* initialize the form.
|
* initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
@ -450,141 +456,63 @@ public final class SkyboxVisualPanel2 extends JPanel {
|
|||||||
private void multipleTexSouthLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexSouthLoadButtonActionPerformed
|
private void multipleTexSouthLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexSouthLoadButtonActionPerformed
|
||||||
Component view = editorSouth.getCustomEditor();
|
Component view = editorSouth.getCustomEditor();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
if (editorSouth.getValue() != null) {
|
if (editorSouth.getAsText()!= null) {
|
||||||
Texture tex = (Texture) editorSouth.getValue();
|
String selected = editorSouth.getAsText();
|
||||||
String selected = tex.getKey().getName();
|
getTexturePreview().requestPreview(selected, "", 80, 80, southPic, null);
|
||||||
|
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, "", 80, 80, southPic, null);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
|
||||||
southPic.setIcon(newicon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_multipleTexSouthLoadButtonActionPerformed
|
}//GEN-LAST:event_multipleTexSouthLoadButtonActionPerformed
|
||||||
|
|
||||||
private void multipleTexNorthLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexNorthLoadButtonActionPerformed
|
private void multipleTexNorthLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexNorthLoadButtonActionPerformed
|
||||||
Component view = editorNorth.getCustomEditor();
|
Component view = editorNorth.getCustomEditor();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
if (editorNorth.getValue() != null) {
|
if (editorNorth.getAsText() != null) {
|
||||||
Texture tex = (Texture) editorNorth.getValue();
|
String selected = editorNorth.getAsText();
|
||||||
String selected = tex.getKey().getName();
|
getTexturePreview().requestPreview(selected, "", 80, 80, northPic, null);
|
||||||
|
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, "", 80, 80, northPic, null);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
|
||||||
northPic.setIcon(newicon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_multipleTexNorthLoadButtonActionPerformed
|
}//GEN-LAST:event_multipleTexNorthLoadButtonActionPerformed
|
||||||
|
|
||||||
private void multipleTexEastLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexEastLoadButtonActionPerformed
|
private void multipleTexEastLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexEastLoadButtonActionPerformed
|
||||||
Component view = editorEast.getCustomEditor();
|
Component view = editorEast.getCustomEditor();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
if (editorEast.getValue() != null) {
|
if (editorEast.getAsText() != null) {
|
||||||
Texture tex = (Texture) editorEast.getValue();
|
String selected = editorEast.getAsText();
|
||||||
String selected = tex.getKey().getName();
|
getTexturePreview().requestPreview(selected, "", 80, 80, eastPic, null);
|
||||||
|
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, "", 80, 80, eastPic, null);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
|
||||||
eastPic.setIcon(newicon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_multipleTexEastLoadButtonActionPerformed
|
}//GEN-LAST:event_multipleTexEastLoadButtonActionPerformed
|
||||||
|
|
||||||
private void multipleTexWestLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexWestLoadButtonActionPerformed
|
private void multipleTexWestLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexWestLoadButtonActionPerformed
|
||||||
Component view = editorWest.getCustomEditor();
|
Component view = editorWest.getCustomEditor();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
if (editorWest.getValue() != null) {
|
if (editorWest.getAsText() != null) {
|
||||||
Texture tex = (Texture) editorWest.getValue();
|
String selected = editorWest.getAsText();
|
||||||
String selected = tex.getKey().getName();
|
getTexturePreview().requestPreview(selected, "", 80, 80, westPic, null);
|
||||||
|
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, "", 80, 80, westPic, null);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
|
||||||
westPic.setIcon(newicon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_multipleTexWestLoadButtonActionPerformed
|
}//GEN-LAST:event_multipleTexWestLoadButtonActionPerformed
|
||||||
|
|
||||||
private void multipleTexTopLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexTopLoadButtonActionPerformed
|
private void multipleTexTopLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexTopLoadButtonActionPerformed
|
||||||
Component view = editorTop.getCustomEditor();
|
Component view = editorTop.getCustomEditor();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
if (editorTop.getValue() != null) {
|
if (editorTop.getAsText() != null) {
|
||||||
Texture tex = (Texture) editorTop.getValue();
|
String selected = editorTop.getAsText();
|
||||||
String selected = tex.getKey().getName();
|
getTexturePreview().requestPreview(selected, "", 80, 80, topPic, null);
|
||||||
|
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, "", 80, 80, topPic, null);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
|
||||||
topPic.setIcon(newicon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_multipleTexTopLoadButtonActionPerformed
|
}//GEN-LAST:event_multipleTexTopLoadButtonActionPerformed
|
||||||
|
|
||||||
private void multipleTexBottomLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexBottomLoadButtonActionPerformed
|
private void multipleTexBottomLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexBottomLoadButtonActionPerformed
|
||||||
Component view = editorBottom.getCustomEditor();
|
Component view = editorBottom.getCustomEditor();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
if (editorBottom.getValue() != null) {
|
if (editorBottom.getAsText() != null) {
|
||||||
Texture tex = (Texture) editorBottom.getValue();
|
String selected = editorBottom.getAsText();
|
||||||
String selected = tex.getKey().getName();
|
getTexturePreview().requestPreview(selected, "", 80, 80, bottomPic, null);
|
||||||
|
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, "", 80, 80, bottomPic, null);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
|
||||||
bottomPic.setIcon(newicon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_multipleTexBottomLoadButtonActionPerformed
|
}//GEN-LAST:event_multipleTexBottomLoadButtonActionPerformed
|
||||||
|
|
||||||
private void singleTexLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_singleTexLoadButtonActionPerformed
|
private void singleTexLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_singleTexLoadButtonActionPerformed
|
||||||
Component view = editorSingle.getCustomEditor();
|
Component view = editorSingle.getCustomEditor();
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
if (editorSingle.getValue() != null) {
|
if (editorSingle.getAsText()!= null) {
|
||||||
Texture tex = (Texture) editorSingle.getValue();
|
String selected = editorSingle.getAsText();
|
||||||
String selected = tex.getKey().getName();
|
getTexturePreview().requestPreview(selected, "", 80, 80, singlePic, null);
|
||||||
|
|
||||||
if (selected.toLowerCase().endsWith(".dds")) {
|
|
||||||
if (ddsPreview == null) {
|
|
||||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
|
||||||
}
|
|
||||||
ddsPreview.requestPreview(selected, "", 80, 80, singlePic, null);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
|
||||||
singlePic.setIcon(newicon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_singleTexLoadButtonActionPerformed
|
}//GEN-LAST:event_singleTexLoadButtonActionPerformed
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user