<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN" "https://www.web3d.org/specifications/x3d-3.2.dtd">
<X3D profile='Immersive' version='3.2' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.2.xsd'>
  <head>
    <meta content='PoolMontereyPeninsulaCollegeUsingBoxes.x3d' name='title'/>
    <meta content='Monterey Peninsula College (MPC) swimming pool, simplest model' name='description'/>
    <meta content='Don Brutzman and MV3204 class' name='creator'/>
    <meta content='9 April 2010' name='created'/>
    <meta content='2 December 2024' name='modified'/>
    <meta content='Includes trace diagnostic for changing user navigation from EXAMINE to FLY when binding/unbinding the initial overhead-perspective Viewpoint' name='info'/>
    <meta content='TODO information about ROV races' name='reference'/>
    <meta content='PoolMontereyPeninsulaCollegeSketch' name='drawing'/>
    <meta content='PoolMontereyPeninsulaCollegeDiagram.png' name='Image'/>
    <meta content='PoolMontereyPeninsulaCollegeDiagram.vsd' name='Image'/>
    <meta content='TODO photo(s) of pool' name='photo'/>
    <meta content='X3D swimming pool' name='subject'/>
    <meta content='under development' name='warning'/>
    <meta content='PoolMontereyPeninsulaCollege.x3d' name='reference'/>
    <meta content='https://www.web3d.org/x3d/content/examples/Savage/Locations/MontereyPeninsulaCollege/PoolMontereyPeninsulaCollegeUsingBoxes.x3d' name='identifier'/>
    <meta content='X3D-Edit, https://www.web3d.org/x3d/tools/X3D-Edit' name='generator'/>
    <meta content='../../license.html' name='license'/>
  </head>
  <Scene>
    <!-- Put CoordinateAxes with correct directional alignment at pool origin -->
    <WorldInfo title='PoolMontereyPeninsulaCollegeUsingBoxes.x3d'/>
    <Inline DEF='CoordinateAxes' url='"../../Tools/Authoring/CoordinateAxes.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/CoordinateAxes.x3d" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.x3d" "../../Tools/Authoring/CoordinateAxes.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/CoordinateAxes.wrl" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.wrl"'/>
    <!-- Only one NavInfo can be bound at a time. Include "ANY" to allow user override. -->
    <!-- Note that our local units here are still meters. -->
    <NavigationInfo DEF='NavigationExamineMode' avatarSize='0.25 1.6 2' speed='5' type='"EXAMINE" "FLY" "ANY"'/>
    <NavigationInfo DEF='NavigationWalkMode' avatarSize='0.25 1.6 2' speed='5' type='"WALK" "ANY"'/>
    <NavigationInfo DEF='NavigationFlyMode' avatarSize='0.25 1.6 2' speed='5' type='"FLY" "ANY"'/>
    <!-- TODO add a deck around the edge of the pool to allow WALKing around -->
    <!-- All pool model measurements are in feet, therefore scale them into meters. X is length, Y is height, Z is width. -->
    <Transform DEF='ScaleFeetToMeters' scale='0.305 0.305 0.305'>
      <!-- Box centers are at local coordinate 0 0 0, this translation shifts them to put corner at pool coordinate 0 0 0 -->
      <!-- Viewpoints are placed here since their position is recorded in feet using the pool coordinate system -->
      <Viewpoint DEF='ViewOverhead' centerOfRotation='37.5 0 32' description='High above looking down from 100 feet above' orientation='1 0 0 -1.5708' position='37.5 100 32'/>
      <ROUTE fromField='isBound' fromNode='ViewOverhead' toField='set_bind' toNode='NavigationExamineMode'/>
      <Group>
        <!-- ======= ROUTE Trace ============================================== -->
        <Script DEF='Trace_ROUTE_ViewOverhead_isBound_TO_NavigationExamineMode_set_bind' mustEvaluate='true'>
          <!-- Trace ROUTEd values on X3D browser console -->
          <field accessType='initializeOnly' appinfo='Sampling frequency in seconds (0 means all values)' name='reportInterval' type='SFTime' value='1.0'/>
          <field accessType='inputOutput' name='traceValue' type='SFBool' value='true'/>
          <field accessType='initializeOnly' name='timeStampPreviousReport' type='SFTime' value='-1'/>
          <![CDATA[
ecmascript:
    function set_traceValue (eventValue, timeStamp)
    {
        Browser.println ('Script method set_traceValue invoked, which is now handing off to traceValueHandler()...');
        traceValueHandler (eventValue, timeStamp);
    }
    function traceValue (eventValue, timeStamp)
    {
        Browser.println ('Script method traceValue invoked, which is now handing off to traceValueHandler()...');
        traceValueHandler (eventValue, timeStamp);
    }
    function traceValueHandler (eventValue, timeStamp)
    {
      // input eventValue received for trace field
      if (timeStamp - timeStampPreviousReport >= reportInterval) {
        Browser.println ('Trace_ROUTE_ViewOverhead_isBound_TO_NavigationExamineMode_set_bind type=SFBool value=' + eventValue);
        timeStampPreviousReport = timeStamp;
        if  (eventValue == true)
             Browser.println ('User navigation should be EXAMINE');
        else Browser.println ('User navigation should be FLY');
      }
    }
    function timeOfDay (someTime) {
      hh = Math.floor (someTime /(60*60)) % 24;
      mm = Math.floor (someTime / 60)     % 60;
      ss = Math.floor (someTime)          % 60;
      if (hh < 9) hour   = '0' + hh;
      else        hour   =       hh;
      if (mm < 9) minute = '0' + mm;
      else        minute =       mm;
      if (ss < 9) second = '0' + ss;
      else        second =       ss;
      return '(' + hour + ':' + minute + ':' + second + ' GMT)';
    }
]]>
        </Script>
        <ROUTE fromField='isBound' fromNode='ViewOverhead' toField='traceValue' toNode='Trace_ROUTE_ViewOverhead_isBound_TO_NavigationExamineMode_set_bind'/>
        <!-- ======= ROUTE Trace block complete ===================================================== -->
      </Group>
      <!-- other Viewpoints do not get EXAMINE navigation type -->
      <Viewpoint description='Shallow end left side, from origin' orientation='0.0067 0.9998 0.0161 -2.3563' position='-12 6 -12'/>
      <Viewpoint description='Pool center left side' orientation='0 0.9955 0.0949 3.1413' position='37.52 10 -20'/>
      <Viewpoint description='Deep end left side' orientation='-0.0203 0.9988 0.0451 2.2984' position='87 6 -12'/>
      <Viewpoint description='Deep end center' orientation='-0.0857 0.9926 0.0857 1.5782' position='95 10 32'/>
      <Viewpoint description='Deep end right side' orientation='-0.1001 0.994 0.0449 0.8487' position='87 6 76'/>
      <Viewpoint description='Pool center right side' orientation='-1 0.002 0.0002 0.2235' position='37.52 10 84'/>
      <Viewpoint description='Shallow end right side' orientation='0.1001 0.994 0.0449 -0.8487' position='-12 6 76'/>
      <Viewpoint description='Shallow end center' orientation='0.0864 0.99251 0.0864 -1.578318' position='-20 10 32'/>
      <Transform DEF='ShiftBoxCornersToPoolCenter' translation='37.5 -12.75 32'>
        <Shape DEF='PoolFloor'>
          <Box size='75 0.25 64'/>
          <Appearance DEF='AppearanceWall'>
            <Material diffuseColor='0.5 0.9 0.9'/>
          </Appearance>
        </Shape>
        <Transform DEF='ShallowWall' translation='-37.5 6.25 0'>
          <Shape DEF='ShortWall'>
            <Box size='0.25 12.75 64'/>
            <Appearance USE='AppearanceWall'/>
          </Shape>
        </Transform>
        <Transform DEF='DeepWall' translation='37.5 6.25 0'>
          <Shape USE='ShortWall'/>
        </Transform>
        <Transform DEF='LeftWall' translation='0 6.25 -32'>
          <Shape DEF='LongWall'>
            <Box size='75 12.75 0.25'/>
            <Appearance USE='AppearanceWall'/>
          </Shape>
        </Transform>
        <Transform DEF='RightWall' translation='0 6.25 32'>
          <Shape USE='LongWall'/>
        </Transform>
        <Transform DEF='DeepFloor' rotation='0 0 1 0.1732' translation='32.5 .9 0'>
          <Shape>
            <Box size='10.152 0.25 64'/>
            <Appearance USE='AppearanceWall'/>
          </Shape>
        </Transform>
        <Transform DEF='DeepFloor2' rotation='0 0 1 -0.2085' translation='21 1.4 0'>
          <Shape>
            <Box size='13.288 0.25 64'/>
            <Appearance USE='AppearanceWall'/>
          </Shape>
        </Transform>
        <Transform DEF='DeepFloor3' rotation='0 0 1 -0.2783' translation='7.5 4.75 0'>
          <Shape>
            <Box size='14.560 0.25 64'/>
            <Appearance USE='AppearanceWall'/>
          </Shape>
        </Transform>
        <Transform DEF='DeepFloor4' rotation='0 0 1 -0.0476' translation='-10 7.25 0'>
          <Shape>
            <Box size='21.024 0.25 64'/>
            <Appearance USE='AppearanceWall'/>
          </Shape>
        </Transform>
        <Transform DEF='DeepFloor5' rotation='0 0 1 -0.0588' translation='-29 8.25 0'>
          <Shape>
            <Box size='17.029 0.25 64'/>
            <Appearance USE='AppearanceWall'/>
          </Shape>
        </Transform>
      </Transform>
    </Transform>
  </Scene>
</X3D>