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;h=52d78b2471fe836b1707393061d3a205125d7d13;hp=6e4c5ec6daa039e5fc1a7d8f423ea4747dc95367;hb=e56f9b775bd49c31e8efab7204bee699036942b3;hpb=2e7e46514dd35006e9dde07b1959540078292691 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 6e4c5ec..52d78b2 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/gui/Avatar.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/gui/Avatar.java @@ -14,13 +14,17 @@ import eu.svjatoslav.sixth.e3d.geometry.Point3D; import static java.lang.Math.cos; import static java.lang.Math.sin; -public class Avatar implements ViewUpdateListener { +public class Avatar implements ViewRenderListener { public static final double SPEED_LIMIT = 30; /** * Just in case we want to adjust global speed for some reason. */ private static final double SPEED_MULTIPLIER = .02d; + /** + * Determines amount of friction user experiences every millisecond while moving around in space. + */ + private static final double MILLISECOND_FRICTION = 1.005; /** * Avatar movement speed, relative to avatar itself. When avatar coordinates * are updated within the world, avatar orientation relative to the world is @@ -32,23 +36,16 @@ public class Avatar implements ViewUpdateListener { * Avatar location within the 3D world. */ private Point3D location = new Point3D(); - /** * Avatar orientation on the X-Z plane. It changes when turning left or * right. */ private double orientationXZ; - /** * Avatar orientation on the Y-Z plane. It changes when looking up or down. */ private double orientationYZ; - /** - * Determines amount of friction user experiences every millisecond while moving around in space. - */ - private static final double MILLISECOND_FRICTION = 1.005; - public Avatar() { } @@ -70,7 +67,7 @@ public class Avatar implements ViewUpdateListener { } @Override - public boolean beforeViewUpdate(final ViewContext viewContext, final int millisecondsSinceLastFrame) { + public boolean beforeRender(final ViewPanel viewPanel, final int millisecondsSinceLastFrame) { final Point3D locationBeforeUpdate = new Point3D(location); translateAvatarLocation(millisecondsSinceLastFrame); @@ -84,8 +81,7 @@ public class Avatar implements ViewUpdateListener { } public void enforceSpeedLimit() { - final double currentSpeed = movementVector - .getDistanceTo(Point3D.ZERO); + final double currentSpeed = movementVector.getVectorLength(); if (currentSpeed <= SPEED_LIMIT) return; @@ -122,7 +118,7 @@ public class Avatar implements ViewUpdateListener { } public double getMovementSpeed() { - return movementVector.getDistanceTo(Point3D.ZERO); + return movementVector.getVectorLength(); } private void applyFrictionToUserMovement(int millisecondsPassedSinceLastFrame) {