X3D Model Documentation: MaterialModulatorExamples.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
  3  <X3D profile='Immersive' version='3.3 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.3.xsd'>
  4       <head>
  5            <meta name='titlecontent=' MaterialModulatorExamples.x3d '/>
  6            <meta name='descriptioncontent='Demonstrate multiple instances of an external prototype.'/>
  7            <meta name='hintcontent='Learning suggestion for authors: try changing the modulation script so that it goes from [0 ... 1] and then [1 ... 0] alternating, rather than abruptly shifting from 1 immediately back to 0.'/>
  8            <meta name='creatorcontent='Don Brutzman'/>
  9            <meta name='createdcontent='7 September 2017'/>
 10            <meta name='modifiedcontent='2 January 2025'/>
 11            <meta name='subjectcontent='X3D prototype instances DEF USE'/>
 12            <meta name='Imagecontent='MaterialModulator.png'/>
 13            <meta name='Imagecontent='MaterialModulatorExamples.png'/>
 14            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorExamples.x3d '/>
 15            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 16            <meta name='licensecontent='../license.html'/>
 17       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: EventToggler, MaterialModulatorInstance, ModulatingBoxShape, TextAppearance, TouchTextInterface

Index for ExternProtoDeclare definition: MaterialModulator
-->
 18       <Scene>
 19            <WorldInfo title='MaterialModulatorExamples.x3d'/>
 20            <ExternProtoDeclare name='MaterialModulatorappinfo='mimic a Material node and modulate the diffuseColor field as an animation effect' documentation='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html'   url=' "MaterialModulator.x3d#MaterialModulator" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulator.x3d#MaterialModulator" '>
 21                 <field name='enabledtype='SFBoolaccessType='inputOutput'
                appinfo='default value true'/>
 22                 <field name='diffuseColortype='SFColoraccessType='inputOutput'
                appinfo='default value 0.8 0.8 0.8'/>
 23                 <field name='emissiveColortype='SFColoraccessType='inputOutput'
                appinfo='default value 0 0 0'/>
 24                 <field name='specularColortype='SFColoraccessType='inputOutput'
                appinfo='default value 0 0 0'/>
 25                 <field name='transparencytype='SFFloataccessType='inputOutput'
                appinfo='default value 0.0'/>
 26                 <field name='shininesstype='SFFloataccessType='inputOutput'
                appinfo='default value 0.2'/>
 27                 <field name='ambientIntensitytype='SFFloataccessType='inputOutput'
                appinfo='default value 0.2'/>
 28            </ExternProtoDeclare>
 29            <!-- Rendered geometry for the ProtoInstance now follows external prototype declaration -->
 30            <Transform rotation='-0.8 0.93923 0.18785 5.759586translation='-2 1 0'>
 31                 <Shape DEF='ModulatingBoxShape'>
 32                      <Box/>
 33                      <Appearance>
 34 
                         <!-- ProtoInstance MaterialModulatorInstance is a DEF node that has 1 USE node: USE_1
                         <!-- ROUTE information for MaterialModulatorInstance node:  [from EventToggler.toggle to enabled ] -->
                         <ProtoInstance name='MaterialModulatorDEF='MaterialModulatorInstancecontainerField='material'>
 35                                <fieldValue name='enabledvalue='true'/>
 36                                <fieldValue name='diffuseColorvalue='0.5 0.1 0.1'/>
 37                                <!-- fieldValue declarations for other Material attributes can appear here -->
 38                           </ProtoInstance>
 39                      </Appearance>
 40                 </Shape>
 41            </Transform>
 42            <Transform rotation='1 0 0 0.523599translation='2 1 0'>
 43                 <Shape>
 44                      <Cylinder/>
 45                      <Appearance>
 46                           <!-- note that ProtoInstance USE does not require name='MaterialModulator' -->
 47                           <ProtoInstance USE='MaterialModulatorInstancecontainerField='material'/>
 48                      </Appearance>
 49                 </Shape>
 50            </Transform>
 51            <Transform translation='-2 3.5 0'>
 52                 <Shape>
 53                      <Text string='"DEF original"'>
 54                           <FontStyle family='"SANS"justify='"MIDDLE" "MIDDLE"size='0.5style='BOLD'/>
 55                      </Text>
 56 
                    <!-- Appearance TextAppearance is a DEF node that has 2 USE nodes: USE_1, USE_2 -->
                    <Appearance DEF='TextAppearance'>
 57                           <Material diffuseColor='0.9 0.9 0.9'/>
 58                      </Appearance>
 59                 </Shape>
 60            </Transform>
 61            <Transform translation='2 3.5 0'>
 62                 <Shape>
 63                      <Text string='"USE copy"'>
 64                           <FontStyle family='"SANS"justify='"MIDDLE" "MIDDLE"size='0.5style='BOLD'/>
 65                      </Text>
 66                      <Appearance USE='TextAppearance'/>
 67                 </Shape>
 68            </Transform>
 69            <Transform translation='0 -2 0'>
 70                 <Shape>
 71                      <Text string=' "enable/disable" "MaterialModulator" '>
 72                           <FontStyle family='"SANS"justify='"MIDDLE" "MIDDLE"style='BOLD'/>
 73                      </Text>
 74                      <Appearance USE='TextAppearance'/>
 75                 </Shape>
 76                 <!-- Selectable Text design pattern has transparent Box and TouchSensor description as a tooltip -->
 77                 <Shape>
 78                      <Box size='8 2 .001'/>
 79                      <Appearance>
 80                           <Material transparency='1'/>
 81                      </Appearance>
 82                 </Shape>
 83                 <!-- Toggle text to enable/disable MaterialModulator -->
 84 
               <!-- ROUTE information for TouchTextInterface node:  [from isActive to EventToggler.set_boolean ] -->
               <TouchSensor DEF='TouchTextInterfacedescription='Select text to enable/disable MaterialModulator'/>
 85 
               <!-- ROUTE information for EventToggler node:  [from TouchTextInterface.isActive to set_boolean ] [from toggle to MaterialModulatorInstance.enabled ] -->
               <BooleanToggle DEF='EventTogglercontainerField='children'/>
 86                 < ROUTE  fromNode='TouchTextInterface' fromField='isActive' toNode='EventToggler' toField='set_boolean'/>
 87                 < ROUTE  fromNode='EventToggler' fromField='toggle' toNode='MaterialModulatorInstance' toField='enabled'/>
 88            </Transform>
 89       </Scene>
 90  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: EventToggler, MaterialModulatorInstance, ModulatingBoxShape, TextAppearance, TouchTextInterface

Index for ExternProtoDeclare definition: MaterialModulator
-->
X3D Tooltips element index: Appearance, BooleanToggle, Box, Cylinder, ExternProtoDeclare, field, fieldValue, FontStyle, head, Material, meta, ProtoInstance, ROUTE, Scene, Shape, Text, TouchSensor, Transform, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and field types

Event Graph ROUTE Table entries with 2 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.

TouchTextInterface
TouchSensor
isActive
SFBool

ROUTE
event to
(1)
EventToggler
BooleanToggle
set_boolean
SFBool
then
 
 
 
EventToggler
BooleanToggle
toggle
SFBool

ROUTE
event to
(2)
MaterialModulatorInstance
ProtoInstance
enabled
SFBool

      MaterialModulatorInstance
ProtoInstance
MaterialModulator
No direct ROUTE connection found for events to/from this node.
This ProtoInstance contains SFNode/MFNode fieldValue declarations with
direct access to other nodes, and thus has potential to produce run-time animation. 

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/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorExamplesIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorExamples.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. -->