Video generation

Navigation:  OLE automation > Video generation >

Video generation

Previous pageReturn to chapter overviewNext page

With SPRAY, OLE automation and the third party shareware tool 'Platypus Animator' you can automatically generate videos like a flight around or through your scenery. Controlled by OLE automation, SPRAY computes the required pictures which are finally composed to a video sequence by the Platypus Animator program.

The following page shows a small and simple example. Note that the video download may consume quite some time ...

 

The following OLE commands are useful for picture and video generation:

 

Computation of view pictures

The command start_grafx performs the computation of all rendered view pictures. In VisulBasic, the line

spray.start_grafx

will do this.

 

Modifying pictures

Once the view pictures are generated you can modify them with the following commands.

 

The command test_ray (no parameters) will tell SPRAY to send one test ray (as if you had selected the 1 menu command in a rendered view). With a loop you can generate as many test rays as you like:

  For i = 1 To 20

     spray.test_ray

  Next i

 

You can add some text using the property text(name: string, the_text: string) = position (integer). Here is an example:

spray.Text("Side", "Specular") = 1

This command adds the text 'Specular' to the picture of the view named 'Side'. Assigning the value 1 (position) places the text in the upper center of the picture. The following values of position may be used:

 1: Top, horizontally centered

 2: Bottom, horizontally centered

 3: Left, vertically centered

 4: Right, vertically centered

 

Here is an example for position 1:

OLE_test_pic

 

Saving pictures

The property save_bitmap of type string is used to save the computed view bitmaps. If you pass a filename to the property SPRAY saves the pictures of the views to the specified filename. The letters A, B, C, ... are added to the filename in order to separate between the individual views in the list of views.

The VisualBasic command

spray.save_bitmap = "c:\video\test\sideview"

will create the files sideviewA.bmp, sideviewB.bmp, ... in the directory c:\video\test.

 

The property save_detector_bitmap(x_pixels, y_pixels : integer, object_name : string) = filename : string is used to generate a picture with a detector spectrum. The parameters x_pixels and  y_pixels set the size of the bitmap, object_name specifies the name of the detector. The filename assigned to the property is used for saving the bitmap. The extension .bmp is automacilly added to the filename.

A VisualBasic command like

spray.save_detector_bitmap(500, 300, "My detector") = "c:\temp\detector1"

creates a picture like the following:

OLE_detector_pic

 

The preparation of video sequences can be done best with the following commands:

save_bitmap_auto(filename : string) = frame : integer saves the bitmaps using a name which is a combination of the string you specify with the filename parameter and the number of the current picture in the sequence of the video, the frame parameter. Using this command in a loop (with increasing frame number) generates a sequence of pictures. The loop must count the frames starting at 0.

After the loop is finished you execute the command write_ini_file(filename : string) = frame : integer with exactly the same filename as you used in the save_bitmap_auto command. The parameter frame must be set to the last frame number in the loop. The write_ini_file command tells SPRAY to create a text files (one for each view in the list of views) which contains information for the Platypus Animator program. The name of the text files will be composed of the filename parameter, the letter 'A' for the first view, the letter 'B' for the second and so on, and the extension .ini .

Finally you have to pass the text files as parameter to the Platypus Animator program. It will create the video sequences and store it as .avi file.

 

Here is a complete example of a VisualBasic routine that creates a video sequence:

 

Public Sub rainbow()

Dim z As Single

 

For j = 0 To 50

    ' Light source is lifted up

    z = j / 50

    spray.object_parameter("Light source", "z") = z

    ' Compute picture

    spray.start_grafx

    ' Send some test rays

    For i = 1 To 100

       spray.test_ray

    Next i

    ' Add a text (the current height of the light source)

    spray.Text("Side", "Height: " + Format(z, "####0.0")) = 1

    ' save the bitmap

    spray.save_bitmap_auto("c:\temp\rainbow") = j

Next j

 

' Write the ini-File for the avimaker program

spray.write_ini_file("c:\temp\rainbow") = 50

 

' call the avimaker program with ini-File as parameter

Call Shell("C:\video\avimaker\AviMaker.exe" + " " + "c:\temp\rainbowA.ini", 1)

 

End Sub

 

The result is shown on the next page.