背景の設定はBackgroundノードで行います。
VRMLでは、背景を次のように定義しています。
Backgroundノードの定義形式を次に示します。
Background { eventIn SFBool set_bind exposedField MFFloat groundAngle [] exposedField MFColor groundColor [] exposedField MFString backUrl [] exposedField MFString bottomUrl [] exposedField MFString frontUrl [] exposedField MFString leftUrl [] exposedField MFString rightUrl [] exposedField MFString topUrl [] exposedField MFFloat skyAngle [] exposedField MFColor skyColor 0 0 0 eventOut SFBool isBound } |
skyColorフィールドとskyAngleフィールドおよびgroundColorフィールドとgroundAngleフィールドを指定した例を示します。
この例では地面は地平線まで定義されています。VRMLブラウザでビューポイントの位置を変えて空や地面がどのように見えるのか試してみてください。
#VRML V2.0 utf8 #background1.wrl #背景 地面が 地平線(90°)まで Background { skyAngle [ 0.785 1.3 1.57 2.07 ] skyColor [ 0.6 0.6 1, 0.7 0.7 1, 0.8 0.8 1, 0.9 0.9 1, 1 1 1 ] groundAngle [ 0.35 0.785 1.20 1.57 ] #ground --> horizon groundColor [0.4 0.2 0.2, 0.4 0.3 0.3, 0.4 0.4 0.4, 0.4 0.5 0.5, 0.4 0.6 0.6] } #視点 Viewpoint { description "horison" position 0 0 0 } Viewpoint { description "zenith" position 0.0 0.0 0 orientation -1 0 0 -1.57 } Viewpoint { description "nadir" position 0.0 0.0 0 orientation -1 0 0 1.57 } |
この例では地面は地平線より下の位置まで定義されています。VRMLブラウザでビューポイントの位置を変えて空や地面がどのように見えるのか試してみてください。
#VRML V2.0 utf8 #background2.wrl #背景 地面が 70°まで Background { skyAngle [ 0.785 1.3 1.57 2.07 ] skyColor [ 0.6 0.6 1, 0.7 0.7 1, 0.8 0.8 1, 0.9 0.9 1, 1 1 1 ] groundAngle [ 0.35 0.785 1.22 ] #ground --> 1.22 (70°) groundColor [0.4 0.2 0.2, 0.4 0.3 0.3, 0.4 0.4 0.4, 0.4 0.5 0.5,0.4 0.6 0.6] } #視点 Viewpoint { description "horison" position 0 0 0 } Viewpoint { description "zenith" position 0.0 0.0 0 orientation -1 0 0 -1.57 } Viewpoint { description "nadir" position 0.0 0.0 0 orientation -1 0 0 1.57 } |
backUrl、bottomUrl、frontUrl、leftUrl、rightUrl、topUrlフィールドを指定した例を示します。
この例では立方体の全部の面にイメージファイルを貼り付けています。VRMLブラウザでビューポイントの位置を変えて各面がどのように見えるのか試してみてください。
#VRML V2.0 utf8 #background_t1.wrl #背景 imagefile Background { frontUrl "image/sh005.gif" #赤煉瓦 backUrl "image/sh026.gif" #白ブロック leftUrl "image/sh022.gif" #緑ブロック rightUrl "image/sy013.gif" #大理石 topUrl "image/se003.gif" #空 bottomUrl "image/sh189.gif" #土 } #視点 Viewpoint { description "front" position 0 0 0 } Viewpoint { description "right" position 0.0 0.0 0 orientation 0 -1 0 1.57 } Viewpoint { description "back" position 0.0 0.0 0 orientation 0 -1 0 3.14 } Viewpoint { description "left" position 0.0 0.0 0 orientation 0 -1 0 -1.57 } Viewpoint { description "top" position 0.0 0.0 0 orientation -1 0 0 -1.57 } Viewpoint { description "bottom" position 0.0 0.0 0 orientation -1 0 0 1.57 } |
この例では立方体の一部の面にイメージファイルを貼り付けています。VRMLブラウザでビューポイントの位置を変えて各面がどのように見えるのか試してみてください。
#VRML V2.0 utf8 #background_t2.wrl #背景 imagefile と sky, ground Background { skyAngle [ 0.785 1.3 1.57 2.07 ] skyColor [ 0.6 0.6 1, 0.7 0.7 1, 0.8 0.8 1, 0.9 0.9 1, 1 1 1 ] groundAngle [ 0.35 0.785 1.22 ] #ground --> 1.22 (70°) groundColor [0.4 0.2 0.2, 0.4 0.3 0.3, 0.4 0.4 0.4, 0.4 0.5 0.5,0.4 0.6 0.6] backUrl "image/sh026.gif" #白ブロック leftUrl "image/sh022.gif" #緑ブロック rightUrl "image/sy013.gif" #大理石 } #視点 Viewpoint { description "front" position 0 0 0 } Viewpoint { description "right" position 0.0 0.0 0 orientation 0 -1 0 1.57 } Viewpoint { description "back" position 0.0 0.0 0 orientation 0 -1 0 3.14 } Viewpoint { description "left" position 0.0 0.0 0 orientation 0 -1 0 -1.57 } Viewpoint { description "top" position 0.0 0.0 0 orientation -1 0 0 -1.57 } Viewpoint { description "bottom" position 0.0 0.0 0 orientation -1 0 0 1.57 } |