public abstract class BVTree extends java.lang.Object implements GLRenderable
TRANSLUCENT, TWO_DIMENSIONAL
Constructor and Description |
---|
BVTree() |
Modifier and Type | Method and Description |
---|---|
abstract void |
build(Boundable[] elems,
int num)
Builds a bounding volume tree for a set of elements.
|
void |
build(java.util.Collection<? extends Boundable> elist)
Builds a bounding volume tree for a set of elements.
|
void |
build(MeshBase mesh)
Builds a bounding volume tree for a mesh.
|
RigidTransform3d |
getBvhToWorld()
Returns the transform that converts points from the local coordinates of
this tree to world coordinates.
|
void |
getBvhToWorld(RigidTransform3d X)
Returns the transform that converts points from the local coordinates of
this tree to world coordinates.
|
void |
getCenter(Vector3d center)
Returns a center point for this bounding volume hierarchy.
|
java.util.ArrayList<BVNode> |
getLeafNodes()
Returns all the leaf nodes in this tree.
|
double |
getMargin()
Returns the extra distance margin by which bounding volumes in this
tree should surround their elements.
|
int |
getMaxLeafElements()
Returns the maximum number of elements that may be contained
in a leaf node.
|
double |
getRadius()
Returns an approximate "radius" for this bounding volume hierarchy.
|
int |
getRenderHints()
Returns a bit code giving rendering hints about this renderable.
|
abstract BVNode |
getRoot()
Returns the root bounding volume for this tree
|
void |
intersectLine(java.util.ArrayList<BVNode> nodes,
Point3d origin,
Vector3d dir,
double min,
double max)
Returns a list of all leaf nodes in this tree which intersect a line.
|
void |
intersectLineSegment(java.util.ArrayList<BVNode> nodes,
Point3d p1,
Point3d p2)
Returns a list of all leaf nodes in this tree which intersect a line
segment.
|
void |
intersectPlane(java.util.ArrayList<BVNode> nodes,
Plane plane)
Returns a list of all leaf nodes in this tree which intersect a plane.
|
void |
intersectPoint(java.util.ArrayList<BVNode> nodes,
Point3d pnt)
Returns a list of all leaf nodes in this tree which contain
a specified point.
|
void |
intersectSphere(java.util.ArrayList<BVNode> nodes,
Point3d center,
double r)
Returns a list of all leaf nodes in this tree which intersect a sphere.
|
void |
intersectTree(java.util.ArrayList<BVNode> nodes1,
java.util.ArrayList<BVNode> nodes2,
BVTree bvt)
Returns all intersecting pairs of leaf nodes between this tree and
another tree.
|
void |
intersectTree(java.util.ArrayList<BVNode> nodes1,
java.util.ArrayList<BVNode> nodes2,
BVTree bvt,
RigidTransform3d X21)
Returns all intersecting pairs of leaf nodes between this tree and
another tree.
|
int |
numberNodes()
Numbers all nodes in this tree in depth-first order and returns the total
number of nodes.
|
int |
numNodes()
Returns the number of nodes in this tree.
|
void |
prerender(RenderList list)
Prepare for rendering, and potentially add itself to a list to be drawn
by a GLRenderer.
|
void |
print() |
void |
print(java.io.PrintWriter pw) |
void |
printElement(java.io.PrintWriter pw,
Boundable src) |
void |
printNumLeafFaces(java.lang.String msg) |
void |
render(GLRenderer renderer,
int flags)
Render this object using Open GL via the JOGL.
|
void |
setBvhToWorld(RigidTransform3d X)
Sets the transform that converts points from the local coordinates of
this tree to world coordinates.
|
void |
setMargin(double margin)
Sets the extra distance margin by which bounding volumes in this tree
should surround their elements.
|
void |
setMaxLeafElements(int max)
Sets the maximum number of elements that may be contained in a leaf node.
|
abstract void |
update()
Updates the bounding volumes in this tree to ensure that they
properly contain their enclosed elements.
|
void |
updateBounds(Point3d min,
Point3d max)
Update the minimum and maximum points for this object.
|
public double getRadius()
public void getCenter(Vector3d center)
center
- returns the center of this bounding volume hierarchy.public RigidTransform3d getBvhToWorld()
setBvhToWorld(maspack.matrix.RigidTransform3d)
public void setBvhToWorld(RigidTransform3d X)
MeshBase.getMeshToWorld(maspack.matrix.RigidTransform3d)
.X
- new transform valuegetBvhToWorld()
public void getBvhToWorld(RigidTransform3d X)
X
- returns the transform for this treesetBvhToWorld(maspack.matrix.RigidTransform3d)
public abstract BVNode getRoot()
public int getMaxLeafElements()
setMaxLeafElements(int)
public void setMaxLeafElements(int max)
build
calls.max
- maximum number of leaf elementsgetMaxLeafElements()
public void setMargin(double margin)
margin
away from the
boundaries of their containing volumes. Setting this value will only be
effective for subsequent build
calls or
update()
calls.
The purpose of a margin is mainly to overcome numercial errors in determining containment.
margin
- getMargin()
,
update()
public double getMargin()
setMargin(double)
public void build(java.util.Collection<? extends Boundable> elist)
elist
- elements around which this tree is to be built.public abstract void build(Boundable[] elems, int num)
elems
- elements around which this tree is to be built.num
- number of elementspublic void build(MeshBase mesh)
getElementsForMesh(maspack.geometry.MeshBase)
.mesh
- mesh for which the tree should be builtpublic void intersectPoint(java.util.ArrayList<BVNode> nodes, Point3d pnt)
nodes
- returns all leaf nodes containing the pointpnt
- point to test for (world coordinates)public void intersectSphere(java.util.ArrayList<BVNode> nodes, Point3d center, double r)
nodes
- returns all leaf nodes intersecting the spherecenter
- center of the sphere (world coordinates)r
- sphere radiuspublic void intersectPlane(java.util.ArrayList<BVNode> nodes, Plane plane)
nodes
- returns all leaf nodes intersecting the planeplane
- plane to intersect with (world coordinates)public void intersectLine(java.util.ArrayList<BVNode> nodes, Point3d origin, Vector3d dir, double min, double max)
x = origin + s dirThe line can be given finite bounds by specifying maximum and minimum bounds for s.
nodes
- returns all leaf nodes intersecting the lineorigin
- originating point for the line (world coordinates)dir
- direction of the line (world coordinates)min
- 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 intersectTree(java.util.ArrayList<BVNode> nodes1, java.util.ArrayList<BVNode> nodes2, BVTree bvt)
getBvhToWorld()
) are taken into account when computing this intersection.nodes1
- intersecting leaf nodes from this treenodes2
- intersecting leaf nodes from the other treebvt
- other tree to intersect withpublic int numberNodes()
public void intersectTree(java.util.ArrayList<BVNode> nodes1, java.util.ArrayList<BVNode> nodes2, BVTree bvt, RigidTransform3d X21)
getBvhToWorld()
.nodes1
- intersecting leaf nodes from this treenodes2
- intersecting leaf nodes from the other treebvt
- other tree to intersect withX21
- transform from the coordinate frame of the other
tree to that of this tree.public void intersectLineSegment(java.util.ArrayList<BVNode> nodes, Point3d p1, Point3d p2)
p1
- first segment end pointp2
- second segment end pointnodes
- returns all leaf nodes intersecting the line segmentpublic abstract void update()
setMargin(double)
public int getRenderHints()
TRANSLUCENT
.getRenderHints
in interface GLRenderable
public void updateBounds(Point3d min, Point3d max)
updateBounds
in interface GLRenderable
min
- minimum pointmax
- maximum pointpublic void prerender(RenderList list)
prerender
in interface GLRenderable
public void render(GLRenderer renderer, int flags)
render
in interface GLRenderable
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 print()
public void print(java.io.PrintWriter pw)
public void printElement(java.io.PrintWriter pw, Boundable src)
public java.util.ArrayList<BVNode> getLeafNodes()
public int numNodes()
public void printNumLeafFaces(java.lang.String msg)