Material ParseScript ?

travelan

18-07-2006 14:08:41

Hi guys!

I'm using OgreDotNet to develop something like a Model Editor. I want to edit a material script from within the application and apply it realtime to the model in OgreDotNet when the user press "refresh" or something.
The problem that comes with MaterialManagers parseScript is that it needs a DataStreamPtr. How can I send a string or textfile to the parseScript function? Can someone help me out?

Thanks in advance!

Trav

rastaman

18-07-2006 15:16:41

try this


string aa= "material MyNewMaterial/ThatIJustCreated\n{\n technique\n {\n pass\n {\n texture_unit\n {\n texture WoodPallet.png\n }\n }\n }\n}\n";
MemoryDataStream mds = new MemoryDataStream( "myMemDataStream" , (uint)aa.Length+2, true );
mds.SetBuffer(aa);
DataStreamPtr dsp = new DataStreamPtr( mds );
MaterialManager.Instance.ParseScript( dsp, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

if (mds != null)
MemoryDataStream.RemoveOwnership(mds);
mds.Dispose();
mds=null;
dsp.Dispose();
dsp=null;

travelan

18-07-2006 15:38:34

Thank you very much! It is working.

Gibo

19-09-2006 14:59:10

Hi Rastaman,
saw your post about loading materials, works well :D

I have a quick question...
If a material is load a texture, how is this done? Should it be done before the ParseScript or after?

Thanks

Gibo

Gibo

26-09-2006 12:09:53

Don't Worry, Solved the problem.. Had to load the the texture first with

Root.GetTextureManager().Load(TextureFilename, OgreDotNet.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

:D

barbapapaz

23-03-2007 07:58:16

Hi

I try to write this with dagon (ogre 1.2.4) but the code has change you have an idea

for example SetBuffer method is deprecated.

thanks