2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.sixth.e3d.math;
7 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
9 public class TransformsPipeline {
12 private Transform[] transforms = new Transform[100];
15 * The number of transforms in the pipeline.
17 private int transformsCount = 0;
20 * Adds a transform to the pipeline.
23 * The transform to add.
25 public void addTransform(final Transform transform) {
26 transforms[transformsCount] = transform;
31 * Clears the pipeline.
38 * Drops the last transform from the pipeline.
40 public void dropTransform() {
47 * @param orinigalPoint
48 * Original point to transform. Original point is not modified.
49 * @param transformedPoint
52 public void transform(final Point3D orinigalPoint, final Point3D transformedPoint) {
54 transformedPoint.clone(orinigalPoint);
56 // apply transforms in reverse order
57 for (int i = transformsCount - 1; i >= 0; i--)
58 transforms[i].transform(transformedPoint);