import com.nolimitscoaster.*;
import nlvm.math3d.*;
public class ExportlineScript extends Script{
float heartline = 0.3f;
float seperation = 1.5f;
float beginDistance = 0.0f;
int beginIndex = 1;
public Coaster currentCoaster;
Train fTrain ;
Vector3f last;
bool first = true ;
float dis = 0.0f;
bool breakScript = false;
float totalDistance = 0.0f;
int i=0;
public bool onInit()
{
currentCoaster = sim.getCoasterForEntityId(getParentEntityId());
fTrain = currentCoaster.getTrainAt(0);
last = new Vector3f();
return true;
}
public void onNextFrame(float fTickTime){
if (breakScript) return;
Vector3f fo = new Vector3f(0.0f, 0.0f, 0.0f);
Vector3f to = new Vector3f(0.0f, 0.0f, 0.0f);
Vector3f ro = new Vector3f(0.0f, 0.0f, 0.0f);
Vector3f po = new Vector3f(0.0f, 0.0f, 0.0f);
fTrain.getBogieOrientationAndPosition(0, fo, to, ro, po);
Vector3f cross = new Vector3f(
ro.y * fo.z - ro.z * fo.y,
ro.z * fo.x - ro.x * fo.z,
ro.x * fo.y - ro.y * fo.x
);
cross.normalize();
cross.mul(heartline);
cross.add(po);
if (first && beginDistance == 0.0f){
first = false;
i++;
} else{
Vector3f v2= po;
Vector3f v1= last;
float distance = (float) Math.sqrt(Math.pow(v2.x -v1.x, 2) + Math.pow(v2.y -v1.y, 2) + Math.pow(v2.z -v1.z, 2));
if(first && beginDistance != 0.0f){
first = false;
distance= 0.0f;
}
dis += distance;
totalDistance = distance;
if (dis > seperation){
if(beginDistance == 0.0f || (beginDistance != 0.0f && totalDistance > beginDistance)) {
System.out.println( po.x +"\t"+po.y +"\t"+ (po.z) );
i++;
}
dis = 0.0f;
}
}
last.x = po.x;
last.y = po.y;
last.z = po.z;
if (i > 490 ){
breakScript = true ;
}
}
}