Page 1 of 1
Fastest way to manually scroll a material on a mesh?
Posted: Wed Jun 29, 2005 8:22 am
by Interrupt
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?
Posted: Wed Jun 29, 2005 9:17 am
by Harlequin
Get your Material from your mesh/submesh or via the material-name from the MaterialManager.
Code: Select all
Material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureScroll (Real u, Real v)
// 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
Posted: Thu Jun 30, 2005 1:50 am
by Interrupt
Thanks for the help! I got it all straightened out now.
Posted: Thu Jun 30, 2005 2:12 am
by haffax
Code: Select all
MaterialPtr skyMat = MaterialManager::getSingletonPtr()->getByName(mSkyDomeEntity->getMesh()->getSubMesh(0)->getMaterialName();
skyMat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setScrollAnimation(0, 0);
The setScrollAnimation() function sets the speed for u and v components.
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.

Posted: Thu Jun 30, 2005 10:02 pm
by Interrupt
Yeah, I posted the question and less than a minute later fixed the problem myself, I tried to edit it before anyone looked at it, but it looks like I was too late
