View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.utils;
2   
3   import javax.vecmath.Point3d;
4   import javax.vecmath.Vector3d;
5   
6   import cz.cuni.amis.pogamut.base3d.worldview.object.Velocity;
7   import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Jump;
8   
9   /**
10   * Class with utility methods for converting to Unreal units plus some handy constants.<p>
11   * Measures are in Unreal Engine native units called Unreal units (UU).
12   * @author ik
13   */
14  public class UnrealUtils {
15  
16  	public static final int iNT_NONE = Integer.MAX_VALUE;
17  	
18  	public static final long lONG_NONE = Long.MAX_VALUE;
19  	
20  	public static final float fLOAT_NONE = Float.MAX_VALUE;
21  	
22  	public static final double dOUBLE_NONE = Double.MAX_VALUE;
23  	
24  	public static final Integer INT_NONE = Integer.MAX_VALUE;
25  	
26  	public static final Long LONG_NONE = Long.MAX_VALUE;
27  	
28  	public static final Float FLOAT_NONE = Float.MAX_VALUE;
29  	
30  	public static final Double DOUBLE_NONE = Double.MAX_VALUE;
31  	
32  	public static final String STRING_NONE = "@@NONE@@";
33  	
34  	public static final Point3d POINT3D_NONE = new Point3d(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
35  	
36  	public static final Vector3d VECTOR3D_NONE = new Vector3d(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
37  	
38      /**
39       * Radius in UU of the bounding cylinder used for collision detection.
40       */
41      public static final double CHARACTER_COLLISION_RADIUS = 25;
42      /**
43       * Height in UU of the bounding cylinder used for collision detection.
44       */
45      public static final double CHARACTER_COLLISION_HEIGHT = 44;
46      /**
47       * Height in UU of the bot when stading.
48       */
49      public static final double CHARACTER_HEIGHT_STANDING = 96;
50      /**
51       * Height in UU of the bot when crouching.
52       */
53      public static final double CHARACTER_HEIGHT_CROUCHING = 64;
54      /**
55       * Speed of the bot while running.
56       * TODO: fill after the reception of INIT message.
57       */
58      public static Velocity CHARACTER_RUN_SPEED;
59      /**
60       * Speed of the bot while walking.
61       * TODO: fill after the reception of INIT message.
62       */
63      public static Velocity CHARACTER_WALK_SPEED;
64      /**
65       * Center of gravity - distance from the floor in UU.
66       * TODO: estimate
67       */
68      public static final double BOT_CENTER_OF_GRAVITY_HEIGHT = 50;
69      /**
70       * NavPoint distance from the floor.
71       * TODO: estimate
72       */
73      public static final double NAV_POINT_HEIGHT = 10;
74  
75      public static final double UT_ANGLE_TO_RAD = 2*Math.PI / 65536;
76  
77      public static final float DEG_TO_UT_ANGLE = 65635 / 360;
78  
79      public static final int UT_ANGLE_TO_DEG =  65525 * 360;
80      
81      /**
82       * UT2004 time is running 110% of normal time. I.e., when 1 sec pass according to {@link System#currentTimeMillis()} than 1.1 secs pass according
83       * to UT2004.
84       */
85      public static final double UT2004_TIME_SPEED = 1.1;
86      
87      /**
88       * Force to be applied to {@link Jump#setForce(Double)} if full jump is needed.
89       * <p><p>
90       * Note that you actually do not need to set this value directly as GB2004 always assumes you want to do full jump. 
91       */
92      public static final int FULL_JUMP_FORCE = 340;
93      
94      /**
95       * Force to be applied to {@link Jump#setForce(Double)} if full double jump is needed.
96       * <p><p>
97       * Note that you actually do not need to set this value directly as GB2004 always assumes you want to do full double jump. 
98       */
99      public static final int FULL_DOUBLEJUMP_FORCE = 705;
100     
101     /**
102      * Delay to be made between two jumps in double jumping ({@link Jump#setDelay(Double)}) if if full double jump is needed.
103      * <p><p>
104      * Note that you actually do not need to set this value directly as GB2004 always assumes you want to do full double jump. 
105      */
106     public static final double FULL_DOUBLEJUMP_DELAY = 0.39;
107     
108     /**
109      * Standard max. velocity of bots (it's actually more 440 but it is better to have this number lower as you will check whether
110      * you're running at max speed with it...).
111      */
112     public static final double MAX_VELOCITY = 439.5;
113     
114     /**
115      * Converts angle in degrees (0-360) to Unreal units used for angles (0-65635).
116      * @param degrees Angle in degrees
117      * @return corresponding angle in Unreal units
118      */
119     public static int degreeToUnrealDegrees(int degrees) {
120         return Math.round((degrees * DEG_TO_UT_ANGLE));
121     }
122 
123     /**
124      * Converts Unreal degrees (0-65635) to normal degrees (0-360).
125      * @param unrealDegrees
126      * @return
127      */
128     public static double unrealDegreeToDegree(int unrealDegrees) {
129         return unrealDegrees / UT_ANGLE_TO_DEG;
130     }
131 
132     public static double unrealDegreeToRad(double unrealDegrees) {
133         return unrealDegrees * UT_ANGLE_TO_RAD;
134     }
135 
136 }