Class Geometry

    • Field Detail

      • SPLIT_TRIANGLE_DEFAULT

        public static boolean SPLIT_TRIANGLE_DEFAULT
        Default setting of setSplitInTriangles(boolean). Can be globally changed to avoid setting it geometry-wise.
      • NORMALIZE_NORMAL_DEFAULT

        public static boolean NORMALIZE_NORMAL_DEFAULT
        Default setting of setNormalizeNormals(boolean). Can be globally changed to avoid setting it geometry-wise.
      • SHOW_NORMALS

        public static boolean SHOW_NORMALS
        A flag to show normals for debugging lighting
      • NORMAL_LINE_WIDTH

        public static int NORMAL_LINE_WIDTH
      • NORMAL_POINT_WIDTH

        public static int NORMAL_POINT_WIDTH
      • NORMAL_END_COLOR

        public static Color NORMAL_END_COLOR
      • NORMAL_START_COLOR

        public static Color NORMAL_START_COLOR
      • color

        protected Color color
      • normalProcessingAutomatic

        protected boolean normalProcessingAutomatic
      • splitInTriangles

        protected boolean splitInTriangles
      • normalizeNormals

        protected boolean normalizeNormals
    • Constructor Detail

      • Geometry

        public Geometry()
        Initializes an empty Geometry with face status defaulting to true, and wireframe status defaulting to false.
      • Geometry

        public Geometry​(int n)
      • Geometry

        public Geometry​(Point... points)
      • Geometry

        public Geometry​(Color wireframeColor,
                        Color faceColor,
                        Coord3d... points)
      • Geometry

        public Geometry​(List<Point> points)
      • Geometry

        public Geometry​(Color wireframeColor,
                        Point... points)
      • Geometry

        public Geometry​(Color wireframeColor,
                        boolean wireframeDisplayed,
                        Point... points)
    • Method Detail

      • setReflectLight

        public void setReflectLight​(boolean reflectLight)
        Description copied from class: Wireframeable
        If true, drawing this object will set ambient, diffuse, specular and shininess parameters. If the drawable has no normal defined, then the normal will be automatically processed.
        Overrides:
        setReflectLight in class Wireframeable
      • setNormals

        public void setNormals​(List<Coord3d> normals,
                               Normal.NormalPer normalPer)
        Provides normals for this geometry. Manually setting normals will disable automatic normal processing. Not providing normals will keep the default automatic normal processing active. You may more simply set a single normal for this geometry by calling setNormal(Coord3d)
        Parameters:
        normals -
        normalPer - indicate if the supplied normals are given per vertex or per geometry. The ability to provide a list is kept for the case where one wishes to {@link #setSplitInTriangles(true)}.
      • setNormal

        public void setNormal​(Coord3d normals)
      • isNormalProcessingAutomatic

        public boolean isNormalProcessingAutomatic()
        Normal processing is false by default, and becomes true as soon as one provide normals through setNormals(List, NormalPer)
        Returns:
      • setNormalProcessingAutomatic

        public void setNormalProcessingAutomatic​(boolean normalProcessingAutomatic)
        Set normal processing to be automatic or not.
        Parameters:
        normalProcessingAutomatic -
      • draw

        public void draw​(IPainter painter)
        Description copied from class: Drawable
        Call OpenGL2 routines for rendering the object.
        Specified by:
        draw in interface IGLRenderer
        Specified by:
        draw in class Drawable
      • drawFace

        protected void drawFace​(IPainter painter)
      • callPointsForFace

        protected void callPointsForFace​(IPainter painter)
        Drawing the point list in face mode (polygon content)
      • callPointsForFace_NoSplit

        protected void callPointsForFace_NoSplit​(IPainter painter)
      • callPointsForFace_NoSplit_NormalSupplied

        protected void callPointsForFace_NoSplit_NormalSupplied​(IPainter painter)
      • callPointsForFace_NoSplit_NormalAuto

        protected void callPointsForFace_NoSplit_NormalAuto​(IPainter painter)
      • callPointsForFace_NoSplit_NoNormal

        protected void callPointsForFace_NoSplit_NoNormal​(IPainter painter)
      • callPointsForFace_SplitInTriangle

        protected void callPointsForFace_SplitInTriangle​(IPainter painter)
      • callPointsForFace_SplitInTriangle_NormalSupplied

        protected void callPointsForFace_SplitInTriangle_NormalSupplied​(IPainter painter,
                                                                        Point p1,
                                                                        Point p2,
                                                                        Point p3,
                                                                        int t)
      • callPointsForFace_SplitInTriangle_NormalAuto

        protected void callPointsForFace_SplitInTriangle_NormalAuto​(IPainter painter,
                                                                    Point p1,
                                                                    Point p2,
                                                                    Point p3)
      • computeNormalAutomatic

        protected Coord3d computeNormalAutomatic​(List<Point> points)
      • applyPointOrMapperColor

        protected void applyPointOrMapperColor​(IPainter painter,
                                               Point p)
        Apply mapper color if a mapper is defined and store the result in the point color, or use point color if mapper is undefined.
      • drawWireframe

        protected void drawWireframe​(IPainter painter)
      • callPointForWireframe

        protected void callPointForWireframe​(IPainter painter)
        Drawing the point list in wireframe mode
      • begin

        protected abstract void begin​(IPainter painter)
        Invoke GL begin with the actual geometry type GL#GL_POINTS, GL#GL_LINES, GL#GL_TRIANGLES, GL2#GL_POLYGON ...
      • add

        public void add​(float x,
                        float y,
                        float z)
      • add

        public void add​(Coord3d coord)
      • add

        public void add​(Coord3d coord,
                        Color color,
                        boolean updateBounds)
      • add

        public void add​(Color faceColor,
                        Coord3d... coords)
      • add

        public void add​(Point point)
      • add

        public void add​(Point point,
                        boolean updateBounds)
        Add a point to the polygon.
      • add

        public void add​(Point... points)
      • add

        public void add​(List<Point> points)
      • getBarycentre

        public Coord3d getBarycentre()
        Description copied from class: Drawable
        Return the barycentre of this object, which is computed as the center of its bounding box. If the bounding box is not available, the returned value is Coord3d.INVALID
        Overrides:
        getBarycentre in class Drawable
        Returns:
        the center of the bounding box, or Coord3d.INVALID.
      • get

        public Point get​(int p)
      • getPoints

        public List<Point> getPoints()
        Returns the list of the mutable points held by this polygon.
      • getPointSet

        public Set<Point> getPointSet()
        Returns a set of the mutable points held by this polygon.
      • getCoordSet

        public Set<Coord3d> getCoordSet()
        Returns a set of the mutable coordinates held by this polygon points.
      • getCoordList

        public List<Coord3d> getCoordList()
        Returns a list of the mutable coordinates held by this polygon points.
      • getCoordArray

        public Coord3d[] getCoordArray()
        Returns an array of the mutable coordinates held by this polygon points.
      • size

        public int size()
      • setPolygonMode

        public void setPolygonMode​(PolygonMode polygonMode)
        A null polygonMode imply no any call to gl.glPolygonMode(...) at rendering
      • isSplitInTriangles

        public boolean isSplitInTriangles()
      • setSplitInTriangles

        public void setSplitInTriangles​(boolean splitInTriangles)
        Splitting a polygon in multiple triangles is said to be better to adress complex rendering issues in OpenGL, but has a (very small) overhead.
      • isNormalizeNormals

        public boolean isNormalizeNormals()
      • setNormalizeNormals

        public void setNormalizeNormals​(boolean normalizeNormals)
        Normalizing normals is usefull to ensure that polygons of different sizes will have a consistent light reflection. Indeed, a large polygon will have a high normal value compared to a small polygon. Normalizing requires a bit more computation though. This setting will only change something as long as
        • The object is configured to {@link #setReflectLight(true)} and if a Light is added to the chart.
        • The object is configured to {@link #setNormalProcessingAutomatic(true)}. Normals processed externally should be normalized externally.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object