Updated copyright
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / math / TransformPipe.java
1 /*
2  * Sixth 3D engine. Copyright ©2012-2019, 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.math;
11
12 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
13
14 public class TransformPipe {
15
16     private Transform[] transforms = new Transform[100];
17
18     private int transformsCount = 0;
19
20     public void addTransform(final Transform transform) {
21         transforms[transformsCount] = transform;
22         transformsCount++;
23     }
24
25     public void clear() {
26         transformsCount = 0;
27     }
28
29     public void dropTransform() {
30         transformsCount--;
31     }
32
33     public void transform(final Point3D source, final Point3D destination) {
34
35         destination.clone(source);
36
37         for (int i = transformsCount - 1; i >= 0; i--)
38             transforms[i].transform(destination);
39     }
40 }