Package com.jme3.scene.shape
Class Cylinder
java.lang.Object
com.jme3.scene.Mesh
com.jme3.scene.shape.Cylinder
- All Implemented Interfaces:
Savable
,JmeCloneable
,Cloneable
A simple cylinder, defined by its height and radius.
(Ported to jME3)
-
Nested Class Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Cylinder()
constructor for serialization only.Cylinder
(int axisSamples, int radialSamples, float radius, float height) Creates a Cylinder.Cylinder
(int axisSamples, int radialSamples, float radius, float height, boolean closed) Creates a Cylinder.Cylinder
(int axisSamples, int radialSamples, float radius, float height, boolean closed, boolean inverted) Creates a new Cylinder.Cylinder
(int axisSamples, int radialSamples, float radius, float radius2, float height, boolean closed, boolean inverted) -
Method Summary
Modifier and TypeMethodDescriptionint
float
int
float
float
boolean
isClosed()
boolean
void
read
(JmeImporter importer) void
updateGeometry
(int axisSamples, int radialSamples, float topRadius, float bottomRadius, float height, boolean closed, boolean inverted) Rebuilds the cylinder based on a new set of parameters.void
write
(JmeExporter e) 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
-
Constructor Details
-
Cylinder
protected Cylinder()constructor for serialization only. Do not use. -
Cylinder
public Cylinder(int axisSamples, int radialSamples, float radius, float height) Creates a Cylinder. By default, its center is the origin. More samples create a better looking cylinder, at the cost of more vertex data.- Parameters:
axisSamples
- Number of triangle samples along the axis.radialSamples
- Number of triangle samples along the radial.radius
- The radius of the cylinder.height
- The cylinder's height.
-
Cylinder
public Cylinder(int axisSamples, int radialSamples, float radius, float height, boolean closed) Creates a Cylinder. By default, its center is the origin. More samples create a better looking cylinder, at the cost of more vertex data.
If the cylinder is closed, the texture is split into axisSamples parts: the topmost and bottommost parts are used for top and bottom of the cylinder, and the rest of the texture is used for the cylinder wall. The middle of the top is mapped to texture coordinates (0.5, 1), bottom to (0.5, 0). Thus, it requires- Parameters:
axisSamples
- Number of triangle samples along the axis.radialSamples
- Number of triangle samples along the radial.radius
- The radius of the cylinder.height
- The cylinder's height.closed
- true to create a cylinder with top and bottom surface
-
Cylinder
public Cylinder(int axisSamples, int radialSamples, float radius, float height, boolean closed, boolean inverted) Creates a new Cylinder. By default, its center is the origin. More samples create a better looking cylinder, at the cost of more vertex data.
If the cylinder is closed, the texture is split into axisSamples parts: the topmost and bottommost parts are used for top and bottom of the cylinder, and the rest of the texture is used for the cylinder wall. The middle of the top is mapped to texture coordinates (0.5, 1), bottom to (0.5, 0). Thus, it requires- Parameters:
axisSamples
- The number of vertices samples along the axis. It is equal to the number of segments + 1; so that, for instance, 4 samples mean the cylinder will be made of 3 segments.radialSamples
- The number of triangle samples along the radius. For instance, 4 means that the sides of the cylinder are made of 4 rectangles, and the top and bottom are made of 4 triangles.radius
- The radius of the cylinder.height
- The cylinder's height.closed
- true to create a cylinder with top and bottom surfaceinverted
- true to create a cylinder that is meant to be viewed from the interior.
-
Cylinder
public Cylinder(int axisSamples, int radialSamples, float radius, float radius2, float height, boolean closed, boolean inverted)
-
-
Method Details
-
getAxisSamples
public int getAxisSamples()- Returns:
- the number of samples along the cylinder axis
-
getHeight
public float getHeight()- Returns:
- Returns the height.
-
getRadialSamples
public int getRadialSamples()- Returns:
- number of samples around cylinder
-
getRadius
public float getRadius()- Returns:
- Returns the radius.
-
getRadius2
public float getRadius2() -
isClosed
public boolean isClosed()- Returns:
- true if end caps are used.
-
isInverted
public boolean isInverted()- Returns:
- true if normals and uvs are created for interior use
-
updateGeometry
public void updateGeometry(int axisSamples, int radialSamples, float topRadius, float bottomRadius, float height, boolean closed, boolean inverted) Rebuilds the cylinder based on a new set of parameters.- Parameters:
axisSamples
- The number of vertices samples along the axis. It is equal to the number of segments + 1; so that, for instance, 4 samples mean the cylinder will be made of 3 segments.radialSamples
- The number of triangle samples along the radius. For instance, 4 means that the sides of the cylinder are made of 4 rectangles, and the top and bottom are made of 4 triangles.topRadius
- the radius of the top of the cylinder.bottomRadius
- the radius of the bottom of the cylinder.height
- the cylinder's height.closed
- should the cylinder have top and bottom surfaces.inverted
- is the cylinder is meant to be viewed from the inside.
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classMesh
- Throws:
IOException
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classMesh
- Throws:
IOException
-