Programming materials in code

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Programming materials in code

Post 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)
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: Programming materials in code

Post by xrgo »

I believe this is what your looking for... maybe?

textureUnitState->setEnvironmentMap(true,Ogre::TextureUnitState::ENV_CURVED);
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Re: Programming materials in code

Post 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:
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Programming materials in code

Post 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).
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Re: Programming materials in code

Post by lonewolff »

Ah no worries, that makes sense :)
Post Reply