Examples of CollisionResult


Examples of com.googlecode.jumpnevolve.math.CollisionResult

          // getan kennzeichnen
          addDone(other);
          other.addDone(this);

          // Kollisionen mit dem Nachbarn prüfen
          CollisionResult colResult = this.shape.getCollision(other
              .getShape(),
              this.velocity.sub(other.velocity).mul(secounds),
              this.isMoveable(), other.isMoveable());

          // Kollision verarbeiten, wenn beide Objekte Blockables sind
          if (this instanceof Blockable && other instanceof Blockable) {
            other.blockWay((Blockable) this, colResult.invert());
            this.blockWay((Blockable) other, colResult);

            // Nur elastische Crashs durchführen, wenn der Crash
            // bereits vorliegt
            if (colResult.isIntersecting()) {
              if (this instanceof ElasticBlockable) {
                if (other instanceof ElasticBlockable) {
                  // Berechnen der neuen Impulse durch
                  // entsprechende Addition der alten Impulse
                  Vector thisImpulse = this.onElasticCrash(
                      other, colResult.getIsOverlap()
                          .neg()), otherImpulse = other
                      .onElasticCrash(this,
                          colResult.getIsOverlap());

                  // Setzen der neuen Impulse, aber je mit
                  // halber Länge, da beide alten Impulse in
                  // den Rechnungen insgesamt doppelt
                  // vorkommen
                  this.setImpulse(thisImpulse.mul(0.5f));
                  other.setImpulse(otherImpulse.mul(0.5f));
                } else {
                  // Neuen Impuls für dieses Objekt setzen
                  this.setImpulse(this.onElasticCrash(other,
                      colResult.getIsOverlap()));

                }
              } else if (other instanceof ElasticBlockable) {
                // Neuen Impuls für das andere Objekt setzen
                other.setImpulse(other.onElasticCrash(this,
                    colResult.getIsOverlap()));
              }
            }
          }

          // Wenn sich die Objekte bereits überschneiden onCrash() für
          // beide Objekte aufrufen
          if (colResult.isIntersecting()) {
            onCrash(other, colResult);
            other.onCrash(this, colResult.invert());
          }
        }
      }

      // Zeit seit dem letzten Frame hinterlegen
View Full Code Here

Examples of com.jme3.collision.CollisionResult

            if (Float.isInfinite(d) || Float.isNaN(d)) {
                return 0;
            }

            Vector3f point = new Vector3f(direction).multLocal(d).addLocal(origin);
            results.addCollision(new CollisionResult(point, d));
            return 1;
        } else {
            throw new UnsupportedCollisionException();
        }
    }
View Full Code Here

Examples of com.jme3.collision.CollisionResult

            root = FastMath.sqrt(discr);

            float distance = root - a1;
            Vector3f point = new Vector3f(ray.direction).multLocal(distance).addLocal(ray.origin);

            CollisionResult result = new CollisionResult(point, distance);
            results.addCollision(result);
            vars.release();
            return 1;
        }

        a1 = ray.direction.dot(diff);
        vars.release();
        if (a1 >= 0.0) {
            return 0;
        }

        discr = a1 * a1 - a;
        if (discr < 0.0) {
            return 0;
        } else if (discr >= FastMath.ZERO_TOLERANCE) {
            root = FastMath.sqrt(discr);
            float dist = -a1 - root;
            Vector3f point = new Vector3f(ray.direction).multLocal(dist).addLocal(ray.origin);
            results.addCollision(new CollisionResult(point, dist));

            dist = -a1 + root;
            point = new Vector3f(ray.direction).multLocal(dist).addLocal(ray.origin);
            results.addCollision(new CollisionResult(point, dist));
            return 2;
        } else {
            float dist = -a1;
            Vector3f point = new Vector3f(ray.direction).multLocal(dist).addLocal(ray.origin);
            results.addCollision(new CollisionResult(point, dist));
            return 1;
        }
    }
View Full Code Here

Examples of com.jme3.collision.CollisionResult

            float d1 = center.distanceSquared(t.get1());
            float d2 = center.distanceSquared(t.get2());
            float d3 = center.distanceSquared(t.get3());
           
            if (d1 <= r2 || d2 <= r2 || d3 <= r2) {
                CollisionResult r = new CollisionResult();
                r.setDistance(FastMath.sqrt(Math.min(Math.min(d1, d2), d3)) - radius);
                results.addCollision(r);
                return 1;
            }

            return 0;
View Full Code Here

Examples of com.jme3.collision.CollisionResult

                Vector3f[] points = new Vector3f[]{
                    new Vector3f(ray.direction).multLocal(distances[0]).addLocal(ray.origin),
                    new Vector3f(ray.direction).multLocal(distances[1]).addLocal(ray.origin)
                };

                CollisionResult result = new CollisionResult(points[0], distances[0]);
                results.addCollision(result);
                result = new CollisionResult(points[1], distances[1]);
                results.addCollision(result);
                return 2;
            }

            Vector3f point = new Vector3f(ray.direction).multLocal(t[0]).addLocal(ray.origin);
            CollisionResult result = new CollisionResult(point, t[0]);
            results.addCollision(result);
            return 1;
        }
        return 0;
    }
View Full Code Here

Examples of com.jme3.collision.CollisionResult

            Ray ray = (Ray) other;
            return collideWithRay(ray, results);
        } else if (other instanceof Triangle) {
            Triangle t = (Triangle) other;
            if (intersects(t.get1(), t.get2(), t.get3())) {
                CollisionResult r = new CollisionResult();
                results.addCollision(r);
                return 1;
            }
            return 0;
        } else {
View Full Code Here

Examples of com.jme3.collision.CollisionResult

                float t = r.intersects(v1, v2, v3);
                if (t < tHit) {
                    tHit = t;
                    Vector3f contactPoint = new Vector3f(r.direction).multLocal(tHit).addLocal(r.origin);
                    CollisionResult cr = new CollisionResult(contactPoint, tHit);
                    cr.setTriangleIndex(tree.getTriangleIndex(i));
                    results.addCollision(cr);
                    cols++;
                }
            }
        }
View Full Code Here

Examples of com.jme3.collision.CollisionResult

                    Vector3f contactNormal = Triangle.computeTriangleNormal(v1, v2, v3, null);
                    Vector3f contactPoint = new Vector3f(d).multLocal(t).addLocal(o);
                    float worldSpaceDist = o.distance(contactPoint);

                    CollisionResult cr = new CollisionResult(contactPoint, worldSpaceDist);
                    cr.setContactNormal(contactNormal);
                    cr.setTriangleIndex(tree.getTriangleIndex(i));
                    results.addCollision(cr);
                    cols++;
                }
            }
        }
View Full Code Here

Examples of com.jme3.collision.CollisionResult

                if (added > 0) {
                    int index = tree.getTriangleIndex(i);
                    int start = results.size() - added;

                    for (int j = start; j < results.size(); j++) {
                        CollisionResult cr = results.getCollisionDirect(j);
                        cr.setTriangleIndex(index);
                    }

                    cols += added;
                }
            }
View Full Code Here

Examples of com.jme3.collision.CollisionResult

            float d = r.intersects(t.get1(), t.get2(), t.get3());
            if (Float.isInfinite(d))
                continue;

            Vector3f contactPoint = new Vector3f(r.getDirection()).multLocal(d).addLocal(r.getOrigin());
            CollisionResult result = new CollisionResult(geoms[t.getGeometryIndex()],
                                                         contactPoint,
                                                         d,
                                                         t.getTriangleIndex());
            results.addCollision(result);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.