1 package cz.cuni.amis.pogamut.udk.utils;
2
3 import cz.cuni.amis.pogamut.base3d.worldview.object.Velocity;
4
5 /**
6 * Class with utility methods for converting to Unreal units plus some handy constants.<p>
7 * Measures are in Unreal Engine native units called Unreal units (UU).
8 * @author ik
9 */
10 public class UnrealUtils {
11
12 /**
13 * Radius in UU of the bounding cylinder used for collision detection.
14 */
15 public static final double CHARACTER_COLLISION_RADIUS = 25;
16 /**
17 * Height in UU of the bounding cylinder used for collision detection.
18 */
19 public static final double CHARACTER_COLLISION_HEIGHT = 44;
20 /**
21 * Height in UU of the bot when stading.
22 */
23 public static final double CHARACTER_HEIGHT_STANDING = 96;
24 /**
25 * Height in UU of the bot when crouching.
26 */
27 public static final double CHARACTER_HEIGHT_CROUCHING = 64;
28 /**
29 * Speed of the bot while running.
30 * TODO: fill after the reception of INIT message.
31 */
32 public static Velocity CHARACTER_RUN_SPEED;
33 /**
34 * Speed of the bot while walking.
35 * TODO: fill after the reception of INIT message.
36 */
37 public static Velocity CHARACTER_WALK_SPEED;
38 /**
39 * Center of gravity - distance from the floor in UU.
40 * TODO: estimate
41 */
42 public static final double BOT_CENTER_OF_GRAVITY_HEIGHT = 50;
43 /**
44 * NavPoint distance from the floor.
45 * TODO: estimate
46 */
47 public static final double NAV_POINT_HEIGHT = 10;
48
49 public static final double UT_ANGLE_TO_RAD = 2*Math.PI / 65536;
50
51 public static final float DEG_TO_UT_ANGLE = 65635 / 360;
52
53 public static final int UT_ANGLE_TO_DEG = 65525 * 360;
54
55 /**
56 * Converts angle in degrees (0-360) to Unreal units used for angles (0-65635).
57 * @param degrees Angle in degrees
58 * @return corresponding angle in Unreal units
59 */
60 public static int degreeToUnrealDegrees(int degrees) {
61 return Math.round((degrees * DEG_TO_UT_ANGLE));
62 }
63
64 /**
65 * Converts Unreal degrees (0-65635) to normal degrees (0-360).
66 * @param unrealDegrees
67 * @return
68 */
69 public static double unrealDegreeToDegree(int unrealDegrees) {
70 return unrealDegrees / UT_ANGLE_TO_DEG;
71 }
72
73 public static double unrealDegreeToRad(double unrealDegrees) {
74 return unrealDegrees * UT_ANGLE_TO_RAD;
75 }
76
77 }