#include <renderable3dtextcomponent.h>
Public Member Functions | |
Renderable3DTextComponentInstance (EntityInstance &entity, Component &resource) | |
virtual bool | init (utility::ErrorState &errorState) override |
void | normalizeText (bool enable) |
bool | isNormalized () const |
bool | computeNormalizationFactor (const std::string &referenceText) |
virtual RenderableGlyph * | getRenderableGlyph (uint index, float scale, utility::ErrorState &error) const override |
![]() | |
RenderableTextComponentInstance (EntityInstance &entity, Component &resource) | |
const FontInstance & | getFont () const |
bool | setText (const std::string &text, utility::ErrorState &error) |
void | setColor (const glm::vec3 &color) |
bool | setText (int lineIndex, const std::string &text, utility::ErrorState &error) |
bool | addLine (const std::string &text, utility::ErrorState &error) |
void | setLineIndex (int index) |
const std::string & | getText () |
const std::string & | getText (int index) |
void | resize (int lines) |
int | getCount () const |
void | clear () |
const math::Rect & | getBoundingBox () const |
const math::Rect & | getBoundingBox (int index) |
const MaterialInstance & | getMaterialInstance () const |
MaterialInstance & | getMaterialInstance () |
float | getDPIScale () const |
![]() | |
RenderableComponentInstance (EntityInstance &entity, Component &resource) | |
void | draw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix) |
void | setVisible (bool visible) |
bool | isVisible () const |
virtual bool | isSupported (nap::CameraComponentInstance &camera) const |
![]() | |
ComponentInstance (EntityInstance &entity, Component &resource) | |
virtual void | update (double deltaTime) |
nap::EntityInstance * | getEntityInstance () const |
nap::Component * | getComponent () const |
template<typename T > | |
T * | getComponent () const |
![]() | |
Object () | |
virtual | ~Object () |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (Object &&)=delete |
Protected Member Functions | |
virtual void | onDraw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix) override |
![]() | |
void | draw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix, const glm::mat4 &modelMatrix) |
bool | hasTransform () const |
const nap::TransformComponentInstance * | getTransform () const |
virtual bool | setup (float scale, utility::ErrorState &errorState) |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
![]() | |
FontInstance * | mFont = nullptr |
Pointer to the font, set on initialization. More... | |
RenderService * | mRenderService = nullptr |
Pointer to the Renderer. More... | |
Runtime version of the Renderable3DTextComponent. This component allows you to render flat text at a specific location in the world.
3D text can only be rendered using the render service, similar to how 3D meshes are rendered. The text can be transformed, scaled and rotated. It's best to render 3D text using a perspective camera. The font size directly influences the size of the text unless normalization is turned on. When normalization is turned on the text is rendered centered on the origin with -0.5-0,5 bounds.
It is possible to cache multiple lines at once, where each line can be selected and drawn individually inside a render loop. This is useful when you want the same component to render multiple lines of text, removing the need to declare a component for each individual line. You cannot update or add a line of text when rendering a frame: inside the render loop. Only update or add new lines of text on update. You can however change the position and line of text to draw inside the render loop.
Renderable3DTextComponentInstance | ( | EntityInstance & | entity, |
Component & | resource | ||
) |
bool computeNormalizationFactor | ( | const std::string & | referenceText | ) |
Calculates normalization factor based on the given reference text. This is called automatically on initialization but can be changed at runtime. Caching this value ensures that at runtime the size of the text doesn't change when normalization is turned on.
referenceText | text used to calculate the normalization factor |
|
overridevirtual |
Creates a Renderable2DMipMapGlyph using the given character index and scale.
index | the index to create the render-able glyph for. |
scale | the render-able glyph scaling factor. |
error | contains the error if the glyph representation could not be created. |
Implements RenderableTextComponentInstance.
|
overridevirtual |
Initialize Renderable3DTextComponentInstance based on the Renderable3DTextComponent resource
errorState | should hold the error message when initialization fails |
Reimplemented from RenderableTextComponentInstance.
bool isNormalized | ( | ) | const |
void normalizeText | ( | bool | enable | ) |
Enables or disables normalization. Normalized text is centered around the origin with approx -0.5 / 0.5 bounds The normalization factor is based on reference text which can be updated by calling: computeNormalizationFactor() Calling computeNormalizationFactor() ensures that the size of the letters don't change size at runtime.
enable | disable or enable normalization |
|
overrideprotectedvirtual |
Draws the text to the currently active render target using the render service. The size of the text is directly related to the size of the font. This function is called by the render service when text is rendered with a user defined camera. In that case the viewMatrix is the world space camera location and the the projection matrix is defined by the camera type. This can be orthographic or perspective. It is recommended to only use a perspective camera when rendering text in 3D. The TransformComponent of the parent entity is used to place the text and is therefore required.
renderTarget | target to render to |
commandBuffer | current command buffer |
viewMatrix | the camera world space location |
projectionMatrix | the camera projection matrix, orthographic or perspective |
Implements RenderableComponentInstance.