Geometry Nodes, pt 4:
Triangles and Quadrilaterals
• Abstract node types
• X3DComposedGeometryNode Type
• Nodes
• Normal Node
• TriangleSet Node
• TriangleFanSet Node
• TriangleStripSet Node
• QuadSet Node
• IndexedTriangleSet Node
• IndexedTriangleFanSet Node
• IndexedTriangleStripSet Node
• IndexedQuadSet Node
X3D Header syntax
<X3D version=''3.1'' profile=''Interchange''>
<head>
<component name=''CADGeometry''
level=''1''/>
</head>
<Scene/>
</X3D>
Προτείνεται το κατέβασμα και του BS Contact player, μαζί με τον Octaga,
καθώς κανείς από τους δύο δεν υποστηρίζει σωστά όλους τους κόμβους
αυτού του κεφαλαίου. Συνδυαστικά όμως, η κάλυψη είναι πλήρης.
X3DComposedGeometryNode type
Type accessType Name Default Range Profile
SFBool initializeOnly ccw true Interchange SFBool initializeOnly colorPerVertex true Interchange SFBool initializeOnly normalPerVertex true Interchange SFBool initializeOnly solid true Interchange SFNode inputOutput color NULL [X3DColorNode] Interchange SFNode inputOutput coord NULL [X3DCoordinateNode] Interchange SFNode inputOutput normal NULL [X3DNormalNode] Interchange SFNode inputOutput textureCoordinate NULL [X3DTextureCoordinateNode] Interchange SFNode inputOutput metadata NULL [X3DMetadataNode] Core
Additional common fields
Type
accessType
Name
Default Range
Profile
SFBool initializeOnly convex
true
true
Interchange
SFFloat initializeOnly creaseAngle 0
[0, ∞)
Interchange
For Geometry Nodes:
Type
accessType
Name
Default Range
Profile
MFInt32 initializeOnly index
[ ]
[0, ∞) or -1 Interchange
MFInt32 inputOnly
set_index
[0, ∞) or -1 Interchange
Normal Node
<Normal DEF="MyNormalNode"
vector="0 0 0, 1 1 1"/>
Type
accessType Name
Default Range
Profile
MFVec3f inputOutput vector
NULL (-∞, ∞)
Interchange
SFNode inputOutput metadata NULL [X3DMetadataObject] Core
Normal mapping
Normal mapping
Type
accessType Name
Default Range
Profile
SFBool initializeOnly ccw true Interchange SFBool initializeOnly colorPerVertex true Interchange SFBool initializeOnly normalPerVertex true Interchange SFBool initializeOnly solid true Interchange SFNode inputOutput color NULL [X3DColorNode] Interchange SFNode inputOutput coord NULL [X3DCoordinateNode] Interchange SFNode inputOutput normal NULL [X3DNormalNode] Interchange SFNode inputOutput textureCoordinate NULL [X3DTextureCoordinateNode] Interchange SFNode inputOutput metadata NULL [X3DMetadataNode] Core
TriangleSet Node
<TriangleSet DEF="MyTriangleSetNode" ccw="true" solid="false" colorPerVertex="true" normalPerVertex="true"> <Color/> <Coordinate/> <Normal/> <TextureCoordinate/> <MetadataSet/> </TriangleSet>TriangleFanSet Node
<TriangleFanSet DEF="MyTriangleFanSetNode" fanCount="4" ccw="true" solid="false" colorPerVertex="true" normalPerVertex="true"> <Color/> <Coordinate point="0 0 0, 0 1 0, 1 1 0, -0.25 0.5 0.5"/> <Normal/> <TextureCoordinate/> <MetadataSet/> </TriangleFanSet>Type
accessType Name
Default Range
Profile
MFInt32 inputOutput fanCount [ ] [3, ∞) Interchange
SFBool initializeOnly ccw true Interchange SFBool initializeOnly colorPerVertex true Interchange SFBool initializeOnly normalPerVertex true Interchange SFBool initializeOnly solid true Interchange SFNode inputOutput color NULL [X3DColorNode] Interchange SFNode inputOutput coord NULL [X3DCoordinateNode] Interchange SFNode inputOutput normal NULL [X3DNormalNode] Interchange SFNode inputOutput textureCoordinate NULL [X3DTextureCoordinateNode] Interchange SFNode inputOutput metadata NULL [X3DMetadataNode] Core
TriangleStripSet Node
<TriangleStripSet DEF="MyTriangleStripSetNode" stripCount="4" ccw="true" solid="false" colorPerVertex="true" normalPerVertex="true"> <Color/> <Coordinate point="0 0 0, 0 1 0, 1 1 0, -0.25 0.5 0.5"/> <Normal/> <TextureCoordinate/> <MetadataSet/> </ TriangleStripSet >Type
accessType Name
Default Range
Profile
MFInt32 inputOutput stripCount [ ] [3, ∞) Interchange SFBool initializeOnly ccw true Interchange SFBool initializeOnly colorPerVertex true Interchange SFBool initializeOnly normalPerVertex true Interchange SFBool initializeOnly solid true Interchange SFNode inputOutput color NULL [X3DColorNode] Interchange SFNode inputOutput coord NULL [X3DCoordinateNode] Interchange SFNode inputOutput normal NULL [X3DNormalNode] Interchange SFNode inputOutput textureCoordinate NULL [X3DTextureCoordinateNode] Interchange SFNode inputOutput metadata NULL [X3DMetadataNode] Core
QuadSet Node
<QuadSet DEF="MyQuadSetNode" ccw="true" solid="false" colorPerVertex="true" normalPerVertex="true"> <Color/> <Coordinate/> <Normal/> <TextureCoordinate/> <MetadataSet/> </ QuadSet >Type accessType Name Default Range Profile
SFBool initializeOnly ccw true
Interchange + CADGeometry:1 component, or Full profile
SFBool initializeOnly colorPerVertex true »
SFBool initializeOnly normalPerVertex true »
SFBool initializeOnly solid true »
SFNode inputOutput color NULL [X3DColorNode] »
SFNode inputOutput coord NULL [X3DCoordinateNode] » SFNode inputOutput normal NULL [X3DNormalNode] » SFNode inputOutput textureCoordinate NULL [X3DTexture CoordinateNode] » SFNode inputOutput metadata NULL [X3DMetadataNode] Core
Type
accessType Name
Default Range
Profile
MFInt32 initializeOnly index [ ] [0, ∞) Interchange MFInt32 inputOnly set_index [0, ∞) Interchange SFBool initializeOnly ccw true Interchange SFBool initializeOnly colorPerVertex true Interchange SFBool initializeOnly normalPerVertex true Interchange SFBool initializeOnly solid true Interchange SFNode inputOutput color NULL [X3DColorNode] Interchange SFNode inputOutput coord NULL [X3DCoordinateNode] Interchange SFNode inputOutput normal NULL [X3DNormalNode] Interchange SFNode inputOutput textureCoordinate NULL [X3DTextureCoordinateNode] Interchange SFNode inputOutput metadata NULL [X3DMetadataNode] Core
IndexedTriangleSet Node
<IndexedTriangleSet DEF="MyIndexedTriangleSetNode" index="0 1 2, 3 4 5" ccw="true" solid="false" colorPerVertex="true" normalPerVertex="true"> <Color/> <Coordinate/> <Normal/> <TextureCoordinate/> <MetadataSet/> </ IndexedTriangleSet >
IndexedTriangleFanSet Node
<IndexedTriangleFanSet DEF="MyIndexedTriangleFanSetNode" index="0 1 2 3 4 5, -1"
ccw="true" solid="false"
colorPerVertex="true" normalPerVertex="true"> <Color/> <Coordinate point="0 0 0, 0 1 0, 1 1 0, -0.25 0.5 0.5"/> <Normal/> <TextureCoordinate/> <MetadataSet/> </ IndexedTriangleFanSet >
Type
accessType Name
Default Range
Profile
MFInt32 initializeOnly index [] [0, ∞) Interchange MFInt32 inputOnly set_index [0, ∞) Interchange SFBool initializeOnly ccw true Interchange SFBool initializeOnly colorPerVertex true Interchange SFBool initializeOnly normalPerVertex true Interchange SFBool initializeOnly solid true Interchange SFNode inputOutput color NULL [X3DColorNode] Interchange SFNode inputOutput coord NULL [X3DCoordinateNode] Interchange SFNode inputOutput normal NULL [X3DNormalNode] Interchange SFNode inputOutput textureCoordinate NULL [X3DTextureCoordinateNode] Interchange SFNode inputOutput metadata NULL [X3DMetadataNode] Core
IndexedTriangleStripSet Node
<IndexedTriangleFanSet DEF="MyIndexedTriangleStripSetNode" ccw="true" solid="false" colorPerVertex="true" normalPerVertex="true"> <Color/> <Coordinate point="0 0 0, 0 1 0, 1 1 0, -0.25 0.5 0.5"/> <Normal/> <TextureCoordinate/> <MetadataSet/> </ IndexedTriangleFanSet >Type
accessType Name
Default Range
Profile
MFInt32 initializeOnly index [] [0, ∞) Interchange MFInt32 inputOnly set_index [0, ∞) Interchange SFBool initializeOnly ccw true Interchange SFBool initializeOnly colorPerVertex true Interchange SFBool initializeOnly normalPerVertex true Interchange SFBool initializeOnly solid true Interchange SFNode inputOutput color NULL [X3DColorNode] Interchange SFNode inputOutput coord NULL [X3DCoordinateNode] Interchange SFNode inputOutput normal NULL [X3DNormalNode] Interchange SFNode inputOutput textureCoordinate NULL [X3DTextureCoordinateNode] Interchange SFNode inputOutput metadata NULL [X3DMetadataNode] Core
Type accessType Name Default Range Profile
MFInt32 initializeOnly index [] [0, ∞)
Interchange + CADGeometry:1 component, or Full profile
MFInt32 inputOnly set_index [0, ∞) »
SFBool initializeOnly ccw true »
SFBool initializeOnly colorPerVertex true »
SFBool initializeOnly normalPerVertex true »
SFBool initializeOnly solid true »
SFNode inputOutput color NULL [X3DColorNode] » SFNode inputOutput coord NULL [X3DCoordinateNode] » SFNode inputOutput normal NULL [X3DNormalNode] » SFNode inputOutput textureCoordinate NULL [X3DTexture CoordinateNode] » SFNode inputOutput metadata NULL [X3DMetadataNode] Core
IndexedQuadSet Node
<IndexedQuadSet DEF="MyIndexedQuadSetNode" index="0 1 2 3, 4 5 6 7" ccw="true" solid="false"
colorPerVertex="true" normalPerVertex="true"> <Color/> <Coordinate/> <Normal/>
<TextureCoordinate/> <MetadataSet/>
Creating Prorotype Nodes
Field Definition Requirements
Type
accessType Name
Default
Range
[fieldType] initializeOnly [fieldName] [required, author specified] [implicit, depends on fieldtype] [fieldType] inputOutput [fieldName] [required, author specified] [implicit, depends on fieldtype] [fieldType] inputOnly [fieldName] [omitted] [implicit, depends on fieldtype] [fieldType] outputOnly [fieldName] [omitted] [implicit, depends on
Name Description Example value Default value
SFBool Single-field boolean true false
MFBool Multiple-field boolean true true false empty list SFColor Single-field RGB Color 0.7 0.9 1 0 0 0 (Black) MFColor Multiple-field RGB Color 0 0.8 1, 0 1 0.5, 0 0 0 empty list SFColorRGBA SF RGB Color+Alphamap 1 0 0.3 0.8 0 0 0 0 (Transp.) MFColorRGBA MF RGB Color+Alphamap 1 0 0.3 0.7, 0.3 0 0 1 empty list
SFFloat SF floating point number 1.8 0
MFFloat MF floating point number -8.4 2 0.2345 empty list
SFDouble SF double precision float 2.7128 0.0
MFDouble MF douple precision float 2.1345 -0.23 1.82 empty list
SFInt32 SF 32-bit integer value 5472 0
MFInt32 MF 32-bit integer value 32 -523 0 -7376 empty list SFImage SF image value 2 1 2 0xFF00 0x2A99 0 0 0 MFImage MF image value 1 2 1 0x88 0xFF,
1 1 3 0xAA00FF empty list
Name Description Example value Default value
SFNode SF X3D node <Shape/> NULL
MFNode MF X3D node array of peers <Shape/> <Group/> empty list SFRotation SF 3-tuple axis + radians 1 0 0 2.4 0 0 1 0 MFRotation MF 3-tuple axis + radians 0 1 0 1.2, 0 1 0 0 empty list
SFString SF string ”X3D is awesome!” ””
MFString MF string ”Hello” ”X3D” ”###” empty list
SFTime SF time 1835.34 0
MFTime MF time -12 0 -3.1 16.5 empty list
SFVec2f/SFVec2d SF 2-float or 2-double vector 2 -1.6 0 MFVec2f/MFVec2d MF 2-float or 2-double vector -1 0.7, 0 0.2, 1 5.4 empty list Similarly for SFVec3f/SFVec3d, MFVec3f/MFVec3d, SFVec4f/SFVec4d, MFVec4f/MFVec4d
SFMatrix3f/
SFMatrix3d SF 3-by-3 matrix of float or double 1 3.67 -5.2 2 -4.1 0 6 -19 4 0 0 1 (identity) 1 0 0 0 1 0 Similarly for MFMatrix3f/MFMatrix3d, SFMatrix4f/SFMatrix4d, MFMatrix4f, MFMatrix4d
Prototype Declaration
<Background skyColor="1 1 1"/>
<ProtoDeclare name='myPrototype'>
<ProtoInterface>
</ProtoInterface>
<ProtoBody>
<Shape>
<Box/>
<Appearance>
<Material/>
</Appearance>
</Shape>
</ProtoBody>
</ProtoDeclare>
<ProtoInstance name='myPrototype'/>
ProtoDeclare node
<ProtoDeclare name='ViewPositionOrientation'>
<ProtoInterface>
<field name=''enabled'' type=''SFBool'' value=''true''
accessType=''inputOutput''
appinfo=''Whether or not ViewPositionOrientation sends output to
console.''/>
<field name=''traceEnabled'' type=''SFBool'' value=''true''
accessType=''initializeOnly'' appinfo=''Output internal trace messages for
debugging this node.'/>
<field name=''set_traceEnabled'' type=''SFBool'' accessType=''inputOnly''
appinfo=''Ability to turn output tracing on/off at runtime.''/>
</ProtoInterface>
<ProtoBody>
<!—ProtoBody definition goes here—>
</ProtoBody>
</ProtoDeclare>
Example Prototype Body Declarations
<ProtoDeclare name='ViewPositionOrientation'>
<ProtoInterface> <!-ProtoInterface field definitions go here-> </ProtoInterface> <ProtoBody>
<ProximitySensor DEF=''WhereSensor'' size=''1000000000 1000000000 1000000000''> <IS> <connect nodeField=''enabled'' protoField=''enabled''/> </IS>
</ProximitySensor>
<Script DEF=''OutputPositionOrientation''>
<field name=''traceEnabled'' type=''SFBool'' accessType=''initializeOnly''/> <field name=''set_traceEnabled'' type=''SFBool'' accessType=''inputOnly''/> <IS>
<connect nodeField=''traceEnabled'' protoField=''traceEnabled''/>
<connect nodeField=''set_traceEnabled'' protoField=''set_traceEnabled''/> </IS>
<![CDATA[ ecmascript:// scripting code goes here ]]> </Script>
<ROUTE fromNode=''WhereSensor'' fromField=''position_changed'' toNode=''OutputPositionOrientation'' toField=''set_position''/> </ProtoBody> </ProtoDeclare>
ExternProtoDeclare Statement
<!—Copy the ExternProtoDeclare and ProtoInstance for ViewPositionOrientation at the
top of a scene graph to add this functionality into other worlds.—>
<ExternProtoDeclare name='ViewPositionOrientation' url='
''../../Tools/Authoring/ViewPositionOrientationPrototype.x3d#ViewPositionOrientation''
''../../Tools/Authoring/ViewPositionOrientationPrototype.wrl#ViewPositionOrientation''
''https://savage.nps.edu/Savage/Tools/Authoring/ViewPositionOrientationPrototype.wrl
#ViewPositionOrientation'''>
<field name='enabled' type='SFBool' accessType='inputOutput' appinfo='Whether or
not ViewPositionOrientation sends output to console.'/>
<field name='traceEnabled' type='SFBool' accessType= 'initializeOnly'
appinfo='Output internal trace messages for debugging this node -developer use
only, can be ignored.'/>
<field name='set_traceEnabled' type='SFBool' accessType= 'inputOnly'
appinfo='Ability to turn output tracing on/off at runtime.'/>
Example Prorotype Instance Creation
<ProtoInstance name= 'ViewPositionOrientation' >
<fieldValue name= 'enabled' value= 'true'/>
</ProtoInstance>
<ProtoDeclare name='myPrototype'> <ProtoInterface>
<field name='ShapeContent' type='SFNode' accessType='inputOutput'> <Box/>
</field>
<field name='ShapeColor' type='SFColor' accessType='inputOutput'/ </ProtoInterface>
<ProtoBody>
<Shape>
<IS>
<connect nodeField='geometry' protoField='ShapeContent'/> </IS>
<Appearance>
<Material> <IS>
<connect nodeField='diffuseColor' protoField='ShapeColor'/> </IS> </Material> </Appearance> </Shape> </ProtoBody> </ProtoDeclare> <ProtoInstance name='myPrototype'> <fieldValue name='ShapeContent'> <Sphere/> </fieldValue>
<fieldValue name='ShapeColor' value="1 0.2 0.2"/> </ProtoInstance>
<ProtoDeclare appinfo='Heads-up display (HUD) keeps child geometry aligned on screen in a consistent location' name='HeadsUpDisplay'>
<ProtoInterface>
<field accessType='inputOutput' name='screenOffset' type='SFVec3f' value='0 0 -5'/> <field accessType='inputOutput' name='children' type='MFNode'/>
<field accessType='outputOnly' name='position_changed' type='SFVec3f'/>
<field accessType='outputOnly' name='orientation_changed' type='SFRotation'/> </ProtoInterface>
<ProtoBody> <Group>
<Transform DEF='HudContainer'> <Transform>
<IS> <connect nodeField='translation' protoField='screenOffset'/> </IS> <Group> <IS> <connect nodeField='children' protoField='children'/> </IS> </Group>
</Transform> </Transform>
<ProximitySensor DEF='HereIAm' enabled='true' size='10000000 10000000 10000000'> <IS> <connect nodeField='position_changed' protoField='position_changed'/>
<connect nodeField='orientation_changed' protoField='orientation_changed'/> </IS> </ProximitySensor>
<ROUTE fromNode='HereIAm' fromField='orientation_changed' toNode='HudContainer' toField='rotation'/>
<ROUTE fromNode='HereIAm' fromField='position_changed' toNode='HudContainer' toField='translation'/>
<ExternProtoDeclare appinfo='HUD' name='HeadsUpDisplay' url='"HeadsUpDisplayPrototype.x3d#HeadsUpDisplay"'>
<field accessType='inputOutput' name='children' type='MFNode'/> <field accessType='inputOutput' name='screenOffset' type='SFVec3f'/> <field accessType='outputOnly' name='position_changed' type='SFVec3f'/>
<field accessType='outputOnly' name='orientation_changed' type='SFRotation'/> </ExternProtoDeclare>
<Background DEF='SandyShallowBottom' groundAngle='0.05 1.52 1.56 1.5707'
groundColor='0.2 0.2 0 0.3 0.3 0 0.5 0.5 0.3 0.1 0.3 0.4 0 0.2 0.4' skyAngle='0.04 0.05 0.1 1.309 1.570' skyColor='0.8 0.8 0.2 0.8 0.8 0.2 0.1 0.1 0.6 0.1 0.1 0.6 0.1 0.25 0.8 0.6 0.6 0.9'/>
<Viewpoint description='Heads-up display (HUD)'/>
<ProtoInstance DEF='HeadsUpDisplay' name='HeadsUpDisplay'> <fieldValue name='screenOffset' value='-0.75 1 -5'/>
<fieldValue name='children'> <Shape>
<Text string='"HUD text stays fixed" "while user navigates"'> <FontStyle justify='"MIDDLE" "MIDDLE"' size='0.3'/>
</Text> <Appearance> <Material diffuseColor='0.894118 0.819608 1'/> </Appearance> </Shape> </fieldValue> </ProtoInstance> <Inline url='"http://X3dGraphics.com/examples/X3dForWebAuthors/HelloWorld.x3d"'/>
<ProtoDeclare appinfo='Prototype node for displaying current viewpoint location and orientation' name='WhereAmI'>
<!-- No ProtoInterface fields are needed for this prototype --> <ProtoBody>
<ProximitySensor DEF='WhereSensor' size='100000 100000 100000'/> <!-- no geometry is rendered in the current scene by the prototype --> <Script DEF='WhereDump' url='"WhereAmI.js"'>
<field accessType='inputOnly' name='position' type='SFVec3f'/>
<field accessType='inputOnly' name='orientation' type='SFRotation'/> </Script>
<ROUTE fromNode='WhereSensor' fromField='orientation_changed' toNode='WhereDump' toField='orientation' />
<ROUTE fromNode='WhereSensor' fromField='position_changed' toNode='WhereDump' toField='position' />
</ProtoBody> </ProtoDeclare>
<!-- ProtoInstance instantiates (creates) a new node using the ProtoDeclare prototype definition -->
<ProtoInstance name='WhereAmI'/>
<Viewpoint description='WhereAmI prototype test' position='0 0 10'/> <Shape>
<Text string='"Check X3D console" "while navigating for" "current viewpoint values"'> <FontStyle justify='"MIDDLE" "MIDDLE"'/>
</Text>
<Appearance>
<Material ambientIntensity='0.23' diffuseColor='0.5 0.243312 0.127417'
emissiveColor='0.015957 0.015957 0.015957' shininess='0.03' specularColor='0.276596 0.055086 0.01524'/>
</Appearance> </Shape>