cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric
Class Raycasting

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.agent.module.sensomotoric.Raycasting
All Implemented Interfaces:
IComponent

public class Raycasting
extends SensomotoricModule<UT2004Bot>

Support for creating rays used for raycasting (see AutoTraceRay that is being utilized).

It is designed to be initialized inside IUT2004BotController.initializeController(UT2004Bot) method call and may be used since IUT2004BotController.botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage) is called.


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
Raycasting(UT2004Bot bot)
           
Raycasting(UT2004Bot bot, java.util.logging.Logger log)
           
 
Method Summary
protected  void checkIfAllInited()
          Sets allRaysInitialized flag to true if all rays has been initialized.
protected  void cleanUp()
          Hook where to perform clean up of data structures of the module.
 void clear()
          Deletes all previous rays and makes this instance ready for setting up new rays.
 java.util.concurrent.Future<AutoTraceRay> createRay(java.lang.String Id, Vector3d Direction, int Length, boolean FastTrace, boolean FloorCorrection, boolean TraceActors)
          Initializes ray usind AddRay command and returns future that waits for the first AutoTraceRay message corresponding to this ray.
 java.util.concurrent.Future<AutoTraceRay> createRay(Vector3d Direction, int Length, boolean FastTrace, boolean FloorCorrection, boolean TraceActors)
          Creates ray with system generated id.
 void endRayInitSequence()
          Once all rays were initialized using createRay(...) methods, call this method to start listening for response from UT.
 Flag<java.lang.Boolean> getAllRaysInitialized()
           
 AutoTraceRay getRay(java.lang.String rayID)
          Returns a ray of specified id.
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
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

Raycasting

public Raycasting(UT2004Bot bot)

Raycasting

public Raycasting(UT2004Bot bot,
                  java.util.logging.Logger log)
Method Detail

getAllRaysInitialized

public Flag<java.lang.Boolean> getAllRaysInitialized()

cleanUp

protected void cleanUp()
Description copied from class: AgentModule
Hook where to perform clean up of data structures of the module.

Called from AgentModule.stop(), AgentModule.kill(), AgentModule.reset().

Overrides:
cleanUp in class AgentModule<UT2004Bot>

clear

public void clear()
           throws CommunicationException
Deletes all previous rays and makes this instance ready for setting up new rays.

Throws:
CommunicationException

endRayInitSequence

public void endRayInitSequence()
Once all rays were initialized using createRay(...) methods, call this method to start listening for response from UT.


createRay

public java.util.concurrent.Future<AutoTraceRay> createRay(java.lang.String Id,
                                                           Vector3d Direction,
                                                           int Length,
                                                           boolean FastTrace,
                                                           boolean FloorCorrection,
                                                           boolean TraceActors)
                                                    throws CommunicationException
Initializes ray usind AddRay command and returns future that waits for the first AutoTraceRay message corresponding to this ray.

Parameters:
Id - User set Id of the ray, so the ray can be identified.
Direction - Vector direction of the ray (it will be relative - added to the vector, where the bot is looking, also takes into account angle of the floor the bot is standing on).
Length - Specifies the length of the ray (in UT units).
FastTrace - True if we want to use FastTrace function instead of Trace function (a bit faster but less information provided - just information if we hit something or not).
FloorCorrection - If we should correct ray directions accoring floor normal. Note: Has issue - we can't set set rays up or down when correction is active.
TraceActors - If we want to trace also actors – bots, monsters, players, items. False if we want to trace just level geometry.
Returns:
Throws:
CommunicationException

createRay

public java.util.concurrent.Future<AutoTraceRay> createRay(Vector3d Direction,
                                                           int Length,
                                                           boolean FastTrace,
                                                           boolean FloorCorrection,
                                                           boolean TraceActors)
                                                    throws CommunicationException
Creates ray with system generated id. Note that the ray is not initialized immediately - we have to wait for GB2004 to confirm us. Therefore you will not receive actual instance of AutoTraceRay but its Future. Use method Future.isDone() to check whether the ray was initialized and method Future.get() to obtain the ray instance.

Parameters:
Direction - Vector direction of the ray (it will be relative - added to the vector, where the bot is looking, also takes into account angle of the floor the bot is standing on).
Length - Specifies the length of the ray (in UT units).
FastTrace - True if we want to use FastTrace function instead of Trace function (a bit faster but less information provided - just information if we hit something or not).
FloorCorrection - If we should correct ray directions according floor normal. Note: Has issue - we can't set set rays up or down when correction is active.
TraceActors - If we want to trace also actors, bots, monsters, players, items. False if we want to trace just level geometry.
Returns:
ray's future - use method Future.isDone() to check whether the ray was initialized and method Future.get() to obtain the ray instance
Throws:
cz.cuni.amis.pogamut.base.communication.exceptions.CommunicationException
CommunicationException

getRay

public AutoTraceRay getRay(java.lang.String rayID)
Returns a ray of specified id. If the ray of the specified id does not exist or was not initialized yet then it returns null.

Note that the AutoTraceRay instance is self updating - once obtained you may use it every logic cycle to obtain current readings from the ray.

Parameters:
rayID -
Returns:

checkIfAllInited

protected void checkIfAllInited()
Sets allRaysInitialized flag to true if all rays has been initialized.