/** * Sets the world space coordinates of the lens flare. * Make sure this is the same position as the light position for which to apply the lens flare effect. * @param position */ public void setPosition(Vector3 position) { mPosition.setAll(position); }
/** * Set the scale of Terrain Note: sy is multiplied by the height map (0:1) * * @param sx * @param sy * @param sz */ public void setScale(double sx, double sy, double sz) { scale.setAll(sx, sy, sz); }
@Override public Vector3 getPosition() { mTransformedPosition.setAll((mTransformedMax.x + mTransformedMin.x) / 2.0, (mTransformedMax.y + mTransformedMin.y) / 2.0, (mTransformedMax.z + mTransformedMin.z) / 2.0); return mTransformedPosition; }
/** * Rotates the given {@link Vector3} by the rotation specified by this {@link Matrix4}. * * @param vec {@link Vector3} The vector to rotate. */ public void rotateVector(@NonNull Vector3 vec) { double x = vec.x * m[M00] + vec.y * m[M01] + vec.z * m[M02]; double y = vec.x * m[M10] + vec.y * m[M11] + vec.z * m[M12]; double z = vec.x * m[M20] + vec.y * m[M21] + vec.z * m[M22]; vec.setAll(x, y, z); }
/** * Rotates this {@link Vector3} as specified by the provided {@link Quaternion}. * * @param quaternion {@link Quaternion} describing the rotation. * * @return A reference to this {@link Vector3} to facilitate chaining. */ @NonNull public Vector3 rotateBy(@NonNull Quaternion quaternion) { return setAll(quaternion.multiply(this)); }
/** * Sets all components of this {@link Vector3} to the values provided representing * the input {@link Axis}. * * @param axis {@link Axis} The cardinal axis to set the values to. * * @return A reference to this {@link Vector3} to facilitate chaining. */ @NonNull public Vector3 setAll(@NonNull Axis axis) { return setAll(getAxisVector(axis)); }
public void setLookAt(ATransformable3D target, Vector3.Axis up) { mTarget = target; mUp = new Vector3().setAll(up); }
public void calculateBounds(Geometry3D geometry) { mMin.setAll(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); mMax.setAll(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE); FloatBuffer vertices = geometry.getVertices(); if (vertices != null) { calculateMinMaxVertices(vertices, mMin, mMax); calculatePoints(); } }
public void transform(Matrix4 matrix) { mPosition.setAll(0, 0, 0); mPosition.multiply(matrix); matrix.getScaling(mTmpPos); mScale = mTmpPos.x > mTmpPos.y ? mTmpPos.x : mTmpPos.y; mScale = mScale > mTmpPos.z ? mScale : mTmpPos.z; }
@Override public ATransformable3D resetToLookAt(Vector3 upAxis) { super.resetToLookAt(upAxis); // We want to rotate the forward axis since that's what Quaternion.lookAt() affects mDirectionVec.setAll(mForwardAxis); // Rotate the vector based on our orientation mDirectionVec.rotateBy(mOrientation); return this; } }
@Override protected void eventStart() { if (isFirstStart()) mFromScale.setAll(mTransformable3D.getScale()); super.eventStart(); }
@Override protected void eventStart() { if (isFirstStart()) mFromPosition.setAll(mTransformable3D.getPosition()); super.eventStart(); }
public boolean intersectsWith(IBoundingVolume boundingVolume) { if(!(boundingVolume instanceof BoundingSphere)) return false; BoundingSphere boundingSphere = (BoundingSphere)boundingVolume; mTmpPos.setAll(mPosition); mTmpPos.subtract(boundingSphere.getPosition()); mDist = mTmpPos.x * mTmpPos.x + mTmpPos.y * mTmpPos.y + mTmpPos.z * mTmpPos.z; mMinDist = mRadius * mScale + boundingSphere.getRadius() * boundingSphere.getScale(); return mDist < mMinDist * mMinDist; }
public boolean isLookingAtObject(Object3D target, float maxAngle) { mHeadViewQuaternion.fromMatrix(mHeadViewMatrix); mHeadViewQuaternion.inverse(); mForwardVec.setAll(0, 0, 1); mForwardVec.rotateBy(mHeadViewQuaternion); mHeadTranslation.setAll(mHeadViewMatrix.getTranslation()); mHeadTranslation.subtract(target.getPosition()); mHeadTranslation.normalize(); return mHeadTranslation.angle(mForwardVec) < maxAngle; } }
@Override protected void applyTransformation() { mTmpQuat.slerp(mFrom, mTo, mInterpolatedTime); mTmpVec.setAll(mForwardVec); mTmpQuat.toRotationMatrix(mRotationMatrix); mTmpVec.multiply(mRotationMatrix); mTmpVec.multiply(mDistance); mTransformable3D.setPosition(mTmpVec); }
@Test public void testSetAllFromDoublesXyz() { final Vector3 v = new Vector3(); assertNotNull(v); final Vector3 out = v.setAll(1d, 2d, 3d); assertNotNull(out); assertTrue(out == v); assertEquals(1d, v.x, 0); assertEquals(2d, v.y, 0); assertEquals(3d, v.z, 0); }
@Test public void testSetAllFromVector3() { final Vector3 v = new Vector3(); assertNotNull(v); final Vector3 out = v.setAll(new Vector3(1d, 2d, 3d)); assertNotNull(out); assertTrue(out == v); assertEquals(1d, v.x, 0); assertEquals(2d, v.y, 0); assertEquals(3d, v.z, 0); }