<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
<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 ' >
<head>
<meta name='titlecontent=' X3DRetreatProtoExercise.x3d '/>
<meta name='creatorcontent='Don Brutzman'/>
<meta name='createdcontent='25 May 2000'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name=' error content=' Contains multiple intentional warnings and errors, for validation testing purposes. '/>
<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.'/>
<meta name='referencecontent=' https://www.web3d.org/x3d/sony/X3DRetreatProtoEx.html '/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/development/X3DRetreatProtoExercise.x3d '/>
<meta name='generatorcontent=' X3D-Edit 3.1, https://www.web3d.org/x3d/content/README.X3D-Edit.html '/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- 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
-->
<Scene>
<!-- ============= Example 1 ============= -->
<!-- GeometryNode and ChildNode are not valid node types, so used type Node/Nodes instead. -->
<!-- Note exercise example is incomplete and has no node(s) defined for body content. -->
<!-- X3D DTD can correctly detect these content errors if they occur, scene will be well-formed but not valid. -->
<ProtoDeclare name='MyProto'>
<ProtoInterface>
<field name='geometrytype='SFNodevalue='NULLaccessType='initializeOnly'/>
<field name='childrentype='MFNodevalue='NULLaccessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<WorldInfo info='"Added this node as PROTO body, so that the example can be valid VRML"'/>
</ProtoBody>
</ProtoDeclare>
<!-- ============= Example 2 ============= -->
<!-- Adding new fields to an existing node. -->
<!-- Corrected example by moving Material from PROTO interface to PROTO body. -->
<ProtoDeclare name='PhysicalMaterial'>
<ProtoInterface>
<field name='masstype='SFFloatvalue='1accessType='inputOutput'/>
<field name='hardnesstype='SFFloatvalue='1accessType='initializeOnly'/>
<field name='frictiontype='SFFloatvalue='1accessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<Material DEF='M'/>
<!-- EXPORT M (this is Blendo nomenclature, not VRML 97) -->
</ProtoBody>
</ProtoDeclare>
<!-- ============= Example 3a ============= -->
<!-- Consider new possibility of declaring a field PROTO. -->
<!-- Again no body provided in this example (since goal is a new FieldPROTO construct). -->
<ProtoDeclare name='Plane'>
<ProtoInterface>
<!-- FIELDPROTO -->
<field name='normaltype='SFVec3fvalue='0 0 1accessType='initializeOnly'/>
<field name='distancetype='SFFloatvalue='0accessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<WorldInfo info='"Added this node as PROTO body, so that the example can be valid VRML"'/>
</ProtoBody>
</ProtoDeclare>
<!-- ============= Example 3b ============= -->
<!-- Example 3b employs the supposed field PROTO. -->
<!-- X3D DTD currently restricts field types to VRML 97 types, and so flags these untyped fields as an error. -->
<!-- We could allow unspecified field types, but would lose checking (and authoring suggestions) on existing types. -->
<ProtoDeclare name='BSPLeaf'>
<ProtoInterface>
<!-- Intentionally invalid type values used. -->
<field name='planetype='Planevalue='0 0 1 0accessType='initializeOnly'/>
<field name='fronttype='BSPLeafvalue='NULLaccessType='initializeOnly'/>
<field name='backtype='BSPLeafvalue='NULLaccessType='initializeOnly'/>
<field name='childrentype='MFNodevalue='NULLaccessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<WorldInfo info='"Added this node as PROTO body, so that the example can be valid VRML"'/>
</ProtoBody>
</ProtoDeclare>
<!-- ============= Example 4 ============= -->
<!-- PROTO with routes. Example nodes moved from interface definition to body. -->
<ProtoDeclare name='SpinGroup'>
<ProtoInterface>
<!-- 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"
-->

<field name='speedtype='SFTimevalue='1accessType='initializeOnly'/>
<field name='startTimetype='SFTimevalue='0accessType='initializeOnly'/>
<field name='stopTimetype='SFTimevalue='0accessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<!-- Corrected example by moving nodes T, G, TS and OI from PROTO interface to PROTO body. -->
<!-- ROUTE information for T node:  [from OI.value_changed to set_rotation ] -->
<Transform DEF='T'>
<!-- EXPORT G (this is Blendo nomenclature, not VRML 97) -->
<Group DEF='G'/>
</Transform>
<!-- ROUTE information for TS node:  [from fraction_changed to OI.set_fraction ] -->
<TimeSensor DEF='TSloop='true'/>

<!-- 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'/>

< ROUTE  fromNode=' TS' fromField='fraction_changed' toNode=' OI' toField='set_fraction'/>
< ROUTE  fromNode=' OI' fromField='value_changed' toNode=' T' toField='set_rotation'/>
</ProtoBody>
</ProtoDeclare>
<!-- ============= Example 5 ============= -->
<!-- Show "overriding of a method of the inherited interface."
-->

<!-- 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"
-->

<ProtoDeclare name='BSPLeaf'>
<ProtoInterface>
<field name='planetype='Planevalue='0 0 1 0accessType='initializeOnly'/>
<field name='fronttype='BSPLeafvalue='NULLaccessType='initializeOnly'/>
<field name='backtype='BSPLeafvalue='NULLaccessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<!-- Here is a curious example problem: an unattached function overriding an unspecified (but commonly occuring) implementation-specific browser function. -->
<!-- This solution wraps a Script node around the render () function to maintain VRML 97 semantics. -->
<!-- Preprocessing can automate this process of wrapping a Script node around inline functions. -->
<!-- Corrected example by moving Group G (renamed GG) from PROTO interface to PROTO body. -->
<Group DEF='GG'/>
<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();
 }
}

        
]]>
</Script>
</ProtoBody>
</ProtoDeclare>
<!-- ============= Example 6 ============= -->
<!-- Show "inclusion of field scripts which execute whenever the field receives an event."
-->

<ProtoDeclare name='AnimatedMaterial'>
<ProtoInterface>
<!-- FROM is Blendo nomenclature, expressed using IS references. IS="timeBase.startTime"
IS="timeBase.stopTime"
-->

<field name='startTimetype='SFTimevalue='0accessType='initializeOnly'/>
<field name='stopTimetype='SFTimevalue='0accessType='initializeOnly'/>
<field name='startColortype='SFColorvalue='0 0 0accessType='initializeOnly'/>
<field name='endColortype='SFColorvalue='0 0 0accessType='initializeOnly'/>
<!-- During the December 3 1999 x3d-contributors meeting, Chris showed how -->
<!-- the VRML 97 specification allows an SF/MFNode field node to be initialized with node content. -->
<!-- This construct is now permitted by DTD, here is an example: -->
<field name='initializedChildrentype='MFNodeaccessType='initializeOnly'>
<Group bboxCenter='1 2 3'/>
<Transform translation='1 2 3'/>
</field>
</ProtoInterface>
<ProtoBody>
<!-- Moved the following content nodes from PROTO interface to PROTO body in order to match valid VRML 97 content. -->
<!-- ROUTE information for MM node:  [from CI.value_changed to set_diffuseColor ] -->
<Material DEF='MM'/>

<ProtoInstance name='IntervalSensor'>
<fieldValue name='timeBase'>
<ProtoInstance name='TimeBaseDEF='timeBase'/>
</fieldValue>
</ProtoInstance>
<!-- ROUTE information for CI node:  [from value_changed to MM.set_diffuseColor ] -->
<ColorInterpolator DEF='CIkey='0 0.5 1'/>

<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.
}

        
]]>
</Script>
< ROUTE  fromNode=' CI' fromField='value_changed' toNode=' MM' toField='set_diffuseColor'/>
</ProtoBody>
</ProtoDeclare>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- 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
-->

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 from this node.
Contains SFNode/MFNode field with indirect access to other nodes. 


timeBase
ProtoInstance
TimeBase
No ROUTE connection found for output from this node.
Contains SFNode/MFNode field with indirect access to other nodes. 


-->

<!-- 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. -->