X3D Model Documentation: Bounce2.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='Bounce2.x3d'/>
  6            <meta name='descriptioncontent='Bouncing beachball (Java version): this world illustrates the use of a Script node to create a computed animation path. In particular, the Script node uses a Java program script to compute translation values for a vertically bouncing beach ball.'/>
  7            <meta name='creatorcontent='David R. Nadeau'/>
  8            <meta name='translatorcontent='Don Brutzman'/>
  9            <meta name='createdcontent='1 July 1998'/>
 10            <meta name='translatedcontent='2 February 2014'/>
 11            <meta name='modifiedcontent='3 November 2019'/>
 12            <meta name='referencecontent='originals/bounce2.wrl'/>
 13            <meta name='referencecontent='http://www.siggraph.org/s98'/>
 14            <meta name='referencecontent='http://www.siggraph.org/s98/conference/courses/18.html'/>
 15            <meta name='referencecontent='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0457.htm'/>
 16            <meta name='referencecontent='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm'/>
 17            <meta name='referencecontent='https://www.web3d.org/x3d/content/examples/X3dResources.html'/>
 18            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Bounce2.x3d'/>
 19            <meta name='generatorcontent='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/>
 20            <meta name='generatorcontent='X3D-Edit, https://savage.nps.edu/X3D-Edit'/>
 21            <meta name='licensecontent='../license.html'/>
 22       </head>
<!--

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

<!-- to top Index for DEF nodes: Ball, Bouncer, Clock, Palm

Index for Viewpoint node: Viewpoint_1
-->
 23       <Scene>
 24            <!-- http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/bounce2.htm -->
 25            <!-- The bounce path is based upon the projectile motion equation of physics, constrained to create a cyclic bouncing path with a user-selected maximum bounce height. Also, there is no friction, drag, or damping. For an explanation of the script, see 'bounce1.wrl'. -->
 26            <!-- Things to experiment with -->
 27            <!-- Encapsulate the ball, script, timer, and sensors within a PROTO for a new node named "BouncingBall". Then use that new BouncingBall node multiple times to create multiple bouncing balls. Your PROTO interface might look like this: -->
 28            <!-- PROTO BouncingBall [ field SFFloat bounceHeight 2.0 field SFTime cycleInterval 2.0 ] { . . . } -->
 29            <!-- See 'bounce3.wrl', which implements such a PROTO. -->
 30            <!-- - Add a shadow under the bouncing ball. To do this, add a circular, semi-transparent, black shape that doesn't bounce. To make the shadow more realistic, scale the shadow in the X and Z directions, shrinking it as the ball goes up, and increasing it as the ball comes down. You'll need to add another eventOut for the Script node and send an XYZ scaling factor triple out that eventOut. Try the following values for the XYZ scale values: -->
 31            <!-- xzscale = 1.0 - 0.5 * y / bounceHeight; -->
 32            <!-- shadowScale_changed[0] = xzscale; -->
 33            <!-- shadowScale_changed[1] = 1.0; -->
 34            <!-- shadowScale_changed[2] = xzscale; -->
 35            <!-- See 'bounce4.wrl', which implements shadows using the above -->
 36            <!-- - Add a sound to the PROTO so that each time the ball touches the ground, it makes a 'boing' sound. -->
 37            <!-- - When the ball hits the ground, scale the ball slightly so that it appears to squish. -->
 38            <WorldInfo info='"Copyright (c) 1997, David R. Nadeau"title='Bouncing beachball (Java)'/>
 39            <Viewpoint description='Bouncing beachball, Java versionorientation='1.0 0.0 0.0 0.1position='0.0 0.6 8.0'/>
 40            <NavigationInfo headlight='falsespeed='2.0'/>
 41            <DirectionalLight ambientIntensity='0.5direction='0.0 -1.0 -0.5'/>
 42            <Background skyAngle='1.371 1.571skyColor='0.0 0.0 1.0 0.0 0.5 1.0 0.7 0.7 1.0'/>
 43            <Shape>
 44                 <Appearance>
 45                      <TextureTransform scale='10.0 10.0'/>
 46                      <Material/>
 47                      <ImageTexture   url=' "sand.jpg " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/sand.jpg " '/>
 48                 </Appearance>
 49                 <IndexedFaceSet solid='falsecoordIndex='0 1 2 3'>
 50                      <Coordinate point='-50.0 -1.0 50.0 50.0 -1.0 50.0 50.0 -1.0 -50.0 -50.0 -1.0 -50.0'/>
 51                 </IndexedFaceSet>
 52            </Shape>
 53            <Transform translation='-3.0 -1.0 -10.0'>
 54 
               <!-- Group Palm is a DEF node that has 3 USE nodes: USE_1, USE_2, USE_3 -->
               <Group DEF='Palm'>
 55                      <Billboard>
 56                           <Shape>
 57                                <Appearance>
 58                                     <ImageTexture   url=' "palm.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/palm.png " '/>
 59                                </Appearance>
 60                                <IndexedFaceSet solid='falsecoordIndex='0 1 2 3texCoordIndex='0 1 2 3'>
 61                                     <TextureCoordinate point='0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0'/>
 62                                     <Coordinate point='-2.5 0.0 0.0 2.5 0.0 0.0 2.5 11.25 0.0 -2.5 11.25 0.0'/>
 63                                </IndexedFaceSet>
 64                           </Shape>
 65                      </Billboard>
 66                      <Shape>
 67                           <Appearance>
 68                                <Material diffuseColor='0.0 0.0 0.0transparency='0.5'/>
 69                                <ImageTexture   url=' "palmsh.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/palmsh.png " '/>
 70                           </Appearance>
 71                           <IndexedFaceSet solid='falsecoordIndex='0 1 2 3texCoordIndex='0 1 2 3'>
 72                                <TextureCoordinate point='0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0'/>
 73                                <Coordinate point='-2.5 0.05 2.5 2.5 0.05 2.5 2.5 0.05 -2.5 -2.5 0.05 -2.5'/>
 74                           </IndexedFaceSet>
 75                      </Shape>
 76                 </Group>
 77            </Transform>
 78            <Transform scale='0.6 0.6 0.6translation='-5.0 -1.0 -6.0'>
 79                 <Group USE='Palm'/>
 80            </Transform>
 81            <Transform translation='5.0 -1.0 -9.0'>
 82                 <Group USE='Palm'/>
 83            </Transform>
 84            <Transform translation='10.0 -1.0 -15.0'>
 85                 <Group USE='Palm'/>
 86            </Transform>
 87 
          <!-- ROUTE information for Ball node:  [from Bouncer.value_changed to set_translation ] -->
          <Transform DEF='Ball'>
 88                 <Shape>
 89                      <Appearance>
 90                           <TextureTransform scale='2.0 1.0'/>
 91                           <Material ambientIntensity='0.5diffuseColor='1.0 1.0 1.0shininess='0.4specularColor='0.7 0.7 0.7'/>
 92                           <ImageTexture   url=' "beach.jpg " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/beach.jpg " '/>
 93                      </Appearance>
 94                      <Sphere/>
 95                 </Shape>
 96            </Transform>
 97 
          <!-- ROUTE information for Clock node:  [from fraction_changed to Bouncer.set_fraction ] -->
          <TimeSensor DEF='ClockcycleInterval='2.0loop='truestartTime='1.0'/>
 98 
 99                 <field name='value_changedtype='SFVec3faccessType='outputOnly'/>
100                 <field name='bounceHeighttype='SFFloatvalue='3.0accessType='initializeOnly'/>
101                 <field name='set_fractiontype='SFFloataccessType='inputOnly'/>
102            </Script>
103            < ROUTE  fromNode='Clock' fromField='fraction_changed' toNode='Bouncer' toField='set_fraction'/>
104            < ROUTE  fromNode='Bouncer' fromField='value_changed' toNode='Ball' toField='set_translation'/>
105       </Scene>
106  </X3D>
<!--

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

<!-- to top Index for DEF nodes: Ball, Bouncer, Clock, Palm

Index for Viewpoint node: Viewpoint_1
-->
X3D Tooltips element index: Appearance, Background, Billboard, Coordinate, DirectionalLight, field, Group, head, ImageTexture, IndexedFaceSet, Material, meta, NavigationInfo, ROUTE, Scene, Script, Shape, Sphere, TextureCoordinate, TextureTransform, TimeSensor, Transform, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, 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.

Clock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
Bouncer
Script
set_fraction
SFFloat
then
 
 
 
Bouncer
Script
value_changed
SFVec3f

ROUTE
event to
(2)
Ball
Transform
set_translation
SFVec3f

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/Vrml2Sourcebook/Siggraph98Course/Bounce2Index.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Bounce2.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)
-->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->