Skip to content

Commit bc9c4e9

Browse files
authored
Merge pull request #604 from neph1/Issue#582
Add WireBox and WireSphere to primitives
2 parents fff86a4 + 4f452ea commit bc9c4e9

File tree

4 files changed

+392
-0
lines changed

4 files changed

+392
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2009-2024 jMonkeyEngine
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
package com.jme3.gde.core.sceneexplorer.nodes.actions.impl;
33+
34+
import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractNewSpatialAction;
35+
import com.jme3.gde.core.sceneexplorer.nodes.actions.NewGeometryAction;
36+
import com.jme3.gde.core.sceneexplorer.nodes.primitives.CreateBoxPanel;
37+
import com.jme3.math.Vector3f;
38+
import com.jme3.scene.Geometry;
39+
import com.jme3.scene.Node;
40+
import com.jme3.scene.Spatial;
41+
import com.jme3.scene.debug.WireBox;
42+
import org.openide.DialogDescriptor;
43+
import org.openide.DialogDisplayer;
44+
import org.openide.NotifyDescriptor;
45+
46+
/**
47+
* Action to create a new primitive (WireBox)
48+
*
49+
* @author MeFisto94
50+
* @author david.bernard.31
51+
*/
52+
@org.openide.util.lookup.ServiceProvider(service = NewGeometryAction.class)
53+
public class NewGeometryWireBoxAction extends AbstractNewSpatialAction implements NewGeometryAction {
54+
55+
CreateBoxPanel form;
56+
57+
public NewGeometryWireBoxAction() {
58+
name = "WireBox";
59+
form = new CreateBoxPanel();
60+
}
61+
62+
@Override
63+
protected boolean prepareCreateSpatial() {
64+
String msg = "Create new WireBox";
65+
Object result = DialogDisplayer.getDefault().notify(
66+
new DialogDescriptor(form, msg));
67+
return (result == NotifyDescriptor.OK_OPTION);
68+
}
69+
70+
@Override
71+
protected Spatial doCreateSpatial(Node parent) {
72+
Vector3f ext = form.getBoxExtents();
73+
Geometry geom = form.getNewGeomPanel().handleGeometry(
74+
pm, new WireBox(ext.x, ext.y, ext.z));
75+
return geom;
76+
}
77+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (c) 2009-2024 jMonkeyEngine
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
package com.jme3.gde.core.sceneexplorer.nodes.actions.impl;
33+
34+
import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractNewSpatialAction;
35+
import com.jme3.gde.core.sceneexplorer.nodes.actions.NewGeometryAction;
36+
import com.jme3.gde.core.sceneexplorer.nodes.primitives.CreateWireSpherePanel;
37+
import com.jme3.scene.Geometry;
38+
import com.jme3.scene.Node;
39+
import com.jme3.scene.Spatial;
40+
import com.jme3.scene.debug.WireSphere;
41+
import org.openide.DialogDescriptor;
42+
import org.openide.DialogDisplayer;
43+
import org.openide.NotifyDescriptor;
44+
45+
/**
46+
* Action to create a new primitive (WireSphere)
47+
*
48+
* @author MeFisto94
49+
* @author david.bernard.31
50+
*/
51+
@org.openide.util.lookup.ServiceProvider(service = NewGeometryAction.class)
52+
public class NewGeometryWireSphereAction extends AbstractNewSpatialAction implements NewGeometryAction {
53+
54+
CreateWireSpherePanel form;
55+
56+
public NewGeometryWireSphereAction() {
57+
name = "WireSphere";
58+
form = new CreateWireSpherePanel();
59+
}
60+
61+
@Override
62+
protected Spatial doCreateSpatial(Node parent) {
63+
Geometry geom = form.getNewGeomPanel().handleGeometry(
64+
pm, new WireSphere(form.getRadius()));
65+
return geom;
66+
}
67+
68+
@Override
69+
protected boolean prepareCreateSpatial() {
70+
String msg = "Create new WireSphere";
71+
Object result = DialogDisplayer.getDefault().notify(
72+
new DialogDescriptor(form, msg));
73+
return (result == NotifyDescriptor.OK_OPTION);
74+
}
75+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4+
<AuxValues>
5+
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
6+
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
7+
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
8+
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
9+
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
10+
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
11+
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
12+
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
13+
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
14+
</AuxValues>
15+
16+
<Layout>
17+
<DimensionLayout dim="0">
18+
<Group type="103" groupAlignment="0" attributes="0">
19+
<Group type="102" alignment="0" attributes="0">
20+
<EmptySpace max="-2" attributes="0"/>
21+
<Group type="103" groupAlignment="0" max="-2" attributes="0">
22+
<Component id="abstractNewGeometryPanel1" max="32767" attributes="0"/>
23+
<Component id="jPanel1" max="32767" attributes="0"/>
24+
</Group>
25+
<EmptySpace max="32767" attributes="0"/>
26+
</Group>
27+
</Group>
28+
</DimensionLayout>
29+
<DimensionLayout dim="1">
30+
<Group type="103" groupAlignment="0" attributes="0">
31+
<Group type="102" alignment="0" attributes="0">
32+
<EmptySpace max="32767" attributes="0"/>
33+
<Component id="abstractNewGeometryPanel1" min="-2" max="-2" attributes="0"/>
34+
<EmptySpace max="-2" attributes="0"/>
35+
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
36+
</Group>
37+
</Group>
38+
</DimensionLayout>
39+
</Layout>
40+
<SubComponents>
41+
<Component class="com.jme3.gde.core.sceneexplorer.nodes.actions.impl.AbstractNewGeometryPanel" name="abstractNewGeometryPanel1">
42+
<Properties>
43+
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
44+
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
45+
<TitledBorder title="General Geometry Settings">
46+
<ResourceString PropertyName="titleX" bundle="com/jme3/gde/core/sceneexplorer/nodes/primitives/Bundle.properties" key="CreateWireSpherePanel.abstractNewGeometryPanel1.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
47+
</TitledBorder>
48+
</Border>
49+
</Property>
50+
</Properties>
51+
</Component>
52+
<Container class="javax.swing.JPanel" name="jPanel1">
53+
<Properties>
54+
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
55+
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
56+
<TitledBorder title="Sphere Specific Settings">
57+
<ResourceString PropertyName="titleX" bundle="com/jme3/gde/core/sceneexplorer/nodes/primitives/Bundle.properties" key="CreateWireSpherePanel.jPanel1.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
58+
</TitledBorder>
59+
</Border>
60+
</Property>
61+
</Properties>
62+
63+
<Layout>
64+
<DimensionLayout dim="0">
65+
<Group type="103" groupAlignment="0" attributes="0">
66+
<Group type="102" attributes="0">
67+
<EmptySpace max="-2" attributes="0"/>
68+
<Component id="lblRadius" min="-2" max="-2" attributes="0"/>
69+
<EmptySpace max="-2" attributes="0"/>
70+
<Component id="spinnerRadius" pref="394" max="32767" attributes="0"/>
71+
<EmptySpace max="-2" attributes="0"/>
72+
</Group>
73+
</Group>
74+
</DimensionLayout>
75+
<DimensionLayout dim="1">
76+
<Group type="103" groupAlignment="0" attributes="0">
77+
<Group type="102" alignment="0" attributes="0">
78+
<EmptySpace max="-2" attributes="0"/>
79+
<Group type="103" groupAlignment="3" attributes="0">
80+
<Component id="spinnerRadius" alignment="3" min="-2" max="-2" attributes="0"/>
81+
<Component id="lblRadius" alignment="3" min="-2" max="-2" attributes="0"/>
82+
</Group>
83+
<EmptySpace max="32767" attributes="0"/>
84+
</Group>
85+
</Group>
86+
</DimensionLayout>
87+
</Layout>
88+
<SubComponents>
89+
<Component class="javax.swing.JSpinner" name="spinnerRadius">
90+
<Properties>
91+
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
92+
<SpinnerModel initial="0.5" numberType="java.lang.Float" stepSize="0.01" type="number"/>
93+
</Property>
94+
</Properties>
95+
</Component>
96+
<Component class="javax.swing.JLabel" name="lblRadius">
97+
<Properties>
98+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
99+
<ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/primitives/Bundle.properties" key="CreateWireSpherePanel.lblRadius.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
100+
</Property>
101+
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
102+
<ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/primitives/Bundle.properties" key="CreateWireSpherePanel.lblRadius.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
103+
</Property>
104+
<Property name="name" type="java.lang.String" value="" noResource="true"/>
105+
</Properties>
106+
</Component>
107+
</SubComponents>
108+
</Container>
109+
</SubComponents>
110+
</Form>
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
* Copyright (c) 2019- jMonkeyEngine
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
package com.jme3.gde.core.sceneexplorer.nodes.primitives;
33+
34+
import com.jme3.gde.core.sceneexplorer.nodes.actions.impl.AbstractNewGeometryPanel;
35+
36+
/**
37+
* This is the Panel which creates a new Primitive (Sphere)
38+
*
39+
* @author MeFisto94
40+
*/
41+
public class CreateWireSpherePanel extends javax.swing.JPanel {
42+
43+
/**
44+
* Creates new form CreateBoxPanel
45+
*/
46+
public CreateWireSpherePanel() {
47+
initComponents();
48+
}
49+
50+
public AbstractNewGeometryPanel getNewGeomPanel() {
51+
return abstractNewGeometryPanel1;
52+
}
53+
54+
public float getRadius() {
55+
return (float) spinnerRadius.getValue();
56+
}
57+
58+
/**
59+
* This method is called from within the constructor to initialize the form.
60+
* WARNING: Do NOT modify this code. The content of this method is always
61+
* regenerated by the Form Editor.
62+
*/
63+
@SuppressWarnings("unchecked")
64+
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
65+
private void initComponents() {
66+
67+
abstractNewGeometryPanel1 = new com.jme3.gde.core.sceneexplorer.nodes.actions.impl.AbstractNewGeometryPanel();
68+
jPanel1 = new javax.swing.JPanel();
69+
spinnerRadius = new javax.swing.JSpinner();
70+
lblRadius = new javax.swing.JLabel();
71+
72+
abstractNewGeometryPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(CreateWireSpherePanel.class, "CreateWireSpherePanel.abstractNewGeometryPanel1.border.title"))); // NOI18N
73+
74+
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(CreateWireSpherePanel.class, "CreateWireSpherePanel.jPanel1.border.title"))); // NOI18N
75+
76+
spinnerRadius.setModel(new javax.swing.SpinnerNumberModel(0.5f, null, null, 0.01f));
77+
78+
org.openide.awt.Mnemonics.setLocalizedText(lblRadius, org.openide.util.NbBundle.getMessage(CreateWireSpherePanel.class, "CreateWireSpherePanel.lblRadius.text")); // NOI18N
79+
lblRadius.setToolTipText(org.openide.util.NbBundle.getMessage(CreateWireSpherePanel.class, "CreateWireSpherePanel.lblRadius.toolTipText")); // NOI18N
80+
lblRadius.setName(""); // NOI18N
81+
82+
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
83+
jPanel1.setLayout(jPanel1Layout);
84+
jPanel1Layout.setHorizontalGroup(
85+
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
86+
.addGroup(jPanel1Layout.createSequentialGroup()
87+
.addContainerGap()
88+
.addComponent(lblRadius)
89+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
90+
.addComponent(spinnerRadius, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)
91+
.addContainerGap())
92+
);
93+
jPanel1Layout.setVerticalGroup(
94+
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
95+
.addGroup(jPanel1Layout.createSequentialGroup()
96+
.addContainerGap()
97+
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
98+
.addComponent(spinnerRadius, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
99+
.addComponent(lblRadius))
100+
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
101+
);
102+
103+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
104+
this.setLayout(layout);
105+
layout.setHorizontalGroup(
106+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
107+
.addGroup(layout.createSequentialGroup()
108+
.addContainerGap()
109+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
110+
.addComponent(abstractNewGeometryPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
111+
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
112+
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
113+
);
114+
layout.setVerticalGroup(
115+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
116+
.addGroup(layout.createSequentialGroup()
117+
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
118+
.addComponent(abstractNewGeometryPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
119+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
120+
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
121+
);
122+
}// </editor-fold>//GEN-END:initComponents
123+
124+
// Variables declaration - do not modify//GEN-BEGIN:variables
125+
private com.jme3.gde.core.sceneexplorer.nodes.actions.impl.AbstractNewGeometryPanel abstractNewGeometryPanel1;
126+
private javax.swing.JPanel jPanel1;
127+
private javax.swing.JLabel lblRadius;
128+
private javax.swing.JSpinner spinnerRadius;
129+
// End of variables declaration//GEN-END:variables
130+
}

0 commit comments

Comments
 (0)