Package edu.cnu.mdi.mdi3D.item3D
Class Quad3D
java.lang.Object
edu.cnu.mdi.mdi3D.item3D.Item3D
edu.cnu.mdi.mdi3D.item3D.Quad3D
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 Summary
FieldsFields 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 TypeMethodDescriptionstatic Quad3DconstantZQuad(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.voiddraw(com.jogamp.opengl.GLAutoDrawable drawable) The custom drawing methodfloat[]Compute the centroid (mean position) of the quad's four corners.float[]A representative point for transparent sorting, in world coordinates.booleanWhether Phong-style lighting is enabled for this quad.voidsetLighted(boolean lighted) Enable or disable Phong-style lighting for this quad.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
-
_coords
protected float[] _coords -
_frame
protected boolean _frame
-
-
Constructor Details
-
Quad3D
Create a quad from an array of coordinates- Parameters:
panel3d- the owner panelcoords- the coordinates [x1, y1, ..., y3, z3]color- the quad colorlineWidth- the line widthframe- 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 panelx1- x coordinate of the first cornery1- y coordinate of the first cornerz1- z coordinate of the first cornerx2- x coordinate of the second cornery2- y coordinate of the second cornerz2- z coordinate of the second cornerx3- x coordinate of the third cornery3- y coordinate of the third cornerz3- z coordinate of the third cornerx4- x coordinate of the fourth cornery4- y coordinate of the fourth cornerz4- z coordinate of the fourth cornercolor- the quad colorlineWidth- the line widthframe- 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 panelz- the z coordinate of the planesize- half the side length; corners are at (±size, ±size, z)color- the quad colorlineWidth- the line widthframe- 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-trueto enable lighting;falsefor flat colour
-
isLighted
public boolean isLighted()Whether Phong-style lighting is enabled for this quad.- Returns:
trueif lighting is enabled
-
draw
public void draw(com.jogamp.opengl.GLAutoDrawable drawable) Description copied from class:Item3DThe custom drawing method -
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: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]
-