|
|
@ -39,10 +39,11 @@ import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* A <code>Curve</code> is a visual, line-based representation of a {@link Spline}. |
|
|
|
* A |
|
|
|
|
|
|
|
* <code>Curve</code> is a visual, line-based representation of a {@link Spline}. |
|
|
|
* The underlying Spline will be sampled N times where N is the number of |
|
|
|
* The underlying Spline will be sampled N times where N is the number of |
|
|
|
* segments as specified in the constructor. Each segment will represent |
|
|
|
* segments as specified in the constructor. Each segment will represent one |
|
|
|
* one line in the generated mesh. |
|
|
|
* line in the generated mesh. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Nehon |
|
|
|
* @author Nehon |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -58,8 +59,7 @@ public class Curve extends Mesh { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a curve mesh. |
|
|
|
* Create a curve mesh. Use a CatmullRom spline model that does not cycle. |
|
|
|
* Use a CatmullRom spline model that does not cycle. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param controlPoints the control points to use to create this curve |
|
|
|
* @param controlPoints the control points to use to create this curve |
|
|
|
* @param nbSubSegments the number of subsegments between the control points |
|
|
|
* @param nbSubSegments the number of subsegments between the control points |
|
|
@ -122,7 +122,7 @@ public class Curve extends Mesh { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
i = 0; |
|
|
|
i = 0; |
|
|
|
int k = 0; |
|
|
|
int k; |
|
|
|
for (int j = 0; j < (spline.getControlPoints().size() - 1) * nbSubSegments; j++) { |
|
|
|
for (int j = 0; j < (spline.getControlPoints().size() - 1) * nbSubSegments; j++) { |
|
|
|
k = j; |
|
|
|
k = j; |
|
|
|
indices[i] = (short) k; |
|
|
|
indices[i] = (short) k; |
|
|
@ -142,8 +142,8 @@ public class Curve extends Mesh { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* This method creates the Bezier path for this curve. |
|
|
|
* This method creates the Bezier path for this curve. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param nbSubSegments |
|
|
|
* @param nbSubSegments amount of subsegments between position control |
|
|
|
* amount of subsegments between position control points |
|
|
|
* points |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void createBezierMesh(int nbSubSegments) { |
|
|
|
private void createBezierMesh(int nbSubSegments) { |
|
|
|
if (nbSubSegments == 0) { |
|
|
|
if (nbSubSegments == 0) { |
|
|
@ -175,7 +175,7 @@ public class Curve extends Mesh { |
|
|
|
array[lineIndex++] = vector3f.z; |
|
|
|
array[lineIndex++] = vector3f.z; |
|
|
|
|
|
|
|
|
|
|
|
//calculating indexes
|
|
|
|
//calculating indexes
|
|
|
|
int i = 0, k = 0; |
|
|
|
int i = 0, k; |
|
|
|
short[] indices = new short[(centerPointsAmount - 1) * nbSubSegments << 1]; |
|
|
|
short[] indices = new short[(centerPointsAmount - 1) * nbSubSegments << 1]; |
|
|
|
for (int j = 0; j < (centerPointsAmount - 1) * nbSubSegments; ++j) { |
|
|
|
for (int j = 0; j < (centerPointsAmount - 1) * nbSubSegments; ++j) { |
|
|
|
k = j; |
|
|
|
k = j; |
|
|
@ -193,8 +193,9 @@ public class Curve extends Mesh { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This method creates the Nurb path for this curve. |
|
|
|
* This method creates the Nurb path for this curve. |
|
|
|
* @param nbSubSegments |
|
|
|
* |
|
|
|
* amount of subsegments between position control points |
|
|
|
* @param nbSubSegments amount of subsegments between position control |
|
|
|
|
|
|
|
* points |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void createNurbMesh(int nbSubSegments) { |
|
|
|
private void createNurbMesh(int nbSubSegments) { |
|
|
|
float minKnot = spline.getMinNurbKnot(); |
|
|
|
float minKnot = spline.getMinNurbKnot(); |
|
|
@ -233,7 +234,7 @@ public class Curve extends Mesh { |
|
|
|
short[] indices = new short[(spline.getControlPoints().size() - 1) * 2]; |
|
|
|
short[] indices = new short[(spline.getControlPoints().size() - 1) * 2]; |
|
|
|
int i = 0; |
|
|
|
int i = 0; |
|
|
|
int cpt = 0; |
|
|
|
int cpt = 0; |
|
|
|
int k = 0; |
|
|
|
int k; |
|
|
|
int j = 0; |
|
|
|
int j = 0; |
|
|
|
for (Iterator<Vector3f> it = spline.getControlPoints().iterator(); it.hasNext();) { |
|
|
|
for (Iterator<Vector3f> it = spline.getControlPoints().iterator(); it.hasNext();) { |
|
|
|
Vector3f vector3f = it.next(); |
|
|
|
Vector3f vector3f = it.next(); |
|
|
@ -263,6 +264,7 @@ public class Curve extends Mesh { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This method returns the length of the curve. |
|
|
|
* This method returns the length of the curve. |
|
|
|
|
|
|
|
* |
|
|
|
* @return the length of the curve |
|
|
|
* @return the length of the curve |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public float getLength() { |
|
|
|
public float getLength() { |
|
|
|