Package com.googlecode.jumpnevolve.math

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

TOP

Related Classes of com.googlecode.jumpnevolve.math.CollisionResult

Copyright © 2018 www.massapicom. 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.