Fastest way to manually scroll a material on a mesh?
-
Interrupt
- Halfling
- Posts: 83
- Joined: Wed Jun 29, 2005 8:15 am
Fastest way to manually scroll a material on a mesh?
Like the title says, I'm trying to find the fastest way to manually manipulate the scroll location of a material on a mesh. I've got a skybox using a texture to determine the sky gradient that changes over time, which basically means it's moving the uv coords of the mesh to the right over time, but I need to match that location up to the time of day in the game. I've looked for some information, but haven't come up with anything besides editing the UV coords of the mesh's VertexBuffer manually. There's a material option to scroll a texture, is there any way to get direct access to that material and manually scroll it?
- Harlequin
- Kobold
- Posts: 35
- Joined: Thu Oct 16, 2003 9:29 pm
- Location: Germany
- Contact:
Get your Material from your mesh/submesh or via the material-name from the MaterialManager.
// Providing thats the Technique/Pass/TextureUnit you want to change - otherwise change the numbers 
As found in the api
http://www.ogre3d.org/docs/api/html/cla ... State.html
Code: Select all
Material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureScroll (Real u, Real v)As found in the api
http://www.ogre3d.org/docs/api/html/cla ... State.html
- haffax
- OGRE Retired Moderator

- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 8
- Contact:
Code: Select all
MaterialPtr skyMat = MaterialManager::getSingletonPtr()->getByName(mSkyDomeEntity->getMesh()->getSubMesh(0)->getMaterialName();
skyMat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setScrollAnimation(0, 0);
Small aside: You don't need to get the pointer from the MaterialPtr, actually you shouldn't, as it defeats the purpose of a shared pointer. The -> is overloaded, so that it already accesses the Material members. And a Material* doesn't help you, when you need to pass a material to an Ogre function, as Ogre expects MaterialPtr intead of Material*.
Edit: I swear there once was a question to my answer in the post above.