Commit 78a3f328 authored by Human Gamer's avatar Human Gamer

Fixed v3 export

parent a41dd5f8
Pipeline #2070196 skipped
......@@ -1885,6 +1885,8 @@ public class Interior
// Looking at MBU in IDA reveals that these don't exist in version 0 OR 1.
if (targetVersion > 1 && targetVersion <= 5)
{
if (this.edges == null)
this.edges = new Edge[0];
dos.writeInt(this.edges.length);
for (int i = 0; i < this.edges.length; i++)
{
......
......@@ -509,7 +509,9 @@ public class InteriorResource
for (OBJIndex index : model.getIndices())
{
Point3F vertex = model.getPositions().get(index.getVertexIndex());
Point2F texCoord = model.getTexCoords().get(index.getTexCoordIndex());
Point2F texCoord = new Point2F(0, 0);
if (index.getTexCoordIndex() > -1)
texCoord = model.getTexCoords().get(index.getTexCoordIndex());
String texture = model.getTextures().get(index.getTextureIndex());
ib.addVertex(vertex, texCoord, texture);
......
......@@ -259,6 +259,18 @@ public class DifInspector
fileMenu.addSeparator();
JMenuItem batchOBJToDif = new JMenuItem("Batch OBJ2DIF");
batchOBJToDif.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
DifInspector.this.batchOBJ2DIF();
}
});
fileMenu.add(batchOBJToDif);
fileMenu.addSeparator();
/*
* JMenuItem verifyMenu = new JMenuItem("Verify BSP"); verifyMenu.addActionListener(new ActionListener() {
*
......@@ -816,6 +828,54 @@ public class DifInspector
this.settings.setVisible(true);
}
public void batchOBJ2DIF()
{
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setMultiSelectionEnabled(true);
chooser.setFileFilter(new FileNameExtensionFilter("Object Model Files (.obj)", "obj"));
if (!Settings.getLastOpenDir().isEmpty())
chooser.setCurrentDirectory(new File(Settings.getLastOpenDir()));
int option = chooser.showOpenDialog(this.frame);
if (option != JFileChooser.APPROVE_OPTION)
return;
File[] files = chooser.getSelectedFiles();
if (files != null && files.length > 0)
{
for (int i = 0; i < files.length; i++)
{
File file = files[i];
if (file != null && file.exists())
{
Thread objLoader = new Thread(new Runnable(){
@Override
public void run()
{
InteriorResource res = new InteriorResource();
if (res.readOBJ(file))
{
String p = file.toString();
p = p.replace(".obj", ".dif");
res.write(new File(p), 0);
} else
{
JOptionPane.showMessageDialog(DifInspector.this.frame, "Failed to load interior!");
}
}
});
objLoader.start();
}
}
JOptionPane.showMessageDialog(DifInspector.this.frame, "Conversion Done!");
}
String dir = chooser.getCurrentDirectory().toString();
Settings.setLastOpenDir(dir);
Settings.saveConfig();
}
public void about()
{
JOptionPane.showMessageDialog(this.frame, "Created By Matthieu Parizeau\nWith help from Anthony Kleine and Whirligig", "About", JOptionPane.INFORMATION_MESSAGE);
......
......@@ -130,8 +130,12 @@ public class InteriorBuilder
float rotation = 0;
if (texture.equalsIgnoreCase("edge_white") || texture.equalsIgnoreCase("edge_white_mbm"))
scale = new Point2F(0.125f, 0.125f);
if (texture.equalsIgnoreCase("plate_1"))
scale = new Point2F(0.125f, 0.125f);
if (texture.equalsIgnoreCase("stripe_caution") || texture.equalsIgnoreCase("stripe_caution_mbm"))
rotation = 45;
if (texture.equalsIgnoreCase("beam"))
rotation = 90;
TexData texData = new TexData(normal, new Point2F(0, 0), rotation, scale);
ImageData imageData = images.get(texture);
TexGenPlanes texGenPlanes = new TexGenPlanes(normal, point, uv);
......
......@@ -23,10 +23,16 @@ public class MeshBuilder
public void addVertex(Point3F vertex, Point2F uv, String texture)
{
this.positions.add(vertex);
this.textureCoordinates.add(uv);
if (texture.contains("."))
texture = texture.substring(0, texture.lastIndexOf("."));
if (texture.equalsIgnoreCase("material"))
{
this.addVertex(vertex, uv);
return;
}
this.positions.add(vertex);
this.textureCoordinates.add(uv);
this.textures.add(texture);
}
......
......@@ -148,7 +148,7 @@ public class OBJModel
public OBJIndex()
{
this.texCoordIndex = -1;
}
public int getVertexIndex()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment