Commit bcc08262 authored by Michele Bosi's avatar Michele Bosi

Vivid: updated Vivid example

parent 628d0c07
......@@ -47,6 +47,7 @@
#include <vlGraphics/DepthSortCallback.hpp>
#include <vlGraphics/GeometryPrimitives.hpp>
#include <vlVivid/VividRendering.hpp>
#include <vlVivid/VividVolume.hpp>
#include <vlGraphics/CalibratedCamera.hpp>
#include <vlGraphics/AdjacencyExtractor.hpp>
......@@ -75,6 +76,7 @@ public:
mVividRendering = new VividRendering;
mVivid = mVividRendering->vividRenderer();
mVividVolume = new VividVolume( mVividRendering.get() );
trackball()->setCamera( mVividRendering->calibratedCamera() );
// Other
......@@ -499,7 +501,10 @@ public:
printf("%f %f %f\n", volume_box.width(), volume_box.height(), volume_box.depth() );
#if 1
ref< Image > volume = vl::loadImage("/volume/BostonTeapot.dat");
mVividRendering->setupVolume( volume.get(), volume_box, NULL );
mVividVolume->setupVolume( volume.get(), volume_box, NULL );
Actor* volume_actor = mVividVolume->volumeActor();
// mVividRendering->sceneManager()->tree()->eraseActor( volume_actor );
mVividRendering->sceneManager()->tree()->addActor( volume_actor );
// volume bounding box outline
ref<Effect> fx_box = VividRendering::makeVividEffect();
......@@ -509,7 +514,7 @@ public:
ref<Geometry> box_outline = vl::makeBox( volume_box );
box_outline->computeNormals();
box_outline->setColorArray( vl::red );
Actor* vol_box = mVividRendering->sceneManager()->tree()->addActor( box_outline.get(), fx_box.get(), mVividRendering->vividVolume()->volumeTransform() );
Actor* vol_box = mVividRendering->sceneManager()->tree()->addActor( box_outline.get(), fx_box.get(), mVividVolume->volumeTransform() );
vol_box->setEnableMask( vl::Vivid::VividEnableMask );
vol_box->setObjectName( "Volume Box" );
#endif
......@@ -566,24 +571,24 @@ public:
}
break;
case 'v':
mVividRendering->setStencilEnabled( ! mVividRendering->stencilEnabled() );
mVividRendering->setStencilEnabled( ! mVividRendering->isStencilEnabled() );
break;
case 'n':
mOutlineMode->setUniformI( (mOutlineMode->getUniformI() + 1) % 6 );
break;
case 'r':
mVivid->initShaders();
mVividRendering->vividVolume()->volumeGLSLProgram()->reload();
mVividVolume->volumeGLSLProgram()->reload();
break;
case 'q':
mVivid->setUseQueryObject(!mVivid->useQueryObject());
break;
case '+':
mVivid->setNumPasses(mVivid->numPasses() + 1);
mVivid->setDetphPeelingPasses(mVivid->depthPeelingPasses() + 1);
break;
case '-':
if (mVivid->numPasses() > 1) {
mVivid->setNumPasses(mVivid->numPasses() - 1);
if (mVivid->depthPeelingPasses() > 1) {
mVivid->setDetphPeelingPasses(mVivid->depthPeelingPasses() - 1);
}
break;
case '1':
......@@ -627,7 +632,7 @@ public:
const char* method[] = { "DepthPeeling", "FastRender", "StencilRender" };
printf("method: %s\n", method[mVividRendering->renderingMode()]);
printf("pass counter: %d\n", mVivid->passCounter());
printf("num passes: %d\n", mVivid->numPasses());
printf("num passes: %d\n", mVivid->depthPeelingPasses());
printf("use query object: %d\n", mVivid->useQueryObject());
printf("---\n");
openglContext()->update();
......@@ -746,6 +751,7 @@ public:
protected:
ref<VividRendering> mVividRendering;
ref<VividRenderer> mVivid;
ref<VividVolume> mVividVolume;
std::set<ref<Effect>> mEffects;
std::vector<String> mLastShaders;
......
......@@ -54,11 +54,13 @@ namespace vl
TextureSampler* backgroundTexSampler() { return mBackgroundTexSampler.get(); }
const TextureSampler* backgroundTexSampler() const { return mBackgroundTexSampler.get(); }
protected:
int passCounter() const { return mPassCounter; }
// For debugging
void initShaders();
bool shadersReady() const;
int passCounter() const { return mPassCounter; }
protected:
const RenderQueue* render(const RenderQueue* in_render_queue, Camera* camera, real frame_clock);
int renderQueue(const RenderQueue* in_render_queue, vl::GLSLProgram* cur_glsl, Camera* camera, real frame_clock, bool depth_peeling_on=true, bool outline_on = false);
void renderBackgroundImage( Camera* camera );
......
......@@ -252,7 +252,6 @@ namespace vl
//! Internal. Used by vl::VividVolume.
const Texture* depthFBOTex() const { return mVividRenderer->depthFBOTex(); }
protected:
VividRenderer* vividRenderer() { return mVividRenderer.get(); }
const VividRenderer* vividRenderer() const { return mVividRenderer.get(); }
......
......@@ -314,4 +314,4 @@ void VividVolume::setupVolume( Image* img, const AABB& bounds, Image* transfer_f
// Defaults
mVolumeActor->gocUniform( "isoValue" )->setUniformF( mIsoValue );
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment