Package rosequartz.coll
Class Collider
java.lang.Object
rosequartz.coll.Collider
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AxisAlignedBoxCollider,SphereCollider
Represents any collider, a shape that can be tested against other colliders to see if they touch or overlap (collide).
This can be used for testing if something runs into a wall or the player enters a certain area.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <C extends Collider>
voidacceptColliderType(Class<C> colliderClass, Function<C,Boolean> action)Registers a function for calculating collision between this collider and the given collider class.Gets the average position of all vertices of the shape.<C extends Collider>
booleangetColliding(C collider)Gets if this collider collides with the given collider.booleangetPointInside(float x, float y, float z)Gets if the given positions are inside this collider.booleangetPointInside(Vec3 xyz)Gets if the given positions are inside this collider.
-
Constructor Details
-
Collider
public Collider()
-
-
Method Details
-
getCenter
Gets the average position of all vertices of the shape.- Returns:
- center position
-
acceptColliderType
protected <C extends Collider> void acceptColliderType(Class<C> colliderClass, Function<C,Boolean> action)Registers a function for calculating collision between this collider and the given collider class. The function is then called every time this collider is checked against that collider.- Type Parameters:
C- the type of the collider that the function calculates- Parameters:
colliderClass- the class of the collider that the function calculatesaction- the calculating function
-
getColliding
Gets if this collider collides with the given collider.- Type Parameters:
C- the type of the checked collider- Parameters:
collider- the collider to check against this one- Returns:
- collision found
-
getPointInside
public boolean getPointInside(float x, float y, float z)Gets if the given positions are inside this collider.- Parameters:
x- the position of the point to check on the x-axisy- the position of the point to check on the y-axisz- the position of the point to check on the z-axis- Returns:
- point inside this collider
-
getPointInside
Gets if the given positions are inside this collider.- Parameters:
xyz- the position of the point to check- Returns:
- point inside this collider
-