Module org.dyn4j

Interface CollisionBody<T extends Fixture>

    • Method Detail

      • getFixture

        T getFixture​(int index)
        Returns the Fixture at the given index.
        Parameters:
        index - the index of the Fixture
        Returns:
        T the fixture
        Throws:
        IndexOutOfBoundsException - if index is out of bounds
        Since:
        2.0.0
      • containsFixture

        boolean containsFixture​(T fixture)
        Returns true if this CollisionBody contains the given Fixture.
        Parameters:
        fixture - the fixture
        Returns:
        boolean
        Since:
        3.2.0
      • getFixture

        T getFixture​(Vector2 point)
        Returns the first Fixture in this CollisionBody, determined by the order in which they were added, that contains the given point.

        Returns null if the point is not contained in any fixture in this CollisionBody.

        Parameters:
        point - a world space point
        Returns:
        T the fixture or null
        Throws:
        NullPointerException - if point is null
        Since:
        3.2.0
      • getFixtures

        List<T> getFixtures​(Vector2 point)
        Returns all the Fixtures in this CollisionBody that contain the given point.

        Returns an empty list if the point is not contained in any fixture in this CollisionBody.

        Parameters:
        point - a world space point
        Returns:
        List<T>
        Throws:
        NullPointerException - if point is null
        Since:
        3.2.0
      • removeFixture

        T removeFixture​(int index)
        Removes the Fixture at the given index.
        Parameters:
        index - the index
        Returns:
        T the fixture removed
        Throws:
        IndexOutOfBoundsException - if index is out of bounds
        Since:
        3.2.0
      • removeAllFixtures

        List<T> removeAllFixtures()
        Removes all fixtures from this CollisionBody and returns them.
        Returns:
        List<T>
        Since:
        3.2.0
      • removeFixture

        T removeFixture​(Vector2 point)
        Removes the first Fixture in this CollisionBody, determined by the order in which they were added, that contains the given point and returns it.

        Returns null if the point is not contained in any Fixture in this CollisionBody.

        Parameters:
        point - a world space point
        Returns:
        T the fixture or null
        Throws:
        NullPointerException - if point is null
        Since:
        3.2.0
      • removeFixtures

        List<T> removeFixtures​(Vector2 point)
        Removes all the Fixtures in this CollisionBody that contain the given point and returns them.

        Returns an empty list if the point is not contained in any Fixture in this CollisionBody.

        Parameters:
        point - a world space point
        Returns:
        List<T>
        Throws:
        NullPointerException - if point is null
        Since:
        3.2.0
      • getFixtureCount

        int getFixtureCount()
        Returns the number of Fixtures attached to this CollisionBody object.
        Returns:
        int
        Since:
        2.0.0
      • getFixtures

        List<T> getFixtures()
        Returns an unmodifiable list containing the Fixtures attached to this CollisionBody.

        The returned list is backed by the internal list, therefore adding or removing fixtures while iterating through the returned list is not permitted. Use the getFixtureIterator() method instead.

        Returns:
        List<T>
        Since:
        3.1.5
        See Also:
        getFixtureIterator()
      • getFixtureIterator

        Iterator<T> getFixtureIterator()
        Returns an iterator for this body's fixtures.

        The returned iterator supports the remove method.

        Returns:
        Iterator<T>
        Since:
        3.2.0
      • contains

        boolean contains​(Vector2 point)
        Returns true if the given world space point is contained in this CollisionBody.

        The point is contained in this CollisionBody if and only if the point is contained in one of this CollisionBody's Fixtures.

        Parameters:
        point - the world space test point
        Returns:
        boolean
        Throws:
        NullPointerException - if point is null
        Since:
        3.2.0
      • getLocalCenter

        Vector2 getLocalCenter()
        Returns the center for this CollisionBody in local coordinates.
        Returns:
        Vector2 the center in local coordinates
        Since:
        3.2.0
      • getWorldCenter

        Vector2 getWorldCenter()
        Returns the center for this CollisionBody in world coordinates.
        Returns:
        Vector2 the center in world coordinates
        Since:
        3.2.0
      • getLocalPoint

        Vector2 getLocalPoint​(Vector2 worldPoint)
        Returns a new point in local coordinates of this CollisionBody given a point in world coordinates.
        Parameters:
        worldPoint - a world space point
        Returns:
        Vector2 local space point
        Throws:
        NullPointerException - if the given point is null
        Since:
        3.2.0
      • getWorldPoint

        Vector2 getWorldPoint​(Vector2 localPoint)
        Returns a new point in world coordinates given a point in the local coordinates of this CollisionBody.
        Parameters:
        localPoint - a point in the local coordinates of this CollisionBody
        Returns:
        Vector2 world space point
        Throws:
        NullPointerException - if the given point is null
        Since:
        3.2.0
      • getLocalVector

        Vector2 getLocalVector​(Vector2 worldVector)
        Returns a new vector in local coordinates of this CollisionBody given a vector in world coordinates.
        Parameters:
        worldVector - a world space vector
        Returns:
        Vector2 local space vector
        Throws:
        NullPointerException - if the given vector is null
        Since:
        3.2.0
      • getWorldVector

        Vector2 getWorldVector​(Vector2 localVector)
        Returns a new vector in world coordinates given a vector in the local coordinates of this CollisionBody.
        Parameters:
        localVector - a vector in the local coordinates of this CollisionBody
        Returns:
        Vector2 world space vector
        Throws:
        NullPointerException - if the given vector is null
        Since:
        3.2.0
      • getRotationDiscRadius

        double getRotationDiscRadius()
        Returns the maximum radius of the disk that the CollisionBody creates if rotated 360 degrees about its center.
        Returns:
        double the maximum radius of the rotation disk
      • getPreviousTransform

        Transform getPreviousTransform()
        Returns the transform of the last iteration.

        This transform represents the last frame's position and orientation.

        Returns:
        Transform
      • setTransform

        void setTransform​(Transform transform)
        Sets this CollisionBody's local to world space Transform.

        If the given transform is null, nothing is done and this method returns immediately.

        Parameters:
        transform - the transform
        Since:
        3.2.0
      • rotateAboutCenter

        void rotateAboutCenter​(double theta)
        Rotates the CollisionBody about its center.
        Parameters:
        theta - the angle of rotation in radians
      • translateToOrigin

        void translateToOrigin()
        Translates the center of the CollisionBody to the world space origin (0,0).

        This method is useful if bodies have a number of fixtures and the center is not at the origin. This method will reposition this CollisionBody so that the center is at the origin.

        Since:
        3.2.0
      • createAABB

        AABB createAABB()
        Creates an AABB from this CollisionBody's attached Fixtures.

        If there are no fixtures attached, a degenerate AABB, (0.0, 0.0) to (0.0, 0.0), is returned.

        Returns:
        AABB
        Since:
        3.0.0
      • setEnabled

        void setEnabled​(boolean enabled)
        Sets the CollisionBody enabled or not.

        A disabled CollisionBody is completely ignored by the engine.

        A CollisionBody will be disabled by only one condition from within the engine - when it's out of bounds. If there's no bounds detection set, then this state will never be set automatically.

        Parameters:
        enabled - true if the CollisionBody should be enabled
        Since:
        4.0.0
      • isEnabled

        boolean isEnabled()
        Returns true if this CollisionBody is enabled.
        Returns:
        boolean
        Since:
        4.0.0