com.badlogic.gdx.graphics.g3d.decals
Class Decal

java.lang.Object
  extended by com.badlogic.gdx.graphics.g3d.decals.Decal

public class Decal
extends Object

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
static int C1
           
static int C2
           
static int C3
           
static int C4
           
static int SIZE
          Size of the decal in floats.
 Vector2 transformationOffset
          The transformation offset can be used to change the pivot point for rotation and scaling.
static int U1
           
static int U2
           
static int U3
           
static int U4
           
static int V1
           
static int V2
           
static int V3
           
static int V4
           
 int value
          Set a multipurpose value which can be queried and used for things like group identification.
static int X1
           
static int X2
           
static int X3
           
static int X4
           
static int Y1
           
static int Y2
           
static int Y3
           
static int Y4
           
static int Z1
           
static int Z2
           
static int Z3
           
static int Z4
           
 
Constructor Summary
Decal()
           
 
Method Summary
 float getHeight()
           
 DecalMaterial getMaterial()
           
 Vector3 getPosition()
          Returns the position of this decal.
 Quaternion getRotation()
          Returns the rotation.
 float getScaleX()
           
 float getScaleY()
           
 TextureRegion getTextureRegion()
           
 float[] getVertices()
          Returns the vertices backing this sprite.
The returned value should under no circumstances be modified.
 float getWidth()
           
 float getX()
           
 float getY()
           
 float getZ()
           
 void lookAt(Vector3 position, Vector3 up)
          Sets the rotation of the Decal to face the given point.
static Decal newDecal(float width, float height, TextureRegion textureRegion)
          Creates a decal using the region for texturing
static Decal newDecal(float width, float height, TextureRegion textureRegion, boolean hasTransparency)
          Creates a decal using the region for texturing
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
static Decal newDecal(TextureRegion textureRegion)
          Creates a decal assuming the dimensions of the texture region
static Decal newDecal(TextureRegion textureRegion, boolean hasTransparency)
          Creates a decal assuming the dimensions of the texture region and adding transparency
 void rotateX(float angle)
          Rotates along local X axis by the specified angle
 void rotateY(float angle)
          Rotates along local Y axis by the specified angle
 void rotateZ(float angle)
          Rotates along local Z axis by the specified angle
 void setBlending(int srcBlendFactor, int dstBlendFactor)
          Sets the blending parameters for this decal
 void setColor(Color tint)
          Sets the color used to tint this decal.
 void setColor(float color)
           
 void setColor(float r, float g, float b, float a)
          Sets the color of all four vertices to the specified color
 void setDimensions(float width, float height)
          Sets the width and height in world units
 void setHeight(float height)
          Sets the height in world units
 void setPosition(float x, float y, float z)
          Sets the position to the given world coordinates
 void setRotation(Vector3 dir, Vector3 up)
          Sets the rotation of this decal based on the (normalized) direction and up vector.
 void setRotationX(float angle)
          Sets the rotation on the local X axis to the specified angle
 void setRotationY(float angle)
          Sets the rotation on the local Y axis to the specified angle
 void setRotationZ(float angle)
          Sets the rotation on the local Z axis to the specified angle
 void setScale(float scale)
          Sets scale along both the x and y axis
 void setScale(float scaleX, float scaleY)
          Sets scale along both the x and y axis
 void setScaleX(float scale)
          Sets scale along the x axis
 void setScaleY(float scale)
          Sets scale along the y axis
 void setTextureRegion(TextureRegion textureRegion)
          Sets the texture region
 void setWidth(float width)
          Sets the width in world units
 void setX(float x)
          Sets the position on the x axis
 void setY(float y)
          Sets the position on the y axis
 void setZ(float z)
          Sets the position on the z axis
 void translate(float x, float y, float z)
          Translates by the specified amount of units
 void translateX(float units)
          Moves by the specified amount of units along the x axis
 void translateY(float units)
          Moves by the specified amount of units along the y axis
 void translateZ(float units)
          Moves by the specified amount of units along the z axis
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.


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.


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
Constructor Detail

Decal

public Decal()
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 component
g - Green component
b - Blue component
a - Alpha component

setColor

public void setColor(Color tint)
Sets the color used to tint this decal. Default is Color.WHITE.


setColor

public void setColor(float color)
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(Vector3 dir,
                        Vector3 up)
Sets the rotation of this decal based on the (normalized) direction and up vector.

Parameters:
dir - the direction vector
up - the up vector

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 axis
y - Units to move along the y axis
z - Units to move along the z axis

setPosition

public void setPosition(float x,
                        float y,
                        float z)
Sets the position to the given world coordinates

Parameters:
x - X position
y - Y Position
z - Z Position

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 axis
scaleY - 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 units
height - 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

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 glBlendFunc
dstBlendFactor - Destination blend factor used by glBlendFunc

getMaterial

public DecalMaterial getMaterial()

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 use
hasTransparency - 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 units
height - Height of the decal in world units
textureRegion - 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 units
height - Height of the decal in world units
textureRegion - TextureRegion to use
hasTransparency - 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 units
height - Height of the decal in world units
textureRegion - TextureRegion to use
srcBlendFactor - Source blend used by glBlendFunc
dstBlendFactor - Destination blend used by glBlendFunc
Returns:
Created decal


Copyright © 2014. All Rights Reserved.