Esempio n. 1
0
 public void update(double t) {
   super.update(t);
   if (m_value != null) {
     double portion = getPortion(t);
     double x = m_xHermite.evaluate(portion);
     double y = m_yHermite.evaluate(portion);
     double z = m_zHermite.evaluate(portion);
     m_value.setPositionRightNow(x, y, z, m_subject);
     edu.cmu.cs.stage3.math.Quaternion q =
         edu.cmu.cs.stage3.math.Quaternion.interpolate(
             m_quaternion0, m_quaternion1, getPortion(t));
     m_value.setOrientationRightNow(q, m_subject);
   }
 }
Esempio n. 2
0
    protected double getValueAtTime(double t) {
      double ft = m_xHermite.evaluateDerivative(t);
      double ht = m_zHermite.evaluateDerivative(t);

      return java.lang.Math.sqrt(ft * ft + ht * ht);
    }
Esempio n. 3
0
    @Override
    public void update(double t) {
      if (getTimeRemaining(t) > 0) {

        edu.cmu.cs.stage3.math.Matrix44 asSeenByTrans =
            m_asSeenBy.getTransformation(subject.getWorld());
        ((edu.cmu.cs.stage3.alice.core.Transformable) m_asSeenBy)
            .standUpRightNow(subject.getWorld());

        double portion = getTimeElapsed(t) / (getTimeElapsed(t) + getTimeRemaining(t));

        if (portion <= 1.0) {
          double x;
          double y;
          double z;
          double dx;
          double dy;
          double dz;

          // get the appropriate position
          x = m_xHermite.evaluate(portion);
          y = m_yHermite.evaluate(portion);
          z = m_zHermite.evaluate(portion);

          subject.setPositionRightNow(x, y, z, m_asSeenBy);

          // face the direction you are moving
          dx = m_xHermite.evaluateDerivative(portion);
          // dy = m_yHermite.evaluateDerivative(portion);
          dy = 0.0;
          dz = m_zHermite.evaluateDerivative(portion);

          if (!(dx == 0 && dy == 0 && dz == 0)) {
            Matrix33 orient = new Matrix33();
            orient.setForwardUpGuide(
                new javax.vecmath.Vector3d(dx, dy, dz), new javax.vecmath.Vector3d(0, 1, 0));
            // System.out.println(m_asSeenBy);
            subject.setOrientationRightNow(orient, m_asSeenBy);
            // subject.s
          } else {
            // System.out.println("deriv 0");
          }

          if (timePerStep == -1) {
            if (!Double.isNaN(duration.doubleValue())) {
              timePerStep = duration.doubleValue() / numberOfSteps;
            } else {
              timePerStep = 1.0 / stepSpeed.doubleValue();
            }
          }

          // int stepNumber = (int)java.lang.Math.ceil(
          // getTimeElapsed(t) * stepSpeed.doubleValue()) - 1;
          int stepNumber = (int) java.lang.Math.ceil(getTimeElapsed(t) * (1.0 / timePerStep)) - 1;
          if (stepNumber == -1) {
            stepNumber = 0;
          }
          if (stepNumber == numberOfSteps) {
            stepNumber -= 1;
          }
          double portionOfStep = (getTimeElapsed(t) - stepNumber * timePerStep) / timePerStep;

          if (portionOfStep > 1.0) {
            portionOfStep = 1.0;
          }

          boolean lastStep = false;
          if (stepNumber == numberOfSteps - 1) {
            lastStep = true;
          }

          if (stepNumber % 2 == 0) {
            stepRight(portionOfStep, lastStep);
          } else {
            stepLeft(portionOfStep, lastStep);
          }

          super.update(t);
        }
        ((edu.cmu.cs.stage3.alice.core.Transformable) m_asSeenBy)
            .setTransformationRightNow(asSeenByTrans, subject.getWorld());
      }
    }