VRML-based virtual concert hall
I have seen a three-dimensional web page, have you seen the 3D exhibition of online stores, is it sighing their true sense, attracting a victory? In fact, a lot is done with VRML, VRML (Virtual Reality Modeling language) is one Combine with the Internet to describe the three-dimensional programming language, which can be applied to create virtual reality objects, sights, and display models.
But we are going to do today is not a virtual 3D web page, but a virtual 3D concert hall, a "virtual concert hall" belonging to your own, how? Heart, heart is not as good as action, come with me! :) II. Prepare work "Wheel is incorrectly slashing work", let's take a look at what we need: First, if your browser is Navaigator, congratulations, you don't need any plug-ins, you can browse VRML web pages; however, If it is IE, you have to install an unpacked program, such as the Cosmo Player developed by ParallelGraphics, or the COSMO Player developed by Platinum, you can go to the "Huajun Software Park" Down, the URL is: http://www.onlinedown.net. Installation The process is as simple as the Flash plugin. I have to prepare the latest "weapon" of Broland - Delphi7. Ok, "Everything is available, I only owe Dongfeng", now start: III. True implementation process Open Delphi7.0, new construction A Project, add a button on the Form, the button's CAPTION property is set to "Open the audio file"; add an OpenDialog control to open the audio file; then select the webbrowser control in the control bar, webbrowser control The IE is built into the form form. Ok, now double-click Button1, fill in the following code: Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); VARFP: TextFile; // Text File CURRENTDIR: String; // File path sSelectSong: String; // VRML file for composing beginif OpenDialog1.Execute () then // select an audio file beginsSelectSong: = sSelectSong 'Shape {appearance Appearance {material Material {}} geometry Sphere {radius 0.25}}'; sSelectSong: = SSELECTSONG 'SOUND {source audioclip {url "; sselectsong: = sselectsong extractFileName (OpenDialog1.FileName); // Open audio file sselectsong: = sselectsong '" loop true} ' ; SSelectSong: = sSelectSong 'maxBack' '10 .0 '; sSelectSong: = sSelectSong ' maxFront ' '10 .0'; sSelectSong: = sSelectSong 'minBack' '5'; sSelectSong: = sSelectSong 'minFront' '6'; sSelectSong : = SSELECTSONG 'Spatialize False}'; // Generate .vrml file, and call IE browser to play AssignFile (FP, 'WRLTESTFILE.WRL'); // Specify file name REWRITE (FP) (FP) (FP) (FP) (FP, " '#VRML V2.0 UTF8'); Writeln (FP, SSELECTSONG); // Write VRML Code Closefile (FP); getDir (0, currentdir); // Take the file path WebBrowser1.naviGate (Currentdir '/ WRLTestFile.wrl ');
Simple, ok, now run. IV. After running with the extension, press "Open Audio File" to select .WAV or .midi audio file (Note Yes .WAV or .midi file, .mp3 file Test Some machines can play, some can't, because the VRNL 2.0 standard only supports these two audio formats and MPEG video formats, using your mouse before and after the top or left, you will feel the changes of the sound, Experience in real understanding, is it true as the real voice? But, this time is very simple, there is only one sphere in it, and it is dark, and it is dark (just like it.), If it is in the universe :)) You are familiar with the VRML grammar, you can make more beautiful scenes so you can listen to the music in your own scene, walking inside, music with your movement, the author passes the top The extension of the program is made into a complete virtual music player - virtual concert hall, and participates in the first prize in Guangdong Province, I think you can also make a "virtual concert hall" that belongs to your own by expansion.. Extension? In fact, through the operation of the above program, a file called WrltestFile.wrl, contains the following VRML code: (1) #VRML V2.0 UTF8 (2) Shape {(3) APPEARANCE APPEARANCE {Material Material {}} (4) Geometry Sphere {Radius 0.25}} (5) Sound {source audioclip {url "jita.wav" loop true} (6) Maxback 10.0 MaxFront 10.0 Minback 5 Minfront 6 (7) Spatialize False (8)} Maybe someone will Surprisingly, can you make the above effect? Secret is the same as a VRML plug-in, these plugins are as important as a game engine, which performs VRML code with your browser. Let us analyze the following VRML code, actually, the above 8-sentence code, we have appeared in the program, just the fifth sentence is a bit different, right, Jita.wav ", this is the exterior introduced by OpenDialog. WAV audio Document. Smart you may think of, by changing or adding other VRML code, isn't it possible to achieve a rich interactive effect, it is completely correct! You can change the size of the ball by changing the fourth sentence of RADIUS, or put the ball Change into other shapes (for example, make speakers), you can change the sixth sentence Maxback, Maxfront, Minback and Min Front to change the spreading direction of the sound source, and you can add your favorite scene background pattern by adding a code in the back of the eighth: (9) Background (10) {(11) Fronturl "bgsky.jpg" (12) Backurl "bgsky.jpg" (13) Lefturl "bgsky.jpg" (14) RightURL "bgsky.jpg" (15) TopURL "bgsky.jpg" (16) BOTTOMURL "BGSKY.JPG" (17)} analysis Let's know that the (11) sentence adds the front background picture in the scene, subsection (12) joins the back background image in the scene, subsection (13), add to the left background picture, subsection (14) joining the scene Background picture, item (15), add to the scene background picture, subsection (16), add to the bottom background picture, I am in the same picture here, you can join yourself casually I like pictures, of course your picture should be placed in the program this directory. Of course, you can also join other stuff, add other interactions. For example, you must have a complete player, there is also a menu selection, play pause, In addition, you can customize multiple source points ("speakers"), the method is to add multiple Sound nodes, for example, you can add a background sound (such as a bird) on the basis of the above code. Code: Sound {source Audioclip {url "bird.wav"