Dynamic Texture 1.0 - easy to use VideoTexture

Hello all,

after a long time Prof. Monster created a new BGE component:

[INDENT]Dynamic Texture[/INDENT]

It makes the VideoTexture available without writing a single line of code. The according modules are available in the attached demonstration file.

News:
now available via GitHub.

  • Use branch runtime (default) for integration into your project.
  • Use branch runtime_with_dependencies for integration into your project when you do not want to download the dependencies separately.
  • Use branch sdk to find demos.


The modules allow to easily:

  • project an image file onto a material
  • project a video file onto a material
  • control the playback of the video
  • project the output of a camera to a material
  • control the playback of the camera

The attached zip file contains

  • the .blend with the python code and a sample setup for each use case + a short introduction.
  • a video file to be played in the demo
  • an image file to be shown in the demo

Have fun
Monster

Attachments

VideoTexture.zip (840 KB)

1 Like

Thank you Professor Monster! I had been struggling with this and I am amazed at how easy this is!

Thank you Professor Monster ( bending on my knees )!
Really WOW!
Bye

Gonna check this out tonight, thanks professor M! btw interesting choice of video :stuck_out_tongue:

Thanks professor monster sir!

I believe that there is a mistake in the text objects; the second object should read “<c> setup camera and play”, not “<v>”

Oh, yes you are right, the camera source will be set up with <c>. Thanks for noting me :D.

Sir Monster,
I need reply to this thread. You made the video name a property, not a part of the text. Without editing any of the text, I was able to put the name of my video into the property page, and then putting the video in the same folder. I was able to see the video in the games engine. For a month I have been trying to do this and I was unable to to do it with all the tutorials I found. I was so frustrated, but this worked! Thank you so much for that!
I don’t know how things work around here, but I made a template file for me to use, using your text and your modules, and your logic bricks. I want to make three templates…The first a video texture…the second …a real time camera…and the third, a static texture which can be turned on and off…I have already made the first one for myself, using the tool arrangement that I like.
My question is- Is it ok for me to make templates from your work…I do not change a single word in the texts…Or am I going beyond what I should do?
Thanks again

Just use it, no problem

Thanks Monster!

thanks for your work Monster!

i tried to change videos, but it did not work with just setting a new Texture.
So i added a little addition to the texture module:

def removeTexture():
    setProperty(INTERNAL_PROPERTY_TEXTURE, None)

Now, it works. Before setting a new Texture, it just have to be cleared.
I needed to do it, because i had a strange problem.
I had a Videotextureplane with a Video running. Everytime i klicked the next Button, the video should have been changed. Well, this did not work …half. In the row of 4 Videos, every second worked, while the other two were black. If i started at position 1, video 1 and 3 worked, if i started at 2, video 2 and 4 worked.
With this addition it works fine -But there is just one Question.
Is setting to None, the same as deleting the Internat Property? I dont like to have unused data in a programm.

i hope this is a useful comment :wink:
have a nice day!
thank you sir!

Hello JMHin20xx,

thanks for this investigation. I haven’t looked what happens if the texture is supposed to be replaced. I noticed that enabling the texture again, seems to remove it. But I never investigated into this direction.

No setting None, changes the value but does not remove the property. In this situation it does not matter as this module treats None-value and non-existing property the same way. So you solution is perfectly fine.

Just in case you want to call removeTexture from a Python controller, I suggest to add the allSensorsPositive check. This way it acts like an AND controller.

Thanks
Monster

Hi monster! Thanks for these scripts, it is a very elegant solution for playing videos in the BGE.

Is there any way to detect when the video stops, and change the state automatically? I’m trying to play a video loop from time to time, in my interface, and I would like the video to stop when the video finishes.

Thanks

Let me check …
The bge.texture.VideoFFmpeg has a status attribute. This might be helpful.

I will do some texts and come back to you

Edit:
Yes, that status is what you need. Unfortunately there are no defined constants on the status (at least not included into the documentation).


SOURCE_ERROR = -1
SOURCE_EMPTY = 0
SOURCE_READY = 1
SOURCE_PLAYING = 2
SOURCE_STOPPED = 3

you can enhance video.py with this code:


def activateOnStop():
    if getVideo().status == SOURCE_STOPPED:
        activateAllActuators()

with that you can activate any actuator (such as an state or an property actuator):

Alway [true] -> Python Module: video.activateOnStop -> your actuator

Thanks master! This is much better than my solution. I have one property which I increment every frame, but I have to set it to the right amount, and it is FPS dependent.

After a looong time, here is the update to 1.2.

This time with filters … included the - BlueScreenFilter


Configuration is as follows:



call via Module: filter.prepareBlueScreen

setup properties:
filter.color - a comma separated list of integers defining the color to filter out (does not need to be blue)
filter.limits - a comma separated list of integers defining the color limits (whatever that means)

Remarks:
I discovered some annoying problems when running in GLSL mode. The textures were still replaced as expected. Unfortunately at all three cubes.
The fix was to replace the meshes with a new cube - pretty strange, but it worked.

Attachments

DynamicTextureDemo1.2.blend (108 KB)

Dynamic Texture now on github … see post#1

Does this work on images as well? And does it work in v 2.78c’s BGE?