Package com.ardor3d.scenegraph
Class Mesh
java.lang.Object
com.ardor3d.scenegraph.Spatial
com.ardor3d.scenegraph.Mesh
- All Implemented Interfaces:
Pickable
,Hintable
,Renderable
,Savable
- Direct Known Subclasses:
BMText
,BMTextBackground
,Box
,Capsule
,ClipmapLevel
,Cylinder
,Disk
,Dodecahedron
,Dome
,DrawableCamera
,Extrusion
,GeoSphere
,Hexagon
,Icosahedron
,InteractRing
,Line
,Octahedron
,OrientedBox
,Point
,PQTorus
,ProjectedGrid
,Pyramid
,Quad
,QuadBox
,QuadQuad
,RoundedBox
,SkinnedMesh
,SkyDome
,Sphere
,StripBox
,Teapot
,TextMesh
,Torus
,TrailMesh
,Tube
,UIArc
,UIDisk
,UIQuad
A Mesh is a spatial describing a renderable geometric object. Data about the mesh is stored locally using MeshData.
-
Field Summary
Modifier and TypeFieldDescriptionprotected ColorRGBA
Default color to use when no per vertex colors are setprotected boolean
Visibility setting that can be used after the scenegraph hierarchical cullingprotected LightState
The compiled lightState for this meshprotected MeshData
Actual buffer representation of the meshprotected BoundingVolume
Local model bounding volumeprotected final EnumMap
<RenderState.StateType, RenderState> The compiled list of renderstates for this mesh, taking into account ancestors states - updated with updateRenderStates()static boolean
Fields inherited from class com.ardor3d.scenegraph.Spatial
_controllers, _delegateMap, _dirtyMark, _frustumIntersects, _listener, _localTransform, _name, _parent, _queueDistance, _renderStateList, _sceneHints, _userData, _worldBound, _worldTransform, ON_DIRTY_ATTACHED, ON_DIRTY_BOUNDING, ON_DIRTY_RENDERSTATE, ON_DIRTY_TRANSFORM, ON_DIRTY_TRANSFORM_ONLY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyWorldRenderStates
(boolean recurse, RenderState.StateStack stack) The method actually implements how the render states are applied to this spatial and (if recurse is true) any children it may have.void
draw
abstract method that handles drawing data to the renderer if it is geometry and passing the call to it's children if it is a node.Retrieves the mesh data object used by this mesh.Retrieves the local bounding volume for this mesh.getModelBound
(BoundingVolume store) Retrieves a copy of the local bounding volume for this mesh.getWorldNormals
(FloatBuffer store) rotates the normals of this Mesh to world normals based on its world settings.getWorldVectors
(FloatBuffer store) translates/rotates and scales the vectors of this Mesh to world coordinates based on its world settings.boolean
intersectsWorldBound
(Ray3 ray) boolean
makeCopy
(boolean shareGeometricData) Create a copy of this spatial.Creates and returns a new instance of this spatial.void
read
(InputCapsule capsule) void
Render the object using the supplied renderer instance.void
protected void
renderArrays
(Renderer renderer, MeshData meshData, int primcount, ContextCapabilities caps) protected void
void
reorderIndices
(IndexBufferData<?> newIndices, IndexMode[] modes, int[] lengths) Let this mesh know we want to change its indices to the provided new order.void
reorderVertexData
(int[] newVertexOrder) Swap around the order of the vertex data in this Mesh.protected void
reorderVertexData
(int[] newVertexOrder, MeshData meshData) Swap around the order of the vertex data in the given MeshData.void
setDefaultColor
(float r, float g, float b, float a) setDefaultColor
sets the color to be used if no per vertex color buffer is set.void
setDefaultColor
(ReadOnlyColorRGBA color) setDefaultColor
sets the color to be used if no per vertex color buffer is set.void
setLightState
(LightState lightState) void
setMeshData
(MeshData meshData) Sets the mesh data object for this mesh.void
setModelBound
(BoundingVolume modelBound) Sets the local bounding volume for this mesh to the given bounds, updated to fit the vertices of this Mesh.void
setModelBound
(BoundingVolume modelBound, boolean autoCompute) Sets the local bounding volume for this mesh to the given bounding volume.void
Sets every color of this geometry's color array to a random color.void
setSolidColor
(ReadOnlyColorRGBA color) setSolidColor
sets the color array of this geometry to a single color.void
setVisible
(boolean isVisible) void
Sorts the lights based on distance to mesh bounding volumeboolean
boolean
void
Recalculate the local bounding volume of this Mesh to fit its vertices.void
updateWorldBound
(boolean recurse) updates the bounding volume of the world.void
write
(OutputCapsule capsule) Methods inherited from class com.ardor3d.scenegraph.Spatial
acceptVisitor, addController, addTranslation, addTranslation, clearControllers, clearDirty, clearDirty, clearRenderState, getController, getControllerCount, getControllers, getCurrentRenderDelegate, getLastFrustumIntersection, getListener, getLocalLastFrustumIntersection, getLocalRenderState, getLocalRenderStates, getName, getParent, getParentHintable, getRenderDelegate, getRotation, getScale, getSceneHints, getTransform, getTranslation, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, isDirty, localToWorld, markDirty, markDirty, onDraw, propagateBoundToRoot, propagateDirtyDown, propagateDirtyUp, propagateStatesFromRoot, propageEventUp, removeController, removeController, removeFromParent, setLastFrustumIntersection, setListener, setName, setParent, setRenderDelegate, setRenderState, setRotation, setRotation, setScale, setScale, setScale, setTransform, setTranslation, setTranslation, setUserData, setWorldRotation, setWorldRotation, setWorldScale, setWorldScale, setWorldScale, setWorldTransform, setWorldTranslation, setWorldTranslation, toString, updateChildren, updateControllers, updateGeometricState, updateGeometricState, updateWorldRenderStates, updateWorldRenderStates, updateWorldTransform, worldToLocal
-
Field Details
-
RENDER_VERTEX_ONLY
public static boolean RENDER_VERTEX_ONLY -
_meshData
Actual buffer representation of the mesh -
_modelBound
Local model bounding volume -
_states
The compiled list of renderstates for this mesh, taking into account ancestors states - updated with updateRenderStates() -
_lightState
The compiled lightState for this mesh -
_defaultColor
Default color to use when no per vertex colors are set -
_isVisible
protected boolean _isVisibleVisibility setting that can be used after the scenegraph hierarchical culling
-
-
Constructor Details
-
Mesh
public Mesh()Constructs a new Mesh. -
Mesh
Constructs a newMesh
with a given name.- Parameters:
name
- the name of the mesh. This is required for identification purposes.
-
-
Method Details
-
getMeshData
Retrieves the mesh data object used by this mesh.- Returns:
- the mesh data object
-
setMeshData
Sets the mesh data object for this mesh.- Parameters:
meshData
- the mesh data object
-
getModelBound
Retrieves the local bounding volume for this mesh.- Returns:
- the local bounding volume for this mesh
-
getModelBound
Retrieves a copy of the local bounding volume for this mesh.- Parameters:
store
- the bounding volume- Returns:
- a copy of the local bounding volume for this mesh
-
setModelBound
Sets the local bounding volume for this mesh to the given bounds, updated to fit the vertices of this Mesh. Marks the spatial as having dirty world bounds.- Parameters:
modelBound
- the bounding volume - only type is used, actual values are replaced.
-
setModelBound
Sets the local bounding volume for this mesh to the given bounding volume. If autoCompute is true (default, if not given) then we will modify the given modelBound to fit the current vertices of this mesh. This will also mark the spatial as having dirty world bounds.- Parameters:
modelBound
- the bounding volumeautoCompute
- if true, update the given modelBound to fit the vertices of this Mesh.
-
updateModelBound
public void updateModelBound()Recalculate the local bounding volume of this Mesh to fit its vertices. -
updateWorldBound
public void updateWorldBound(boolean recurse) Description copied from class:Spatial
updates the bounding volume of the world. Abstract, geometry transforms the bound while node merges the children's bound. In most cases, users will want to call updateModelBound() and let this function be called automatically during updateGeometricState().- Specified by:
updateWorldBound
in classSpatial
- Parameters:
recurse
- true to recurse down the scenegraph tree
-
getWorldVectors
translates/rotates and scales the vectors of this Mesh to world coordinates based on its world settings. The results are stored in the given FloatBuffer. If given FloatBuffer is null, one is created.- Parameters:
store
- the FloatBuffer to store the results in, or null if you want one created.- Returns:
- store or new FloatBuffer if store == null.
-
getWorldNormals
rotates the normals of this Mesh to world normals based on its world settings. The results are stored in the given FloatBuffer. If given FloatBuffer is null, one is created.- Parameters:
store
- the FloatBuffer to store the results in, or null if you want one created.- Returns:
- store or new FloatBuffer if store == null.
-
render
Description copied from interface:Renderable
Render the object using the supplied renderer instance.- Specified by:
render
in interfaceRenderable
- Parameters:
renderer
- the renderer
-
render
-
renderArrays
protected void renderArrays(Renderer renderer, MeshData meshData, int primcount, ContextCapabilities caps) -
renderVBO
-
applyWorldRenderStates
Description copied from class:Spatial
The method actually implements how the render states are applied to this spatial and (if recurse is true) any children it may have. By default, this function does nothing.- Overrides:
applyWorldRenderStates
in classSpatial
- Parameters:
recurse
- true to recurse down the scenegraph treestack
- The stack for each state
-
isVisible
public boolean isVisible() -
setVisible
public void setVisible(boolean isVisible) -
draw
Description copied from class:Spatial
draw
abstract method that handles drawing data to the renderer if it is geometry and passing the call to it's children if it is a node. -
sortLights
public void sortLights()Sorts the lights based on distance to mesh bounding volume- Overrides:
sortLights
in classSpatial
-
getLightState
-
setLightState
-
setDefaultColor
setDefaultColor
sets the color to be used if no per vertex color buffer is set.- Parameters:
color
- the default color to set
-
setDefaultColor
public void setDefaultColor(float r, float g, float b, float a) setDefaultColor
sets the color to be used if no per vertex color buffer is set.- Parameters:
r
- the red component of the default color to setg
- the green component of the default color to setb
- the blue component of the default color to seta
- the alpha component of the default color to set
-
getDefaultColor
- Returns:
- the default color
-
getWorldRenderState
- Parameters:
type
- StateType of RenderState we want to grab- Returns:
- the compiled RenderState for this Mesh, either from RenderStates applied locally or those inherited from this Mesh's ancestors. May be null if a state of the given type was never applied in either place.
-
setSolidColor
setSolidColor
sets the color array of this geometry to a single color. For greater efficiency, try setting the the ColorBuffer to null and using DefaultColor instead.- Parameters:
color
- the color to set.
-
setRandomColors
public void setRandomColors()Sets every color of this geometry's color array to a random color. -
supportsBoundsIntersectionRecord
public boolean supportsBoundsIntersectionRecord()- Specified by:
supportsBoundsIntersectionRecord
in interfacePickable
- Returns:
- true if this pickable supports intersectsWorldBoundsWhere. False if this method will always return null.
-
supportsPrimitivesIntersectionRecord
public boolean supportsPrimitivesIntersectionRecord()- Specified by:
supportsPrimitivesIntersectionRecord
in interfacePickable
- Returns:
- true if this pickable supports intersectsPrimitivesWhere. False if this method will always return null.
-
intersectsWorldBound
- Specified by:
intersectsWorldBound
in interfacePickable
- Parameters:
ray
- a ray, in world coordinates.- Returns:
- true if the given ray intersects our world bounding volume. false if it does not.
-
intersectsWorldBoundsWhere
- Specified by:
intersectsWorldBoundsWhere
in interfacePickable
- Parameters:
ray
- a ray, in world coordinates.- Returns:
- an intersection record containing information about where the ray intersected our bounding volume, or null if it does not.
-
intersectsPrimitivesWhere
- Specified by:
intersectsPrimitivesWhere
in interfacePickable
- Parameters:
ray
- a ray, in world coordinates.- Returns:
- an intersection record containing information about where the ray intersected our primitives, or null if it does not.
-
makeCopy
Description copied from class:Spatial
Create a copy of this spatial. -
makeInstanced
Description copied from class:Spatial
Creates and returns a new instance of this spatial. Used for instanced rendering. All instances visible on the screen will be drawn in one draw call. The new instance will share all data (meshData and renderStates) with the current mesh and all other instances created from this spatial.- Overrides:
makeInstanced
in classSpatial
- Returns:
- an instanced copy of this node
-
reorderIndices
Let this mesh know we want to change its indices to the provided new order. Override this to provide extra functionality for sub types as needed.- Parameters:
newIndices
- the IntBufferData to switch to.modes
- the new segment modes to use.lengths
- the new lengths to use.
-
reorderVertexData
public void reorderVertexData(int[] newVertexOrder) Swap around the order of the vertex data in this Mesh. This is usually called by a tool that has attempted to determine a more optimal order for vertex data.- Parameters:
newVertexOrder
- a mapping to the desired new order, where the current location of a vertex is the index into this array and the value at that location in the array is the new location to store the vertex data.
-
reorderVertexData
Swap around the order of the vertex data in the given MeshData. Override to provide specific behavior to the Mesh object.- Parameters:
newVertexOrder
- a mapping to the desired new order, where the current location of a vertex is the index into this array and the value at that location in the array is the new location to store the vertex data.meshData
- the meshData object to work against.
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
- Overrides:
getClassTag
in classSpatial
- See Also:
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classSpatial
- Parameters:
capsule
- the capsule- Throws:
IOException
- Signals that an I/O exception has occurred.- See Also:
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classSpatial
- Parameters:
capsule
- the input capsule- Throws:
IOException
- Signals that an I/O exception has occurred.- See Also:
-