I'm trying to load a material from a string, which I could do in
PyOgre like this:
ogre.MaterialManager.getSingleton().parseScript(someString,
"General")
Is there a way of doing this in Python-Ogre?
I'm thinking if I could create a MemoryStreamDataPtr from a string, I
could just pass that to parseScript, but there doesn't seem to be any
way to do that.
Anyone have any suggestions?
On Apr 29, 10:22 pm, "Bernie Roehl" <bro...@gmail.com> wrote:
> It could be called like this:
>
> ogre.MaterialManager.getSingleton().parseScript(file("myfile.material"),
> "General")
>
> ... in other words, the string would be the contents of a .material file.
> Of course, it wouldn't actually be loaded from a file. In my case, it would
> be receiving over the network.
>
It appears that the MemoryDataStream is not being created correctly.
As a test, I tried doing the following:
>>> string = str("Hello world")
>>> memBuffer = ctypes.create_string_buffer(string)
>>> print memBuffer
<ctypes.c_char_Array_12 object at 0x008EDD00>
>>> print memBuffer[0]
'H'
>>> # So far, so good
>>> dataptr = ogre.MemoryDataStream (ctypes.addressof(memBuffer), len(string)+1)
>>> print dataptr
<ogre.renderer.OGRE._ogre_.MemoryDataStream object at 0x01421B40>
>>> # Good
>>> print dataptr.getLine()
>>> # Not so good :-(
Every call to dataptr.getLine() returns an empty string, which
explains why the materials aren't being loaded.
Am I missing something?
f= file(
"test.material", 'r'> RawMemBuffer = ctypes.create_string_buffer ( MatString ) ## Note it allocates
> > > ogre.MaterialManager.getSingleton ().parseScript(file("myfile.material"),