keyframed material animation?

MrPixel

05-12-2010 01:03:19

In the oFusion exporter we are defining node animations that are triggered on certain events. Several animation clips are exported based on the keyframe range specified in the export (the animations are associated with a particular event using a naming convention). We would like to include material animations (or material swapping) with the node animations. The only way I can think to accomplish this is pretty clunky - like associating alternate materials to swap in when the event/animation is triggered. Is there a better way?

Lioric

06-12-2010 02:40:24

If you could provide more details on how you need your scene to be setup (how many objects are in the animations, how are you grouping them, or any other related detail), then probably I can suggest you more detailed options, but probably for a quick implementation you can easily add the material names and their keyframes (as in when to change them in the animation, the animation name the they belong, the time or the frames where the material must be active and displayed in the object) as user properties to your objects in your scene, then you can easily parse those properties at load time in your application to create and setup your material animation tracks as needed

As per the user prop, you can define it as a string containing the name, and the frames or time positions when they are active, lets say that you add this to a object in Max that needs its material to be animated:

"MaterialAnimation=materialRed,0,100"
"MaterialAnimation=materialGreen,101,150"
"MaterialAnimation=otherMaterialName,151,300"

Then you will parse the string properties named "MaterialAnimation" in your application when you load the scene, they contain the material name, and the start and end frames (you can add more data as needed), when the entity that has these props defined is loaded in your application you simply parse them and create your animation (in this sample, materialRed will be active by default and from frame 0 to 150 of the animation, after this materialGreen is enabled to frame 150, and otherMaterialName to the frame 300)

See this article for detailed information on creating "User defined properties" in Max and using it in your application:

http://www.ofusiontechnologies.com/support-center/index.php?x=&mod_id=2&id=17


To easily handle multiple objects and several animation, you can create a small maxscript dialog that let you edit the material animations on multiple (selected) objects, see the file "objectAnims.ms" from the "maxroot\oFusion\scripts\" folder as a sample (or as the base for your "material animation" editor), it contains almost all the code you need, you just need to customize it for "material animation" handling and modify it to use the "getUserProperties" and "setUserProperties" maxscript methods that will store the string as a user defined prop in each selected object

MrPixel

07-12-2010 21:32:54

Hmmm, I'll have to describe what we are doing rather abstractly or the legal guys will beat me up. Imaging a single object in the scene. When the object is clicked on, other objects animate out of the single object. Then clicking on any one of the new objects can potentially have other objects animate out of it. And the process is reversible. In Max we have the complete animation for opening and closing the full hierarchy. In the oFusion export dialog, we define each animation that occurs on an open or close with a keyframe range (and a naming convention) to identify the animation to play on a particular event. We would like to add material change (ideally material animation) to some of these node animations.

We're already using user properties for other things so it a fine idea to use that to identify the alternate materials. The only issue is that we have dozens of animation clips even for the simplest hierarchy - so it would be a lot of manual entry for the artist to specify the materials for each clip. Providing a dialog like objectAnims might make it easier - I'll look into that.

If the description above gives you a better idea of what we are doing and you have other suggestions - I'm all ears.