X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgui%2FAvatar.java;fp=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgui%2FAvatar.java;h=abbf0dda352b270d0fb0b2fcf3827b5c3d52efdf;hp=9876589cc9439625f7bf819729866c23e5935b7e;hb=8aa50f568d2edcfe974ceed4192158951e7f3215;hpb=9d03f0af97129ee791c0b1a33703fe1e34e9c050 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 9876589..abbf0dd 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/gui/Avatar.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/gui/Avatar.java @@ -9,8 +9,16 @@ 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. + */ 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. @@ -61,6 +69,7 @@ public class Avatar implements ViewRenderListener { setAngleYZ(angleYZ); } + @Override public boolean beforeRender(final ViewPanel viewPanel, final int millisecondsSinceLastFrame) { @@ -116,11 +125,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; @@ -131,7 +150,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) {