Skip to content

Commit 967a7b3

Browse files
committed
Plane works
1 parent f4e23bc commit 967a7b3

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Editors/EditorPlane.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public partial class EditorPlane : EditorBase
1616
{
1717
public EditorPlane()
1818
{
19-
InitializeComponent();
19+
InitializeComponent();
2020
}
2121

2222
public override bool ValidateState()
@@ -35,5 +35,22 @@ public override void LoadState(object item)
3535

3636
numDistance.Value = (decimal)pl.Distance;
3737
}
38+
39+
public override void SaveState(object item)
40+
{
41+
if (!(item is Plane pl))
42+
return;
43+
44+
// Update the plane's normal
45+
pl.Normal = new Vector(
46+
(float)numX.Value,
47+
(float)numY.Value,
48+
(float)numZ.Value
49+
);
50+
51+
// Update the plane's distance
52+
pl.Distance = (float)numDistance.Value;
53+
}
54+
3855
}
3956
}

MainForm.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ private void BuildScene()
8181
s3.Enabled = true;
8282
mScene.AddObject(s3);
8383

84+
Plane pln = new();
85+
pln.Material.Color = Color.yellow;
86+
mScene.AddObject(pln);
87+
8488
PointLight p = new PointLight();
8589
p.setPosition(new Vector(0, 15, 35));
8690
p.setColor(Color.white);
@@ -139,7 +143,7 @@ public MainForm()
139143
private void RegisterEditors()
140144
{
141145
EditorFactory.Register(typeof(Sphere).Name, () => new EditorSphere());
142-
//EditorFactory.Register(typeof(Plane).Name, () => new EditorPlane());
146+
EditorFactory.Register(typeof(Plane).Name, () => new EditorPlane());
143147
}
144148

145149
private void LoadItemsList()

0 commit comments

Comments
 (0)