Commit fb2be8a2 authored by Dat Nguyen's avatar Dat Nguyen

Multiple light sources

parent 11d82eed
......@@ -11,6 +11,7 @@
void Gui::setup(){
guiLighting.setup();
guiLighting.setName("Lighting Controls");
guiLighting.add(selection.setup("SphereNum", 0, 0, 4));
guiLighting.add(a1.setup("Red", 0.8f, -1.0f, 1.0f));
guiLighting.add(a2.setup("Green", 0.f, -1.0f, 1.0f));
guiLighting.add(a3.setup("Blue", 0.2f, -1.0f, 1.0f));
......@@ -18,6 +19,16 @@ void Gui::setup(){
guiLighting.add(d2.setup("Diffuse 2", 0.f, -1.0f, 1.0f));
guiLighting.add(d3.setup("Diffuse 3", 1.f, -1.0f, 1.0f));
guiLighting1.setup();
guiLighting1.setName("Lighting Controls2");
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(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));
guiLighting1.add(d33.setup("Diffuse 3", 1.f, -1.0f, 1.0f));
guiBrushes.setup();
guiBrushes.setName("Brush Effects");
guiBrushes.setPosition(ofGetWindowWidth()-210,10);
......
......@@ -19,7 +19,10 @@ public:
void draw();
ofxPanel guiLighting;
ofxPanel guiLighting1;
ofxIntSlider selection;
ofxFloatSlider a1,a2,a3,d1,d2,d3;
ofxFloatSlider a11,a22,a33,d11,d22,d33;
ofxPanel guiBrushes;
ofxToggle standard, bubbles, lightCluster;
......
......@@ -22,7 +22,7 @@ void lightBalls::update(ofVec3f _tempPos) {
}
void lightBalls::display() {
for (int i = 0; i < Flocking.size(); i++) {
for (int i = 0; i < 2; i++) {
Flocking[i].display();
}
}
......
......@@ -201,31 +201,77 @@ void ofApp::update(){
} // end of state = 1
if(mouseMode == false){
}
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));
}
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(45);
ofEnableDepthTest();
// 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));
// v_light[1].setAmbientColor(ofFloatColor(0.5, 0.5, 0.5, 1.0));
// 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);
if (state == 0) {
}
if (state == 1) {
for(int i = 0; i<v_light.size(); i++){
v_light[i].enable();
// light.setPosition(0, 0, planeDist);
v_light[i].setPosition(lightPos.x, lightPos.y, lightPos.z);
v_light[i].setAmbientColor(ofFloatColor(userInterface.a1, userInterface.a2, userInterface.a3, 1.0));
v_light[i].setDiffuseColor(ofFloatColor(userInterface.d1, userInterface.d2, userInterface.d3));
v_light[i].setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
v_light[i].setPosition(lightBalls.Flocking[i].x, lightBalls.Flocking[i].y, lightBalls.Flocking[i].z);
v_light[i].setPosition(0, 0, 0);
// v_light[i].setAmbientColor(ofFloatColor(userInterface.a1, userInterface.a2, userInterface.a3, 1.0));
// v_light[i].setDiffuseColor(ofFloatColor(userInterface.d1, userInterface.d2, userInterface.d3));
// v_light[i].setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
}
//Lighting
cam.begin();
ofFill();
......@@ -263,6 +309,7 @@ void ofApp::draw(){
//User Interface
userInterface.guiLighting.draw();
userInterface.guiLighting1.draw();
userInterface.guiBrushes.draw();
ofSetColor(255,255,255,255);
......
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