Video and xith

Hi. We are trying to create an interactive movie for a school project. We will need both 3D and video, however we have no experience in doing 3D in java, so we would like to know if it is possible to use e.g. Xith3D to do the 3D part, and then when video is needed, run it in the same window as the 3D (stop the 3D stuff and run video on top of it). We have done something similar with Java2D, but as I understand it, there is a big difference with the way Xith handles e.g. threads and so on.

I am just trying to do something similar.

I want to use xith3d to display a live video image inside the 3D world.

I had no time yet to implement it but here is what I am planning:

Use JNI to get access to my video4linux stuff to grab images (if you have some mpeg video stream you need to use you codec code in this part)

Get the image info from the C-side into java. I don’t know if one can use direct memory mapping between C and Java to avoid the extra memory copying. Get the image provided from the C-side into a texture on the Xith3d side (I have not figured out this part yet). Map this texture to some 3D geometry (a quad would be the simplest).

Note that you will probably need to scale your image to fit into a texture (only power of 2 sizes allowed).

Too bad I have not come around to implement it by now :frowning:

Ca$

we got this working in JOGL using QuickTime for Java :wink:
[not linux mind- sorry]

I have been told, that JNI and Java openGL commands are a fully interchangeable. Meaning, you could initialize gl context, create a geometry, bind a texture id, then call JNI method where you grap a videoframe and use glTextSubImage2D method to update a texture.

Or something like that, but still havent made it working. My JNI side is not a very strong, so no wonder is struggle. Ive done only simple JNI dlls previously…and used Borland Delphi ProjectJedi JNI wrapper.

I am still struggling on how to get the image data from the C-side into the texture on the java side without brute force array copying.

How can this be done and where do I put the data ?
From C I get a byte buffer containing an RGB (or BGR or ABGR, RGBA) image. Do I now use the BufferedImage I get from the Texture class or the ImageComponent2D ?

In C there was an openGL function which could partially or fully update a texture and this worked very well.

If you only need to show the Video or the 3d-world - not both together, you could simply put the xith-canvas into an Panel and add this one to a Frame. If you want to show the video, you simply could remove the Panel with the xith-canvas and replace it with the video-canvas. If you need to show the 3d-world again you just could simply switch it back.

Thread handling is done by the programmer himself … so there’s no problem there. :wink:

Putting the xith canvas into a panel wouldn’t slow down the performance. If not, the idea sounds great. Actually we did the same thing in 2D.

The idea about showing video inside the 3D world is also interesting for further projects. Can anyone post some code examples? E.g. the one with using QuickTime and Jogl?

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jogl;action=display;num=1058674409;start=31#31

make your texture dirty and should work… i havent
tryed it with the newer QTJ if it dont work anymore
i can revisit it.