X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgui%2FAvatar.java;h=f2d58c98f5f9ec61fd644ef66264141a3ebd077c;hb=HEAD;hp=050a14ec1757a34495815c0c308d89d03755f76f;hpb=59baa428fb2d9e7f0fe5423f4cea47f2d6245914;p=sixth-3d.git diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/Avatar.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/Avatar.java index 050a14e..f2d58c9 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/gui/Avatar.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/gui/Avatar.java @@ -1,12 +1,7 @@ /* - * Sixth 3D engine. Copyright ©2012-2019, 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. - * + * Sixth 3D engine. Author: Svjatoslav Agejenko. + * This project is released under Creative Commons Zero (CC0) license. */ - package eu.svjatoslav.sixth.e3d.gui; import eu.svjatoslav.sixth.e3d.geometry.Point3D; @@ -14,8 +9,19 @@ import eu.svjatoslav.sixth.e3d.geometry.Point3D; import static java.lang.Math.cos; import static java.lang.Math.sin; +/** + * The avatar is a user-controlled object in the 3D world. + * + * It is a point in space that can be moved around by the user. + * It has orientation in space, and it can also be rotated around. + */ public class Avatar implements ViewRenderListener { + /** + * Avatar movement speed, relative to the world. When avatar coordinates are + * updated within the world, avatar orientation relative to the world is + * taken into account. + */ public static final double SPEED_LIMIT = 30; /** * Just in case we want to adjust global speed for some reason. @@ -66,6 +72,7 @@ public class Avatar implements ViewRenderListener { setAngleYZ(angleYZ); } + @Override public boolean beforeRender(final ViewPanel viewPanel, final int millisecondsSinceLastFrame) { @@ -121,11 +128,21 @@ public class Avatar implements ViewRenderListener { return movementVector.getVectorLength(); } + /** + * Apply friction to avatar movement vector. + * + * @param millisecondsPassedSinceLastFrame We want avatar movement to be independent of framerate. + * Therefore, we take frame rendering time into account when translating + * avatar between consecutive frames. + */ private void applyFrictionToUserMovement(int millisecondsPassedSinceLastFrame) { for (int i = 0; i < millisecondsPassedSinceLastFrame; i++) applyMillisecondFrictionToUserMovementVector(); } + /** + * Apply friction to avatar movement vector. + */ private void applyMillisecondFrictionToUserMovementVector() { getMovementVector().x /= MILLISECOND_FRICTION; getMovementVector().y /= MILLISECOND_FRICTION; @@ -136,7 +153,7 @@ public class Avatar implements ViewRenderListener { * Translate coordinates based on avatar movement vector and avatar orientation in the world. * * @param millisecondsPassedSinceLastFrame We want avatar movement to be independent of framerate. - * Therefore we take frame rendering time into account when translating + * Therefore, we take frame rendering time into account when translating * avatar between consecutive frames. */ private void translateAvatarLocationBasedOnMovementVector(int millisecondsPassedSinceLastFrame) {