Refactoring.
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / geometry / TransformPipe.java
1 /*
2  * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 3 of the GNU Lesser General Public License
6  * or later as published by the Free Software Foundation.
7  *
8  */
9
10 package eu.svjatoslav.sixth.e3d.geometry;
11
12 public class TransformPipe {
13
14     private Transform[] transforms = new Transform[100];
15
16     private int transformsCount = 0;
17
18     public void addTransform(final Transform transform) {
19         transforms[transformsCount] = transform;
20         transformsCount++;
21     }
22
23     public void clear() {
24         transformsCount = 0;
25     }
26
27     public void dropTransform() {
28         transformsCount--;
29     }
30
31     public void transform(final Point3D source, final Point3D destination) {
32
33         destination.clone(source);
34
35         for (int i = transformsCount - 1; i >= 0; i--)
36             transforms[i].transform(destination);
37     }
38 }