trackeditor: check object ac file surfaces

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8954 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: e55884a41a2d75237a6a82a0071cdf8901f5216d
Former-commit-id: 985ffa181d717072f4be00f5a5df4ac4ecf310fd
This commit is contained in:
iobyte 2023-05-29 01:44:31 +00:00
parent e7b2872098
commit 4abfa13a03
4 changed files with 79 additions and 2 deletions

View file

@ -736,7 +736,72 @@ public class CheckDialog extends JDialog
{
e.printStackTrace();
}
Ac3d ac3dFile = new Ac3d();
try
{
ac3dFile.read(file);
Ac3dObject root = ac3dFile.getRoot();
if (root != null && "world".equals(root.getType()))
{
for (int i = 0; i < root.getKids().size(); i++)
{
checkKid(file, root.getKids().get(i));
}
}
}
catch (Ac3dException e)
{
textArea.append("Object file " + file.toString() + " line " + e.getLineNumber() + " : " + e.getLocalizedMessage() + "\n");
}
catch (Exception e)
{
textArea.append("Object file " + file.toString() + " : " + e.getLocalizedMessage() + "\n");
}
}
public void checkKid(File file, Ac3dObject object)
{
if ("poly".equals(object.getType()))
{
Set<Integer> types = new HashSet<Integer>();
Set<Integer> mats = new HashSet<Integer>();
for (int i = 0; i < object.getSurfaces().size(); i++)
{
Ac3dSurface surface = object.getSurfaces().get(i);
if (surface.getRefs().size() != 3)
{
textArea.append("Object file " + file.toString() + " line " + surface.getLinenum() + " : surface with " + surface.getRefs().size() + " vertices\n");
}
types.add(surface.getSurf());
mats.add(surface.getMat());
}
if (types.size() > 1)
{
textArea.append("Object file " + file.toString() + " line " + object.getLinenum() + " : object with " + types.size() + " surface types\n");
}
if (mats.size() > 1)
{
textArea.append("Object file " + file.toString() + " line " + object.getLinenum() + " : object with " + types.size() + " materials\n");
}
}
else
{
for (int i = 0; i < object.getKids().size(); i++)
{
checkKid(file, object.getKids().get(i));
}
}
}
private void checkTexture(String description, String texture)
{
Vector<String> messages = new Vector<String>();

View file

@ -34,7 +34,7 @@ public class Properties
private static Properties instance = new Properties();
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
public final String title = "sd2-trackeditor";
public final String version = "1.2.19";
public final String version = "1.2.20";
private String path;
private double imageScale = 1;

View file

@ -191,6 +191,7 @@ public class Ac3d
else if (tokens[0].equals("SURF"))
{
surface.setSurf(Integer.decode(tokens[1]));
surface.setLinenum(linenum);
}
else if (tokens[0].equals("mat"))
{
@ -228,7 +229,7 @@ public class Ac3d
{
while (readLine())
{
if (tokens.length == 0)
if (tokens.length == 0 || (tokens.length == 1 && tokens[0].isBlank()))
{
continue;
}

View file

@ -39,6 +39,7 @@ public class Ac3dSurface
public static final int SIDED_ONE = 0x00;
public static final int SIDED_TWO = 0x20;
private int linenum = 0;
private Integer surf;
private Integer mat;
private Vector<Ref> refs = new Vector<Ref>();
@ -223,4 +224,14 @@ public class Ac3dSurface
{
refs.add(new Ref(index, i, j));
}
public int getLinenum()
{
return linenum;
}
public void setLinenum(int linenum)
{
this.linenum = linenum;
}
}