Commit ac3dd516 authored by Dat Nguyen's avatar Dat Nguyen

added Gui to Change colours

parent b3c8d1c0
No preview for this file type
No preview for this file type
This diff is collapsed.
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "2DE9C8846D9375EAACFABA8963120E8E7719BAF5",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"2DE9C8846D9375EAACFABA8963120E8E7719BAF5" : 0,
"3CF9CC193C754AA505D0F7C10588670389ED4B82" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "5A20955C-CFAE-4A01-844F-F00B489DBA33",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"2DE9C8846D9375EAACFABA8963120E8E7719BAF5" : "openFrameworks\/",
"3CF9CC193C754AA505D0F7C10588670389ED4B82" : "openFrameworks\/addons\/ofxImmediateModeInput\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "Lux",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "apps\/myApps\/Lux\/Lux.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/openframeworks\/openFrameworks.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "2DE9C8846D9375EAACFABA8963120E8E7719BAF5"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/ofnode\/ofxImmediateModeInput.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3CF9CC193C754AA505D0F7C10588670389ED4B82"
}
]
}
\ No newline at end of file
ofxImmediateModeInput @ 69400656
Subproject commit 694006565505cd0227b3fa78a5c22495c90fee8b
ofxImmediateModeInput
ofxGui
......@@ -29,7 +29,7 @@ void lightDrawing::update() {
void lightDrawing::draw() {
ofSetColor(255);
ofSetLineWidth(10);
ofSetLineWidth(2);
for (int i = 0; i < drawLine.size(); i++) {
drawLine[i].draw();
drawLine[i].getSmoothed(1);
......
......@@ -41,7 +41,7 @@ void ofApp::camRotate(){
cam.tilt(ydiff);
cam.pan(xdiff);
if(mouseMode == false)
glfwSetCursorPos(window, windowcenterx, windowcentery);
......@@ -50,10 +50,15 @@ void ofApp::camRotate(){
//--------------------------------------------------------------
void ofApp::setup(){
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
mouseMode = false;
isMouseInited = false;
ofEnableDepthTest();
isMouseHeldDown = false;
playerLocationX = 0;
playerLocationY = 0;
......@@ -72,11 +77,17 @@ 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();
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));
}
......@@ -116,11 +127,17 @@ void ofApp::update(){
auto push = input.keyPushed;
auto hold = input.keyHolded;
if( push[GLFW_MOUSE_BUTTON_LEFT] ) LightDrawing.mousePressed();
if( hold[GLFW_MOUSE_BUTTON_LEFT] ) LightDrawing.mouseDragged(pos);
if(mouseMode == false){
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
}else{
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
if(isMouseHeldDown == true){
LightDrawing.mouseDragged(pos);
}
LightDrawing.update();
......@@ -150,44 +167,30 @@ void ofApp::update(){
cam.boom(1.4);
}
light.enable();
//light.setSpotlight();
//ofSeedRandom();
srand(time(NULL));
float a = ofRandom(-1.f,1.f);
float b = ofRandom(-1.f,1.f);
float c = ofRandom(-1.f,1.f);
light.setPosition(0, 0, planeDist);
light.setAmbientColor(ofFloatColor(b, c, c, 1.0));
light.setDiffuseColor(ofFloatColor(b, b, c));
light.setSpecularColor(ofFloatColor(a, a, a));
srand(time(NULL));
}
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(45);
ofSetColor(255,255,255,255);
ofFill();
ofCircle(ofGetWindowWidth()/2,ofGetWindowHeight()/2,2);
ofSetColor(255);
ofDrawBitmapString("world coordinate: " + ofToString(pos.x, 2) + "," + ofToString(pos.y, 2) + "," + ofToString(pos.z, 2), 20, 20);
ofDrawBitmapString("player coordinate: " + ofToString(cam.getX(), 2) + "," + ofToString(cam.getY(), 2) + "," + ofToString(cam.getZ(), 2), 20, 40);
ofNoFill();
ofEnableDepthTest();
light.enable();
light.setPosition(0, 0, planeDist);
light.setAmbientColor(ofFloatColor(a1, a2, a3, 1.0));
light.setDiffuseColor(ofFloatColor(d1, d2, d3));
light.setSpecularColor(ofFloatColor(1.f, 1.f, 1.f));
cam.begin();
ofSetLineWidth(1);
ofDrawSphere(0, 0, planeDist, 20); //this is our reference sphere
......@@ -204,24 +207,37 @@ void ofApp::draw(){
// ofDrawBox(ofRandom(-1000,1000),ofRandom(-1000,1000), ofRandom(-1000,1000),100);
ofDrawBox(100,100,10,100);
}
LightDrawing.light.enable();
//LightDrawing.light.enable();
LightDrawing.draw();
//LightDrawing.light.disable();
cam.end();
light.disable();
ofDisableDepthTest();
ofDisableLighting();
gui.draw();
cam.end();
ofSetColor(255,255,255,255);
ofFill();
ofCircle(ofGetWindowWidth()/2,ofGetWindowHeight()/2,2);
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if(key == OF_KEY_ALT){
mouseMode = !mouseMode;
}
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
if (key == 'r') {
LightDrawing.clearAllLines();
}
......@@ -230,22 +246,28 @@ void ofApp::keyReleased(int key){
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
if(mouseMode == false)
camRotate();
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
if(mouseMode == false)
camRotate();
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
if(mouseMode == false){
LightDrawing.mousePressed();
isMouseHeldDown = true;
}
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
if(mouseMode == false)
isMouseHeldDown = false;
}
//--------------------------------------------------------------
......
#pragma once
#include "ofMain.h"
#include "ofxImmediateModeInput.h"
#include "lightDrawing.h"
#include "ofxGui.h"
class ofApp : public ofBaseApp{
......@@ -25,7 +25,7 @@ class ofApp : public ofBaseApp{
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxImmediateModeInput input;
bool intersectPlane(const ofVec3f &n, const ofVec3f &p0, const ofVec3f &l0, const ofVec3f &l, float &t);
......@@ -40,12 +40,16 @@ class ofApp : public ofBaseApp{
float planeDist;
ofVec3f p;
bool mouseMode;
bool isMouseHeldDown;
bool isMouseInited;
lightDrawing LightDrawing;
GLFWwindow *window = static_cast<ofAppGLFWWindow*>(ofGetWindowPtr())->getGLFWWindow();
ofLight light;
ofLight light,light2;
ofxPanel gui;
ofxFloatSlider a1,a2,a3,d1,d2,d3;
};
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