Package com.ardor3d.ui.text
Class BMText
java.lang.Object
com.ardor3d.scenegraph.Spatial
com.ardor3d.scenegraph.Mesh
com.ardor3d.ui.text.BMText
- All Implemented Interfaces:
Pickable
,Hintable
,Renderable
,Savable
- Direct Known Subclasses:
BasicText
Text spatial which uses textures generated by BMFont
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Alignment of the text block from the pivot pointstatic enum
static enum
static enum
Justification within a text block -
Field Summary
Modifier and TypeFieldDescriptionprotected BMText.Align
protected final Vector2
protected BMText.AutoFade
protected boolean
protected BMText.AutoScale
protected final Vector2
protected final Vector2
protected int
protected BMFont
protected double
protected BMText.Justify
protected final Vector3
protected int
protected float[]
protected final List
<BMTextChangeListener> protected final Vector3
protected final Matrix3
protected float
protected final Vector2
protected int
protected ColorRGBA
protected ColorRGBA
protected String
protected boolean
Fields inherited from class com.ardor3d.scenegraph.Mesh
_defaultColor, _isVisible, _lightState, _meshData, _modelBound, _states, RENDER_VERTEX_ONLY
Fields inherited from class com.ardor3d.scenegraph.Spatial
_controllers, _delegateMap, _dirtyMark, _frustumIntersects, _listener, _localTransform, _name, _parent, _queueDistance, _renderStateList, _sceneHints, _userData, _worldBound, _worldTransform, ON_DIRTY_ATTACHED, ON_DIRTY_BOUNDING, ON_DIRTY_RENDERSTATE, ON_DIRTY_TRANSFORM, ON_DIRTY_TRANSFORM_ONLY
-
Constructor Summary
ModifierConstructorDescriptionprotected
BMText()
BMText
(String sName, String text, BMFont font, BMText.Align align) BMText
(String sName, String text, BMFont font, BMText.Align align, BMText.Justify justify) BMText
(String sName, String text, BMFont font, BMText.Align align, BMText.Justify justify, boolean useBlend) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(BMTextChangeListener listener) protected void
addToLineSizes
(float sizeX, int lineIndex) protected void
protected void
calculateSize
(String text) protected void
checkBuffers
(String text) Check whether buffers have sufficient capacity to hold current string values; if not, increase capacity and set the limit.void
correctTransform
(Camera cam) protected void
distanceAlphaFade
(ReadOnlyVector2 range, double distance) Set transparency based on distance from camera to text. if (distance < range.x) then opaque, if (distance > range.y) then transparent, else lerpvoid
draw
abstract method that handles drawing data to the renderer if it is geometry and passing the call to it's children if it is a node.getAlign()
int
boolean
getFont()
double
float
get height in world unitsprotected float
getJustificationXOffset
(int lineIndex) int
getSize()
getText()
boolean
float
getWidth()
get width in world unitsstatic BMText
makeCopy
(boolean shareGeometricData) Create a copy of this spatial.boolean
removeChangeListener
(BMTextChangeListener listener) protected void
screenSizeCapAlphaFade
(double capSize, double depthScale, float alphaFallof) Set transparency based on native screen size.void
setAlign
(BMText.Align align) void
setAutoFade
(BMText.AutoFade autoFade) void
setAutoFadeDistanceRange
(double nearOpaque, double farTransparent) void
setAutoFadeFalloff
(float factor) alpha falloff factor used when FixedPixelSize or CapScreenSize is used.void
setAutoFadeFixedPixelSize
(int pixelSize) void
setAutoRotate
(boolean doAutoTransform) automatically rotate test to face the cameravoid
setAutoScale
(BMText.AutoScale autoScale) Set scaling policyvoid
setFixedOffset
(double x, double y) set a fixed offset from the alignment center of rotation IN FONT UNITSvoid
setFixedOffset
(ReadOnlyVector2 offset) set a fixed offset from the alignment center of rotation IN FONT UNITSvoid
void
setFontScale
(double scale) If AutoScale is enabled, this scale parameter acts as a bias.void
setJustify
(BMText.Justify justify) void
Set text string and recreate geometryvoid
setTextColor
(float r, float g, float b, float a) void
void
setUseBlend
(boolean useBlend) void
updateScaleAndAlpha
(Camera cam, Renderer r) Update the text's scaleMethods inherited from class com.ardor3d.scenegraph.Mesh
applyWorldRenderStates, getClassTag, getDefaultColor, getLightState, getMeshData, getModelBound, getModelBound, getWorldNormals, getWorldRenderState, getWorldVectors, intersectsPrimitivesWhere, intersectsWorldBound, intersectsWorldBoundsWhere, isVisible, makeInstanced, read, render, render, renderArrays, renderVBO, reorderIndices, reorderVertexData, reorderVertexData, setDefaultColor, setDefaultColor, setLightState, setMeshData, setModelBound, setModelBound, setRandomColors, setSolidColor, setVisible, sortLights, supportsBoundsIntersectionRecord, supportsPrimitivesIntersectionRecord, updateModelBound, updateWorldBound, write
Methods inherited from class com.ardor3d.scenegraph.Spatial
acceptVisitor, addController, addTranslation, addTranslation, clearControllers, clearDirty, clearDirty, clearRenderState, getController, getControllerCount, getControllers, getCurrentRenderDelegate, getLastFrustumIntersection, getListener, getLocalLastFrustumIntersection, getLocalRenderState, getLocalRenderStates, getName, getParent, getParentHintable, getRenderDelegate, getRotation, getScale, getSceneHints, getTransform, getTranslation, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, isDirty, localToWorld, markDirty, markDirty, onDraw, propagateBoundToRoot, propagateDirtyDown, propagateDirtyUp, propagateStatesFromRoot, propageEventUp, removeController, removeController, removeFromParent, setLastFrustumIntersection, setListener, setName, setParent, setRenderDelegate, setRenderState, setRotation, setRotation, setScale, setScale, setScale, setTransform, setTranslation, setTranslation, setUserData, setWorldRotation, setWorldRotation, setWorldScale, setWorldScale, setWorldScale, setWorldTransform, setWorldTranslation, setWorldTranslation, toString, updateChildren, updateControllers, updateGeometricState, updateGeometricState, updateWorldRenderStates, updateWorldRenderStates, updateWorldTransform, worldToLocal
-
Field Details
-
_font
-
_textString
-
_fontScale
protected double _fontScale -
_autoRotate
protected boolean _autoRotate -
_lines
protected int _lines -
_size
-
_lineWidths
protected float[] _lineWidths -
_textClr
-
_tempClr
-
_listeners
-
_autoScale
-
_autoFade
-
_fixedPixelAlphaThresh
protected int _fixedPixelAlphaThresh -
_screenSizeAlphaFalloff
protected float _screenSizeAlphaFalloff -
_distanceAlphaRange
-
_useBlend
protected boolean _useBlend -
_justify
-
_spacing
protected int _spacing -
_align
-
_alignOffset
-
_fixedOffset
-
_look
-
_left
-
_rot
-
-
Constructor Details
-
BMText
protected BMText() -
BMText
- Parameters:
sName
- the spatial nametext
- the text to renderfont
- the font
-
BMText
-
BMText
-
BMText
public BMText(String sName, String text, BMFont font, BMText.Align align, BMText.Justify justify, boolean useBlend) - Parameters:
sName
- the spatial nametext
- the text to render.font
- the fontalign
- the alignmentjustify
- the justificationuseBlend
- if true: use alpha blending and use transparent render bucket, else if false: alpha test only and use opaque render bucket
-
-
Method Details
-
initSavable
-
setTextColor
-
setTextColor
public void setTextColor(float r, float g, float b, float a) -
setFontScale
public void setFontScale(double scale) If AutoScale is enabled, this scale parameter acts as a bias. Setting the scale to 0.95 will sharpen the font and increase readability a bit if you're using a bilinear min filter on the texture. When AutoScale is disabled, this scales the font to world units, e.g. setScale(1) would make the font characters approximately 1 world unit in size, regardless of the font point size.- Parameters:
scale
- the scale
-
getFontScale
public double getFontScale() -
setAutoScale
Set scaling policy- Parameters:
autoScale
- the scale policy to set
-
getAutoScale
-
setAutoFade
-
getAutoFade
-
setAutoFadeFixedPixelSize
public void setAutoFadeFixedPixelSize(int pixelSize) -
getAutoFadeFixedPixelSize
public int getAutoFadeFixedPixelSize() -
setAutoFadeFalloff
public void setAutoFadeFalloff(float factor) alpha falloff factor used when FixedPixelSize or CapScreenSize is used. Can be any positive value; useful range is ~ 0-2- 0 = transparent instantaneously
- 1 = transparent when approximately 1/2 size
- Parameters:
factor
- the fall-off factor to set
-
setAutoFadeDistanceRange
public void setAutoFadeDistanceRange(double nearOpaque, double farTransparent) - Parameters:
nearOpaque
- text is completely opaque when distance between camera and text is less than this valuefarTransparent
- text is completely transparent when distance between camera and text is greater than this value
-
setAutoRotate
public void setAutoRotate(boolean doAutoTransform) automatically rotate test to face the camera- Parameters:
doAutoTransform
-true
if the automatic rotation is enabled
-
getAutoRotate
public boolean getAutoRotate() -
draw
Description copied from class:Spatial
draw
abstract method that handles drawing data to the renderer if it is geometry and passing the call to it's children if it is a node. -
correctTransform
- Parameters:
cam
- the camera
-
updateScaleAndAlpha
Update the text's scale- Parameters:
cam
- the camerar
- the renderer
-
screenSizeCapAlphaFade
protected void screenSizeCapAlphaFade(double capSize, double depthScale, float alphaFallof) Set transparency based on native screen size.- Parameters:
capSize
- 1/(font point size)depthScale
- the depth scalealphaFallof
- the alpha fall-off
-
distanceAlphaFade
Set transparency based on distance from camera to text. if (distance < range.x) then opaque, if (distance > range.y) then transparent, else lerp- Parameters:
range
- the rangedistance
- the distance
-
getWidth
public float getWidth()get width in world units- Returns:
- the width in world units
-
getHeight
public float getHeight()get height in world units- Returns:
- the height in world units
-
addToLineSizes
protected void addToLineSizes(float sizeX, int lineIndex) -
calculateSize
- Parameters:
text
- the text to render
-
calculateAlignmentOffset
protected void calculateAlignmentOffset() -
checkBuffers
Check whether buffers have sufficient capacity to hold current string values; if not, increase capacity and set the limit.- Parameters:
text
- the text to render
-
getJustificationXOffset
protected float getJustificationXOffset(int lineIndex) -
getFont
-
setFont
-
setUseBlend
public void setUseBlend(boolean useBlend) - Parameters:
useBlend
- if true: use alpha blending and use transparent render bucket, else if false: alpha test only and use opaque render bucket
-
getUseBlend
public boolean getUseBlend() -
setText
Set text string and recreate geometry- Parameters:
text
- the text to render
-
getText
-
setAlign
- Parameters:
align
- the alignment
-
getAlign
-
setJustify
-
getJustify
-
setFixedOffset
public void setFixedOffset(double x, double y) set a fixed offset from the alignment center of rotation IN FONT UNITS- Parameters:
x
- the x value of the offsety
- the y value of the offset
-
setFixedOffset
set a fixed offset from the alignment center of rotation IN FONT UNITS- Parameters:
offset
- the offset
-
getLineCount
public int getLineCount() -
getFixedOffset
-
getSize
-
addChangeListener
-
removeChangeListener
-
makeCopy
Description copied from class:Spatial
Create a copy of this spatial.
-