use of com.microsoft.Malmo.Schemas.AnimationDecorator in project malmo by Microsoft.
the class AnimationDecoratorImplementation method parseParameters.
@Override
public boolean parseParameters(Object params) {
if (params == null || !(params instanceof AnimationDecorator))
return false;
this.params = (AnimationDecorator) params;
// Initialise starting positions / velocities:
if (this.params.getLinear() != null) {
Linear linear = this.params.getLinear();
this.origin = new Vec3(linear.getInitialPos().getX().doubleValue(), linear.getInitialPos().getY().doubleValue(), linear.getInitialPos().getZ().doubleValue());
this.velocity = new Vec3(linear.getInitialVelocity().getX().doubleValue(), linear.getInitialVelocity().getY().doubleValue(), linear.getInitialVelocity().getZ().doubleValue());
this.minCanvas = new Vec3(linear.getCanvasBounds().getMin().getX(), linear.getCanvasBounds().getMin().getY(), linear.getCanvasBounds().getMin().getZ());
this.maxCanvas = new Vec3(linear.getCanvasBounds().getMax().getX(), linear.getCanvasBounds().getMax().getY(), linear.getCanvasBounds().getMax().getZ());
} else {
// Initialise a RNG:
long seed = 0;
String strSeed = this.params.getParametric().getSeed();
if (strSeed == null || strSeed == "" || strSeed.equals("random"))
seed = System.currentTimeMillis();
else
seed = Long.parseLong(strSeed);
this.rng = new Random(seed);
try {
double x = EvaluationHelper.eval(this.params.getParametric().getX(), 0, this.rng);
double y = EvaluationHelper.eval(this.params.getParametric().getY(), 0, this.rng);
double z = EvaluationHelper.eval(this.params.getParametric().getZ(), 0, this.rng);
this.origin = new Vec3(x, y, z);
} catch (Exception e) {
// Malformed equations.
System.out.println("ERROR: malformed equations in animation - check these:");
System.out.println(" " + this.params.getParametric().getX());
System.out.println(" " + this.params.getParametric().getY());
System.out.println(" " + this.params.getParametric().getZ());
}
}
return true;
}
Aggregations