Package edu.cnu.mdi.mdi3D.item3D
Class Cylinder
java.lang.Object
edu.cnu.mdi.mdi3D.item3D.Item3D
edu.cnu.mdi.mdi3D.item3D.Cylinder
A solid cylindrical tube between two endpoints, with a fixed radius,
optional extension beyond its defining endpoints, and optional Phong-style
lighting.
-
Field Summary
Fields inherited from class edu.cnu.mdi.mdi3D.item3D.Item3D
_panel3D, FILLALPHA, FILLCOLOR, FONT, LINE_WIDTH, LINEALPHA, LINECOLOR, TEXT_COLOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddraw(com.jogamp.opengl.GLAutoDrawable drawable) The custom drawing methodfloat[]A representative point for transparent sorting, in world coordinates.booleanWhether Phong-style lighting is enabled for this cylinder.voidreset(float x1, float y1, float z1, float x2, float y2, float z2) Move the cylinder to new endpoints, replacing the ones supplied at construction.voidsetExtend(boolean extend) Set whether we draw the cylinder longer than its defining center line.voidsetExtensionFactor(float extensionFactor) If drawing extended, what factor to extend byvoidsetLighted(boolean lighted) Enable or disable Phong-style lighting for this cylinder.Methods inherited from class edu.cnu.mdi.mdi3D.item3D.Item3D
addChild, defaultProperties, dispose, disposeItem, drawItem, get, getChildren, getColor, getFillAlpha, getFillColor, getFloat, getFont, getFont, getInt, getLineAlpha, getLineColor, getLineWidth, getPanel3D, getParent, getString, getTextColor, isVisible, put, removeChild, setAlphaOfColor, setFillAlpha, setFillColor, setFont, setLineAlpha, setLineColor, setLineWidth, setTextColor, setVisible
-
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 panelx1- X coordinate of one endy1- Y coordinate of one endz1- Z coordinate of one endx2- X coordinate of the other endy2- Y coordinate of the other endz2- Z coordinate of the other endradius- Radius of the cylindercolor- Color of the cylinder
-
Cylinder
Constructor for a Cylinder item in 3D space.- Parameters:
panel3D- The parent 3D paneldata- 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- iftruedraw 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-trueto enable lighting;falsefor flat colour
-
isLighted
public boolean isLighted()Whether Phong-style lighting is enabled for this cylinder.- Returns:
trueif lighting is enabled
-
draw
public void draw(com.jogamp.opengl.GLAutoDrawable drawable) Description copied from class:Item3DThe custom drawing method -
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 endy1- Y coordinate of one endz1- Z coordinate of one endx2- X coordinate of the other endy2- Y coordinate of the other endz2- Z coordinate of the other end
-
getSortPoint
public float[] getSortPoint()Description copied from class:Item3DA representative point for transparent sorting, in world coordinates. Default is origin. Override in items with a natural center (Sphere, Cube, Cylinder, etc.).- Overrides:
getSortPointin classItem3D- Returns:
- the sort point as
[x, y, z]
-