Skip to content

Commit c4348d3

Browse files
committed
Can select object colors now
1 parent aea77c0 commit c4348d3

File tree

5 files changed

+144
-51
lines changed

5 files changed

+144
-51
lines changed

Editors/EditorGObject.Designer.cs

Lines changed: 22 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editors/EditorMaterial.Designer.cs

Lines changed: 22 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editors/EditorMaterial.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public override void ResetState()
2828

2929
public override bool ValidateState()
3030
{
31-
return true;
31+
return true;
3232
}
3333

3434
public override void LoadState(object item)
@@ -39,6 +39,11 @@ public override void LoadState(object item)
3939
if (obj.Material == null)
4040
return;
4141

42+
int r = (int)(obj.Material.Color.r * 255);
43+
int g = (int)(obj.Material.Color.g * 255);
44+
int b = (int)(obj.Material.Color.b * 255);
45+
panelColor.BackColor = System.Drawing.Color.FromArgb(r, g, b);
46+
4247
numGloss.Value = (decimal)obj.Material.Gloss;
4348
numSpecular.Value = (decimal)obj.Material.Specular;
4449
numReflection.Value = (decimal)obj.Material.Reflection;
@@ -52,9 +57,29 @@ public override void SaveState(object item)
5257
if (obj.Material == null)
5358
return;
5459

60+
// take color from panel and store back into Material.Color
61+
var c = panelColor.BackColor;
62+
obj.Material.Color.r = c.R / 255f;
63+
obj.Material.Color.g = c.G / 255f;
64+
obj.Material.Color.b = c.B / 255f;
65+
66+
// save numeric values back into material
5567
obj.Material.Gloss = (float)numGloss.Value;
5668
obj.Material.Specular = (float)numSpecular.Value;
5769
obj.Material.Reflection = (float)numReflection.Value;
5870
}
71+
72+
73+
private void panelColor_Click(object sender, EventArgs e)
74+
{
75+
// Show dialog with current color pre-selected
76+
dlgColor.Color = panelColor.BackColor;
77+
78+
if (dlgColor.ShowDialog() == DialogResult.OK)
79+
{
80+
// Update the panel to the new color
81+
panelColor.BackColor = dlgColor.Color;
82+
}
83+
}
5984
}
6085
}

0 commit comments

Comments
 (0)