|
@@ -0,0 +1,164 @@
|
|
|
+/*
|
|
|
+ * 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.actions.impl;
|
|
|
+
|
|
|
+import com.jme3.gde.core.assets.ProjectAssetManager;
|
|
|
+import com.jme3.material.Material;
|
|
|
+import com.jme3.math.ColorRGBA;
|
|
|
+import com.jme3.scene.Geometry;
|
|
|
+
|
|
|
+/**
|
|
|
+ * This is the base Panel to be used within every "New Geometry/Primitive" dialogue
|
|
|
+ * as it will provide basic elements like MeshName, Material Color, etc.
|
|
|
+ *
|
|
|
+ * @author MeFisto94
|
|
|
+ */
|
|
|
+public class AbstractNewGeometryPanel extends javax.swing.JPanel {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates new form AbstractNewGeometryPanel
|
|
|
+ */
|
|
|
+ public AbstractNewGeometryPanel() {
|
|
|
+ initComponents();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 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")
|
|
|
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
|
+ private void initComponents() {
|
|
|
+
|
|
|
+ inGeomName = new javax.swing.JTextField();
|
|
|
+ lblGeomName = new javax.swing.JLabel();
|
|
|
+ lblMatDef = new javax.swing.JLabel();
|
|
|
+ inMatDef = new javax.swing.JComboBox<>();
|
|
|
+ lblDefaultColor = new javax.swing.JLabel();
|
|
|
+ inRandomColor = new javax.swing.JCheckBox();
|
|
|
+
|
|
|
+ inGeomName.setText(org.openide.util.NbBundle.getMessage(AbstractNewGeometryPanel.class, "AbstractNewGeometryPanel.inGeomName.text")); // NOI18N
|
|
|
+
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(lblGeomName, org.openide.util.NbBundle.getMessage(AbstractNewGeometryPanel.class, "AbstractNewGeometryPanel.lblGeomName.text")); // NOI18N
|
|
|
+
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(lblMatDef, org.openide.util.NbBundle.getMessage(AbstractNewGeometryPanel.class, "AbstractNewGeometryPanel.text")); // NOI18N
|
|
|
+ lblMatDef.setToolTipText(org.openide.util.NbBundle.getMessage(AbstractNewGeometryPanel.class, "AbstractNewGeometryPanel.toolTipText")); // NOI18N
|
|
|
+ lblMatDef.setName(""); // NOI18N
|
|
|
+
|
|
|
+ inMatDef.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Common/MatDefs/Misc/Unshaded.j3md", "Common/MatDefs/Light/Lighting.j3md", "Common/MatDefs/Light/PBRLighting.j3md" }));
|
|
|
+
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(lblDefaultColor, org.openide.util.NbBundle.getMessage(AbstractNewGeometryPanel.class, "AbstractNewGeometryPanel.lblDefaultColor.text")); // NOI18N
|
|
|
+
|
|
|
+ org.openide.awt.Mnemonics.setLocalizedText(inRandomColor, org.openide.util.NbBundle.getMessage(AbstractNewGeometryPanel.class, "AbstractNewGeometryPanel.inRandomColor.text")); // NOI18N
|
|
|
+ inRandomColor.setToolTipText(org.openide.util.NbBundle.getMessage(AbstractNewGeometryPanel.class, "AbstractNewGeometryPanel.inRandomColor.toolTipText")); // NOI18N
|
|
|
+
|
|
|
+ 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)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(lblGeomName)
|
|
|
+ .addComponent(lblMatDef))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addComponent(inMatDef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addGap(0, 0, Short.MAX_VALUE))
|
|
|
+ .addComponent(inGeomName)))
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(lblDefaultColor)
|
|
|
+ .addComponent(inRandomColor))
|
|
|
+ .addGap(0, 0, Short.MAX_VALUE)))
|
|
|
+ .addContainerGap())
|
|
|
+ );
|
|
|
+ layout.setVerticalGroup(
|
|
|
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addGap(8, 8, 8)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
+ .addComponent(lblGeomName)
|
|
|
+ .addComponent(inGeomName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
+ .addComponent(lblMatDef)
|
|
|
+ .addComponent(inMatDef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
+ .addComponent(lblDefaultColor)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
|
|
|
+ .addComponent(inRandomColor)
|
|
|
+ .addContainerGap())
|
|
|
+ );
|
|
|
+ }// </editor-fold>//GEN-END:initComponents
|
|
|
+
|
|
|
+
|
|
|
+ // Variables declaration - do not modify//GEN-BEGIN:variables
|
|
|
+ private javax.swing.JTextField inGeomName;
|
|
|
+ private javax.swing.JComboBox<String> inMatDef;
|
|
|
+ private javax.swing.JCheckBox inRandomColor;
|
|
|
+ private javax.swing.JLabel lblDefaultColor;
|
|
|
+ private javax.swing.JLabel lblGeomName;
|
|
|
+ private javax.swing.JLabel lblMatDef;
|
|
|
+ // End of variables declaration//GEN-END:variables
|
|
|
+
|
|
|
+
|
|
|
+ public void handleGeometry(ProjectAssetManager assetManager, Geometry geom) {
|
|
|
+ geom.setName(inGeomName.getText());
|
|
|
+ ColorRGBA col;
|
|
|
+
|
|
|
+ if (inRandomColor.isSelected()) {
|
|
|
+ col = ColorRGBA.randomColor();
|
|
|
+ } else {
|
|
|
+ // @TODO: Add a Color Picker Dialog and preserve the state
|
|
|
+ col = ColorRGBA.Red;
|
|
|
+ }
|
|
|
+
|
|
|
+ Material mat = new Material(assetManager, inMatDef.getSelectedItem().toString());
|
|
|
+ switch (inMatDef.getSelectedItem().toString()) {
|
|
|
+ case "Common/MatDefs/Misc/Unshaded.j3md":
|
|
|
+ mat.setColor("Color", col);
|
|
|
+ break;
|
|
|
+ case "Common/MatDefs/Light/Lighting.j3md":
|
|
|
+ mat.setColor("Diffuse", col);
|
|
|
+ break;
|
|
|
+ case "Common/MatDefs/Light/PBRLighting.j3md":
|
|
|
+ mat.setColor("BaseColor", col);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ geom.setMaterial(mat);
|
|
|
+ }
|
|
|
+}
|