| 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
|
| 3 | <X3D profile='Immersive' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'> |
| 4 | <head> |
| 5 | <meta name='title' content=' ProjectileSliderBarPrototype.x3d '/> |
| 6 | <meta name='description' content='A generic slider bar prototype. Colors, size of the bar and name are changable.'/> |
| 7 | <meta name='creator' content='Ozan APAYDIN'/> |
| 8 | <meta name='created' content='1 December 2001'/> |
| 9 | <meta name='modified' content='30 November 2024'/> |
| 10 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Basic/StudentProjects/ProjectileSliderBarPrototype.x3d '/> |
| 11 | <meta name='generator' content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
| 12 | <meta name='license' content='../license.html'/> |
| 13 | </head> |
| 14 | <Scene> |
| 15 | <WorldInfo title='ProjectileSliderBarPrototype.x3d'/> |
| 16 | <ProtoDeclare name='ProjectileSliderBar'> |
| 17 | <ProtoInterface> |
| 18 |
<field name='name' type='MFString' accessType='initializeOnly'
appinfo='Name of the Slider Bar. It appears on the left side of the bar.'/> |
| 19 |
<field name='length' type='SFFloat' value='1' accessType='initializeOnly'
appinfo='Length of the Slider bar. According to given value bar will arrange itself.'/> |
| 20 |
<field name='width' type='SFFloat' value='1' accessType='initializeOnly'
appinfo='Width of the Slider bar. According to given value bar will arrange itself.'/> |
| 21 |
<field name='maxValue' type='SFFloat' value='1' accessType='initializeOnly'
appinfo='Max. value of Slider Bar.It can be assigned a positive or a negative value.'/> |
| 22 |
<field name='minValue' type='SFFloat' value='0' accessType='initializeOnly'
appinfo='Min. value of Slider Bar. It can be assigned a positive or a negative value.'/> |
| 23 |
<field name='barColor' type='SFColor' value='1 0 0' accessType='initializeOnly'
appinfo='Color of Slider Bar.'/> |
| 24 |
<field name='pointerColor' type='SFColor' value='1 1 0' accessType='initializeOnly'
appinfo='Pointer Color of Slider Bar.'/> |
| 25 |
<field name='nameColor' type='SFColor' value='1 0 1' accessType='initializeOnly'
appinfo='Slider Bar Name Color.'/> |
| 26 |
<field name='currentValueColor' type='SFColor' value='0.2 0.8 0.2' accessType='initializeOnly'
appinfo='Color of Current Value text.'/> |
| 27 |
<field name='currentValueInt' type='SFInt32' accessType='outputOnly'
appinfo='If the precision is 0 current Value will be output in this eventOut field as Integer else in currentValueFloat eventOut field as Float.'/> |
| 28 |
<field name='currentValueFloat' type='SFFloat' accessType='outputOnly'
appinfo='If the precision is NOT 0 current Value will be output in this eventOut field as Float else in currentValueInt eventOut field as Integer.'/> |
| 29 |
<field name='precision' type='SFInt32' value='2' accessType='initializeOnly'
appinfo='Count of the numbers after Decimal Point. Example : If precision is 2 1.562777 -> 1.56'/> |
| 30 |
<field name='translation' type='SFVec3f' value='0 0 0' accessType='initializeOnly'
appinfo='Translation values of Slider Bar to define its location on the screen.'/> |
| 31 | </ProtoInterface> |
| 32 | <ProtoBody> |
| 33 | <Group DEF='HUDGroup'> |
| 34 | <Collision enabled='false'> |
| 35 |
<!-- ROUTE information for HudProx node:
[from position_changed to HudTransform.set_translation
]
[from orientation_changed to HudTransform.set_rotation
]
[self-route from position_changed to center
]
-->
<ProximitySensor DEF='HudProx' size='1000000 1000000 1000000'/> |
| 36 |
<!-- ROUTE information for HudTransform node:
[from HudProx.position_changed to set_translation
]
[from HudProx.orientation_changed to set_rotation
]
-->
<Transform DEF='HudTransform'> |
| 37 | <Transform translation='0 0 -0.2'> |
| 38 | <Transform DEF='SliderTransform'> |
| 39 | <IS> |
| 40 | <connect nodeField='translation' protoField='translation'/> |
| 41 | </IS> |
| 42 | <Group DEF='SliderShape'> |
| 43 |
<!-- Transform
barTransform is a DEF node that has 1 USE node: USE_1 -->
<Transform DEF='barTransform'> |
| 44 | <Shape> |
| 45 | <Appearance> |
| 46 | <Material DEF='BarColor' diffuseColor='0 0 1'> |
| 47 | <IS> |
| 48 | <connect nodeField='diffuseColor' protoField='barColor'/> |
| 49 | </IS> |
| 50 | </Material> |
| 51 | </Appearance> |
| 52 | <Box DEF='bar' size='0.05 0.001 0.000001'/> |
| 53 | </Shape> |
| 54 | </Transform> |
| 55 |
<!-- Transform
pointerTransform is a DEF node that has 1 USE node: USE_1
<!-- ROUTE information for pointerTransform node: [from SVPlaneSensor.translation_changed to set_translation ] --> <Transform DEF='pointerTransform'> |
| 56 | <Shape> |
| 57 | <Appearance> |
| 58 | <Material DEF='PointerColor' diffuseColor='1 1 0'> |
| 59 | <IS> |
| 60 | <connect nodeField='diffuseColor' protoField='pointerColor'/> |
| 61 | </IS> |
| 62 | </Material> |
| 63 | </Appearance> |
| 64 | <Cone DEF='pointer' bottomRadius='0.0025' height='0.005'/> |
| 65 | </Shape> |
| 66 |
<!-- PlaneSensor
SVPlaneSensor is a DEF node that has 2 USE nodes: USE_1, USE_2
<!-- ROUTE information for SVPlaneSensor node: [from translation_changed to pointerTransform.set_translation ] [from translation_changed to CurrentValueFinder.updateCurrentValue ] --> <PlaneSensor DEF='SVPlaneSensor' maxPosition='0.025 0' minPosition='-0.025 0'/> |
| 67 | </Transform> |
| 68 |
<!-- Transform
sliderNameTransform is a DEF node that has 1 USE node: USE_1 -->
<Transform DEF='sliderNameTransform'> |
| 69 | <Shape> |
| 70 | <Text DEF='SliderName'> |
| 71 | <IS> |
| 72 | <connect nodeField='string' protoField='name'/> |
| 73 | </IS> |
| 74 | <FontStyle justify='"END"' size='0.0085' style='BOLD'/> |
| 75 | </Text> |
| 76 | <Appearance> |
| 77 | <Material DEF='sliderNameColor'> |
| 78 | <IS> |
| 79 | <connect nodeField='diffuseColor' protoField='nameColor'/> |
| 80 | </IS> |
| 81 | </Material> |
| 82 | </Appearance> |
| 83 | </Shape> |
| 84 | </Transform> |
| 85 |
<!-- Transform
currentValueTransform is a DEF node that has 1 USE node: USE_1 -->
<Transform DEF='currentValueTransform'> |
| 86 | <Shape DEF='currentValue'> |
| 87 |
<!-- Text
currentValueText is a DEF node that has 2 USE nodes: USE_1, USE_2 -->
<Text DEF='currentValueText'> |
| 88 | <FontStyle DEF='currentValueFont' justify='"BEGIN" "MIDDLE"' size='0.0085' style='BOLD'/> |
| 89 | </Text> |
| 90 | <Appearance> |
| 91 | <Material DEF='valueColor'> |
| 92 | <IS> |
| 93 | <connect nodeField='diffuseColor' protoField='currentValueColor'/> |
| 94 | </IS> |
| 95 | </Material> |
| 96 | </Appearance> |
| 97 | </Shape> |
| 98 | </Transform> |
| 99 | </Group> |
| 100 | </Transform> |
| 101 | </Transform> |
| 102 | </Transform> |
| 103 | </Collision> |
| 104 | </Group> |
| 105 | <Script DEF='ShapeOrganizer' directOutput='true'> |
| 106 | <field name='Length' type='SFFloat' accessType='initializeOnly'/> |
| 107 | <field name='Width' type='SFFloat' accessType='initializeOnly'/> |
| 108 | <field name='SliderNameTransformNode' type='SFNode' accessType='initializeOnly'> |
| 109 | <Transform USE='sliderNameTransform'/> |
| 110 | </field> |
| 111 | <field name='CurrentValueTransformNode' type='SFNode' accessType='initializeOnly'> |
| 112 | <Transform USE='currentValueTransform'/> |
| 113 | </field> |
| 114 | <field name='BarTransformNode' type='SFNode' accessType='initializeOnly'> |
| 115 | <Transform USE='barTransform'/> |
| 116 | </field> |
| 117 | <field name='PointerTransformNode' type='SFNode' accessType='initializeOnly'> |
| 118 | <Transform USE='pointerTransform'/> |
| 119 | </field> |
| 120 | <field name='CurrentValueText' type='SFNode' accessType='initializeOnly'> |
| 121 | <Text USE='currentValueText'/> |
| 122 | </field> |
| 123 | <field name='SVPlaneSensorNode' type='SFNode' accessType='initializeOnly'> |
| 124 | <PlaneSensor USE='SVPlaneSensor'/> |
| 125 | </field> |
| 126 | <IS> |
| 127 | <connect nodeField='Length' protoField='length'/> |
| 128 | <connect nodeField='Width' protoField='width'/> |
| 129 | </IS> |
<![CDATA[
ecmascript:
function initialize() {
for(i = 0; i < 3; i++) {
BarTransformNode.scale[i] = 1;
if(i == 2) {
PointerTransformNode.scale[i] = 0.1;
}
else {
PointerTransformNode.scale[i] = 1;
}
}
setBarSize();
setPointerSize();
setCurrentValueTransform();
setNameTransform();
}
function setBarSize() {
BarTransformNode.scale[0] = Length * BarTransformNode.scale[0];
BarTransformNode.scale[1] = Width * BarTransformNode.scale[1];
}
function setPointerSize() {
PointerTransformNode.scale[0] = Width * PointerTransformNode.scale[0];
PointerTransformNode.scale[1] = Width * PointerTransformNode.scale[1];
SVPlaneSensorNode.minPosition[0] = Length * SVPlaneSensorNode.minPosition[0];
SVPlaneSensorNode.maxPosition[0] = Length * SVPlaneSensorNode.maxPosition[0];
}
function setCurrentValueTransform() {
CurrentValueTransformNode.translation[0] = (BarTransformNode.scale[0] * 0.05 / 2) + (BarTransformNode.scale[1] * 0.001 * 2);
}
function setNameTransform() {
SliderNameTransformNode.translation[0] = -((BarTransformNode.scale[0] * 0.05 / 2) + (BarTransformNode.scale[1] * 0.001 * 2));
}
]]>
|
|
| 131 | </Script> |
| 132 |
<!-- ROUTE information for CurrentValueFinder node:
[from SVPlaneSensor.translation_changed to updateCurrentValue
]
-->
<Script DEF='CurrentValueFinder' directOutput='true'> |
| 133 | <field name='SVPlaneSensorNode' type='SFNode' accessType='initializeOnly'> |
| 134 | <PlaneSensor USE='SVPlaneSensor'/> |
| 135 | </field> |
| 136 | <field name='MaxValue' type='SFFloat' accessType='initializeOnly'/> |
| 137 | <field name='MinValue' type='SFFloat' accessType='initializeOnly'/> |
| 138 | <field name='CurrentValueTextNode' type='SFNode' accessType='initializeOnly'> |
| 139 | <Text USE='currentValueText'/> |
| 140 | </field> |
| 141 | <field name='updateCurrentValue' type='SFVec3f' accessType='inputOnly'/> |
| 142 | <field name='CurrentValueInt' type='SFInt32' accessType='outputOnly'/> |
| 143 | <field name='CurrentValueFloat' type='SFFloat' accessType='outputOnly'/> |
| 144 | <field name='Precision' type='SFInt32' accessType='initializeOnly'/> |
| 145 | <IS> |
| 146 | <connect nodeField='MaxValue' protoField='maxValue'/> |
| 147 | <connect nodeField='MinValue' protoField='minValue'/> |
| 148 | <connect nodeField='CurrentValueInt' protoField='currentValueInt'/> |
| 149 | <connect nodeField='CurrentValueFloat' protoField='currentValueFloat'/> |
| 150 | <connect nodeField='Precision' protoField='precision'/> |
| 151 | </IS> |
<![CDATA[
ecmascript:
var totalLength;
function initialize() {
realValue = (MaxValue + MinValue) / 2;
realValue = roundOff(realValue, Precision);
CurrentValueFloat = realValue;
CurrentValueInt = Math.round(realValue);
totalLength = SVPlaneSensorNode.maxPosition[0] - SVPlaneSensorNode.minPosition[0];
updateCurrentValueText(realValue.toString());
}
//Map pointer translation value to the real value
function updateCurrentValue(translation, timeEvent) {
var displayString;
var curPositionOnBar = translation[0] + totalLength / 2;
var x = (MaxValue - MinValue) * curPositionOnBar / totalLength;
var realValue = MinValue + x;
if(Precision == 0) { //If
CurrentValueInt = Math.round(realValue);
displayString = CurrentValueInt.toString();
}
else {
CurrentValueFloat = roundOff(realValue, Precision);
displayString = CurrentValueFloat.toString();
}
updateCurrentValueText(displayString);
}
function updateCurrentValueText(dispStr) {
CurrentValueTextNode.string[0] = dispStr;
}
//A function to round the values regarding to given precision.
function roundOff(value, precision) {
var result;
var isNegative = false;
var wholeInt = Math.round(value * Math.pow(10, precision));
//Negative numbers creates exceptional condition, therefor they are converted
//to positive values.
if(wholeInt < 0) {
wholeInt = -wholeInt;
isNegative = true;
}
var whole = wholeInt.toString();
var decPoint = whole.length - precision;
//Exception when precision is bigger than the string length
if(decPoint < 0) {
i = -decPoint;
for(i; i > 0; i--) {
whole ='0' + whole;
}
//Calculate decPoint according to new string expanded with 0s
decPoint = whole.length - precision;
}
if(whole !='0') {
//Put the decimal point on the appropriate place
result = whole.substring(0, decPoint);
result +='.';
result += whole.substring(decPoint, whole.length);
}
else { //If the string is'0', then result is'0'
result = whole;
}
//Negative numbers are altered.
if(isNegative) {
result ='-' + result;
}
//Convert the String value to Float.
resultFloat = parseFloat(result);
return resultFloat;
}
]]>
|
|
| 153 | </Script> |
| 154 | < ROUTE fromNode='HudProx' fromField='position_changed' toNode='HudTransform' toField='set_translation'/> |
| 155 | < ROUTE fromNode='HudProx' fromField='orientation_changed' toNode='HudTransform' toField='set_rotation'/> |
| 156 | < ROUTE fromNode='HudProx' fromField='position_changed' toNode='HudProx' toField='center'/> |
| 157 | < ROUTE fromNode='SVPlaneSensor' fromField='translation_changed' toNode='pointerTransform' toField='set_translation'/> |
| 158 | < ROUTE fromNode='SVPlaneSensor' fromField='translation_changed' toNode='CurrentValueFinder' toField='updateCurrentValue'/> |
| 159 | </ProtoBody> |
| 160 | </ProtoDeclare> |
| 161 | <Viewpoint description='Slider bar' position='0 0 5'/> |
| 162 | <ProtoInstance name='ProjectileSliderBar'> |
| 163 | <fieldValue name='name' value='"AFAA"'/> |
| 164 | <fieldValue name='length' value='1.5'/> |
| 165 | <fieldValue name='width' value='1'/> |
| 166 | <fieldValue name='maxValue' value='10'/> |
| 167 | <fieldValue name='minValue' value='-2'/> |
| 168 | </ProtoInstance> |
| 169 | </Scene> |
| 170 | </X3D> |
Event Graph ROUTE Table entries with 5 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.
|
CurrentValueFinder
Script |
No direct ROUTE connection found for events to/from this node. Contains SFNode fields with direct access to another node. |
|
ShapeOrganizer
Script |
No direct ROUTE connection found for events to/from this node. Contains SFNode fields with direct access to another node. |
|
HudProx
ProximitySensor position_changed SFVec3f |
HudTransform
Transform set_translation SFVec3f |
|
|
HudProx
ProximitySensor orientation_changed SFRotation |
HudTransform
Transform set_rotation SFRotation |
| line 162
ProtoInstance ProjectileSliderBar |
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. |
|
SVPlaneSensor
PlaneSensor translation_changed SFVec3f |
pointerTransform
Transform set_translation SFVec3f |
|
|
SVPlaneSensor
PlaneSensor translation_changed SFVec3f |
CurrentValueFinder
Script updateCurrentValue SFVec3f |
<!--
Color-coding 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)
<ProtoInstance name='ProtoName'>
<field
name='fieldName'/> </ProtoInstance>
-->
<!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->