Class Shape
java.lang.Object
dev.prozilla.pine.core.rendering.shape.Shape
- All Implemented Interfaces:
Cloneable<Shape>,ColoredDrawable,Drawable,TexturedDrawable
Represents a shape using vertex and UV arrays which respectively represent the vertex and texture coordinates of each triangle.
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanIftrue, the vertex and UV arrays of this shape will be re-generated before the next draw call. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddModifier(ShapeModifier modifier) Adds a modifier to this shape.abstract Shapeclone()Returns a new object that is equal to this object.voiddraw(Renderer renderer, TextureAsset texture, Color color, float depth) Draws this shape using its vertex and UV arrays.voidgenerate()Generates the arrays of vertices and texture coordinates for this shape and applies each modifier.protected abstract float[]Generates the UV array for this shape.protected abstract float[]Generates the vertex array for this shape.<M extends ShapeModifier>
MgetModifier(Class<M> modifierType) Gets the first modifier of a given type.voidremoveModifier(ShapeModifier modifier) Removes a modifier from this shape.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.prozilla.pine.core.rendering.shape.ColoredDrawable
drawMethods inherited from interface dev.prozilla.pine.core.rendering.shape.TexturedDrawable
draw, draw
-
Field Details
-
isDirty
public boolean isDirtyIftrue, the vertex and UV arrays of this shape will be re-generated before the next draw call.
-
-
Constructor Details
-
Shape
public Shape(float[] vertices, float[] uvArray) Creates a shape with pre-generated geometry.- Parameters:
vertices- The vertex arrayuvArray- The UV array
-
Shape
public Shape()Creates a shape that will be generated before the first draw call.
-
-
Method Details
-
generate
public void generate()Generates the arrays of vertices and texture coordinates for this shape and applies each modifier. -
generateVertices
protected abstract float[] generateVertices()Generates the vertex array for this shape.Odd elements define the x-component of the vertex and even elements define the y-component.
Every three vertices (or six elements) define a triangle.
- Returns:
- The array of vertices.
-
generateUVs
protected abstract float[] generateUVs()Generates the UV array for this shape.Odd elements define the x-component of the texture coordinate and even elements define the y-component.
- Returns:
- The array of texture coordinates.
-
draw
Draws this shape using its vertex and UV arrays.- Specified by:
drawin interfaceTexturedDrawable- Parameters:
renderer- The renderertexture- The texture to draw withcolor- The color to draw withdepth- The depth of the entity- See Also:
-
getModifier
Gets the first modifier of a given type.- Type Parameters:
M- The type of modifier- Parameters:
modifierType- The type of modifier to search for- Returns:
- The modifier of the given type, or
nullif there is none.
-
addModifier
Adds a modifier to this shape.- Parameters:
modifier- The modifier to add
-
removeModifier
Removes a modifier from this shape.- Parameters:
modifier- The modifier to remove
-
cloneWithModifiers
-
clone
Description copied from interface:CloneableReturns a new object that is equal to this object.
-