The lights are directional, so call those triples directions, not

positions.

[git-p4: depot-paths = "//depot/solvespace/": change = 1784]
solver
Jonathan Westhues 2008-06-10 20:30:18 -08:00
parent d471872830
commit f8636eaddf
5 changed files with 30 additions and 30 deletions

View File

@ -824,13 +824,13 @@ void GraphicsWindow::Paint(int w, int h) {
glLightfv(GL_LIGHT1, GL_DIFFUSE, li1);
glLightfv(GL_LIGHT1, GL_SPECULAR, li1);
Vector lp;
lp = VectorFromProjs(SS.lightPos[0]);
GLfloat lp0[4] = { (GLfloat)lp.x, (GLfloat)lp.y, (GLfloat)lp.z, 0 };
glLightfv(GL_LIGHT0, GL_POSITION, lp0);
lp = VectorFromProjs(SS.lightPos[1]);
GLfloat lp1[4] = { (GLfloat)lp.x, (GLfloat)lp.y, (GLfloat)lp.z, 0 };
glLightfv(GL_LIGHT1, GL_POSITION, lp1);
Vector ld;
ld = VectorFromProjs(SS.lightDir[0]);
GLfloat ld0[4] = { (GLfloat)ld.x, (GLfloat)ld.y, (GLfloat)ld.z, 0 };
glLightfv(GL_LIGHT0, GL_POSITION, ld0);
ld = VectorFromProjs(SS.lightDir[1]);
GLfloat ld1[4] = { (GLfloat)ld.x, (GLfloat)ld.y, (GLfloat)ld.z, 0 };
glLightfv(GL_LIGHT1, GL_POSITION, ld1);
// For debugging, draw the backs of the triangles in red, so that we
// notice when a shell is open

View File

@ -17,12 +17,12 @@ void SolveSpace::Init(char *cmdLine) {
lightIntensity[0] = ((int)CnfThawDWORD( 700, "LightIntensity_0"))/1000.0;
lightIntensity[1] = ((int)CnfThawDWORD( 400, "LightIntensity_1"))/1000.0;
// Light positions
lightPos[0].x = ((int)CnfThawDWORD(-500, "LightPos_0_Right" ))/1000.0;
lightPos[0].y = ((int)CnfThawDWORD( 500, "LightPos_0_Up" ))/1000.0;
lightPos[0].z = ((int)CnfThawDWORD( 0, "LightPos_0_Forward" ))/1000.0;
lightPos[1].x = ((int)CnfThawDWORD( 500, "LightPos_1_Right" ))/1000.0;
lightPos[1].y = ((int)CnfThawDWORD( 0, "LightPos_1_Up" ))/1000.0;
lightPos[1].z = ((int)CnfThawDWORD( 0, "LightPos_1_Forward" ))/1000.0;
lightDir[0].x = ((int)CnfThawDWORD(-500, "LightDir_0_Right" ))/1000.0;
lightDir[0].y = ((int)CnfThawDWORD( 500, "LightDir_0_Up" ))/1000.0;
lightDir[0].z = ((int)CnfThawDWORD( 0, "LightDir_0_Forward" ))/1000.0;
lightDir[1].x = ((int)CnfThawDWORD( 500, "LightDir_1_Right" ))/1000.0;
lightDir[1].y = ((int)CnfThawDWORD( 0, "LightDir_1_Up" ))/1000.0;
lightDir[1].z = ((int)CnfThawDWORD( 0, "LightDir_1_Forward" ))/1000.0;
// Mesh tolerance
meshTol = ((int)CnfThawDWORD(1000, "MeshTolerance"))/1000.0;
// Recent files menus
@ -64,13 +64,13 @@ void SolveSpace::Exit(void) {
// Light intensities
CnfFreezeDWORD((int)(lightIntensity[0]*1000), "LightIntensity_0");
CnfFreezeDWORD((int)(lightIntensity[1]*1000), "LightIntensity_1");
// Light positions
CnfFreezeDWORD((int)(lightPos[0].x*1000), "LightPos_0_Right");
CnfFreezeDWORD((int)(lightPos[0].y*1000), "LightPos_0_Up");
CnfFreezeDWORD((int)(lightPos[0].z*1000), "LightPos_0_Forward");
CnfFreezeDWORD((int)(lightPos[1].x*1000), "LightPos_1_Right");
CnfFreezeDWORD((int)(lightPos[1].y*1000), "LightPos_1_Up");
CnfFreezeDWORD((int)(lightPos[1].z*1000), "LightPos_1_Forward");
// Light directions
CnfFreezeDWORD((int)(lightDir[0].x*1000), "LightDir_0_Right");
CnfFreezeDWORD((int)(lightDir[0].y*1000), "LightDir_0_Up");
CnfFreezeDWORD((int)(lightDir[0].z*1000), "LightDir_0_Forward");
CnfFreezeDWORD((int)(lightDir[1].x*1000), "LightDir_1_Right");
CnfFreezeDWORD((int)(lightDir[1].y*1000), "LightDir_1_Up");
CnfFreezeDWORD((int)(lightDir[1].z*1000), "LightDir_1_Forward");
// Mesh tolerance
CnfFreezeDWORD((int)(meshTol*1000), "MeshTolerance");

View File

@ -249,7 +249,7 @@ public:
// Little bits of extra configuration state
static const int MODEL_COLORS = 8;
int modelColor[MODEL_COLORS];
Vector lightPos[2];
Vector lightDir[2];
double lightIntensity[2];
double meshTol;

View File

@ -763,11 +763,11 @@ void TextWindow::ShowGroupSolveInfo(void) {
}
}
void TextWindow::ScreenChangeLightPosition(int link, DWORD v) {
void TextWindow::ScreenChangeLightDirection(int link, DWORD v) {
char str[1024];
sprintf(str, "%.2f, %.2f, %.2f", CO(SS.lightPos[v]));
sprintf(str, "%.2f, %.2f, %.2f", CO(SS.lightDir[v]));
ShowTextEditControl(29+2*v, 8, str);
SS.TW.edit.meaning = EDIT_LIGHT_POSITION;
SS.TW.edit.meaning = EDIT_LIGHT_DIRECTION;
SS.TW.edit.i = v;
}
void TextWindow::ScreenChangeLightIntensity(int link, DWORD v) {
@ -809,12 +809,12 @@ void TextWindow::ShowConfiguration(void) {
}
Printf(false, "");
Printf(false, "%Ft light position intensity");
Printf(false, "%Ft light direction intensity");
for(i = 0; i < 2; i++) {
Printf(false, "%Bp #%d (%2,%2,%2)%Fl%D%f%Ll[c]%E "
"%2 %Fl%D%f%Ll[c]%E",
(i & 1) ? 'd' : 'a', i,
CO(SS.lightPos[i]), i, &ScreenChangeLightPosition,
CO(SS.lightDir[i]), i, &ScreenChangeLightDirection,
SS.lightIntensity[i], i, &ScreenChangeLightIntensity);
}
@ -867,10 +867,10 @@ void TextWindow::EditControlDone(char *s) {
SS.lightIntensity[edit.i] = min(1, max(0, atof(s)));
InvalidateGraphics();
break;
case EDIT_LIGHT_POSITION: {
case EDIT_LIGHT_DIRECTION: {
double x, y, z;
if(sscanf(s, "%lf, %lf, %lf", &x, &y, &z)==3) {
SS.lightPos[edit.i] = Vector::From(x, y, z);
SS.lightDir[edit.i] = Vector::From(x, y, z);
} else {
Error("Bad format: specify coordinates as x, y, z");
}

4
ui.h
View File

@ -59,7 +59,7 @@ public:
static const int EDIT_NOTHING = 0;
static const int EDIT_TIMES_REPEATED = 1;
static const int EDIT_GROUP_NAME = 2;
static const int EDIT_LIGHT_POSITION = 3;
static const int EDIT_LIGHT_DIRECTION = 3;
static const int EDIT_LIGHT_INTENSITY = 4;
static const int EDIT_COLOR = 5;
static const int EDIT_MESH_TOLERANCE = 6;
@ -110,7 +110,7 @@ public:
// These ones do stuff with the edit control
static void ScreenChangeExprA(int link, DWORD v);
static void ScreenChangeGroupName(int link, DWORD v);
static void ScreenChangeLightPosition(int link, DWORD v);
static void ScreenChangeLightDirection(int link, DWORD v);
static void ScreenChangeLightIntensity(int link, DWORD v);
static void ScreenChangeColor(int link, DWORD v);
static void ScreenChangeMeshTolerance(int link, DWORD v);