Package jme3utilities.mesh
Class DomeMesh
java.lang.Object
com.jme3.scene.Mesh
jme3utilities.mesh.DomeMesh
- All Implemented Interfaces:
com.jme3.export.Savable,com.jme3.util.clone.JmeCloneable,Cloneable
public class DomeMesh
extends com.jme3.scene.Mesh
A 3-D, static, Triangles-mode mesh for a dome (or a pie-cut segment thereof)
with radius=1, centered at the origin, with its apex at (0,1,0) and its
equator in the X-Z plane.
The key differences between this class and com.jme3.scene.shape.Dome are:
- the radius and center ARE NOT configurable,
- the texture coordinates, segment angle, and vertical angle ARE configurable, and
- the normal vectors have the correct sign (JME issue #615).
The projection to texture space is an "azimuthal equidistant projection". The dome's equator maps to a circle of radius uvScale centered at (topU,topV). The +X direction maps to +U, and the +Z direction maps to -V.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.scene.Mesh
com.jme3.scene.Mesh.Mode -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatdefault for the first (U) texture coordinate at the apex of the domestatic final floatdefault for the 2nd (V) texture coordinate at the apex of the domestatic final floatdefault UV distance from apex to rim -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDomeMesh()No-argument constructor needed by SavableClassUtil.DomeMesh(int rimSamples, int quadrantSamples) Instantiate an inward-facing hemispherical dome with a specified number of samples on each axis.DomeMesh(int rimSamples, int quadrantSamples, float topU, float topV, float uvScale, boolean inwardFacing) Instantiate a hemispherical dome with a specified number of samples on each axis and a specified texture coordinate-system. -
Method Summary
Modifier and TypeMethodDescriptioncom.jme3.math.Vector2fdirectionUV(com.jme3.math.Vector3f direction) Determine the texture coordinate of a point on this mesh that's in the specified direction from the center of the mesh.floatelevationAngle(float u, float v) Compute the elevation angle of a point on this mesh, given its texture coordinates.floatRead the U-V scale of this dome.floatDeprecated.floatRead the vertical angle of this dome.voidread(com.jme3.export.JmeImporter importer) De-serialize this mesh, for example when loading from a J3O file.voidsetSegmentAngle(float newAngle) Regenerate the mesh for a new segment angle: 2*Pi produces a complete dome, Pi results in a half dome, and so on.voidsetVerticalAngle(float newAngle) Regenerate the mesh for a new vertical angle: Pi/2 produces a hemisphere and so on.voidwrite(com.jme3.export.JmeExporter exporter) Serialize this mesh, for example when saving to a J3O file.Methods inherited from class com.jme3.scene.Mesh
addMorphTarget, clearBuffer, clearCollisionData, clone, cloneFields, cloneForAnim, collideWith, createCollisionData, deepClone, extractVertexData, generateBindPose, generateBindPose, getBound, getBuffer, getBufferList, getBuffers, getElementLengths, getFloatBuffer, getId, getIndexBuffer, getIndicesAsList, getInstanceCount, getLineWidth, getLodLevel, getMaxNumWeights, getMode, getModeStart, getMorphIndex, getMorphTarget, getMorphTargetNames, getMorphTargets, getNumLodLevels, getPatchVertexCount, getPointSize, getShortBuffer, getTriangle, getTriangle, getTriangle, getTriangleCount, getTriangleCount, getVertexCount, hasMorphTargets, isAnimated, isAnimatedByBone, isAnimatedByJoint, jmeClone, prepareForAnim, removeMorphTarget, removeMorphTarget, scaleTextureCoordinates, setBound, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setDynamic, setElementLengths, setId, setInterleaved, setLineWidth, setLodLevels, setMaxNumWeights, setMode, setModeStart, setPatchVertexCount, setStatic, setStreamed, updateBound, updateCounts
-
Field Details
-
defaultTopU
public static final float defaultTopUdefault for the first (U) texture coordinate at the apex of the dome- See Also:
-
defaultTopV
public static final float defaultTopVdefault for the 2nd (V) texture coordinate at the apex of the dome- See Also:
-
defaultUvScale
public static final float defaultUvScaledefault UV distance from apex to rim- See Also:
-
-
Constructor Details
-
DomeMesh
protected DomeMesh()No-argument constructor needed by SavableClassUtil. -
DomeMesh
public DomeMesh(int rimSamples, int quadrantSamples) Instantiate an inward-facing hemispherical dome with a specified number of samples on each axis. Use this constructor to generate domes for SkyMaterial.- Parameters:
rimSamples- number of samples around the rim (≥3)quadrantSamples- number of samples from apex to rim, inclusive (≥2)
-
DomeMesh
public DomeMesh(int rimSamples, int quadrantSamples, float topU, float topV, float uvScale, boolean inwardFacing) Instantiate a hemispherical dome with a specified number of samples on each axis and a specified texture coordinate-system. This is the most general form of the constructor.- Parameters:
rimSamples- number of samples around the rim (≥3)quadrantSamples- number of samples from apex to rim, inclusive (≥2)topU- U-coordinate of the apex (≤1, ≥0)topV- V-coordinate of the apex (≤1, ≥0)uvScale- UV distance from apex to equator (<0.5, >0)inwardFacing- if true, vertex normals point inward; if false, they point outward
-
-
Method Details
-
directionUV
public com.jme3.math.Vector2f directionUV(com.jme3.math.Vector3f direction) Determine the texture coordinate of a point on this mesh that's in the specified direction from the center of the mesh.- Parameters:
direction- (length>0, unaffected)- Returns:
- a new vector, or null if direction is too far below the equator
-
elevationAngle
public float elevationAngle(float u, float v) Compute the elevation angle of a point on this mesh, given its texture coordinates.- Parameters:
u- the first texture coordinate (≤1, ≥0)v- the 2nd texture coordinate (≤1, ≥0)- Returns:
- angle in radians (≤Pi/2)
-
getUVScale
Deprecated.usegetUvScale()Read the U-V scale of this dome.- Returns:
- UV distance from apex to equator (<0.5, >0)
-
getUvScale
public float getUvScale()Read the U-V scale of this dome.- Returns:
- UV distance from apex to equator (<0.5, >0)
-
getVerticalAngle
public float getVerticalAngle()Read the vertical angle of this dome.- Returns:
- angle (in radians, <Pi, >0)
- See Also:
-
setSegmentAngle
public void setSegmentAngle(float newAngle) Regenerate the mesh for a new segment angle: 2*Pi produces a complete dome, Pi results in a half dome, and so on.- Parameters:
newAngle- (in radians, ≤2*Pi, >0)
-
setVerticalAngle
public void setVerticalAngle(float newAngle) Regenerate the mesh for a new vertical angle: Pi/2 produces a hemisphere and so on.- Parameters:
newAngle- (in radians, <Pi, >0)
-
read
De-serialize this mesh, for example when loading from a J3O file.- Specified by:
readin interfacecom.jme3.export.Savable- Overrides:
readin classcom.jme3.scene.Mesh- Parameters:
importer- (not null)- Throws:
IOException- from importer
-
write
Serialize this mesh, for example when saving to a J3O file.- Specified by:
writein interfacecom.jme3.export.Savable- Overrides:
writein classcom.jme3.scene.Mesh- Parameters:
exporter- (not null)- Throws:
IOException- from exporter
-
getUvScale()