2 * Sixth 3D engine. Copyright ©2012-2018, 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.geometry;
12 import eu.svjatoslav.sixth.e3d.gui.RenderingContext;
14 public class GeometryCoordinate {
16 public Point3D coordinate;
17 public Point3D transformedCoordinate;
18 public Point2D onScreenCoordinate;
20 int lastTransformedFrame;
22 public GeometryCoordinate() {
23 coordinate = new Point3D();
24 transformedCoordinate = new Point3D();
25 onScreenCoordinate = new Point2D();
28 public GeometryCoordinate(final Point3D location) {
29 coordinate = location;
30 transformedCoordinate = new Point3D();
31 onScreenCoordinate = new Point2D();
34 public void transform(final TransformPipe transforms,
35 final RenderingContext renderContext) {
37 if (lastTransformedFrame == renderContext.frameNumber)
40 lastTransformedFrame = renderContext.frameNumber;
42 transforms.transform(coordinate, transformedCoordinate);
44 onScreenCoordinate.x = ((transformedCoordinate.x / transformedCoordinate.z) * renderContext.zoom)
45 + renderContext.xCenter;
46 onScreenCoordinate.y = ((transformedCoordinate.y / transformedCoordinate.z) * renderContext.zoom)
47 + renderContext.yCenter;