sdk : added spot light support to jmp
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7895 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
58d485467a
commit
53354f5dda
@ -39,6 +39,7 @@ import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.light.LightList;
|
||||
import com.jme3.light.PointLight;
|
||||
import com.jme3.light.SpotLight;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Spatial;
|
||||
@ -170,6 +171,9 @@ public class JmeSpatialChildren extends Children.Keys<Object> {
|
||||
if (pair.getLight() instanceof PointLight) {
|
||||
return new Node[]{new JmePointLight(pair.getSpatial(), (PointLight) pair.getLight()).setReadOnly(readOnly)};
|
||||
}
|
||||
if (pair.getLight() instanceof SpotLight) {
|
||||
return new Node[]{new JmeSpotLight(pair.getSpatial(), (SpotLight) pair.getLight()).setReadOnly(readOnly)};
|
||||
}
|
||||
if (pair.getLight() instanceof DirectionalLight) {
|
||||
return new Node[]{new JmeDirectionalLight(pair.getSpatial(), (DirectionalLight) pair.getLight()).setReadOnly(readOnly)};
|
||||
}
|
||||
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.sceneexplorer.nodes;
|
||||
|
||||
|
||||
import com.jme3.light.SpotLight;
|
||||
import com.jme3.scene.Spatial;
|
||||
import org.openide.cookies.SaveCookie;
|
||||
import org.openide.loaders.DataObject;
|
||||
import org.openide.nodes.Sheet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author normenhansen
|
||||
*/
|
||||
@org.openide.util.lookup.ServiceProvider(service=SceneExplorerNode.class)
|
||||
public class JmeSpotLight extends JmeLight{
|
||||
SpotLight spotLight;
|
||||
|
||||
public JmeSpotLight() {
|
||||
}
|
||||
|
||||
public JmeSpotLight(Spatial spatial, SpotLight spotLight) {
|
||||
super(spatial, spotLight);
|
||||
this.spotLight = spotLight;
|
||||
lookupContents.add(spotLight);
|
||||
setName("SpotLight");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sheet createSheet() {
|
||||
//TODO: multithreading..
|
||||
Sheet sheet = super.createSheet();
|
||||
Sheet.Set set = Sheet.createPropertiesSet();
|
||||
set.setDisplayName("SpotLight");
|
||||
set.setName(SpotLight.class.getName());
|
||||
SpotLight obj = spotLight;
|
||||
if (obj == null) {
|
||||
return sheet;
|
||||
}
|
||||
|
||||
createFields(SpotLight.class, set, obj);
|
||||
|
||||
sheet.put(set);
|
||||
return sheet;
|
||||
|
||||
}
|
||||
|
||||
public Class getExplorerObjectClass() {
|
||||
return SpotLight.class;
|
||||
}
|
||||
|
||||
public Class getExplorerNodeClass() {
|
||||
return JmeSpotLight.class;
|
||||
}
|
||||
|
||||
public org.openide.nodes.Node[] createNodes(Object key, DataObject key2, SaveCookie cookie) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -39,6 +39,7 @@ import com.jme3.light.AmbientLight;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.light.PointLight;
|
||||
import com.jme3.light.SpotLight;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Spatial;
|
||||
@ -77,6 +78,8 @@ public class NewLightPopup extends AbstractAction implements Presenter.Popup {
|
||||
result.add(new JMenuItem(new AddAmbientAction()));
|
||||
result.add(new JMenuItem(new AddDirectionalAction()));
|
||||
result.add(new JMenuItem(new AddPointAction()));
|
||||
result.add(new JMenuItem(new AddSpotAction()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -135,6 +138,28 @@ public class NewLightPopup extends AbstractAction implements Presenter.Popup {
|
||||
public Void call() throws Exception {
|
||||
PointLight light = new PointLight();
|
||||
light.setColor(ColorRGBA.White);
|
||||
node.addLight(light);
|
||||
addLightUndo(node, light);
|
||||
setModified();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private class AddSpotAction extends AbstractAction {
|
||||
|
||||
public AddSpotAction() {
|
||||
putValue(NAME, "Spot Light");
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
||||
|
||||
public Void call() throws Exception {
|
||||
SpotLight light = new SpotLight();
|
||||
light.setColor(ColorRGBA.White);
|
||||
node.addLight(light);
|
||||
addLightUndo(node, light);
|
||||
setModified();
|
||||
return null;
|
||||
|
@ -26,15 +26,14 @@ package com.jme3.gde.core.sceneviewer;
|
||||
|
||||
import com.jme3.gde.core.filters.FilterExplorerTopComponent;
|
||||
import com.jme3.gde.core.scene.SceneApplication;
|
||||
import com.jme3.gde.core.scene.controller.toolbars.CameraToolbar;
|
||||
import com.jme3.gde.core.sceneviewer.actions.ToggleOrthoPerspAction;
|
||||
import com.jme3.system.JmeCanvasContext;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JToolBar;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.windows.TopComponent;
|
||||
import org.openide.windows.WindowManager;
|
||||
@ -47,7 +46,6 @@ import org.openide.awt.UndoRedo;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.HelpCtx;
|
||||
import org.openide.util.Lookup;
|
||||
import org.openide.util.lookup.Lookups;
|
||||
|
||||
/**
|
||||
* Top component which displays something.
|
||||
@ -65,8 +63,7 @@ public final class SceneViewerTopComponent extends TopComponent {
|
||||
private SceneApplication app;
|
||||
private HelpCtx helpContext = new HelpCtx("com.jme3.gde.core.sceneviewer");
|
||||
private Canvas oglCanvas;
|
||||
//toolbar actions
|
||||
private ToggleOrthoPerspAction toggleOrthoPerspAction;
|
||||
|
||||
|
||||
public SceneViewerTopComponent() {
|
||||
initComponents();
|
||||
@ -79,7 +76,7 @@ public final class SceneViewerTopComponent extends TopComponent {
|
||||
app = SceneApplication.getApplication();
|
||||
oglCanvas = ((JmeCanvasContext) app.getContext()).getCanvas();
|
||||
oGLPanel.add(oglCanvas);
|
||||
toggleOrthoPerspAction = new ToggleOrthoPerspAction();
|
||||
|
||||
} catch (Exception e) {
|
||||
Exceptions.printStackTrace(e);
|
||||
showOpenGLError(e.toString());
|
||||
@ -117,8 +114,6 @@ public final class SceneViewerTopComponent extends TopComponent {
|
||||
jToggleButton1 = new javax.swing.JToggleButton();
|
||||
jSeparator1 = new javax.swing.JToolBar.Separator();
|
||||
enableWireframe = new javax.swing.JToggleButton();
|
||||
jSeparator2 = new javax.swing.JToolBar.Separator();
|
||||
enableOrtho = new javax.swing.JToggleButton();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
enableStats = new javax.swing.JToggleButton();
|
||||
oGLPanel = new javax.swing.JPanel();
|
||||
@ -168,27 +163,6 @@ public final class SceneViewerTopComponent extends TopComponent {
|
||||
}
|
||||
});
|
||||
jToolBar1.add(enableWireframe);
|
||||
jToolBar1.add(jSeparator2);
|
||||
|
||||
enableOrtho.setFont(new java.awt.Font("Tahoma", 0, 8)); // NOI18N
|
||||
enableOrtho.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/core/sceneviewer/icons/persp.png"))); // NOI18N
|
||||
org.openide.awt.Mnemonics.setLocalizedText(enableOrtho, org.openide.util.NbBundle.getMessage(SceneViewerTopComponent.class, "SceneViewerTopComponent.enableOrtho.text")); // NOI18N
|
||||
enableOrtho.setToolTipText(org.openide.util.NbBundle.getMessage(SceneViewerTopComponent.class, "SceneViewerTopComponent.enableOrtho.toolTipText")); // NOI18N
|
||||
enableOrtho.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
|
||||
enableOrtho.setFocusable(false);
|
||||
enableOrtho.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
|
||||
enableOrtho.setMaximumSize(new java.awt.Dimension(27, 23));
|
||||
enableOrtho.setMinimumSize(new java.awt.Dimension(27, 23));
|
||||
enableOrtho.setPreferredSize(new java.awt.Dimension(50, 23));
|
||||
enableOrtho.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/core/sceneviewer/icons/ortho.png"))); // NOI18N
|
||||
enableOrtho.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
enableOrthoActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jToolBar1.add(enableOrtho);
|
||||
enableOrtho.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SceneViewerTopComponent.class, "SceneViewerTopComponent.jToggleButton2.AccessibleContext.accessibleName")); // NOI18N
|
||||
|
||||
jToolBar1.add(jPanel1);
|
||||
|
||||
enableStats.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/core/sceneviewer/icons/65.png"))); // NOI18N
|
||||
@ -227,26 +201,17 @@ public final class SceneViewerTopComponent extends TopComponent {
|
||||
FilterExplorerTopComponent.findInstance().setFilterEnabled(jToggleButton1.isSelected());
|
||||
}//GEN-LAST:event_jToggleButton1ActionPerformed
|
||||
|
||||
private void enableOrthoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enableOrthoActionPerformed
|
||||
toggleOrthoPerspAction.actionPerformed(evt);
|
||||
}//GEN-LAST:event_enableOrthoActionPerformed
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JToggleButton enableCamLight;
|
||||
private javax.swing.JToggleButton enableOrtho;
|
||||
private javax.swing.JToggleButton enableStats;
|
||||
private javax.swing.JToggleButton enableWireframe;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JToolBar.Separator jSeparator1;
|
||||
private javax.swing.JToolBar.Separator jSeparator2;
|
||||
private javax.swing.JToggleButton jToggleButton1;
|
||||
private javax.swing.JToolBar jToolBar1;
|
||||
private javax.swing.JPanel oGLPanel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
public void toggleOrthoModeButton(boolean enabled) {
|
||||
enableOrtho.setText(NbBundle.getMessage(SceneViewerTopComponent.class, "SceneViewerTopComponent.enableOrtho.text" + (enabled ? "O" : "")));
|
||||
enableOrtho.setSelected(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets default instance. Do not use directly: reserved for *.settings files only,
|
||||
@ -359,4 +324,8 @@ private void enableOrthoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
|
||||
public UndoRedo getUndoRedo() {
|
||||
return Lookup.getDefault().lookup(UndoRedo.class);
|
||||
}
|
||||
|
||||
public void addAdditionnalToolbar(JToolBar tb){
|
||||
jToolBar1.add(tb,4);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.jme3.gde.core.sceneviewer.actions;
|
||||
|
||||
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import org.openide.awt.ActionRegistration;
|
||||
import org.openide.awt.ActionReference;
|
||||
import org.openide.awt.ActionReferences;
|
||||
import org.openide.awt.ActionID;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
|
||||
@ActionID(category = "SceneComposer",
|
||||
id = "com.jme3.gde.core.sceneviewer.actions.SwitchFrontViewAcction")
|
||||
@ActionRegistration(displayName = "#CTL_SwitchFrontViewAcction")
|
||||
@ActionReferences({
|
||||
@ActionReference(path = "Actions/jMonkeyPlatform"),
|
||||
@ActionReference(path = "Shortcuts", name = "NUMPAD1")
|
||||
})
|
||||
@Messages("CTL_SwitchFrontViewAcction=Switch to front view")
|
||||
public final class SwitchFrontViewAction implements ActionListener {
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||
if (svtc.hasFocus()) {
|
||||
System.out.println("front view");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -27,8 +27,7 @@ public final class ToggleOrthoPerspAction implements ActionListener {
|
||||
|
||||
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||
if (svtc.hasFocus()) {
|
||||
boolean toggle = SceneApplication.getApplication().toggleOrthoPerspMode();
|
||||
svtc.toggleOrthoModeButton(toggle);
|
||||
SceneApplication.getApplication().getCamController().toggleOrthoPerspMode();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user