X3D Model Documentation: ParallelepipedPrototype.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='ParallelepipedPrototype.x3d'/>
  6            <meta name='descriptioncontent='Reusable prototype for creating a Parallelepiped, which is a 3D figure formed by six parallelograms; also sometimes referred to as a rhomboid.'/>
  7            <meta name='creatorcontent='Don Brutzman'/>
  8            <meta name='createdcontent='25 November 2011'/>
  9            <meta name='modifiedcontent='20 October 2019'/>
 10            <meta name='referencecontent='ParallelepipedExamples.x3d'/>
 11            <meta name='Imagecontent='ParallelepipedVertexIndices.png'/>
 12            <meta name='drawingcontent='GeometricShapes.vsd'/>
 13            <meta name='referencecontent='https://en.wikipedia.org/wiki/Parallelepiped'/>
 14            <meta name='referencecontent='http://upload.wikimedia.org/wikipedia/commons/f/f6/Parallelepiped.svg'/>
 15            <meta name='referencecontent='http://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Parallelepiped.svg/500px-Parallelepiped.svg.png'/>
 16            <meta name='subjectcontent='parallelopiped rhomboid geometry polyhedron'/>
 17            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/GeometricShapes/ParallelepipedPrototype.x3d'/>
 18            <meta name='referencecontent='https://www.web3d.org/x3d/content/examples/X3dResources.html'/>
 19            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 20            <meta name='licensecontent='../license.html'/>
 21       </head>
<!--

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

<!-- to top Index for DEF nodes: BlueAppearance, IFS, ParallelepipedScript, TransparentBox

Index for ProtoDeclare definition: Parallelepiped
-->
 22       <Scene>
 23            <WorldInfo title='ParallelepipedPrototype.x3d'/>
 24            <ProtoDeclare name='Parallelepipedappinfo='Parallelepiped is a 3D figure formed by six parallelograms; also sometimes referred to as a rhomboid'>
 25                 <ProtoInterface>
 26                      <field name='pointtype='MFVec3fvalue='0 1 0 1 1 0 1 1 1 0 1 1 0 0 0 1 0 0 1 0 1 0 0 1accessType='inputOutput'/>
 27                      <field name='colorPerVertextype='SFBoolvalue='trueaccessType='initializeOnly'/>
 28                      <field name='normalPerVertextype='SFBoolvalue='trueaccessType='initializeOnly'/>
 29                      <field name='colorIndextype='MFInt32accessType='initializeOnly'/>
 30                      <field name='normalIndextype='MFInt32accessType='initializeOnly'/>
 31                      <field name='texCoordIndextype='MFInt32accessType='initializeOnly'/>
 32                      <field name='colortype='SFNodeaccessType='inputOutput'>
 33                           <!-- initialization node (if any) goes here -->
 34                      </field>
 35                      <field name='normaltype='SFNodeaccessType='inputOutput'>
 36                           <!-- initialization node (if any) goes here -->
 37                      </field>
 38                      <field name='texCoordtype='SFNodeaccessType='inputOutput'>
 39                           <!-- initialization node (if any) goes here -->
 40                      </field>
 41                 </ProtoInterface>
 42                 <ProtoBody>
 43                      <!-- First node determines node type of this prototype -->
 44                      <IndexedFaceSet DEF='IFSconvex='falsesolid='falsecoordIndex='0 3 2 1 -1 4 5 6 7 -1 0 1 5 4 -1 1 2 6 5 -1 2 3 7 6 -1 3 0 4 7 -1'>
 45                           <IS>
 46                                <connect nodeField='colorPerVertexprotoField='colorPerVertex'/>
 47                                <connect nodeField='normalPerVertexprotoField='normalPerVertex'/>
 48                                <connect nodeField='colorIndexprotoField='colorIndex'/>
 49                                <connect nodeField='normalIndexprotoField='normalIndex'/>
 50                                <connect nodeField='texCoordIndexprotoField='texCoordIndex'/>
 51                                <connect nodeField='colorprotoField='color'/>
 52                                <connect nodeField='normalprotoField='normal'/>
 53                                <connect nodeField='texCoordprotoField='texCoord'/>
 54                           </IS>
 55                           <Coordinate>
 56                                <IS>
 57                                     <connect nodeField='pointprotoField='point'/>
 58                                </IS>
 59                           </Coordinate>
 60                      </IndexedFaceSet>
 61                      <!-- This embedded Script provides the X3D author with additional visibility and control over prototype inputs and outputs -->
 62                      <Script DEF='ParallelepipedScript'>
 63                           <field name='pointtype='MFVec3faccessType='inputOutput'/>
 64                           <IS>
 65                                <connect nodeField='pointprotoField='point'/>
 66                           </IS>
  <![CDATA[
          
ecmascript:
function initialize ()
{
    checkCoordinatePoints ();
}
function checkCoordinatePoints ()
{
    // A parallelepiped has three sets of four parallel edges; the edges within each set are of equal length.
    // Quality assurance: check that lengths of corresponding sides match.
    
    edge01 = length2(point[0], point[1]); // top
    edge12 = length2(point[1], point[2]);
    edge23 = length2(point[2], point[3]);
    edge30 = length2(point[3], point[0]);
    edge45 = length2(point[4], point[5]); // bottom
    edge56 = length2(point[5], point[6]);
    edge67 = length2(point[6], point[7]);
    edge74 = length2(point[7], point[4]);
    edge04 = length2(point[0], point[4]); // sides
    edge15 = length2(point[1], point[5]);
    edge26 = length2(point[2], point[6]);
    edge37 = length2(point[3], point[7]);
    
    epsilon = edge01 * 0.001;
    
    if      ((Math.abs(edge01 - edge23) > epsilon) ||
             (Math.abs(edge23 - edge67) > epsilon) ||
             (Math.abs(edge67 - edge45) > epsilon) ||
             (Math.abs(edge45 - edge01) > epsilon))
         Browser.println ('Warning, mismatched parallelopiped sides 02/33/45/67');
    else if ((Math.abs(edge30 - edge12) > epsilon) ||
             (Math.abs(edge12 - edge56) > epsilon) ||
             (Math.abs(edge56 - edge74) > epsilon) ||
             (Math.abs(edge74 - edge30) > epsilon))
         Browser.println ('Warning, mismatched parallelopiped sides 30/12/56/74');
    else if ((Math.abs(edge04 - edge15) > epsilon) ||
             (Math.abs(edge15 - edge26) > epsilon) ||
             (Math.abs(edge26 - edge37) > epsilon) ||
             (Math.abs(edge37 - edge04) > epsilon))
         Browser.println ('Warning, mismatched parallelopiped sides 04/15/26/37');
}
function length2 (pointA, pointB)
{    
    return Math.sqrt((pointA.x - pointB.x)*(pointA.x - pointB.x) +
                     (pointA.y - pointB.y)*(pointA.y - pointB.y) +
                     (pointA.z - pointB.z)*(pointA.z - pointB.z));
}
function set_point (eventValue)
{
   // input eventValue received for inputOutput field
    point = eventValue;
    checkCoordinatePoints ();
}

        
]]>
 68                      </Script>
 69                 </ProtoBody>
 70            </ProtoDeclare>
 71            <!-- ================================================================================ -->
 72            <Background skyColor='0.905882 1 0.858824'/>
 73            <Anchor description='Open ParallelepipedExamples scene'   url=' "ParallelepipedExamples.x3d" "https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/GeometricShapes/ParallelepipedExamples.x3d" "ParallelepipedExamples.wrl" "https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/GeometricShapes/ParallelepipedExamples.wrl" '>
 74                 <Shape>
 75                      <Text string='"This scene defines a" "Parallelepiped prototype" "" "Select this text to open" "ParallelepipedExamples scene"'>
 76                           <FontStyle justify='"MIDDLE" "MIDDLE"'/>
 77                      </Text>
 78                      <Appearance DEF='BlueAppearance'>
 79                           <Material diffuseColor='0 0.698039 1'/>
 80                      </Appearance>
 81                 </Shape>
 82                 <Shape DEF='TransparentBox'>
 83                      <Box size='11 5 0.1'/>
 84                      <Appearance>
 85                           <Material transparency='1'/>
 86                      </Appearance>
 87                 </Shape>
 88            </Anchor>
 89       </Scene>
 90  </X3D>
<!--

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

<!-- to top Index for DEF nodes: BlueAppearance, IFS, ParallelepipedScript, TransparentBox

Index for ProtoDeclare definition: Parallelepiped
-->
X3D Tooltips element index: Anchor, Appearance, Background, Box, connect, Coordinate, field, FontStyle, head, IndexedFaceSet, IS, Material, meta, ProtoBody, ProtoDeclare, ProtoInterface, Scene, Script, Shape, Text, WorldInfo, X3D, accessType and type, XML data types, field types

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

ParallelepipedScript
Script
No ROUTE connection found for output events from this node.
This Script has no direct access to other nodes. 


Anchor
description='Open ParallelepipedExamples 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/X3dForAdvancedModeling/GeometricShapes/ParallelepipedPrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/GeometricShapes/ParallelepipedPrototype.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. -->