-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a44a289
commit 6cfac83
Showing
14 changed files
with
2,709 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//these are our texture names, set in openFrameworks on the shader object in set up | ||
uniform sampler2DRect image; | ||
void main (void) | ||
{ | ||
//use the color from the image, but use the r channel of the mask as the alpha channel of our output | ||
gl_FragData[0] = texture2DRect(image, gl_TexCoord[0].st); | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
CloudsData/visualsystems/Uextrude/shaders/meshExtrude.vert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
uniform sampler2DRect image; | ||
uniform float extrusionAmount; | ||
|
||
//RGB to brightness needs to be weighted based on our percpetion of value and color. | ||
//Green informs most of what we see as the 'value' of a color, while blue very little | ||
float sampleBrightness(vec3 color){ | ||
vec3 grayWeight = vec3(0.3, 0.59, 0.11); | ||
return dot(grayWeight, color); | ||
} | ||
|
||
void main(void) | ||
{ | ||
//passes the texture coordinates along to the fragment shader | ||
gl_TexCoord[0] = gl_MultiTexCoord0; | ||
|
||
//samples the texture at the vertex location to get a color | ||
float brightness = sampleBrightness( texture2DRect(image, gl_TexCoord[0].st).rgb ); | ||
|
||
//create a new vertex that is the default vertex, plus move the Z along with the brightness | ||
vec4 extrudedVertex = vec4(gl_Vertex.x, | ||
gl_Vertex.y, | ||
gl_Vertex.z + brightness * extrusionAmount, | ||
gl_Vertex.w); | ||
|
||
//position equation that is the same as ftransform() but takes into account our modified vertex | ||
gl_Position = gl_ModelViewProjectionMatrix * extrudedVertex; | ||
} |
191 changes: 191 additions & 0 deletions
191
CloudsLibrary/src/VisualSystems/Uextrude/vs_src/CloudsVisualSystemUextrude.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
// | ||
// CloudsVisualSystemUextrude.cpp | ||
// | ||
|
||
#include "CloudsVisualSystemUextrude.h" | ||
#include "CloudsRGBDVideoPlayer.h" | ||
|
||
//#include "CloudsRGBDVideoPlayer.h" | ||
//#ifdef AVF_PLAYER | ||
//#include "ofxAVFVideoPlayer.h" | ||
//#endif | ||
|
||
//These methods let us add custom GUI parameters and respond to their events | ||
void CloudsVisualSystemUextrude::selfSetupGui(){ | ||
|
||
|
||
} | ||
|
||
void CloudsVisualSystemUextrude::selfGuiEvent(ofxUIEventArgs &e){ | ||
if(e.widget->getName() == "Custom Button"){ | ||
cout << "Button pressed!" << endl; | ||
} | ||
} | ||
|
||
//Use system gui for global or logical settings, for exmpl | ||
void CloudsVisualSystemUextrude::selfSetupSystemGui(){ | ||
|
||
} | ||
|
||
void CloudsVisualSystemUextrude::guiSystemEvent(ofxUIEventArgs &e){ | ||
|
||
} | ||
//use render gui for display settings, like changing colors | ||
void CloudsVisualSystemUextrude::selfSetupRenderGui(){ | ||
|
||
} | ||
|
||
void CloudsVisualSystemUextrude::guiRenderEvent(ofxUIEventArgs &e){ | ||
|
||
} | ||
|
||
// selfSetup is called when the visual system is first instantiated | ||
// This will be called during a "loading" screen, so any big images or | ||
// geometry should be loaded here | ||
void CloudsVisualSystemUextrude::selfSetup(){ | ||
|
||
|
||
//load(getVisualSystemDataPath()+"shaders/city"); | ||
|
||
//someImage.loadImage( getVisualSystemDataPath() + "images/someImage.png"; | ||
|
||
glEnable(GL_DEPTH_TEST); | ||
|
||
ofSetVerticalSync(true); | ||
ofSetFrameRate(60); | ||
|
||
//initialize the video grabber | ||
vidGrabber.initGrabber(640,480); | ||
|
||
//this determines how much we push the meshes out | ||
extrusionAmount = 500.0; | ||
|
||
//store the width and height for convenience | ||
int width = vidGrabber.getWidth(); | ||
int height = vidGrabber.getHeight(); | ||
|
||
//taken right from the MeshDistort example | ||
//except we add texture coords now | ||
for (int y = 0; y < height; y++){ | ||
for (int x = 0; x<width; x++){ | ||
mainMesh.addVertex(ofPoint(x,y,0)); // mesh index = x + y*width | ||
mainMesh.addTexCoord(ofVec2f(x,y)); // lock each vertex to the right texture coordinate | ||
} | ||
} | ||
|
||
for (int y = 0; y<height-1; y++){ | ||
for (int x=0; x<width-1; x++){ | ||
mainMesh.addIndex(x+y*width); // 0 | ||
mainMesh.addIndex((x+1)+y*width); // 1 | ||
mainMesh.addIndex(x+(y+1)*width); // 10 | ||
|
||
mainMesh.addIndex((x+1)+y*width); // 1 | ||
mainMesh.addIndex((x+1)+(y+1)*width); // 11 | ||
mainMesh.addIndex(x+(y+1)*width); // 10 | ||
} | ||
} | ||
|
||
extrudeShader.load(getVisualSystemDataPath() + "shaders/meshExtrude"); | ||
|
||
|
||
} | ||
|
||
// selfPresetLoaded is called whenever a new preset is triggered | ||
// it'll be called right before selfBegin() and you may wish to | ||
// refresh anything that a preset may offset, such as stored colors or particles | ||
void CloudsVisualSystemUextrude::selfPresetLoaded(string presetPath){ | ||
|
||
} | ||
|
||
// selfBegin is called when the system is ready to be shown | ||
// this is a good time to prepare for transitions | ||
// but try to keep it light weight as to not cause stuttering | ||
void CloudsVisualSystemUextrude::selfBegin(){ | ||
|
||
} | ||
|
||
//do things like ofRotate/ofTranslate here | ||
//any type of transformation that doesn't have to do with the camera | ||
void CloudsVisualSystemUextrude::selfSceneTransformation(){ | ||
|
||
} | ||
|
||
//normal update call | ||
void CloudsVisualSystemUextrude::selfUpdate(){ | ||
|
||
vidGrabber.update(); | ||
|
||
} | ||
|
||
// selfDraw draws in 3D using the default ofEasyCamera | ||
// you can change the camera by returning getCameraRef() | ||
void CloudsVisualSystemUextrude::selfDraw(){ | ||
|
||
extrudeShader.begin(); | ||
extrudeShader.setUniformTexture("image", vidGrabber, 0); | ||
extrudeShader.setUniform1f("extrusionAmount", extrusionAmount); | ||
|
||
ofPushMatrix(); | ||
ofTranslate(ofGetWidth()/2- vidGrabber.getWidth()/2, | ||
ofGetHeight()/2-vidGrabber.getHeight()/2); | ||
|
||
mainMesh.drawFaces(); | ||
|
||
ofPopMatrix(); | ||
|
||
extrudeShader.end(); | ||
|
||
|
||
} | ||
|
||
// draw any debug stuff here | ||
void CloudsVisualSystemUextrude::selfDrawDebug(){ | ||
|
||
} | ||
// or you can use selfDrawBackground to do 2D drawings that don't use the 3D camera | ||
void CloudsVisualSystemUextrude::selfDrawBackground(){ | ||
|
||
//turn the background refresh off | ||
//bClearBackground = false; | ||
|
||
} | ||
// this is called when your system is no longer drawing. | ||
// Right after this selfUpdate() and selfDraw() won't be called any more | ||
void CloudsVisualSystemUextrude::selfEnd(){ | ||
|
||
|
||
|
||
} | ||
// this is called when you should clear all the memory and delet anything you made in setup | ||
void CloudsVisualSystemUextrude::selfExit(){ | ||
|
||
} | ||
|
||
//events are called when the system is active | ||
//Feel free to make things interactive for you, and for the user! | ||
void CloudsVisualSystemUextrude::selfKeyPressed(int key){ | ||
|
||
if(key == 'R'){ | ||
extrudeShader.load("meshExtrude"); | ||
} | ||
|
||
} | ||
void CloudsVisualSystemUextrude::selfKeyReleased(ofKeyEventArgs & args){ | ||
|
||
} | ||
|
||
void CloudsVisualSystemUextrude::selfMouseDragged(ofMouseEventArgs& data){ | ||
|
||
} | ||
|
||
void CloudsVisualSystemUextrude::selfMouseMoved(ofMouseEventArgs& data){ | ||
|
||
} | ||
|
||
void CloudsVisualSystemUextrude::selfMousePressed(ofMouseEventArgs& data){ | ||
|
||
} | ||
|
||
void CloudsVisualSystemUextrude::selfMouseReleased(ofMouseEventArgs& data){ | ||
|
||
} |
102 changes: 102 additions & 0 deletions
102
CloudsLibrary/src/VisualSystems/Uextrude/vs_src/CloudsVisualSystemUextrude.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// | ||
// CLOUDS Interactive Documentary | ||
// | ||
// VISUAL SYSTEMS | ||
// | ||
// Welcome to the Uextrude CloudsVisualSystem | ||
// | ||
// | ||
// | ||
|
||
#pragma once | ||
|
||
#include "CloudsVisualSystem.h" | ||
|
||
//TODO: rename this to your own visual system | ||
class CloudsVisualSystemUextrude : public CloudsVisualSystem { | ||
public: | ||
|
||
//TODO: Change this to the name of your visual system | ||
//This determines your data path so name it at first! | ||
//ie getVisualSystemDataPath() uses this | ||
string getSystemName(){ | ||
return "Uextrude"; | ||
} | ||
|
||
//These methods let us add custom GUI parameters and respond to their events | ||
void selfSetupGui(); | ||
void selfGuiEvent(ofxUIEventArgs &e); | ||
|
||
//Use system gui for global or logical settings, for exmpl | ||
void selfSetupSystemGui(); | ||
void guiSystemEvent(ofxUIEventArgs &e); | ||
|
||
//use render gui for display settings, like changing colors | ||
void selfSetupRenderGui(); | ||
void guiRenderEvent(ofxUIEventArgs &e); | ||
|
||
// selfSetup is called when the visual system is first instantiated | ||
// This will be called during a "loading" screen, so any big images or | ||
// geometry should be loaded here | ||
void selfSetup(); | ||
|
||
// selfBegin is called when the system is ready to be shown | ||
// this is a good time to prepare for transitions | ||
// but try to keep it light weight as to not cause stuttering | ||
void selfBegin(); | ||
|
||
// selfPresetLoaded is called whenever a new preset is triggered | ||
// it'll be called right before selfBegin() and you may wish to | ||
// refresh anything that a preset may offset, such as stored colors or particles | ||
void selfPresetLoaded(string presetPath); | ||
|
||
//do things like ofRotate/ofTranslate here | ||
//any type of transformation that doesn't have to do with the camera | ||
void selfSceneTransformation(); | ||
|
||
//normal update call | ||
void selfUpdate(); | ||
|
||
// selfDraw draws in 3D using the default ofEasyCamera | ||
// you can change the camera by returning getCameraRef() | ||
void selfDraw(); | ||
|
||
// draw any debug stuff here | ||
void selfDrawDebug(); | ||
|
||
// or you can use selfDrawBackground to do 2D drawings that don't use the 3D camera | ||
void selfDrawBackground(); | ||
|
||
// this is called when your system is no longer drawing. | ||
// Right after this selfUpdate() and selfDraw() won't be called any more | ||
void selfEnd(); | ||
|
||
// this is called when you should clear all the memory and delet anything you made in setup | ||
void selfExit(); | ||
|
||
//events are called when the system is active | ||
//Feel free to make things interactive for you, and for the user! | ||
void selfKeyPressed(int key); | ||
void selfKeyReleased(ofKeyEventArgs & args); | ||
|
||
void selfMouseDragged(ofMouseEventArgs& data); | ||
void selfMouseMoved(ofMouseEventArgs& data); | ||
void selfMousePressed(ofMouseEventArgs& data); | ||
void selfMouseReleased(ofMouseEventArgs& data); | ||
|
||
|
||
// if you use a custom camera to fly through the scene | ||
// you must implement this method for the transitions to work properly | ||
// ofCamera& getCameraRef(){ | ||
// return myCustomCamera; | ||
// } | ||
|
||
// | ||
|
||
float extrusionAmount; | ||
ofVboMesh mainMesh; | ||
ofVideoGrabber vidGrabber; | ||
ofShader extrudeShader; | ||
|
||
protected: | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.