Class Quad3D

java.lang.Object
edu.cnu.mdi.mdi3D.item3D.Item3D
edu.cnu.mdi.mdi3D.item3D.Quad3D

public class Quad3D extends Item3D
A single filled (and optionally framed) quadrilateral, defined by four corner vertices in world coordinates. Corners are expected in either winding order around the quad's perimeter, not crossed.
  • Field Details

    • _coords

      protected float[] _coords
    • _frame

      protected boolean _frame
  • Constructor Details

    • Quad3D

      public Quad3D(Panel3D panel3d, float[] coords, Color color, float lineWidth, boolean frame)
      Create a quad from an array of coordinates
      Parameters:
      panel3d - the owner panel
      coords - the coordinates [x1, y1, ..., y3, z3]
      color - the quad color
      lineWidth - the line width
      frame - frame the quad
    • Quad3D

      public Quad3D(Panel3D panel3d, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, Color color, float lineWidth, boolean frame)
      Create a quad from 12 explicit coordinates
      Parameters:
      panel3d - the owner panel
      x1 - x coordinate of the first corner
      y1 - y coordinate of the first corner
      z1 - z coordinate of the first corner
      x2 - x coordinate of the second corner
      y2 - y coordinate of the second corner
      z2 - z coordinate of the second corner
      x3 - x coordinate of the third corner
      y3 - y coordinate of the third corner
      z3 - z coordinate of the third corner
      x4 - x coordinate of the fourth corner
      y4 - y coordinate of the fourth corner
      z4 - z coordinate of the fourth corner
      color - the quad color
      lineWidth - the line width
      frame - frame the quad
  • Method Details

    • constantZQuad

      public static Quad3D constantZQuad(Panel3D panel3d, float z, float size, Color color, float lineWidth, boolean frame)
      Create a square quad centered on the origin, lying in a constant-z plane.
      Parameters:
      panel3d - the owner panel
      z - the z coordinate of the plane
      size - half the side length; corners are at (±size, ±size, z)
      color - the quad color
      lineWidth - the line width
      frame - frame the quad
      Returns:
      the new constant-z quad
    • setLighted

      public void setLighted(boolean lighted)
      Enable or disable Phong-style lighting for this quad.

      When enabled, the quad is drawn with a single face normal (computed via Support3D.drawShadedQuad(com.jogamp.opengl.GLAutoDrawable, float[], java.awt.Color, java.awt.Color, float, boolean)) so its shading visibly changes as it — or the scene around it — rotates. Works for a quad at any orientation, not just axis-aligned ones. Disabled by default, matching the flat-colour appearance existing callers already expect.

      Parameters:
      lighted - true to enable lighting; false for flat colour
    • isLighted

      public boolean isLighted()
      Whether Phong-style lighting is enabled for this quad.
      Returns:
      true if lighting is enabled
    • draw

      public void draw(com.jogamp.opengl.GLAutoDrawable drawable)
      Description copied from class: Item3D
      The custom drawing method
      Specified by:
      draw in class Item3D
      Parameters:
      drawable - the OpenGL drawable
    • getCentroid

      public float[] getCentroid()
      Compute the centroid (mean position) of the quad's four corners.
      Returns:
      the centroid as [x, y, z]
    • getSortPoint

      public float[] getSortPoint()
      Description copied from class: Item3D
      A representative point for transparent sorting, in world coordinates. Default is origin. Override in items with a natural center (Sphere, Cube, Cylinder, etc.).
      Overrides:
      getSortPoint in class Item3D
      Returns:
      the sort point as [x, y, z]