[Closed] animating the material editor slots
I have a script that animates a piano keyboard there’s 97 keys in all , I’m using two slots in the material editor , slot one has the diffuse set to white and slot two is set to black for all the sharp keys , now what I would like to do is make the key or keys turn red if it or they are in the down position . I know I could do this just by changing the diffuse values but this would only work if each key object had its own material slot and I dont want to use up all the slots if I can help it. I have tried using a third material slot set to red and setting any keys in the down position to that material slot but its seems when I do this it will not record it in the animation , what I mean is , if I run the script with the material editor open you can see the red slot being assigned to the key objects but when you play back the animation the changes are not recorded .maybe I’m missing something silly ??. has anyone got a better idea on how I can do this ??
Thanks for reading
No ideas on how I can go about this then ? . Im goin to work on it over the weekend I will post up here if I come up with anything that works .
if you look at Moonlight Sonata a A virtual player piano video from Andy murdock this is what Im trying to do , as I said before I got the animation working fine its just the textures bit I need help with .
any help or ideas would be great .
Thanks for reading
I take it you are animating the keys by rotation?if so couldn’t you animate the diffuse based on the rotation of the key. white/black being 0 or at rest and red being 1 or pressed and it would fade from white/black to red in that duration.
just a thought probably not what your looking for but none the less thread bumped.
-Baker
sorry for the late reply but Im at work . The keys do rotate but my point is , I dont want to use 97 [font=Verdana]materials , I only want to use 3 if I can . one white one black and one red.[/font]
so if the key is a minor key its white . if the key is a sharp its black .this bit is fine the part of the script that makes the keyboard also adds the right colours to the keys objects. as Im only using 2 colours at this point Im only using 2 slots in the material editor. simple so far
the next bit of the script animates the rotation of the keys and that works fine
what i would like it to do is rotate and change the said key object to a material slot other then the 2 Im using ( slot 1 or 2 /black,white) . I can do this as the script itself runs but it wont save that data . so when I play back the animation my script made it all works apart from the colours changing .
I think maybe Im goin about this the wrong way , maybe I should make all the keys objects use the same material and make that material a multimaterial and then just change the Mat Ids . say ID 1 = black ID 2 white and change any rotated key to ID 3 being red .
anyway thanks for the help I will let you know how I get on
Im leaving work now so will post back a bit later when i get home …
why don’t you want to have 97 materials?
If you script everything script these materials, too.
Georg
Well i did not explain that well what I mean is this:
you have three materials
mWhite=getMeditMaterial 1
mBlack=getMeditMaterial 2
mRed=getMeditMaterial 3
and your keys are assigned the black and white respectively.
on the transition of the down key a function checks to see what color the current key is and assigns mRed to it with the same diffuse as the current key it then rotates and blends from the current color “white/black” to the red color once the key is done it changes back to the original material “mWhite/mBlack” the only problem with this is that more than one key will be pressed over a given amount of time which means more than 3 materials would have to be used.
also I agree with the above if it is scripted what would it matter.
and if that is the case you could have a white and black material and just create a red for each key.
How about this, don’t use maps at all. Control the diffuse color on your keys by vertex color.
Have two maps: One for black keys, one for white. Put vertex color in the diffuse(+ambient) slot.
Have your script change the vertex color on the object in question based on angle, or however you are choosing to do it.
thats how a pro would do it nice idea I am gonna have to try doing this.
-Baker
Thanks for the replys guys i will try the idea skywisenight said and let you know how I get on.
Thanks guys