Class ConvexObject

  • Direct Known Subclasses:
    Segment, SpritedRectangle, Triangle

    public abstract class ConvexObject
    extends AbstractDrawable3DObject
    Author:
    Calixte DENIZET Class to represent a convex object. Collision and relative positions of convexs object are relatively easy to determinate. About the method isBehind, it could be interesting to use the algorithm of Chung-Wang.
    • Method Detail

      • breakObject

        public abstract java.util.List<ConvexObject> breakObject​(ConvexObject o)
        Abstract method Break this ConvexObject against the ConvexObject o
        Parameters:
        o - a ConvexObject
        Returns:
        a list of ConvexObject.
      • breakObject

        public abstract java.util.List<ConvexObject> breakObject​(Vector4d v)
        Abstract method Break this ConvexObject against a plane
        Parameters:
        v - plane definition
        Returns:
        a list of ConvexObject.
      • drawAreas

        protected void drawAreas​(java.awt.Graphics2D g2d)
      • areCoplanar

        public boolean areCoplanar​(ConvexObject o)
        Test the coplanarity of two objects
        Parameters:
        o - a ConvexObject
        Returns:
        true if the two objects are coplanar
      • isBehind

        public int isBehind​(ConvexObject o)
        Check if o is behind this. Take care: the algorithms used are for convex objects (typically tri-tri, seg-seg or tri-seg)
        Returns:
        true if o is behind this
      • check2DIntersection

        public boolean check2DIntersection​(ConvexObject o)
        Check the intersections of the projection on the xOy-plane of this and o The algorithm is the following: for each edge, determinate the normal vector and project all the points of this and o on the normal. If the intersection of [this.min,this.max] and [o.min, o.max] is empty, then we have a separating line so the two objects are separated.
        Parameters:
        o - the object to test with this
        Returns:
        true if there is a collision
      • check2DTrueIntersection

        public boolean check2DTrueIntersection​(ConvexObject o)
        Check the intersections of the projection on the xOy-plane of this and o The algorithm is the following: for each edge, determinate the normal vector and project all the points of this and o on the normal. If the intersection of [this.min,this.max] and [o.min, o.max] is empty, then we have a separating line so the two objects are separated.
        Parameters:
        o - the object to test with this
        Returns:
        true if there is a collision
      • check

        protected int check​(ConvexObject o,
                            Vector3d v)
        Check the intersection this and o against vector v. The algorithm is just to project this and o on the vector v and to check if the two projected sets can be separated.
        Parameters:
        v - the vector where to project
        Returns:
        1 if o is behind this, 0 if it is undeterminated and -1 if this is behind o.