Refactoring.
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / math / TransformPipe.java
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/math/TransformPipe.java b/src/main/java/eu/svjatoslav/sixth/e3d/math/TransformPipe.java
new file mode 100644 (file)
index 0000000..b554953
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
+ *
+ */
+
+package eu.svjatoslav.sixth.e3d.math;
+
+import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+
+public class TransformPipe {
+
+    private Transform[] transforms = new Transform[100];
+
+    private int transformsCount = 0;
+
+    public void addTransform(final Transform transform) {
+        transforms[transformsCount] = transform;
+        transformsCount++;
+    }
+
+    public void clear() {
+        transformsCount = 0;
+    }
+
+    public void dropTransform() {
+        transformsCount--;
+    }
+
+    public void transform(final Point3D source, final Point3D destination) {
+
+        destination.clone(source);
+
+        for (int i = transformsCount - 1; i >= 0; i--)
+            transforms[i].transform(destination);
+    }
+}