Commit b1bf2d48 authored by Kevin Dang's avatar Kevin Dang

adding the files

parent 3c9e2614
//
// flocking.cpp
// Lux
//
// Created by Dat Nguyen & Kevin Dang
//
//
#include <stdio.h>
#include "flocking.h"
flocking::flocking(float _x, float _y, float _z): x(_x), y(_y), z(_z) {
x = ofRandom(-100,100);
y = ofRandom(-100,100);
z = ofRandom(-100,100);
location.set(x, y, z);
velocity.set(0,0,0);
acceleration.set(-0.001,0.01,0.01);
topSpeed = 5;
}
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;
velocity = velocity + acceleration;
velocity.limit(topSpeed);
location = location + velocity;
}
void flocking::display() {
ofPushMatrix();
ofTranslate(location.x, location.y, location.z);
ofSetColor(255);
ofFill();
ofDrawSphere(0,0,0,20);
ofPopMatrix();
}
\ No newline at end of file
//
// flocking.h
// Lux
//
// Created by Dat Nguyen & Kevin Dang
//
//
#ifndef flocking_h
#define flocking_h
#include "ofMain.h"
class flocking {
public:
flocking(float _x, float _y, float _z);
float x;
float y;
float z;
void display();
void update(ofVec3f _tempPos);
ofVec3f location, velocity, acceleration, dir, staticTarget;
float topSpeed;
};
#endif /* flocking_h */
//
// lightBalls.cpp
// Lux
//
// Created by Dat Nguyen & Kevin Dang
//
//
#include <stdio.h>
#include "lightBalls.h"
lightBalls::lightBalls() {
for (int i = 0; i < 5; i++) {
Flocking.push_back(flocking(0,0,0));
}
}
void lightBalls::update(ofVec3f _tempPos) {
for (int i = 0; i < Flocking.size(); i++) {
Flocking[i].update(_tempPos);
}
}
void lightBalls::display() {
for (int i = 0; i < Flocking.size(); i++) {
Flocking[i].display();
}
}
//
// lightBalls.h
// Lux
//
// Created by Dat Nguyen & Kevin Dang
//
//
#ifndef lightBalls_h
#define lightBalls_h
#include "ofMain.h"
#include "flocking.h"
class lightBalls {
public:
lightBalls();
void display();
void update(ofVec3f _tempPos);
vector <flocking> Flocking;
};
#endif /* lightBalls_h */
//
// populateSmallSphere.cpp
// Lux
//
// Created by Dat Nguyen & Kevin Dang
//
//
#include <stdio.h>
#include "populateSmallSphere.h"
populateSmallSphere::populateSmallSphere() {
for (int i = 0; i < 600; i++) {
sphereObjects.push_back(smallSphereObject(0,0,0));
}
}
void populateSmallSphere::display() {
for (int i = 0; i < sphereObjects.size(); i++) {
sphereObjects[i].display();
}
}
\ No newline at end of file
//
// populateSmallSphere.h
// Lux
//
// Created by Dat Nguyen & Kevin Dang
//
//
#ifndef populateSmallSphere_h
#define populateSmallSphere_h
#include "ofMain.h"
#include "smallSphereObject.h"
class populateSmallSphere {
public:
populateSmallSphere();
void display();
vector <smallSphereObject> sphereObjects;
};
#endif /* populateSmallSphere_h */
//
// smallSphereObject.cpp
// Lux
//
// Created by Dat Nguyen & Kevin Dang
//
//
#include <stdio.h>
#include "smallSphereObject.h"
smallSphereObject::smallSphereObject(float _x, float _y, float _z): x(_x), y(_y), z(_z) {
x = ofRandom(-2500,2500);
y = ofRandom(-2500,2500);
z = ofRandom(-2500,2500);
location.set(x, y, z);
}
void smallSphereObject::display() {
ofPushMatrix();
ofTranslate(location.x, location.y, location.z);
ofSetColor(255);
ofFill();
ofDrawSphere(0,0,0,2);
ofPopMatrix();
}
\ No newline at end of file
//
// smallSphereObject.h
// Lux
//
// Created by Dat Nguyen & Kevin Dang
//
//
#ifndef smallSphereObject_h
#define smallSphereObject_h
#include "ofMain.h"
class smallSphereObject {
private:
float x;
float y;
float z;
ofVec3f location;
public:
smallSphereObject(float _x, float _y, float _z);
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