Working on render bits.

This commit is contained in:
Andrzej Kapolka 2014-07-24 17:01:15 -07:00
parent d0c5fec777
commit 605b3282e7
4 changed files with 46 additions and 9 deletions

View file

@ -140,7 +140,32 @@ bool SpannerRenderVisitor::visit(Spanner* spanner, const glm::vec3& clipMinimum,
return true;
}
class RenderVisitor : public MetavoxelVisitor {
public:
RenderVisitor(const MetavoxelLOD& lod);
virtual int visit(MetavoxelInfo& info);
};
RenderVisitor::RenderVisitor(const MetavoxelLOD& lod) :
MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getRendererAttribute(),
QVector<AttributePointer>(), lod) {
}
int RenderVisitor::visit(MetavoxelInfo& info) {
if (!info.isLeaf) {
return DEFAULT_ORDER;
}
static_cast<MetavoxelRenderer*>(info.inputValues.at(0).getInlineValue<
SharedObjectPointer>().data())->getImplementation()->render(info);
return STOP_RECURSION;
}
void MetavoxelSystem::render() {
RenderVisitor renderVisitor(getLOD());
guide(renderVisitor);
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
const int VIEWPORT_WIDTH_INDEX = 2;
@ -480,6 +505,9 @@ AttributeValue PointBufferAttribute::inherit(const AttributeValue& parentValue)
PointMetavoxelRendererImplementation::PointMetavoxelRendererImplementation() {
}
void PointMetavoxelRendererImplementation::render(MetavoxelInfo& info) {
}
static void enableClipPlane(GLenum plane, float x, float y, float z, float w) {
GLdouble coefficients[] = { x, y, z, w };
glClipPlane(plane, coefficients);

View file

@ -133,6 +133,8 @@ class PointMetavoxelRendererImplementation : public MetavoxelRendererImplementat
public:
Q_INVOKABLE PointMetavoxelRendererImplementation();
virtual void render(MetavoxelInfo& info);
};
/// Base class for spanner renderers; provides clipping.

View file

@ -83,7 +83,7 @@ Box MetavoxelData::getBounds() const {
void MetavoxelData::guide(MetavoxelVisitor& visitor) {
// let the visitor know we're about to begin a tour
visitor.prepare();
visitor.prepare(this);
// start with the root values/defaults (plus the guide attribute)
const QVector<AttributePointer>& inputs = visitor.getInputs();
@ -140,7 +140,7 @@ void MetavoxelData::guideToDifferent(const MetavoxelData& other, MetavoxelVisito
}
// let the visitor know we're about to begin a tour
visitor.prepare();
visitor.prepare(this);
// start with the root values/defaults (plus the guide attribute)
const QVector<AttributePointer>& inputs = visitor.getInputs();
@ -1270,8 +1270,8 @@ MetavoxelVisitor::MetavoxelVisitor(const QVector<AttributePointer>& inputs,
MetavoxelVisitor::~MetavoxelVisitor() {
}
void MetavoxelVisitor::prepare() {
// nothing by default
void MetavoxelVisitor::prepare(MetavoxelData* data) {
_data = data;
}
bool MetavoxelVisitor::postVisit(MetavoxelInfo& info) {
@ -1295,7 +1295,8 @@ SpannerVisitor::SpannerVisitor(const QVector<AttributePointer>& spannerInputs, c
_order(order) {
}
void SpannerVisitor::prepare() {
void SpannerVisitor::prepare(MetavoxelData* data) {
MetavoxelVisitor::prepare(data);
_visit = Spanner::getAndIncrementNextVisit();
}
@ -1354,7 +1355,8 @@ RaySpannerIntersectionVisitor::RaySpannerIntersectionVisitor(const glm::vec3& or
_spannerMaskCount(spannerMasks.size()) {
}
void RaySpannerIntersectionVisitor::prepare() {
void RaySpannerIntersectionVisitor::prepare(MetavoxelData* data) {
MetavoxelVisitor::prepare(data);
_visit = Spanner::getAndIncrementNextVisit();
}
@ -1866,6 +1868,9 @@ void MetavoxelRendererImplementation::init(MetavoxelRenderer* renderer) {
_renderer = renderer;
}
void MetavoxelRendererImplementation::render(MetavoxelInfo& info) {
}
QByteArray MetavoxelRenderer::getImplementationClassName() const {
return "MetavoxelRendererImplementation";
}

View file

@ -315,7 +315,7 @@ public:
float getMinimumLODThresholdMultiplier() const { return _minimumLODThresholdMultiplier; }
/// Prepares for a new tour of the metavoxel data.
virtual void prepare();
virtual void prepare(MetavoxelData* data);
/// Visits a metavoxel.
/// \param info the metavoxel data
@ -340,6 +340,7 @@ protected:
QVector<AttributePointer> _outputs;
MetavoxelLOD _lod;
float _minimumLODThresholdMultiplier;
MetavoxelData* _data;
QList<MetavoxelVisitation> _visitations;
int _depth;
};
@ -360,7 +361,7 @@ public:
/// \return true to continue, false to short-circuit the tour
virtual bool visit(Spanner* spanner, const glm::vec3& clipMinimum, float clipSize) = 0;
virtual void prepare();
virtual void prepare(MetavoxelData* data);
virtual int visit(MetavoxelInfo& info);
protected:
@ -407,7 +408,7 @@ public:
/// \return true to continue, false to short-circuit the tour
virtual bool visitSpanner(Spanner* spanner, float distance) = 0;
virtual void prepare();
virtual void prepare(MetavoxelData* data);
virtual int visit(MetavoxelInfo& info, float distance);
protected:
@ -546,6 +547,7 @@ public:
Q_INVOKABLE MetavoxelRendererImplementation();
virtual void init(MetavoxelRenderer* renderer);
virtual void render(MetavoxelInfo& info);
protected: