Commit 075d0c7c authored by Dat Nguyen's avatar Dat Nguyen

Linked Multiple lighting to gui

parent c3b6776d
......@@ -9,26 +9,41 @@
#include "Gui.h"
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));
guiLighting.add(d1.setup("Diffuse 1", 0.f, -1.0f, 1.0f));
guiLighting.add(d2.setup("Diffuse 2", 0.f, -1.0f, 1.0f));
guiLighting.add(d3.setup("Diffuse 3", 1.f, -1.0f, 1.0f));
a1[0].setup("Red", 0, 0, 255);
a2[0].setup("Green", 0, 0, 255);
a3[0].setup("Blue", 0., 0, 255);
d1[0].setup("Diffuse 1", 0, 0, 255);
d2[0].setup("Diffuse 2", 255, 0, 255);
d3[0].setup("Diffuse 3", 0, 0, 255);
s1[0].setup("Specular 1", 255, 0, 255);
s2[0].setup("Specular 2", 255, 0, 255);
s3[0].setup("Specular 3", 255, 0, 255);
a1[1].setup("Red", 0, 0, 255);
a2[1].setup("Green", 0, 0, 255);
a3[1].setup("Blue", 0., 0, 255);
d1[1].setup("Diffuse 1", 255, 0, 255);
d2[1].setup("Diffuse 2", 0, 0, 255);
d3[1].setup("Diffuse 3", 0, 0, 255);
s1[1].setup("Specular 1", 255, 0, 255);
s2[1].setup("Specular 2", 255, 0, 255);
s3[1].setup("Specular 3", 255, 0, 255);
guiLighting1.setup();
guiLighting1.setName("Lighting Controls2");
guiLighting1.setPosition(10,500);
guiLighting1.add(selection.setup("SphereNum", 0, 0, 4));
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));
guiLighting1.add(d33.setup("Diffuse 3", 1.f, -1.0f, 1.0f));
select.setup("Select Sphere");
select.add(selection.setup("SphereNum", 0, 0, 1));
for(int i = 0; i<2; i++){
guiLighting[i].setup("Lighting Controls");
guiLighting[i].add(&a1[i]);
guiLighting[i].add(&a2[i]);
guiLighting[i].add(&a3[i]);
guiLighting[i].add(&d1[i]);
guiLighting[i].add(&d2[i]);
guiLighting[i].add(&d3[i]);
guiLighting[i].add(&s1[i]);
guiLighting[i].add(&s2[i]);
guiLighting[i].add(&s3[i]);
}
guiBrushes.setup();
guiBrushes.setName("Brush Effects");
......@@ -40,6 +55,8 @@ void Gui::setup(){
}
void Gui::draw(){
guiLighting.draw();
select.draw();
guiLighting[selection].setPosition(select.getPosition().x, select.getPosition().y+50);
guiLighting[selection].draw();
guiBrushes.draw();
}
\ No newline at end of file
......@@ -18,11 +18,13 @@ public:
void setup();
void draw();
ofxPanel guiLighting;
ofxPanel guiLighting1;
ofxPanel select;
ofxPanel guiLighting[2];
ofxIntSlider selection;
ofxFloatSlider a1,a2,a3,d1,d2,d3;
ofxFloatSlider a11,a22,a33,d11,d22,d33;
ofxIntSlider a1[5],a2[5],a3[5],d1[5],d2[5],d3[5],s1[5],s2[5],s3[5];
vector <ofxIntSlider> a,aa,aaa,d,dd,ddd,s,ss,sss;
ofxPanel guiBrushes;
ofxToggle standard, bubbles, lightCluster;
......
......@@ -93,7 +93,15 @@ void ofApp::setup(){
v_light.push_back(light);
}
light0.setDiffuseColor( ofColor(0.f, 255.f, 0.f));
light0.setSpecularColor( ofColor(255.f, 255.f, 255.f));
light0.setAreaLight(1000, 1000);
light1.setDiffuseColor( ofColor(255.f, 0.f, 0.f));
light1.setSpecularColor( ofColor(255.f, 255.f, 255.f));
light1.setAreaLight(1000, 1000);
}
//--------------------------------------------------------------
......@@ -208,36 +216,44 @@ 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));
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 );
//
// v_light[0].setDiffuseColor( ofColor(0.f, 255.f, 0.f));
//
// // specular color, the highlight/shininess color //
// v_light[0].setSpecularColor( ofColor(255.f, 255.f, 255.f));
// v_light[0].setAreaLight(500, 500);
// //light1.setAmbientColor( ofColor(150.f, 0.0f, 0.f));
// v_light[1].setDiffuseColor( ofColor(255.f, 0.f, 0.f));
// v_light[1].setSpecularColor( ofColor(255.f, 255.f, 255.f));
// v_light[1].setAreaLight(500, 500);
//
//
// // 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 );
// for(int i = 0; i<2; i++){
// v_light[i].setPosition(lightBalls.Flocking[i].location.x, lightBalls.Flocking[i].location.y, lightBalls.Flocking[i].location.z);
//
// }
if(userInterface.selection==0){
//light0.setAmbientColor( ofColor(userInterface.a1, userInterface.a2, userInterface.a3));
light0.setDiffuseColor( ofColor(userInterface.d1[0], userInterface.d2[0], userInterface.d3[0]));
light0.setSpecularColor( ofColor(userInterface.s1[0], userInterface.s2[0], userInterface.s3[0]));
}
if(userInterface.selection==1){
//light1.setAmbientColor( ofColor(userInterface.a1, userInterface.a2, userInterface.a3));
light1.setDiffuseColor( ofColor(userInterface.d1[1], userInterface.d2[1], userInterface.d3[1]));
light1.setSpecularColor( ofColor(userInterface.s1[1], userInterface.s2[1], userInterface.s3[1]));
}
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);
}
//--------------------------------------------------------------
......@@ -249,69 +265,34 @@ void ofApp::draw(){
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));
// 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, 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) {
}
if (state == 1) {
for(int i = 0; i<v_light.size(); i++){
v_light[i].enable();
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();
// ofDrawSphere(lightPos.x,lightPos.y,lightPos.z, sphereSize); //this is our reference sphere
if(mouseMode == true && userInterface.selection==0){
ofNoFill();
ofDrawSphere(light0.getX(), light0.getY(), light0.getZ(), 50);
}
if(mouseMode == true && userInterface.selection==1){
ofNoFill();
ofDrawSphere(light1.getX(), light1.getY(), light1.getZ(), 50);
}
ofFill();
// ofDrawSphere(lightPos.x,lightPos.y,lightPos.z, sphereSize); //this is our reference sphere
//ofDrawLine(cam.getPosition(), cam.getPosition() + ray * cam.getFarClip()); //notice we can't see this line at all !!!
......@@ -337,9 +318,8 @@ void ofApp::draw(){
ofDisableLighting();
//User Interface
userInterface.guiLighting.draw();
userInterface.guiLighting1.draw();
userInterface.guiBrushes.draw();
userInterface.draw();
//userInterface.guiLighting1.draw();
ofSetColor(255,255,255,255);
ofFill();
......
......@@ -52,8 +52,7 @@ public:
GLFWwindow *window = static_cast<ofAppGLFWWindow*>(ofGetWindowPtr())->getGLFWWindow();
ofLight light0;
ofLight light1;
ofLight light0,light1;
ofLight 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