Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions example-bouncingball/Project.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
//THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
OF_PATH = ../../..

//THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
#include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"

OTHER_LDFLAGS = $(OF_CORE_LIBS)
HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
1 change: 1 addition & 0 deletions example-bouncingball/addons.make
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ofxTriangleMesh
Empty file.
1,020 changes: 1,020 additions & 0 deletions example-bouncingball/example-bouncingball.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example-bouncingball.app"
BlueprintName = "example-bouncingball"
ReferencedContainer = "container:example-bouncingball.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example-bouncingball.app"
BlueprintName = "example-bouncingball"
ReferencedContainer = "container:example-bouncingball.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example-bouncingball.app"
BlueprintName = "example-bouncingball"
ReferencedContainer = "container:example-bouncingball.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example-bouncingball.app"
BlueprintName = "example-bouncingball"
ReferencedContainer = "container:example-bouncingball.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Debug"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example-bouncingball.app"
BlueprintName = "example-bouncingball"
ReferencedContainer = "container:example-bouncingball.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Release">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example-bouncingball.app"
BlueprintName = "example-bouncingball"
ReferencedContainer = "container:example-bouncingball.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example-bouncingball.app"
BlueprintName = "example-bouncingball"
ReferencedContainer = "container:example-bouncingball.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example-bouncingball.app"
BlueprintName = "example-bouncingball"
ReferencedContainer = "container:example-bouncingball.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Release">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
20 changes: 20 additions & 0 deletions example-bouncingball/openFrameworks-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.openFrameworks</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
46 changes: 46 additions & 0 deletions example-bouncingball/src/Ball.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include "ofMain.h"

class Ball {

public:
Ball(float _x, float _y, float _mWidth, float _mHeight) {
x = _x;
y = _y;
xDir = ofRandom(-5, 5);
yDir = ofRandom(-5, 5);
d = 10;
mWidth = _mWidth;
mHeight = _mHeight;
}

//--------------------------------------
// Moves and changes direction if it hits a wall.
void calc() {
if (x < 0 || x > mWidth) xDir *= -1;
if (y < 0 || y > mHeight) yDir *= -1;
x += xDir;
y += yDir;
}

//--------------------------------------
void draw() {
ofSetColor(0, 0, 0, 100);
ofFill();
ofCircle(x, y, d);
ofSetColor(0);
ofNoFill();
ofCircle(x, y, d);
}
float x;
float y;
private:

float xDir;
float yDir;
float d;
float mWidth;
float mHeight;

};
16 changes: 16 additions & 0 deletions example-bouncingball/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "ofMain.h"
#include "testApp.h"
#include "ofAppGlutWindow.h"

//========================================================================
int main( ){

ofAppGlutWindow window;
ofSetupOpenGL(&window, 1280,720, 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());

}
105 changes: 105 additions & 0 deletions example-bouncingball/src/testApp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include "testApp.h"

//--------------------------------------------------------------
void testApp::setup(){
for(int i = 0 ; i < 10 ; i++)
{
Ball* ball = new Ball(ofRandomWidth(), ofRandomHeight() , ofGetWidth(),ofGetHeight());
balls.push_back(ball);
}
}

//--------------------------------------------------------------
void testApp::update(){

}

//--------------------------------------------------------------
void testApp::draw(){
ofBackgroundGradient(ofColor::white, ofColor::gray);
ofBackgroundGradient(ofColor::white, ofColor(200,200,200), OF_GRADIENT_LINEAR);

for (int i = 0; i < balls.size(); i++) {
balls[i]->calc();
balls[i]->draw();
}

if (balls.size() > 2){

ofPolyline lineRespaced;
for (int i = 0; i < balls.size(); i++) {
lineRespaced.addVertex(ofVec2f(balls[i]->x,balls[i]->y));
}

// add the last point (so when we resample, it's a closed polygon)
lineRespaced.addVertex(lineRespaced[0]);
// resample
lineRespaced = lineRespaced.getResampledBySpacing(20);
// I want to make sure the first point and the last point are not the same, since triangle is unhappy:
lineRespaced.getVertices().erase(lineRespaced.getVertices().begin());
// if we have a proper set of points, mesh them:
if (lineRespaced.size() > 5){

// angle constraint = 28
// size constraint = -1 (don't constraint triangles by size);

mesh.triangulate(lineRespaced, 28, -1);


// this is an alternative, constrain on size not angle:
//mesh.triangulate(lineRespaced, -1, 200);

// see ofxTriangleMesh.h for info.

}
}
mesh.draw();

}

//--------------------------------------------------------------
void testApp::keyPressed(int key){

}

//--------------------------------------------------------------
void testApp::keyReleased(int key){

}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
Ball* ball = new Ball(x, y, ofGetWidth(),ofGetHeight());
balls.push_back(ball);
}

//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){


}

//--------------------------------------------------------------
void testApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){

}
Loading