I want to add dynamic/ procedurally generated textures to terra rather than the static ones loaded from the json. Assuming I already can generate these textures, what is the best way to tell terra to use them?
Terra dynamic materials
- dark_sylinc
- OGRE Team Member
- Posts: 5298
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1279
- Contact:
Re: Terra dynamic materials
Just create an HlmsTerraDatablock via HlmsTerra::createDatablock, modify it to your liking, then set it via Terra::setDatablock.
As for the heightmap, Terra::load accepts an Image2 which can be created at runtime.
-
- Goblin
- Posts: 272
- Joined: Thu Jun 10, 2004 4:19 am
- x 26
Re: Terra dynamic materials
I notice that by default through the json, terra sets properties on the hlms to load it's textures, I think. I see that with this code:
Code: Select all
Ogre::HlmsDatablock *datablock = hlmsManager->getHlms( Ogre::HLMS_USER3 )->getDefaultDatablock();
Ogre::HlmsMacroblock macroblock;
macroblock.mPolygonMode = Ogre::PM_WIREFRAME;
datablock->setMacroblock( macroblock );
mTerra->setDatablock(datablock);
, I can set a datablock. My question at the moment is how do I assign a given texturename/id into the data block that terra would use?
I guess it would need to be a terraHlmsDataBlock rather than datablock, still, my question remains.
- dark_sylinc
- OGRE Team Member
- Posts: 5298
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1279
- Contact:
Re: Terra dynamic materials
Cast to HlmsTerraDatablock* and call HlmsTerraDatablock::setTexture( TerraTextureTypes, tex );
Is that what you're asking or did I misunderstand?
Cheers
-
- Goblin
- Posts: 272
- Joined: Thu Jun 10, 2004 4:19 am
- x 26
Re: Terra dynamic materials
seems to be working great, thanks buddy!