
Chapter 28.5. Playing Movies in a Java 3D World (Part 2)


This code comes from the website for the book:

  Killer Game Programming in Java
  Andrew Davison
  O'Reilly, May 2005
  ISBN: 0-596-00730-2
  http://www.oreilly.com/catalog/killergame/
  http://fivedots.coe.psu.ac.th/~ad/jg

However, this example and the associated chapter do _NOT_ appear 
in the printed book.

Contact Address:
  Dr. Andrew Davison
  Dept. of Computer Engineering
  Prince of Songkla University
  Hat Yai, Songkhla 90112, Thailand
  E-mail: ad@fivedots.coe.psu.ac.th


If you use this code, please mention my name, and include a link
to the book's Web site.

Thanks,
  Andrew

---------------------------------
Compilation: 

$ javac *.java
   // you must have Java 3D and QTJ installed for the compilation to succeed;
   // if you get "Warning" messages, please see the note below


Java 3D is available from http://java.sun.com/products/java-media/3D/
or https://java3d.dev.java.net/
Either Java 3D 1.3.1 or 1.3.2 is fine.

QTJ (QuickTime for Java) is available from 
http://developer.apple.com/quicktime/qtjava/
I installed QTJ 6.1, which is part of QuickTime 6.5.2 
For a few more details, see below.

---------------------------------
Execution: 

$ java Movie3D <movie fnm>

e.g. 

$ java Movie3D john.mov

The movie should be located in the movies/ subdirectory.

Move the viewpoint by dragging the mouse. Hold the ALT key and
drag to move in and out.


---------------------------------
Different Version of QTSnapper

There are three different versions of QTSnapper here:

* QTSnapper:    Get the next frame by incrementing a counter

* QTSnapper1:   Get the next frame based on the current time.
                Frames can be skipped, but the image is often corrupted.

* QTSnapper2:   Get the next frame by snapping a PICT image

To switch between them, you will need to edit QTMovieScreen.java,
changing the lines:

  // global declaration
  private QTSnapper snapper;    
    
  // instatantion in QTMovieScreen()
  snapper = new QTSnapper(fnm);

Change the class name used on the two line.

In the downloaded code, QTMovieScreen uses QTSnapper. 


---------------------------------
Notes on QTJ
http://developer.apple.com/quicktime/qtjava/

When I installed QuickTime 6.5.2, I had to explicitly include
QTJ 6.1 in the list of installed components; it isn't there
by default.

On my machine, two DLLs were added to C:\windows\system
and a zip file, QTJava.zip, to c:\windows\system and
<JAVA HOME>\jre1.5.0\lib\ext. (On my machine, JAVA_HOME
is c:\program files\java.)

QTJava.zip contains the QTJ Java packages and classes.

If you want to compile QTJ code without the hassle of setting 
CLASSPATH, then you should copy QTJava.zip over to 
<JAVA HOME>\jdk1.5.0\jre\lib\ext

You should make sure that a QTJava environment variable
has been added to autoexec.bat. It should be set to something
like:

  SET QTJAVA="C:\Program Files\Java\jre1.5.0\lib\ext\QTJava.zip"

This should have been done automatically as part of the 
installation process.

Once this is all done, you can test the installation by compiling
and running QTVersionCheck.java (which is in this directory):

  $ javac QTVersionCheck.java

  $ java QTVersionCheck

---------------------------------
Note on "unchecked or unsafe operation" Warnings

I have not used J2SE 5.0's type-safe collections, so that this code 
will compile in early versions of J2SE (e.g. version 1.4).

The warning messages are always related to my use of collections
(e.g. ArrayList) without specifying a type for the objects they will
contain at run time.

No. of Warnings generated in J2SE 5.0 for the example:
/Movie3D: 9 warnings

---------------------------------
Last updated: 2nd June 2005