Package com.jme3.scene.shape
Class RectangleMesh
java.lang.Object
com.jme3.scene.Mesh
com.jme3.scene.shape.RectangleMesh
- All Implemented Interfaces:
Savable
,JmeCloneable
,Cloneable
A static, indexed, Triangle-mode mesh that renders a rectangle or
parallelogram, with customizable normals and texture coordinates.
It uses a Rectangle
to locate its vertices, which
are named as follows:
C +----+ D |\ | | \ | | \ | | \| A +----+ B
In the vertex buffers, the order of the vertices is A, B, D, then C.
The default texture coordinates have:
- U=0 at vertices A and C
- U=1 at vertices B and D
- V=0 at vertices A and B
- V=1 at vertices C and D
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionInstantiates a unit-square mesh in the X-Y plane, centered at (0.5, 0.5), with normals in the +Z direction.RectangleMesh
(Rectangle rectangle) Instantiates a rectangle or parallelogram mesh based on the specifiedRectangle
.RectangleMesh
(Vector3f a, Vector3f b, Vector3f c) Instantiates a rectangle or parallelogram mesh based on 3 specified vertex positions. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(Cloner cloner, Object original) Called internally by com.jme3.util.clone.Cloner.void
flip()
Flips this mesh by reversing its normal vector direction and setting theflipped
variable accordingly.Provides access to the internal normal-direction vector.Provides access to the internalRectangle
on which the mesh is based.Vector2f[]
Provides access to the internal texture-coordinate array.void
read
(JmeImporter importer) void
setRectangle
(Rectangle rectangle) Sets theRectangle
and updates the mesh accordingly.void
setTexCoords
(Vector2f[] texCoords) Sets the texture coordinates and updates the mesh accordingly.protected void
void
write
(JmeExporter e) Methods inherited from class com.jme3.scene.Mesh
addMorphTarget, clearBuffer, clearCollisionData, clone, 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
-
RectangleMesh
public RectangleMesh()Instantiates a unit-square mesh in the X-Y plane, centered at (0.5, 0.5), with normals in the +Z direction. -
RectangleMesh
Instantiates a rectangle or parallelogram mesh based on the specifiedRectangle
.- Parameters:
rectangle
- to locate the vertices and set the normals (not null, alias created)
-
RectangleMesh
Instantiates a rectangle or parallelogram mesh based on 3 specified vertex positions.- Parameters:
a
- the mesh position of vertex A (not null, alias created)b
- the mesh position of vertex B (not null, alias created)c
- the mesh position of vertex C (not null, alias created)
-
-
Method Details
-
getRectangle
Provides access to the internalRectangle
on which the mesh is based.- Returns:
- the pre-existing instance (do not modify!)
-
setRectangle
Sets theRectangle
and updates the mesh accordingly.- Parameters:
rectangle
- the desired Rectangle (not null, alias created)
-
getTexCoords
Provides access to the internal texture-coordinate array.- Returns:
- the pre-existing array of length 4 (do not modify!)
-
setTexCoords
Sets the texture coordinates and updates the mesh accordingly.- Parameters:
texCoords
- the desired texture coordinates for each vertex (not null, alias created)- Throws:
IllegalArgumentException
- if the array length isn't exactly 4
-
getNormal
Provides access to the internal normal-direction vector.- Returns:
- the pre-existing vector (do not modify!)
-
flip
public void flip()Flips this mesh by reversing its normal vector direction and setting theflipped
variable accordingly. This variable will be used by theupdateMesh()
method to rearrange the index buffer. -
updateMesh
protected void updateMesh() -
cloneFields
Called internally by com.jme3.util.clone.Cloner. Do not call directly.- Specified by:
cloneFields
in interfaceJmeCloneable
- Overrides:
cloneFields
in classMesh
- Parameters:
cloner
- The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.original
- The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classMesh
- Throws:
IOException
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classMesh
- Throws:
IOException
-