How can i apply a video stream on a surface using Xith3D ?

Folks,

I need some help with this subject: i’ve created a rectangle in Xith3D and i want to apply a video stream (possibly from a mpeg file) in one of its surface. How can i do that ? Is there some simple way to do that ?

Best Regards,

Wagner Bila

Easiest way is probably to use a BufferedImage (I assume you can grab the current frame of your video as some paintable image), but expect your framerate to drop like a stone. I’d guesstimate it at 20 FPS or so with an average (i.e. cutting-edge about 2 years ago) PC setup, depending very much on the resolution of the video. If your stream is something like 240x180, then it might put out decent FPS.

How I implemented dynamic textures for my current project went something like this:

  • Get a handle on a placeholder Texture2D. Be sure you load it with the dynamic-texture flag set.

  • Use the texture’s getImage() method to get an ImageComponent2D.

  • Call getImage() on the ImageComponent2D to get a BufferedImage.

  • Get a Graphics2D context from the BufferedImage.

  • Apply the Texture2D to your geometry.

  • Every frame, paint the video to the Graphics2D.

  • Then call update() from the ImageComponent2D to update it.

There’s probably a much faster and more efficient method, but this is the best I can offer. Good luck!