虚拟实境模型语言基础教程及实例

Virtual Reality Modeling Language (VRML) Basic Tutorial with Examples


实例(五〕龙飞在天


或言靖边名将,武林巨擘皆武曲星谪下凡尘。是可信欤?缘李小龙故,吾宁信
之。

本实例试图体现的就是李小龙回归到那苍苍中武曲星座里的景象:

(一〕从第一行开始:

#VRML V2.0 utf8 

WorldInfo {   
   title "永恒"   
   info [   
      "Author: 金臂螳螂",   
      "Date: March 1, 1998 (Sun)"  
   ]   
}   

NavigationInfo {   
   type "EXAMINE"   
}

Background {   
      groundAngle [0.523, 1.047, 1.571]  
      groundColor [0 0 0, 0 0 1, 0 0 1, 0 1 1]  
      skyAngle [0.523, 1.047, 1.571]  
      skyColor [1 1 1, 1 1 1, 0 1 1, 0 1 1]  
}

Group {  
   children [   

      DEF EntryView Viewpoint { #此虚拟实境亦规定了进入,内外三个视点。 
      fieldOfView 1.57   
      orientation 1 0 0 0.79   
      position 0.0 -7.0 10.0   
      description "EntryView"  
      },

      DEF Outside Viewpoint {   
      position 0 0 40   
      description "Outside"   
      },

      DEF Inside Viewpoint {   
      position 0 0 6  
      description "Inside"   
      }   

   ]   
}

(二〕设计星座:

Group {  
   children [   

   DEF Lee Transform {   
     children Shape {   
       appearance Appearance {   
       material Material { emissiveColor 1.0 0.5 0.0 }   
       texture ImageTexture {url "stand.gif"}  #粘贴图案为李小龙。 
       }   
       geometry Box {size 3 3 3}   #立方体   
     },   
   },

   DEF Lee Transform {   
      
    children Shape { appearance Appearance { material Material { emissiveColor 1.0 0.5 0.0 transparency 0.8 #颜色及透明的协调形成一雾状球网。 } } geometry Sphere {radius 10} #圆球 }, }, DEF Long Transform { translation 4.0 0.0 0.0 center -4.0 0.0 0.0 children [ Shape { appearance Appearance { material Material { diffuseColor 0.0 0.0 1.0 specularColor 0.9 0.9 0.9 shininess 0.3 } texture ImageTexture {url "reptile.gif"} #粘贴图案为龙。 } geometry Sphere { radius 0.5 } #球A,绕立方体(李小龙)旋转。 }, DEF Snake Transform { translation 1.0 0.0 0.0 center -1.0 0.0 0.0 children Shape { appearance Appearance { material Material { diffuseColor 0.7 0.7 0.7 shininess 1.3 } } geometry Sphere {radius 0.2} #球B,绕球A旋转。 } } ] }, 以上,以李小龙(立方体)为恒星,另设球A绕李小龙转,球B绕球A转。最外层有一 个雾状球型网,罩住星座以增加些神秘感。 (三〕设计星座的旋转: DEF Bruce TimeSensor { cycleInterval 8.0 loop TRUE }, DEF Reptile TimeSensor { cycleInterval 5.0 loop TRUE }, DEF Serpent TimeSensor { cycleInterval 2.0 loop TRUE }, DEF LeePath OrientationInterpolator { key [ 0.0, 0.50, 1.0 ] keyValue [ 0.0 0.0 1.0 0.0, 0.0 0.0 1.0 3.14, 0.0 0.0 1.0 6.28 ] }, DEF LongPath OrientationInterpolator { key [ 0.0, 0.50, 1.0 ] keyValue [ 0.0 0.0 1.0 0.0, 0.0 0.0 1.0 3.14, 0.0 0.0 1.0 6.28 ] }, DEF SnakePath OrientationInterpolator { key [ 0.0, 0.50, 1.0 ] keyValue [ 0.0 0.0 1.0 0.0, 0.0 0.0 1.0 3.14, 0.0 0.0 1.0 6.28 ] } ] } ROUTE Bruce.fraction_changed TO LeePath.set_fraction ROUTE Reptile.fraction_changed TO LongPath.set_fraction ROUTE Serpent.fraction_changed TO SnakePath.set_fraction ROUTE LeePath.value_changed TO Lee.set_rotation ROUTE LongPath.value_changed TO Long.set_rotation ROUTE SnakePath.value_changed TO Snake.set_rotation #以上事件的设计教为复杂,不再赘述。提纲掣领,慢慢推求,自然明澈。 #不过一点数理,又有何难? #学而不知数理,犹如宝镜微尘,世上六艺乱纷纷,数乃人之根本。 #聪明蒙童易得,愚昧皓首难成,漫同高士共评论,数澈不差分寸。 (四〕至此,将所有红色指令按其出现的顺序剪切到一个文件里作为源码,再存 为*.wrl文件,如e_Dragon.wrl。 最后,浏览此e_Dragon.wrl虚拟实境,并逐一对照核实源码中所言效果,以知 其所以然。 练习题:阅读并理解此虚拟实境之源码,修改源码,取消雾状网。

页眉

主页