use of org.jwildfire.create.eden.scene.PositionableSceneElement in project JWildfire by thargor6.
the class AddSceneObjectsVisitor method calcTransform.
private Matrix4 calcTransform(PositionableSceneElement pElement) {
Matrix4 transform = Matrix4.IDENTITY;
List<Matrix4> transforms = new ArrayList<Matrix4>();
PositionableSceneElement element = pElement;
while (element != null) {
transforms.add(Matrix4.scale(element.getSize().getX(), element.getSize().getY(), element.getSize().getZ()));
if (MathLib.fabs(element.getOrientation().getAlpha()) > MathLib.EPSILON) {
transforms.add(Matrix4.rotateX((float) Math.toRadians(element.getOrientation().getAlpha())));
}
if (MathLib.fabs(element.getOrientation().getBeta()) > MathLib.EPSILON) {
transforms.add(Matrix4.rotateY((float) Math.toRadians(element.getOrientation().getBeta())));
}
if (MathLib.fabs(element.getOrientation().getGamma()) > MathLib.EPSILON) {
transforms.add(Matrix4.rotateZ((float) Math.toRadians(element.getOrientation().getGamma())));
}
transforms.add(Matrix4.translation(element.getPosition().getX(), element.getPosition().getY(), element.getPosition().getZ()));
element = element.getParent();
}
for (int i = transforms.size() - 1; i >= 0; i--) {
transform = transform.multiply(transforms.get(i));
}
return transform;
}
Aggregations