Page 1 of 1

Programming materials in code

Posted: Tue Nov 11, 2014 4:23 am
by lonewolff
Hi Guys,

Just playing with materials made in code. So far, so good :)

There are some things I am unsure of how to translate in to code.

How would I do this programmatically?

Code: Select all

env_map spherical
Is there a list somewhere where things like this are translated into code?

Thanks in advance. 8)

Re: Programming materials in code

Posted: Tue Nov 11, 2014 4:55 am
by xrgo
I believe this is what your looking for... maybe?

textureUnitState->setEnvironmentMap(true,Ogre::TextureUnitState::ENV_CURVED);

Re: Programming materials in code

Posted: Tue Nov 11, 2014 5:35 am
by lonewolff
Close 8)

It looks good on the sphere, but when the sphere is rotated the image doesn't move with it (i.e. same part of image is always faving the camera).

Maybe this is by design with this particular call, being an 'environment' call.

So, not quite there I am afraid. :(


[edit]
Tried adding this, but it just throws an exception.

Code: Select all

TextureUnitState* textureUnit=material->getTechnique(0)->getPass(0)->getTextureUnitState(tex);
textureUnit->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
But, at this point I am really just guessing. :oops:

Re: Programming materials in code

Posted: Tue Nov 11, 2014 9:14 am
by Kojack
lonewolff wrote: Maybe this is by design with this particular call, being an 'environment' call.
Yep, this is intended. env_map simulates a reflected environment, so just like a mirrored ball, no matter how you rotate it the same thing is reflected.

If you want to spherically map a texture onto a mesh, you need to generate UV coords for that in your modelling program (or do it mathematically if your object is made in code, such as a manual object).

Re: Programming materials in code

Posted: Tue Nov 11, 2014 10:36 am
by lonewolff
Ah no worries, that makes sense :)