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: 1206
Joined: Wed Dec 28, 2005 12:58 am
x 5

Programming materials in code

Post by lonewolff » Tue Nov 11, 2014 4:23 am

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)
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1064
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 83

Re: Programming materials in code

Post by xrgo » Tue Nov 11, 2014 4:55 am

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

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

User avatar
lonewolff
Ogre Magi
Posts: 1206
Joined: Wed Dec 28, 2005 12:58 am
x 5

Re: Programming materials in code

Post by lonewolff » Tue Nov 11, 2014 5:35 am

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:
0 x

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7152
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 19

Re: Programming materials in code

Post by Kojack » Tue Nov 11, 2014 9:14 am

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).
0 x

User avatar
lonewolff
Ogre Magi
Posts: 1206
Joined: Wed Dec 28, 2005 12:58 am
x 5

Re: Programming materials in code

Post by lonewolff » Tue Nov 11, 2014 10:36 am

Ah no worries, that makes sense :)
0 x

Post Reply