Implement #524 Allow flat colors. Adds an edit control for Ambient lighting.

pull/655/head
phkahler 2020-07-17 16:59:17 -04:00 committed by whitequark
parent c75b2e473e
commit 188b2e26ce
3 changed files with 18 additions and 2 deletions

View File

@ -18,6 +18,12 @@ void TextWindow::ScreenChangeLightIntensity(int link, uint32_t v) {
SS.TW.edit.i = v; SS.TW.edit.i = v;
} }
void TextWindow::ScreenChangeLightAmbient(int link, uint32_t v) {
SS.TW.ShowEditControl(31, ssprintf("%.2f", SS.ambientIntensity));
SS.TW.edit.meaning = Edit::LIGHT_AMBIENT;
SS.TW.edit.i = 0;
}
void TextWindow::ScreenChangeColor(int link, uint32_t v) { void TextWindow::ScreenChangeColor(int link, uint32_t v) {
SS.TW.ShowEditControlWithColorPicker(13, SS.modelColor[v]); SS.TW.ShowEditControlWithColorPicker(13, SS.modelColor[v]);
@ -218,6 +224,10 @@ void TextWindow::ShowConfiguration() {
CO(SS.lightDir[i]), i, &ScreenChangeLightDirection, CO(SS.lightDir[i]), i, &ScreenChangeLightDirection,
SS.lightIntensity[i], i, &ScreenChangeLightIntensity); SS.lightIntensity[i], i, &ScreenChangeLightIntensity);
} }
Printf(false, "%Bp ambient lighting "
"%2 %Fl%D%f%Ll[c]%E",
(i & 1) ? 'd' : 'a', i,
SS.ambientIntensity, &ScreenChangeLightAmbient);
Printf(false, ""); Printf(false, "");
Printf(false, "%Ft chord tolerance (in percents)%E"); Printf(false, "%Ft chord tolerance (in percents)%E");
@ -371,7 +381,10 @@ bool TextWindow::EditControlDoneForConfiguration(const std::string &s) {
SS.lightIntensity[edit.i] = min(1.0, max(0.0, atof(s.c_str()))); SS.lightIntensity[edit.i] = min(1.0, max(0.0, atof(s.c_str())));
SS.GW.Invalidate(); SS.GW.Invalidate();
break; break;
case Edit::LIGHT_AMBIENT:
SS.ambientIntensity = min(1.0, max(0.0, atof(s.c_str())));
SS.GW.Invalidate();
break;
case Edit::LIGHT_DIRECTION: { case Edit::LIGHT_DIRECTION: {
double x, y, z; double x, y, z;
if(sscanf(s.c_str(), "%lf, %lf, %lf", &x, &y, &z)==3) { if(sscanf(s.c_str(), "%lf, %lf, %lf", &x, &y, &z)==3) {

View File

@ -33,7 +33,7 @@ void SolveSpaceUI::Init() {
// Light intensities // Light intensities
lightIntensity[0] = settings->ThawFloat("LightIntensity_0", 1.0); lightIntensity[0] = settings->ThawFloat("LightIntensity_0", 1.0);
lightIntensity[1] = settings->ThawFloat("LightIntensity_1", 0.5); lightIntensity[1] = settings->ThawFloat("LightIntensity_1", 0.5);
ambientIntensity = 0.3; // no setting for that yet ambientIntensity = settings->ThawFloat("Light_Ambient", 0.3);
// Light positions // Light positions
lightDir[0].x = settings->ThawFloat("LightDir_0_Right", -1.0); lightDir[0].x = settings->ThawFloat("LightDir_0_Right", -1.0);
lightDir[0].y = settings->ThawFloat("LightDir_0_Up", 1.0); lightDir[0].y = settings->ThawFloat("LightDir_0_Up", 1.0);
@ -213,6 +213,7 @@ void SolveSpaceUI::Exit() {
// Light intensities // Light intensities
settings->FreezeFloat("LightIntensity_0", (float)lightIntensity[0]); settings->FreezeFloat("LightIntensity_0", (float)lightIntensity[0]);
settings->FreezeFloat("LightIntensity_1", (float)lightIntensity[1]); settings->FreezeFloat("LightIntensity_1", (float)lightIntensity[1]);
settings->FreezeFloat("Light_Ambient", (float)ambientIntensity);
// Light directions // Light directions
settings->FreezeFloat("LightDir_0_Right", (float)lightDir[0].x); settings->FreezeFloat("LightDir_0_Right", (float)lightDir[0].x);
settings->FreezeFloat("LightDir_0_Up", (float)lightDir[0].y); settings->FreezeFloat("LightDir_0_Up", (float)lightDir[0].y);

View File

@ -315,6 +315,7 @@ public:
G_CODE_FEED = 114, G_CODE_FEED = 114,
G_CODE_PLUNGE_FEED = 115, G_CODE_PLUNGE_FEED = 115,
AUTOSAVE_INTERVAL = 116, AUTOSAVE_INTERVAL = 116,
LIGHT_AMBIENT = 117,
// For TTF text // For TTF text
TTF_TEXT = 300, TTF_TEXT = 300,
// For the step dimension screen // For the step dimension screen
@ -467,6 +468,7 @@ public:
static void ScreenChangeGroupScale(int link, uint32_t v); static void ScreenChangeGroupScale(int link, uint32_t v);
static void ScreenChangeLightDirection(int link, uint32_t v); static void ScreenChangeLightDirection(int link, uint32_t v);
static void ScreenChangeLightIntensity(int link, uint32_t v); static void ScreenChangeLightIntensity(int link, uint32_t v);
static void ScreenChangeLightAmbient(int link, uint32_t v);
static void ScreenChangeColor(int link, uint32_t v); static void ScreenChangeColor(int link, uint32_t v);
static void ScreenChangeChordTolerance(int link, uint32_t v); static void ScreenChangeChordTolerance(int link, uint32_t v);
static void ScreenChangeMaxSegments(int link, uint32_t v); static void ScreenChangeMaxSegments(int link, uint32_t v);