@ -90,7 +90,7 @@ public class Spline implements Savable {
type = splineType ;
type = splineType ;
this . curveTension = curveTension ;
this . curveTension = curveTension ;
this . cycle = cycle ;
this . cycle = cycle ;
this . computeTotalLent gh ( ) ;
this . computeTotalLengt h ( ) ;
}
}
/ * *
/ * *
@ -116,7 +116,7 @@ public class Spline implements Savable {
this . controlPoints . addAll ( controlPoints ) ;
this . controlPoints . addAll ( controlPoints ) ;
this . curveTension = curveTension ;
this . curveTension = curveTension ;
this . cycle = cycle ;
this . cycle = cycle ;
this . computeTotalLent gh ( ) ;
this . computeTotalLengt h ( ) ;
}
}
/ * *
/ * *
@ -144,7 +144,7 @@ public class Spline implements Savable {
this . weights [ i ] = controlPoint . w ;
this . weights [ i ] = controlPoint . w ;
}
}
CurveAndSurfaceMath . prepareNurbsKnots ( knots , basisFunctionDegree ) ;
CurveAndSurfaceMath . prepareNurbsKnots ( knots , basisFunctionDegree ) ;
this . computeTotalLent gh ( ) ;
this . computeTotalLengt h ( ) ;
}
}
private void initCatmullRomWayPoints ( List < Vector3f > list ) {
private void initCatmullRomWayPoints ( List < Vector3f > list ) {
@ -186,7 +186,7 @@ public class Spline implements Savable {
controlPoints . add ( controlPoints . get ( 0 ) . clone ( ) ) ;
controlPoints . add ( controlPoints . get ( 0 ) . clone ( ) ) ;
}
}
if ( controlPoints . size ( ) > 1 ) {
if ( controlPoints . size ( ) > 1 ) {
this . computeTotalLent gh ( ) ;
this . computeTotalLengt h ( ) ;
}
}
}
}
@ -197,7 +197,7 @@ public class Spline implements Savable {
public void removeControlPoint ( Vector3f controlPoint ) {
public void removeControlPoint ( Vector3f controlPoint ) {
controlPoints . remove ( controlPoint ) ;
controlPoints . remove ( controlPoint ) ;
if ( controlPoints . size ( ) > 1 ) {
if ( controlPoints . size ( ) > 1 ) {
this . computeTotalLent gh ( ) ;
this . computeTotalLengt h ( ) ;
}
}
}
}
@ -209,7 +209,7 @@ public class Spline implements Savable {
/ * *
/ * *
* This method computes the total length of the curve .
* This method computes the total length of the curve .
* /
* /
private void computeTotalLent gh ( ) {
private void computeTotalLengt h ( ) {
totalLength = 0 ;
totalLength = 0 ;
float l = 0 ;
float l = 0 ;
if ( segmentsLength = = null ) {
if ( segmentsLength = = null ) {
@ -317,7 +317,7 @@ public class Spline implements Savable {
public void setCurveTension ( float curveTension ) {
public void setCurveTension ( float curveTension ) {
this . curveTension = curveTension ;
this . curveTension = curveTension ;
if ( type = = SplineType . CatmullRom & & ! getControlPoints ( ) . isEmpty ( ) ) {
if ( type = = SplineType . CatmullRom & & ! getControlPoints ( ) . isEmpty ( ) ) {
this . computeTotalLent gh ( ) ;
this . computeTotalLengt h ( ) ;
}
}
}
}
@ -342,7 +342,7 @@ public class Spline implements Savable {
controlPoints . add ( controlPoints . get ( 0 ) ) ;
controlPoints . add ( controlPoints . get ( 0 ) ) ;
}
}
this . cycle = cycle ;
this . cycle = cycle ;
this . computeTotalLent gh ( ) ;
this . computeTotalLengt h ( ) ;
} else {
} else {
this . cycle = cycle ;
this . cycle = cycle ;
}
}
@ -369,7 +369,7 @@ public class Spline implements Savable {
* /
* /
public void setType ( SplineType type ) {
public void setType ( SplineType type ) {
this . type = type ;
this . type = type ;
this . computeTotalLent gh ( ) ;
this . computeTotalLengt h ( ) ;
}
}
/ * *
/ * *
@ -435,9 +435,13 @@ public class Spline implements Savable {
OutputCapsule oc = ex . getCapsule ( this ) ;
OutputCapsule oc = ex . getCapsule ( this ) ;
oc . writeSavableArrayList ( ( ArrayList ) controlPoints , "controlPoints" , null ) ;
oc . writeSavableArrayList ( ( ArrayList ) controlPoints , "controlPoints" , null ) ;
oc . write ( type , "type" , SplineType . CatmullRom ) ;
oc . write ( type , "type" , SplineType . CatmullRom ) ;
float list [ ] = new float [ segmentsLength . size ( ) ] ;
for ( int i = 0 ; i < segmentsLength . size ( ) ; i + + ) {
float list [ ] = null ;
list [ i ] = segmentsLength . get ( i ) ;
if ( segmentsLength ! = null ) {
list = new float [ segmentsLength . size ( ) ] ;
for ( int i = 0 ; i < segmentsLength . size ( ) ; i + + ) {
list [ i ] = segmentsLength . get ( i ) ;
}
}
}
oc . write ( list , "segmentsLength" , null ) ;
oc . write ( list , "segmentsLength" , null ) ;
@ -454,7 +458,7 @@ public class Spline implements Savable {
public void read ( JmeImporter im ) throws IOException {
public void read ( JmeImporter im ) throws IOException {
InputCapsule in = im . getCapsule ( this ) ;
InputCapsule in = im . getCapsule ( this ) ;
controlPoints = ( ArrayList < Vector3f > ) in . readSavableArrayList ( "wayPoints" , null ) ;
controlPoints = ( ArrayList < Vector3f > ) in . readSavableArrayList ( "controlPoints" , new ArrayList < Vector3f > ( ) ) ; /* Empty List as default, prevents null pointers */
float list [ ] = in . readFloatArray ( "segmentsLength" , null ) ;
float list [ ] = in . readFloatArray ( "segmentsLength" , null ) ;
if ( list ! = null ) {
if ( list ! = null ) {
segmentsLength = new ArrayList < Float > ( ) ;
segmentsLength = new ArrayList < Float > ( ) ;