Class AbstractGameObject
- java.lang.Object
-
- com.badlogic.gdx.graphics.g3d.Renderable
-
- com.bombinggames.wurfelengine.core.gameobjects.AbstractGameObject
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
AbstractEntity,RenderCell
public abstract class AbstractGameObject extends com.badlogic.gdx.graphics.g3d.Renderable implements java.io.SerializableAn AbstractGameObject is something wich can be found in the game world.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected GameSpaceSpritespritecaching the sprite for rendering
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractGameObject()Creates an object.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description com.badlogic.gdx.graphics.ColorgetColor()get the tint of the object.abstract CoordinategetCoord()not copy savefloatgetDepth()Returns the depth of the object.abstract intgetDimensionZ()The height of the object for depth sorting.abstract floatgetLightlevelB()How bright is the object?abstract floatgetLightlevelG()How bright is the object?abstract floatgetLightlevelR()How bright is the object?abstract java.lang.StringgetName()Returns the name of the objectstatic com.badlogic.gdx.graphics.PixmapgetPixmap()abstract PointgetPoint()Can be internal reference or shared object.abstract PositiongetPosition()Return the coordinates of the object in the game world.floatgetRotation()Returns the rotation of the object.floatgetScaling()Returns the scale factor of the object.GameSpaceSpritegetSprite()static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegiongetSprite(char category, byte id, byte value)Returns a sprite texture.abstract chargetSpriteCategory()Get the category letter for accessing sprites.abstract bytegetSpriteId()the id of the sprite using for rendering.
By default is the same as the block id but in some cases some objects share one sprite so they can have the same id.static com.badlogic.gdx.graphics.g2d.TextureAtlasgetSpritesheet()Returns the spritesheet used for rendering.static java.lang.StringgetSpritesheetPath()path of the spritesheetabstract bytegetSpriteValue()Get the value.static com.badlogic.gdx.graphics.TexturegetTextureDiffuse()the diffuse mapstatic com.badlogic.gdx.graphics.TexturegetTextureNormal()the normal mapbooleanisHidden()Returns true, when set as hidden.static voidloadSheet()Load the spritesheet from memory.voidrender(GameView view)Draws an object if it is not hidden and not clipped.voidrender(GameView view, int xPos, int yPos)Renders at a custom position in projection space. uses heapvoidsetColor(com.badlogic.gdx.graphics.Color color)Give the object a tint.static voidsetCustomSpritesheet(java.lang.String customPath)Set your custom spritesheet path. the suffix will be addedvoidsetHidden(boolean hidden)Hides an object.abstract voidsetLightlevel(float lightlevel)Set the brightness of the object.abstract voidsetPosition(Position pos)Set the coordinates without safety check.voidsetRotation(float rotation)voidsetScaling(float scaling)Absolute scaling factor.booleanshouldBeRendered(Camera camera)Gives information if object should be rendered.static voidstaticDispose()disposes static fieldsvoidupdateSpriteCache()Updates the saved vertex data with the engine default configuration (category, sprite id and sprite value).
-
-
-
Field Detail
-
sprite
protected transient GameSpaceSprite sprite
caching the sprite for rendering
-
-
Method Detail
-
staticDispose
public static void staticDispose()
disposes static fields
-
getTextureDiffuse
public static com.badlogic.gdx.graphics.Texture getTextureDiffuse()
the diffuse map- Returns:
-
getTextureNormal
public static com.badlogic.gdx.graphics.Texture getTextureNormal()
the normal map- Returns:
-
getPixmap
public static com.badlogic.gdx.graphics.Pixmap getPixmap()
- Returns:
- can be null if pixmap loadin is disabled
-
setCustomSpritesheet
public static void setCustomSpritesheet(java.lang.String customPath)
Set your custom spritesheet path. the suffix will be added- Parameters:
customPath- format like "com/bombinggames/wurfelengine/core/images/Spritesheet" without suffix
-
getSpritesheetPath
public static java.lang.String getSpritesheetPath()
path of the spritesheet- Returns:
-
loadSheet
public static void loadSheet() throws java.io.FileNotFoundExceptionLoad the spritesheet from memory.- Throws:
java.io.FileNotFoundException
-
getSprite
public static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion getSprite(char category, byte id, byte value)Returns a sprite texture.- Parameters:
category- the category of the sprite e.g. 'b' for blocksid- the id of the objectvalue- the value of the object- Returns:
-
getSpritesheet
public static com.badlogic.gdx.graphics.g2d.TextureAtlas getSpritesheet()
Returns the spritesheet used for rendering.- Returns:
- the spritesheet used by the objects
-
getSpriteCategory
public abstract char getSpriteCategory()
Get the category letter for accessing sprites.- Returns:
-
getDimensionZ
public abstract int getDimensionZ()
The height of the object for depth sorting.- Returns:
- game space
-
setPosition
public abstract void setPosition(Position pos)
Set the coordinates without safety check. May use different object pointing to the same position.- Parameters:
pos- the coordinates you want to set
-
getLightlevelR
public abstract float getLightlevelR()
How bright is the object? The lightlevel is a scale applied to the color. 1 is default value.- Returns:
- 1 is default bright. 0 is black.
-
getLightlevelG
public abstract float getLightlevelG()
How bright is the object? The lightlevel is a scale applied to the color. 1 is default value.- Returns:
- 1 is default bright. 0 is black.
-
getLightlevelB
public abstract float getLightlevelB()
How bright is the object? The lightlevel is a scale applied to the color. 1 is default value.- Returns:
- 1 is default bright. 0 is black.
-
setLightlevel
public abstract void setLightlevel(float lightlevel)
Set the brightness of the object. The lightlevel is a scaling factor. 1 is default value.- Parameters:
lightlevel- 1 is default bright. 0 is black.
-
getPosition
public abstract Position getPosition()
Return the coordinates of the object in the game world. Not copy safe as it points to the interaly used object.- Returns:
- Reference to the position object which points to the location in the game world.
- See Also:
getPoint()
-
getPoint
public abstract Point getPoint()
Can be internal reference or shared object.- Returns:
- See Also:
getPosition()
-
getCoord
public abstract Coordinate getCoord()
not copy save- Returns:
- See Also:
getPosition()
-
getDepth
public float getDepth()
Returns the depth of the object. The depth is the game world space projected on one axis orthogonal to the camera's angle. Objects nearer to camera have a bigger value.- Returns:
- distance from zero level
-
render
public void render(GameView view)
Draws an object if it is not hidden and not clipped. in game space- Parameters:
view-
-
render
public void render(GameView view, int xPos, int yPos)
Renders at a custom position in projection space. uses heap- Parameters:
view-xPos- rendering position, center of sprite in projection spaceyPos- rendering position, center of sprite in projection space
-
updateSpriteCache
public void updateSpriteCache()
Updates the saved vertex data with the engine default configuration (category, sprite id and sprite value).
-
getSpriteId
public abstract byte getSpriteId()
the id of the sprite using for rendering.
By default is the same as the block id but in some cases some objects share one sprite so they can have the same id.- Returns:
- in range [0;
RenderCell.OBJECTTYPESNUM].
-
getSpriteValue
public abstract byte getSpriteValue()
Get the value. It is like a sub-id and can identify the status.- Returns:
- in range [0;
RenderCell.VALUESNUM]. Is -1 if about to destroyed.
-
getName
public abstract java.lang.String getName()
Returns the name of the object- Returns:
- the name of the object
-
getRotation
public float getRotation()
Returns the rotation of the object.- Returns:
- in degrees
-
getScaling
public float getScaling()
Returns the scale factor of the object.- Returns:
- 1 is no scaling
-
isHidden
public boolean isHidden()
Returns true, when set as hidden. Hidden objects are not rendered even when they are clipped ("clipped" by the meaning of the raytracing).- Returns:
- if the object is invisible
-
setHidden
public void setHidden(boolean hidden)
Hides an object. It won't be rendered but still affects physics.- Parameters:
hidden-
-
setRotation
public void setRotation(float rotation)
- Parameters:
rotation- set the rotation in degrees.
-
setScaling
public void setScaling(float scaling)
Absolute scaling factor.- Parameters:
scaling- 1 no scaling, > bigger, < 1 smaller
-
setColor
public void setColor(com.badlogic.gdx.graphics.Color color)
Give the object a tint. The default brightness is RGBA 0x808080FF so you can make it brighter and darker by modifying R, G and B.- Parameters:
color- refence is kept
-
getColor
public com.badlogic.gdx.graphics.Color getColor()
get the tint of the object. The default brightness is RGBA 0x808080FF so you can make it brighter and darker by modifying R, G and B.- Returns:
- not copy safe, not null
-
getSprite
public GameSpaceSprite getSprite()
- Returns:
- the sprite used for rendering
-
shouldBeRendered
public boolean shouldBeRendered(Camera camera)
Gives information if object should be rendered.- Parameters:
camera-- Returns:
-
-