Class Cylinder

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

public class Cylinder extends Item3D
A solid cylindrical tube between two endpoints, with a fixed radius, optional extension beyond its defining endpoints, and optional Phong-style lighting.
  • Constructor Details

    • Cylinder

      public Cylinder(Panel3D panel3D, float x1, float y1, float z1, float x2, float y2, float z2, float radius, Color color)
      Constructor for a Cylinder item in 3D space.
      Parameters:
      panel3D - The parent 3D panel
      x1 - X coordinate of one end
      y1 - Y coordinate of one end
      z1 - Z coordinate of one end
      x2 - X coordinate of the other end
      y2 - Y coordinate of the other end
      z2 - Z coordinate of the other end
      radius - Radius of the cylinder
      color - Color of the cylinder
    • Cylinder

      public Cylinder(Panel3D panel3D, float[] data, Color color)
      Constructor for a Cylinder item in 3D space.
      Parameters:
      panel3D - The parent 3D panel
      data - the endpoints and radius as [x1, y1, z1, x2, y2, z2, radius]
      color - Color of the cylinder
  • Method Details

    • setExtend

      public void setExtend(boolean extend)
      Set whether we draw the cylinder longer than its defining center line.
      Parameters:
      extend - if true draw the cylinder longer than its defining center line.
    • setExtensionFactor

      public void setExtensionFactor(float extensionFactor)
      If drawing extended, what factor to extend by
      Parameters:
      extensionFactor - the extension factor
    • setLighted

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

      When enabled, the tube is drawn with smooth per-vertex normals via Support3D.drawShadedTube(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, float, float, float, java.awt.Color, boolean), so shading visibly changes as the cylinder (or the scene around it) rotates. 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 cylinder.
      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
    • reset

      public void reset(float x1, float y1, float z1, float x2, float y2, float z2)
      Move the cylinder to new endpoints, replacing the ones supplied at construction.
      Parameters:
      x1 - X coordinate of one end
      y1 - Y coordinate of one end
      z1 - Z coordinate of one end
      x2 - X coordinate of the other end
      y2 - Y coordinate of the other end
      z2 - Z coordinate of the other end
    • 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]