@Override protected void applyTransformation() { if (mDiffScale == null) mDiffScale = Vector3.subtractAndCreate(mToScale, mFromScale); mMultipliedScale.scaleAndSet(mDiffScale, mInterpolatedTime); mAddedScale.addAndSet(mFromScale, mMultipliedScale); mTransformable3D.setScale(mAddedScale); }
@Override protected void applyTransformation() { if (mDiffPosition == null) mDiffPosition = Vector3.subtractAndCreate(mToPosition, mFromPosition); mMultipliedPosition.scaleAndSet(mDiffPosition, mInterpolatedTime); mAddedPosition.addAndSet(mFromPosition, mMultipliedPosition); mTransformable3D.setPosition(mAddedPosition); }
@Override public Matrix4 getViewMatrix() { mPosition.addAndSet(mLinkedObject.getWorldPosition(), mCameraOffset); mLinkedObject.getOrientation(mOrientation); onRecalculateModelMatrix(null); return super.getViewMatrix(); } }
public void calculatePoint(Vector3 result, double t) { mTmpPoint1.setAll(mPoint2); mTmpPoint1.multiply(t); mTmpPoint2.setAll(mPoint1); mTmpPoint2.multiply(1.0f - t); result.addAndSet(mTmpPoint1, mTmpPoint2); }
@Override public Matrix4 getViewMatrix() { mPosition.addAndSet(mLinkedObject.getWorldPosition(), mCameraOffset); setLookAt(mLinkedObject.getWorldPosition()); onRecalculateModelMatrix(null); return super.getViewMatrix(); }
p = mCurrentCommandIsRelative ? c.addAndSet(mPreviousPoint, c) : c; break; case VERTICAL: c = new Vector3(0, -Double.parseDouble(vals[0]), 0); if (mCurrentCommandIsRelative) p = c.addAndSet(mPreviousPoint, c); else c = new Vector3(Double.parseDouble(vals[0]), 0, 0); if (mCurrentCommandIsRelative) p = c.addAndSet(mPreviousPoint, c); else case CURVE_TO: c = new Vector3(Double.parseDouble(vals[4]), -Double.parseDouble(vals[5]), 0); p = mCurrentCommandIsRelative ? c.addAndSet(mPreviousPoint, c) : c; cp1 = new Vector3(Double.parseDouble(vals[0]), -Double.parseDouble(vals[1]), 0); if (mCurrentCommandIsRelative) case SMOOTH_CURVE_TO: c = new Vector3(Double.parseDouble(vals[2]), -Double.parseDouble(vals[3]), 0); p = mCurrentCommandIsRelative ? c.addAndSet(mPreviousPoint, c) : c; cp1 = reflect(mPreviousControlPoint, mPreviousPoint); cp2 = new Vector3(Double.parseDouble(vals[0]), -Double.parseDouble(vals[1]), 0); case LINE_TO: c = new Vector3(Double.parseDouble(vals[0]), -Double.parseDouble(vals[1]), 0); p = mCurrentCommandIsRelative ? c.addAndSet(mPreviousPoint, c) : c; bezierPath.addCurve(new LinearBezierCurve3D(mPreviousPoint.clone(), p));
public void calculatePoint(Vector3 result, double t) { mCurrent = t; if(mCurrent <0) mCurrent=0; if(mCurrent >1) mCurrent=1; mTmpPoint1.setAll(mPoint1); mTmpPoint1.multiply((1-mCurrent) * (1-mCurrent)); mTmpPoint2.setAll(mControlPoint); mTmpPoint2.multiply(2 * (1-mCurrent) * t); mTmpPoint3.setAll(mPoint2); mTmpPoint3.multiply(mCurrent * mCurrent); mTmpPoint2.add(mTmpPoint3); result.addAndSet(mTmpPoint1, mTmpPoint2); }
/** * Intersects a ray defined by a start and end point and a {@link Plane}. * @param rayStart Startpoint of the ray * @param rayEnd Endpoint of the ray * @param plane The plane * @param hitPoint The intersection point (optional) * @return True if there is an intersection, false otherwise. */ public static boolean intersectRayPlane(Vector3 rayStart, Vector3 rayEnd, Plane plane, Vector3 hitPoint) { Vector3 rayDir = Vector3.subtractAndCreate(rayEnd, rayStart); double denorm = rayDir.dot(plane.getNormal()); if (denorm != 0) { double t = -(rayStart.dot(plane.getNormal()) + plane.getD()) / denorm; if (t < 0) return false; if (hitPoint != null) hitPoint.addAndSet(rayStart, Vector3.scaleAndCreate(rayDir, t)); return true; } else if (plane.getPointSide(rayStart) == Plane.PlaneSide.ONPLANE) { if (hitPoint != null) hitPoint.setAll(rayStart); return true; } else { return false; } }
case 6: //-X/-Y/-Z mMin.setAll(min); mMax.addAndSet(mMin, side_lengths); break; case 7: //+X/-Y/-Z
@Test public void testAddAndSet() { final Vector3 u = new Vector3(1d, 2d, 3d); final Vector3 v = new Vector3(0.1d, 0.2d, 0.3d); final Vector3 t = new Vector3(); final Vector3 out = t.addAndSet(u, v); assertNotNull(out); assertTrue(out == t); assertEquals(1.1d, t.x, 0); assertEquals(2.2d, t.y, 0); assertEquals(3.3d, t.z, 0); }
@Override protected void applyTransformation() { if (mDiffPosition == null) mDiffPosition = Vector3.subtractAndCreate(mToPosition, mFromPosition); mMultipliedPosition.scaleAndSet(mDiffPosition, mInterpolatedTime); mAddedPosition.addAndSet(mFromPosition, mMultipliedPosition); mTransformable3D.setPosition(mAddedPosition); }
@Override protected void applyTransformation() { if (mDiffScale == null) mDiffScale = Vector3.subtractAndCreate(mToScale, mFromScale); mMultipliedScale.scaleAndSet(mDiffScale, mInterpolatedTime); mAddedScale.addAndSet(mFromScale, mMultipliedScale); mTransformable3D.setScale(mAddedScale); }
@Override public Matrix4 getViewMatrix() { mPosition.addAndSet(mLinkedObject.getWorldPosition(), mCameraOffset); mLinkedObject.getOrientation(mOrientation); onRecalculateModelMatrix(null); return super.getViewMatrix(); } }
public void calculatePoint(Vector3 result, double t) { mTmpPoint1.setAll(mPoint2); mTmpPoint1.multiply(t); mTmpPoint2.setAll(mPoint1); mTmpPoint2.multiply(1.0f - t); result.addAndSet(mTmpPoint1, mTmpPoint2); }
@Override public Matrix4 getViewMatrix() { mPosition.addAndSet(mLinkedObject.getWorldPosition(), mCameraOffset); setLookAt(mLinkedObject.getWorldPosition()); onRecalculateModelMatrix(null); return super.getViewMatrix(); }
p = mCurrentCommandIsRelative ? c.addAndSet(mPreviousPoint, c) : c; break; case VERTICAL: c = new Vector3(0, -Double.parseDouble(vals[0]), 0); if (mCurrentCommandIsRelative) p = c.addAndSet(mPreviousPoint, c); else c = new Vector3(Double.parseDouble(vals[0]), 0, 0); if (mCurrentCommandIsRelative) p = c.addAndSet(mPreviousPoint, c); else case CURVE_TO: c = new Vector3(Double.parseDouble(vals[4]), -Double.parseDouble(vals[5]), 0); p = mCurrentCommandIsRelative ? c.addAndSet(mPreviousPoint, c) : c; cp1 = new Vector3(Double.parseDouble(vals[0]), -Double.parseDouble(vals[1]), 0); if (mCurrentCommandIsRelative) case SMOOTH_CURVE_TO: c = new Vector3(Double.parseDouble(vals[2]), -Double.parseDouble(vals[3]), 0); p = mCurrentCommandIsRelative ? c.addAndSet(mPreviousPoint, c) : c; cp1 = reflect(mPreviousControlPoint, mPreviousPoint); cp2 = new Vector3(Double.parseDouble(vals[0]), -Double.parseDouble(vals[1]), 0); case LINE_TO: c = new Vector3(Double.parseDouble(vals[0]), -Double.parseDouble(vals[1]), 0); p = mCurrentCommandIsRelative ? c.addAndSet(mPreviousPoint, c) : c; bezierPath.addCurve(new LinearBezierCurve3D(mPreviousPoint.clone(), p));
private void p(Vector3 result, double t) { mTmpPoint1.setAll(mPoint1); mTmpPoint1.multiply((1.0f - t) * (1.0f - t)); mTmpPoint2.setAll(mControlPoint); mTmpPoint2.multiply(2 * (1.0f - t) * t); mTmpPoint3.setAll(mPoint2); mTmpPoint3.multiply(t * t); mTmpPoint2.add(mTmpPoint3); result.addAndSet(mTmpPoint1, mTmpPoint2); }
/** * Intersects a ray defined by a start and end point and a {@link Plane}. * @param rayStart Startpoint of the ray * @param rayEnd Endpoint of the ray * @param plane The plane * @param hitPoint The intersection point (optional) * @return True if there is an intersection, false otherwise. */ public static boolean intersectRayPlane(Vector3 rayStart, Vector3 rayEnd, Plane plane, Vector3 hitPoint) { Vector3 rayDir = Vector3.subtractAndCreate(rayEnd, rayStart); double denorm = rayDir.dot(plane.getNormal()); if (denorm != 0) { double t = -(rayStart.dot(plane.getNormal()) + plane.getD()) / denorm; if (t < 0) return false; if (hitPoint != null) hitPoint.addAndSet(rayStart, Vector3.scaleAndCreate(rayDir, t)); return true; } else if (plane.getPointSide(rayStart) == Plane.PlaneSide.ONPLANE) { if (hitPoint != null) hitPoint.setAll(rayStart); return true; } else { return false; } }
case 6: //-X/-Y/-Z mMin.setAll(min); mMax.addAndSet(mMin, side_lengths); break; case 7: //+X/-Y/-Z