Terra dynamic materials

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
Nickak2003
Goblin
Posts: 272
Joined: Thu Jun 10, 2004 4:19 am
x 26

Terra dynamic materials

Post by Nickak2003 »

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?

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: Terra dynamic materials

Post by dark_sylinc »

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.

Nickak2003
Goblin
Posts: 272
Joined: Thu Jun 10, 2004 4:19 am
x 26

Re: Terra dynamic materials

Post by Nickak2003 »

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.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: Terra dynamic materials

Post by dark_sylinc »

Cast to HlmsTerraDatablock* and call HlmsTerraDatablock::setTexture( TerraTextureTypes, tex );

Is that what you're asking or did I misunderstand?

Cheers

Nickak2003
Goblin
Posts: 272
Joined: Thu Jun 10, 2004 4:19 am
x 26

Re: Terra dynamic materials

Post by Nickak2003 »

seems to be working great, thanks buddy!

Post Reply