Merge branch 'master' into PBRisComing
This commit is contained in:
commit
fcff7f6933
@ -176,7 +176,7 @@ public class NewtMouseInput implements MouseInput, MouseListener {
|
||||
|
||||
// invert DY
|
||||
int actualX = lastKnownLocation.getX();
|
||||
int actualY = component.getHeight() - lastKnownLocation.getY();
|
||||
int actualY = component.getSurfaceHeight() - lastKnownLocation.getY();
|
||||
MouseMotionEvent evt = new MouseMotionEvent(actualX, actualY,
|
||||
newX - lastEventX,
|
||||
lastEventY - newY,
|
||||
@ -215,7 +215,7 @@ public class NewtMouseInput implements MouseInput, MouseListener {
|
||||
|
||||
@Override
|
||||
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());
|
||||
synchronized (eventQueue) {
|
||||
eventQueue.add(evt);
|
||||
@ -224,7 +224,7 @@ public class NewtMouseInput implements MouseInput, MouseListener {
|
||||
|
||||
@Override
|
||||
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());
|
||||
synchronized (eventQueue) {
|
||||
eventQueue.add(evt);
|
||||
@ -285,8 +285,8 @@ public class NewtMouseInput implements MouseInput, MouseListener {
|
||||
private void recenterMouse(final GLWindow component) {
|
||||
eventsSinceRecenter = 0;
|
||||
isRecentering = true;
|
||||
centerLocation.setX(component.getWidth() / 2);
|
||||
centerLocation.setY(component.getHeight() / 2);
|
||||
centerLocation.setX(component.getSurfaceWidth() / 2);
|
||||
centerLocation.setY(component.getSurfaceHeight() / 2);
|
||||
centerLocationOnScreen.setX(centerLocation.getX());
|
||||
centerLocationOnScreen.setY(centerLocation.getY());
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
|
@ -31,9 +31,8 @@
|
||||
*/
|
||||
package com.jme3.gde.core.properties;
|
||||
|
||||
import com.jme3.asset.TextureKey;
|
||||
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.texture.Texture;
|
||||
import java.awt.event.MouseEvent;
|
||||
@ -42,6 +41,7 @@ import java.awt.event.WindowListener;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.DefaultListSelectionModel;
|
||||
@ -52,8 +52,6 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import jme3tools.converters.ImageToAwt;
|
||||
import org.openide.util.ImageUtilities;
|
||||
|
||||
/**
|
||||
* Displays all textures in the ProjectAssetManager,
|
||||
@ -68,7 +66,7 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection
|
||||
|
||||
private ProjectAssetManager assetManager;
|
||||
private TexturePropertyEditor editor;
|
||||
private DDSPreview ddsPreview;
|
||||
private TexturePreview texPreview;
|
||||
private Preferences prefs;
|
||||
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()) {
|
||||
String selected = TreeUtil.getPath(node.getUserObjectPath());
|
||||
selected = selected.substring(0, selected.lastIndexOf("/"));
|
||||
Texture tex = assetManager.loadTexture(selected);
|
||||
editor.setValue(tex);
|
||||
// Texture tex = assetManager.loadTexture(selected);
|
||||
// editor.setValue(tex);
|
||||
editor.setAsText(selected);
|
||||
return true;
|
||||
}
|
||||
@ -270,7 +268,7 @@ private void noTexturebuttonActionPerformed(java.awt.event.ActionEvent evt) {//G
|
||||
|
||||
private void setSelectedTexture(Texture texture) {
|
||||
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("/");
|
||||
TreePath parent = new TreePath((TreeNode) jTree1.getModel().getRoot());
|
||||
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) {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
|
||||
|
||||
@ -295,25 +294,14 @@ private void noTexturebuttonActionPerformed(java.awt.event.ActionEvent evt) {//G
|
||||
return;
|
||||
}
|
||||
|
||||
//Object nodeInfo = node.getUserObject();
|
||||
if (node.isLeaf()) {
|
||||
String selected = TreeUtil.getPath(node.getUserObjectPath());
|
||||
selected = selected.substring(0, selected.lastIndexOf("/"));
|
||||
Icon newicon = null;
|
||||
if (selected.toLowerCase().endsWith(".dds")) {
|
||||
if (ddsPreview == null) {
|
||||
ddsPreview = new DDSPreview(assetManager);
|
||||
if (texPreview == null) {
|
||||
texPreview = new TexturePreview(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);
|
||||
} else {
|
||||
imagePreviewLabel.setIcon(null);
|
||||
@ -323,27 +311,34 @@ private void noTexturebuttonActionPerformed(java.awt.event.ActionEvent evt) {//G
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
if (ddsPreview != null) {
|
||||
ddsPreview.cleanUp();
|
||||
if (texPreview != null) {
|
||||
texPreview.cleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowIconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,14 @@ public class TexturePropertyEditor implements PropertyEditor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
if(texture == null && assetKey != null){
|
||||
if (manager == null){
|
||||
manager = SceneApplication.getApplication().getAssetManager();
|
||||
}
|
||||
texture = manager.loadTexture(assetKey);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -6,9 +6,8 @@ varying vec2 texCoord;
|
||||
|
||||
void main(){
|
||||
float depthx = floor(texCoord.x);
|
||||
float depthy=(m_Rows-1.0) - floor(texCoord.y);
|
||||
//vec3 texC=vec3(texCoord.x,texCoord.y ,0.7);//
|
||||
float depthy = (float(m_Rows) - 1.0) - floor(texCoord.y);
|
||||
|
||||
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);
|
||||
}
|
@ -13,7 +13,7 @@ package com.jme3.gde.materials.multiview.widgets;
|
||||
import com.jme3.asset.AssetNotFoundException;
|
||||
import com.jme3.gde.core.assets.ProjectAssetManager;
|
||||
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.multiview.MaterialEditorTopComponent;
|
||||
import com.jme3.texture.Texture;
|
||||
@ -39,7 +39,7 @@ public class TexturePanel extends MaterialPropertyWidget {
|
||||
private boolean flip = false;
|
||||
private boolean repeat = false;
|
||||
private String textureName = null;
|
||||
private DDSPreview ddsPreview;
|
||||
private TexturePreview texPreview;
|
||||
private final ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
|
||||
|
||||
/** Creates new form SelectionPanel */
|
||||
@ -53,22 +53,13 @@ public class TexturePanel extends MaterialPropertyWidget {
|
||||
if (!"".equals(textureName)) {
|
||||
exec.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
Texture tex = manager.loadTexture(textureName);
|
||||
if (textureName.toLowerCase().endsWith(".dds")) {
|
||||
if (ddsPreview == null) {
|
||||
ddsPreview = new DDSPreview(manager);
|
||||
}
|
||||
ddsPreview.requestPreview(textureName, "", 80, 80, 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);
|
||||
}
|
||||
});
|
||||
if (texPreview == null) {
|
||||
texPreview = new TexturePreview(manager);
|
||||
}
|
||||
texPreview.requestPreview(textureName, "", 80, 25, texturePreview, null);
|
||||
} catch (AssetNotFoundException a) {
|
||||
Logger.getLogger(MaterialEditorTopComponent.class.getName()).log(Level.WARNING, "Could not load texture {0}", textureName);
|
||||
}
|
||||
@ -318,8 +309,8 @@ public class TexturePanel extends MaterialPropertyWidget {
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
if (ddsPreview != null) {
|
||||
ddsPreview.cleanUp();
|
||||
if (texPreview != null) {
|
||||
texPreview.cleanUp();
|
||||
}
|
||||
exec.shutdownNow();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ package com.jme3.gde.terraineditor;
|
||||
import com.jme3.gde.core.assets.AssetDataObject;
|
||||
import com.jme3.gde.core.assets.ProjectAssetManager;
|
||||
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.SceneApplication;
|
||||
import com.jme3.gde.core.scene.SceneListener;
|
||||
@ -122,7 +122,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
|
||||
//private TerrainNodeListener terrainDeletedNodeListener;
|
||||
private boolean availableNormalTextures;
|
||||
private HelpCtx ctx = new HelpCtx("sdk.terrain_editor");
|
||||
private DDSPreview ddsPreview;
|
||||
private TexturePreview texPreview;
|
||||
private Map<String, JButton> buttons = new HashMap<String, JButton>();
|
||||
private JPanel insideToolSettings;
|
||||
|
||||
@ -153,35 +153,29 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
|
||||
private float max = 0;
|
||||
private final Object lock = new Object();
|
||||
|
||||
@Override
|
||||
public void incrementProgress(float f) {
|
||||
progress += f;
|
||||
progressHandle.progress((int) progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMonitorMax(float f) {
|
||||
max = f;
|
||||
// java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
// synchronized(lock){
|
||||
if (progressHandle == null) {
|
||||
progressHandle = ProgressHandleFactory.createHandle("Calculating terrain entropies...");
|
||||
progressHandle.start((int) max);
|
||||
}
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMonitorMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void progressComplete() {
|
||||
// SwingUtilities.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
progressHandle.finish();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
@ -1632,6 +1626,13 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
|
||||
|
||||
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) {
|
||||
|
||||
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 = SceneApplication.getApplication().getAssetManager().loadTexture((String)value);
|
||||
if (tex != null) {
|
||||
String selected = tex.getKey().getName();
|
||||
|
||||
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);
|
||||
}
|
||||
getTexturePreview().requestPreview(selected, "", 80, 80, lbl, null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1694,24 +1683,17 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
|
||||
TexturePropertyEditor editor = new TexturePropertyEditor(selectedTex);
|
||||
Component view = editor.getCustomEditor();
|
||||
view.setVisible(true);
|
||||
Texture tex = (Texture) editor.getValue();
|
||||
if (editor.getValue() != null) {
|
||||
String selected = tex.getKey().getName();
|
||||
|
||||
if (selected.toLowerCase().endsWith(".dds")) {
|
||||
if (ddsPreview == null) {
|
||||
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
|
||||
}
|
||||
ddsPreview.requestPreview(selected, "", 80, 80, lbl, null);
|
||||
if (editor.getAsText() != null) {
|
||||
|
||||
} else {
|
||||
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
|
||||
lbl.setIcon(newicon);
|
||||
}
|
||||
String selected = editor.getAsText();
|
||||
getTexturePreview().requestPreview(selected, "", 80, 80, lbl, null);
|
||||
Texture tex = SceneApplication.getApplication().getAssetManager().loadTexture(selected);
|
||||
setTextureInModel(row, tex);
|
||||
} else if (supportsNullTexture()) {
|
||||
lbl.setIcon(null);
|
||||
}
|
||||
setTextureInModel(row, tex);
|
||||
|
||||
} finally {
|
||||
alreadyChoosing = false;
|
||||
}
|
||||
|
@ -261,7 +261,6 @@ public class TerrainToolController extends SceneToolController {
|
||||
*/
|
||||
void doTerrainEditToolActionEnded() {
|
||||
if (terrainTool != null) {
|
||||
System.out.println("undo tagged");
|
||||
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.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.texture.Texture;
|
||||
import com.jme3.util.SkyFactory;
|
||||
import java.awt.Component;
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import jme3tools.converters.ImageToAwt;
|
||||
@ -50,7 +48,7 @@ import org.openide.util.ImageUtilities;
|
||||
|
||||
public final class SkyboxVisualPanel2 extends JPanel {
|
||||
|
||||
private DDSPreview ddsPreview;
|
||||
private TexturePreview texPreview;
|
||||
|
||||
/** Creates new form SkyboxVisualPanel2 */
|
||||
public SkyboxVisualPanel2() {
|
||||
@ -111,6 +109,14 @@ public final class SkyboxVisualPanel2 extends JPanel {
|
||||
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
|
||||
* initialize the form.
|
||||
* 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
|
||||
Component view = editorSouth.getCustomEditor();
|
||||
view.setVisible(true);
|
||||
if (editorSouth.getValue() != null) {
|
||||
Texture tex = (Texture) editorSouth.getValue();
|
||||
String selected = tex.getKey().getName();
|
||||
|
||||
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);
|
||||
}
|
||||
if (editorSouth.getAsText()!= null) {
|
||||
String selected = editorSouth.getAsText();
|
||||
getTexturePreview().requestPreview(selected, "", 80, 80, southPic, null);
|
||||
}
|
||||
}//GEN-LAST:event_multipleTexSouthLoadButtonActionPerformed
|
||||
|
||||
private void multipleTexNorthLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexNorthLoadButtonActionPerformed
|
||||
Component view = editorNorth.getCustomEditor();
|
||||
view.setVisible(true);
|
||||
if (editorNorth.getValue() != null) {
|
||||
Texture tex = (Texture) editorNorth.getValue();
|
||||
String selected = tex.getKey().getName();
|
||||
|
||||
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);
|
||||
}
|
||||
if (editorNorth.getAsText() != null) {
|
||||
String selected = editorNorth.getAsText();
|
||||
getTexturePreview().requestPreview(selected, "", 80, 80, northPic, null);
|
||||
}
|
||||
}//GEN-LAST:event_multipleTexNorthLoadButtonActionPerformed
|
||||
|
||||
private void multipleTexEastLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexEastLoadButtonActionPerformed
|
||||
Component view = editorEast.getCustomEditor();
|
||||
view.setVisible(true);
|
||||
if (editorEast.getValue() != null) {
|
||||
Texture tex = (Texture) editorEast.getValue();
|
||||
String selected = tex.getKey().getName();
|
||||
|
||||
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);
|
||||
}
|
||||
if (editorEast.getAsText() != null) {
|
||||
String selected = editorEast.getAsText();
|
||||
getTexturePreview().requestPreview(selected, "", 80, 80, eastPic, null);
|
||||
}
|
||||
}//GEN-LAST:event_multipleTexEastLoadButtonActionPerformed
|
||||
|
||||
private void multipleTexWestLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexWestLoadButtonActionPerformed
|
||||
Component view = editorWest.getCustomEditor();
|
||||
view.setVisible(true);
|
||||
if (editorWest.getValue() != null) {
|
||||
Texture tex = (Texture) editorWest.getValue();
|
||||
String selected = tex.getKey().getName();
|
||||
|
||||
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);
|
||||
}
|
||||
if (editorWest.getAsText() != null) {
|
||||
String selected = editorWest.getAsText();
|
||||
getTexturePreview().requestPreview(selected, "", 80, 80, westPic, null);
|
||||
}
|
||||
}//GEN-LAST:event_multipleTexWestLoadButtonActionPerformed
|
||||
|
||||
private void multipleTexTopLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexTopLoadButtonActionPerformed
|
||||
Component view = editorTop.getCustomEditor();
|
||||
view.setVisible(true);
|
||||
if (editorTop.getValue() != null) {
|
||||
Texture tex = (Texture) editorTop.getValue();
|
||||
String selected = tex.getKey().getName();
|
||||
|
||||
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);
|
||||
}
|
||||
if (editorTop.getAsText() != null) {
|
||||
String selected = editorTop.getAsText();
|
||||
getTexturePreview().requestPreview(selected, "", 80, 80, topPic, null);
|
||||
}
|
||||
}//GEN-LAST:event_multipleTexTopLoadButtonActionPerformed
|
||||
|
||||
private void multipleTexBottomLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexBottomLoadButtonActionPerformed
|
||||
Component view = editorBottom.getCustomEditor();
|
||||
view.setVisible(true);
|
||||
if (editorBottom.getValue() != null) {
|
||||
Texture tex = (Texture) editorBottom.getValue();
|
||||
String selected = tex.getKey().getName();
|
||||
|
||||
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);
|
||||
}
|
||||
if (editorBottom.getAsText() != null) {
|
||||
String selected = editorBottom.getAsText();
|
||||
getTexturePreview().requestPreview(selected, "", 80, 80, bottomPic, null);
|
||||
}
|
||||
}//GEN-LAST:event_multipleTexBottomLoadButtonActionPerformed
|
||||
|
||||
private void singleTexLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_singleTexLoadButtonActionPerformed
|
||||
Component view = editorSingle.getCustomEditor();
|
||||
view.setVisible(true);
|
||||
if (editorSingle.getValue() != null) {
|
||||
Texture tex = (Texture) editorSingle.getValue();
|
||||
String selected = tex.getKey().getName();
|
||||
|
||||
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);
|
||||
}
|
||||
if (editorSingle.getAsText()!= null) {
|
||||
String selected = editorSingle.getAsText();
|
||||
getTexturePreview().requestPreview(selected, "", 80, 80, singlePic, null);
|
||||
}
|
||||
}//GEN-LAST:event_singleTexLoadButtonActionPerformed
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user