Fastest way to manually scroll a material on a mesh?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
Interrupt
Halfling
Posts: 83
Joined: Wed Jun 29, 2005 8:15 am

Fastest way to manually scroll a material on a mesh?

Post 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?
User avatar
Harlequin
Kobold
Posts: 35
Joined: Thu Oct 16, 2003 9:29 pm
Location: Germany
Contact:

Post 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
team-pantheon programmer
creators of Rastullahs Lockenpracht
Interrupt
Halfling
Posts: 83
Joined: Wed Jun 29, 2005 8:15 am

Post by Interrupt »

Thanks for the help! I got it all straightened out now.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post 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. :?
team-pantheon programmer
creators of Rastullahs Lockenpracht
Interrupt
Halfling
Posts: 83
Joined: Wed Jun 29, 2005 8:15 am

Post 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 :P
Post Reply