X3D Model Documentation: Flames.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='Flames.x3d'/>
  6            <meta name='descriptioncontent='Flickering flames: this prototype declaration illustrates the use of a script to cycle between textures, and then encapsulation of the script, a clock, and a polygon, all within a new Flames prototype node that makes flickering flames. See the Match.x3d scene for an example.'/>
  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='20 October 2019'/>
 12            <meta name='referencecontent='Match.x3d'/>
 13            <meta name='referencecontent='originals/flames.wrl'/>
 14            <meta name='referencecontent='http://www.siggraph.org/s98'/>
 15            <meta name='referencecontent='http://www.siggraph.org/s98/conference/courses/18.html'/>
 16            <meta name='referencecontent='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0499.htm'/>
 17            <meta name='referencecontent='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm'/>
 18            <meta name='referencecontent='https://www.web3d.org/x3d/content/examples/X3dResources.html'/>
 19            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Flames.x3d'/>
 20            <meta name='generatorcontent='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/>
 21            <meta name='generatorcontent='X3D-Edit, https://savage.nps.edu/X3D-Edit'/>
 22            <meta name='licensecontent='../license.html'/>
 23       </head>
<!--

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

<!-- to top Index for DEF nodes: Clock, Flame1, FlameAppearance, FlameSelector

Index for ProtoDeclare definition: Flames
-->
 24       <Scene>
 25            <!-- Three flame textures are used: flames1.png flames2.png flames3.png -->
 26            <!-- All three textures have a transparency channel (alpha channel) so that areas outside of the flame are transparent. -->
 27            <!-- flame1.png was hand-drawn in PhotoShop. The other two flames were created by applying the PhotoShop 'Twirl' filter to several parts of the original flame. This creates a curling effect that looks vaugely flame-like. For a better effect, use more flame images and more care in applying the Twirl filter... or hand draw them all. -->
 28            <WorldInfo info='"Copyright (c) 1997, David R. Nadeau"title='Flickering Flames'/>
 29            <ProtoDeclare name='Flames'>
 30                 <ProtoInterface>
 31                      <field name='startTimetype='SFTimevalue='0.0accessType='initializeOnly'/>
 32                      <field name='cycleIntervaltype='SFTimevalue='1.0accessType='initializeOnly'/>
 33                 </ProtoInterface>
 34                 <ProtoBody>
 35                      <Shape>
 36 
                         <!-- ROUTE information for FlameAppearance node:  [from FlameSelector.texture_changed to set_texture ] -->
                         <Appearance DEF='FlameAppearance'/>
 37                           <IndexedFaceSet solid='falsecoordIndex='0 1 2 3texCoordIndex='0 1 2 3'>
 38                                <TextureCoordinate point='0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0'/>
 39                                <Coordinate point='-0.5 0.0 0.0 0.5 0.0 0.0 0.5 1.8 0.0 -0.5 1.8 0.0'/>
 40                           </IndexedFaceSet>
 41                      </Shape>
 42 
                    <!-- ROUTE information for Clock node:  [from fraction_changed to FlameSelector.set_fraction ] -->
                    <TimeSensor DEF='Clockloop='true'>
 43                           <IS>
 44                                <connect nodeField='startTimeprotoField='startTime'/>
 45                                <connect nodeField='cycleIntervalprotoField='cycleInterval'/>
 46                           </IS>
 47                      </TimeSensor>
 48 
                    <!-- ROUTE information for FlameSelector node:  [from Clock.fraction_changed to set_fraction ] [from texture_changed to FlameAppearance.set_texture ] -->
                    <Script DEF='FlameSelectordirectOutput='true'>
 49                           <field name='flameTexturestype='MFNodeaccessType='initializeOnly'>
 50 
                              <!-- ImageTexture Flame1 is a DEF node that has 1 USE node: USE_1 -->
                              <ImageTexture DEF='Flame1repeatS='falserepeatT='false'   url=' "flames1.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames1.png " '/>
 51                                <ImageTexture repeatS='falserepeatT='false'   url=' "flames2.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames2.png " '/>
 52                                <ImageTexture USE='Flame1'/>
 53                                <ImageTexture repeatS='falserepeatT='false'   url=' "flames3.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames3.png " '/>
 54                           </field>
 55                           <field name='texture_changedtype='SFNodeaccessType='outputOnly'/>
 56                           <field name='set_fractiontype='SFFloataccessType='inputOnly'/>
  <![CDATA[
          
ecmascript:
    function set_fraction( f, tm ) {
            if ( f < 0.25 )
                    texture_changed = flameTextures[0];
            else if ( f < 0.50 )
                    texture_changed = flameTextures[1];
            else if ( f < 0.75 )
                    texture_changed = flameTextures[2];
            else
                    texture_changed = flameTextures[3];
    }

        
]]>
 58                      </Script>
 59                      < ROUTE  fromNode='Clock' fromField='fraction_changed' toNode='FlameSelector' toField='set_fraction'/>
 60                      < ROUTE  fromNode='FlameSelector' fromField='texture_changed' toNode='FlameAppearance' toField='set_texture'/>
 61                 </ProtoBody>
 62            </ProtoDeclare>
 63            <!-- Display scene instructions for viewing an example scene with a corresponding prototype instance -->
 64            <Background skyColor='0 0.333333 0.66667'/>
 65            <Anchor description='select text to view parent scene'   url=' "Match.x3d" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Match.x3d" "Match.wrl" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Match.wrl" '>
 66                 <Shape>
 67                      <Text string='"The Flames.x3d scene holds" "a prototype declaration" "" "Select this text to view example usage" "in Match.x3d scene"'>
 68                           <FontStyle justify='"MIDDLE" "MIDDLE"style='BOLD'/>
 69                      </Text>
 70                      <Appearance>
 71                           <Material diffuseColor='1 0.9 0.4'/>
 72                      </Appearance>
 73                 </Shape>
 74                 <!-- Invisible box behind text makes selection easier -->
 75                 <Shape>
 76                      <Box size='12 5 0.1'/>
 77                      <Appearance>
 78                           <Material transparency='1'/>
 79                      </Appearance>
 80                 </Shape>
 81            </Anchor>
 82       </Scene>
 83  </X3D>
<!--

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

<!-- to top Index for DEF nodes: Clock, Flame1, FlameAppearance, FlameSelector

Index for ProtoDeclare definition: Flames
-->
X3D Tooltips element index: Anchor, Appearance, Background, Box, connect, Coordinate, field, FontStyle, head, ImageTexture, IndexedFaceSet, IS, Material, meta, ProtoBody, ProtoDeclare, ProtoInterface, ROUTE, Scene, Script, Shape, Text, TextureCoordinate, TimeSensor, 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)
FlameSelector
Script
set_fraction
SFFloat
then
 
 
 
FlameSelector
Script
texture_changed
SFNode

ROUTE
event to
(2)
FlameAppearance
Appearance
set_texture
SFNode


Anchor
description='select text to view parent scene' 
User-interaction hint for this node. 
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/FlamesIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Flames.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)
    <ProtoDeclare name='ProtoName'> <field name='fieldName'/> </ProtoDeclare> -->

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