public class AABB extends BVNode
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
AABB() |
AABB(double minx,
double miny,
double minz,
double maxx,
double maxy,
double maxz) |
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.
|
void |
getHalfWidths(Vector3d hw) |
double |
getRadius()
Returns an approximate "radius" for this bounding volume.
|
boolean |
intersectsLine(double[] dists,
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(AABB aabb,
double margin) |
void |
set(Boundable[] elementList,
int nelems,
double margin) |
void |
setMaximums(double maxx,
double maxy,
double maxz) |
void |
setMinimums(double minx,
double miny,
double minz) |
boolean |
update(double margin)
Update node
|
void |
updateBounds(Vector3d min,
Vector3d max)
Update the minimum and maximum points for this object.
|
void |
updateForAABB(AABB aabb,
double margin)
Grow this AABB if necessary to accommodate anothor aabb.
|
boolean |
updateForPoint(Point3d pnt,
double margin) |
addChild, getDepth, getElements, getFirstChild, getNext, getNumber, getNumElements, getParent, getRenderHints, isLeaf, numChildren, setElements, setNumber, setParent, updateFor
public AABB()
public AABB(double minx, double miny, double minz, double maxx, double maxy, double maxz)
public double getRadius()
BVNode
public void getCenter(Vector3d center)
BVNode
public void getHalfWidths(Vector3d hw)
public void setMinimums(double minx, double miny, double minz)
public void setMaximums(double maxx, double maxy, double maxz)
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[] dists, 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
dists
- 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 intersectsPlane(Vector3d n, double d)
BVNode
n^T x = d
intersectsPlane
in class BVNode
n
- normal direction of the planed
- dot product offsetpublic boolean intersectsLineSegment(Point3d p1, Point3d p2)
BVNode
intersectsLineSegment
in class BVNode
p1
- first segment end pointp2
- second segment end pointpublic void set(Boundable[] elementList, int nelems, double margin)
public void set(AABB aabb, double margin)
public boolean updateForPoint(Point3d pnt, double margin)
public 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 void updateForAABB(AABB aabb, double margin)
aabb
- AABB that should fit inside this boxmargin
- additional tolerance marginpublic 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 min, Vector3d max)
IsRenderable
min
- minimum pointmax
- maximum pointpublic void prerender(RenderList list)
IsRenderable
list.addIfVisible (obj);
for each of the objects in question.list
- list of objects to be renderedpublic 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 scale(double s)
s
. This can be used to enlarge a volume to
accommodate a margin.s
- scaling factor