Package com.ardor3d.math
Class Ray3
java.lang.Object
com.ardor3d.math.Line3Base
com.ardor3d.math.Ray3
- All Implemented Interfaces:
Poolable
,ReadOnlyLine3Base
,ReadOnlyRay3
,Savable
,Externalizable
,Serializable
- See Also:
-
Field Summary
Fields inherited from class com.ardor3d.math.Line3Base
_direction, _origin
-
Constructor Summary
ConstructorDescriptionRay3()
Constructs a new ray with an origin at (0,0,0) and a direction of (0,0,1).Ray3
(ReadOnlyRay3 source) Copy constructor.Ray3
(ReadOnlyVector3 origin, ReadOnlyVector3 direction) Constructs a new ray using the supplied origin point and unit length direction vector -
Method Summary
Modifier and TypeMethodDescriptionclone()
double
distanceSquared
(ReadOnlyVector3 point, Vector3 store) boolean
static final Ray3
double
getDistanceToPrimitive
(Vector3[] worldVertices) protected boolean
intersects
(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, Vector3 locationStore, boolean doPlanar) Ray vs triangle implementation.boolean
intersects
(Vector3[] polygonVertices, Vector3 locationStore) boolean
intersectsPlane
(ReadOnlyPlane plane, Vector3 locationStore) boolean
intersectsQuad
(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, ReadOnlyVector3 pointD, Vector3 locationStore) boolean
intersectsQuadPlanar
(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, ReadOnlyVector3 pointD, Vector3 locationStore) boolean
intersectsTriangle
(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, Vector3 locationStore) boolean
intersectsTrianglePlanar
(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, Vector3 locationStore) static boolean
isValid
(ReadOnlyRay3 ray) Check a ray... if it is null or the values of its origin or direction are NaN or infinite, return false.static final void
releaseTempInstance
(Ray3 ray) Releases a Ray back to be used by a future call to fetchTempInstance.set
(ReadOnlyRay3 source) Copies the values of the given source ray into this ray.toString()
Methods inherited from class com.ardor3d.math.Line3Base
getClassTag, getDirection, getOrigin, hashCode, read, readExternal, setDirection, setOrigin, write, writeExternal
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.ardor3d.math.type.ReadOnlyLine3Base
getDirection, getOrigin
-
Constructor Details
-
Ray3
public Ray3()Constructs a new ray with an origin at (0,0,0) and a direction of (0,0,1). -
Ray3
Copy constructor.- Parameters:
source
- the ray to copy from.
-
Ray3
Constructs a new ray using the supplied origin point and unit length direction vector- Parameters:
origin
- the origindirection
- the direction - unit length
-
-
Method Details
-
set
Copies the values of the given source ray into this ray.- Parameters:
source
- the source ray- Returns:
- this ray for chaining
- Throws:
NullPointerException
- if source is null.
-
getDistanceToPrimitive
- Specified by:
getDistanceToPrimitive
in interfaceReadOnlyRay3
- Parameters:
worldVertices
- an array of vectors describing a polygon- Returns:
- the distance from our origin to the primitive or POSITIVE_INFINITY if we do not intersect.
-
intersects
- Specified by:
intersects
in interfaceReadOnlyRay3
- Parameters:
polygonVertices
- the vertices of the polygonlocationStore
- the store of the location- Returns:
- true if this ray intersects a polygon described by the given vertices.
-
intersectsTriangle
public boolean intersectsTriangle(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, Vector3 locationStore) - Specified by:
intersectsTriangle
in interfaceReadOnlyRay3
- Parameters:
pointA
- the point ApointB
- the point BpointC
- the point ClocationStore
- if not null, and this ray intersects, the point of intersection is calculated and stored in this Vector3- Returns:
- true if this ray intersects a triangle formed by the given three points.
- Throws:
NullPointerException
- if any of the points are null.
-
intersectsTrianglePlanar
public boolean intersectsTrianglePlanar(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, Vector3 locationStore) - Specified by:
intersectsTrianglePlanar
in interfaceReadOnlyRay3
- Parameters:
pointA
- the point ApointB
- the point BpointC
- the point ClocationStore
- if not null, and this ray intersects, the point of intersection is calculated and stored in this Vector3 as (t, u, v) where t is the distance from the _origin to the point of intersection and (u, v) is the intersection point on the triangle plane.- Returns:
- true if this ray intersects a triangle formed by the given three points.
- Throws:
NullPointerException
- if any of the points are null.
-
intersectsQuad
public boolean intersectsQuad(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, ReadOnlyVector3 pointD, Vector3 locationStore) - Specified by:
intersectsQuad
in interfaceReadOnlyRay3
- Parameters:
pointA
- the point ApointB
- the point BpointC
- the point CpointD
- the point DlocationStore
- if not null, and this ray intersects, the point of intersection is calculated and stored in this Vector3- Returns:
- true if this ray intersects a triangle formed by the given three points. The points are assumed to be coplanar.
- Throws:
NullPointerException
- if any of the points are null.
-
intersectsQuadPlanar
public boolean intersectsQuadPlanar(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, ReadOnlyVector3 pointD, Vector3 locationStore) - Specified by:
intersectsQuadPlanar
in interfaceReadOnlyRay3
- Parameters:
pointA
- the point ApointB
- the point BpointC
- the point CpointD
- the point DlocationStore
- if not null, and this ray intersects, the point of intersection is calculated and stored in this Vector3 as (t, u, v) where t is the distance from the _origin to the point of intersection and (u, v) is the intersection point on the triangle plane.- Returns:
- true if this ray intersects a quad formed by the given four points. The points are assumed to be coplanar.
- Throws:
NullPointerException
- if any of the points are null.
-
intersects
protected boolean intersects(ReadOnlyVector3 pointA, ReadOnlyVector3 pointB, ReadOnlyVector3 pointC, Vector3 locationStore, boolean doPlanar) Ray vs triangle implementation.- Parameters:
pointA
- the point ApointB
- the point BpointC
- the point ClocationStore
- the store of the locationdoPlanar
-true
if the intersection is planar (has no effect iflocationStore
isnull
)- Returns:
- true if this ray intersects a triangle formed by the given three points.
- Throws:
NullPointerException
- if any of the points are null.
-
intersectsPlane
- Specified by:
intersectsPlane
in interfaceReadOnlyRay3
- Parameters:
plane
- the planelocationStore
- if not null, and this ray intersects the plane, the world location of the point of intersection is stored in this vector.- Returns:
- true if the ray collides with the given Plane
- Throws:
NullPointerException
- if the plane is null.
-
distanceSquared
- Specified by:
distanceSquared
in interfaceReadOnlyLine3Base
- Parameters:
point
- the pointstore
- if not null, the closest point is stored in this param- Returns:
- the squared distance from this ray to the given point.
- Throws:
NullPointerException
- if the point is null.
-
isValid
Check a ray... if it is null or the values of its origin or direction are NaN or infinite, return false. Else return true.- Parameters:
ray
- the ray to check- Returns:
- true or false as stated above.
-
toString
-
equals
-
clone
- Specified by:
clone
in interfaceReadOnlyRay3
- Overrides:
clone
in classObject
-
fetchTempInstance
- Returns:
- An instance of Ray that is intended for temporary use in calculations and so forth. Multiple calls to the method should return instances of this class that are not currently in use.
-
releaseTempInstance
Releases a Ray back to be used by a future call to fetchTempInstance. TAKE CARE: this Ray object should no longer have other classes referencing it or "Bad Things" will happen.- Parameters:
ray
- the Ray to release.
-