[x3d-public] Display a reference coordinate system at the bottom left of my view

Hans Moritz Guenther hgunther at mit.edu
Tue Jun 25 04:00:26 PDT 2024


Thanks for your help.

For the benefit of people who search through the mailing list later, 
here is the code that ended up with:

I still needed rotations. The ProximitySensor gives me the location and 
the viewing direction of the viewpoint, so I'm rotating my x,y,z arrows 
around the location of the viewpoint to make sure they stay in view, 
even as the viewpoint looks in different directions (and not "behind" 
the viewpoint). Then, I need a second rotation to undo that rotation to 
keep the x,y,z aligned with the coordinate axes.

I thought about how to undo that rotation for a while and in the end 
used a short js script to reverse the rotation.

Code is below,

Moritz

<ProximitySensorDEF='HereIAm'size='1000000 1000000 
1000000'></ProximitySensor>
<TransformDEF='HUD'>
<TransformDEF='PushBack'translation='-2.5 -2.5 -10'>
<TransformDEF='layer2'>
<Group>
<!-- Vertical Y arrow and label -->
<GroupDEF='ArrowGreen'>
<Shape>
<CylinderDEF='ArrowCylinder'radius='.025'top='false'></Cylinder>
<AppearanceDEF='Green'>
<MaterialdiffuseColor='.1 .6 .1'emissiveColor='.05 .2 .05'></Material>
</Appearance>
</Shape>
<Transformtranslation='0 1 0'>
<Shape>
<ConeDEF='ArrowCone'bottomRadius='.05'height='.1'></Cone>
<AppearanceUSE='Green'></Appearance>
</Shape>
</Transform>
</Group>
<Transformtranslation='0 1.5 0'>
<Billboard>
<Shape>
<AppearanceDEF='LABEL_APPEARANCE'>
<MaterialdiffuseColor='1 1 .3'emissiveColor='.33 .33 .1'></Material>
</Appearance>
<Textstring='"Dispersion" "+Y"'>
<FontStyleDEF='LABEL_FONT'family='"SANS"'justify='"MIDDLE" 
"MIDDLE"'size='.2'></FontStyle>
</Text>
</Shape>
</Billboard>
</Transform>
</Group>
<Transformrotation='0 0 1 -1.57079'>
<!-- Horizontal X arrow and label -->
<Group>
<GroupDEF='ArrowRed'>
<Shape>
<CylinderUSE='ArrowCylinder'></Cylinder>
<AppearanceDEF='Red'>
<MaterialdiffuseColor='.7 .1 .1'emissiveColor='.33 0 0'></Material>
</Appearance>
</Shape>
<Transformtranslation='0 1 0'>
<Shape>
<ConeUSE='ArrowCone'></Cone>
<AppearanceUSE='Red'></Appearance>
</Shape>
</Transform>
</Group>
<Transformrotation='0 0 1 1.57079'translation='-0.05 1.1 0'>
<!-- note label rotated back to original coordinate frame -->
<Billboard>
<Shape>
<AppearanceUSE='LABEL_APPEARANCE'></Appearance>
<Textstring='"opt. axis" "+X"'>
<FontStyleUSE='LABEL_FONT'></FontStyle>
</Text>
</Shape>
</Billboard>
</Transform>
</Group>
</Transform>
<Transformrotation='1 0 0 1.57079'>
<!-- Perpendicular Z arrow and label, note right-hand rule -->
<Group>
<GroupDEF='ArrowBlue'>
<Shape>
<CylinderUSE='ArrowCylinder'></Cylinder>
<AppearanceDEF='Blue'>
<MaterialdiffuseColor='.3 .3 1'emissiveColor='.1 .1 .33'></Material>
</Appearance>
</Shape>
<Transformtranslation='0 1 0'>
<Shape>
<ConeUSE='ArrowCone'></Cone>
<AppearanceUSE='Blue'></Appearance>
</Shape>
</Transform>
</Group>
<Transformrotation='1 0 0 -1.57079'translation='0 1.1 -0.05'>
<!-- note label rotated back to original coordinate frame -->
<Billboard>
<Shape>
<AppearanceUSE='LABEL_APPEARANCE'></Appearance>
<Textstring='"cross-disp" "+Z"'>
<FontStyleUSE='LABEL_FONT'></FontStyle>
</Text>
</Shape>
</Billboard>
</Transform>
</Group>
</Transform>
</Transform>
</Transform>
</Transform>
<Scripttype='model/x3d+xml'DEF='InvertRotationScript'>
<field accessType='inputOnly' type='SFRotation' 
name='invert_rotation'></field>
<field accessType='outputOnly' type='SFRotation' 
name='inverted_rotation'></field>
<![CDATA[ecmascript:
function invert_rotation (value, time)
{
inverted_rotation = new SFRotation (value[0], value[1], value[2], 
-value[3]);
}
]]>
</Script>
<ROUTEfromNode='HereIAm'fromField='orientation_changed'toNode='HUD'toField='rotation'></ROUTE>
<ROUTEfromNode='HereIAm'fromField='position_changed'toNode='HUD'toField='translation'></ROUTE>
<ROUTEfromNode='HereIAm'fromField='orientation_changed'toNode='InvertRotationScript'toField='invert_rotation'></ROUTE>
<ROUTEfromNode='InvertRotationScript'fromField='inverted_rotation'toNode='layer2'toField='rotation'></ROUTE>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20240625/0fe812eb/attachment-0001.html>


More information about the x3d-public mailing list