artisynth.core.mechmodels
Class RigidBody

java.lang.Object
  extended by artisynth.core.modelbase.ModelComponentBase
      extended by artisynth.core.modelbase.RenderableComponentBase
          extended by artisynth.core.mechmodels.DynamicMechComponentBase
              extended by artisynth.core.mechmodels.Frame
                  extended by artisynth.core.mechmodels.RigidBody
All Implemented Interfaces:
Collidable, DynamicMechComponent, ForceEffector, MotionTargetComponent, CopyableComponent, HasCoordinateFrame, ModelComponent, RenderableComponent, Tracable, ScalableUnits, TransformableGeometry, PullController.Pullable, java.lang.Cloneable, HasProperties, HierarchyNode, GLRenderable, GLSelectable, HasRenderProps, Renderable, Scannable
Direct Known Subclasses:
DeformableBody, RigidCompositeBody

public class RigidBody
extends Frame
implements CopyableComponent, Collidable, PullController.Pullable


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.Frame
addExternalForce, addForce, addPointForce, addPosImpulse, addPosJacobian, addScaledExternalForce, addSolveBlock, addSolveBlocks, addTargetJacobian, addVelJacobian, applyForces, computeAppliedWrench, computeAppliedWrench, computePointPosition, computePointVelocity, computePointVelocity, createMassBlock, createSolveBlock, drawAxes, getAxisLength, getBodyForce, getBodyVelocity, getBodyVelState, getExternalForce, getForce, getForce, getForce, getFrameDamping, getFrameDampingMode, getJacobianType, getMoment, getOrientation, getPosDerivative, getPose, getPose, getPosition, getPosState, getPosStateSize, getRotaryDamping, getRotaryDampingMode, getRotation, getSelection, getState, getState, getTargetActivity, getTargetOrientation, getTargetPos, getTargetPose, getTargetPosition, getTargetVel, getTargetVelocity, getTracables, getTracingProbe, getTransForce, getVelocity, getVelocity, getVelState, getVelStateSize, getWorldVelState, resetTargets, setAxisLength, setExternalForce, setForce, setForce, setForcesToExternal, setFrameDamping, setFrameDampingMode, setOrientation, setRotaryDamping, setRotaryDampingMode, setState, setTargetActivity, setTargetOrientation, setTargetPos, setTargetPose, setTargetPosition, setTargetVel, setTargetVelocity, setVelocity, velocityLimitExceeded, zeroExternalForces, zeroForces
 
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 artisynth.core.modelbase.ModelComponentBase
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getChildren, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasChildren, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, postscan, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, updateReferences
 
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

myProps

public static PropertyList myProps
Constructor Detail

RigidBody

public RigidBody()

RigidBody

public RigidBody(java.lang.String name)

RigidBody

public RigidBody(RigidTransform3d XBodyToWorld,
                 SpatialInertia M,
                 PolygonalMesh mesh,
                 java.lang.String meshFileName)
Method Detail

getAllPropertyInfo

public PropertyList getAllPropertyInfo()
Description copied from interface: HasProperties
Returns a list giving static information about all properties exported by this object.

Specified by:
getAllPropertyInfo in interface HasProperties
Overrides:
getAllPropertyInfo in class Frame
Returns:
static information for all exported properties

isMassConstant

public boolean isMassConstant()
Specified by:
isMassConstant in interface DynamicMechComponent
Overrides:
isMassConstant in class Frame

getMass

public double getMass(double t)
Description copied from interface: DynamicMechComponent
Returns the scalar mass of this component at time t.

Specified by:
getMass in interface DynamicMechComponent
Overrides:
getMass in class Frame

getMass

public void getMass(Matrix M,
                    double t)
Description copied from interface: DynamicMechComponent
Gets the mass of this component at a particular time.

Specified by:
getMass in interface DynamicMechComponent
Overrides:
getMass in class Frame
Parameters:
M - matrix to return the mass in
t - current time

getMassForces

public int getMassForces(VectorNd f,
                         double t,
                         int idx)
Description copied from interface: DynamicMechComponent
Gets the mass forces for this component at a particular time. The forces should be stored in 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.

Specified by:
getMassForces in interface DynamicMechComponent
Overrides:
getMassForces in class Frame
Parameters:
f - vector to return the forces in
t - current time
idx - starting location within f where forces should be stored
Returns:
updated value for idx

getInverseMass

public void getInverseMass(Matrix Minv,
                           Matrix M)
Description copied from interface: DynamicMechComponent
Inverts a mass for this component.

Specified by:
getInverseMass in interface DynamicMechComponent
Overrides:
getInverseMass in class DynamicMechComponentBase
Parameters:
Minv - matrix to return the inverse mass in
M - matrix containing the mass to be inverted

getInertiaMethod

public RigidBody.InertiaMethod getInertiaMethod()

setInertiaMethod

public void setInertiaMethod(RigidBody.InertiaMethod method)
Sets the InertiaMethod method used to determine the inertia for this RigidBody.

Parameters:
method - inertia method for this RigidBody
See Also:
setInertia(maspack.spatialmotion.SpatialInertia), setInertiaFromDensity(double), setInertiaFromMass(double)

getInertia

public void getInertia(SpatialInertia M)

setCenterOfMass

public void setCenterOfMass(Point3d com)

getCenterOfMass

public void getCenterOfMass(Point3d com)

getCenterOfMass

public Point3d getCenterOfMass()

setInertiaFromDensity

public void setInertiaFromDensity(double density)
Causes the inertia to be automatically computed from the mesh volume and a given density. If the mesh is currently 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.

Parameters:
density - desired uniform density

setInertiaFromMass

public 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). If the mesh is currently 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.

Parameters:
mass - desired body mass

computeVolume

public double computeVolume()

setDensity

public void setDensity(double density)
Sets the density for the mesh, which is defined at the mass divided by the mesh volume. If the mesh is currently non-null, the mass will be updated accordingly. If the current InertiaMethod is either Density or Mass, the other components of the spatial inertia will also be updated.

Parameters:
density - new density value

getDensityRange

public Range getDensityRange()

getDensity

public double getDensity()
Returns the density of this body. This is either the value set explictly by setInertiaFromDensity, or is the mass/volume ratio for the most recently defined mesh.

Returns:
density for this body.

setMass

public void setMass(double mass)
Sets the mass for the mesh. If the mesh is currently non-null, then the density (defined as the mass divided by the mesh volume) will be updated accordingly. If the current InertiaMethod is either Density or Mass, the other components of the spatial inertia will also be updated.

Parameters:
mass - new mass value

getMass

public double getMass()
Returns the mass of this body.

Specified by:
getMass in interface Collidable

getMassRange

public Range getMassRange()

setRotationalInertia

public void setRotationalInertia(SymmetricMatrix3d J)
Explicitly sets the rotational inertia of this body. Also sets the uniform density (as returned by getDensity) to be undefined).


getRotationalInertia

public void getRotationalInertia(SymmetricMatrix3d J)

getRotationalInertia

public SymmetricMatrix3d getRotationalInertia()
Returns the rotational inertia of this body.

Returns:
rotational inertia (should not be modified).

setInertia

public void setInertia(SpatialInertia M)
Explicitly sets the spatial inertia of this body. Also sets the uniform density (as returned by getDensity) to be undefined).


setInertia

public void setInertia(double m,
                       SymmetricMatrix3d J)
Explicitly sets the mass and rotational inertia of this body. Also sets the uniform density (as returned by getDensity) to be undefined).


setInertia

public void setInertia(double m,
                       SymmetricMatrix3d J,
                       Point3d com)
Explicitly sets the mass, rotational inertia, and center of mass of this body. Also sets the uniform density (as returned by getDensity) to be undefined).


setInertia

public void setInertia(double m,
                       double Jxx,
                       double Jyy,
                       double Jzz)
Explicitly sets the mass and rotational inertia of this body. Also sets the uniform density (as returned by getDensity) to be undefined).


getMesh

public PolygonalMesh getMesh()

getSurfaceMesh

public PolygonalMesh getSurfaceMesh()

getMeshFileName

public java.lang.String getMeshFileName()

setMeshFileName

public void setMeshFileName(java.lang.String filename)

getMeshFileTransform

public AffineTransform3dBase getMeshFileTransform()
Returns the file transform associated with this rigid body's mesh.

Returns:
mesh file transform (should not be modified)
See Also:
setMeshFileTransform(maspack.matrix.AffineTransform3dBase)

setMeshFileTransform

public void setMeshFileTransform(AffineTransform3dBase X)
Sets the transform used to modify a mesh originally read from a file. It is only meaningful if there is a also mesh file name.

Parameters:
X - new mesh file transform, or null

setMesh

public void setMesh(PolygonalMesh mesh,
                    java.lang.String fileName)

setSurfaceMesh

public void setSurfaceMesh(PolygonalMesh mesh,
                           java.lang.String fileName)

scaleMesh

public void scaleMesh(double s)

setMesh

public void setMesh(PolygonalMesh mesh,
                    java.lang.String fileName,
                    AffineTransform3dBase X)
Sets a mesh for this body. If the body has a uniform density (i.e., getDensity returns a non-negative value), then the spatial inertia is automatically calculated from the mesh and the uniform density.


setSurfaceMesh

public void setSurfaceMesh(PolygonalMesh mesh,
                           java.lang.String fileName,
                           AffineTransform3dBase X)
Sets a mesh for this body. If the body has a uniform density (i.e., getDensity returns a non-negative value), then the spatial inertia is automatically calculated from the mesh and the uniform density.


setPose

public void setPose(RigidTransform3d XBodyToWorld)
Overrides:
setPose in class Frame

setPose

public void setPose(double x,
                    double y,
                    double z,
                    double roll,
                    double pitch,
                    double yaw)

setPosition

public void setPosition(Point3d pos)
Overrides:
setPosition in class Frame

setRotation

public void setRotation(Quaternion q)
Overrides:
setRotation in class Frame

extrapolatePose

public void extrapolatePose(Twist vel,
                            double h)

setVelocity

public void setVelocity(Twist v)
Overrides:
setVelocity in class Frame

setBodyVelocity

public void setBodyVelocity(Twist v)
Overrides:
setBodyVelocity in class Frame

addVelocity

public void addVelocity(Twist v)

addScaledVelocity

public void addScaledVelocity(double s,
                              Twist v)

setState

public void setState(Frame frame)
Overrides:
setState in class Frame

setState

public int setState(VectorNd x,
                    int idx)
Overrides:
setState in class Frame

setPosState

public int setPosState(double[] buf,
                       int idx)
Specified by:
setPosState in interface DynamicMechComponent
Overrides:
setPosState in class Frame

setVelState

public int setVelState(double[] buf,
                       int idx)
Specified by:
setVelState in interface DynamicMechComponent
Overrides:
setVelState in class Frame

updatePose

public void updatePose()
Overrides:
updatePose in class Frame

applyGravity

public void applyGravity(Vector3d gacc)
Description copied from class: Frame
Applies a gravity force to this component, given a prescribed gravity acceleration vector.

Specified by:
applyGravity in interface DynamicMechComponent
Overrides:
applyGravity in class Frame

applyPosImpulse

public int applyPosImpulse(double[] delx,
                           int idx)

scan

public void scan(ReaderTokenizer rtok,
                 java.lang.Object ref)
          throws java.io.IOException
Description copied from class: ModelComponentBase
Scans this element from a ReaderTokenizer. The expected text format is assumed to be compatible with that produced by write.

Specified by:
scan in interface ModelComponent
Specified by:
scan in interface Scannable
Overrides:
scan in class ModelComponentBase
Parameters:
rtok - Tokenizer from which to scan the element
ref - optional reference object which can be used for resolving references to other objects
Throws:
java.io.IOException - if an I/O or formatting error occured

write

public void write(java.io.PrintWriter pw,
                  NumberFormat fmt,
                  java.lang.Object ref)
           throws java.io.IOException
Description copied from class: ModelComponentBase
Writes a text description of this element to a PrintWriter. The text description should be compatable with scan and complete enough to allow full reconstruction of the element.

Specified by:
write in interface Scannable
Overrides:
write in class ModelComponentBase
Parameters:
pw - stream for writing the element
fmt - numeric formating information
ref - optional reference object which can be used for producing references to other objects
Throws:
java.io.IOException - if an I/O error occured

createRenderProps

public RenderProps createRenderProps()
Description copied from interface: HasRenderProps
Factory method to create render properties appropriate to this object.

Specified by:
createRenderProps in interface HasRenderProps
Overrides:
createRenderProps in class Frame
Returns:
new render properties for this object

updateBounds

public void updateBounds(Point3d pmin,
                         Point3d pmax)
Description copied from interface: GLRenderable
Update the minimum and maximum points for this object. In an x-y-z coordinate system with x directed to the right and y directed upwards, the minimum and maximum points can be thought of as defining the left-lower-far and right-upper-near corners of a bounding cube. This method should only reduce the elements of the minimum point and increase the elements of the maximum point, since it may be used as part of an iteration to determine the bounding cube for several different objects.

Specified by:
updateBounds in interface GLRenderable
Overrides:
updateBounds in class Frame
Parameters:
pmin - minimum point
pmax - maximum point

render

public void render(GLRenderer renderer,
                   int flags)
Description copied from interface: GLRenderable
Render this object using Open GL via the JOGL.

Specified by:
render in interface GLRenderable
Overrides:
render in class Frame
Parameters:
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.

prerender

public void prerender(RenderList list)
Description copied from interface: GLRenderable
Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer.

Specified by:
prerender in interface GLRenderable
Overrides:
prerender in class Frame

transformGeometry

public void transformGeometry(AffineTransform3dBase X,
                              TransformableGeometry topObject,
                              int flags)
Description copied from interface: TransformableGeometry
Applies an affine transformation to the geometry of this object. If recursively invoked within a component hierarchy, then 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.

Specified by:
transformGeometry in interface TransformableGeometry
Overrides:
transformGeometry in class Frame
Parameters:
X - affine transformation
topObject - component on which the method was initially invoked
flags - provides information about the context in which the transformation is being applied.

transformGeometry

public void transformGeometry(AffineTransform3dBase X)
Description copied from interface: TransformableGeometry
Applies an affine transformation to the geometry of this object. This method should be equivalent to
 transformGeometry (X, this, 0);
 

Specified by:
transformGeometry in interface TransformableGeometry
Overrides:
transformGeometry in class Frame
Parameters:
X - affine transformation

scaleDistance

public void scaleDistance(double s)
Description copied from interface: ScalableUnits
Scales all distance coordinates.

Specified by:
scaleDistance in interface ScalableUnits
Overrides:
scaleDistance in class Frame
Parameters:
s - scaling factor

scaleMass

public void scaleMass(double s)
Description copied from interface: ScalableUnits
Scales all mass units.

Specified by:
scaleMass in interface ScalableUnits
Overrides:
scaleMass in class Frame
Parameters:
s - scaling factor

setDynamic

public void setDynamic(boolean dynamic)

isDuplicatable

public boolean isDuplicatable()
Returns true if this component can be duplicated. Duplication means that we can expect to be able to make a complete copy of the component along with all it's external references. This method should return 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, artisynth.core.modelbase.ModelComponent) to build the list of copy references.

Specified by:
isDuplicatable in interface CopyableComponent
Overrides:
isDuplicatable in class Frame
Returns:
true if this component can be duplicated.

getCopyReferences

public boolean getCopyReferences(java.util.List<ModelComponent> refs,
                                 ModelComponent ancestor)
Collects external references which must also be copied in order to duplicate this component. These references should exclude those which are contained within a specified component hierarchy. This method should return true if and only if CopyableComponent.isDuplicatable() returns true.

Specified by:
getCopyReferences in interface CopyableComponent
Overrides:
getCopyReferences in class Frame
Parameters:
refs - list to which references are appended
ancestor - root node of the hierarchy from which references are to be excluded
Returns:
false if it is discovered that the component cannot be duplicated

copy

public ModelComponent copy(int flags,
                           java.util.Map<ModelComponent,ModelComponent> copyMap)
Description copied from interface: CopyableComponent
Create a copy of this component. If 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.

Specified by:
copy in interface CopyableComponent
Overrides:
copy in class Frame

getFrameMarkers

public FrameMarker[] getFrameMarkers()
Returns an array of all FrameMarkers currently associated with this rigid body.

Returns:
list of all frame markers

updateAttachmentPosStates

public void updateAttachmentPosStates()

createSphere

public static RigidBody createSphere(java.lang.String bodyName,
                                     double r,
                                     double density,
                                     int nslices)
Creates an spherical RigidBody with a prescribed uniform density. The sphere is centered on the origin.

Parameters:
bodyName - name of the RigidBody
r - radius of the sphere
density - density of the body
nslices - number of slices used in creating the mesh
Returns:
spherical rigid body

createEllipsoid

public 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. The ellipsoid is centered on the origin.

Parameters:
bodyName - name of the RigidBody
a - semi-axis length in the x direction
b - semi-axis length in the y direction
c - semi-axis length in the z direction
density - density of the body
nslices - number of slices used in creating the mesh
Returns:
ellipsoidal rigid body

createBox

public 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. The box is centered on the origin.

Parameters:
bodyName - name of the RigidBody
wx - width of the box in the x direction
wy - width of the box in the y direction
wz - width of the box in the z direction
density - density of the body
Returns:
box-shaped rigid body

createCylinder

public static RigidBody createCylinder(java.lang.String bodyName,
                                       double r,
                                       double h,
                                       double density,
                                       int nsides)
Creates a cylindrical RigidBody with a prescribed uniform density. The cylinder is centered on the origin and is parallel to the z axis.

Parameters:
bodyName - name of the RigidBody
r - cylinder radius
h - cylinder height
density - density of the body
nsides - number of sides used in creating the cylinder mesh
Returns:
cylindrical rigid body

createFromMesh

public static RigidBody createFromMesh(java.lang.String bodyName,
                                       PolygonalMesh mesh,
                                       double density,
                                       double scale)

createFromMesh

public static RigidBody createFromMesh(java.lang.String bodyName,
                                       PolygonalMesh mesh,
                                       java.lang.String meshFilePath,
                                       double density,
                                       double scale)

createFromMesh

public static RigidBody createFromMesh(java.lang.String bodyName,
                                       java.lang.String meshPath,
                                       double density,
                                       double scale)

createFromMesh

public static RigidBody createFromMesh(java.lang.String bodyName,
                                       java.lang.Object obj,
                                       java.lang.String relPath,
                                       double density,
                                       double scale)

findFreeAttachedBodies

public boolean findFreeAttachedBodies(java.util.List<RigidBody> freeBodies,
                                      boolean rejectSelected)

getRelativePoses

public java.util.ArrayList<RigidTransform3d> getRelativePoses(java.util.List<RigidBody> bodies)

setRelativePoses

public void setRelativePoses(java.util.List<RigidBody> bodies,
                             java.util.ArrayList<RigidTransform3d> poses)

createCollisionData

public RigidBodyCollisionData createCollisionData()
Specified by:
createCollisionData in interface Collidable

isCollidable

public boolean isCollidable()
Specified by:
isCollidable in interface Collidable

isPullable

public boolean isPullable()
Specified by:
isPullable in interface PullController.Pullable

getOriginData

public Point3d getOriginData(MouseRayEvent ray)
Description copied from interface: PullController.Pullable
Constructs force origin storage data given a mouse ray (e.g. intersect ray with mesh to determine for origin point) If null, assumes that there is no origin, so no force can be applied

Specified by:
getOriginData in interface PullController.Pullable

getOriginPoint

public Point3d getOriginPoint(java.lang.Object data)
Description copied from interface: PullController.Pullable
Determines the world-coordinate point to which force will be applied (used for determining magnitude of force)

Specified by:
getOriginPoint in interface PullController.Pullable

getPointRenderRadius

public double getPointRenderRadius()
Specified by:
getPointRenderRadius in interface PullController.Pullable

applyForce

public void applyForce(java.lang.Object orig,
                       Vector3d force)
Description copied from interface: PullController.Pullable
Given the supplied force origin info and a force vector, apply the force (typically sets an external force)

Specified by:
applyForce in interface PullController.Pullable