Skip to content
Browse files

ran uncrustify script

  • Loading branch information...
1 parent 65d659b commit 55a5cca122d5cdac37b3de5536b7b19f4933219b @elliotwoods committed
View
6 examples/3d/advanced3dExample/src/Grid.cpp
@@ -9,9 +9,9 @@ void grid::customDraw(){
ofPushStyle();
//give a saturation and lightness
- ofSetColor(255,100,100);
-
+ ofSetColor(255, 100, 100);
+
ofDrawGrid(100.0f);
-
+
ofPopStyle();
}
View
5 examples/3d/advanced3dExample/src/Grid.h
@@ -8,8 +8,7 @@
//
// We inherit from ofNode
-class grid : public ofNode
-{
+class grid : public ofNode {
public:
- void customDraw();
+ void customDraw();
};
View
23 examples/3d/advanced3dExample/src/OrthoCamera.cpp
@@ -13,33 +13,34 @@ orthoCamera::orthoCamera(){
void orthoCamera::begin(ofRectangle rect){
ofCamera::begin(rect);
-
+
//--
// Calculate aspect ratio
float vw = ofGetViewportWidth();
float vh = ofGetViewportHeight();
-
+
//aspect ratio
- float ar = vw/vh;
-
+ float ar = vw / vh;
+
float scalex, scaley;
-
- if (ar > 1.0f){
+
+ if(ar > 1.0f){
//wide
scalex = scale * ar;
scaley = scale;
- }else{
+ }
+ else{
//tall
scalex = scale;
scaley = scale / ar;
}
-
+
//
//--
-
-
-
+
+
+
//--
// Setup projection
View
3 examples/3d/advanced3dExample/src/OrthoCamera.h
@@ -8,8 +8,7 @@
//
// We inherit from ofCamera
-class orthoCamera : public ofCamera
-{
+class orthoCamera : public ofCamera {
public:
orthoCamera();
void begin(ofRectangle rect = ofGetWindowRect());
View
94 examples/3d/advanced3dExample/src/Swarm.cpp
@@ -4,58 +4,58 @@
// with 'simple harmonic motion'
swarm::swarm(){
- light.setAmbientColor(ofColor(0,0,0));
+ light.setAmbientColor(ofColor(0, 0, 0));
}
void swarm::init(int nParticles, float positionDispersion, float velocityDispersion){
-
+
// Check if we've already initialised
- if (particles.size() != 0){
+ if(particles.size() != 0){
// clear out old data
ofLogWarning("swarm") << "Swarm: Already initialised";
-
+
particles.clear();
}
-
+
ofSeedRandom();
//
ofVec3f position, velocity;
ofColor color;
- for (int i=0; i< nParticles; i++){
- position.x = (ofRandom(1.0f)-0.5f) * positionDispersion;
- position.y = (ofRandom(1.0f)-0.5f) * positionDispersion;
- position.z = (ofRandom(1.0f)-0.5f) * positionDispersion;
-
- velocity.x = (ofRandom(1.0f)-0.5f) * velocityDispersion;
- velocity.y = (ofRandom(1.0f)-0.5f) * velocityDispersion;
- velocity.z = (ofRandom(1.0f)-0.5f) * velocityDispersion;
-
+ for(int i = 0; i < nParticles; i++){
+ position.x = (ofRandom(1.0f) - 0.5f) * positionDispersion;
+ position.y = (ofRandom(1.0f) - 0.5f) * positionDispersion;
+ position.z = (ofRandom(1.0f) - 0.5f) * positionDispersion;
+
+ velocity.x = (ofRandom(1.0f) - 0.5f) * velocityDispersion;
+ velocity.y = (ofRandom(1.0f) - 0.5f) * velocityDispersion;
+ velocity.z = (ofRandom(1.0f) - 0.5f) * velocityDispersion;
+
color.r = ofRandom(255.0f);
color.g = ofRandom(255.0f);
color.b = 150.0f;
color.a = 255.0f;
-
+
particle newParticle;
newParticle.position = position;
newParticle.velocity = velocity;
newParticle.color = color;
-
+
// add our new particle to the vector
particles.push_back(newParticle);
}
-
+
}
void swarm::customDraw(){
// We run the update ourselves manually. ofNode does
// not do this for us.
- update();
-
-
-
+ update();
+
+
+
//--
// Draw particles
-
+
// We use the position of the first
// particle as the position of the
// light.
@@ -63,23 +63,23 @@ void swarm::customDraw(){
light.enable();
light.setPosition(particles[0].position);
- for (int i=0; i < particles.size(); i++){
+ for(int i = 0; i < particles.size(); i++){
ofPushStyle();
ofSetColor(particles[i].color);
-
+
ofSphere(particles[i].position, 1.0);
-
+
ofPopStyle();
}
-
+
light.disable();
ofDisableLighting();
-
+
//
//--
-
-
-
+
+
+
// Render light as white sphere
ofSetColor(255, 255, 255);
ofSphere(light.getPosition(), 2.0);
@@ -89,21 +89,21 @@ void swarm::customDraw(){
}
void swarm::update(){
-
+
// Calculate time past per frame
float dt = ofGetLastFrameTime();
-
+
// Update positions, velocities
- for (int i=0; i< particles.size(); i++){
+ for(int i = 0; i < particles.size(); i++){
// -----------
- //
+ //
// MOTION MATHS
//
// 'Simple Harmonic Motion' + a little extra
// ----
//
-
+
// [1] apply velocity to postion
// (i.e. integrate velocity)
//
@@ -113,12 +113,12 @@ void swarm::update(){
// therefore
// x = x + v * dt (*)
//
-
+
// (velcotity is taken from previous frame)
particles[i].position += particles[i].velocity * dt;
-
-
-
+
+
+
// [2] apply spring force to velocity
// (i.e. integrate acceleration)
//
@@ -131,21 +131,21 @@ void swarm::update(){
// v = v + (dt * a)
// v = v + (dt * -k * x)
//
- particles[i].velocity += - SPRING_CONSTANT * particles[i].position * dt;
-
-
+ particles[i].velocity += -SPRING_CONSTANT * particles[i].position * dt;
+
+
// [3] to get a super simple kind of 'flocking' behaviour
// we add a second spring force to velocity relative
// to the position of the light
// NOTICE: THIS ISN'T REAL FLOCKING!
- particles[i].velocity += - SPRING_CONSTANT * (particles[i].position - light.getPosition() ) * dt;
-
-
+ particles[i].velocity += -SPRING_CONSTANT * (particles[i].position - light.getPosition()) * dt;
+
+
// [4] Force a maximum velocity
- if (particles[i].velocity.length() > MAX_VELOCITY) {
+ if(particles[i].velocity.length() > MAX_VELOCITY){
particles[i].velocity /= particles[i].velocity.length() * MAX_VELOCITY;
}
-
+
//
// -----------
View
13 examples/3d/advanced3dExample/src/Swarm.h
@@ -6,25 +6,24 @@
// This 'swarm' object demonstrates a simple particle system
// with 'simple harmonic motion'
-class swarm : public ofNode
-{
- struct particle{
+class swarm : public ofNode {
+ struct particle {
ofVec3f position;
ofVec3f velocity;
ofColor color;
};
-
+
public:
swarm();
void init(int nParticles, float positionDispersion, float velocityDispersion);
void customDraw();
ofLight light;
-
+
protected:
// we call this update function ourselves
// at the beginning of customDraw
void update();
-
+
// objects
- vector<particle> particles;
+ vector<particle>particles;
};
View
8 examples/3d/advanced3dExample/src/main.cpp
@@ -3,14 +3,14 @@
#include "ofAppGlutWindow.h"
//========================================================================
-int main( ){
+int main(){
- ofAppGlutWindow window;
- ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
+ ofAppGlutWindow window;
+ ofSetupOpenGL(&window, 1024, 768, OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
- ofRunApp( new testApp());
+ ofRunApp(new testApp());
}
View
193 examples/3d/advanced3dExample/src/testApp.cpp
@@ -31,55 +31,55 @@
//--------------------------------------------------------------
void testApp::setup(){
-
+
ofSetVerticalSync(true);
ofBackground(70, 70, 70);
ofEnableSmoothing();
glEnable(GL_DEPTH_TEST);
-
-
+
+
//--
// Setup cameras
-
+
iMainCamera = 0;
bCamParent = false;
-
+
// user camera
camEasyCam.setTarget(nodeSwarm);
camEasyCam.setDistance(100);
cameras[0] = &camEasyCam;
-
+
// front
camFront.scale = 20;
cameras[1] = &camFront;
-
+
// top
camTop.scale = 20;
camTop.tilt(-90);
cameras[2] = &camTop;
-
+
// left
camLeft.scale = 20;
camLeft.pan(-90);
cameras[3] = &camLeft;
-
+
//
//--
-
-
-
+
+
+
//--
// Define viewports
-
+
setupViewports();
-
+
//
//--
-
-
-
-
+
+
+
+
//--
// Setup swarm
@@ -93,27 +93,27 @@ void testApp::setup(){
//--------------------------------------------------------------
void testApp::setupViewports(){
//call here whenever we resize the window
-
+
//--
// Define viewports
-
- float xOffset = ofGetWidth()/3;
- float yOffset = ofGetHeight()/N_CAMERAS;
-
+
+ float xOffset = ofGetWidth() / 3;
+ float yOffset = ofGetHeight() / N_CAMERAS;
+
viewMain.x = xOffset;
viewMain.y = 0;
viewMain.width = xOffset * 2;
viewMain.height = ofGetHeight();
-
- for (int i=0; i<N_CAMERAS; i++) {
-
+
+ for(int i = 0; i < N_CAMERAS; i++){
+
viewGrid[i].x = 0;
viewGrid[i].y = yOffset * i;
viewGrid[i].width = xOffset;
viewGrid[i].height = yOffset;
}
-
+
//
//--
}
@@ -126,95 +126,94 @@ void testApp::update(){
//--------------------------------------------------------------
void testApp::draw(){
-
+
ofDrawBitmapString("test", 10, 10);
-
+
//--
// Highlight background of selected camera
-
+
glDisable(GL_DEPTH_TEST);
ofPushStyle();
ofSetColor(100, 100, 100);
ofRect(viewGrid[iMainCamera]);
ofPopStyle();
glEnable(GL_DEPTH_TEST);
-
+
//
//--
-
-
-
+
+
+
//--
// Draw all viewports
-
+
// draw main viewport
cameras[iMainCamera]->begin(viewMain);
drawScene(iMainCamera);
-
+
// calculate mouse ray whilst this camera is active
updateMouseRay();
-
+
cameras[iMainCamera]->end();
-
+
// draw side viewports
- for (int i=0; i<N_CAMERAS; i++)
- {
+ for(int i = 0; i < N_CAMERAS; i++){
cameras[i]->begin(viewGrid[i]);
drawScene(i);
cameras[i]->end();
}
-
+
//
//--
-
-
-
+
+
+
//--
// Draw annotations (text, gui, etc)
-
+
ofPushStyle();
glDepthFunc(GL_ALWAYS); // draw on top of everything
-
+
// draw some labels
ofSetColor(255, 255, 255);
ofDrawBitmapString("Press keys 1-4 to select a camera for main view", viewMain.x + 20, 30);
- ofDrawBitmapString("Camera selected: " + ofToString(iMainCamera+1), viewMain.x + 20, 50);
+ ofDrawBitmapString("Camera selected: " + ofToString(iMainCamera + 1), viewMain.x + 20, 50);
ofDrawBitmapString("Press 'f' to toggle fullscreen", viewMain.x + 20, 70);
ofDrawBitmapString("Press 'p' to toggle parents on OrthoCamera's", viewMain.x + 20, 90);
-
- ofDrawBitmapString("EasyCam", viewGrid[0].x + 20, viewGrid[0].y + 30);
- ofDrawBitmapString("Front", viewGrid[1].x + 20, viewGrid[1].y + 30);
- ofDrawBitmapString("Top", viewGrid[2].x + 20, viewGrid[2].y + 30);
- ofDrawBitmapString("Left", viewGrid[3].x + 20, viewGrid[3].y + 30);
+
+ ofDrawBitmapString("EasyCam", viewGrid[0].x + 20, viewGrid[0].y + 30);
+ ofDrawBitmapString("Front", viewGrid[1].x + 20, viewGrid[1].y + 30);
+ ofDrawBitmapString("Top", viewGrid[2].x + 20, viewGrid[2].y + 30);
+ ofDrawBitmapString("Left", viewGrid[3].x + 20, viewGrid[3].y + 30);
// draw outlines on views
ofSetLineWidth(5);
ofNoFill();
ofSetColor(255, 255, 255);
//
- for (int i=0; i<N_CAMERAS; i++){
+ for(int i = 0; i < N_CAMERAS; i++){
ofRect(viewGrid[i]);
}
//
ofRect(viewMain);
-
- // restore the GL depth function
+
+ // restore the GL depth function
glDepthFunc(GL_LESS);
ofPopStyle();
-
+
//
//--
}
-void testApp::drawScene(int iCameraDraw){
-
+void testApp::drawScene(int iCameraDraw){
+
nodeSwarm.draw();
nodeGrid.draw();
-
+
//--
// Draw frustum preview for ofEasyCam camera
-
+
// This code draws our camera in
// the scene (reddy/pink lines)
//
@@ -225,19 +224,19 @@ void testApp::drawScene(int iCameraDraw){
// Often we refer to the volume
// which can be seen by the
// camera as 'the view frustum'.
-
-
+
+
// First check if we're already drawing the view through the easycam
// If so, don't draw the frustum preview.
- if (iCameraDraw != 0){
-
+ if(iCameraDraw != 0){
+
ofPushStyle();
ofPushMatrix();
-
+
//--
// Create transform for box->frustum
-
- // In 'camera space' the bounds of
+
+ // In 'camera space' the bounds of
// the view are defined by a box
// with bounds -1->1 in each axis
//
@@ -252,7 +251,7 @@ void testApp::drawScene(int iCameraDraw){
// transformed into a frustum in
// world space.
//
-
+
// The camera's matricies are dependant on
// the aspect ratio of the viewport.
// (Which is why we use the viewport as
@@ -261,17 +260,18 @@ void testApp::drawScene(int iCameraDraw){
// If this camera is fullscreen we'll use
// viewMain, else we'll use viewGrid[0]
ofRectangle boundsToUse;
- if ( iMainCamera == 0 ) {
+ if(iMainCamera == 0){
boundsToUse = viewMain;
- }else{
+ }
+ else{
boundsToUse = viewGrid[0];
}
-
+
// Now lets get the inverse ViewProjection
// for the camera
ofMatrix4x4 inverseCameraMatrix;
- inverseCameraMatrix.makeInvertOf( camEasyCam.getModelViewProjectionMatrix( boundsToUse ) );
-
+ inverseCameraMatrix.makeInvertOf(camEasyCam.getModelViewProjectionMatrix(boundsToUse));
+
// By default, we can say
// 'we are drawing in world space'
//
@@ -293,16 +293,16 @@ void testApp::drawScene(int iCameraDraw){
// to OpenGL, and apply that matrix to
// the current OpenGL transform
glMultMatrixf(inverseCameraMatrix.getPtr());
-
+
//
//--
-
-
-
+
+
+
//--
// Draw box in camera space
// (i.e. frustum in world space)
-
+
ofNoFill();
// i.e. a box -1, -1, -1 to +1, +1, +1
ofBox(0, 0, 0, 2.0f);
@@ -312,24 +312,24 @@ void testApp::drawScene(int iCameraDraw){
ofPopStyle();
ofPopMatrix();
}
-
+
//
//--
-
-
+
+
//--
// Draw mouse ray
-
+
// Draw the ray if ofEasyCam is in main view,
// and we're not currently drawing in that view
- if (iMainCamera == 0 && iCameraDraw != 0){
+ if(iMainCamera == 0 && iCameraDraw != 0){
ofPushStyle();
ofSetColor(100, 100, 255);
ofLine(ray[0], ray[1]);
ofPopStyle();
}
-
+
//
//--
}
@@ -339,7 +339,7 @@ void testApp::updateMouseRay(){
// Define ray in screen space
ray[0] = ofVec3f(ofGetMouseX(), ofGetMouseY(), -1);
ray[1] = ofVec3f(ofGetMouseX(), ofGetMouseY(), 1);
-
+
// Transform ray into world space
ray[0] = cameras[iMainCamera]->screenToWorld(ray[0], viewMain);
ray[1] = cameras[iMainCamera]->screenToWorld(ray[1], viewMain);
@@ -347,27 +347,28 @@ void testApp::updateMouseRay(){
//--------------------------------------------------------------
void testApp::keyPressed(int key){
-
- if (key >= '1' && key <= '4'){
+
+ if(key >= '1' && key <= '4'){
iMainCamera = key - '1';
}
-
- if (key == 'f'){
+
+ if(key == 'f'){
ofToggleFullscreen();
}
-
- if (key == 'p'){
- if (bCamParent){
+
+ if(key == 'p'){
+ if(bCamParent){
camFront.clearParent();
camTop.clearParent();
camLeft.clearParent();
-
+
bCamParent = false;
- }else{
+ }
+ else{
camFront.setParent(nodeSwarm.light);
camTop.setParent(nodeSwarm.light);
camLeft.setParent(nodeSwarm.light);
-
+
bCamParent = true;
}
}
@@ -378,7 +379,7 @@ void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
-void testApp::mouseMoved(int x, int y ){
+void testApp::mouseMoved(int x, int y){
}
//--------------------------------------------------------------
View
22 examples/3d/advanced3dExample/src/testApp.h
@@ -19,20 +19,20 @@
#define N_CAMERAS 4
-class testApp : public ofBaseApp{
+class testApp : public ofBaseApp {
public:
void setup();
void update();
void draw();
-
+
void setupViewports();
void drawScene(int iCameraDraw);
void updateMouseRay();
-
- void keyPressed (int key);
+
+ void keyPressed(int key);
void keyReleased(int key);
- void mouseMoved(int x, int y );
+ void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
@@ -41,20 +41,20 @@ class testApp : public ofBaseApp{
//cameras (all these inherit from ofCamera)
ofEasyCam camEasyCam;
orthoCamera camFront;
- orthoCamera camTop;
- orthoCamera camLeft;
-
+ orthoCamera camTop;
+ orthoCamera camLeft;
+
//cameras have parent?
bool bCamParent;
//camera pointers
ofCamera * cameras[N_CAMERAS];
int iMainCamera;
-
+
//viewports
ofRectangle viewMain;
- ofRectangle viewGrid[N_CAMERAS];
-
+ ofRectangle viewGrid[N_CAMERAS];
+
//my custom node
swarm nodeSwarm;
grid nodeGrid;
View
53 examples/gl/viewportExample/src/testApp.cpp
@@ -34,36 +34,38 @@ void testApp::draw(){
//--
// 2d view
-
+
drawViewportOutline(viewport2D);
-
+
// keep a copy of your viewport and transform matrices for later
ofPushView();
-
+
// tell OpenGL to change your viewport. note that your transform matrices will now need setting up
- ofViewport(viewport2D);
-
+ ofViewport(viewport2D);
+
// setup transform matrices for normal oF-style usage, i.e.
// 0,0=left,top
// ofGetViewportWidth(),ofGetViewportHeight()=right,bottom
ofSetupScreen();
-
+
ofNoFill();
ofEnableSmoothing();
- for (int x = 0; x < 1000; x+=20)
- for (int y = 0; y < 1000; y+=20)
- ofCircle(x, y, sin( (x + y) / 100.0f + ofGetElapsedTimef()) * 5.0f);
-
+ for(int x = 0; x < 1000; x += 20){
+ for(int y = 0; y < 1000; y += 20){
+ ofCircle(x, y, sin((x + y) / 100.0f + ofGetElapsedTimef()) * 5.0f);
+ }
+ }
+
// restore the old viewport (now full view and oF coords)
ofPopView();
//--
-
-
+
+
//--
// 3d view
drawViewportOutline(viewport3D);
-
+
// note the camera accepts the viewport as an argument
// this is so that the camera can be aware of which viewport
// it is acting on
@@ -72,30 +74,30 @@ void testApp::draw(){
camera.begin(viewport3D);
ofDrawGrid(100);
camera.end();
- //--
-
-
+ //--
+
+
ofDrawBitmapString("Press [space] to randomize viewports", 20, 20);
}
-
+
//--------------------------------------------------------------
void testApp::randomize(ofRectangle & viewport){
// utlitly function to randomise a rectangle
- viewport.x = ofRandom( ofGetWidth() * 2.0f / 3.0f );
- viewport.y = ofRandom( ofGetHeight() * 2.0f / 3.0f );
- viewport.width = 100 + ofRandom( ofGetWidth() - viewport.x - 100);
- viewport.height = 100 + ofRandom( ofGetHeight() - viewport.y - 100);
+ viewport.x = ofRandom(ofGetWidth() * 2.0f / 3.0f);
+ viewport.y = ofRandom(ofGetHeight() * 2.0f / 3.0f);
+ viewport.width = 100 + ofRandom(ofGetWidth() - viewport.x - 100);
+ viewport.height = 100 + ofRandom(ofGetHeight() - viewport.y - 100);
}
//--------------------------------------------------------------
-void testApp::randomizeViewports(){
+void testApp::randomizeViewports(){
randomize(viewport2D);
randomize(viewport3D);
}
//--------------------------------------------------------------
-void testApp::drawViewportOutline(const ofRectangle & viewport){
+void testApp::drawViewportOutline(const ofRectangle & viewport){
ofPushStyle();
ofFill();
ofSetColor(100);
@@ -111,8 +113,9 @@ void testApp::drawViewportOutline(const ofRectangle & viewport){
//--------------------------------------------------------------
void testApp::keyPressed(int key){
- if (key == ' ')
+ if(key == ' '){
randomizeViewports();
+ }
}
//--------------------------------------------------------------
@@ -151,6 +154,6 @@ void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
-void testApp::dragEvent(ofDragInfo dragInfo){
+void testApp::dragEvent(ofDragInfo dragInfo){
}
View
12 examples/gl/viewportExample/src/testApp.h
@@ -2,16 +2,16 @@
#include "ofMain.h"
-class testApp : public ofBaseApp{
+class testApp : public ofBaseApp {
public:
void setup();
void update();
void draw();
-
+
void randomize(ofRectangle & viewport);
void randomizeViewports();
- void drawViewportOutline(const ofRectangle & viewport);
-
+ void drawViewportOutline(const ofRectangle & viewport);
+
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
@@ -21,9 +21,9 @@ class testApp : public ofBaseApp{
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
-
+
ofRectangle viewport2D;
ofRectangle viewport3D;
-
+
ofEasyCam camera;
};

0 comments on commit 55a5cca

Please sign in to comment.
Something went wrong with that request. Please try again.