X3D Model Documentation: DvdControllerExample.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2 
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
  3  <X3D profile='Immersive' version='3.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'>
  4       <head>
  5            <meta name='titlecontent=' DvdControllerExample.x3d '/>
  6            <meta name='descriptioncontent="Digital Virtual Display (DVD) Controller interface example to control a scenario's animation timing, defined using an ExternProtoDeclare for easy reuse."/>
  7            <meta name='creatorcontent='Jane Wu, Don Brutzman'/>
  8            <meta name='createdcontent='10 November 2001'/>
  9            <meta name='modifiedcontent='5 March 2024'/>
 10            <meta name='subjectcontent='DvdController animation control'/>
 11            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/DvdControllerExample.x3d '/>
 12            <meta name='generatorcontent='X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit'/>
 13            <meta name='licensecontent='../../license.html'/>
 14       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: actual_time_changed, DvdControllerInterface, FractionConverter, FractionText, SecondsConverter, SecondsElapsedText, TimeText, TimeTextScript

Index for ExternProtoDeclare definitions: DvdController, SingleTypeConversion
-->
 15       <Scene>
 16            <WorldInfo title='DvdControllerExample.x3d'/>
 17            <ExternProtoDeclare name='DvdControllerappinfo='Digital Virtual Display (DVD) Controller Prototype is a heads=up display (HUD) to control animation timing'   url=' "DvdControllerPrototype.x3d#DvdController" "../../../Savage/Tools/HeadsUpDisplays/DvdControllerPrototype.x3d#DvdController" "https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/DvdControllerPrototype.x3d#DvdController" "DvdControllerPrototype.wrl#DvdController" "../../../Savage/Tools/HeadsUpDisplays/DvdControllerPrototype.wrl#DvdController" "https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/DvdControllerPrototype.wrl#DvdController" '>
 18                 <field name='descriptiontype='SFStringaccessType='initializeOnly'
                appinfo='Short description of what is animated by this DvdController.'/>
 19                 <field name='playEnabledtype='SFBoolaccessType='initializeOnly'
                appinfo='Whether or not play mode is enabled including during startup.'/>
 20                 <field name='displayModetype='SFStringaccessType='initializeOnly'
                appinfo='Initializes how control buttons and slider are displayed. The control buttons include DIS control (i.e. Master Ghost Local) and Playback control (i.e. Reset to Start Fast Rewind Rewind Pause Play Fast Forward Reset to End). Possible values are (case sensitive): ALL DIS_ONLY PLAYBACK_ONLY SLIDER_ONLY DIS_PLAYBACK DIS_SLIDER PLAYBACK_SLIDER and NONE.'/>
 21                 <field name='setDisplayModetype='SFStringaccessType='inputOnly'
                appinfo='Sets how control buttons and slider are displayed. The control buttons include DIS control (i.e. Master Ghost Local) and Playback control (i.e. Reset to Start Fast Rewind Rewind Pause Play Fast Forward Reset to End). Possible values are (case sensitive): ALL DIS_ONLY PLAYBACK_ONLY SLIDER_ONLY DIS_PLAYBACK DIS_SLIDER PLAYBACK_SLIDER and NONE.'/>
 22                 <field name='buttonColortype='SFColoraccessType='initializeOnly'
                appinfo='Default button color.'/>
 23                 <field name='selectedButtonColortype='SFColoraccessType='initializeOnly'
                appinfo='Button color when selected by user.'/>
 24                 <field name='labelColortype='SFColoraccessType='initializeOnly'
                appinfo='Default label color.'/>
 25                 <field name='selectedLabelColortype='SFColoraccessType='initializeOnly'
                appinfo='Label color when selected by user.'/>
 26                 <field name='locationOffsettype='SFVec3faccessType='initializeOnly'
                appinfo='Modified screen location and distance (for size).'/>
 27                 <field name='clockEnabledtype='SFBoolaccessType='initializeOnly'/>
 28                 <field name='cycleIntervaltype='SFTimeaccessType='initializeOnly'
                appinfo='Time for complete loop cycle in seconds.'/>
 29                 <field name='set_cycleIntervaltype='SFTimeaccessType='inputOnly'/>
 30                 <field name='cycleInterval_changedtype='SFTimeaccessType='outputOnly'/>
 31                 <field name='speedFactortype='SFFloataccessType='initializeOnly'
                appinfo='Factor used to determine the speed increase/decrease for Fast Rewind and Fast Forward action.'/>
 32                 <field name='isActivetype='SFBoolaccessType='outputOnly'/>
 33                 <field name='startTime_changedtype='SFTimeaccessType='outputOnly'/>
 34                 <field name='stopTime_changedtype='SFTimeaccessType='outputOnly'/>
 35                 <field name='time_changedtype='SFTimeaccessType='outputOnly'/>
 36                 <field name='fraction_changedtype='SFFloataccessType='outputOnly'/>
 37                 <field name='secondsElapsedtype='SFTimeaccessType='outputOnly'/>
 38                 <field name='isMastertype='SFBoolaccessType='outputOnly'
                appinfo='isMaster isRemote and isLocal are booleans represent a 3-way toggle. Only one of them can have a true value at any time.'/>
 39                 <field name='isRemotetype='SFBoolaccessType='outputOnly'
                appinfo='isMaster isRemote and isLocal are booleans represent a 3-way toggle. Only one of them can have a true value at any time.'/>
 40                 <field name='isLocaltype='SFBoolaccessType='outputOnly'
                appinfo='isMaster isRemote and isLocal are booleans represent a 3-way toggle. Only one of them can have a true value at any time.'/>
 41                 <field name='isPausedtype='SFBoolaccessType='outputOnly'
                appinfo='isPaused and isRunning always have opposite values. When isPaused is true isRunning will be false and vice versa.'/>
 42                 <field name='isRunningtype='SFBoolaccessType='outputOnly'
                appinfo='isPaused and isRunning always have opposite values. When isPaused is true isRunning will be false and vice versa.'/>
 43                 <field name='traceEnabledtype='SFBoolaccessType='initializeOnly'
                appinfo='Enable/disable console output for troubleshooting.'/>
 44                 <field name='testTimeValtype='SFTimeaccessType='initializeOnly'/>
 45            </ExternProtoDeclare>
 46            <ExternProtoDeclare name='SingleTypeConversionappinfo='SingleTypeConversion converts from a single typed value to various other types of values'   url=' "../../../Savage/Tools/Authoring/SingleTypeConversionPrototype.x3d#SingleTypeConversion" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/SingleTypeConversionPrototype.x3d#SingleTypeConversion" "../../../Savage/Tools/Authoring/SingleTypeConversionPrototype.wrl#SingleTypeConversion" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/SingleTypeConversionPrototype.wrl#SingleTypeConversion" '>
 47                 <field name='decimalPlacestype='SFInt32accessType='initializeOnly'
                appinfo='decimalPlaces is the number of significant digits after the decimal point. The -1 value indicates no round off.'/>
 48                 <field name='setDecimalPlacestype='SFInt32accessType='inputOnly'/>
 49                 <field name='BooleanValuetype='SFBoolaccessType='inputOnly'/>
 50                 <field name='FloatValuetype='SFFloataccessType='inputOnly'/>
 51                 <field name='IntegerValuetype='SFInt32accessType='inputOnly'/>
 52                 <field name='TimeValuetype='SFTimeaccessType='inputOnly'/>
 53                 <field name='BooleanResulttype='SFBoolaccessType='outputOnly'/>
 54                 <field name='FloatResulttype='SFFloataccessType='outputOnly'/>
 55                 <field name='IntegerResulttype='SFInt32accessType='outputOnly'/>
 56                 <field name='TimeResulttype='SFTimeaccessType='outputOnly'/>
 57                 <field name='StringResulttype='SFStringaccessType='outputOnly'/>
 58                 <field name='StringsResulttype='MFStringaccessType='outputOnly'/>
 59            </ExternProtoDeclare>
 60            <!-- ============================== -->
 61            <Transform>
 62 
               <!-- ROUTE information for DvdControllerInterface node:  [from time_changed to TimeTextScript.setCurrentTime ] [from fraction_changed to FractionConverter.FloatValue ] [from secondsElapsed to SecondsConverter.TimeValue ] -->
               <ProtoInstance name='DvdControllerDEF='DvdControllerInterface'>
 63                      <fieldValue name='displayModevalue='PLAYBACK_SLIDER'/>
 64                      <fieldValue name='playEnabledvalue='true'/>
 65                      <fieldValue name='buttonColorvalue='0.655 0.655 0.655'/>
 66                      <fieldValue name='selectedButtonColorvalue='0.675 0.675 0.675'/>
 67                      <fieldValue name='selectedLabelColorvalue='0.9 0 0'/>
 68                      <fieldValue name='locationOffsetvalue='-5 -2 0'/>
 69                      <fieldValue name='cycleIntervalvalue='10'/>
 70                      <fieldValue name='speedFactorvalue='10.0'/>
 71                      <fieldValue name='traceEnabledvalue='true'/>
 72                 </ProtoInstance>
 73            </Transform>
 74            <Transform translation='-3 0 0'>
 75                 <Transform translation='-5 3 -5'>
 76                      <Shape>
 77                           <Appearance>
 78                                <Material/>
 79                           </Appearance>
 80                           <Text string='"fraction_changed:"'/>
 81                      </Shape>
 82                 </Transform>
 83                 <Transform translation='4 3 -5'>
 84                      <Shape>
 85                           <Appearance>
 86                                <Material/>
 87                           </Appearance>
 88 
                         <!-- ROUTE information for FractionText node:  [from FractionConverter.StringsResult to set_string ] -->
                         <Text DEF='FractionTextstring=' "N/A" '/>
 89                      </Shape>
 90                 </Transform>
 91                 <Transform translation='-5 2 -5'>
 92                      <Shape>
 93                           <Appearance>
 94                                <Material/>
 95                           </Appearance>
 96                           <Text string='"secondsElapsed:"'/>
 97                      </Shape>
 98                 </Transform>
 99                 <Transform translation='4 2 -5'>
100                      <Shape>
101                           <Appearance>
102                                <Material/>
103                           </Appearance>
104 
                         <!-- ROUTE information for SecondsElapsedText node:  [from SecondsConverter.StringsResult to set_string ] -->
                         <Text DEF='SecondsElapsedTextstring=' "N/A" '/>
105                      </Shape>
106                 </Transform>
107                 <Transform translation='-5 1 -5'>
108                      <Shape>
109                           <Appearance>
110                                <Material/>
111                           </Appearance>
112                           <Text DEF='actual_time_changedstring='"local clock time:"'/>
113                      </Shape>
114                 </Transform>
115                 <Transform translation='4 1 -5'>
116                      <Shape>
117                           <Appearance>
118                                <Material/>
119                           </Appearance>
120 
                         <!-- ROUTE information for TimeText node:  [from TimeTextScript.timeText to set_string ] -->
                         <Text DEF='TimeTextstring=' "N/A" '/>
121                      </Shape>
122                 </Transform>
123            </Transform>
124 
          <!-- ROUTE information for TimeTextScript node:  [from DvdControllerInterface.time_changed to setCurrentTime ] [from timeText to TimeText.set_string ] -->
          <Script DEF='TimeTextScript'>
125                 <field name='timetype='SFTimevalue='-1accessType='initializeOnly'/>
126                 <field name='setCurrentTimetype='SFTimeaccessType='inputOnly'/>
127                 <field name='timeTexttype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function initialize ()
{
	tracePrint('initialize () complete');
}
function setCurrentTime(value, timeStamp)
{
	tracePrint('setCurrentTime(' + value + ')');
	myDate = new Date(); // value unused, causes BS Contact fatal error
        if (myDate == null)
        {
            Browser.println ('[DvdControllerExample TimeTextScript] setCurrentTime() error: class Date not supported');
            return;
        }
	numHour   = myDate.getHours();
	numMinute = myDate.getMinutes();
	numSecond = myDate.getSeconds();

	date = myDate.getDate();
	monthNumber = myDate.getMonth();
	year = myDate.getYear() + 1900;

	// javascript switch statement is convenient but not consistently supported, so test the old-fashioned way:
        
        if (monthNumber==0)
	{
            monthText ='January';
	}
        else if (monthNumber==1)
	{
            monthText ='February';
	}
        else if (monthNumber==2)
	{
            monthText ='March';
	}
        else if (monthNumber==3)
	{
            monthText ='April';
	}
        else if (monthNumber==4)
	{
            monthText ='May';
	}
        else if (monthNumber==5)
	{
            monthText ='June';
	}
        else if (monthNumber==6)
	{
            monthText ='July';
	}
        else if (monthNumber==7)
	{
            monthText ='August';
	}
        else if (monthNumber==8)
	{
            monthText ='September';
	}
        else if (monthNumber==9)
	{
            monthText ='October';
	}
        else if (monthNumber==10)
	{
            monthText ='November';
	}
        else if (monthNumber==11)
	{
            monthText ='December';
	}
        else
	{
            monthText ='(illegal month index)';
        }

	if (numHour < 10)
		hour ='0' + numHour;
	else
		hour = numHour;

	if (numMinute < 10)
		minute ='0' + numMinute;
	else
		minute = numMinute;

	numSecond = Math.round(numSecond * 1000.0) / 1000.0;
	if (numSecond < 10)
		second ='0' + numSecond;
	else
		second = numSecond;
	text = hour + ':' + minute + ':' + second + ', ' + date + ' ' + monthText + ' ' + year;
	timeText = new MFString(text);
        //deprecated	timeText = new MFString(myDate.toGMTString());

        tracePrint ('timeText=' + timeText.toString());
}
function tracePrint (text)
{
	if (true) Browser.println ('[DvdControllerExample TimeTextScript] ' + text);
}

    
]]>
129            </Script>
130            < ROUTE  fromNode='DvdControllerInterface' fromField='time_changed' toNode='TimeTextScript' toField='setCurrentTime'/>
131            < ROUTE  fromNode='TimeTextScript' fromField='timeText' toNode='TimeText' toField='set_string'/>
132 
          <!-- ROUTE information for FractionConverter node:  [from DvdControllerInterface.fraction_changed to FloatValue ] [from StringsResult to FractionText.set_string ] -->
          <ProtoInstance name='SingleTypeConversionDEF='FractionConverter'>
133                 <fieldValue name='decimalPlacesvalue='2'/>
134            </ProtoInstance>
135            < ROUTE  fromNode='DvdControllerInterface' fromField='fraction_changed' toNode='FractionConverter' toField='FloatValue'/>
136            < ROUTE  fromNode='FractionConverter' fromField='StringsResult' toNode='FractionText' toField='set_string'/>
137 
          <!-- ROUTE information for SecondsConverter node:  [from DvdControllerInterface.secondsElapsed to TimeValue ] [from StringsResult to SecondsElapsedText.set_string ] -->
          <ProtoInstance name='SingleTypeConversionDEF='SecondsConverter'>
138                 <fieldValue name='decimalPlacesvalue='2'/>
139            </ProtoInstance>
140            < ROUTE  fromNode='DvdControllerInterface' fromField='secondsElapsed' toNode='SecondsConverter' toField='TimeValue'/>
141            < ROUTE  fromNode='SecondsConverter' fromField='StringsResult' toNode='SecondsElapsedText' toField='set_string'/>
142       </Scene>
143  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top DEF nodes index: actual_time_changed, DvdControllerInterface, FractionConverter, FractionText, SecondsConverter, SecondsElapsedText, TimeText, TimeTextScript

Index for ExternProtoDeclare definitions: DvdController, SingleTypeConversion
-->
X3D Tooltips element index: Appearance, ExternProtoDeclare, field, fieldValue, head, Material, meta, ProtoInstance, ROUTE, Scene, Script, Shape, Text, Transform, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and field types

Event Graph ROUTE Table entries with 6 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

      TimeTextScript
Script
timeText
MFString

ROUTE
event to
(1)
TimeText
Text
set_string
MFString

DvdControllerInterface
ProtoInstance
time_changed
SFTime

ROUTE
event to
(1)
TimeTextScript
Script
setCurrentTime
SFTime
then
 
 
 
TimeTextScript
Script
timeText
MFString

ROUTE
event to
(2)
TimeText
Text
set_string
MFString
DvdControllerInterface
ProtoInstance
fraction_changed
SFFloat

ROUTE
event to
(1)
FractionConverter
ProtoInstance
FloatValue
SFFloat
then
 
 
 
FractionConverter
ProtoInstance
StringsResult
MFString

ROUTE
event to
(2)
FractionText
Text
set_string
MFString
DvdControllerInterface
ProtoInstance
secondsElapsed
SFTime

ROUTE
event to
(1)
SecondsConverter
ProtoInstance
TimeValue
SFTime
then
 
 
 
SecondsConverter
ProtoInstance
StringsResult
MFString

ROUTE
event to
(2)
SecondsElapsedText
Text
set_string
MFString

      FractionConverter
ProtoInstance
StringsResult
MFString

ROUTE
event to
(1)
FractionText
Text
set_string
MFString

      SecondsConverter
ProtoInstance
StringsResult
MFString

ROUTE
event to
(1)
SecondsElapsedText
Text
set_string
MFString

Additional guidance on X3D animation can be found in the 10-Step Animation Design Process and Event Tracing hint sheets. Have fun with X3D! 😀

-->
<!-- Online at
https://www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/DvdControllerExampleIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Savage/Tools/HeadsUpDisplays/DvdControllerExample.x3d -->

<!-- Color-coding legend: X3D terminology <X3dNode  DEF='idNamefield='value'/> matches XML terminology <XmlElement  DEF='idNameattribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
    <ProtoInstance name='ProtoName'> <field name='fieldName'/> </ProtoInstance> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->