コード例 #1
0
  /**
   * Locally applies this transform to the given point: P' = M*P+T
   *
   * @param point
   * @return the transformed point.
   * @throws NullPointerException if point is null.
   */
  public CCVector3 applyForward(CCVector3 point, CCVector3 theStore) {
    if (point == null) {
      throw new NullPointerException();
    }
    if (theStore == null) theStore = new CCVector3();

    if (_myIsIdentity) {
      // No need to make changes
      // Y = X
      theStore.set(point);
      return theStore;
    }

    if (_myIsRotationMatrix) {
      // Scale is separate from matrix
      // Y = R*S*X + T
      theStore.set(point.x * _myScale.x, point.y * _myScale.y, point.z * _myScale.z);
      _myMatrix.applyPost(theStore, theStore);
      theStore.addLocal(_myTranslation);
      return theStore;
    }

    // scale is part of matrix.
    // Y = M*X + T
    _myMatrix.applyPost(point, theStore);
    theStore.addLocal(_myTranslation);
    return theStore;
  }
コード例 #2
0
 /**
  * Locally adds to the translation of this transform.
  *
  * @param vec
  * @return this transform for chaining.
  */
 public CCTransform translate(final CCVector3 vec) {
   _myTranslation.addLocal(vec);
   _myIsIdentity = _myIsIdentity && _myTranslation.equals(CCVector3.ZERO);
   return this;
 }
コード例 #3
0
 /**
  * Locally adds to the translation of this transform.
  *
  * @param x
  * @param y
  * @param z
  * @return this transform for chaining.
  */
 public CCTransform translate(final double x, final double y, final double z) {
   _myTranslation.addLocal(x, y, z);
   _myIsIdentity = _myIsIdentity && _myTranslation.equals(CCVector3.ZERO);
   return this;
 }