Commit a2abbfef authored by Dat Nguyen's avatar Dat Nguyen

Added Stroke Width to Gui, Bubble Random improved looks more natural, added...

Added Stroke Width to Gui, Bubble Random improved looks more natural, added extra bits to prevent bugs in light cluster mode
parent cf236846
No preview for this file type
No preview for this file type
......@@ -10,6 +10,7 @@
1CD33E884D9E3358252E82A1 /* ofxToggle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 907C5B5E104864A2D3A25745 /* ofxToggle.cpp */; };
483908258D00B98B4BE69F07 /* ofxLabel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 78D67A00EB899FAC09430597 /* ofxLabel.cpp */; };
4F04D6251CBD1ED70092E1D7 /* lightDrawing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F04D6231CBD1ED70092E1D7 /* lightDrawing.cpp */; };
4F72D8D31CBE8F19000E43E6 /* Gui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F72D8D11CBE8F19000E43E6 /* Gui.cpp */; };
5CBB2AB3A60F65431D7B555D /* ofxButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C88333E71C9457E441C33474 /* ofxButton.cpp */; };
837220E80EB56CD44AD27F2A /* ofxSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15F2C6477A769C03A56D1401 /* ofxSlider.cpp */; };
856AA354D08AB4B323081444 /* ofxBaseGui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9604B925D32EE39065747725 /* ofxBaseGui.cpp */; };
......@@ -58,6 +59,8 @@
2834D88A62CD23F3DE2C47D1 /* ofxButton.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; name = ofxButton.h; path = ../../../addons/ofxGui/src/ofxButton.h; sourceTree = SOURCE_ROOT; };
4F04D6231CBD1ED70092E1D7 /* lightDrawing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lightDrawing.cpp; sourceTree = "<group>"; };
4F04D6241CBD1ED70092E1D7 /* lightDrawing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lightDrawing.h; sourceTree = "<group>"; };
4F72D8D11CBE8F19000E43E6 /* Gui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Gui.cpp; sourceTree = "<group>"; };
4F72D8D21CBE8F19000E43E6 /* Gui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gui.h; sourceTree = "<group>"; };
52AFA1F08C420992CAAAE648 /* ofxSlider.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; name = ofxSlider.h; path = ../../../addons/ofxGui/src/ofxSlider.h; sourceTree = SOURCE_ROOT; };
78D67A00EB899FAC09430597 /* ofxLabel.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = ofxLabel.cpp; path = ../../../addons/ofxGui/src/ofxLabel.cpp; sourceTree = SOURCE_ROOT; };
802251BAF1B35B1D67B32FD0 /* ofxSliderGroup.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = ofxSliderGroup.cpp; path = ../../../addons/ofxGui/src/ofxSliderGroup.cpp; sourceTree = SOURCE_ROOT; };
......@@ -163,6 +166,8 @@
E4B69E1C0A3A1BDC003C02F2 /* src */ = {
isa = PBXGroup;
children = (
4F72D8D11CBE8F19000E43E6 /* Gui.cpp */,
4F72D8D21CBE8F19000E43E6 /* Gui.h */,
4F04D6231CBD1ED70092E1D7 /* lightDrawing.cpp */,
4F04D6241CBD1ED70092E1D7 /* lightDrawing.h */,
E4B69E1D0A3A1BDC003C02F2 /* main.cpp */,
......@@ -277,6 +282,7 @@
F285EB3169F1566CA3D93C20 /* ofxPanel.cpp in Sources */,
837220E80EB56CD44AD27F2A /* ofxSlider.cpp in Sources */,
4F04D6251CBD1ED70092E1D7 /* lightDrawing.cpp in Sources */,
4F72D8D31CBE8F19000E43E6 /* Gui.cpp in Sources */,
B56FE57CC35806596D38118C /* ofxSliderGroup.cpp in Sources */,
1CD33E884D9E3358252E82A1 /* ofxToggle.cpp in Sources */,
);
......
//
// Gui.cpp
// Lux
//
// Created by Dat Nguyen on 13/04/2016.
//
//
#include "Gui.h"
void Gui::setup(){
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,100);
guiBrushes.add(standard.setup("Standard", true));
guiBrushes.add(standardSize.setup("Standard Brush Size", 2.f, 1.f, 10.f));
guiBrushes.add(bubbles.setup("Bubble", false));
guiBrushes.add(lightCluster.setup("Line Cluster", false));
}
void Gui::draw(){
guiLighting.draw();
guiBrushes.draw();
}
\ No newline at end of file
//
// Gui.h
// Lux
//
// Created by Dat Nguyen on 13/04/2016.
//
//
#ifndef Gui_h
#define Gui_h
#include "ofMain.h"
#include "ofxGui.h"
class lightDrawing;
class Gui{
public:
void setup();
void draw();
ofxPanel guiLighting;
ofxFloatSlider a1,a2,a3,d1,d2,d3;
ofxPanel guiBrushes;
ofxToggle standard, bubbles, lightCluster;
ofxFloatSlider standardSize;
};
#endif /* Gui_h */
......@@ -16,7 +16,6 @@ lightDrawing::lightDrawing() {}
void lightDrawing::setup() {
minDistance = 10;
leftMouseButtonPressed = false;
rightMouseButtonPressed = false;
}
......@@ -34,7 +33,7 @@ void lightDrawing::draw() {
ofPushStyle();
ofSetColor(255);
ofSetLineWidth(2);
ofSetLineWidth(standardSize);
for (int i = 0; i < drawLine.size(); i++) {
drawLine[i].draw();
drawLine[i].getSmoothed(1);
......@@ -81,20 +80,15 @@ void lightDrawing::clearAllLines() {
void lightDrawing::mouseDragged(ofVec3f _pos) {
if (leftMouseButtonPressed) {
drawLine[drawLine.size() - 1].addVertex(_pos);
}
}
void lightDrawing::mouseRPressed() {
leftMouseButtonPressed = true;
drawLine.push_back(ofPolyline());
}
void lightDrawing::mouseRReleased() {
leftMouseButtonPressed = false;
}
void lightDrawing::mousePressed(ofVec3f _pos) {
// drawLine.push_back(ofPolyline());
......
......@@ -9,10 +9,11 @@
#ifndef lightDrawing_h
#define lightDrawing_h
#include "ofMain.h"
#include "Gui.h"
// based from tutorial: http://openframeworks.cc/ofBook/chapters/foreword.html
class lightDrawing {
class lightDrawing : public Gui {
public:
lightDrawing();
......@@ -23,13 +24,10 @@ public:
void clearAllLines();
void mouseDragged(ofVec3f _pos);
void mouseRPressed();
void mouseRReleased();
void update(ofVec3f _pos);
ofPolyline currentPolyline;
bool leftMouseButtonPressed;
bool rightMouseButtonPressed;
ofVec3f lastPoint;
float minDistance;
......
......@@ -72,27 +72,12 @@ void ofApp::setup(){
// https://books.google.co.uk/books?id=xi7OBQAAQBAJ&pg=PA424&lpg=PA424&dq=is+camera+position+fixed+computer+graphics&source=bl&ots=8npc21kB6U&sig=VDSzQmYi82q2Qr6vIohCm9uc_rM&hl=en&sa=X&ved=0ahUKEwiihKO9qffLAhWC6xQKHSQMAQQQ6AEIMDAD#v=onepage&q=is%20camera%20position%20fixed%20computer%20graphics&f=false
// http://www.academia.edu/4978694/Mastering_openFrameworks_-_Chapter_7_Drawing_in_3D
//ofEnableAlphaBlending();
ofEnableAlphaBlending();
LightDrawing.setup();
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", false));
guiBrushes.add(lightCluster.setup("Line Cluster", true));
LightDrawing.bubblesetup();
userInterface.setup();
}
//--------------------------------------------------------------
......@@ -131,7 +116,7 @@ void ofApp::update(){
//User Mouse Show/Hide
if(mouseMode == false){
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
}else{
......@@ -139,52 +124,52 @@ void ofApp::update(){
}
if(isMouseHeldDown == true && standard == true){
//Prevent drawing in mouseMode
if(mouseMode == true){
isMouseHeldDown = false;
}
//User Drawing Effects
if(isMouseHeldDown == true && userInterface.standard == true){
LightDrawing.mouseDragged(pos);
}
if(isMouseHeldDown == true && bubbles == true && ofGetFrameNum() % 2 == 0){
if(isMouseHeldDown == true && userInterface.bubbles == true && ofGetFrameNum() % 2 == 0){
LightDrawing.createbubble(pos);
}
if(isMouseHeldDown == true && lightCluster == true){
if(isMouseHeldDown == true && userInterface.lightCluster == true){
LightDrawing.mousePressed(pos);
}
//User Camera Movements
if (ofGetKeyPressed('w') == true) {
cam.dolly(-1.4);
}
if (ofGetKeyPressed('s') == true) {
cam.dolly(1.4);
}
if (ofGetKeyPressed('a') == true) {
cam.truck(-1.4);
}
if (ofGetKeyPressed('d') == true) {
cam.truck(1.4);
}
if (ofGetKeyPressed('q') == true) {
cam.boom(-1.4);
}
if (ofGetKeyPressed('e') == true) {
cam.boom(1.4);
}
//Updates lightdrawing
if(userInterface.lightCluster == true)
LightDrawing.update(pos);
//light.setSpotlight();
//ofSeedRandom();
srand(time(NULL));
//Setting LineWidth
LightDrawing.standardSize = userInterface.standardSize;
LightDrawing.update(pos);
}
......@@ -198,8 +183,8 @@ void ofApp::draw(){
//Lighting
light.enable();
light.setPosition(0, 0, planeDist);
light.setAmbientColor(ofFloatColor(a1, a2, a3, 1.0));
light.setDiffuseColor(ofFloatColor(d1, d2, d3));
light.setAmbientColor(ofFloatColor(userInterface.a1, userInterface.a2, userInterface.a3, 1.0));
light.setDiffuseColor(ofFloatColor(userInterface.d1, userInterface.d2, userInterface.d3));
light.setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
cam.begin();
......@@ -218,21 +203,16 @@ void ofApp::draw(){
}
LightDrawing.draw();
LightDrawing.bubbledraw();
if(bubbles == true){
}
cam.end();
ofDisableDepthTest();
ofDisableLighting();
//User Interface
guiLighting.draw();
guiBrushes.draw();
userInterface.guiLighting.draw();
userInterface.guiBrushes.draw();
ofSetColor(255,255,255,255);
ofFill();
......@@ -244,7 +224,11 @@ void ofApp::draw(){
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if(key == OF_KEY_ALT){
if(key == OF_KEY_TAB){
//Prevent bug in light cluster mode
if(userInterface.lightCluster == true && isMouseHeldDown == true){
LightDrawing.mouseReleased(pos);
}
mouseMode = !mouseMode;
}
}
......@@ -274,31 +258,25 @@ void ofApp::mouseDragged(int x, int y, int button){
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
if(mouseMode == false && standard == true){
isMouseHeldDown = true;
if(mouseMode == false && userInterface.standard == true){
LightDrawing.mouseRPressed();
isMouseHeldDown = true;
}
if(bubbles == true){
isMouseHeldDown = true;
}
if (lightCluster == true) {
isMouseHeldDown = true;
}
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
if(mouseMode == false)
if(mouseMode == false){
isMouseHeldDown = false;
LightDrawing.mouseReleased(pos);
LightDrawing.mouseRReleased();
if(userInterface.lightCluster == true)
LightDrawing.mouseReleased(pos);
}
}
......
......@@ -2,7 +2,7 @@
#include "ofMain.h"
#include "lightDrawing.h"
#include "ofxGui.h"
#include "Gui.h"
class ofApp : public ofBaseApp{
......@@ -47,12 +47,9 @@ class ofApp : public ofBaseApp{
GLFWwindow *window = static_cast<ofAppGLFWWindow*>(ofGetWindowPtr())->getGLFWWindow();
ofLight light,light2;
ofLight light;
ofxPanel guiLighting;
ofxFloatSlider a1,a2,a3,d1,d2,d3;
ofxPanel guiBrushes;
ofxToggle standard, bubbles, lightCluster;
Gui userInterface;
};
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