2 * Sixth 3D engine. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
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.
10 package eu.svjatoslav.sixth.e3d.math;
12 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
13 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
14 import eu.svjatoslav.sixth.e3d.gui.RenderingContext;
16 public class GeometryCoordinate {
18 public Point3D coordinate;
19 public Point3D transformedCoordinate;
20 public Point2D onScreenCoordinate;
22 private int lastTransformedFrame;
24 public GeometryCoordinate() {
25 coordinate = new Point3D();
26 transformedCoordinate = new Point3D();
27 onScreenCoordinate = new Point2D();
30 public GeometryCoordinate(final Point3D location) {
31 coordinate = location;
32 transformedCoordinate = new Point3D();
33 onScreenCoordinate = new Point2D();
36 public void transform(final TransformPipe transforms,
37 final RenderingContext renderContext) {
39 if (lastTransformedFrame == renderContext.frameNumber)
42 lastTransformedFrame = renderContext.frameNumber;
44 transforms.transform(coordinate, transformedCoordinate);
46 onScreenCoordinate.x = ((transformedCoordinate.x / transformedCoordinate.z) * renderContext.zoom)
47 + renderContext.xCenter;
48 onScreenCoordinate.y = ((transformedCoordinate.y / transformedCoordinate.z) * renderContext.zoom)
49 + renderContext.yCenter;