Animation for Color?

Problems building or running the engine, queries about how to use features etc.
Post Reply
Eddie00
Gnoblar
Posts: 2
Joined: Wed Jul 20, 2016 6:48 am

Animation for Color?

Post by Eddie00 »

I want to change the color gradually through Animation(0.5,0,1)->(1,0,0,1). Is it possible?
Or I have to change the color in FrameListener via material.
Is there any better way to achieve my goal?
Thanks in advance
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: Animation for Color?

Post by spacegaier »

I think Ogre::Animation is meant for position movements along some predefined tracks/paths.

To animate the color of an object (SubEntity), I spontaneously see at least three possible options:

1. Use a FrameListener / rendering loop, where you can update the color directly in your application as needed.

2. Use a texture that has the different colors blended into different areas and animate/rotate/scroll that texture over the object via the material.

3. Use a shader where you can either directly change the color in the shader by taking the old color value and changing it or computing a color value in your application and passing that as a parameter into the shader.
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
Eddie00
Gnoblar
Posts: 2
Joined: Wed Jul 20, 2016 6:48 am

Re: Animation for Color?

Post by Eddie00 »

spacegaier wrote:I think Ogre::Animation is meant for position movements along some predefined tracks/paths.

To animate the color of an object (SubEntity), I spontaneously see at least three possible options:

1. Use a FrameListener / rendering loop, where you can update the color directly in your application as needed.

2. Use a texture that has the different colors blended into different areas and animate/rotate/scroll that texture over the object via the material.

3. Use a shader where you can either directly change the color in the shader by taking the old color value and changing it or computing a color value in your application and passing that as a parameter into the shader.
Thank you for your answer, I only think of first option.
So I guess it's impossible to use Ogre::Animation to animate color change.
I think I'll go for option 1.
Will it be inefficient to do the following in FrameListener?

Code: Select all

Ogre::SubEntity* sub = mEntity->getSubEntity(0);
sub->setCustomParameter(1,color);
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: Animation for Color?

Post by spacegaier »

Instead of setting a custom parameter on the SubEntity (that you would need to react to somewhere), you could directly manipulate its material instead.
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
Post Reply