InitialObjectDescriptor {
 objectDescriptorID 1
 audioProfileLevelIndication 254
 visualProfileLevelIndication 254
 sceneProfileLevelIndication 254
 graphicsProfileLevelIndication 254
 ODProfileLevelIndication 254
 esDescr [
  ES_Descriptor {
   ES_ID 1
   decConfigDescr DecoderConfigDescriptor {
    streamType 3
    decSpecificInfo BIFSConfig {
     isCommandStream true
     pixelMetric true
     pixelWidth 200
     pixelHeight 200
    }
   }
  }
 ]
}

OrderedGroup {
 children [
  Background2D {
   backColor 1 1 1
  }
  WorldInfo {
   info [   
    "This test shows how a TouchSensor node and a TimeSensor can be used to make a new Event called MoveOver, which is TRUE when the mouse moves over a Shape or FALSE when the mouse has not moved over the Shape for a certain period of time." 
    "This is an example to show how new events can be created based on existing tools and events (no scripting). This particular event simulates the Lingo MouseWithin event. "
    ""
    "GPAC Regression Tests" "$Date: 2007-07-27 09:46:07 $ - $Revision: 1.2 $" 
    "(C) 2002-2006 GPAC Team"
   ]
   title "Move Over"
  }
  Transform2D {
   children [
    Shape {
     appearance Appearance {
      material DEF M Material2D {
       emissiveColor 1 0 0
       filled TRUE
      }
     }
     geometry Rectangle {
      size 100 100
     }
    }
    DEF TS TouchSensor {}
   ]
  }
  DEF V_ISOVER_TO_FACTOR Valuator {
  }
  DEF V_HITPOINT_CHANGED_TO_ONE Valuator {
    Factor1 0
    Offset1 1
  }
  DEF DUMMY_TIMER TimeSensor { enabled FALSE }  
  DEF T TimeSensor {
    cycleInterval 1
    loop TRUE
    startTime -1
  }
  DEF STOP_TIME_OFFSETER Valuator { Offset1 0.1 } # minimum duration between two mouse move
  
  DEF START_TIMER Conditional {
    buffer {
        REPLACE DUMMY_TIMER.startTime BY 0
        REPLACE T.startTime BY 0
    }
  }
  DEF VALUATOR Valuator {
  }
  DEF V_MOVE_OVER Valuator {
  }
  DEF OUT Conditional {
    buffer {
        REPLACE T.stopTime BY 0
    }
  }
  DEF C Conditional {
    buffer {
        REPLACE M.emissiveColor BY 0 1 0
    }
  }
  DEF RC Conditional {
    buffer {
        REPLACE M.emissiveColor BY 1 0 0
    }
  }
  Transform2D {
    translation 20 60
    children [
      Transform2D {
        translation -80 0
        children [
          Transform2D {
            translation 0 20
            children [
              Shape {
                appearance DEF TEXT_APP Appearance { material Material2D { emissiveColor 0 0 0 filled TRUE } }
                geometry Text {
                    string "Mouse Over   & "
                    fontStyle DEF TEXT_STYLE FontStyle { size 10 family "SANS" justify ["MIDDLE" "MIDDLE" ] }
                }
              }
            ]
          }
          Shape {
            appearance USE TEXT_APP
            geometry DEF MOUSE_OVER_TEXT Text {
                fontStyle USE TEXT_STYLE 
            }
          }
        ]
      }
      Transform2D {
        translation -10 0
        children [
          Transform2D {
            translation 0 20
            children [
              Shape {
                appearance USE TEXT_APP 
                geometry Text {
                    string [ " Mouse has " " moved recently  =" ]
                    fontStyle USE TEXT_STYLE
                }
              }
            ]
          }
          Shape {
            appearance USE TEXT_APP
            geometry DEF TIMER_STATUS_TEXT Text {
                fontStyle USE TEXT_STYLE 
            }
          }
        ]
      }
      Transform2D {
        translation 60 0
        children [
          Transform2D {
            translation 0 20
            children [
              Shape {
                appearance USE TEXT_APP 
                geometry Text {
                    string [ "Result" "Move Over" ]
                    fontStyle USE TEXT_STYLE 
                }
              }
            ]
          }
          Shape {
            appearance USE TEXT_APP
            geometry DEF RESULT_TEXT Text {
                fontStyle USE TEXT_STYLE 
            }
          }
        ]
      }
    ]
  }
#  Transform2D {
#    translation -60 -80
#    children [
#      Transform2D {
#        translation 0 0
#        children [
#          Transform2D {
#            translation 0 20
#            children [
#              Shape {
#                appearance USE TEXT_APP 
#                geometry Text {
#                    string "Start Time"
#                    fontStyle USE TEXT_STYLE
#                }
#              }
#            ]
#          }
#          Shape {
#            appearance USE TEXT_APP
#            geometry DEF START_TIME_TEXT Text {
#                fontStyle USE TEXT_STYLE 
#            }
#          }
#        ]
#      }
#      Transform2D {
#        translation 60 0
#        children [
#          Transform2D {
#            translation 0 20
#            children [
#              Shape {
#                appearance USE TEXT_APP 
#                geometry Text {
#                    string "Stop Time"
#                    fontStyle USE TEXT_STYLE 
#                }
#              }
#            ]
#          }
#          Shape {
#            appearance USE TEXT_APP
#            geometry DEF STOP_TIME_TEXT Text {
#                fontStyle USE TEXT_STYLE 
#            }
#          }
#        ]
#      }
#    ]
#  }
#  DEF V_START_TIME Valuator {Factor1 100}
#  DEF V_STOP_TIME Valuator {Factor1 100}
 ]
}

# These two routes do the following: 
# read the startTime field of a DUMMY_TIMER (which is equal to NOW because, has been replaced by 0)
# offset this value by the appropriate delay
# set the stoptime value of the real timer
ROUTE DUMMY_TIMER.startTime TO STOP_TIME_OFFSETER.inSFTime
ROUTE STOP_TIME_OFFSETER.outSFTime TO T.stopTime

# This is a route to force the stop of the timer when the mouse exits the shape
ROUTE TS.isOver TO OUT.reverseActivate

# These 2 routes convert the isOver (a boolean) into a float 
# and stores the value in the factor of a valuator
ROUTE TS.isOver TO V_ISOVER_TO_FACTOR.inSFBool
ROUTE V_ISOVER_TO_FACTOR.outSFFloat TO V_MOVE_OVER.Factor1

# Display the status of the IsOver boolean
ROUTE V_ISOVER_TO_FACTOR.outMFString TO MOUSE_OVER_TEXT.string

#These 2 routes create an event (Boolean = TRUE) whenever the mouse moves
#and activates a conditional
ROUTE TS.hitPoint_changed TO V_HITPOINT_CHANGED_TO_ONE.inSFVec3f
ROUTE V_HITPOINT_CHANGED_TO_ONE.outSFBool TO START_TIMER.activate

# When the timer is active, it means the mouse is moving, we route this event to the move_over valuator
ROUTE T.isActive TO V_MOVE_OVER.inSFBool

# Display of the status of the timer
ROUTE T.isActive TO VALUATOR.inSFBool
ROUTE VALUATOR.outMFString TO TIMER_STATUS_TEXT.string

# Trigger one action when the result is TRUE
ROUTE V_MOVE_OVER.outSFBool TO C.activate
# Trigger one action when the result is FALSE
ROUTE V_MOVE_OVER.outSFBool TO RC.reverseActivate

# Display of the final result
ROUTE V_MOVE_OVER.outMFString TO RESULT_TEXT.string

# Display of the startTime of the Timer
#ROUTE T.startTime TO V_START_TIME.inSFTime
#ROUTE V_START_TIME.outMFString TO START_TIME_TEXT.string

# Display of the stopTime of the Timer
#ROUTE T.stopTime TO V_STOP_TIME.inSFTime
#ROUTE V_STOP_TIME.outMFString TO STOP_TIME_TEXT.string