Adding and Scripting Video

Tutorial:Virtual Worlds Made Easy - Adding & Scripting Video
Time to complete: 10 minutes approximately
Summary: This tutorial will show you how to add a video to your scene and play it with a button.
Aim: Learn how to use and script video elements.
Required application: VastPark Creator
Required media: A short Avi or WMV video.

Required IMML Elements:

  • Box Primitive
  • Plane
  • Scripts x 3
  • Triggers x 3
  • Camera

This tutorial carries on from the VWME-Scripting Buttons tutorial.

The first thing we need to do is to create the elements required for this scene. Start by creating a Plane at position 0, 0, 6 that is 4, 3. Your plane will be lying flat at when you create it so rotate on the x axis by -90 degrees. Name your plane "VideoPlane".

The next step is to create a "Play" button. You can use any primitive or model as a button, for this example I chose a cone which I rotated -90 degrees on the z axis and changed the Emissive color to green. Name your button "PlayButton".

My PlayButton’s properties:
Position : -0.2, -2, 6
Rotation : 0, 0, -90
Size : 0.8, 0.8, 0.8

Add in a camera so that you can see the action. Position you camera in a place that you can see both the screen and the buttons. For the my scene, I placed my camera at 0,0,-4. Name the camera "MyCamera" and set the scene camera to "MyCamera". To do this, click a blank area of the 3d window to unselect all elements then expand the "Appearance" panel. Click the Camera drop down menu and select your desired scene camera.

After positioning the plane, adjust the emissive effect of the plane by selecting the plane and expanding the Appearance tab under Properties. In the box in the emissive section replace the defalt value with "#FFFFFF".

Now all we need is a video to display on the screen. To add the video we will need to jump in to the IMML code. To do this hit the <>IMML button below the 3d window.

Find the Primitive named "VideoPlane".

And below this tag you will find the materialGroup section which contains a material. Directly below the Material we want to add a video tag.

Begin by typing a backwards triangle bracket ,which looks like this <, this should prompt the syntax help. You can continue to type ‘Video’ or use the down arrows to select Video. You will have now open a video tag which will allow you add some more details.

Pressing space will again open the syntax help. Here we want to add the following properties:

Enabled = "False"
Loop = "False"
Source = " https://s3.amazonaws.com/vp.movies/skyloop.wmv "

Once these have been add close off your video tag with the opposite triangle bracket >. If any of your code as a red squiggle beneath it, the same you see in Word when you make a spelling error, you have an error somewhere in your IMML. Hover the mouse cursor over the offending word to receive some help in debugging.

Next we need to do is change the "OnMouseClick" script to enable the Video.
Double click the script in the Scene Explorer and change the script to look like this.

function main(obj, args)
scene:getelement('VideoPlane').video.enabled = true
end

The next step is to now create the trigger for this script. To do this make sure no objects are currently selected, then expand the "Triggers" tab under the "Properties" toolbar.
To create the trigger select "MouseClick" in the first box then "OnMouseClick" in the second box followed by selecting the green plus icon next to it. This should create the trigger "On MouseClick, Do OnMouseClick" below.

Save the Park and then run Interactive Preview. When you click on the Button the video will start playing.

For best results run the IMML in the VastPark Player. You can download this IMML from the files at the bottom of this page.

VWME8-Video1.jpg (15.4 kB) Adrian Shepherd, 06/01/2010 03:46 pm

VWME8-Video2.jpg (10.9 kB) Adrian Shepherd, 06/01/2010 03:46 pm

VWME8-Video3.jpg (14.1 kB) Adrian Shepherd, 06/01/2010 03:46 pm

VideoTutorial-ImmlButton.PNG (4 kB) Chanthu Shamsu, 01/13/2012 03:32 am

VideoTutorial-VideoTag.PNG (9.6 kB) Chanthu Shamsu, 01/13/2012 03:33 am

videoTutorial.imml (1002 Bytes) Chanthu Shamsu, 01/13/2012 03:41 am

VideoTutorial-ScreenSetup.PNG (13.1 kB) Chanthu Shamsu, 01/13/2012 03:50 am

Trigger.jpg (12.4 kB) Malcolm Kennett, 01/16/2012 01:26 am

Emissive.jpg (30.6 kB) Malcolm Kennett, 01/16/2012 03:12 am

VideoTutorial.jpg (18.2 kB) Malcolm Kennett, 01/16/2012 04:34 am

VideoTutorial.imml (1.7 kB) Malcolm Kennett, 01/16/2012 04:34 am

VideoPlane.jpg (25.8 kB) Malcolm Kennett, 01/16/2012 04:51 am