cz.cuni.amis.pogamut.ut2004.bot.command
Class SimpleRayCasting

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT>
      extended by cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule<UT2004Bot>
          extended by cz.cuni.amis.pogamut.ut2004.bot.command.BotCommands
              extended by cz.cuni.amis.pogamut.ut2004.bot.command.SimpleRayCasting
All Implemented Interfaces:
IComponent

public class SimpleRayCasting
extends BotCommands

This command module provides basic ray tracing control. Note that you will need to register listeners in your code in order to receive answers to commands issued by this module. For fastTrace register listener for FastTraceResponse() class. For trace register listener for TraceResponse() class. For autoTracing rays register listener for AutoTraceRay() class.


Field Summary
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule
act, worldView
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
agent, controller, eventBus, log
 
Constructor Summary
SimpleRayCasting(UT2004Bot agent, java.util.logging.Logger log)
          Constructor.
 
Method Summary
 void addAutoTraceRay(java.lang.String id, Vector3d direction, int length, boolean bFastTrace, boolean bFloorCorrection, boolean bTraceActors)
          Adds a new ray to auto ray tracing rays set.
 void addDefaultAutoTraceRays()
          This command removes all existing auto trace rays and adds a default auto trace rays set.
 void changeAutoTraceRay(java.lang.String id, Vector3d direction, int length, boolean bFastTrace, boolean bFloorCorrection, boolean bTraceActors)
          To change the ray it is sufficient to call addAutoTraceRay function with proper Id.
 void disableAutoTracing()
          Disables auto trace rays.
 void enableAutoTracing()
          Enables auto trace rays.
 void fastTrace(java.lang.String id, ILocated to)
          Sends a ray from actual bot location to desired location.
 void fastTrace(java.lang.String id, ILocated from, ILocated to)
          Sends a ray from desired location to desired location.
 void removeAllAutoTraceRays()
          Removes all autoTraceRays.
 void removeAutoTraceRay(java.lang.String id)
          Remove one autoTraceRay with desired id from the list.
 void trace(java.lang.String id, ILocated to, boolean bTraceActors)
          Sends a ray from actual bot location to desired location.
 void trace(java.lang.String id, ILocated from, ILocated to, boolean bTraceActors)
          Sends a ray from desired location to desired location.
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
cleanUp, getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleRayCasting

public SimpleRayCasting(UT2004Bot agent,
                        java.util.logging.Logger log)
Constructor. Setups the command module based on given agent and logger.

Parameters:
agent - AbstractUT2004Bot we will send commands for
log - Logger to be used for logging runtime/debug info.
Method Detail

fastTrace

public void fastTrace(java.lang.String id,
                      ILocated to)
Sends a ray from actual bot location to desired location. To receive response register listener for FastTraceResponse() messages and check Id. This ray collides only with level geometry (not with dynamic items - other players, items).

Parameters:
id - user determined id of the ray (use to match response)
to - end location of this ray

fastTrace

public void fastTrace(java.lang.String id,
                      ILocated from,
                      ILocated to)
Sends a ray from desired location to desired location. To receive response register listener for FastTraceResponse() messages and check Id. This ray collides only with level geometry (not with dynamic items - other players, items).

Parameters:
id - user determined id of the ray (use to match response)
from - start location of this ray
to - end location of this ray

trace

public void trace(java.lang.String id,
                  ILocated to,
                  boolean bTraceActors)
Sends a ray from actual bot location to desired location. To receive response register listener for TraceResponse() messages and check Id. Normaly this ray collides only with level geometry. If bTraceActors is set to true it will collide also with dynamic items - other players and items or vehicles in the map.

Parameters:
id - user determined id of the ray (use to match response)
to - end location of this ray

trace

public void trace(java.lang.String id,
                  ILocated from,
                  ILocated to,
                  boolean bTraceActors)
Sends a ray from desired location to desired location. To receive response register listener for TraceResponse() messages and check Id. Normaly this ray collides only with level geometry. If bTraceActors is set to true it will collide also with dynamic items - other players and items or vehicles in the map.

Parameters:
id - user determined id of the ray (use to match response)
from - start location of this ray
to - end location of this ray

addAutoTraceRay

public void addAutoTraceRay(java.lang.String id,
                            Vector3d direction,
                            int length,
                            boolean bFastTrace,
                            boolean bFloorCorrection,
                            boolean bTraceActors)
Adds a new ray to auto ray tracing rays set. If automatic ray tracing will be enabled, each ray in this set will be cast (natively in UT) each synchronous batch and the response will come through ATR synchronous GameBots messsages (in Pogamut class AutoTraceRay() class). Each ray has its Id used to change its parameters, its direction, lenght and three boolean variables. Each ray is casted from actual bot location and this cannot be changed. To start automatic ray casting (each synchronous batch) use command enableAutoTracign() or send INIT message with proper parameters (AutoTrace true).

Parameters:
id - String id of this ray, used to change its parameters or delete it
direction - vector direction of this ray (1,0,0) for straight ahead, (0,1,0) for 90 degrees right, etc. The vector does not have to be normalized.
length - length of the ray in UT units. One character in UT is approximately 200 UT units long.
bFastTrace - true if we want to use FastTrace function for this ray cast (faster, but only world geometry can be traced)
bFloorCorrection - if true the rays direction will be adjusted according to floor normal. So if we will climb a hill, the rays will adjust to the steepnes of the hill.
bTraceActors - if true and bFastTrace set to true, also dynamic items in the map will be traced (other players and items)

changeAutoTraceRay

public void changeAutoTraceRay(java.lang.String id,
                               Vector3d direction,
                               int length,
                               boolean bFastTrace,
                               boolean bFloorCorrection,
                               boolean bTraceActors)
To change the ray it is sufficient to call addAutoTraceRay function with proper Id. This function is here to tell this information.

Parameters:
id - String id of this ray, used to change its parameters or delete it
direction - vector direction of this ray (1,0,0) for straight ahead, (0,1,0) for 90 degrees right, etc. The vector does not have to be normalized.
length - length of the ray in UT units. One character in UT is approximately 200 UT units long.
bFastTrace - true if we want to use FastTrace function for this ray cast (faster, but only world geometry can be traced)
bFloorCorrection - if true the rays direction will be adjusted according to floor normal. So if we will climb a hill, the rays will adjust to the steepnes of the hill.
bTraceActors - if true and bFastTrace set to true, also dynamic items in the map will be traced (other players and items)

addDefaultAutoTraceRays

public void addDefaultAutoTraceRays()
This command removes all existing auto trace rays and adds a default auto trace rays set. This set consists of three rays: first ray with Id StraghtAhead (direction (1,0,0), length 250 UT units), second ray with Id 45toLeft (direction (1,-1,0), length 200 UT units) and third ray with Id 45toRight (direction (1,1,0), length 200 UT units). All rays will be set with FastTrace to false, TraceActors to false and FloorCorrection to false. To start automatic ray casting (each synchronous batch) use command enableAutoTracign().


removeAutoTraceRay

public void removeAutoTraceRay(java.lang.String id)
Remove one autoTraceRay with desired id from the list. The ray will be deleted And no longer visualized in the environment.

Parameters:
id - id of the ray we want to delete

removeAllAutoTraceRays

public void removeAllAutoTraceRays()
Removes all autoTraceRays. The rays will be deleted and no longer visualized in the environment.


enableAutoTracing

public void enableAutoTracing()
Enables auto trace rays. This means that each time GameBots synchronous batch arrives, the rays will be casted and the results will be a part of this synchronous batch (ATR messages, in Pogamut AutoTraceRay() class). To get these results register listener to AutoTraceRays() class.


disableAutoTracing

public void disableAutoTracing()
Disables auto trace rays. This means that auto trace rays messages (AutoTraceRay() class) will no longer be a part of GameBots synchronous batch and the rays won't be casted. However the rays won't be deleted.