Skip to content

Instantly share code, notes, and snippets.

View roymacdonald's full-sized avatar

Roy Macdonald roymacdonald

View GitHub Profile
@roymacdonald
roymacdonald / downloadImgsFromJson.sh
Last active August 12, 2020 04:49
call this script from terminal an pass to it the file with the URLs you want to download. One URL per line
#!/bin/bash
if [ $# -eq 0 ];then
echo "Usage:"
echo " downloadImgsFromJson.sh /path/to/json/file"
exit 1
fi
URLS=($(cat "$1" | grep -o "\"original\":.*$" | sed -E "s/\"original\": \"(.*)\"/\1/g" ))

ofEasyCam custom mouse interaction

written by Roy Macdonald

A new feature in openFrameworks 0.10 is that you can customize ofEasyCam's mouse interactions. This allows you to mimic your favorite CAD software or use a configuration that feels better for certain purposes.

2D ortho camera

I like to modify these for 2D interactions in ortho mode. This allows you to easilly navigate your "canvas".

@roymacdonald
roymacdonald / ofApp.cpp
Last active February 4, 2020 19:25
Clotoid curve test (openFrameworks code)
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
gui.setup();
gui.add(T);
gui.add(scale);
gui.add(N);
gui.add(inc.set("Angle Increment", T/(float)N, 0, 0.1));
export PS1="\[\e[1;93m\]\h\[\e[0m\]:\[\e[1;96m\]\w\[\e[0m\] \u\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias randPass="openssl rand -base64 12"
alias findGrep="find . -type f -print0 | xargs -0 grep -C2 --color"
alias findGrepCpp="find . -type f -name "*.h" -or -name "*.hpp" -or -name "*.cpp" -print0 | xargs -0 grep -C2 --color"
alias findGrepMultiline="find . -type f -print0 | xargs -0 pcregrep --color -C2 -M "
alias gss="git status"

The depth test

What is it for

When any geometry gets rendered (remember that even for simply drawing textures you need a geometry to "hold" the texture) it gets drawn on top of what's already been rendered. There are a lot of cases in which this behavior is fine or even desirable, ie. 2D rendering. On the other hand, there are cases in which this behavior might not be what you are looking for, usually when drawing three dimensional objects. For example, you want to draw two spheres that are partially overlapping. Each sphere is a different geometry, so one will get drawn before the other. When the depth test is disabled, one sphere will get drawn on top of the other regardless of its depth - its position in the Z axis-, making it look spatially incorrect. To get the spatially correct looking render what we want to happen is to have drawn only the pixels of the overlapping geometries that have the lowest depth. in order to achieve this is that we use depth testing.

To enable the depth test call

ofEn

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@roymacdonald
roymacdonald / ofApp.h
Last active February 25, 2016 17:50
Testing ofDrawBitmapString bounding box
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
void setup(){
mode = OF_BITMAPMODE_SIMPLE;
clic.set(200,200);
@roymacdonald
roymacdonald / board.svg
Last active September 30, 2015 22:32
Test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@roymacdonald
roymacdonald / ofApp.cpp
Created August 25, 2015 04:19
openframeworks audio pasthrough
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
int bufferSize = 256;
ofSoundStreamSetup(2, 2, this, 44100, bufferSize, 4);
}
@roymacdonald
roymacdonald / main.cpp
Created August 13, 2015 03:36
Test for openFrameworks fix-ofNodeOrbit
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
ofSetupOpenGL(1024,768, OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN