public class RigidMeshComp extends DynamicMeshComponent implements PointAttachable, HasSurfaceMesh
ModelComponent.NavpanelVisibility
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_HAS_MASS |
static PropertyList |
myProps |
DEFAULT_COLOR_INTERPOLATION, DEFAULT_SELECTABLE, DEFAULT_VERTEX_COLOR_MIXING
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
TG_ARTICULATED, TG_DRAGGER, TG_PRESERVE_ORIENTATION, TG_SIMULATING
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
RigidMeshComp() |
RigidMeshComp(MeshBase mesh) |
RigidMeshComp(MeshBase mesh,
java.lang.String fileName,
AffineTransform3dBase X) |
RigidMeshComp(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
connectToHierarchy(CompositeComponent hcomp)
Called by the system after this component, or an ancestor of this
component, is added to the component hierarchy (i.e., added as
a child of another CompositeComponent).
|
boolean |
containsContactMaster(CollidableDynamicComponent comp) |
RigidMeshComp |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap) |
PointFrameAttachment |
createPointAttachment(Point pnt)
Returns a PointAttachment that attaches
pnt
to this component. |
void |
disconnectFromHierarchy(CompositeComponent hcomp)
Called by the system after this component, or an ancestor of this
component, is removed from the component hierarchy (i.e., removed as a
child of its parent).
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
MassDistribution |
getDefaultMassDistribution(MeshBase mesh) |
double |
getDensity()
Returns the density of this RigidMeshComp.
|
double |
getMass()
Returns the mass of this RigidMeshComp.
|
MassDistribution |
getMassDistribution()
Queries the mass distribution for this RigidMeshComp.
|
RigidBody |
getRigidBody() |
void |
getSelection(java.util.LinkedList<java.lang.Object> list,
int qid)
Append to
list the component (or components) associated with
the qid -th selection query issued by this component's render
method. |
PolygonalMesh |
getSurfaceMesh()
Returns the surface mesh associated with this component, or
null if no mesh exists. |
PolygonalMesh[] |
getSurfaceMeshes()
Returns an array listing all the (non-null) surface meshes associated
with this component, or a zero-length array if there are none.
|
PointAttachment |
getVertexAttachment(int vidx)
Retrieves (or creates) a vertex attachment component associated with
vertex vidx, describing how its motion is driven by the underlying
physical system.
|
PointAttachment |
getVertexAttachment(Vertex3d vtx)
Retrieves (or creates) a vertex attachment component associated with
vertex vtx, describing how its motion is driver by the underlying
physical system.
|
double |
getVolume()
Returns the volume of this RigidMeshComp.
|
boolean |
hasExplicitDensity()
Queries if a density has been explicitly set by
setDensity(double) . |
boolean |
hasExplicitMass()
Queries if a mass has been explicitly set by
setMass(double) . |
boolean |
hasExplicitMassOrDensity()
Queries if either the mass or density has been explicitly set
by
setMass(double) or setDensity(double) . |
boolean |
hasExplicitVolume()
Queries if a volume has been explicitly set by
setVolume(double) . |
boolean |
hasMass()
Queries whether or not this RigidMeshComp has mass.
|
boolean |
isCollidable()
Queries whether or not this RigidMeshComp is collidable.
|
boolean |
isDeformable() |
int |
numSelectionQueriesNeeded()
If this selectable manages its own selection (by issuing selection
queries within its
render method), then this method should
return the maximum number of selection queries that will be
required. |
int |
numSurfaceMeshes()
Returns the number of surfaces meshes associated with this
component, or 0 if no meshes exist.
|
void |
render(Renderer renderer,
RenderProps props,
int flags) |
void |
scaleDistance(double s)
Scales all distance coordinates.
|
void |
scaleMass(double s)
Scales all mass units.
|
void |
scaleMesh(double sx,
double sy,
double sz) |
void |
setDensity(double d)
Explicitly sets a density value for this RigidMeshComp if
d >= 0 . |
void |
setHasMass(boolean enable)
Sets whether or not this RigidMeshComp has mass.
|
void |
setIsCollidable(boolean enable)
Sets whether or not this RigidMeshComp is collidable.
|
void |
setMass(double mass)
Explicitly sets a mass value for this RigidMeshComp if
mass >= 0 . |
void |
setMassDistribution(MassDistribution dist)
Sets the mass distribution for this RigidMeshComp.
|
void |
setMesh(MeshBase mesh,
java.lang.String fileName,
AffineTransform3dBase X) |
void |
setVolume(double vol)
Explicitly sets a volume value for this RigidMeshComp if
the
vol >= 0 and the mesh is not a PolygonalMesh . |
void |
transformGeometry(GeometryTransformer gtr,
TransformGeometryContext context,
int flags)
Transforms the geometry of this component, using the geometry transformer
gtr to transform its individual attributes. |
void |
transformMesh(AffineTransform3dBase X) |
addTransformableDependencies, createSurfaceMeshArray, getColorInterpolation, getFileName, getFileTransform, getMesh, getMeshToWorld, getSurfaceMeshes, getVertex, getVertexColorMixing, isFileTransformRigid, isMeshModified, isMeshPolygonal, isMeshTriangular, isSelectable, numSurfaceMeshes, numVertices, prerender, prerenderMesh, render, setColorInterpolation, setFileName, setFileTransform, setMesh, setMesh, setMeshToWorld, setSelectable, setVertexColorMixing, transformGeometry, updateBounds, updatePosition, updateSlavePos
createRenderProps, defaultRenderPropsAreNull, getRenderHints, getRenderProps, isVisible, setRenderProps, setVisible, updateRenderProps
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, createTempFlag, getChildren, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasChildren, hasState, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, postscan, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, scan, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, updateReferences, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable, updateReferences
getProperty
getChildren, hasChildren
postscan
isWritable, write
transformPriority
public static boolean DEFAULT_HAS_MASS
public static PropertyList myProps
public RigidMeshComp()
public RigidMeshComp(java.lang.String name)
public RigidMeshComp(MeshBase mesh, java.lang.String fileName, AffineTransform3dBase X)
public RigidMeshComp(MeshBase mesh)
public void setMesh(MeshBase mesh, java.lang.String fileName, AffineTransform3dBase X)
setMesh
in class MeshComponent
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class MeshComponent
public boolean hasMass()
setHasMass(boolean)
for a description of what this means.true
if this RigidMeshComp has masspublic void setHasMass(boolean enable)
RigidBody.InertiaMethod.DENSITY
or RigidBody.InertiaMethod.MASS
.enable
- if true
, sets this RigidMeshComp to have masspublic MassDistribution getMassDistribution()
getMassDistribution()
for a description of what this means.public void setMassDistribution(MassDistribution dist)
RigidBody.InertiaMethod.DENSITY
or RigidBody.InertiaMethod.MASS
.dist
- new mass distribution for this RigidMeshComppublic MassDistribution getDefaultMassDistribution(MeshBase mesh)
public double getVolume()
PolygonalMesh
, this is the value returned by
PolygonalMesh.computeVolume()
. Otherwise, the volume is 0, unless
setVolume(double)
is used to explicitly set a non-zero volume value.setVolume(double)
public void setVolume(double vol)
vol >= 0
and the mesh is not a PolygonalMesh
.
Otherwise, causes the value returned by
#getVolume
to return to its default value.vol
- explicit volume value if >= 0
getVolume()
public boolean hasExplicitVolume()
setVolume(double)
.true
if a volume has been explicitly setsetVolume(double)
public double getMass()
getVolume()
) times the density (as returned by
getDensity()
). Otherwise, if a mass value has been explicitly set
using setMass(double)
, then this explicit value is returned.setMass(double)
public void setMass(double mass)
mass >= 0
.
Otherwise, if mass < 0
, causes the value returned by
#getMass
to return to its default value. In both cases,
any explicit density set by setDensity(double)
is unset.mass
- explicit mass value if >= 0
.getMass()
public boolean hasExplicitMass()
setMass(double)
.true
if a mass has been explicitly setsetMass(double)
public double getDensity()
setDensity(double)
), the density is this explicit value, or if the mass has
been explicitly set (using setMass(double)
), the density is the mass
divided by the volume (as returned by getVolume()
).setDensity(double)
public void setDensity(double d)
d >= 0
.
Otherwise, if d < 0
, unsets any explicitly set density. In both
cases, any explicit mass set by setMass(double)
is also unset.d
- explicit density value if >= 0
.getDensity()
public boolean hasExplicitDensity()
setDensity(double)
.true
if a density has been explicitly setsetDensity(double)
public boolean hasExplicitMassOrDensity()
setMass(double)
or setDensity(double)
.true
if mass or density has been explicitly setsetMass(double)
public void render(Renderer renderer, RenderProps props, int flags)
render
in class MeshComponent
public RigidBody getRigidBody()
public RigidMeshComp copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
copy
in class MeshComponent
public int numSelectionQueriesNeeded()
IsSelectable
render
method), then this method should
return the maximum number of selection queries that will be
required. Otherwise, this method should return -1.numSelectionQueriesNeeded
in interface IsSelectable
numSelectionQueriesNeeded
in class RenderableComponentBase
public void getSelection(java.util.LinkedList<java.lang.Object> list, int qid)
IsSelectable
list
the component (or components) associated with
the qid
-th selection query issued by this component's render
method. This will only be called if this component manages its own
selection (i.e., the number nums
returned by IsSelectable.numSelectionQueriesNeeded()
is positive), and qid
will in
turn be a number between 0 and nums
-1.getSelection
in interface IsSelectable
getSelection
in class RenderableComponentBase
list
- selected objects are appended to the end of this listqid
- index of the selection querypublic boolean isCollidable()
setIsCollidable(boolean)
for a description of what this means.true
if this RigidMeshComp is collidablepublic void setIsCollidable(boolean enable)
enable
- if true
, makes this RigidMeshComp collidable.public boolean isDeformable()
public PointAttachment getVertexAttachment(int vidx)
DynamicMeshComponent
getVertexAttachment
in class DynamicMeshComponent
vidx
- vertex indexpublic PointAttachment getVertexAttachment(Vertex3d vtx)
DynamicMeshComponent
getVertexAttachment
in class DynamicMeshComponent
vtx
- vertexpublic boolean containsContactMaster(CollidableDynamicComponent comp)
public PointFrameAttachment createPointAttachment(Point pnt)
PointAttachable
pnt
to this component. It should not be assumed that pnt
is currently connected to the component hierarchy, and no attempt
should be made to connect the returned attachment to the hierarchy;
the latter, if desired, is the responsibility of the caller.
In some cases, it may not be possible to attach the point at its present location. In that case, the method will create an attachment to the nearest feasible location.
createPointAttachment
in interface PointAttachable
pnt
- point for which an attachment should be createdpnt
to this componentpublic void transformMesh(AffineTransform3dBase X)
public void transformGeometry(GeometryTransformer gtr, TransformGeometryContext context, int flags)
TransformableGeometry
gtr
to transform its individual attributes. The
context
argument supplies information about what other
components are currently being transformed, and also allows the
requesting of update actions to be performed after all transform called
have completed. The context is also the usual entity that calls
this method, from within its TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
method. The argument flags
provides flags to specify
various conditions associated with the the transformation.
At present, the available flags are TransformableGeometry.TG_SIMULATING
and
TransformableGeometry.TG_ARTICULATED
.
This method is not usually called directly by applications.
Instead, it is typically called from within the
TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
method of the context,
which takes care of the various operations needed for a
complete transform operation, including calling
TransformableGeometry.addTransformableDependencies(artisynth.core.modelbase.TransformGeometryContext, int)
to collect other
components that should be transformed, calling
TransformableGeometry.transformGeometry(maspack.matrix.AffineTransform3dBase)
for each component, notifying
component parents that the geometry has changed, and calling
any requested TransformGeometryAction
s. More details
are given in the documentation for
TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
.
TransformGeometryContext
provides a number of
static convenience transform
methods
which take care of building the context and calling
apply()
for a specified set of components.
This method should not
generally call transformGeometry()
for its descendant
components. Instead, descendants needing transformation should be
specified by adding them to the context in the method TransformableGeometry.addTransformableDependencies(artisynth.core.modelbase.TransformGeometryContext, int)
.
transformGeometry
in interface TransformableGeometry
transformGeometry
in class MeshComponent
gtr
- transformer implementing the transformcontext
- context information, including what other components
are being transformedflags
- specifies conditions associated with the transformationpublic void connectToHierarchy(CompositeComponent hcomp)
ModelComponentBase
When this method is called, ModelComponent.getParent()
will return the new
parent component; the system will have set this beforehand.
connectToHierarchy
in interface ModelComponent
connectToHierarchy
in class ModelComponentBase
hcomp
- hierarchy component to which this component,
or its ancestor, was attachedpublic void disconnectFromHierarchy(CompositeComponent hcomp)
ModelComponentBase
When this method is called, ModelComponent.getParent()
will still return this
original parent component; the system will set this to null
after.
disconnectFromHierarchy
in interface ModelComponent
disconnectFromHierarchy
in class ModelComponentBase
hcomp
- hierarchy component from which this component,
or its ancestor, was detachedpublic void scaleMass(double s)
ScalableUnits
scaleMass
in interface ScalableUnits
scaleMass
in class MeshComponent
s
- scaling factorpublic void scaleDistance(double s)
ScalableUnits
scaleDistance
in interface ScalableUnits
scaleDistance
in class MeshComponent
s
- scaling factorpublic void scaleMesh(double sx, double sy, double sz)
public PolygonalMesh getSurfaceMesh()
HasSurfaceMesh
null
if no mesh exists. If multiple surface
meshes exist, this should be first one in the array returned
by HasSurfaceMesh.getSurfaceMeshes()
.getSurfaceMesh
in interface HasSurfaceMesh
public int numSurfaceMeshes()
HasSurfaceMesh
HasSurfaceMesh.getSurfaceMesh()
returns null
, then this method should return 0.numSurfaceMeshes
in interface HasSurfaceMesh
public PolygonalMesh[] getSurfaceMeshes()
HasSurfaceMesh
HasSurfaceMesh.getSurfaceMesh()
returns null
, then a
zero-length array should be returned.getSurfaceMeshes
in interface HasSurfaceMesh