Creating a WebDock

Tutorial:Virtual Worlds Made Easy - Creating Web Docks
Time to complete: 10 minutes approximately
Summary: This tutoroial will show you how to add a web dock to your scene and enable it with a button.
Aim: Learn how to use and script web docks.
Required applications: VastPark Creator, VastPark Player

Required IMML Elements:
  • Box Primitive
  • Web Dock
  • Scripts x 3
  • Triggers x 3
  • Camera

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

The first thing to do is to remove the Box and the Light from the scene. This can be done by clicking on them and pressing delete on the keyboard.
All you should be left with is the "Button", Camera and Scripts we used earlier.

From here were going to add in our Web Dock. A "Dock" is an IMML element that can have elements nested inside it.
On this case we are going to nest a Box Primitive inside it and in the Primitives Material will be a web source.
Go to the IMML Editor and at the bottom of the document before the closing IMML tag paste in this code:

<Dock Name="WebDock" HorizontalAlignment="Centre" VerticalAlignment="Top">
    <Primitive Name="WebPrim" Type="Box" Complexity="Medium" Size="30,50,1" Visible="False">
        <MaterialGroup Id="-1">
            <Web UpdateRate="-1" Source="http://www.vastpark.com:80/"/>
            <Material Ambient="#4c4c4c" Diffuse="#cccccc" Emissive="#000000" Specular="#000000" EnableTextures="True"/>
        </MaterialGroup>
    </Primitive>
</Dock>

The web tag can have any website that you like inside it, just the link inside the Source"" of the web tag.
A dock will automatically "dock" itself to whatever camera you are using in the scene.
I don't want to display the Web Dock until after the scene has loaded so the visibility of the "WebPrim" is set to false.
I'm going to script this to my MouseClick event for the button that was created earlier.
So in the "OnMouseClick" script I'm going to toggle the visibility of the "WebPrim".

function main(obj, args)
scene:getelement('WebPrim').visible = not scene:getelement('WebPrim').visible
end

Save the Park and then you will need to open the IMML file inside the VastPark Player as Web Docks don't render in the VastPark Creator.
With any luck you should have a website appear when you click on the green button.

You can download this IMML from the files at the bottom of this page.

VWME9-WebDock1.jpg (22.8 kB) Adrian Shepherd, 06/02/2010 01:25 pm

VWME-WebDocks.imml (1.7 kB) Adrian Shepherd, 06/02/2010 01:39 pm