r2124 - tools/ObjToMap/objtomap
savagex at icculus.org
savagex at icculus.org
Tue Jan 16 10:33:23 EST 2007
Author: savagex
Date: 2007-01-16 10:33:23 -0500 (Tue, 16 Jan 2007)
New Revision: 2124
Added:
tools/ObjToMap/objtomap/Configuration.java
tools/ObjToMap/objtomap/JFrameMain.form
tools/ObjToMap/objtomap/JFrameMain.java
tools/ObjToMap/objtomap/Main.java
Modified:
tools/ObjToMap/objtomap/ObjToMap.java
Log:
new version of ObjToMap - this this it is a GUI application (w000t!)
Added: tools/ObjToMap/objtomap/Configuration.java
===================================================================
--- tools/ObjToMap/objtomap/Configuration.java (rev 0)
+++ tools/ObjToMap/objtomap/Configuration.java 2007-01-16 15:33:23 UTC (rev 2124)
@@ -0,0 +1,17 @@
+
+package objtomap;
+
+public class Configuration {
+
+ public double brush_thickness, scale;
+ public boolean detail, autotexture;
+ public String objfile, mapfile;
+
+ /** Creates a new instance of Configuration */
+ public Configuration() {
+ brush_thickness = 4.0;
+ scale = 128.0;
+ detail = true;
+ }
+
+}
Added: tools/ObjToMap/objtomap/JFrameMain.form
===================================================================
--- tools/ObjToMap/objtomap/JFrameMain.form (rev 0)
+++ tools/ObjToMap/objtomap/JFrameMain.form 2007-01-16 15:33:23 UTC (rev 2124)
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="3"/>
+ <Property name="title" type="java.lang.String" value="ObjToMap"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jPanel3" alignment="0" max="32767" attributes="0"/>
+ <Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
+ <Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
+ <Component id="jButtonStart" alignment="1" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jPanel3" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jButtonStart" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="jPanel1">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Input File (.obj)"/>
+ </Border>
+ </Property>
+ </Properties>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jTextFieldInputFile" pref="477" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jButtonSelectInputFile" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jButtonSelectInputFile" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="jTextFieldInputFile" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JTextField" name="jTextFieldInputFile">
+ </Component>
+ <Component class="javax.swing.JButton" name="jButtonSelectInputFile">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Select file"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonSelectInputFileActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="jPanel2">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Output File (.map)"/>
+ </Border>
+ </Property>
+ </Properties>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jTextFieldOutputFile" pref="477" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jButtonSelectOutputFile" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jTextFieldOutputFile" min="-2" max="-2" attributes="0"/>
+ <Component id="jButtonSelectOutputFile" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JTextField" name="jTextFieldOutputFile">
+ </Component>
+ <Component class="javax.swing.JButton" name="jButtonSelectOutputFile">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Select file"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonSelectOutputFileActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="jPanel3">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Configuration"/>
+ </Border>
+ </Property>
+ </Properties>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="jLabel2" alignment="1" min="-2" max="-2" attributes="0"/>
+ <Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" max="-2" attributes="0">
+ <Component id="jTextFieldScale" max="32767" attributes="1"/>
+ <Component id="jTextFieldThickness" alignment="0" pref="56" max="32767" attributes="1"/>
+ </Group>
+ </Group>
+ <Component id="jCheckDetail" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace pref="377" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <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"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="jTextFieldScale" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace pref="21" max="32767" attributes="0"/>
+ <Component id="jCheckDetail" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Brush thickness:"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel2">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Model scale:"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="jCheckDetail">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Make generated brushes detail"/>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+ <EmptyBorder bottom="0" left="0" right="0" top="0"/>
+ </Border>
+ </Property>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[0, 0, 0, 0]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckDetailActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JTextField" name="jTextFieldThickness">
+ <Events>
+ <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jTextFieldThicknessFocusLost"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JTextField" name="jTextFieldScale">
+ <Events>
+ <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jTextFieldScaleFocusLost"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="jButtonStart">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Start conversion"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonStartActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
Added: tools/ObjToMap/objtomap/JFrameMain.java
===================================================================
--- tools/ObjToMap/objtomap/JFrameMain.java (rev 0)
+++ tools/ObjToMap/objtomap/JFrameMain.java 2007-01-16 15:33:23 UTC (rev 2124)
@@ -0,0 +1,280 @@
+/*
+ * JFrameMain.java
+ *
+ * Created on 16. Januar 2007, 15:36
+ */
+
+package objtomap;
+
+import java.io.IOException;
+import javax.swing.JFileChooser;
+
+/**
+ *
+ * @author user
+ */
+public class JFrameMain extends javax.swing.JFrame {
+
+ private Configuration config;
+
+ /** Creates new form JFrameMain */
+ public JFrameMain(Configuration c) {
+ config = c;
+ initComponents();
+
+ updateForms();
+ }
+
+ private void updateForms() {
+ jTextFieldInputFile.setText(config.objfile);
+ jTextFieldOutputFile.setText(config.mapfile);
+ jTextFieldScale.setText(Double.toString(config.scale));
+ jTextFieldThickness.setText(Double.toString(config.brush_thickness));
+ jCheckDetail.setSelected(config.detail);
+ }
+
+
+ /** 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.
+ */
+ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
+ private void initComponents() {
+ jPanel1 = new javax.swing.JPanel();
+ jTextFieldInputFile = new javax.swing.JTextField();
+ jButtonSelectInputFile = new javax.swing.JButton();
+ jPanel2 = new javax.swing.JPanel();
+ jTextFieldOutputFile = new javax.swing.JTextField();
+ jButtonSelectOutputFile = new javax.swing.JButton();
+ jPanel3 = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ jLabel2 = new javax.swing.JLabel();
+ jCheckDetail = new javax.swing.JCheckBox();
+ jTextFieldThickness = new javax.swing.JTextField();
+ jTextFieldScale = 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)"));
+
+ jButtonSelectInputFile.setText("Select file");
+ jButtonSelectInputFile.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButtonSelectInputFileActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jTextFieldInputFile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 477, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jButtonSelectInputFile)
+ .addContainerGap())
+ );
+ jPanel1Layout.setVerticalGroup(
+ jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel1Layout.createSequentialGroup()
+ .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jButtonSelectInputFile)
+ .add(jTextFieldInputFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Output File (.map)"));
+
+ jButtonSelectOutputFile.setText("Select file");
+ jButtonSelectOutputFile.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButtonSelectOutputFileActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
+ jPanel2.setLayout(jPanel2Layout);
+ jPanel2Layout.setHorizontalGroup(
+ jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jTextFieldOutputFile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 477, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jButtonSelectOutputFile)
+ .addContainerGap())
+ );
+ jPanel2Layout.setVerticalGroup(
+ jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel2Layout.createSequentialGroup()
+ .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jTextFieldOutputFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(jButtonSelectOutputFile))
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Configuration"));
+ jLabel1.setText("Brush thickness:");
+
+ jLabel2.setText("Model scale:");
+
+ jCheckDetail.setText("Make generated brushes detail");
+ jCheckDetail.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ jCheckDetail.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ jCheckDetail.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jCheckDetailActionPerformed(evt);
+ }
+ });
+
+ jTextFieldThickness.addFocusListener(new java.awt.event.FocusAdapter() {
+ public void focusLost(java.awt.event.FocusEvent evt) {
+ jTextFieldThicknessFocusLost(evt);
+ }
+ });
+
+ jTextFieldScale.addFocusListener(new java.awt.event.FocusAdapter() {
+ public void focusLost(java.awt.event.FocusEvent evt) {
+ jTextFieldScaleFocusLost(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
+ jPanel3.setLayout(jPanel3Layout);
+ jPanel3Layout.setHorizontalGroup(
+ jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel3Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel3Layout.createSequentialGroup()
+ .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(jLabel2)
+ .add(jLabel1))
+ .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(jCheckDetail))
+ .addContainerGap(377, 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))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel2)
+ .add(jTextFieldScale, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 21, Short.MAX_VALUE)
+ .add(jCheckDetail)
+ .addContainerGap())
+ );
+
+ jButtonStart.setText("Start conversion");
+ jButtonStart.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButtonStartActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(jButtonStart))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jPanel1, 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(jPanel2, 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(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jButtonStart)
+ .addContainerGap())
+ );
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void jButtonSelectOutputFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectOutputFileActionPerformed
+ JFileChooser fc = new JFileChooser();
+ int returnval = fc.showSaveDialog(this);
+ if(returnval == JFileChooser.APPROVE_OPTION) {
+ config.mapfile = fc.getSelectedFile().getPath();
+ }
+ updateForms();
+ }//GEN-LAST:event_jButtonSelectOutputFileActionPerformed
+
+ private void jButtonSelectInputFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectInputFileActionPerformed
+ JFileChooser fc = new JFileChooser();
+ int returnval = fc.showOpenDialog(this);
+ if(returnval == JFileChooser.APPROVE_OPTION) {
+ config.objfile = fc.getSelectedFile().getPath();
+ }
+ updateForms();
+ }//GEN-LAST:event_jButtonSelectInputFileActionPerformed
+
+ private void jButtonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonStartActionPerformed
+ config.objfile = jTextFieldInputFile.getText();
+ config.mapfile = jTextFieldOutputFile.getText();
+
+ ObjToMap converter = new ObjToMap(config);
+ try {
+ converter.parseOBJ();
+ converter.writeMap();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }//GEN-LAST:event_jButtonStartActionPerformed
+
+ private void jCheckDetailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckDetailActionPerformed
+ config.detail = jCheckDetail.isSelected();
+ updateForms();
+ }//GEN-LAST:event_jCheckDetailActionPerformed
+
+ private void jTextFieldScaleFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldScaleFocusLost
+ try {
+ config.scale = Double.parseDouble(jTextFieldScale.getText());
+ } catch(Exception e) {}
+ updateForms();
+ }//GEN-LAST:event_jTextFieldScaleFocusLost
+
+ private void jTextFieldThicknessFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldThicknessFocusLost
+ try {
+ config.brush_thickness = Double.parseDouble(jTextFieldThickness.getText());
+ } catch(Exception e) {}
+ updateForms();
+ }//GEN-LAST:event_jTextFieldThicknessFocusLost
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton jButtonSelectInputFile;
+ private javax.swing.JButton jButtonSelectOutputFile;
+ private javax.swing.JButton jButtonStart;
+ private javax.swing.JCheckBox jCheckDetail;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ 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 jTextFieldThickness;
+ // End of variables declaration//GEN-END:variables
+
+}
Added: tools/ObjToMap/objtomap/Main.java
===================================================================
--- tools/ObjToMap/objtomap/Main.java (rev 0)
+++ tools/ObjToMap/objtomap/Main.java 2007-01-16 15:33:23 UTC (rev 2124)
@@ -0,0 +1,36 @@
+/*
+ * Main.java
+ *
+ * Created on 16. Januar 2007, 15:24
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package objtomap;
+
+import java.io.IOException;
+import java.util.Vector;
+import javax.swing.UIManager;
+
+/**
+ *
+ * @author user
+ */
+public class Main {
+
+
+ public static void main(String[] args) throws IOException {
+
+ try {
+ UIManager.setLookAndFeel(
+ UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e) { }
+
+ Configuration config = new Configuration();
+
+ JFrameMain main = new JFrameMain(config);
+ main.setVisible(true);
+
+ }
+}
Modified: tools/ObjToMap/objtomap/ObjToMap.java
===================================================================
--- tools/ObjToMap/objtomap/ObjToMap.java 2007-01-16 14:21:07 UTC (rev 2123)
+++ tools/ObjToMap/objtomap/ObjToMap.java 2007-01-16 15:33:23 UTC (rev 2124)
@@ -17,42 +17,25 @@
public class ObjToMap {
- public static void main(String[] args) throws IOException {
- if(args.length != 2 && args.length != 3) {
- System.out.println("USAGE: infile.obj outfile.map [scale, default 128]");
- System.exit(1);
- }
- ObjToMap m = new ObjToMap();
-
- double scale;
- if(args.length == 2)
- scale = 128d;
- else
- scale = Double.parseDouble(args[2]);
-
- String objfile = args[0];
- String mapfile = args[1];
-
- Vector points = new Vector();
- Vector faces = new Vector();
-
-
- m.parseOBJ(objfile, points, faces, scale);
-
- System.out.println("Read points: " + points.size() + " Read faces: " + faces.size());
-
- m.writeMap(mapfile, faces);
-
+ private Vector points, faces;
+ private Configuration config;
+
+ public ObjToMap(Configuration c) {
+ config = c;
}
- private void parseOBJ(String filename, Vector points, Vector faces, double scale) throws IOException {
+ public void parseOBJ() throws IOException {
+ points = new Vector();
+ faces = new Vector();
+ double scale = config.scale;
+
BufferedReader in = null;
try {
- in = new BufferedReader(new FileReader(filename));
+ in = new BufferedReader(new FileReader(config.objfile));
} catch(Exception e) {
System.err.println("Input file not found!");
- System.exit(1);
+ return;
}
String currentmat = "common/caulk";
@@ -121,15 +104,19 @@
}
+ System.out.println("Read points: " + points.size() + " Read faces: " + faces.size());
+
}
- private void writeMap(String filename, Vector faces) {
+ public void writeMap() {
+ if(faces == null) return;
+
PrintWriter out = null;
try {
- out = new PrintWriter(new FileWriter(filename));
+ out = new PrintWriter(new FileWriter(config.mapfile));
} catch(Exception e) {
System.err.println("Can't open output file?!");
- System.exit(1);
+ return;
}
StringBuffer sb = new StringBuffer();
@@ -221,16 +208,16 @@
Vector3D normal_xy = new Vector3D(0.0, 0.0, 1.0);
double angle_xy = Math.acos(normal.dotproduct(normal_xy)) / (2 * Math.PI) * 360.0;
-
+
// this looks like a floor, extrude along the z-axis
if(angle_xy < 70.0) {
normal.x = 0.0;
normal.y = 0.0;
normal.z = 1.0;
}
-
- normal.scale(4.0);
+ normal.scale(config.brush_thickness);
+
Vector3D p1_, p2_, p3_;
p1_ = p1.substract(normal);
@@ -260,7 +247,13 @@
private String getMapPlaneString(Vector3D p1, Vector3D p2, Vector3D p3, String material) {
- return "( " + (float)p1.x + " " + (float)p1.y + " " + (float)p1.z + " ) ( " + (float)p2.x + " " + (float)p2.y + " " + (float)p2.z + " ) ( " + (float)p3.x + " " + (float)p3.y + " " + (float)p3.z + " ) " + material + " 0 0 0 0.5 0.5 134217728 0 0\n";
+ int flag;
+ if(config.detail)
+ flag = 134217728;
+ 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";
}
}
More information about the nexuiz-commits
mailing list