From 4f452eaa4935560b4c71e250cb4714f9669bce7a Mon Sep 17 00:00:00 2001 From: rickard Date: Mon, 29 Apr 2024 20:33:58 +0200 Subject: [PATCH] Add WireBox and WireSphere to primitives --- .../impl/NewGeometryWireBoxAction.java | 77 +++++++++++ .../impl/NewGeometryWireSphereAction.java | 75 ++++++++++ .../primitives/CreateWireSpherePanel.form | 110 +++++++++++++++ .../primitives/CreateWireSpherePanel.java | 130 ++++++++++++++++++ 4 files changed, 392 insertions(+) create mode 100644 jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryWireBoxAction.java create mode 100644 jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryWireSphereAction.java create mode 100644 jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateWireSpherePanel.form create mode 100644 jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateWireSpherePanel.java diff --git a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryWireBoxAction.java b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryWireBoxAction.java new file mode 100644 index 00000000..233fe750 --- /dev/null +++ b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryWireBoxAction.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2009-2024 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.actions.impl; + +import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractNewSpatialAction; +import com.jme3.gde.core.sceneexplorer.nodes.actions.NewGeometryAction; +import com.jme3.gde.core.sceneexplorer.nodes.primitives.CreateBoxPanel; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.scene.debug.WireBox; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; + +/** + * Action to create a new primitive (WireBox) + * + * @author MeFisto94 + * @author david.bernard.31 + */ +@org.openide.util.lookup.ServiceProvider(service = NewGeometryAction.class) +public class NewGeometryWireBoxAction extends AbstractNewSpatialAction implements NewGeometryAction { + + CreateBoxPanel form; + + public NewGeometryWireBoxAction() { + name = "WireBox"; + form = new CreateBoxPanel(); + } + + @Override + protected boolean prepareCreateSpatial() { + String msg = "Create new WireBox"; + Object result = DialogDisplayer.getDefault().notify( + new DialogDescriptor(form, msg)); + return (result == NotifyDescriptor.OK_OPTION); + } + + @Override + protected Spatial doCreateSpatial(Node parent) { + Vector3f ext = form.getBoxExtents(); + Geometry geom = form.getNewGeomPanel().handleGeometry( + pm, new WireBox(ext.x, ext.y, ext.z)); + return geom; + } +} diff --git a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryWireSphereAction.java b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryWireSphereAction.java new file mode 100644 index 00000000..c99c9c28 --- /dev/null +++ b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryWireSphereAction.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2009-2024 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.actions.impl; + +import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractNewSpatialAction; +import com.jme3.gde.core.sceneexplorer.nodes.actions.NewGeometryAction; +import com.jme3.gde.core.sceneexplorer.nodes.primitives.CreateWireSpherePanel; +import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.scene.debug.WireSphere; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; + +/** + * Action to create a new primitive (WireSphere) + * + * @author MeFisto94 + * @author david.bernard.31 + */ +@org.openide.util.lookup.ServiceProvider(service = NewGeometryAction.class) +public class NewGeometryWireSphereAction extends AbstractNewSpatialAction implements NewGeometryAction { + + CreateWireSpherePanel form; + + public NewGeometryWireSphereAction() { + name = "WireSphere"; + form = new CreateWireSpherePanel(); + } + + @Override + protected Spatial doCreateSpatial(Node parent) { + Geometry geom = form.getNewGeomPanel().handleGeometry( + pm, new WireSphere(form.getRadius())); + return geom; + } + + @Override + protected boolean prepareCreateSpatial() { + String msg = "Create new WireSphere"; + Object result = DialogDisplayer.getDefault().notify( + new DialogDescriptor(form, msg)); + return (result == NotifyDescriptor.OK_OPTION); + } +} diff --git a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateWireSpherePanel.form b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateWireSpherePanel.form new file mode 100644 index 00000000..15b570c8 --- /dev/null +++ b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateWireSpherePanel.form @@ -0,0 +1,110 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateWireSpherePanel.java b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateWireSpherePanel.java new file mode 100644 index 00000000..9a258fa8 --- /dev/null +++ b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateWireSpherePanel.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2019- 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.primitives; + +import com.jme3.gde.core.sceneexplorer.nodes.actions.impl.AbstractNewGeometryPanel; + +/** + * This is the Panel which creates a new Primitive (Sphere) + * + * @author MeFisto94 + */ +public class CreateWireSpherePanel extends javax.swing.JPanel { + + /** + * Creates new form CreateBoxPanel + */ + public CreateWireSpherePanel() { + initComponents(); + } + + public AbstractNewGeometryPanel getNewGeomPanel() { + return abstractNewGeometryPanel1; + } + + public float getRadius() { + return (float) spinnerRadius.getValue(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + abstractNewGeometryPanel1 = new com.jme3.gde.core.sceneexplorer.nodes.actions.impl.AbstractNewGeometryPanel(); + jPanel1 = new javax.swing.JPanel(); + spinnerRadius = new javax.swing.JSpinner(); + lblRadius = new javax.swing.JLabel(); + + abstractNewGeometryPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(CreateWireSpherePanel.class, "CreateWireSpherePanel.abstractNewGeometryPanel1.border.title"))); // NOI18N + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(CreateWireSpherePanel.class, "CreateWireSpherePanel.jPanel1.border.title"))); // NOI18N + + spinnerRadius.setModel(new javax.swing.SpinnerNumberModel(0.5f, null, null, 0.01f)); + + org.openide.awt.Mnemonics.setLocalizedText(lblRadius, org.openide.util.NbBundle.getMessage(CreateWireSpherePanel.class, "CreateWireSpherePanel.lblRadius.text")); // NOI18N + lblRadius.setToolTipText(org.openide.util.NbBundle.getMessage(CreateWireSpherePanel.class, "CreateWireSpherePanel.lblRadius.toolTipText")); // NOI18N + lblRadius.setName(""); // NOI18N + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(lblRadius) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(spinnerRadius, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(spinnerRadius, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblRadius)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(abstractNewGeometryPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(abstractNewGeometryPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private com.jme3.gde.core.sceneexplorer.nodes.actions.impl.AbstractNewGeometryPanel abstractNewGeometryPanel1; + private javax.swing.JPanel jPanel1; + private javax.swing.JLabel lblRadius; + private javax.swing.JSpinner spinnerRadius; + // End of variables declaration//GEN-END:variables +}