<?xml version="1.0" encoding="UTF-8"?>
<X3D>
<Scene>
<NavigationInfo
type='
"EXAMINE"'
/>
<!-- Viewpoint #1 -->
<Viewpoint position='0 8 11' orientation='-1 0 0 0.75' description='bird'/>
<!-- Background -->
<Background
skyAngle='1.4 1.8 3'
skyColor='
0 0 1
0.8 1 1
0 0.7 0'
/>
<!-- field -->
<Transform translation='0 -0.05 0'>
<Shape>
<Appearance>
<Material diffuseColor='1 1 1'/>
<ImageTexture
url='
"field.jpg"'
/>
<TextureTransform scale='3 3'/>
</Appearance>
<Box size='10 0.1 10'/>
</Shape>
</Transform>
<!-- car -->
<Transform DEF='Car-Tf'>
<!-- body -->
<Transform translation='0 0.1 0' rotation='1 0 0 -1.571' scale='1 1 0.5'>
<Shape>
<Appearance>
<Material diffuseColor='1 0 0'/>
</Appearance>
<Cone bottomRadius='0.2' height='0.5'/>
</Shape>
</Transform>
<!-- tire -->
<Transform translation='0.1 0.1 -0.15' rotation='0 0 1 1.571'>
<Shape DEF='Tire-Sp'>
<Appearance>
<Material diffuseColor='0 0 0'/>
</Appearance>
<Cylinder radius='0.1' height='0.05'/>
</Shape>
</Transform>
<Transform translation='-0.1 0.1 -0.15' rotation='0 0 1 1.571'>
<Shape USE='Tire-Sp'/>
</Transform>
<Transform translation='-0.2 0.1 0.25' rotation='0 0 1 1.571'>
<Shape USE='Tire-Sp'/>
</Transform>
<Transform translation='0.2 0.1 0.25' rotation='0 0 1 1.571'>
<Shape USE='Tire-Sp'/>
</Transform>
<!-- Viewpoint #2 -->
<Viewpoint position='0 2 4' orientation='-1 0 0 0.5' description='driver'/>
</Transform>
<!-- switches -->
<Transform DEF='Console-Tf'>
<Transform translation='0 -0.1 -0.5'>
<!-- stop switch -->
<Group>
<TouchSensor DEF='Stop-ThS'/>
<Shape>
<Appearance>
<Material diffuseColor='1 1 0'/>
</Appearance>
<Box size='0.03 0.03 0.03'/>
</Shape>
</Group>
<!-- forword switch -->
<Transform translation='0 0.06 0'>
<TouchSensor DEF='F-ThS'/>
<Shape DEF='Arrow-Sp'>
<Appearance>
<Material diffuseColor='0 1 1'/>
</Appearance>
<Cone bottomRadius='0.025' height='0.05'/>
</Shape>
</Transform>
<!-- back switch -->
<Transform translation='0 -0.06 0'>
<TouchSensor DEF='B-ThS'/>
<Transform rotation='0 0 1 3.141'>
<Shape USE='Arrow-Sp'/>
</Transform>
</Transform>
<!-- turn right switch -->
<Transform translation='0.06 0 0'>
<TouchSensor DEF='R-ThS'/>
<Transform rotation='0 0 1 -1.571'>
<Shape USE='Arrow-Sp'/>
</Transform>
</Transform>
<!-- turn left switch -->
<Transform translation='-0.06 0 0'>
<TouchSensor DEF='L-ThS'/>
<Transform rotation='0 0 1 1.571'>
<Shape USE='Arrow-Sp'/>
</Transform>
</Transform>
</Transform>
</Transform>
<ProximitySensor DEF='Console-PrS' size='1000 1000 1000'/>
<ROUTE fromNode='Console-PrS' fromField='position_changed' toNode='Console-Tf' toField='set_translation'/>
<ROUTE fromNode='Console-PrS' fromField='orientation_changed' toNode='Console-Tf' toField='set_rotation'/>
<TimeSensor DEF='TiS' loop='TRUE'/>
<Script DEF='Sc'>
<field accessType='inputOnly' type='SFBool' name='isActive_Stop'/>
<field accessType='inputOnly' type='SFBool' name='isActive_Forward'/>
<field accessType='inputOnly' type='SFBool' name='isActive_Back'/>
<field accessType='inputOnly' type='SFBool' name='isActive_Right'/>
<field accessType='inputOnly' type='SFBool' name='isActive_Left'/>
<field accessType='inputOnly' type='SFFloat' name='set_fraction'/>
<field accessType='outputOnly' type='SFVec3f' name='positionCar'/>
<field accessType='outputOnly' type='SFRotation' name='orientationCar'/>
<field accessType='initializeOnly' type='SFVec3f' name='moveVec' value='0 0 -1'/>
<field accessType='initializeOnly' type='SFVec3f' name='initDirection' value='0 0 -1'/>
<field accessType='initializeOnly' type='SFFloat' name='moveSpeed' value='0'/>
<field accessType='initializeOnly' type='SFFloat' name='turnSpeed' value='0'/>
<field accessType='initializeOnly' type='SFFloat' name='oldF' value='0'/>
<field accessType='initializeOnly' type='SFBool' name='isCortona' value='FALSE'/>
<![CDATA[ecmascript:
function initialize () {
positionCar = new SFVec3f (0, 0, 0);
// 車の向きをy軸を中心とした回転に設定する。
orientationCar = new SFRotation (0, 1, 0, 0);
// 実行中のブラウザーが Cortona か調べる。
isCortona = (Browser.getName() == 'Cortona VRML Client');
}
function isActive_Stop () {
moveSpeed = 0;
}
function isActive_Forward () {
moveSpeed = 1;
}
function isActive_Back () {
moveSpeed = -1;
}
function isActive_Right (active) {
// 右ターンスイッチが押されたならば turnSpeed を -1 に、離されたならば 0 にセットする。
turnSpeed = -active;
}
function isActive_Left (active) {
// 左ターンスイッチが押されたならば turnSpeed を 1 に、離されたならば 0 にセットする。
turnSpeed = active;
}
function set_fraction (f) {
// fraction の変化量を得る。
var df = f - oldF;
if ( df < 0 ) df++;
oldF = f;
// ブラウザーがCortonaならば、df にフレームレートの逆数を入れる。
if ( isCortona ) {
var fps = Browser.getCurrentFrameRate();
if ( fps > 0.0 ) df = 1 / fps;
}
if ( turnSpeed != 0 ) {
// 車の向きを変える。
orientationCar.angle += turnSpeed * df;
// 車の向きに従って移動ベクトルを回転させる。
moveVec = orientationCar.multVec( initDirection );
}
if ( moveSpeed != 0 ) {
// 車を移動させる。
positionCar = moveVec.multiply( moveSpeed * df ).add( positionCar );
}
}
]]>
</Script>
<ROUTE fromNode='Stop-ThS' fromField='isActive' toNode='Sc' toField='isActive_Stop'/>
<ROUTE fromNode='F-ThS' fromField='isActive' toNode='Sc' toField='isActive_Forward'/>
<ROUTE fromNode='B-ThS' fromField='isActive' toNode='Sc' toField='isActive_Back'/>
<ROUTE fromNode='R-ThS' fromField='isActive' toNode='Sc' toField='isActive_Right'/>
<ROUTE fromNode='L-ThS' fromField='isActive' toNode='Sc' toField='isActive_Left'/>
<ROUTE fromNode='TiS' fromField='fraction_changed' toNode='Sc' toField='set_fraction'/>
<ROUTE fromNode='Sc' fromField='positionCar' toNode='Car-Tf' toField='translation'/>
<ROUTE fromNode='Sc' fromField='orientationCar' toNode='Car-Tf' toField='rotation'/>
</Scene>
</X3D>