r5903 - in trunk/misc/tools: ObjToMap ttf2conchars
esteel at icculus.org
esteel at icculus.org
Fri Feb 20 03:30:05 EST 2009
Author: esteel
Date: 2009-02-20 03:30:03 -0500 (Fri, 20 Feb 2009)
New Revision: 5903
Added:
trunk/misc/tools/ObjToMap/AutoTexturingEntry.java
trunk/misc/tools/ObjToMap/Configuration.java
trunk/misc/tools/ObjToMap/JFrameMain.form
trunk/misc/tools/ObjToMap/JFrameMain.java
trunk/misc/tools/ObjToMap/Main.java
trunk/misc/tools/ObjToMap/ObjToMap.java
Removed:
trunk/misc/tools/ObjToMap/objtomap/
Modified:
trunk/misc/tools/ttf2conchars/foo.sh
Log:
set another x bit\
moved files from misc/tools/ObjToMap/objtomap to misc/tools/ObjToMap .. no reason to have that extra dir or is there?!?
Copied: trunk/misc/tools/ObjToMap/AutoTexturingEntry.java (from rev 5902, trunk/misc/tools/ObjToMap/objtomap/AutoTexturingEntry.java)
===================================================================
--- trunk/misc/tools/ObjToMap/AutoTexturingEntry.java (rev 0)
+++ trunk/misc/tools/ObjToMap/AutoTexturingEntry.java 2009-02-20 08:30:03 UTC (rev 5903)
@@ -0,0 +1,11 @@
+package objtomap;
+
+public class AutoTexturingEntry {
+ public double angle;
+ public String texturename;
+
+ public AutoTexturingEntry() {
+ angle = 0.0;
+ texturename = "common/caulk";
+ }
+}
Copied: trunk/misc/tools/ObjToMap/Configuration.java (from rev 5902, trunk/misc/tools/ObjToMap/objtomap/Configuration.java)
===================================================================
--- trunk/misc/tools/ObjToMap/Configuration.java (rev 0)
+++ trunk/misc/tools/ObjToMap/Configuration.java 2009-02-20 08:30:03 UTC (rev 5903)
@@ -0,0 +1,23 @@
+
+package objtomap;
+
+import java.util.Vector;
+
+public class Configuration {
+
+ public double brush_thickness, scale, texture_scale, minz;
+ public boolean detail, autotexture, simpleterrain;
+ public String objfile, mapfile;
+ public Vector autotexturing;
+
+
+ /** Creates a new instance of Configuration */
+ public Configuration() {
+ brush_thickness = 4.0;
+ texture_scale = 0.5;
+ scale = 128.0;
+ detail = true;
+ autotexturing = new Vector();
+ }
+
+}
Copied: trunk/misc/tools/ObjToMap/JFrameMain.form (from rev 5902, trunk/misc/tools/ObjToMap/objtomap/JFrameMain.form)
===================================================================
--- trunk/misc/tools/ObjToMap/JFrameMain.form (rev 0)
+++ trunk/misc/tools/ObjToMap/JFrameMain.form 2009-02-20 08:30:03 UTC (rev 5903)
@@ -0,0 +1,348 @@
+<?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="jPanel4" alignment="0" max="32767" 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" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jPanel4" 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">
+ <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>
+ <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">
+ <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>
+ <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>
+ <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="234" 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"/>
+ <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">
+ <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="19" 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>
+ <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">
+ <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>
+ <Container class="javax.swing.JPanel" name="jPanel4">
+ <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="Auto-texturing"/>
+ </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="jScrollPane1" pref="473" max="32767" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" max="-2" attributes="0">
+ <Component id="jButtonAdd" max="32767" attributes="1"/>
+ <Component id="jButtonDelte" alignment="1" pref="104" max="32767" attributes="1"/>
+ </Group>
+ <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">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jButtonAdd" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jButtonDelte" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Component id="jScrollPane1" alignment="1" pref="167" max="32767" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTable" name="jTableTexturing">
+ <Properties>
+ <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
+ <Table columnCount="4" rowCount="4">
+ <Column editable="true" title="Title 1" type="java.lang.Object"/>
+ <Column editable="true" title="Title 2" type="java.lang.Object"/>
+ <Column editable="true" title="Title 3" type="java.lang.Object"/>
+ <Column editable="true" title="Title 4" type="java.lang.Object"/>
+ </Table>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="jButtonAdd">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="New"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonAddActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="jButtonDelte">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Remove"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonDelteActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
Copied: trunk/misc/tools/ObjToMap/JFrameMain.java (from rev 5902, trunk/misc/tools/ObjToMap/objtomap/JFrameMain.java)
===================================================================
--- trunk/misc/tools/ObjToMap/JFrameMain.java (rev 0)
+++ trunk/misc/tools/ObjToMap/JFrameMain.java 2009-02-20 08:30:03 UTC (rev 5903)
@@ -0,0 +1,475 @@
+/*
+ * JFrameMain.java
+ *
+ * Created on 16. Januar 2007, 15:36
+ */
+
+package objtomap;
+
+import java.io.IOException;
+import java.util.Vector;
+import javax.swing.JFileChooser;
+import javax.swing.table.AbstractTableModel;
+
+/**
+ *
+ * @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));
+ jTextFieldTextureScale.setText(Double.toString(config.texture_scale));
+ jTextFieldThickness.setText(Double.toString(config.brush_thickness));
+ jCheckDetail.setSelected(config.detail);
+
+ jTableTexturing.setModel(new AutoTexturingTableModel(config.autotexturing));
+
+ /*try {
+ jTableRelations.setDefaultEditor(Class.forName("businesslearner.Letter"), new DefaultCellEditor(comboBoxLetters));
+ jTableRelations.setDefaultEditor("".getClass(), new DefaultCellEditor(comboBoxRelations));
+ } catch (ClassNotFoundException ex) {
+ ex.printStackTrace();
+ }*/
+
+ }
+
+
+
+
+ /** 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();
+ jLabel3 = new javax.swing.JLabel();
+ jTextFieldTextureScale = new javax.swing.JTextField();
+ jButtonStart = new javax.swing.JButton();
+ jPanel4 = new javax.swing.JPanel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ jTableTexturing = new javax.swing.JTable();
+ jButtonAdd = new javax.swing.JButton();
+ jButtonDelte = 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() {
+ 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)"));
+ 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() {
+ 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);
+ }
+ });
+
+ 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(
+ 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(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(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(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)
+ .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, 19, 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);
+ }
+ });
+
+ jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Auto-texturing"));
+ jTableTexturing.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+ {null, null, null, null},
+ {null, null, null, null},
+ {null, null, null, null},
+ {null, null, null, null}
+ },
+ new String [] {
+ "Title 1", "Title 2", "Title 3", "Title 4"
+ }
+ ));
+ jScrollPane1.setViewportView(jTableTexturing);
+
+ jButtonAdd.setText("New");
+ jButtonAdd.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButtonAddActionPerformed(evt);
+ }
+ });
+
+ jButtonDelte.setText("Remove");
+ jButtonDelte.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButtonDelteActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
+ jPanel4.setLayout(jPanel4Layout);
+ jPanel4Layout.setHorizontalGroup(
+ jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+ .add(jButtonAdd, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(jButtonDelte, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ jPanel4Layout.setVerticalGroup(
+ jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel4Layout.createSequentialGroup()
+ .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jPanel4Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jButtonAdd)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jButtonDelte))
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+
+ 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, jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .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.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jPanel4, 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 jButtonDelteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDelteActionPerformed
+ int index = jTableTexturing.getSelectedRow();
+ if(index < 0) return;
+ config.autotexturing.remove(index);
+ updateForms();
+ }//GEN-LAST:event_jButtonDelteActionPerformed
+
+ private void jButtonAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddActionPerformed
+ config.autotexturing.add(new AutoTexturingEntry());
+ updateForms();
+ }//GEN-LAST:event_jButtonAddActionPerformed
+
+ 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);
+ 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 jButtonAdd;
+ private javax.swing.JButton jButtonDelte;
+ 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.JLabel jLabel3;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel jPanel4;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTable jTableTexturing;
+ 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
+
+ private class AutoTexturingTableModel extends AbstractTableModel {
+
+ Vector texturing;
+
+ public AutoTexturingTableModel(Vector t) {
+ texturing = t;
+ }
+
+ private String[] columnNames = {"Starting angle (against xy plane)","Texture name"};
+
+
+ public int getColumnCount() {
+ return 2;
+ }
+
+ public int getRowCount() {
+ return texturing.size();
+ }
+
+ public String getColumnName(int col) {
+ return columnNames[col];
+ }
+
+ public Object getValueAt(int row, int col) {
+ if(row < 0 | row > texturing.size()) return null;
+
+ AutoTexturingEntry e = (AutoTexturingEntry)texturing.get(row);
+ if(col == 0)
+ return new Double(e.angle);
+ else
+ return e.texturename;
+ }
+
+ public Class getColumnClass(int c) {
+ return getValueAt(0, c).getClass();
+ }
+
+ public boolean isCellEditable(int row, int col) {
+ return true;
+ }
+
+ public void setValueAt(Object value, int row, int col) {
+
+ AutoTexturingEntry e = (AutoTexturingEntry)texturing.get(row);
+
+ if(col == 0) {
+ Double angle = (Double)value;
+ e.angle = angle.doubleValue();
+ } else {
+ e.texturename = (String)value;
+ }
+
+ fireTableCellUpdated(row, col);
+ }
+ }
+
+}
Copied: trunk/misc/tools/ObjToMap/Main.java (from rev 5902, trunk/misc/tools/ObjToMap/objtomap/Main.java)
===================================================================
--- trunk/misc/tools/ObjToMap/Main.java (rev 0)
+++ trunk/misc/tools/ObjToMap/Main.java 2009-02-20 08:30:03 UTC (rev 5903)
@@ -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);
+
+ }
+}
Copied: trunk/misc/tools/ObjToMap/ObjToMap.java (from rev 5902, trunk/misc/tools/ObjToMap/objtomap/ObjToMap.java)
===================================================================
--- trunk/misc/tools/ObjToMap/ObjToMap.java (rev 0)
+++ trunk/misc/tools/ObjToMap/ObjToMap.java 2009-02-20 08:30:03 UTC (rev 5903)
@@ -0,0 +1,318 @@
+/* This code is *ugly*. It may blind you.
+ *
+ * I hereby pollute the software world by putting this into public domain.
+ *
+ * SavageX
+ */
+
+
+package objtomap;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Vector;
+
+public class ObjToMap {
+
+ private Vector points, faces;
+ private Configuration config;
+
+ public ObjToMap(Configuration c) {
+ config = c;
+ }
+
+ public void parseOBJ() throws IOException {
+
+ points = new Vector();
+ faces = new Vector();
+ double scale = config.scale;
+ config.simpleterrain = true;
+ config.minz = Double.MAX_VALUE;
+
+
+ BufferedReader in = null;
+ try {
+ in = new BufferedReader(new FileReader(config.objfile));
+ } catch(Exception e) {
+ System.err.println("Input file not found!");
+ return;
+ }
+
+ String currentmat = "common/caulk";
+
+ while(in.ready()) {
+ String line = in.readLine();
+ line.trim();
+ line = line.replaceAll(" ", " ");
+ String[] tokens = line.split(" ");
+ if(tokens.length > 1) {
+
+ if(tokens[0].equals("v")) {
+ // vertices
+ Vector3D p = new Vector3D();
+ p.x = Double.parseDouble(tokens[3]) * scale;
+ p.y = Double.parseDouble(tokens[1]) * scale;
+ p.z = Double.parseDouble(tokens[2]) * scale;
+ points.add(p);
+
+ if(p.z < config.minz)
+ config.minz = p.z;
+
+ } else if(tokens[0].equals("f")) {
+ // faces
+
+ if(tokens.length == 4) {
+ // TriFace
+
+ String[] facetokens1 = tokens[1].split("/");
+ String[] facetokens2 = tokens[2].split("/");
+ String[] facetokens3 = tokens[3].split("/");
+
+ Face f = new Face();
+ f.material = currentmat;
+ Vector3D p1, p2, p3;
+ p1 = (Vector3D)points.get(Integer.parseInt(facetokens1[0]) - 1);
+ p2 = (Vector3D)points.get(Integer.parseInt(facetokens2[0]) - 1);
+ p3 = (Vector3D)points.get(Integer.parseInt(facetokens3[0]) - 1);
+
+ f.setPoints(p1, p2, p3);
+ if(f.getXYangle() >= 90.0)
+ config.simpleterrain = false;
+
+ faces.add(f);
+
+ } else if(tokens.length == 5) {
+ // QuadFace
+ String[] facetokens1 = tokens[1].split("/");
+ String[] facetokens2 = tokens[2].split("/");
+ String[] facetokens3 = tokens[3].split("/");
+ String[] facetokens4 = tokens[4].split("/");
+
+ Vector3D p1, p2, p3;
+
+ Face f1 = new Face();
+ f1.material = currentmat;
+ p1 = (Vector3D)points.get(Integer.parseInt(facetokens1[0]) - 1);
+ p2 = (Vector3D)points.get(Integer.parseInt(facetokens2[0]) - 1);
+ p3 = (Vector3D)points.get(Integer.parseInt(facetokens3[0]) - 1);
+ f1.setPoints(p1, p2, p3);
+
+ if(f1.getXYangle() >= 90.0)
+ config.simpleterrain = false;
+
+ faces.add(f1);
+
+ Face f2 = new Face();
+ f2.material = currentmat;
+ p1 = (Vector3D)points.get(Integer.parseInt(facetokens1[0]) - 1);
+ p2 = (Vector3D)points.get(Integer.parseInt(facetokens3[0]) - 1);
+ p3 = (Vector3D)points.get(Integer.parseInt(facetokens4[0]) - 1);
+ f2.setPoints(p1, p2, p3);
+
+ if(f2.getXYangle() >= 90.0)
+ config.simpleterrain = false;
+
+ faces.add(f2);
+ }
+ } else if(tokens[0].equals("usemtl")) {
+ //change material
+
+ currentmat = tokens[1];
+ }
+ }
+
+ }
+
+ System.out.println("Read points: " + points.size() + " Read faces: " + faces.size());
+
+ }
+
+ public void writeMap() {
+ if(faces == null) return;
+
+ PrintWriter out = null;
+ try {
+ out = new PrintWriter(new FileWriter(config.mapfile));
+ } catch(Exception e) {
+ System.err.println("Can't open output file?!");
+ return;
+ }
+
+ out.print("{\n\"classname\" \"worldspawn\"\n");
+
+ for(int i = 0; i < faces.size(); i++) {
+ Face f = (Face)faces.get(i);
+ out.print(f.generateBrush());
+ }
+
+ out.print("}\n");
+ out.flush();
+ out.close();
+ }
+
+
+ private class Vector3D {
+ public double x, y, z;
+
+ public Vector3D() {
+ this(0.0, 0.0, 0.0);
+ }
+
+ public Vector3D(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public Vector3D crossproduct(Vector3D p1) {
+ Vector3D result = new Vector3D();
+
+ result.x = this.y * p1.z - this.z * p1.y;
+ result.y = this.z * p1.x - this.x * p1.z;
+ result.z = this.x * p1.y - this.y * p1.x;
+
+ return result;
+ }
+
+ public double dotproduct(Vector3D p1) {
+ return this.x * p1.x + this.y * p1.y + this.z * p1.z;
+ }
+
+ public Vector3D substract(Vector3D p1) {
+ Vector3D result = new Vector3D();
+
+ result.x = this.x - p1.x;
+ result.y = this.y - p1.y;
+ result.z = this.z - p1.z;
+
+ return result;
+ }
+
+ public void scale(double factor) {
+ x *= factor;
+ y *= factor;
+ z *= factor;
+ }
+
+ public double length() {
+ return Math.sqrt((x*x) + (y*y) + (z*z));
+ }
+
+ public void normalize() {
+ double l = length();
+
+ x /= l;
+ y /= l;
+ z /= l;
+ }
+
+ }
+
+
+ private class Face {
+ private Vector3D p1, p2, p3, normal;
+ private double angle_xy = 0.0;
+ public String material;
+
+ public void setPoints(Vector3D p1, Vector3D p2, Vector3D p3) {
+ this.p1 = p1;
+ this.p2 = p2;
+ this.p3 = p3;
+
+ computeNormal();
+ computeXYangle();
+ }
+
+ public double getXYangle() {
+ return angle_xy;
+ }
+
+ private void computeNormal() {
+ Vector3D vector1 = p1.substract(p2);
+ Vector3D vector2 = p1.substract(p3);
+
+ normal = vector1.crossproduct(vector2);
+ normal.normalize();
+ }
+
+ private void computeXYangle() {
+ Vector3D normal_xy = new Vector3D(0.0, 0.0, 1.0);
+ angle_xy = Math.acos(normal.dotproduct(normal_xy)) / (2 * Math.PI) * 360.0;
+ }
+
+ public String generateBrush() {
+ String result = "{\n";
+
+ // 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(config.brush_thickness);
+
+ Vector3D p1_, p2_, p3_;
+
+ if(!config.simpleterrain) {
+ p1_ = p1.substract(normal);
+ p2_ = p2.substract(normal);
+ p3_ = p3.substract(normal);
+ } else {
+ double min = config.minz;
+ min -= 16.0;
+ p1_ = new Vector3D(p1.x, p1.y, min);
+ p2_ = new Vector3D(p2.x, p2.y, min);
+ p3_ = new Vector3D(p3.x, p3.y, min);
+ }
+
+ String mat = material;
+
+ if(config.autotexturing.size() > 0) {
+ double maxangle = -1.0;
+ for(int i = 0; i < config.autotexturing.size(); i++) {
+ AutoTexturingEntry e = (AutoTexturingEntry)config.autotexturing.get(i);
+ if(angle_xy >= e.angle && e.angle > maxangle) {
+ mat = e.texturename;
+ maxangle = e.angle;
+ }
+ }
+ }
+
+ // top face, apply texture here
+ result += getMapPlaneString(p3, p2, p1, mat);
+
+ // bottom face
+ result += getMapPlaneString(p1_, p2_, p3_, "common/caulk");
+
+ // extruded side 1
+ result += getMapPlaneString(p1, p1_, p3_, "common/caulk");
+
+ // extruded side 2
+ result += getMapPlaneString(p2, p3, p3_, "common/caulk");
+
+ // extruded side 3
+ result += getMapPlaneString(p1, p2, p2_, "common/caulk");
+
+ result += "}\n";
+
+ return result;
+ }
+
+
+ private String getMapPlaneString(Vector3D p1, Vector3D p2, Vector3D p3, String material) {
+ 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 " + config.texture_scale + " " + config.texture_scale + " " + flag + " 0 0\n";
+ }
+
+ }
+
+}
Property changes on: trunk/misc/tools/ttf2conchars/foo.sh
___________________________________________________________________
Name: svn:executable
+ *
More information about the nexuiz-commits
mailing list