Skip to content

Commit

Permalink
unprotect shader and street shots
Browse files Browse the repository at this point in the history
  • Loading branch information
obviousjim committed Apr 17, 2012
1 parent a1c6b49 commit b808dd7
Show file tree
Hide file tree
Showing 12 changed files with 970 additions and 14 deletions.
1 change: 0 additions & 1 deletion CameraPerspectiveTest/src/testApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ void testApp::draw(){
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(viewMatrix.getPtr());


for(int i = 0; i < nodes.size(); i++){
nodes[i].draw();
}
Expand Down
5 changes: 4 additions & 1 deletion Renderer/bin/data/shaders/unproject.frag
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

varying float debug;
uniform sampler2DRect tex0;

varying vec4 texCdNorm;
void main()
{
vec4 col = texture2DRect(tex0, gl_TexCoord[0].st);
//col = texCdNorm;

col.a = 1.;
//col.rg = gl_TexCoord[0].xy;
gl_FragColor = col * debug;

}
28 changes: 16 additions & 12 deletions Renderer/bin/data/shaders/unproject.vert
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ uniform float dummy;
uniform vec2 dim;
uniform vec2 fudge;
varying float debug;
varying vec4 texCdNorm;

void main(void)
{
debug = 1.;
mat4 tTex = gl_TextureMatrix[0];
gl_Position = ftransform();
vec4 object = gl_Vertex;
vec4 texCd = object * tTex;
texCd.w /= 1.;
debug = 1.;

texCd.xy /= dim / 2.;
texCd.y *= 2.0;
// texCd.xy += fudge;
texCd.xy += vec2(0.0, .22);
texCd.xy += 1.;
texCd.xy /= 2.;
texCd.z = 0.;
texCd.xy *= dim;
vec4 withinRGB = tTex *object;
withinRGB.rgb /= withinRGB.w;

withinRGB.xy += 1.;
withinRGB.xy /= 2.;
withinRGB.y = 1. - withinRGB.y;
withinRGB.xy += vec2(0, .043);

//debug = -tTex[3][2] > 20. ? 1. : 0.;
vec4 texCd = vec4(0.);
texCdNorm = withinRGB;
texCd.xy = texCdNorm.xy * dim;

gl_TexCoord[0] = texCd;
}
}
1 change: 1 addition & 0 deletions Renderer/src/testApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void testApp::setup(){
newPortrait.setup(type, portraitMediaBin+compositionMediaBin, soundDirectory+soundFile);
portraits.popTag();//portrait


allPortraits.push_back( newPortrait );
}
portraits.popTag(); //portraits
Expand Down
9 changes: 9 additions & 0 deletions StreetShots/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)
645 changes: 645 additions & 0 deletions StreetShots/StreetShots.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Empty file added StreetShots/bin/data/.gitkeep
Empty file.
32 changes: 32 additions & 0 deletions StreetShots/bin/data/playlist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<takesfolder>/Users/focus/Desktop/__RGBD_Bins/_manchester_night_out/takes</takesfolder>
<take>
<folder>G_TAKE_04_15_00_41_09_PoleWalk1</folder>
<intime>51797</intime>
<outtime>219600</outtime>
<soundfile />
</take>
<take>
<folder>G_TAKE_04_15_00_48_14_PeopleWalk</folder>
<intime />
<outtime />
<soundfile />
</take>
<!--
<take>
<folder>G_TAKE_04_15_00_55_17_Car</take>
<take>G_TAKE_04_15_00_55_53_Cars</take>
<take>G_TAKE_04_15_00_59_24_Printworks</take>
<take>G_TAKE_04_15_01_02_00_TrainFewPeople</take>
<take>G_TAKE_04_15_01_02_33_no_one</take>
<take>G_TAKE_04_15_01_11_14_park</take>
-->
<!--
<take>
<folder>G_TAKE_04_15_00_48_14_PeopleWalk</folder>
<intime></intime>
<outtime></outtime>
<soundfile></soundfile>
</take>
-->
20 changes: 20 additions & 0 deletions StreetShots/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>
10 changes: 10 additions & 0 deletions StreetShots/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "testApp.h"
#include "ofAppGlutWindow.h"

//--------------------------------------------------------------
int main(){
ofAppGlutWindow window; // create a window
// set width, height, mode (OF_WINDOW or OF_FULLSCREEN)
ofSetupOpenGL(&window, 1024, 768, OF_WINDOW);
ofRunApp(new testApp()); // start the app
}
187 changes: 187 additions & 0 deletions StreetShots/src/testApp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#include "testApp.h"
#include "ofxXmlSettings.h"

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

ofSetFrameRate(60);
ofBackground(0);

scrubMode = false;
if(!playlist.loadFile("playlist.xml")){
ofLogError("Error loading playlist xml");
}
string takesfolder = playlist.getValue("takesfolder", "");
cout << "takes folder " << takesfolder << endl;
int numTakes = playlist.getNumTags("take");
for(int i = 0; i < numTakes; i++){
StreetTake take;
take.xmlIndex = i;
playlist.pushTag("take", i);
take.path = ofToDataPath(takesfolder + "/" + playlist.getValue("folder", ""));
take.images.loadSequence( take.path );
take.intime = playlist.getValue("intime", 0);
take.outtime = playlist.getValue("outtime", int(take.images.getDurationInMillis()));
take.soundFile = playlist.getValue("soundFile", "");

playlist.popTag();
sequences.push_back(take);
}
currentTake = 0;

cam.setup();
cam.usemouse = true;
cam.autosavePosition;
cam.loadCameraPosition();
cam.speed = 5;

startTime = ofGetElapsedTimeMillis();
}

//--------------------------------------------------------------
void testApp::update(){
if(scrubMode){
long time = ofMap(mouseX, 0, ofGetWidth(), 0, sequences[currentTake].images.getDurationInMillis(), true);
sequences[currentTake].images.selectTime(time);
}
}

//--------------------------------------------------------------
void testApp::draw(){
drawPointcloud();
if(scrubMode){
ofSetColor(255);
ofDrawBitmapString("Current Path " + sequences[currentTake].path, 50, 50);
}
else{
long currentMillis = ofGetElapsedTimeMillis() - startTime + sequences[currentTake].intime;
if(currentMillis < sequences[currentTake].outtime){
sequences[currentTake].images.selectTime(currentMillis);
}
else {
nextTake();
}
}
}

void testApp::drawPointcloud(){

ofShortPixels& pix = sequences[currentTake].images.getPixels();

glEnable(GL_DEPTH_TEST);
ofMesh mesh;
ofRectangle rect = ofRectangle(0,0, ofGetWidth(), ofGetHeight());
//glEnable(GL_POINT_SMOOTH);
//glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB); // allows per-point size
glPointSize(2);

for(int y = 0; y < 480; y++){
for(int x = 0; x < 640; x++){
//0.104200 ref dist 120.000000
double ref_pix_size = 0.104200;
double ref_distance = 120.000000;
double wz = pix.getPixels()[y*640+x];
double factor = 2 * ref_pix_size * wz / ref_distance;
double wx = (double)(x - 640/2) * factor;
double wy = (double)(y - 480/2) * factor;
mesh.addVertex(ofVec3f(wx,-wy,-wz));
}
}

cam.begin(rect);
mesh.drawVertices();
cam.end();

glDisable(GL_DEPTH_TEST);

}

//--------------------------------------------------------------
void testApp::keyPressed(int key){
if(key == ' '){
scrubMode = !scrubMode;
if(!scrubMode){
startTime = ofGetElapsedTimeMillis();
}
}
if(scrubMode && key == '['){
long time = ofMap(mouseX, 0, ofGetWidth(), 0, sequences[currentTake].images.getDurationInMillis(), true);
playlist.pushTag("take",sequences[currentTake].xmlIndex);
playlist.setValue("intime", int(time));
playlist.popTag();
playlist.saveFile();
cout << "set in to " << time << endl;
}
if(scrubMode && key == ']'){
long time = ofMap(mouseX, 0, ofGetWidth(), 0, sequences[currentTake].images.getDurationInMillis(), true);
playlist.pushTag("take",sequences[currentTake].xmlIndex);
playlist.setValue("outtime", int(time));
playlist.popTag();
playlist.saveFile();

cout << "set out to " << time << endl;
}

if(scrubMode && key == OF_KEY_LEFT){
nextTake();
}
if(scrubMode && key == OF_KEY_RIGHT){
previousTake();
}

if(key == 'f'){
ofToggleFullscreen();
}
}

void testApp::nextTake(){
currentTake = (currentTake + 1) % sequences.size();
}

void testApp::previousTake(){
currentTake--;
if(currentTake < 0){
currentTake = sequences.size()-1;
}

}

//--------------------------------------------------------------
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){

}

//--------------------------------------------------------------
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){

}
46 changes: 46 additions & 0 deletions StreetShots/src/testApp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include "ofMain.h"
#include "ofxDepthImageSequence.h"
#include "ofxGameCamera.h"

typedef struct {
ofxDepthImageSequence images;
long intime;
long outtime;
string soundFile;
int xmlIndex;
string path;
} StreetTake;

class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();

void keyPressed(int key);
void keyReleased(int key);
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);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);

void nextTake();
void previousTake();

bool scrubMode;
void drawPointcloud();

//vector<ofxDepthImageSequence> sequences;
vector<StreetTake> sequences;
int currentTake;
ofSoundPlayer player;
ofxXmlSettings playlist;

long startTime;
ofxGameCamera cam;
};

0 comments on commit b808dd7

Please sign in to comment.