Skip to content

Commit

Permalink
add individual quilt tile view
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciogonzalezvivo committed Nov 23, 2023
1 parent c642119 commit 024bc84
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion deps/vera
32 changes: 17 additions & 15 deletions src/core/sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

// ------------------------------------------------------------------------- CONTRUCTOR
Sandbox::Sandbox():
screenshotFile(""), lenticular(""), quilt(-1),
screenshotFile(""), lenticular(""), quilt_resolution(-1), quilt_tile(-1),
frag_index(-1), vert_index(-1), geom_index(-1),
verbose(false), cursor(true), help(false), fxaa(false),
// Main Vert/Frag/Geom
Expand Down Expand Up @@ -1138,9 +1138,9 @@ void Sandbox::loadAssets(WatchFileList &_files) {
if (lenticular.size() > 0)
vera::setLenticularProperties(lenticular);

if (quilt >= 0) {
vera::setQuiltProperties(quilt);
addDefine("QUILT", vera::toString(quilt));
if (quilt_resolution >= 0) {
vera::setQuiltProperties(quilt_resolution);
addDefine("QUILT", vera::toString(quilt_resolution));
addDefine("QUILT_WIDTH", vera::toString( vera::getQuiltWidth() ));
addDefine("QUILT_HEIGHT", vera::toString( vera::getQuiltHeight() ));
addDefine("QUILT_COLUMNS", vera::toString( vera::getQuiltColumns() ));
Expand All @@ -1154,8 +1154,12 @@ void Sandbox::loadAssets(WatchFileList &_files) {
if (geom_index != -1)
uniforms.activeCamera->orbit(m_camera_elevation, m_camera_azimuth, m_sceneRender.getArea() * 8.5);

if (lenticular.size() == 0)
vera::setWindowSize(vera::getQuiltWidth(), vera::getQuiltHeight());
if (lenticular.size() == 0) {
if (quilt_tile >= 0)
vera::setWindowSize(vera::getQuiltWidth()/vera::getQuiltColumns(), vera::getQuiltHeight()/vera::getQuiltRows());
else
vera::setWindowSize(vera::getQuiltWidth(), vera::getQuiltHeight());
}
}

// Prepare viewport
Expand Down Expand Up @@ -1568,7 +1572,7 @@ void Sandbox::_updateBuffers() {

// Update Postprocessing
if (m_postprocessing || m_plot == PLOT_RGB || m_plot == PLOT_RED || m_plot == PLOT_GREEN || m_plot == PLOT_BLUE || m_plot == PLOT_LUMA) {
if (quilt >= 0)
if (quilt_resolution >= 0)
m_sceneRender.updateBuffers(uniforms, vera::getQuiltWidth(), vera::getQuiltHeight());
else
m_sceneRender.updateBuffers(uniforms, vera::getWindowWidth(), vera::getWindowHeight());
Expand Down Expand Up @@ -1811,7 +1815,7 @@ void Sandbox::render() {
// Load main shader
m_canvas_shader.use();

if (quilt >= 0) {
if (quilt_resolution >= 0) {
vera::renderQuilt([&](const vera::QuiltProperties& quilt, glm::vec4& viewport, int &viewIndex) {

// set up the camera rotation and position for current view
Expand All @@ -1829,7 +1833,7 @@ void Sandbox::render() {
m_canvas_shader.setUniform("u_projectionMatrix", glm::mat4(1.0f));
m_canvas_shader.setUniform("u_modelViewProjectionMatrix", glm::mat4(1.));
vera::getBillboard()->render( &m_canvas_shader );
}, true);
}, quilt_tile, true);
}

else {
Expand All @@ -1850,13 +1854,11 @@ void Sandbox::render() {

else {
TRACK_BEGIN("render:3D_scene")
if (quilt >= 0) {
if (quilt_resolution >= 0) {
vera::renderQuilt([&](const vera::QuiltProperties& quilt, glm::vec4& viewport, int &viewIndex){

// set up the camera rotation and position for current view
uniforms.activeCamera->setVirtualOffset(m_sceneRender.getArea() * 0.75, viewIndex, quilt.totalViews);
// uniforms.activeCamera->setVirtualOffset(5.0f, viewIndex, quilt.totalViews);
// uniforms.activeCamera->setVirtualOffset(10.0f, viewIndex, quilt.totalViews);

uniforms.set("u_tile", float(quilt.columns), float(quilt.rows), float(quilt.totalViews));
uniforms.set("u_viewport", float(viewport.x), float(viewport.y), float(viewport.z), float(viewport.w));
Expand All @@ -1865,7 +1867,7 @@ void Sandbox::render() {

if (m_sceneRender.showGrid || m_sceneRender.showAxis || m_sceneRender.showBBoxes)
m_sceneRender.renderDebug(uniforms);
}, true);
}, quilt_tile, true);
}

else {
Expand Down Expand Up @@ -2407,7 +2409,7 @@ void Sandbox::onMouseDrag(float _x, float _y, int _button) {
if (uniforms.activeCamera == nullptr)
return;

if (quilt < 0) {
if (quilt_resolution < 0) {
// If it's not playing on the HOLOPLAY
// produce continue draging like blender
//
Expand Down Expand Up @@ -2495,7 +2497,7 @@ void Sandbox::onViewportResize(int _newWidth, int _newHeight) {
}

if (m_postprocessing || m_plot == PLOT_LUMA || m_plot == PLOT_RGB || m_plot == PLOT_RED || m_plot == PLOT_GREEN || m_plot == PLOT_BLUE ) {
if (quilt >= 0)
if (quilt_resolution >= 0)
m_sceneRender.updateBuffers(uniforms, vera::getQuiltWidth(), vera::getQuiltHeight());
else
m_sceneRender.updateBuffers(uniforms, _newWidth, _newHeight);
Expand Down
3 changes: 2 additions & 1 deletion src/core/sandbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class Sandbox {

// Quilt/Lenticular
std::string lenticular;
int quilt;
int quilt_resolution;
int quilt_tile;

// States
int frag_index;
Expand Down
18 changes: 13 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,16 @@ int main(int argc, char **argv) {
}
else if ( argument == "-quilt" || argument == "--quilt" ) {
if (++i < argc)
sandbox.quilt = vera::toInt(argv[i]);
sandbox.quilt_resolution = vera::toInt(argv[i]);
else
std::cout << "Argument '" << argument << "' should be followed by a <quilt index type>" << std::endl;
}
else if ( argument == "-quilt_tile" || argument == "--quilt_tile" ) {
if (++i < argc)
sandbox.quilt_tile = vera::toInt(argv[i]);
else
std::cout << "Argument '" << argument << "' should be followed by a <tile index type>" << std::endl;
}
else if ( argument == "-lenticular" || argument == "--lenticular" ) {
std::string calibration_file = "default";
if (i+1 < argc) {
Expand All @@ -476,9 +482,10 @@ int main(int argc, char **argv) {
else
std::cout << "Argument '" << argument << "' should be followed by a path to calibration JSON file" << std::endl;

sandbox.quilt_tile = -1;
sandbox.lenticular = calibration_file;
if (sandbox.quilt == -1)
sandbox.quilt = 0;
if (sandbox.quilt_resolution == -1)
sandbox.quilt_resolution = 0;
}

else if ( argument == "-p" || argument == "-port" || argument == "--port" ) {
Expand Down Expand Up @@ -1937,8 +1944,9 @@ void printUsage(char * executableName) {
std::cerr << " --noncurses # disable ncurses command interface" << std::endl;
std::cerr << " --fps <fps> # fix the max FPS" << std::endl;
std::cerr << " --fxaa # set FXAA as postprocess filter" << std::endl;
std::cerr << " --quilt <0-7> # quilt render (HoloPlay)" << std::endl;
std::cerr << " --lenticular <visual.json> # lenticular calubration file, Looking Glass Model (HoloPlay)" << std::endl;
std::cerr << " --quilt <0-15> # quilt render (HoloPlay)" << std::endl;
std::cerr << " --quilt_tile <N> # render a particular tile of a quilt (HoloPlay)" << std::endl;
std::cerr << " --lenticular <visual.json> # lenticular calibration file, Looking Glass Model (HoloPlay)" << std::endl;
std::cerr << " -I<include_folder> # add an include folder to default for #include files" << std::endl;
std::cerr << " -D<define> # add system #defines directly from the console argument" << std::endl;
std::cerr << " -p <OSC_port> # open OSC listening port" << std::endl;
Expand Down

0 comments on commit 024bc84

Please sign in to comment.