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       * @deprecated you should not use this as it is not reliable in multi-bot scenario
58       */
59      public static Velocity CHARACTER_RUN_SPEED;
60      /**
61       * Speed of the bot while walking.
62       * TODO: fill after the reception of INIT message.
63       * @deprecated you should not use this as it is not reliable in multi-bot scenario
64       */
65      public static Velocity CHARACTER_WALK_SPEED;
66      /**
67       * Center of gravity - distance from the floor in UU.
68       * TODO: estimate
69       */
70      public static final double BOT_CENTER_OF_GRAVITY_HEIGHT = 50;
71      /**
72       * NavPoint distance from the floor.
73       * TODO: estimate
74       */
75      public static final double NAV_POINT_HEIGHT = 10;
76  
77      public static final double FULL_ANGLE_IN_UNREAL_DEGREES = 65536;
78      
79      public static final double ONE_DEGREE_IN_UNREAL_DEGREES = ((double)FULL_ANGLE_IN_UNREAL_DEGREES) / ((double)360);
80      
81      public static final double ONE_RAD_IN_UNREAL_DEGREES = ((double)FULL_ANGLE_IN_UNREAL_DEGREES) / ((double)2*Math.PI);
82      
83      public static final double ONE_UNREAL_DEGREE_IN_DEGREES = ((double)360) / ((double)FULL_ANGLE_IN_UNREAL_DEGREES);
84      
85      public static final double ONE_UNREAD_DEGREE_IN_RAD = ((double)2*Math.PI) / ((double)FULL_ANGLE_IN_UNREAL_DEGREES);
86      
87      /**
88       * @deprecated use {@link UnrealUtils#ONE_UNREAD_DEGREE_IN_RAD}
89       */
90      public static final double UT_ANGLE_TO_RAD = 2*Math.PI / ((double)FULL_ANGLE_IN_UNREAL_DEGREES);
91  
92      /**
93       * @deprecated use {@link UnrealUtils#ONE_DEGREE_IN_UNREAL_DEGREES}
94       */
95      public static final double DEG_TO_UT_ANGLE = ((double)FULL_ANGLE_IN_UNREAL_DEGREES) / ((double)360);
96  
97      /**
98       * @deprecated 
99       */
100     public static final double UT_ANGLE_TO_DEG =  FULL_ANGLE_IN_UNREAL_DEGREES * 360;
101     
102     /**
103      * @deprecated use {@link UnrealUtils#ONE_RAD_IN_UNREAL_DEGREES}
104      */
105     public static final double RAD_TO_UT_ANGLE =  ((double)FULL_ANGLE_IN_UNREAL_DEGREES) / (2 * Math.PI);
106     
107     /**
108      * 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
109      * to UT2004.
110      */
111     public static final double UT2004_TIME_SPEED = 1.1;
112     
113     /**
114      * Force to be applied to {@link Jump#setForce(Double)} if full jump is needed.
115      * <p><p>
116      * Note that you actually do not need to set this value directly as GB2004 always assumes you want to do full jump. 
117      */
118     public static final int FULL_JUMP_FORCE = 340;
119     
120     /**
121      * Force to be applied to {@link Jump#setForce(Double)} if full double jump is needed.
122      * <p><p>
123      * Note that you actually do not need to set this value directly as GB2004 always assumes you want to do full double jump.
124      * We raised this value by 50 (was 705) in GameBots of Pogamut 3.3.1 because of problems of accessing spots 
125      * on the verge of reachability with double jump. 
126      */
127     public static final int FULL_DOUBLEJUMP_FORCE = 755;
128     
129     /**
130      * Delay to be made between two jumps in double jumping ({@link Jump#setDelay(Double)}) if full double jump is needed.
131      * <p><p>
132      * Note that you actually do not need to set this value directly as GB2004 always assumes you want to do full double jump.
133      * <p><p>
134      * In seconds. 
135      */
136     public static final double FULL_DOUBLEJUMP_DELAY = 0.39;
137     
138     /**
139      * Standard max. velocity of bots (it's actually almost 440 but it is better to have this number lower as you will check whether
140      * you're running at max speed with it...).
141      */
142     public static final double MAX_VELOCITY = 439.5;
143     
144     /**
145      * Converts angle in degrees (0-360) to Unreal units used for angles (0 - 65536).
146      * @param degrees Angle in degrees
147      * @return corresponding angle in Unreal units
148      */
149     public static int degreeToUnrealDegrees(double degrees) {
150         return (int)Math.round((degrees * (double)ONE_DEGREE_IN_UNREAL_DEGREES));
151     }
152 
153     /**
154      * Converts Unreal degrees (0-65536) to normal degrees (0 - 360).
155      * @param unrealDegrees
156      * @return
157      */
158     public static double unrealDegreeToDegree(int unrealDegrees) {
159         return ((double)unrealDegrees) * ((double)ONE_UNREAL_DEGREE_IN_DEGREES);
160     }
161 
162     /**
163      * Converts Unreal degrees (0-65536) to radians (0 - 2*PI)
164      * @param unrealDegrees
165      * @return
166      */
167     public static double unrealDegreeToRad(double unrealDegrees) {
168         return ((double)unrealDegrees) * ((double)ONE_UNREAD_DEGREE_IN_RAD);
169     }
170 
171 }