|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectartisynth.core.modelbase.ModelComponentBase
artisynth.core.modelbase.RenderableComponentBase
artisynth.core.mechmodels.DynamicMechComponentBase
artisynth.core.mechmodels.Frame
artisynth.core.mechmodels.RigidBody
public class RigidBody
Nested Class Summary | |
---|---|
static class |
RigidBody.InertiaMethod
|
Nested classes/interfaces inherited from interface artisynth.core.mechmodels.Collidable |
---|
Collidable.DefaultCollidable |
Nested classes/interfaces inherited from interface artisynth.core.modelbase.ModelComponent |
---|
ModelComponent.NavpanelVisibility |
Field Summary | |
---|---|
static PropertyList |
myProps
|
Fields inherited from class artisynth.core.mechmodels.Frame |
---|
dynamicVelInWorldCoords, myRenderFrame |
Fields inherited from class artisynth.core.modelbase.ModelComponentBase |
---|
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames |
Fields inherited from interface artisynth.core.modelbase.CopyableComponent |
---|
COPY_REFERENCES |
Fields inherited from interface artisynth.core.mechmodels.Collidable |
---|
Default, Deformable, RigidBody, Self |
Fields inherited from interface artisynth.core.util.TransformableGeometry |
---|
ARTICULATED, SIMULATING |
Fields inherited from interface maspack.render.GLRenderable |
---|
TRANSLUCENT, TWO_DIMENSIONAL |
Constructor Summary | |
---|---|
RigidBody()
|
|
RigidBody(RigidTransform3d XBodyToWorld,
SpatialInertia M,
PolygonalMesh mesh,
java.lang.String meshFileName)
|
|
RigidBody(java.lang.String name)
|
Method Summary | |
---|---|
void |
addScaledVelocity(double s,
Twist v)
|
void |
addVelocity(Twist v)
|
void |
applyForce(java.lang.Object orig,
Vector3d force)
Given the supplied force origin info and a force vector, apply the force (typically sets an external force) |
void |
applyGravity(Vector3d gacc)
Applies a gravity force to this component, given a prescribed gravity acceleration vector. |
int |
applyPosImpulse(double[] delx,
int idx)
|
double |
computeVolume()
|
ModelComponent |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap)
Create a copy of this component. |
static RigidBody |
createBox(java.lang.String bodyName,
double wx,
double wy,
double wz,
double density)
Creates a box-shaped RigidBody with a prescribed uniform density. |
RigidBodyCollisionData |
createCollisionData()
|
static RigidBody |
createCylinder(java.lang.String bodyName,
double r,
double h,
double density,
int nsides)
Creates a cylindrical RigidBody with a prescribed uniform density. |
static RigidBody |
createEllipsoid(java.lang.String bodyName,
double a,
double b,
double c,
double density,
int nslices)
Creates an ellipsoidal RigidBody with a prescribed uniform density. |
static RigidBody |
createFromMesh(java.lang.String bodyName,
java.lang.Object obj,
java.lang.String relPath,
double density,
double scale)
|
static RigidBody |
createFromMesh(java.lang.String bodyName,
PolygonalMesh mesh,
double density,
double scale)
|
static RigidBody |
createFromMesh(java.lang.String bodyName,
PolygonalMesh mesh,
java.lang.String meshFilePath,
double density,
double scale)
|
static RigidBody |
createFromMesh(java.lang.String bodyName,
java.lang.String meshPath,
double density,
double scale)
|
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object. |
static RigidBody |
createSphere(java.lang.String bodyName,
double r,
double density,
int nslices)
Creates an spherical RigidBody with a prescribed uniform density. |
void |
extrapolatePose(Twist vel,
double h)
|
boolean |
findFreeAttachedBodies(java.util.List<RigidBody> freeBodies,
boolean rejectSelected)
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by this object. |
Point3d |
getCenterOfMass()
|
void |
getCenterOfMass(Point3d com)
|
boolean |
getCopyReferences(java.util.List<ModelComponent> refs,
ModelComponent ancestor)
Collects external references which must also be copied in order to duplicate this component. |
double |
getDensity()
Returns the density of this body. |
Range |
getDensityRange()
|
FrameMarker[] |
getFrameMarkers()
Returns an array of all FrameMarkers currently associated with this rigid body. |
void |
getInertia(SpatialInertia M)
|
RigidBody.InertiaMethod |
getInertiaMethod()
|
void |
getInverseMass(Matrix Minv,
Matrix M)
Inverts a mass for this component. |
double |
getMass()
Returns the mass of this body. |
double |
getMass(double t)
Returns the scalar mass of this component at time t. |
void |
getMass(Matrix M,
double t)
Gets the mass of this component at a particular time. |
int |
getMassForces(VectorNd f,
double t,
int idx)
Gets the mass forces for this component at a particular time. |
Range |
getMassRange()
|
PolygonalMesh |
getMesh()
|
java.lang.String |
getMeshFileName()
|
AffineTransform3dBase |
getMeshFileTransform()
Returns the file transform associated with this rigid body's mesh. |
Point3d |
getOriginData(MouseRayEvent ray)
Constructs force origin storage data given a mouse ray (e.g. |
Point3d |
getOriginPoint(java.lang.Object data)
Determines the world-coordinate point to which force will be applied (used for determining magnitude of force) |
double |
getPointRenderRadius()
|
java.util.ArrayList<RigidTransform3d> |
getRelativePoses(java.util.List<RigidBody> bodies)
|
SymmetricMatrix3d |
getRotationalInertia()
Returns the rotational inertia of this body. |
void |
getRotationalInertia(SymmetricMatrix3d J)
|
PolygonalMesh |
getSurfaceMesh()
|
boolean |
isCollidable()
|
boolean |
isDuplicatable()
Returns true if this component can be duplicated. |
boolean |
isMassConstant()
|
boolean |
isPullable()
|
void |
prerender(RenderList list)
Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer. |
void |
render(GLRenderer renderer,
int flags)
Render this object using Open GL via the JOGL. |
void |
scaleDistance(double s)
Scales all distance coordinates. |
void |
scaleMass(double s)
Scales all mass units. |
void |
scaleMesh(double s)
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer. |
void |
setBodyVelocity(Twist v)
|
void |
setCenterOfMass(Point3d com)
|
void |
setDensity(double density)
Sets the density for the mesh, which is defined at the mass divided by the mesh volume. |
void |
setDynamic(boolean dynamic)
|
void |
setInertia(double m,
double Jxx,
double Jyy,
double Jzz)
Explicitly sets the mass and rotational inertia of this body. |
void |
setInertia(double m,
SymmetricMatrix3d J)
Explicitly sets the mass and rotational inertia of this body. |
void |
setInertia(double m,
SymmetricMatrix3d J,
Point3d com)
Explicitly sets the mass, rotational inertia, and center of mass of this body. |
void |
setInertia(SpatialInertia M)
Explicitly sets the spatial inertia of this body. |
void |
setInertiaFromDensity(double density)
Causes the inertia to be automatically computed from the mesh volume and a given density. |
void |
setInertiaFromMass(double mass)
Causes the inertia to be automatically computed from the mesh volume and a given mass (with the density computed by dividing the mass by the mesh volume). |
void |
setInertiaMethod(RigidBody.InertiaMethod method)
Sets the InertiaMethod method used to
determine the inertia for this RigidBody. |
void |
setMass(double mass)
Sets the mass for the mesh. |
void |
setMesh(PolygonalMesh mesh,
java.lang.String fileName)
|
void |
setMesh(PolygonalMesh mesh,
java.lang.String fileName,
AffineTransform3dBase X)
Sets a mesh for this body. |
void |
setMeshFileName(java.lang.String filename)
|
void |
setMeshFileTransform(AffineTransform3dBase X)
Sets the transform used to modify a mesh originally read from a file. |
void |
setPose(double x,
double y,
double z,
double roll,
double pitch,
double yaw)
|
void |
setPose(RigidTransform3d XBodyToWorld)
|
void |
setPosition(Point3d pos)
|
int |
setPosState(double[] buf,
int idx)
|
void |
setRelativePoses(java.util.List<RigidBody> bodies,
java.util.ArrayList<RigidTransform3d> poses)
|
void |
setRotation(Quaternion q)
|
void |
setRotationalInertia(SymmetricMatrix3d J)
Explicitly sets the rotational inertia of this body. |
void |
setState(Frame frame)
|
int |
setState(VectorNd x,
int idx)
|
void |
setSurfaceMesh(PolygonalMesh mesh,
java.lang.String fileName)
|
void |
setSurfaceMesh(PolygonalMesh mesh,
java.lang.String fileName,
AffineTransform3dBase X)
Sets a mesh for this body. |
void |
setVelocity(Twist v)
|
int |
setVelState(double[] buf,
int idx)
|
void |
transformGeometry(AffineTransform3dBase X)
Applies an affine transformation to the geometry of this object. |
void |
transformGeometry(AffineTransform3dBase X,
TransformableGeometry topObject,
int flags)
Applies an affine transformation to the geometry of this object. |
void |
updateAttachmentPosStates()
|
void |
updateBounds(Point3d pmin,
Point3d pmax)
Update the minimum and maximum points for this object. |
void |
updatePose()
|
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes a text description of this element to a PrintWriter. |
Methods inherited from class artisynth.core.mechmodels.DynamicMechComponentBase |
---|
addMasterAttachment, getAttachment, getMasterAttachments, getSolveIndex, hasState, isActive, isAttached, isControllable, isDynamic, isParametric, removeMasterAttachment, setAttached, setSolveIndex |
Methods inherited from class artisynth.core.modelbase.RenderableComponentBase |
---|
getRenderHints, getRenderProps, isSelectable, numSelectionQueriesNeeded, setRenderProps, updateRenderProps |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface artisynth.core.modelbase.ModelComponent |
---|
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, postscan, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences |
Methods inherited from interface maspack.properties.HasProperties |
---|
getProperty |
Methods inherited from interface maspack.properties.HierarchyNode |
---|
getChildren, hasChildren |
Methods inherited from interface maspack.util.Scannable |
---|
isWritable |
Methods inherited from interface artisynth.core.mechmodels.DynamicMechComponent |
---|
addMasterAttachment, checkFlag, clearFlag, getAttachment, getMasterAttachments, getSolveIndex, isActive, isAttached, isControllable, isDynamic, isParametric, removeMasterAttachment, setAttached, setFlag, setSolveIndex |
Field Detail |
---|
public static PropertyList myProps
Constructor Detail |
---|
public RigidBody()
public RigidBody(java.lang.String name)
public RigidBody(RigidTransform3d XBodyToWorld, SpatialInertia M, PolygonalMesh mesh, java.lang.String meshFileName)
Method Detail |
---|
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class Frame
public boolean isMassConstant()
isMassConstant
in interface DynamicMechComponent
isMassConstant
in class Frame
public double getMass(double t)
DynamicMechComponent
getMass
in interface DynamicMechComponent
getMass
in class Frame
public void getMass(Matrix M, double t)
DynamicMechComponent
getMass
in interface DynamicMechComponent
getMass
in class Frame
M
- matrix to return the mass int
- current timepublic int getMassForces(VectorNd f, double t, int idx)
DynamicMechComponent
f
, starting at the location
specified by idx
. Upon return, this method should
return the value of idx
incremented by the dimension
of the mass forces.
getMassForces
in interface DynamicMechComponent
getMassForces
in class Frame
f
- vector to return the forces int
- current timeidx
- starting location within f
where forces should be stored
idx
public void getInverseMass(Matrix Minv, Matrix M)
DynamicMechComponent
getInverseMass
in interface DynamicMechComponent
getInverseMass
in class DynamicMechComponentBase
Minv
- matrix to return the inverse mass inM
- matrix containing the mass to be invertedpublic RigidBody.InertiaMethod getInertiaMethod()
public void setInertiaMethod(RigidBody.InertiaMethod method)
InertiaMethod
method used to
determine the inertia for this RigidBody.
method
- inertia method for this RigidBodysetInertia(maspack.spatialmotion.SpatialInertia)
,
setInertiaFromDensity(double)
,
setInertiaFromMass(double)
public void getInertia(SpatialInertia M)
public void setCenterOfMass(Point3d com)
public void getCenterOfMass(Point3d com)
public Point3d getCenterOfMass()
public void setInertiaFromDensity(double density)
null
then
the inertia remains unchanged. Subsequent (non-null
) changes
to the mesh will cause the inertia to be recomputed.
The inertia method is set to
Density
.
density
- desired uniform densitypublic void setInertiaFromMass(double mass)
null
the mass
of the inertia is updated but the otherwise the inertia and density
are left unchanged. Subsequent (non-null
) changes
to the mesh will cause the inertia to be recomputed.
The inertia method is set to Mass
.
mass
- desired body masspublic double computeVolume()
public void setDensity(double density)
Density
or
Mass
, the other components of
the spatial inertia will also be updated.
density
- new density valuepublic Range getDensityRange()
public double getDensity()
setInertiaFromDensity
, or is the
mass/volume ratio for the most recently defined mesh.
public void setMass(double mass)
Density
or
Mass
, the
other components of the spatial inertia will also be updated.
mass
- new mass valuepublic double getMass()
getMass
in interface Collidable
public Range getMassRange()
public void setRotationalInertia(SymmetricMatrix3d J)
getDensity
) to be undefined).
public void getRotationalInertia(SymmetricMatrix3d J)
public SymmetricMatrix3d getRotationalInertia()
public void setInertia(SpatialInertia M)
getDensity
) to be undefined).
public void setInertia(double m, SymmetricMatrix3d J)
getDensity
) to be
undefined).
public void setInertia(double m, SymmetricMatrix3d J, Point3d com)
getDensity
) to be undefined).
public void setInertia(double m, double Jxx, double Jyy, double Jzz)
getDensity
) to be
undefined).
public PolygonalMesh getMesh()
public PolygonalMesh getSurfaceMesh()
public java.lang.String getMeshFileName()
public void setMeshFileName(java.lang.String filename)
public AffineTransform3dBase getMeshFileTransform()
setMeshFileTransform(maspack.matrix.AffineTransform3dBase)
public void setMeshFileTransform(AffineTransform3dBase X)
X
- new mesh file transform, or null
public void setMesh(PolygonalMesh mesh, java.lang.String fileName)
public void setSurfaceMesh(PolygonalMesh mesh, java.lang.String fileName)
public void scaleMesh(double s)
public void setMesh(PolygonalMesh mesh, java.lang.String fileName, AffineTransform3dBase X)
getDensity
returns a non-negative value), then the
spatial inertia is automatically calculated from the mesh and the uniform
density.
public void setSurfaceMesh(PolygonalMesh mesh, java.lang.String fileName, AffineTransform3dBase X)
getDensity
returns a non-negative value), then the
spatial inertia is automatically calculated from the mesh and the uniform
density.
public void setPose(RigidTransform3d XBodyToWorld)
setPose
in class Frame
public void setPose(double x, double y, double z, double roll, double pitch, double yaw)
public void setPosition(Point3d pos)
setPosition
in class Frame
public void setRotation(Quaternion q)
setRotation
in class Frame
public void extrapolatePose(Twist vel, double h)
public void setVelocity(Twist v)
setVelocity
in class Frame
public void setBodyVelocity(Twist v)
setBodyVelocity
in class Frame
public void addVelocity(Twist v)
public void addScaledVelocity(double s, Twist v)
public void setState(Frame frame)
setState
in class Frame
public int setState(VectorNd x, int idx)
setState
in class Frame
public int setPosState(double[] buf, int idx)
setPosState
in interface DynamicMechComponent
setPosState
in class Frame
public int setVelState(double[] buf, int idx)
setVelState
in interface DynamicMechComponent
setVelState
in class Frame
public void updatePose()
updatePose
in class Frame
public void applyGravity(Vector3d gacc)
Frame
applyGravity
in interface DynamicMechComponent
applyGravity
in class Frame
public int applyPosImpulse(double[] delx, int idx)
public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
ModelComponentBase
write
.
scan
in interface ModelComponent
scan
in interface Scannable
scan
in class ModelComponentBase
rtok
- Tokenizer from which to scan the elementref
- optional reference object which can be used for resolving references to
other objects
java.io.IOException
- if an I/O or formatting error occuredpublic void write(java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref) throws java.io.IOException
ModelComponentBase
scan
and complete
enough to allow full reconstruction of the element.
write
in interface Scannable
write
in class ModelComponentBase
pw
- stream for writing the elementfmt
- numeric formating informationref
- optional reference object which can be used for producing references to
other objects
java.io.IOException
- if an I/O error occuredpublic RenderProps createRenderProps()
HasRenderProps
createRenderProps
in interface HasRenderProps
createRenderProps
in class Frame
public void updateBounds(Point3d pmin, Point3d pmax)
GLRenderable
updateBounds
in interface GLRenderable
updateBounds
in class Frame
pmin
- minimum pointpmax
- maximum pointpublic void render(GLRenderer renderer, int flags)
GLRenderable
render
in interface GLRenderable
render
in class Frame
renderer
- renderer object which is used to perform the rendering. Provides pointers
to GL and GLU, along with helper functions.flags
- supplies flags that may be used to control different
aspects of the rendering. Flags are defined in GLRenderer
and currently include
GLRenderer.SELECTED
,
GLRenderer.VERTEX_COLORING
,
GLRenderer.HSV_COLOR_INTERPOLATION
,
GLRenderer.SORT_FACES
, and
GLRenderer.CLEAR_MESH_DISPLAY_LISTS
.public void prerender(RenderList list)
GLRenderable
prerender
in interface GLRenderable
prerender
in class Frame
public void transformGeometry(AffineTransform3dBase X, TransformableGeometry topObject, int flags)
TransformableGeometry
topComponent
should be the component for which the method
was initially invoked. The variable flags
provides
information about the context in which the transformation is
being applied. At present, the available flags are
TransformableGeometry.SIMULATING
and TransformableGeometry.ARTICULATED
.
transformGeometry
in interface TransformableGeometry
transformGeometry
in class Frame
X
- affine transformationtopObject
- component on which the method was initially invokedflags
- provides information about the context in which the
transformation is being applied.public void transformGeometry(AffineTransform3dBase X)
TransformableGeometry
transformGeometry (X, this, 0);
transformGeometry
in interface TransformableGeometry
transformGeometry
in class Frame
X
- affine transformationpublic void scaleDistance(double s)
ScalableUnits
scaleDistance
in interface ScalableUnits
scaleDistance
in class Frame
s
- scaling factorpublic void scaleMass(double s)
ScalableUnits
scaleMass
in interface ScalableUnits
scaleMass
in class Frame
s
- scaling factorpublic void setDynamic(boolean dynamic)
public boolean isDuplicatable()
true
if and only if CopyableComponent.getCopyReferences(java.util.List, artisynth.core.modelbase.ModelComponent)
returns true.
This method is not currently used. It is intended to provide a faster
way of determining if a component can be duplicated, without having to
use CopyableComponent.getCopyReferences(java.util.List
to build the list of copy references.
isDuplicatable
in interface CopyableComponent
isDuplicatable
in class Frame
true
if this component can be duplicated.public boolean getCopyReferences(java.util.List<ModelComponent> refs, ModelComponent ancestor)
true
if and only if CopyableComponent.isDuplicatable()
returns
true.
getCopyReferences
in interface CopyableComponent
getCopyReferences
in class Frame
refs
- list to which references are appendedancestor
- root node of the hierarchy from which references are to be excluded
public ModelComponent copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
CopyableComponent
COPY_REFERENCES
is set in flags
, then any component referenced
by this component should itself be set to a copy. This
should be done first checking copyMap
for an
existing copy of the referenced component. If there is no existing
copy, then a copy should be created by calling copy
recursively and adding the new copy to copyMap
.
copy
in interface CopyableComponent
copy
in class Frame
public FrameMarker[] getFrameMarkers()
public void updateAttachmentPosStates()
public static RigidBody createSphere(java.lang.String bodyName, double r, double density, int nslices)
bodyName
- name of the RigidBodyr
- radius of the spheredensity
- density of the bodynslices
- number of slices used in creating the mesh
public static RigidBody createEllipsoid(java.lang.String bodyName, double a, double b, double c, double density, int nslices)
bodyName
- name of the RigidBodya
- semi-axis length in the x directionb
- semi-axis length in the y directionc
- semi-axis length in the z directiondensity
- density of the bodynslices
- number of slices used in creating the mesh
public static RigidBody createBox(java.lang.String bodyName, double wx, double wy, double wz, double density)
bodyName
- name of the RigidBodywx
- width of the box in the x directionwy
- width of the box in the y directionwz
- width of the box in the z directiondensity
- density of the body
public static RigidBody createCylinder(java.lang.String bodyName, double r, double h, double density, int nsides)
bodyName
- name of the RigidBodyr
- cylinder radiush
- cylinder heightdensity
- density of the bodynsides
- number of sides used in creating the cylinder mesh
public static RigidBody createFromMesh(java.lang.String bodyName, PolygonalMesh mesh, double density, double scale)
public static RigidBody createFromMesh(java.lang.String bodyName, PolygonalMesh mesh, java.lang.String meshFilePath, double density, double scale)
public static RigidBody createFromMesh(java.lang.String bodyName, java.lang.String meshPath, double density, double scale)
public static RigidBody createFromMesh(java.lang.String bodyName, java.lang.Object obj, java.lang.String relPath, double density, double scale)
public boolean findFreeAttachedBodies(java.util.List<RigidBody> freeBodies, boolean rejectSelected)
public java.util.ArrayList<RigidTransform3d> getRelativePoses(java.util.List<RigidBody> bodies)
public void setRelativePoses(java.util.List<RigidBody> bodies, java.util.ArrayList<RigidTransform3d> poses)
public RigidBodyCollisionData createCollisionData()
createCollisionData
in interface Collidable
public boolean isCollidable()
isCollidable
in interface Collidable
public boolean isPullable()
isPullable
in interface PullController.Pullable
public Point3d getOriginData(MouseRayEvent ray)
PullController.Pullable
getOriginData
in interface PullController.Pullable
public Point3d getOriginPoint(java.lang.Object data)
PullController.Pullable
getOriginPoint
in interface PullController.Pullable
public double getPointRenderRadius()
getPointRenderRadius
in interface PullController.Pullable
public void applyForce(java.lang.Object orig, Vector3d force)
PullController.Pullable
applyForce
in interface PullController.Pullable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |