r2130 - tools/ObjToMap/objtomap

savagex at icculus.org savagex at icculus.org
Thu Jan 18 07:21:04 EST 2007


Author: savagex
Date: 2007-01-18 07:21:04 -0500 (Thu, 18 Jan 2007)
New Revision: 2130

Modified:
   tools/ObjToMap/objtomap/Configuration.java
   tools/ObjToMap/objtomap/JFrameMain.form
   tools/ObjToMap/objtomap/JFrameMain.java
   tools/ObjToMap/objtomap/ObjToMap.java
Log:
add texture scaling and get rid of a UI blooper


Modified: tools/ObjToMap/objtomap/Configuration.java
===================================================================
--- tools/ObjToMap/objtomap/Configuration.java	2007-01-17 18:43:23 UTC (rev 2129)
+++ tools/ObjToMap/objtomap/Configuration.java	2007-01-18 12:21:04 UTC (rev 2130)
@@ -3,13 +3,14 @@
 
 public class Configuration {
     
-    public double brush_thickness, scale;
+    public double brush_thickness, scale, texture_scale;
     public boolean detail, autotexture;
     public String objfile, mapfile;
     
     /** Creates a new instance of Configuration */
     public Configuration() {
         brush_thickness = 4.0;
+        texture_scale = 0.5;
         scale = 128.0;
         detail = true;
     }

Modified: tools/ObjToMap/objtomap/JFrameMain.form
===================================================================
--- tools/ObjToMap/objtomap/JFrameMain.form	2007-01-17 18:43:23 UTC (rev 2129)
+++ tools/ObjToMap/objtomap/JFrameMain.form	2007-01-18 12:21:04 UTC (rev 2130)
@@ -83,6 +83,9 @@
       </Layout>
       <SubComponents>
         <Component class="javax.swing.JTextField" name="jTextFieldInputFile">
+          <Events>
+            <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jTextFieldInputFileFocusLost"/>
+          </Events>
         </Component>
         <Component class="javax.swing.JButton" name="jButtonSelectInputFile">
           <Properties>
@@ -129,6 +132,9 @@
       </Layout>
       <SubComponents>
         <Component class="javax.swing.JTextField" name="jTextFieldOutputFile">
+          <Events>
+            <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jTextFieldOutputFileFocusLost"/>
+          </Events>
         </Component>
         <Component class="javax.swing.JButton" name="jButtonSelectOutputFile">
           <Properties>
@@ -165,10 +171,14 @@
                               <Component id="jTextFieldScale" max="32767" attributes="1"/>
                               <Component id="jTextFieldThickness" alignment="0" pref="56" max="32767" attributes="1"/>
                           </Group>
+                          <EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
+                          <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace min="12" pref="12" max="-2" attributes="0"/>
+                          <Component id="jTextFieldTextureScale" min="-2" pref="58" max="-2" attributes="0"/>
                       </Group>
                       <Component id="jCheckDetail" alignment="0" min="-2" max="-2" attributes="0"/>
                   </Group>
-                  <EmptySpace pref="377" max="32767" attributes="0"/>
+                  <EmptySpace pref="234" max="32767" attributes="0"/>
               </Group>
           </Group>
         </DimensionLayout>
@@ -178,6 +188,8 @@
                   <Group type="103" groupAlignment="3" attributes="0">
                       <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
                       <Component id="jTextFieldThickness" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="jTextFieldTextureScale" alignment="3" min="-2" max="-2" attributes="0"/>
                   </Group>
                   <EmptySpace max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="3" attributes="0">
@@ -228,6 +240,16 @@
             <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jTextFieldScaleFocusLost"/>
           </Events>
         </Component>
+        <Component class="javax.swing.JLabel" name="jLabel3">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Texture scale:"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JTextField" name="jTextFieldTextureScale">
+          <Events>
+            <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jTextFieldTextureScaleFocusLost"/>
+          </Events>
+        </Component>
       </SubComponents>
     </Container>
     <Component class="javax.swing.JButton" name="jButtonStart">

Modified: tools/ObjToMap/objtomap/JFrameMain.java
===================================================================
--- tools/ObjToMap/objtomap/JFrameMain.java	2007-01-17 18:43:23 UTC (rev 2129)
+++ tools/ObjToMap/objtomap/JFrameMain.java	2007-01-18 12:21:04 UTC (rev 2130)
@@ -29,6 +29,7 @@
         jTextFieldInputFile.setText(config.objfile);
         jTextFieldOutputFile.setText(config.mapfile);
         jTextFieldScale.setText(Double.toString(config.scale));
+        jTextFieldTextureScale.setText(Double.toString(config.texture_scale));
         jTextFieldThickness.setText(Double.toString(config.brush_thickness));
         jCheckDetail.setSelected(config.detail);
     }
@@ -53,11 +54,18 @@
         jCheckDetail = new javax.swing.JCheckBox();
         jTextFieldThickness = new javax.swing.JTextField();
         jTextFieldScale = new javax.swing.JTextField();
+        jLabel3 = new javax.swing.JLabel();
+        jTextFieldTextureScale = new javax.swing.JTextField();
         jButtonStart = new javax.swing.JButton();
 
         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
         setTitle("ObjToMap");
         jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Input File (.obj)"));
+        jTextFieldInputFile.addFocusListener(new java.awt.event.FocusAdapter() {
+            public void focusLost(java.awt.event.FocusEvent evt) {
+                jTextFieldInputFileFocusLost(evt);
+            }
+        });
 
         jButtonSelectInputFile.setText("Select file");
         jButtonSelectInputFile.addActionListener(new java.awt.event.ActionListener() {
@@ -87,6 +95,11 @@
         );
 
         jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Output File (.map)"));
+        jTextFieldOutputFile.addFocusListener(new java.awt.event.FocusAdapter() {
+            public void focusLost(java.awt.event.FocusEvent evt) {
+                jTextFieldOutputFileFocusLost(evt);
+            }
+        });
 
         jButtonSelectOutputFile.setText("Select file");
         jButtonSelectOutputFile.addActionListener(new java.awt.event.ActionListener() {
@@ -141,6 +154,14 @@
             }
         });
 
+        jLabel3.setText("Texture scale:");
+
+        jTextFieldTextureScale.addFocusListener(new java.awt.event.FocusAdapter() {
+            public void focusLost(java.awt.event.FocusEvent evt) {
+                jTextFieldTextureScaleFocusLost(evt);
+            }
+        });
+
         org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
         jPanel3.setLayout(jPanel3Layout);
         jPanel3Layout.setHorizontalGroup(
@@ -155,16 +176,22 @@
                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                         .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                             .add(jTextFieldScale)
-                            .add(jTextFieldThickness, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)))
+                            .add(jTextFieldThickness, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE))
+                        .add(29, 29, 29)
+                        .add(jLabel3)
+                        .add(12, 12, 12)
+                        .add(jTextFieldTextureScale, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                     .add(jCheckDetail))
-                .addContainerGap(377, Short.MAX_VALUE))
+                .addContainerGap(234, Short.MAX_VALUE))
         );
         jPanel3Layout.setVerticalGroup(
             jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
             .add(jPanel3Layout.createSequentialGroup()
                 .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                     .add(jLabel1)
-                    .add(jTextFieldThickness, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                    .add(jTextFieldThickness, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jLabel3)
+                    .add(jTextFieldTextureScale, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                 .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                     .add(jLabel2)
@@ -210,6 +237,23 @@
         pack();
     }// </editor-fold>//GEN-END:initComponents
 
+    private void jTextFieldOutputFileFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldOutputFileFocusLost
+        config.mapfile = jTextFieldOutputFile.getText();
+        updateForms();
+    }//GEN-LAST:event_jTextFieldOutputFileFocusLost
+
+    private void jTextFieldInputFileFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldInputFileFocusLost
+        config.objfile = jTextFieldInputFile.getText();
+        updateForms();
+    }//GEN-LAST:event_jTextFieldInputFileFocusLost
+
+    private void jTextFieldTextureScaleFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldTextureScaleFocusLost
+        try {
+            config.texture_scale = Double.parseDouble(jTextFieldTextureScale.getText());
+        } catch(Exception e) {}
+        updateForms();
+    }//GEN-LAST:event_jTextFieldTextureScaleFocusLost
+
     private void jButtonSelectOutputFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectOutputFileActionPerformed
         JFileChooser fc = new JFileChooser();
         int returnval = fc.showSaveDialog(this);
@@ -268,12 +312,14 @@
     private javax.swing.JCheckBox jCheckDetail;
     private javax.swing.JLabel jLabel1;
     private javax.swing.JLabel jLabel2;
+    private javax.swing.JLabel jLabel3;
     private javax.swing.JPanel jPanel1;
     private javax.swing.JPanel jPanel2;
     private javax.swing.JPanel jPanel3;
     private javax.swing.JTextField jTextFieldInputFile;
     private javax.swing.JTextField jTextFieldOutputFile;
     private javax.swing.JTextField jTextFieldScale;
+    private javax.swing.JTextField jTextFieldTextureScale;
     private javax.swing.JTextField jTextFieldThickness;
     // End of variables declaration//GEN-END:variables
     

Modified: tools/ObjToMap/objtomap/ObjToMap.java
===================================================================
--- tools/ObjToMap/objtomap/ObjToMap.java	2007-01-17 18:43:23 UTC (rev 2129)
+++ tools/ObjToMap/objtomap/ObjToMap.java	2007-01-18 12:21:04 UTC (rev 2130)
@@ -253,7 +253,7 @@
             else
                 flag = 0;
             
-            return "( " + p1.x + " " + p1.y + " " + p1.z + " ) ( " + p2.x + " " + p2.y + " " + p2.z + " ) ( " + p3.x + " " + p3.y + " " + p3.z + " ) " + material + " 0 0 0 0.5 0.5 " + flag + " 0 0\n";
+            return "( " + p1.x + " " + p1.y + " " + p1.z + " ) ( " + p2.x + " " + p2.y + " " + p2.z + " ) ( " + p3.x + " " + p3.y + " " + p3.z + " ) " + material + " 0 0 0 " + config.texture_scale + " " + config.texture_scale + " " + flag + " 0 0\n";
         }
         
     }




More information about the nexuiz-commits mailing list