Commit e6acf4f8 authored by Human Gamer's avatar Human Gamer

New Stuff

parent be4ef65b
Pipeline #2775709 skipped
......@@ -4,7 +4,7 @@ import java.io.BufferedWriter;
import java.io.IOException;
import com.matt.difinspector.io.ReverseDataInputStream;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.math.Point3F;
public class AISpecialNode
{
......
......@@ -4,13 +4,13 @@ import java.io.BufferedWriter;
import java.io.IOException;
import com.matt.difinspector.io.ReverseDataInputStream;
import com.matt.difinspector.math.Box3F;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.math.SphereF;
import com.matt.difinspector.structures.BSPNode;
import com.matt.difinspector.structures.BSPSolidLeaf;
import com.matt.difinspector.structures.Box3F;
import com.matt.difinspector.structures.ColorF;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.structures.SphereF;
import com.matt.difinspector.structures.Surface;
public class ForceField
......
......@@ -15,12 +15,16 @@ import com.matt.difinspector.map.Brush;
import com.matt.difinspector.map.BrushPlane;
import com.matt.difinspector.materials.MaterialList;
import com.matt.difinspector.materials.TexGenList;
import com.matt.difinspector.math.Box3F;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.math.SphereF;
import com.matt.difinspector.math.TriangleF;
import com.matt.difinspector.models.OBJModel;
import com.matt.difinspector.models.OBJModel.OBJIndex;
import com.matt.difinspector.structures.AnimatedLight;
import com.matt.difinspector.structures.BSPNode;
import com.matt.difinspector.structures.BSPSolidLeaf;
import com.matt.difinspector.structures.Box3F;
import com.matt.difinspector.structures.ColorI;
import com.matt.difinspector.structures.ConvexHull;
import com.matt.difinspector.structures.CoordBin;
......@@ -29,15 +33,11 @@ import com.matt.difinspector.structures.ItrPaddedPoint;
import com.matt.difinspector.structures.LightState;
import com.matt.difinspector.structures.LightStateData;
import com.matt.difinspector.structures.NullSurface;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.structures.Portal;
import com.matt.difinspector.structures.SphereF;
import com.matt.difinspector.structures.Surface;
import com.matt.difinspector.structures.TexGenPlanes;
import com.matt.difinspector.structures.TexMatrix;
import com.matt.difinspector.structures.TriFan;
import com.matt.difinspector.structures.TriangleF;
import com.matt.difinspector.structures.Zone;
import com.matt.difinspector.util.Util;
import com.matt.jmatt.lists.ErrorList;
......
......@@ -5,8 +5,8 @@ import java.io.IOException;
import com.matt.difinspector.io.ReverseDataInputStream;
import com.matt.difinspector.io.ReverseDataOutputStream;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.structures.QuatF;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.math.QuatF;
import com.matt.difinspector.structures.WayPoint;
public class InteriorPathFollower
......
......@@ -5,9 +5,9 @@ import java.io.IOException;
import com.matt.difinspector.io.ReverseDataInputStream;
import com.matt.difinspector.io.ReverseDataOutputStream;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.structures.Edge;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.structures.Polyhedron;
public class InteriorResTrigger
......
......@@ -14,11 +14,11 @@ import java.util.List;
import com.matt.difinspector.io.ReverseDataInputStream;
import com.matt.difinspector.io.ReverseDataOutputStream;
import com.matt.difinspector.main.DifInspector;
import com.matt.difinspector.math.Point2F;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.mesh.InteriorBuilder;
import com.matt.difinspector.models.OBJModel;
import com.matt.difinspector.models.OBJModel.OBJIndex;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.structures.Point3F;
import com.matt.jmatt.lists.ErrorList;
public class InteriorResource
......
......@@ -6,12 +6,12 @@ import java.io.IOException;
import com.matt.difinspector.io.ReverseDataInputStream;
import com.matt.difinspector.io.ReverseDataOutputStream;
import com.matt.difinspector.materials.MaterialList;
import com.matt.difinspector.structures.Box3F;
import com.matt.difinspector.structures.MatrixF;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.structures.Point2I;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.math.Box3F;
import com.matt.difinspector.math.MatrixF;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.math.Point2F;
import com.matt.difinspector.math.Point2I;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.structures.Primitive;
import com.matt.difinspector.util.Util;
......
......@@ -5,7 +5,7 @@ import java.io.IOException;
import com.matt.difinspector.io.ReverseDataInputStream;
import com.matt.difinspector.io.ReverseDataOutputStream;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.math.Point3F;
public class ItrGameEntity
{
......
......@@ -4,7 +4,7 @@ import java.io.IOException;
import com.matt.difinspector.io.ReverseDataInputStream;
import com.matt.difinspector.io.ReverseDataOutputStream;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.math.Point3F;
public class MirrorSubObject extends InteriorSubObject
{
......
......@@ -39,16 +39,16 @@ import java.util.List;
import javax.imageio.ImageIO;
import com.matt.difinspector.structures.Box3F;
import com.matt.difinspector.math.Box3F;
import com.matt.difinspector.math.MatrixF;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.math.Point2F;
import com.matt.difinspector.math.Point2I;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.math.QuatF;
import com.matt.difinspector.math.SphereF;
import com.matt.difinspector.structures.ColorF;
import com.matt.difinspector.structures.ColorI;
import com.matt.difinspector.structures.MatrixF;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.structures.Point2I;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.structures.QuatF;
import com.matt.difinspector.structures.SphereF;
/**
* A data input stream lets an application read primitive Java data
......
......@@ -34,16 +34,16 @@ import java.io.UTFDataFormatException;
import javax.imageio.ImageIO;
import com.matt.difinspector.structures.Box3F;
import com.matt.difinspector.math.Box3F;
import com.matt.difinspector.math.MatrixF;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.math.Point2F;
import com.matt.difinspector.math.Point2I;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.math.QuatF;
import com.matt.difinspector.math.SphereF;
import com.matt.difinspector.structures.ColorF;
import com.matt.difinspector.structures.ColorI;
import com.matt.difinspector.structures.MatrixF;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.structures.Point2I;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.structures.QuatF;
import com.matt.difinspector.structures.SphereF;
/**
* A data output stream lets an application write primitive Java data types to an output stream in a portable way. An
......
......@@ -21,9 +21,9 @@ import javax.swing.filechooser.FileNameExtensionFilter;
import com.matt.difinspector.dts.DTSShape;
import com.matt.difinspector.interior.Interior;
import com.matt.difinspector.interior.InteriorResource;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.mesh.InteriorBuilder;
import com.matt.difinspector.render.GLRender;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.util.Settings;
public class DifInspector
......@@ -359,7 +359,7 @@ public class DifInspector
});
renderMenu.add(previewMenu);
JMenuItem settingsMenu = new JMenuItem("Render Settings");
/*JMenuItem settingsMenu = new JMenuItem("Render Settings");
settingsMenu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
......@@ -367,7 +367,7 @@ public class DifInspector
DifInspector.this.renderSettings();
}
});
renderMenu.add(settingsMenu);
renderMenu.add(settingsMenu);*/
this.menu.add(renderMenu);
......
......@@ -10,8 +10,8 @@ import javax.swing.JFrame;
import javax.swing.JPanel;
import com.matt.difinspector.interior.InteriorResource;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.render.EnumSelectionMode;
import com.matt.difinspector.structures.PlaneF;
public class PlaneEditor extends JFrame
{
......
......@@ -11,7 +11,7 @@ import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.math.PlaneF;
public class PlaneField extends JComponent
{
......
......@@ -10,7 +10,7 @@ import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import com.matt.difinspector.interior.Interior;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.util.Util;
public class PlanesPanel extends SubPanel
......
......@@ -11,7 +11,7 @@ import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.math.Point2F;
public class Point2Field extends JComponent
{
......
......@@ -11,7 +11,7 @@ import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import com.matt.difinspector.structures.Point2I;
import com.matt.difinspector.math.Point2I;
public class Point2IField extends JComponent
{
......
......@@ -11,7 +11,7 @@ import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.math.Point3F;
public class Point3Field extends JComponent
{
......
......@@ -13,8 +13,9 @@ import javax.swing.JRadioButton;
import com.matt.difinspector.interior.Interior;
import com.matt.difinspector.interior.InteriorResource;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.math.QuatF;
import com.matt.difinspector.render.GLRender;
import com.matt.difinspector.structures.Point3F;
public class RenderSettings extends JFrame
{
......@@ -230,7 +231,7 @@ public class RenderSettings extends JFrame
this.render.setAutoRotate(this.rotate.isSelected());
this.render.getCamera().getTransform().setPosition(this.position.getPoint());
this.render.getCamera().getTransform().setRotation(this.rotation.getPoint());
this.render.getCamera().getTransform().setRotation(new QuatF(this.rotation.getPoint()));
}
private void updateHighlighting()
......
......@@ -8,7 +8,7 @@ import javax.swing.JFrame;
import javax.swing.JPanel;
import com.matt.difinspector.materials.TexData;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.math.Point2F;
public class SetCoordsWindow extends JFrame
{
......
......@@ -15,10 +15,10 @@ import javax.swing.JTextField;
import com.matt.difinspector.interior.InteriorResource;
import com.matt.difinspector.materials.TexData;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.structures.Point2I;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.math.Point2F;
import com.matt.difinspector.math.Point2I;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.structures.Surface;
import com.matt.difinspector.structures.TexGenPlanes;
import com.matt.difinspector.util.ImageData;
......
......@@ -5,7 +5,7 @@ import java.awt.FlowLayout;
import javax.swing.JComponent;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.math.Point2F;
public class TexCoordField extends JComponent
{
......
......@@ -3,8 +3,8 @@ package com.matt.difinspector.map;
import java.util.ArrayList;
import java.util.List;
import com.matt.difinspector.math.Point3F;
import com.matt.difinspector.structures.ConvexHull;
import com.matt.difinspector.structures.Point3F;
public class Brush
{
......
......@@ -2,8 +2,8 @@ package com.matt.difinspector.map;
import java.util.List;
import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.math.PlaneF;
import com.matt.difinspector.math.Point3F;
public class BrushPlane
{
......
package com.matt.difinspector.materials;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.math.Point2F;
import com.matt.difinspector.math.Point3F;
public class TexData
{
......
package com.matt.difinspector.math;
public class AngAxisF
{
protected Point3F axis;
protected float angle;
public AngAxisF(float x, float y, float z, float angle)
{
this(new Point3F(x, y, z), angle);
}
public AngAxisF()
{
this(1, 0, 0, 0);
}
public AngAxisF(Point3F axis, float angle)
{
this.axis = axis;
this.angle = angle;
}
public AngAxisF(QuatF quaternion)
{
float cosHalfAngle = quaternion.w;
float angle = (float)Math.acos(cosHalfAngle) * 2;
float sinHalfAngle = (float)Math.sin(angle / 2);
float x = quaternion.x / sinHalfAngle;
float y = quaternion.y / sinHalfAngle;
float z = quaternion.z / sinHalfAngle;
this.axis = new Point3F(x, y, z);
this.angle = (float) Math.toDegrees(angle);
}
public AngAxisF toDegrees()
{
return new AngAxisF(this.axis, (float)Math.toDegrees(this.angle));
}
public AngAxisF toRadians()
{
return new AngAxisF(this.axis, (float)Math.toRadians(this.angle));
}
public Point3F toEuler()
{
Point3F axis = new Point3F(this.axis.x, this.axis.y, this.axis.z);
Point3F euler = axis.mul(-this.angle);
return euler;
}
public Point3F getAxis()
{
return axis;
}
public void setAxis(Point3F axis)
{
this.axis = axis;
}
public float getAngle()
{
return angle;
}
public void setAngle(float angle)
{
this.angle = angle;
}
@Override
public boolean equals(Object o)
{
if (!(o instanceof AngAxisF))
return false;
AngAxisF other = (AngAxisF)o;
return this.axis.equals(other.axis) && this.angle == other.angle;
}
@Override
public String toString()
{
return "(AngAxisF){axis: " + this.axis.toString() + ", angle: " + this.angle + "}";
}
}
package com.matt.difinspector.structures;
package com.matt.difinspector.math;
public class Box3F
{
......
package com.matt.difinspector.math;
public class MatrixF
{
private float[][] m;
public MatrixF()
{
this.m = new float[4][4];
}
public MatrixF(float[][] m)
{
this.m = m;
}
public MatrixF initIdentity()
{
m[0][0] = 1; m[0][1] = 0; m[0][2] = 0; m[0][3] = 0;
m[1][0] = 0; m[1][1] = 1; m[1][2] = 0; m[1][3] = 0;
m[2][0] = 0; m[2][1] = 0; m[2][2] = 1; m[2][3] = 0;
m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1;
return this;
}
public MatrixF initTranslation(float x, float y, float z)
{
m[0][0] = 1; m[0][1] = 0; m[0][2] = 0; m[0][3] = x;
m[1][0] = 0; m[1][1] = 1; m[1][2] = 0; m[1][3] = y;
m[2][0] = 0; m[2][1] = 0; m[2][2] = 1; m[2][3] = z;
m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1;
return this;
}
public MatrixF initRotation(float x, float y, float z)
{
MatrixF rx = new MatrixF();
MatrixF ry = new MatrixF();
MatrixF rz = new MatrixF();
x = (float)Math.toRadians(x);
y = (float)Math.toRadians(y);
z = (float)Math.toRadians(z);
rz.m[0][0] = (float)Math.cos(z); rz.m[0][1] = -(float)Math.sin(z); rz.m[0][2] = 0; rz.m[0][3] = 0;
rz.m[1][0] = (float)Math.sin(z); rz.m[1][1] = (float)Math.cos(z); rz.m[1][2] = 0; rz.m[1][3] = 0;
rz.m[2][0] = 0; rz.m[2][1] = 0; rz.m[2][2] = 1; rz.m[2][3] = 0;
rz.m[3][0] = 0; rz.m[3][1] = 0; rz.m[3][2] = 0; rz.m[3][3] = 1;
rx.m[0][0] = 1; rx.m[0][1] = 0; rx.m[0][2] = 0; rx.m[0][3] = 0;
rx.m[1][0] = 0; rx.m[1][1] = (float)Math.cos(x); rx.m[1][2] = -(float)Math.sin(x); rx.m[1][3] = 0;
rx.m[2][0] = 0; rx.m[2][1] = (float)Math.sin(x); rx.m[2][2] = (float)Math.cos(x); rx.m[2][3] = 0;
rx.m[3][0] = 0; rx.m[3][1] = 0; rx.m[3][2] = 0; rx.m[3][3] = 1;
ry.m[0][0] = (float)Math.cos(y); ry.m[0][1] = 0; ry.m[0][2] = -(float)Math.sin(y); ry.m[0][3] = 0;
ry.m[1][0] = 0; ry.m[1][1] = 1; ry.m[1][2] = 0; ry.m[1][3] = 0;
ry.m[2][0] = (float)Math.sin(y); ry.m[2][1] = 0; ry.m[2][2] = (float)Math.cos(y); ry.m[2][3] = 0;
ry.m[3][0] = 0; ry.m[3][1] = 0; ry.m[3][2] = 0; ry.m[3][3] = 1;
m = rz.mul(ry.mul(rx)).getM();
return this;
}
public MatrixF initScale(float x, float y, float z)
{
m[0][0] = x; m[0][1] = 0; m[0][2] = 0; m[0][3] = 0;
m[1][0] = 0; m[1][1] = y; m[1][2] = 0; m[1][3] = 0;
m[2][0] = 0; m[2][1] = 0; m[2][2] = z; m[2][3] = 0;
m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1;
return this;
}
public MatrixF initPerspective(float fov, float aspectRatio, float zNear, float zFar)
{
float tanHalfFOV = (float)Math.tan(fov / 2);
float zRange = zNear - zFar;
m[0][0] = 1.0f / (tanHalfFOV * aspectRatio); m[0][1] = 0; m[0][2] = 0; m[0][3] = 0;
m[1][0] = 0; m[1][1] = 1.0f / tanHalfFOV; m[1][2] = 0; m[1][3] = 0;
m[2][0] = 0; m[2][1] = 0; m[2][2] = (-zNear - zFar) / zRange; m[2][3] = 2 * zFar * zNear / zRange;
m[3][0] = 0; m[3][1] = 0; m[3][2] = 1; m[3][3] = 0;
return this;
}
public MatrixF initOrthographic(float left, float right, float bottom, float top, float near, float far)
{
float width = right - left;
float height = top - bottom;
float depth = far - near;
m[0][0] = 2 / width; m[0][1] = 0; m[0][2] = 0; m[0][3] = -(right + left) / width;
m[1][0] = 0; m[1][1] = 2 / height; m[1][2] = 0; m[1][3] = -(top + bottom) / height;
m[2][0] = 0; m[2][1] = 0; m[2][2] = -2 / depth; m[2][3] = -(far + near) / depth;
m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1;
return this;
}
public MatrixF initRotation(Point3F forward, Point3F up)
{
Point3F f = forward.normalized();
Point3F r = up.normalized();
r = r.cross(f);
Point3F u = f.cross(r);
return initRotation(f, u, r);
}
public MatrixF initRotation(Point3F forward, Point3F up, Point3F right)
{
Point3F f = forward;
Point3F r = right;
Point3F u = up;
m[0][0] = r.x; m[0][1] = r.y; m[0][2] = r.z; m[0][3] = 0;
m[1][0] = u.x; m[1][1] = u.y; m[1][2] = u.z; m[1][3] = 0;
m[2][0] = f.x; m[2][1] = f.y; m[2][2] = f.z; m[2][3] = 0;
m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1;
return this;
}
public Point3F transform(Point3F r)
{
return new Point3F(m[0][0]*r.x + m[0][1]*r.y + m[0][2]*r.z + m[0][3],
m[1][0]*r.x + m[1][1]*r.y + m[1][2]*r.z + m[1][3],
m[2][0]*r.x + m[2][1]*r.y + m[2][2]*r.z + m[2][3]);
}
public MatrixF mul(MatrixF r)
{
MatrixF res = new MatrixF();
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
res.set(i, j, m[i][0] * r.get(0, j) +
m[i][1] * r.get(1, j) +
m[i][2] * r.get(2, j) +
m[i][3] * r.get(3, j));
}
}
return res;
}
public Point3F toEuler()
{
Point3F r = new Point3F();
r.x = (float)Math.asin(m[2][1]);
if (Math.cos(r.x) != 0.0f)
{
r.y = (float)Math.atan2(-m[2][0], m[2][2]);
r.z = (float)Math.atan2(-m[0][1], m[1][1]);
} else {
r.y = 0.0f;
r.z = (float)Math.atan2(m[1][0], m[0][0]);
}
return r;
}
public float[][] getM()
{
return this.m;
}
public float get(int x, int y)
{
return this.m[x][y];
}