/** * Recalculates the model matrix for this {@link ATransformable3D} object if necessary. * * @param parentMatrix {@link Matrix4} The parent matrix, if any, to apply to this object. * @return A flag indicating whether the model matrix was recalculated or not. */ public boolean onRecalculateModelMatrix(Matrix4 parentMatrix) { if (mIsModelMatrixDirty) { calculateModelMatrix(parentMatrix); if (mGraphNode != null) mGraphNode.updateObject(this); mIsModelMatrixDirty = false; return true; } return false; }
/** * Gets the current orientation of this {@link ATransformable3D} object. * * @return A scratch {@link Quaternion} containing the orientation. Copy this * value immediately. */ public Quaternion getOrientation() { return getOrientation(mTmpOrientation); }
@Override protected void applyTransformation() { mSplinePath.calculatePoint(mTempPoint1, mInterpolatedTime); mTransformable3D.setPosition(mTempPoint1); if(mTarget != null) { mTransformable3D.setLookAt(mTarget.getPosition()); if(mUp != null) mTransformable3D.setUpAxis(mUp); } if (mOrientToPath) { // -- calculate tangent mSplinePath.calculatePoint(mTempPoint2, mInterpolatedTime + mLookatDelta * (mIsReversing ? -1 : 1)); mTransformable3D.setLookAt(mTempPoint2); } }
/** * Sets the x component of the position for this {@link ATransformable3D}. * If this is part of a scene graph, the graph will be notified of the change. * * @param x double The new x component for the position. */ public void setX(double x) { mPosition.x = x; if (mLookAtEnabled && mLookAtValid) resetToLookAt(); markModelMatrixDirty(); }
/** * Sets the scale of this {@link ATransformable3D} object. If this is part of a scene graph, * the graph will be notified of the change. * * @param scale double The scaling factor on the z axis. * * @return A reference to this {@link ATransformable3D} to facilitate chaining. */ public ATransformable3D setScaleZ(double scale) { mScale.z = scale; markModelMatrixDirty(); return this; }
public CoalesceConfig(ASpiral3D spiral, ATransformable3D object, ATransformable3D coalesceAround, double endProximity) { this.spiral = spiral; this.object = object; this.coalesceAroundObject = coalesceAround; this.coalesceAroundPoint = coalesceAroundObject.getPosition(); this.endProximity = endProximity; }
/** * Enables auto-enforcement of look at target, and orients to look at the current target. */ public void enableLookAt() { mLookAtEnabled = true; resetToLookAt(); }
@Override protected void applyTransformation() { Quaternion orientation = new Quaternion().slerp(mQuatFrom, mQuat, mInterpolatedTime, false); mTransformable3D.setOrientation(orientation); }
@Override protected void applyTransformation() { mSplinePath.calculatePoint(mTempPoint1, mInterpolatedTime); mTransformable3D.setPosition(mTempPoint1); if (mOrientToPath) { // -- calculate tangent mSplinePath.calculatePoint(mTempPoint2, mInterpolatedTime + mLookatDelta * (mIsReversing ? -1 : 1)); mTransformable3D.setLookAt(mTempPoint2); } }
@Override public boolean onRecalculateModelMatrix(Matrix4 parentMatrix) { super.onRecalculateModelMatrix(parentMatrix); mMMatrix.rotate(mLocalOrientation); return true; }
/** * Rotates this object from its initial orientation around the provided axis by the specified angle. * * @param axis {@link Vector3} The axis or rotation. * @param angle {@code double} The angle of rotation. */ public void rotateAround(Vector3 axis, double angle) { rotateAround(axis, angle, true); }
@Override protected void eventStart() { if (isFirstStart()) mFromScale.setAll(mTransformable3D.getScale()); super.eventStart(); }
/** * Sets the y component of the position for this {@link ATransformable3D}. * If this is part of a scene graph, the graph will be notified of the change. * * @param y double The new y component for the position. */ public void setY(double y) { mPosition.y = y; if (mLookAtEnabled && mLookAtValid) resetToLookAt(); markModelMatrixDirty(); }
/** * Sets the scale of this {@link ATransformable3D} object. If this is part of a scene graph, * the graph will be notified of the change. * * @param scale double The scaling factor on the x axis. * * @return A reference to this {@link ATransformable3D} to facilitate chaining. */ public ATransformable3D setScaleX(double scale) { mScale.x = scale; markModelMatrixDirty(); return this; }
@Override protected void applyTransformation() { synchronized (mCoalesceObjects) { synchronized (mThetaRanges) { int i; final int j = mCoalesceObjects.size(); for (i = 0; i < j; ++i) { // Retrieve the configuration CoalesceConfig config = mCoalesceObjects.get(i); double theta = mThetaRanges.get(i) * mInterpolatedTime; // Calculate the next point config.spiral.calculatePoint(config.object.getPosition(), theta); // Add the coalesce point to translate our spiral config.object.getPosition().add(config.coalesceAroundPoint); } } } }
/** * Resets the orientation of this {@link ATransformable3D} object to look at its look at * target and use the current up axis. If this is part of a scene graph, the graph * will be notified of the change. * * @return A reference to this {@link ATransformable3D} to facilitate chaining. */ public ATransformable3D resetToLookAt() { resetToLookAt(mUpAxis); return this; }
@Override protected void applyTransformation() { // Rotation around an axis by amount of degrees. mRotationAngle = mRotateFrom + (mInterpolatedTime * mDegreesToRotate); mQuat.fromAngleAxis(mRotationAxis, mRotationAngle); mQuat.multiply(mQuatFrom); mTransformable3D.setOrientation(mQuat); }
@Override public boolean onRecalculateModelMatrix(Matrix4 parentMatrix) { super.onRecalculateModelMatrix(parentMatrix); mMMatrix.rotate(mLocalOrientation); return true; }
/** * Rotates this object from its initial orientation around the provided axis by the specified angle. * * @param axis {@link Vector3} The axis or rotation. * @param angle {@code double} The angle of rotation. */ public void rotateAround(Vector3 axis, double angle) { rotateAround(axis, angle, true); }
@Override protected void eventStart() { if (isFirstStart()) mFromScale.setAll(mTransformable3D.getScale()); super.eventStart(); }