/*
* 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;
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.
setAngleYZ(angleYZ);
}
+
@Override
public boolean beforeRender(final ViewPanel viewPanel, final int millisecondsSinceLastFrame) {
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;
* 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) {