demo.rraBattleScene
Class BattleScene

java.lang.Object
  |
  +--vrml.BaseNode
        |
        +--vrml.node.Script
              |
              +--demo.rraBattleScene.BattleScene
All Implemented Interfaces:
Timed

public class BattleScene
extends Script
implements Timed

Version:
1.0
Author:
LT Timothy M. Holliday ( http://www.stl.nps.navy.mil/~auv/holliday)
Location:
http://www.stl.nps.navy.mil/dis-java-vrml/mil/navy/nps/rra/BattleScene.java
Summary:
Interfaces between the browser and pinserver. This script also provides for platform mobility and controls all timing of the interactions between ping requests, VRML returns and platform movement.
Explanation:
A VRML world is in essence a static world, with some basic movements. To be able to emulate more real world processes the VRML world needs to have a script connection to a program running outside of the VRML rendering engine, that is running in the browsers virtual machine. This program is that extension of a particular VRML world. It also provides network connections to a sonar ping server runing on a separate computer. This network connection is provided since both rendering VRML and calculating real-time sonar are computationally intensive. Thus, the two functions are distributed two two machines over the net.

History:
15Jan98 /Timothy M. Holliday /New
17Mar98 /Timothy M. Holliday /Added HTML comment convention
See Also:
BridgeServer, PingServer

Field Summary
(package private)  MFNode addBeamChildren
           
(package private)  MFNode addChildren
           
(package private)  SFVec3f beamTranslation
           
(package private)  SFRotation beamYaw
           
 boolean createVRMLThreadRunning
           
static float DETECT_BEAM
           
static float DETECT_BOTH
           
static float DETECT_TARGETS
           
static java.lang.String HOST
           
(package private)  java.io.DataInputStream in
           
(package private)  BaseNode[] nodes
           
(package private)  java.io.DataOutputStream out
           
(package private)  ControlPanel panel
           
static int PORT
           
(package private)  MFNode removeBeamChildren
           
(package private)  MFNode removeChildren
           
static float SET_SONAR_PARAMETERS
           
(package private)  java.net.Socket socket
           
(package private)  SFVec3f translation
           
(package private)  SFRotation yaw
           
 
Constructor Summary
BattleScene()
           
 
Method Summary
 void AddBeamChildren(BaseNode[] nodes)
          This method adds the beam VRML to the scene graph
 void AddTargetsChildren(BaseNode[] nodes)
          This method adds the target VRML to the scene graph
 void initialize()
          This method initializes the Java script.
 void processEvent(Event ev)
          This method processes events generated by the VRML Browser.
 void removeBeam()
          This method decides whiche beam VRML to remove from the scene graph
 void RemoveBeamChildren(BaseNode[] nodes)
          This method removes the beam VRML from the scene graph
 void RemoveTargetsChildren(BaseNode[] nodes)
          This method removes the target VRML from the scene graph
 void setManeuver(float d, float s, float c)
          This method is called by the control panel to set the requested maneuver in BattleScene.
 void setSonarParameters(float elevation, float azimuth, float verticalBeamWidth, float horizontalBeamWidth, float verticalBeamConfiguration, float horizontalBeamConfiguration, float verticalSearchWidth, float horizontalSearchWidth, float pingI, float powerLevel)
          This method is called by the control panel to set the requested sonar ping inn BattleScene.
 void shutdown()
          This method cleans up memory and closes sockets at shutdown
 void sonarDetection(float order)
          This method is called from the control panel to initiate a sonar ping.
 void tick(TimerThread t)
          This method receives ticks from TimerThread and updates vehicle position in the VRML scene.
 void waitOnThreads()
          This method is called by sonarDetection to decide if another sonar request can be made.
 
Methods inherited from class vrml.node.Script
eventsProcessed, getEventIn, getEventOut, getField, processEvents, toString
 
Methods inherited from class vrml.BaseNode
getBrowser, getType
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

panel

ControlPanel panel

addChildren

MFNode addChildren

removeChildren

MFNode removeChildren

addBeamChildren

MFNode addBeamChildren

removeBeamChildren

MFNode removeBeamChildren

beamTranslation

SFVec3f beamTranslation

yaw

SFRotation yaw

translation

SFVec3f translation

beamYaw

SFRotation beamYaw

nodes

BaseNode[] nodes

PORT

public static final int PORT

HOST

public static final java.lang.String HOST

SET_SONAR_PARAMETERS

public static final float SET_SONAR_PARAMETERS

DETECT_TARGETS

public static final float DETECT_TARGETS

DETECT_BEAM

public static final float DETECT_BEAM

DETECT_BOTH

public static final float DETECT_BOTH

socket

java.net.Socket socket

in

java.io.DataInputStream in

out

java.io.DataOutputStream out

createVRMLThreadRunning

public boolean createVRMLThreadRunning
Constructor Detail

BattleScene

public BattleScene()
Method Detail

initialize

public void initialize()
This method initializes the Java script. It establishes connections to the browser, the control panel, the timer and to BridgeServer.
Overrides:
initialize in class Script

tick

public void tick(TimerThread t)
This method receives ticks from TimerThread and updates vehicle position in the VRML scene.
Specified by:
tick in interface Timed

processEvent

public void processEvent(Event ev)
This method processes events generated by the VRML Browser. When the VRML world is entered, an 'entered' event is sent out and this event handler processes it and starts the whole simulation in motion.
Overrides:
processEvent in class Script

shutdown

public void shutdown()
This method cleans up memory and closes sockets at shutdown
Overrides:
shutdown in class Script

setManeuver

public void setManeuver(float d,
                        float s,
                        float c)
This method is called by the control panel to set the requested maneuver in BattleScene.

setSonarParameters

public void setSonarParameters(float elevation,
                               float azimuth,
                               float verticalBeamWidth,
                               float horizontalBeamWidth,
                               float verticalBeamConfiguration,
                               float horizontalBeamConfiguration,
                               float verticalSearchWidth,
                               float horizontalSearchWidth,
                               float pingI,
                               float powerLevel)
This method is called by the control panel to set the requested sonar ping inn BattleScene.

waitOnThreads

public void waitOnThreads()
This method is called by sonarDetection to decide if another sonar request can be made. Another sonar request cannot be made if the threads for adding VRML beams and targets are still alive. When the threads die this indicates that the VRML has been added to the scene graph and another request can be made.

sonarDetection

public void sonarDetection(float order)
This method is called from the control panel to initiate a sonar ping. When a ping is recieved and the required threads die a new sonar request is made and the corresponding VRML is received.

AddBeamChildren

public void AddBeamChildren(BaseNode[] nodes)
This method adds the beam VRML to the scene graph

removeBeam

public void removeBeam()
This method decides whiche beam VRML to remove from the scene graph

RemoveBeamChildren

public void RemoveBeamChildren(BaseNode[] nodes)
This method removes the beam VRML from the scene graph

AddTargetsChildren

public void AddTargetsChildren(BaseNode[] nodes)
This method adds the target VRML to the scene graph

RemoveTargetsChildren

public void RemoveTargetsChildren(BaseNode[] nodes)
This method removes the target VRML from the scene graph