Package edu.cnu.mdi.mdi3D.item3D
Class Cube
java.lang.Object
edu.cnu.mdi.mdi3D.item3D.Item3D
edu.cnu.mdi.mdi3D.item3D.Cube
A solid, axis-aligned cube, optionally framed and optionally rendered with
Phong-style per-face lighting.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanfinal floatfinal floatfinal floatfinal floatFields 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 cube.voidsetLighted(boolean lighted) Enable or disable Phong-style lighting for this cube.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
-
Field Details
-
xc
public final float xc -
yc
public final float yc -
zc
public final float zc -
length
public final float length -
_frame
protected boolean _frame
-
-
Constructor Details
-
Cube
Create an unframed cube.- Parameters:
panel3D- the owner 3D panelxc- x coordinate of the centeryc- y coordinate of the centerzc- z coordinate of the centerlength- side lengthcolor- fill color
-
Cube
public Cube(Panel3D panel3D, float xc, float yc, float zc, float length, Color color, boolean frame) Create a cube, optionally framed.- Parameters:
panel3D- the owner 3D panelxc- x coordinate of the centeryc- y coordinate of the centerzc- z coordinate of the centerlength- side lengthcolor- fill colorframe- iftrue, also draw a wireframe outline
-
-
Method Details
-
setLighted
public void setLighted(boolean lighted) Enable or disable Phong-style lighting for this cube.When enabled, each of the six faces is drawn with its own face normal via
Support3D.drawShadedRectangularSolid(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, float, float, java.awt.Color, java.awt.Color, float, boolean, boolean), so shading visibly changes as the cube (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 cube.- Returns:
trueif lighting is enabled
-
draw
public void draw(com.jogamp.opengl.GLAutoDrawable drawable) Description copied from class:Item3DThe custom drawing method -
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]
-