/** * return the type of spline used for the path interpolation for this path * @return the path interpolation spline type */ public SplineType getPathSplineType() { return spline.getType(); }
/** * Create a curve mesh from a Spline * * @param spline the spline to use * @param nbSubSegments the number of subsegments between the control points */ public Curve(Spline spline, int nbSubSegments) { super(); this.spline = spline; switch (spline.getType()) { case CatmullRom: this.createCatmullRomMesh(nbSubSegments); break; case Bezier: this.createBezierMesh(nbSubSegments); break; case Nurb: this.createNurbMesh(nbSubSegments); break; case Linear: default: this.createLinearMesh(); break; } }
/** * This method interpolates the data for the nurbs curve. * @param u * the u value * @param nurbSpline * the nurbs spline definition * @param store * the resulting point in 3D space */ public static void interpolateNurbs(float u, Spline nurbSpline, Vector3f store) { if (nurbSpline.getType() != SplineType.Nurb) { throw new IllegalArgumentException("Given spline is not of a NURB type!"); } List<Vector3f> controlPoints = nurbSpline.getControlPoints(); float[] weights = nurbSpline.getWeights(); List<Float> knots = nurbSpline.getKnots(); int controlPointAmount = controlPoints.size(); store.set(Vector3f.ZERO); float delimeter = 0; for (int i = 0; i < controlPointAmount; ++i) { float val = weights[i] * CurveAndSurfaceMath.computeBaseFunctionValue(i, nurbSpline.getBasisFunctionDegree(), u, knots); store.addLocal(nurbSpline.getControlPoints().get(i) .mult(val)); delimeter += val; } store.divideLocal(delimeter); }
private void attachDebugNode(Node root) { if (debugNode == null) { debugNode = new Node(); Material m = assetManager.loadMaterial("Common/Materials/RedColor.j3m"); for (Iterator<Vector3f> it = spline.getControlPoints().iterator(); it.hasNext();) { Vector3f cp = it.next(); Geometry geo = new Geometry("box", new Box(0.3f, 0.3f, 0.3f)); geo.setLocalTranslation(cp); geo.setMaterial(m); debugNode.attachChild(geo); } switch (spline.getType()) { case CatmullRom: debugNode.attachChild(CreateCatmullRomPath()); break; case Linear: debugNode.attachChild(CreateLinearPath()); break; default: debugNode.attachChild(CreateLinearPath()); break; } root.attachChild(debugNode); } }
/** * return the type of spline used for the path interpolation for this path * @return the path interpolation spline type */ public SplineType getPathSplineType() { return spline.getType(); }
/** * Create a curve mesh from a Spline * * @param spline the spline to use * @param nbSubSegments the number of subsegments between the control points */ public Curve(Spline spline, int nbSubSegments) { super(); this.spline = spline; switch (spline.getType()) { case CatmullRom: this.createCatmullRomMesh(nbSubSegments); break; case Bezier: this.createBezierMesh(nbSubSegments); break; case Nurb: this.createNurbMesh(nbSubSegments); break; case Linear: default: this.createLinearMesh(); break; } }
/** * Create a curve mesh from a Spline * * @param spline the spline to use * @param nbSubSegments the number of subsegments between the control points */ public Curve(Spline spline, int nbSubSegments) { super(); this.spline = spline; switch (spline.getType()) { case CatmullRom: this.createCatmullRomMesh(nbSubSegments); break; case Bezier: this.createBezierMesh(nbSubSegments); break; case Nurb: this.createNurbMesh(nbSubSegments); break; case Linear: default: this.createLinearMesh(); break; } }
/** * This method interpolates the data for the nurbs curve. * @param u * the u value * @param nurbSpline * the nurbs spline definition * @param store * the resulting point in 3D space */ public static void interpolateNurbs(float u, Spline nurbSpline, Vector3f store) { if (nurbSpline.getType() != SplineType.Nurb) { throw new IllegalArgumentException("Given spline is not of a NURB type!"); } List<Vector3f> controlPoints = nurbSpline.getControlPoints(); float[] weights = nurbSpline.getWeights(); List<Float> knots = nurbSpline.getKnots(); int controlPointAmount = controlPoints.size(); store.set(Vector3f.ZERO); float delimeter = 0; for (int i = 0; i < controlPointAmount; ++i) { float val = weights[i] * CurveAndSurfaceMath.computeBaseFunctionValue(i, nurbSpline.getBasisFunctionDegree(), u, knots); store.addLocal(nurbSpline.getControlPoints().get(i) .mult(val)); delimeter += val; } store.divideLocal(delimeter); }
/** * This method interpolates tha data for the nurbs curve. * @param u * the u value * @param nurbSpline * the nurbs spline definition * @param store * the resulting point in 3D space */ public static void interpolateNurbs(float u, Spline nurbSpline, Vector3f store) { if (nurbSpline.getType() != SplineType.Nurb) { throw new IllegalArgumentException("Given spline is not of a NURB type!"); } List<Vector3f> controlPoints = nurbSpline.getControlPoints(); float[] weights = nurbSpline.getWeights(); List<Float> knots = nurbSpline.getKnots(); int controlPointAmount = controlPoints.size(); store.set(Vector3f.ZERO); float delimeter = 0; for (int i = 0; i < controlPointAmount; ++i) { float val = weights[i] * CurveAndSurfaceMath.computeBaseFunctionValue(i, nurbSpline.getBasisFunctionDegree(), u, knots); store.addLocal(nurbSpline.getControlPoints().get(i) .mult(val)); delimeter += val; } store.divideLocal(delimeter); }
private void attachDebugNode(Node root) { if (debugNode == null) { debugNode = new Node(); Material m = assetManager.loadMaterial("Common/Materials/RedColor.j3m"); for (Iterator<Vector3f> it = spline.getControlPoints().iterator(); it.hasNext();) { Vector3f cp = it.next(); Geometry geo = new Geometry("box", new Box(0.3f, 0.3f, 0.3f)); geo.setLocalTranslation(cp); geo.setMaterial(m); debugNode.attachChild(geo); } switch (spline.getType()) { case CatmullRom: debugNode.attachChild(CreateCatmullRomPath()); break; case Linear: debugNode.attachChild(CreateLinearPath()); break; default: debugNode.attachChild(CreateLinearPath()); break; } root.attachChild(debugNode); } }