X3D Model Documentation: X3DRetreatProtoExercise.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='X3DRetreatProtoExercise.x3d'/>
  6            <meta name='creatorcontent='Don Brutzman'/>
  7            <meta name='createdcontent='25 May 2000'/>
  8            <meta name='modifiedcontent='20 October 2019'/>
  9            <meta name=' error content=' Contains multiple intentional warnings and errors, for validation testing purposes. '/>
 10            <meta name='descriptioncontent='Solutions to the Proto Exercise posed by Chris Marrin of SONY at the May 2000 X3D Retreat. This exercise includes intentionally illegal VRML and does not render.'/>
 11            <meta name='referencecontent='https://www.web3d.org/x3d/sony/X3DRetreatProtoEx.html'/>
 12            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/development/X3DRetreatProtoExercise.x3d'/>
 13            <meta name='generatorcontent='X3D-Edit 3.1, https://www.web3d.org/x3d/content/README.X3D-Edit.html'/>
 14            <meta name='licensecontent='../license.html'/>
 15       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: AnimatedMaterialInitialize, CI, G, GG, M, MM, OI, RENDERscript, T, timeBase, TS

Index for ProtoDeclare definitions: AnimatedMaterial, BSPLeaf, BSPLeaf, MyProto, PhysicalMaterial, Plane, SpinGroup
-->
 16       <Scene>
 17            <!-- ============= Example 1 ============= -->
 18            <!-- GeometryNode and ChildNode are not valid node types, so used type Node/Nodes instead. -->
 19            <!-- Note exercise example is incomplete and has no node(s) defined for body content. -->
 20            <!-- X3D DTD can correctly detect these content errors if they occur, scene will be well-formed but not valid. -->
 21            <ProtoDeclare name='MyProto'>
 22                 <ProtoInterface>
 23                      <field name='geometrytype='SFNodevalue='NULLaccessType='initializeOnly'/>
 24                      <field name='childrentype='MFNodevalue='NULLaccessType='initializeOnly'/>
 25                 </ProtoInterface>
 26                 <ProtoBody>
 27                      <WorldInfo info='"Added this node as PROTO body, so that the example can be valid VRML"'/>
 28                 </ProtoBody>
 29            </ProtoDeclare>
 30            <!-- ============= Example 2 ============= -->
 31            <!-- Adding new fields to an existing node. -->
 32            <!-- Corrected example by moving Material from PROTO interface to PROTO body. -->
 33            <ProtoDeclare name='PhysicalMaterial'>
 34                 <ProtoInterface>
 35                      <field name='masstype='SFFloatvalue='1accessType='inputOutput'/>
 36                      <field name='hardnesstype='SFFloatvalue='1accessType='initializeOnly'/>
 37                      <field name='frictiontype='SFFloatvalue='1accessType='initializeOnly'/>
 38                 </ProtoInterface>
 39                 <ProtoBody>
 40                      <Material DEF='M'/>
 41                      <!-- EXPORT M (this is Blendo nomenclature, not VRML 97) -->
 42                 </ProtoBody>
 43            </ProtoDeclare>
 44            <!-- ============= Example 3a ============= -->
 45            <!-- Consider new possibility of declaring a field PROTO. -->
 46            <!-- Again no body provided in this example (since goal is a new FieldPROTO construct). -->
 47            <ProtoDeclare name='Plane'>
 48                 <ProtoInterface>
 49                      <!-- FIELDPROTO -->
 50                      <field name='normaltype='SFVec3fvalue='0 0 1accessType='initializeOnly'/>
 51                      <field name='distancetype='SFFloatvalue='0accessType='initializeOnly'/>
 52                 </ProtoInterface>
 53                 <ProtoBody>
 54                      <WorldInfo info='"Added this node as PROTO body, so that the example can be valid VRML"'/>
 55                 </ProtoBody>
 56            </ProtoDeclare>
 57            <!-- ============= Example 3b ============= -->
 58            <!-- Example 3b employs the supposed field PROTO. -->
 59            <!-- X3D DTD currently restricts field types to VRML 97 types, and so flags these untyped fields as an error. -->
 60            <!-- We could allow unspecified field types, but would lose checking (and authoring suggestions) on existing types. -->
 61            <ProtoDeclare name='BSPLeaf'>
 62                 <ProtoInterface>
 63                      <!-- Intentionally invalid type values used. -->
 64                      <field name='planetype='Planevalue='0 0 1 0accessType='initializeOnly'/>
 65                      <field name='fronttype='BSPLeafvalue='NULLaccessType='initializeOnly'/>
 66                      <field name='backtype='BSPLeafvalue='NULLaccessType='initializeOnly'/>
 67                      <field name='childrentype='MFNodevalue='NULLaccessType='initializeOnly'/>
 68                 </ProtoInterface>
 69                 <ProtoBody>
 70                      <WorldInfo info='"Added this node as PROTO body, so that the example can be valid VRML"'/>
 71                 </ProtoBody>
 72            </ProtoDeclare>
 73            <!-- ============= Example 4 ============= -->
 74            <!-- PROTO with routes. Example nodes moved from interface definition to body. -->
 75            <ProtoDeclare name='SpinGroup'>
 76                 <ProtoInterface>
 77                      <!-- Example 4 calls three of the field references ROUTEs, but they actually match VRML 97 'IS' statements. IS="TS.cycleInterval" IS="TS.startTime" IS="TS.stopTime" -->
 78                      <field name='speedtype='SFTimevalue='1accessType='initializeOnly'/>
 79                      <field name='startTimetype='SFTimevalue='0accessType='initializeOnly'/>
 80                      <field name='stopTimetype='SFTimevalue='0accessType='initializeOnly'/>
 81                 </ProtoInterface>
 82                 <ProtoBody>
 83                      <!-- Corrected example by moving nodes T, G, TS and OI from PROTO interface to PROTO body. -->
 84 
                    <!-- ROUTE information for T node:  [from OI.value_changed to set_rotation ] -->
                    <Transform DEF='T'>
 85                           <!-- EXPORT G (this is Blendo nomenclature, not VRML 97) -->
 86                           <Group DEF='G'/>
 87                      </Transform>
 88 
                    <!-- ROUTE information for TS node:  [from fraction_changed to OI.set_fraction ] -->
                    <TimeSensor DEF='TSloop='true'/>
 89 
                    <!-- ROUTE information for OI node:  [from TS.fraction_changed to set_fraction ] [from value_changed to T.set_rotation ] -->
                    <OrientationInterpolator DEF='OIkey='0 0.25 0.5 0.75 1keyValue='0 1 0 0 0 1 0 1.57 0 1 0 3.14 0 1 0 4.71 0 1 0 0'/>
 90                      < ROUTE  fromNode='TS' fromField='fraction_changed' toNode='OI' toField='set_fraction'/>
 91                      < ROUTE  fromNode='OI' fromField='value_changed' toNode='T' toField='set_rotation'/>
 92                 </ProtoBody>
 93            </ProtoDeclare>
 94            <!-- ============= Example 5 ============= -->
 95            <!-- Show "overriding of a method of the inherited interface." -->
 96            <!-- X3D DTD currently restricts field types to VRML 97 types, other values can be entered but are flagged as invalid. IS="RENDERscript.plane" IS="RENDERscript.front" IS="RENDERscript.back" -->
 97            <ProtoDeclare name='BSPLeaf'>
 98                 <ProtoInterface>
 99                      <field name='planetype='Planevalue='0 0 1 0accessType='initializeOnly'/>
100                      <field name='fronttype='BSPLeafvalue='NULLaccessType='initializeOnly'/>
101                      <field name='backtype='BSPLeafvalue='NULLaccessType='initializeOnly'/>
102                 </ProtoInterface>
103                 <ProtoBody>
104                      <!-- Here is a curious example problem: an unattached function overriding an unspecified (but commonly occuring) implementation-specific browser function. -->
105                      <!-- This solution wraps a Script node around the render () function to maintain VRML 97 semantics. -->
106                      <!-- Preprocessing can automate this process of wrapping a Script node around inline functions. -->
107                      <!-- Corrected example by moving Group G (renamed GG) from PROTO interface to PROTO body. -->
108                      <Group DEF='GG'/>
109                      <Script DEF='RENDERscript'>
  <![CDATA[
          
ecmascript:
function render()
{
 var result = plane.onPlane(System.sceneManager.getCameraPos());
 if (result < 0) {
  front.render();
  G.render();
  back.render();
 }
 else if (result > 0) {
  back.render();
  G.render();
  front.render();
 }
 else {
  front.render();
  back.render();
 }
}

        
]]>
111                      </Script>
112                 </ProtoBody>
113            </ProtoDeclare>
114            <!-- ============= Example 6 ============= -->
115            <!-- Show "inclusion of field scripts which execute whenever the field receives an event." -->
116            <ProtoDeclare name='AnimatedMaterial'>
117                 <ProtoInterface>
118                      <!-- FROM is Blendo nomenclature, expressed using IS references. IS="timeBase.startTime" IS="timeBase.stopTime" -->
119                      <field name='startTimetype='SFTimevalue='0accessType='initializeOnly'/>
120                      <field name='stopTimetype='SFTimevalue='0accessType='initializeOnly'/>
121                      <field name='startColortype='SFColorvalue='0 0 0accessType='initializeOnly'/>
122                      <field name='endColortype='SFColorvalue='0 0 0accessType='initializeOnly'/>
123                      <!-- During the December 3 1999 x3d-contributors meeting, Chris showed how -->
124                      <!-- the VRML 97 specification allows an SF/MFNode field node to be initialized with node content. -->
125                      <!-- This construct is now permitted by DTD, here is an example: -->
126                      <field name='initializedChildrentype='MFNodeaccessType='initializeOnly'>
127                           <Group bboxCenter='1 2 3'/>
128                           <Transform translation='1 2 3'/>
129                      </field>
130                 </ProtoInterface>
131                 <ProtoBody>
132                      <!-- Moved the following content nodes from PROTO interface to PROTO body in order to match valid VRML 97 content. -->
133 
                    <!-- ROUTE information for MM node:  [from CI.value_changed to set_diffuseColor ] -->
                    <Material DEF='MM'/>
134                      <ProtoInstance name='IntervalSensor'>
135                           <fieldValue name='timeBase'>
136                                <ProtoInstance name='TimeBaseDEF='timeBase'/>
137                           </fieldValue>
138                      </ProtoInstance>
139 
                    <!-- ROUTE information for CI node:  [from value_changed to MM.set_diffuseColor ] -->
                    <ColorInterpolator DEF='CIkey='0 0.5 1'/>
140                      <Script DEF='AnimatedMaterialInitialize'>
  <![CDATA[
          
ecmascript:
{ // simple exercise for reader to initialize/update PROTO field values
  // to the MM Material node.  Be sure to add some IS statements to match.
}

        
]]>
142                      </Script>
143                      < ROUTE  fromNode='CI' fromField='value_changed' toNode='MM' toField='set_diffuseColor'/>
144                 </ProtoBody>
145            </ProtoDeclare>
146       </Scene>
147  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: AnimatedMaterialInitialize, CI, G, GG, M, MM, OI, RENDERscript, T, timeBase, TS

Index for ProtoDeclare definitions: AnimatedMaterial, BSPLeaf, BSPLeaf, MyProto, PhysicalMaterial, Plane, SpinGroup
-->
X3D Tooltips element index: ColorInterpolator, field, fieldValue, Group, head, Material, meta, OrientationInterpolator, ProtoBody, ProtoDeclare, ProtoInstance, ProtoInterface, ROUTE, Scene, Script, TimeSensor, Transform, WorldInfo, X3D, accessType and type, XML data types, field types

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

TS
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
OI
OrientationInterpolator
set_fraction
SFFloat
then
 
 
 
OI
OrientationInterpolator
value_changed
SFRotation

ROUTE
event to
(2)
T
Transform
set_rotation
SFRotation


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

timeBase
ProtoInstance
TimeBase
No ROUTE connection found for output events 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/development/X3DRetreatProtoExerciseIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/development/X3DRetreatProtoExercise.x3d -->

<!-- Color legend: X3D terminology <X3dNode DEF='idName' field='value'/> matches XML terminology <XmlElement DEF='idName' attribute='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. -->