JOGL: src/jogl/classes/com/jogamp/math/geom/Frustum.java Source File

JOGL v2.6.0-rc-20250822 JOGL, High-Performance Graphics Binding for Java™ (public API).

Frustum.java
Go to the documentation of this file.
1/**
2 * Copyright 2010-2024 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.math.geom;
29
30import com.jogamp.math.FovHVHalves;
31import com.jogamp.math.Matrix4f;
32import com.jogamp.math.Vec3f;
33import com.jogamp.math.Vec4f;
34
35/**
36 * Providing frustum {@link #getPlanes() planes} derived by different inputs
37 * ({@link #updateFrustumPlanes(float[], int) P*MV}, ..) used to classify objects
38 * <ul>
39 * <li> {@link #classifyPoint(Vec3f) point} </li>
40 * <li> {@link #classifySphere(Vec3f, float) sphere} </li>
41 * </ul>
42 * and to test whether they are outside
43 * <ul>
44 * <li> {@link #isOutside(Vec3f) point} </li>
45 * <li> {@link #isSphereOutside(Vec3f, float) sphere} </li>
46 * <li> {@link #isOutside(AABBox) bounding-box} </li>
47 * <li> {@link #isOutside(Cube) cube} </li>
48 * </ul>
49 *
50 * <p>
51 * Extracting the world-frustum planes from the P*Mv:
52 * <pre>
53 * Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix
54 * Gil Gribb <ggribb@ravensoft.com>
55 * Klaus Hartmann <k_hartmann@osnabrueck.netsurf.de>
56 * http://graphics.cs.ucf.edu/cap4720/fall2008/plane_extraction.pdf
57 * </pre>
58 * Classifying Point, Sphere and AABBox:
59 * <pre>
60 * Efficient View Frustum Culling
61 * Daniel Sýkora <sykorad@fel.cvut.cz>
62 * Josef Jelínek <jelinej1@fel.cvut.cz>
63 * http://www.cg.tuwien.ac.at/hostings/cescg/CESCG-2002/DSykoraJJelinek/index.html
64 * </pre>
65 * <pre>
66 * Lighthouse3d.com
67 * http://www.lighthouse3d.com/tutorials/view-frustum-culling/
68 * </pre>
69 *
70 * Fundamentals about Planes, Half-Spaces and Frustum-Culling:<br/>
71 * <pre>
72 * Planes and Half-Spaces, Max Wagner <mwagner@digipen.edu>
73 * http://www.emeyex.com/site/tuts/PlanesHalfSpaces.pdf
74 * </pre>
75 * <pre>
76 * Frustum Culling, Max Wagner <mwagner@digipen.edu>
77 * http://www.emeyex.com/site/tuts/FrustumCulling.pdf
78 * </pre>
79 * </p>
80 */
81 public final class Frustum {
82 /**
83 * {@link Frustum} description by {@link #fovhv} and {@link #zNear}, {@link #zFar}.
84 */
85 public static class FovDesc {
86 /** Field of view in both directions, may not be centered, either {@link FovHVHalves#inTangents} or radians. */
87 public final FovHVHalves fovhv;
88 /** Near Z */
89 public final float zNear;
90 /** Far Z */
91 public final float zFar;
92 /**
93 * @param fovhv field of view in both directions, may not be centered, either {@link FovHVHalves#inTangents} or radians
94 * @param zNear
95 * @param zFar
96 * @throws IllegalArgumentException if {@code zNear <= 0} or {@code zFar <= zNear}.
97 */
98 public FovDesc(final FovHVHalves fovhv, final float zNear, final float zFar) throws IllegalArgumentException {
99 if( zNear <= 0.0f || zFar <= zNear ) {
100 throw new IllegalArgumentException("Requirements zNear > 0 and zFar > zNear, but zNear "+zNear+", zFar "+zFar);
101 }
102 this.fovhv = fovhv;
103 this.zNear = zNear;
104 this.zFar = zFar;
105 }
106 @Override
107 public final String toString() {
108 return "FrustumFovDesc["+fovhv.toStringInDegrees()+", Z["+zNear+" - "+zFar+"]]";
109 }
110 }
111
112 /** Normalized planes[l, r, b, t, n, f] */
113 protected final Plane[] planes = new Plane[6];
114
115 /**
116 * Creates an undefined instance w/o calculating the frustum.
117 * <p>
118 * Use one of the <code>update(..)</code> methods to set the {@link #getPlanes() planes}.
119 * </p>
120 * @see #updateByPlanes(Plane[])
121 * @see #updateFrustumPlanes(float[], int)
122 */
123 public Frustum() {
124 planes[LEFT ] = new Plane();
125 planes[RIGHT ] = new Plane();
126 planes[BOTTOM] = new Plane();
127 planes[TOP ] = new Plane();
128 planes[NEAR ] = new Plane();
129 planes[FAR ] = new Plane();
130 }
131
132 public Frustum(final Frustum o) {
133 planes[LEFT ] = new Plane(o.planes[LEFT]);
134 planes[RIGHT ] = new Plane(o.planes[RIGHT]);
135 planes[BOTTOM] = new Plane(o.planes[BOTTOM]);
136 planes[TOP ] = new Plane(o.planes[TOP]);
137 planes[NEAR ] = new Plane(o.planes[NEAR]);
138 planes[FAR ] = new Plane(o.planes[FAR]);
139 }
140
141 public Frustum set(final Frustum o) {
142 planes[LEFT ].set(o.planes[LEFT]);
143 planes[RIGHT ].set(o.planes[RIGHT]);
144 planes[BOTTOM].set(o.planes[BOTTOM]);
145 planes[TOP ].set(o.planes[TOP]);
146 planes[NEAR ].set(o.planes[NEAR]);
147 planes[FAR ].set(o.planes[FAR]);
148 return this;
149 }
150
151 /**
152 * Plane equation := dot(n, x - p) = 0 -> Ax + By + Cz + d == 0
153 * <p>
154 * In order to work w/ {@link Frustum#isOutside(AABBox) isOutside(..)} methods,
155 * the normals have to point to the inside of the frustum.
156 * </p>
157 */
158 public static class Plane {
159 /** Normal of the plane */
160 public final Vec3f n;
161
162 /** Distance to origin */
163 public float d;
164
165 public Plane() {
166 n = new Vec3f();
167 d = 0f;
168 }
169
170 public Plane(final Plane o) {
171 n = new Vec3f(o.n);
172 d = o.d;
173 }
174
175 public Plane set(final Plane o) {
176 n.set(o.n);
177 d = o.d;
178 return this;
179 }
180
181 /**
182 * Setup of plane using 3 points. None of the three points are mutated.
183 * <p>
184 * Since this method may not properly define whether the normal points inside the frustum,
185 * consider using {@link #set(Vec3f, Vec3f)}.
186 * </p>
187 * @param p0 point on plane, used as the shared start-point for vec(p0->p1) and vec(p0->p2)
188 * @param p1 point on plane
189 * @param p2 point on plane
190 * @return this plane for chaining
191 */
192 public Plane set(final Vec3f p0, final Vec3f p1, final Vec3f p2) {
193 final Vec3f v = p1.minus(p0);
194 final Vec3f u = p2.minus(p0);
195 n.cross(v, u).normalize();
196 d = n.copy().scale(-1).dot(p0);
197 return this;
198 }
199
200 /**
201 * Setup of plane using given normal and one point on plane. The given normal is mutated, the point not mutated.
202 * @param n normal to plane pointing to the inside of this frustum
203 * @param p0 point on plane, consider choosing the closest point to origin
204 * @return this plane for chaining
205 */
206 public Plane set(final Vec3f n, final Vec3f p0) {
207 this.n.set(n);
208 d = n.scale(-1).dot(p0);
209 return this;
210 }
211
212 /** Sets the given {@link Vec4f} {@code out} to {@code ( n, d )}. Returns {@code out} for chaining. */
213 public Vec4f toVec4f(final Vec4f out) {
214 out.set(n, d);
215 return out;
216 }
217
218 /**
219 * Sets the given {@code [float[off]..float[off+4])} {@code out} to {@code ( n, d )}.
220 * @param out the {@code float[off+4]} output array
221 */
222 public void toFloats(final float[/* off+4] */] out, final int off) {
223 out[off+0] = n.x();
224 out[off+1] = n.y();
225 out[off+2] = n.z();
226 out[off+3] = d;
227 }
228
229 /**
230 * Return signed distance of plane to given point.
231 * <ul>
232 * <li>If dist &lt; 0 , then the point p lies in the negative halfspace.</li>
233 * <li>If dist = 0 , then the point p lies in the plane.</li>
234 * <li>If dist &gt; 0 , then the point p lies in the positive halfspace.</li>
235 * </ul>
236 * A plane cuts 3D space into 2 half spaces.
237 * <p>
238 * Positive halfspace is where the plane’s normals vector points into.
239 * </p>
240 * <p>
241 * Negative halfspace is the <i>other side</i> of the plane, i.e. *-1
242 * </p>
243 **/
244 public final float distanceTo(final float x, final float y, final float z) {
245 return n.x() * x + n.y() * y + n.z() * z + d;
246 }
247
248 /** Return distance of plane to given point, see {@link #distanceTo(float, float, float)}. */
249 public final float distanceTo(final Vec3f p) {
250 return n.dot(p) + d;
251 }
252
253 @Override
254 public String toString() {
255 return "Plane[ [ " + n + " ], " + d + "]";
256 }
257 }
258
259 /** Index for left plane: {@value} */
260 public static final int LEFT = 0;
261 /** Index for right plane: {@value} */
262 public static final int RIGHT = 1;
263 /** Index for bottom plane: {@value} */
264 public static final int BOTTOM = 2;
265 /** Index for top plane: {@value} */
266 public static final int TOP = 3;
267 /** Index for near plane: {@value} */
268 public static final int NEAR = 4;
269 /** Index for far plane: {@value} */
270 public static final int FAR = 5;
271
272 /**
273 * {@link Plane}s are ordered in the returned array as follows:
274 * <ul>
275 * <li>{@link #LEFT}</li>
276 * <li>{@link #RIGHT}</li>
277 * <li>{@link #BOTTOM}</li>
278 * <li>{@link #TOP}</li>
279 * <li>{@link #NEAR}</li>
280 * <li>{@link #FAR}</li>
281 * </ul>
282 * <p>
283 * {@link Plane}'s normals are pointing to the inside of the frustum
284 * in order to work w/ {@link #isOutside(AABBox) isOutside(..)} methods.
285 * </p>
286 *
287 * @return array of normalized {@link Plane}s, order see above.
288 */
289 public final Plane[] getPlanes() { return planes; }
290
291 /**
292 * Sets each of the given {@link Vec4f}[6] {@code out} to {@link Plane#toVec4f(Vec4f)}
293 * in the order {@link #LEFT}, {@link #RIGHT}, {@link #BOTTOM}, {@link #TOP}, {@link #NEAR}, {@link #FAR}.
294 * @param out the {@link Vec4f}[6] output array
295 * @return {@code out} for chaining
296 */
297 public Vec4f[] getPlanes(final Vec4f[] out) {
298 planes[LEFT ].toVec4f(out[0]);
299 planes[RIGHT ].toVec4f(out[1]);
300 planes[BOTTOM].toVec4f(out[2]);
301 planes[TOP ].toVec4f(out[3]);
302 planes[NEAR ].toVec4f(out[4]);
303 planes[FAR ].toVec4f(out[5]);
304 return out;
305 }
306
307 /** Sets the given {@code [float[off]..float[off+4*6])} {@code out} to {@code ( n, d )}. */
308 /**
309 * Sets each of the given {@code [float[off]..float[off+4*6])} {@code out} to {@link Plane#toFloats(float[], int)},
310 * i.e. [n.x, n.y, n.z, d, ...].
311 * <p>
312 * Plane order is as follows: {@link #LEFT}, {@link #RIGHT}, {@link #BOTTOM}, {@link #TOP}, {@link #NEAR}, {@link #FAR}.
313 * </p>
314 * @param out the {@code float[off+4*6]} output array
315 * @return {@code out} for chaining
316 */
317 public void getPlanes(final float[/* off+4*6] */] out, final int off) {
318 planes[LEFT ].toFloats(out, off+4*0);
319 planes[RIGHT ].toFloats(out, off+4*1);
320 planes[BOTTOM].toFloats(out, off+4*2);
321 planes[TOP ].toFloats(out, off+4*3);
322 planes[NEAR ].toFloats(out, off+4*4);
323 planes[FAR ].toFloats(out, off+4*5);
324 }
325
326 /**
327 * Copy the given <code>src</code> planes into this this instance's planes.
328 * @param src the 6 source planes
329 */
330 public final void updateByPlanes(final Plane[] src) {
331 for (int i = 0; i < 6; ++i) {
332 final Plane pD = planes[i];
333 final Plane pS = src[i];
334 pD.d = pS.d;
335 System.arraycopy(pS.n, 0, pD.n, 0, 3);
336 }
337 }
338
339 /**
340 * Calculate the frustum planes in world coordinates
341 * using the passed {@link FovDesc}.
342 * <p>
343 * Operation Details:
344 * <ul>
345 * <li>The given {@link FovDesc} will be transformed
346 * into the given perspective matrix (column major order) first,
347 * see {@link Matrix4f#setToPerspective(FovHVHalves, float, float)}.</li>
348 * <li>Then the perspective matrix is used to {@link Matrix4f#getFrustum(Frustum)} this instance.</li>
349 * </ul>
350 * </p>
351 * <p>
352 * Frustum plane's normals will point to the inside of the viewing frustum,
353 * as required by this class.
354 * </p>
355 *
356 * @param m 4x4 matrix in column-major order (also result)
357 * @param fovDesc {@link Frustum} {@link FovDesc}
358 * @return given matrix for chaining
359 * @see Matrix4f#setToPerspective(FovHVHalves, float, float)
360 * @see Matrix4f#getFrustum(Frustum)
361 * @see Matrix4f#getFrustum(Frustum, FovDesc)
362 */
363 public Matrix4f updateByFovDesc(final Matrix4f m, final FovDesc fovDesc) {
364 m.setToPerspective(fovDesc.fovhv, fovDesc.zNear, fovDesc.zFar);
365 setFromMat(m);
366 return m;
367 }
368
369 /**
370 * Calculate the frustum planes in world coordinates
371 * using the passed column major order matrix, usually a projection (P) or premultiplied P*MV matrix.
372 * <p>
373 * Frustum plane's normals will point to the inside of the viewing frustum,
374 * as required by this class.
375 * </p>
376 * @see Matrix4f#getFrustum(Frustum)
377 */
378 public Frustum setFromMat(final Matrix4f pmv) {
379 return pmv.getFrustum(this);
380 }
381
382 /**
383 * Calculate the frustum planes using the given {@link Cube}.
384 * <p>
385 * One useful application is to {@link Cube#transform(Matrix4f) transform}
386 * an {@link AABBox}, see {@link Cube#Cube(AABBox)} from its object-space
387 * into model-view (Mv) and produce the {@link Frustum} planes using this method
388 * for CPU side object culling and GPU shader side fragment clipping.
389 * </p>
390 * <p>
391 * Frustum plane's normals will point to the inside of the viewing frustum,
392 * as required by this class.
393 * </p>
394 * @param c the {@link Cube} source
395 * @return this frustum for chaining
396 * @see Cube#updateFrustumPlanes(Frustum)
397 * @see Cube#Cube(AABBox)
398 * @see Cube#transform(Matrix4f)
399 */
400 public Frustum updateFrustumPlanes(final Cube c) {
401 return c.updateFrustumPlanes(this);
402 }
403
404 private static final boolean intersects(final Plane p, final AABBox box) {
405 final Vec3f lo = box.getLow();
406 final Vec3f hi = box.getHigh();
407
408 return p.distanceTo(lo.x(), lo.y(), lo.z()) > 0.0f ||
409 p.distanceTo(hi.x(), lo.y(), lo.z()) > 0.0f ||
410 p.distanceTo(lo.x(), hi.y(), lo.z()) > 0.0f ||
411 p.distanceTo(hi.x(), hi.y(), lo.z()) > 0.0f ||
412 p.distanceTo(lo.x(), lo.y(), hi.z()) > 0.0f ||
413 p.distanceTo(hi.x(), lo.y(), hi.z()) > 0.0f ||
414 p.distanceTo(lo.x(), hi.y(), hi.z()) > 0.0f ||
415 p.distanceTo(hi.x(), hi.y(), hi.z()) > 0.0f;
416 }
417
418 /**
419 * Returns whether the given {@link AABBox} is completely outside of this frustum.
420 * <p>
421 * Note: If method returns false, the box may only be partially inside, i.e. intersects with this frustum
422 * </p>
423 */
424 public final boolean isOutside(final AABBox box) {
425 return !intersects(planes[0], box) ||
426 !intersects(planes[1], box) ||
427 !intersects(planes[2], box) ||
428 !intersects(planes[3], box) ||
429 !intersects(planes[4], box) ||
430 !intersects(planes[5], box);
431 }
432
433 private static final boolean intersects(final Plane p, final Cube c) {
434 return p.distanceTo(c.lbf) > 0.0f ||
435 p.distanceTo(c.rbf) > 0.0f ||
436 p.distanceTo(c.rtf) > 0.0f ||
437 p.distanceTo(c.ltf) > 0.0f ||
438 p.distanceTo(c.lbn) > 0.0f ||
439 p.distanceTo(c.rbn) > 0.0f ||
440 p.distanceTo(c.rtn) > 0.0f ||
441 p.distanceTo(c.ltn) > 0.0f;
442 }
443
444 /**
445 * Returns whether the given {@link Cube} is completely outside of this frustum.
446 * <p>
447 * Note: If method returns false, the box may only be partially inside, i.e. intersects with this frustum
448 * </p>
449 */
450 public final boolean isOutside(final Cube c) {
451 return !intersects(planes[0], c) ||
452 !intersects(planes[1], c) ||
453 !intersects(planes[2], c) ||
454 !intersects(planes[3], c) ||
455 !intersects(planes[4], c) ||
456 !intersects(planes[5], c);
457 }
458
459
460 public static enum Location { OUTSIDE, INSIDE, INTERSECT };
461
462 /**
463 * Classifies the given {@link Vec3f} point whether it is outside, inside or on a plane of this frustum.
464 *
465 * @param p the point
466 * @return {@link Location} of point related to frustum planes
467 */
468 public final Location classifyPoint(final Vec3f p) {
469 Location res = Location.INSIDE;
470
471 for (int i = 0; i < 6; ++i) {
472 final float d = planes[i].distanceTo(p);
473 if ( d < 0.0f ) {
474 return Location.OUTSIDE;
475 } else if ( d == 0.0f ) {
476 res = Location.INTERSECT;
477 }
478 }
479 return res;
480 }
481
482 /**
483 * Returns whether the given {@link Vec3f} point is completely outside of this frustum.
484 *
485 * @param p the point
486 * @return true if outside of the frustum, otherwise inside or on a plane
487 */
488 public final boolean isOutside(final Vec3f p) {
489 return planes[0].distanceTo(p) < 0.0f ||
490 planes[1].distanceTo(p) < 0.0f ||
491 planes[2].distanceTo(p) < 0.0f ||
492 planes[3].distanceTo(p) < 0.0f ||
493 planes[4].distanceTo(p) < 0.0f ||
494 planes[5].distanceTo(p) < 0.0f;
495 }
496
497 /**
498 * Classifies the given sphere whether it is is outside, intersecting or inside of this frustum.
499 *
500 * @param p center of the sphere
501 * @param radius radius of the sphere
502 * @return {@link Location} of point related to frustum planes
503 */
504 public final Location classifySphere(final Vec3f p, final float radius) {
505 Location res = Location.INSIDE; // fully inside
506
507 for (int i = 0; i < 6; ++i) {
508 final float d = planes[i].distanceTo(p);
509 if ( d < -radius ) {
510 // fully outside
511 return Location.OUTSIDE;
512 } else if (d < radius ) {
513 // intersecting
514 res = Location.INTERSECT;
515 }
516 }
517 return res;
518 }
519
520 /**
521 * Returns whether the given sphere is completely outside of this frustum.
522 *
523 * @param p center of the sphere
524 * @param radius radius of the sphere
525 * @return true if outside of the frustum, otherwise inside or intersecting
526 */
527 public final boolean isSphereOutside(final Vec3f p, final float radius) {
528 return Location.OUTSIDE == classifySphere(p, radius);
529 }
530
531 public StringBuilder toString(StringBuilder sb) {
532 if( null == sb ) {
533 sb = new StringBuilder();
534 }
535 sb.append("Frustum[Planes[").append(System.lineSeparator())
536 .append(" L: ").append(planes[0]).append(", ").append(System.lineSeparator())
537 .append(" R: ").append(planes[1]).append(", ").append(System.lineSeparator())
538 .append(" B: ").append(planes[2]).append(", ").append(System.lineSeparator())
539 .append(" T: ").append(planes[3]).append(", ").append(System.lineSeparator())
540 .append(" N: ").append(planes[4]).append(", ").append(System.lineSeparator())
541 .append(" F: ").append(planes[5]).append("], ").append(System.lineSeparator())
542 .append("]");
543 return sb;
544 }
545
546 @Override
547 public String toString() {
548 return toString(null).toString();
549 }
550}
com.jogamp.math.FovHVHalves
Horizontal and vertical field of view (FOV) halves, allowing a non-centered projection.
Definition: FovHVHalves.java:37
com.jogamp.math.FovHVHalves.toStringInDegrees
final String toStringInDegrees()
Definition: FovHVHalves.java:169
com.jogamp.math.Matrix4f
Basic 4x4 float matrix implementation using fields for intensive use-cases (host operations).
Definition: Matrix4f.java:89
com.jogamp.math.Matrix4f.getFrustum
Frustum getFrustum(final Frustum frustum)
Calculate the frustum planes in world coordinates using this column major order matrix,...
Definition: Matrix4f.java:1340
com.jogamp.math.Matrix4f.setToPerspective
Matrix4f setToPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar)
Set this matrix to perspective frustum projection.
Definition: Matrix4f.java:1303
com.jogamp.math.Vec3f
3D Vector based upon three float components.
Definition: Vec3f.java:37
com.jogamp.math.Vec3f.copy
Vec3f copy()
Definition: Vec3f.java:66
com.jogamp.math.Vec3f.scale
Vec3f scale(final float s)
this = this * s, returns this.
Definition: Vec3f.java:218
com.jogamp.math.Vec3f.normalize
Vec3f normalize()
Normalize this vector in place.
Definition: Vec3f.java:297
com.jogamp.math.Vec3f.dot
float dot(final Vec3f o)
Return the dot product of this vector and the given one.
Definition: Vec3f.java:338
com.jogamp.math.Vec3f.minus
Vec3f minus(final Vec3f arg)
Returns this - arg; creates new vector.
Definition: Vec3f.java:255
com.jogamp.math.Vec3f.cross
Vec3f cross(final Vec3f arg)
Returns this cross arg; creates new vector.
Definition: Vec3f.java:343
com.jogamp.math.Vec3f.set
Vec3f set(final Vec3f o)
this = o, returns this.
Definition: Vec3f.java:79
com.jogamp.math.Vec4f
4D Vector based upon four float components.
Definition: Vec4f.java:37
com.jogamp.math.Vec4f.set
Vec4f set(final Vec4f o)
this = o, returns this.
Definition: Vec4f.java:67
com.jogamp.math.geom.AABBox
Axis Aligned Bounding Box.
Definition: AABBox.java:54
com.jogamp.math.geom.AABBox.getHigh
final Vec3f getHigh()
Returns the maximum right-top-near (xyz) coordinate.
Definition: AABBox.java:131
com.jogamp.math.geom.AABBox.getLow
final Vec3f getLow()
Returns the minimum left-bottom-far (xyz) coordinate.
Definition: AABBox.java:140
com.jogamp.math.geom.Cube
Simple 8-point Vec3f cube compound having z-far <= z-near @endiliteral.
Definition: Cube.java:48
com.jogamp.math.geom.Cube.updateFrustumPlanes
Frustum updateFrustumPlanes(final Frustum frustum)
Calculate the frustum planes using this Cube.
Definition: Cube.java:194
com.jogamp.math.geom.Cube.ltf
final Vec3f ltf
left -top -far (xyz) in AABB case, otherwise arbitrary
Definition: Cube.java:56
com.jogamp.math.geom.Cube.ltn
final Vec3f ltn
left -top -near (xyz) in AABB case, otherwise arbitrary
Definition: Cube.java:65
com.jogamp.math.geom.Cube.rtn
final Vec3f rtn
right-top -near (xyz) in AABB case, otherwise arbitrary
Definition: Cube.java:63
com.jogamp.math.geom.Cube.lbn
final Vec3f lbn
left -bottom-near (xyz) in AABB case, otherwise arbitrary
Definition: Cube.java:59
com.jogamp.math.geom.Cube.rbn
final Vec3f rbn
right-bottom-near (xyz) in AABB case, otherwise arbitrary
Definition: Cube.java:61
com.jogamp.math.geom.Cube.rtf
final Vec3f rtf
right-top -far (xyz) in AABB case, otherwise arbitrary
Definition: Cube.java:54
com.jogamp.math.geom.Cube.rbf
final Vec3f rbf
right-bottom-far (xyz) in AABB case, otherwise arbitrary
Definition: Cube.java:52
com.jogamp.math.geom.Cube.lbf
final Vec3f lbf
left -bottom-far (xyz) in AABB case, otherwise arbitrary
Definition: Cube.java:50
com.jogamp.math.geom.Frustum.FovDesc
Frustum description by fovhv and zNear, zFar.
Definition: Frustum.java:85
com.jogamp.math.geom.Frustum.FovDesc.toString
final String toString()
Definition: Frustum.java:107
com.jogamp.math.geom.Frustum.FovDesc.zFar
final float zFar
Far Z.
Definition: Frustum.java:91
com.jogamp.math.geom.Frustum.FovDesc.fovhv
final FovHVHalves fovhv
Field of view in both directions, may not be centered, either FovHVHalves#inTangents or radians.
Definition: Frustum.java:87
com.jogamp.math.geom.Frustum.FovDesc.FovDesc
FovDesc(final FovHVHalves fovhv, final float zNear, final float zFar)
Definition: Frustum.java:98
com.jogamp.math.geom.Frustum.FovDesc.zNear
final float zNear
Near Z.
Definition: Frustum.java:89
com.jogamp.math.geom.Frustum.Plane
Plane equation := dot(n, x - p) = 0 -> Ax + By + Cz + d == 0.
Definition: Frustum.java:158
com.jogamp.math.geom.Frustum.Plane.distanceTo
final float distanceTo(final float x, final float y, final float z)
Return signed distance of plane to given point.
Definition: Frustum.java:244
com.jogamp.math.geom.Frustum.Plane.n
final Vec3f n
Normal of the plane.
Definition: Frustum.java:160
com.jogamp.math.geom.Frustum.Plane.Plane
Plane(final Plane o)
Definition: Frustum.java:170
com.jogamp.math.geom.Frustum.Plane.toVec4f
Vec4f toVec4f(final Vec4f out)
Sets the given Vec4f out to ( n, d ).
Definition: Frustum.java:213
com.jogamp.math.geom.Frustum.Plane.Plane
Plane()
Definition: Frustum.java:165
com.jogamp.math.geom.Frustum.Plane.toString
String toString()
Definition: Frustum.java:254
com.jogamp.math.geom.Frustum.Plane.toFloats
void toFloats(final float[] out, final int off)
Sets the given [float[off]..float[off+4]) out to ( n, d ).
Definition: Frustum.java:222
com.jogamp.math.geom.Frustum.Plane.set
Plane set(final Plane o)
Definition: Frustum.java:175
com.jogamp.math.geom.Frustum.Plane.d
float d
Distance to origin.
Definition: Frustum.java:163
com.jogamp.math.geom.Frustum.Plane.distanceTo
final float distanceTo(final Vec3f p)
Return distance of plane to given point, see distanceTo(float, float, float).
Definition: Frustum.java:249
com.jogamp.math.geom.Frustum
Providing frustum planes derived by different inputs (P*MV, ..) used to classify objects.
Definition: Frustum.java:81
com.jogamp.math.geom.Frustum.NEAR
static final int NEAR
Index for near plane: {@value}.
Definition: Frustum.java:268
com.jogamp.math.geom.Frustum.classifyPoint
final Location classifyPoint(final Vec3f p)
Classifies the given Vec3f point whether it is outside, inside or on a plane of this frustum.
Definition: Frustum.java:468
com.jogamp.math.geom.Frustum.setFromMat
Frustum setFromMat(final Matrix4f pmv)
Calculate the frustum planes in world coordinates using the passed column major order matrix,...
Definition: Frustum.java:378
com.jogamp.math.geom.Frustum.toString
String toString()
Definition: Frustum.java:547
com.jogamp.math.geom.Frustum.updateByFovDesc
Matrix4f updateByFovDesc(final Matrix4f m, final FovDesc fovDesc)
Calculate the frustum planes in world coordinates using the passed FovDesc.
Definition: Frustum.java:363
com.jogamp.math.geom.Frustum.updateFrustumPlanes
Frustum updateFrustumPlanes(final Cube c)
Calculate the frustum planes using the given Cube.
Definition: Frustum.java:400
com.jogamp.math.geom.Frustum.classifySphere
final Location classifySphere(final Vec3f p, final float radius)
Classifies the given sphere whether it is is outside, intersecting or inside of this frustum.
Definition: Frustum.java:504
com.jogamp.math.geom.Frustum.BOTTOM
static final int BOTTOM
Index for bottom plane: {@value}.
Definition: Frustum.java:264
com.jogamp.math.geom.Frustum.getPlanes
final Plane[] getPlanes()
Planes are ordered in the returned array as follows:
Definition: Frustum.java:289
com.jogamp.math.geom.Frustum.getPlanes
void getPlanes(final float[] out, final int off)
Sets the given [float[off]..float[off+4*6]) out to ( n, d ).
Definition: Frustum.java:317
com.jogamp.math.geom.Frustum.isOutside
final boolean isOutside(final AABBox box)
Returns whether the given AABBox is completely outside of this frustum.
Definition: Frustum.java:424
com.jogamp.math.geom.Frustum.updateByPlanes
final void updateByPlanes(final Plane[] src)
Copy the given src planes into this this instance's planes.
Definition: Frustum.java:330
com.jogamp.math.geom.Frustum.isOutside
final boolean isOutside(final Vec3f p)
Returns whether the given Vec3f point is completely outside of this frustum.
Definition: Frustum.java:488
com.jogamp.math.geom.Frustum.RIGHT
static final int RIGHT
Index for right plane: {@value}.
Definition: Frustum.java:262
com.jogamp.math.geom.Frustum.Frustum
Frustum()
Creates an undefined instance w/o calculating the frustum.
Definition: Frustum.java:123
com.jogamp.math.geom.Frustum.Frustum
Frustum(final Frustum o)
Definition: Frustum.java:132
com.jogamp.math.geom.Frustum.isOutside
final boolean isOutside(final Cube c)
Returns whether the given Cube is completely outside of this frustum.
Definition: Frustum.java:450
com.jogamp.math.geom.Frustum.getPlanes
Vec4f[] getPlanes(final Vec4f[] out)
Sets each of the given Vec4f[6] out to Plane#toVec4f(Vec4f) in the order LEFT, RIGHT,...
Definition: Frustum.java:297
com.jogamp.math.geom.Frustum.toString
StringBuilder toString(StringBuilder sb)
Definition: Frustum.java:531
com.jogamp.math.geom.Frustum.TOP
static final int TOP
Index for top plane: {@value}.
Definition: Frustum.java:266
com.jogamp.math.geom.Frustum.LEFT
static final int LEFT
Index for left plane: {@value}.
Definition: Frustum.java:260
com.jogamp.math.geom.Frustum.planes
final Plane[] planes
Normalized planes[l, r, b, t, n, f].
Definition: Frustum.java:113
com.jogamp.math.geom.Frustum.FAR
static final int FAR
Index for far plane: {@value}.
Definition: Frustum.java:270
com.jogamp.math.geom.Frustum.isSphereOutside
final boolean isSphereOutside(final Vec3f p, final float radius)
Returns whether the given sphere is completely outside of this frustum.
Definition: Frustum.java:527
com.jogamp.math.geom.Frustum.Location
Definition: Frustum.java:460
com.jogamp.math.geom.Frustum.Location.INSIDE
INSIDE
Definition: Frustum.java:460
com.jogamp.math.geom.Frustum.Location.INTERSECT
INTERSECT
Definition: Frustum.java:460
com.jogamp.math.geom.Frustum.Location.OUTSIDE
OUTSIDE
Definition: Frustum.java:460