APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.graphics.g3d.decals

public Class Decal

extends Object
Class Inheritance
Imports
com.badlogic.gdx.graphics.Color, .GL20, com.badlogic.gdx.graphics.g2d.TextureRegion, com.badlogic.gdx.math.Quaternion, .Vector2, .Vector3, com.badlogic.gdx.utils.NumberUtils

Represents a sprite in 3d space. Typical 3d transformations such as translation, rotation and scaling are supported. The position includes a z component other than setting the depth no manual layering has to be performed, correct overlay is guaranteed by using the depth buffer.

Decals are handled by the DecalBatch.

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
protected Color
protected Vector2
pack-priv static final Vector3
protected DecalMaterial
protected Vector3
protected Quaternion
protected static Quaternion
protected Vector2
public static final int
SIZE

Size of the decal in floats.

private static Vector3
tmp

Temporary vector for various calculations.

private static Vector3
public Vector2
transformationOffset

The transformation offset can be used to change the pivot point for rotation and scaling.

public static final int
public static final int
public static final int
public static final int
protected boolean
public static final int
public static final int
public static final int
public static final int
public int
value

Set a multipurpose value which can be queried and used for things like group identification.

private static final int
VERTEX_SIZE

Size of a decal vertex in floats

protected float[]
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public
public
Decal(DecalMaterial material)

Method Summary

Modifier and TypeMethod and Description
public Color

Returns:

The color of this decal.
getColor
()

Returns the color of this decal.

public float
getHeight()

Returns: height in world units

public DecalMaterial
public Vector3

Returns:

vector representing the position
getPosition
()

Returns the position of this decal.

public Quaternion

Returns:

Quaternion representing the rotation
getRotation
()

Returns the rotation.

public float
getScaleX()

Returns: Scale on the x axis

public float
getScaleY()

Returns: Scale on the y axis

public TextureRegion
getTextureRegion()

Returns: the texture region this Decal uses.

public float[]

Returns:

vertex array backing the decal
getVertices
()

Returns the vertices backing this sprite.

public float
getWidth()

Returns: width in world units

public float
getX()

Returns: position on the x axis

public float
getY()

Returns: position on the y axis

public float
getZ()

Returns: position on the z axis

public void
lookAt(Vector3 position, Vector3 up)

Sets the rotation of the Decal to face the given point.

public static Decal

Returns:

Created decal
newDecal
(TextureRegion
Texture region to use
textureRegion
)

Creates a decal assuming the dimensions of the texture region

public static Decal

Returns:

Created decal
newDecal
(TextureRegion
Texture region to use
textureRegion
,
boolean
Whether or not this sprite will be treated as having transparency (transparent png, etc.)
hasTransparency
)

Creates a decal assuming the dimensions of the texture region and adding transparency

public static Decal

Returns:

Created decal
newDecal
(float
Width of the decal in world units
width
,
float
Height of the decal in world units
height
,
TextureRegion
TextureRegion to use
textureRegion
)

Creates a decal using the region for texturing

public static Decal

Returns:

Created decal
newDecal
(float
Width of the decal in world units
width
,
float
Height of the decal in world units
height
,
TextureRegion
TextureRegion to use
textureRegion
,
boolean
Whether or not this sprite will be treated as having transparency (transparent png, etc.)
hasTransparency
)

Creates a decal using the region for texturing

public static Decal

Returns:

Created decal
newDecal
(float
Width of the decal in world units
width
,
float
Height of the decal in world units
height
,
TextureRegion
TextureRegion to use
textureRegion
,
int
Source blend used by glBlendFunc
srcBlendFactor
,
int
Destination blend used by glBlendFunc
dstBlendFactor
)

Creates a decal using the region for texturing and the specified blending parameters for blending

public static Decal

Returns:

Created decal
newDecal
(float
Width of the decal in world units
width
,
float
Height of the decal in world units
height
,
TextureRegion
TextureRegion to use
textureRegion
,
int
Source blend used by glBlendFunc
srcBlendFactor
,
int
Destination blend used by glBlendFunc
dstBlendFactor
,
DecalMaterial
Custom decal material
material
)

Creates a decal using the region for texturing and the specified blending parameters for blending

protected void
resetVertices()

Resets the position components of the vertices array based ont he dimensions (preparation for transformation)

public void
rotateX(float
Angle in degrees to rotate by
angle
)

Rotates along local X axis by the specified angle

public void
rotateY(float
Angle in degrees to rotate by
angle
)

Rotates along local Y axis by the specified angle

public void
rotateZ(float
Angle in degrees to rotate by
angle
)

Rotates along local Z axis by the specified angle

public void
setBlending(int
Source blend factor used by glBlendFunc
srcBlendFactor
,
int
Destination blend factor used by glBlendFunc
dstBlendFactor
)

Sets the blending parameters for this decal

public void
setColor(float
Red component
r
,
float
Green component
g
,
float
Blue component
b
,
float
Alpha component
a
)

Sets the color of all four vertices to the specified color

public void
setColor(Color tint)

Sets the color used to tint this decal.

public void
setDimensions(float
Width in world units
width
,
float
Height in world units
height
)

Sets the width and height in world units

public void
setHeight(float
Height in world units
height
)

Sets the height in world units

public void
setMaterial(DecalMaterial
custom material
material
)

Set material

public void
setPackedColor(float color)

Sets the color of this decal, expanding the alpha from 0-254 to 0-255.

public void
setPosition(float
X position
x
,
float
Y Position
y
,
float
Z Position
z
)

Sets the position to the given world coordinates

public void
public void
setRotation(float
Angle in degrees to rotate around the Y axis
yaw
,
float
Angle in degrees to rotate around the X axis
pitch
,
float
Angle in degrees to rotate around the Z axis
roll
)

Sets the rotation of this decal to the given angles on all axes.

public void
setRotation(Vector3
the direction vector
dir
,
Vector3
the up vector
up
)

Sets the rotation of this decal based on the (normalized) direction and up vector.

public void
setRotation(Quaternion
desired Rotation
q
)

Sets the rotation of this decal based on the provided Quaternion

public void
setRotationX(float
Angle in degrees to set rotation to
angle
)

Sets the rotation on the local X axis to the specified angle

public void
setRotationY(float
Angle in degrees to set rotation to
angle
)

Sets the rotation on the local Y axis to the specified angle

public void
setRotationZ(float
Angle in degrees to set rotation to
angle
)

Sets the rotation on the local Z axis to the specified angle

public void
setScale(float
Scale on the x axis
scaleX
,
float
Scale on the y axis
scaleY
)

Sets scale along both the x and y axis

public void
setScale(float
New scale
scale
)

Sets scale along both the x and y axis

public void
setScaleX(float
New scale along x axis
scale
)

Sets scale along the x axis

public void
setScaleY(float
New scale along y axis
scale
)

Sets scale along the y axis

public void
setTextureRegion(TextureRegion
Texture region to apply
textureRegion
)

Sets the texture region

public void
setWidth(float
Width in world units
width
)

Sets the width in world units

public void
setX(float
Position to locate the decal at
x
)

Sets the position on the x axis

public void
setY(float
Position to locate the decal at
y
)

Sets the position on the y axis

public void
setZ(float
Position to locate the decal at
z
)

Sets the position on the z axis

protected void
transformVertices()

Transforms the position component of the vertices using properties such as position, scale, etc.

public void
translate(float
Units to move along the x axis
x
,
float
Units to move along the y axis
y
,
float
Units to move along the z axis
z
)

Translates by the specified amount of units

public void
public void
translateX(float
Units to move the decal
units
)

Moves by the specified amount of units along the x axis

public void
translateY(float
Units to move the decal
units
)

Moves by the specified amount of units along the y axis

public void
translateZ(float
Units to move the decal
units
)

Moves by the specified amount of units along the z axis

protected void
update()

Recalculates vertices array if it grew out of sync with the properties (position, ..)

protected void
updateUVs()

Re-applies the uv coordinates from the material's texture region to the uv components of the vertices array

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

C1back to summary
public static final int C1
C2back to summary
public static final int C2
C3back to summary
public static final int C3
C4back to summary
public static final int C4
colorback to summary
protected Color color
dimensionsback to summary
protected Vector2 dimensions
dirback to summary
pack-priv static final Vector3 dir
materialback to summary
protected DecalMaterial material
positionback to summary
protected Vector3 position
rotationback to summary
protected Quaternion rotation
rotatorback to summary
protected static Quaternion rotator
scaleback to summary
protected Vector2 scale
SIZEback to summary
public static final int SIZE

Size of the decal in floats. It takes a float[SIZE] to hold the decal.

tmpback to summary
private static Vector3 tmp

Temporary vector for various calculations.

tmp2back to summary
private static Vector3 tmp2
transformationOffsetback to summary
public Vector2 transformationOffset

The transformation offset can be used to change the pivot point for rotation and scaling. By default the pivot is the middle of the decal.

U1back to summary
public static final int U1
U2back to summary
public static final int U2
U3back to summary
public static final int U3
U4back to summary
public static final int U4
updatedback to summary
protected boolean updated
V1back to summary
public static final int V1
V2back to summary
public static final int V2
V3back to summary
public static final int V3
V4back to summary
public static final int V4
valueback to summary
public int value

Set a multipurpose value which can be queried and used for things like group identification.

VERTEX_SIZEback to summary
private static final int VERTEX_SIZE

Size of a decal vertex in floats

verticesback to summary
protected float[] vertices
X1back to summary
public static final int X1
X2back to summary
public static final int X2
X3back to summary
public static final int X3
X4back to summary
public static final int X4
Y1back to summary
public static final int Y1
Y2back to summary
public static final int Y2
Y3back to summary
public static final int Y3
Y4back to summary
public static final int Y4
Z1back to summary
public static final int Z1
Z2back to summary
public static final int Z2
Z3back to summary
public static final int Z3
Z4back to summary
public static final int Z4

Constructor Detail

Decalback to summary
public Decal()
Decalback to summary
public Decal(DecalMaterial material)

Method Detail

getColorback to summary
public Color getColor()

Returns the color of this decal. The returned color should under no circumstances be modified.

Returns:Color

The color of this decal.

getHeightback to summary
public float getHeight()
Returns:float

height in world units

getMaterialback to summary
public DecalMaterial getMaterial()
getPositionback to summary
public Vector3 getPosition()

Returns the position of this decal. The returned vector should under no circumstances be modified.

Returns:Vector3

vector representing the position

getRotationback to summary
public Quaternion getRotation()

Returns the rotation. The returned quaternion should under no circumstances be modified.

Returns:Quaternion

Quaternion representing the rotation

getScaleXback to summary
public float getScaleX()
Returns:float

Scale on the x axis

getScaleYback to summary
public float getScaleY()
Returns:float

Scale on the y axis

getTextureRegionback to summary
public TextureRegion getTextureRegion()
Returns:TextureRegion

the texture region this Decal uses. Do not modify it!

getVerticesback to summary
public float[] getVertices()

Returns the vertices backing this sprite.
The returned value should under no circumstances be modified.

Returns:float[]

vertex array backing the decal

getWidthback to summary
public float getWidth()
Returns:float

width in world units

getXback to summary
public float getX()
Returns:float

position on the x axis

getYback to summary
public float getY()
Returns:float

position on the y axis

getZback to summary
public float getZ()
Returns:float

position on the z axis

lookAtback to summary
public void lookAt(Vector3 position, Vector3 up)

Sets the rotation of the Decal to face the given point. Useful for billboarding.

newDecalback to summary
public static Decal newDecal(TextureRegion textureRegion)

Creates a decal assuming the dimensions of the texture region

Parameters
textureRegion:TextureRegion

Texture region to use

Returns:Decal

Created decal

newDecalback to summary
public static Decal newDecal(TextureRegion textureRegion, boolean hasTransparency)

Creates a decal assuming the dimensions of the texture region and adding transparency

Parameters
textureRegion:TextureRegion

Texture region to use

hasTransparency:boolean

Whether or not this sprite will be treated as having transparency (transparent png, etc.)

Returns:Decal

Created decal

newDecalback to summary
public static Decal newDecal(float width, float height, TextureRegion textureRegion)

Creates a decal using the region for texturing

Parameters
width:float

Width of the decal in world units

height:float

Height of the decal in world units

textureRegion:TextureRegion

TextureRegion to use

Returns:Decal

Created decal

newDecalback to summary
public static Decal newDecal(float width, float height, TextureRegion textureRegion, boolean hasTransparency)

Creates a decal using the region for texturing

Parameters
width:float

Width of the decal in world units

height:float

Height of the decal in world units

textureRegion:TextureRegion

TextureRegion to use

hasTransparency:boolean

Whether or not this sprite will be treated as having transparency (transparent png, etc.)

Returns:Decal

Created decal

newDecalback to summary
public static Decal newDecal(float width, float height, TextureRegion textureRegion, int srcBlendFactor, int dstBlendFactor)

Creates a decal using the region for texturing and the specified blending parameters for blending

Parameters
width:float

Width of the decal in world units

height:float

Height of the decal in world units

textureRegion:TextureRegion

TextureRegion to use

srcBlendFactor:int

Source blend used by glBlendFunc

dstBlendFactor:int

Destination blend used by glBlendFunc

Returns:Decal

Created decal

newDecalback to summary
public static Decal newDecal(float width, float height, TextureRegion textureRegion, int srcBlendFactor, int dstBlendFactor, DecalMaterial material)

Creates a decal using the region for texturing and the specified blending parameters for blending

Parameters
width:float

Width of the decal in world units

height:float

Height of the decal in world units

textureRegion:TextureRegion

TextureRegion to use

srcBlendFactor:int

Source blend used by glBlendFunc

dstBlendFactor:int

Destination blend used by glBlendFunc

material:DecalMaterial

Custom decal material

Returns:Decal

Created decal

resetVerticesback to summary
protected void resetVertices()

Resets the position components of the vertices array based ont he dimensions (preparation for transformation)

rotateXback to summary
public void rotateX(float angle)

Rotates along local X axis by the specified angle

Parameters
angle:float

Angle in degrees to rotate by

rotateYback to summary
public void rotateY(float angle)

Rotates along local Y axis by the specified angle

Parameters
angle:float

Angle in degrees to rotate by

rotateZback to summary
public void rotateZ(float angle)

Rotates along local Z axis by the specified angle

Parameters
angle:float

Angle in degrees to rotate by

setBlendingback to summary
public void setBlending(int srcBlendFactor, int dstBlendFactor)

Sets the blending parameters for this decal

Parameters
srcBlendFactor:int

Source blend factor used by glBlendFunc

dstBlendFactor:int

Destination blend factor used by glBlendFunc

setColorback to summary
public void setColor(float r, float g, float b, float a)

Sets the color of all four vertices to the specified color

Parameters
r:float

Red component

g:float

Green component

b:float

Blue component

a:float

Alpha component

setColorback to summary
public void setColor(Color tint)

Sets the color used to tint this decal. Default is Color#WHITE.

setDimensionsback to summary
public void setDimensions(float width, float height)

Sets the width and height in world units

Parameters
width:float

Width in world units

height:float

Height in world units

setHeightback to summary
public void setHeight(float height)

Sets the height in world units

Parameters
height:float

Height in world units

setMaterialback to summary
public void setMaterial(DecalMaterial material)

Set material

Parameters
material:DecalMaterial

custom material

setPackedColorback to summary
public void setPackedColor(float color)

Sets the color of this decal, expanding the alpha from 0-254 to 0-255.

See Also
setColor(Color)
setPositionback to summary
public void setPosition(float x, float y, float z)

Sets the position to the given world coordinates

Parameters
x:float

X position

y:float

Y Position

z:float

Z Position

setPositionback to summary
public void setPosition(Vector3 pos)
See Also
Decal#setPosition(float, float, float)
setRotationback to summary
public void setRotation(float yaw, float pitch, float roll)

Sets the rotation of this decal to the given angles on all axes.

Parameters
yaw:float

Angle in degrees to rotate around the Y axis

pitch:float

Angle in degrees to rotate around the X axis

roll:float

Angle in degrees to rotate around the Z axis

setRotationback to summary
public void setRotation(Vector3 dir, Vector3 up)

Sets the rotation of this decal based on the (normalized) direction and up vector.

Parameters
dir:Vector3

the direction vector

up:Vector3

the up vector

setRotationback to summary
public void setRotation(Quaternion q)

Sets the rotation of this decal based on the provided Quaternion

Parameters
q:Quaternion

desired Rotation

setRotationXback to summary
public void setRotationX(float angle)

Sets the rotation on the local X axis to the specified angle

Parameters
angle:float

Angle in degrees to set rotation to

setRotationYback to summary
public void setRotationY(float angle)

Sets the rotation on the local Y axis to the specified angle

Parameters
angle:float

Angle in degrees to set rotation to

setRotationZback to summary
public void setRotationZ(float angle)

Sets the rotation on the local Z axis to the specified angle

Parameters
angle:float

Angle in degrees to set rotation to

setScaleback to summary
public void setScale(float scaleX, float scaleY)

Sets scale along both the x and y axis

Parameters
scaleX:float

Scale on the x axis

scaleY:float

Scale on the y axis

setScaleback to summary
public void setScale(float scale)

Sets scale along both the x and y axis

Parameters
scale:float

New scale

setScaleXback to summary
public void setScaleX(float scale)

Sets scale along the x axis

Parameters
scale:float

New scale along x axis

setScaleYback to summary
public void setScaleY(float scale)

Sets scale along the y axis

Parameters
scale:float

New scale along y axis

setTextureRegionback to summary
public void setTextureRegion(TextureRegion textureRegion)

Sets the texture region

Parameters
textureRegion:TextureRegion

Texture region to apply

setWidthback to summary
public void setWidth(float width)

Sets the width in world units

Parameters
width:float

Width in world units

setXback to summary
public void setX(float x)

Sets the position on the x axis

Parameters
x:float

Position to locate the decal at

setYback to summary
public void setY(float y)

Sets the position on the y axis

Parameters
y:float

Position to locate the decal at

setZback to summary
public void setZ(float z)

Sets the position on the z axis

Parameters
z:float

Position to locate the decal at

transformVerticesback to summary
protected void transformVertices()

Transforms the position component of the vertices using properties such as position, scale, etc.

translateback to summary
public void translate(float x, float y, float z)

Translates by the specified amount of units

Parameters
x:float

Units to move along the x axis

y:float

Units to move along the y axis

z:float

Units to move along the z axis

translateback to summary
public void translate(Vector3 trans)
See Also
Decal#translate(float, float, float)
translateXback to summary
public void translateX(float units)

Moves by the specified amount of units along the x axis

Parameters
units:float

Units to move the decal

translateYback to summary
public void translateY(float units)

Moves by the specified amount of units along the y axis

Parameters
units:float

Units to move the decal

translateZback to summary
public void translateZ(float units)

Moves by the specified amount of units along the z axis

Parameters
units:float

Units to move the decal

updateback to summary
protected void update()

Recalculates vertices array if it grew out of sync with the properties (position, ..)

updateUVsback to summary
protected void updateUVs()

Re-applies the uv coordinates from the material's texture region to the uv components of the vertices array