Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
Public Member Functions | Static Public Member Functions | List of all members
Wizt::FloatingAnemone Struct Reference

#include <FloatingAnemone.hpp>

Inheritance diagram for Wizt::FloatingAnemone:
Wizt::FloatingOriginAnemone Wizt::FloatOrigin Wizt::VStateCreatorBase Wizt::FloatingProgrammableEdgeRenderer Wizt::FloatingSkeletonRenderer Wizt::PictureBase Wizt::ShadedFieldAnemone Wizt::SurfaceRenderer Wizt::VertexFieldShader< DisplayShader, RenderCategory > Wizt::EdgeShader Wizt::LineSetRenderer Wizt::PictureInjectorBase Wizt::HeightDots Wizt::HeightDotsMultiView Wizt::WhiteDots

Public Member Functions

string WorldToScreen () const override
 The name of the shader parameter used to store the translation vector.
 
string getShaderPrefix (const GridAnemone::AnemoneCreationContext &ARC, const GridAnemone::AnemoneExplorer &AE) const
 
bool initializeTranslation (Anemone &RenderAnemone, const GridAnemone::AnemoneCreationContext &ARC, const RefPtr< GridAnemone::AnemoneExplorer > &AE) const
 Call this function from.
 
bool updateTranslation (Anemone &RenderAnemone, const GridAnemone::AnemoneCreationContext &ARC, const RefPtr< GridAnemone::AnemoneExplorer > &AE) const
 
RefPtr< GridAnemone::AnemoneExplorergetAnemoneExplorer (const WeakPtr< GridAnemone > &theGridAnemone, VRenderContext &Context) const
 Provide GLSL code defining uniform variables that relate to the floating origin approach.
 
- Public Member Functions inherited from Wizt::FloatingOriginAnemone
RefPtr< GridAnemone::AnemoneExplorergetAnemoneExplorer (const WeakPtr< GridAnemone > &theGridAnemone, VRenderContext &Context) const
 Creation of an AnemoneExplorer that takes care of the floating origin during rendering, it needs to be overridden in a child class of GridAnemone like this:
 
bool hasChangedAbsoluteTranslationVector (const RefPtr< GridAnemone::AnemoneExplorer > &AE) const
 
- Public Member Functions inherited from Wizt::FloatOrigin
RefPtr< Chunk< Eagle::point3 > > computeShiftedCoordinates (const RefPtr< Chunk< Eagle::point3 > > &RawCoordinates, const Eagle::tvector3 &TranslationVector) const
 
VRenderContext::ModelViewState getCoordinateTranslation (const VRenderContext &Context, Eagle::tvector3 &TranslationVector) const
 
VRenderContext::ModelViewState getCoordinateTranslation (const VRenderContext &Context, Intercube &IC, Eagle::tvector3 &TranslationVector) const
 
- Public Member Functions inherited from Wizt::VStateCreatorBase
RefPtr< State > & getState (const WeakPtr< ValuePool > &VP) const
 
RefPtr< InterfaceBasehasLocalInterface (const type_info &InterfaceType) const
 
RefPtr< State > myState (const WeakPtr< ValuePool > &Context) const
 
virtual RefPtr< State > newState () const
 
void setState (const WeakPtr< ValuePool > &, const RefPtr< State > &st) const
 

Static Public Member Functions

static RefPtr< RenderBasin::VertexAttributecreatePossiblyShiftedVertices (const RefPtr< TypedChunk< Eagle::PhysicalSpace::point > > &Coordinates, const BoundingBox &BBox, const GridAnemone::AnemoneCreationContext &ARC, const RefPtr< GridAnemone::AnemoneExplorer > &AE)
 If the AnemoneExplorer is a FloatingAnemoneExplorer (which will be the case if getAnemoneExplorer() has been implemented as documented), then shift coordinates into the center of the bounding box, create a vertex attribute from it and set a CoordinateShift interface to the AnemoneExplorer.
 
static RefPtr< RenderBasin::VertexAttributecreatePossiblyShiftedVertices (const RefPtr< Fiber::MemBase > &Coordinates, const BoundingBox &BBox, const GridAnemone::AnemoneCreationContext &ARC, const RefPtr< GridAnemone::AnemoneExplorer > &AE, const MemCore::Attributes &Attribs, bool AllowProceduralCoordinates)
 If the AnemoneExplorer is a FloatingAnemoneExplorer (which will be the case if getAnemoneExplorer() has been implemented as documented), then shift coordinates into the center of the bounding box, create a vertex attribute from it and set a CoordinateShift interface to the AnemoneExplorer.
 
static std::pair< RefPtr< RenderBasin::VertexAttribute >, boolcreatePossiblyShiftedVertices (Fiber::CreativeArrayBase &myPrimaryDataFragment, const GridAnemone::AnemoneCreationContext &ARC, const RefPtr< GridAnemone::AnemoneExplorer > &AE, bool AllowProceduralCoordinates, const Fiber::CreativeArrayBase::result &AsyncCallback)
 Same as similar function, but using a Creator to create the coordinates and possibly compute the bounding box information.
 
- Static Public Member Functions inherited from Wizt::FloatingOriginAnemone
static RefPtr< RenderBasin::VertexAttributecreatePossiblyShiftedVertices (const RefPtr< TypedChunk< Eagle::PhysicalSpace::point > > &Coordinates, const GridAnemone::AnemoneCreationContext &ARC, const RefPtr< GridAnemone::AnemoneExplorer > &AE)
 
- Static Public Member Functions inherited from Wizt::FloatOrigin
static VRenderContext::ModelViewState getTranslationVector (const VRenderContext &Context, Intercube &IC, Eagle::tvector3 &TranslationVector, double CameraShiftThreshold)
 
static Eagle::tvector3 getTranslationVector (Intercube &IC)
 

Detailed Description

Author
Werner Benger

Supporting Render Anemone API using shaders via FloatOrigin support. There will be two translations involved:

Member Function Documentation

◆ createPossiblyShiftedVertices() [1/2]

RefPtr< RenderBasin::VertexAttribute > Wizt::FloatingAnemone::createPossiblyShiftedVertices ( const RefPtr< Fiber::MemBase > &  Coordinates,
const BoundingBox BBox,
const GridAnemone::AnemoneCreationContext ARC,
const RefPtr< GridAnemone::AnemoneExplorer > &  AE,
const MemCore::Attributes Attribs,
bool  AllowProceduralCoordinates 
)
static

If the AnemoneExplorer is a FloatingAnemoneExplorer (which will be the case if getAnemoneExplorer() has been implemented as documented), then shift coordinates into the center of the bounding box, create a vertex attribute from it and set a CoordinateShift interface to the AnemoneExplorer.

Otherwise, just load the coordinates as is.

Calls FloatingAnemoneExplorer::computeCenterShift().

◆ createPossiblyShiftedVertices() [2/2]

std::pair< RefPtr< RenderBasin::VertexAttribute >, bool > Wizt::FloatingAnemone::createPossiblyShiftedVertices ( Fiber::CreativeArrayBase myPrimaryDataFragment,
const GridAnemone::AnemoneCreationContext ARC,
const RefPtr< GridAnemone::AnemoneExplorer > &  AE,
bool  AllowProceduralCoordinates,
const Fiber::CreativeArrayBase::result &  AsyncCallback 
)
static

Same as similar function, but using a Creator to create the coordinates and possibly compute the bounding box information.

The bool return value tells whether the data are yet under creation, assign as:

const auto&[VertexAttribute,YetUnderCreation] = createPossiblyShiftedVertices(...);
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
static RefPtr< RenderBasin::VertexAttribute > createPossiblyShiftedVertices(const RefPtr< TypedChunk< Eagle::PhysicalSpace::point > > &Coordinates, const BoundingBox &BBox, const GridAnemone::AnemoneCreationContext &ARC, const RefPtr< GridAnemone::AnemoneExplorer > &AE)
If the AnemoneExplorer is a FloatingAnemoneExplorer (which will be the case if getAnemoneExplorer() h...
Definition FloatingAnemone.cpp:146

References createPossiblyShiftedVertices(), and MemCore::Timer::secs().

◆ getAnemoneExplorer()

RefPtr< GridAnemone::AnemoneExplorer > Wizt::FloatingOriginAnemone::getAnemoneExplorer ( const WeakPtr< GridAnemone > &  theGridAnemone,
VRenderContext Context 
) const

Provide GLSL code defining uniform variables that relate to the floating origin approach.

This GLSL code can be embedded into vertex, geometry or fragment shaders equally. The provided code is equivalent to:

// The translational part of the model view matrix
uniform vec3 vish_translation;
// The value by which vertices in a vertex array are offset from their real value.
//
// To improve numerical accuracy, vertices are shifted before uploading
// to the GPU by a certain shift vector, which is usually the center
// of the bounding box surrounding an Anemone.
//
uniform vec3 vish_origin;
// The camera observer location relative to the vertex translation
// compute actual world coordinates from shifted vertex coordinates
vec3 vish_WorldPosition(in vec3 theVertex);
// project shifted vertex coordinates to screen coordinates
#ifdef VERTEX_SHADER
// get absolute coordinates of current vertex, also works for procedural (e.g. uniform) coordinates
// get relative coordinates of current vertex, also works for procedural (e.g. uniform) coordinates
#endif

◆ initializeTranslation()

bool Wizt::FloatingAnemone::initializeTranslation ( Anemone RenderAnemone,
const GridAnemone::AnemoneCreationContext ARC,
const RefPtr< GridAnemone::AnemoneExplorer > &  AE 
) const

Call this function from.

AnemoneRenderStatus initializeAnemone(Anemone&RenderAnemone,
const RefPtr<AnemoneExplorer>&AE) const override;
The context of creating a RenderAnemone.
Definition AnemoneCreationContext.hpp:58

in a child class of GridAnemone after computing shifted vertices via createPossiblyShiftedVertices() or similar functions that define the internal shift vector.

References Wizt::FloatingAnemoneExplorer::initializeTranslation().

Referenced by Wizt::EdgeShader::feedAnemone(), and Wizt::FloatingSkeletonRenderer::feedAnemone().

◆ WorldToScreen()

string Wizt::FloatingAnemone::WorldToScreen ( ) const
override

The name of the shader parameter used to store the translation vector.

Shader code must be of the form such as:

uniform vec3 TranslationVector;
void main(void)
{
vec4 theVertex = gl_Vertex;
vec4 theVertex_EyeSpace = gl_ModelViewMatrix*(theVertex-vec4(TranslationVector,0));
}
@endcod
This name can be modified in a subclass if required. It will be used
when initializing a Render Anemone via the initializeAnemone() call.
/
// string TranslationVectorUniformName = "TranslationVector";
/**
To improve numerical accuracy, vertices are shifted before uploading
to the GPU by a certain shift vector, which is usually the center
of the bounding box surrounding an Anemone. This shift vector
shows up in the shader code under this given name as defined
here. A child class can change this name if another one is
desired for some reason.
/
// string CenterShiftVectorUniformName = "CenterShift";
// [[deprecated("This is actually the vertex offset by which vertices are shifted")]]
// const char*getFloatingOrigin() const;
// string RelativeObserverUniformName = "RelativeObserver";
~FloatingAnemone();
#if 0
static string WorldToScreen(const string&TranslationVectorName);
/**
Shader function to define uniform variable and function
for translation-corrected vertices.
@code
uniform vec3 TranslationVector;
vec4 WorldToScreen(vec4 theVertex)
{
vec4 theVertex_EyeSpace = gl_ModelViewMatrix*(theVertex-vec4(TranslationVector,0));
return gl_ProjectionMatrix*theVertex_EyeSpace;
}
enable_if_callable_t< T, Args... > call(T &&obj, Args &&... args)