Hallo,
wie der Titel schon sagt, benötige ich eine Funktion, die ohne die 3D Funktionen von Oggre Auskommt.
Etwas in dieser art. Leider bekomme ich das nicht zum Funktionieren. Im Netz habe ich folgendes gefunden.
Code: Alles auswählen
;function intersect(a, b) {
; Return (a.minX <= b.maxX && a.maxX >= b.minX) && (a.minY <= b.maxY && a.maxY >= b.minY) && (a.minZ <= b.maxZ && a.maxZ >= b.minZ);
; public Static boolean checkCollision(ObjectBox a, ObjectBox b){
; {
; //check the X axis
; If(Math.abs(a.getX() - b.getX()) < a.getSizeX() + b.getSizeX())
; {
; //check the Y axis
; If(Math.abs(a.getY() - b.getY()) < a.getSizeY() + b.getSizeY())
; {
; //check the Z axis
; If(Math.abs(a.getZ() - b.getZ()) < a.getSizeZ() + b.getSizeZ())
; {
; Return true;
; }
; }
; }
;
;Return false;
; }
Code: Alles auswählen
;function intersect(sphere, box) {
; // get box closest point To sphere center by clamping
; var x = Math.max(box.minX, Math.min(sphere.x, box.maxX));
; var y = Math.max(box.minY, Math.min(sphere.y, box.maxY));
; var z = Math.max(box.minZ, Math.min(sphere.z, box.maxZ));
;
; // this is the same As isPointInsideSphere
; var distance = Math.sqrt((x - sphere.x) * (x - sphere.x) +
; (y - sphere.y) * (y - sphere.y) +
; (z - sphere.z) * (z - sphere.z));
;
; Return distance < sphere.radius;
Gruss TFT