|
The Vish Visualization Shell 0.3
Vish
|
By default, the Camera in Vish is NOT translated to the location of the specified observer, but it resides at location (0,0,0). More...
#include <ocean/Anemonia/FloatOrigin.hpp>
Public Member Functions | |
| RefPtr< Chunk< Eagle::point3 > > | computeShiftedCoordinates (const RefPtr< Chunk< Eagle::point3 > > &RawCoordinates, const Eagle::tvector3 &TranslationVector) const |
| Given raw coordinates that are shifted far from the origin, compute shifted coordinated according to the given TranslationVector that has been provided by getCoordinateTranslation(). | |
| VRenderContext::ModelViewState | getCoordinateTranslation (const VRenderContext &Context, Eagle::tvector3 &TranslationVector) const |
| VRenderContext::ModelViewState | getCoordinateTranslation (const VRenderContext &Context, Intercube &IC, Eagle::tvector3 &TranslationVector) const |
| Get the coordinate translaton as cached at a given Intercube. | |
Public Member Functions inherited from Wizt::VStateCreatorBase | |
| RefPtr< State > & | getState (const WeakPtr< ValuePool > &VP) const |
| Retrieve a pointer to a state object for the given context. | |
| RefPtr< InterfaceBase > | hasLocalInterface (const type_info &InterfaceType) const |
| Check whether any of the local object states has an interface of the given type. | |
| RefPtr< State > | myState (const WeakPtr< ValuePool > &Context) const |
| Retrieve a state for the current context, possibly creating one. | |
| virtual RefPtr< State > | newState () const |
| create a new state object. Child classes might deliver child states. | |
| void | setState (const WeakPtr< ValuePool > &, const RefPtr< State > &st) const |
| Set a state object for a given context. | |
Static Public Member Functions | |
| static VRenderContext::ModelViewState | getTranslationVector (const VRenderContext &Context, Intercube &IC, Eagle::tvector3 &TranslationVector, double CameraShiftThreshold) |
| The core function. | |
| static Eagle::tvector3 | getTranslationVector (Intercube &IC) |
| Get the current translation vector that needs to be subtracted from coordinates when rendering. | |
By default, the Camera in Vish is NOT translated to the location of the specified observer, but it resides at location (0,0,0).
This is to allow FloatOrigin objects to shift and move their data to the observer's location to enhance the numerical precision of OpenGL rendering.
So, if we render an object that does NOT provide this data shifting functionality, i.e. it is NOT a FloatOrigin object, then we have to translate the camera to the origin of the observer.
Basically implements the ideas from http://www.floatingorigin.com/ i.e. shift the coordinates, not the camera.
Render code using FloatOrigin works like this:
In practice, the translation vector is \not exactly the camera position, but comes with a tiny offset from that one, depending on said threshold. Thus, recomputing data values at each render() call is not needed, but only if this threshold has been exceeded, otherwise caching of shifted coordinates is the way to go, but only worth the effort for a significant amount of data values.
Basic code (without caching) is as follows:
Here, the VRenderContext::ModelViewState performs the - little - translation within the camera threshold. I.e., the translation part of the modelview matrix is not entirely zero, but managed within this object. Its constructor sets the offset translation, its destructor removes it. The offset translation is always specific to each render object. In the above code, both WorldCoordinates and TranslationVector a large numbers, each of them would not fit into the floating point precision of GPU rendering. However, the difference, LocalCoordinates, is tiny enough to be sent, and handled, by the GPU in single-precision.
To enable threshold caching, the previous observer origin needs to be remembered somewhere. This is done by the caller providing an MemCore::Intercube object, for instance the VObject::State, but it can also be an Intercube attached to each of multiple data fragments. Then, provide this Intercube object to the getTranslationVector() function with an explicit argument.
| VRenderContext::ModelViewState Wizt::FloatOrigin::getCoordinateTranslation | ( | const VRenderContext & | Context, |
| Eagle::tvector3 & | TranslationVector | ||
| ) | const |
Get the coordinate translaton as cached at the object's local
state.
This might be problematic, it is better to cache the float
origin at a better suitable object.
@param TranslationVector output only - the translation vector by which
coordinates need to be shifted
Referenced by Wizt::BaseCursor3D::environment_render().
|
static |
The core function.
This function computes a translation vector as required for shifting coordinates. It also shifts the model view matrix if required, so this function must be called in advance of any rendering that uses the same translation vector shift.
References MemCore::Intercube::addInterface().