Class Decal
- java.lang.Object
-
- com.badlogic.gdx.graphics.g3d.decals.Decal
-
public class Decal extends java.lang.ObjectRepresents 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 theDecalBatch.
-
-
Field Summary
Fields Modifier and Type Field Description static intC1static intC2static intC3static intC4protected Colorcolorprotected Vector2dimensionsprotected DecalMaterialmaterialprotected Vector3positionprotected Quaternionrotationprotected static Quaternionrotatorprotected Vector2scalestatic intSIZESize of the decal in floats.Vector2transformationOffsetThe transformation offset can be used to change the pivot point for rotation and scaling.static intU1static intU2static intU3static intU4protected booleanupdatedstatic intV1static intV2static intV3static intV4intvalueSet a multipurpose value which can be queried and used for things like group identification.protected float[]verticesstatic intX1static intX2static intX3static intX4static intY1static intY2static intY3static intY4static intZ1static intZ2static intZ3static intZ4
-
Constructor Summary
Constructors Constructor Description Decal()Decal(DecalMaterial material)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ColorgetColor()Returns the color of this decal.floatgetHeight()DecalMaterialgetMaterial()Vector3getPosition()Returns the position of this decal.QuaterniongetRotation()Returns the rotation.floatgetScaleX()floatgetScaleY()TextureRegiongetTextureRegion()float[]getVertices()Returns the vertices backing this sprite.
The returned value should under no circumstances be modified.floatgetWidth()floatgetX()floatgetY()floatgetZ()voidlookAt(Vector3 position, Vector3 up)Sets the rotation of the Decal to face the given point.static DecalnewDecal(float width, float height, TextureRegion textureRegion)Creates a decal using the region for texturingstatic DecalnewDecal(float width, float height, TextureRegion textureRegion, boolean hasTransparency)Creates a decal using the region for texturingstatic DecalnewDecal(float width, float height, TextureRegion textureRegion, int srcBlendFactor, int dstBlendFactor)Creates a decal using the region for texturing and the specified blending parameters for blendingstatic DecalnewDecal(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 blendingstatic DecalnewDecal(TextureRegion textureRegion)Creates a decal assuming the dimensions of the texture regionstatic DecalnewDecal(TextureRegion textureRegion, boolean hasTransparency)Creates a decal assuming the dimensions of the texture region and adding transparencyprotected voidresetVertices()Resets the position components of the vertices array based ont he dimensions (preparation for transformation)voidrotateX(float angle)Rotates along local X axis by the specified anglevoidrotateY(float angle)Rotates along local Y axis by the specified anglevoidrotateZ(float angle)Rotates along local Z axis by the specified anglevoidsetBlending(int srcBlendFactor, int dstBlendFactor)Sets the blending parameters for this decalvoidsetColor(float r, float g, float b, float a)Sets the color of all four vertices to the specified colorvoidsetColor(Color tint)Sets the color used to tint this decal.voidsetDimensions(float width, float height)Sets the width and height in world unitsvoidsetHeight(float height)Sets the height in world unitsvoidsetMaterial(DecalMaterial material)Set materialvoidsetPackedColor(float color)Sets the color of this decal, expanding the alpha from 0-254 to 0-255.voidsetPosition(float x, float y, float z)Sets the position to the given world coordinatesvoidsetPosition(Vector3 pos)voidsetRotation(float yaw, float pitch, float roll)Sets the rotation of this decal to the given angles on all axes.voidsetRotation(Quaternion q)Sets the rotation of this decal based on the provided QuaternionvoidsetRotation(Vector3 dir, Vector3 up)Sets the rotation of this decal based on the (normalized) direction and up vector.voidsetRotationX(float angle)Sets the rotation on the local X axis to the specified anglevoidsetRotationY(float angle)Sets the rotation on the local Y axis to the specified anglevoidsetRotationZ(float angle)Sets the rotation on the local Z axis to the specified anglevoidsetScale(float scale)Sets scale along both the x and y axisvoidsetScale(float scaleX, float scaleY)Sets scale along both the x and y axisvoidsetScaleX(float scale)Sets scale along the x axisvoidsetScaleY(float scale)Sets scale along the y axisvoidsetTextureRegion(TextureRegion textureRegion)Sets the texture regionvoidsetWidth(float width)Sets the width in world unitsvoidsetX(float x)Sets the position on the x axisvoidsetY(float y)Sets the position on the y axisvoidsetZ(float z)Sets the position on the z axisprotected voidtransformVertices()Transforms the position component of the vertices using properties such as position, scale, etc.voidtranslate(float x, float y, float z)Translates by the specified amount of unitsvoidtranslate(Vector3 trans)voidtranslateX(float units)Moves by the specified amount of units along the x axisvoidtranslateY(float units)Moves by the specified amount of units along the y axisvoidtranslateZ(float units)Moves by the specified amount of units along the z axisprotected voidupdate()Recalculates vertices array if it grew out of sync with the properties (position, ..)protected voidupdateUVs()Re-applies the uv coordinates from the material's texture region to the uv components of the vertices array
-
-
-
Field Detail
-
SIZE
public static final int SIZE
Size of the decal in floats. It takes a float[SIZE] to hold the decal.- See Also:
- Constant Field Values
-
value
public int value
Set a multipurpose value which can be queried and used for things like group identification.
-
vertices
protected float[] vertices
-
position
protected Vector3 position
-
rotation
protected Quaternion rotation
-
scale
protected Vector2 scale
-
color
protected Color color
-
transformationOffset
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.
-
dimensions
protected Vector2 dimensions
-
material
protected DecalMaterial material
-
updated
protected boolean updated
-
X1
public static final int X1
- See Also:
- Constant Field Values
-
Y1
public static final int Y1
- See Also:
- Constant Field Values
-
Z1
public static final int Z1
- See Also:
- Constant Field Values
-
C1
public static final int C1
- See Also:
- Constant Field Values
-
U1
public static final int U1
- See Also:
- Constant Field Values
-
V1
public static final int V1
- See Also:
- Constant Field Values
-
X2
public static final int X2
- See Also:
- Constant Field Values
-
Y2
public static final int Y2
- See Also:
- Constant Field Values
-
Z2
public static final int Z2
- See Also:
- Constant Field Values
-
C2
public static final int C2
- See Also:
- Constant Field Values
-
U2
public static final int U2
- See Also:
- Constant Field Values
-
V2
public static final int V2
- See Also:
- Constant Field Values
-
X3
public static final int X3
- See Also:
- Constant Field Values
-
Y3
public static final int Y3
- See Also:
- Constant Field Values
-
Z3
public static final int Z3
- See Also:
- Constant Field Values
-
C3
public static final int C3
- See Also:
- Constant Field Values
-
U3
public static final int U3
- See Also:
- Constant Field Values
-
V3
public static final int V3
- See Also:
- Constant Field Values
-
X4
public static final int X4
- See Also:
- Constant Field Values
-
Y4
public static final int Y4
- See Also:
- Constant Field Values
-
Z4
public static final int Z4
- See Also:
- Constant Field Values
-
C4
public static final int C4
- See Also:
- Constant Field Values
-
U4
public static final int U4
- See Also:
- Constant Field Values
-
V4
public static final int V4
- See Also:
- Constant Field Values
-
rotator
protected static Quaternion rotator
-
-
Constructor Detail
-
Decal
public Decal()
-
Decal
public Decal(DecalMaterial material)
-
-
Method Detail
-
setColor
public void setColor(float r, float g, float b, float a)Sets the color of all four vertices to the specified color- Parameters:
r- Red componentg- Green componentb- Blue componenta- Alpha component
-
setColor
public void setColor(Color tint)
Sets the color used to tint this decal. Default isColor.WHITE.
-
setPackedColor
public void setPackedColor(float color)
Sets the color of this decal, expanding the alpha from 0-254 to 0-255.- See Also:
setColor(Color)
-
setRotationX
public void setRotationX(float angle)
Sets the rotation on the local X axis to the specified angle- Parameters:
angle- Angle in degrees to set rotation to
-
setRotationY
public void setRotationY(float angle)
Sets the rotation on the local Y axis to the specified angle- Parameters:
angle- Angle in degrees to set rotation to
-
setRotationZ
public void setRotationZ(float angle)
Sets the rotation on the local Z axis to the specified angle- Parameters:
angle- Angle in degrees to set rotation to
-
rotateX
public void rotateX(float angle)
Rotates along local X axis by the specified angle- Parameters:
angle- Angle in degrees to rotate by
-
rotateY
public void rotateY(float angle)
Rotates along local Y axis by the specified angle- Parameters:
angle- Angle in degrees to rotate by
-
rotateZ
public void rotateZ(float angle)
Rotates along local Z axis by the specified angle- Parameters:
angle- Angle in degrees to rotate by
-
setRotation
public void setRotation(float yaw, float pitch, float roll)Sets the rotation of this decal to the given angles on all axes.- Parameters:
yaw- Angle in degrees to rotate around the Y axispitch- Angle in degrees to rotate around the X axisroll- Angle in degrees to rotate around the Z axis
-
setRotation
public void setRotation(Vector3 dir, Vector3 up)
Sets the rotation of this decal based on the (normalized) direction and up vector.- Parameters:
dir- the direction vectorup- the up vector
-
setRotation
public void setRotation(Quaternion q)
Sets the rotation of this decal based on the provided Quaternion- Parameters:
q- desired Rotation
-
getRotation
public Quaternion getRotation()
Returns the rotation. The returned quaternion should under no circumstances be modified.- Returns:
- Quaternion representing the rotation
-
translateX
public void translateX(float units)
Moves by the specified amount of units along the x axis- Parameters:
units- Units to move the decal
-
setX
public void setX(float x)
Sets the position on the x axis- Parameters:
x- Position to locate the decal at
-
getX
public float getX()
- Returns:
- position on the x axis
-
translateY
public void translateY(float units)
Moves by the specified amount of units along the y axis- Parameters:
units- Units to move the decal
-
setY
public void setY(float y)
Sets the position on the y axis- Parameters:
y- Position to locate the decal at
-
getY
public float getY()
- Returns:
- position on the y axis
-
translateZ
public void translateZ(float units)
Moves by the specified amount of units along the z axis- Parameters:
units- Units to move the decal
-
setZ
public void setZ(float z)
Sets the position on the z axis- Parameters:
z- Position to locate the decal at
-
getZ
public float getZ()
- Returns:
- position on the z axis
-
translate
public void translate(float x, float y, float z)Translates by the specified amount of units- Parameters:
x- Units to move along the x axisy- Units to move along the y axisz- Units to move along the z axis
-
translate
public void translate(Vector3 trans)
- See Also:
translate(float, float, float)
-
setPosition
public void setPosition(float x, float y, float z)Sets the position to the given world coordinates- Parameters:
x- X positiony- Y Positionz- Z Position
-
setPosition
public void setPosition(Vector3 pos)
- See Also:
setPosition(float, float, float)
-
getColor
public Color getColor()
Returns the color of this decal. The returned color should under no circumstances be modified.- Returns:
- The color of this decal.
-
getPosition
public Vector3 getPosition()
Returns the position of this decal. The returned vector should under no circumstances be modified.- Returns:
- vector representing the position
-
setScaleX
public void setScaleX(float scale)
Sets scale along the x axis- Parameters:
scale- New scale along x axis
-
getScaleX
public float getScaleX()
- Returns:
- Scale on the x axis
-
setScaleY
public void setScaleY(float scale)
Sets scale along the y axis- Parameters:
scale- New scale along y axis
-
getScaleY
public float getScaleY()
- Returns:
- Scale on the y axis
-
setScale
public void setScale(float scaleX, float scaleY)Sets scale along both the x and y axis- Parameters:
scaleX- Scale on the x axisscaleY- Scale on the y axis
-
setScale
public void setScale(float scale)
Sets scale along both the x and y axis- Parameters:
scale- New scale
-
setWidth
public void setWidth(float width)
Sets the width in world units- Parameters:
width- Width in world units
-
getWidth
public float getWidth()
- Returns:
- width in world units
-
setHeight
public void setHeight(float height)
Sets the height in world units- Parameters:
height- Height in world units
-
getHeight
public float getHeight()
- Returns:
- height in world units
-
setDimensions
public void setDimensions(float width, float height)Sets the width and height in world units- Parameters:
width- Width in world unitsheight- Height in world units
-
getVertices
public float[] getVertices()
Returns the vertices backing this sprite.
The returned value should under no circumstances be modified.- Returns:
- vertex array backing the decal
-
update
protected void update()
Recalculates vertices array if it grew out of sync with the properties (position, ..)
-
transformVertices
protected void transformVertices()
Transforms the position component of the vertices using properties such as position, scale, etc.
-
resetVertices
protected void resetVertices()
Resets the position components of the vertices array based ont he dimensions (preparation for transformation)
-
updateUVs
protected void updateUVs()
Re-applies the uv coordinates from the material's texture region to the uv components of the vertices array
-
setTextureRegion
public void setTextureRegion(TextureRegion textureRegion)
Sets the texture region- Parameters:
textureRegion- Texture region to apply
-
getTextureRegion
public TextureRegion getTextureRegion()
- Returns:
- the texture region this Decal uses. Do not modify it!
-
setBlending
public void setBlending(int srcBlendFactor, int dstBlendFactor)Sets the blending parameters for this decal- Parameters:
srcBlendFactor- Source blend factor used by glBlendFuncdstBlendFactor- Destination blend factor used by glBlendFunc
-
getMaterial
public DecalMaterial getMaterial()
-
setMaterial
public void setMaterial(DecalMaterial material)
Set material- Parameters:
material- custom material
-
lookAt
public void lookAt(Vector3 position, Vector3 up)
Sets the rotation of the Decal to face the given point. Useful for billboarding.- Parameters:
position-up-
-
newDecal
public static Decal newDecal(TextureRegion textureRegion)
Creates a decal assuming the dimensions of the texture region- Parameters:
textureRegion- Texture region to use- Returns:
- Created decal
-
newDecal
public static Decal newDecal(TextureRegion textureRegion, boolean hasTransparency)
Creates a decal assuming the dimensions of the texture region and adding transparency- Parameters:
textureRegion- Texture region to usehasTransparency- Whether or not this sprite will be treated as having transparency (transparent png, etc.)- Returns:
- Created decal
-
newDecal
public static Decal newDecal(float width, float height, TextureRegion textureRegion)
Creates a decal using the region for texturing- Parameters:
width- Width of the decal in world unitsheight- Height of the decal in world unitstextureRegion- TextureRegion to use- Returns:
- Created decal
-
newDecal
public static Decal newDecal(float width, float height, TextureRegion textureRegion, boolean hasTransparency)
Creates a decal using the region for texturing- Parameters:
width- Width of the decal in world unitsheight- Height of the decal in world unitstextureRegion- TextureRegion to usehasTransparency- Whether or not this sprite will be treated as having transparency (transparent png, etc.)- Returns:
- Created decal
-
newDecal
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- Width of the decal in world unitsheight- Height of the decal in world unitstextureRegion- TextureRegion to usesrcBlendFactor- Source blend used by glBlendFuncdstBlendFactor- Destination blend used by glBlendFunc- Returns:
- Created decal
-
newDecal
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- Width of the decal in world unitsheight- Height of the decal in world unitstextureRegion- TextureRegion to usesrcBlendFactor- Source blend used by glBlendFuncdstBlendFactor- Destination blend used by glBlendFuncmaterial- Custom decal material- Returns:
- Created decal
-
-