Commit 30b65188 authored by Dat Nguyen's avatar Dat Nguyen

Added Brush Gui, Added Sphere brush effect

parent ac3dd516
No preview for this file type
<Lighting_Controls>
<Red>0.8</Red>
<Green>0</Green>
<Blue>0.2</Blue>
<Diffuse_1>0</Diffuse_1>
<Diffuse_2>0</Diffuse_2>
<Diffuse_3>1</Diffuse_3>
</Lighting_Controls>
......@@ -22,9 +22,7 @@ void lightDrawing::setup() {
sumX = 0;
}
void lightDrawing::update() {
light.setPosition(meanX,meanY,meanZ);
}
void lightDrawing::draw() {
......@@ -123,4 +121,30 @@ void lightDrawing::mousePressed() {
}
void lightDrawing::bubblesetup(){
}
void lightDrawing::bubbledraw(){
for(int i = 0; i < storeSphere.size(); i++){
storeSphere[i].draw();
}
}
void lightDrawing::createbubble(ofVec3f _pos){
sphere.setRadius(ofRandom(0.01,2));
storeSphere.push_back(sphere);
storeSphere[storeSphere.size()-1].setPosition(_pos+ofVec3f(ofRandom(-5,5),ofRandom(-5,5),0));
sphere.setRadius(ofRandom(0.01,2));
storeSphere.push_back(sphere);
storeSphere[storeSphere.size()-1].setPosition(_pos+ofVec3f(ofRandom(-5,5),ofRandom(-5,5),0));
sphere.setRadius(ofRandom(0.01,2));
storeSphere.push_back(sphere);
storeSphere[storeSphere.size()-1].setPosition(_pos+ofVec3f(ofRandom(-5,5),ofRandom(-5,5),0));
}
......@@ -23,9 +23,7 @@ public:
void mouseDragged(ofVec3f _pos);
void mousePressed();
void update();
ofLight light;
vector <ofVec3f> getLineXYZ;
......@@ -47,6 +45,14 @@ public:
int countTest;
vector <ofSpherePrimitive> storeSphere;
ofSpherePrimitive sphere;
void bubblesetup();
void bubbledraw();
void createbubble(ofVec3f _pos);
};
......
......@@ -50,11 +50,6 @@ void ofApp::camRotate(){
//--------------------------------------------------------------
void ofApp::setup(){
mouseMode = false;
isMouseInited = false;
isMouseHeldDown = false;
......@@ -81,14 +76,22 @@ void ofApp::setup(){
LightDrawing.setup();
gui.setup();
gui.add(a1.setup("Red", 0.8f, -1.0f, 1.0f));
gui.add(a2.setup("Green", 0.f, -1.0f, 1.0f));
gui.add(a3.setup("Blue", 0.2f, -1.0f, 1.0f));
gui.add(d1.setup("Diffuse 1", 0.f, -1.0f, 1.0f));
gui.add(d2.setup("Diffuse 2", 0.f, -1.0f, 1.0f));
gui.add(d3.setup("Diffuse 3", 1.f, -1.0f, 1.0f));
guiLighting.setup();
guiLighting.setName("Lighting Controls");
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));
guiBrushes.setup();
guiBrushes.setName("Brush Effects");
guiBrushes.setPosition(810,10);
guiBrushes.add(standard.setup("Standard", false));
guiBrushes.add(bubbles.setup("Bubble", true));
LightDrawing.bubblesetup();
}
//--------------------------------------------------------------
......@@ -135,11 +138,13 @@ void ofApp::update(){
}
if(isMouseHeldDown == true){
if(isMouseHeldDown == true && standard == true){
LightDrawing.mouseDragged(pos);
}
LightDrawing.update();
if(isMouseHeldDown == true && bubbles == true && ofGetFrameNum() % 2 == 0){
LightDrawing.createbubble(pos);
}
if (ofGetKeyPressed('w') == true) {
......@@ -181,9 +186,9 @@ void ofApp::draw(){
ofBackground(45);
ofEnableDepthTest();
light.enable();
//Lighting
light.enable();
light.setPosition(0, 0, planeDist);
light.setAmbientColor(ofFloatColor(a1, a2, a3, 1.0));
light.setDiffuseColor(ofFloatColor(d1, d2, d3));
......@@ -197,28 +202,31 @@ void ofApp::draw(){
//ofDrawLine(cam.getPosition(), cam.getPosition() + ray * cam.getFarClip()); //notice we can't see this line at all !!!
//this is because it goes directly from the origin of the camera
//along the line of sight
for (int i = 0; i < 50; i++) {
ofSetColor(255);
ofFill();
// ofDrawBox(<#float x#>, <#float y#>, <#float z#>, <#float size#>);
// ofDrawBox(ofRandom(-1000,1000),ofRandom(-1000,1000), ofRandom(-1000,1000),100);
// ofDrawBox(ofRandom(-1000,1000),ofRandom(-1000,1000), ofRandom(-1000,1000),100);
ofDrawBox(100,100,10,100);
}
//LightDrawing.light.enable();
LightDrawing.draw();
//LightDrawing.light.disable();
LightDrawing.bubbledraw();
if(bubbles == true){
}
cam.end();
light.disable();
ofDisableDepthTest();
ofDisableLighting();
gui.draw();
//User Interface
guiLighting.draw();
guiBrushes.draw();
ofSetColor(255,255,255,255);
ofFill();
......@@ -258,16 +266,24 @@ void ofApp::mouseDragged(int x, int y, int button){
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
if(mouseMode == false){
LightDrawing.mousePressed();
isMouseHeldDown = true;
if(mouseMode == false && standard == true){
LightDrawing.mousePressed();
isMouseHeldDown = true;
}
if(bubbles == true){
isMouseHeldDown = true;
}
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
if(mouseMode == false)
isMouseHeldDown = false;
}
//--------------------------------------------------------------
......
......@@ -49,7 +49,10 @@ class ofApp : public ofBaseApp{
ofLight light,light2;
ofxPanel gui;
ofxPanel guiLighting;
ofxFloatSlider a1,a2,a3,d1,d2,d3;
ofxPanel guiBrushes;
ofxToggle standard, bubbles;
};
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