⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch21.htm

📁 《Perl 5 Unreleased》
💻 HTM
📖 第 1 页 / 共 5 页
字号:
&nbsp;24&nbsp;&nbsp;} # End Separator<BR>

&nbsp;25<BR>

&nbsp;26&nbsp;&nbsp;Separator {<BR>

&nbsp;27&nbsp;&nbsp;Material {<BR>

&nbsp;28&nbsp;&nbsp;ambientColor .1 .1 .1<BR>

&nbsp;29&nbsp;&nbsp;} # End Material<BR>

&nbsp;30&nbsp;&nbsp;Transform {<BR>

&nbsp;31&nbsp;&nbsp;translation .15 .1 0<BR>

&nbsp;32&nbsp;&nbsp;} # End Transform<BR>

&nbsp;33&nbsp;&nbsp;Cube {<BR>

&nbsp;34&nbsp;&nbsp;width .1<BR>

&nbsp;35&nbsp;&nbsp;height .2<BR>

&nbsp;36&nbsp;&nbsp;depth .1<BR>

&nbsp;37&nbsp;&nbsp;}<BR>

&nbsp;38<BR>

&nbsp;39&nbsp;&nbsp;} # End Separator<BR>

&nbsp;40<BR>

&nbsp;41&nbsp;&nbsp;Separator {<BR>

&nbsp;42&nbsp;&nbsp;Material {<BR>

&nbsp;43&nbsp;&nbsp;ambientColor .2 .2 .2<BR>

&nbsp;44&nbsp;&nbsp;} # End Material<BR>

&nbsp;45&nbsp;&nbsp;Transform {<BR>

&nbsp;46&nbsp;&nbsp;translation .25 .15 0<BR>

&nbsp;47&nbsp;&nbsp;} # End Transform<BR>

&nbsp;48&nbsp;&nbsp;Cube {<BR>

&nbsp;49&nbsp;&nbsp;width .1<BR>

&nbsp;50&nbsp;&nbsp;height .3<BR>

&nbsp;51&nbsp;&nbsp;depth .1<BR>

&nbsp;52&nbsp;&nbsp;}<BR>

&nbsp;53<BR>

&nbsp;54&nbsp;&nbsp;} # End Separator<BR>

&nbsp;55<BR>

&nbsp;56&nbsp;&nbsp;Separator {<BR>

&nbsp;57&nbsp;&nbsp;Material {<BR>

&nbsp;58&nbsp;&nbsp;ambientColor .3 .3 .3<BR>

&nbsp;59&nbsp;&nbsp;} # End Material<BR>

&nbsp;60&nbsp;&nbsp;Transform {<BR>

&nbsp;61&nbsp;&nbsp;translation .35 .2 0<BR>

&nbsp;62&nbsp;&nbsp;} # End Transform<BR>

&nbsp;63&nbsp;&nbsp;Cube {<BR>

&nbsp;64&nbsp;&nbsp;width .1<BR>

&nbsp;65&nbsp;&nbsp;height .4<BR>

&nbsp;66&nbsp;&nbsp;depth .1<BR>

&nbsp;67&nbsp;&nbsp;}<BR>

&nbsp;68<BR>

&nbsp;69&nbsp;&nbsp;} # End Separator<BR>

&nbsp;70<BR>

&nbsp;71&nbsp;&nbsp;Separator {<BR>

&nbsp;72&nbsp;&nbsp;Material {<BR>

&nbsp;73&nbsp;&nbsp;ambientColor .4 .4 .4<BR>

&nbsp;74&nbsp;&nbsp;} # End Material<BR>

&nbsp;75&nbsp;&nbsp;Transform {<BR>

&nbsp;76&nbsp;&nbsp;translation .45 .25 0<BR>

&nbsp;77&nbsp;&nbsp;} # End Transform<BR>

&nbsp;78&nbsp;&nbsp;Cube {<BR>

&nbsp;79&nbsp;&nbsp;width .1<BR>

&nbsp;80&nbsp;&nbsp;height .5<BR>

&nbsp;81&nbsp;&nbsp;depth .1<BR>

&nbsp;82&nbsp;&nbsp;}<BR>

&nbsp;83<BR>

&nbsp;84&nbsp;&nbsp;} # End Separator<BR>

&nbsp;85<BR>

&nbsp;86&nbsp;&nbsp;Separator {<BR>

&nbsp;87&nbsp;&nbsp;Material {<BR>

&nbsp;88&nbsp;&nbsp;ambientColor .5 .5 .5<BR>

&nbsp;89&nbsp;&nbsp;} # End Material<BR>

&nbsp;90&nbsp;&nbsp;Transform {<BR>

&nbsp;91&nbsp;&nbsp;translation .55 .3 0<BR>

&nbsp;92&nbsp;&nbsp;} # End Transform<BR>

&nbsp;93&nbsp;&nbsp;Cube {<BR>

&nbsp;94&nbsp;&nbsp;width .1<BR>

&nbsp;95&nbsp;&nbsp;height .6<BR>

&nbsp;96&nbsp;&nbsp;depth .1<BR>

&nbsp;97&nbsp;&nbsp;}<BR>

&nbsp;98<BR>

&nbsp;99&nbsp;&nbsp;} # End Separator<BR>

100<BR>

101&nbsp;&nbsp;Separator {<BR>

102&nbsp;&nbsp;Material {<BR>

103&nbsp;&nbsp;ambientColor .6 .6 .6<BR>

104&nbsp;&nbsp;} # End Material<BR>

105&nbsp;&nbsp;Transform {<BR>

106&nbsp;&nbsp;translation .65 .35 0<BR>

107&nbsp;&nbsp;} # End Transform<BR>

108&nbsp;&nbsp;Cube {<BR>

109&nbsp;&nbsp;width .1<BR>

110&nbsp;&nbsp;height .7<BR>

111&nbsp;&nbsp;depth .1<BR>

112&nbsp;&nbsp;}<BR>

113<BR>

114&nbsp;&nbsp;} # End Separator<BR>

115<BR>

116&nbsp;&nbsp;Separator {<BR>

117&nbsp;&nbsp;Material {<BR>

118&nbsp;&nbsp;ambientColor .7 .7 .7<BR>

119&nbsp;&nbsp;} # End Material<BR>

120&nbsp;&nbsp;Transform {<BR>

121&nbsp;&nbsp;translation .75 .4 0<BR>

122&nbsp;&nbsp;} # End Transform<BR>

123&nbsp;&nbsp;Cube {<BR>

124&nbsp;&nbsp;width .1<BR>

125&nbsp;&nbsp;height .8<BR>

126&nbsp;&nbsp;depth .1<BR>

127&nbsp;&nbsp;}<BR>

128<BR>

129&nbsp;&nbsp;} # End Separator<BR>

130<BR>

131&nbsp;&nbsp;Separator {<BR>

132&nbsp;&nbsp;Material {<BR>

133&nbsp;&nbsp;ambientColor .8 .8 .8<BR>

134&nbsp;&nbsp;} # End Material<BR>

135&nbsp;&nbsp;Transform {<BR>

136&nbsp;&nbsp;translation .85 .45 0<BR>

137&nbsp;&nbsp;} # End Transform<BR>

138&nbsp;&nbsp;Cube {<BR>

139&nbsp;&nbsp;width .1<BR>

140&nbsp;&nbsp;height .9<BR>

141&nbsp;&nbsp;depth .1<BR>

142&nbsp;&nbsp;}<BR>

143<BR>

144&nbsp;&nbsp;} # End Separator<BR>

145<BR>

146&nbsp;&nbsp;} # End Separator</FONT></TT>

</BLOCKQUOTE>

<HR>

<P>

The script can be modified to use cylinders instead of cubes with

a minor adjustment. The modified script to use cylinders is shown

in Listing 21.5. Note the use of <TT><FONT FACE="Courier">VRML::Cylinder</FONT></TT>

instead of <TT><FONT FACE="Courier">Cube</FONT></TT>. Also, note

how the parameters to <TT><FONT FACE="Courier">Cylinder</FONT></TT>

are different from <TT><FONT FACE="Courier">Cube</FONT></TT>,

but the calling sequence to put each <TT><FONT FACE="Courier">Cylinder</FONT></TT>

at its location is not very different from the calling sequence

used when placing <TT><FONT FACE="Courier">Cube</FONT></TT>s.

<P>

Listing 21.6 presents the output generated by the code in Listing

21.5. Compare Listing 21.6 with Listing 21.4 and notice how the

cylinders are translated and created. Figure 21.2 illustrates

using cylinders to represent data.

<P>

<A HREF="f21-2.gif" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/f21-2.gif" ><B>Figure 21.2 : </B><I>Using cylinders to represent data.</I></A>

<HR>

<BLOCKQUOTE>

<B>Listing 21.5. Using cylinders instead of cubes to represent

data.<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT><FONT FACE="Courier">&nbsp;1 #!/usr/bin/perl<BR>

&nbsp;2<BR>

&nbsp;3 use VRML;<BR>

&nbsp;4 use VRML::Cylinder;<BR>

&nbsp;5<BR>

&nbsp;6 my $header = VRML::new();<BR>

&nbsp;7 $header-&gt;VRML::startHeader;<BR>

&nbsp;8<BR>

&nbsp;9 $header-&gt;VRML::startSeparator;<BR>

10<BR>

11 $header-&gt;VRML::setPointLight('location' =&gt; [1,1,1], 'color'

=&gt; [0.2, 0.2, 0.5]);<BR>

12 $width = 0.1;<BR>

13 my @cubeb;<BR>

14<BR>

15 for ($i= 0; $i&lt; 9; $i++) {<BR>

16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$j

= $width / 2 + $i * $width;<BR>

17&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ht

= $i * 0.1 + 0.1;<BR>

18&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cubeb[$i]

= $header-&gt;VRML::putCylinder(<BR>

19&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'radius'

=&gt; $width/2, 'height' =&gt; $ht , 'parts' =&gt; 'ALL',<BR>

20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'translation'

=&gt; [$j,$ht/2,0],<BR>

21&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ambientColor'

=&gt; [$i/10, $i/10,$i/10]<BR>

22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);

<BR>

23&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

<BR>

24<BR>

25 $header-&gt;VRML::stopSeparator;</FONT></TT>

</BLOCKQUOTE>

<HR>

<HR>

<BLOCKQUOTE>

<B>Listing 21.6. VRML output when using cylinders instead of cubes.

<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT><FONT FACE="Courier">&nbsp;&nbsp;1&nbsp;#VRML V1.0 ascii<BR>

&nbsp;&nbsp;2&nbsp;#<BR>

&nbsp;&nbsp;3&nbsp;# Created by VRML.pm flag<BR>

&nbsp;&nbsp;4&nbsp;#<BR>

&nbsp;&nbsp;5<BR>

&nbsp;&nbsp;6 Separator {<BR>

&nbsp;&nbsp;7 PointLight {<BR>

&nbsp;&nbsp;8 location 1 1 1<BR>

&nbsp;&nbsp;9 color .2 .2 .5<BR>

&nbsp;10 } # End PointLight<BR>

&nbsp;11 Separator {<BR>

&nbsp;12 Material {<BR>

&nbsp;13 ambientColor 0 0 0<BR>

&nbsp;14 } # End Material<BR>

&nbsp;15 Transform {<BR>

&nbsp;16 translation .05 .05 0<BR>

&nbsp;17 } # End Transform<BR>

&nbsp;18 Cylinder {<BR>

&nbsp;19 parts ALL<BR>

&nbsp;20 radius .05<BR>

&nbsp;21 height .1<BR>

&nbsp;22 }<BR>

&nbsp;23<BR>

&nbsp;24 } # End Separator<BR>

&nbsp;25<BR>

&nbsp;26 Separator {<BR>

&nbsp;27 Material {<BR>

&nbsp;28 ambientColor .1 .1 .1<BR>

&nbsp;29 } # End Material<BR>

&nbsp;30 Transform {<BR>

&nbsp;31 translation .15 .1 0<BR>

&nbsp;32 } # End Transform<BR>

&nbsp;33 Cylinder {<BR>

&nbsp;34 parts ALL<BR>

&nbsp;35 radius .05<BR>

&nbsp;36 height .2<BR>

&nbsp;37 }<BR>

&nbsp;38<BR>

&nbsp;39 } # End Separator<BR>

&nbsp;40<BR>

&nbsp;41 Separator {<BR>

&nbsp;42 Material {<BR>

&nbsp;43 ambientColor .2 .2 .2<BR>

&nbsp;44 } # End Material<BR>

&nbsp;45 Transform {<BR>

&nbsp;46 translation .25 .15 0<BR>

&nbsp;47 } # End Transform<BR>

&nbsp;48 Cylinder {<BR>

&nbsp;49 parts ALL<BR>

&nbsp;50 radius .05<BR>

&nbsp;51 height .3<BR>

&nbsp;52 }<BR>

&nbsp;53<BR>

&nbsp;54 } # End Separator<BR>

&nbsp;55<BR>

&nbsp;56 Separator {<BR>

&nbsp;57 Material {<BR>

&nbsp;58 ambientColor .3 .3 .3<BR>

&nbsp;59 } # End Material<BR>

&nbsp;60 Transform {<BR>

&nbsp;61 translation .35 .2 0<BR>

&nbsp;62 } # End Transform<BR>

&nbsp;63 Cylinder {<BR>

&nbsp;64 parts ALL<BR>

&nbsp;65 radius .05<BR>

&nbsp;66 height .4<BR>

&nbsp;67 }<BR>

&nbsp;68<BR>

&nbsp;69 } # End Separator<BR>

&nbsp;70<BR>

&nbsp;71 Separator {<BR>

&nbsp;72 Material {<BR>

&nbsp;73 ambientColor .4 .4 .4<BR>

&nbsp;74 } # End Material<BR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -