public class OBB extends BVNode
Modifier and Type | Class and Description |
---|---|
static class |
OBB.Method
Method used to generate an OBB from a set of boundables
|
Modifier and Type | Field and Description |
---|---|
static double |
defaultTolerance |
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
OBB() |
OBB(double wx,
double wy,
double wz) |
OBB(double wx,
double wy,
double wz,
RigidTransform3d X) |
OBB(MeshBase mesh) |
OBB(Vector3d widths,
RigidTransform3d X) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsPoint(Point3d pnt)
Returns true if this bounding volume contains a prescribed point.
|
double |
distanceAlongLine(Point3d origin,
Vector3d dir,
double min,
double max)
Code is modified from "An Efficient and Robust Ray-Box Intersection
Algorithm", Amy Williams, Steve Barrus, R.
|
double |
distanceToPoint(Point3d pnt)
Returns the distance of a point to this bounding volume, or 0
if the point is on or inside it.
|
void |
getCenter(Vector3d center)
Returns a center point for this bounding volume.
|
Vector3d |
getHalfWidths()
Gets the half-widths for this OBB.
|
void |
getHalfWidths(Vector3d halfWidths)
Sets the half-widths for this OBB.
|
double |
getRadius()
Returns an approximate "radius" for this bounding volume.
|
void |
getSortedAxes(Vector3d[] axes)
Returns the axes of the box, sorted in order from largest to smallest.
|
RigidTransform3d |
getTransform()
Returns the transform associated with this OBB.
|
void |
getTransform(RigidTransform3d XObbToRef)
Gets the transform associated with this OBB.
|
void |
getWidths(Vector3d widths)
Gets the widths for this OBB.
|
boolean |
intersectsLine(double[] lam,
Point3d origin,
Vector3d dir,
double min,
double max)
Returns true if this bounding volume intersects a line.
|
boolean |
intersectsLineSegment(Point3d p1,
Point3d p2)
Returns true if this bounding volume intersects a line segment.
|
boolean |
intersectsPlane(Vector3d n,
double d)
Returns true if this bounding volume intersects a plane
described by
|
boolean |
intersectsSphere(Point3d pnt,
double r)
Returns true if this bounding volume intersects a sphere.
|
boolean |
isContained(Boundable[] boundables,
double tol)
Returns true if an entire set of elements is contained within this
bounding volume.
|
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).
|
void |
render(Renderer renderer,
int flags)
Render this object using the functionality of the supplied
Renderer . |
void |
scale(double s)
Scales this bounding volume node by the indicated scale factor
s . |
void |
set(Boundable[] elems,
int num,
double margin,
OBB.Method method) |
void |
set(MeshBase mesh,
double margin,
OBB.Method method)
Sets this OBB to contain the points for a mesh.
|
void |
set(Point3d[] pnts,
double margin,
OBB.Method method) |
void |
setHalfWidths(Vector3d hw) |
void |
setTransform(RigidTransform3d XObbToRef)
Sets the transform associated with this OBB.
|
void |
setWidths(double wx,
double wy,
double wz)
Sets the widths for this OBB.
|
void |
setWidths(Vector3d widths)
Sets the widths for this OBB.
|
boolean |
update(double margin)
Update node
|
void |
updateBounds(Vector3d pmin,
Vector3d pmax)
Update the minimum and maximum points for this object.
|
boolean |
updateForPoint(Point3d p,
double margin)
Update the half-widths of this node to accommodate a single point
p within a prescribed margin. |
addChild, getDepth, getElements, getFirstChild, getNext, getNumber, getNumElements, getParent, getRenderHints, isLeaf, numChildren, setElements, setNumber, setParent, updateFor
public OBB()
public OBB(double wx, double wy, double wz, RigidTransform3d X)
public OBB(double wx, double wy, double wz)
public OBB(Vector3d widths, RigidTransform3d X)
public OBB(MeshBase mesh)
public double getRadius()
BVNode
public void getCenter(Vector3d center)
BVNode
public void setWidths(double wx, double wy, double wz)
wx
- new width value for the 'x' principal axiswy
- new width value for the 'y' principal axiswz
- new width value for the 'z' principal axispublic void setHalfWidths(Vector3d hw)
public void setWidths(Vector3d widths)
widths
- specifies new width values for this OBBpublic void getWidths(Vector3d widths)
widths
- returns the width values for this OBBpublic void getHalfWidths(Vector3d halfWidths)
halfWidths
- returns the half-width values for this OBBpublic Vector3d getHalfWidths()
public void setTransform(RigidTransform3d XObbToRef)
XObbToRef
- new transform valuepublic void getTransform(RigidTransform3d XObbToRef)
XObbToRef
- returns the transform valuepublic RigidTransform3d getTransform()
public void set(MeshBase mesh, double margin, OBB.Method method)
mesh
- mesh to fit the OBB tomargin
- extra distance by with the OBB should be grown. If
less than 0, a default margin is computed.method
- method used to compute the OBBpublic void set(Point3d[] pnts, double margin, OBB.Method method)
public void getSortedAxes(Vector3d[] axes)
public void set(Boundable[] elems, int num, double margin, OBB.Method method)
public boolean containsPoint(Point3d pnt)
BVNode
containsPoint
in class BVNode
pnt
- point to be testedpublic boolean intersectsSphere(Point3d pnt, double r)
BVNode
intersectsSphere
in class BVNode
pnt
- center point of the spherer
- radius of the spherepublic boolean intersectsLine(double[] lam, Point3d origin, Vector3d dir, double min, double max)
BVNode
x = origin + s dirThe line can be given finite bounds by specifying maximum and minimum bounds for s.
intersectsLine
in class BVNode
lam
- if non-null, returns the lower and upper values of s
that define the intersection regionorigin
- originating point for the linedir
- direction of the linemin
- minimum s value for the line, or -infinity if there
is no minimum valuemax
- maximum s value for the line, or +infinity if there
is no maximum valuepublic boolean updateForPoint(Point3d p, double margin)
p
within a prescribed margin.p
- point to accommodatemargin
- extra space marginpublic boolean update(double margin)
BVNode
margin
- supplied margin around boundarypublic boolean isContained(Boundable[] boundables, double tol)
BVNode
isContained
in class BVNode
boundables
- set of boundable elements to checktol
- specifies the minimum amount by which each element
must be insidepublic double distanceToPoint(Point3d pnt)
BVNode
distanceToPoint
in class BVNode
pnt
- point to check distance forpublic double distanceAlongLine(Point3d origin, Vector3d dir, double min, double max)
distanceAlongLine
in class BVNode
origin
- originating point for the linedir
- direction of the linemin
- minimum s value for the line, or -infinity if there
is no minimum valuemax
- maximum s value for the line, or +infinity if there
is no maximum valuepublic void updateBounds(Vector3d pmin, Vector3d pmax)
IsRenderable
pmin
- minimum pointpmax
- maximum pointpublic void render(Renderer renderer, int flags)
IsRenderable
Renderer
.renderer
- provides the functionality used to perform the rendering.flags
- flags that may be used to control different
aspects of the rendering. Flags are defined in Renderer
and currently include
Renderer.HIGHLIGHT
and
Renderer.SORT_FACES
.public void prerender(RenderList list)
IsRenderable
list.addIfVisible (obj);
for each of the objects in question.list
- list of objects to be renderedpublic boolean intersectsLineSegment(Point3d p1, Point3d p2)
BVNode
intersectsLineSegment
in class BVNode
p1
- first segment end pointp2
- second segment end pointpublic boolean intersectsPlane(Vector3d n, double d)
BVNode
n^T x = d
intersectsPlane
in class BVNode
n
- normal direction of the planed
- dot product offsetpublic void scale(double s)
s
. This can be used to enlarge a volume to
accommodate a margin.s
- scaling factor