Commit 5acb707a authored by Human Gamer's avatar Human Gamer

Automatically Flips Normals

parent baba25d1
......@@ -220,7 +220,7 @@ public class DifInspector
DifInspector.this.exportMap();
}
});
//fileMenu.add(exportMap);
fileMenu.add(exportMap);
JMenuItem exportCsx = new JMenuItem("Export Csx");
exportCsx.addActionListener(new ActionListener() {
......
......@@ -61,12 +61,16 @@ public class InteriorBuilder
Mesh mesh = builder.build();
Interior result = new Interior();
System.out.println("Adding Points");
ItrPaddedPoint[] points = new ItrPaddedPoint[mesh.getVertices().length];
for (int i = 0; i < points.length; i++)
points[i] = new ItrPaddedPoint(mesh.getVertices()[i]);
result.setPoints(points);
System.out.println("Adding Windings");
result.setWindings(mesh.getIndices());
System.out.println("Adding MaterialList");
MaterialList materialList = new MaterialList();
for (String texture : mesh.getTextures())
materialList.addMaterial(texture);
......@@ -74,6 +78,7 @@ public class InteriorBuilder
int[] textureIndices = mesh.getTextureIndices();
System.out.println("Adding TexGenEQs");
OptimizedList<Point2F> texCoords = new OptimizedList<Point2F>(mesh.getTextureCoords(), mesh.getTexCoordIndices());
OptimizedList<TexGenPlanes> texGenEQs = new OptimizedList<TexGenPlanes>();
......@@ -88,6 +93,7 @@ public class InteriorBuilder
texGenList.add(planes);
result.setTexGenEQs(texGenList);
System.out.println("Processing Faces");
OptimizedList<Point3F> vertices = new OptimizedList<Point3F>(mesh.getVertices(), mesh.getIndices());
OptimizedList<Face> faces = new OptimizedList<Face>();
......@@ -140,6 +146,7 @@ public class InteriorBuilder
}
System.out.println();*/
System.out.println("Adding Planes");
List<Face> facesObjs = faces.getObjects();
OptimizedList<PlaneF> planes = new OptimizedList<PlaneF>();
for (Face f : facesObjs)
......@@ -148,11 +155,13 @@ public class InteriorBuilder
}
result.setPlanes(planes.getObjects());
System.out.println("Adding Plane Normals");
Point3F[] planeNormals = new Point3F[planes.sizeIndices()];
for (int i = 0; i < planes.sizeIndices(); i++)
planeNormals[i] = planes.getObject(i);
result.setPlaneNormals(planeNormals);
System.out.println("Adding Surfaces");
OptimizedList<Surface> surfaces = new OptimizedList<Surface>();
OptimizedList<String> textures = new OptimizedList<String>(mesh.getTextures(), mesh.getTextureIndices());
......@@ -184,6 +193,7 @@ public class InteriorBuilder
}
result.setSurfaces(surfaces.getObjects());
System.out.println("Adding PointVisibilities");
byte[] pointVisibilities = new byte[points.length];
for (int i = 0; i < points.length; i++)
{
......@@ -191,53 +201,78 @@ public class InteriorBuilder
}
result.setPointVisibility(pointVisibilities);
System.out.println("Adding Winding Indices");
result.setWindingIndices(new TriFan[0]);
System.out.println("Adding Zones");
Zone[] zones = new Zone[1];
zones[0] = new Zone((short)0, (short)0, 0, 0, (short)surfaces.sizeIndices(), (short)0, 0, 0, (short)0, (short)0);
result.setZones(zones);
System.out.println("Adding Zone Surfaces");
short[] zoneSurfaces = new short[surfaces.sizeIndices()];
for (short i = 0; i < surfaces.sizeIndices(); i++)
zoneSurfaces[i] = i;
result.setZoneSurfaces(zoneSurfaces);
System.out.println("Adding Zone Static Meshes");
result.setZoneStaticMeshes(new int[0]);
System.out.println("Adding Zone Portal List");
result.setZonePortalList(new short[0]);
System.out.println("Adding Portals");
result.setPortals(new Portal[0]);
System.out.println("Adding NormalLMapIndices");
// NormalLMapIndices may be more complicated
int[] normalLMapIndices = new int[surfaces.sizeIndices()];
for (int i = 0; i < surfaces.sizeIndices(); i++)
normalLMapIndices[i] = i;
result.setNormalLMapIndices(normalLMapIndices);
System.out.println("Adding AlarmLMapIndices");
int[] alarmLMapIndices = new int[surfaces.sizeIndices()];
for (int i = 0; i < surfaces.sizeIndices(); i++)
alarmLMapIndices[i] = 255;
result.setAlarmLMapIndices(alarmLMapIndices);
System.out.println("Adding NullSurfaces");
// TODO: Null Surfaces
result.setNullSurfaces(new NullSurface[0]);
System.out.println("Adding LightMaps");
// TODO: Light Maps
result.setLightMaps(new BufferedImage[0]);
result.setLightDirMaps(new BufferedImage[0]);
result.setLightMapKeep(new boolean[0]);
System.out.println("Adding Solid Leaf Surfaces");
// TODO: Solid Leaf Surfaces
int[] solidLeafSurfaces = new int[planes.sizeIndices()];
for (int i = 0; i < planes.sizeIndices(); i++)
solidLeafSurfaces[i] = i;
result.setSolidLeafSurfaces(solidLeafSurfaces);
System.out.println("Adding Animated Lights");
result.setAnimatedLights(new AnimatedLight[0]);
System.out.println("Adding Light States");
result.setLightStates(new LightState[0]);
System.out.println("Adding Light State Data");
result.setLightStateData(new LightStateData[0]);
System.out.println("Adding State Data Buffer");
result.setStateDataBuffer(new byte[0]);
System.out.println("Adding Name Buffer");
result.setNameBuffer(new char[0]);
System.out.println("Adding Sub Objects");
result.setSubObjects(new InteriorSubObject[0]);
System.out.println("Adding Convex Hulls");
ConvexHull[] convexHulls = new ConvexHull[surfaces.sizeIndices()];
for (int i = 0; i < surfaces.sizeIndices(); i++)
{
......@@ -262,8 +297,10 @@ public class InteriorBuilder
}
result.setConvexHulls(convexHulls);
// TODO: Convex Hull Emit Strings
System.out.println("Adding Convex Hull Emit Strings");
result.setConvexHullEmitStrings(new byte[]{0});
// TODO: Hull Indices
System.out.println("Adding Hull Indices");
int[] hullIndices = new int[convexHulls.length * 8];
for (int i = 0; i < hullIndices.length; i++)
{
......@@ -271,11 +308,13 @@ public class InteriorBuilder
}
result.setHullIndices(hullIndices);
// TODO: Hull Plane Indices
System.out.println("Adding Hull Plane Indices");
short[] hullPlaneIndices = new short[planes.sizeIndices()];
for (short i = 0; i < planes.sizeIndices(); i++)
hullPlaneIndices[i] = i;
result.setHullPlaneIndices(hullPlaneIndices);
// TODO: Hull Emit String Indices
System.out.println("Adding Hull Emit String Indices");
int[] hullEmitStringIndices = new int[convexHulls.length * 8];
for (int i = 0; i < hullEmitStringIndices.length; i++)
{
......@@ -283,49 +322,70 @@ public class InteriorBuilder
}
result.setHullEmitStringIndices(hullEmitStringIndices);
System.out.println("Adding Hull Surface Indices");
int[] hullSurfaceIndices = new int[surfaces.sizeIndices()];
for (int i = 0; i < surfaces.sizeIndices(); i++)
hullSurfaceIndices[i] = surfaces.indexOfObject(surfaces.getObject(i));
result.setHullSurfaceIndices(hullSurfaceIndices);
// TODO: Poly List Planes
System.out.println("Adding Poly List Planes");
short[] polyListPlanes = new short[planes.sizeIndices()];
for (short i = 0; i < planes.sizeIndices(); i++)
polyListPlanes[i] = i;
result.setPolyListPlanes(polyListPlanes);
// TODO: Poly List Points
System.out.println("Adding Poly List Points");
int[] polyListPoints = new int[points.length];
for (int i = 0; i < points.length; i++)
polyListPoints[i] = i;
result.setPolyListPoints(polyListPoints);
// TODO: Poly List Strings
System.out.println("Adding Poly List Strings");
byte[] polyListStrings = new byte[]{0};
result.setPolyListStrings(polyListStrings);
// TODO: CoordBins
// TODO: CoordBinIndices
System.out.println("Building CoordBins");
CoordBin[] coordBins = new CoordBin[256];
for (int i = 0; i < coordBins.length; i++)
coordBins[i] = new CoordBin(i, 1);
result.setCoordBins(coordBins);
System.out.println("Building CoordBin Indices");
short[] coordBinIndices = new short[coordBins.length];
for (short i = 0; i < coordBins.length; i++)
coordBinIndices[i] = i;
result.setCoordBinIndices(coordBinIndices);
System.out.println("Adding CoordBinMode");
result.setCoordBinMode(0);
System.out.println("Adding BaseAmbient");
result.setBaseAmbient(new ColorI((byte)0, (byte)0, (byte)0, (byte)-1));
System.out.println("Adding AlarmAmbient");
result.setAlarmAmbient(new ColorI((byte)0, (byte)0, (byte)0, (byte)-1));
System.out.println("Adding Static Meshes");
result.setStaticMeshes(new InteriorSimpleMesh[0]);
System.out.println("Adding Normals");
result.setNormals(new Point3F[0]);
System.out.println("Adding TexMatrices");
result.setTexMatrices(new TexMatrix[0]);
System.out.println("Adding TexMatIndices");
result.setTexMatIndices(new int[0]);
System.out.println("Adding Light Map Border Size");
result.setLightMapBorderSize(2);
// TODO: BSPNodes
System.out.println("Adding BSPNodes");
BSPNode[] bspNodes = new BSPNode[surfaces.sizeIndices()];
for (int i = 0; i < surfaces.sizeIndices(); i++)
{
......@@ -339,11 +399,13 @@ public class InteriorBuilder
}
result.setBspNodes(bspNodes);
System.out.println("Adding BSPSolidLeaves");
BSPSolidLeaf[] bspSolidLeaves = new BSPSolidLeaf[surfaces.sizeIndices()];
for (int i = 0; i < surfaces.sizeIndices(); i++)
bspSolidLeaves[i] = new BSPSolidLeaf(i, (short)1);
result.setBspSolidLeaves(bspSolidLeaves);
System.out.println("Processing Data");
result.processData();
return result;
......
......@@ -84,6 +84,16 @@ public class OBJModel
}
meshReader.close();
System.out.println("Reversing Vertex Order");
List<OBJIndex> newIndices = new ArrayList<OBJIndex>();
for (int i = this.indices.size() - 1; i >= 0; i--)
{
newIndices.add(this.indices.get(i));
}
this.indices = newIndices;
}
private OBJIndex parseOBJIndex(String token, String texture)
......@@ -91,6 +101,11 @@ public class OBJModel
String[] values = token.split("/");
OBJIndex result = new OBJIndex();
if (texture.isEmpty())
{
texture = "NULL";
this.textures.add(texture);
}
result.setTextureIndex(this.textures.indexOf(texture));
result.setVertexIndex(Integer.parseInt(values[0]) - 1);
......
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