mil.navy.nps.dis
Class EspduTransform

java.lang.Object
  |
  +--vrml.BaseNode
        |
        +--vrml.node.Script
              |
              +--mil.navy.nps.dis.EspduTransform
All Implemented Interfaces:
NetworkCommBadge, PduSubscriber

public class EspduTransform
extends Script
implements PduSubscriber, NetworkCommBadge

This Java class provides the communicatons interface between the EspduTransform Script node (in the VRML scene) and the rest of the DIS class library used for entities.

Version:
1.2
Author:
Don Brutzman (http://web.nps.navy.mil/~brutzman) This code includes parts of Kent Watsen's EAI-based World.java/Ownship.java and Don McGregors's testing/BehaviorStreamBufferTest.java
Location:
EspduTransform.java
web.nps.navy.mil/~brutzman/vrtp/mil/navy/nps/dis/EspduTransform.java
www.web3D.org/WorkingGroups/vrtp/mil/navy/nps/dis/EspduTransform.java
Hierarchy Diagram:
History:
1 February 2000 Olivier Doucy, Don Brutzman added timestamp as an eventOut
3 September 99 Don Brutzman added rtpEnabled boolean flag
19 June 99 Don Brutzman Removed articulationParameterValue15 to stay within VRML browser conformance limit of 25 eventOuts
1 June 99 Don Brutzman, Quay Jones Added detonated and detonateTime
18 May 99 Don Brutzman, Quay Jones Changed fired to fired1 and fired2 in VRML scene to enable primary and secondary weapons.
6 Apr 99 Don Brutzman Adding ArticulatedParameter eventOuts, shutdown, various thread/trace fixes. Ignore received PDUs when sending. Changed MFVec3f LineOfFirePointArray code to SFVec3f's munitionStartPoint & munitionEndPoint for run-time reliability.
20 Feb 99, 14 Mar 99 Don Brutzman, Don McGregor, Bill Bohman Added collided, active, fired, multicastRelayHost, multicastRelayPort. Also added FirePdu geometry to show munitions. Incorporated entityDispatcher.checkForTrafficAndFallBackToTunnel (...) for automatic unicast connectivity when multicast is not locally available.
6 Feb 99 Don Brutzman Move VRML EspduTransformPROTO to same directory as dis package
Fix write capability
02 Dec 98 Scott Heller Added smoothing. See SmoothingDesign.pdf
25 Oct 98 Don Brutzman Javadoc updates for jdk1.2b4
Restructure classes, move EspduTransform to dis package
12 Feb 98 Don Brutzman changes for documentation templates + complements in documentation
5 Feb 98 Don McGregor changes for multiple entities, using EntityDispatcher
1 Aug 97 Don Brutzman New

Associated VRML Files:
EspduTransformPROTO.wrl (PROTO definition)
EspduTransformEXAMPLE.wrl (Example Use)

Entity coordinate systems (right-hand rule applies):

          DIS                 VRML

      -Z entity up         Y entity up
           ^                   ^
           |                   |
           |                   |
           |                   |
           +------> X          +-------> X    nose of entity body
          /                   /
         /                   /
        /                   /
       Y                   Z
         right-hand side
         of entity body

  Rotation angle axes (right-hand rule applies):

           DIS        VRML      Angle of rotation

  Roll      X          X         phi
  Pitch     Y          Z        theta
  Yaw       Z         -Y         psi
Unfinished business:
Need to verify PDU identity and match that given in scene? (already done by EntityDispatcher)
Need to verify Euler angle order & quaternion conversion
Is there another callback alternative to trigger processEvent originating from DIS rather than VRML? Apparently not... readPdu and writePdu events generated by read/write TimeSensors adjacent to the Script node trigger this script's processEvent script.
Is VRML timeSensor processEvent trigger best? Likely so, since it ensures VRML scene redraw doesn't undergo starvation, and it also prevents "simultaneous" data access/modification of Transform node values by VRML browser/Java script.
Exercise clock synchronization or relative local time? dead reckon interval is currently estimated by accumulating the number of seconds since the last pdu update.
Add official DIS algorithms for dead-reckoning.

Debugging notes:
System.out.println text appears on WorldView's VRML console
or on the Netscape Java console when using CosmoPlayer
See Also:
EntityDispatcher, BehaviorStreamBuffer, RunningAverage, CollisionPdu, DetonationPdu, EntityStatePdu, FirePdu

Field Summary
protected  SFInt32 articulationParameterCount
           
protected  SFFloat articulationParameterValue0
           
protected  SFFloat articulationParameterValue1
           
protected  SFFloat articulationParameterValue10
           
protected  SFFloat articulationParameterValue11
           
protected  SFFloat articulationParameterValue12
           
protected  SFFloat articulationParameterValue13
           
protected  SFFloat articulationParameterValue14
           
protected  SFFloat articulationParameterValue2
           
protected  SFFloat articulationParameterValue3
           
protected  SFFloat articulationParameterValue4
           
protected  SFFloat articulationParameterValue5
           
protected  SFFloat articulationParameterValue6
           
protected  SFFloat articulationParameterValue7
           
protected  SFFloat articulationParameterValue8
           
protected  SFFloat articulationParameterValue9
           
protected  Browser browser
           
protected  boolean DEBUG
          When DEBUG is true, console text messages trace the internals of script operation.
protected  float DR_LIMIT
           
protected static EntityDispatcher entityDispatcher
           
protected static java.lang.Thread entityDispatcherThread
           
protected  EntityStatePdu espdu
           
protected  Timer localFireTimer1
           
protected  Timer localFireTimer2
           
protected  int MAX_ARTICULATION_PARAMETERS
           
protected  SFVec3f munitionEndPoint
          munitionEndPoint is node's field (hook to VRML scene) computed from FirePdu matching detonation point of munition.
protected  SFVec3f munitionStartPoint
          munitionStartPoint is node's field (hook to VRML scene) obtained from FirePdu matching launch point of munition.
protected  ProtocolDataUnit pdu
           
protected  float SMOOTH_LIMIT
          what portion of an averageupdateTime should we smooth for? For example 0.5 will cause the the smoothing algorithm to reaquire the most recent DR track with in half the PDU averageUpdateTime.
protected  SecurityStrategy strategy
          Get platform-specific security strategy
 
Constructor Summary
EspduTransform()
          Constructor that includes setting security permissions since Internet Explorer will throw a com.ms.security.SecurityExceptionEx if initialize () is called from an external source (i.e.
 
Method Summary
protected  void debug(java.lang.String pDiagnostic)
          Debugging output routine.
 boolean getDEBUG()
          Access DEBUG trace variable.
 boolean getDoNotSmooth()
          Get Smoothing flag.
 EntityID getEntityIDObject()
          gets the entity ID, which is the unique triplet that identifies the entity, consisting of (site, application, entity) ID numbers.
 java.lang.String getName()
          Simple name for the ESPDU is the marking field.
 void initialize()
          initialize () gets needed information for setup from the invoking scene entity and VRML browser, and also prints the values if DEBUG is true.
static void main(java.lang.String[] args)
          main method was originally intended to be used for debugging, to determine if EntityDispatcher really is sending things to us.
 void processEvent(Event event)
          This is the main method, called by the VRML scene with periodicity readInterval (or writeInterval).
 void receivePDU(ProtocolDataUnit pPDU)
          receivePDU () is called by the entity dispatcher when a PDU for the node arrives from the network.
 void setDEBUG(boolean pDEBUG)
          Modify DEBUG trace variable.
 void setDoNotSmooth(boolean pDoNotSmooth)
          Set Smoothing flag.
 void setEntityIDObject(EntityID pEIO)
          resets the entity ID triplet = (site, application, entity) ID numbers.
 void shutdown()
          shutdown() is called when VRML scene exits.
 void startEntityDispatcherThread()
          Simple method to launch thread because Microsoft puts security restraints on everything.
 boolean toggleSmoothing()
          Turn Smoothing on or off.
protected  void trace(java.lang.String pDiagnostic)
          Guaranteed trace output routine.
 
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

entityDispatcher

protected static EntityDispatcher entityDispatcher

entityDispatcherThread

protected static java.lang.Thread entityDispatcherThread

browser

protected Browser browser

pdu

protected ProtocolDataUnit pdu

espdu

protected EntityStatePdu espdu

MAX_ARTICULATION_PARAMETERS

protected final int MAX_ARTICULATION_PARAMETERS

articulationParameterCount

protected SFInt32 articulationParameterCount

articulationParameterValue0

protected SFFloat articulationParameterValue0

articulationParameterValue1

protected SFFloat articulationParameterValue1

articulationParameterValue2

protected SFFloat articulationParameterValue2

articulationParameterValue3

protected SFFloat articulationParameterValue3

articulationParameterValue4

protected SFFloat articulationParameterValue4

articulationParameterValue5

protected SFFloat articulationParameterValue5

articulationParameterValue6

protected SFFloat articulationParameterValue6

articulationParameterValue7

protected SFFloat articulationParameterValue7

articulationParameterValue8

protected SFFloat articulationParameterValue8

articulationParameterValue9

protected SFFloat articulationParameterValue9

articulationParameterValue10

protected SFFloat articulationParameterValue10

articulationParameterValue11

protected SFFloat articulationParameterValue11

articulationParameterValue12

protected SFFloat articulationParameterValue12

articulationParameterValue13

protected SFFloat articulationParameterValue13

articulationParameterValue14

protected SFFloat articulationParameterValue14

SMOOTH_LIMIT

protected final float SMOOTH_LIMIT
what portion of an averageupdateTime should we smooth for? For example 0.5 will cause the the smoothing algorithm to reaquire the most recent DR track with in half the PDU averageUpdateTime.

DR_LIMIT

protected final float DR_LIMIT

munitionStartPoint

protected SFVec3f munitionStartPoint
munitionStartPoint is node's field (hook to VRML scene) obtained from FirePdu matching launch point of munition.

munitionEndPoint

protected SFVec3f munitionEndPoint
munitionEndPoint is node's field (hook to VRML scene) computed from FirePdu matching detonation point of munition.

strategy

protected SecurityStrategy strategy
Get platform-specific security strategy

DEBUG

protected boolean DEBUG
When DEBUG is true, console text messages trace the internals of script operation.

localFireTimer1

protected Timer localFireTimer1

localFireTimer2

protected Timer localFireTimer2
Constructor Detail

EspduTransform

public EspduTransform()
Constructor that includes setting security permissions since Internet Explorer will throw a com.ms.security.SecurityExceptionEx if initialize () is called from an external source (i.e. the IE browser) and security isn't already set up. Reference: Code Signing for Java Applets by Daniel Griscom, griscom@suitable.com at http://www.suitable.com/CodeSigningCodeExp.shtml
Method Detail

toggleSmoothing

public boolean toggleSmoothing()
Turn Smoothing on or off. Returns the new state of DoNotSmooth.

getDoNotSmooth

public boolean getDoNotSmooth()
Get Smoothing flag.

setDoNotSmooth

public void setDoNotSmooth(boolean pDoNotSmooth)
Set Smoothing flag.

getDEBUG

public boolean getDEBUG()
Access DEBUG trace variable.

setDEBUG

public void setDEBUG(boolean pDEBUG)
Modify DEBUG trace variable.

debug

protected void debug(java.lang.String pDiagnostic)
Debugging output routine. Pass in a string, and it gets printed out on the console. You can pass in strings such as "foo " + bar.getName(). Text output appears in the Java Console (CosmoPlayer browser) or in the VRML console (WorldView browser).

trace

protected void trace(java.lang.String pDiagnostic)
Guaranteed trace output routine. Pass in a string, and it gets printed out on the console. You can pass in strings such as "foo " + bar.getName(). Text output appears in the Java Console (CosmoPlayer browser) or in the VRML console (WorldView browser).

Can't be static or all entities look the same.


getName

public java.lang.String getName()
Simple name for the ESPDU is the marking field.

initialize

public void initialize()
initialize () gets needed information for setup from the invoking scene entity and VRML browser, and also prints the values if DEBUG is true. For a good initialize () discussion, see example 3.15, pp. 95-97, "Java for 3D and VRML Worlds," Lea/Matsuda/Miyashita, New Riders Press, 1996.
Overrides:
initialize in class Script

startEntityDispatcherThread

public void startEntityDispatcherThread()
Simple method to launch thread because Microsoft puts security restraints on everything.

EntityDispatcher is static; only one copy is shared between all instances of the EspduTransform. If it's null the first time through here, create and thread it.

This is synchronized, since we may have N EspduTransforms attempting to instantiate themselves at once, all accessing this shared class variable. The synchronization prevents multiple access.

This is actually some magic code. Java keeps several mutex locks around, one for every instance of a class and one for the class itself. We can't sychronize on entityDispatcher because that's null the first time through, which will fail silently. We also can't use a java primitive type. So I created a completely arbitrary instance of an object as a class variable, and synchronize on that. It's a standin for the EntityDispatcher in a way.


receivePDU

public void receivePDU(ProtocolDataUnit pPDU)
receivePDU () is called by the entity dispatcher when a PDU for the node arrives from the network. The PDU is added to the list of PDUs that have already arrived, and is later sent up to the 3D scene graph when processEvent() is called by the VRML scene.
Specified by:
receivePDU in interface PduSubscriber

getEntityIDObject

public EntityID getEntityIDObject()
gets the entity ID, which is the unique triplet that identifies the entity, consisting of (site, application, entity) ID numbers. This is set in the VRML node, and retrieved for use here.

setEntityIDObject

public void setEntityIDObject(EntityID pEIO)
resets the entity ID triplet = (site, application, entity) ID numbers.

processEvent

public void processEvent(Event event)
This is the main method, called by the VRML scene with periodicity readInterval (or writeInterval).
Overrides:
processEvent in class Script

shutdown

public void shutdown()
shutdown() is called when VRML scene exits.
Overrides:
shutdown in class Script

main

public static void main(java.lang.String[] args)
main method was originally intended to be used for debugging, to determine if EntityDispatcher really is sending things to us.

Sigh. We can't actually use main(), since that's declared in Script, and we can't override static methods. So as an alternative we rename this something else and then call it from another class that can have a main method. Reverify that this block of code is correct if you do resurrect it.