Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e4ab292347 | |||
| 7e422dca80 |
+2
-1
@@ -1 +1,2 @@
|
|||||||
.DS_Store
|
|
||||||
|
src/.DS_Store
|
||||||
|
|||||||
+67
-106
@@ -1,115 +1,76 @@
|
|||||||
<!-- THIS FILE NEEDS TO GO IN THE APPLICATION /data/ folder -->
|
<!-- THIS FILE NEEDS TO GO IN THE APPLICATION /data/ folder -->
|
||||||
|
|
||||||
<config>
|
<config>
|
||||||
<mode>analysing</mode>
|
<mode>analysis</mode>
|
||||||
<camera>
|
|
||||||
<id>1</id>
|
|
||||||
<width>640</width>
|
|
||||||
<height>480</height>
|
|
||||||
</camera>
|
|
||||||
<display>
|
|
||||||
<fps>30</fps>
|
|
||||||
</display>
|
|
||||||
<locale>
|
|
||||||
<name>FUTURE</name>
|
|
||||||
</locale>
|
|
||||||
|
|
||||||
<analysis_NUM_RUN>
|
<camera>
|
||||||
<NUM_RUN_shadowscapes> 1 </NUM_RUN_shadowscapes>
|
<id>1</id>
|
||||||
<NUM_RUN_relaxrate> 1 </NUM_RUN_relaxrate>
|
<width>640</width>
|
||||||
<NUM_RUN_iresponse> 1 </NUM_RUN_iresponse>
|
<height>480</height>
|
||||||
<NUM_RUN_shapefromshading> 1 </NUM_RUN_shapefromshading>
|
</camera>
|
||||||
<NUM_RUN_strobe> 1 </NUM_RUN_strobe>
|
|
||||||
<NUM_RUN_camnoise> 1 </NUM_RUN_camnoise>
|
|
||||||
<NUM_RUN_colorsingle> 1 </NUM_RUN_colorsingle>
|
|
||||||
<NUM_RUN_colormulti> 1 </NUM_RUN_colormulti>
|
|
||||||
<NUM_RUN_diffnoise> 1 </NUM_RUN_diffnoise>
|
|
||||||
</analysis_NUM_RUN>
|
|
||||||
|
|
||||||
<analysis_time>
|
<display>
|
||||||
<acquiretime_shadowscapes> 5 </acquiretime_shadowscapes>
|
<fps>30</fps>
|
||||||
<acquiretime_relaxrate> 5 </acquiretime_relaxrate>
|
</display>
|
||||||
<acquiretime_iresponse> 5 </acquiretime_iresponse>
|
|
||||||
<acquiretime_shapefromshading> 5 </acquiretime_shapefromshading>
|
<locale>
|
||||||
<acquiretime_strobe> 5 </acquiretime_strobe>
|
<name>FUTURE</name>
|
||||||
<acquiretime_camnoise> 5 </acquiretime_camnoise>
|
</locale>
|
||||||
<acquiretime_colorsingle> 5 </acquiretime_colorsingle>
|
|
||||||
<acquiretime_colormulti> 5 </acquiretime_colormulti>
|
<analysis_NUM_RUN>
|
||||||
<acquiretime_diffnoise> 5 </acquiretime_diffnoise>
|
<NUM_RUN_shadowscapes> 1 </NUM_RUN_shadowscapes>
|
||||||
</analysis_time>
|
<NUM_RUN_relaxrate> 1 </NUM_RUN_relaxrate>
|
||||||
|
<NUM_RUN_iresponse> 1 </NUM_RUN_iresponse>
|
||||||
|
<NUM_RUN_shapefromshading> 1 </NUM_RUN_shapefromshading>
|
||||||
|
<NUM_RUN_strobe> 1 </NUM_RUN_strobe>
|
||||||
|
<NUM_RUN_camnoise> 1 </NUM_RUN_camnoise>
|
||||||
|
<NUM_RUN_colorsingle> 1 </NUM_RUN_colorsingle>
|
||||||
|
<NUM_RUN_colormulti> 1 </NUM_RUN_colormulti>
|
||||||
|
<NUM_RUN_diffnoise> 1 </NUM_RUN_diffnoise>
|
||||||
|
</analysis_NUM_RUN>
|
||||||
|
|
||||||
|
<analysis_time>
|
||||||
|
<acquiretime_shadowscapes> 7 </acquiretime_shadowscapes>
|
||||||
|
<acquiretime_relaxrate> 10 </acquiretime_relaxrate>
|
||||||
|
<acquiretime_iresponse> 30 </acquiretime_iresponse>
|
||||||
|
<acquiretime_shapefromshading> 30 </acquiretime_shapefromshading>
|
||||||
|
<acquiretime_strobe> 30 </acquiretime_strobe>
|
||||||
|
<acquiretime_camnoise> 30 </acquiretime_camnoise>
|
||||||
|
<acquiretime_colorsingle> 40 </acquiretime_colorsingle>
|
||||||
|
<acquiretime_colormulti> 15 </acquiretime_colormulti>
|
||||||
|
<acquiretime_diffnoise> 30 </acquiretime_diffnoise>
|
||||||
|
</analysis_time>
|
||||||
|
|
||||||
|
<algorithms>
|
||||||
|
<vertices_per_frame>1000</vertices_per_frame>
|
||||||
|
<pixel_per_vertex>4</pixel_per_vertex>
|
||||||
|
|
||||||
<viewport>
|
<colormulti>
|
||||||
<tx>0</tx>
|
<algo>2</algo>
|
||||||
<ty>-20</ty>
|
<scale>2</scale>
|
||||||
<tz>-400</tz>
|
<draw_style>3</draw_style>
|
||||||
<rx>-10</rx>
|
<line_width>2</line_width>
|
||||||
<ry>0</ry>
|
</colormulti>
|
||||||
<rz>0</rz>
|
|
||||||
</viewport>
|
|
||||||
|
|
||||||
<algorithms>
|
<relaxrate>
|
||||||
<vertices_per_frame>1000</vertices_per_frame>
|
<algo>4</algo>
|
||||||
<pixel_per_vertex>4</pixel_per_vertex>
|
<scale>600</scale>
|
||||||
<colormulti>
|
<draw_style>2</draw_style>
|
||||||
<algo>2</algo>
|
<line_width>4</line_width>
|
||||||
<scale>1</scale>
|
</relaxrate>
|
||||||
<draw_style>2</draw_style>
|
|
||||||
<line_width>0.5</line_width>
|
|
||||||
</colormulti>
|
|
||||||
<colorsingle>
|
|
||||||
<algo>2</algo>
|
|
||||||
<scale>1</scale>
|
|
||||||
<draw_style>2</draw_style>
|
|
||||||
<line_width>0.5</line_width>
|
|
||||||
</colorsingle>
|
|
||||||
<relaxrate>
|
|
||||||
<algo>1</algo>
|
|
||||||
<scale>500</scale>
|
|
||||||
<draw_style>1</draw_style>
|
|
||||||
<line_width>2</line_width>
|
|
||||||
<point_size>2</point_size>
|
|
||||||
</relaxrate>
|
|
||||||
<diffnoise>
|
|
||||||
<algo>1</algo>
|
|
||||||
<scale>500</scale>
|
|
||||||
<draw_style>1</draw_style>
|
|
||||||
<line_width>2</line_width>
|
|
||||||
<point_size>2</point_size>
|
|
||||||
</diffnoise>
|
|
||||||
<shapeshade>
|
|
||||||
<algo>1</algo>
|
|
||||||
<scale>500</scale>
|
|
||||||
<draw_style>1</draw_style>
|
|
||||||
<line_width>2</line_width>
|
|
||||||
<point_size>2</point_size>
|
|
||||||
</shapeshade>
|
|
||||||
<strobe>
|
|
||||||
<algo>1</algo>
|
|
||||||
<scale>500</scale>
|
|
||||||
<draw_style>1</draw_style>
|
|
||||||
<line_width>2</line_width>
|
|
||||||
<point_size>2</point_size>
|
|
||||||
</strobe>
|
|
||||||
<camnoise>
|
|
||||||
<algo>1</algo>
|
|
||||||
<scale>500</scale>
|
|
||||||
<draw_style>1</draw_style>
|
|
||||||
<line_width>2</line_width>
|
|
||||||
<point_size>2</point_size>
|
|
||||||
</camnoise>
|
|
||||||
<shadowscapes>
|
|
||||||
<algo>4</algo>
|
|
||||||
<scale>500</scale>
|
|
||||||
<draw_style>2</draw_style>
|
|
||||||
<line_width>2</line_width>
|
|
||||||
</shadowscapes>
|
|
||||||
<iresponse>
|
|
||||||
<algo>1</algo>
|
|
||||||
<scale>500</scale>
|
|
||||||
<draw_style>1</draw_style>
|
|
||||||
<line_width>2</line_width>
|
|
||||||
<point_size>2</point_size>
|
|
||||||
</iresponse>
|
|
||||||
</algorithms>
|
|
||||||
|
|
||||||
|
<shadowscapes>
|
||||||
|
<algo>1</algo>
|
||||||
|
<scale>650</scale>
|
||||||
|
<draw_style>1</draw_style>
|
||||||
|
<line_width>1</line_width>
|
||||||
|
</shadowscapes>
|
||||||
|
|
||||||
|
</algorithms>
|
||||||
|
|
||||||
|
<relaxrate>
|
||||||
|
<treshold>51</treshold>
|
||||||
|
<maxblobs>25</maxblobs>
|
||||||
|
</relaxrate>
|
||||||
|
|
||||||
</config>
|
</config>
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<!-- THIS FILE NEEDS TO GO IN THE APPLICATION /data/ folder -->
|
|
||||||
|
|
||||||
<config>
|
|
||||||
<display>
|
|
||||||
<fps>30</fps>
|
|
||||||
</display>
|
|
||||||
<locale>
|
|
||||||
<name>DRAWING</name>
|
|
||||||
</locale>
|
|
||||||
|
|
||||||
<viewport>
|
|
||||||
<tx>0</tx>
|
|
||||||
<ty>-0</ty>
|
|
||||||
<tz>-0</tz>
|
|
||||||
<rx>0</rx>
|
|
||||||
<ry>0</ry>
|
|
||||||
<rz>0</rz>
|
|
||||||
</viewport>
|
|
||||||
|
|
||||||
<renderer>
|
|
||||||
<edit>true</edit>
|
|
||||||
<vertices_per_frame>1000</vertices_per_frame>
|
|
||||||
<pixel_per_vertex>1</pixel_per_vertex>
|
|
||||||
<algorithm>
|
|
||||||
<algo>3</algo>
|
|
||||||
<scale>0.71</scale>
|
|
||||||
<draw_style>3</draw_style>
|
|
||||||
<line_width>0.1</line_width>
|
|
||||||
</algorithm>
|
|
||||||
</renderer>
|
|
||||||
</config>
|
|
||||||
@@ -64,7 +64,7 @@ ofxXmlSettings RefractiveIndex::XML;
|
|||||||
ofShader RefractiveIndex::_shader;
|
ofShader RefractiveIndex::_shader;
|
||||||
ofVboMesh RefractiveIndex::_mesh_vbo;
|
ofVboMesh RefractiveIndex::_mesh_vbo;
|
||||||
|
|
||||||
ofxArcBall RefractiveIndex::cam;
|
//ofxArcBall RefractiveIndex::cam;
|
||||||
|
|
||||||
string msg;
|
string msg;
|
||||||
|
|
||||||
|
|||||||
@@ -1,320 +0,0 @@
|
|||||||
/*
|
|
||||||
RefractiveIndexRenderer.cpp - RefractiveIndexRenderer library
|
|
||||||
Copyright (c) 2013 Copenhagen Institute of Interaction Design.
|
|
||||||
All right reserved.
|
|
||||||
|
|
||||||
This library is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Lesser Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser Public License
|
|
||||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
+ author: dviid
|
|
||||||
+ contact: dviid@labs.ciid.dk
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "RefractiveIndexRenderer.h"
|
|
||||||
|
|
||||||
// of
|
|
||||||
#include "ofSystemUtils.h"
|
|
||||||
|
|
||||||
// of addons
|
|
||||||
#include "ofxFileHelper.h"
|
|
||||||
|
|
||||||
const int VPF = 1000;
|
|
||||||
const int PPV = 4;
|
|
||||||
|
|
||||||
int W = 1280, INPUT_W = 0, H = 800, INPUT_H = 0, SIZE = 0;
|
|
||||||
|
|
||||||
bool killnow = false;
|
|
||||||
bool go = false;
|
|
||||||
bool edit = false;
|
|
||||||
|
|
||||||
ofTrueTypeFont font;
|
|
||||||
ofImage image;
|
|
||||||
|
|
||||||
const int algo_default = 1;
|
|
||||||
const float scale_default = 1;
|
|
||||||
const int draw_style_default = 3;
|
|
||||||
const int line_width_default = 0.5f;
|
|
||||||
const float point_size_default = 0.5f;
|
|
||||||
|
|
||||||
//viewport
|
|
||||||
float tx, ty, tz, rx, ry, rz;
|
|
||||||
|
|
||||||
|
|
||||||
void RefractiveIndexRenderer::setup(){
|
|
||||||
|
|
||||||
ofSetLogLevel(OF_LOG_VERBOSE);
|
|
||||||
|
|
||||||
cout << "Loading configuration..." << endl;
|
|
||||||
if(!XML.loadFile("config.renderer.refindx")) {
|
|
||||||
ofLog(OF_LOG_ERROR) << "error loading config - using defaults.";
|
|
||||||
}
|
|
||||||
|
|
||||||
string e = XML.getValue("config:renderer:edit", "false");
|
|
||||||
edit = (e == "true");
|
|
||||||
|
|
||||||
if(!setup_dirs())
|
|
||||||
exit();
|
|
||||||
|
|
||||||
if(_images_directory_filenames.size() == 0)
|
|
||||||
exit();
|
|
||||||
|
|
||||||
SIZE = _images_directory_filenames.size();
|
|
||||||
go = true;
|
|
||||||
|
|
||||||
// we assume all files from the images dir are the same size
|
|
||||||
|
|
||||||
string sample = _images_directory_filenames[(int)ofRandom(0, _images_directory_filenames.size() -1)];
|
|
||||||
if(!image.loadImage(sample))
|
|
||||||
exit();
|
|
||||||
INPUT_W = image.getWidth();
|
|
||||||
INPUT_H = image.getHeight();
|
|
||||||
|
|
||||||
// allocate pixels data
|
|
||||||
_pixels.allocate(W, H, OF_IMAGE_COLOR);
|
|
||||||
|
|
||||||
// allocate FBO
|
|
||||||
_fbo.allocate(W, H, GL_RGB);
|
|
||||||
|
|
||||||
// allocate VBO
|
|
||||||
setup_vbo(W, H);
|
|
||||||
|
|
||||||
// create shader
|
|
||||||
setup_shader();
|
|
||||||
|
|
||||||
// set index count (progess in rendering + saving images from FBO to drawing/ files)
|
|
||||||
_indx = 0;
|
|
||||||
|
|
||||||
// set load font
|
|
||||||
font.loadFont("/System/Library/Fonts/Geneva.dfont", 16);
|
|
||||||
|
|
||||||
algo = XML.getValue("config:renderer:algorithm:algo", algo_default);
|
|
||||||
scale = XML.getValue("config:renderer:algorithm:scale", scale_default);
|
|
||||||
draw_style = XML.getValue("config:renderer:algorithm:draw_style", draw_style_default);
|
|
||||||
line_width = XML.getValue("config:renderer:algorithm:line_width", line_width_default);
|
|
||||||
point_size = XML.getValue("config:renderer:algorithm:point_size", point_size_default);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
void RefractiveIndexRenderer::update(){
|
|
||||||
if(killnow)
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
void RefractiveIndexRenderer::draw(){
|
|
||||||
|
|
||||||
static bool done = false;
|
|
||||||
|
|
||||||
if(!go) return;
|
|
||||||
|
|
||||||
if(!edit) {
|
|
||||||
char str[255];
|
|
||||||
sprintf(str, "%s \n input: %s\n output: %s \n at: %i \n total: %i", (done ? "Done!" : "Rendering"),_images_directory.c_str(), _draw_directory.c_str(), _indx, SIZE);
|
|
||||||
font.drawString(str, 10, 50);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(done) return;
|
|
||||||
|
|
||||||
if(_indx >= _images_directory_filenames.size()) {
|
|
||||||
if(!edit) {
|
|
||||||
done = true;
|
|
||||||
image.clear();
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
_indx = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear previous image
|
|
||||||
image.clear();
|
|
||||||
|
|
||||||
// load new image to render
|
|
||||||
image.loadImage(_images_directory_filenames[_indx++]);
|
|
||||||
image.resize(W, H);
|
|
||||||
|
|
||||||
// bind FBO
|
|
||||||
_fbo.begin();
|
|
||||||
|
|
||||||
// camera
|
|
||||||
_cam.begin();
|
|
||||||
|
|
||||||
// GL
|
|
||||||
//ofEnableAlphaBlending();
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
glLineWidth(line_width);
|
|
||||||
glPointSize(point_size);
|
|
||||||
glEnable(GL_POINT_SMOOTH);
|
|
||||||
|
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
|
||||||
ofRotateX(rx+1.5*cos(ofGetElapsedTimef())); ofRotateY(ry+1.5*sin(ofGetElapsedTimef())); ofRotateZ(rz);
|
|
||||||
//ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
|
||||||
glScalef(1.5, 1, 1);
|
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
|
|
||||||
// bind texture
|
|
||||||
image.bind();
|
|
||||||
|
|
||||||
// bind shader
|
|
||||||
_shader.begin();
|
|
||||||
_shader.setUniform1i("algo", algo);
|
|
||||||
_shader.setUniform1f("scale", scale);
|
|
||||||
_shader.setUniform1i("tex0", 0);
|
|
||||||
|
|
||||||
// VBO draw
|
|
||||||
switch (draw_style) {
|
|
||||||
case VERTS:
|
|
||||||
_mesh_vbo.drawVertices();
|
|
||||||
break;
|
|
||||||
case WIRE:
|
|
||||||
_mesh_vbo.drawWireframe();
|
|
||||||
break;
|
|
||||||
case FACE:
|
|
||||||
_mesh_vbo.drawFaces();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unbind shader
|
|
||||||
_shader.end();
|
|
||||||
|
|
||||||
// unbind texture
|
|
||||||
image.unbind();
|
|
||||||
|
|
||||||
_cam.end();
|
|
||||||
|
|
||||||
// unbind FBO
|
|
||||||
_fbo.end();
|
|
||||||
|
|
||||||
if(edit) {
|
|
||||||
_fbo.draw(0, 0);
|
|
||||||
} else {
|
|
||||||
std::stringstream s;
|
|
||||||
s << _indx;
|
|
||||||
save(_draw_directory + "/" + s.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
void RefractiveIndexRenderer::exit(){
|
|
||||||
ofLog(OF_LOG_ERROR) << "exit...";
|
|
||||||
}
|
|
||||||
void RefractiveIndexRenderer::keyPressed (int key){
|
|
||||||
if( key =='e'){
|
|
||||||
edit = !edit;
|
|
||||||
_indx = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool file_cmp(string f0, string f1)
|
|
||||||
{
|
|
||||||
int v0 = atoi(f0.substr(0, f0.find("_")).c_str());
|
|
||||||
int v1 = atoi(f1.substr(0, f1.find("_")).c_str());
|
|
||||||
return v0 < v1;
|
|
||||||
}
|
|
||||||
bool RefractiveIndexRenderer::setup_dirs(){
|
|
||||||
|
|
||||||
// ask for a directory
|
|
||||||
ofFileDialogResult r = ofSystemLoadDialog("choooose da folda", true);
|
|
||||||
if(!r.bSuccess) {
|
|
||||||
ofSystemAlertDialog("OOOOPS.... ERROR...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy names
|
|
||||||
_images_directory = r.filePath;
|
|
||||||
_draw_directory = r.filePath + "/darwings";
|
|
||||||
|
|
||||||
// list all images in the directory and save into vector
|
|
||||||
File dir(_images_directory);
|
|
||||||
|
|
||||||
if(dir.exists() && dir.isDirectory()) {
|
|
||||||
vector<string> list;
|
|
||||||
dir.list(list);
|
|
||||||
|
|
||||||
std::sort(list.begin(), list.end(), file_cmp);
|
|
||||||
|
|
||||||
for(int i = 0; i < list.size(); i++) {
|
|
||||||
string filepath = _images_directory + "/" + list[i];
|
|
||||||
_images_directory_filenames.push_back(filepath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create drawing directory
|
|
||||||
if(!ofxFileHelper::doesDirectoryExist(_draw_directory))
|
|
||||||
ofxFileHelper::makeDirectory(_draw_directory);
|
|
||||||
|
|
||||||
}
|
|
||||||
void RefractiveIndexRenderer::setup_vbo(int img_width, int img_height){
|
|
||||||
|
|
||||||
int vertices_per_frame = XML.getValue("config:renderer:vertices_per_frame", VPF);
|
|
||||||
int pixel_per_vertex = XML.getValue("config:renderer:pixel_per_vertex", PPV);
|
|
||||||
|
|
||||||
int vertices_X = img_width / pixel_per_vertex, vertices_Y = img_height / pixel_per_vertex;
|
|
||||||
|
|
||||||
// VBO
|
|
||||||
for(int i = 0; i < vertices_X; i++){
|
|
||||||
for(int j = 0; j < vertices_Y; j++) {
|
|
||||||
_verts.push_back(ofVec3f((i / (float)vertices_X) * vertices_per_frame, (j / (float) vertices_Y) * vertices_per_frame, 0.0f));
|
|
||||||
_tex.push_back(ofVec2f(i / (float)vertices_X * img_width, j / (float) vertices_Y * img_height));
|
|
||||||
//_tex.push_back(ofVec2f(i * pixel_per_vertex, j * pixel_per_vertex));
|
|
||||||
if( ( i + 1 < vertices_X ) && ( j + 1 < vertices_Y ) ) {
|
|
||||||
//triangle #1
|
|
||||||
_ind.push_back( (i+0) * vertices_Y + (j+0) );
|
|
||||||
_ind.push_back( (i+1) * vertices_Y + (j+0) );
|
|
||||||
_ind.push_back( (i+1) * vertices_Y + (j+1) );
|
|
||||||
|
|
||||||
//triangle #2
|
|
||||||
_ind.push_back( (i+1) * vertices_Y + (j+1) );
|
|
||||||
_ind.push_back( (i+0) * vertices_Y + (j+1) );
|
|
||||||
_ind.push_back( (i+0) * vertices_Y + (j+0) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//ofEnableNormalizedTexCoords();
|
|
||||||
|
|
||||||
_mesh_vbo.addVertices(_verts);
|
|
||||||
_mesh_vbo.addTexCoords(_tex);
|
|
||||||
_mesh_vbo.addIndices(_ind);
|
|
||||||
|
|
||||||
_mesh_vbo.setMode(OF_PRIMITIVE_TRIANGLES);
|
|
||||||
|
|
||||||
}
|
|
||||||
void RefractiveIndexRenderer::setup_shader(){
|
|
||||||
|
|
||||||
// TODO: INTEGRATE JAMIE CODE
|
|
||||||
/*
|
|
||||||
_shader.setGeometryOutputCount(3);
|
|
||||||
_shader.load("rfi.vert", "rfi.frag", "rfi.geom");
|
|
||||||
_shader.setGeometryInputType(GL_TRIANGLES);
|
|
||||||
_shader.setGeometryOutputType(GL_TRIANGLES);
|
|
||||||
*/
|
|
||||||
_shader.setGeometryOutputCount(3);
|
|
||||||
_shader.load("dviid/rfi.vert.glsl", "dviid/rfi.frag.glsl", "dviid/rfi.geom.glsl");
|
|
||||||
_shader.setGeometryInputType(GL_TRIANGLES);
|
|
||||||
_shader.setGeometryOutputType(GL_TRIANGLES);
|
|
||||||
|
|
||||||
printf("Maximum number of output vertices support is: %i\n", _shader.getGeometryMaxOutputCount());
|
|
||||||
|
|
||||||
}
|
|
||||||
void RefractiveIndexRenderer::save(string filename){
|
|
||||||
|
|
||||||
// clear pixels
|
|
||||||
_pixels.clear();
|
|
||||||
|
|
||||||
// copy fbo pixels to of pixels
|
|
||||||
_fbo.readToPixels(_pixels);
|
|
||||||
|
|
||||||
// save pixels
|
|
||||||
ofSaveImage(_pixels, filename+".jpg", OF_IMAGE_QUALITY_BEST);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
RefractiveIndexRenderer.h - RefractiveIndexRenderer library
|
|
||||||
Copyright (c) 2012 Copenhagen Institute of Interaction Design.
|
|
||||||
All right reserved.
|
|
||||||
|
|
||||||
This library is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Lesser Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser Public License
|
|
||||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
+ author: dviid
|
|
||||||
+ contact: dviid@labs.ciid.dk
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// of
|
|
||||||
#include "ofMain.h"
|
|
||||||
#include "ofEvents.h"
|
|
||||||
|
|
||||||
// of addons
|
|
||||||
#include "ofxXmlSettings.h"
|
|
||||||
#include "ofxArcBall.h"
|
|
||||||
|
|
||||||
#define VERTS 1
|
|
||||||
#define WIRE 2
|
|
||||||
#define FACE 3
|
|
||||||
|
|
||||||
class RefractiveIndexRenderer : public ofBaseApp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
// of
|
|
||||||
void setup();
|
|
||||||
void update();
|
|
||||||
void draw();
|
|
||||||
void exit();
|
|
||||||
void keyPressed (int key);
|
|
||||||
|
|
||||||
bool setup_dirs();
|
|
||||||
void setup_vbo(int img_width, int img_height);
|
|
||||||
void setup_shader();
|
|
||||||
|
|
||||||
void save(string filename);
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ofVboMesh _mesh_vbo;
|
|
||||||
vector<ofVec3f> _verts;
|
|
||||||
vector<ofVec2f> _tex;
|
|
||||||
vector<unsigned int> _ind;
|
|
||||||
|
|
||||||
ofShader _shader;
|
|
||||||
ofPixels _pixels;
|
|
||||||
ofFbo _fbo;
|
|
||||||
int _indx;
|
|
||||||
|
|
||||||
ofxXmlSettings XML;
|
|
||||||
|
|
||||||
string _images_directory;
|
|
||||||
string _draw_directory;
|
|
||||||
vector<string> _images_directory_filenames;
|
|
||||||
|
|
||||||
int algo;
|
|
||||||
float scale;
|
|
||||||
int draw_style;
|
|
||||||
float line_width;
|
|
||||||
float point_size;
|
|
||||||
|
|
||||||
ofxArcBall _cam;
|
|
||||||
|
|
||||||
};
|
|
||||||
+3
-6
@@ -1,9 +1,8 @@
|
|||||||
#include "ofAppGlutWindow.h"
|
#include "ofAppGlutWindow.h"
|
||||||
#include "RefractiveIndex.h"
|
#include "RefractiveIndex.h"
|
||||||
#include "RefractiveIndexRenderer.h"
|
|
||||||
|
|
||||||
#define SCREEN_WIDTH 1280
|
#define SCREEN_WIDTH 800
|
||||||
#define SCREEN_HEIGHT 800
|
#define SCREEN_HEIGHT 600
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
@@ -23,8 +22,6 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ofSetupOpenGL(&window, SCREEN_WIDTH, SCREEN_HEIGHT, (fullscreen ? OF_FULLSCREEN : OF_WINDOW));
|
ofSetupOpenGL(&window, SCREEN_WIDTH, SCREEN_HEIGHT, (fullscreen ? OF_FULLSCREEN : OF_WINDOW));
|
||||||
//ofRunApp(new RefractiveIndex());
|
ofRunApp(new RefractiveIndex());
|
||||||
ofRunApp(new RefractiveIndexRenderer());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ void CamNoiseAnalysis::draw()
|
|||||||
glPointSize(point_size);
|
glPointSize(point_size);
|
||||||
glEnable(GL_POINT_SMOOTH);
|
glEnable(GL_POINT_SMOOTH);
|
||||||
|
|
||||||
RefractiveIndex::cam.begin();
|
//RefractiveIndex::cam.begin();
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
ofTranslate(tx, ty, tz);
|
||||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||||
@@ -355,7 +355,7 @@ void CamNoiseAnalysis::draw()
|
|||||||
|
|
||||||
image2.unbind();
|
image2.unbind();
|
||||||
|
|
||||||
RefractiveIndex::cam.end();
|
//RefractiveIndex::cam.end();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ void ColorMultiAnalysis::draw()
|
|||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
glLineWidth(line_width);
|
glLineWidth(line_width);
|
||||||
|
|
||||||
RefractiveIndex::cam.begin();
|
//RefractiveIndex::cam.begin();
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
ofTranslate(tx, ty, tz);
|
||||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||||
@@ -342,7 +342,7 @@ void ColorMultiAnalysis::draw()
|
|||||||
|
|
||||||
image2.unbind();
|
image2.unbind();
|
||||||
|
|
||||||
RefractiveIndex::cam.end();
|
//RefractiveIndex::cam.end();
|
||||||
|
|
||||||
_RUN_DONE = true;
|
_RUN_DONE = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ void ColorSingleAnalysis::draw()
|
|||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
glLineWidth(line_width);
|
glLineWidth(line_width);
|
||||||
|
|
||||||
RefractiveIndex::cam.begin();
|
//RefractiveIndex::cam.begin();
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
ofTranslate(tx, ty, tz);
|
||||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||||
@@ -358,7 +358,7 @@ void ColorSingleAnalysis::draw()
|
|||||||
|
|
||||||
image2.unbind();
|
image2.unbind();
|
||||||
|
|
||||||
RefractiveIndex::cam.end();
|
//RefractiveIndex::cam.end();
|
||||||
|
|
||||||
_RUN_DONE = true;
|
_RUN_DONE = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ void DiffNoiseAnalysis::draw()
|
|||||||
glPointSize(point_size);
|
glPointSize(point_size);
|
||||||
glEnable(GL_POINT_SMOOTH);
|
glEnable(GL_POINT_SMOOTH);
|
||||||
|
|
||||||
RefractiveIndex::cam.begin();
|
//RefractiveIndex::cam.begin();
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
ofTranslate(tx, ty, tz);
|
||||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||||
@@ -366,7 +366,7 @@ void DiffNoiseAnalysis::draw()
|
|||||||
|
|
||||||
image2.unbind();
|
image2.unbind();
|
||||||
|
|
||||||
RefractiveIndex::cam.end();
|
//RefractiveIndex::cam.end();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ void IResponseAnalysis::draw()
|
|||||||
glPointSize(point_size);
|
glPointSize(point_size);
|
||||||
glEnable(GL_POINT_SMOOTH);
|
glEnable(GL_POINT_SMOOTH);
|
||||||
|
|
||||||
RefractiveIndex::cam.begin();
|
//RefractiveIndex::cam.begin();
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
ofTranslate(tx, ty, tz);
|
||||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||||
@@ -331,7 +331,7 @@ void IResponseAnalysis::draw()
|
|||||||
|
|
||||||
image2.unbind();
|
image2.unbind();
|
||||||
|
|
||||||
RefractiveIndex::cam.end();
|
//RefractiveIndex::cam.end();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ void RelaxRateAnalysis::draw()
|
|||||||
glPointSize(point_size);
|
glPointSize(point_size);
|
||||||
glEnable(GL_POINT_SMOOTH);
|
glEnable(GL_POINT_SMOOTH);
|
||||||
|
|
||||||
RefractiveIndex::cam.begin();
|
//RefractiveIndex::cam.begin();
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
ofTranslate(tx, ty, tz);
|
||||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||||
@@ -328,7 +328,7 @@ void RelaxRateAnalysis::draw()
|
|||||||
|
|
||||||
image2.unbind();
|
image2.unbind();
|
||||||
|
|
||||||
RefractiveIndex::cam.end();
|
//RefractiveIndex::cam.end();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ void ShadowScapesAnalysis::draw()
|
|||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
glLineWidth(line_width);
|
glLineWidth(line_width);
|
||||||
|
|
||||||
RefractiveIndex::cam.begin();
|
//RefractiveIndex::cam.begin();
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
ofTranslate(tx, ty, tz);
|
||||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||||
@@ -371,7 +371,7 @@ void ShadowScapesAnalysis::draw()
|
|||||||
|
|
||||||
image2.unbind();
|
image2.unbind();
|
||||||
|
|
||||||
RefractiveIndex::cam.end();
|
//RefractiveIndex::cam.end();
|
||||||
|
|
||||||
_RUN_DONE = true;
|
_RUN_DONE = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ void ShapeFromShadingAnalysis::draw()
|
|||||||
glPointSize(point_size);
|
glPointSize(point_size);
|
||||||
glEnable(GL_POINT_SMOOTH);
|
glEnable(GL_POINT_SMOOTH);
|
||||||
|
|
||||||
RefractiveIndex::cam.begin();
|
//RefractiveIndex::cam.begin();
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
ofTranslate(tx, ty, tz);
|
||||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||||
@@ -524,7 +524,7 @@ void ShapeFromShadingAnalysis::draw()
|
|||||||
|
|
||||||
image2.unbind();
|
image2.unbind();
|
||||||
|
|
||||||
RefractiveIndex::cam.end();
|
//RefractiveIndex::cam.end();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ void StrobeAnalysis::draw()
|
|||||||
glPointSize(point_size);
|
glPointSize(point_size);
|
||||||
glEnable(GL_POINT_SMOOTH);
|
glEnable(GL_POINT_SMOOTH);
|
||||||
|
|
||||||
RefractiveIndex::cam.begin();
|
//RefractiveIndex::cam.begin();
|
||||||
|
|
||||||
ofTranslate(tx, ty, tz);
|
ofTranslate(tx, ty, tz);
|
||||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||||
@@ -353,7 +353,7 @@ void StrobeAnalysis::draw()
|
|||||||
|
|
||||||
image2.unbind();
|
image2.unbind();
|
||||||
|
|
||||||
RefractiveIndex::cam.end();
|
//RefractiveIndex::cam.end();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user