| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#ifndef AVOGADRO_RENDERING_VOLUMEGEOMETRY_H |
| 7 |
#define AVOGADRO_RENDERING_VOLUMEGEOMETRY_H |
| 8 |
|
| 9 |
#include "drawable.h" |
| 10 |
#include <avogadro/core/cube.h> |
| 11 |
|
| 12 |
namespace Avogadro { |
| 13 |
namespace Rendering { |
| 14 |
|
| 15 |
/** |
| 16 |
* @class VolumeGeometry |
| 17 |
* @brief Demonstrates volume rendering with an offscreen pass and a fullscreen quad. |
| 18 |
*/ |
| 19 |
class AVOGADRORENDERING_EXPORT VolumeGeometry : public Drawable |
| 20 |
{ |
| 21 |
public: |
| 22 |
VolumeGeometry(); |
| 23 |
VolumeGeometry(const VolumeGeometry& other); |
| 24 |
~VolumeGeometry() override; |
| 25 |
|
| 26 |
VolumeGeometry& operator=(VolumeGeometry); |
| 27 |
friend void swap(VolumeGeometry& lhs, VolumeGeometry& rhs); |
| 28 |
|
| 29 |
/** |
| 30 |
* Accept a visit from our friendly visitor. |
| 31 |
*/ |
| 32 |
void accept(Visitor&) override; |
| 33 |
|
| 34 |
/** |
| 35 |
* Render the volume. |
| 36 |
*/ |
| 37 |
void render(const Camera& camera) override; |
| 38 |
|
| 39 |
|
| 40 |
/** |
| 41 |
* Destroy all GL resources (FBO, textures, etc.). |
| 42 |
*/ |
| 43 |
void end(); |
| 44 |
|
| 45 |
/** |
| 46 |
* Clear the contents of the node. |
| 47 |
*/ |
| 48 |
void clear() override; |
| 49 |
|
| 50 |
/** |
| 51 |
* Call once to initialize all GL objects/shaders. |
| 52 |
*/ |
| 53 |
void initialize(); |
| 54 |
void resizeFBO(int width, int height); |
| 55 |
|
| 56 |
/** |
| 57 |
* Colors for positive/negative isovalues (for real volume rendering). |
| 58 |
*/ |
| 59 |
void setPositiveColor(const Vector3ub& c) { m_positiveColor = c; } |
| 60 |
Vector3ub positiveColor() const { return m_positiveColor; } |
| 61 |
|
| 62 |
void setNegativeColor(const Vector3ub& c) { m_negativeColor = c; } |
| 63 |
Vector3ub negativeColor() const { return m_negativeColor; } |
| 64 |
|
| 65 |
/** |
| 66 |
* Assign which Cube to render. |
| 67 |
*/ |
| 68 |
void setCube(const Core::Cube& cube); |
| 69 |
const Core::Cube* cube() const { return m_cube; } |
| 70 |
|
| 71 |
protected: |
| 72 |
// We store bounding box vertices, for real volume rendering if needed: |
| 73 |
float m_boundingVertices[24]; |
| 74 |
Vector3ub m_positiveColor; |
| 75 |
Vector3ub m_negativeColor; |
| 76 |
const Core::Cube* m_cube = nullptr; |
| 77 |
bool m_dirty = false; |
| 78 |
|
| 79 |
class Private; |
| 80 |
Private* d; |
| 81 |
|
| 82 |
// Size at which we create our offscreen buffer: |
| 83 |
int m_width; |
| 84 |
int m_height; |
| 85 |
}; |
| 86 |
|
| 87 |
} // End namespace Rendering |
| 88 |
} // End namespace Avogadro |
| 89 |
|
| 90 |
#endif // AVOGADRO_RENDERING_VOLUMEGEOMETRY_H |