Search code examples
java-3d

Java 3D: Get intersection of two Shape3D's?


Is it possible to get the intersection co-ords of two shapes3d's?

(One is a Line and the other is a QuadArray)

Just wondering if there is a simple way before I try a hack and slash method?

-I'm pretty new to Java 3D so I may have missed a function which does exactly what I need.


Solution

  • The Easy way is to use Bounds and intersect method :

    Bounds quadArrayBounds = quadArrayShape.getBounds();
    if (quadArrayBounds.intersect(new Point3d(startLine.x, startLine.y, startLine.z), 
    new Vector3d(endLine.x, endLine.y, endLine.z))){
                   // Action to do if Intesect is true
                }