Interface

ButtonTemplate {
    eventIn     SFBool      set_enabled
    field       SFNode      activeAppearance        NULL
    field       SFNode      activeGeometry          NULL
    field       SFNode      activeOverAppearance    NULL
    field       SFNode      activeOverGeometry      NULL
    field       SFNode      appearance              NULL
    field       SFNode      disabledAppearance      NULL
    field       SFNode      disabledGeometry        NULL
    field       SFBool      enabled                 TRUE
    field       SFNode      geometry                NULL
    field       SFNode      overAppearance          NULL
    field       SFNode      overGeometry            NULL
    eventOut    SFBool      enabled_changed
    eventOut    SFBool      isActive
    eventOut    SFBool      isOver
    eventOut    SFTime      pressedTime
}

Description

The button is an instantiation of a ButtonTemplate. Push it to make the sphere… um… “boing.”
ButtonTemplate Preview

ButtonTemplate simply provides button logic along with the ability to change appearance and geometry depending on whether the pointer is over the button, the button is active (that is, the button has been pressed, but the button on the pointing device has not been released), or the button is disabled.

Use of the ButtonTemplate does not require that different geometries be specified for all states. If no change is desired, simply USE a node given for an existing state:

ButtonTemplate {
    appearance
        DEF APPEARANCE Appearance {
            material
                Material {
                    diffuseColor 0.8 0.0 0.0
                }
        }
    overAppearance
        USE APPEARANCE
    .
    .
    .
}

Download