public class SkinMeshBody extends SkinMeshBase implements CollidableBody, PointAttachable
Each vertex is connected internally to the master bodies by a PointSkinAttachment
, which contains a weighted PointSkinAttachment.SkinConnection
to each body. The connection weights are
computed based on the distance from the vertex to each body, and sum to
one. All connections collectively determine the vertex position as the
master bodies move and/or deform.
A typical procedure for creating a SkinMeshBody
in code
is as follows:
// create the body with an underlying mesh: SkinMeshBody skinMesh = new SkinMeshBody(mesh); // add the master body references: skinMesh.addMasterBody (rigidBody1); skinMesh.addMasterBody (rigidBody2); skinMesh.addMasterBody (femModel1); // compute the weighted connections for each vertex: skinMesh.computeAllVertexConnections();
By default, computeAllVertexConnections()
uses an inverse
square distance weighting scheme to determine the connection
weights. Applications may determine the connection weights in other ways,
either by specifying a different weighting function or by specifying them
explicitly. Applications can also add point-based markers or create
point-based attachments for a {\tt SkinMeshBody}.
For full details, see the Chapter ``Skinning'' in the ArtiSynth Modeling Guide.
Modifier and Type | Class and Description |
---|---|
static class |
SkinMeshBody.BodyInfo
Base class for information about bodies (e.g., Frames or
FemNodels) used to control the skinning.
|
static class |
SkinMeshBody.ElementRotationData
Contains information about the rotation of a FEM element, which is needed
when connecting a point or vertex to an FEM model using an
ElementConnection.
|
static class |
SkinMeshBody.FemConnectionType
Decsribes the connection type used for FEM bodies.
|
static class |
SkinMeshBody.FemModelInfo
Contains information for each FemModel controlling this SkinMeshBody.
|
static class |
SkinMeshBody.FrameBlending
Characterizes the blend mechanism used for the frame-based
portion of the skinning.
|
static class |
SkinMeshBody.FrameInfo
Contains information for each frame controlling this SkinMeshBody.
|
static class |
SkinMeshBody.NearestPoint
Contains information about the nearest point on a master body to a
another point or mesh vertex.
|
Collidable.Collidability, Collidable.Group
ModelComponent.NavpanelVisibility
CompositeComponent.NavpanelDisplay
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_ATTACH_POINTS_TO_MESH |
static double |
DEFAULT_DQ_BLEND_TOLERANCE |
static int |
DEFAULT_DQ_MAX_BLEND_STEPS |
static SkinMeshBody.FemConnectionType |
DEFAULT_FEM_CONNECTION_TYPE |
static SkinMeshBody.FrameBlending |
DEFAULT_FRAME_BLENDING |
static PropertyList |
myProps |
DEFAULT_COLOR_INTERPOLATION, DEFAULT_SELECTABLE, DEFAULT_VERTEX_COLOR_MIXING
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
All, AllBodies, Deformable, Rigid, Self
TG_ARTICULATED, TG_DRAGGER, TG_PRESERVE_ORIENTATION, TG_SIMULATING
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
SkinMeshBody()
Creates an empty SkinMeshBody with no mesh.
|
SkinMeshBody(MeshBase mesh)
Creates a SkinMeshBody with a specified mesh.
|
SkinMeshBody(java.lang.String name,
MeshBase mesh)
Creates a SkinMeshBody with a specified name and mesh.
|
Modifier and Type | Method and Description |
---|---|
void |
addFemModel(FemModel3d fem)
Deprecated.
|
void |
addFrame(Frame frame)
Deprecated.
|
SkinMarker |
addMarker(Point3d pos)
Creates and adds a marker to this SkinMeshBody.
|
SkinMarker |
addMarker(java.lang.String name,
Point3d pos)
Creates and adds a marker to this SkinMeshBody.
|
SkinMarker |
addMarker(java.lang.String name,
Point3d pos,
VectorNd weights)
Creates and adds a marker to this SkinMeshBody.
|
void |
addMasterBody(ModelComponent body)
Adds a master body with this SkinMeshBody so that it can be used for
skinning control.
|
SkinMarker |
addMeshMarker(Point3d pos)
Creates and adds a marker to the nearest mesh feature of this skin body.
|
SkinMarker |
addMeshMarker(java.lang.String name,
Point3d pos)
Creates and adds a marker to the nearest mesh feature of this skin body.
|
boolean |
allowCollision(ContactPoint cpnt,
Collidable other,
java.util.Set<Vertex3d> attachedVertices)
Returns
true if a collision between this Collidable
and other should be allowed for the contact point
cpnt . |
void |
clearMarkers()
Removes all markers from this SkinMeshBody.
|
void |
clearVertexConnections(int vidx)
Clears master body connections for a specified vertex of this
SkinMeshBody's mesh.
|
void |
collectVertexMasters(java.util.List<ContactMaster> mlist,
Vertex3d vtx)
Collects the contact masters for a particular mesh vertex.
|
void |
computeAllVertexConnections()
Computes master body connections for every vertex of this SkinMeshBody's
mesh.
|
void |
computeVertexConnections(int vidx,
VectorNd weights)
Computes master body connections for a specified vertex of this
SkinMeshBody's mesh.
|
void |
computeWeights()
Deprecated.
Use
computeAllVertexConnections() instead. |
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)
Returns true if this Collidable contains a specified contact master
component.
|
PointSkinAttachment |
createPointAttachment(Point pnt)
Creates an attachment between a
Point and this skin body. |
PointSkinAttachment |
createPointAttachment(Point pnt,
VectorNd weights)
Creates an attachment between a
Point and the master bodies of
this SkinMeshBody. |
PointSkinAttachment |
createPointMeshAttachment(Point pnt)
Creates an attachment between a
Point and the nearest mesh
feature of this skin mesh body. |
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).
|
java.util.List<SkinMeshBody.BodyInfo> |
getAllMasterBodyInfo()
Returns the information structures of all master bodies that are
currently registered with this SkinMeshBody.
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
void |
getAttachments(java.util.List<DynamicAttachment> list,
int level) |
boolean |
getAttachPointsToMesh()
Queries whether the point attachments created by
createPointAttachment(Point) should connect directly to the skin body's
mesh. |
RigidTransform3d |
getBasePose(Frame frame)
Queries the base pose of a
Frame based master body. |
Collidable.Collidability |
getCollidable()
Returns the
Collidable.Collidability of this Collidable. |
Collidable |
getCollidableAncestor()
Returns the most immediate Collidable ancestor of this Collidable,
if any.
|
int |
getCollidableIndex() |
PolygonalMesh |
getCollisionMesh()
Returns the mesh that should be used for computing collisions, or
null if there is no such mesh. |
DistanceGridComp |
getDistanceGridComp()
Returns a
DistanceGridComp object that in turn contains
a signed distance grid that can be used with a SignedDistanceCollider,
or null if this Collidable
does not support a signed distance grid (i.e., if
CollidableBody.hasDistanceGrid() returns false ). |
double |
getDQBlendTolerance()
Queries the tolerance used for iterative dual-quaternion frame blending.
|
int |
getDQMaxBlendSteps()
Queries the maximum number of steps used for iterative dual-quaternion
frame blending.
|
SkinMeshBody.FemConnectionType |
getFemConnectionType()
Queries the connection type to be used when creating subsequent
connections to FEM master bodies.
|
SkinMeshBody.FrameBlending |
getFrameBlending()
Queries the blend type for that part of the skinning that depends on
frames.
|
double |
getMass()
Returns an estimate of the mass of this SkinMeshBody (as determined by
the underlying master bodies) for purposes of handling collisions.
|
ModelComponent |
getMasterBody(int idx)
Gets the
idx -th master body registered with this
SkinMeshBody. |
void |
getSoftReferences(java.util.List<ModelComponent> refs)
Appends all soft references for this component to a list.
|
PointSkinAttachment |
getVertexAttachment(int idx)
Returns the attachment associated with the idx-th mesh vertex of this
SkinMeshBody.
|
PointSkinAttachment |
getVertexAttachment(Vertex3d vtx)
Returns the attachment associated with a specific mesh vertex of this
SkinMeshBody.
|
Point3d |
getVertexBasePosition(int idx)
Returns the base (i.e., initial) position for a specified vertex in this
SkinMeshBody.
|
double |
getVertexBaseWeight(int idx)
Returns the base weight for a specified vertex in this SkinMeshBody.
|
SkinWeightingFunction |
getWeightingFunction()
Returns the weighting function used to compute connections.
|
boolean |
hasDistanceGrid()
Returns
true if this Collidable supports a signed
distance grid that can be used with a SignedDistanceCollider. |
boolean |
hasInvariantMasters()
Queries whether or not the contact masters for a particular collision
point are invariant across all contacts.
|
boolean |
hasMasterBody(ModelComponent body)
Returns true is a specified master body is currently registered
with this SkinMeshBody.
|
boolean |
isCompound()
Queries whether or not this collidable has sub-collidables.
|
boolean |
isDeformable()
Returns
true if this collidable is deformable. |
PointList<SkinMarker> |
markers()
Returns the list of markers associated with this SkinMeshBody.
|
int |
numMasterBodies()
Returns the number of master bodies currently registered with this
SkinMeshBody.
|
int |
numVertexAttachments()
Returns the number of vertex attachments in this SkinMeshBody.
|
void |
prerender(RenderList list)
Called prior to rendering to allow this object to update the internal
state required for rendering (such as by caching rendering coordinates).
|
boolean |
removeMarker(SkinMarker mkr)
Removes a marker from this SkinMeshBody.
|
boolean |
removeMasterBody(ModelComponent body)
Removes a master body from this SkinMeshBody.
|
void |
setAttachPointsToMesh(boolean enable)
Sets whether the point attachments created by
createPointAttachment(Point) should connect directly to the skin body's
mesh. |
void |
setBasePose(Frame frame,
RigidTransform3d TBW0)
Sets the base pose of a
Frame based master body. |
void |
setCollidable(Collidable.Collidability c) |
void |
setCollidableIndex(int idx) |
void |
setDQBlendTolerance(double tol)
Sets the tolerance used for iterative dual-quaternion frame blending.
|
void |
setDQMaxBlendSteps(int max)
Sets the maximum number of steps used for iterative dual-quaternion
frame blending.
|
void |
setFemConnectionType(SkinMeshBody.FemConnectionType type)
Sets the connection type to be used when creating subsequent connections
to FEM master bodies.
|
void |
setFrameBlending(SkinMeshBody.FrameBlending type)
Sets the blend type for that part of the skinning that
depends on frames.
|
void |
setGaussianWeighting(double sigma)
Sets the weighting function to be used in computing connections to an
inverse square weighting implemented by
InverseSquareWeighting . |
void |
setInverseSquareWeighting()
Sets the weighting function to be used in computing connections to an
inverse square weighting implemented by
InverseSquareWeighting . |
void |
setMesh(MeshBase mesh)
Sets the mesh associated with the this SkinMeshBody.
|
void |
setVertexBasePosition(int idx,
Vector3d pos)
Sets the base (i.e., initial) position for a specified vertex in this
SkinMeshBody.
|
void |
setVertexBaseWeight(int idx,
double w,
boolean normalize)
Sets the base weight for a specified vertex in this SkinMeshBody.
|
void |
setWeightingFunction(SkinWeightingFunction fxn)
Sets the weighting function to be used in computing connections in
subsequent calls to the methods
computeAllVertexConnections() ,
computeVertexConnections(int, maspack.matrix.VectorNd) , addMarker(Point3d) , createPointAttachment(Point) , etc. |
void |
smoothWeights()
Smooths vertex connection weights by looking at neighbouring vertices.
|
void |
smoothWeights(Function1x1 weightFunction,
int networkDist)
Smooths vertex connection weights according to a function of
distance.
|
void |
smoothWeights(int networkDist)
Smooths vertex connection weights according to a function of
distance.
|
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 |
updateReferences(boolean undo,
java.util.Deque<java.lang.Object> undoInfo)
May be called by the system if any of the soft references for
this component are removed from the the component hierarchy.
|
void |
updateSlavePos()
Updates the mesh vertices to reflect the current position of the
attached Frames, FemModels, and points.
|
componentChanged, copy, findComponent, get, get, getByNumber, getChildren, getNavpanelDisplay, getNavpanelVisibility, getNumberLimit, getSurfaceMesh, getSurfaceMeshes, hasChildren, hierarchyContainsReferences, indexOf, numComponents, numSurfaceMeshes, postscan, scaleDistance, scan, setDisplayMode, setNavpanelDisplay, updateNameMap, updateSlaveVel
addTransformableDependencies, createSurfaceMeshArray, getColorInterpolation, getFileName, getFileTransform, getMesh, getMeshToWorld, getSurfaceMeshes, getVertex, getVertexColorMixing, isFileTransformRigid, isMeshModified, isMeshPolygonal, isMeshTriangular, isSelectable, numSurfaceMeshes, numVertices, prerenderMesh, render, render, scaleMass, setColorInterpolation, setFileName, setFileTransform, setMesh, setMesh, setMeshToWorld, setSelectable, setVertexColorMixing, transformGeometry, updateBounds, updatePosition
createRenderProps, defaultRenderPropsAreNull, getRenderHints, getRenderProps, getSelection, isVisible, numSelectionQueriesNeeded, setRenderProps, setVisible, updateRenderProps
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, createTempFlag, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNumber, getParent, getProperty, hasState, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable
getProperty
getChildren, hasChildren
postscan
isWritable, write
transformPriority
public static SkinMeshBody.FrameBlending DEFAULT_FRAME_BLENDING
public static double DEFAULT_DQ_BLEND_TOLERANCE
public static int DEFAULT_DQ_MAX_BLEND_STEPS
public static boolean DEFAULT_ATTACH_POINTS_TO_MESH
public static final SkinMeshBody.FemConnectionType DEFAULT_FEM_CONNECTION_TYPE
public static PropertyList myProps
public SkinMeshBody()
public SkinMeshBody(MeshBase mesh)
mesh
- mesh to be associated with the bodypublic SkinMeshBody(java.lang.String name, MeshBase mesh)
name
- name of the bodymesh
- mesh to be associated with the bodypublic PropertyList getAllPropertyInfo()
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class SkinMeshBase
public void setFrameBlending(SkinMeshBody.FrameBlending type)
type
- frame blending typepublic SkinMeshBody.FrameBlending getFrameBlending()
public Collidable.Collidability getCollidable()
Collidable.Collidability
of this Collidable. This provides
control over whether external and/or internal collisions are enabled for
this Collidable. This setting takes precedence over default and
explicitly requested collision behaviors.
Note that for collisions to actually occur, they still need to be enabled through either a default or explicit collision behavior in the MechModel.
getCollidable
in interface Collidable
public void setCollidable(Collidable.Collidability c)
public SkinWeightingFunction getWeightingFunction()
setWeightingFunction(artisynth.core.femmodels.SkinWeightingFunction)
public void setWeightingFunction(SkinWeightingFunction fxn)
computeAllVertexConnections()
,
computeVertexConnections(int, maspack.matrix.VectorNd)
, addMarker(Point3d)
, createPointAttachment(Point)
, etc. Current vertex and marker
connections will remain unchanged.fxn
- new weighting function.public void setInverseSquareWeighting()
InverseSquareWeighting
. This is equivalent to calling
setWeightingFunction (new InverseSquareWeighting())
public void setGaussianWeighting(double sigma)
InverseSquareWeighting
. This is equivalent to calling
setWeightingFunction (new InverseSquareWeighting())
public double getDQBlendTolerance()
public void setDQBlendTolerance(double tol)
tol
- new blending tolerancepublic int getDQMaxBlendSteps()
public void setDQMaxBlendSteps(int max)
max
- maximum number of blending stepspublic boolean getAttachPointsToMesh()
createPointAttachment(Point)
should connect directly to the skin body's
mesh. See setAttachPointsToMesh
for details.true
, point attachments created by createPointAttachment(Point)
should connect to skin body's meshsetAttachPointsToMesh(boolean)
public void setAttachPointsToMesh(boolean enable)
createPointAttachment(Point)
should connect directly to the skin body's
mesh. If this is true
, and the body's mesh is both an instance of
PolygonalMesh
and triangular, then the point attachment is
created using createPointMeshAttachment(Point)
. Otherwise, a
direct connection to the master bodies is created using createPointAttachment(Point,VectorNd)
.enable
- if true
, subsequent point attachments
created by createPointAttachment(Point)
should connect to skin body's meshgetAttachPointsToMesh()
public void setMesh(MeshBase mesh)
computeAllVertexConnections()
or
computeVertexConnections(int,VectorNd)
.setMesh
in class MeshComponent
mesh
- new mesh to be associated with this bodypublic Point3d getVertexBasePosition(int idx)
idx
- index of the vertex. Must be less than
numVertexAttachments()
.public void setVertexBasePosition(int idx, Vector3d pos)
idx
- index of the vertex. Must be less than numVertexAttachments()
.pos
- new base positionpublic double getVertexBaseWeight(int idx)
idx
- index of the vertex. Must be less than
numVertexAttachments()
.public void setVertexBaseWeight(int idx, double w, boolean normalize)
idx
- index of the vertex. Must be less than numVertexAttachments()
.w
- new base weight to setnormalize
- if true
, and the other connection weights
sum to a non-zero value, scales the other connection weights
so that the total weight sum remains unchanged.public int numVertexAttachments()
MeshComponent.numVertices()
.numVertexAttachments
in class SkinMeshBase
public PointSkinAttachment getVertexAttachment(int idx)
getVertexAttachment
in class SkinMeshBase
idx
- index of the vertex for which the attachment is desired.
Must be less that numVertexAttachments()
.public PointSkinAttachment getVertexAttachment(Vertex3d vtx)
getVertexAttachment
in class DynamicMeshComponent
vtx
- vertex for which the attachment is desired.public void getAttachments(java.util.List<DynamicAttachment> list, int level)
public SkinMarker addMarker(Point3d pos)
addMarker(String,Point3d)
,
with name
equal to null
.pos
- initial marker positionpublic SkinMarker addMarker(java.lang.String name, Point3d pos)
pos
) and the
current master body configurations, with the connection weights for each
master body determined by the skin weighting function (as returned by
getWeightingFunction()
).name
- name of the markerpos
- initial marker positionpublic SkinMarker addMarker(java.lang.String name, Point3d pos, VectorNd weights)
pos
) and the
current master body configurations, with the connection weights for each
master body specified by weights
.
The size of weights
must be >=
numMasterBodies()
. If it is >= numMasterBodies()+1
, the
additional value specifies the marker attachment's base weight.
name
- name of the markerpos
- initial marker positionweights
- connection weightspublic SkinMarker addMeshMarker(Point3d pos)
addMeshMarker(String,Point3d)
, with
name
equal to null
.pos
- requested initial marker positionpublic SkinMarker addMeshMarker(java.lang.String name, Point3d pos)
PolygonalMesh
and
triangular. The requested marker position pos
is then projected
onto the nearest mesh feature (e.g., a face for a PolygonalMesh
or a line segment for a PolylineMesh
), and the master body
connections are formed by a linear combination of the connections of the
nearest feature vertices, based on the barycentric coordinates of the
projected point position.
Attaching markers to the mesh entails a greater computational cost but
ensures that the marker will remain connected to the mesh in the same
relative position. If the vertex connections are subsequently changed,
such as through a call to computeAllVertexConnections()
, the
marker will no longer follow the mesh position.
name
- name of the markerpos
- requested initial marker positionpublic boolean removeMarker(SkinMarker mkr)
mkr
- marker to removetrue
if the marker was present and was removedpublic void clearMarkers()
public PointList<SkinMarker> markers()
public void addFrame(Frame frame)
addMasterBody(artisynth.core.modelbase.ModelComponent)
insteadpublic boolean removeMasterBody(ModelComponent body)
body
- master body to be removedpublic boolean hasMasterBody(ModelComponent body)
body
- body to be queriedpublic ModelComponent getMasterBody(int idx)
idx
-th master body registered with this
SkinMeshBody.idx
- index of the desired body; must be between 0 and
the number returned by numMasterBodies()
numMasterBodies()
.public int numMasterBodies()
public void addMasterBody(ModelComponent body)
Frame
and FemModel3d
.body
- master body to be registeredpublic RigidTransform3d getBasePose(Frame frame)
Frame
based master body.frame
- frame for which the base pose is requestedframe
public void setBasePose(Frame frame, RigidTransform3d TBW0)
Frame
based master body.frame
- frame for which the base pose is to be setTBW0
- new base posepublic java.util.List<SkinMeshBody.BodyInfo> getAllMasterBodyInfo()
public void addFemModel(FemModel3d fem)
addMasterBody(artisynth.core.modelbase.ModelComponent)
insteadpublic void computeWeights()
computeAllVertexConnections()
instead.public void computeAllVertexConnections()
getWeightingFunction()
).public void computeVertexConnections(int vidx, VectorNd weights)
The connection weights for each master body can be specified by the
optional argument weights
. If weights
is null
,
then the weights are determined by the skin weighting function (as
returned by getWeightingFunction()
). If non-null
, the size
of weights
must be >=
numMasterBodies()
. If it
is >= numMasterBodies()+1
, the additional value specifies the
vertex attachment's base weight.
vidx
- index of the vertex for which connections are to be computedweights
- if non-null
, specifies connection weightspublic void clearVertexConnections(int vidx)
vidx
- index of the vertex for which connections are to be cleared
`public void smoothWeights(Function1x1 weightFunction, int networkDist)
This method is experimental.
weightFunction
- single-input single-output function of distance
to use as weightsnetworkDist
- number of paths to traverse to collect verticespublic void smoothWeights(int networkDist)
smoothWeights(Function1x1,int)
with
weightFunction
set to a constant value of 1.
This method is experimental.
networkDist
- number of paths to traverse to collect verticespublic void smoothWeights()
smoothWeights(Function1x1,int)
with weightFunction
set to a constant value of 1 and networkDist
set to 1.
This method is experimental.
public void updateSlavePos()
updateSlavePos
in interface HasSlaveObjects
updateSlavePos
in class SkinMeshBase
public void setFemConnectionType(SkinMeshBody.FemConnectionType type)
SkinMeshBody.FemConnectionType.ELEMENT
. The alternative is the legacy
displacement based connection (type SkinMeshBody.FemConnectionType.DISPLACEMENT
. This method is provided to allow
applications to employ the legacy displacement connection type ( which
works well only for FEM deformations that do not involve a large amount
of rotation).
Changing the connection type will only affect connections that are
created through subsequent calls to the methods computeAllVertexConnections()
, computeVertexConnections(int, maspack.matrix.VectorNd)
, addMarker(Point3d)
, createPointAttachment(Point)
, etc.
type
- new element connection typepublic SkinMeshBody.FemConnectionType getFemConnectionType()
public PointSkinAttachment createPointAttachment(Point pnt)
Point
and this skin body. If
getAttachPointsToMesh()
returns true
, and the body has a
triangular mesh, then the point is connected to the mesh using createPointMeshAttachment(Point)
. Otherwise, the point is connected to
the masters using a direct connection via createPointAttachment(Point,VectorNd)
.createPointAttachment
in interface PointAttachable
pnt
- point to be attachedpublic PointSkinAttachment createPointMeshAttachment(Point pnt)
Point
and the nearest mesh
feature of this skin mesh body. The mesh must be both an instance of
PolygonalMesh
and triangular. The point to be attached is then
projected onto the nearest mesh feature (e.g., a face for a PolygonalMesh
or a line segment for a PolylineMesh
), and the
master body connections are formed by a linear combination of the
connections of the nearest feature vertices, based on the barycentric
coodinates of the projected point position.
Attaching points to the mesh entails a greater computational cost but
ensures that the attached point will remain connected to the mesh in the
same relative position. If the vertex connections are subsequently
changed, such as through a call to computeAllVertexConnections()
,
the attached point will no longer follow the mesh position.
pnt
- point to be attachedpublic PointSkinAttachment createPointAttachment(Point pnt, VectorNd weights)
Point
and the master bodies of
this SkinMeshBody. The connection weights for each master body are
specified by weights
.
The size of weights
must be >=
numMasterBodies()
. If it is >= numMasterBodies()+1
, the
additional value specifies the attachment's base weight.
pnt
- point to be attachedweights
- connection weightspublic PolygonalMesh getCollisionMesh()
null
if there is no such mesh. If this method
returns null
, then no collisions will
be performed for this collidable, regardless any default or explicit
collision behaviors that have been arranged by the system.getCollisionMesh
in interface CollidableBody
public boolean hasDistanceGrid()
true
if this Collidable supports a signed
distance grid that can be used with a SignedDistanceCollider. At
present, this will only be true for non-deformable bodies.hasDistanceGrid
in interface CollidableBody
true
if this Collidable supports a signed
distance gridpublic DistanceGridComp getDistanceGridComp()
DistanceGridComp
object that in turn contains
a signed distance grid that can be used with a SignedDistanceCollider,
or null
if this Collidable
does not support a signed distance grid (i.e., if
CollidableBody.hasDistanceGrid()
returns false
).getDistanceGridComp
in interface CollidableBody
public Collidable getCollidableAncestor()
null
.getCollidableAncestor
in interface Collidable
null
.public boolean isCompound()
isCompound
in interface Collidable
true
if this collidable has sub-collidablespublic boolean isDeformable()
true
if this collidable is deformable. Whether or
not a collidable is deformable determines how it responds to default
collision behaviors involving deformable and rigid collidables. Also,
self-collisions among sub-collidables of a collidable A are permitted
only if A is deformable.isDeformable
in interface Collidable
true
if this collidable is deformablepublic double getMass()
getMass
in interface CollidableBody
public void collectVertexMasters(java.util.List<ContactMaster> mlist, Vertex3d vtx)
mlist
. The vertex
should be a vertex of the mesh returned by CollidableBody.getCollisionMesh()
.
If CollidableBody.hasInvariantMasters()
returns true
, then the
contact masters will not depend on vtx
.
collectVertexMasters
in interface CollidableBody
mlist
- collected master componentsvtx
- vertex for which the master components are requestedpublic boolean hasInvariantMasters()
A collidable that has invariant contact masters typically has fewer dynamic degrees of freedom compared to one that does not.
hasInvariantMasters
in interface CollidableBody
true
if contact masters are constantpublic boolean containsContactMaster(CollidableDynamicComponent comp)
containsContactMaster
in interface CollidableBody
comp
- component to test fortrue
if comp
is contained in
this Collidablepublic boolean allowCollision(ContactPoint cpnt, Collidable other, java.util.Set<Vertex3d> attachedVertices)
true
if a collision between this Collidable
and other
should be allowed for the contact point
cpnt
. In making this decision, this method may
refer to attachedVertices
, which supplies a list
of vertices on this Collidable which are attached in some way
to the other Collidable.allowCollision
in interface CollidableBody
cpnt
- contact point being testedother
- opposing collidableattachedVertices
- list of vertices attached to other
.true
if the collision should be allowedpublic int getCollidableIndex()
getCollidableIndex
in interface CollidableBody
public void setCollidableIndex(int idx)
setCollidableIndex
in interface CollidableBody
public void transformGeometry(GeometryTransformer gtr, TransformGeometryContext context, int flags)
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 SkinMeshBase
gtr
- transformer implementing the transformcontext
- context information, including what other components
are being transformedflags
- specifies conditions associated with the transformationpublic void prerender(RenderList list)
list.addIfVisible (obj);
for each of the objects in question.prerender
in interface IsRenderable
prerender
in class MeshComponent
list
- list of objects to be renderedpublic void connectToHierarchy(CompositeComponent hcomp)
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)
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 getSoftReferences(java.util.List<ModelComponent> refs)
updateReferences()
method will
be called to update its internal reference information.getSoftReferences
in interface ModelComponent
getSoftReferences
in class ModelComponentBase
refs
- list to which soft references are appendedpublic void updateReferences(boolean undo, java.util.Deque<java.lang.Object> undoInfo)
undo
equal to false
,
this component should then examine its soft references and
use ComponentUtils.areConnected()
to determine which of them have been disconnected from the hierarchy.
Disconnected references should be removed, and sufficient information
should be appended to undoInfo
to allow this update
to be undone if this method is called later with undo
equal to true
. When undoing an update, the undo
information should be removed from the front of undoInfo
.updateReferences
in interface ModelComponent
updateReferences
in class ModelComponentBase
undo
- if true
, indicates that the most
recent reference update should be undone, using the supplied
undo information.undoInfo
- if undo
is false
, should be used
to store information allowing the reference update to be undone.
Otherwise, if undo
is true
, then this
supplied information to undo the most recent update.