Commit 4ec9c55b authored by Kevin Dang's avatar Kevin Dang

updates include:

• light spheres now go to player position when user presses space bar
• increased sphere number to 5
• added box world objects
parent 075d0c7c
No preview for this file type
......@@ -110,10 +110,10 @@
0A08A9381CC5352400153E01 /* World Objects */ = {
isa = PBXGroup;
children = (
0A08A92A1CC5350D00153E01 /* lightBalls.cpp */,
0A08A92B1CC5350D00153E01 /* lightBalls.h */,
0A08A92C1CC5350D00153E01 /* populateSmallSphere.cpp */,
0A08A92A1CC5350D00153E01 /* lightBalls.cpp */,
0A08A92D1CC5350D00153E01 /* populateSmallSphere.h */,
0A08A92C1CC5350D00153E01 /* populateSmallSphere.cpp */,
);
name = "World Objects";
sourceTree = "<group>";
......@@ -121,10 +121,10 @@
0A08A9391CC5353500153E01 /* Miscellaneous */ = {
isa = PBXGroup;
children = (
0A08A9281CC5350D00153E01 /* flocking.cpp */,
0A08A9291CC5350D00153E01 /* flocking.h */,
0A08A92E1CC5350D00153E01 /* smallSphereObject.cpp */,
0A08A9281CC5350D00153E01 /* flocking.cpp */,
0A08A92F1CC5350D00153E01 /* smallSphereObject.h */,
0A08A92E1CC5350D00153E01 /* smallSphereObject.cpp */,
);
name = Miscellaneous;
sourceTree = "<group>";
......@@ -200,13 +200,13 @@
E4B69E1C0A3A1BDC003C02F2 /* src */ = {
isa = PBXGroup;
children = (
4F72D8D11CBE8F19000E43E6 /* Gui.cpp */,
4F72D8D21CBE8F19000E43E6 /* Gui.h */,
4F04D6231CBD1ED70092E1D7 /* lightDrawing.cpp */,
4F04D6241CBD1ED70092E1D7 /* lightDrawing.h */,
E4B69E1D0A3A1BDC003C02F2 /* main.cpp */,
E4B69E1E0A3A1BDC003C02F2 /* ofApp.cpp */,
E4B69E1F0A3A1BDC003C02F2 /* ofApp.h */,
E4B69E1E0A3A1BDC003C02F2 /* ofApp.cpp */,
4F72D8D21CBE8F19000E43E6 /* Gui.h */,
4F72D8D11CBE8F19000E43E6 /* Gui.cpp */,
4F04D6241CBD1ED70092E1D7 /* lightDrawing.h */,
4F04D6231CBD1ED70092E1D7 /* lightDrawing.cpp */,
0A08A9391CC5353500153E01 /* Miscellaneous */,
0A08A9381CC5352400153E01 /* World Objects */,
);
......
......@@ -9,30 +9,55 @@
#include "Gui.h"
void Gui::setup(){
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);
d2[0].setup("Diffuse 2", 0, 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);
d1[1].setup("Diffuse 1", 0, 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);
a1[2].setup("Red", 0, 0, 255);
a2[2].setup("Green", 0, 0, 255);
a3[2].setup("Blue", 0., 0, 255);
d1[2].setup("Diffuse 1", 0, 0, 255);
d2[2].setup("Diffuse 2", 0, 0, 255);
d3[2].setup("Diffuse 3", 0, 0, 255);
a1[3].setup("Red", 0, 0, 255);
a2[3].setup("Green", 0, 0, 255);
a3[3].setup("Blue", 0., 0, 255);
d1[3].setup("Diffuse 1", 0, 0, 255);
d2[3].setup("Diffuse 2", 0, 0, 255);
d3[3].setup("Diffuse 3", 0, 0, 255);
a1[4].setup("Red", 0, 0, 255);
a2[4].setup("Green", 0, 0, 255);
a3[4].setup("Blue", 0., 0, 255);
d1[4].setup("Diffuse 1", 0, 0, 255);
d2[4].setup("Diffuse 2", 0, 0, 255);
d3[4].setup("Diffuse 3", 0, 0, 255);
// s1[0].setup("Specular 1", 255, 255, 255);
// s2[0].setup("Specular 2", 255, 255, 255);
// s3[0].setup("Specular 3", 255, 255, 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);
select.setup("Select Sphere");
select.add(selection.setup("SphereNum", 0, 0, 1));
for(int i = 0; i<2; i++){
select.add(selection.setup("SphereNum", 0, 0, 4));
for(int i = 0; i<5; i++){
guiLighting[i].setup("Lighting Controls");
guiLighting[i].add(&a1[i]);
guiLighting[i].add(&a2[i]);
......
......@@ -18,9 +18,9 @@ public:
void setup();
void draw();
ofxPanel select;
ofxPanel guiLighting[2];
ofxPanel guiLighting[5];
ofxIntSlider selection;
ofxIntSlider a1[5],a2[5],a3[5],d1[5],d2[5],d3[5],s1[5],s2[5],s3[5];
......
......@@ -22,7 +22,7 @@ flocking::flocking(float _x, float _y, float _z): x(_x), y(_y), z(_z) {
void flocking::update(ofVec3f _tempPos) {
staticTarget.set(ofRandom(_tempPos.x-100,_tempPos.x+100),ofRandom(_tempPos.y-100,_tempPos.y+100),ofRandom(_tempPos.z-100,_tempPos.z+100));
dir.normalize();
dir = dir * 0.1;
acceleration = dir;
......@@ -33,7 +33,7 @@ void flocking::update(ofVec3f _tempPos) {
void flocking::display() {
ofPushMatrix();
ofTranslate(location.x, location.y, location.z);
ofSetColor(255);
ofFill();
......
......@@ -19,10 +19,15 @@ void lightBalls::update(ofVec3f _tempPos) {
for (int i = 0; i < Flocking.size(); i++) {
Flocking[i].update(_tempPos);
}
for (int i = 0; i < Flocking.size(); i++) {
Flocking[i].dir.set(Flocking[i].staticTarget.x - Flocking[i].location.x,Flocking[i].staticTarget.y - Flocking[i].location.y);
}
}
void lightBalls::display() {
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 5; i++) {
Flocking[i].display();
}
}
......
......@@ -84,24 +84,32 @@ void ofApp::setup(){
userInterface.setup();
lightPos.set(0,0,planeDist);
// lightPos.set(0,0,planeDist);
ofDisableArbTex();
ofSetSmoothLighting(true);
for(int i = 0; i<5; i++){
v_light.push_back(light);
newLightBallPosition.push_back(ofVec3f());
}
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);
light2.setDiffuseColor( ofColor(255.f, 0.f, 0.f));
light2.setSpecularColor( ofColor(255.f, 255.f, 255.f));
light2.setAreaLight(1000, 1000);
light3.setDiffuseColor( ofColor(255.f, 0.f, 0.f));
light3.setSpecularColor( ofColor(255.f, 255.f, 255.f));
light3.setAreaLight(1000, 1000);
light4.setDiffuseColor( ofColor(255.f, 0.f, 0.f));
light4.setSpecularColor( ofColor(255.f, 255.f, 255.f));
light4.setAreaLight(1000, 1000);
}
//--------------------------------------------------------------
......@@ -110,12 +118,6 @@ void ofApp::update(){
if (state == 1) {
lightBalls.update(lightPos);
for (int i = 0; i < lightBalls.Flocking.size(); i++) {
lightBalls.Flocking[i].dir.set(lightBalls.Flocking[i].staticTarget.x - lightBalls.Flocking[i].location.x,lightBalls.Flocking[i].staticTarget.y - lightBalls.Flocking[i].location.y);
}
/*** Simon's Help Start ***/
//get the mouse coordinate
......@@ -177,7 +179,7 @@ void ofApp::update(){
//User Camera Movements
if (ofGetKeyPressed('w') == true) {
cam.dolly(-1.4);
cam.dolly(-10.4);
}
if (ofGetKeyPressed('s') == true) {
cam.dolly(1.4);
......@@ -205,54 +207,68 @@ void ofApp::update(){
LightDrawing.standardSize = userInterface.standardSize;
lightBalls.Flocking[0].dir.set(newLightBallPosition[0].x - lightBalls.Flocking[0].location.x,newLightBallPosition[0].y - lightBalls.Flocking[0].location.y, newLightBallPosition[0].z - lightBalls.Flocking[0].location.z);
lightBalls.Flocking[1].dir.set(newLightBallPosition[1].x - lightBalls.Flocking[1].location.x,newLightBallPosition[1].y - lightBalls.Flocking[1].location.y, newLightBallPosition[1].z - lightBalls.Flocking[1].location.z);
lightBalls.Flocking[2].dir.set(newLightBallPosition[2].x - lightBalls.Flocking[2].location.x,newLightBallPosition[2].y - lightBalls.Flocking[2].location.y, newLightBallPosition[2].z - lightBalls.Flocking[2].location.z);
lightBalls.Flocking[3].dir.set(newLightBallPosition[3].x - lightBalls.Flocking[3].location.x,newLightBallPosition[3].y - lightBalls.Flocking[3].location.y, newLightBallPosition[3].z - lightBalls.Flocking[3].location.z);
lightBalls.Flocking[4].dir.set(newLightBallPosition[4].x - lightBalls.Flocking[4].location.x,newLightBallPosition[4].y - lightBalls.Flocking[4].location.y, newLightBallPosition[4].z - lightBalls.Flocking[4].location.z);
lightBalls.update(lightPos);
} // end of state = 1
if(mouseMode == false){
}
//
// 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);
//
//
// 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));
if(userInterface.selection == 0){
light0.setAmbientColor( ofColor(userInterface.a1[0], userInterface.a2[0], userInterface.a3[0]));
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));
if(userInterface.selection == 1){
light1.setAmbientColor( ofColor(userInterface.a1[1], userInterface.a2[1], userInterface.a3[1]));
light1.setDiffuseColor( ofColor(userInterface.d1[1], userInterface.d2[1], userInterface.d3[1]));
light1.setSpecularColor( ofColor(userInterface.s1[1], userInterface.s2[1], userInterface.s3[1]));
}
if(userInterface.selection == 2){
light1.setAmbientColor( ofColor(userInterface.a1[2], userInterface.a2[2], userInterface.a3[2]));
light1.setDiffuseColor( ofColor(userInterface.d1[2], userInterface.d2[2], userInterface.d3[2]));
light1.setSpecularColor( ofColor(userInterface.s1[2], userInterface.s2[2], userInterface.s3[2]));
}
if(userInterface.selection == 3){
light1.setAmbientColor( ofColor(userInterface.a1[3], userInterface.a2[3], userInterface.a3[3]));
light1.setDiffuseColor( ofColor(userInterface.d1[3], userInterface.d2[3], userInterface.d3[3]));
light1.setSpecularColor( ofColor(userInterface.s1[3], userInterface.s2[3], userInterface.s3[3]));
}
if(userInterface.selection == 4){
light1.setAmbientColor( ofColor(userInterface.a1[4], userInterface.a2[4], userInterface.a3[4]));
light1.setDiffuseColor( ofColor(userInterface.d1[4], userInterface.d2[4], userInterface.d3[4]));
light1.setSpecularColor( ofColor(userInterface.s1[4], userInterface.s2[4], userInterface.s3[4]));
}
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);
light2.setPosition(lightBalls.Flocking[2].location.x, lightBalls.Flocking[2].location.y, lightBalls.Flocking[2].location.z);
light3.setPosition(lightBalls.Flocking[3].location.x, lightBalls.Flocking[3].location.y, lightBalls.Flocking[3].location.z);
light4.setPosition(lightBalls.Flocking[4].location.x, lightBalls.Flocking[4].location.y, lightBalls.Flocking[4].location.z);
}
......@@ -265,16 +281,19 @@ void ofApp::draw(){
ofEnableLighting();
light0.enable();
light1.enable();
light2.enable();
light3.enable();
light4.enable();
if (state == 0) {
}
if (state == 1) {
//Lighting
cam.begin();
if(mouseMode == true && userInterface.selection==0){
......@@ -287,17 +306,25 @@ void ofApp::draw(){
ofDrawSphere(light1.getX(), light1.getY(), light1.getZ(), 50);
}
if(mouseMode == true && userInterface.selection==2){
ofNoFill();
ofDrawSphere(light2.getX(), light2.getY(), light2.getZ(), 50);
}
if(mouseMode == true && userInterface.selection==3){
ofNoFill();
ofDrawSphere(light3.getX(), light3.getY(), light3.getZ(), 50);
}
if(mouseMode == true && userInterface.selection==4){
ofNoFill();
ofDrawSphere(light4.getX(), light4.getY(), light4.getZ(), 50);
}
ofFill();
// ofDrawSphere(lightPos.x,lightPos.y,lightPos.z, sphereSize); //this is our reference sphere
ofFill();
//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);
......@@ -348,6 +375,31 @@ void ofApp::keyPressed(int key){
mouseMode = !mouseMode;
}
if (key == ' ') {
if (userInterface.selection == 0) {
newLightBallPosition[0] = pos;
}
if (userInterface.selection == 1) {
newLightBallPosition[1] = pos;
}
if (userInterface.selection == 2) {
newLightBallPosition[2] = pos;
}
if (userInterface.selection == 3) {
newLightBallPosition[3] = pos;
}
if (userInterface.selection == 4) {
newLightBallPosition[4] = pos;
}
}
} // end of state == 1
......@@ -362,6 +414,9 @@ void ofApp::keyReleased(int key){
LightDrawing.clearPreviousLine();
}
} // end of state == 1
......
......@@ -33,9 +33,7 @@ public:
bool intersectPlane(const ofVec3f &n, const ofVec3f &p0, const ofVec3f &l0, const ofVec3f &l, float &t);
ofCamera cam;
ofVec3f pos;
ofVec3f ray;
......@@ -52,11 +50,7 @@ public:
GLFWwindow *window = static_cast<ofAppGLFWWindow*>(ofGetWindowPtr())->getGLFWWindow();
ofLight light0,light1;
ofLight light;
vector<ofLight> v_light;
ofLight light0,light1,light2,light3,light4;
Gui userInterface;
......@@ -67,8 +61,10 @@ public:
populateSmallSphere smallSpheres;
lightBalls lightBalls;
vector <ofVec3f> newLightBallPosition;
bool running;
float runningSpeed;
};
......@@ -13,13 +13,16 @@ populateSmallSphere::populateSmallSphere() {
for (int i = 0; i < 600; i++) {
sphereObjects.push_back(smallSphereObject(0,0,0));
}
for (int i = 0; i < 5; i++) {
boxObject.push_back(boxObjects(0,0,0));
}
}
void populateSmallSphere::display() {
for (int i = 0; i < sphereObjects.size(); i++) {
sphereObjects[i].display();
}
for (int i = 0; i < boxObject.size(); i++) {
boxObject[i].display();
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ public:
populateSmallSphere();
void display();
vector <smallSphereObject> sphereObjects;
vector <boxObjects> boxObject;
};
#endif /* populateSmallSphere_h */
......
......@@ -24,4 +24,14 @@ void smallSphereObject::display() {
ofFill();
ofDrawSphere(0,0,0,2);
ofPopMatrix();
}
void boxObjects::display() {
ofPushMatrix();
ofTranslate(location.x, location.y, location.z);
ofSetColor(255);
ofFill();
ofDrawBox(0, 0, 0, 40);
ofPopMatrix();
}
\ No newline at end of file
......@@ -11,14 +11,23 @@
#include "ofMain.h"
class smallSphereObject {
private:
protected:
float x;
float y;
float z;
ofVec3f location;
public:
smallSphereObject(float _x, float _y, float _z);
explicit smallSphereObject(float _x, float _y, float _z);
virtual void display();
};
class boxObjects: public smallSphereObject {
public:
using smallSphereObject::smallSphereObject;
void display();
};
#endif /* smallSphereObject_h */
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