|
Krotos Modules 3
|
A component to display the grains of the reformer engine. More...
#include <GrainVisualiser.h>
Public Types | |
| enum | GrainRenderStyle { Compound = 0 , DotsWithLines , NUM_GRAIN_STYLES } |
| Enumerate the sets of PNGs used to render grains. More... | |
Public Member Functions | |
| GrainVisualiser () | |
| ~GrainVisualiser () override | |
| void | drawGrain (Graphics &graphicContext, Graphics &overlayContext, float x, float y, float diameter, float sprite, float envelope=0.f) |
| Draw a grain blob into the grain display 2D. | |
| void | drawGrainPerspective (Graphics &graphicContext, Graphics &overlayContext, float x, float y, float z, float q, const AffineTransform &transform, float envelope=-1.f) |
| Draw a grain blob into the grain display 3D. | |
| void | drawBackdropGradient (juce::Graphics &g) |
| Draw a gradient for the display background. | |
| void | drawBackdrop (juce::Graphics &g) |
| The backdrop is graphic which is drawn into the background of the display This method draws it into the supplied graphics context. | |
| int | calcBaseFrame (const float parallax, float &interFrame) |
| Calculates which frame index into the background cache for a given parallax value. | |
| int | calcBaseFrame (float parallax) |
| Calculates which frame index into the background cache for a given parallax value. | |
| void | drawInterpolatedBackground (juce::Graphics &g, float parallax) |
| Draw the background from the backgound frames store The final image will be interpolated from the two nearest frames. | |
| void | drawDisplayBuffer (juce::Graphics &g) |
| Draw the display buffer into a graphics context. | |
| const AffineTransform | makeParallaxRotationTransform (float parallax) |
| Make an affine transform to rotate X & Z around the Y axis. | |
| void | paint (Graphics &g) override |
| Paints in the grains display This method is called when the component is asked to re-paint itself This will be triggered either by the system - at random times of its choosing, or by timerCallback() in KwidgetGUI_XyPad calling m_grainVisualiser->repaint(); If sound data is not available, this call will paint in copy of the most recent legitimately rendered frame. | |
| void | updateBackgroundCacheFrame (SampleEngineShallow *sampleEngine, int index) |
| Regenerate a frame in the background cache. | |
| void | requestBackgroundCacheRegeneration () |
| Sets a flag to request regeneration of the background cache. | |
| void | paintPlayingGrains (SampleEngineShallow *sampleEngine) |
| Paint the grain display into the display buffer. | |
| void | drawBackgroundFrame (Graphics &graphicContext, Graphics &overlayContext, SampleEngineShallow *sampleEngine, float parallax) |
| Draws all the grain display components - background. | |
| void | markBackgroundFramesDirty () |
| Sets the dirty flag true for every background frame. | |
| void | prepareToAddSampleEngines () |
| Called to indicate that you are about to start adding sample engines to the grain visualiser. | |
| void | finishedAddingSampleEngines () |
| Called to indicate that you have finished adding sample engines to the grain visualiser Checks to see if we need to regenerate the background cache. Simply detects a change in the number of active engines. We might add more detection methods as needs arise. | |
| void | shallowCopy (KrotosSampleOscillatorSound *sound) |
| Set which sound is to be displayed. | |
| void | setPuckPosition (Point< float > position) |
| void | setPerformMode (bool val) |
| Set the visualiser into display mode. | |
| void | loadBinaryAssetGrainGraphics (GrainRenderStyle style) |
| Loads the PNGs for display of grains from binary assets. | |
Public Member Functions inherited from krotos::ZoomableComponent | |
| ZoomableComponent ()=default | |
| ~ZoomableComponent () override=default | |
| void | setHorizontalZoomFactor (float factor) |
| void | setHorizontalZoomCenter (float center) |
| void | setVerticalZoomFactor (float factor) |
| void | setVerticalZoomCenter (float center) |
| void | setHorizontalZoomFromRange (const Range< float > xr) |
| void | SetTransformToFit (int width, int height) |
| float | getHorizontalZoomFactor () const |
| float | getHorizontalZoomCenter () const |
| float | getVerticalZoomFactor () const |
| float | getVerticalZoomCenter () const |
| Range< float > | getHorizontalRange () const |
| Range< float > | getVerticalRange () const |
Static Public Attributes | |
| static constexpr int | ReformerMaxDisplayedInstances {4} |
Additional Inherited Members | |
Protected Member Functions inherited from krotos::ZoomableComponent | |
| void | drawNormalisedZoomedRect (Graphics &g, const Rectangle< float > &rect) const |
| void | drawNormalisedZoomedRectLine (Graphics &g, const Rectangle< float > &rect) const |
| void | drawZoomedRect (Graphics &g, const Rectangle< float > &rect) const |
| void | drawNormalisedZoomedLine (Graphics &g, Line< float > line, float thickness) const |
| void | drawZoomedLine (Graphics &g, const Line< float > &line, float thickness) const |
| void | drawNormalisedZoomedText (Graphics &g, String text, Rectangle< float > bounds) const |
| void | drawNormalisedZoomedPath (Graphics &g, const Path &path, float thickness) |
| void | drawZoomedPath (Graphics &g, Path path, float thickness) |
| void | drawNormalisedZoomedImage (Graphics &g, Image &image, const Rectangle< float > &bounds, bool fillAlphaChannelWithCurrentBrush=false) |
| void | fillNormalisedZoomedEllipse (Graphics &g, const Rectangle< float > &bounds) |
| void | drawNormalisedZoomedEllipse (Graphics &g, const Rectangle< float > &bounds) |
| void | drawZoomedEllipse (Graphics &g, const Rectangle< float > &bounds) |
A component to display the grains of the reformer engine.
| krotos::GrainVisualiser::GrainVisualiser | ( | ) |
|
override |
|
inline |
Calculates which frame index into the background cache for a given parallax value.
| parallax | Parallax value from 0 to 1 |
| interFrame | Returns a float representing the porportion of transition from baseframe to baseframe+1 |
|
inline |
Calculates which frame index into the background cache for a given parallax value.
| parallax | Parallax value from 0 to 1 |
| void krotos::GrainVisualiser::drawBackdrop | ( | juce::Graphics & | g | ) |
The backdrop is graphic which is drawn into the background of the display This method draws it into the supplied graphics context.
| g | Graphics context to draw into |
| void krotos::GrainVisualiser::drawBackdropGradient | ( | juce::Graphics & | g | ) |
Draw a gradient for the display background.
| g | Graphics context to draw into |
| void krotos::GrainVisualiser::drawBackgroundFrame | ( | Graphics & | graphicContext, |
| Graphics & | overlayContext, | ||
| SampleEngineShallow * | sampleEngine, | ||
| float | parallax ) |
Draws all the grain display components - background.
| gBg | Graphics context to draw into |
| parallax | The angle of rotation |
| enableLiveGrains | If true, will render the scene without using the pre-rendered background frames |
| void krotos::GrainVisualiser::drawDisplayBuffer | ( | juce::Graphics & | g | ) |
Draw the display buffer into a graphics context.
| g | Graphics context to draw into |
| void krotos::GrainVisualiser::drawGrain | ( | Graphics & | graphicContext, |
| Graphics & | overlayContext, | ||
| float | x, | ||
| float | y, | ||
| float | diameter, | ||
| float | sprite, | ||
| float | envelope = 0.f ) |
Draw a grain blob into the grain display 2D.
| g | Graphics context to draw into |
| x | X position, normalised 0->1 |
| y | Y position, normalised 0->1 |
| d | Diameter of blob, normalised 0->1 |
| sprite | Choice of png to represent the grain, normalised 0->1 |
| Choice | of png to represent the grain, normalised 0->1 |
| envelope | bulge/opacity of the grain, normalised 0->1 |
| void krotos::GrainVisualiser::drawGrainPerspective | ( | Graphics & | graphicContext, |
| Graphics & | overlayContext, | ||
| float | x, | ||
| float | y, | ||
| float | z, | ||
| float | q, | ||
| const AffineTransform & | transform, | ||
| float | envelope = -1.f ) |
Draw a grain blob into the grain display 3D.
| g | Graphics context to draw into |
| x | X position, normalised 0->1 |
| y | Y position, normalised 0->1 |
| c | Z position, normalised 0->1 |
| transform | AffineTransform to effect the rotation of the display about the y axis |
| envelope | bulge/opacity of the grain, normalised 0->1. Set to -1 to disable |
| void krotos::GrainVisualiser::drawInterpolatedBackground | ( | juce::Graphics & | g, |
| float | parallax ) |
Draw the background from the backgound frames store The final image will be interpolated from the two nearest frames.
| g | Graphics context to draw into |
| parallax | The angle of rotation |
|
inline |
Called to indicate that you have finished adding sample engines to the grain visualiser Checks to see if we need to regenerate the background cache. Simply detects a change in the number of active engines. We might add more detection methods as needs arise.
| void krotos::GrainVisualiser::loadBinaryAssetGrainGraphics | ( | GrainRenderStyle | style | ) |
Loads the PNGs for display of grains from binary assets.
| style | Sets the set of graphics you wish to load |
| const AffineTransform krotos::GrainVisualiser::makeParallaxRotationTransform | ( | float | parallax | ) |
Make an affine transform to rotate X & Z around the Y axis.
| parallax | A value from 0-1 representing the desired rotation |
| void krotos::GrainVisualiser::markBackgroundFramesDirty | ( | ) |
Sets the dirty flag true for every background frame.
|
override |
Paints in the grains display This method is called when the component is asked to re-paint itself This will be triggered either by the system - at random times of its choosing, or by timerCallback() in KwidgetGUI_XyPad calling m_grainVisualiser->repaint(); If sound data is not available, this call will paint in copy of the most recent legitimately rendered frame.
| g | Graphics context to draw into |
| void krotos::GrainVisualiser::paintPlayingGrains | ( | SampleEngineShallow * | sampleEngine | ) |
Paint the grain display into the display buffer.
| sampleEngine | Pointer to the Sample Engine we wish to display |
|
inline |
Called to indicate that you are about to start adding sample engines to the grain visualiser.
|
inline |
Sets a flag to request regeneration of the background cache.
|
inline |
Set the visualiser into display mode.
| val | True for display mode on, false for off |
|
inline |
|
inline |
Set which sound is to be displayed.
| sound |
| void krotos::GrainVisualiser::updateBackgroundCacheFrame | ( | SampleEngineShallow * | sampleEngine, |
| int | index ) |
Regenerate a frame in the background cache.
| sampleEngine | containing the grains to be displayed |
| index | to the background frame to regenerate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |
|
private |
|
private |
|
private |
|
private |