X3D Model Documentation: BounceTrimesh.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN" "https://www.web3d.org/specifications/x3d-3.2.dtd">
  3  <X3D profile='Immersive' version='3.2 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.2.xsd'>
  4       <head>
  5            <component level='2name='RigidBodyPhysics'/>
  6            <meta name='titlecontent='BounceTrimesh.x3d'/>
  7            <meta name='descriptioncontent='Example scene for RigidBodyPhysics component'/>
  8            <meta name='creatorcontent='Alan Hudson and Justin Couch'/>
  9            <meta name='translatorcontent='Don Brutzman'/>
 10            <meta name='createdcontent='1 January 2008'/>
 11            <meta name='translatedcontent='26 December 2008'/>
 12            <meta name='modifiedcontent='20 October 2019'/>
 13            <meta name='referencecontent='http://www.xj3d.org/extensions/index.html#Physics'/>
 14            <meta name='referencecontent='originals/bounce_trimesh.x3dv'/>
 15            <meta name='referencecontent='https://www.web3d.org/x3d/specifications/ISO-IEC-FDIS-19775-1.2-X3D-AbstractSpecification/Part01/components/rigid_physics.html'/>
 16            <meta name=' warning content=' under development '/>
 17            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Basic/RigidBodyPhysics/BounceTrimesh.x3d'/>
 18            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 19            <meta name='generatorcontent='Xj3D converter, http://www.xj3d.org'/>
 20            <meta name='licensecontent='../license.html'/>
 21       </head>
<!--

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

<!-- to top Index for DEF nodes: BALL-GEOM, BODY-1, BODY-COLLECTION, COLLISION-GROUP, COLLISION-OUTPUT, CONTACT-SCRIPT, GROUND-GEOM, INDICATOR-MATERIAL

Index for Viewpoint node: Viewpoint_1
-->
 22       <Scene>
 23            <WorldInfo title='BounceTrimesh.x3d'/>
 24            <Viewpoint position='0.0 0.0 4.0'/>
 25            <Group>
 26 
               <!-- CollidableShape BALL-GEOM is a DEF node that has 2 USE nodes: USE_1, USE_2 -->
               <CollidableShape DEF='BALL-GEOMcontainerField='children'>
 27                      <Shape containerField='shape'>
 28                           <Appearance>
 29                                <Material emissiveColor='1.0 0.0 0.0'/>
 30                           </Appearance>
 31                           <Sphere radius='0.1'/>
 32                      </Shape>
 33                 </CollidableShape>
 34 
               <!-- CollidableShape GROUND-GEOM is a DEF node that has 2 USE nodes: USE_1, USE_2 -->
               <CollidableShape DEF='GROUND-GEOMtranslation='0.0 -0.5 0.0containerField='children'>
 35                      <Shape containerField='shape'>
 36                           <Appearance>
 37                                <Material emissiveColor='0.0 1.0 0.0'/>
 38                           </Appearance>
 39                           <TriangleSet ccw='truecolorPerVertex='truenormalPerVertex='truesolid='truecontainerField='geometry'>
 40                                <Coordinate point='-10.0 0.0 10.0 10.0 0.0 10.0 10.0 0.0 -10.0 -10.0 0.0 10.0 10.0 0.0 -10.0 -10.0 0.0 -10.0'/>
 41                           </TriangleSet>
 42                      </Shape>
 43                 </CollidableShape>
 44            </Group>
 45            <Transform translation='1.0 1.0 0.0'>
 46                 <Shape>
 47                      <Appearance>
 48 
                         <!-- ROUTE information for INDICATOR-MATERIAL node:  [from CONTACT-SCRIPT.indicatorColor to emissiveColor ] -->
                         <Material DEF='INDICATOR-MATERIALemissiveColor='0.0 0.0 1.0'/>
 49                      </Appearance>
 50                      <Sphere radius='0.2'/>
 51                 </Shape>
 52            </Transform>
 53 
          <!-- ROUTE information for BODY-COLLECTION node:  [from CONTACT-SCRIPT.correctedContacts to set_contacts ] -->
          <RigidBodyCollection DEF='BODY-COLLECTIONcontainerField='children'>
 54                 <RigidBody DEF='BODY-1containerField='bodiesposition='0.0 2.0 0.0'>
 55                      <CollidableShape USE='BALL-GEOMcontainerField='geometry'/>
 56                 </RigidBody>
 57            </RigidBodyCollection>
 58 
          <!-- ROUTE information for COLLISION-OUTPUT node:  [from contacts to CONTACT-SCRIPT.set_jointContacts ] [from isActive to CONTACT-SCRIPT.activeSensor ] -->
          <CollisionSensor DEF='COLLISION-OUTPUT'>
 59                 <CollisionCollection DEF='COLLISION-GROUPbounce='1.0containerField='colliderminBounceSpeed='1.0'>
 60                      <CollidableShape USE='BALL-GEOMcontainerField='collidables'/>
 61                      <CollidableShape USE='GROUND-GEOMcontainerField='collidables'/>
 62                 </CollisionCollection>
 63            </CollisionSensor>
 64 
 65                 <field name='activeSensortype='SFBoolaccessType='inputOnly'/>
 66                 <field name='indicatorColortype='SFColoraccessType='outputOnly'/>
 67                 <field name='set_jointContactstype='MFNodeaccessType='inputOnly'/>
 68                 <field name='correctedContactstype='MFNodeaccessType='outputOnly'/>
 69                 <field name='groundtype='SFNodeaccessType='initializeOnly'>
 70                      <CollidableShape USE='GROUND-GEOMcontainerField='children'/>
 71                 </field>
  <![CDATA[
      
ecmascript:
    function set_jointContacts(val) {
      for(i = 0; i < val.length; i++) {
        if(val[i].geometry1.equals(ground)) {
	  val[i].geometry1 = null;
	  val[i].body1 = null;
	  val[i].bounce = 1;
	}

        if(val[i].geometry2.equals(ground)) {
	  val[i].geometry2 = null;
	  val[i].body2 = null;
	  val[i].bounce = 1;
	}
      }
      correctedContacts = val;
    }

    function activeSensor(val) {
      if(val) {
        indicatorColor.r = 0;
        indicatorColor.g = 1;
        indicatorColor.b = 0;
      }	else {
        indicatorColor.r = 1;
        indicatorColor.g = 0;
        indicatorColor.b = 0;
      }
    }

    
]]>
 73            </Script>
 74            < ROUTE  fromNode='COLLISION-OUTPUT' fromField='contacts' toNode='CONTACT-SCRIPT' toField='set_jointContacts'/>
 75            < ROUTE  fromNode='COLLISION-OUTPUT' fromField='isActive' toNode='CONTACT-SCRIPT' toField='activeSensor'/>
 76            < ROUTE  fromNode='CONTACT-SCRIPT' fromField='indicatorColor' toNode='INDICATOR-MATERIAL' toField='emissiveColor'/>
 77            < ROUTE  fromNode='CONTACT-SCRIPT' fromField='correctedContacts' toNode='BODY-COLLECTION' toField='set_contacts'/>
 78       </Scene>
 79  </X3D>
<!--

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

<!-- to top Index for DEF nodes: BALL-GEOM, BODY-1, BODY-COLLECTION, COLLISION-GROUP, COLLISION-OUTPUT, CONTACT-SCRIPT, GROUND-GEOM, INDICATOR-MATERIAL

Index for Viewpoint node: Viewpoint_1
-->
X3D Tooltips element index: Appearance, CollidableShape, CollisionCollection, CollisionSensor, component, Coordinate, field, Group, head, Material, meta, RigidBody, RigidBodyCollection, ROUTE, Scene, Script, Shape, Sphere, Transform, TriangleSet, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

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

COLLISION-OUTPUT
CollisionSensor
contacts
MFNode

ROUTE
event to
(1)
CONTACT-SCRIPT
Script
set_jointContacts
MFNode
then
 
 
 
CONTACT-SCRIPT
Script
correctedContacts
MFNode

ROUTE
event to
(2)
BODY-COLLECTION
RigidBodyCollection
set_contacts
MFNode
  then
 
 
 
CONTACT-SCRIPT
Script
indicatorColor
SFColor

ROUTE
event to
(2)
INDICATOR-MATERIAL
Material
emissiveColor
SFColor
COLLISION-OUTPUT
CollisionSensor
isActive
SFBool

ROUTE
event to
(1)
CONTACT-SCRIPT
Script
activeSensor
SFBool
then
 
 
 
CONTACT-SCRIPT
Script
correctedContacts
MFNode

ROUTE
event to
(2)
BODY-COLLECTION
RigidBodyCollection
set_contacts
MFNode
  then
 
 
 
CONTACT-SCRIPT
Script
indicatorColor
SFColor

ROUTE
event to
(2)
INDICATOR-MATERIAL
Material
emissiveColor
SFColor
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/Basic/RigidBodyPhysics/BounceTrimeshIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/RigidBodyPhysics/BounceTrimesh.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. -->