Browse Source

fix cylinder creation

rickard 1 year ago
parent
commit
8890c8b64b

+ 3 - 7
jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryCylinderAction.java

@@ -38,7 +38,6 @@ import com.jme3.scene.Geometry;
 import com.jme3.scene.Node;
 import com.jme3.scene.Node;
 import com.jme3.scene.Spatial;
 import com.jme3.scene.Spatial;
 import com.jme3.scene.shape.Cylinder;
 import com.jme3.scene.shape.Cylinder;
-import com.jme3.scene.shape.Sphere;
 import org.openide.DialogDescriptor;
 import org.openide.DialogDescriptor;
 import org.openide.DialogDisplayer;
 import org.openide.DialogDisplayer;
 import org.openide.NotifyDescriptor;
 import org.openide.NotifyDescriptor;
@@ -60,17 +59,14 @@ public class NewGeometryCylinderAction extends AbstractNewSpatialAction implemen
 
 
     @Override
     @Override
     protected Spatial doCreateSpatial(Node parent) {
     protected Spatial doCreateSpatial(Node parent) {
-        Cylinder cylinder = new Cylinder(form.getZSamples(), form.getRadialSamples(), form.getRadius(), form.getHeight(), form.isClosed(), form.isInverted());
-        Sphere s = new Sphere(form.getZSamples(), form.getRadialSamples(),
-                form.getRadius(), form.isClosed(), form.isInverted());
-        Geometry geom = form.getNewGeomPanel().handleGeometry(pm, s);
-        // parent.attachChild(geom); // was present in previous code, but should neither be necessary nor correct
+        Cylinder cylinder = new Cylinder(form.getZSamples(), form.getRadialSamples(), form.getRadius(), form.getCylinderHeight(), form.isClosed(), form.isInverted());
+        Geometry geom = form.getNewGeomPanel().handleGeometry(pm, cylinder);
         return geom;
         return geom;
     }
     }
 
 
     @Override
     @Override
     protected boolean prepareCreateSpatial() {
     protected boolean prepareCreateSpatial() {
-        String msg = "Create new Sphere";
+        String msg = "Create new Cylinder";
         DialogDescriptor dd = new DialogDescriptor(form, msg);
         DialogDescriptor dd = new DialogDescriptor(form, msg);
         Object result = DialogDisplayer.getDefault().notify(dd);
         Object result = DialogDisplayer.getDefault().notify(dd);
         return (result == NotifyDescriptor.OK_OPTION);
         return (result == NotifyDescriptor.OK_OPTION);

+ 2 - 0
jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/Bundle.properties

@@ -36,3 +36,5 @@ CreateCylinderPanel.lblRadius.toolTipText=
 CreateCylinderPanel.checkClosed.text=Closed
 CreateCylinderPanel.checkClosed.text=Closed
 CreateCylinderPanel.checkInverted.text=Inverted
 CreateCylinderPanel.checkInverted.text=Inverted
 CreateQuadPanel.checkCentered.text=centered
 CreateQuadPanel.checkCentered.text=centered
+CreateCylinderPanel.lblHeight.toolTipText=
+CreateCylinderPanel.lblHeight.text=Height:

+ 46 - 11
jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateCylinderPanel.form

@@ -32,7 +32,7 @@
               <EmptySpace max="-2" attributes="0"/>
               <EmptySpace max="-2" attributes="0"/>
               <Component id="abstractNewGeometryPanel1" min="-2" max="-2" attributes="0"/>
               <Component id="abstractNewGeometryPanel1" min="-2" max="-2" attributes="0"/>
               <EmptySpace max="-2" attributes="0"/>
               <EmptySpace max="-2" attributes="0"/>
-              <Component id="jPanel1" pref="174" max="32767" attributes="0"/>
+              <Component id="jPanel1" max="32767" attributes="0"/>
           </Group>
           </Group>
       </Group>
       </Group>
     </DimensionLayout>
     </DimensionLayout>
@@ -73,21 +73,26 @@
                       </Group>
                       </Group>
                       <Group type="102" alignment="0" attributes="0">
                       <Group type="102" alignment="0" attributes="0">
                           <Component id="lblZSamples" min="-2" max="-2" attributes="0"/>
                           <Component id="lblZSamples" min="-2" max="-2" attributes="0"/>
-                          <EmptySpace min="-2" pref="51" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
                           <Component id="spinnerZSamples" max="32767" attributes="0"/>
                           <Component id="spinnerZSamples" max="32767" attributes="0"/>
                       </Group>
                       </Group>
                       <Group type="102" alignment="0" attributes="0">
                       <Group type="102" alignment="0" attributes="0">
                           <Component id="lblRadius" min="-2" max="-2" attributes="0"/>
                           <Component id="lblRadius" min="-2" max="-2" attributes="0"/>
-                          <EmptySpace min="-2" pref="78" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" pref="63" max="-2" attributes="0"/>
                           <Component id="spinnerRadius" max="32767" attributes="0"/>
                           <Component id="spinnerRadius" max="32767" attributes="0"/>
                       </Group>
                       </Group>
-                      <Group type="102" alignment="0" attributes="0">
+                      <Group type="102" attributes="0">
                           <Group type="103" groupAlignment="0" attributes="0">
                           <Group type="103" groupAlignment="0" attributes="0">
-                              <Component id="checkClosed" min="-2" max="-2" attributes="0"/>
-                              <Component id="checkInverted" min="-2" max="-2" attributes="0"/>
+                              <Component id="checkInverted" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="checkClosed" alignment="0" min="-2" max="-2" attributes="0"/>
                           </Group>
                           </Group>
                           <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
                           <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
                       </Group>
                       </Group>
+                      <Group type="102" alignment="0" attributes="0">
+                          <Component id="lblHeight" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" pref="66" max="-2" attributes="0"/>
+                          <Component id="spinnerHeight" max="32767" attributes="0"/>
+                      </Group>
                   </Group>
                   </Group>
                   <EmptySpace max="-2" attributes="0"/>
                   <EmptySpace max="-2" attributes="0"/>
               </Group>
               </Group>
@@ -111,11 +116,23 @@
                       <Component id="lblRadius" alignment="3" min="-2" max="-2" attributes="0"/>
                       <Component id="lblRadius" alignment="3" min="-2" max="-2" attributes="0"/>
                       <Component id="spinnerRadius" alignment="3" min="-2" max="-2" attributes="0"/>
                       <Component id="spinnerRadius" alignment="3" min="-2" max="-2" attributes="0"/>
                   </Group>
                   </Group>
-                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                  <Component id="checkClosed" min="-2" max="-2" attributes="0"/>
-                  <EmptySpace max="32767" attributes="0"/>
-                  <Component id="checkInverted" min="-2" max="-2" attributes="0"/>
-                  <EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" attributes="0">
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="lblHeight" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="spinnerHeight" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace pref="75" max="32767" attributes="0"/>
+                      </Group>
+                      <Group type="102" alignment="1" attributes="0">
+                          <EmptySpace max="32767" attributes="0"/>
+                          <Component id="checkClosed" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Component id="checkInverted" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
               </Group>
               </Group>
           </Group>
           </Group>
         </DimensionLayout>
         </DimensionLayout>
@@ -186,6 +203,24 @@
             <Property name="name" type="java.lang.String" value="" noResource="true"/>
             <Property name="name" type="java.lang.String" value="" noResource="true"/>
           </Properties>
           </Properties>
         </Component>
         </Component>
+        <Component class="javax.swing.JLabel" name="lblHeight">
+          <Properties>
+            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+              <ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/primitives/Bundle.properties" key="CreateCylinderPanel.lblHeight.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+              <ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/primitives/Bundle.properties" key="CreateCylinderPanel.lblHeight.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
+            </Property>
+            <Property name="name" type="java.lang.String" value="" noResource="true"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JSpinner" name="spinnerHeight">
+          <Properties>
+            <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
+              <SpinnerModel initial="0.5" numberType="java.lang.Float" stepSize="0.01" type="number"/>
+            </Property>
+          </Properties>
+        </Component>
       </SubComponents>
       </SubComponents>
     </Container>
     </Container>
   </SubComponents>
   </SubComponents>

+ 37 - 11
jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/primitives/CreateCylinderPanel.java

@@ -62,6 +62,10 @@ public class CreateCylinderPanel extends javax.swing.JPanel {
     public float getRadius() {
     public float getRadius() {
         return (float) spinnerRadius.getValue();
         return (float) spinnerRadius.getValue();
     }
     }
+    
+    public float getCylinderHeight() {
+        return (float) spinnerHeight.getValue();
+    }
 
 
     public boolean isClosed() {
     public boolean isClosed() {
         return checkClosed.isSelected();
         return checkClosed.isSelected();
@@ -90,6 +94,8 @@ public class CreateCylinderPanel extends javax.swing.JPanel {
         checkInverted = new javax.swing.JCheckBox();
         checkInverted = new javax.swing.JCheckBox();
         spinnerRadius = new javax.swing.JSpinner();
         spinnerRadius = new javax.swing.JSpinner();
         lblRadius = new javax.swing.JLabel();
         lblRadius = new javax.swing.JLabel();
+        lblHeight = new javax.swing.JLabel();
+        spinnerHeight = new javax.swing.JSpinner();
 
 
         abstractNewGeometryPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(CreateCylinderPanel.class, "CreateCylinderPanel.abstractNewGeometryPanel1.border.title"))); // NOI18N
         abstractNewGeometryPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(CreateCylinderPanel.class, "CreateCylinderPanel.abstractNewGeometryPanel1.border.title"))); // NOI18N
 
 
@@ -116,6 +122,12 @@ public class CreateCylinderPanel extends javax.swing.JPanel {
         lblRadius.setToolTipText(org.openide.util.NbBundle.getMessage(CreateCylinderPanel.class, "CreateCylinderPanel.lblRadius.toolTipText")); // NOI18N
         lblRadius.setToolTipText(org.openide.util.NbBundle.getMessage(CreateCylinderPanel.class, "CreateCylinderPanel.lblRadius.toolTipText")); // NOI18N
         lblRadius.setName(""); // NOI18N
         lblRadius.setName(""); // NOI18N
 
 
+        org.openide.awt.Mnemonics.setLocalizedText(lblHeight, org.openide.util.NbBundle.getMessage(CreateCylinderPanel.class, "CreateCylinderPanel.lblHeight.text")); // NOI18N
+        lblHeight.setToolTipText(org.openide.util.NbBundle.getMessage(CreateCylinderPanel.class, "CreateCylinderPanel.lblHeight.toolTipText")); // NOI18N
+        lblHeight.setName(""); // NOI18N
+
+        spinnerHeight.setModel(new javax.swing.SpinnerNumberModel(0.5f, null, null, 0.01f));
+
         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
         jPanel1.setLayout(jPanel1Layout);
         jPanel1.setLayout(jPanel1Layout);
         jPanel1Layout.setHorizontalGroup(
         jPanel1Layout.setHorizontalGroup(
@@ -129,17 +141,21 @@ public class CreateCylinderPanel extends javax.swing.JPanel {
                         .addComponent(spinnerRadialSamples))
                         .addComponent(spinnerRadialSamples))
                     .addGroup(jPanel1Layout.createSequentialGroup()
                     .addGroup(jPanel1Layout.createSequentialGroup()
                         .addComponent(lblZSamples)
                         .addComponent(lblZSamples)
-                        .addGap(51, 51, 51)
+                        .addGap(41, 41, 41)
                         .addComponent(spinnerZSamples))
                         .addComponent(spinnerZSamples))
                     .addGroup(jPanel1Layout.createSequentialGroup()
                     .addGroup(jPanel1Layout.createSequentialGroup()
                         .addComponent(lblRadius)
                         .addComponent(lblRadius)
-                        .addGap(78, 78, 78)
+                        .addGap(63, 63, 63)
                         .addComponent(spinnerRadius))
                         .addComponent(spinnerRadius))
                     .addGroup(jPanel1Layout.createSequentialGroup()
                     .addGroup(jPanel1Layout.createSequentialGroup()
                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(checkClosed)
-                            .addComponent(checkInverted))
-                        .addGap(0, 0, Short.MAX_VALUE)))
+                            .addComponent(checkInverted)
+                            .addComponent(checkClosed))
+                        .addGap(0, 0, Short.MAX_VALUE))
+                    .addGroup(jPanel1Layout.createSequentialGroup()
+                        .addComponent(lblHeight)
+                        .addGap(66, 66, 66)
+                        .addComponent(spinnerHeight)))
                 .addContainerGap())
                 .addContainerGap())
         );
         );
         jPanel1Layout.setVerticalGroup(
         jPanel1Layout.setVerticalGroup(
@@ -157,11 +173,19 @@ public class CreateCylinderPanel extends javax.swing.JPanel {
                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(lblRadius)
                     .addComponent(lblRadius)
                     .addComponent(spinnerRadius, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                     .addComponent(spinnerRadius, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                .addComponent(checkClosed)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(checkInverted)
-                .addGap(29, 29, 29))
+                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(jPanel1Layout.createSequentialGroup()
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                            .addComponent(lblHeight)
+                            .addComponent(spinnerHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+                        .addContainerGap(75, Short.MAX_VALUE))
+                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .addComponent(checkClosed)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                        .addComponent(checkInverted)
+                        .addContainerGap())))
         );
         );
 
 
         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@@ -181,7 +205,7 @@ public class CreateCylinderPanel extends javax.swing.JPanel {
                 .addContainerGap()
                 .addContainerGap()
                 .addComponent(abstractNewGeometryPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addComponent(abstractNewGeometryPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 174, Short.MAX_VALUE))
+                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
         );
         );
     }// </editor-fold>//GEN-END:initComponents
     }// </editor-fold>//GEN-END:initComponents
 
 
@@ -190,9 +214,11 @@ public class CreateCylinderPanel extends javax.swing.JPanel {
     private javax.swing.JCheckBox checkClosed;
     private javax.swing.JCheckBox checkClosed;
     private javax.swing.JCheckBox checkInverted;
     private javax.swing.JCheckBox checkInverted;
     private javax.swing.JPanel jPanel1;
     private javax.swing.JPanel jPanel1;
+    private javax.swing.JLabel lblHeight;
     private javax.swing.JLabel lblRadialSamples;
     private javax.swing.JLabel lblRadialSamples;
     private javax.swing.JLabel lblRadius;
     private javax.swing.JLabel lblRadius;
     private javax.swing.JLabel lblZSamples;
     private javax.swing.JLabel lblZSamples;
+    private javax.swing.JSpinner spinnerHeight;
     private javax.swing.JSpinner spinnerRadialSamples;
     private javax.swing.JSpinner spinnerRadialSamples;
     private javax.swing.JSpinner spinnerRadius;
     private javax.swing.JSpinner spinnerRadius;
     private javax.swing.JSpinner spinnerZSamples;
     private javax.swing.JSpinner spinnerZSamples;