• No results found

Geometry Nodes, pt 4: Triangles and Quadrilaterals

N/A
N/A
Protected

Academic year: 2021

Share "Geometry Nodes, pt 4: Triangles and Quadrilaterals"

Copied!
33
0
0

Loading.... (view fulltext now)

Full text

(1)

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

(2)

X3D Header syntax

<X3D version=''3.1'' profile=''Interchange''>

<head>

<component name=''CADGeometry''

level=''1''/>

</head>

<Scene/>

</X3D>

Προτείνεται το κατέβασμα και του BS Contact player, μαζί με τον Octaga,

καθώς κανείς από τους δύο δεν υποστηρίζει σωστά όλους τους κόμβους

αυτού του κεφαλαίου. Συνδυαστικά όμως, η κάλυψη είναι πλήρης.

(3)

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

(4)

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

(5)

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

(6)
(7)

Normal mapping

(8)

Normal mapping

(9)

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>

(10)
(11)

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

(12)

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

(13)

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

(14)
(15)

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 >

(16)

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

(17)

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

(18)

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/>

(19)

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

(20)

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

(21)

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

(22)

Prototype Declaration

<Background skyColor="1 1 1"/>

<ProtoDeclare name='myPrototype'>

<ProtoInterface>

</ProtoInterface>

<ProtoBody>

<Shape>

<Box/>

<Appearance>

<Material/>

</Appearance>

</Shape>

</ProtoBody>

</ProtoDeclare>

<ProtoInstance name='myPrototype'/>

(23)

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>

(24)

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>

(25)

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.'/>

(26)

Example Prorotype Instance Creation

<ProtoInstance name= 'ViewPositionOrientation' >

<fieldValue name= 'enabled' value= 'true'/>

</ProtoInstance>

(27)

<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>

(28)

<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'/>

(29)

<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"'/>

(30)
(31)

<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>

(32)

// Filename: WhereAmI.js

// Author: Leonard Daly

function position (value) {

x = setDigits (value[0], 100);

y = setDigits (value[1], 100);

z = setDigits (value[2], 100);

Browser.print ('Position (X,Y,Z) = ' + x + ' ' + y + ' ' + z + '\n');

}

function orientation (value) {

x = setDigits (value[0], 1000);

y = setDigits (value[1], 1000);

z = setDigits (value[2], 1000);

r = setDigits (value[3], 100);

Browser.print ('Orientation (X,Y,Z,R) = ' + x + ' ' + y + ' ' + z + ' ' + r + '\n');

}

function setDigits (v, p) {

return Math.floor (v*p + .5) / p;

}

(33)

References

Related documents

Our data indicate that over the last quarter century non-union voice, particularly direct voice, is associated with better financial performance and labor productivity than union

Banka nabízí běžný účet pod názvem IQkonto, ke kterému klient obdrží zdarma internetové bankovnictví, elektronickou platební kartu Maestro Standard, roční

 Hypertonic injections – used when there is loss of sodium in an excess of water  Sodium Chloride injection – fluid and electrolyte replenisher.  Antidote to silver

American Economic Association, American Law and Economics Association, Canadian Economic Association, Econometric Society, Economic Science Association, Society of Empirical

• Ensure the Logistics Section is set up properly, including Check-In, and that appropriate personnel, equipment, and supplies are in place, including maps, status boards,

Iteration will occur in a raid group as groups perform the patterns of behaviour in order to attack mobs during the raid.. Members exhibit different

RECOGNIZING RECOGNIZING RECOGNIZING RECOGNIZING SUBROGATION AND SUBROGATION AND SUBROGATION AND SUBROGATION AND THIRD PARTY THIRD PARTY THIRD PARTY THIRD PARTY LIABILITY

Parents are indifferent between having different types of kids if their actions are identical cases 1 and 2 for investors and case 1 for receivers.. Consider first the population