Commit e528cdbd authored by Human Gamer's avatar Human Gamer

Planes are now rendered

parent c48ae6b1
Pipeline #1781609 skipped
......@@ -10,6 +10,7 @@ import javax.swing.JFrame;
import javax.swing.JPanel;
import com.matt.difinspector.interior.InteriorResource;
import com.matt.difinspector.render.EnumSelectionMode;
import com.matt.difinspector.structures.PlaneF;
public class PlaneEditor extends JFrame
......@@ -59,6 +60,18 @@ public class PlaneEditor extends JFrame
this.planeId = 0;
}
@Override
public void setVisible(boolean b)
{
if (b)
{
DifInspector.getInstance().getRender().setSelected(EnumSelectionMode.PLANES, this.planeId);
} else {
DifInspector.getInstance().getRender().setSelected(EnumSelectionMode.NONE, 0);
}
super.setVisible(b);
}
public void setInterior(InteriorResource interior)
{
this.interior = interior;
......
......@@ -10,6 +10,7 @@ import javax.swing.JFrame;
import javax.swing.JPanel;
import com.matt.difinspector.interior.InteriorResource;
import com.matt.difinspector.render.EnumSelectionMode;
import com.matt.difinspector.structures.ItrPaddedPoint;
public class PointEditor extends JFrame
......@@ -59,6 +60,18 @@ public class PointEditor extends JFrame
this.pointId = 0;
}
@Override
public void setVisible(boolean b)
{
if (b)
{
DifInspector.getInstance().getRender().setSelected(EnumSelectionMode.POINTS, this.pointId);
} else {
DifInspector.getInstance().getRender().setSelected(EnumSelectionMode.NONE, 0);
}
super.setVisible(b);
}
public void setInterior(InteriorResource interior)
{
this.interior = interior;
......
......@@ -172,6 +172,7 @@ public class Selector extends JFrame
public void select()
{
this.setVisible(false);
int selectedIndex = this.indexField.getValue();
if (this.mode == EnumSelectionMode.SURFACES)
......@@ -180,7 +181,5 @@ public class Selector extends JFrame
DifInspector.getInstance().editPoint(selectedIndex);
else if (this.mode == EnumSelectionMode.PLANES)
DifInspector.getInstance().editPlane(selectedIndex);
this.setVisible(false);
}
}
......@@ -24,12 +24,14 @@ public class InteriorRender extends SceneObject
private int highlightIndex;
private EnumSelectionMode surfaceHighlight;
private ColorF highlightColor;
private ColorF highlightColorAlt;
public InteriorRender(InteriorResource interior)
{
this.interior = interior;
this.highlightColor = new ColorF(0.0f, 0.0f, 1.0f, 0.75f);
this.highlightColorAlt = new ColorF(0.0f, 1.0f, 0.0f, 0.75f);
this.surfaceHighlight = EnumSelectionMode.NONE;
this.highlightIndex = -1;
......@@ -337,7 +339,7 @@ public class InteriorRender extends SceneObject
{
PlaneF plane = planes[this.highlightIndex];
Plane p = new Plane(plane, this.highlightColor);
Plane p = new Plane(plane, this.highlightColorAlt, this.highlightColor);
p.render();
}
}
......
......@@ -10,31 +10,76 @@ import com.matt.difinspector.structures.Point3F;
public class Plane
{
protected PlaneF plane;
protected ColorF color;
protected ColorF colorFront;
protected ColorF colorBack;
public Plane(PlaneF plane, ColorF color)
public Plane(PlaneF plane, ColorF colorFront, ColorF colorBack)
{
this.plane = plane;
this.color = color;
this.colorFront = colorFront;
this.colorBack = colorBack;
}
public void render()
{
glColor(this.color);
{
Point3F up = new Point3F(0, 0, 1);
Point3F down = new Point3F(0, 0, -1);
Point3F left = new Point3F(0, 1, 0);
Point3F right = new Point3F(0, -1, 0);
float d = this.plane.getD();
Point3F tx = plane.cross(new Point3F(0.123664f, 0.16623f, 0.75443f));
Point3F ty = plane.cross(tx);
Point3F plane = this.plane;
float n = plane.length();
if (up.equals(plane))
{
up = new Point3F(1, 0, 0);
} else if (down.equals(plane))
{
up = new Point3F(-1, 0, 0);
}
if (left.equals(plane))
{
left = new Point3F(1, 0, 0);
} else if (right.equals(plane))
{
left = new Point3F(-1, 0, 0);
}
glBegin(GL_QUADS);
{
glVertex4f((tx.getX() + ty.getX()) + n * d, (tx.getY() + ty.getY()) + n * d, (tx.getZ() + ty.getZ()) + n * d, 0);
glVertex4f((tx.getX() - ty.getX()) + n * d, (tx.getY() - ty.getY()) + n * d, (tx.getZ() - ty.getZ()) + n * d, 0);
glVertex4f((-tx.getX() - ty.getX()) + n * d, (-tx.getY() - ty.getY()) + n * d, (-tx.getZ() - ty.getZ()) + n * d, 0);
glVertex4f((-tx.getX() + ty.getX()) + n * d, (-tx.getY() + ty.getY()) + n * d, (-tx.getZ() + ty.getZ()) + n * d, 0);
// HACKY HACK Y U NO WERK
if (plane.getX() > 0)
{
// Side 1
glColor(this.colorBack);
glVertex(plane.cross(up).mul(10).sub(plane.mul(d)));
glVertex(plane.cross(left).mul(10).sub(plane.mul(d)));
glVertex(up.cross(plane).mul(10).sub(plane.mul(d)));
glVertex(left.cross(plane).mul(10).sub(plane.mul(d)));
// Side 2
glColor(this.colorFront);
glVertex(left.cross(plane).mul(10).sub(plane.mul(d)));
glVertex(up.cross(plane).mul(10).sub(plane.mul(d)));
glVertex(plane.cross(left).mul(10).sub(plane.mul(d)));
glVertex(plane.cross(up).mul(10).sub(plane.mul(d)));
} else {
// Side 1
glColor(this.colorFront);
glVertex(plane.cross(up).mul(10).sub(plane.mul(d)));
glVertex(plane.cross(left).mul(10).sub(plane.mul(d)));
glVertex(up.cross(plane).mul(10).sub(plane.mul(d)));
glVertex(left.cross(plane).mul(10).sub(plane.mul(d)));
// Side 2
glColor(this.colorBack);
glVertex(left.cross(plane).mul(10).sub(plane.mul(d)));
glVertex(up.cross(plane).mul(10).sub(plane.mul(d)));
glVertex(plane.cross(left).mul(10).sub(plane.mul(d)));
glVertex(plane.cross(up).mul(10).sub(plane.mul(d)));
}
}
glEnd();
}
......
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