public class SphereWidget extends JOGLEdgedFacetedWidget
A sphere.
The face geometry is tessellated into azimuth wedges and then elevation segments, with defined normals. The edge geometry is composed of the three circles where the sphere intersects the coordinate planes.
The radius is mutable, and the sphere is centered at the origin of the
local coordinate frame. It may be further positioned e.g. by manipulating
Widget.rx
.
trackWidgetLength(float...)
may be called to enable Widget.widgetLength
tracking, which causes the radius length to track Widget.widgetLength
*trackRadiusFactor
.
Face vertex array is ns
azimuthal strips.
Edge vertex array is three great-circle line strips in the YZ, XZ, and XY planes, in that order.
Copyright (C) 2008 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
cvsid |
static int |
DEF_NUM_SECTORS
default
ns |
int |
ns
number of azimuth and elevation sectors
|
protected float |
radius
current radius
|
float |
sectorAngle
angle span of each sector
|
protected float |
trackRadiusFactor
mapping from
Widget.widgetLength to radius, NaN if none |
edgeGeometry, edgeVertices, faceGeometry, faceVertices, X, Y, Z
DASHED_PATTERN, DEF_EDGE_COLOR, DEF_OFFSET_BIAS, DEF_OFFSET_FACTOR, DOTTED_PATTERN, edgeAppearance, edgeColoringAttributes, edgeLineAttributes, EDGES, edgeTransparencyAttributes, facePolygonAttributes, SOLID_PATTERN
faceAppearance, faceMaterial, FACES, faceTransparencyAttributes
alpha, appearance, autoSetBoundingSpheres, boundingSphereCenter, boundingSphereCenterInView, boundingSphereRadius, boundingSphereRadiusInView, dbgEnabled, dbgNormalsGeometry, dbgNormalsVertices, dbgSpheresGeometry, dbgSpheresVertices, DEF_DBG_NORMAL_LENGTH, DEF_WIDGET_LENGTH, enabled, geometry, numGeometries, primitiveIterator, propertyMap, rx, vertexAccessor, widgetLength
Constructor and Description |
---|
SphereWidget()
Covers
SphereWidget(float, int) , uses DEF_NUM_SECTORS and radius = 0.5f. |
SphereWidget(float radius)
Covers
SphereWidget(float, int) , uses DEF_NUM_SECTORS . |
SphereWidget(float radius,
int numSectors)
Creates a new SphereWidget with given radius and
ns . |
Modifier and Type | Method and Description |
---|---|
static java.nio.FloatBuffer |
computeEdges(java.nio.FloatBuffer edgeVertices,
int initialVertexIndex,
int ns,
float radius,
float... center)
Re-usable utility function to compute coords for sphere edges.
|
void |
enableAxialEdges(boolean enable)
enable/disable the YZ and XZ plane edge circles
|
void |
enableRadialEdges(boolean enable)
enable/disable the XY plane edge circles
|
boolean |
setRadius(float radius)
Set the radius.
|
void |
trackWidgetLength(float... trackFactor)
set
trackRadiusFactor , see class header doc |
protected void |
widgetLengthChanged()
implements
Widget.widgetLength tracking, see class header doc |
gevc, gfnc, gfvc, sev, sevc, sfn, sfnc, sfv, sfvc
enableEdges, getEdgeAppearance, getEdgeGeometry, setAlpha, setColor, setColor, setEdgeAlpha, setEdgeColor, setEdgeColor, setEdgePattern, setEdgePattern, setEdgeWidth, setFaceOffset, setFaceOffsetBias, setFaceOffsetFactor
enableFaces, getFaceAppearance, getFaceGeometry, setFaceAlpha, setFaceColor, setFaceColor
cons, countGeometryArrays, disableBoundingSphere, disableBoundingSpheres, dump, dump, enableDBGGeometry, enableGeometry, ensureBoundingSpheresInView, getAppearance, getBoundingSphereCenter, getBoundingSphereRadius, getGeometry, getProperty, getWidget, getWidgetAlpha, hasBoundingSphere, hasBoundingSphereInView, hasProperty, indexOf, populateFrom, recomputeBoundingSphere, recomputeBoundingSpheres, removeDBGNormals, removeDBGSpheres, removeGeometry, removeGeometry, removeProperty, replaceAppearanceWithClone, replaceGeometryWithClone, scaleWidget, setAppearance, setBoundingSphereCenter, setBoundingSphereRadius, setGeometry, setGeometryAlpha, setGeometryAlpha, setGeometryAndAppearance, setProperty, setProperty, setWidgetAlpha, setWidgetLength, updateAllDBGNormals, updateAllDBGNormals, updateAllDBGSpheres, updateDBGNormals, updateDBGNormals, updateDBGSpheres, updateExistingDBGNormals, updateExistingDBGSpheres
private static final java.lang.String cvsid
public static final int DEF_NUM_SECTORS
ns
public final int ns
public final float sectorAngle
protected float radius
protected float trackRadiusFactor
Widget.widgetLength
to radius, NaN if nonepublic SphereWidget(float radius, int numSectors)
Creates a new SphereWidget with given radius and ns
.
radius
- the non-negative radiusnumSectors
- the number of sectors, must be positive and evenpublic SphereWidget(float radius)
Covers SphereWidget(float, int)
, uses DEF_NUM_SECTORS
.
public SphereWidget()
Covers SphereWidget(float, int)
, uses DEF_NUM_SECTORS
and radius = 0.5f.
public void enableAxialEdges(boolean enable)
public void enableRadialEdges(boolean enable)
public boolean setRadius(float radius)
Set the radius.
radius
- the new radius, ignored if NaN, otherwise must be
non-negativepublic static java.nio.FloatBuffer computeEdges(java.nio.FloatBuffer edgeVertices, int initialVertexIndex, int ns, float radius, float... center)
Re-usable utility function to compute coords for sphere edges.
Three circles are generated which are the intersections of the sphere surface with the x=0, y=0 and z=0 planes, in that order.
edgeVertices
- the buffer in which to generate the vertices, or null
or to cons. Writing begins at initialVertexIndex. The geometry
mode is GL_LINE_STRIP
and the vertex format is GL_V3F
.initialVertexIndex
- the write start index in edgeVerticesns
- the number of sectors per circleradius
- the sphere radiuscenter
- gives the sphere center coordinates in up to three
dimensions; unspecified dimensions are left centered at zero, greater than
three dimensions are ignoredjava.lang.IllegalArgumentException
- if edgeVertices is not null but
its capacity is insufficientpublic void trackWidgetLength(float... trackFactor)
trackRadiusFactor
, see class header doctrackWidgetLength
in class Widget
protected void widgetLengthChanged()
Widget.widgetLength
tracking, see class header docwidgetLengthChanged
in class Widget