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='title' content='Bounce2.x3d'/> |
6 | <meta name='description' content='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='creator' content='David R. Nadeau'/> |
8 | <meta name='translator' content='Don Brutzman'/> |
9 | <meta name='created' content='1 July 1998'/> |
10 | <meta name='translated' content='2 February 2014'/> |
11 | <meta name='modified' content='3 November 2019'/> |
12 | <meta name='reference' content='originals/bounce2.wrl'/> |
13 | <meta name='reference' content='http://www.siggraph.org/s98'/> |
14 | <meta name='reference' content='http://www.siggraph.org/s98/conference/courses/18.html'/> |
15 | <meta name='reference' content='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0457.htm'/> |
16 | <meta name='reference' content='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm'/> |
17 | <meta name='reference' content='https://www.web3d.org/x3d/content/examples/X3dResources.html'/> |
18 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Bounce2.x3d'/> |
19 | <meta name='generator' content='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/> |
20 | <meta name='generator' content='X3D-Edit, https://savage.nps.edu/X3D-Edit'/> |
21 | <meta name='license' content='../license.html'/> |
22 | </head> |
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 version' orientation='1.0 0.0 0.0 0.1' position='0.0 0.6 8.0'/> |
40 | <NavigationInfo headlight='false' speed='2.0'/> |
41 | <DirectionalLight ambientIntensity='0.5' direction='0.0 -1.0 -0.5'/> |
42 | <Background skyAngle='1.371 1.571' skyColor='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='false' coordIndex='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 | |
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='false' coordIndex='0 1 2 3' texCoordIndex='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.0' transparency='0.5'/> |
69 | <ImageTexture url=' "palmsh.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/palmsh.png " '/> |
70 | </Appearance> |
71 | <IndexedFaceSet solid='false' coordIndex='0 1 2 3' texCoordIndex='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.6' translation='-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.5' diffuseColor='1.0 1.0 1.0' shininess='0.4' specularColor='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='Clock' cycleInterval='2.0' loop='true' startTime='1.0'/> |
98 |
<!-- ROUTE information for Bouncer node:
[from Clock.fraction_changed to set_fraction
]
[from value_changed to Ball.set_translation
]
-->
<Script DEF='Bouncer' url=' "Bounce2Script.class" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Bounce2Script.class" '> |
99 | <field name='value_changed' type='SFVec3f' accessType='outputOnly'/> |
100 | <field name='bounceHeight' type='SFFloat' value='3.0' accessType='initializeOnly'/> |
101 | <field name='set_fraction' type='SFFloat' accessType='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 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 |
Bouncer
Script set_fraction SFFloat |
then
|
Bouncer
Script value_changed SFVec3f |
Ball
Transform set_translation SFVec3f |
<!--
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)
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->