public class GLShape
extends java.lang.Object
Number of construtors are provided to create common geometric shapes.
Constructor and Description |
---|
GLShape(int type,
float[] vertexes,
float[] normals,
short[] indexes)
a GLShape from indexed normals and vertexes.
|
GLShape(int type,
java.nio.FloatBuffer vertexBuffer,
java.nio.FloatBuffer normalBuffer,
java.nio.ShortBuffer indexBuffer)
creates a GLShape from indexed normals and vertexes.
|
Modifier and Type | Method and Description |
---|---|
static GLShape |
createCylinder(float baseRadius,
float topRadius,
float height,
int segments,
int bands)
creates an open ended conical cylinder of given radiuses with given number of segments and slices.
|
static GLShape |
createDisk(float radius,
int segments)
creates a disk of given radius with given number of segments.
|
static GLShape |
createLines(float[] floatData)
creates GSHape as a group of lines from pair of points represented by three floats each.
|
static GLShape |
createSphere(float radius,
int segments,
int bands)
creates a sphere of given radiuses with given number of segments and bands.
|
void |
render(GL gl)
renders this shape into the given OpenGL context.
|
void |
transform(javax.vecmath.Matrix4f m)
transforms this shape by the given matrix.
|
public GLShape(int type, java.nio.FloatBuffer vertexBuffer, java.nio.FloatBuffer normalBuffer, java.nio.ShortBuffer indexBuffer)
type
- of OpenGL primitive to create, use GL.TRIAGLES or gl.GL_LINESvertexBuffer
- the vertexes as FloatBuffernormalBuffer
- the normal as FloatBufferindexBuffer
- the indexes as ShortBufferpublic GLShape(int type, float[] vertexes, float[] normals, short[] indexes)
type
- of OpenGL primitive to create, use GL.TRIAGLES or gl.GL_LINESvertexes
- the vertexes as float[]normals
- the normal as float[]indexes
- the indexes as short[]public static GLShape createLines(float[] floatData)
floatData
- the point coordinates, 2 x 3 floats for each linepublic static GLShape createDisk(float radius, int segments)
The shape is centered at the origin.
radius
- of the disksegments
- number of triangular 'pie' or 'cake' slices to createpublic static GLShape createCylinder(float baseRadius, float topRadius, float height, int segments, int bands)
The bottom of the cylinder is centered at the origin and cylinder extends in the positive Z axis direction.
baseRadius
- at the bottom of the cylindertopRadius
- at the top of the cylinderheight
- height of the the cylindersegments
- number of quadrilaterals on each band that make up the cylinderbands
- number of bands in the cylinder it the axial directionpublic static GLShape createSphere(float radius, int segments, int bands)
The sphere is centered around the origin and the Z axis is like the pole axis of the Mercator projection and the quadrilaterals are developed like the squares on a Mercator map.
radius
- of the spheresegments
- number of segments around the Z axisbands
- number of triangle bands along the Z axispublic void transform(javax.vecmath.Matrix4f m)
m
- matrix to transform this withpublic void render(GL gl)
gl
- the rendering context