Skip to content

Commit 54f7e9d

Browse files
committed
Updated D3D_ToProjection and Button Improvements
Extended the D3D_ToProjection method to include custom sizes, and improved the Button GUI elements
1 parent 8011ec2 commit 54f7e9d

5 files changed

Lines changed: 35 additions & 2 deletions

File tree

src/studios/vanish/engine/Button.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public enum ButtonType
2323
private int state = 0;
2424
private Shape bounds;
2525
private boolean down = false;
26+
public FillMode FillMode = studios.vanish.engine.FillMode.Solid;
2627
Window wnd;
2728
public Button(Window wnd, String text)
2829
{
@@ -67,6 +68,7 @@ else if (Type == ButtonType.Circle)
6768
{
6869
bounds = new Circle(BackColor[state], Location, rad);
6970
}
71+
bounds.FillMode = FillMode;
7072
}
7173
public void Check(Point MouseLocation, int Button)
7274
{

src/studios/vanish/engine/Circle.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ public Point GetShapeCenter()
8787
}
8888
public void Render(GraphicsUnit Graphics)
8989
{
90-
Graphics.FillEllipse(Color, new Point(Center.X - Radius, Center.Y - Radius), new Size(Radius * 2, Radius * 2));
90+
if (FillMode == studios.vanish.engine.FillMode.Solid)
91+
{
92+
Graphics.FillEllipse(Color, new Point(Center.X - Radius, Center.Y - Radius), new Size(Radius * 2, Radius * 2));
93+
}
94+
else
95+
{
96+
Graphics.DrawEllipse(Color, new Point(Center.X - Radius, Center.Y - Radius), new Size(Radius * 2, Radius * 2));
97+
}
9198
}
9299
}

src/studios/vanish/engine/GraphicsUnit.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ public Vertex D3D_ToProjection(Vertex vertex)
193193
}
194194
return position;
195195
}
196+
public Vertex D3D_ToProjection(Vertex vertex, Size wndSize, Vertex offset)
197+
{
198+
Size center = Resolution.half();
199+
double factor = FieldOfView / vertex.Z;
200+
factor = Math.abs(factor);
201+
Vertex position = new Vertex(vertex.X * factor + center.Width, vertex.Y * -factor + center.Height, vertex.Z);
202+
position.X = (position.X * wndSize.Width) / Resolution.Width;
203+
position.Y = (position.Y * wndSize.Height) / Resolution.Height;
204+
if (vertex.Z < 0)
205+
{
206+
position.X *= center.Width / 2;
207+
position.Y *= center.Height / 2;
208+
}
209+
position = position.add(offset);
210+
return position;
211+
}
196212
public static Vertex D3D_FromProjection(Point point, Size resolution, Size windowSize, double FieldOfView, double CameraZ)
197213
{
198214
Vertex position = new Vertex((point.X * resolution.Width) / windowSize.Width, (point.Y * resolution.Height) / windowSize.Height, CameraZ);

src/studios/vanish/engine/Rectangle.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ public Point GetShapeCenter()
2727
}
2828
public void Render(GraphicsUnit Graphics)
2929
{
30-
Graphics.FillRectangle(Color, Location, Size);
30+
if (FillMode == studios.vanish.engine.FillMode.Solid)
31+
{
32+
Graphics.FillRectangle(Color, Location, Size);
33+
}
34+
else
35+
{
36+
Graphics.DrawRectangle(Color, Location, Size);
37+
}
3138
}
3239
}

src/studios/vanish/engine/Shape.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public abstract class Shape
66
public Size Size;
77
public int Radius;
88
public Color Color;
9+
public FillMode FillMode = studios.vanish.engine.FillMode.Solid;
910
public void Initialize(Color Color, Point Location, Size Size)
1011
{
1112
this.Color = Color;

0 commit comments

Comments
 (0)