Esempio n. 1
0
  /**
   * Signals the game object to update its model transformation matrix. The transformations are only
   * actually updated if the object was modified.
   */
  private void updateTransformations() {
    if (mDirty) {
      mModelMatrix.setIdentity();

      mModelMatrix.translate(TMP_VEC3.set(mPosition).add(mPivot));
      mModelMatrix.translate(TMP_VEC3.set(mPivot).negate());

      switch (mRotationMode) {
        case XYZ:
          mModelMatrix.rotateX(mRotation.x);
          mModelMatrix.rotateY(mRotation.y);
          mModelMatrix.rotateZ(mRotation.z);
          break;

        case XZY:
          mModelMatrix.rotateX(mRotation.x);
          mModelMatrix.rotateZ(mRotation.z);
          mModelMatrix.rotateY(mRotation.y);
          break;

        case YXZ:
          mModelMatrix.rotateY(mRotation.y);
          mModelMatrix.rotateX(mRotation.x);
          mModelMatrix.rotateZ(mRotation.z);
          break;

        case YZX:
          mModelMatrix.rotateY(mRotation.y);
          mModelMatrix.rotateX(mRotation.z);
          mModelMatrix.rotateZ(mRotation.x);
          break;

        case ZXY:
          mModelMatrix.rotateZ(mRotation.z);
          mModelMatrix.rotateX(mRotation.x);
          mModelMatrix.rotateY(mRotation.y);
          break;

        case ZYX:
          mModelMatrix.rotateZ(mRotation.z);
          mModelMatrix.rotateY(mRotation.y);
          mModelMatrix.rotateX(mRotation.x);
          break;
      }

      mModelMatrix.scale(mScale);
      mModelMatrix.translate(mPivot);

      mDirty = false;
    }
  }
Esempio n. 2
0
 /**
  * Sets the anchor point of this game object, between 0;0 and 1;1, where 0;0 is top-left and 1;1
  * is bottom-right.
  *
  * @param anchorPoint the anchor point to set
  */
 @Override
 public final void setAnchorPoint(final Vector2 anchorPoint) {
   mAnchorPoint.set(anchorPoint);
   mPivot.set(-mSize.x * mAnchorPoint.x, -mSize.y * mAnchorPoint.y, 0);
   mDirty = true;
 }
Esempio n. 3
0
 public final void setScale(Vector3 scale) {
   mScale.set(scale);
   mDirty = true;
 }
Esempio n. 4
0
 @Override
 public final void setRotation(final Vector3 rotation) {
   mRotation.set(rotation);
   mDirty = true;
 }
Esempio n. 5
0
 @Override
 public final void setPosition(final Vector3 position) {
   mPosition.set(position);
   mDirty = true;
 }