cityflight_0.wrl source
#VRML V2.0 utf8

# 視点
Viewpoint {
position 7 20 12
orientation -1 0.14 0 1.3
description "vp1"
}
Viewpoint {
position 4.5 2 27
orientation -0.4 0.4 -0.8 0.23
description "vp2"
}

# ナビゲート情報
NavigationInfo {
type "EXAMINE"
headlight FALSE
}

# 太陽光
DirectionalLight {
direction -0.7 -1 -1
ambientIntensity 0.7
}

# 白い背景
Background {
skyColor 1 1 1
}

# 霧
Fog {
visibilityRange 50
fogType "EXPONENTIAL"
}

# 雛型は表示されないようにSwitchノード内に納めています。
Switch {
choice [
# ビルの雛型
DEF Buildings Group {
children [
# 歩道
Transform {
translation 0 0.02 0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0.8 0.65 0.6
}
texture ImageTexture {
url "tile.png"
}
textureTransform TextureTransform {
scale 40 40
}
}
geometry Box {
size 6 0.04 6
}
}
]
}
# 石畳
Transform {
translation 0 0.04 0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0.95 0.95 1
}
texture ImageTexture {
url "floor.png"
}
textureTransform TextureTransform {
scale 10 10
}
}
geometry Box {
size 4.75 0.04 4.75
}
}
]
}
# ビルA棟
Transform {
translation 1 6 1
children [
DEF Building-Sp Shape {
appearance Appearance {
material Material {
diffuseColor 0.8 0.8 0.9
}
texture ImageTexture {
url "wall.png"
}
textureTransform TextureTransform {
scale 8 30
}
}
geometry Box {
size 2.5 12 2.5
}
}
]
}
Transform {
translation 1 0.06 1
children [
DEF Green-Sp Shape {
appearance Appearance {
material Material {
diffuseColor 0.1 0.4 0.2
}
texture ImageTexture {
url "green.png"
}
textureTransform TextureTransform {
scale 20 20
}
}
geometry Box {
size 2.7 0.06 2.7
}
}
]
}
Transform {
translation 1 12.03 1
children [
DEF Roof-Sp Shape {
appearance Appearance {
material Material {
diffuseColor 1 1 0.95
}
texture ImageTexture {
url "roof.png"
}
}
geometry Box {
size 2.5 0.06 2.5
}
}
]
}
# ビルB棟
Transform {
translation -1 6 -1
children USE Building-Sp
}
Transform {
translation -1 0.06 -1
children USE Green-Sp
}
Transform {
translation -1 12.03 -1
children USE Roof-Sp
}
# ビル中央
Transform {
translation 0 2 0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0.9 0.9 1.0
}
}
geometry Box {
size 2 4 2
}
}
]
}
Transform {
translation 0 7 0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0.9 0.9 0.85
}
}
geometry Box {
size 1 12 1
}
}
]
}
]
}
# 道路の雛型
DEF Road Group {
children [
Transform {
translation -2 -0.04 -2
children [
DEF Road-Sp Shape {
appearance Appearance {
material Material {
diffuseColor 0.3 0.3 0.3
}
texture ImageTexture {
url "road.png"
}
}
geometry Box {
size 4 0.04 4
}
}
]
}
Transform {
translation -2 -0.04 2
rotation 0 1 0 1.5708
children USE Road-Sp
}
Transform {
translation 2 -0.04 2
rotation 0 1 0 3.1416
children USE Road-Sp
}
Transform {
translation 2 -0.04 -2
rotation 0 1 0 4.7124
children USE Road-Sp
}
]
}
]
}

# ビルと道路などが配置される場所
DEF City-Tf Transform {}

# ビルと道路配置スクリプト
DEF Sc Script {
eventOut MFNode children
field SFNode Buildings USE Buildings
field SFNode Road USE Road
url "javascript:

function initialize () {

var Sections = new MFNode ();

for ( var z = -3; z <= 3; z++ ) {
for ( var x = -2; x <= 2; x++ ) {

var OneSection = new SFNode ( 'Transform {}' );
OneSection.translation = new SFVec3f( x * 8, 0, z * 8 );
OneSection.children[0] = Buildings;
OneSection.children[1] = Road;

Sections[Sections.length] = OneSection;

}
}

children = Sections;
}

"
}

ROUTE Sc.children TO City-Tf.children

# 都市スクロール用タイムセンサー
DEF TiS TimeSensor {
loop TRUE
}

# 都市スクロールアニメデータ
# 1区画分のみZ軸に沿ってずらしているだけだが、ループさせると無限に続いているように見える。
DEF PI PositionInterpolator {
key [ 0.0 1.0 ]
keyValue [
0 0 0
0 0 8
]
}

ROUTE TiS.fraction_changed TO PI.set_fraction
ROUTE PI.value_changed TO City-Tf.translation