public class AABBox extends Object
A few references for collision detection, intersections:
http://www.realtimerendering.com/intersections.html http://www.codercorner.com/RayAABB.cpp http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtinter0.htm http://realtimecollisiondetection.net/files/levine_swept_sat.txt
Constructor and Description |
---|
AABBox()
Create an Axis Aligned bounding box (AABBox)
where the low and and high MAX float Values.
|
AABBox(AABBox src)
Create an AABBox copying all values from the given one
|
AABBox(float[] low,
float[] high)
Create a AABBox defining the low and high
|
AABBox(float lx,
float ly,
float lz,
float hx,
float hy,
float hz)
Create an AABBox specifying the coordinates
of the low and high
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(float x,
float y)
Check if the x & y coordinates are bounded/contained
by this AABBox
|
boolean |
contains(float x,
float y,
float z)
Check if the xyz coordinates are bounded/contained
by this AABBox.
|
AABBox |
copy(AABBox src)
Copy given AABBox 'src' values to this AABBox.
|
boolean |
equals(Object obj) |
float[] |
getCenter()
Get the Center of this AABBox
|
float |
getDepth() |
float |
getHeight() |
float[] |
getHigh()
Get the max xyz-coordinates
|
float[] |
getLow()
Get the min xyz-coordinates
|
float |
getMaxX() |
float |
getMaxY() |
float |
getMaxZ() |
float |
getMinX() |
float |
getMinY() |
float |
getMinZ() |
float[] |
getRayIntersection(float[] result,
Ray ray,
float epsilon,
boolean assumeIntersection,
float[] tmp1V3,
float[] tmp2V3,
float[] tmp3V3)
Return intersection of a
Ray with this bounding box,
or null if none exist. |
float |
getSize()
Get the size of this AABBox where the size is represented by the
length of the vector between low and high.
|
float |
getWidth() |
int |
hashCode() |
boolean |
intersects2DRegion(float x,
float y,
float w,
float h)
Check if there is a common region between this AABBox and the passed
2D region irrespective of z range
|
boolean |
intersectsRay(Ray ray)
Check if
Ray intersects this bounding box. |
AABBox |
mapToWindow(AABBox result,
float[] mat4PMv,
int[] view,
boolean useCenterZ,
float[] vec3Tmp0,
float[] vec4Tmp1,
float[] vec4Tmp2)
Assume this bounding box as being in object space and
compute the window bounding box.
|
AABBox |
reset()
resets this box to the inverse low/high, allowing the next
resize(float, float, float) command to hit. |
AABBox |
resize(AABBox newBox)
Resize the AABBox to encapsulate another AABox
|
AABBox |
resize(AABBox newBox,
jogamp.graph.geom.plane.AffineTransform t,
float[] tmpV3)
Resize the AABBox to encapsulate another AABox, which will be transformed on the fly first.
|
AABBox |
resize(float[] xyz)
Resize the AABBox to encapsulate the passed
xyz-coordinates.
|
AABBox |
resize(float[] xyz,
int offset)
Resize the AABBox to encapsulate the passed
xyz-coordinates.
|
AABBox |
resize(float x,
float y,
float z)
Resize the AABBox to encapsulate the passed
xyz-coordinates.
|
AABBox |
rotate(Quaternion quat)
Rotate this AABBox by a float[3] vector
|
AABBox |
scale(float size,
float[] tmpV3)
Scale this AABBox by a constant
|
AABBox |
setSize(float[] low,
float[] high)
Set size of the AABBox specifying the coordinates
of the low and high.
|
AABBox |
setSize(float lx,
float ly,
float lz,
float hx,
float hy,
float hz)
Set size of the AABBox specifying the coordinates
of the low and high.
|
String |
toString() |
AABBox |
translate(float[] t)
Translate this AABBox by a float[3] vector
|
public AABBox()
public AABBox(AABBox src)
src
- the box value to be used for the new instancepublic AABBox(float lx, float ly, float lz, float hx, float hy, float hz)
lx
- min x-coordinately
- min y-coordnatelz
- min z-coordinatehx
- max x-coordinatehy
- max y-coordinatehz
- max z-coordinatepublic AABBox(float[] low, float[] high)
low
- min xyz-coordinateshigh
- max xyz-coordinatespublic final AABBox reset()
resize(float, float, float)
command to hit.public final float[] getHigh()
public final float[] getLow()
public final AABBox copy(AABBox src)
src
- source AABBoxpublic final AABBox setSize(float[] low, float[] high)
low
- min xyz-coordinateshigh
- max xyz-coordinatespublic final AABBox setSize(float lx, float ly, float lz, float hx, float hy, float hz)
lx
- min x-coordinately
- min y-coordnatelz
- min z-coordinatehx
- max x-coordinatehy
- max y-coordinatehz
- max z-coordinatepublic final AABBox resize(AABBox newBox)
newBox
- AABBox to be encapsulated inpublic final AABBox resize(AABBox newBox, jogamp.graph.geom.plane.AffineTransform t, float[] tmpV3)
newBox
- AABBox to be encapsulated int
- the AffineTransform
applied on newBox on the flytmpV3
- temp float[3] storagepublic final AABBox resize(float x, float y, float z)
x
- x-axis coordinate valuey
- y-axis coordinate valuez
- z-axis coordinate valuepublic final AABBox resize(float[] xyz, int offset)
xyz
- xyz-axis coordinate valuesoffset
- of the arraypublic final AABBox resize(float[] xyz)
xyz
- xyz-axis coordinate valuespublic final boolean contains(float x, float y)
x
- x-axis coordinate valuey
- y-axis coordinate valuepublic final boolean contains(float x, float y, float z)
x
- x-axis coordinate valuey
- y-axis coordinate valuez
- z-axis coordinate valuepublic final boolean intersects2DRegion(float x, float y, float w, float h)
x
- lower left x-coordy
- lower left y-coordw
- widthh
- hightpublic final boolean intersectsRay(Ray ray)
Ray
intersects this bounding box.
Versions uses the SAT[1], testing 6 axes. Original code for OBBs from MAGIC. Rewritten for AABBs and reorganized for early exits[2].
[1] SAT = Separating Axis Theorem [2] http://www.codercorner.com/RayAABB.cpp
ray
- public final float[] getRayIntersection(float[] result, Ray ray, float epsilon, boolean assumeIntersection, float[] tmp1V3, float[] tmp2V3, float[] tmp3V3)
Ray
with this bounding box,
or null if none exist.
Method is based on the requirements:
Report bugs: p.terdiman@codercorner.com (original author)
[1] http://www.codercorner.com/RayAABB.cpp [2] http://tog.acm.org/resources/GraphicsGems/gems/RayBox.c
result
- vec3ray
- epsilon
- assumeIntersection
- if true, method assumes an intersection, i.e. by pre-checking via intersectsRay(Ray)
.
In this case method will not validate a possible non-intersection and just computes
coordinates.tmp1V3
- temp vec3tmp2V3
- temp vec3tmp3V3
- temp vec3public final float getSize()
public final float[] getCenter()
public final AABBox scale(float size, float[] tmpV3)
size
- a constant float valuetmpV3
- caller provided temporary 3-component vectorpublic final AABBox translate(float[] t)
t
- the float[3] translation vectorpublic final AABBox rotate(Quaternion quat)
quat
- the Quaternion
used for rotationpublic final float getMinX()
public final float getMinY()
public final float getMinZ()
public final float getMaxX()
public final float getMaxY()
public final float getMaxZ()
public final float getWidth()
public final float getHeight()
public final float getDepth()
public AABBox mapToWindow(AABBox result, float[] mat4PMv, int[] view, boolean useCenterZ, float[] vec3Tmp0, float[] vec4Tmp1, float[] vec4Tmp2)
If useCenterZ
is true
,
only 4 mapObjToWinCoords
operations are made on points [1..4] using getCenter()
's z-value.
Otherwise 8 mapObjToWinCoords
operation on all 8 points are performed.
[2] ------ [4] | | | | [1] ------ [3]
mat4PMv
- P x Mv matrixview
- useCenterZ
- vec3Tmp0
- 3 component vector for temp storagevec4Tmp1
- 4 component vector for temp storagevec4Tmp2
- 4 component vector for temp storageCopyright 2010 JogAmp Community.