Class W3DEnvironment

All Implemented Interfaces:
IW3DEnvironment

public class W3DEnvironment extends Iv4xrEnvironment implements IW3DEnvironment
An extension of Iv4xrEnvironment. It adds methods typical for interacting with a 3D-virtual-world environment. Examples of such an environment are 3D games or simulators. This class provides only a partial implementation of Iv4xrEnvironment. You still need to implement the method sendCommand_(EnvOperation).
Author:
Wish
  • Field Details

    • LOADWORLD_CMDNAME

      public static String LOADWORLD_CMDNAME
    • OBSERVE_CMDNAME

      public static String OBSERVE_CMDNAME
    • MOVETOWARD_CMDNAME

      public static String MOVETOWARD_CMDNAME
    • worldNavigableMesh

      protected Mesh worldNavigableMesh
      A polygon-mesh describing the navigable surface of the 3D-world represented by this environment.
  • Constructor Details

    • W3DEnvironment

      public W3DEnvironment()
  • Method Details

    • worldNavigableMesh

      public Mesh worldNavigableMesh()
      Return the polygon-mesh describing the navigable surface of the 3D-world represented by this environment. This is the mesh stored in worldNavigableMesh.
      Overrides:
      worldNavigableMesh in class Iv4xrEnvironment
    • interact

      public WorldModel interact(String agentId, String targetId, String interactionType)
      Execute an interaction of the specified type on the given target entity in the real environment. The parameter interactionType is a string specifying the name of the interaction to do, e.g. "Open" or "TurnOn". This string should not be the same command names that are already pre-defined by this class, such as OBSERVE_CMDNAME. This method has no further argument to send to the real environment. The method should return a new observation by the specified agent, sampled after the interaction.
      Specified by:
      interact in interface IW3DEnvironment
      Parameters:
      agentId - The id of the agent that does the interaction.
      targetId - The id of the entity that is the target of the interaction.
    • observe

      public WorldModel observe(String agentId)
      Send a command to the real environment that will cause it to send back what the agent of the given id observes in the real environment. The observation will be parsed into an instance of WorldModel.
      Overrides:
      observe in class Iv4xrEnvironment
      Parameters:
      agentId - The id of the agent whose observation is requested.
      Returns:
      An instance of WorldModel representing what the specified agent observes.
    • moveToward

      public WorldModel moveToward(String agentId, Vec3 agentLocation, Vec3 targetLocation)
      A command to instruct an agent to move a small distance towards the given target location. How far the agent actually moves depends on the real environment. Typically, the calling agent will execute interactions/commands in update cycles. Then it depends on how fast time proceeds in the real environment as we advance from one agent's update-cycle to the next. A possible setup is to make the real environment to run in sync with the agent's cycles and to fix the simulated time between cycles, e.g. 1/30-th second. In this case, the agent will then move to some distance of the specified velocity/30. The method should return a new observation, sampled at the end of its movement.
      Specified by:
      moveToward in interface IW3DEnvironment
    • loadWorld

      public void loadWorld()
      Send a command to the real environment that should cause it to send over the navigation-mesh of its 3D world. This mesh is assumed to be static (does not change through out the agents' runs).
      Specified by:
      loadWorld in interface IW3DEnvironment
    • sendCommand_

      protected Object sendCommand_(Environment.EnvOperation cmd)
      You need to implement this method. There are a number of pre-defined command names, namely: cmd.command is LOADWORLD_CMDNAME: this should ask the real-environment to send back an navigation-mesh. This method should package it as an instance of Mesh and return it. cmd.command is OBSERVE_CMDNAME: this should ask the real-environment to send over the observation of agent cmd.invokerId. This method should package the result as an instance of WorldModel and return it. cmd.command is MOVETOWARD_CMDNAME: this should ask the real-environment to move its entity/agent cmd.invokerId in the direction specified by cmd.arg. This method should also obtain the observation of the said agent at the end of the move, and package the observation as an instance of WorldModel and return it. cmd.command has other values: this should ask the real-environment to apply an interaction by the agent cmd.invokerId on the entity specified by cmd.targetId, and with interaction type specified by cmd.command (e.g. "OPEN" or "CLOSE"). This method should also obtain the observation of the said agent at the end of the interaction, and package the observation as an instance of WorldModel and return it.
      Overrides:
      sendCommand_ in class Environment
      Parameters:
      cmd - representing the command to send to the real environment.
      Returns:
      an object that the real environment sends back as the result of the command, if any. If the cmd specifies what the expected type of the returned object, then this method should guarantee that the returned object is indeed an instance of the specified type.