Sorry for what is essentially a cross post, but I need to be able to do this or switch game engines.
I need to change the image texture data on a mesh (just a plane) while the game is running. I can’t put the texture on before the game because the texture is generated from the game (e.g. screen shot or in-game paint program.) I know how to change the uv mapping to put different parts of a preexisting image onto a mesh, but I need to change or replace the image data itself.
Any hacks or kludges are welcome. My brain has run out of ideas.
unless you can run native code it cannot be done well
and if it can (or running native code) the NaN developers did something seriously wrong.
If you can import blender, it can (very slowly) be done in python, I imagine, using Blender.BGL …
the problem with what you suggest is that you suggest (implicityly) that mipmas are generated at game runtime. This isn’t a good idea, and I doubt it is something the blender source allows. If you could change scenes, and ran your own distribution of blender, this may be easier.
(inocherent, but maybe the Blender.BGL (call a bitmap drawing function with a Blender.BGL.Buffer(…) object containing image data) thing is the most likely method)
oh, blender.bgl may not be avaliable to python in the game engine of 2.25
it is in 2.23, and can almost easily (though it isn’t trivial) be used to crash blender, or run native code, hence it being dropped from the game engine.
the problem with what you suggest is that you suggest (implicityly) that mipmas are generated at game runtime. This isn’t a good idea,
Why not? I’m just displaying data on my screen. Why shouldn’t I be able to do that when I want to? I don’t expect it to be extremely fast. Aren’t mipmaps regenerated anyway when I do a GameLogic.getCurrentController().getOwner().getMesh().getVertex().setUV()?
and I doubt it is something the blender source allows. If you could change scenes,
Not a problem. Scenes can be switched very quickly.
and ran your own distribution of blender, this may be easier.
You mean just reprogram blender? I was hoping to avoid that.
(inocherent, but maybe the Blender.BGL (call a bitmap drawing function with a Blender.BGL.Buffer(…) object containing image data) thing is the most likely method)
This sounds on the level of just reprogramming the blender source.
you shouldn’t be able to run native code for portability, and security reasons
this is one of the reasons why the plugin doesn’t have the blender module
blender.BGL is an opengl implementation (1.1.0 in my recent test) in python
the calls that require a pointer take a buffer instead
if you have in a python script
from Blender.BGL import *
you can run opengl commands like in c, except for the pointer thing I mentioned before.
Except, I don’t know if there is a bitwise or in python, so I usually just add values together (may not be relavant for you), for example
glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
(yes, and then I check the carry flag… )
being lazy I don’t know if all in this post is correct, I don’t know all commands well enough
I think changing the mesh makes the most sense too. You said it was only a plane. That’s four points. Make a few, no big deal. Put them on another layer, use change mesh.