Commit c3b6776d authored by Dat Nguyen's avatar Dat Nguyen

multiple light source updated

parent f6d080e6
......@@ -21,9 +21,10 @@ void Gui::setup(){
guiLighting1.setup();
guiLighting1.setName("Lighting Controls2");
guiLighting1.setPosition(10,500);
guiLighting1.add(selection.setup("SphereNum", 0, 0, 4));
guiLighting1.add(a11.setup("Red", 0.8f, -1.0f, 1.0f));
guiLighting1.add(a22.setup("Green", 0.f, -1.0f, 1.0f));
guiLighting1.add(a11.setup("Red", 0.1f, -1.0f, 1.0f));
guiLighting1.add(a22.setup("Green", 0.8f, -1.0f, 1.0f));
guiLighting1.add(a33.setup("Blue", 0.2f, -1.0f, 1.0f));
guiLighting1.add(d11.setup("Diffuse 1", 0.f, -1.0f, 1.0f));
guiLighting1.add(d22.setup("Diffuse 2", 0.f, -1.0f, 1.0f));
......
......@@ -53,6 +53,7 @@ void ofApp::camRotate(){
//--------------------------------------------------------------
void ofApp::setup(){
ofSetVerticalSync(true);
state = 1;
mouseMode = false;
......@@ -85,7 +86,8 @@ void ofApp::setup(){
lightPos.set(0,0,planeDist);
ofDisableArbTex();
ofSetSmoothLighting(true);
for(int i = 0; i<5; i++){
v_light.push_back(light);
......@@ -180,10 +182,10 @@ void ofApp::update(){
}
if (ofGetKeyPressed('q') == true) {
cam.boom(-1.4);
cam.boom(1.4);
}
if (ofGetKeyPressed('e') == true) {
cam.boom(1.4);
cam.boom(-1.4);
}
......@@ -206,12 +208,36 @@ void ofApp::update(){
}
v_light[0].setAmbientColor(ofFloatColor(userInterface.a1, userInterface.a2, userInterface.a3, 1.0));
v_light[0].setDiffuseColor(ofFloatColor(userInterface.d1, userInterface.d2, userInterface.d3));
v_light[0].setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
v_light[1].setAmbientColor(ofFloatColor(0.7, 0.7, 0.7, 1.0));
v_light[1].setDiffuseColor(ofFloatColor(0.5, 0.5, 0.5));
v_light[1].setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
// v_light[0].setAmbientColor(ofFloatColor(userInterface.a1, userInterface.a2, userInterface.a3, 1.0));
// v_light[0].setDiffuseColor(ofFloatColor(userInterface.d1, userInterface.d2, userInterface.d3));
// v_light[0].setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
// v_light[1].setAmbientColor(ofFloatColor(0.7, 0.7, 0.7, 1.0));
// v_light[1].setDiffuseColor(ofFloatColor(0.5, 0.5, 0.5));
// v_light[1].setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
light0.setDiffuseColor( ofColor(0.f, 255.f, 0.f));
// specular color, the highlight/shininess color //
light0.setSpecularColor( ofColor(255.f, 255.f, 0.f));
light0.setPointLight();
light1.setDiffuseColor( ofColor(255.f, 0.f, 0.f));
light1.setSpecularColor( ofColor(255.f, 255.f, 255.f));
// turn the light into spotLight, emit a cone of light //
light1.setPointLight();
// // size of the cone of emitted light, angle between light axis and side of cone //
// // angle range between 0 - 90 in degrees //
// light1.setSpotlightCutOff( 50 );
//
// // rate of falloff, illumitation decreases as the angle from the cone axis increases //
// // range 0 - 128, zero is even illumination, 128 is max falloff //
// light1.setSpotConcentration( 45 );
light0.setPosition(lightBalls.Flocking[0].location.x, lightBalls.Flocking[0].location.y, lightBalls.Flocking[0].location.z);
light1.setPosition(lightBalls.Flocking[1].location.x, lightBalls.Flocking[1].location.y, lightBalls.Flocking[1].location.z);
}
//--------------------------------------------------------------
......@@ -220,6 +246,9 @@ void ofApp::draw(){
ofBackground(45);
ofEnableDepthTest();
ofEnableLighting();
light0.enable();
light1.enable();
// v_light[userInterface.selection].setAmbientColor(ofFloatColor(userInterface.a1, userInterface.a2, userInterface.a3, 1.0));
// v_light[userInterface.selection].setDiffuseColor(ofFloatColor(userInterface.d1, userInterface.d2, userInterface.d3));
// v_light[userInterface.selection].setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
......@@ -230,29 +259,29 @@ void ofApp::draw(){
// v_light[1].setDiffuseColor(ofFloatColor(0.5, 0.5, 0.5));
// v_light[1].setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
GLfloat light_ambient[] = {userInterface.a1, userInterface.a2, userInterface.a3, 1.0};
GLfloat light_diffuse[] = {userInterface.d1, userInterface.d2, userInterface.d3, 1.0};
GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0};
GLfloat light_position[] = {lightBalls.Flocking[0].location.x, lightBalls.Flocking[0].location.y, lightBalls.Flocking[0].location.z, 0.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
//glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 60.0f);
glEnable(GL_LIGHT0);
GLfloat light_ambient1[] = {userInterface.a11, userInterface.a22, userInterface.a33, 1.0};
GLfloat light_diffuse1[] = {userInterface.d11, userInterface.d22, userInterface.d33, 1.0};
GLfloat light_specular1[] = {1.0, 1.0, 1.0, 1.0};
GLfloat light_position1[] = {lightBalls.Flocking[1].location.x, lightBalls.Flocking[1].location.y, lightBalls.Flocking[1].location.z, 0.0};
glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient1);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse1);
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular1);
glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
//glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 60.0f);
glEnable(GL_LIGHT1);
// GLfloat light_ambient[] = {userInterface.a1, userInterface.a2, userInterface.a3, 1.0};
// GLfloat light_diffuse[] = {userInterface.d1, userInterface.d2, userInterface.d3, 1.0};
// GLfloat light_specular[] = {1.0, 0.0, 0.0, 1.0};
// GLfloat light_position[] = {lightBalls.Flocking[0].location.x, lightBalls.Flocking[0].location.y, lightBalls.Flocking[0].location.z, 0.0};
//
// glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
// glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
// glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
// glLightfv(GL_LIGHT0, GL_POSITION, light_position);
// glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 90.0f);
// glEnable(GL_LIGHT0);
//
// GLfloat light_ambient1[] = {userInterface.a11, userInterface.a22, userInterface.a33, 1.0};
// GLfloat light_diffuse1[] = {userInterface.d11, userInterface.d22, userInterface.d33, 1.0};
// GLfloat light_specular1[] = {0.0, 1.0, 0.0, 1.0};
// GLfloat light_position1[] = {lightBalls.Flocking[1].location.x, lightBalls.Flocking[1].location.y, lightBalls.Flocking[1].location.z, 0.0};
//
// glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient1);
// glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse1);
// glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular1);
// glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
// glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 90.0f);
// glEnable(GL_LIGHT1);
if (state == 0) {
......
......@@ -52,6 +52,9 @@ public:
GLFWwindow *window = static_cast<ofAppGLFWWindow*>(ofGetWindowPtr())->getGLFWWindow();
ofLight light0;
ofLight light1;
ofLight light;
vector<ofLight> v_light;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment