X3D Model Documentation: HAnimPosePrototype.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 4.0//EN" "https://www.web3d.org/specifications/x3d-4.0.dtd">
  3  <X3D profile='Immersive' version='4.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-4.0.xsd'>
  4       <head>
  5            <meta name='titlecontent=' HAnimPosePrototype.x3d '/>
  6            <meta name='descriptioncontent='Define an experimental new node to simply capture a single pose for an HAnimHumanoid model.'/>
  7            <meta name='createdcontent='4 April 2025'/>
  8            <meta name='modifiedcontent='5 April 2025'/>
  9            <meta name='creatorcontent='Don Brutzman'/>
 10            <meta name='creatorcontent='Joe Williams'/>
 11            <meta name=' warning content=' under development '/>
 12            <meta name='referencecontent=' HAnimPoseDesignNotes19MAR2025.pdf '/>
 13            <meta name='referencecontent='HAnim Architecture volume 1 version 2.0, clause 4.8.2 Modelling of human-like HAnim figures, https://www.web3d.org/documents/specifications/19774/V2.0/Architecture/concepts.html#ModellingOfHumanLikeHAnimFigures'/>
 14            <meta name='referencecontent='HAnim Architecture volume 1 version 2.0, clause 4.8.3 Poses, https://www.web3d.org/documents/specifications/19774/V2.0/Architecture/concepts.html#Poses'/>
 15            <meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/HelloWorldScenes/HAnimPosePrototype.x3d '/>
 16            <meta name='licensecontent=' https://www.web3d.org/x3d/content/examples/license.html '/>
 17            <meta name='generatorcontent='X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit'/>
 18       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: HAnimPoseScriptOperations, ModelInfo, PrototypeRootNode

Index for ProtoDeclare definition: HAnimPose
-->
 19       <Scene>
 20            <!-- Example scene to illustrate X3D nodes and fields (XML elements and attributes) -->
 21            <WorldInfo DEF='ModelInfoinfo='"Design to illustrate a potential HAnimPose node"title='HAnimPose Prototype'/>
 22            <NavigationInfo/>
 23            <ProtoDeclare name='HAnimPoseappinfo='Assumes HAnimHumanoid configuration must be in I pose, which can be achieved by resetting every HAnimJoint to default values'>
 24                 <ProtoInterface>
 25                      <field name='enabledtype='SFBoolvalue='trueaccessType='inputOutput'
                     appinfo='default value true'/>
 26                      <field name='setPosetype='SFBoolaccessType='inputOnly'
                     appinfo="this event tells the HAnimPose node to do it's thing!"/>
 27                      <field name='nametype='SFStringvalue='PoseNameaccessType='inputOutput'
                     appinfo='name of this pose'/>
 28                      <field name='namesPoseJointstype='MFStringvalue='"nameJoint1" "nameJoint2" "nameJoint3" "nameJoint4"accessType='inputOutput'
                     appinfo='names of joints in pose'/>
 29                      <field name='positionsPoseJointstype='MFVec3faccessType='inputOutput'
                     appinfo='positions of joints in pose'/>
 30                      <field name='rotationsPoseJointstype='MFRotationaccessType='inputOutput'
                     appinfo='rotations of joints in pose'/>
 31                      <field name='whichChoicetype='SFInt32accessType='inputOutput'
                     appinfo='selects one of the HAnimHumanoid nodes'/>
 32                      <field name='childrentype='MFNodeaccessType='inputOutput'
                     appinfo='references one or more HAnimHumanoid nodes, typically via USE references'/>
 33                      <field name='addChildrentype='MFNodeaccessType='inputOnly'
                     appinfo='references one or more HAnimHumanoid nodes, typically via USE references'/>
 34                      <field name='removeChildrentype='MFNodeaccessType='inputOnly'
                     appinfo='references one or more HAnimHumanoid nodes, typically via USE references'/>
 35                      <field name='traceEnabledtype='SFBoolvalue='trueaccessType='inputOutput'
                     appinfo='debug trace to Browser output console'/>
 36                 </ProtoInterface>
 37                 <ProtoBody>
 38                      <!-- First node determines node type of this prototype -->
 39                      <Switch DEF='PrototypeRootNodewhichChoice='-1'>
 40                           <IS>
 41                                <connect nodeField='whichChoiceprotoField='whichChoice'/>
 42                                <connect nodeField='childrenprotoField='children'/>
 43                                <connect nodeField='addChildrenprotoField='addChildren'/>
 44                                <connect nodeField='removeChildrenprotoField='removeChildren'/>
 45                           </IS>
 46                      </Switch>
 47                      <!-- Subsequent nodes do not render, but still must be a valid X3D subgraph -->
 48                      <MetadataString name='interfacereference='https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/concepts.html#InterfaceHierarchyvalue='"X3DGroupingNode"'/>
 49                      <!-- This embedded Script provides the X3D author with additional visibility and control over prototype inputs and outputs -->
 50                      <Script DEF='HAnimPoseScriptOperationsdirectOutput='true'>
 51                           <field name='enabledtype='SFBoolaccessType='inputOutput'
                          appinfo='default value true'/>
 52                           <field name='setPosetype='SFBoolaccessType='inputOnly'
                          appinfo="this event tells the HAnimPose node to do it's thing!"/>
 53                           <field name='nametype='SFStringaccessType='inputOutput'
                          appinfo='name of this pose'/>
 54                           <field name='namesPoseJointstype='MFStringaccessType='inputOutput'
                          appinfo='names of joints in pose'/>
 55                           <field name='positionsPoseJointstype='MFVec3faccessType='inputOutput'
                          appinfo='positions of joints in pose'/>
 56                           <field name='rotationsPoseJointstype='MFRotationaccessType='inputOutput'
                          appinfo='rotations of joints in pose'/>
 57                           <field name='whichChoicetype='SFInt32accessType='inputOutput'
                          appinfo='selects one of the HAnimHumanoid nodes'/>
 58                           <field name='childrentype='MFNodeaccessType='inputOutput'
                          appinfo='references one or more HAnimHumanoid nodes, typically via USE references'/>
 59                           <field name='addChildrentype='MFNodeaccessType='inputOnly'
                          appinfo='references one or more HAnimHumanoid nodes, typically via USE references'/>
 60                           <field name='removeChildrentype='MFNodeaccessType='inputOnly'
                          appinfo='references one or more HAnimHumanoid nodes, typically via USE references'/>
 61                           <field name='traceEnabledtype='SFBoolaccessType='inputOutput'
                          appinfo='debug trace to Browser output console'/>
 62                           <IS>
 63                                <connect nodeField='enabledprotoField='enabled'/>
 64                                <connect nodeField='setPoseprotoField='setPose'/>
 65                                <connect nodeField='nameprotoField='name'/>
 66                                <connect nodeField='namesPoseJointsprotoField='namesPoseJoints'/>
 67                                <connect nodeField='positionsPoseJointsprotoField='positionsPoseJoints'/>
 68                                <connect nodeField='rotationsPoseJointsprotoField='rotationsPoseJoints'/>
 69                                <connect nodeField='whichChoiceprotoField='whichChoice'/>
 70                                <connect nodeField='childrenprotoField='children'/>
 71                                <connect nodeField='addChildrenprotoField='addChildren'/>
 72                                <connect nodeField='removeChildrenprotoField='removeChildren'/>
 73                                <connect nodeField='traceEnabledprotoField='traceEnabled'/>
 74                           </IS>
  <![CDATA[
          

ecmascript:

// Needed functionality:
// a. get access to a humanoid
// b. confirm skeletalConfiguration = 'BASIC' so we know that it has a valid default pose
// c. walk the tree for all joints, then set transation, scale, rotation to default values
// d. for each name/position/rotation triplet in the pose arrays, update the appropriate
//    HAnimJoint nodes to that corresponding set of values

var scriptName='HAnimPoseScript';

function initialize ()
{
    // TODO author initialization code (if any) goes here
    
    // check that array sizes are identical for namesPoseJoints, positionsPoseJoints, rotationsPoseJoints
    
    // check humanoid connectivity

    tracePrint ('initialization() successful');
}
function set_enabled (eventValue)
{
    // input eventValue received for inputOutput field enabled
    enabled = eventValue;
    tracePrint ('enabled = ' + enabled);

    // TODO author code (if any) goes here
}
function setPose (eventValue)
{
    // input eventValue received for inputOnly field setPose
    setPose = eventValue;

    tracePrint ('setPose = ' + setPose);

    // TODO author code (if any) goes here
}
function set_name (eventValue)
{
    // input eventValue received for inputOutput field name
    name = eventValue;
    tracePrint ('name = ' + name);

    // TODO author code (if any) goes here
}
function set_namesPoseJoints (eventValue)
{
    // input eventValue received for inputOutput field namesPoseJoints
    namesPoseJoints = eventValue;
    tracePrint ('namesPoseJoints = ' + namesPoseJoints);

    // TODO author code (if any) goes here
}
function set_positionsPoseJoints (eventValue)
{
    // input eventValue received for inputOutput field positionsPoseJoints
    positionsPoseJoints = eventValue;
    tracePrint ('positionsPoseJoints = ' + positionsPoseJoints);

    // TODO author code (if any) goes here
}
function set_rotationsPoseJoints (eventValue)
{
    // input eventValue received for inputOutput field rotationsPoseJoints
    rotationsPoseJoints = eventValue;
    tracePrint ('rotationsPoseJoints = ' + rotationsPoseJoints);

    // TODO author code (if any) goes here
}
function set_humanoid (eventValue)
{
    // input eventValue received for inputOutput field humanoid
    humanoid = eventValue;
    tracePrint ('humanoid = ' + humanoid);

    // TODO author code (if any) goes here
}
// ================== Trace output functions ==================

function tracePrint (outputString)
{
   // if traceEnabled is true, print outputString on X3D browser console
   if (traceEnabled)
      Browser.println ('[' + scriptName.toString()' ' + name.toString()': ' + outputString.toString() + ']');
}
function alwaysPrint (outputString)
{
      // always print outputString on X3D browser console
      Browser.println ('[' + scriptName.toString()' ' + name.toString()': ' + outputString.toString() + ']');
}
function set_traceEnabled (eventValue)
{
      // input eventValue received for inputOutput field
      traceEnabled = eventValue;
}
// ===========================================================

        
]]>
 76                      </Script>
 77                      <!-- Add any ROUTEs here that connect Script to/from prior nodes within ProtoBody -->
 78                      <!-- This embedded Script provides the X3D author with additional visibility and control over prototype inputs and outputs -->
 79                      <!-- Add any ROUTEs here that connect Script to/from prior nodes within ProtoBody -->
 80                 </ProtoBody>
 81            </ProtoDeclare>
 82            <ProtoInstance name='HAnimPose'>
 83                 <fieldValue name='namevalue='A'/>
 84                 <fieldValue name='namesPoseJointsvalue='"l_hip" "r_hip"'/>
 85                 <fieldValue name='positionsPoseJointsvalue='0 0 0 0 0 0'/>
 86                 <fieldValue name='rotationsPoseJointsvalue='0 0 1 0.2 0 0 1 -0.2'/>
 87            </ProtoInstance>
 88            <ProtoInstance name='HAnimPose'>
 89                 <fieldValue name='namevalue='T'/>
 90                 <fieldValue name='namesPoseJointsvalue='"l_shoulder" "r_shoulder"'/>
 91                 <fieldValue name='positionsPoseJointsvalue='0 0 0 0 0 0'/>
 92                 <fieldValue name='rotationsPoseJointsvalue='0 0 1 1.57 0 0 1 -1.57'/>
 93            </ProtoInstance>
 94            <!-- Add any ROUTEs here that connect ProtoInstance to/from prior nodes in Scene (and outside of ProtoDeclare) -->
 95       </Scene>
 96  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: HAnimPoseScriptOperations, ModelInfo, PrototypeRootNode

Index for ProtoDeclare definition: HAnimPose
-->
X3D Tooltips element index: connect, field, fieldValue, head, IS, meta, MetadataString, NavigationInfo, ProtoBody, ProtoDeclare, ProtoInstance, ProtoInterface, Scene, Script, Switch, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and 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.

HAnimPoseScriptOperations
Script
No direct ROUTE connection found for events to/from this node.
Contains MFNode fields with direct access to another node.
This Script has no direct access to other nodes. 

line 82
ProtoInstance
HAnimPose
No direct ROUTE connection found for events to/from this node.
This ProtoInstance contains SFNode/MFNode fieldValue declarations with
direct access to other nodes, and thus has potential to produce run-time animation. 

line 88
ProtoInstance
HAnimPose
No direct ROUTE connection found for events to/from this node.
This ProtoInstance contains SFNode/MFNode fieldValue declarations with
direct access to other nodes, and thus has potential to produce run-time animation. 

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/HelloWorldScenes/HAnimPosePrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/HelloWorldScenes/HAnimPosePrototype.x3d -->

<!-- Color-coding legend: X3D terminology <X3dNode  DEF='idNamefield='value'/> matches XML terminology <XmlElement  DEF='idNameattribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
    <ProtoInstance name='ProtoName'> <field name='fieldName'/> </ProtoInstance> -->

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