Change drawing order depending on camera direction.
This commit is contained in:
@@ -253,20 +253,23 @@ void RenderingState::render(float time) const
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-LAYER_X_OFFSET / 2 * currentData->size(), 0, 0);
|
||||
|
||||
for (auto i : Range(currentData->size())) {
|
||||
glPushMatrix();
|
||||
renderLayerName(currentData->at(i).name());
|
||||
if (options.renderLayers) {
|
||||
layerVisualisations[i]->draw(time);
|
||||
}
|
||||
if (options.renderInteractions && i < interactionAnimations.size() && interactionAnimations[i]) {
|
||||
interactionAnimations[i]->draw(time);
|
||||
// Ensure we render back-to-front for transparency
|
||||
if (angle[0] <= 0) {
|
||||
// Render from the first to the last layer.
|
||||
glTranslatef(-LAYER_X_OFFSET / 2 * currentData->size(), 0, 0);
|
||||
for (auto i : Range(currentData->size())) {
|
||||
drawLayer(time, i);
|
||||
glTranslatef(LAYER_X_OFFSET, 0, 0);
|
||||
}
|
||||
} else {
|
||||
// Render from the last layer to the first layer.
|
||||
glTranslatef(LAYER_X_OFFSET / 2 * (currentData->size() - 2), 0, 0);
|
||||
for (auto i = currentData->size(); i--;) {
|
||||
drawLayer(time, i);
|
||||
|
||||
glPopMatrix();
|
||||
glTranslatef(LAYER_X_OFFSET, 0, 0);
|
||||
glTranslatef(-LAYER_X_OFFSET, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
@@ -276,6 +279,21 @@ void RenderingState::render(float time) const
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
void RenderingState::drawLayer(float time, unsigned long i) const
|
||||
{
|
||||
glPushMatrix();
|
||||
|
||||
renderLayerName(currentData->at(i).name());
|
||||
if (options.renderLayers) {
|
||||
layerVisualisations[i]->draw(time);
|
||||
}
|
||||
if (options.renderInteractions && i < interactionAnimations.size() && interactionAnimations[i]) {
|
||||
interactionAnimations[i]->draw(time);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void RenderingState::renderOverlayText() const
|
||||
{
|
||||
std::stringstream overlayText;
|
||||
|
||||
@@ -90,5 +90,7 @@ namespace fmri
|
||||
std::string debugInfo() const;
|
||||
void renderOverlayText() const;
|
||||
void renderLayerName(const std::string& name) const;
|
||||
|
||||
void drawLayer(float time, unsigned long i) const;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user